pyrsig.utils package¶
Module contents¶
- pyrsig.utils.customize_grid(grid_kw, bbox, clip=True)[source]¶
Redefine grid_kw to cover bbox by removing extra rows and columns and redefining XORIG, YORIG, NCOLS and NROWS.
- Parameters:
grid_kw (dict or str) – If str, must be a known grid in default grids. If dict, must include all IOAPI grid metadata properties
bbox (tuple) – wlon, slat, elon, nlat in decimal degrees (-180 to 180)
clip (bool) – If True, limit grid to original grid bounds
- Returns:
ogrid_kw – IOAPI grid metadata properties with XORIG/YORIG and NCOLS/NROWS adjusted such that it only covers bbox or (if clip) only covers the portion of bbox covered by the original grid_kw.
- Return type:
dict
- pyrsig.utils.get_file(url, outpath, maxtries=5, verbose=1, overwrite=False)[source]¶
Download file from RSIG using fault tolerance and optional caching when overwrite is False.
- Parameters:
url (str) – path to retrieve
outpath (str) – path to save file to
maxtries (int) – try this many times before quitting
verbose (int) – Level of verbosity
overwrite (bool) – If True, overwrite existing files. If False, reuse existing files.
- Return type:
None
- pyrsig.utils.get_proj4(attrs, earth_radius=6370000.0)[source]¶
Create a proj4 formatted grid definition using IOAPI attrs and earth_radius
- Parameters:
attrs (dict-like) – Mappable of IOAPI properties that supports the items method
earth_radius (float) – Assumed radius of the earth. 6370000 is the WRF default.
- Returns:
projstr – proj4 formatted string such that the domain southwest corner starts at (0, 0) and ends at (NCOLS, NROWS)
- Return type:
str
- pyrsig.utils.legacy_get(url, *args, **kwds)[source]¶
Previously used LegacyAdapter, but now selectively chooses adapter based on domain and package options. If verify option for domain is False, suppress warning because it is expected. If legacy is True, use old TLS that was deprecated in openssl v3.
- Parameters:
url (str) – Path for get call.
args (iterable) – Arguments to get
kwds (mappable) – Keywords to get
- Returns:
response – Response from requests get
- Return type:
requests.Response