Environment Class#

class rocketpy.Environment[source]#

Keeps all environment information stored, such as wind and temperature conditions, as well as gravity.

Variables:
  • Environment.earth_radius (float) – Value of Earth’s Radius as 6.3781e6 m.

  • Environment.air_gas_constant (float) – Value of Air’s Gas Constant as 287.05287 J/K/Kg

  • Environment.gravity (float) – Positive value of gravitational acceleration in m/s^2.

  • Environment.latitude (float) – Launch site latitude.

  • Environment.longitude (float) – Launch site longitude.

  • Environment.datum (string) – The desired reference ellipsoid model, the following options are available: “SAD69”, “WGS84”, “NAD83”, and “SIRGAS2000”. The default is “SIRGAS2000”, then this model will be used if the user make some typing mistake

  • Environment.initial_east (float) – Launch site East UTM coordinate

  • Environment.initial_north (float) – Launch site North UTM coordinate

  • Environment.initial_utm_zone (int) – Launch site UTM zone number

  • Environment.initial_utm_letter (string) – Launch site UTM letter, to keep the latitude band and describe the UTM Zone

  • Environment.initial_hemisphere (string) – Launch site S/N hemisphere

  • Environment.initial_ew (string) – Launch site E/W hemisphere

  • Environment.elevation (float) – Launch site elevation.

  • Environment.date (datetime) – Date time of launch in UTC.

  • Environment.local_date (datetime) – Date time of launch in the local time zone, defined by Environment.timezone.

  • Environment.timezone (string) –

    Local time zone specification. See pytz. for time zone information.

  • Environment.elev_lon_array (array) – Unidimensional array containing the longitude coordinates.

  • Environment.elev_lat_array (array) – Unidimensional array containing the latitude coordinates.

  • Environment.elev_array (array) – Two-dimensional Array containing the elevation information.

  • Environment.topographic_profile_activated (bool) – True if the user already set a topographic profile. False otherwise.

  • Environment.max_expected_height (float) – Maximum altitude in meters to keep weather data. The altitude must be above sea level (ASL). Especially useful for controlling plottings. Can be altered as desired by doing max_expected_height = number.

  • Environment.pressure_ISA (Function) – Air pressure in Pa as a function of altitude as defined by the International Standard Atmosphere ISO 2533. Only defined after load Environment.load_international_standard_atmosphere has been called. Can be accessed as regular array, or called as a Function. See Function for more information.

  • Environment.temperature_ISA (Function) – Air temperature in K as a function of altitude as defined by the International Standard Atmosphere ISO 2533. Only defined after load Environment.load_international_standard_atmosphere has been called. Can be accessed as regular array, or called as a Function. See Function for more information.

  • Environment.pressure (Function) – Air pressure in Pa as a function of altitude. Can be accessed as regular array, or called as a Function. See Function for more information.

  • Environment.barometric_height (Function) – Geometric height above sea level in m as a function of pressure. Can be accessed as regular array, or called as a Function. See Function for more information.

  • Environment.temperature (Function) – Air temperature in K as a function of altitude. Can be accessed as regular array, or called as a Function. See Function for more information.

  • Environment.speed_of_sound (Function) – Speed of sound in air in m/s as a function of altitude. Can be accessed as regular array, or called as a Function. See Function for more information.

  • Environment.density (Function) – Air density in kg/m³ as a function of altitude. Can be accessed as regular array, or called as a Function. See Function for more information.

  • Environment.dynamic_viscosity (Function) – Air dynamic viscosity in Pa*s as a function of altitude. Can be accessed as regular array, or called as a Function. See Function for more information.

  • Environment.wind_speed (Function) – Wind speed in m/s as a function of altitude. Can be accessed as regular array, or called as a Function. See Function for more information.

  • Environment.wind_direction (Function) – Wind direction (from which the wind blows) in degrees relative to north (positive clockwise) as a function of altitude. Can be accessed as an array, or called as a Function. See Function for more information.

  • Environment.wind_heading (Function) – Wind heading (direction towards which the wind blows) in degrees relative to north (positive clockwise) as a function of altitude. Can be accessed as an array, or called as a Function. See Function for more information.

  • Environment.wind_velocity_x (Function) – Wind U, or X (east) component of wind velocity in m/s as a function of altitude. Can be accessed as an array, or called as a Function. See Function for more information.

  • Environment.wind_velocity_y (Function) – Wind V, or Y (north) component of wind velocity in m/s as a function of altitude. Can be accessed as an array, or called as a Function. See Function for more information.

  • Environment.atmospheric_model_type (string) – Describes the atmospheric model which is being used. Can only assume the following values: standard_atmosphere, custom_atmosphere, wyoming_sounding, NOAARucSounding, Forecast, Reanalysis, Ensemble.

  • Environment.atmospheric_model_file (string) – Address of the file used for the atmospheric model being used. Only defined for wyoming_sounding, NOAARucSounding, Forecast, Reanalysis, Ensemble

  • Environment.atmospheric_model_dict (dictionary) – Dictionary used to properly interpret netCDF and OPeNDAP files. Only defined for Forecast, Reanalysis, Ensemble.

  • Environment.atmospheric_model_init_date (datetime) – Datetime object instance of first available date in netCDF and OPeNDAP files when using Forecast, Reanalysis or Ensemble.

  • Environment.atmospheric_model_end_date (datetime) – Datetime object instance of last available date in netCDF and OPeNDAP files when using Forecast, Reanalysis or Ensemble.

  • Environment.atmospheric_model_interval (int) – Hour step between weather condition used in netCDF and OPeNDAP files when using Forecast, Reanalysis or Ensemble.

  • Environment.atmospheric_model_init_lat (float) – Latitude of vertex just before the launch site in netCDF and OPeNDAP files when using Forecast, Reanalysis or Ensemble.

  • Environment.atmospheric_model_end_lat (float) – Latitude of vertex just after the launch site in netCDF and OPeNDAP files when using Forecast, Reanalysis or Ensemble.

  • Environment.atmospheric_model_init_lon (float) – Longitude of vertex just before the launch site in netCDF and OPeNDAP files when using Forecast, Reanalysis or Ensemble.

  • Environment.atmospheric_model_end_lon (float) – Longitude of vertex just after the launch site in netCDF and OPeNDAP files when using Forecast, Reanalysis or Ensemble.

  • Environment.lat_array (array) – Defined if netCDF or OPeNDAP file is used, for Forecasts, Reanalysis and Ensembles. 2x2 matrix for each pressure level of latitudes corresponding to the vertices of the grid cell which surrounds the launch site.

  • Environment.lon_array (array) – Defined if netCDF or OPeNDAP file is used, for Forecasts, Reanalysis and Ensembles. 2x2 matrix for each pressure level of longitudes corresponding to the vertices of the grid cell which surrounds the launch site.

  • Environment.lon_index (int) – Defined if netCDF or OPeNDAP file is used, for Forecasts, Reanalysis and Ensembles. Index to a grid longitude which is just over the launch site longitude, while lon_index - 1 points to a grid longitude which is just under the launch site longitude.

  • Environment.lat_index (int) – Defined if netCDF or OPeNDAP file is used, for Forecasts, Reanalysis and Ensembles. Index to a grid latitude which is just over the launch site latitude, while lat_index - 1 points to a grid latitude which is just under the launch site latitude.

  • Environment.geopotentials (array) – Defined if netCDF or OPeNDAP file is used, for Forecasts, Reanalysis and Ensembles. 2x2 matrix for each pressure level of geopotential heights corresponding to the vertices of the grid cell which surrounds the launch site.

  • Environment.wind_us (array) – Defined if netCDF or OPeNDAP file is used, for Forecasts, Reanalysis and Ensembles. 2x2 matrix for each pressure level of wind U (east) component corresponding to the vertices of the grid cell which surrounds the launch site.

  • Environment.wind_vs (array) – Defined if netCDF or OPeNDAP file is used, for Forecasts, Reanalysis and Ensembles. 2x2 matrix for each pressure level of wind V (north) component corresponding to the vertices of the grid cell which surrounds the launch site.

  • Environment.levels (array) – Defined if netCDF or OPeNDAP file is used, for Forecasts, Reanalysis and Ensembles. List of pressure levels available in the file.

  • Environment.temperatures (array) – Defined if netCDF or OPeNDAP file is used, for Forecasts, Reanalysis and Ensembles. 2x2 matrix for each pressure level of temperatures corresponding to the vertices of the grid cell which surrounds the launch site.

  • Environment.time_array (array) – Defined if netCDF or OPeNDAP file is used, for Forecasts, Reanalysis and Ensembles. Array of dates available in the file.

  • Environment.height (array) – Defined if netCDF or OPeNDAP file is used, for Forecasts, Reanalysis and Ensembles. List of geometric height corresponding to launch site location.

  • Environment.level_ensemble (array) – Only defined when using Ensembles.

  • Environment.height_ensemble (array) – Only defined when using Ensembles.

  • Environment.temperature_ensemble (array) – Only defined when using Ensembles.

  • Environment.wind_u_ensemble (array) – Only defined when using Ensembles.

  • Environment.wind_v_ensemble (array) – Only defined when using Ensembles.

  • Environment.wind_heading_ensemble (array) – Only defined when using Ensembles.

  • Environment.wind_direction_ensemble (array) – Only defined when using Ensembles.

  • Environment.wind_speed_ensemble (array) – Only defined when using Ensembles.

  • Environment.num_ensemble_members (int) – Number of ensemble members. Only defined when using Ensembles.

  • Environment.ensemble_member (int) – Current selected ensemble member. Only defined when using Ensembles.

