...
- All data is in NetCDF format
- The script requires Python and the ECMWF WebAPI to access ECMWF public datasets
The script only works correctly for ECMWF ERA-Interim data, do not use it with other datasets
Input data has to be gridded, not spectral
Get input data
For this use case, To compute geopotential on model levels you need both temperature (t) and Specific specific humidity (q) for each model level. You also need both surface geopotential (z) and logarithm of surface pressure (lnsp) for model level = 1. In the two scripts below you
The scripts below downloads all this data from ECMWF, generating two output files. You can change date, time, type, step and gridType, time, grid and area in the script, but make sure you use the same values in both scripts, i.e. the blocks so that the two output files are synchronized. Later the calculation of geopotential will iterate through the date/time/step parameters, allowing you to get the calculating values for multiple times.
First get temperature (t) and Specific humidity (q), using the ECMWF Web API:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
#!/usr/bin/env python from ecmwfapi import ECMWFDataServer server = ECMWFDataServer() server.retrieve({ "class": "ei", "dataset": "interim", "dateexpver": "2015-08-011", "expverlevelist": "1all", "streamlevtype": "operml", "typeparam": "ant/q", "gridstream": "0.75/0.75", "levtype": "ml", "levelist": "all", "param": "t/q", "time": "0", "step": "0", oper", "date": "2015-08-01", #date: Specify a single date as "2015-08-01" or a period as "2015-08-01/to/2015-08-31". "type": "an", #type: Use an (analysis) unless you have a particular reason to use fc (forecast). "time": "00:00:00", #time: With type=an, time can be any of "00:00:00/06:00:00/12:00:00/18:00:00". With type=fc, time can be any of "00:00:00/12:00:00", "step": "0", #step: With type=an, step is always "0". With type=fc, step can be any of "3/6/9/12". "grid": "0.75/0.75", #grid: Only regular lat/lon grids are supported. "area": "75/-20/10/60", #area: N/W/S/E, here we have Europe. "format": "netcdf", "target": "tq_ml.nc", }) | ||||||
Code Block | ||||||
| ||||||
#!/usr/bin/env python from ecmwfapi import ECMWFDataServer server = ECMWFDataServer() #target: the name of the output file. }) server.retrieve({ "class": "ei", "dataset": "interim", "date "expver": "2016-12-011", "expver "levelist": "1", "stream "levtype": "ml", "param": "operz/lnsp", "typestream": "anoper", "griddate": "0.75/0.75", "levtype2015-08-01", "type": "mlan", "levelisttime": "100:00:00", "paramstep": "z/lnsp0", "time "grid": "0.75/0.75", "steparea": "075/-20/10/60", "format": "netcdf", "target": "zlnsp_ml.nc", }) |
Compute geopotential on model levels
...