...
- Locally (full control on the process)
| Table of Contents |
|---|
GloFAS
CDS API
Time series extraction:
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
import cdsapi
from datetime import datetime, timedelta
def get_monthsdays(start =[2019,1,1],end=[2019,12,31]):
# reforecast time index
start, end = datetime(*start),datetime(*end)
days = [start + timedelta(days=i) for i in range((end - start).days + 1)]
monthday = [d.strftime("%B-%d").split("-") for d in days if d.weekday() in [0,3] ]
return monthday
if __name__ == '__main__':
c = cdsapi.Client()
# station coordinates (lat,lon)
COORDS = {
"Thames":[51.35,-0.45]
}
# select date index corresponding to the event
MONTHSDAYS = get_monthsdays(start =[2019,7,11],end=[2019,7,11])
YEAR = '2007'
LEADTIMES = ['%d'%(l) for l in range(24,1128,24)]
# loop over date index (just 1 in this case)
for md in MONTHSDAYS:
month = md[0].lower()
day = md[1]
# loop over station coordinates
for station in COORDS:
station_point_coord = COORDS[station]*2 # coordinates input for the area keyword
c.retrieve(
'cems-glofas-reforecast',
{
'system_version': 'version_2_2',
'variable': 'river_discharge_in_the_last_24_hours',
'format': 'grib',
'hydrological_model': 'htessel_lisflood',
'product_type': ['control_reforecast','ensemble_perturbed_reforecasts'],
'area':station_point_coord,
'hyear': YEAR,
'hmonth': month ,
'hday': day ,
'leadtime_hour': LEADTIMES,
},
f'glofas_reforecast_{station}_{month}_{day}.grib') |
...
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
## === retrieve GloFAS Seasonal Reforecast ===
## === subset South America/Amazon region ===
import cdsapi
if __name__ == '__main__':
c = cdsapi.Client()
YEARS = ['%d'%(y) for y in range(1981,2021)]
MONTHS = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']
LEADTIMES = ['%d'%(l) for l in range(24,2976,24)]
for year in YEARS:
for month in MONTHS:
c.retrieve(
'cems-glofas-seasonal-reforecast',
{
'system_version': 'version_2_2',
'variable':'river_discharge_in_the_last_24_hours',
'format':'grib',
'hydrological_model':'htessel_lisflood',
'hyear': year,
'hmonth': month,
'leadtime_hour': LEADTIMES,
'area': [ 10.95, -90.95, -30.95, -29.95 ]
},
f'glofas_seasonal_reforecast_{year}_{month}.grib') |
Local machine
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
import cdsapi
c = cdsapi.Client()
c.retrieve(
'cems-glofas-historical',
{
'variable': 'river_discharge_in_the_last_24_hours',
'format': 'grib',
'hydrological_model': 'lisflood',
'product_type': 'intermediate',
'hyear': '2021',
'hmonth': 'january',
'hday': [
'01', '02', '03',
'04', '05', '06',
'07', '08', '09',
'10', '11', '12',
'13', '14', '15',
'16', '17', '18',
'19', '20', '21',
'22', '23', '24',
'25', '26', '27',
'28', '29', '30',
'31',
],
'system_version': 'version_3_1',
},
'glofas_historical.grib') |
...
| Warning | ||
|---|---|---|
| ||
When transforming from lat/lon (source coordinates) to projected LAEA (target coordinates), you need to consider that the number of decimal places of the source coordinates affects the target coordinates precision: An interval of 0.001 degrees corresponds to about 100 metres in LAEA. An interval of 0.00001 degrees corresponds to about 1 metre in LAEA. |
CDS API
to update once cropping works....
Time series extraction:
Area cropping:
Local machine
| Code Block | ||||
|---|---|---|---|---|
| ||||
import cdsapi
c = cdsapi.Client()
c.retrieve(
'efas-reforecast',
{
'format': 'grib',
'product_type': 'ensemble_perturbed_reforecasts',
'variable': 'river_discharge_in_the_last_6_hours',
'model_levels': 'surface_level',
'hyear': '2007',
'hmonth': 'march',
'hday': [
'04', '07',
],
'leadtime_hour': [
'0', '12', '18',
'6',
],
},
'efas_reforecast.grib') |
...