__init__(gravity=None, date=None, latitude=0, longitude=0, elevation=0, datum='SIRGAS2000', timezone='UTC', max_expected_height=80000.0)[source]#

Initialize Environment class, saving launch rail length, launch date, location coordinates and elevation. Note that by default the standard atmosphere is loaded until another

Parameters:
  • gravity (int, float, callable, string, array, optional) – Surface gravitational acceleration. Positive values point the acceleration down. If None, the Somigliana formula is used to

  • date (array, optional) – Array of length 4, stating (year, month, day, hour (UTC)) of rocket launch. Must be given if a Forecast, Reanalysis or Ensemble, will be set as an atmospheric model.

  • latitude (float, optional) – Latitude in degrees (ranging from -90 to 90) of rocket launch location. Must be given if a Forecast, Reanalysis or Ensemble will be used as an atmospheric model or if Open-Elevation will be used to compute elevation.

  • longitude (float, optional) – Longitude in degrees (ranging from -180 to 360) of rocket launch location. Must be given if a Forecast, Reanalysis or Ensemble will be used as an atmospheric model or if Open-Elevation will be used to compute elevation.

  • elevation (float, optional) – Elevation of launch site measured as height above sea level in meters. Alternatively, can be set as ‘Open-Elevation’ which uses the Open-Elevation API to find elevation data. For this option, latitude and longitude must also be specified. Default value is 0.

  • datum (string) – The desired reference ellipsoidal model, the following options are available: “SAD69”, “WGS84”, “NAD83”, and “SIRGAS2000”. The default is “SIRGAS2000”, then this model will be used if the user make some typing mistake.

  • timezone (string, optional) – Name of the time zone. To see all time zones, import pytz and run print(pytz.all_timezones). Default time zone is “UTC”.

  • max_expected_height (float, optional) – Maximum altitude in meters to keep weather data. The altitude must be above sea level (ASL). Especially useful for visualization. Can be altered as desired by doing max_expected_height = number. Depending on the atmospheric model, this value may be automatically mofified.

