API Reference

Date Formatters

Date formatter functions.

reshapr.utils.date_formatters.ddmmmyy(arrow_date)[source]

Return an Arrow date as a string formatted as lower-cased ddmmmyy; e.g. 28feb22.

Parameters:

arrow_date (arrow.arrow.Arrow) – Date/time to format.

Returns:

Date formatted as lower-cased ddmmmyy.

Return type:

str

reshapr.utils.date_formatters.nemo_yyyymm(arrow_date)[source]

Return an Arrow date as a string formatted using the NEMO forcing date convention; i.e. y2022m02.

Parameters:

arrow_date (arrow.arrow.Arrow) – Date/time to format.

Returns:

Date formatted as NEMO forcing date.

Return type:

str

reshapr.utils.date_formatters.nemo_yyyymmdd(arrow_date)[source]

Return an Arrow date as a string formatted using the NEMO forcing date convention; i.e. y2022m02d28.

Parameters:

arrow_date (arrow.arrow.Arrow) – Date/time to format.

Returns:

Date formatted as NEMO forcing date.

Return type:

str

reshapr.utils.date_formatters.yyyy(arrow_date)[source]

Return an Arrow date as a string of digits formatted as yyyy; e.g. 2022.

Parameters:

arrow_date (arrow.arrow.Arrow) – Date/time to format.

Returns:

Date formatted as yyyy digits.

Return type:

str

reshapr.utils.date_formatters.yyyymm01(arrow_date)[source]

Return the first day of the month for an Arrow date as a string of digits formatted as yyyymm01; e.g. 20220201.

Parameters:

arrow_date (arrow.arrow.Arrow) – Date/time to format.

Returns:

Date formatted as yyyymm01 digits.

Return type:

str

reshapr.utils.date_formatters.yyyymm_end(arrow_date)[source]

Return the last day of the month for an Arrow date as a string of digits formatted as yyyymmdd; e.g. 20220228.

Parameters:

arrow_date (arrow.arrow.Arrow) – Date/time to format.

Returns:

Date formatted as yyyymmdd digits.

Return type:

str

reshapr.utils.date_formatters.yyyymmdd(arrow_date)[source]

Return an Arrow date as a string of digits formatted as yyyymmdd; e.g. 20220228.

Parameters:

arrow_date (arrow.arrow.Arrow) – Date/time to format.

Returns:

Date formatted as yyyymmdd digits.

Return type:

str

Extraction

v1 extraction API.

reshapr.api.v1.extract.extract_dataset()[source]

Not implemented.

Returns:

TBD

reshapr.api.v1.extract.extract_netcdf(config, config_yaml)[source]

Extract model variable(s) time series from model product to a netCDF file.

Recommended use is to load the config dict from a YAML file (optionally overriding extraction state/end dates) with load_extraction_config(), then call this function.

Parameters:
  • config (dict) – Extraction processing configuration dictionary.

  • config_yaml (pathlib.Path) – File path and name of the YAML file that the extraction processing configuration dictionary was read from. Used in netCDF4 file history metadata.

Returns:

File path and name that netCDF4 file was written to.

Return type:

pathlib.Path

reshapr.api.v1.extract.load_extraction_config(config_yaml, start_date=None, end_date=None)[source]

Read an extraction processing configuration YAML file and return a config dict.

If start/end dates are provided, use them to override the values from the YAML file. None means do not override.

Parameters:
  • config_yaml (pathlib.Path) – File path and name of the YAML file to read the extraction processing configuration dictionary from. Please see extract Process Configuration File for details.

  • start_date (arrow.arrow.Arrow or None) – Start date for extraction. When provided, this date overrides the start date in config file.

  • end_date (arrow.arrow.Arrow or None) – End date for extraction. When provided, this date overrides the end date in config file.

Returns:

Extraction processing configuration dictionary.

Return type:

dict

Raises:

ValueError if processing configuration YAML file cannot be opened.