Skip to content
Snippets Groups Projects
Commit 2e5dc3f4 authored by Michael Blaschek's avatar Michael Blaschek :bicyclist:
Browse files

merged recent changes

parents 8430d16d 389487d6
No related branches found
No related tags found
No related merge requests found
...@@ -324,12 +324,63 @@ then you have a problem, and there is no unique solution. Take a closer look at ...@@ -324,12 +324,63 @@ then you have a problem, and there is no unique solution. Take a closer look at
### Running a real-case simulation ### Running a real-case simulation
### Output and restart files
incl. how to modify output paths
### Suggested workflow ### Suggested workflow
### Analysing model output ### Analysing model output
Things to remember:
* staggered grid (Arakawa-C)
* mass-based vertical coordinate (level height AGL is time-dependent)
* terrain-following coordinate system (curvilinear)
* in the model output, some variables are split into base state + perturbation
[Python interface to WRF](https://wrf-python.readthedocs.io/en/latest/) [Python interface to WRF](https://wrf-python.readthedocs.io/en/latest/)
Example of a very basic Python class to create an object from a WRF run, initialized with only some basic information:
```py
class wrfrun:
def __init__(self, filename):
self.filename = filename
self.nc = netCDF4.Dataset(filename)
self.dx = self.nc.DX
self.dy = self.nc.DY
self.nx = self.nc.dimensions['west_east'].size
self.ny = self.nc.dimensions['south_north'].size
self.x = np.arange(0,self.nx*self.dx,self.dx)
self.y = np.arange(0,self.ny*self.dy,self.dy)
self.valid_times = self.nc['XTIME'][:]*60
self.current_time = 0
def set_time(self,step):
self.current_time = step
def add_wind(self):
udum = self.nc['U'][self.current_time,:,:,:]
vdum = self.nc['V'][self.current_time,:,:,:]
wdum = self.nc['W'][self.current_time,:,:,:]
self.u = 0.5*(udum[:,:,:-1]+udum[:,:,1:])
self.v = 0.5*(vdum[:,:-1,:]+vdum[:,1:,:])
self.w = 0.5*(wdum[:-1,:,:]+wdum[1:,:,:])
del udum,vdum,wdum
```
The last function adds 3D wind variables at a specific time, after destaggering.
The `wrfrun` class is then used as follows:
```py
wrf = wrfrun("./wrfout_d01_0001-01-01_00:00:00")
wrf.set_time(36)
wrf.add_wind()
```
Variables are then accessible as `wrf.u`, `wrf.v` etc.
### Important namelist settings ### Important namelist settings
## Advanced usage ## Advanced usage
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment