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')[source]

Class for analyzing the environment.

List of ideas suggested by Logan:
  • average max/min temperature

  • record max/min temperature

  • average max wind gust

  • record max wind gust

  • plot of wind gust distribution (should be Weibull)

  • animation of who wind gust distribution evolves over average day

  • temperature progression throughout the day at some fine interval (ex: 10 min) with 1, 2, 3, sigma contours (sketch below)

  • average, 1, 2, 3 sigma wind profile from 0 - 35,000 ft AGL

  • 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

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 and end date. - The class then parses the weather data from the start date to the end date. - The class then calculates the average max/min temperature, average max wind gust, and average day wind rose. - The class then plots the average max/min temperature, average max wind gust, and average day wind rose.

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.

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-single-levels-preliminary-back-extension?tab=overview -

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.

Must get the following variables: - surface elevation: self.elevation = float - 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(SAcup_wind_constraints=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(SAcup_wind_constraints=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(SAcup_altitude_constraints=False)[source]

Average wind speed 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(SAcup_altitude_constraints=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 windroses 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(SAcup_wind_constraints=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(SAcup_wind_constraints=False)[source]

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

process_wind_profile_over_average_day()[source]

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

plot_wind_profile_over_average_day(SAcup_altitude_constraints=False)[source]

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

animate_wind_profile_over_average_day(SAcup_altitude_constraints=False)[source]

Animation of how wind profile evolves throughout an average day.