Identify the data you want
- ML, 3 parameters
- Time: 00 and 12, April 2017
- first 90 steps (0/to/90/by/1)
- 10 levels closer to surface (127/to/137)
Use MARS list to find out the size
LIST, OUTPUT = COST, CLASS = OD, TYPE = FC, STREAM = OPER, EXPVER = 0001, LEVTYPE = ML, LEVELIST = 127/128/129/130/131/132/133/134/135/136/137, PARAM = 130/131/132, DATE = 20170401/20170402/20170403/20170404/20170405/20170406/20170407/20170408/20170409/20170410/20170411/20170412/20170413/20170414/20170415/20170416/20170417/20170418/20170419/20170420/20170421/20170422/20170423/20170424/20170425/20170426/20170427/20170428/20170429/20170430, TIME = 0000/1200, STEP = 0/to/90/by/1, TARGET = list.txt
When we run the list action this is the output:
size=591270399720; number_of_fields=180180; online_size=206846193282; off_line_size=384424206438; number_of_tape_files=60; number_of_disk_files=546; number_of_online_fields=63033; number_of_offline_fields=117147; number_of_tapes=8;
The data is too large: ~590 GB and split across 8 tapes.
Use the MARS catalogue to know the data distribution in files and tapes
Using the MARS catalogue we browse the data we want to get until we get to the final stage which gives us a selection and several options: http://apps.ecmwf.int/mars-catalogue/?class=od&stream=oper&expver=1&type=fc&year=2017&month=apr&levtype=ml&date=2017-04-01&time=00:00:00
For this particular case we can choose for 1 day, 1 time, different "Parameter", "Level" and "Step". This means that all the fields you can choose in this page are in the same tape file. Therefore users should get as much data as possible from this page.
If we run the list of the data that we need and appears in the final stage page we get:
LIST, CLASS = OD, TYPE = FC, STREAM = OPER, EXPVER = 0001, LEVTYPE = ML, LEVELIST = 127/128/129/130/131/132/133/134/135/136/137, PARAM = 130/131/132, DATE = 20170401, TIME = 0000, STEP = 0/to/90/by/1, OUTPUT = cost, TARGET = list2.txt
size=9854506662; number_of_fields=3003; online_size=6211981722; off_line_size=3642524940; number_of_tape_files=1; number_of_disk_files=12; number_of_online_fields=1893; number_of_offline_fields=1110; number_of_tapes=1;
In this case the raw data (without post-processing) is ~9.85GB, which would be reduced if you interpolate to lat/lon and/or filter the area.
The data is 1 single tape, which is sensible.
Now that we know the size of the data that we want to retrive in one go from the same hypercube we can start the study of the way to iterate to get the full time and date.
Split the request in sensible chunks iterating through the correct keywords
Using the browser we know how the data is distributed in the MARS tree. Now we focus on the current selection section. In this case:
From the top to the bottom we have to start iterating from the inner loop to the outer loop "Time", "date", ...
This is an example BASH script to loop 1 time/ 1 day in one go for one month
#!/bin/bash PARAMS="130/131/132" LEVELIST="127/128/129/130/131/132/133/134/135/136/137" TIMES="0000 1200" YEAR="2017" MONTH="04" #date loop for y in ${YEAR}; do for m in ${MONTH}; do #get the number of days for this particular month/year days_per_month=$(cal ${m} ${y} | awk 'NF {DAYS = $NF}; END {print DAYS}') for my_date in $(seq -w 1 ${days_per_month}); do my_date=${YEAR}${MONTH}${my_date} #time lop for my_time in ${TIMES}; do cat << EOF > my_request_${my_date}_${my_time}.mars REQUEST, CLASS = OD, TYPE = FC, STREAM = OPER, EXPVER = 0001, LEVTYPE = ML, LEVELIST = ${LEVELIST}, PARAM = ${PARAMS}, DATE = ${my_date}, TIME = ${my_time}, STEP = 0/to/90/by/1, TARGET = oper_ml_${my_date}_${my_time}.grib EOF mars my_request_${my_date}_${my_time}.mars if [ $? -eq 0 ]; then rm -f my_request_${my_date}_${my_time}.mars fi done done done done