Environment Class#

class rocketpy.Environment.Environment(gravity=None, date=None, latitude=0, longitude=0, elevation=0, datum='SIRGAS2000', timezone='UTC')[source]#

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

Constants#
earth_radius#

Value of Earth’s Radius = 6.3781e6 m.

Type:

float

air_gas_constant#

Value of Air’s Gas Constant = 287.05287 J/K/Kg

Type:

float

Gravity#
gravity#

Positive value of gravitational acceleration in m/s^2.

Type:

float

Coordinates and Date
latitude#

Launch site latitude.

Type:

float

longitude#

Launch site longitude.

Type:

float

datum#

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

Type:

string

initial_east#

Launch site East UTM coordinate

Type:

float

initial_north#

Launch site North UTM coordinate

Type:

float

initial_utm_zone#

Launch site UTM zone number

Type:

int

initial_utm_letter#

Launch site UTM letter, to keep the latitude band and describe the UTM Zone

Type:

string

initial_hemisphere#

Launch site S/N hemisphere

Type:

string

initial_ew#

Launch site E/W hemisphere

Type:

string

elevation#

Launch site elevation.

Type:

float

date#

Date time of launch in UTC.

Type:

datetime

local_date#

Date time of launch in the local time zone, defined by Environment.timezone.

Type:

datetime

timezone#

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

Type:

string

Topographic information
elev_lon_array#

Unidimensional array containing the longitude coordinates

Type:

array

elev_lat_array#

Unidimensional array containing the latitude coordinates

Type:

array

elev_array#

Two-dimensional Array containing the elevation information

Type:

array

topographic_profile_activated#

True if the user already set a topographic profile

Type:

bool

Atmosphere Static Conditions
max_expected_height#

Maximum altitude in meters to keep weather data. Used especially for plotting range. Can be altered as desired.

Type:

float

pressure_ISA#

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.

Type:

Function

temperature_ISA#

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.

Type:

Function

pressure#

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.

Type:

Function

temperature#

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.

Type:

Function

speed_of_sound#

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.

Type:

Function

density#

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.

Type:

Function

dynamic_viscosity#

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.

Type:

Function

Atmosphere Wind Conditions
wind_speed#

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.

Type:

Function

wind_direction#

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

Type:

Function

wind_heading#

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

Type:

Function

wind_velocity_x#

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

Type:

Function

wind_velocity_y#

Wind V, or Y (east) component of wind velocity in m/s as a function of altitude. Can be accessed as regular array, or called as a function. See Function for more information.

Type:

Function

Atmospheric Model Details
atmospheric_model_type#

Describes the atmospheric model which is being used. Can only assume the following values: ‘standard_atmosphere’, ‘custom_atmosphere’, ‘wyoming_sounding’, ‘NOAARucSounding’, ‘Forecast’, ‘Reanalysis’, ‘Ensemble’.

Type:

string

atmospheric_model_file#

Address of the file used for the atmospheric model being used. Only defined for ‘wyoming_sounding’, ‘NOAARucSounding’, ‘Forecast’, ‘Reanalysis’, ‘Ensemble’

Type:

string

atmospheric_model_dict#

Dictionary used to properly interpret netCDF and OPeNDAP files. Only defined for ‘Forecast’, ‘Reanalysis’, ‘Ensemble’.

Type:

dictionary

atmospheric_model_init_date#

Datetime object instance of first available date in netCDF and OPeNDAP files when using ‘Forecast’, ‘Reanalysis’ or ‘Ensemble’.

Type:

datetime

atmospheric_model_end_date#

Datetime object instance of last available date in netCDF and OPeNDAP files when using ‘Forecast’, ‘Reanalysis’ or ‘Ensemble’.

Type:

datetime

atmospheric_model_interval#

Hour step between weather condition used in netCDF and OPeNDAP files when using ‘Forecast’, ‘Reanalysis’ or ‘Ensemble’.

Type:

int

atmospheric_model_init_lat#

