Changes between Version 16 and Version 17 of FirstSteps


Ignore:
Timestamp:
May 31, 2025, 7:02:03 PM (2 days ago)
Author:
lnerger
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FirstSteps

    v16 v17  
    77demonstrating the implementation and application of PDAF with a simple 2-dimensional example.
    88
     9Here we describe the steps for a Linux-based computer.
     10
    911== First Test Case - A Single Analysis Step ==
    1012
    11 In this test case, a data assimilation program is used to read an ensemble of model fields from files and compute an analysis step. This is the so-called offline coupling mode of PDAF. A full description of this test case is provided in the [wiki:PdafTutorial implementation tutorial for the offline mode of PDAF].
     13In this test case, a data assimilation program is used to read an ensemble of model fields from files and compute an analysis step. This is the so-called ''offline coupled mode'' of PDAF. A full description of this test case is provided in the [wiki:PdafTutorial implementation tutorial for the offline mode of PDAF].
    1214
    1315=== Compiling ===
    1416
    15 We recommend to first look at the tutorial offline_2D_serial, which is a
     17We recommend to first look at the tutorial `offline_2D_serial`, which is a
    1618single analysis step acting on an ensemble of 2D model fields without any
    1719parallelization.
     
    2325and run
    2426{{{
    25 make PDAF_ARCH=linux_gfortran_openmpi
     27make PDAF_ARCH=linux_gfortran
    2628}}}
    2729This compiles the assimilation program including PDAF. The compilation
     
    3537./PDAF_offline
    3638}}}
    37 The program reads ensemble files and a file holding the observations from the directory `tutorial/inputs_offline/`. Then it computes a single analysis step of the ensemble Kalman filter ESTKF. Running the program should not take more than a second. The program generates the
    38 output files
    39 `state_ana.txt` (The analysis state)
    40 and
    41 `ens_01_ana.txt` to `ens_09_ana.txt` (the analysis ensemble).
    42 
    43 The screen output shows the progress of the program. For example the ensemble standard deviation before and after the analysis step and final timing and memory information are shown. Lines starting with 'PDAF' are outputs from the code part of PDAF other lines are from the user routines.
     39The program reads ensemble files and a file holding the observations from the directory `tutorial/inputs_offline/`. Then, it computes a single analysis step of the ensemble Kalman filter ESTKF. Running the program should only take seconds. The program generates the output files
     40* `state_ana.txt` (the analysis state)
     41* `ens_01_ana.txt` to `ens_09_ana.txt` (the analysis ensemble).
     42
     43The screen output shows the progress of the program. For example, the ensemble standard deviation before and after the analysis step and final timing and memory information are shown. Lines starting with 'PDAF' are outputs from the core part of PDAF; other lines are from the user routines.
    4444
    4545=== Plotting ===
    4646
    47 To plot, e.g. the analysis field you can use Matlab or Octave and do
    48 {{{
    49 load state_ana.txt
    50 pcolor(state_ana)
    51 }}}
    52 You can also plot the initial ensemble mean field by
    53 {{{
    54 cd ../inputs_offline
    55 load state_ini.txt
    56 pcolor(state_ini)
    57 }}}
    58 Analogously you can plot the observations (`obs.txt`) and the true state (`true.txt`) from which the observations have been generated. In the
    59 observation file, only 28 grid points are observed, while non-observed grid points have the value -999.0. To get a meaningful plot, you can specify the limits for the color map by
    60 {{{
    61 set(gca,'clim',[-2 2])
    62 }}}
    63 
    64 Alternatively, you can plot using Python with e.g.
     47You can plot using Python with, for example
    6548{{{
    6649import numpy as np
     
    7558}}}
    7659
     60Analogously you can plot the observations (`obs.txt`) and the true state (`true.txt`) from which the observations have been generated. These files are in the input directory. In the observation file, only 28 grid points are observed, while non-observed grid points have the value -999.0. To get a meaningful plot, you can specify the color limits by
     61{{{
     62plt.clim([-1.5, 1.5])
     63}}}
     64before showing the plot.
     65
     66
    7767=== Assimilation Options ===
    7868
    79 There are various options you can set to modify the assimilation,
     69There are various options you can set on the command line to modify the assimilation.
     70
    8071For example you can run
    8172{{{
    8273./PDAF_offline -filtertype 7
    8374}}}
    84 With this setting, the localized filter LESTKF instead of the global ESTKF.
    85 Without further settings, the localization radius is set to 0 so that only
     75to apply the localized filter LESTKF instead of the global ESTKF.
     76Without further settings, the localization radius is set to 0.0 so that only
    8677the observed grid points are changed by the assimilation.
    87 You can further set the localization cut-offg radius with
     78You can further set the localization cut-off radius with
    8879{{{
    8980./PDAF_offline -filtertype 7 -cradius 5.0
    9081}}}
    91 Now the LESTKF is used with a localization radius of 5 grid points. This
    92 localization still uses a constant weight of the observation. So you will
     82Now, the LESTKF is used with a localization radius of 5 grid points. This
     83localization uses a constant weight of the observation. So you will
    9384see steps in the analysis fields around each observation. To add a
    9485tapering so that observations get less influence for increasing distance,
     
    9889}}}
    9990Now, the filter is applied with the 5th-order polynomial function by
    100 Gaspari and Cohn. As a result you get a smoothly changing analysis field.
     91Gaspari and Cohn (1999). As a result you get a smoothly varying analysis field.
    10192You can also change the ensemble size, e.g. running
    10293{{{
     
    10495}}}
    10596to run with an ensemble of 5 model states. (For this test case we only
    106 prepared 9, so only dim_obs<=9 is possible to run here.)
    107 The standard deviation (RMS error) of the observation is set to 0.5 in the program. To change it to, e.g. 2.0, would would run
     97prepared 9 ensemble files, so only dim_ens<=9 is possible to run here. Please note that such ensemble size is usually too low for real cases)
     98The standard deviation (RMS error) of the observation is set to 0.5 in the program. To change it to, e.g. 2.0, you can run
    10899{{{
    109100./PDAF_offline -rms_obs 2.0
    110101}}}
    111 Also the inflation can be specified on the command line. PDAF uses the so-called forgetting factor, which is a positive value <=1 (the ensemble variance is influted by the inverse of the forgetting factor). One can specify the forgetting factor as
     102Also the inflation can be specified on the command line. PDAF uses the so-called forgetting factor, which is a positive value <=1.0 (the ensemble variance is inflated by the inverse of the forgetting factor). One can specify the forgetting factor as
    112103{{{
    113104./PDAF_offline -forget 0.9
    114105}}}
    115 All the different options can be combined. For a complete list of possible options, see the file `init_pdaf_offline.F90`, which is the source code file in which the default values of options are specified.
     106All the different options can be combined. For a complete list of possible options, see the file `mod_assimilate.F90`, which is the source code file in which the default values of options are declared and explained.
    116107
    117108
     
    120111== Second Test Case - A Sequence of Analysis Steps ==
    121112
    122 As a second test case, we recommend to look at the tutorial online_2D_serialmodel.
     113As a second test case, we recommend to look at the tutorial `online_2D_serialmodel`.
    123114This case is again a simple 2D model field, but now coupled to PDAF with
    124 time stepping. This is the so-called online-coupling of PDAF, in which the model code is augmented with data assimilation functionality provided by PDAF. A full description of this test case is provided in the [wiki:PdafTutorial implementation tutorial for the online mode of PDAF].
     115time stepping. This is the so-called ''online coupling'' of PDAF, in which the model code is augmented with data assimilation functionality provided by PDAF. A full description of this test case is provided in the [wiki:PdafTutorial implementation tutorial for the online mode of PDAF].
    125116
    126117=== Compiling ===
     
    131122}}}
    132123and run
    133 {{{
    134 make cleanall PDAF_ARCH=linux_gfortran_openmpi
    135 }}}
    136 and then
    137124{{{
    138125make model_pdaf PDAF_ARCH=linux_gfortran_openmpi
     
    140127This compiles the assimilation program including PDAF. The compilation
    141128should work for computers running Linux, but it requires that OpenMPI
    142 is installed on the computer. If it's not installed, please install it
    143 using the Linux package providing it. If the compilation still fails,
     129is installed on the computer. If it is not installed, please install the Linux package providing it. If the compilation still fails,
    144130please see below the section [#CompilationProblems Compilation Problems].
    145131
     
    148134Having compiled the program, you can just run it by executing
    149135{{{
    150 mpirun -np 9 ./model_pdaf -dim_ens 9
    151 }}}
    152 The program computes a sequence of 9 analysis steps with two model time
    153 steps in between subsequent analysis steps. The initial ensemble are read from the directory `tutorial/inputs_online/`, where also the observation files are stored. The assimilation uses of the
     136mpirun -np 5 ./model_pdaf -dim_ens 5
     137}}}
     138The program computes a sequence of 9 analysis steps with of forecase phase of 2 time steps (thus two model time steps are computed in between subsequent analysis steps). The initial ensemble files are read from the directory `tutorial/inputs_online/`, where also the observation files are stored. The assimilation uses of the
    154139ensemble Kalman filter ESTKF. It should not take more than a few seconds.
    155 The program generates the
    156 output files
    157 `state_stepX_ana.txt` (The analysis state at time step X)
    158 and
    159 `ens_01_stepX_ana.txt` to `ens_09_stepX_ana.txt` (the analysis ensemble at time step X)
    160 `ens_01_stepX_for.txt to `ens_09_stepX_for.txt` (the forecast ensemble at time step X)
     140The program generates the output files
     141* `state_stepX_ana.txt` (the analysis state at time step X)
     142* `ens_01_stepX_ana.txt` to `ens_09_stepX_ana.txt` (the analysis ensemble at time step X)
     143* `ens_01_stepX_for.txt` to `ens_09_stepX_for.txt` (the forecast ensemble at time step X)
    161144
    162145=== Plotting ===
     
    167150inputs_online/
    168151
    169 To plot the analysis field at time step 10, you can do
    170 {{{
    171 load state_step10_ana.txt
    172 pcolor(state_step10_ana)
    173 }}}
    174 You can also plot the initial model field by
    175 {{{
    176 cd ../inputs_online
    177 load state_ini.txt
    178 pcolor(state_ini)
    179 }}}
    180 The directory `inputs_online/` also contains files for the true state at time steps 1 to 18.
    181 For example, you can plot the true state at time step 15, with
    182 {{{
    183 load true_step15.txt
    184 pcolor(true_step15)
    185 }}}
    186 Analogously you can plot the observations (`obs_stepX.txt`) with time step X. In the
    187 observation file, observation gaps are indiced by the value -999.0. So
    188 to get a meaningful plot, you can specify the limits for the color map by
    189 {{{
    190 set(gca,'clim',[-2 2])
    191 }}}
     152You can plot using Python with, for example
     153{{{
     154import numpy as np
     155import matplotlib.pyplot as plt
     156
     157file = 'state_step10_ana.txt'
     158
     159field = np.loadtxt(file)
     160
     161plt.pcolor(field)
     162plt.show()
     163}}}
     164
     165Analogously, you can also plot the initial model field `state_ini.txt`, the true state (`true_stepX.txt`), or observations (`obs_stepX.txt`) with X the time step.
    192166
    193167
    194168=== Assimilation Options ===
    195169
    196 The same options as for the first test case can be used here, too. In addition, one can specify the
    197 forecast length (number of time steps between two analysis steps by
     170The same options as for the first test case can be used here, too.
     171
     172In addition, one can specify the
     173forecast length (number of time steps between two analysis steps) by
    198174{{{
    199175mpirun -np 9 ./model_pdaf -dim_ens 9 -delt_obs 6