cmaqsatproc.readers package

Subpackages

Submodules

cmaqsatproc.readers.core module

class cmaqsatproc.readers.core.satellite[source]

Bases: object

classmethod add_weights(intx, option='equal')[source]

Add Weights to intersection dataframe (intx) using predefined options: * ‘equal’ uses equal weights for all overlapping pixels * ‘area’ uses area of intersection for all overlapping pixels * other methods can be added by overriding this mehtod

Parameters:

intx (geopandas.GeoDataFrame) – Dataframe that has a geometry field that supports area

Return type:

None

classmethod cmr_download(check='exists', **kwds)[source]

Uses cmr_links to get links from the NASA Common Metadata Repo and downloads them to local disk.

Parameters:
  • check (str) – Options are exists and size. - exists : keep cached if it exists. - size : keep cached if it is the full file size

  • kwds (mappable) – Passed through to utils.getcmrlinks. See getcmrlinks for valid keywords

Returns:

dests – List of local files downloaded

Return type:

list

Uses utils.getcmrlinks to get links from the NASA Common Metadata Repository (CMR)

Parameters:
  • method (str) – Options are opendap, download, or s3

  • kwds (mappable) – Passed through to utils.getcmrlinks and utils.getcmrgranules. Summary of getcmrgranules copied below for convenience. See getcmrgranules for definitive docs.

Returns:

links – List of links to OpenDAP, http downloadable, or s3 links

Return type:

list

Notes

getcmrgranules keywords

temporalstr

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, P01Y, etc)

bboxlist

Longitude/latitude bounding edges as floats (wlon,slat,elon,nlat)

polyshapely.geometry.Polygon

The exterior will be converted to floats and ordered x1,y1,…,xN,yN

filterfuncfunction

Takes a link dictionary from CMR and returns True if it should be retained

concept_idstr

Optional, NASA concept_id that is the unique identifier for a collection in NASA’s Common Metadata Repository

short_namestr

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

classmethod cmr_to_level3(temporal, grid, griddims=None, weighting='area', bbox=None, verbose=0, varkeys=None, as_dataset=True, link_kwargs=None, **kwargs)[source]

Wrapper around cmr_links and paths_to_level3. For description of keywords, see those methods.

Parameters:

link_kwargs (mappable) – The method keyword of link_kwargs defaults to ‘download’, but can also be ‘opendap’. When ‘opendap’, cmr_to_level3 opens the files directly from the daac. When ‘download’, the files are downloaded and read from local disk.

property ds
classmethod from_dataset(ds, path='unknown')[source]

Create a satellite object from a dataset

Parameters:

ds (xarray.Dataset) – Satellite dataset

Returns:

sat – Satellite processing instance

Return type:

satellite

classmethod open_dataset(path, bbox=None, **kwargs)[source]

Create a satellite object from the dataset at a path. The path can be a local path or a remote path (OpenDAP or s3).

Parameters:
  • path (str) – Path to a satellite file

  • bbox (iterable) – swlon, swlat, nelon, nelat in decimal degrees East and North of 0, 0

  • kwargs (mappable) – Passed to xarray.open_dataset

Returns:

sat – Satellite processing instance

Return type:

satellite

classmethod paths_to_level3(paths, grid, griddims=None, weighting='area', bbox=None, verbose=0, varkeys=None, as_dataset=True, **kwargs)[source]

Iteratively apply output = cls(path).to_level3(*args, path=path, **kwds) and then grouped_weighted_avg(output[dims]) for each dimset.

For description of keywords, see to_level3.

shorten_name(k)[source]

By default, nothing is done and k is returned. Override this method to make short names that are suitable for other purposes (e.g., IOAPI 16 character names)

to_dataframe(*varkeys, valid=True, geo=False, default_keys=False)[source]

Transform the Dataset into a dataframe. This function is similar to xr.Dataset.to_dataframe, but includes geopandas support and filtering for valid pixels.

Parameters:
  • varkeys (iterable) – Keys to use in the dataframe. Defaults to class._defaultkeys that is class specific

  • valid (bool) – If true, only return valid pixels.

  • geo (bool) – Add geometry to output a geopandas.GeoDataFrame

Returns:

df

Return type:

pandas.DataFrame or geopandas.GeoDataFrame

to_level3(*varkeys, grid, griddims=None, weighting='area', as_dataset=True, verbose=0)[source]

Convert variables from L2 file to a custom L3 file.

Parameters:
  • varkeys (iterable) – See to_dataframe

  • grid (geopandas.GeoDataFrame) – Defines the grid used as the L3 destination

  • griddims (iterable) – Defaults to grid.index.names

  • weighting (str) – Passed as option to self.add_weights

Returns:

outputs – Dictionary of outputs by output dimensions or Dataset of outputs as a dataset

