Commit 2929ca15 authored by Ludvig Isaksson's avatar Ludvig Isaksson
Browse files

First commit. Scripts and readmes added.

parents
# 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-climate-change-service-regional-reanalysis-europe).
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/).
## MARS retrieval examples
All data produced within the Copernicus Climate Change Service regional reanalysis for Europe and the pre-operational UERRA project is 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.
#!/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_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 total precipitation every 24 hours at 06 UTC.
Origin Meteo France, surface level, analysis fields.
Request cost per day is 1 field, 2.2 Mbytes.
"""
server.retrieve({
"class": "ur",
"stream": "oper",
"type": "an",
"dataset": "uerra",
"origin" : "lfpw",
"date": requestDates,
"expver": "prod",
"levtype": "sfc",
"param": "228228",
"target": target,
"time": "06"
})
if __name__ == '__main__':
retrieve_uerra_lfpw()
# MARS retrieval examples
All data produced within the Copernicus Climate Change Service regional reanalysis for Europe and the pre-operational UERRA project is publicly available for download via the ECMWF MARS system. These are example python scripts for retrieving temperature and 24 hour precipitation data. Please note that these requests can result in the retrieval of a lot of data.
Before running these scripts it is recommended to explore the available data and the corresponding MARS requests via Web-MARS:<br />
[UERRA-HARMONIE data in Web-MARS](http://apps.ecmwf.int/datasets/data/uerra/levtype=sfc/stream=oper/type=an/)<br />
[MESCAN-SURFEX data in Web-MARS](http://apps.ecmwf.int/datasets/data/uerra-mescan-surfex/levtype=sfc/stream=oper/type=an/)<br />
Then modify the time, parameters, levels etc. in the scripts to match your specific needs.
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 examples are based on the [UERRA SMHI retrieval efficiency Web-API example](https://software.ecmwf.int/wiki/display/WEBAPI/UERRA+SMHI+retrieval+efficiency).
## 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-climate-change-service-regional-reanalysis-europe).
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/).
#!/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 origin SMHI, height level, analysis fields.
Request cost per day is 220 fields, 168 Mbytes.
"""
server.retrieve({
"class": "ur",
"stream": "oper",
"type": "an",
"dataset": "uerra",
"origin" : "eswi",
"date": requestDates,
"expver": "prod",
"levtype": "hl",
"levelist": "15/30/50/75/100/150/200/250/300/400/500",
"param": "10/54/130/157/3031",
"target": target,
"time": "00/06/12/18"
})
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 origin SMHI, height level, forecast fields.
Request cost per day is 3080 fields, 2.4 GB.
"""
server.retrieve({
"expect": "any",
"class": "ur",
"stream": "oper",
"type": "fc",
"dataset": "uerra",
"origin" : "eswi",
"date": requestDates,
"expver": "prod",
"levtype": "hl",
"levelist": "15/30/50/75/100/150/200/250/300/400/500",
"param": "10/54/130/157/246/247/3031",
"step": "1/2/3/4/5/6/9/12/15/18/21/24/27/30",
"target": target,
"time": "00/06/12/18"
})
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 origin SMHI, model level, analysis fields.
Request cost per day is 1040 fields, 713 Mbytes.
"""
server.retrieve({
"class": "ur",
"stream": "oper",
"type": "an",
"dataset": "uerra",
"origin" : "eswi",
"date": requestDates,
"expver": "prod",
"levtype": "ml",
"levelist": "1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/28/29/30/31/32/33/34/35/36/37/38/39/40/41/42/43/44/45/46/47/48/49/50/51/52/53/54/55/56/57/58/59/60/61/62/63/64/65",
"param": "130/131/132/133",
"target": target,
"time": "00/06/12/18"
})
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 origin SMHI, pressure level, analysis fields.
Request cost per day is 480 fields, 278 Mbytes.
"""
server.retrieve({
"class": "ur",
"stream": "oper",
"type": "an",
"dataset": "uerra",
"origin" : "eswi",
"date": requestDates,
"expver": "prod",
"levtype": "pl",
"levelist": "10/20/30/50/70/100/150/200/250/300/400/500/600/700/750/800/825/850/875/900/925/950/975/1000",
"param": "129/130/131/132/157",
"target": target,
"time": "00/06/12/18"
})
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 origin SMHI, pressure level, forecast fields.
Request cost per day is 7680 fields, 4.7 GB.
"""
server.retrieve({
"expect": "any",
"class": "ur",
"stream": "oper",
"type": "fc",
"dataset": "uerra",
"origin" : "eswi",
"date": requestDates,
"expver": "prod",
"levtype": "pl",
"levelist": "10/20/30/50/70/100/150/200/250/300/400/500/600/700/750/800/825/850/875/900/925/950/975/1000",
"param": "129/130/131/132/157/246/247/260257",
"step": "1/2/3/4/5/6/9/12/15/18/21/24/27/30",
"target": target,
"time": "00/06/12/18"
})
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 origin SMHI, surface level, analysis fields.
Request cost per day is 72 fields, 52 Mbytes.
"""
server.retrieve({
"class": "ur",
"stream": "oper",
"type": "an",
"dataset": "uerra",
"origin" : "eswi",
"date": requestDates,
"expver": "prod",
"levtype": "sfc",
"param": "33/134/151/167/172/173/207/235/3073/3074/3075/228002/228141/228164/260057/260242/260260/260509",
"target": target,
"time": "00/06/12/18"
})
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 origin SMHI, surface level, forecast fields.
Request cost per day is 1064 fields, 757 Mbytes.
"""
server.retrieve({
"expect": "any",
"class": "ur",
"stream": "oper",
"type": "fc",
"dataset": "uerra",
"origin" : "eswi",
"date": requestDates,
"expver": "prod",
"levtype": "sfc",
"param": "33/49/134/146/147/151/167/169/173/175/176/177/201/202/207/235/3073/3074/3075/228141/228144/228164/228228/260057/260242/260259/260260/260264/260509",
"target": target,
"time": "00/06/12/18",
"step": "1/2/3/4/5/6/9/12/15/18/21/24/27/30"
})
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 origin SMHI, soil level, analysis fields.
Request cost per day is 24 fields, 14 Mbytes.