source: flex_extract.git/README.md @ 982c91b

ctbtodev
Last change on this file since 982c91b was 3fc6232, checked in by Anne Philipp <anne.philipp@…>, 5 years ago

merged modified README from v7.0.4 into this one

  • Property mode set to 100644
File size: 21.7 KB
Line 
1# flex_extract
2
3`flex_extract` is a software package to support retrieving meteorological fields from the ECMWF MARS archive as input for the `FLEXTRA`/`FLEXPART` Atmospheric Transport Modelling system.
4
5`FLEXPART` (“FLEXible PARTicle dispersion model”) is a Lagrangian transport and dispersion model suitable for the simulation of a large range of atmospheric transport processes.
6
7`FLEXPART` expects GRIB files containing a set of meteorological fields separated by time. The format of these file names look like: `<prefix>YYMMDDHH`, where `<prefix>` can be defined by the user (usually it should be limited to "2" characters because of further processing reasons).
8
9The MARS (Meteorological Archival and Retrieval System) archive from ECMWF saves a number of different data sets, such as the ERA-Interim and ERA 5 reanalysis and the daily operational data. More can be found here: <https://confluence.ecmwf.int/display/UDOC/MARS+content>
10
11To define the data set and its composition of, e.g. time, field types and paramaters, `flex_extract` uses `CONTROL` files to set a number of MARS keywords and `flex_extract` specific control parameters. Detailed description can be found in the documentation and a set of example `CONTROL` files are also distributed with `flex_extract`.
12
13
14
15
16
17## ECMWF DATA
18
19
20There are two modes for accessing ECMWF data sets: the **_full access_** and the **_public access_** mode.
21A description of these two modes and links to the available data sets is available here: https://www.ecmwf.int/en/forecasts/datasets/archive-datasets
22
23####  Important note for public users
24
25If you want to extract public data sets from the ECMWF servers you first have to register at the ECMWF. Do this by following the instructions at: https://software.ecmwf.int/wiki/display/WEBAPI/Access+MARS
26
27Afterwards you **_need to accept the licenses_** of the data sets you want to extract:
28
29https://software.ecmwf.int/wiki/display/WEBAPI/Available+ECMWF+Public+Datasets
30
31Now your able to use `flex_extract` in public mode (command line parameter "*--public=1*").
32
33
34
35
36
37
38## Application modes
39
40There are 4 different modes of running `flex_extract` :
411. Remote (*): ***flex_extract*** is installed and executed directly on the ECMWF Linux member state server ecgate. Users have to be a registered member-state user.
422. Gateway (*): ***flex_extract*** is installed on a local machine and the scripts are submitted to ECMWF
43computer facilities via a member-state gateway server. Users have to be a registered member-state user.
443. Local member state (*): ***flex_extract*** is installed and executed on a local machine. Users have to be a registered member-state user.
454. Local public (**): ***flex_extract*** is installed and executed on a local machine. Users do not have to be a member-state user. A normal registration at the ECMWF website is enough.
46
47*(\*) To get a ms (member-state) user access, users have to be a resident of a [member state](https://www.ecmwf.int/en/about/who-we-are/member-states) and have to contact their national meteorological center for granting access.*
48
49*(\*\*) To get a public user account, the user can just register at the ECMWF website following the instructions [here](https://apps.ecmwf.int/registration/)!*
50
51
52
53
54<!--
55[![NPM Version][npm-image]][npm-url]
56[![Build Status][travis-image]][travis-url]
57[![Downloads Stats][npm-downloads]][npm-url]
58
59
60![](header.png)
61-->
62
63
64
65
66
67
68
69
70## Installation
71
72
73
74### Requirements
75
76
77To run the python part of flex_extract a [Python 3](https://docs.python.org/3/) environment is needed.<br>
78We tested `flex_extract` with a normal Linux Python package distribution and Anaconda Python.
79* [Python3](https://www.python.org/downloads/) or [Anaconda Python 3](https://www.anaconda.com/distribution/#download-section)
80* [numpy](http://www.numpy.org/)
81* [ecmwf-api-client](https://confluence.ecmwf.int/display/WEBAPI/ECMWF+Web+API+Home)
82* [cdsapi](https://cds.climate.copernicus.eu/api-how-to)
83* [genshi](https://genshi.edgewall.org/)
84* [eccodes for python](https://packages.debian.org/sid/python3-eccodes) (e.g. manually from source or from distribution package) or [eccodes for conda](https://anaconda.org/conda-forge/eccodes)
85 
86 For the Fortran part of flex_extract we need:
87 
88 * [gfortran](https://gcc.gnu.org/wiki/GFortran)
89 * [fftw3](http://www.fftw.org)
90 * [eccodes](https://software.ecmwf.int/wiki/display/ECC)
91 * [emoslib](https://software.ecmwf.int/wiki/display/EMOS/Emoslib)
92
93
94
95###  Prepare the environment
96
97
98##### On ecgate
99
100All libraries and software packages needed by flex_extract are already installed on the ECMWF servers. They can be loaded by a module management system. In general, `flex_extract` is managing the correct settings of modules if you submit to the `ecgate` or `cca` queue. If the user works directly on ecgate, he has to assure that a Python3 environment is loaded before starting `flex_extract`.
101
102```bash
103# on ecgate
104module unload python
105module load python3
106```
107
108##### On a local and a gateway machine
109
110The easiest way to install all required packages is to use the package management system of the Linux distribution. If you have any problems with this method, you can ask for support or just try to install specific packages from source.
111
112_We are not describing the installation of a gateway server since this is out of scope. Please see [here](https://confluence.ecmwf.int/display/ECAC/ECaccess+Home)!_
113
114On a Linux Debian or Ubuntu system:
115
116```sh
117# on your local system, do:
118sudo apt -PV install python3
119sudo apt -PV install pip3
120sudo apt -PV install gfortran
121sudo apt -PV install fftw3-dev
122sudo apt -PV install libeccodes-dev
123sudo apt -PV install libemos-dev
124sudo apt -PV install python3-eccodes
125pip3 install cdsapi
126pip3 install ecmwf-api-client
127pip3 install genshi
128pip3 install numpy
129```
130
131Afterwards, check the availability of the python packages:
132```python
133# check in python3 console
134import eccodes
135import cdsapi
136import ecmwfapi
137import genshi
138```
139Additionally, start simple test retrievals for both API's:
140```python
141#!/usr/bin/env python3
142from ecmwfapi import ECMWFDataServer
143   
144server = ECMWFDataServer()
145   
146server.retrieve({
147    'stream'    : "oper",
148    'levtype'   : "sfc",
149    'param'     : "165.128/166.128/167.128",
150    'dataset'   : "interim",
151    'step'      : "0",
152    'grid'      : "0.75/0.75",
153    'time'      : "00/06/12/18",
154    'date'      : "2014-07-01/to/2014-07-31",
155    'type'      : "an",
156    'class'     : "ei",
157    'target'    : "download_ecmwfapi.grib"
158})
159```
160```python
161#!/usr/bin/env python
162import cdsapi
163c = cdsapi.Client()
164c.retrieve("reanalysis-era5-pressure-levels",
165{
166"variable": "temperature",
167"pressure_level": "1000",
168"product_type": "reanalysis",
169"year": "2008",
170"month": "01",
171"day": "01",
172"time": "12:00",
173"format": "grib"
174},
175"download_cdsapi.grib")
176```
177 
178
179
180### Some important notes for a manual installation process:
181- Use the same compiler and compiler version for all libraries and the Fortran program of `flex_extract`.
182- Don't forget to set all library paths to the `LD_LIBRARY_PATH` variable.
183- Don't forget to adapt the makefile for the Fortran program.
184- Please follow the instructions on the websites of the libraries.
185
186For the manual installation of these libraries it is useful to consider the official documentation (and also the hints from the ECMWF) rather than trying to explain every detail in here. Nevertheless, if you have to do the manual installation, we recommend doing the installation in the following order (see links to the libraries in the table above):
187
188
1891. Read `Emoslib` [installation instructions](https://confluence.ecmwf.int/display/EMOS/Installation+Guide).
1902. Read [ECMWF blog about gfortran](https://software.ecmwf.int/wiki/display/SUP/2015/05/11/Building+ECMWF+software+with+gfortran).
1913. [Install `FFTW`](http://www.fftw.org/).
1924. [Install `EMOSLIB`](https://confluence.ecmwf.int/display/EMOS/Emoslib) (Hint: Apply make 2 times! One time without any options and one time with single precision option).
1935. [Install `ECCODES` from source](https://confluence.ecmwf.int/display/ECC/ecCodes+installation) from source (for python and fortran). `ECCODES` is downward compatible with `GRIB_API`. `GRIB_API` support was expire at the end of 2018.
1946. For local usage and as public user, install the ECMWF key by following step 1 [here](https://confluence.ecmwf.int/display/WEBAPI/Access+ECMWF+Public+Datasets).
1957. [Install `ECMWF_Web API.`](https://confluence.ecmwf.int/display/WEBAPI/Access+ECMWF+Public+Datasets#AccessECMWFPublicDatasets-python)
1968. [Install `CDS API.`](https://cds.climate.copernicus.eu/api-how-to)
1979. Check `LD_LIBRARY_PATH `environment variable if it contains all paths to the libs.
19810. Do some tests as listed above.
199
200
201
202
203
204
205### Installation of `flex_extract`
206
207
208To install `flex_extract` you have to first decide which application mode you want to use and then, if you choosed one of the local version, edit the corresponding Makefile for the Fortran programm. Makefiles for ECMWF server are already fixed.
209For example:
210```bash
211cd flex_extract_v7.1/source/fortran
212nedit Makefile.local.gfortran
213```
214Edit the pathes to the ECCODES library on your local machine in this file:
215```sh
216ECCODES_INCLUDE_DIR=/usr/lib/
217ECCODES_LIB= -L/usr/lib -leccodes_f90  -leccodes -lm 
218```
219Now go to the root directory and open the setup.sh file:
220```bash
221cd ../../
222nedit setup.sh
223```
224In this file edit the labelled block for "AVAILABLE COMMANDLINE ARGUMENTS TO SET"
225```bash
226# -----------------------------------------------------------------
227# AVAILABLE COMMANDLINE ARGUMENTS TO SET
228#
229# THE USER HAS TO SPECIFY THESE PARAMETER
230#
231TARGET='ecgate'
232MAKEFILE='Makefile.gfortran'
233ECUID='uid'
234ECGID='gid'
235GATEWAY='server.example.edu'
236DESTINATION='example@genericSftp'
237FLEXPARTDIR=""
238JOB_TEMPLATE="job.template"
239CONTROLFILE="CONTROL_EA5.testgrid"
240```
241
242
243
244
245
246
247
248
249
250```
251./setup.sh
252```
253
254
255On ECMWF servers a makefile named "Makefile.gfortran" is already provided in the "source/fortran"-directory. It is also the default makefile, so that the parameter does not have to be set when calling "install.py".
256
257If the ***flex_extract*** is to be installed within a ***FLEXPART*** environment it should be called with the parameter `flexpart_root_scripts` to let ***flex_extract*** know about the path to ***FLEXPART***.
258
259The installation was successful if the compilation of the Fortran program ``CONVERT2`` didn't fail and is displayed in the terminal.
260
261#### Installation using a gateway server (***flex_extract*** mode 2 only)
262
263---
264
265If the user has a gateway server and the Ecaccess toolkit available, ***flex_extract*** can be installed such that it is executed on the local machine and a job script is submitted to the ECMWF server. The final ***FLEXPART*** input files are then send back via the Ecaccess command line tool "ectrans". To use this tool, the user has to create an association directly on the local gateway server via the localhost ecaccess.ecmwf.int and provide the association name as the "destination"-parameter when calling "install.py".
266
267The gateway server has to be registered at ECMWF. For information about a gateway server see:
268- https://software.ecmwf.int/wiki/display/ECAC/Releases+-+Gateway+package
269- and the Software Installation Plan (SIP.pdf) in the docs/ directory.
270
271Afterwards ***flex_extract*** can be installed with the following command:
272```
273./install.py --target=local --makefile=Makefile.gfortan --ecuid=<id> --ecgid=<gid> --gateway=<servername> --destination=<destinationname>
274```
275
276If the installation was successful the user gets an email with a success note!
277
278
279
280
281## How to use flex_extract
282
283A few motivating and useful examples of how your product can be used. Spice this up with code blocks and potentially more screenshots.
284
285_For more examples and usage, please refer to the [Wiki][wiki]._
286
287
288
289
290This section provides the absolut basics on how ***flex_extract*** is to be used. For more information about possible settings, performance, parameter combinations and so one, the user is referred to the SIP.pdf and SUT.pdf documents and the www.flexpart.eu community website. It is also possible to ask for help by writing to the ***FLEXPART*** user email list (registration needed) or by creating a ticket on the community website.
291
292#### CONTROL file
293
294***flex_extract*** is controlled by providing "CONTROL"-files with a list of parameter settings. These parameter are described in detail in the *Software User Tutorial (SUT.pdf)*.
295The "CONTROL"-files specifies which ECMWF data set is to be retrieved, the time and spatial resolution, the format of the grib file and many more. In the `python` directory are some example `CONTROL` files for the different data sets and access modes which can be retrieved with ***flex_extract***:
296
297```
298CONTROL_CERA
299CONTROL_CV
300CONTROL_EA5.public
301CONTROL_FC.pure
302CONTROL_OD.highres.gauss
303CONTROL_CERA.public
304CONTROL_EA5
305CONTROL_EI.global
306CONTROL_FC.twiceaday
307CONTROL_OPS.4V
308CONTROL_CF
309CONTROL_EA5.highres
310CONTROL_EI.public
311CONTROL_OD.highres.eta
312CONTROL.temp
313```
314
315For information about all the possible parameter settings and explanation, please see the SUT.pdf document in the `docs/` directory.
316
317`CONTROL`-files with a `.public` ending is usable for the public access mode. The main difference is the parameter ``dataset`` which explicitly specifies the public data sets. Additionally, not all meteorological fields and times were archived in the public data sets and are considered in the public `CONTROL`-files.
318
319#### Python scripts
320
321* `submit.py`
322
323This is the main program for doing both, retrieving ECMWF data and generating the ***FLEXPART*** input files. It combines the two sub-programs `getMARSdata.py` and `prepareFLEXPART.py` which can also be run by themselves for debugging purposes.
324Use the `-h` option to get the parameter options:
325
326```
327usage: submit.py [-h] [--start_date START_DATE] [--end_date END_DATE]
328                 [--date_chunk DATE_CHUNK] [--basetime BASETIME] [--step STEP]
329                 [--levelist LEVELIST] [--area AREA] [--inputdir INPUTDIR]
330                 [--outputdir OUTPUTDIR]
331                 [--flexpart_root_scripts FLEXPART_ROOT_SCRIPTS] [--ppid PPID]
332                 [--job_template JOB_TEMPLATE] [--queue QUEUE]
333                 [--controlfile CONTROLFILE] [--debug DEBUG] [--public PUBLIC]
334
335Retrieve FLEXPART input from ECMWF MARS archive
336
337optional arguments:
338  -h, --help            show this help message and exit
339  --start_date START_DATE
340                        start date YYYYMMDD (default: None)
341  --end_date END_DATE   end_date YYYYMMDD (default: None)
342  --date_chunk DATE_CHUNK
343                        # of days to be retrieved at once (default: None)
344  --basetime BASETIME   base such as 00/12 (for half day retrievals) (default:
345                        None)
346  --step STEP           steps such as 00/to/48 (default: None)
347  --levelist LEVELIST   Vertical levels to be retrieved, e.g. 30/to/60
348                        (default: None)
349  --area AREA           area defined as north/west/south/east (default: None)
350  --inputdir INPUTDIR   root directory for storing intermediate files
351                        (default: None)
352  --outputdir OUTPUTDIR
353                        root directory for storing output files (default:
354                        None)
355  --flexpart_root_scripts FLEXPART_ROOT_SCRIPTS
356                        FLEXPART root directory (to find grib2flexpart and
357                        COMMAND file) Normally flex_extract resides in the
358                        scripts directory of the FLEXPART distribution
359                        (default: None)
360  --ppid PPID           Specify parent process id for rerun of prepareFLEXPART
361                        (default: None)
362  --job_template JOB_TEMPLATE
363                        job template file for submission to ECMWF (default:
364                        job.temp)
365  --queue QUEUE         queue for submission to ECMWF (e.g. ecgate or cca )
366                        (default: None)
367  --controlfile CONTROLFILE
368                        file with control parameters (default: CONTROL.temp)
369  --debug DEBUG         Debug mode - leave temporary files intact (default: 0)
370  --public PUBLIC       Public mode - retrieves the public datasets (default:
371                        0)
372```
373
374*Optional arguments are listed in squared brackets.*
375
376
377* `getMARSdata.py`
378
379This program retrieves the ECMWF data from ECMWF servers using [ECMWF WebApi](https://software.ecmwf.int/wiki/display/WEBAPI/ECMWF+Web+API+Home) or [Mars](https://software.ecmwf.int/wiki/display/UDOC/MARS+user+documentation), depending on your user status and your selection of the running mode. It requires the `ECMWF WebApi` python library (see Requirements below). Check with your local IT group as it may be already available.
380
381
382* `prepareFLEXPART.py`
383
384This program generates FLEXPART input files from the retrieved meteorological fields. It requires python interface to grib_api or eccodes and the Fortran program `CONVERT2` (located in `src` directory). `CONVERT2` needs a namelist which is generated from the python program.
385
386
387#### execute flex_extract locally (member-state user)
388
389Almost every command line parameter for the `submit.py` script call has a default value or is read from the specified `CONTROL` file.
390Therefore, for a local extraction of ERA-Interim data as a member-state user the script can be called simply by passing a `CONTROL` file and a starting date with the following command:
391```
392./submit.py --controlfile=CONTROL_EI.global --start_date=20101201
393```
394If there was just a starting date without an end date, ***flex_extract*** retrieves just this one day of meteorological data. The `CONTROL_EI.global` file has a set of default values which needs to be adjusted regarding users needs. It is also possible to set the dates within the `CONTROL`-file instead of passing it via command line parameter.
395
396
397#### execute flex_extract locally (public user)
398
399As a public user one has to use the `CONTROL` file with the `.public` extension and the parameter `public`:
400```
401./submit.py --controlfile=CONTROL_EI.public --start_date=20101201 --public=1
402```
403Otherwise, except of the different data available, the usage of ***flex_extract*** is the same as for member-state users.
404
405#### execute flex_extract via gateway server
406
407If ***flex_extract*** was installed via a gateway server and a file "*ECMWF_ENV*" is available in the ``python``-directory, the ``submit.py`` script can be called with the `--queue` option. A job script is then prepared and submitted to the ECMWF server (in this case, "ecgate") .
408
409```
410./submit.py --queue=ecgate --controlfile=CONTROL_EI.global --start_date=20101201
411```
412
413The job status can then be checked by typing:
414````
415ecaccess-job-list
416````
417
418If the parameters *ecuid*, *ecgid*, *gateway* and *destination* were set correctly during installation and the gateway server is running, the resulting ***FLEXPART*** input files can be directly transferred to the local gateway by setting the paramter ``ectrans`` in the ``CONTROL``-file to ``1``.
419
420Regardless of the job being successful or not, the user will receive an email with the log messages.
421
422
423
424
425## Development setup
426
427install more python modules and run some tests, describe here
428
429Describe how to install all development dependencies and how to run an automated test-suite of some kind. Potentially do this for multiple platforms.
430
431```sh
432make install
433npm test
434```
435
436## Release History
437
438* 7.1
439   * Completely revised/refactored python section
440   * restructured program directories
441   * simplified installation process
442   * CHANGE: upgraded to Python3
443   * CHANGE: applied PEP8 style guide
444   * CHANGE: use of genshi templates
445   * CHANGE: modularization of python source code
446   * CAHNGE: upgrade from grib_api to ecCodes
447   * ADD: first UNIT tests
448   * ADD: some regression tests   
449   * ADD: more detailed documentation
450   * ADD: local retrieval via CDS API for ERA 5 data
451* 7.0.4
452    * FIX: ERA 5 retrieval
453    * FIX: CERA-20C retrieval
454    * FIX: in BASETIME retrieval option
455    * FIX: `CONVERT2` FORTRAN program: initialise fields to 0.
456    * ADD: Ensemble retrieval for ENFO and ELDA stream (ZAMG specific with extra ensembles for ELDA stream)
457* 7.0.3
458    * CHANGE:
459    * ADD: output of mars requests to an extra file
460    * ADD: CERA-20C download
461    * ADD: ERA 5 download
462    * ADD: public user interface with ECMWF Web API
463    * ADD: use of ECMWF Web API for local retrieval version
464* 7.0.2
465    * Python based version
466    * CHANGE: korn shell scripts were substituted by python scripts
467* v0.1 - v6.0
468    * old versions which should no longer be used anymore
469
470# SUPPORT
471
472##### FLEXPART's community website: <http://flexpart.eu>
473
474##### flex_extract information:  [https://www.flexpart.eu/wiki/FpInputMetEcmwf](https://www.flexpart.eu/wiki/FpInputMetEcmwf)
475
476##### Git-repository: <https://www.flexpart.eu/browser/flex_extract.git>
477
478##### Mailing list: [FP-dev(at)lists.univie.ac.at](mailto:fp-dev@lists.univie.ac.at)
479
480##### Ticket system: <https://www.flexpart.eu/report/1>
481
482
483If you have any problems please open a ticket at <http://flexpart.eu> or send an e-mail to: <br>
484 [FP-dev(at)lists.univie.ac.at](mailto:fp-dev@lists.univie.ac.at)
485
486
487
488
489# COPYRIGHT AND LICENSE
490 &copy; Copyright 2014-2019.
491 Anne Philipp and Leopold Haimberger
492 
493<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />
494
495 This work is licensed under the <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>. <br />
496 To view a copy of this license, visit  http://creativecommons.org/licenses/by/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
497
498
499<!--
500[npm-image]: https://img.shields.io/npm/v/datadog-metrics.svg?style=flat-square
501[npm-url]: https://npmjs.org/package/datadog-metrics
502[npm-downloads]: https://img.shields.io/npm/dm/datadog-metrics.svg?style=flat-square
503[travis-image]: https://img.shields.io/travis/dbader/node-datadog-metrics/master.svg?style=flat-square
504[travis-url]: https://travis-ci.org/dbader/node-datadog-metrics
505[wiki]: https://github.com/yourname/yourproject/wiki
506-->
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG