Changes between Version 17 and Version 18 of Lorenz_63_model
- Timestamp:
- Jun 1, 2025, 4:00:34 PM (3 days ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Lorenz_63_model
v17 v18 3 3 [[PageOutline(2-3,Contents of this page)]] 4 4 5 Note: The data assimilation with the Lorenz-63 model has been added in version 1.14 of PDAF. Here, the use is described for PDAF 1.15 where we moved the Lorenz-63 case into the directory `models`. 5 The implementation of the Lorenz-63 model coupled to PDAF is in the directory `models/lorenz63/` of the PDAF package. 6 Provided is a full implementation of PDAF with the nonlinear Lorenz-63 model (E. N. Lorenz (1963) Deterministic non-periodic flows. J. Atmos. Sci. 20, 130-141) providing the possibility to assess various filter and smoother methods. The model has state dimenion 3. So it is not usable for 7 localized filters, but it is a good test case for the particle filter. 6 8 7 The implementation of the Lorenz-63 model coupled to PDAF is in the directory `models/lorenz63/` of the PDAF package. 8 Provided is a full implementation of PDAF with the nonlinear Lorenz-63 model (E. N. Lorenz (1963) Deterministic non-periodic flows. J. Atmos. Sci. 20, 130-141) providing various filter and smoother methods. The model has state dimenion 3. So it's not usable for 9 localized filters, but it's a good test case for the particle filter. 10 11 Next to the implementation of the Lorenz-63 model with PDAF, the test case provides tool programs and scripts that 9 Next to the implementation of the Lorenz-96 model with PDAF, the test case provides tool programs and scripts (in the subdirectory `tools/`) that 12 10 allow to run a test case and to display the outputs. Note, that this implementation runs without parallelization. 13 11 … … 15 13 == Running the test case == 16 14 17 Runnning a data assimilation experiment with the Lorenz-63 model is a two step process: First one runs the model without PDAF to generate a file holding the trajectory of a forward run. Then one generates files with observations and a covariance matrix for the initialization of the initial ensemble. In the second step, one compiles the Lorenz-63 model with activated coupling to PDAF and runs the data assimilation experiments.15 Runnning a data assimilation experiment with the Lorenz-63 model is a two step process: First one runs the model without PDAF to generate a file holding the trajectory of a forward run. Then, one generates a file with observations and a file holding information on the covariance matrix (EOFs and singular values, see the [wiki:EnsembleGeneration page on ensemble generation]). The second file will be used to generate the initial ensemble with second-order exact sampling. Afterwards, one compiles the Lorenz-63 model with activated coupling to PDAF and runs the data assimilation experiments. 18 16 19 17 === 1. Compile and run the forward model without assimilation === 20 18 21 First change in the file `make.arch/linux_gfortran_openmpi.h`the line22 {{{ 19 First, we compile the Lorenz-96 model without assimilation. For this we need to deactivate the code parts that couple to PDAF. For this, change in the file make.arch/linux_gfortran.h the line 20 23 21 CPP_DEFS = -DUSE_PDAF 24 }}} 25 to 26 {{{ 22 23 to 24 27 25 CPP_DEFS = #-DUSE_PDAF 28 }}} 29 to deactivate the coupling to PDAF in the model code. Now build the forward model program with 26 27 Now build the forward model program with 30 28 {{{ 31 29 cd models/lorenz63 32 make lorenz_63 PDAF_ARCH=linux_gfortran _openmpi30 make lorenz_63 PDAF_ARCH=linux_gfortran 33 31 }}} 34 You have to ensure 35 that in the machine-specific make include file `linux_gfortran_openmpi.h` `-DUSE_PDAF` is not defined 36 for CPP_DEFS (such that calls to PDAF are not active). You can replace `linux_gfortran_openmpi` by any other make include file from `make.arch/`, e.g. specify `macos_gfortran` for compiling on MacOS. The executable is generated in the directory. 32 The executable is generated in the current directory. 37 33 38 '''Note''': The implementation uses the NetCDF library for file outputs. If the compilation above fails, please ensure the netcdf-library ist installed. On computers running Linux, it is usually available as a package of the operating system. On MacOS one can install the netcdf library e.g. using Fink or !MacPorts. NetCDF is a self-describing binary output format, but here it is not required that you know details about it. Anyway, if you like to look 'into' a NetCDF file, please try to use `ncdump FILENAME | less`. 34 You can replace `linux_gfortran` by any other make include file from `make.arch/`, e.g. specify `macos_gfortran_openmpi` for compiling on MacOS. 35 36 '''Note''': The implementation uses the NetCDF library for file outputs. If the compilation above fails, please ensure the netCDF-library is installed. On computers running Linux, netCDF is usually available as a package of the operating system. On MacOS one can install the netcdf library e.g. using Homebrew or !MacPorts. NetCDF is a self-describing binary output format, but here it is not required that you know details about it. Anyway, if you like to look 'into' a NetCDF file, please try to use `ncdump FILENAME | less`. 39 37 40 38 To run the forward model use … … 49 47 {{{ 50 48 cd tools 51 make generate_obs PDAF_ARCH=linux_gfortran _openmpi49 make generate_obs PDAF_ARCH=linux_gfortran 52 50 }}} 53 51 … … 56 54 ./generate_obs 57 55 }}} 58 to generate a file holding observations (`obs_l63.nc` in models/lorenz63/).56 to generate a file holding observations (`obs_l63.nc` in `models/lorenz63/`). 59 57 60 58 61 59 === 3. Build and run the assimilation program === 62 60 63 Now do 64 {{{ 65 cd ../../../make.arch 66 }}} 67 and change in the file `linux_gfortran_openmpi.h` the line 61 Now edit the file `make.arch/linux_gfortran.h` again and change the line 68 62 {{{ 69 63 CPP_DEFS = #-DUSE_PDAF … … 76 70 77 71 Now compile the Lorenz-63 model with activated 78 coupling to PDAF. First clean the directories for the main driver and the Lorenz-63 modelusing72 coupling to PDAF. First remove the binary files from the previous compilation using 79 73 {{{ 80 cd ../models/lorenz63 81 make clean PDAF_ARCH=linux_gfortran_openmpi 74 make clean PDAF_ARCH=linux_gfortran 82 75 }}} 83 (This removes object files that were compiled without support for PDAF) 84 Then build the executable using 76 Then build the assimilative program using 85 77 {{{ 86 make pdaf_lorenz_63 PDAF_ARCH=linux_gfortran _openmpi78 make pdaf_lorenz_63 PDAF_ARCH=linux_gfortran 87 79 }}} 88 80 The program `pdaf_lorenz_63` is generated in the current directory. … … 93 85 ./tools/run_ESTKF.sh 94 86 }}} 95 The script run_ESTKF.sh runs an experiment with the ESTKF filter method for ensmeble size 20 in which only the variable X os the model is observed at each 10th time step. The execution should only take seconds. 87 The script run_ESTKF.sh runs an experiment with the ESTKF filter method for ensmeble size 20 in which only the variable 'X' of the model is observed at each 10th time step. The execution should only take seconds. The run will generate the output file `ESTKF_N20.nc`. 88 96 89 Further you can run 97 90 {{{ 98 91 ./tools/run_PF.sh 99 92 }}} 100 to run a similar experiment with the particle filter. 93 to run a similar experiment with the particle filter. The run will generate the output file `PF_N20.nc`. 101 94 102 95 … … 110 103 111 104 The following plot functions are available: 112 ||= Script =||= Description =||105 ||= !Function/Script =||= Description =|| 113 106 || plot_eofs || Plot the mean state and the eigenvectors (EOFs) from the file holdig the covariance matrix that is generated with tools/generate_covar.F90. || 114 107 || plot_obs || Plot the observations for a specified time step. The observation file is generated using tools/generate_obs.F90. || … … 121 114 The scripts need the specification of the input file and the time step or variable to plot. The syntax of the functions is identical for Matlab and Python (except for `plot_rms`): 122 115 123 ||= Matlab =||= Python=||= Comment =||116 ||= Python =||= !Matlab/Octave =||= Comment =|| 124 117 || plot_eofs(filename, index) || plot_eofs(filename, index) || index=0 for mean state, index>1 for EOFs || 125 118 || plot_obs(filename, timestep) || plot_obs(filename, timestep) || || 126 119 || plot_obs_series(filename, variable) || plot_obs_series(filename, variable) || || 127 || plot_rms(filename [, plot_forecast= 1, plot_analysis=1]) || plot_rms(filename [, plot_forecast=True, plot_analysis=True]) ||plot_forecast/plot_analysis are optional and switch on/off a plot ||120 || plot_rms(filename [, plot_forecast=True, plot_analysis=True]) ||plot_rms(filename [, plot_forecast=1, plot_analysis=1]) || plot_forecast/plot_analysis are optional and switch on/off a plot || 128 121 || plot_sigma(filename) || plot_sigma(filename) || || 129 122 || plot_state(filename, timestep [, choice='t']) || plot_state(filename, timestep [, choice='t']) || `choice` is optional; options for `choice`: 't' true (use with truth file `state.nc`); for use with assimilation experiment output files: 'f' forecast, 'a' analysis, 'i' initial || 130 || plot_state_series(filename, variable [, choice='t']) || plot_state(filename, variable [, choice='t']) || `choice` is optional; options for `choice`: 't' true (use with truth file `state_l63.nc`); for use with assimilation experiment output files: 'f' forecast, 'a' analysis, 'i' initial||123 || plot_state_series(filename, variable, choice='t') || plot_state(filename, variable [, choice='t']) || options for `choice`: 't' true (use with truth file `state_l63.nc`); for use with assimilation experiment output files: 'f' forecast, 'a' analysis || 131 124 132 125 Here `filename` is the name of the file including its path. 133 126 In Matlab use 'help' to display the information about required input. 134 135 '''!Matlab/Octave plotting examples:'''[[BR]]136 `plot_obs('../obs.nc',100)` plots the observation at time step 100[[BR]]137 `plot_obs_series('../obs.nc',1)` plots the time series of observations for variable X (likely set 2=Y, 3=Z) [[BR]]138 `plot_state('../ESTKF_N20.nc',100,'f')` plots the forecast state estimate from the ESTKF run example at the 100th analysis step[[BR]]139 `plot_rms('../t1_N30_f0.97.nc')` plots the true and estimated RMS errors over time for the chosen experiment[[BR]]140 `plot_state('../state_l63.nc',1101)` plots the true state at model time step 1101 (= analysis step 100)[[BR]]141 `plot_state_series('../ESTKF_N20.nc',1,'f')` plots the time series for the ESTKF run example of the forecast state for variable X[[BR]]142 127 143 128 '''Python plotting'''[[BR]] … … 152 137 `./plot_l63.py plot_obs ../obs_l63.nc 4`[[BR]] 153 138 (If this fails you can also try to run the script as 154 `python plot_l63.py plot_obs ../obs_l63.nc 4`). To plot only the Analysis RMS error one can use[[BR]] 155 `plot_rms ../ESTKF_N20.nc False True` 139 `python plot_l63.py plot_obs ../obs_l63.nc 4`). [[BR]] 140 To plot only the analysis RMS error one can use[[BR]] 141 `./plot_l63.py plot_rms ../ESTKF_N20.nc False True` 142 143 '''!Matlab/Octave plotting examples:'''[[BR]] 144 `plot_obs('../obs.nc',100)` plots the observation at time step 100[[BR]] 145 `plot_obs_series('../obs.nc',1)` plots the time series of observations for variable X (likely set 2=Y, 3=Z) [[BR]] 146 `plot_state('../ESTKF_N20.nc',100,'f')` plots the forecast state estimate from the ESTKF run example at the 100th analysis step[[BR]] 147 `plot_rms('../t1_N30_f0.97.nc')` plots the true and estimated RMS errors over time for the chosen experiment[[BR]] 148 `plot_state('../state_l63.nc',1101)` plots the true state at model time step 1101 (= analysis step 100)[[BR]] 149 `plot_state_series('../ESTKF_N20.nc',1,'f')` plots the time series for the ESTKF run example of the forecast state for variable X[[BR]] 156 150 157 151