source: flex_extract.git/python/README.md @ e18f4b5

ctbtodev
Last change on this file since e18f4b5 was e18f4b5, checked in by skomo <p.skomorowski@…>, 6 years ago

initial git repo of version 7.0.3

  • Property mode set to 100644
File size: 8.7 KB
Line 
1# README #
2
3This documentation shows how to use these python scripts to extract ECMWF data and generate the ***FLEXPART*** specific input files.
4
5### Introduction ###
6
7To run ***FLEXPART*** with ECMWF data, you first need to retrieve ECMWF GRIB fields and generate ***FLEXPART*** specific input files afterwards. ***FLEXPART*** needs the GRIB data seperated by time so that flex_extract will combine all data in output files seperated for each time step. The format of these output filenames looks like: `prefixYYMMDDHH`, where prefix can be defined in ***flex_extract*** (usually it should be limited to "2" characters because of further processing reasons).
8
9For setting up a complete ***FLEXPART*** environment it is recommended to build a directory structure such as:
10
11 ![FLEXPART directory structure](../docs/Fp_extract_strukt-pngnew.png)
12
13For installation instructions and usage of ***FLEXPART*** please see ***FLEXPART***-Documentation!
14
15### Overview ###
16
17%-- list all files in python dir and shortly explain structure
18
19##### CONTROL file #####
20For specifying which ECMWF dataset you would like to retrieve and which time and spatial resolution you would like to retrieve you have to prepare a `CONTROL` file. In the directory you can find a couple of example `CONTROL` files:
21
22```
23CONTROL_CERA
24CONTROL_CV
25CONTROL_EA5.public
26CONTROL_FC.pure
27CONTROL_OD.highres.gauss
28CONTROL_CERA.public
29CONTROL_EA5
30CONTROL_EI.global
31CONTROL_FC.twiceaday
32CONTROL_OPS.4V
33CONTROL_CF
34CONTROL_EA5.highres
35CONTROL_EI.public
36CONTROL_OD.highres.eta
37CONTROL.temp
38```
39
40#### Python scripts ####
41
42The main program for doing both, retrieving ECMWF data and generate the FLEXPART input files, is `submit.py`. It combines the two sub-programs `getMARSdata.py` and `prepareFLEXPART.py` which can also be run by themselves for example for debugging purposes.
43To get the usage of the program, use the `-h` option:
44
45```
46usage: submit.py [-h] [--start_date START_DATE] [--end_date END_DATE]
47                 [--date_chunk DATE_CHUNK] [--basetime BASETIME] [--step STEP]
48                 [--levelist LEVELIST] [--area AREA] [--inputdir INPUTDIR]
49                 [--outputdir OUTPUTDIR]
50                 [--flexpart_root_scripts FLEXPART_ROOT_SCRIPTS] [--ppid PPID]
51                 [--job_template JOB_TEMPLATE] [--queue QUEUE]
52                 [--controlfile CONTROLFILE] [--debug DEBUG] [--public PUBLIC]
53
54Retrieve FLEXPART input from ECMWF MARS archive
55
56optional arguments:
57  -h, --help            show this help message and exit
58  --start_date START_DATE
59                        start date YYYYMMDD (default: None)
60  --end_date END_DATE   end_date YYYYMMDD (default: None)
61  --date_chunk DATE_CHUNK
62                        # of days to be retrieved at once (default: None)
63  --basetime BASETIME   base such as 00/12 (for half day retrievals) (default:
64                        None)
65  --step STEP           steps such as 00/to/48 (default: None)
66  --levelist LEVELIST   Vertical levels to be retrieved, e.g. 30/to/60
67                        (default: None)
68  --area AREA           area defined as north/west/south/east (default: None)
69  --inputdir INPUTDIR   root directory for storing intermediate files
70                        (default: None)
71  --outputdir OUTPUTDIR
72                        root directory for storing output files (default:
73                        None)
74  --flexpart_root_scripts FLEXPART_ROOT_SCRIPTS
75                        FLEXPART root directory (to find grib2flexpart and
76                        COMMAND file) Normally flex_extract resides in the
77                        scripts directory of the FLEXPART distribution
78                        (default: None)
79  --ppid PPID           Specify parent process id for rerun of prepareFLEXPART
80                        (default: None)
81  --job_template JOB_TEMPLATE
82                        job template file for submission to ECMWF (default:
83                        job.temp)
84  --queue QUEUE         queue for submission to ECMWF (e.g. ecgate or cca )
85                        (default: None)
86  --controlfile CONTROLFILE
87                        file with control parameters (default: CONTROL.temp)
88  --debug DEBUG         Debug mode - leave temporary files intact (default: 0)
89  --public PUBLIC       Public mode - retrieves the public datasets (default:
90                        False)
91```
92
93
94Optional arguments are listed in squared brackets.
95
96The sub-programs `getMARSdata.py` and `prepareFLEXPART.py` are the two main parts of this software.
97
98* `getMARSdata.py`
99
100This 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.
101
102
103* `prepareFLEXPART.py`
104
105This program generates FLEXPART input files. It requires python interface to grib_api and the Fortran program `CONVERT2` (located in `src` directory with instruction on how to compile it). `CONVERT2` needs a namelist which is generated from the python program.
106
107
108### Requirements ###
109
110| Python Support        | Link            | Notes |
111| --------------------- |:----------------------:|:-------------------------|
112| python                | [http://www.python.org](http://www.python.org)  | We have used [Anaconda python](https://store.continuum.io/cshop/anaconda/) for our testing |
113| python-numpy          | [http://www.numpy.org/](http://www.numpy.org/)  | Not necessary if you have installed python Anaconda
114| ecmwfapi              | [https://software.ecmwf.int/wiki/display/WEBAPI/ECMWF+Web+API+Home](https://software.ecmwf.int/wiki/display/WEBAPI/ECMWF+Web+API+Home) | You also need to install your API key (as explained in the documentation)
115
116| Utilities             | Link            | Notes |
117| --------------------- |:----------------------:|:-------------------------|
118|gfortran|[https://gcc.gnu.org/wiki/GFortran](https://gcc.gnu.org/wiki/GFortran)| Make sure that you are using the same compiler version for all libraries in connection with flex_extract, GRIB_API and FLEXPART, otherwise you will have problems.|
119|  grib-api             | [https://software.ecmwf.int/wiki/display/GRIB/Home](https://software.ecmwf.int/wiki/display/GRIB/Home) | Make sure you install GRIB-API with JPEG support and python GRIB-API.|
120|FFTW|[http://www.fftw.org](http://www.fftw.org)|This is needed by the Emos library, as is mentioned in the installation instructions for Emos|
121|  Emos                 | [https://software.ecmwf.int/wiki/display/EMOS/Emoslib](https://software.ecmwf.int/wiki/display/EMOS/Emoslib) | Make sure you carefully read the instructions and have installed the FFTW package before installing Emos.|
122| CONVERT2     | |to run prepareFLEXPART.py, you need to compile the Fortragn program CONVERT2 (located in the src directory). See separate README file in this directory to get instructions on how to compile this code.|
123
124### Installation ###
125
126*  Environment
127
128At UIO, Red Hat 6 Linux systems (64 bits) were used for testing. We use the [Module package](http://modules.sourceforge.net/) to set-up user environment.
129
130* Getting the source code
131In the directory of your choice:
132
133`
134git clone git@bitbucket.org:flexpart/flexpart.git
135`
136This command will create a subdirectory called flexpart: it contains the latest FLEXPART version.
137
138Then set the environment variable `FLEXPART_ROOT`:
139
140** Korn-shell or Bash users:
141`
142cd flexpart
143export FLEXPART_ROOT=$PWD
144`
145
146** C-shell users:
147
148`
149cd flexpart
150setenv FLEXPART_ROOT=$PWD
151`
152
153* Installation
154
155Make sure you first generate the `CONVERT2` program (see separate instructions in `preproc/src`).
156
157Users need to be able to execute prepareFLEXPART.py and getMARSdata.py so make sure they have the correct unix permissions:
158
159`
160cd preproc/python
161chmod uog+rx getMARSdata.py prepareFLEXPART.py
162`
163
164These two programs must be in the user PATH. At UIO this is done automatically when loading flexpart. If not, you would need to do the following:
165
166** Korn-shell or Bash users:
167`
168export PATH=$FLEXPART_HOME/preproc/python:$PATH
169`
170
171** C-shell users:
172
173`
174setenv PATH $FLEXPART_HOME/preproc/python:$PATH
175`
176
177Where `$FLEXPART_HOME` is the directory where FLEXPART
178
179* Testing your installation
180
181First check that grib-api python interface is correctly installed on your platform:
182`
183python
184>>> from gribapi import *
185>>>
186`
187Use `CTRL-D` to quit python.
188
189Then check that `ecmwfapi` is properly installed:
190`
191python
192>>> from ecmwfapi import *
193>>>
194`
195
196If the two previous tests were successful, you can run `tests/preproc` (See separate instructions in `tests/preproc`).
197
198If any of these two tests fail, this probably means that either `ecmwfapi` or `grib-api` have not been installed properly.
199
200Please report any problems.
201
202###  Installation FAQ ###
203
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG