cmaqsatproc.utils package¶
Module contents¶
- cmaqsatproc.utils.EasyDataFramePoint(df, xkey='cn_x', ykey='cn_y')[source]¶
Thin wrapper on geopandas.points_from_xy. Create points from a rows with centers named xkey and ykey.
- Parameters:
df (pandas.DataFrame) – Must contain x, y
- Returns:
points – List of shapely.geometry.Polygons
- Return type:
list
- cmaqsatproc.utils.EasyDataFramePolygon(df, wrap=True, progress=False, lowmem=False)[source]¶
Create polygons from a row with corners of a pixel specificied using columns ll_x, ll_y … uu_x, uu_y.
The wrap functionality prevents polygons from straddling the dateline.
- Parameters:
df (pandas.DataFrame) – Must contain ll, lu, uu, ul for x and y (e.g., ll_x, ll_y)
wrap (bool) – If True (default), each polygon that crosses the dateline will be truncated to the Western portion.
- Returns:
polys – List of shapely.geometry.Polygons
- Return type:
list
- cmaqsatproc.utils.cdconvert(inval, inunit, outunit)[source]¶
Converts between du, mole m**-2, and molecules cm**-2
- cmaqsatproc.utils.getcmrgranules(temporal, bbox=None, poly=None, verbose=0, **kwds)[source]¶
Return all links from the Common Metadata Repository (CMR) for the product granules with short_name, date_range, and optionally a bounding box.
- Parameters:
temporal (str) – NASA temporal that is recognized by NASA CMR For example: - YYYY-MM-DDTHH:MM:SSZ or - YYYY-MM-DDTHH:MM:SSZ/YYYY-MM-DDTHH:MM:SSZ or - YYYY-MM-DDTHH:MM:SSZ/P01D (or P01M or P01Y, etc)
bbox (list) – Longitude/latitude bounding edges as floats (wlon,slat,elon,nlat)
poly (shapely.geometry.Polygon) – The exterior will be converted to floats and ordered x1,y1,…,xN,yN
filterfunc (function) – Takes a link dictionary from CMR and returns True if it should be retained
concept_id (str) – Optional, NASA concept_id that is the unique identifier for a collection in NASA’s Common Metadata Repository
short_name (str) – Optional, short_name identifier for a collection that is often, but not always unique in the NASA CMR. If you have the short_name and want the concept_id put the url below in your browser where you replace OMNO2 (the example) with your short_name https://cmr.earthdata.nasa.gov/search/collections?short_name=OMNO2
- Returns:
jr – json result as a dictionary
- Return type:
dictionary
- cmaqsatproc.utils.getcmrlinks(*args, filterfunc=None, **kwds)[source]¶
Return all links from the Common Metadata Repository for the product granules with args and kwds passed thru to getcmrgranules
- Parameters:
args – Passed to getcmrgranules as arguments and keywords (see getcmrgranules)
kwds – Passed to getcmrgranules as arguments and keywords (see getcmrgranules)
filterfunc (function) – Takes a link dictionary from CMR and returns True if it should be retained
- Returns:
links – List of all links where filterfunc is None or just links for which filterfunc returns True.
- Return type:
list
- cmaqsatproc.utils.rootremover(strlist, insert=False)[source]¶
Find the longest common root and replace it with {root}
- Parameters:
strlist (list) – List of strings from which to find a common root and replace with ‘{root}’
insert (bool) – If true, insert f’root: {root}’ at the beginning of the short list.
- Returns:
List with each element of strlist where the longest common root has been removed. If insert, then the root is inserted
- Return type:
stem, short_list