Commit 18450d18 authored by Ludvig Isaksson's avatar Ludvig Isaksson
Browse files

cds complete added

parent 24533d91
# Copernicus Climate Change Service regional reanalysis for Europe - User Examples
This project contains example code for users of the Copernicus Climate Change Service regional reanalysis for Europe (C3S_322_Lot1) data. More information about the service can be found at the [Copernicus Climate Change Service regional reanalysis for Europe website](https://climate.copernicus.eu/copernicus-regional-reanalysis-europe-cerra).
The reanalysis data used here were initially produced within the FP7 pre-operational UERRA project.<br />
More information about the reanalyses systems and data can be found at the [UERRA website](http://www.uerra.eu/).
## CDS retrieval examples
All data produced within the Copernicus Climate Change Service regional reanalysis for Europe and the pre-operational UERRA project are publicly available for download. The analyses are listed in the [Copernicus Climate Data Store (CDS)](https://cds.climate.copernicus.eu/cdsapp#!/search?type=dataset&text=uerra) and can be downloaded via the Copernicus Climate Data Store API (CDS API).
The examples provided here use the python CDS API client.
Information about prerequisites for running these examples can be found at the [CDS website](https://cds.climate.copernicus.eu/api-how-to).
The folder ["cds_retrieve_analyses_examples"](cds_retrieve_analyses_examples/) contains an example python script for retrieving analysis data from the Copernicus Climate Change Service regional reanalysis for Europe via the CDS API.<br />
Modify the date, time and parameter to match your specific needs.
## MARS retrieval examples
All the data produced are publicly available for download via the ECMWF MARS system.
The examples provided here uses the python ECMWF Web-API client.
Information about prerequisites for running these examples can be found at the [ECMWF website](https://software.ecmwf.int/wiki/display/WEBAPI/Access+ECMWF+Public+Datasets).
The folder ["mars_retrieve_examples"](mars_retrieve_examples/) contains example python scripts for retrieving temperature and 24 hour precipitation data from the Copernicus Climate Change Service regional reanalysis for Europe reanalysis via the ECMWF MARS system.<br />
Modify the time, parameters, levels etc. to match your specific needs.
The folder ["mars_retrieve_total"](mars_retrieve_total/) contains python scripts for retrieving all datasets from the Copernicus Climate Change Service regional reanalysis for Europe reanalysis via the ECMWF MARS system.<br />
The scripts are provided as a complete base showing all available data. Please note that this means a lot of data. Modify the time, parameters, levels etc. to match your specific needs.
## Create forcing data for NEMO-Nordic
The folder ["create_forcing_for_NEMO"](create_forcing_for_NEMO/) contains a script system, which can be used to prepare forcing data for NEMO-Nordic (a regional ocean model). The scripts retrieve hourly data from MARS and mix analyses and forecasts. Then, the data is post-processed for the usage with NEMO-Nordic. For instance, relative humidity is transferred to specific humidity. At the end, the data is stored in netcdf-format as needed by NEMO.
# Copernicus Climate Change Service regional reanalysis for Europe - User Examples
This project contains example code for users of the Copernicus Climate Change Service regional reanalysis for Europe (C3S_322_Lot1) data. More information about the service can be found at the [Copernicus Climate Change Service regional reanalysis for Europe website](https://climate.copernicus.eu/copernicus-regional-reanalysis-europe-cerra).
The reanalysis data used here were initially produced within the FP7 pre-operational UERRA project.<br />
More information about the reanalyses systems and data can be found at the [UERRA website](http://www.uerra.eu/).
## CDS retrieval examples
All data produced within the Copernicus Climate Change Service regional reanalysis for Europe and the pre-operational UERRA project are publicly available for download. The analyses are listed in the [Copernicus Climate Data Store (CDS)](https://cds.climate.copernicus.eu/cdsapp#!/search?type=dataset&text=uerra) and can also be examined and downloaded using the CDS web GUI. The complete datasets (including forecast data) can only be downloaded via the Copernicus Climate Data Store API (CDS API) or the ECMWF MARS system.
The examples provided here use the python CDS API client.
Information about prerequisites for running these examples can be found at the [CDS website](https://cds.climate.copernicus.eu/api-how-to).
The folder ["cds_retrieve_analyses_examples"](cds_retrieve_analyses_examples/) contains an example python script for retrieving analysis data from the Copernicus Climate Change Service regional reanalysis for Europe via the CDS API.<br />
Modify the date, time and parameter to match your specific needs.
The folder ["cds_retrieve_complete_examples"](cds_retrieve_analyses_examples/) contains example python scripts for retrieving forecast data from the Copernicus Climate Change Service regional reanalysis for Europe via the CDS API.<br />
Modify the date, time and parameter to match your specific needs.
## MARS retrieval examples
All the data produced are publicly available for download via the ECMWF MARS system.
The examples provided here uses the python ECMWF Web-API client.
Information about prerequisites for running these examples can be found at the [ECMWF website](https://software.ecmwf.int/wiki/display/WEBAPI/Access+ECMWF+Public+Datasets).
The folder ["mars_retrieve_examples"](mars_retrieve_examples/) contains example python scripts for retrieving temperature and 24 hour precipitation data from the Copernicus Climate Change Service regional reanalysis for Europe reanalysis via the ECMWF MARS system.<br />
Modify the time, parameters, levels etc. to match your specific needs.
The folder ["mars_retrieve_total"](mars_retrieve_total/) contains python scripts for retrieving all datasets from the Copernicus Climate Change Service regional reanalysis for Europe reanalysis via the ECMWF MARS system.<br />
The scripts are provided as a complete base showing all available data. Please note that this means a lot of data. Modify the time, parameters, levels etc. to match your specific needs.
## Create forcing data for NEMO-Nordic
The folder ["create_forcing_for_NEMO"](create_forcing_for_NEMO/) contains a script system, which can be used to prepare forcing data for NEMO-Nordic (a regional ocean model). The scripts retrieve hourly data from MARS and mix analyses and forecasts. Then, the data is post-processed for the usage with NEMO-Nordic. For instance, relative humidity is transferred to specific humidity. At the end, the data is stored in netcdf-format as needed by NEMO.
#!/usr/bin/env python
import cdsapi
import calendar
c = cdsapi.Client()
def retrieve_uerra():
"""
A function to demonstrate how to iterate over several years and months etc
for a particular UERRA request for origin UERRA-HARMONIE.
Change the variables below to adapt the iteration to your needs.
You can use the variable 'targetFile' to organise the requested data in files as you wish.
In the example below the data are organised in files per month.
"""
yearStart = 2015
yearEnd = 2015
monthStart = 1
monthEnd = 12
for year in list(range(yearStart, yearEnd + 1)):
for month in list(range(monthStart, monthEnd + 1)):
numberOfDays = calendar.monthrange(year, month)[1]
targetFile = "ofile_%04d%02d.grb" % (year, month)
requestDates = ['{:02}'.format(i) for i in range(1, numberOfDays+1)]
requestMonth = '{:02}'.format(month)
requestYear = '{:04}'.format(year)
uerra_request(requestYear, requestMonth, requestDates, targetFile)
def uerra_request(reqYear, reqMonth, reqDates, target):
"""
A UERRA request for 2 metre temperature every 6th hour.
Origin uerra_harmonie, surface level, analysis fields.
Request cost per day is 4 fields, 1.8 Mbytes.
"""
c.retrieve(
'reanalysis-uerra-europe-single-levels',
{
'format':'grib',
'variable':'2m_temperature',
'year':reqYear,
'month':reqMonth,
'day':reqDates,
'time':['00:00','06:00','12:00','18:00'],
'origin':'uerra_harmonie'
},
target)
if __name__ == '__main__':
retrieve_uerra()
#!/usr/bin/env python
import cdsapi
import calendar
c = cdsapi.Client()
def retrieve_uerra():
"""
A function to demonstrate how to iterate over several years and months etc
for a particular UERRA request for origin UERRA-HARMONIE.
Change the variables below to adapt the iteration to your needs.
You can use the variable 'targetFile' to organise the requested data in files as you wish.
In the example below the data are organised in files per month.
"""
yearStart = 2015
yearEnd = 2015
monthStart = 1
monthEnd = 12
for year in list(range(yearStart, yearEnd + 1)):
for month in list(range(monthStart, monthEnd + 1)):
numberOfDays = calendar.monthrange(year, month)[1]
targetFile = "ofile_%04d%02d.grb" % (year, month)
requestDates = ['{:02}'.format(i) for i in range(1, numberOfDays+1)]
requestMonth = '{:02}'.format(month)
requestYear = '{:04}'.format(year)
uerra_request(requestYear, requestMonth, requestDates, targetFile)
def uerra_request(reqYear, reqMonth, reqDates, target):
"""
A UERRA request for 2 metre temperature every 6th hour.
Origin uerra_harmonie, surface level, analysis fields.
Request cost per day is 4 fields, 1.8 Mbytes.
"""
c.retrieve(
'reanalysis-uerra-europe-single-levels',
{
'format':'grib',
'variable':'2m_temperature',
'year':reqYear,
'month':reqMonth,
'day':reqDates,
'time':['00:00','06:00','12:00','18:00'],
'origin':'uerra_harmonie'
},
target)
if __name__ == '__main__':
retrieve_uerra()
# CDS analyses data retrieval examples
All data produced within the Copernicus Climate Change Service regional reanalysis for Europe and the pre-operational UERRA project are publicly available for download.
This is an example of retrieving UERRA analyses data from one of the [CDS listed datasets](https://cds.climate.copernicus.eu/cdsapp#!/search?type=dataset&text=uerra). Please note that only the analyses are available via CDS. All other data (e.g. hourly forecasts) must be downloaded via the ECMWF MARS system. See examples in the ["mars_retrieve_examples"](./../mars_retrieve_examples/) folder.
Before running this script it is recommended to explore the available data and the corresponding CDS API requests by browsing the [CDS datasets](https://cds.climate.copernicus.eu/cdsapp#!/search?type=dataset&text=uerra).
Then modify the time, parameter and data origin in the script to match your specific needs.
The example provided here uses the python CDS API client.
Information about prerequisites for running this example can be found at the [CDS website](https://cds.climate.copernicus.eu/api-how-to).
## General information
This project contains example code for users of the Copernicus Climate Change Service regional reanalysis for Europe (C3S_322_Lot1) data.
More information about the service can be found at the [Copernicus Climate Change Service regional reanalysis for Europe website](https://climate.copernicus.eu/copernicus-regional-reanalysis-europe-cerra).
The reanalysis data were initially produced within the FP7 pre-operational UERRA project.
More information about the reanalyses systems and data can be found at the [UERRA website](http://www.uerra.eu/).
# CDS analyses data retrieval examples
All data produced within the Copernicus Climate Change Service regional reanalysis for Europe and the pre-operational UERRA project are publicly available for download.
This is an example of retrieving UERRA analyses data from one of the [CDS listed datasets](https://cds.climate.copernicus.eu/cdsapp#!/search?type=dataset&text=uerra). Please note that this retrieval method is only applicable for analyses data. All other data (e.g. hourly forecasts) must be downloaded via the methods described in the ["cds_retrieve_complete_examples"](./../cds_retrieve_complete_examples/) folder or the ["mars_retrieve_examples"](./../mars_retrieve_examples/) folder.
Before running this script it is recommended to explore the available data and the corresponding CDS API requests by browsing the [CDS datasets](https://cds.climate.copernicus.eu/cdsapp#!/search?type=dataset&text=uerra).
Then modify the time, parameter and data origin in the script to match your specific needs.
The example provided here uses the python CDS API client.
Information about prerequisites for running this example can be found at the [CDS website](https://cds.climate.copernicus.eu/api-how-to).
## General information
This project contains example code for users of the Copernicus Climate Change Service regional reanalysis for Europe (C3S_322_Lot1) data.
More information about the service can be found at the [Copernicus Climate Change Service regional reanalysis for Europe website](https://climate.copernicus.eu/copernicus-regional-reanalysis-europe-cerra).
The reanalysis data were initially produced within the FP7 pre-operational UERRA project.
More information about the reanalyses systems and data can be found at the [UERRA website](http://www.uerra.eu/).
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
# Create forcing data for NEMO-Nordic
These scripts are an example of how the UERRA data can be used for input to other model systems, in this case the NEMO-Nordic (a regional ocean model).
The objectives of the scripts
-----------------------------
These scripts will:
1. download the needed,
2. extract the region needed for NEMO-Nordic,
3. convert the units as needed for NEMO-Nordic,
4. save the final files as netCDF.
Instructions
------------
Basically, users have only to adopt the "Configure section" in the
main script - Create_NEMO_forcing_from_UERRA.py
1. Set the dates your are interested in.
2. Define directories for downloaded data, the final data, and
a directory for temporary files.
Then, all you have to do is to run the main script...
Create_NEMO_forcing_from_UERRA.py
Good to know
------------
The scripts need some time to run. Especially the downloading of data
from the MARS archive takes time. Here, we are talking about days if
you want to produce forcing data for longer periods (several years).
A rough estimate is about six hours for each year. However, this depends
on your system as well as the load on MARS.
You will need some disk space. For each year you will need around 50GB
space.
Technical details
-----------------
The scripts were developed and tested with Python 2.7.9.
The scripts use [CDO](http://mpimet.mpg.de/cdo) commands to a large degree so the CDO python bindings need to be installed.
Below is info from the cdo -V command:<br>
Climate Data Operators version 1.7.0 (http://mpimet.mpg.de/cdo)<br>
Features: DATA PTHREADS OpenMP4 HDF5 NC4/HDF5 OPeNDAP Z PROJ.4 SSE2<br>
Libraries: HDF5/1.8.14 proj/4.7<br>
Filetypes: srv ext ieg grb grb2 nc nc2 nc4 nc4c CDI library version : 1.7.0<br> CGRIBEX library version : 1.7.3 <br>
GRIB_API library version : 1.14.0 <br>
netCDF library version : 4.3.2<br>
HDF5 library version : 1.8.14<br>
Moreover, to fetch data from the MARS archive, you will need the
corresponding modules. Please find out on [ECMWF's website](https://software.ecmwf.int/wiki/display/WEBAPI/Access+ECMWF+Public+Datasets).
Otherwise, used modules should be standard.
Overview on the order of called routines
----------------------------------------
Create_NEMO_forcing_from_UERRA.py<br>
==> Get_UERRA_data.py<br>
&nbsp;&nbsp;&nbsp;&nbsp;==> a) Get_UERRA_data.py<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==> Forecasts<br>
&nbsp;&nbsp;&nbsp;&nbsp;==> b) Get_UERRA_data.py<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==> Analyses<br>
&nbsp;&nbsp;&nbsp;&nbsp;==> c) Get_UERRA_data.py<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==> Precipitation (differences incorporated)<br>
==> Convert_for_NEMO.py<br>
&nbsp;&nbsp;&nbsp;&nbsp;==> a) Convert_for_NEMO.py<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==> Precipitation<br>
&nbsp;&nbsp;&nbsp;&nbsp;==> b) Convert_for_NEMO.py<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==> Parameters with analysis<br>
&nbsp;&nbsp;&nbsp;&nbsp;==> c) Convert_for_NEMO.py<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==> Radiation<br>
&nbsp;&nbsp;&nbsp;&nbsp;==> d) Convert_for_NEMO.py<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==> Humidity<br>
## General information
This project contains example code for users of the Copernicus Climate Change Service regional reanalysis for Europe (C3S_322_Lot1) data.
More information about the service can be found at the [Copernicus Climate Change Service regional reanalysis for Europe website](https://climate.copernicus.eu/copernicus-regional-reanalysis-europe-cerra).
The reanalysis data were initially produced within the FP7 pre-operational UERRA project.
More information about the reanalyses systems and data can be found at the [UERRA website](http://www.uerra.eu/).
# Create forcing data for NEMO-Nordic
These scripts are an example of how the UERRA data can be used for input to other model systems, in this case the NEMO-Nordic (a regional ocean model).
The objectives of the scripts
-----------------------------
These scripts will:
1. download the needed,
2. extract the region needed for NEMO-Nordic,
3. convert the units as needed for NEMO-Nordic,
4. save the final files as netCDF.
Instructions
------------
Basically, users have only to adopt the "Configure section" in the
main script - Create_NEMO_forcing_from_UERRA.py
1. Set the dates your are interested in.
2. Define directories for downloaded data, the final data, and
a directory for temporary files.
Then, all you have to do is to run the main script...
Create_NEMO_forcing_from_UERRA.py
Good to know
------------
The scripts need some time to run. Especially the downloading of data
from the MARS archive takes time. Here, we are talking about days if
you want to produce forcing data for longer periods (several years).
A rough estimate is about six hours for each year. However, this depends
on your system as well as the load on MARS.
You will need some disk space. For each year you will need around 50GB
space.
Technical details
-----------------
The scripts were developed and tested with Python 2.7.9.
The scripts use [CDO](http://mpimet.mpg.de/cdo) commands to a large degree so the CDO python bindings need to be installed.
Below is info from the cdo -V command:<br>
Climate Data Operators version 1.7.0 (http://mpimet.mpg.de/cdo)<br>
Features: DATA PTHREADS OpenMP4 HDF5 NC4/HDF5 OPeNDAP Z PROJ.4 SSE2<br>
Libraries: HDF5/1.8.14 proj/4.7<br>
Filetypes: srv ext ieg grb grb2 nc nc2 nc4 nc4c CDI library version : 1.7.0<br> CGRIBEX library version : 1.7.3 <br>
GRIB_API library version : 1.14.0 <br>
netCDF library version : 4.3.2<br>
HDF5 library version : 1.8.14<br>
Moreover, to fetch data from the MARS archive, you will need the
corresponding modules. Please find out on [ECMWF's website](https://software.ecmwf.int/wiki/display/WEBAPI/Access+ECMWF+Public+Datasets).
Otherwise, used modules should be standard.
Overview on the order of called routines
----------------------------------------
Create_NEMO_forcing_from_UERRA.py<br>
==> Get_UERRA_data.py<br>
&nbsp;&nbsp;&nbsp;&nbsp;==> a) Get_UERRA_data.py<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==> Forecasts<br>
&nbsp;&nbsp;&nbsp;&nbsp;==> b) Get_UERRA_data.py<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==> Analyses<br>
&nbsp;&nbsp;&nbsp;&nbsp;==> c) Get_UERRA_data.py<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==> Precipitation (differences incorporated)<br>
==> Convert_for_NEMO.py<br>
&nbsp;&nbsp;&nbsp;&nbsp;==> a) Convert_for_NEMO.py<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==> Precipitation<br>
&nbsp;&nbsp;&nbsp;&nbsp;==> b) Convert_for_NEMO.py<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==> Parameters with analysis<br>
&nbsp;&nbsp;&nbsp;&nbsp;==> c) Convert_for_NEMO.py<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==> Radiation<br>
&nbsp;&nbsp;&nbsp;&nbsp;==> d) Convert_for_NEMO.py<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;==> Humidity<br>
## General information
This project contains example code for users of the Copernicus Climate Change Service regional reanalysis for Europe (C3S_322_Lot1) data.
More information about the service can be found at the [Copernicus Climate Change Service regional reanalysis for Europe website](https://climate.copernicus.eu/copernicus-regional-reanalysis-europe-cerra).
The reanalysis data were initially produced within the FP7 pre-operational UERRA project.
More information about the reanalyses systems and data can be found at the [UERRA website](http://www.uerra.eu/).
File mode changed from 100644 to 100755
#!/usr/bin/env python
import calendar
from ecmwfapi import ECMWFDataServer
server = ECMWFDataServer()
def retrieve_uerra_lfpw():
"""
A function to demonstrate how to iterate efficiently over several years and months etc
for a particular UERRA request for origin Meteo France.
Change the variables below to adapt the iteration to your needs.
You can use the variable 'target' to organise the requested data in files as you wish.
In the example below the data are organised in files per month.
"""
yearStart = 2015
yearEnd = 2015
monthStart = 1
monthEnd = 12
for year in list(range(yearStart, yearEnd + 1)):
for month in list(range(monthStart, monthEnd + 1)):
startDate = '%04d%02d%02d' % (year, month, 1)
numberOfDays = calendar.monthrange(year, month)[1]
lastDate = '%04d%02d%02d' % (year, month, numberOfDays)
target = "ofile_%04d%02d.grb" % (year, month)
requestDates = (startDate + "/TO/" + lastDate)
uerra_lfpw_request(requestDates, target)
def uerra_lfpw_request(requestDates, target):
"""
A UERRA request for 2 metre temperature every 6 hours.
Origin Meteo France, surface level, analysis fields.
Request cost per day is 4 fields, 8.7 Mbytes.
"""
server.retrieve({
"class": "ur",
"stream": "oper",
"type": "an",
"dataset": "uerra",
"origin" : "lfpw",
"date": requestDates,
"expver": "prod",
"levtype": "sfc",
"param": "167",
"target": target,
"time": "00/06/12/18"
})
if __name__ == '__main__':
retrieve_uerra_lfpw()
#!/usr/bin/env python
import calendar
from ecmwfapi import ECMWFDataServer
server = ECMWFDataServer()
def retrieve_uerra_lfpw():
"""
A function to demonstrate how to iterate efficiently over several years and months etc
for a particular UERRA request for origin Meteo France.
Change the variables below to adapt the iteration to your needs.
You can use the variable 'target' to organise the requested data in files as you wish.
In the example below the data are organised in files per month.
"""
yearStart = 2015
yearEnd = 2015
monthStart = 1
monthEnd = 12
for year in list(range(yearStart, yearEnd + 1)):
for month in list(range(monthStart, monthEnd + 1)):
startDate = '%04d%02d%02d' % (year, month, 1)
numberOfDays = calendar.monthrange(year, month)[1]
lastDate = '%04d%02d%02d' % (year, month, numberOfDays)
target = "ofile_%04d%02d.grb" % (year, month)
requestDates = (startDate + "/TO/" + lastDate)
uerra_lfpw_request(requestDates, target)
def uerra_lfpw_request(requestDates, target):
"""
A UERRA request for 2 metre temperature every 6 hours.
Origin Meteo France, surface level, analysis fields.
Request cost per day is 4 fields, 8.7 Mbytes.
"""
server.retrieve({
"class": "ur",
"stream": "oper",
"type": "an",
"dataset": "uerra",
"origin" : "lfpw",
"date": requestDates,
"expver": "prod",
"levtype": "sfc",
"param": "167",
"target": target,
"time": "00/06/12/18"
})
if __name__ == '__main__':
retrieve_uerra_lfpw()
#!/usr/bin/env python
import calendar
from ecmwfapi import ECMWFDataServer
server = ECMWFDataServer()
def retrieve_uerra_eswi():
"""
A function to demonstrate how to iterate efficiently over several years and months etc
for a particular UERRA request for origin SMHI.
Change the variables below to adapt the iteration to your needs.
You can use the variable 'target' to organise the requested data in files as you wish.
In the example below the data are organised in files per month.
"""
yearStart = 2016
yearEnd = 2016
monthStart = 1
monthEnd = 12
for year in list(range(yearStart, yearEnd + 1)):
for month in list(range(monthStart, monthEnd + 1)):
startDate = '%04d%02d%02d' % (year, month, 1)
numberOfDays = calendar.monthrange(year, month)[1]
lastDate = '%04d%02d%02d' % (year, month, numberOfDays)
target = "ofile_%04d%02d.grb" % (year, month)
requestDates = (startDate + "/TO/" + lastDate)
uerra_eswi_request(requestDates, target)
def uerra_eswi_request(requestDates, target):
"""
A UERRA request for 2 metre temperature every hour.
Origin SMHI, surface level, forecast fields.
Request cost per day is 24 fields, 11 Mbytes.
"""
server.retrieve({
"class": "ur",
"stream": "oper",
"type": "fc",
"dataset": "uerra",
"origin" : "eswi",
"date": requestDates,
"expver": "prod",
"levtype": "sfc",
"param": "167",
"target": target,
"time": "00/06/12/18",
"step": "1/2/3/4/5/6",
})
if __name__ == '__main__':
retrieve_uerra_eswi()
#!/usr/bin/env python
import calendar
from ecmwfapi import ECMWFDataServer
server = ECMWFDataServer()
def retrieve_uerra_eswi():
"""
A function to demonstrate how to iterate efficiently over several years and months etc
for a particular UERRA request for origin SMHI.
Change the variables below to adapt the iteration to your needs.
You can use the variable 'target' to organise the requested data in files as you wish.
In the example below the data are organised in files per month.
"""
yearStart = 2016
yearEnd = 2016
monthStart = 1
monthEnd = 12
for year in list(range(yearStart, yearEnd + 1)):
for month in list(range(monthStart, monthEnd + 1)):
startDate = '%04d%02d%02d' % (year, month, 1)
numberOfDays = calendar.monthrange(year, month)[1]
lastDate = '%04d%02d%02d' % (year, month, numberOfDays)
target = "ofile_%04d%02d.grb" % (year, month)
requestDates = (startDate + "/TO/" + lastDate)
uerra_eswi_request(requestDates, target)
def uerra_eswi_request(requestDates, target):
"""
A UERRA request for 2 metre temperature every hour.
Origin SMHI, surface level, forecast fields.
Request cost per day is 24 fields, 11 Mbytes.
"""
server.retrieve({
"class": "ur",
"stream": "oper",
"type": "fc",
"dataset": "uerra",
"origin" : "eswi",
"date": requestDates,
"expver": "prod",
"levtype": "sfc",
"param": "167",
"target": target,
"time": "00/06/12/18",
"step": "1/2/3/4/5/6",
})
if __name__ == '__main__':
retrieve_uerra_eswi()
#!/usr/bin/env python
import calendar
from ecmwfapi import ECMWFDataServer
server = ECMWFDataServer()
def retrieve_uerra_lfpw():
"""
A function to demonstrate how to iterate efficiently over several years and months etc
for a particular UERRA request for origin Meteo France.