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

.

parent 437b4111
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id:fd5c3005-f237-4495-9185-2d4d474cafd5 tags: %% Cell type:markdown id:fd5c3005-f237-4495-9185-2d4d474cafd5 tags:
# Tutorial 2: Forecast after DA # Tutorial 2: Forecast after DA
**Goal**: To run an ensemble of forecasts. **Goal**: To run an ensemble of forecasts.
[free_forecast.py ](https://github.com/lkugler/DART-WRF/blob/master/free_forecast.py) contains examples. [free_forecast.py ](https://github.com/lkugler/DART-WRF/blob/master/free_forecast.py) contains examples.
Initialize the forecast with either (1) or (2). Run the forecast with (3) Initialize the forecast with either (1) or (2). Run the forecast with (3)
1) Initialize a forecast from defined profiles of temperature, humidity and wind, i.e. from a `wrf_profile` (see WRF guide) 1) Initialize a forecast from defined profiles of temperature, humidity and wind, i.e. from a `wrf_profile` (see WRF guide)
2) Initialize a forecast from an existing forecast, i.e. from WRF restart files - optionally with updates from data assimilation. 2) Initialize a forecast from an existing forecast, i.e. from WRF restart files - optionally with updates from data assimilation.
3) Run the forecast 3) Run the forecast
### 1) Initialize from sounding profiles ### 1) Initialize from sounding profiles
It is necessary to set the path to the prepared WRF input soundings in `config/cfg.py` like this It is necessary to set the path to the prepared WRF input soundings in `config/cfg.py` like this
```python ```python
exp.input_profile = '/user/test/data/initial_profiles/wrf/ens/raso.fc.<iens>.wrfprof' exp.input_profile = '/users/students/lehre/advDA_s2023/data/initial_profiles/raso.fc.<iens>.wrfprof'
``` ```
where `<iens>` is a placeholder, since there is one file for each member, from `raso.fc.001.wrfprof` to `raso.fc.040.wrfprof`. where `<iens>` is a placeholder, since there is one file for each member, from `raso.fc.001.wrfprof` to `raso.fc.040.wrfprof`.
Then, we set up the workflows as usual and prepare the input profiles using `prepare_WRFrundir`. Then, we set up the workflows as usual and prepare the input profiles.
```python ```python
import datetime as dt import datetime as dt
from dartwrf.workflows import WorkFlows from dartwrf.workflows import WorkFlows
w = WorkFlows(exp_config='cfg.py', server_config='srvx1.py') w = WorkFlows(exp_config='cfg.py', server_config='srvx1.py')
begin = dt.datetime(2008, 7, 30, 7) begin = dt.datetime(2008, 7, 30, 7)
w.prepare_WRFrundir(begin) w.prepare_WRFrundir(begin)
``` ```
Finally, the WRF's ideal.exe program is called for all ensemble members to create initial condition files, called `wrfinput_d01`, for each member. Finally, the WRF's ideal.exe program is called for all ensemble members to create initial condition files, called `wrfinput_d01`, for each member.
```python ```python
w.run_ideal() w.run_ideal()
``` ```
Now we can go to step 3 to run the forecast. Now we can go to step 3 to run the forecast.
### 2) Initialize a forecast from a previous forecast ### 2) Initialize a forecast from a previous forecast
To run a forecast from initial conditions of a previous forecasts, we import these modules To run a forecast from initial conditions of a previous forecasts, we import these modules
```python ```python
import datetime as dt import datetime as dt
from dartwrf.workflows import WorkFlows from dartwrf.workflows import WorkFlows
``` ```
Let's say you want to run a forecast starting at 9 UTC until 12 UTC. Let's say you want to run a forecast starting at 9 UTC until 12 UTC.
Initial conditions shall be taken from a previous experiment in `/user/test/data/sim_archive/exp_abc` which was initialized at 6 UTC and there are WRF restart files for 9 UTC. Initial conditions shall be taken from a previous experiment in `/user/test/data/sim_archive/exp_abc` which was initialized at 6 UTC and there are WRF restart files for 9 UTC.
Then the code would be Then the code would be
```python ```python
prior_path_exp = '/user/test/data/sim_archive/exp_abc' prior_path_exp = '/user/test/data/sim_archive/exp_abc'
prior_init_time = dt.datetime(2008,7,30,6) prior_init_time = dt.datetime(2008,7,30,6)
prior_valid_time = dt.datetime(2008,7,30,9) prior_valid_time = dt.datetime(2008,7,30,9)
w = WorkFlows(exp_config='cfg.py', server_config='srvx1.py') w = WorkFlows(exp_config='cfg.py', server_config='srvx1.py')
begin = dt.datetime(2008, 7, 30, 9) begin = dt.datetime(2008, 7, 30, 9)
end = dt.datetime(2008, 7, 30, 12) end = dt.datetime(2008, 7, 30, 12)
w.prepare_WRFrundir(begin) w.prepare_WRFrundir(begin)
w.prepare_IC_from_prior(prior_path_exp, prior_init_time, prior_valid_time) w.prepare_IC_from_prior(prior_path_exp, prior_init_time, prior_valid_time)
``` ```
#### 2b) Optional: Update posterior with increments from assimilation #### 2b) Optional: Update posterior with increments from assimilation
In order to continue a forecast after assimilation you need the posterior = prior (1) + increments (2) In order to continue a forecast after assimilation you need the posterior = prior (1) + increments (2)
1. Prepare initial conditions from a prior forecast: 1. Prepare initial conditions from a prior forecast:
```python ```python
id = w.prepare_IC_from_prior(prior_path_exp, prior_init_time, prior_valid_time, depends_on=id) w.prepare_IC_from_prior(prior_path_exp, prior_init_time, prior_valid_time)
``` ```
2. Update the initial conditions from data assimilation: 2. Update the initial conditions from data assimilation:
```python ```python
id = w.update_IC_from_DA(time, depends_on=id) w.update_IC_from_DA(time)
``` ```
After this, the wrfrst files are updated with assimilation increments from DART output and copied to the WRF's run directories so you can continue to run the forecast ensemble. After this, the wrfrst files are updated with assimilation increments from DART output and copied to the WRF's run directories so you can continue to run the forecast ensemble.
### 3) Run the forecast ### 3) Run the forecast
Define how long you want to run the forecast and when you want WRF-restart files. Since they take a lot of space, we want as few as possible. Define how long you want to run the forecast and when you want WRF-restart files. Since they take a lot of space, we want as few as possible.
```python ```python
timedelta_integrate = dt.timedelta(hours=5) timedelta_integrate = dt.timedelta(hours=5)
w.run_ENS(begin=begin, # start integration from here w.run_ENS(begin=begin, # start integration from here
end=time + timedelta_integrate, # integrate until here end=time + timedelta_integrate, # integrate until here
output_restart_interval=9999, # do not write WRF restart files output_restart_interval=9999, # do not write WRF restart files
) )
``` ```
If you want to assimilate in 15 minutes again, use If you want to assimilate in 15 minutes again, use
```python ```python
timedelta_integrate = dt.timedelta(hours=5) timedelta_integrate = dt.timedelta(hours=5)
timedelta_btw_assim = dt.timedelta(minutes=15) timedelta_btw_assim = dt.timedelta(minutes=15)
output_restart_interval = timedelta_btw_assim.total_seconds()/60 output_restart_interval = timedelta_btw_assim.total_seconds()/60
id = w.run_ENS(begin=time, # start integration from here w.run_ENS(begin=time, # start integration from here
end=time + timedelta_integrate, # integrate until here end=time + timedelta_integrate, # integrate until here
output_restart_interval=output_restart_interval output_restart_interval=output_restart_interval
) )
``` ```
%% Cell type:code id:400244f1-098b-46ea-b29d-2226c7cbc827 tags: %% Cell type:code id:400244f1-098b-46ea-b29d-2226c7cbc827 tags:
``` python ``` python
``` ```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment