Skip to content
Snippets Groups Projects
Commit b2eadf7f authored by lkugler's avatar lkugler
Browse files

docs

parent 4d95a02a
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id:fd5c3005-f237-4495-9185-2d4d474cafd5 tags:
# Tutorial 1: The assimilation step
DART-WRF is a python package which automates many things like configuration, saving configuration and output, handling computing resources, etc.
**Goal**: Using a predefined configuration file, run an example of Data Assimilation.
**What you need to know**:
- There is a config/ folder with experimental configuration in config/cfg.py.
- There is an example script analysis_only.py which handles the DA programs.
**To-Do**:
- Go into the DART-WRF folder that we created and installed last time.
- Copy the configuration file from `` to your config/ folder.
%% Cell type:code id:400244f1-098b-46ea-b29d-2226c7cbc827 tags:
%% Cell type:markdown id:24b23d8c-29e6-484c-ad1f-f2bc07e66c66 tags:
We start by importing some modules:
```python
import os, sys, shutil
import datetime as dt
from dartwrf import utils
from config.cfg import exp
from config.clusters import cluster
```
Then, we set the directory paths and times of the prior ensemble forecasts:
```python
prior_path_exp = '/mnt/jetfs/scratch/lkugler/data/sim_archive/exp_v1.19_P3_wbub7_noDA'
prior_init_time = dt.datetime(2008,7,30,12)
prior_valid_time = dt.datetime(2008,7,30,12,30)
assim_time = prior_valid_time
```
Finally, we run the data assimilation by calling
```python
cluster.setup()
os.system(
cluster.python+' '+cluster.scripts_rundir+'/assim_synth_obs.py '
+assim_time.strftime('%Y-%m-%d_%H:%M ')
+prior_init_time.strftime('%Y-%m-%d_%H:%M ')
+prior_valid_time.strftime('%Y-%m-%d_%H:%M ')
+prior_path_exp
)
create_satimages(time)
```
Congratulations! You're done!
%% Cell type:markdown id:31b23faf-0986-407f-b07f-d635a71ec2c6 tags:
---
#### Queueing systems
Note: In case you have to use a queueing system, use the builtin job scheduler, e.g.:
```python
id = cluster.create_job("Assim",
cfg_update={"ntasks": "12", "time": "60", "mem": "200G",
"ntasks-per-node": "12", "ntasks-per-core": "2"}
).run(cluster.python+' '+cluster.scripts_rundir+'/assim_synth_obs.py '
+assim_time.strftime('%Y-%m-%d_%H:%M ')
+prior_init_time.strftime('%Y-%m-%d_%H:%M ')
+prior_valid_time.strftime('%Y-%m-%d_%H:%M ')
+prior_path_exp, depends_on=[depends_on])
```
where `depends_on` is either `None` or `int` (a previous job's SLURM id).
%% Cell type:code id:82e809a8-5972-47f3-ad78-6290afe4ae17 tags:
``` python
```
......
%% Cell type:markdown id:fd5c3005-f237-4495-9185-2d4d474cafd5 tags:
# Tutorial 2: Cycled experiment
**Goal**: To run a cycled data assimilation experiment.
[`cycled_exp.py`](https://github.com/lkugler/DART-WRF/blob/master/generate_free.py) contains an example which will be explained here:
#### Configure your experiment
See tutorial 1.
#### Prepare initial conditions (from input_sounding)
1) Define starting time:
`begin = dt.datetime(2008, 7, 30, 6)`
2) WRF needs directories with certain files:
`id = prepare_WRFrundir(begin)`
3) Create 3D initial conditions from input_sounding etc.:
`id = run_ideal(depends_on=id)`
#### Run free forecast
Let's say you want to run a free forecast starting at 6z, which you want to use as prior for an assimilation at 9z. Then you need can use the above defined 3 steps to create initial conditions.
Then you can run an ensemble forecast using:
```
#### Prepare initial conditions from previous forecasts
Before starting, let's set up the directory structure with
```python
begin = dt.datetime(2008, 7, 30, 6)
prepare_WRFrundir(begin)
```
#### Run a forecast
Let's say you
- want to run a forecast starting at 6 UTC until 12 UTC
- do not want WRF restart files
then the required code is
```python
begin = dt.datetime(2008, 7, 30, 6)
end = dt.datetime(2008, 7, 30, 12)
id = run_ENS(begin=begin, # start integration from here
end=end, # integrate until here
input_is_restart=False,
output_restart_interval=(end-begin).total_seconds()/60,
output_restart_interval=9999, # do not write WRF restart files
depends_on=id)
```
where `begin` & `end` are `dt.datetime` objects.
Note that `begin` and `end` are `dt.datetime` objects.
#### Assimilate
To assimilate observations at dt.datetime `time` use this command:
`id = assimilate(time, prior_init_time, prior_valid_time, prior_path_exp, depends_on=id)`
#### Update initial conditions from Data Assimilation
In order to continue after assimilation you need the posterior = prior (1) + increments (2)
1. Set prior with this function:
`id = prepare_IC_from_prior(prior_path_exp, prior_init_time, prior_valid_time, depends_on=id)`
where path is `str`, times are `dt.datetime`.
2. To update the model state with assimilation increments, you need to update the WRF restart files by running
`id = update_IC_from_DA(time, depends_on=id)`
After this, the wrfrst files are updated with assimilation increments (filter_restart) and copied to the WRF's run directories so you can continue to run the ENS after assimilation using
After this, the wrfrst files are updated with assimilation increments (filter_restart) and copied to the WRF's run directories so you can continue to run the ENS after assimilation using function `run_ENS()`.
#### Cycled data assimilation code
Then the loop looks like
```
id = run_ENS(begin=time, # start integration from here
end=time + timedelta_integrate, # integrate until here
restart_path=cluster.archivedir+prior_init_time.strftime('/%Y-%m-%d_%H:%M/'),
output_restart_interval=timedelta_btw_assim.total_seconds()/60,
depends_on=id)
```
where times are `dt.datetime`; `timedelta` variables are `dt.timedelta`.
#### Job scheduling status
The script submits jobs into the SLURM queue with dependencies so that SLURM starts the jobs itself as soon as resources are available. Most jobs need only a few cores, but model integration is done across many nodes:
```
```bash
$ squeue -u `whoami` --sort=i
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
1710274 mem_0384 prepwrfr lkugler PD 0:00 1 (Priority)
1710275 mem_0384 IC-prior lkugler PD 0:00 1 (Dependency)
1710276 mem_0384 Assim-42 lkugler PD 0:00 1 (Dependency)
1710277 mem_0384 IC-prior lkugler PD 0:00 1 (Dependency)
1710278 mem_0384 IC-updat lkugler PD 0:00 1 (Dependency)
1710279 mem_0384 preWRF2- lkugler PD 0:00 1 (Dependency)
1710280_[1-10] mem_0384 runWRF2- lkugler PD 0:00 1 (Dependency)
1710281 mem_0384 pRTTOV-6 lkugler PD 0:00 1 (Dependency)
1710282 mem_0384 Assim-3a lkugler PD 0:00 1 (Dependency)
1710283 mem_0384 IC-prior lkugler PD 0:00 1 (Dependency)
1710284 mem_0384 IC-updat lkugler PD 0:00 1 (Dependency)
1710285 mem_0384 preWRF2- lkugler PD 0:00 1 (Dependency)
1710286_[1-10] mem_0384 runWRF2- lkugler PD 0:00 1 (Dependency)
1710287 mem_0384 pRTTOV-7 lkugler PD 0:00 1 (Dependency)
```
%% Cell type:code id:400244f1-098b-46ea-b29d-2226c7cbc827 tags:
``` python
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment