Skip to content

Commit 1b5d9fe

Browse files
committed
ENH: address copilot comments
1 parent 1dc1372 commit 1b5d9fe

3 files changed

Lines changed: 28 additions & 99 deletions

File tree

rocketpy/environment/environment.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,14 @@ class Environment:
178178
``Ensemble``.
179179
Environment.lat_array : array
180180
Defined if ``netCDF`` or ``OPeNDAP`` file is used, for Forecasts,
181-
Reanalysis and Ensembles. 2x2 matrix for each pressure level of
182-
latitudes corresponding to the vertices of the grid cell which
183-
surrounds the launch site.
181+
Reanalysis and Ensembles. Two-element list ``[x1, x2]`` containing
182+
the latitude coordinates of the grid-cell vertices that bracket the
183+
launch site and are used in bilinear interpolation.
184184
Environment.lon_array : array
185185
Defined if ``netCDF`` or ``OPeNDAP`` file is used, for Forecasts,
186-
Reanalysis and Ensembles. 2x2 matrix for each pressure level of
187-
longitudes corresponding to the vertices of the grid cell which
188-
surrounds the launch site.
186+
Reanalysis and Ensembles. Two-element list ``[y1, y2]`` containing
187+
the longitude coordinates of the grid-cell vertices that bracket the
188+
launch site and are used in bilinear interpolation.
189189
Environment.lon_index : int
190190
Defined if ``netCDF`` or ``OPeNDAP`` file is used, for Forecasts,
191191
Reanalysis and Ensembles. Index to a grid longitude which
@@ -223,7 +223,8 @@ class Environment:
223223
surrounds the launch site.
224224
Environment.time_array : array
225225
Defined if ``netCDF`` or ``OPeNDAP`` file is used, for Forecasts,
226-
Reanalysis and Ensembles. Array of dates available in the file.
226+
Reanalysis and Ensembles. Two-element list with the first and last
227+
values from the dataset time variable in the dataset native units.
227228
Environment.height : array
228229
Defined if ``netCDF`` or ``OPeNDAP`` file is used, for Forecasts,
229230
Reanalysis and Ensembles. List of geometric height corresponding to

rocketpy/environment/fetchers.py

Lines changed: 6 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ def fetch_atmospheric_data_from_windy(lat, lon, model):
9393

9494

9595
def fetch_gfs_file_return_dataset(max_attempts=10, base_delay=2):
96-
"""Fetches the latest GFS (Global Forecast System) dataset from the NOAA's
97-
GrADS data server using the OpenDAP protocol.
96+
"""Fetches the latest GFS (Global Forecast System) dataset from the UCAR
97+
THREDDS data server using the OPeNDAP protocol.
9898
9999
Parameters
100100
----------
@@ -128,8 +128,8 @@ def fetch_gfs_file_return_dataset(max_attempts=10, base_delay=2):
128128

129129

130130
def fetch_nam_file_return_dataset(max_attempts=10, base_delay=2):
131-
"""Fetches the latest NAM (North American Mesoscale) dataset from the NOAA's
132-
GrADS data server using the OpenDAP protocol.
131+
"""Fetches the latest NAM (North American Mesoscale) dataset from the UCAR
132+
THREDDS data server using the OPeNDAP protocol.
133133
134134
Parameters
135135
----------
@@ -161,8 +161,8 @@ def fetch_nam_file_return_dataset(max_attempts=10, base_delay=2):
161161

162162

163163
def fetch_rap_file_return_dataset(max_attempts=10, base_delay=2):
164-
"""Fetches the latest RAP (Rapid Refresh) dataset from the NOAA's GrADS data
165-
server using the OpenDAP protocol.
164+
"""Fetches the latest RAP (Rapid Refresh) dataset from the UCAR THREDDS
165+
data server using the OPeNDAP protocol.
166166
167167
Parameters
168168
----------
@@ -193,78 +193,6 @@ def fetch_rap_file_return_dataset(max_attempts=10, base_delay=2):
193193
raise RuntimeError("Unable to load latest weather data for RAP through " + file_url)
194194

195195

