From d8a888412eea75938ca56a9147af936728810a7a Mon Sep 17 00:00:00 2001 From: Lee de Mora Date: Wed, 13 Dec 2023 10:36:53 +0000 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Valeriu Predoi --- bgcval2/bgcval2_make_report.py | 9 +++------ bgcval2/functions/circulation.py | 7 ------- bgcval2/p2p/matchDataAndModel.py | 3 +-- bgcval2/revert_shelves.py | 8 +++----- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/bgcval2/bgcval2_make_report.py b/bgcval2/bgcval2_make_report.py index 8c12805c..4eae28b2 100755 --- a/bgcval2/bgcval2_make_report.py +++ b/bgcval2/bgcval2_make_report.py @@ -984,10 +984,10 @@ def newImageLocation(fn): outlevels = {} for i, fn in enumerate(l2Fields): for lv in levels: - if fn.find(lv)>-1: - outlevels[lv]= True + if fn.find(lv) > -1: + outlevels[lv] = True fn = fn.replace(lv, '') - outdict[fn]= True + outdict[fn] = True l2Fields = [key for key, v in outdict.items()] slices = [key for key, v in outlevels.items()] @@ -1000,7 +1000,6 @@ def newImageLocation(fn): Descriptions = {} FileLists = {} FileOrder = {} - #print(l2Fields, slices) for key in sorted(l2Fields): #if key not in ['Alkalinity','Nitrate']: continue @@ -1546,8 +1545,6 @@ def newImageLocation(fn): if found: continue sectionTitle = 'Physics Key Metrics' if fn.find(key) > -1: -# if key in ['MA_SST', 'MA_SSS', 'MA_Nitrate',] and fn.find('Global_Surface') < 0: -# continue try: categories[sectionTitle].append(fn) except: diff --git a/bgcval2/functions/circulation.py b/bgcval2/functions/circulation.py index 775e16f9..7af0d624 100644 --- a/bgcval2/functions/circulation.py +++ b/bgcval2/functions/circulation.py @@ -304,18 +304,11 @@ def twentysixnorth025(nc,keys,**kwargs): continue if not depths[t, z, la, lo] or np.ma.is_masked(depths[t, z, la, lo]): continue -# if not alttmask_AMOC26N[la, lo]: -# continue -# if not tmask_AMOC26N[z, la, lo]: -# continue -# if np.ma.is_masked(zv[0, z, la, lo]): -# continue atlmoc[z, la] = atlmoc[z, la] - e1v[t, 0, la, lo] * thkcello[t, z, la, lo] * vo[t, z, la, lo] / 1.E06 for z in range(thkcello.shape[1] -2, 1, -1): # add from the bottom up atlmoc[z, :] = atlmoc[z+1, :] + atlmoc[z, :] print('AMOC:', atlmoc.max()) - #assert 0 return atlmoc.max() diff --git a/bgcval2/p2p/matchDataAndModel.py b/bgcval2/p2p/matchDataAndModel.py index 2a9593fb..f470c46f 100755 --- a/bgcval2/p2p/matchDataAndModel.py +++ b/bgcval2/p2p/matchDataAndModel.py @@ -943,7 +943,6 @@ def loadMesh(self, modelfile=None): if not set(ncER.variables.keys()).intersection(set(depthNames)): print('load mesh: no depth field available in ', modelfile) self.depthcc = np.array([0]) -# assert 0 # self.depthcc = choose_best_ncvar(ncER, depthNames)[:] self.datescc = var_to_datetime(ncER.variables[self.modelcoords['t']]) @@ -1135,7 +1134,7 @@ def var_to_datetime(ncvar): if units in ['months since 0000-01-01 00:00:00', ]: units = 'months since 2000-01-01 00:00:00' return num2date(ncvar[:], 'months since 2000-01-01 00:00:00', calendar='360_day') - elif units.find('months since')>-1: + elif units.find('months since') > -1: return num2date(ncvar[:], units, calendar='360_day') return num2date(ncvar[:], ncvar.units, calendar=calendar) diff --git a/bgcval2/revert_shelves.py b/bgcval2/revert_shelves.py index 564efa83..b9a2d152 100644 --- a/bgcval2/revert_shelves.py +++ b/bgcval2/revert_shelves.py @@ -13,8 +13,6 @@ from bgcval2.Paths.paths import paths_setter - - def get_paths( config_user=None ): @@ -84,12 +82,12 @@ def remove_data(jobID, # generate a time key from year/month. if month: - if isinstance(month, str) and len(month) ==1: + if isinstance(month, str) and len(month) == 1: month = int(month) if isinstance(month, int): month = bvt.mnStr(month) - time_key = year+month + time_key = year + month else: time_key = year @@ -186,7 +184,7 @@ def get_args(): default=['all',], nargs='+', type=str, - help='One or more datasets - default is everything. ', + help='One or more datasets - default is everything (all available keys). ', required=False) parser.add_argument('-d',