Data Sources

Local Module

local.load_GPM_IMERG_files(file_path=None, filename_pattern=None, filelist=None, variable_name='precipitationCal', name='GPM_IMERG')

Load multiple GPM Level 3 IMEGE files containing calibrated precipitation and generate an OCW Dataset obejct.

Parameters:
  • file_path (string) – Directory to the HDF files to load.
  • filename_pattern (string) – Path to the HDF files to load.
  • filelist (string) – A list of filenames
  • variable_name (string) – The variable name to load from the HDF file.
  • name (string) – (Optional) A name for the loaded dataset.
Returns:

An OCW Dataset object with the requested variable’s data from the HDF file.

Return type:

dataset.Dataset

Raises ValueError:
 

local.load_NLDAS_forcingA_files(file_path=None, filename_pattern=None, filelist=None, variable_name='APCPsfc_110_SFC_acc1h', name='')

Load multiple NLDAS2 forcingAWRF files containing 2D fields such as precipitation and surface variables into a Dataset. The dataset can be spatially subset.

Parameters:
  • file_path (string) – Directory to the NetCDF file to load.
  • filename_pattern (string) – Path to the NetCDF file to load.
  • filelist (string) – A list of filenames
  • variable_name (string) – The variable name to load from the NetCDF file.
  • name (string) – (Optional) A name for the loaded dataset.
Returns:

An OCW Dataset object with the requested variable’s data from the NetCDF file.

Return type:

dataset.Dataset

Raises ValueError:
 

local.load_WRF_2d_files(file_path=None, filename_pattern=None, filelist=None, variable_name='T2', name='')

Load multiple WRF (or nuWRF) original output files containing 2D fields such as precipitation and surface variables into a Dataset. The dataset can be spatially subset.

Parameters:
  • file_path (string) – Directory to the NetCDF file to load.
  • filename_pattern (string) – Path to the NetCDF file to load.
  • filelist (string) – A list of filenames
  • variable_name (string) – The variable name to load from the NetCDF file.
  • name (string) – (Optional) A name for the loaded dataset.
Returns:

An OCW Dataset object with the requested variable’s data from the NetCDF file.

Return type:

dataset.Dataset

Raises ValueError:
 

local.load_WRF_2d_files_RAIN(file_path=None, filename_pattern=None, filelist=None, name='')

Load multiple WRF (or nuWRF) original output files containing 2D fields such as precipitation and surface variables into a Dataset. The dataset can be spatially subset.

Parameters:
  • file_path (string) – Directory to the NetCDF file to load.
  • filename_pattern (string) – Path to the NetCDF file to load.
  • name (string) – (Optional) A name for the loaded dataset.
Returns:

An OCW Dataset object with the requested variable’s data from the NetCDF file.

Return type:

dataset.Dataset

Raises ValueError:
 

local.load_dataset_from_multiple_netcdf_files(variable_name, lat_name=None, lon_name=None, time_name=None, name='', file_list=None, file_path=None, filename_pattern=None, mask_file=None, mask_variable=None, mask_value=0)

Load multiple netCDF files from the same source (an observation or a model) into a Dataset. The dataset can be spatially subset.

Parameters:
  • filelist (string) – A text file including a list of filenames
  • variable_name (string) – The variable name to load from the NetCDF file.
  • lat_name (string) – (Optional) The latitude variable name to extract from the dataset.
  • lon_name (string) – (Optional) The longitude variable name to extract from the dataset.
  • time_name (string) – (Optional) The time variable name to extract from the dataset.
  • name (string) – (Optional) A name for the loaded dataset.
  • file_path (string) – Directory to the NetCDF file to load.
  • filename_pattern (string) – Path to the NetCDF file to load.
  • mask_file – A netcdf file with two-dimensional mask indices
  • mask_variable – The variable name to load from the mask_file.
  • mask_value (int) – an index for spatial subsetting a dataset
Returns:

An OCW Dataset object with the requested variable’s data from the NetCDF file.

Return type:

dataset.Dataset

Raises ValueError:
 

local.load_file(file_path, variable_name, variable_unit=None, elevation_index=0, name='', lat_name=None, lon_name=None, time_name=None)

Load a NetCDF file into a Dataset.

Parameters:
  • file_path (string) – Path to the NetCDF file to load.
  • variable_name (string) – The variable name to load from the NetCDF file.
  • variable_unit (string) – (Optional) The variable unit to load from the NetCDF file.
  • elevation_index (int) – (Optional) The elevation index for which data should be returned. Climate data is often times 4 dimensional data. Some datasets will have readins at different height/elevation levels. OCW expects 3D data so a single layer needs to be stripped out when loading. By default, the first elevation layer is used. If desired you may specify the elevation value to use.
  • name (string) – (Optional) A name for the loaded dataset.
  • lat_name (string) – (Optional) The latitude variable name to extract from the dataset.
  • lon_name (string) – (Optional) The longitude variable name to extract from the dataset.
  • time_name (string) – (Optional) The time variable name to extract from the dataset.