Return type:

None

set_date(date, timezone='UTC')[source]#

Set date and time of launch and update weather conditions if date dependent atmospheric model is used.

Parameters:
  • date (Datetime) – Datetime object specifying launch date and time.

  • timezone (string, optional) – Name of the time zone. To see all time zones, import pytz and run print(pytz.all_timezones). Default time zone is “UTC”.

Return type:

None

set_location(latitude, longitude)[source]#

Set latitude and longitude of launch and update atmospheric conditions if location dependent model is being used.

Parameters:
  • latitude (float) – Latitude of launch site. May range from -90 to 90 degrees.

  • longitude (float) – Longitude of launch site. Either from 0 to 360 degrees or from -180 to 180 degrees.

Return type:

None

set_gravity_model(gravity)[source]#

Sets the gravity model to be used in the simulation based on the given user input to the gravity parameter.

Parameters:

gravity (None or Function source) – If None, the Somigliana formula is used to compute the gravity acceleration. Otherwise, the user can provide a Function object representing the gravity model.

Returns:

Function object representing the gravity model.

Return type:

Function

somigliana_gravity#

Computes the gravity acceleration with the Somigliana formula. An height correction is applied to the normal gravity that is accurate for heights used in aviation. The formula is based on the WGS84 ellipsoid, but is accurate for other reference ellipsoids.

Parameters:

height (float) – Height above the reference ellipsoid in meters.

Returns:

Function object representing the gravity model.

Return type:

Function

set_elevation(elevation='Open-Elevation')[source]#

Set elevation of launch site given user input or using the Open-Elevation API.

Parameters:

elevation (float, string, optional) –