Latitude of vertex just before the launch site in netCDF and OPeNDAP files when using ‘Forecast’, ‘Reanalysis’ or ‘Ensemble’.

Type:

float

atmospheric_model_end_lat#

Latitude of vertex just after the launch site in netCDF and OPeNDAP files when using ‘Forecast’, ‘Reanalysis’ or ‘Ensemble’.

Type:

float

atmospheric_model_init_lon#

Longitude of vertex just before the launch site in netCDF and OPeNDAP files when using ‘Forecast’, ‘Reanalysis’ or ‘Ensemble’.

Type:

float

atmospheric_model_end_lon#

Longitude of vertex just after the launch site in netCDF and OPeNDAP files when using ‘Forecast’, ‘Reanalysis’ or ‘Ensemble’.

Type:

float

Atmospheric Model Storage
lat_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.

Type:

array

lon_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.

Type:

array

lon_index#

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.

Type:

int

lat_index#

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 lon_index - 1 points to a grid latitude which is just under the launch site latitude.

Type:

int

geopotentials#

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.

Type:

array

wind_us#

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.

Type:

array

wind_vs#

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.

Type:

array

levels#

Defined if netCDF or OPeNDAP file is used, for Forecasts, Reanalysis and Ensembles. List of pressure levels available in the file.

Type:

array

temperatures#

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.

Type:

array

time_array#

Defined if netCDF or OPeNDAP file is used, for Forecasts, Reanalysis and Ensembles. Array of dates available in the file.

Type:

array

height#

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

Type:

array

Atmospheric Model Ensemble Specific Data
level_ensemble#

Only defined when using Ensembles.

Type:

array

height_ensemble#

Only defined when using Ensembles.

Type:

array

temperature_ensemble#

Only defined when using Ensembles.

Type:

array

wind_u_ensemble#

Only defined when using Ensembles.

Type:

array

wind_v_ensemble#

Only defined when using Ensembles.

Type:

array

wind_heading_ensemble#

Only defined when using Ensembles.

Type:

array

wind_direction_ensemble#

Only defined when using Ensembles.

Type:

array

wind_speed_ensemble#

Only defined when using Ensembles.

Type:

array

num_ensemble_members#

Number of ensemble members. Only defined when using Ensembles.

Type:

int

ensemble_member#

Current selected ensemble member. Only defined when using Ensembles.

Type:

int

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

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

  • "UTC". (print(pytz.all_timezones). Default time zone is) –

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) –

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. See Environment.set_location for more details.

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

Raises:
  • ValueError – [description]

  • ValueError – [description]

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 http://weather.uwyo.edu/upperair/sounding.html. 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 https://rucsoundings.noaa.gov/. 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. 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. References: 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. References: 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’:

    {‘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 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 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.

Parameters:

None

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 self.pressure_ISA and self.temperature_ISA.

Parameters:

None

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.

Parameters:

None

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.

Parameters:

None

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.

Parameters:

None

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.

Parameters:

None

Return type:

None

all_info()[source]#

Prints out all data and graphs available about the Environment.

Parameters:

None

Return type:

None

all_plot_info_returned()[source]#

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

Parameters:

None

Returns:

plotInfo – Dict of data relevant to plot externally

Return type:

Dict

all_info_returned()[source]#

Returns as dicts all data available about the Environment.

Parameters:

None

Returns:

info – Information relevant about the Environment class.

Return type:

Dict

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 customAtmosphere.

Parameters:

filename

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:

earthGeometry – The namedtuple containing the Earth geometry.

Return type:

namedtuple

geodesic_to_utm(lat, lon)[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°

Returns:

  • x (float) – East coordinate, always positive

  • y – 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

utm_to_geodesic(x, y, utm_zone, hemis)[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

Returns:

  • lat (float) – latitude of the analyzed point

  • lon (float) – latitude of the analyzed point

calculate_earth_radius(lat)[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

Returns:

Earth Radius at the desired latitude in meters

Return type:

float

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:

  • deg (float) – The degrees.

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

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