Returns:

An OCW Dataset object with the requested variable’s data from the NetCDF file.

Return type:

dataset.Dataset

Raises ValueError:
 

When the specified file path cannot be loaded by ndfCDF4 or when the lat/lon/time variable name cannot be determined automatically.

local.load_multiple_files(file_path, variable_name, dataset_name='model', variable_unit=None, lat_name=None, lon_name=None, time_name=None)

load multiple netcdf files with common filename pattern and return an array of OCW datasets

Parameters:
  • file_path (string) – directory name and common file name patterns where the NetCDF files to load are stored.
  • dataset_name (:mod:’string’) – a name of dataset when reading a single file
  • variable_name (string) – The variable name to load from the NetCDF file.
  • variable_unit (string) – (Optional) The variable unit to load from the NetCDF file.
  • elevation_index – (Optional) The elevation index for which data should be returned. Climate data is often times 4 dimensional data. Some datasets will have readins at different height/elevation levels. OCW expects 3D data so a single layer needs to be stripped out when loading. By default, the first elevation layer is used. If desired you may specify the elevation value to use.
  • lat_name (string) – (Optional) The latitude variable name to extract from the dataset.
  • lon_name (string) – (Optional) The longitude variable name to extract from the dataset.
  • time_name (string) – (Optional) The time variable name to extract from the dataset.
Returns:

An array of OCW Dataset objects, an array of dataset names

Return type:

list

RCMED Module

Classes:
RCMED - A class for retrieving data from Regional Climate Model Evalutaion Database (JPL). More information about the RCMED Query Specification can be found below: https://rcmes.jpl.nasa.gov/query-api/query.php?
rcmed.get_parameters_metadata()

Get the metadata of all parameter from RCMED.

Returns:Dictionary of information for each parameter stored in one list
Return type:list of dict
rcmed.parameter_dataset(dataset_id, parameter_id, min_lat, max_lat, min_lon, max_lon, start_time, end_time, name='')

Get data from one database(parameter).

Parameters:
  • dataset_id (int) – Dataset id.
  • parameter_id (int) – Parameter id
  • min_lat (float) – Minimum latitude
  • max_lat (float) – Maximum latitude
  • min_lon (float) – Minimum longitude
  • max_lon (float) – Maximum longitude
  • start_time (datetime.datetime) – Start time
  • end_time (datetime.datetime) – End time
  • name (string) – (Optional) A name for the loaded dataset.
Returns:

An OCW Dataset object contained the requested data from RCMED.

Return type:

dataset.Dataset

DAP Module

dap.load(url, variable, name='')

Load a Dataset from an OpenDAP URL

Parameters:
  • url (string) – The OpenDAP URL for the dataset of interest.
  • variable (string) – The name of the variable to read from the dataset.
  • name (string) – (Optional) A name for the loaded dataset.
Returns:

A dataset.Dataset containing the dataset pointed to by the OpenDAP URL.

Raises:

ServerError

ESGF Module

esgf.load_dataset(dataset_id, variable, esgf_username, esgf_password, search_url='http://esgf-node.jpl.nasa.gov/esg-search/search', elevation_index=0, name='', save_path='/tmp', **additional_constraints)

Load an ESGF dataset.

Parameters:
  • dataset_id (string) – The ESGF ID of the dataset to load.
  • variable (string) – The variable to load.
  • esgf_username (string) – ESGF OpenID value to use for authentication.
  • esgf_password (string) – ESGF Password to use for authentication.
  • search_url (string) – (Optional) The ESGF node to use for searching. Defaults to the Jet Propulsion Laboratory node.
  • elevation_index (int) – (Optional) The elevation level to strip out when loading the dataset using ocw.data_source.local.
  • name (string) – (Optional) A name for the loaded dataset.
  • save_path (string) – (Optional) Path to where downloaded files should be saved.
  • additional_constraints – (Optional) Additional key,value pairs to pass as constraints to the search wrapper. These can be anything found on the ESGF metadata page for a dataset.
Returns:

A list of dataset.Dataset contained the requested dataset. If the dataset is stored in multiple files each will be loaded into a separate dataset.Dataset.

Raises ValueError:
 

If no dataset can be found for the supplied ID and variable, or if the requested dataset is a multi-file dataset.