@@ -73,6 +73,17 @@ def CMIP6_member(member):
7373
7474# Members to loop through
7575
76+
77+ # Create directory on scratch to save the data
78+ scratchdatadir = '/scratch/xv83/TMIP/data'
79+
80+ # Depends on time window
81+ start_time , end_time = time_window_strings (year_start , num_years )
82+ start_time_str = f'Jan{ start_time } '
83+ end_time_str = f'Dec{ end_time } '
84+
85+
86+
7687def inputdirfun (member ):
7788 return f'{ scratchdatadir } /{ model } /{ experiment } /{ CMIP6_member (member )} /{ start_time_str } -{ end_time_str } /cyclo{ lumpby } '
7889
@@ -83,8 +94,12 @@ def isvalidmember(member):
8394 return os .path .isfile (inputfilepathfun (member ))
8495
8596members = [m for m in range (1 , 41 ) if isvalidmember (m )]
97+
98+ # # For debugging only
99+ # members = members[0:2]
100+
86101paths = [inputfilepathfun (m ) for m in members ]
87- members_axis = pd .Index (members , name = "members " )
102+ members_axis = pd .Index (members , name = "member " )
88103
89104
90105# function to open all files and combine them
@@ -93,11 +108,11 @@ def open_my_dataset(paths):
93108 ds = xr .open_mfdataset (
94109 paths ,
95110 chunks = {'Ti' :- 1 , 'lev' :- 1 }, # TODO these dim names likely won't work for my Gammas
96- concat_dim = members_axis , # TODO these dim names likely won't work for my Gammas
111+ concat_dim = [ members_axis ] , # TODO these dim names likely won't work for my Gammas
97112 compat = 'override' ,
98113 preprocess = None ,
99114 engine = 'netcdf4' ,
100- data_vars = 'minimal' ,
115+ # data_vars='minimal', # <- cannot have this option otherwise only one member is loaded it seems
101116 coords = 'minimal' ,
102117 combine = 'nested' ,
103118 parallel = True ,
@@ -109,29 +124,19 @@ def open_my_dataset(paths):
109124
110125
111126
112- # Create directory on scratch to save the data
113- scratchdatadir = '/scratch/xv83/TMIP/data'
114-
115- # Depends on time window
116- start_time , end_time = time_window_strings (year_start , num_years )
117- start_time_str = f'Jan{ start_time } '
118- end_time_str = f'Dec{ end_time } '
119-
120-
121127
122128outputdir = f'{ scratchdatadir } /{ model } /{ experiment } /all_members/{ start_time_str } -{ end_time_str } /cyclo{ lumpby } '
123129print ("Creating directory: " , outputdir )
124130os .makedirs (outputdir , exist_ok = True )
125- print (" averaging data from: " , inputdir )
126131print (" to be saved in: " , outputdir )
127132
128133print ("Starting client" )
129134
130135# This `if` statement is required in scripts (not required in Jupyter)
131136if __name__ == '__main__' :
132- client = Client (n_workers = 44 , threads_per_worker = 1 )
137+ client = Client (n_workers = 40 , threads_per_worker = 1 )
133138
134- age_ds = open_my_dataset (paths [ 0 : 2 ] )
139+ age_ds = open_my_dataset (paths )
135140 print ("\n age_ds: " , age_ds )
136141 age = age_ds .age
137142 print ("\n age: " , age )
0 commit comments