Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DART-WRF
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DataAssimilation
DART-WRF
Commits
a14aa337
Commit
a14aa337
authored
2 years ago
by
lkugler
Browse files
Options
Downloads
Patches
Plain Diff
.
parent
7aee5064
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/source/tutorial1.ipynb
+16
-133
16 additions, 133 deletions
docs/source/tutorial1.ipynb
with
16 additions
and
133 deletions
docs/source/tutorial1.ipynb
+
16
−
133
View file @
a14aa337
{
{
"cells": [
"cells": [
{
{
"cell_type": "markdown",
"cell_type": "code",
"id": "fd5c3005-f237-4495-9185-2d4d474cafd5",
"execution_count": 1,
"metadata": {},
"id": "59276951-d31b-4c5d-bca3-fac762e663cc",
"source": [
"\n",
"# Tutorial 1: The assimilation step\n",
"DART-WRF is a python package which automates many things like configuration, saving configuration and output, handling computing resources, etc.\n",
"\n",
"The data for this experiment is accessible for students on the server srvx1.\n"
]
},
{
"cell_type": "markdown",
"id": "93d59d4d-c514-414e-81fa-4ff390290811",
"metadata": {},
"source": [
"### Configuring the experiment\n",
"Firstly, you need to configure the experiment in `config/cfg.py`.\n",
"\n",
"Let's go through the most important settings:\n",
"\n",
"- expname should be a unique identifier and will be used as folder name\n",
"- model_dx is the model resolution in meters\n",
"- n_ens is the ensemble size\n",
"- update_vars are the WRF variables which shall be updated by the assimilation\n",
"- filter_kind is 1 for the EAKF (see the DART documentation for more)\n",
"- prior and post_inflation defines what inflation we want (see the DART docs)\n",
"- sec is the statistical sampling error correction from Anderson (2012)\n",
"\n",
"```python\n",
"exp = utils.Experiment()\n",
"exp.expname = \"test_newcode\"\n",
"exp.model_dx = 2000\n",
"exp.n_ens = 10\n",
"exp.update_vars = ['U', 'V', 'W', 'THM', 'PH', 'MU', 'QVAPOR', 'QCLOUD', 'QICE', 'PSFC']\n",
"exp.filter_kind = 1\n",
"exp.prior_inflation = 0\n",
"exp.post_inflation = 4\n",
"exp.sec = True\n",
"\n",
"```\n",
"In case you want to generate new observations like for an observing system simulations experiment, OSSE), set \n",
"```python\n",
"exp.use_existing_obsseq = False`.\n",
"```\n",
"\n",
"`exp.nature` defines which WRF files will be used to draw observations from, e.g.: \n",
"```python\n",
"exp.nature = '/users/students/lehre/advDA_s2023/data/sample_nature/'\n",
"```\n",
"\n",
"`exp.input_profile` is used, if you create initial conditions from a so called wrf_profile (see WRF guide).\n",
"```python\n",
"exp.input_profile = '/doesnt_exist/initial_profiles/wrf/ens/raso.fc.<iens>.wrfprof'\n",
"```\n",
"\n",
"\n",
"For horizontal localization half-width of 20 km and 3 km vertically, set\n",
"```python\n",
"exp.cov_loc_vert_km_horiz_km = (3, 20)\n",
"```\n",
"You can also set it to False for no vertical localization.\n",
"\n",
"#### Single observation\n",
"Set your desired observations like this. \n",
"```python\n",
"t = dict(plotname='Temperature', plotunits='[K]',\n",
" kind='RADIOSONDE_TEMPERATURE', \n",
" n_obs=1, # number of observations\n",
" obs_locations=[(45., 0.)], # location of observations\n",
" error_generate=0.2, # observation error used to generate observations\n",
" error_assimilate=0.2, # observation error used for assimilation\n",
" heights=[1000,], # for radiosondes, use range(1000, 17001, 2000)\n",
" cov_loc_radius_km=50) # horizontal localization half-width\n",
"\n",
"exp.observations = [t,] # select observations for assimilation\n",
"```\n",
"\n",
"#### Multiple observations\n",
"To generate a grid of observations, use\n",
"```python\n",
"vis = dict(plotname='VIS 0.6µm', plotunits='[1]',\n",
" kind='MSG_4_SEVIRI_BDRF', sat_channel=1, \n",
" n_obs=961, obs_locations='square_array_evenly_on_grid',\n",
" error_generate=0.03, error_assimilate=0.03,\n",
" cov_loc_radius_km=20)\n",
"```\n",
"\n",
"But caution, n_obs should only be one of the following:\n",
"\n",
"- 22500 for 2km observation density/resolution \n",
"- 5776 for 4km; \n",
"- 961 for 10km; \n",
"- 256 for 20km; \n",
"- 121 for 30km\n",
"\n",
"For vertically resolved data, like radar, n_obs is the number of observations at each observation height level."
]
},
{
"cell_type": "markdown",
"id": "16bd3521-f98f-4c4f-8019-31029fd678ae",
"metadata": {},
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['/mnt/users/staff/lkugler/AdvDA23/DART-WRF/docs/source', '/home/swd/manual/nwp/2023.1/lib/python310.zip', '/home/swd/manual/nwp/2023.1/lib/python3.10', '/home/swd/manual/nwp/2023.1/lib/python3.10/lib-dynload', '', '/users/staff/lkugler/.local/lib/python3.10/site-packages', '/home/swd/manual/nwp/2023.1/lib/python3.10/site-packages']\n"
]
}
],
"source": [
"source": [
"### Configuring the hardware\n",
"# Test\n",
"In case you use a cluster which is not supported, configure paths inside `config/clusters.py`.\n",
"import os, sys\n",
"\n",
"print(sys.path)"
"\n",
"\n",
"\n",
"### Assimilate observations\n",
"We start by importing some modules:\n",
"```python\n",
"import datetime as dt\n",
"from dartwrf.workflows import WorkFlows\n",
"```\n",
"\n",
"To assimilate observations at dt.datetime `time` we set the directory paths and times of the prior ensemble forecasts:\n",
"\n",
"```python\n",
"prior_path_exp = '/users/students/lehre/advDA_s2023/data/sample_ensemble/'\n",
"prior_init_time = dt.datetime(2008,7,30,12)\n",
"prior_valid_time = dt.datetime(2008,7,30,12,30)\n",
"assim_time = prior_valid_time\n",
"```\n",
"\n",
"Finally, we run the data assimilation by calling\n",
"```python\n",
"w = WorkFlows(exp_config='cfg.py', server_config='srvx1.py')\n",
"\n",
"w.assimilate(assim_time, prior_init_time, prior_valid_time, prior_path_exp)\n",
"```\n",
"\n",
"Congratulations! You're done!"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": null,
"execution_count": null,
"id": "
82e809a8-5972-47f3-ad78-6290afe4ae17
",
"id": "
feeeb389-8ec6-4186-8abd-d10a0c715e63
",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": []
"source": []
...
...
%% Cell type:
markdown id:fd5c3005-f237-4495-9185-2d4d474cafd5
tags:
%% Cell type:
code id:59276951-d31b-4c5d-bca3-fac762e663cc
tags:
```
python
# Tutorial 1: The assimilation step
# Test
DART-WRF is a python package which automates many things like configuration, saving configuration and output, handling computing resources, etc.
import
os
,
sys
print
(
sys
.
path
)
The data for this experiment is accessible for students on the server srvx1.
%% Cell type:markdown id:93d59d4d-c514-414e-81fa-4ff390290811 tags:
### Configuring the experiment
Firstly, you need to configure the experiment in
`config/cfg.py`
.
Let's go through the most important settings:
-
expname should be a unique identifier and will be used as folder name
-
model_dx is the model resolution in meters
-
n_ens is the ensemble size
-
update_vars are the WRF variables which shall be updated by the assimilation
-
filter_kind is 1 for the EAKF (see the DART documentation for more)
-
prior and post_inflation defines what inflation we want (see the DART docs)
-
sec is the statistical sampling error correction from Anderson (2012)
```
python
exp
=
utils
.
Experiment
()
exp
.
expname
=
"
test_newcode
"
exp
.
model_dx
=
2000
exp
.
n_ens
=
10
exp
.
update_vars
=
[
'
U
'
,
'
V
'
,
'
W
'
,
'
THM
'
,
'
PH
'
,
'
MU
'
,
'
QVAPOR
'
,
'
QCLOUD
'
,
'
QICE
'
,
'
PSFC
'
]
exp
.
filter_kind
=
1
exp
.
prior_inflation
=
0
exp
.
post_inflation
=
4
exp
.
sec
=
True
```
In case you want to generate new observations like for an observing system simulations experiment, OSSE), set
```
python
exp
.
use_existing_obsseq
=
False
`
.
```
`exp.nature`
defines which WRF files will be used to draw observations from, e.g.:
```
python
exp
.
nature
=
'
/users/students/lehre/advDA_s2023/data/sample_nature/
'
```
`exp.input_profile`
is used, if you create initial conditions from a so called wrf_profile (see WRF guide).
```
python
exp
.
input_profile
=
'
/doesnt_exist/initial_profiles/wrf/ens/raso.fc.<iens>.wrfprof
'
```
For horizontal localization half-width of 20 km and 3 km vertically, set
```
python
exp
.
cov_loc_vert_km_horiz_km
=
(
3
,
20
)
```
You can also set it to False for no vertical localization.
#### Single observation
Set your desired observations like this.
```
python
t
=
dict
(
plotname
=
'
Temperature
'
,
plotunits
=
'
[K]
'
,
kind
=
'
RADIOSONDE_TEMPERATURE
'
,
n_obs
=
1
,
# number of observations
obs_locations
=
[(
45.
,
0.
)],
# location of observations
error_generate
=
0.2
,
# observation error used to generate observations
error_assimilate
=
0.2
,
# observation error used for assimilation
heights
=
[
1000
,],
# for radiosondes, use range(1000, 17001, 2000)
cov_loc_radius_km
=
50
)
# horizontal localization half-width
exp
.
observations
=
[
t
,]
# select observations for assimilation
```
#### Multiple observations
To generate a grid of observations, use
```
python
vis
=
dict
(
plotname
=
'
VIS 0.6µm
'
,
plotunits
=
'
[1]
'
,
kind
=
'
MSG_4_SEVIRI_BDRF
'
,
sat_channel
=
1
,
n_obs
=
961
,
obs_locations
=
'
square_array_evenly_on_grid
'
,
error_generate
=
0.03
,
error_assimilate
=
0.03
,
cov_loc_radius_km
=
20
)
```
But caution, n_obs should only be one of the following:
-
22500 for 2km observation density/resolution
-
5776 for 4km;
-
961 for 10km;
-
256 for 20km;
-
121 for 30km
For vertically resolved data, like radar, n_obs is the number of observations at each observation height level.
%% Cell type:markdown id:16bd3521-f98f-4c4f-8019-31029fd678ae tags:
### Configuring the hardware
In case you use a cluster which is not supported, configure paths inside
`config/clusters.py`
.
### Assimilate observations
We start by importing some modules:
```
python
import
datetime
as
dt
from
dartwrf.workflows
import
WorkFlows
```
To assimilate observations at dt.datetime
`time`
we set the directory paths and times of the prior ensemble forecasts:
```
python
prior_path_exp
=
'
/users/students/lehre/advDA_s2023/data/sample_ensemble/
'
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
%% Output
```
python
w
=
WorkFlows
(
exp_config
=
'
cfg.py
'
,
server_config
=
'
srvx1.py
'
)
w
.
assimilate
(
assim_time
,
prior_init_time
,
prior_valid_time
,
prior_path_exp
)
```
Congratulations! You're done!
['/mnt/users/staff/lkugler/AdvDA23/DART-WRF/docs/source', '/home/swd/manual/nwp/2023.1/lib/python310.zip', '/home/swd/manual/nwp/2023.1/lib/python3.10', '/home/swd/manual/nwp/2023.1/lib/python3.10/lib-dynload', '', '/users/staff/lkugler/.local/lib/python3.10/site-packages', '/home/swd/manual/nwp/2023.1/lib/python3.10/site-packages']
%% Cell type:code id:
82e809a8-5972-47f3-ad78-6290afe4ae17
tags:
%% Cell type:code id:
feeeb389-8ec6-4186-8abd-d10a0c715e63
tags:
```
python
```
python
```
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment