@@ -133,16 +133,17 @@ def add_region(fig, ax, lons, lats, data):
133133 return fig , ax , im
134134
135135
136- def make_figure (region ):
136+ def make_figure (region , orcaGridfn = None ):
137137 """
138138 Make a figure for this region.
139139 """
140140 fig_fn = bvt .folder ('images/regions' )+ region + '.png'
141141
142- paths_dict , config_user = get_run_configuration ("defaults" )
143- # filter paths dict into an object that's usable below
144- paths = paths_setter (paths_dict )
145- orcaGridfn = paths .orcaGridfn
142+ if not orcaGridfn :
143+ paths_dict , config_user = get_run_configuration ("defaults" )
144+ # filter paths dict into an object that's usable below
145+ paths = paths_setter (paths_dict )
146+ orcaGridfn = paths .orcaGridfn
146147
147148 nc = Dataset (orcaGridfn , 'r' )
148149 dat = nc .variables ['mbathy' ][:].squeeze ()
@@ -216,19 +217,21 @@ def make_figure(region):
216217
217218
218219
219- def calc_area (region ):
220+ def calc_area (region , orcaGridfn = None ):
220221 """
221222 Calculate the area for this region.
222223 """
223224
224- paths_dict , config_user = get_run_configuration ("defaults" )
225- # filter paths dict into an object that's usable below
226- paths = paths_setter (paths_dict )
227- orcaGridfn = paths .orcaGridfn
225+ if not orcaGridfn :
226+ paths_dict , config_user = get_run_configuration ("defaults" )
227+ paths = paths_setter (paths_dict )
228+ orcaGridfn = paths .orcaGridfn
229+ print ('calc_area: opening:' , orcaGridfn )
228230
229231 nc = Dataset (orcaGridfn , 'r' )
230232 dat = nc .variables ['mbathy' ][:].squeeze ()
231- area = nc .variables ['area' ][:].squeeze ()
233+ #area = nc.variables['area'][:].squeeze()
234+ area = nc .variables ['e2t' ][:]* nc .variables ['e1t' ][:]
232235 lats = nc .variables ['nav_lat' ][:].squeeze ()
233236 lons = nc .variables ['nav_lon' ][:].squeeze ()
234237 lons = bvt .makeLonSafeArr (lons )
@@ -247,12 +250,12 @@ def calc_area(region):
247250 region_mask = makeMask ('bathy' , region , xt , xz , xy , xx , xd , debug = True )
248251
249252 new_area = np .ma .masked_where (region_mask + old_mask_flat , flat_area )
250-
251- print ('region:' , new_area . sum () )
253+ total_area = new_area . sum ()
254+ print ('region:' , total_area )
252255
253256
254257 out_fn = bvt .folder ('region_areas' )+ region + '.txt'
255- txt = '' .join ([region , ', ' , str (int (area )), '\n ' ])
258+ txt = '' .join ([region , ', ' , str (int (total_area )), '\n ' ])
256259 fn = open (out_fn , 'w' )
257260 fn .write (txt )
258261 fn .close ()
@@ -264,38 +267,46 @@ def calc_area(region):
264267
265268def main ():
266269# paths_dict, config_user = get_run_configuration("defaults")
270+ paths_dict , config_user = get_run_configuration ("defaults" )
271+ # filter paths dict into an object that's usable below
272+ paths = paths_setter (paths_dict )
273+ orcaGridfn = paths .orcaGridfn
274+
267275
268276 regions = [
269- # 'LIseas',
270- # 'LIGINseas',
271- # 'GLINseas',
272- # 'Ascension',
273- # 'ITCZ',
277+ 'LIseas' ,
278+ 'LIGINseas' ,
279+ 'GLINseas' ,
280+ 'Ascension' ,
281+ # 'ITCZ',
274282# 'TristandaCunha',
275283# 'Pitcairn',
276- # 'Cornwall',
277- # 'SubtropicNorthAtlantic',
278- # 'SPNA',
279- # 'STNA',
284+ 'Cornwall' ,
285+ 'SubtropicNorthAtlantic' ,
286+ 'SPNA' ,
287+ 'STNA' ,
280288 'SouthernOcean' ,
281289 'subpolar' ,
282290 'NorthEastAtlantic' ,
283- # 'ArcticOcean',
284- # 'Equator10',
285- # 'NorthPacificOcean',
291+ 'ArcticOcean' ,
292+ 'Equator10' ,
293+ 'NorthPacificOcean' ,
294+ 'SouthAtlanticOcean' ,
295+ 'NorthernSubpolarPacific' ,
296+ 'NorthernSubpolarAtlantic' ,
297+ 'SouthPacificOcean' ,
298+ 'NorthAtlanticOcean' ,
286299 'SouthAtlanticOcean' ,
287- # 'SouthPacificOcean',
288- # 'NorthAtlanticOcean',
289- # 'SouthAtlanticOcean',
290- # 'GINseas',
291- # 'LabradorSea',
292- # 'IrmingerSea',
300+ 'GINseas' ,
301+ 'LabradorSea' ,
302+ 'IrmingerSea' ,
293303 'EquatorialAtlanticOcean' ,
294- # 'Global',
295- # 'ignoreInlandSeas',
304+ 'Global' ,
305+ 'ignoreInlandSeas' ,
296306 ]
297307 for region in regions [:]:
298- make_figure (region )
308+ calc_area (region , orcaGridfn = orcaGridfn )
309+ make_figure (region , orcaGridfn = orcaGridfn )
299310
300311if __name__ == "__main__" :
301312 main ()
0 commit comments