Environment Analysis Class

class rocketpy.EnvironmentAnalysis.EnvironmentAnalysis(start_date, end_date, latitude, longitude, start_hour=0, end_hour=24, surfaceDataFile=None, pressureLevelDataFile=None, timezone=None, unit_system='metric', forecast_date=None, forecast_args=None, maxExpectedAltitude=None)[source]

Class for analyzing the environment.

List of properties currently implemented:
  • average max/min temperature at surface level

  • record max/min temperature at surface level

  • temperature progression throughout the day

  • temperature profile over an average day

  • average max wind gust at surface level

  • record max wind gust at surface level

  • average, 1, 2, 3 sigma wind profile

  • average day wind rose

  • animation of how average wind rose evolves throughout an average day

  • animation of how wind profile evolves throughout an average day

  • pressure profile over an average day

  • wind velocity x profile over average day

  • wind velocity y profile over average day

  • wind speed profile over an average day

  • average max surface 100m wind speed

  • average max surface 10m wind speed

  • average min surface 100m wind speed

  • average min surface 10m wind speed

  • average sustained surface100m wind along day

  • average sustained surface10m wind along day

  • maximum surface 10m wind speed

  • average cloud base height

  • percentage of days with no cloud coverage

  • percentage of days with precipitation

You can also visualize all those attributes by exploring some of the methods:
  • plot of wind gust distribution (should be Weibull)

  • plot wind profile over average day

  • plot sustained surface wind speed distribution over average day

  • plot wind gust distribution over average day

  • plot average day wind rose all hours

  • plot average day wind rose specific hour

  • plot average pressure profile

  • plot average surface10m wind speed along day

  • plot average sustained surface100m wind speed along day

  • plot average temperature along day

  • plot average wind speed profile

  • plot surface10m wind speed distribution

  • animate wind profile over average day

  • animate sustained surface wind speed distribution over average day

  • animate wind gust distribution over average day

  • animate average wind rose

  • animation of who wind gust distribution evolves over average day

  • allInfo

All items listed are relevant to either
  1. participant safety

  2. launch operations (range closure decision)

  3. rocket performance

How does this class work? - The class is initialized with a start_date, end_date, start_hour and end_hour. - The class then parses the weather data from the start date to the end date. Always parsing the data from start_hour to end_hour. - The class then calculates the average max/min temperature, average max wind gust, and average day wind rose. - The class then allows for plotting the average max/min temperature, average max wind gust, and average day wind rose.

Remaining TODOs: - Make ‘windSpeedLimit’ a dynamic/flexible variable

Constructor for the EnvironmentAnalysis class. :param start_date: Start date and time of the analysis. When parsing the weather data

from the source file, only data after this date will be parsed.

Parameters
  • end_date (datetime.datetime) – End date and time of the analysis. When parsing the weather data from the source file, only data before this date will be parsed.

  • latitude (float) – Latitude coordinate of the location where the analysis will be carried out.

  • longitude (float) – Longitude coordinate of the location where the analysis will be carried out.

  • start_hour (int, optional) – Starting hour of the analysis. When parsing the weather data from the source file, only data after this hour will be parsed.

  • end_hour (int, optional) – End hour of the analysis. When parsing the weather data from the source file, only data before this hour will be parsed.

  • surfaceDataFile (str, optional) – Path to the netCDF file containing the surface data.

  • pressureLevelDataFile (str, optional) – Path to the netCDF file containing the pressure level data.

  • timezone (str, optional) – Name of the timezone to be used when displaying results. To see all available time zones, import pytz and run print(pytz.all_timezones). Default time zone is the local time zone at the latitude and longitude specified.

  • unit_system (str, optional) – Unit system to be used when displaying results. Options are: SI, metric, imperial. Default is metric.

  • forecast_date (datetime.date, optional) – Date for the forecast models. It will be requested the environment forecast for multiple hours within that specified date.

  • forecast_args (dictionary, optional) – Arguments for setting the forecast on the Environment class. With this argument it is possible to change the forecast model being used.

  • maxExpectedAltitude (float, optional) – Maximum expected altitude for your analysis. This is used to calculate plot limits from pressure level data profiles. If None is set, the maximum altitude will be calculated from the pressure level data. Default is None.

Returns

Return type

None

parsePressureLevelData()[source]

Parse pressure level data from a weather file.

Sources of information: - https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-pressure-levels?tab=form