Elevation of launch site measured as height above sea level in meters. Alternatively, can be set as ‘Open-Elevation’ which uses the Open-Elevation API to find elevation data. For this option, latitude and longitude must have already been specified.

Return type:

None

get_elevation_from_topographic_profile(lat, lon)[source]#

Function which receives as inputs the coordinates of a point and finds its elevation in the provided Topographic Profile.

Parameters:
  • lat (float) – latitude of the point.

  • lon (float) – longitude of the point.

Returns:

elevation – Elevation provided by the topographic data, in meters.

Return type:

float

set_atmospheric_model(type, file=None, dictionary=None, pressure=None, temperature=None, wind_u=0, wind_v=0)[source]#

Defines an atmospheric model for the Environment. Supported functionality includes using data from the International Standard Atmosphere, importing data from weather reanalysis, forecasts and ensemble forecasts, importing data from upper air soundings and inputting data as custom functions, arrays or csv files.

Parameters:
  • type (string) –

    One of the following options:

    • standard_atmosphere: sets pressure and temperature profiles corresponding to the International Standard Atmosphere defined by ISO 2533 and ranging from -2 km to 80 km of altitude above sea level. Note that the wind profiles are set to zero when this type is chosen.

    • wyoming_sounding: sets pressure, temperature, wind-u and wind-v profiles and surface elevation obtained from an upper air sounding given by the file parameter through an URL. This URL should point to a data webpage given by selecting plot type as text: list, a station and a time at weather.uwyo. An example of a valid link would be:

      http://weather.uwyo.edu/cgi-bin/sounding?region=samer&TYPE=TEXT%3ALIST&YEAR=2019&MONTH=02&FROM=0200&TO=0200&STNM=82599

    • NOAARucSounding: sets pressure, temperature, wind-u and wind-v profiles and surface elevation obtained from an upper air sounding given by the file parameter through an URL. This URL should point to a data webpage obtained through NOAA’s Ruc Sounding servers, which can be accessed in rucsoundings. Selecting ROABs as the initial data source, specifying the station through it’s WMO-ID and opting for the ASCII (GSD format) button, the following example URL opens up:

      https://rucsoundings.noaa.gov/get_raobs.cgi?data_source=RAOB&latest=latest&start_year=2019&start_month_name=Feb&start_mday=5&start_hour=12&start_min=0&n_hrs=1.0&fcst_len=shortest&airport=83779&text=Ascii%20text%20%28GSD%20format%29&hydrometeors=false&start=latest

      Any ASCII GSD format page from this server can be read, so information from virtual soundings such as GFS and NAM can also be imported.

    • windy_atmosphere: sets pressure, temperature, wind-u and wind-v profiles and surface elevation obtained from the Windy API. See file argument to specify the model as either ECMWF, GFS or ICON.

    • Forecast: sets pressure, temperature, wind-u and wind-v profiles and surface elevation obtained from a weather forecast file in netCDF format or from an OPeNDAP URL, both given through the file parameter. When this type is chosen, the date and location of the launch should already have been set through the date and location parameters when initializing the Environment. The netCDF and OPeNDAP datasets must contain at least geopotential height or geopotential, temperature, wind-u and wind-v profiles as a function of pressure levels. If surface geopotential or geopotential height is given, elevation is also set. Otherwise, elevation is not changed. Profiles are interpolated bi-linearly using supplied latitude and longitude. The date used is the nearest one to the date supplied. Furthermore, a dictionary must be supplied through the dictionary parameter in order for the dataset to be accurately read. Lastly, the dataset must use a rectangular grid sorted in either ascending or descending order of latitude and longitude.

    • Reanalysis: sets pressure, temperature, wind-u and wind-v profiles and surface elevation obtained from a weather forecast file in netCDF format or from an OPeNDAP URL, both given through the file parameter. When this type is chosen, the date and location of the launch should already have been set through the date and location parameters when initializing the Environment. The netCDF and OPeNDAP datasets must contain at least geopotential height or geopotential, temperature, wind-u and wind-v profiles as a function of pressure levels. If surface geopotential or geopotential height is given, elevation is also set. Otherwise, elevation is not changed. Profiles are interpolated bi-linearly using supplied latitude and longitude. The date used is the nearest one to the date supplied. Furthermore, a dictionary must be supplied through the dictionary parameter in order for the dataset to be accurately read. Lastly, the dataset must use a rectangular grid sorted in either ascending or descending order of latitude and longitude.

    • Ensemble: sets pressure, temperature, wind-u and wind-v profiles and surface elevation obtained from a weather forecast file in netCDF format or from an OPeNDAP URL, both given through the file parameter. When this type is chosen, the date and location of the launch should already have been set through the date and location parameters when initializing the Environment. The netCDF and OPeNDAP datasets must contain at least geopotential height or geopotential, temperature, wind-u and wind-v profiles as a function of pressure levels. If surface geopotential or geopotential height is given, elevation is also set. Otherwise, elevation is not changed. Profiles are interpolated bi-linearly using supplied latitude and longitude. The date used is the nearest one to the date supplied. Furthermore, a dictionary must be supplied through the dictionary parameter in order for the dataset to be accurately read. Lastly, the dataset must use a rectangular grid sorted in either ascending or descending order of latitude and longitude. By default the first ensemble forecast is activated.

      See also

      To activate other ensemble forecasts see Environment.selectEnsembleMemberMember.

    • custom_atmosphere: sets pressure, temperature, wind-u and wind-v profiles given though the pressure, temperature, wind-u and wind-v parameters of this method. If pressure or temperature is not given, it will default to the International Standard Atmosphere. If the wind components are not given, it will default to 0.

  • file (string, optional) –

    String that must be given when type is either wyoming_sounding, Forecast, Reanalysis, Ensemble or Windy. It specifies the location of the data given, either through a local file address or a URL. If type is Forecast, this parameter can also be either GFS, FV3, RAP or NAM for latest of these forecasts.

    Note

    Time referece for the Forecasts are:

    • GFS: Global - 0.25deg resolution - Updates every 6 hours, forecast for 81 points spaced by 3 hours

    • FV3: Global - 0.25deg resolution - Updates every 6 hours, forecast for 129 points spaced by 3 hours

    • RAP: Regional USA - 0.19deg resolution - Updates hourly, forecast for 40 points spaced hourly

    • NAM: Regional CONUS Nest - 5 km resolution - Updates every 6 hours, forecast for 21 points spaced by 3 hours

    If type is Ensemble, this parameter can also be either GEFS, or CMC for the latest of these ensembles.

    Note

    Time referece for the Ensembles are:

    • GEFS: Global, bias-corrected, 0.5deg resolution, 21 forecast members, Updates every 6 hours, forecast for 65 points spaced by 4 hours

    • CMC: Global, 0.5deg resolution, 21 forecast members, Updates every 12 hours, forecast for 65 points spaced by 4 hours

    If type is Windy, this parameter can be either GFS, ECMWF, ICON or ICONEU. Default in this case is ECMWF.

  • dictionary (dictionary, string, optional) –

    Dictionary that must be given when type is either Forecast, Reanalysis or Ensemble. It specifies the dictionary to be used when reading netCDF and OPeNDAP files, allowing the correct retrieval of data. Acceptable values include ECMWF, NOAA and UCAR for default dictionaries which can generally be used to read datasets from these institutes. Alternatively, a dictionary structure can also be given, specifying the short names used for time, latitude, longitude, pressure levels, temperature profile, geopotential or geopotential height profile, wind-u and wind-v profiles in the dataset given in the file parameter. Additionally, ensemble dictionaries must have the ensemble as well. An example is the following dictionary, used for NOAA:

    dictionary = {
        "time": "time",
        "latitude": "lat",
        "longitude": "lon",
        "level": "lev",
        "ensemble": "ens",
        "temperature": "tmpprs",
        "surface_geopotential_height": "hgtsfc",
        "geopotential_height": "hgtprs",
        "geopotential": None,
        "u_wind": "ugrdprs",
        "v_wind": "vgrdprs",
    }
    

  • pressure (float, string, array, callable, optional) – This defines the atmospheric pressure profile. Should be given if the type parameter is custom_atmosphere. If not, than the the Standard Atmosphere pressure will be used. If a float is given, it will define a constant pressure profile. The float should be in units of Pa. If a string is given, it should point to a .CSV file containing at most one header line and two columns of data. The first column must be the geometric height above sea level in meters while the second column must be the pressure in Pa. If an array is given, it is expected to be a list or array of coordinates (height in meters, pressure in Pa). Finally, a callable or function is also accepted. The function should take one argument, the height above sea level in meters and return a corresponding pressure in Pa.

  • temperature (float, string, array, callable, optional) – This defines the atmospheric temperature profile. Should be given if the type parameter is custom_atmosphere. If not, than the the Standard Atmosphere temperature will be used. If a float is given, it will define a constant temperature profile. The float should be in units of K. If a string is given, it should point to a .CSV file containing at most one header line and two columns of data. The first column must be the geometric height above sea level in meters while the second column must be the temperature in K. If an array is given, it is expected to be a list or array of coordinates (height in meters, temperature in K). Finally, a callable or function is also accepted. The function should take one argument, the height above sea level in meters and return a corresponding temperature in K.

  • wind_u (float, string, array, callable, optional) – This defines the atmospheric wind-u profile, corresponding the magnitude of the wind speed heading East. Should be given if the type parameter is custom_atmosphere. If not, it will be assumed to be constant and equal to 0. If a float is given, it will define a constant wind-u profile. The float should be in units of m/s. If a string is given, it should point to a .CSV file containing at most one header line and two columns of data. The first column must be the geometric height above sea level in meters while the second column must be the wind-u in m/s. If an array is given, it is expected to be an array of coordinates (height in meters, wind-u in m/s). Finally, a callable or function is also accepted. The function should take one argument, the height above sea level in meters and return a corresponding wind-u in m/s.

  • wind_v (float, string, array, callable, optional) – This defines the atmospheric wind-v profile, corresponding the magnitude of the wind speed heading North. Should be given if the type parameter is custom_atmosphere. If not, it will be assumed to be constant and equal to 0. If a float is given, it will define a constant wind-v profile. The float should be in units of m/s. If a string is given, it should point to a .CSV file containing at most one header line and two columns of data. The first column must be the geometric height above sea level in meters while the second column must be the wind-v in m/s. If an array is given, it is expected to be an array of coordinates (height in meters, wind-v in m/s). Finally, a callable or function is also accepted. The function should take one argument, the height above sea level in meters and return a corresponding wind-v in m/s.

