metreload.merra2

Module for retrieving MERRA-2 data

Module Contents

metreload.merra2.DODS_URL = https://goldsmr4.gesdisc.eosdis.nasa.gov/dods
metreload.merra2.TIME_CHUNKS
metreload.merra2.get_merra2_collection_dataframe(collection, username, password, start_time, end_time, variables, location)

Get a MERRA-2 data collection as a pandas DataFrame

Parameters:
  • collection (str) – Earth Science Data Types Name of the collection (9 characters)
  • username (str) –
  • password (str) –
  • start_time (str) – Timestamp in the form YYYY-MM-DD
  • end_time (str) – Timestamp in the form YYYY-MM-DD
  • [ (variables) – List of variables to include, or None to include all
  • location (tuple) – Location in the form of tuple (lat, lon) or (north, west, south, east)
  • in WGS84 system. (coordinates) –
metreload.merra2.get_merra2_data(collection, username, password, savedir, start_time, end_time, variables, location)

Convenience function for downloading MERRA-2 data as netCDF files

Parameters:
  • collection (str) – Name of data collection
  • savedir (str) – Directory to save files to
  • start_time (str) – Timestamp in the form YYYY-MM-DDTHH
  • end_time (str) – See above.
  • variables (list) – List of variables to include, or None to include all
  • location (tuple) – Location in the form of tuple (lat, lon) or (north, west, south, east) coordinates in WGS84 system.
class metreload.merra2.MERRA2Dataset(ds)

Bases: object

Class for MERRA-2 datasets

__del__(self)
__enter__(self)
__exit__(self, exc_type, exc_value, traceback)
close(self)

Close the dataset

static open(collection, username, password, base_url=DODS_URL)

Open a MERRA-2 data collection

Parameters:
  • collection (str) – Earth Science Data Types Name of the collection (9 characters)
  • username (str) –
  • password (str) –
  • base_url (str, optional) – Base url for requests, default https://goldsmr4.gesdisc.eosdis.nasa.gov/dods
to_netcdf(self, savedir)

Save to netCDF4 files

Parameters:savedir (str) – Path to save files to
to_xarray(self)

Convert to xarray Dataset

to_dataframe(self)

Convert to pandas DataFrame

subset(self, location=None, start_time=None, end_time=None, variables=None)

Subset the data accordingly

Parameters:
  • location (tuple) – Location in the form of tuple (lat, lon) or (north, west, south, east)
  • in WGS84 system. (coordinates) –
  • start_time (str) – Timestamp in the form YYYY-MM-DDTHH
  • end_time (str) – See above.
  • variables (list) – List of variables to include, or None to include all