credit.output#
- Content:
load_metadata()
make_xarray()
save_netcdf_increment()
Attributes#
Functions#
|
Load metadata attributes from yaml file in credit/metadata directory |
|
Split the output tensor of the model to upper air variables and diagnostics/surface variables. |
|
Create two xarray.DataArray objects for upper air and surface variables. |
|
Save CREDIT model prediction output to netCDF file. Also performs pressure level |
Module Contents#
- credit.output.logger#
- credit.output.load_metadata(conf)#
Load metadata attributes from yaml file in credit/metadata directory
- credit.output.split_and_reshape(tensor, conf)#
Split the output tensor of the model to upper air variables and diagnostics/surface variables.
Upperair level arrangement: top-of-atmosphere–> near-surface –> single layer An example: U (top-of-atmosphere) –> U (near-surface) –> V (top-of-atmosphere) –> V (near-surface) The shape of the output tensor is (variables, latitude, longitude)
- Parameters:
tensor – PyTorch Tensor containing output of the AI NWP model
conf – config file for the model
- credit.output.make_xarray(pred, forecast_datetime, lat, lon, conf)#
Create two xarray.DataArray objects for upper air and surface variables.
- Parameters:
pred (torch.Tensor or np.ndarray) – Prediction tensor containing both upper air and surface variables.
forecast_datetime (datetime) – The forecast initialization datetime.
lat (np.ndarray or list) – Latitude values.
lon (np.ndarray or list) – Longitude values.
conf (dict) – Configuration dictionary containing details about the data structure and variables.
- Returns:
- DataArray containing upper air variables with dimensions
[time, vars, level, latitude, longitude].
- darray_single_level (xarray.DataArray): DataArray containing surface variables with dimensions
[time, vars, latitude, longitude].
- Return type:
darray_upper_air (xarray.DataArray)
- credit.output.save_netcdf_increment(darray_upper_air: xarray.DataArray, darray_single_level: xarray.DataArray, nc_filename: str, forecast_hour: int, meta_data: dict, conf: dict)#
Save CREDIT model prediction output to netCDF file. Also performs pressure level interpolation on the output if you wish.
- Parameters:
darray_upper_air (xr.DataArray) – upper air variable predictions
darray_single_level (xr.DataArray) – surface variable predictions
nc_filename (str) – file description to go into output filenames
forecast_hour (int) – how many hours since the initialization of the model.
meta_data (dict) – metadata dictionary for output variables
conf (dict) – configuration dictionary for training and/or rollout