196-
def fetch_hrrr_file_return_dataset(max_attempts=10, base_delay=2):
197-
"""Fetches the latest HRRR (High-Resolution Rapid Refresh) dataset from
198-
the NOAA's GrADS data server using the OpenDAP protocol.
199-
200-
Parameters
201-
----------
202-
max_attempts : int, optional
203-
The maximum number of attempts to fetch the dataset. Default is 10.
204-
base_delay : int, optional
205-
The base delay in seconds between attempts. Default is 2.
206-
207-
Returns
208-
-------
209-
netCDF4.Dataset
210-
The HRRR dataset.
211-
212-
Raises
213-
------
214-
RuntimeError
215-
If unable to load the latest weather data for HRRR.
216-
"""
217-
file_url = "https://thredds.ucar.edu/thredds/dodsC/grib/NCEP/HRRR/CONUS_2p5km/Best"
218-
attempt_count = 0
219-
while attempt_count < max_attempts:
220-
try:
221-
return netCDF4.Dataset(file_url)
222-
except OSError:
223-
attempt_count += 1
224-
time.sleep(base_delay**attempt_count)
225-
226-
raise RuntimeError(
227-
"Unable to load latest weather data for HRRR through " + file_url
228-
)
229-
230-
231-
def fetch_aigfs_file_return_dataset(max_attempts=10, base_delay=2):
232-
"""Fetches the latest AIGFS (Artificial Intelligence GFS) dataset from
233-
the NOAA's GrADS data server using the OpenDAP protocol.
234-
235-
Parameters
236-
----------
237-
max_attempts : int, optional
238-
The maximum number of attempts to fetch the dataset. Default is 10.
239-
base_delay : int, optional
240-
The base delay in seconds between attempts. Default is 2.
241-
242-
Returns
243-
-------
244-
netCDF4.Dataset
245-
The AIGFS dataset.
246-
247-
Raises
248-
------
249-
RuntimeError
250-
If unable to load the latest weather data for AIGFS.
251-
"""
252-
file_url = (
253-
"https://thredds.ucar.edu/thredds/dodsC/grib/NCEP/AIGFS/Global_0p25deg/Best"
254-
)
255-
attempt_count = 0
256-
while attempt_count < max_attempts:
257-
try:
258-
return netCDF4.Dataset(file_url)
259-
except OSError:
260-
attempt_count += 1
261-
time.sleep(base_delay**attempt_count)
262-
263-
raise RuntimeError(
264-
"Unable to load latest weather data for AIGFS through " + file_url
265-
)
266-
267-
268196
def fetch_hiresw_file_return_dataset(max_attempts=10, base_delay=2):
269197
"""Fetches the latest HiResW (High-Resolution Window) dataset from the NOAA's
270198
GrADS data server using the OpenDAP protocol.

rocketpy/environment/weather_model_mapping.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ class WeatherModelMapping:
77
Each dictionary in this class maps those canonical keys to the actual
88
variable names in a specific data provider format.
99
10-
Mapping families
11-
----------------
12-
- Base names (for example ``GFS``, ``NAM``, ``RAP``) represent the current
13-
default mappings used by the latest-model shortcuts and THREDDS-style
14-
datasets.
15-
- ``*_LEGACY`` names represent older NOMADS-style variable naming
16-
conventions (for example ``lev``, ``tmpprs``, ``ugrdprs`` and
17-
``vgrdprs``) and are intended for archived or previously downloaded files.
10+
Mapping families
11+
----------------
12+
- Base names (for example ``GFS``, ``NAM``, ``RAP``) represent the current
13+
default mappings used by the latest-model shortcuts and THREDDS-style
14+
datasets.
15+
- ``*_LEGACY`` names represent older NOMADS-style variable naming
16+
conventions (for example ``lev``, ``tmpprs``, ``ugrdprs`` and
17+
``vgrdprs``) and are intended for archived or previously downloaded files.
1818
19-
Notes
20-
-----
21-
- Mappings can also include optional keys such as ``projection`` for
22-
projected grids and ``ensemble`` for member dimensions.
23-
- The :meth:`get` method is case-insensitive, so ``"gfs_legacy"`` and
24-
``"GFS_LEGACY"`` are equivalent.
19+
Notes
20+
-----
21+
- Mappings can also include optional keys such as ``projection`` for
22+
projected grids and ``ensemble`` for member dimensions.
23+
- The :meth:`get` method is case-insensitive, so ``"gfs_legacy"`` and
24+
``"GFS_LEGACY"`` are equivalent.
2525
"""
2626

2727
GFS = {

0 commit comments

Comments
 (0)