Must get the following variables from a ERA5 file: - Geopotential - U-component of wind - V-component of wind - Temperature

Must compute the following for each date and hour available in the dataset: - pressure = Function(…, inputs=”Height Above Sea Level (m)”, outputs=”Pressure (Pa)”) - temperature = Function(…, inputs=”Height Above Sea Level (m)”, outputs=”Temperature (K)”) - windDirection = Function(…, inputs=”Height Above Sea Level (m)”, outputs=”Wind Direction (Deg True)”) - windHeading = Function(…, inputs=”Height Above Sea Level (m)”, outputs=”Wind Heading (Deg True)”) - windSpeed = Function(…, inputs=”Height Above Sea Level (m)”, outputs=”Wind Speed (m/s)”) - windVelocityX = Function(…, inputs=”Height Above Sea Level (m)”, outputs=”Wind Velocity X (m/s)”) - windVelocityY = Function(…, inputs=”Height Above Sea Level (m)”, outputs=”Wind Velocity Y (m/s)”)

Return a dictionary with all the computed data with the following structure: pressureLevelDataDict: {

“date”{
“hour”: {

“data”: …, “data”: …

}, “hour”: {

“data”: …, “data”: …

}

}, “date” : {

“hour”: {

“data”: …, “data”: …

}, “hour”: {

“data”: …, “data”: …

}

}

}

parseSurfaceData()[source]

Parse surface data from a weather file. Currently only supports files from ECMWF. You can download a file from the following website: https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-single-levels?tab=form

Must get the following variables: - surface elevation: self.elevation = float # Select ‘Geopotential’ - 2m temperature: surfaceTemperature = float - Surface pressure: surfacePressure = float - 10m u-component of wind: surface10mWindVelocityX = float - 10m v-component of wind: surface10mWindVelocityY = float - 100m u-component of wind: surface100mWindVelocityX = float - 100m V-component of wind: surface100mWindVelocityY = float - Instantaneous 10m wind gust: surfaceWindGust = float - Total precipitation: totalPrecipitation = float - Cloud base height: cloudBaseHeight = float

