utils.py
add_month_day_dims(daily_ts, monthly_ts, time_dim='time', spatial_dims=('lat', 'lon'))
Reshape daily and monthly data to have explicit month (M) and day (T) dimensions.
Here we assume maximum 31 days in a month, and invalid day entries will be padded with NaN.
Returns:
| Name | Type | Description |
|---|---|---|
daily_m |
xr.DataArray - dims: (M, T, H, W)
|
|
monthly_m |
xr.DataArray - dims: (M, H, W)
|
|
padded_days_mask |
xr.DataArray - dims: (M, T=31), bool, True where day is padded
|
|
Source code in climanet/utils.py
pred_to_numpy(pred, orig_H=None, orig_W=None, land_mask=None)
pred: (B, M, H_pad,W_pad) or (B, H, W) torch tensor orig_H/W: original sizes before padding (optional) land_mask: (H_pad,W_pad) or (H,W) bool; if given, land will be set to NaN returns: (H,W) numpy array
Source code in climanet/utils.py
regrid_to_boundary_centered_grid(da, roll=False)
Interpolates a DataArray from its current center-based grid onto a new grid whose coordinates are derived from user-specified boundaries.
Includes robust handling for 0-360 vs -180-180 longitude domains.
Assumes dimensions are named 'lat' and 'lon'.