-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpathfinder.py
More file actions
219 lines (207 loc) · 14.7 KB
/
pathfinder.py
File metadata and controls
219 lines (207 loc) · 14.7 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon May 3 15:00:03 2021
Function to find right variables for ice core study for a selection of models in CMIP6
@author: Kine Onsum Moseid
"""
# on betzy: /trd-project1/NS9252K/ESGF/CMIP6/CMIP
def pathfinder(model,var,):
###### CHANGE VARIABLE path DEPENDING ON WHAT MACHINE YOU ARE ON ######
if 'NorESM' in model:
path = '/home/kristineom/Documents/phdgreier/lifetimes/noresm/'
else:
path = '/home/kristineom/Documents/phdgreier/ice_cores/betzy/'
####################################################################
if 'GISS-E2-1-' in model:
# Both models have pr and bc as below
histwet = 'NS9252K/ESGF/CMIP6/CMIP/NASA-GISS/'+model+'/historical/r1i1p3f1/AERmon/wet'+var+'/gn/v20*/*'
histdry = 'NS9252K/ESGF/CMIP6/CMIP/NASA-GISS/'+model+'/historical/r1i1p3f1/AERmon/dry'+var+'/gn/v20*/*'
ctrlwet = 'NS9252K/ESGF/CMIP6/CMIP/NASA-GISS/'+model+'/piControl/r1i1p3f1/AERmon/wet'+var+'/gn/v20*/*'
ctrldry = 'NS9252K/ESGF/CMIP6/CMIP/NASA-GISS/'+model+'/piControl/r1i1p3f1/AERmon/dry'+var+'/gn/v20*/*'
elif 'EC-Earth3-AerChem' in model:
# This model has bc as below
# This model has pr in similar path but grid is "gr"
histwet = 'NS9252K/ESGF/CMIP6/CMIP/EC-Earth-Consortium/EC-Earth3-AerChem/historical/r1i1p1f1/AERmon/wet'+var+'/gn/v*/*'
histdry = 'NS9252K/ESGF/CMIP6/CMIP/EC-Earth-Consortium/EC-Earth3-AerChem/historical/r1i1p1f1/AERmon/dry'+var+'/gn/v*/*'
ctrlwet = 'NS9252K/ESGF/CMIP6/CMIP/EC-Earth-Consortium/EC-Earth3-AerChem/piControl/r1i1p1f1/AERmon/wet'+var+'/gn/v*/*'
ctrldry = 'NS9252K/ESGF/CMIP6/CMIP/EC-Earth-Consortium/EC-Earth3-AerChem/piControl/r1i1p1f1/AERmon/dry'+var+'/gn/v*/*'
elif 'MPI-ESM-1-2-HAM' in model:
# Has pr in historical r1i1p1f1 and picontrol as below
# Has bc as below
histwet = 'NS9252K/ESGF/CMIP6/CMIP/HAMMOZ-Consortium/MPI-ESM-1-2-HAM/historical/r3i1p1f1/AERmon/wet'+var+'/gn/v*/*'
histdry = 'NS9252K/ESGF/CMIP6/CMIP/HAMMOZ-Consortium/MPI-ESM-1-2-HAM/historical/r3i1p1f1/AERmon/dry'+var+'/gn/v*/*'
ctrlwet = 'NS9252K/ESGF/CMIP6/CMIP/HAMMOZ-Consortium/MPI-ESM-1-2-HAM/piControl/r1i1p1f1/AERmon/wet'+var+'/gn/v*/*'
ctrldry = 'NS9252K/ESGF/CMIP6/CMIP/HAMMOZ-Consortium/MPI-ESM-1-2-HAM/piControl/r1i1p1f1/AERmon/dry'+var+'/gn/v*/*'
elif 'CESM2' in model:
# both models have pr and bc as below
histwet = 'NS9252K/ESGF/CMIP6/CMIP/NCAR/'+model+'/historical/r1i1p1f1/AERmon/wet'+var+'/gn/v*/*.nc'
histdry = 'NS9252K/ESGF/CMIP6/CMIP/NCAR/'+model+'/historical/r1i1p1f1/AERmon/dry'+var+'/gn/v*/*.nc'
ctrlwet = 'NS9252K/ESGF/CMIP6/CMIP/NCAR/'+model+'/piControl/r1i1p1f1/AERmon/wet'+var+'/gn/v*/*.nc'
ctrldry = 'NS9252K/ESGF/CMIP6/CMIP/NCAR/'+model+'/piControl/r1i1p1f1/AERmon/dry'+var+'/gn/v*/*.nc'
elif 'CanESM5' in model:
# Has pr and bc as below
histwet = 'NS9252K/ESGF/CMIP6/CMIP/CCCma/CanESM5/historical/r1i1p1f1/AERmon/wet'+var+'/gn/v*/*'
histdry = 'NS9252K/ESGF/CMIP6/CMIP/CCCma/CanESM5/historical/r1i1p1f1/AERmon/dry'+var+'/gn/v*/*'
ctrlwet = 'NS9252K/ESGF/CMIP6/CMIP/CCCma/CanESM5/piControl/r1i1p1f1/AERmon/wet'+var+'/gn/v*/*'
ctrldry = 'NS9252K/ESGF/CMIP6/CMIP/CCCma/CanESM5/piControl/r1i1p1f1/AERmon/dry'+var+'/gn/v*/*'
elif 'INM-CM' in model:
# Both models have pr and bc as below
histwet = 'NS9252K/ESGF/CMIP6/CMIP/INM/'+model+'/historical/r1i1p1f1/AERmon/wet'+var+'/gr1/v*/*'
histdry = 'NS9252K/ESGF/CMIP6/CMIP/INM/'+model+'/historical/r1i1p1f1/AERmon/dry'+var+'/gr1/v*/*'
ctrlwet = 'NS9252K/ESGF/CMIP6/CMIP/INM/'+model+'/piControl/r1i1p1f1/AERmon/wet'+var+'/gr1/v*/*'
ctrldry = 'NS9252K/ESGF/CMIP6/CMIP/INM/'+model+'/piControl/r1i1p1f1/AERmon/dry'+var+'/gr1/v*/*'
elif 'GFDL-ESM4' in model:
# Has pr and bc as below
histwet = 'NS9252K/ESGF/CMIP6/CMIP/NOAA-GFDL/GFDL-ESM4/historical/r1i1p1f1/AERmon/wet'+var+'/gr1/v*/*'
histdry = 'NS9252K/ESGF/CMIP6/CMIP/NOAA-GFDL/GFDL-ESM4/historical/r1i1p1f1/AERmon/dry'+var+'/gr1/v*/*'
ctrlwet = 'NS9252K/ESGF/CMIP6/CMIP/NOAA-GFDL/GFDL-ESM4/piControl/r1i1p1f1/AERmon/wet'+var+'/gr1/v*/*'
ctrldry = 'NS9252K/ESGF/CMIP6/CMIP/NOAA-GFDL/GFDL-ESM4/piControl/r1i1p1f1/AERmon/dry'+var+'/gr1/v*/*'
elif 'CNRM-ESM2-1' in model:
# Has pr and bc as below
histwet = 'NS9252K/ESGF/CMIP6/CMIP/CNRM-CERFACS/CNRM-ESM2-1/historical/r1i1p1f2/AERmon/wet'+var+'/gr/v*/*'
histdry = 'NS9252K/ESGF/CMIP6/CMIP/CNRM-CERFACS/CNRM-ESM2-1/historical/r1i1p1f2/AERmon/dry'+var+'/gr/v*/*'
ctrlwet = 'NS9252K/ESGF/CMIP6/CMIP/CNRM-CERFACS/CNRM-ESM2-1/piControl/r1i1p1f2/AERmon/wet'+var+'/gr/v*/*'
ctrldry = 'NS9252K/ESGF/CMIP6/CMIP/CNRM-CERFACS/CNRM-ESM2-1/piControl/r1i1p1f2/AERmon/dry'+var+'/gr/v*/*'
elif 'MRI-ESM2-0' in model:
# Has pr and bc as below
histwet = 'NS9252K/ESGF/CMIP6/CMIP/MRI/MRI-ESM2-0/historical/r1i1p1f1/AERmon/wet'+var+'/gn/v*/*'
histdry = 'NS9252K/ESGF/CMIP6/CMIP/MRI/MRI-ESM2-0/historical/r1i1p1f1/AERmon/dry'+var+'/gn/v*/*'
ctrlwet = 'NS9252K/ESGF/CMIP6/CMIP/MRI/MRI-ESM2-0/piControl/r1i1p1f1/AERmon/wet'+var+'/gn/v*/*'
ctrldry = 'NS9252K/ESGF/CMIP6/CMIP/MRI/MRI-ESM2-0/piControl/r1i1p1f1/AERmon/dry'+var+'/gn/v*/*'
elif 'MIROC6' in model:
# Has pr and bc as below
histwet = 'NS9252K/ESGF/CMIP6/CMIP/MIROC/MIROC6/historical/r1i1p1f1/AERmon/wet'+var+'/gn/v*/*'
histdry = 'NS9252K/ESGF/CMIP6/CMIP/MIROC/MIROC6/historical/r1i1p1f1/AERmon/dry'+var+'/gn/v*/*'
ctrlwet = 'NS9252K/ESGF/CMIP6/CMIP/MIROC/MIROC6/piControl/r1i1p1f1/AERmon/wet'+var+'/gn/v*/*'
ctrldry = 'NS9252K/ESGF/CMIP6/CMIP/MIROC/MIROC6/piControl/r1i1p1f1/AERmon/dry'+var+'/gn/v*/*'
elif 'NorESM2' in model:
# Both has pr as below
# MM is missing both so4 and bc in piControl
histwet = 'CMIP6/CMIP/NCC/'+model+'/historical/r1i1p1f1/AERmon/wet'+var+'/gn/latest/*'
histdry = 'CMIP6/CMIP/NCC/'+model+'/historical/r1i1p1f1/AERmon/dry'+var+'/gn/latest/*'
ctrlwet = 'CMIP6/CMIP/NCC/'+model+'/piControl/r1i1p1f1/AERmon/wet'+var+'/gn/latest/*'
ctrldry = 'CMIP6/CMIP/NCC/'+model+'/piControl/r1i1p1f1/AERmon/dry'+var+'/gn/latest/*'
return path+histwet, path+histdry, path+ctrlwet, path+ctrldry
def pr_pathfinder(model):
###### CHANGE VARIABLE path DEPENDING ON WHAT MACHINE YOU ARE ON ######
if 'NorESM' in model:
path = '/home/kristineom/Documents/phdgreier/lifetimes/noresm/' #This folder needs to be sshfs-ed
elif 'EC-Earth' in model:
path = '/home/kristineom/Documents/phdgreier/ice_cores/EC-Earth3-AerChem/' #local machine only
elif 'MRI' in model:
areapath= '/home/kristineom/Documents/phdgreier/ice_cores/EC-Earth3-AerChem/'
path = '/home/kristineom/Documents/phdgreier/ice_cores/betzy/'
else:
path = '/home/kristineom/Documents/phdgreier/ice_cores/betzy/' # Betzy
####################################3
if 'GISS-E2-1-' in model:
histpr = 'NS9252K/ESGF/CMIP6/CMIP/NASA-GISS/'+model+'/historical/r1i1p3f1/Amon/pr/gn/v20*/*'
ctrlpr = 'NS9252K/ESGF/CMIP6/CMIP/NASA-GISS/'+model+'/piControl/r1i1p3f1/Amon/pr/gn/v20*/*'
area = 'NS9252K/ESGF/CMIP6/CMIP/NASA-GISS/'+model+'/piControl/r1i1p3f1/fx/areacella/gn/latest/areacella_fx_'+model+'_piControl_r1i1p3f1_gn.nc'
elif 'EC-Earth3-AerChem' in model:
#histpr = 'NS9252K/ESGF/CMIP6/CMIP/EC-Earth-Consortium/EC-Earth3-AerChem/historical/r1i1p1f1/Amon/pr/gr/v*/*'
histpr = 'pr_Amon_EC-Earth3-AerChem_historical_r1i1p1f1_gn_185001-201412.nc'
ctrlpr = 'NS9252K/ESGF/CMIP6/CMIP/EC-Earth-Consortium/EC-Earth3-AerChem/piControl/r1i1p1f1/Amon/pr/gr/v*/*'
#area = 'NS9252K/ESGF/CMIP6/CMIP/EC-Earth-Consortium/EC-Earth3-AerChem/historical/r1i1p1f1/fx/areacella/gr/latest/areacella_fx_EC-Earth3-AerChem_historical_r1i1p1f1_gr.nc'
area = 'areacella_fx_EC-Earth3-AerChem_historical_r1i1p1f1_gn.nc'
elif 'MPI-ESM-1-2-HAM' in model:
histpr = 'NS9252K/ESGF/CMIP6/CMIP/HAMMOZ-Consortium/MPI-ESM-1-2-HAM/historical/r1i1p1f1/Amon/pr/gn/v*/*'
ctrlpr = 'NS9252K/ESGF/CMIP6/CMIP/HAMMOZ-Consortium/MPI-ESM-1-2-HAM/piControl/r1i1p1f1/Amon/pr/gn/v*/*'
area = 'NS9252K/ESGF/CMIP6/CMIP/HAMMOZ-Consortium/MPI-ESM-1-2-HAM/historical/r1i1p1f1/fx/areacella/gn/latest/areacella_fx_MPI-ESM-1-2-HAM_historical_r1i1p1f1_gn.nc'
elif 'CESM2' in model:
histpr = 'NS9252K/ESGF/CMIP6/CMIP/NCAR/'+model+'/historical/r1i1p1f1/Amon/pr/gn/v*/*.nc'
ctrlpr = 'NS9252K/ESGF/CMIP6/CMIP/NCAR/'+model+'/piControl/r1i1p1f1/Amon/pr/gn/v*/*.nc'
area = 'NS9252K/ESGF/CMIP6/CMIP/NCAR/'+model+'/historical/r1i1p1f1/fx/areacella/gn/latest/areacella_fx_'+model+'_historical_r1i1p1f1_gn.nc'
elif 'CanESM5' in model:
histpr = 'NS9252K/ESGF/CMIP6/CMIP/CCCma/CanESM5/historical/r1i1p1f1/Amon/pr/gn/latest/*'
ctrlpr = 'NS9252K/ESGF/CMIP6/CMIP/CCCma/CanESM5/piControl/r1i1p1f1/Amon/pr/gn/latest/*'
area = 'NS9252K/ESGF/CMIP6/CMIP/CCCma/CanESM5/historical/r1i1p1f1/fx/areacella/gn/latest/areacella_fx_CanESM5_historical_r1i1p1f1_gn.nc'
elif 'INM-CM' in model:
histpr = 'NS9252K/ESGF/CMIP6/CMIP/INM/'+model+'/historical/r1i1p1f1/Amon/pr/gr1/v*/*'
ctrlpr = 'NS9252K/ESGF/CMIP6/CMIP/INM/'+model+'/piControl/r1i1p1f1/Amon/pr/gr1/v*/*'
if '5-0' in model:
area = 'NS9252K/ESGF/CMIP6/CMIP/INM/INM-CM5-0/historical/r1i1p1f1/fx/areacella/gr1/latest/areacella_fx_INM-CM5-0_historical_r1i1p1f1_gr1.nc'
else:
area = 'NS9252K/ESGF/CMIP6/CMIP/INM/'+model+'/piControl/r1i1p1f1/fx/areacella/gr1/latest/areacella_fx_'+model+'_piControl_r1i1p1f1_gr1.nc'
elif 'GFDL-ESM4' in model:
histpr = 'NS9252K/ESGF/CMIP6/CMIP/NOAA-GFDL/GFDL-ESM4/historical/r1i1p1f1/Amon/pr/gr1/v*/*'
ctrlpr = 'NS9252K/ESGF/CMIP6/CMIP/NOAA-GFDL/GFDL-ESM4/piControl/r1i1p1f1/Amon/pr/gr1/v*/*'
area = 'NS9252K/ESGF/CMIP6/CMIP/NOAA-GFDL/GFDL-ESM4/historical/r1i1p1f1/fx/areacella/gr1/latest/areacella_fx_GFDL-ESM4_historical_r1i1p1f1_gr1.nc'
elif 'CNRM-ESM2-1' in model:
histpr = 'NS9252K/ESGF/CMIP6/CMIP/CNRM-CERFACS/CNRM-ESM2-1/historical/r1i1p1f2/Amon/pr/gr/v*/*'
ctrlpr = 'NS9252K/ESGF/CMIP6/CMIP/CNRM-CERFACS/CNRM-ESM2-1/piControl/r1i1p1f2/Amon/pr/gr/v*/*'
area = 'NS9252K/ESGF/CMIP6/CMIP/CNRM-CERFACS/CNRM-CM6-1/historical/r1i1p1f2/fx/areacella/gr/latest/areacella_fx_CNRM-CM6-1_historical_r1i1p1f2_gr.nc'
elif 'MRI-ESM2-0' in model:
# MRI HAS SPECIAL AREACELLA FILE LOCATED IN SAME DIRECTORY AS LOCAL EC-EARTH #
histpr = 'NS9252K/ESGF/CMIP6/CMIP/MRI/MRI-ESM2-0/historical/r1i1p1f1/Amon/pr/gn/latest/*'
ctrlpr = 'NS9252K/ESGF/CMIP6/CMIP/MRI/MRI-ESM2-0/piControl/r1i1p1f1/Amon/pr/gn/latest/*'
area = areapath+'areacella_fx_MRI-ESM2-0_historical_r1i1p1f1_gn_TL95_192x96.nc'
elif 'MIROC6' in model:
histpr = 'NS9252K/ESGF/CMIP6/CMIP/MIROC/MIROC6/historical/r1i1p1f1/Amon/pr/gn/latest/*'
ctrlpr = 'NS9252K/ESGF/CMIP6/CMIP/MIROC/MIROC6/piControl/r1i1p1f1/Amon/pr/gn/latest/*'
area = 'NS9252K/ESGF/CMIP6/CMIP/MIROC/MIROC6/historical/r1i1p1f1/fx/areacella/gn/latest/areacella_fx_MIROC6_historical_r1i1p1f1_gn.nc'
elif 'NorESM2' in model:
histpr = 'CMIP6/CMIP/NCC/'+model+'/historical/r1i1p1f1/Amon/pr/gn/latest/*'
ctrlpr = 'CMIP6/CMIP/NCC/'+model+'/piControl/r1i1p1f1/Amon/pr/gn/latest/*'
area = 'CMIP6/CMIP/NCC/NorESM2-LM/historical/r1i1p1f1/fx/areacella/gn/latest/areacella_fx_NorESM2-LM_historical_r1i1p1f1_gn.nc'
if 'MRI' in model:
return path+histpr, path+ctrlpr, area
else:
return path+histpr, path+ctrlpr, path+area
def pathfinder_var(model,var):
###### CHANGE VARIABLE path DEPENDING ON WHAT MACHINE YOU ARE ON ######
if 'NorESM' in model:
path = '/home/kristineom/Documents/phdgreier/lifetimes/noresm/'
else:
path = '/home/kristineom/Documents/phdgreier/ice_cores/betzy/'
####################################################################
if 'GISS-E2-1-' in model:
# Both models have pr and bc as below
hist = 'NS9252K/ESGF/CMIP6/CMIP/NASA-GISS/'+model+'/historical/r1i1p3f1/AERmon/'+var+'/gn/latest/*'
elif 'EC-Earth3-AerChem' in model:
hist = 'NS9252K/ESGF/CMIP6/CMIP/EC-Earth-Consortium/EC-Earth3-AerChem/historical/r1i1p1f1/AERmon/'+var+'/gn/v*/*'
elif 'MPI-ESM-1-2-HAM' in model:
hist = 'NS9252K/ESGF/CMIP6/CMIP/HAMMOZ-Consortium/MPI-ESM-1-2-HAM/historical/r3i1p1f1/AERmon/'+var+'/gn/v*/*'
elif 'CESM2' in model:
# both models have pr and bc as below
hist = 'NS9252K/ESGF/CMIP6/CMIP/NCAR/'+model+'/historical/r1i1p1f1/AERmon/'+var+'/gn/latest/*'
elif 'CanESM5' in model:
# Has pr and bc as below
hist = 'NS9252K/ESGF/CMIP6/CMIP/CCCma/CanESM5/historical/r1i1p1f1/AERmon/'+var+'/gn/latest/*'
elif 'INM-CM' in model:
# Both models have pr and bc as below
hist = 'NS9252K/ESGF/CMIP6/CMIP/INM/'+model+'/historical/r1i1p1f1/AERmon/'+var+'/gr1/latest/*'
elif 'GFDL-ESM4' in model:
# Has pr and bc as below
hist = 'NS9252K/ESGF/CMIP6/CMIP/NOAA-GFDL/GFDL-ESM4/historical/r1i1p1f1/AERmon/'+var+'/gr1/latest/*'
elif 'CNRM-ESM2-1' in model:
# Has pr and bc as below
hist = 'NS9252K/ESGF/CMIP6/CMIP/CNRM-CERFACS/CNRM-ESM2-1/historical/r1i1p1f2/AERmon/'+var+'/gr/latest/'+var+'*'
elif 'MRI-ESM2-0' in model:
hist = 'NS9252K/ESGF/CMIP6/CMIP/MRI/MRI-ESM2-0/historical/r1i1p1f1/AERmon/'+var+'/gn/latest/*'
elif 'MIROC6' in model:
hist = 'NS9252K/ESGF/CMIP6/CMIP/MIROC/MIROC6/historical/r1i1p1f1/AERmon/'+var+'/gn/v*/*'
elif 'NorESM2' in model:
# Both has pr as below
# MM is missing both so4 and bc in piControl
hist = 'CMIP6/CMIP/NCC/'+model+'/historical/r1i1p1f1/AERmon/'+var+'/gn/latest/*'
return path+hist
def pathfinder_damip(model,var,mon):
if 'CESM2' in model:
# both models have pr and bc as below
hist = 'NS9252K/ESGF/CMIP6/DAMIP/NCAR/'+model+'/hist-nat/r1i1p1f1/'+mon+'mon/'+var+'/gn/latest/*'
elif 'CanESM5' in model:
# Has pr and bc as below
hist = 'NS9252K/ESGF/CMIP6/DAMIP/CCCma/CanESM5/hist-nat/r1i1p1f1/'+mon+'mon/'+var+'/gn/latest/*'
elif 'NorESM2' in model:
# Both has pr as below
# MM is missing both so4 and bc in piControl
hist = 'CMIP6/DAMIP/NCC/'+model+'/hist-nat/r1i1p1f1/'+mon+'mon/'+var+'/gn/latest/*'
return hist
"""
histwet = '/historical/r1i1p1f1/AERmon/wet'+var+'/gn/v*/*'
histdry = '/historical/r1i1p1f1/AERmon/dry'+var+'/gn/v*/*'
ctrlwet = '/piControl/r1i1p1f1/AERmon/wet'+var+'/gn/v*/*'
ctrldry = '/piControl/r1i1p1f1/AERmon/dry'+var+'/gn/v*/*'
"""