credit.credit_ptype#
Classes#
Module Contents#
- class credit.credit_ptype.CreditPostProcessor#
- save_vars = ['ML_u', 'ML_rain_ale', 'ML_rain_epi', 'ML_snow_ale', 'ML_snow_epi', 'ML_icep_ale',...#
- dewpoint_temp(dataset: xarray.Dataset)#
- convert_longitude(lon)#
Convert longitude from -180-180 to 0-360
- subset_extent(nwp_data, extent, data_proj=None)#
Subset data by given extent in projection coordinates.
- Parameters:
nwp_data – Xr.dataset of NWP data
extent – List of coordinates for subsetting (lon_min, lon_max, lat_min, lat_max)
transformer – Pyproj Projection transformer object
- Returns:
Subsetted Xr.Dataset
- extract_variable_levels(dataset: xarray.Dataset) numpy.ndarray#
Extracts data from an xarray dataset into a NumPy array of shape (84, lat, lon), where each height level is treated as a separate variable.
- Parameters:
dataset (xr.Dataset) – Input dataset with dimensions (time, height, lat, lon) and variables (t, dpt, u, v).
- Returns:
Extracted data of shape (lat * long, 84).
- Return type:
np.ndarray
- load_scaler(scaler_path)#
Load bridgescaler object.
- Parameters:
scaler_path – Path to scalar object.
- Returns:
Loaded bridgescaler object
- load_model(model_path)#
- transform_data(input_data, transformer, input_features)#
Transform data for input into ML model.
- Parameters:
input_data – Pandas Dataframe of input data
transformer – Bridgescaler object used to fit data.
- Returns:
Pandas dataframe of transformed input.
- grid_predictions(data, predictions, output_uncertainties=False)#
Populate gridded xarray dataset with ML probabilities and categorical predictions as separate variables.
- Parameters:
data – Xarray dataset of input data.
predictions – Pandas Dataframe of ML predictions.
output_uncertainties – Boolean, whether to output uncertainties.
- Returns:
Xarray dataset of ML predictions and surface variables on model grid.
- ptype_classification(dataset)#
- write_to_netcdf(dataset, nc_filename, forecast_hour, conf)#
Saves the processed data to a NetCDF file.