Meteorology#

class physics.environment.meteorology.BaseMeteorology#

Bases: ABC

abstract calculate_solar_irradiances(coords, time_zones, local_times, elevations)#
property solar_irradiance: ndarray#

Return the solar irradiance in W/m^2 every tick, if available.

Returns:

ndarray of solar irradiances in W/m^2 at every tick

Raises:

UnboundLocalError – if solar irradiances are not available.

abstract spatially_localize(cumulative_distances: ndarray) None#
abstract temporally_localize(unix_timestamps, start_time, tick) None#
property weather_indices: ndarray#

Return the weather indices at every tick, if available.

Returns:

ndarray of weather indices at every tick

Raises:

UnboundLocalError – if weather indices are not available.

property wind_direction: ndarray#

Return the wind direction in degrees, following the meteorological convention, if available.

Returns:

ndarray of wind directions in degrees at every tick.

Raises:

UnboundLocalError – if wind directions are not available.

property wind_speed: ndarray#

Return the wind speeds in m/s at every tick, if available.

Returns:

ndarray of wind speeds in m/s at every tick

Raises:

UnboundLocalError – if wind speeds are not available.

class physics.environment.meteorology.IrradiantMeteorology(race, weather_forecasts)#

Bases: BaseMeteorology

IrradiantMeteorology encapsulates meteorological data that includes solar irradiance data, but not cloud cover.

calculate_solar_irradiances(coords, time_zones, local_times, elevations)#

Calculates the Global Horizontal Irradiance from the Sun, relative to a location on the Earth, for arrays of coordinates, times, elevations and weathers https://www.pveducation.org/pvcdrom/properties-of-sunlight/calculation-of-solar-insolation Note: If local_times and time_zones are both unadjusted for Daylight Savings, the

calculation will end up just the same

Parameters:
  • coords (np.ndarray) – (float[N][lat, lng]) array of latitudes and longitudes

  • time_zones (np.ndarray) – (int[N]) time zones at different locations in seconds relative to UTC

  • local_times (np.ndarray) – (int[N]) unix time that the vehicle will be at each location. (Adjusted for Daylight Savings)

  • elevations (np.ndarray) – (float[N]) elevation from sea level in m

Returns:

(float[N]) Global Horizontal Irradiance in W/m2

Return type:

np.ndarray

spatially_localize(cumulative_distances: ndarray, simplify_weather: bool = False) None#
Parameters:
  • cumulative_distances (np.ndarray) – NumPy Array representing cumulative distances theoretically achievable for a given input speed array

  • simplify_weather (bool) – enable to only use a single weather coordinate (for track races without varying weather)

temporally_localize(unix_timestamps, start_time, tick) None#

Takes in an array of indices of the weather_forecast array, and an array of timestamps. Uses those to figure out what the weather forecast is at each time step being simulated.

we only have weather at discrete timestamps. The car however can be in any timestamp in between. Therefore, we must be able to choose the weather timestamp that is closest to the one that the car is in so that we can more accurately determine the weather experienced by the car at that timestamp.

For example, imagine the car is at some coordinate (x,y) at timestamp 100. Imagine we know the weather forecast at (x,y) for five different timestamps: 0, 30, 60, 90, and 120. Which weather forecast should we choose? Clearly, we should choose the weather forecast at 90 since it is the closest to 100. That’s what the below code is accomplishing.

Parameters:
  • unix_timestamps (np.ndarray) – (int[N]) unix timestamps of the vehicle’s journey

  • start_time (int) – time since the start of the race that simulation is beginning

  • tick (int) – length of a tick in seconds

Returns:

a SolcastEnvironment object with time_dt, latitude, longitude, wind_speed, wind_direction, and ghi.

Return type:

SolcastEnvironment

class physics.environment.meteorology.CloudedMeteorology(race, weather_forecasts)#

Bases: BaseMeteorology

CloudedMeteorology encapsulates meteorological data that includes cloud cover, but not solar irradiance (necessitating manual computation).

calculate_solar_irradiances(coords, time_zones, local_times, elevations)#

Calculates the Global Horizontal Irradiance from the Sun, relative to a location on the Earth, for arrays of coordinates, times, elevations and weathers https://www.pveducation.org/pvcdrom/properties-of-sunlight/calculation-of-solar-insolation Note: If local_times and time_zones are both unadjusted for Daylight Savings, the

calculation will end up just the same

Parameters:
  • coords (np.ndarray) – (float[N][lat, lng]) array of latitudes and longitudes

  • time_zones (np.ndarray) – (int[N]) time zones at different locations in seconds relative to UTC

  • local_times (np.ndarray) – (int[N]) unix time that the vehicle will be at each location. (Adjusted for Daylight Savings)

  • elevations (np.ndarray) – (float[N]) elevation from sea level in m

Returns:

(float[N]) Global Horizontal Irradiance in W/m2

Return type:

np.ndarray

spatially_localize(cumulative_distances: ndarray, simplify_weather: bool = False) None#

IMPORTANT: we only have weather coordinates for a discrete set of coordinates. However, the car could be at any coordinate in between these available weather coordinates. We need to figure out what coordinate the car is at at each timestep and then we can figure out the full weather forecast at each timestep.

For example, imagine the car is at some coordinate (10, 20). Further imagine that we have a week’s worth of weather forecasts for the following five coordinates: (5, 4), (11, 19), (20, 30), (40, 30), (0, 60). Which set of weather forecasts should we choose? Well, we should choose the (11, 19) one since our coordinate (10, 20) is closest to (11, 19). This is what the following code is accomplishing. However, it is not dealing with the coordinates directly but rather is dealing with the distances between the coordinates.

Furthermore, once we have chosen a week’s worth of weather forecasts for a specific coordinate, we must isolate a single weather forecast depending on what time the car is at the coordinate (10, 20). That is the job of the get_weather_forecast_in_time() method.

Parameters:
  • cumulative_distances (np.ndarray) – NumPy Array representing cumulative distances theoretically achievable for a given input speed array

  • simplify_weather (bool) – enable to only use a single weather coordinate (for track races without varying weather)

temporally_localize(unix_timestamps, start_time, tick) None#

Takes in an array of indices of the weather_forecast array, and an array of timestamps. Uses those to figure out what the weather forecast is at each time step being simulated.

we only have weather at discrete timestamps. The car however can be in any timestamp in between. Therefore, we must be able to choose the weather timestamp that is closest to the one that the car is in so that we can more accurately determine the weather experienced by the car at that timestamp.

For example, imagine the car is at some coordinate (x,y) at timestamp 100. Imagine we know the weather forecast at (x,y) for five different timestamps: 0, 30, 60, 90, and 120. Which weather forecast should we choose? Clearly, we should choose the weather forecast at 90 since it is the closest to 100. That’s what the below code is accomplishing.

Parameters:
  • unix_timestamps (np.ndarray) – (int[N]) unix timestamps of the vehicle’s journey

  • tick (int) – length of a tick in seconds

Returns:

  • A NumPy array of size [N][9]

  • [9] (latitude, longitude, unix_time, timezone_offset, unix_time_corrected, wind_speed, wind_direction,

    cloud_cover, precipitation, description):

Return type:

np.ndarray