credit.nwp#

Attributes#

Functions#

build_GFS_init(output_grid, date, variables[, ...])

Download GFS model level initial conditions, regrid to CREDIT model's grid, and vertically interpolate

_get_gfs_maps(variable_mapping_type)

_add_pressure_and_geopotential(data, temperature_var, ...)

Derive pressure and geopotential fields from model level data and to dataset

_build_file_path(date, base_path[, file_type, step])

Create NOMADS filepaths for etiher upper air or surface data

_load_gfs_variable(variable[, full_file_path])

_load_gfs_data(full_file_path, variables[, pool])

Load GFS data directly from Nomads or Google Cloud server

_combine_data(atm_data, sfc_data, temperature_var, ...)

Merge upper air and surface data

_regrid_variable(variable_data, regridder)

_regrid(nwp_data, output_grid[, method, pool])

Spatially regrid (interpolate) from GFS grid to CREDIT grid

_vertical_interpolation(state_dataset, ...)

_format_data(data_dict, regridded_data, model_levels)

Format data for CREDIT model ingestion

_format_datetime(init_time)

Format datetime string from CREDIT configuration file

Module Contents#

credit.nwp.gfs_map#
credit.nwp.level_map#
credit.nwp.upper_air#
credit.nwp.surface#
credit.nwp.build_GFS_init(output_grid: xarray.Dataset, date: pandas.Timestamp, variables: list, model_level_file: str = '', model_levels: numpy.ndarray = None, gdas_base_path: str = 'gs://global-forecast-system/', variable_mapping: str = 'wchapmanera5', n_procs: int = 1)#

Download GFS model level initial conditions, regrid to CREDIT model’s grid, and vertically interpolate 3D variables to CREDIT model levels.

Parameters:
  • output_grid (xr.Dataset) – netCDF file containing latitude and longitude coordinates of CREDIT model grid.

  • date (pd.Timestamp) – date of GFS initialization

  • variables (list) – list of variable names.

  • model_level_file (str) – Path to file containing output model level a and b coefficients on full and half levels.

  • model_levels (np.ndarray) – Subset of model levels to interpolate to.

  • gdas_base_path (str) – Path to GFS base directory on NOMADS (archives last 10 days) or Google Cloud (since 2021)

  • variable_mapping (str)

  • n_procs (int) – Number of processors to use in pool.

Returns:

(xr.Dataset) Interpolated GFS initial conditions

credit.nwp._get_gfs_maps(variable_mapping_type: str)#
credit.nwp._add_pressure_and_geopotential(data, temperature_var, specific_humidity_var)#

Derive pressure and geopotential fields from model level data and to dataset :param data: (xr.Dataset) GFS model level data

Returns:

xr.Dataset

credit.nwp._build_file_path(date, base_path, file_type='atm', step='f000')#

Create NOMADS filepaths for etiher upper air or surface data :param date: (pd.Timestamp) date of GFS initialization :param base_path: (str) NOMADS base directory (archives last 10 days) :param file_type: (str) Type of analysis data (supports ‘atm’ or ‘sfc’) :param step: (str) “anl” or “f000” to “f009”. f times have additional diagnostics

like ugrd10 and vgrd10 not found in the analysis files.

Returns:

(str) NOMADS or Google Cloud filepaths that can be read in xarray with the h5netcdf engine

credit.nwp._load_gfs_variable(variable, full_file_path=None)#
credit.nwp._load_gfs_data(full_file_path, variables, pool=None)#

Load GFS data directly from Nomads or Google Cloud server :param full_file_path: (str) NOMADS filepath :param variables: (list) list of variable names

Returns:

xr.Dataset

credit.nwp._combine_data(atm_data, sfc_data, temperature_var, specific_humidity_var)#

Merge upper air and surface data :param atm_data: (xr.Dataset) GFS upper air data :param sfc_data: (xr.Dataset) GFS surface data

Returns:

xr.Dataset

credit.nwp._regrid_variable(variable_data, regridder)#
credit.nwp._regrid(nwp_data, output_grid, method='bilinear', pool=None)#

Spatially regrid (interpolate) from GFS grid to CREDIT grid :param nwp_data: GFS initial conditions :type nwp_data: xr.Dataset :param output_grid: CREDIT grid :type output_grid: xr.Dataset :param method: conservative or bilinear :type method: str

Returns:

Regridded GFS initial conditions

Return type:

(xr.Dataset)

credit.nwp._vertical_interpolation(state_dataset, model_level_file, model_levels, variable_mapping, variables, surface_pressure_var)#
credit.nwp._format_data(data_dict, regridded_data, model_levels)#

Format data for CREDIT model ingestion :param data_dict: (dict) Dictionary of xr.DataArrays of interpolated GFS model level data :param regridded_data: (xr.Dataset) GFS initial conditions on CREDIT grid :param model_levels: (list) list of model level indices to extract from L137 model levels

Returns:

xr.Dataset of GFS initial conditions interpolated to CREDIT grid and model levels

credit.nwp._format_datetime(init_time)#

Format datetime string from CREDIT configuration file :param init_time: (dict) Dictionary of Forecast times from configuration file

Returns:

pd.Timestamp of initialization time