-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_ERA5_waves.py
More file actions
47 lines (41 loc) · 1.59 KB
/
get_ERA5_waves.py
File metadata and controls
47 lines (41 loc) · 1.59 KB
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
import os
import datetime
import cdsapi #Setup as per https://cds.climate.copernicus.eu/how-to-api
import pandas as pd
dates = pd.date_range(datetime.date(2006,1,1),datetime.date(2023,12,1),freq='MS')
dates = dates[::-1] # reverse order to start downloading from the most recent data
client = cdsapi.Client()
download_folder = '/storage/shared/oceanparcels/output_data/data_Michael/ERA5/waves_NECCTON'
name_ = 'ERA5_global_waves_monthly_'
for date_ in dates:
file_str = os.path.join(download_folder, name_ + str(date_.date()) + '.nc')
dataset = 'reanalysis-era5-single-levels'
request = {
'product_type': ['reanalysis'],
'variable': ['mean_wave_period','peak_wave_period','u_component_stokes_drift','v_component_stokes_drift'],
'year': str(date_.year),
'month': '%2.2i' %date_.month,
'day': [
'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',
],
"time": [ # Take 6 hourly data to reduce load on CDS
"00:00",
"06:00",
"12:00",
"18:00"
],
'data_format': 'netcdf',
}
target = file_str
client.retrieve(dataset, request, target)
print(file_str, "retrieved.")