Return type:

dict or xr.Dataset

Module contents

class cmaqsatproc.readers.satellite[source]

Bases: object

classmethod add_weights(intx, option='equal')[source]

Add Weights to intersection dataframe (intx) using predefined options: * ‘equal’ uses equal weights for all overlapping pixels * ‘area’ uses area of intersection for all overlapping pixels * other methods can be added by overriding this mehtod

Parameters:

intx (geopandas.GeoDataFrame) – Dataframe that has a geometry field that supports area

Return type:

None

classmethod cmr_download(check='exists', **kwds)[source]

Uses cmr_links to get links from the NASA Common Metadata Repo and downloads them to local disk.

Parameters:
  • check (str) – Options are exists and size. - exists : keep cached if it exists. - size : keep cached if it is the full file size

  • kwds (mappable) – Passed through to utils.getcmrlinks. See getcmrlinks for valid keywords

Returns:

dests – List of local files downloaded

Return type:

list

Uses utils.getcmrlinks to get links from the NASA Common Metadata Repository (CMR)

Parameters:
  • method (str) – Options are opendap, download, or s3

  • kwds (mappable) – Passed through to utils.getcmrlinks and utils.getcmrgranules. Summary of getcmrgranules copied below for convenience. See getcmrgranules for definitive docs.

Returns:

links – List of links to OpenDAP, http downloadable, or s3 links

Return type:

list

Notes

getcmrgranules keywords

temporalstr

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, P01Y, etc)

bboxlist

Longitude/latitude bounding edges as floats (wlon,slat,elon,nlat)

polyshapely.geometry.Polygon

The exterior will be converted to floats and ordered x1,y1,…,xN,yN

filterfuncfunction

Takes a link dictionary from CMR and returns True if it should be retained

concept_idstr

Optional, NASA concept_id that is the unique identifier for a collection in NASA’s Common Metadata Repository

short_namestr

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

classmethod cmr_to_level3(temporal, grid, griddims=None, weighting='area', bbox=None, verbose=0, varkeys=None, as_dataset=True, link_kwargs=None, **kwargs)[source]

Wrapper around cmr_links and paths_to_level3. For description of keywords, see those methods.

Parameters:

link_kwargs (mappable) – The method keyword of link_kwargs defaults to ‘download’, but can also be ‘opendap’. When ‘opendap’, cmr_to_level3 opens the files directly from the daac. When ‘download’, the files are downloaded and read from local disk.

property ds
classmethod from_dataset(ds, path='unknown')[source]

Create a satellite object from a dataset

Parameters:

ds (xarray.Dataset) – Satellite dataset

Returns:

sat – Satellite processing instance

Return type:

satellite

classmethod open_dataset(path, bbox=None, **kwargs)[source]

Create a satellite object from the dataset at a path. The path can be a local path or a remote path (OpenDAP or s3).

Parameters:
  • path (str) – Path to a satellite file

  • bbox (iterable) – swlon, swlat, nelon, nelat in decimal degrees East and North of 0, 0

  • kwargs (mappable) – Passed to xarray.open_dataset

Returns:

sat – Satellite processing instance

Return type:

satellite

classmethod paths_to_level3(paths, grid, griddims=None, weighting='area', bbox=None, verbose=0, varkeys=None, as_dataset=True, **kwargs)[source]

Iteratively apply output = cls(path).to_level3(*args, path=path, **kwds) and then grouped_weighted_avg(output[dims]) for each dimset.

For description of keywords, see to_level3.

shorten_name(k)[source]

By default, nothing is done and k is returned. Override this method to make short names that are suitable for other purposes (e.g., IOAPI 16 character names)

to_dataframe(*varkeys, valid=True, geo=False, default_keys=False)[source]

Transform the Dataset into a dataframe. This function is similar to xr.Dataset.to_dataframe, but includes geopandas support and filtering for valid pixels.

Parameters:
  • varkeys (iterable) – Keys to use in the dataframe. Defaults to class._defaultkeys that is class specific

  • valid (bool) – If true, only return valid pixels.

  • geo (bool) – Add geometry to output a geopandas.GeoDataFrame

Returns:

df

Return type:

pandas.DataFrame or geopandas.GeoDataFrame

to_level3(*varkeys, grid, griddims=None, weighting='area', as_dataset=True, verbose=0)[source]

Convert variables from L2 file to a custom L3 file.

Parameters:
  • varkeys (iterable) – See to_dataframe

  • grid (geopandas.GeoDataFrame) – Defines the grid used as the L3 destination

  • griddims (iterable) – Defaults to grid.index.names

  • weighting (str) – Passed as option to self.add_weights

Returns:

outputs – Dictionary of outputs by output dimensions or Dataset of outputs as a dataset

Return type:

dict or xr.Dataset