-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopernicusmarine_download.py
More file actions
113 lines (100 loc) · 4.74 KB
/
copernicusmarine_download.py
File metadata and controls
113 lines (100 loc) · 4.74 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Script to download necessary Copernicus Marine data for Arctic NECCTON simulations
import copernicusmarine as cm
from argparse import ArgumentParser
import os
import os.path
import pandas as pd
longitude_range = [-180., 180.]
latitude_range = [50., 90.]
depth_range = [0., 70.]
p = ArgumentParser(description="Download Copernicus Marine data for Arctic NECCTON simulations")
p.add_argument('-startdate', '--startdate', default='2020-01-01', help='Start date for data download (YYYY-MM-DD)')
p.add_argument('-enddate', '--enddate', default='2021-01-01', help='End date for data download (YYYY-MM-DD)')
parsed_args = p.parse_args()
start_day = pd.Timestamp(parsed_args.startdate)
end_day = pd.Timestamp(parsed_args.enddate)
output_directory = "/storage/shared/oceanparcels/output_data/data_Michael/NECCTONsimulations/data/copernicus_data/"
total_days = (end_day - start_day).days + 1 #+1 to include end day
for i in range(total_days):
current_day = start_day + pd.Timedelta(days=i)
# Download hydrodynamics
output_filename = f"cmems_mod_glo_phy_my_{current_day.strftime('%Y-%m-%d')}.nc"
if not os.path.isfile(output_directory + output_filename):
cm.subset(
dataset_id="cmems_mod_glo_phy_my_0.083deg_P1D-m",
variables=["uo", "vo", "so", "thetao"],
minimum_longitude=longitude_range[0],
maximum_longitude=longitude_range[1],
minimum_latitude=latitude_range[0],
maximum_latitude=latitude_range[1],
minimum_depth=depth_range[0],
maximum_depth=depth_range[1],
start_datetime=current_day.isoformat(),
end_datetime=(current_day).isoformat(),
coordinates_selection_method='outside',
file_format="netcdf",
output_filename = output_filename,
output_directory = output_directory
)
# Download biogeochemistry
output_filename = f"cmems_mod_glo_bgc_my_nppv_{current_day.strftime('%Y-%m-%d')}.nc"
if not os.path.isfile(output_directory + output_filename):
# Download the phyc data seprately because it is monthly!
cm.subset(
dataset_id="cmems_mod_glo_bgc_my_0.25deg_P1D-m",
variables=["nppv"],
minimum_longitude=longitude_range[0],
maximum_longitude=longitude_range[1],
minimum_latitude=latitude_range[0],
maximum_latitude=latitude_range[1],
minimum_depth=depth_range[0],
maximum_depth=depth_range[1],
start_datetime=current_day.isoformat(),
end_datetime=(current_day).isoformat(),
coordinates_selection_method='outside',
file_format="netcdf",
output_filename = output_filename,
output_directory = output_directory
)
# Download the wave data
output_filename = f"cmems_mod_glo_wav_my_{current_day.strftime('%Y-%m-%d')}.nc"
if not os.path.isfile(output_directory + output_filename):
cm.subset(
dataset_id="cmems_mod_glo_wav_my_0.2deg_PT3H-i",
variables=["VSDX", "VSDY", "VTPK"],
minimum_longitude=longitude_range[0],
maximum_longitude=longitude_range[1],
minimum_latitude=latitude_range[0],
maximum_latitude=latitude_range[1],
minimum_depth=depth_range[0],
maximum_depth=depth_range[1],
start_datetime=current_day.isoformat(),
end_datetime=(current_day+pd.Timedelta(hours=21)).isoformat(),
coordinates_selection_method='outside',
file_format="netcdf",
output_filename = output_filename,
output_directory = output_directory
)
# Ensure all of phyc is downloaded (although, this has already been done!)
# for i in range(12*16):
# start_day = pd.Timestamp('2008-01-01') + pd.DateOffset(months=i)
# output_filename = f"cmems_mod_glo_bgc_my_phyc_{start_day.strftime('%Y-%m-%d')}.nc"
# # Download the phyc data seprately because it is monthly!
# if not os.path.isfile(output_directory + output_filename):
# cm.subset(
# dataset_id="cmems_mod_glo_bgc_my_0.25deg_P1M-m",
# variables=["phyc"],
# minimum_longitude=longitude_range[0],
# maximum_longitude=longitude_range[1],
# minimum_latitude=latitude_range[0],
# maximum_latitude=latitude_range[1],
# minimum_depth=depth_range[0],
# maximum_depth=depth_range[1],
# start_datetime=start_day.isoformat(),
# end_datetime=(start_day).isoformat(),
# coordinates_selection_method='outside',
# file_format="netcdf",
# output_filename = output_filename,
# output_directory = output_directory
# )
# print(start_day)