Return type:

None

process_standard_atmosphere()[source]#

Sets pressure and temperature profiles corresponding to the International Standard Atmosphere defined by ISO 2533 and ranging from -2 km to 80 km of altitude above sea level. Note that the wind profiles are set to zero.

Return type:

None

process_custom_atmosphere(pressure=None, temperature=None, wind_u=0, wind_v=0)[source]#

Import pressure, temperature and wind profile given by user.

Parameters:
  • pressure (float, string, array, callable, optional) – This defines the atmospheric pressure profile. Should be given if the type parameter is custom_atmosphere. If not, than the the Standard Atmosphere pressure will be used. If a float is given, it will define a constant pressure profile. The float should be in units of Pa. If a string is given, it should point to a .CSV file containing at most one header line and two columns of data. The first column must be the geometric height above sea level in meters while the second column must be the pressure in Pa. If an array is given, it is expected to be a list or array of coordinates (height in meters, pressure in Pa). Finally, a callable or function is also accepted. The function should take one argument, the height above sea level in meters and return a corresponding pressure in Pa.

  • temperature (float, string, array, callable, optional) – This defines the atmospheric temperature profile. Should be given if the type parameter is custom_atmosphere. If not, than the the Standard Atmosphere temperature will be used. If a float is given, it will define a constant temperature profile. The float should be in units of K. If a string is given, it should point to a .CSV file containing at most one header line and two columns of data. The first column must be the geometric height above sea level in meters while the second column must be the temperature in K. If an array is given, it is expected to be a list or array of coordinates (height in meters, temperature in K). Finally, a callable or function is also accepted. The function should take one argument, the height above sea level in meters and return a corresponding temperature in K.

  • wind_u (float, string, array, callable, optional) – This defines the atmospheric wind-u profile, corresponding the the magnitude of the wind speed heading East. Should be given if the type parameter is custom_atmosphere. If not, it will be assumed constant and 0. If a float is given, it will define a constant wind-u profile. The float should be in units of m/s. If a string is given, it should point to a .CSV file containing at most one header line and two columns of data. The first column must be the geometric height above sea level in meters while the second column must be the wind-u in m/s. If an array is given, it is expected to be an array of coordinates (height in meters, wind-u in m/s). Finally, a callable or function is also accepted. The function should take one argument, the height above sea level in meters and return a corresponding wind-u in m/s.

  • wind_v (float, string, array, callable, optional) – This defines the atmospheric wind-v profile, corresponding the the magnitude of the wind speed heading North. Should be given if the type parameter is custom_atmosphere. If not, it will be assumed constant and 0. If a float is given, it will define a constant wind-v profile. The float should be in units of m/s. If a string is given, it should point to a .CSV file containing at most one header line and two columns of data. The first column must be the geometric height above sea level in meters while the second column must be the wind-v in m/s. If an array is given, it is expected to be an array of coordinates (height in meters, wind-v in m/s). Finally, a callable or function is also accepted. The function should take one argument, the height above sea level in meters and return a corresponding wind-v in m/s.

