credit.transforms.transforms_global#
- Content
Normalize_ERA5_and_Forcing
ToTensor_ERA5_and_Forcing
Attributes#
Classes#
Class to normalize ERA5 and Forcing Datasets. |
|
Class to convert ERA5 and Forcing Datasets to torch tensor. |
Module Contents#
- credit.transforms.transforms_global.logger#
- class credit.transforms.transforms_global.Normalize_ERA5_and_Forcing(conf)#
Class to normalize ERA5 and Forcing Datasets.
- mean_ds#
- std_ds#
- mean_tensors#
- std_tensors#
- levels#
- varname_upper_air#
- num_upper_air#
- flag_surface#
- flag_dyn_forcing#
- flag_diagnostic#
- flag_forcing#
- flag_static#
- __call__(sample: credit.data.Sample, inverse: bool = False) credit.data.Sample#
Normalize ERA5 and Forcing.
- Parameters:
sample – batch.
inverse – whether to transform or inverse transform the sample.
- Returns:
transformed and normalized sample.
- Return type:
torch.tensor
- transform_dataset(DS: xarray.Dataset) xarray.Dataset#
- transform_array(x: torch.Tensor) torch.Tensor#
Transform of y_pred.
Transform via provided scaler file/s of the prediction variable. Dynamic forcing, forcing, and static vars not transformed.
- Parameters:
x – batch.
- Returns:
transformed x.
- transform(sample: Dict[str, numpy.ndarray]) Dict[str, numpy.ndarray]#
Transform training batches.
Transform handles forcing & static as follows: - forcing & static don’t need to be transformed; users should transform them and save them to the file - other variables (upper-air, surface, dynamic forcing, diagnostics) need to be transformed
- Parameters:
sample – batch.
- Returns:
transformed sample.
- inverse_transform(x: torch.Tensor) torch.Tensor#
Inverse transform of y_pred.
Inverse transform of prediction variable. Dynamic forcing, forcing, and static vars not transformed.
- Parameters:
x – batch.
- Returns:
inverse transformed x.
- inverse_transform_input(x: torch.Tensor) torch.Tensor#
Inverse transform for input x.
Forcing and static variables are not transformed (they were not transformed in the transform function).
- Parameters:
x – batch.
- Returns:
transformed x.
- _align_coords(DS: xarray.Dataset, ref_ds: xarray.Dataset, rtol: float = 1e-06, atol: float = 1e-08) xarray.Dataset#
Ensure DS has the same lat/lon as ref_ds (to within tolerance), then re-assign DS.coords to exactly match ref_ds.coords.
- inverse_transform_dataset(DS: xarray.Dataset, rtol: float = 1e-06, atol: float = 1e-08) xarray.Dataset#
Inverse‐transform DS by (DS * std_ds) + mean_ds, after aligning its coordinates to mean_ds/std_ds.
- class credit.transforms.transforms_global.ToTensor_ERA5_and_Forcing(conf)#
Class to convert ERA5 and Forcing Datasets to torch tensor.
- conf#
- output_dtype = Ellipsis#
- hist_len#
- for_len#
- flag_surface#
- flag_dyn_forcing#
- flag_diagnostic#
- flag_forcing#
- flag_static#
- varname_upper_air#
- flag_upper_air = True#
- num_forcing_static = 0#
- __call__(sample: credit.data.Sample) credit.data.Sample#
Convert variables to input/output torch tensors.
- Parameters:
sample (interator) – batch.
- Returns:
converted torch tensor.
- Return type:
torch.tensor