Return a dictionary with all the computed data with the following structure: surfaceDataDict: {

“date”{
“hour”: {

“data”: …, …

}

convertPressureLevelData()[source]

Convert pressure level data to desired unit system.

convertSurfaceData()[source]

Convert surface data to desired unit system.

process_data()[source]

Process data that is shown in the allInfo method.

calculate_pressure_stats()[source]

Calculate pressure level statistics.

calculate_average_cloud_base_height()[source]

Calculate average cloud base height.

calculate_min_cloud_base_height()[source]

Calculate average cloud base height.

calculate_percentage_of_days_with_no_cloud_coverage()[source]

Calculate percentage of days with cloud coverage.

calculate_percentage_of_days_with_precipitation()[source]

Computes the ratio between days with precipitation (> 10 mm) and total days.

plot_wind_gust_distribution()[source]

Get all values of wind gust speed (for every date and hour available) and plot a single distribution. Expected result is a Weibull distribution.

plot_surface10m_wind_speed_distribution(windSpeedLimit=False)[source]

Get all values of sustained surface wind speed (for every date and hour available) and plot a single distribution. Expected result is a Weibull distribution.

calculate_average_temperature_along_day()[source]

Computes average temperature progression throughout the day, including sigma contours.

plot_average_temperature_along_day()[source]

Plots average temperature progression throughout the day, including sigma contours.

calculate_average_sustained_surface10m_wind_along_day()[source]

Computes average sustained wind speed progression throughout the day, including sigma contours.

plot_average_surface10m_wind_speed_along_day(windSpeedLimit=False)[source]

Plots average surface wind speed progression throughout the day, including sigma contours.

calculate_average_sustained_surface100m_wind_along_day()[source]

Computes average sustained wind speed progression throughout the day, including sigma contours.

plot_average_sustained_surface100m_wind_speed_along_day()[source]

Plots average surface wind speed progression throughout the day, including sigma contours.

plot_average_wind_speed_profile(clear_range_limits=False)[source]

Average wind speed for all datetimes available.

plot_average_wind_heading_profile(clear_range_limits=False)[source]

Average wind heading for all datetimes available.

process_wind_speed_and_direction_data_for_average_day()[source]

Process the wind_speed and wind_direction data to generate lists of all the wind_speeds recorded for a following hour of the day and also the wind direction. Also calculates the greater and the smallest wind_speed recorded

Returns

Return type

None

plot_average_pressure_profile(clear_range_limits=False)[source]

Average wind speed for all datetimes available.

static plot_wind_rose(wind_direction, wind_speed, bins=None, title=None, fig=None, rect=None)[source]

Plot a windrose given the data.

Parameters
  • wind_direction (list[float]) –

  • wind_speed (list[float]) –

  • bins (1D array or integer, optional) – number of bins, or a sequence of bins variable. If not set, bins=6, then bins=linspace(min(var), max(var), 6)

  • title (str, optional) – Title of the plot

  • fig (matplotlib.pyplot.figure, optional) –

Returns

Return type

WindroseAxes

plot_average_day_wind_rose_specific_hour(hour, fig=None)[source]

Plot a specific hour of the average windrose

Parameters
  • hour (int) –

  • fig (matplotlib.pyplot.figure) –

Returns

Return type

None

plot_average_day_wind_rose_all_hours()[source]

Plot wind roses for all hours of a day, in a grid like plot.

animate_average_wind_rose(figsize=(8, 8), filename='wind_rose.gif')[source]

Animates the wind_rose of an average day. The inputs of a wind_rose are the location of the place where we want to analyze, (x,y,z). The data is assembled by hour, which means, the windrose of a specific hour is generated by bringing together the data of all of the days available for that specific hour. It’s possible to change the size of the gif using the parameter figsize, which is the height and width in inches.

Parameters

figsize (array) –

Returns

Image

Return type

ipywidgets.widgets.widget_media.Image

plot_wind_gust_distribution_over_average_day()[source]

Plots shown in the animation of how the wind gust distribution varies throughout the day.

animate_wind_gust_distribution_over_average_day()[source]

Animation of how the wind gust distribution varies throughout the day.

plot_sustained_surface_wind_speed_distribution_over_average_day(windSpeedLimit=False)[source]

Plots shown in the animation of how the sustained surface wind speed distribution varies throughout the day.

animate_sustained_surface_wind_speed_distribution_over_average_day(windSpeedLimit=False)[source]

Animation of how the sustained surface wind speed distribution varies throughout the day.

process_temperature_profile_over_average_day()[source]

Compute the average temperature profile for each available hour of a day, over all days in the dataset.

process_pressure_profile_over_average_day()[source]

Compute the average pressure profile for each available hour of a day, over all days in the dataset.

process_wind_speed_profile_over_average_day()[source]

Compute the average wind profile for each available hour of a day, over all days in the dataset.

process_wind_velocity_x_profile_over_average_day()[source]

Compute the average windVelocityX profile for each available hour of a day, over all days in the dataset.

process_wind_velocity_y_profile_over_average_day()[source]

Compute the average windVelocityY profile for each available hour of a day, over all days in the dataset.

plot_wind_profile_over_average_day(clear_range_limits=False)[source]

Creates a grid of plots with the wind profile over the average day.

process_wind_heading_profile_over_average_day()[source]

Compute the average wind velocities (both X and Y components) profile for each available hour of a day, over all days in the dataset.

plot_wind_heading_profile_over_average_day(clear_range_limits=False)[source]

Creates a grid of plots with the wind heading profile over the average day.

animate_wind_profile_over_average_day(clear_range_limits=False)[source]

Animation of how wind profile evolves throughout an average day.

animate_wind_heading_profile_over_average_day(clear_range_limits=False)[source]

Animation of how wind heading profile evolves throughout an average day.

exportMeanProfiles(filename='export_env_analysis')[source]

Exports the mean profiles of the weather data to a file in order to it be used as inputs on Environment Class by using the CustomAtmosphere model.

Parameters

filename (str, optional) – Name of the file where to be saved, by default “EnvAnalysisDict”

Returns

Return type

None

classmethod load(filename='EnvAnalysisDict')[source]

Load a previously saved Environment Analysis file. Example: EnvA = EnvironmentAnalysis.load(“filename”).

Parameters

filename (str, optional) – Name of the previous saved file, by default “EnvAnalysisDict”

Returns

Return type

EnvironmentAnalysis object

save(filename='EnvAnalysisDict')[source]

Save the Environment Analysis object to a file so it can be used later.

Parameters

filename (str, optional) – Name of the file where to be saved, by default “EnvAnalysisDict”

Returns

Return type

None