Changes between Version 17 and Version 18 of Lorenz_63_model


Ignore:
Timestamp:
Jun 1, 2025, 4:00:34 PM (3 days ago)
Author:
lnerger
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Lorenz_63_model

    v17 v18  
    33[[PageOutline(2-3,Contents of this page)]]
    44
    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`.
     5The implementation of the Lorenz-63 model coupled to PDAF is in the directory `models/lorenz63/` of the PDAF package.
     6Provided 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
     7localized filters, but it is a good test case for the particle filter.
    68
    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
     9Next to the implementation of the Lorenz-96 model with PDAF, the test case provides tool programs and scripts  (in the subdirectory `tools/`) that
    1210allow to run a test case and to display the outputs. Note, that this implementation runs without parallelization.
    1311
     
    1513== Running the test case  ==
    1614
    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.
     15Runnning 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.
    1816
    1917=== 1. Compile and run the forward model without assimilation ===
    2018
    21 First change in the file `make.arch/linux_gfortran_openmpi.h` the line
    22 {{{
     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
    2321CPP_DEFS = -DUSE_PDAF
    24 }}}
    25 to 
    26 {{{
     22
     23to
     24
    2725CPP_DEFS = #-DUSE_PDAF
    28 }}}
    29 to deactivate the coupling to PDAF in the model code. Now build the forward model program with
     26
     27Now build the forward model program with
    3028{{{
    3129  cd models/lorenz63
    32   make lorenz_63 PDAF_ARCH=linux_gfortran_openmpi
     30  make lorenz_63 PDAF_ARCH=linux_gfortran
    3331}}}
    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.
     32The executable is generated in the current directory.
    3733
    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`. 
     34You 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`.
    3937
    4038To run the forward model use
     
    4947{{{
    5048  cd tools
    51   make generate_obs PDAF_ARCH=linux_gfortran_openmpi
     49  make generate_obs PDAF_ARCH=linux_gfortran
    5250}}}
    5351
     
    5654  ./generate_obs
    5755}}}
    58 to generate a file holding observations (`obs_l63.nc` in models/lorenz63/).
     56to generate a file holding observations (`obs_l63.nc` in `models/lorenz63/`).
    5957
    6058
    6159=== 3. Build and run the assimilation program ===
    6260
    63 Now do
    64 {{{
    65   cd ../../../make.arch
    66 }}}
    67 and change in the file `linux_gfortran_openmpi.h` the line
     61Now edit the file `make.arch/linux_gfortran.h` again and change the line
    6862{{{
    6963CPP_DEFS = #-DUSE_PDAF
     
    7670
    7771Now compile the Lorenz-63 model with activated
    78 coupling to PDAF. First clean the directories for the main driver and the Lorenz-63 model using
     72coupling to PDAF. First remove the binary files from the previous compilation using
    7973{{{
    80   cd ../models/lorenz63
    81   make clean PDAF_ARCH=linux_gfortran_openmpi
     74  make clean PDAF_ARCH=linux_gfortran
    8275}}}
    83 (This removes object files that were compiled without support for PDAF)
    84 Then build the executable using
     76Then build the assimilative program using
    8577{{{
    86   make pdaf_lorenz_63 PDAF_ARCH=linux_gfortran_openmpi
     78  make pdaf_lorenz_63 PDAF_ARCH=linux_gfortran
    8779}}}
    8880The program `pdaf_lorenz_63` is generated in the current directory.
     
    9385  ./tools/run_ESTKF.sh
    9486}}}
    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.
     87The 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
    9689Further you can run
    9790{{{
    9891  ./tools/run_PF.sh
    9992}}}
    100 to run a similar experiment with the particle filter.
     93to run a similar experiment with the particle filter. The run will generate the output file `PF_N20.nc`.
    10194
    10295
     
    110103
    111104The following plot functions are available:
    112 ||= Script =||= Description =||
     105||= !Function/Script =||= Description =||
    113106|| 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. ||
    114107|| plot_obs || Plot the observations for a specified time step. The observation file is generated using tools/generate_obs.F90. ||
     
    121114The 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`):
    122115
    123 ||= Matlab =||= Python =||= Comment =||
     116||= Python =||= !Matlab/Octave =||= Comment =||
    124117|| plot_eofs(filename, index) || plot_eofs(filename, index) || index=0 for mean state, index>1 for EOFs ||
    125118|| plot_obs(filename, timestep) || plot_obs(filename, timestep) || ||
    126119|| 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 ||
    128121|| plot_sigma(filename) || plot_sigma(filename) || ||
    129122|| 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 ||
    131124
    132125Here `filename` is the name of the file including its path.
    133126In 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]]
    142127
    143128'''Python plotting'''[[BR]]
     
    152137`./plot_l63.py plot_obs ../obs_l63.nc 4`[[BR]]
    153138(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]]
     140To 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]]
    156150
    157151