fre.pp.ppval_script module

This script will determine an estimated number of timesteps from a postprocessed time-series file’s name and run nccheck on it. Ran during time-series file creation during rename-split-to-pp and make-timeseries tasks in fre postprocessing workflow.

fre.pp.ppval_script.getenot(date_start: str, date_end: str, chunk_type: str, cal: str)

Returns the estimated number of timesteps using elapsed time (calculated using date_start/date_end) and data frequency (provided in chunk_type argument). Date string formats must be YYYY,YYYYMM,YYYYMMDD,YYYYMMDDHH,or YYYYMMDDHH:mm

Ex: Will return value of 36 (timesteps) for 3 years of data with monthly frequency output (3 years * 12 months)

Parameters:
  • date_start (str) – Starting time of data chunk

  • date_end (str) – Ending time of data chunk

  • chunk_type (str) – Frequency of data chunk

  • cal (str) – Calendar type corresponding to data (must be a cftime supported calendar: ‘standard’, ‘gregorian’, ‘proleptic_gregorian’, ‘noleap’, ‘365_day’, ‘360_day’, ‘julian’, ‘all_leap’, ‘366_day’)

Returns:

Estimated number of timesteps

Return type:

int

fre.pp.ppval_script.validate(filepath: str)

Compares the number of timesteps in a postprocessed time-series netCDF (.nc) file to the number of expected timesteps as calculated using elapsed time and data frequency. Runs nccheck on every timeseries file in pp dir.

Parameters:

filepath (str) – Path to time-series file to be checked

Raises:

ValueError – Calendar name doesn’t follow cftime conventions, frequency can’t be determined from filepath, or number of timesteps differ from expectation

Returns:

Returns 0 unless an exception is raised or number of timesteps differ from expectation

Return type:

int