diff --git a/README.md b/README.md index aa68357..24b164d 100644 --- a/README.md +++ b/README.md @@ -3,58 +3,58 @@ change update_rho -> thetao_new => Restart["tn"] # EMULATOR FRO NEMO MODEL ![img1](img/emulator.png) -Add retstart and prepare +Add retstart and prepare # Jumper.ipynb -### *Prepare and forecast simulations* +### *Prepare and forecast simulations* -The objective is to implement a Gaussian process forecast to forecast yearly simulations of NEMO coupled climate model. For this we need simulations files of the sea surface height (zos or ssh), the salinity (so) and temperature (thetao). +The objective is to implement a Gaussian process forecast to forecast yearly simulations of NEMO coupled climate model. For this we need simulations files of the sea surface height (zos or ssh), the salinity (so) and temperature (thetao). We apply PCA on each simulation to transform those features to time series. And we observe the trend in the first component. ![img1](img/jumper1.png) We forecast each component with a Gaussian process with the following kernel. -- Long term trend : 0.1*DotProduct(sigma_0=0.0) +- Long term trend : 0.1*DotProduct(sigma_0=0.0) - Periodic patterns : 10 * ExpSineSquared(length_scale=5/45, periodicity=5/45)#0.5**2*RationalQuadratic(length_scale=5.0, alpha=1.0) + 10 * ExpSineSquared(length_scale=5.0) - White noise : 2*WhiteKernel(noise_level=1) - + ![img2](img/jumper3.png) -And we evaluate the RMSE +And we evaluate the RMSE ![img2](img/jumper2.png) # Restart.ipynb -### *Update of restart files for NEMO* +### *Update of restart files for NEMO* The objective is to update the last restart file to initialize the jump. For this we need the 340 restarts files of the last simulated year. We also need the predictions of the sea surface height (zos or ssh), the salinity (so) and temperature (thetao). We also need the Mask dataset of the corresponding simulation where several informations are needed. ![img5](img/img3.png) -### 1 - Predicted features -- zos : Predicted sea surface height (ssh) - grid T - t,y,x -- so : Predicted salinity - grid T - t,z,y,x +### 1 - Predicted features +- zos : Predicted sea surface height (ssh) - grid T - t,y,x +- so : Predicted salinity - grid T - t,z,y,x - thetao : Predicted temperature - grid T - t,z,y,x -### 2 - Maskdataset +### 2 - Maskdataset **The Maskdataset contains mask on all grids, vectors and constants** - -- dimensions t:1 y:331 x:360 z:75 -- umask : continent mask for u grid (continent : 0, sea : 1) + +- dimensions t:1 y:331 x:360 z:75 +- umask : continent mask for u grid (continent : 0, sea : 1) - vmask : continent mask for v grid (continent : 0, sea : 1) - e3t_0 : initial thickness of cell on z axis on grid T (e:thickness, i:direction, t:grid, 0:initial state / ref) = e3t_ini restart -- e2t : thickness of cell on y axis on grid T +- e2t : thickness of cell on y axis on grid T - e1t : thickness of cell on y axis on grid T -- ff_f : corriolis force +- ff_f : corriolis force ### 3 - Necessary features to update restart -This is the list of features from the source restart file we need to exploit to update restart. +This is the list of features from the source restart file we need to exploit to update restart. - e3t : e3t_ini*(1+tmask4D*np.expand_dims(np.tile(ssh*ssmask/(bathy+(1-ssmask)),(75,1,1)),axis=0)) - deptht : depth of the z axis - grid T @@ -62,11 +62,11 @@ This is the list of features from the source restart file we need to exploit to ### 4 - Restart file update **The restart files contains all physical and dynamical features of the simulation** - -There is a total of 340 restart file per year. Each file contains a slice of x and y dimensions. Each files contains 58 data variables which 15 are updates using the predictions - -**NB** : difference between now (n) and before (b) arrays : they represent the same states, in practice the restart file save two successive states. In our code we set the two to the same state to use euler forward for the restart. +There is a total of 340 restart file per year. Each file contains a slice of x and y dimensions. Each files contains 58 data variables which 15 are updates using the predictions + + +**NB** : difference between now (n) and before (b) arrays : they represent the same states, in practice the restart file save two successive states. In our code we set the two to the same state to use euler forward for the restart. - ssh(n/b) : sea surface height => last prediction of zos - s(n/b) : sea salinity => last prediction of so @@ -95,9 +95,9 @@ F # main -### *Prepare and forecast simulations and initialize restarts files with one command line* +### *Prepare and forecast simulations and initialize restarts files with one command line* Prepare, forecats and predict -NB : En amont code de Guillaume pour obtenir des moyennes annuelles +NB : En amont code de Guillaume pour obtenir des moyennes annuelles #python main.py --ye True --start 25 --end 65 --comp 0.9 --steps 30 --path /scratchu/mtissot/SIMUp6Y diff --git a/lib/forecast.py b/lib/forecast.py index 4c0fa10..9328e1b 100644 --- a/lib/forecast.py +++ b/lib/forecast.py @@ -78,7 +78,7 @@ class Simulation: x_size (int) : The size of the x dimension. z_size (int or None) : The size of the z dimension, if available. shape (tuple) : The shape of the simulation data. - simulation (xarray.DataArray) : The loaded simulation data + simulation (xarray.DataArray) : The loaded simulation data """ def __init__( @@ -296,7 +296,7 @@ def getPC(self, n): Returns: (numpy.ndarray): The principal component map. """ - map_ = np.zeros((np.product(self.shape)), dtype=float) + map_ = np.zeros((np.prod(self.shape)), dtype=float) map_[~self.bool_mask] = np.nan map_[self.bool_mask] = self.pca.components_[n] map_ = map_.reshape(self.shape) diff --git a/main_restart.py b/main_restart.py index 707b705..e903a72 100644 --- a/main_restart.py +++ b/main_restart.py @@ -95,7 +95,7 @@ def update_Restarts(restarts_file, mask_file, jobs=10): recordFullRestart(args.restart_path, args.radical, restart) recordPiecedRestart(args.restart_path, args.radical, restart) - print("""All done. Now you just need to : + print("""All done. Now you just need to : - Back transform the coordinates of the pieced restart files using ncks to the original version (see bash script xarray_to_CMIP.sh) - Rename/Overwrite the "NEW_" restart files to their old version if you’re happy with them (see other bash script rewrite.sh) - Point to the restart directory in your simulation config.card (if all your non-NEMO restart files are also in the restart_path directory, of course). diff --git a/tools/CMIP_to_xarray.sh b/tools/CMIP_to_xarray.sh index fafee1f..d41a55a 100755 --- a/tools/CMIP_to_xarray.sh +++ b/tools/CMIP_to_xarray.sh @@ -1,10 +1,9 @@ #### # Hopefully you made sure your restart files have been made modifiable ( chmod 666 should be fine) -# +# #### for i in "$@"; do ncrename -v y,yy $i - ncrename -v x,xx $i + ncrename -v x,xx $i done -