Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Computer Resources
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Monitor
Service Desk
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
IMGW
Computer Resources
Commits
389487d6
Commit
389487d6
authored
2 years ago
by
Stefano Serafin
Browse files
Options
Downloads
Patches
Plain Diff
WRF.md added TOC entries + basic Python class
parent
d1ad2741
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
WRF.md
+49
-0
49 additions, 0 deletions
WRF.md
with
49 additions
and
0 deletions
WRF.md
+
49
−
0
View file @
389487d6
...
...
@@ -12,6 +12,7 @@
*
[
Running WRF in a software container
](
#
)
*
[
Running an idealized simulation
](
#
)
*
[
Running a real-case simulation
](
#
)
*
[
Output and restart files
](
#
)
*
[
Suggested workflow
](
#
)
*
[
Analysing model output
](
#
)
*
[
Important namelist settings
](
#
)
...
...
@@ -344,12 +345,60 @@ then you have a problem, and there is no unique solution. Take a closer look at
## Running a real-case simulation
## Output and restart files
incl. how to modify output paths
## Suggested workflow
## 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/)
Example of a very basic Python class to create an object from a WRF run, initialized with only some basic information:
```
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:
```
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
# Advanced usage
...
...
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