ERA5

This version was edited to integrate with EarthSHAB.

Contributing authors: Craig Motell and Michael Rodriguez of NIWC Pacific Edited and integrated: Tristan Schuler

class ERA5.ERA5(start_coord)[source]
__init__(start_coord)[source]

Create a class object containing information about an ERA5. Along the way, it checks whether it can take a subset of your model data. For example, if you have data before or after your simulation times, you can ignore these data through saving indexes.

Parameters:

start_coord – starting coordinate of balloon for simulation

Note

Similar to class GFS which stores NOAA GFS data from NOMAD server

See also

GFS

closestIdx(arr, k)[source]

Given an ordered array and a value, determines the index of the closest item contained in the array.

determineRanges(netcdf_ranges)[source]

Determine the dimensions of actual data. If you have columns or rows with missing data as indicated by NaN, then this function will return your actual shape size so you can resize your data being used.

fill_missing_data(data)[source]

Helper function to fill in linearly interpolate and fill in missing data

get2NearestAltIdxs(h, alt_m)[source]

Determines 2 nearest indexes for altitude for interpolating angles. It does index wrap from 0 to -1, which is taken care of in ERA5.interpolateBearing()

getNearestAltbyIndex(int_hr_idx, lat_i, lon_i, alt_m)[source]

Determines the nearest altitude based off of geo potential height of a .25 degree lat/lon area. at a given latitude, longitude index

getNearestLatIdx(lat, min, max)[source]

Determines the nearest latitude index (to .25 degrees), which will be integer index starting at 0 where you data is starting

getNearestLonIdx(lon, min, max)[source]

Determines the nearest longitude (to .25 degrees)

getNewCoord(coord, dt)[source]

Determines the new coordinates of the balloon based on the effects of U and V wind components.

Parameters:
  • coord (dict) – Contains current position, altitude and time of balloon object.

  • dt (float) – Integration time

  • Returns – lat_new, lon_new, x_wind_vel, y_wind_vel, bearing, closest_lat, closest_lon, closest alt

init_with_time()[source]

adds to class object containing information about an ERA5 but without any time variables.

Returns:

ERA5 – Initialize class object with our NetCDF data.

Return type:

ERA5 Class Object

Notes

Similar to class GFS which stores NOAA GFS data from NOMAD server

interpolateBearing(h, u, v, alt_m)[source]

Given altitude, u_velocity and v_velocity arrays as well as a desired altitude, perform a linear interpolation between the 2 altitudes (h0 and h1) while accounting for possible 0/360degree axis crossover.

interpolateBearingTime(bearing0, speed0, bearing1, speed1, hour_index)[source]

Similar to ERA5.interpolateBearing() however bearings and speeds are already known and linearly then interpolated with respect to time (t0 and t1)

windVectorToBearing(u, v)[source]

Helper function to conver u-v wind components to bearing and speed.

wind_alt_Interpolate(alt_m, diff_time, lat_idx, lon_idx)[source]

Warning

This function is no longer used. Use wind_alt_Interpolate2 which does 2 different types of interpolation to choose from.

Performs a 2 step linear interpolation to determine horizontal wind velocity. First the altitude is interpolated between the two nearest .25 degree lat/lon areas. Once altitude is matched, a second linear interpolation is performed with respect to time.

Note

I performed a lot of clean up of this code from what Craig originally sent me. I’m not exactly sure what about all the difference from GFS to ERA5 for this function. I will do more cleaning and variable renaming in a later version. The results are the same right now thoug.

Parameters:
  • alt_m (float) – Contains current altitude of balloon object.

  • diff_time – This parameter is calculated in two different places, need to clean up this parameter

  • lon_idx (integer) – Closest index into longitude array

  • lat_idx (integer) – Closest index into latitude array

  • Returns

    ufloat

    u component wind vector

    vfloat

    v component wind vector

wind_alt_Interpolate2(alt_m, diff_time, lat_idx, lon_idx)[source]

Performs two different types of a 2 step linear interpolation to determine horizontal wind velocity. First the altitude is interpolated between the two nearest .25 degree lat/lon areas. Once altitude is matched, a second linear interpolation is performed with respect to time.

The old method performs the linear interpolation using u-v wind Components the new method performs the linear interpolation using wind bearing and speed.

Both are calculated in this function. The examples use the new method (bearing and wind), which should be slightly more accurate.

Parameters:
  • alt_m (float) – Contains current altitude of balloon object.

  • diff_time – This parameter is calculated in two different places, need to clean up this parameter

  • lon_idx (integer) – Closest index into longitude array

  • lat_idx (integer) – Closest index into latitude array

  • note: (..) – TODO:

  • Returns

    u_newfloat

    u component wind vector (bearing/speed interpolation)

    v_newfloat

    v component wind vector (bearing/speed interpolation)

    u_oldfloat

    u component wind vector (u-v component interpolation)

    v_oldfloat

    v component wind vector (u-v component interpolation)