ClimeTrend / DMD-ERA5

MIT License
1 stars 0 forks source link

Develop the DMD on ERA5 module #7

Open dsj976 opened 4 weeks ago

dsj976 commented 4 weeks ago

This module would take as inputs:

  1. ERA5 slice downloaded using era5-download
  2. Optionally, the projection basis (the U matrix) generated with era5-svd

DMD would be performed with the PyDMD package, which can optionally do data pre-processing prior to performing DMD. We need to make sure that the SVD performed with era5-svd matches the data pre-processing that PyDMD will do internally (e.g. mean-centering, standardization, delay embedding). The era5-dmd module should check that the data-preprocessing performed by era5-svd matches the data-preprocessing requested by the user.

U = xarrray.open_dataset("data/era5-svd/U.nc")  # the POD modes produced by `era5-svd`

era5 = xarray.open_dataet("data/era5-download/2020-01-01_2020-01-10_1h.nc") # ERA5 slice downloaded with `era5-download`
X = era5["Temperature"].values  # Numpy array
t = era5.time.values  # Numpy array

# U.attrs should state any pre-processing that has been done by `era5-svd` (e.g. U.attrs['delay_embedding'] = 2)

optdmd = BOPDMD(
    svd_rank=svd_rank,
    num_trials=0,
    use_proj=True,
    proj_basis = U,  # this is the projection basis calculated by `era5-svd` 
    varpro_opts_dict={"verbose": True}
    )

delay = 2
delay_optdmd = hankel_preprocessing(optdmd, d=delay)

def check_pre_processing_matches():
    """Check that U.attrs, era5.attrs and inputs to `BOPDMD` and `fit` all match."""

t_delay = t [:-delay+1]
delay_optdmd.fit(X, t=t_delay)
LydiaFrance commented 4 weeks ago

@dsj976 Is it okay if I branch off from cli-svd?

dsj976 commented 4 weeks ago

@LydiaFrance yes ocf!