Return type:

None

process_windy_atmosphere(model='ECMWF')[source]#

Process data from Windy.com to retrieve atmospheric forecast data.

Parameters:

model (string, optional) – The atmospheric model to use. Default is ECMWF. Options are: ECMWF for the ECMWF-HRES model, GFS for the GFS model, ICON for the ICON-Global model or ICONEU for the ICON-EU model.

process_wyoming_sounding(file)[source]#

Import and process the upper air sounding data from Wyoming Upper Air Soundings database given by the url in file. Sets pressure, temperature, wind-u, wind-v profiles and surface elevation.

Parameters:

file (string) –

URL of an upper air sounding data output from Wyoming Upper Air Soundings database.

Example:

http://weather.uwyo.edu/cgi-bin/sounding?region=samer&TYPE=TEXT%3ALIST&YEAR=2019&MONTH=02&FROM=0200&TO=0200&STNM=82599

More can be found at: http://weather.uwyo.edu/upperair/sounding.html.

Return type:

None

process_noaaruc_sounding(file)[source]#

Import and process the upper air sounding data from NOAA Ruc Soundings database (https://rucsoundings.noaa.gov/) given as ASCII GSD format pages passed by its url to the file parameter. Sets pressure, temperature, wind-u, wind-v profiles and surface elevation.

Parameters:

file (string) –

URL of an upper air sounding data output from NOAA Ruc Soundings in ASCII GSD format.

Example:

https://rucsoundings.noaa.gov/get_raobs.cgi?data_source=RAOB&latest=latest&start_year=2019&start_month_name=Feb&start_mday=5&start_hour=12&start_min=0&n_hrs=1.0&fcst_len=shortest&airport=83779&text=Ascii%20text%20%28GSD%20format%29&hydrometeors=false&start=latest

More can be found at: https://rucsoundings.noaa.gov/.

Return type:

None

select_ensemble_member(member=0)[source]#

Activates ensemble member, meaning that all atmospheric variables read from the Environment instance will correspond to the desired ensemble member.

Parameters:

member (int) – Ensemble member to be activated. Starts from 0.

Return type:

None

load_international_standard_atmosphere()[source]#

Defines the pressure and temperature profile functions set by ISO 2533 for the International Standard atmosphere and saves them as Environment.pressure_ISA and Environment.temperature_ISA.

Return type:

None

calculate_density_profile()[source]#

Compute the density of the atmosphere as a function of height by using the formula rho = P/(RT). This function is automatically called whenever a new atmospheric model is set.

Return type:

None

calculate_speed_of_sound_profile()[source]#

Compute the speed of sound in the atmosphere as a function of height by using the formula a = sqrt(gamma*R*T). This function is automatically called whenever a new atmospheric model is set.

Return type:

None

calculate_dynamic_viscosity()[source]#

Compute the dynamic viscosity of the atmosphere as a function of height by using the formula given in ISO 2533 u = B*T^(1.5)/(T+S). This function is automatically called whenever a new atmospheric model is set. Warning: This equation is invalid for very high or very low temperatures and under conditions occurring at altitudes above 90 km.

Return type:

None

add_wind_gust(wind_gust_x, wind_gust_y)[source]#

Adds a function to the current stored wind profile, in order to simulate a wind gust.

Parameters:
  • wind_gust_x (float, callable) – Callable, function of altitude, which will be added to the x velocity of the current stored wind profile. If float is given, it will be considered as a constant function in altitude.

  • wind_gust_y (float, callable) – Callable, function of altitude, which will be added to the y velocity of the current stored wind profile. If float is given, it will be considered as a constant function in altitude.

Return type:

None

info()[source]#

Prints most important data and graphs available about the Environment.

Return type:

None

all_info()[source]#

Prints out all data and graphs available about the Environment.

Return type:

None

all_plot_info_returned()[source]#

Returns a dictionary with all plot information available about the Environment.

Returns:

plot_info – Dict of data relevant to plot externally

Return type:

Dict

Warning

Deprecated in favor of utilities.get_instance_attributes.

all_info_returned()[source]#

Returns as dicts all data available about the Environment.

Returns:

info – Information relevant about the Environment class.

Return type:

Dict

Warning

Deprecated in favor of utilities.get_instance_attributes.

export_environment(filename='environment')[source]#

Export important attributes of Environment class to a .json file, saving all the information needed to recreate the same environment using custom_atmosphere.

Parameters:

filename (string) – The name of the file to be saved, without the extension.

Return type:

None

set_earth_geometry(datum)[source]#

Sets the Earth geometry for the Environment class based on the datum provided.

Parameters:

datum (str) – The datum to be used for the Earth geometry.

Returns:

earth_geometry – The namedtuple containing the Earth geometry.

Return type:

namedtuple

static geodesic_to_utm(lat, lon, semi_major_axis=6378137.0, flattening=0.0033528106647474805)[source]#

Function which converts geodetic coordinates, i.e. lat/lon, to UTM projection coordinates. Can be used only for latitudes between -80.00° and 84.00°

Parameters:
  • lat (float) – The latitude coordinates of the point of analysis, must be contained between -80.00° and 84.00°

  • lon (float) – The longitude coordinates of the point of analysis, must be contained between -180.00° and 180.00°

  • semi_major_axis (float) – The semi-major axis of the ellipsoid used to represent the Earth, must be given in meters (default is 6,378,137.0 m, which corresponds to the WGS84 ellipsoid)

  • flattening (float) – The flattening of the ellipsoid used to represent the Earth, usually between 1/250 and 1/150 (default is 1/298.257223563, which corresponds to the WGS84 ellipsoid)

Returns:

  • x (float) – East coordinate, always positive

  • y (float) – North coordinate, always positive

  • utm_zone (int) – The number of the UTM zone of the point of analysis, can vary between 1 and 60

  • utm_letter (string) – The letter of the UTM zone of the point of analysis, can vary between C and X, omitting the letters “I” and “O”

  • hemis (string) – Returns “S” for southern hemisphere and “N” for Northern hemisphere

  • EW (string) – Returns “W” for western hemisphere and “E” for eastern hemisphere

static utm_to_geodesic(x, y, utm_zone, hemis, semi_major_axis=6378137.0, flattening=0.0033528106647474805)[source]#

Function to convert UTM coordinates to geodesic coordinates (i.e. latitude and longitude). The latitude should be between -80° and 84°

Parameters:
  • x (float) – East UTM coordinate in meters

  • y (float) – North UTM coordinate in meters

  • utm_zone (int) – The number of the UTM zone of the point of analysis, can vary between 1 and 60

  • hemis (string) – Equals to “S” for southern hemisphere and “N” for Northern hemisphere

  • semi_major_axis (float) – The semi-major axis of the ellipsoid used to represent the Earth, must be given in meters (default is 6,378,137.0 m, which corresponds to the WGS84 ellipsoid)

  • flattening (float) – The flattening of the ellipsoid used to represent the Earth, usually between 1/250 and 1/150 (default is 1/298.257223563, which corresponds to the WGS84 ellipsoid)

Returns:

  • lat (float) – latitude of the analyzed point

  • lon (float) – latitude of the analyzed point

static calculate_earth_radius(lat, semi_major_axis=6378137.0, flattening=0.0033528106647474805)[source]#

Simple function to calculate the Earth Radius at a specific latitude based on ellipsoidal reference model (datum). The earth radius here is assumed as the distance between the ellipsoid’s center of gravity and a point on ellipsoid surface at the desired Pay attention: The ellipsoid is an approximation for the earth model and will obviously output an estimate of the perfect distance between earth’s relief and its center of gravity.

Parameters:
  • lat (float) – latitude in which the Earth radius will be calculated

  • semi_major_axis (float) – The semi-major axis of the ellipsoid used to represent the Earth, must be given in meters (default is 6,378,137.0 m, which corresponds to the WGS84 ellipsoid)

  • flattening (float) – The flattening of the ellipsoid used to represent the Earth, usually between 1/250 and 1/150 (default is 1/298.257223563, which corresponds to the WGS84 ellipsoid)

Returns:

radius – Earth Radius at the desired latitude in meters

Return type:

float

static decimal_degrees_to_arc_seconds(angle)[source]#
Function to convert an angle in decimal degrees to deg/min/sec.

Converts (°) to (° ‘ “)

Parameters:

angle (float) – The angle that you need convert to deg/min/sec. Must be given in decimal degrees.

Returns:

  • degrees (float) – The degrees.

  • arc_minutes (float) – The arc minutes. 1 arc-minute = (1/60)*degree

  • arc_seconds (float) – The arc Seconds. 1 arc-second = (1/3600)*degree