From 435d9d4647b65bed2c61d9ae2e81e073b82ba137 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Thu, 21 Jul 2022 13:20:13 -0400 Subject: [PATCH 01/22] remove rst_dir for MERRA-2 --- .../post/remap_restart/remap_analysis.py | 66 +++++++++++ .../post/remap_restart/remap_catchANDcn.py | 26 +++++ .../remap_lake_landice_saltwater.py | 29 +++++ GEOS_Util/post/remap_restart/remap_params.py | 103 ------------------ GEOS_Util/post/remap_restart/remap_params.tpl | 1 + .../post/remap_restart/remap_questions.py | 21 ++-- .../post/remap_restart/remap_restarts.py | 4 - GEOS_Util/post/remap_restart/remap_upper.py | 31 ++++++ 8 files changed, 161 insertions(+), 120 deletions(-) diff --git a/GEOS_Util/post/remap_restart/remap_analysis.py b/GEOS_Util/post/remap_restart/remap_analysis.py index 0990f497..eab791db 100755 --- a/GEOS_Util/post/remap_restart/remap_analysis.py +++ b/GEOS_Util/post/remap_restart/remap_analysis.py @@ -19,6 +19,8 @@ class analysis(remap_base): def __init__(self, **configs): super().__init__(**configs) + if self.config['input']['shared']['MERRA-2']: + self.copy_merra2() def remap(self): config = self.config @@ -132,6 +134,70 @@ def find_analysis(self): analysis_in = bkgs + sfcs + traks + anasat return list(dict.fromkeys(analysis_in)) + def copy_merra2(self): + if not self.config['input']['shared']['MERRA-2']: + return + bkg = self.config['output']['shared'][['bkg'] + if ( not bkg ): return + + expid = self.config['input']['shared']['expid'] + yyyymmddhh_ = str(self.config['input']['shared']['yyyymmddhh']) + yyyy_ = yyyymmddhh_[0:4] + mm_ = yyyymmddhh_[4:6] + dd_ = yyyymmddhh_[6:8] + hh_ = yyyymmddhh_[8:10] + + merra_2_rst_dir = '/archive/users/gmao_ops/MERRA2/gmao_ops/GEOSadas-5_12_4/'+expid +'/rs/Y'+yyyy_ +'/M'+mm_+'/' + rst_dir = self.config['input']['shared']['rst_dir'] + '/' + os.makedirs(rst_dir, exist_ok = True) + print(' Copy MERRA-2 analysis files \n from \n ' + merra_2_rst_dir + '\n to\n '+ rst_dir +'\n') + + rst_time = datetime(year=int(yyyy_), month=int(mm_), day=int(dd_), hour = int(hh_)) + + anafiles=[] + for h in [3,4,5,6,7,8,9]: + delt = timedelta(hours = h-3) + new_time = rst_time + delt + yyyy = "Y"+str(new_time.year) + mm = 'M%02d'%new_time.month + ymd = '%04d%02d%02d'%(new_time.year,new_time.month, new_time.day) + hh = '%02d'%h + newhh= '%02d'%new_time.hour + m2_rst_dir = merra_2_rst_dir.replace('Y'+yyyy_,yyyy).replace('M'+mm_,mm) + # bkg files + for ftype in ['sfc', 'eta']: + fname = expid + '.bkg'+hh+'_'+ftype+'_rst.'+ymd+'_'+newhh+'z.nc4' + f = m2_rst_dir+'/'+fname + if(os.path.isfile(f)): + anafiles.append(f) + else: + print('Warning: Cannot find '+f) + + # gaas_bkg_sfc files + if (h==6 or h==9): + fname = expid+'.gaas_bkg_sfc_rst.'+ymd+'_'+newhh+'z.nc4' + f = m2_rst_dir+'/'+fname + if (os.path.isfile(f)): + anafiles.append(f) + else: + print('Warning: Cannot find '+f) + # trak.GDA.rst file + delt = timedelta(hours = 3) + new_time = rst_time - delt + yyyy = "Y"+str(new_time.year) + mm = 'M%02d'%new_time.month + ymdh = '%04d%02d%02d%02d'%(new_time.year, new_time.month, new_time.day, new_time.hour) + m2_rst_dir = merra_2_rst_dir.replace('Y'+yyyy_,yyyy).replace('M'+mm_,mm) + fname = expid+'.trak.GDA.rst.'+ymdh+'z.txt' + f = m2_rst_dir+'/'+fname + if (os.path.isfile(f)): anafiles.append(f) + + for f in anafiles: + fname = os.path.basename(f) + f_tmp = rst_dir+'/'+fname + print("Copy file "+f +" to " + rst_dir) + shutil.copy(f,f_tmp) + if __name__ == '__main__' : ana = analysis(params_file='remap_params.yaml') ana.remap() diff --git a/GEOS_Util/post/remap_restart/remap_catchANDcn.py b/GEOS_Util/post/remap_restart/remap_catchANDcn.py index 44337f3e..1ef13cad 100755 --- a/GEOS_Util/post/remap_restart/remap_catchANDcn.py +++ b/GEOS_Util/post/remap_restart/remap_catchANDcn.py @@ -12,6 +12,8 @@ class catchANDcn(remap_base): def __init__(self, **configs): super().__init__(**configs) + if self.config['input']['shared']['MERRA-2']: + self.copy_merra2() def remap(self): if not self.config['output']['surface']['remap_catch']: @@ -129,6 +131,30 @@ def remap(self): print( "cd " + cwdir) os.chdir(cwdir) + def copy_merra2(self): + if not self.config['input']['shared']['MERRA-2']: + return + + expid = self.config['input']['shared']['expid'] + yyyymmddhh_ = str(self.config['input']['shared']['yyyymmddhh']) + yyyy_ = yyyymmddhh_[0:4] + mm_ = yyyymmddhh_[4:6] + dd_ = yyyymmddhh_[6:8] + hh_ = yyyymmddhh_[8:10] + + suffix = yyyymmddhh_[0:8]+'_'+ hh_ + 'z.bin' + merra_2_rst_dir = '/archive/users/gmao_ops/MERRA2/gmao_ops/GEOSadas-5_12_4/'+expid +'/rs/Y'+yyyy_ +'/M'+mm_+'/' + rst_dir = self.config['input']['shared']['rst_dir'] + '/' + os.makedirs(rst_dir, exist_ok = True) + print(' Copy MERRA-2 catchment Restart \n from \n ' + merra_2_rst_dir + '\n to\n '+ rst_dir +'\n') + + f = merra_2_rst_dir + expid+'.catch_internal_rst.' + suffix + + fname = os.path.basename(f) + dest = rst_dir + '/'+fname + print("Copy file "+f +" to " + rst_dir) + shutil.copy(f, dest) + if __name__ == '__main__' : catch = catchANDcn(params_file='remap_params.yaml') catch.remap() diff --git a/GEOS_Util/post/remap_restart/remap_lake_landice_saltwater.py b/GEOS_Util/post/remap_restart/remap_lake_landice_saltwater.py index 4d25ae33..76cb9809 100755 --- a/GEOS_Util/post/remap_restart/remap_lake_landice_saltwater.py +++ b/GEOS_Util/post/remap_restart/remap_lake_landice_saltwater.py @@ -11,6 +11,8 @@ class lake_landice_saltwater(remap_base): def __init__(self, **configs): super().__init__(**configs) + if self.config['input']['shared']['MERRA-2']: + self.copy_merra2() def remap(self): if not self.config['output']['surface']['remap_water']: @@ -164,6 +166,33 @@ def find_rst(self): return restarts_in + def copy_merra2(self): + if not self.config['input']['shared']['MERRA-2']: + return + + expid = self.config['input']['shared']['expid'] + yyyymmddhh_ = str(self.config['input']['shared']['yyyymmddhh']) + yyyy_ = yyyymmddhh_[0:4] + mm_ = yyyymmddhh_[4:6] + dd_ = yyyymmddhh_[6:8] + hh_ = yyyymmddhh_[8:10] + + suffix = yyyymmddhh_[0:8]+'_'+ hh_ + 'z.bin' + merra_2_rst_dir = '/archive/users/gmao_ops/MERRA2/gmao_ops/GEOSadas-5_12_4/'+expid +'/rs/Y'+yyyy_ +'/M'+mm_+'/' + rst_dir = self.config['input']['shared']['rst_dir'] + '/' + os.makedirs(rst_dir, exist_ok = True) + print(' Copy MERRA-2 surface restarts \n from \n ' + merra_2_rst_dir + '\n to\n '+ rst_dir +'\n') + + surfin = [ merra_2_rst_dir + expid+'.lake_internal_rst.' + suffix, + merra_2_rst_dir + expid+'.landice_internal_rst.' + suffix, + merra_2_rst_dir + expid+'.saltwater_internal_rst.'+ suffix] + + for f in surfin : + fname = os.path.basename(f) + dest = rst_dir + '/'+fname + print("Copy file "+f +" to " + rst_dir) + shutil.copy(f, dest) + if __name__ == '__main__' : lls = lake_landice_saltwater(params_file='remap_params.yaml') lls.remap() diff --git a/GEOS_Util/post/remap_restart/remap_params.py b/GEOS_Util/post/remap_restart/remap_params.py index cd5ec03c..7f1e93da 100755 --- a/GEOS_Util/post/remap_restart/remap_params.py +++ b/GEOS_Util/post/remap_restart/remap_params.py @@ -268,109 +268,6 @@ def init_merra2(self): self.common_in['bc_base']= 'discover_ops' self.common_in['tag']= 'Ganymed-4_0' - def copy_merra2(self): - if not self.common_in['MERRA-2']: - return - print("\n Copy MERRA-2 :\n") - expid = self.common_in['expid'] - yyyymmddhh_ = str(self.common_in['yyyymmddhh']) - surfix = yyyymmddhh_[0:8]+'_'+self.hh+'z.bin' - merra_2_rst_dir = '/archive/users/gmao_ops/MERRA2/gmao_ops/GEOSadas-5_12_4/'+expid +'/rs/Y'+self.yyyy +'/M'+self.mm+'/' - rst_dir = self.common_in['rst_dir'] + '/' - os.makedirs(rst_dir, exist_ok = True) - print(' Copy MERRA-2 Restart \n from \n ' + merra_2_rst_dir + '\n to\n '+ rst_dir +'\n') - - upperin =[merra_2_rst_dir + expid+'.fvcore_internal_rst.' + surfix, - merra_2_rst_dir + expid+'.moist_internal_rst.' + surfix, - merra_2_rst_dir + expid+'.agcm_import_rst.' + surfix, - merra_2_rst_dir + expid+'.gocart_internal_rst.' + surfix, - merra_2_rst_dir + expid+'.pchem_internal_rst.' + surfix ] - - surfin = [ merra_2_rst_dir + expid+'.catch_internal_rst.' + surfix, - merra_2_rst_dir + expid+'.lake_internal_rst.' + surfix, - merra_2_rst_dir + expid+'.landice_internal_rst.' + surfix, - merra_2_rst_dir + expid+'.saltwater_internal_rst.'+ surfix] - - for f in upperin : - fname = os.path.basename(f) - dest = rst_dir + '/'+fname - print("Copy file "+f +" to " + rst_dir) - shutil.copy(f, dest) - - for f in surfin : - fname = os.path.basename(f) - dest = rst_dir + '/'+fname - print("Copy file "+f +" to " + rst_dir) - shutil.copy(f, dest) - - # prepare analysis files - bkg = self.ana_out['bkg'] - if ( not bkg ): return - yyyy_ = yyyymmddhh_[0:4] - mm_ = yyyymmddhh_[4:6] - dd_ = yyyymmddhh_[6:8] - hh_ = yyyymmddhh_[8:10] - rst_time = datetime(year=int(yyyy_), month=int(mm_), day=int(dd_), hour = int(hh_)) - expid_in = self.common_in['expid'] - expid_out = self.common_out['expid'] - if (expid_out) : - expid_out = expid_out + '.' - else: - expid_out = '' - - agrid_in = self.common_in['agrid'] - agrid_out = self.common_out['agrid'] - - anafiles=[] - for h in [3,4,5,6,7,8,9]: - delt = timedelta(hours = h-3) - new_time = rst_time + delt - yyyy = "Y"+str(new_time.year) - mm = 'M%02d'%new_time.month - ymd = '%04d%02d%02d'%(new_time.year,new_time.month, new_time.day) - hh = '%02d'%h - newhh= '%02d'%new_time.hour - m2_rst_dir = merra_2_rst_dir.replace('Y'+yyyy_,yyyy).replace('M'+mm_,mm) - # bkg files - for ftype in ['sfc', 'eta']: - fname = expid_in+'.bkg'+hh+'_'+ftype+'_rst.'+ymd+'_'+newhh+'z.nc4' - f = m2_rst_dir+'/'+fname - if(os.path.isfile(f)): - anafiles.append(f) - else: - print('Warning: Cannot find '+f) - # cbkg file - fname = expid_in + '.cbkg' + hh + '_eta_rst.' + ymd + '_' + newhh + 'z.nc4' - f = m2_rst_dir+'/'+fname - if(os.path.isfile(f)): - anafiles.append(f) - else: - print('Warning: Cannot find '+f) - # gaas_bkg_sfc files - if (h==6 or h==9): - fname = expid_in+'.gaas_bkg_sfc_rst.'+ymd+'_'+newhh+'z.nc4' - f = m2_rst_dir+'/'+fname - if (os.path.isfile(f)): - anafiles.append(f) - else: - print('Warning: Cannot find '+f) - # trak.GDA.rst file - delt = timedelta(hours = 3) - new_time = rst_time - delt - yyyy = "Y"+str(new_time.year) - mm = 'M%02d'%new_time.month - ymdh = '%04d%02d%02d%02d'%(new_time.year, new_time.month, new_time.day, new_time.hour) - m2_rst_dir = merra_2_rst_dir.replace('Y'+yyyy_,yyyy).replace('M'+mm_,mm) - fname = expid_in+'.trak.GDA.rst.'+ymdh+'z.txt' - f = m2_rst_dir+'/'+fname - if (os.path.isfile(f)): anafiles.append(f) - - for f in anafiles: - fname = os.path.basename(f) - f_tmp = rst_dir+'/'+fname - print("Copy file "+f +" to " + rst_dir) - shutil.copy(f,f_tmp) - def get_bcbase(self, opt): base = '' model = '' diff --git a/GEOS_Util/post/remap_restart/remap_params.tpl b/GEOS_Util/post/remap_restart/remap_params.tpl index d08caee7..6cba4c75 100644 --- a/GEOS_Util/post/remap_restart/remap_params.tpl +++ b/GEOS_Util/post/remap_restart/remap_params.tpl @@ -8,6 +8,7 @@ input: drymass: 1 hydrostatic: 0 shared: + MERRA-2: false agrid: bcs_dir: expid: diff --git a/GEOS_Util/post/remap_restart/remap_questions.py b/GEOS_Util/post/remap_restart/remap_questions.py index 8547bfc0..09333fb8 100755 --- a/GEOS_Util/post/remap_restart/remap_questions.py +++ b/GEOS_Util/post/remap_restart/remap_questions.py @@ -30,13 +30,7 @@ def fvcore_name(x): return False def tmp_merra2_dir(x): - cmd = 'whoami' - p = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE) - (user, err) = p.communicate() - p_status = p.wait() - print(user) - user = user.decode().split() - tmp_merra2 = '/discover/nobackup/'+user[0]+'/merra2_tmp'+x['input:shared:yyyymmddhh']+'/' + tmp_merra2 = x['output:shared:out_dir']+ '/merra2_tmp_'+x['input:shared:yyyymmddhh']+'/' return tmp_merra2 def we_default(tag): @@ -101,18 +95,19 @@ def ask_questions(): "message": "From what restart date/time would you like to remap? (must be 10 digits: yyyymmddhh)", "validate": lambda text: len(text)==10 , }, + { "type": "path", - "name": "input:shared:rst_dir", - "message": "Enter a directory to which the archived MERRA-2 archive files can be copied: ", - "default": lambda x: tmp_merra2_dir(x), - "when": lambda x: x['input:shared:MERRA-2'], + "name": "output:shared:out_dir", + "message": "Enter the directory for new restarts:\n" }, { "type": "path", - "name": "output:shared:out_dir", - "message": "Enter the directory for new restarts:\n" + "name": "input:shared:rst_dir", + "message": "Enter a temporary directory for archived MERRA-2 files: ", + "default": lambda x: tmp_merra2_dir(x), + "when": lambda x: x['input:shared:MERRA-2'], }, { diff --git a/GEOS_Util/post/remap_restart/remap_restarts.py b/GEOS_Util/post/remap_restart/remap_restarts.py index f91e4af3..c90852e2 100644 --- a/GEOS_Util/post/remap_restart/remap_restarts.py +++ b/GEOS_Util/post/remap_restart/remap_restarts.py @@ -70,10 +70,6 @@ def main(argv): print("\nYou answered not to continue, exiting.\n") sys.exit(0) - # copy merra2 files from archives - if params: - params.copy_merra2() - # upper air upper = upperair(params_file=config_yaml) upper.remap() diff --git a/GEOS_Util/post/remap_restart/remap_upper.py b/GEOS_Util/post/remap_restart/remap_upper.py index 090eb7af..5938627f 100755 --- a/GEOS_Util/post/remap_restart/remap_upper.py +++ b/GEOS_Util/post/remap_restart/remap_upper.py @@ -11,6 +11,8 @@ class upperair(remap_base): def __init__(self, **configs): super().__init__(**configs) + if self.config['input']['shared']['MERRA-2']: + self.copy_merra2() def remap(self): if not self.config['output']['air']['remap'] : @@ -267,6 +269,35 @@ def find_rst(self): return restarts_in + def copy_merra2(self): + if not self.config['input']['shared']['MERRA-2']: + return + + expid = self.config['input']['shared']['expid'] + yyyymmddhh_ = str(self.config['input']['shared']['yyyymmddhh']) + yyyy_ = yyyymmddhh_[0:4] + mm_ = yyyymmddhh_[4:6] + dd_ = yyyymmddhh_[6:8] + hh_ = yyyymmddhh_[8:10] + + suffix = yyyymmddhh_[0:8]+'_'+ hh_ + 'z.bin' + merra_2_rst_dir = '/archive/users/gmao_ops/MERRA2/gmao_ops/GEOSadas-5_12_4/'+expid +'/rs/Y'+yyyy_ +'/M'+mm_+'/' + rst_dir = self.config['input']['shared']['rst_dir'] + '/' + os.makedirs(rst_dir, exist_ok = True) + print(' Copy MERRA-2 upper air restarts \n from \n ' + merra_2_rst_dir + '\n to\n '+ rst_dir +'\n') + + upperin =[merra_2_rst_dir + expid+'.fvcore_internal_rst.' + suffix, + merra_2_rst_dir + expid+'.moist_internal_rst.' + suffix, + merra_2_rst_dir + expid+'.agcm_import_rst.' + suffix, + merra_2_rst_dir + expid+'.gocart_internal_rst.' + suffix, + merra_2_rst_dir + expid+'.pchem_internal_rst.' + suffix ] + + for f in upperin : + fname = os.path.basename(f) + dest = rst_dir + '/'+fname + print("Copy file "+f +" to " + rst_dir) + shutil.copy(f, dest) + if __name__ == '__main__' : air = upperair(params_file='remap_params.yaml') air.remap() From 0dd190806a8483fae65989425c0f71ba9b22cfa9 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Thu, 21 Jul 2022 14:17:45 -0400 Subject: [PATCH 02/22] fix typos --- GEOS_Util/post/remap_restart/remap_analysis.py | 2 +- GEOS_Util/post/remap_restart/remap_params.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/GEOS_Util/post/remap_restart/remap_analysis.py b/GEOS_Util/post/remap_restart/remap_analysis.py index eab791db..9627e030 100755 --- a/GEOS_Util/post/remap_restart/remap_analysis.py +++ b/GEOS_Util/post/remap_restart/remap_analysis.py @@ -137,7 +137,7 @@ def find_analysis(self): def copy_merra2(self): if not self.config['input']['shared']['MERRA-2']: return - bkg = self.config['output']['shared'][['bkg'] + bkg = self.config['output']['analysis']['bkg'] if ( not bkg ): return expid = self.config['input']['shared']['expid'] diff --git a/GEOS_Util/post/remap_restart/remap_params.py b/GEOS_Util/post/remap_restart/remap_params.py index 7f1e93da..e5ade55a 100755 --- a/GEOS_Util/post/remap_restart/remap_params.py +++ b/GEOS_Util/post/remap_restart/remap_params.py @@ -35,6 +35,7 @@ def __init__(self, config_from_question): config_tpl = yaml.load(stream) # params for shared + config_tpl['input']['shared']['MERRA-2'] = self.common_in.get('MERRA-2') config_tpl['input']['shared']['agrid'] = self.common_in.get('agrid') config_tpl['input']['shared']['ogrid'] = self.common_in.get('ogrid') config_tpl['input']['shared']['rst_dir'] = self.common_in['rst_dir']+'/' @@ -43,6 +44,7 @@ def __init__(self, config_from_question): config_tpl['output']['air']['nlevel'] = self.upper_out.get('nlevel') config_tpl['output']['air']['remap'] = self.upper_out.get('remap') + config_tpl['input']['surface']['catch_model'] = self.surf_in.get('catch_model') config_tpl['output']['surface']['remap_water'] = self.surf_out.get('remap') config_tpl['output']['surface']['remap_catch'] = self.surf_out.get('remap') config_tpl['output']['shared']['agrid'] = self.common_out['agrid'] @@ -267,6 +269,7 @@ def init_merra2(self): self.common_in['ogrid'] = '1440x720' self.common_in['bc_base']= 'discover_ops' self.common_in['tag']= 'Ganymed-4_0' + self.surf_in['catch_model'] = 'catch' def get_bcbase(self, opt): base = '' From 08131a54065ed20cf78f6e6c724cb2ad17fd2844 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Fri, 22 Jul 2022 15:21:02 -0400 Subject: [PATCH 03/22] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1738bbad..2cf45fae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- change the location of the temporary folder for remap_restarts MERRA-2 case + ### Fixed ### Removed From bb5e4b008698bcf4ea00e72b1e6d79de6650c3a6 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Tue, 26 Jul 2022 13:27:36 -0400 Subject: [PATCH 04/22] add command line to run the program. --- .../post/remap_restart/remap_restarts.py | 49 ++++++---- GEOS_Util/post/remap_restart/remap_utils.py | 89 +++++++++++++++++++ 2 files changed, 123 insertions(+), 15 deletions(-) create mode 100644 GEOS_Util/post/remap_restart/remap_utils.py diff --git a/GEOS_Util/post/remap_restart/remap_restarts.py b/GEOS_Util/post/remap_restart/remap_restarts.py index c90852e2..41be3a0a 100644 --- a/GEOS_Util/post/remap_restart/remap_restarts.py +++ b/GEOS_Util/post/remap_restart/remap_restarts.py @@ -9,6 +9,7 @@ import sys, getopt import ruamel.yaml import questionary +from remap_utils import * from remap_questions import get_config_from_questionary from remap_params import * from remap_upper import * @@ -17,11 +18,16 @@ from remap_catchANDcn import * def main(argv): - config_yaml = '' + + question_flag = False + cmd2yaml_flag = False + yaml_flag = False + config = '' + try: - opts, args = getopt.getopt(argv,"hc:", ['config_file=']) + opts, args = getopt.getopt(argv,"hc:o", ['config_file=']) except getopt.GetoptError: - print('Usage: remap_restarts.py -c remap_params.yaml or ./remap_restarts.py ') + print('Usage: remap_restarts.py -c remap_params.yaml or ./remap_restarts.py or ./remap_restarts.py -o key=value ....') sys.exit('command line error') for opt, arg in opts: if opt == '-h': @@ -31,6 +37,8 @@ def main(argv): 2) Use questionary to convert template remap_params.tpl to \n remap_params.yaml and then remap. \n ./remap_restarts.py \n + 3) Use command line to input a flattened yaml file: \n + ./remap_restarts.py -o input:air:drymass=1 input:air:hydrostatic=0 ... \nHelp message: \n 1) Each individual script can be executed independently 2) remap_questions.py generates raw_answer.yaml @@ -42,21 +50,29 @@ def main(argv): sys.exit(0) if opt in("-c", "--config_file"): config_yaml = arg + yaml_flag = True + + if opt == '-o': + print("\n Use command line to input a flattened yaml config file \n") + cmd2yaml_flag = True + config_yaml = 'remap_params.yaml' - params = '' - if config_yaml == '': - config = get_config_from_questionary() - params = remap_params(config) - params.convert_to_yaml() - config_yaml = 'remap_params.yaml' + if yaml_flag : + config = yaml_to_config(config_yaml) - with open(config_yaml, 'r') as f: - for line in f.readlines(): - trimmed_line = line.rstrip() - if trimmed_line: # Don't print blank lines - print(trimmed_line) + if cmd2yaml_flag : + config = args_to_config(args) + if not ( yaml_flag or cmd2yaml_flag) : + raw_config = get_config_from_questionary() + params = remap_params(raw_config) + config = params.config + question_flag = True + config_yaml = 'remap_params.yaml' + print('\n') + print_config(config) + questions = [ { "type": "confirm", @@ -69,7 +85,10 @@ def main(argv): if not answer['Continue'] : print("\nYou answered not to continue, exiting.\n") sys.exit(0) - + + if yaml_flag or question_flag : write_cmd(config) + if cmd2yaml_flag or question_flag : config_to_yaml(config, config_yaml) + # upper air upper = upperair(params_file=config_yaml) upper.remap() diff --git a/GEOS_Util/post/remap_restart/remap_utils.py b/GEOS_Util/post/remap_restart/remap_utils.py new file mode 100644 index 00000000..199e418c --- /dev/null +++ b/GEOS_Util/post/remap_restart/remap_utils.py @@ -0,0 +1,89 @@ +import os +import subprocess +import ruamel.yaml +from collections import OrderedDict + +def config_to_yaml(config, yaml_file): + yaml = ruamel.yaml.YAML() + with open(yaml_file, "w") as f: + yaml.dump(config, f) + +def yaml_to_config(yaml_file): + yaml = ruamel.yaml.YAML() + stream ='' + with open(yaml_file, 'r') as f: + stream = f.read() + config = yaml.load(stream) + return config + +def write_cmd(config) : + def flatten_nested(nested_dict, result=None, prefix=''): + if result is None: + result = dict() + for k, v in nested_dict.items(): + new_k = ':'.join((prefix, k)) if prefix else k + if not (isinstance(v, dict) or isinstance(v, OrderedDict)): + result.update({new_k: v}) + else: + flatten_nested(v, result, new_k) + return result + + out_dir = config['output']['shared']['out_dir'] + if not os.path.exists(out_dir) : os.makedirs(out_dir) + bin_path = os.path.dirname(os.path.realpath(__file__)) + + cmd = '#!/usr/local/bin/csh \n' + cmd = cmd + 'set BINPATH=' + bin_path +'\n' + cmd = cmd + 'source $BINPATH/g5_modules \n' + + flat_dict = flatten_nested(config) + + k = 1 + for key, value in flat_dict.items(): + if isinstance(value, int) : value = str(value) + if isinstance(value, float) : value = str(value) + if k == 1: + cmd = cmd + 'set FLATYAML="' + key+"="+ value+ '"\n' + else: + cmd = cmd + 'set FLATYAML="$FLATYAML '+ key+"="+ value+ '"\n' + k = k+1 + + cmd = cmd + '$BINPATH/remap_restarts.py -o $FLATYAML' + + with open(out_dir + '/remap_restarts.CMD', 'w') as f: + f.write(cmd) + subprocess.call(['chmod', '+x',out_dir + '/remap_restarts.CMD']) + +def args_to_config(args): + config = {} + config['input'] = {} + config['input']['air'] = {} + config['input']['shared'] = {} + config['input']['surface'] = {} + config['output'] = {} + config['output']['shared'] = {} + config['output']['air'] = {} + config['output']['surface'] = {} + config['output']['analysis'] = {} + config['slurm'] = {} + for values in args: + [keys, value] = values.split("=") + key = keys.split(':') + if value.lower() in ['false', 'null'] : + value = False + elif value.lower() in ['true'] : + value = True + if len(key) == 2: + config[key[0]][key[1]] = value + if len(key) == 3: + config[key[0]][key[1]][key[2]] = value + + return config + +def print_config( config, indent = 0 ): + for k, v in config.items(): + if isinstance(v, dict): + print(" " * indent, f"{k}:") + print_config(v, indent+1) + else: + print(" " * indent, f"{k}: {v}") From 9f73755a07a42d03957554f2b1d62bb86e4dad69 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang <52509753+weiyuan-jiang@users.noreply.github.com> Date: Tue, 26 Jul 2022 14:47:20 -0400 Subject: [PATCH 05/22] Update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cf45fae..7c4cedb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- change the location of the temporary folder for remap_restarts MERRA-2 case +- Generated command line to run the program +- changed the location of the temporary folder for remap_restarts MERRA-2 case ### Fixed From 2ce38281700ed5f7a8bc85bd10df0e649fe2df63 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Tue, 26 Jul 2022 15:10:01 -0400 Subject: [PATCH 06/22] consolidate converting to yaml file --- GEOS_Util/post/remap_restart/remap_params.py | 19 ++----------------- GEOS_Util/post/remap_restart/remap_utils.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/GEOS_Util/post/remap_restart/remap_params.py b/GEOS_Util/post/remap_restart/remap_params.py index e5ade55a..12967c2c 100755 --- a/GEOS_Util/post/remap_restart/remap_params.py +++ b/GEOS_Util/post/remap_restart/remap_params.py @@ -7,9 +7,9 @@ import time import shlex import subprocess -import questionary from datetime import datetime from datetime import timedelta +from remap_utils import config_to_yaml class remap_params(object): def __init__(self, config_from_question): @@ -66,21 +66,6 @@ def __init__(self, config_from_question): self.config = config_tpl - def convert_to_yaml(self) : - if os.path.exists('remap_params.yaml') : - overwrite = questionary.confirm("Do you want to overwrite remap_params.yaml file?", default=False).ask() - if not overwrite : - while True: - new_name = questionary.text("What's the backup name for existing remap_params.yaml?", default='remap_params.yaml.1').ask() - if os.path.exists(new_name): - print('\n'+ new_name + ' exists, please enter a new one. \n') - else: - shutil.move('remap_params.yaml', new_name) - break - yaml = ruamel.yaml.YAML() - with open("remap_params.yaml", "w") as f: - yaml.dump(self.config, f) - def init_tags(self): # copy and paste from remap.pl # minor change. Add "D" to the number for each group @@ -508,4 +493,4 @@ def params_for_analysis(self, config_tpl): stream = f.read() config = yaml.load(stream) param = remap_params(config) - param.convert_to_yaml() + config_to_yaml(param.config, 'remap_params.yaml') diff --git a/GEOS_Util/post/remap_restart/remap_utils.py b/GEOS_Util/post/remap_restart/remap_utils.py index 199e418c..d04c4cb3 100644 --- a/GEOS_Util/post/remap_restart/remap_utils.py +++ b/GEOS_Util/post/remap_restart/remap_utils.py @@ -2,8 +2,20 @@ import subprocess import ruamel.yaml from collections import OrderedDict +import shutil +import questionary def config_to_yaml(config, yaml_file): + if os.path.exists(yaml_file) : + overwrite = questionary.confirm("Do you want to overwrite " + yaml_file + "?" , default=False).ask() + if not overwrite : + while True: + new_name = questionary.text("What's the backup name? ", default=yaml_file +'.1').ask() + if os.path.exists(new_name): + print('\n'+ new_name + ' exists, please enter a new one. \n') + else: + shutil.move(yaml_file, new_name) + break yaml = ruamel.yaml.YAML() with open(yaml_file, "w") as f: yaml.dump(config, f) From 735979553a9305557bcdf6d16258081c7d9fb77f Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Wed, 27 Jul 2022 13:19:04 -0400 Subject: [PATCH 07/22] hide temporary folder for merra-2 from users --- GEOS_Util/post/remap_restart/remap_questions.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/GEOS_Util/post/remap_restart/remap_questions.py b/GEOS_Util/post/remap_restart/remap_questions.py index 09333fb8..a5706612 100755 --- a/GEOS_Util/post/remap_restart/remap_questions.py +++ b/GEOS_Util/post/remap_restart/remap_questions.py @@ -17,13 +17,15 @@ def fvcore_name(x): ymdh = x['input:shared:yyyymmddhh'] time = ymdh[0:8] + '_'+ymdh[8:10] - files = glob.glob(x['input:shared:rst_dir']+'/*fvcore_*'+time+'*') + rst_dir = x.get('input:shared:rst_dir') + if not rst_dir : return False + files = glob.glob(rst_dir+'/*fvcore_*'+time+'*') if len(files) ==1 : fname = files[0] print('\nFound ' + fname) return fname else: - fname = x['input:shared:rst_dir']+'/fvcore_internal_rst' + fname = rst_dir+'/fvcore_internal_rst' if os.path.exists(fname): print('\nFound ' + fname) return fname @@ -102,14 +104,6 @@ def ask_questions(): "message": "Enter the directory for new restarts:\n" }, - { - "type": "path", - "name": "input:shared:rst_dir", - "message": "Enter a temporary directory for archived MERRA-2 files: ", - "default": lambda x: tmp_merra2_dir(x), - "when": lambda x: x['input:shared:MERRA-2'], - }, - { "type": "text", "name": "input:shared:agrid", @@ -328,6 +322,8 @@ def ask_questions(): answers = questionary.prompt(questions) if not answers.get('input:shared:model') : answers['input:shared:model'] = 'data' + if answers['input:shared:MERRA-2']: + answers['input:shared:rst_dir'] = tmp_merra2_dir(answers) answers['input:shared:rst_dir'] = os.path.abspath(answers['input:shared:rst_dir']) if answers.get('output:shared:ogrid') == 'CS': answers['output:shared:ogrid'] = answers['output:shared:agrid'] From ee96b752afcbfdc374676b2380b880297b322451 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Wed, 27 Jul 2022 14:48:56 -0400 Subject: [PATCH 08/22] remove temporary merra2 folder --- GEOS_Util/post/remap_restart/remap_analysis.py | 5 +++-- GEOS_Util/post/remap_restart/remap_base.py | 5 +++++ GEOS_Util/post/remap_restart/remap_catchANDcn.py | 5 +++-- GEOS_Util/post/remap_restart/remap_lake_landice_saltwater.py | 5 +++-- GEOS_Util/post/remap_restart/remap_upper.py | 5 +++-- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/GEOS_Util/post/remap_restart/remap_analysis.py b/GEOS_Util/post/remap_restart/remap_analysis.py index 9627e030..f7160289 100755 --- a/GEOS_Util/post/remap_restart/remap_analysis.py +++ b/GEOS_Util/post/remap_restart/remap_analysis.py @@ -19,8 +19,7 @@ class analysis(remap_base): def __init__(self, **configs): super().__init__(**configs) - if self.config['input']['shared']['MERRA-2']: - self.copy_merra2() + self.copy_merra2() def remap(self): config = self.config @@ -107,6 +106,8 @@ def remap(self): print( "cd " + cwdir) os.chdir(cwdir) + self.remove_merra2() + def get_grid_kind(this, grid): hgrd = {} hgrd['C12'] = 'a' diff --git a/GEOS_Util/post/remap_restart/remap_base.py b/GEOS_Util/post/remap_restart/remap_base.py index 2f5a9406..5163c91e 100755 --- a/GEOS_Util/post/remap_restart/remap_base.py +++ b/GEOS_Util/post/remap_restart/remap_base.py @@ -3,6 +3,7 @@ import os import ruamel.yaml import shutil +import subprocess class remap_base(object): def __init__(self, **configs): @@ -28,3 +29,7 @@ def __init__(self, **configs): out_dir = self.config['output']['shared']['out_dir'] if not os.path.exists(out_dir) : os.makedirs(out_dir) break + def remove_merra2(self): + if self.config['input']['shared']['MERRA-2']: + print(" remove temporary folder that contains MERRA-2 archived files ... \n") + subprocess.call(['/bin/rm', '-rf', self.config['input']['shared']['rst_dir']]) diff --git a/GEOS_Util/post/remap_restart/remap_catchANDcn.py b/GEOS_Util/post/remap_restart/remap_catchANDcn.py index 1ef13cad..35db3e99 100755 --- a/GEOS_Util/post/remap_restart/remap_catchANDcn.py +++ b/GEOS_Util/post/remap_restart/remap_catchANDcn.py @@ -12,8 +12,7 @@ class catchANDcn(remap_base): def __init__(self, **configs): super().__init__(**configs) - if self.config['input']['shared']['MERRA-2']: - self.copy_merra2() + self.copy_merra2() def remap(self): if not self.config['output']['surface']['remap_catch']: @@ -131,6 +130,8 @@ def remap(self): print( "cd " + cwdir) os.chdir(cwdir) + self.remove_merra2() + def copy_merra2(self): if not self.config['input']['shared']['MERRA-2']: return diff --git a/GEOS_Util/post/remap_restart/remap_lake_landice_saltwater.py b/GEOS_Util/post/remap_restart/remap_lake_landice_saltwater.py index 76cb9809..45c1c1dd 100755 --- a/GEOS_Util/post/remap_restart/remap_lake_landice_saltwater.py +++ b/GEOS_Util/post/remap_restart/remap_lake_landice_saltwater.py @@ -11,8 +11,7 @@ class lake_landice_saltwater(remap_base): def __init__(self, **configs): super().__init__(**configs) - if self.config['input']['shared']['MERRA-2']: - self.copy_merra2() + self.copy_merra2() def remap(self): if not self.config['output']['surface']['remap_water']: @@ -140,6 +139,8 @@ def remap(self): print('cd ' + cwdir) os.chdir(cwdir) + self.remove_merra2() + def find_rst(self): surf_restarts =[ "route_internal_rst" , diff --git a/GEOS_Util/post/remap_restart/remap_upper.py b/GEOS_Util/post/remap_restart/remap_upper.py index 5938627f..2fa1f0f2 100755 --- a/GEOS_Util/post/remap_restart/remap_upper.py +++ b/GEOS_Util/post/remap_restart/remap_upper.py @@ -11,8 +11,7 @@ class upperair(remap_base): def __init__(self, **configs): super().__init__(**configs) - if self.config['input']['shared']['MERRA-2']: - self.copy_merra2() + self.copy_merra2() def remap(self): if not self.config['output']['air']['remap'] : @@ -251,6 +250,8 @@ def remap(self): print('cd ' + cwdir) os.chdir(cwdir) + self.remove_merra2() + def find_rst(self): rst_dir = self.config['input']['shared']['rst_dir'] yyyymmddhh_ = str(self.config['input']['shared']['yyyymmddhh']) From 4f74f97029932070d4306ac509b12dc28730b128 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Wed, 27 Jul 2022 15:03:16 -0400 Subject: [PATCH 09/22] more clean up --- GEOS_Util/post/remap_restart/remap_utils.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/GEOS_Util/post/remap_restart/remap_utils.py b/GEOS_Util/post/remap_restart/remap_utils.py index d04c4cb3..e85d1e9a 100644 --- a/GEOS_Util/post/remap_restart/remap_utils.py +++ b/GEOS_Util/post/remap_restart/remap_utils.py @@ -52,15 +52,14 @@ def flatten_nested(nested_dict, result=None, prefix=''): k = 1 for key, value in flat_dict.items(): - if isinstance(value, int) : value = str(value) - if isinstance(value, float) : value = str(value) + if isinstance(value, int) or isinstance(value, float) : value = str(value) if k == 1: - cmd = cmd + 'set FLATYAML="' + key+"="+ value+ '"\n' + cmd = cmd + 'set FLAT_YAML="' + key+"="+ value+ '"\n' else: - cmd = cmd + 'set FLATYAML="$FLATYAML '+ key+"="+ value+ '"\n' + cmd = cmd + 'set FLAT_YAML="$FLAT_YAML '+ key+"="+ value+ '"\n' k = k+1 - cmd = cmd + '$BINPATH/remap_restarts.py -o $FLATYAML' + cmd = cmd + '$BINPATH/remap_restarts.py -o $FLAT_YAML' with open(out_dir + '/remap_restarts.CMD', 'w') as f: f.write(cmd) @@ -81,7 +80,7 @@ def args_to_config(args): for values in args: [keys, value] = values.split("=") key = keys.split(':') - if value.lower() in ['false', 'null'] : + if value.lower() in ['false', 'null', 'none'] : value = False elif value.lower() in ['true'] : value = True From e1d6234f35a6bbe500eea98a12c94a6b5ce68468 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Thu, 28 Jul 2022 09:22:23 -0400 Subject: [PATCH 10/22] add catch_tilefile entry. Catch can be in local domain --- GEOS_Util/post/remap_restart/remap_params.tpl | 5 ++++- GEOS_Util/post/remap_restart/remap_utils.py | 15 ++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/GEOS_Util/post/remap_restart/remap_params.tpl b/GEOS_Util/post/remap_restart/remap_params.tpl index 6cba4c75..94cedbfd 100644 --- a/GEOS_Util/post/remap_restart/remap_params.tpl +++ b/GEOS_Util/post/remap_restart/remap_params.tpl @@ -20,7 +20,8 @@ input: wemin: # it supports three models: catch, catchcnclm40, catchcnclm45 catch_model: null - + # if catch_tilefile is null, it searches bcs_dir + catch_tilefile: null output: shared: agrid: @@ -40,6 +41,8 @@ output: remap_water: true # remap catch(cn) remap_catch: true + # if catch_tilefile is null, it searches bcs_dir + catch_tilefile: null analysis: bkg: true aqua: False diff --git a/GEOS_Util/post/remap_restart/remap_utils.py b/GEOS_Util/post/remap_restart/remap_utils.py index e85d1e9a..582a7a15 100644 --- a/GEOS_Util/post/remap_restart/remap_utils.py +++ b/GEOS_Util/post/remap_restart/remap_utils.py @@ -66,17 +66,10 @@ def flatten_nested(nested_dict, result=None, prefix=''): subprocess.call(['chmod', '+x',out_dir + '/remap_restarts.CMD']) def args_to_config(args): - config = {} - config['input'] = {} - config['input']['air'] = {} - config['input']['shared'] = {} - config['input']['surface'] = {} - config['output'] = {} - config['output']['shared'] = {} - config['output']['air'] = {} - config['output']['surface'] = {} - config['output']['analysis'] = {} - config['slurm'] = {} + # template file should be with this util file + remap_tpl = os.path.dirname(os.path.realpath(__file__)) + '/remap_params.tpl' + config = yaml_to_config(remap_tpl) + # fill in the config with args for values in args: [keys, value] = values.split("=") key = keys.split(':') From d08e6332d87b6a9286aa5cc9b9f5447cba2b465c Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Thu, 28 Jul 2022 09:33:15 -0400 Subject: [PATCH 11/22] get catch tile file from catc_tilefile entry first --- GEOS_Util/post/remap_restart/remap_catchANDcn.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/GEOS_Util/post/remap_restart/remap_catchANDcn.py b/GEOS_Util/post/remap_restart/remap_catchANDcn.py index 35db3e99..3aa1d7f0 100755 --- a/GEOS_Util/post/remap_restart/remap_catchANDcn.py +++ b/GEOS_Util/post/remap_restart/remap_catchANDcn.py @@ -43,8 +43,12 @@ def remap(self): in_wemin = config['input']['surface']['wemin'] out_wemin = config['output']['surface']['wemin'] surflay = config['output']['surface']['surflay'] - in_tilefile = glob.glob(in_bcsdir+ '/*-Pfafstetter.til')[0] - out_tilefile = glob.glob(out_bcsdir+ '/*-Pfafstetter.til')[0] + in_tilefile = config['input']['surface']['catch_tilefile'] + if not in_tilefile : + in_tilefile = glob.glob(in_bcsdir+ '/*-Pfafstetter.til')[0] + out_tilefile = config['output']['surface']['catch_tilefile'] + if not out_tilefile : + out_tilefile = glob.glob(out_bcsdir+ '/*-Pfafstetter.til')[0] account = config['slurm']['account'] # even the input is binary, the output si nc4 suffix = time+'z.nc4' From a92be4660070890b62ced0bd8ef6886b93f3cc0c Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Mon, 1 Aug 2022 13:14:43 -0400 Subject: [PATCH 12/22] add more test cases --- GEOS_Util/post/remap_restart/remap_params.py | 15 +----- GEOS_Util/post/remap_restart/remap_utils.py | 20 ++++++++ GEOS_Util/post/tests/amip_c180Toc90.yaml | 52 ++++++++++++++++++++ GEOS_Util/post/tests/c180Toc360.yaml | 52 ++++++++++++++++++++ GEOS_Util/post/tests/c360Toc24.yaml | 52 ++++++++++++++++++++ GEOS_Util/post/tests/test_remap_cases.yaml | 11 ++++- 6 files changed, 188 insertions(+), 14 deletions(-) create mode 100644 GEOS_Util/post/tests/amip_c180Toc90.yaml create mode 100644 GEOS_Util/post/tests/c180Toc360.yaml create mode 100644 GEOS_Util/post/tests/c360Toc24.yaml diff --git a/GEOS_Util/post/remap_restart/remap_params.py b/GEOS_Util/post/remap_restart/remap_params.py index 12967c2c..b112aab3 100755 --- a/GEOS_Util/post/remap_restart/remap_params.py +++ b/GEOS_Util/post/remap_restart/remap_params.py @@ -9,7 +9,7 @@ import subprocess from datetime import datetime from datetime import timedelta -from remap_utils import config_to_yaml +from remap_utils import config_to_yaml, merra2_expid class remap_params(object): def __init__(self, config_from_question): @@ -237,18 +237,7 @@ def init_time(self): def init_merra2(self): if not self.common_in['MERRA-2']: return - print("\n MERRA-2 sources:\n") - yyyymm = int(self.yyyymm) - if yyyymm < 197901 : - exit("Error. MERRA-2 data < 1979 not available\n") - elif (yyyymm < 199201): - self.common_in['expid'] = "d5124_m2_jan79" - elif (yyyymm < 200106): - self.common_in['expid'] = "d5124_m2_jan91" - elif (yyyymm < 201101): - self.common_in['expid'] = "d5124_m2_jan00" - else: - self.common_in['expid'] = "d5124_m2_jan10" + self.common_in = merra2_expid(self.common_in) self.common_in['agrid'] = 'C180' self.common_in['ogrid'] = '1440x720' diff --git a/GEOS_Util/post/remap_restart/remap_utils.py b/GEOS_Util/post/remap_restart/remap_utils.py index 582a7a15..acde6274 100644 --- a/GEOS_Util/post/remap_restart/remap_utils.py +++ b/GEOS_Util/post/remap_restart/remap_utils.py @@ -91,3 +91,23 @@ def print_config( config, indent = 0 ): print_config(v, indent+1) else: print(" " * indent, f"{k}: {v}") + +def merra2_expid(config): + if not config['MERRA-2']: + return config + yyyymm = int(config.get('yyyymmddhh')[0:6]) + if yyyymm < 197901 : + exit("Error. MERRA-2 data < 1979 not available\n") + elif (yyyymm < 199201): + expid = "d5124_m2_jan79" + elif (yyyymm < 200106): + expid = "d5124_m2_jan91" + elif (yyyymm < 201101): + expid = "d5124_m2_jan00" + else: + expid = "d5124_m2_jan10" + config['expid'] = expid + + return config + + diff --git a/GEOS_Util/post/tests/amip_c180Toc90.yaml b/GEOS_Util/post/tests/amip_c180Toc90.yaml new file mode 100644 index 00000000..103c38fd --- /dev/null +++ b/GEOS_Util/post/tests/amip_c180Toc90.yaml @@ -0,0 +1,52 @@ +# +# This template file can be filled with questionary or manually +# +# + +input: + air: + drymass: 1 + hydrostatic: 0 + shared: + MERRA-2: false + agrid: C180 + bcs_dir: /discover/nobackup/ltakacs/bcs/Icarus-NLv3/Icarus-NLv3_MERRA-2//CF0180x6C_DE1440xPE0720/ + expid: JM_v10.22.2_L072_C180_AMIP + ogrid: 1440X720 + rst_dir: /discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/amip_c180Toc90/inputs/ + yyyymmddhh: '1990062621' + surface: + zoom: '2' + wemin: '13' + # it supports three models: catch, catchcnclm40, catchcnclm45 + catch_model: catch + catch_tilefile: null +output: + shared: + agrid: C90 + bcs_dir: /discover/nobackup/ltakacs/bcs/Icarus-NLv3/Icarus-NLv3_Ostia//CF0090x6C_CF0090x6C/ + expid: C90CS_JM_v10.22.2_L072_C180_AMIP + ogrid: C90 + out_dir: $NOBACKUP/REMAP_TESTS/amip_c180Toc90/ + air: + # remap upper air or not + remap: true + nlevel: '72' + surface: + split_saltwater: true + surflay: 50.0 + wemin: '13' + # remap lake, saltwater, landicet + remap_water: true + # remap catch(cn) + remap_catch: true + catch_tilefile: null + analysis: + bkg: false + aqua: true + lcv: false + +slurm: + account: g0620 + qos: debug + constraint: sky diff --git a/GEOS_Util/post/tests/c180Toc360.yaml b/GEOS_Util/post/tests/c180Toc360.yaml new file mode 100644 index 00000000..58b9e253 --- /dev/null +++ b/GEOS_Util/post/tests/c180Toc360.yaml @@ -0,0 +1,52 @@ +# +# This template file can be filled with questionary or manually +# +# + +input: + air: + drymass: 1 + hydrostatic: 0 + shared: + MERRA-2: false + agrid: C180 + bcs_dir: /discover/nobackup/ltakacs/bcs/Icarus-NLv3/Icarus-NLv3_MERRA-2//CF0180x6C_DE1440xPE0720/ + expid: Jason-3_4_NL_REAMIP_MERRA2_C180 + ogrid: 1440X720 + rst_dir: /discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/c180Toc360/inputs/ + yyyymmddhh: '1985050921' + surface: + zoom: '2' + wemin: '13' + # it supports three models: catch, catchcnclm40, catchcnclm45 + catch_model: catch + catch_tilefile: null +output: + shared: + agrid: C360 + bcs_dir: /discover/nobackup/ltakacs/bcs/Icarus-NLv3/Icarus-NLv3_Ostia//CF0360x6C_CF0360x6C/ + expid: C360CS_Jason-3_4_NL_REAMIP_MERRA2_C180 + ogrid: C360 + out_dir: $NOBACKUP/REMAP_TESTS/c360Toc24/ + air: + # remap upper air or not + remap: true + nlevel: '91' + surface: + split_saltwater: true + surflay: 50.0 + wemin: '13' + # remap lake, saltwater, landicet + remap_water: true + # remap catch(cn) + remap_catch: true + catch_tilefile: null + analysis: + bkg: false + aqua: true + lcv: false + +slurm: + account: g0620 + qos: debug + constraint: sky diff --git a/GEOS_Util/post/tests/c360Toc24.yaml b/GEOS_Util/post/tests/c360Toc24.yaml new file mode 100644 index 00000000..62c38681 --- /dev/null +++ b/GEOS_Util/post/tests/c360Toc24.yaml @@ -0,0 +1,52 @@ +# +# This template file can be filled with questionary or manually +# +# + +input: + air: + drymass: 1 + hydrostatic: 0 + shared: + MERRA-2: false + agrid: C360 + bcs_dir: /discover/nobackup/projects/gmao/share/gmao_ops/fvInput/g5gcm/bcs/Icarus-NLv3/Icarus-NLv3_Ostia//CF0360x6C_CF0360x6C/ + expid: x0046a + ogrid: C360 + rst_dir: /discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/c360Toc24/inputs + yyyymmddhh: '2022010121' + surface: + zoom: '4' + wemin: '13' + # it supports three models: catch, catchcnclm40, catchcnclm45 + catch_model: catch + catch_tilefile: null +output: + shared: + agrid: C24 + bcs_dir: /discover/nobackup/ltakacs/bcs/Icarus-NLv3/Icarus-NLv3_Reynolds//CF0024x6C_DE0360xPE0180/ + expid: C24c_x0046a + ogrid: 360X180 + out_dir: $NOBACKUP/REMAP_TESTS/c360Toc24/ + air: + # remap upper air or not + remap: true + nlevel: '181' + surface: + split_saltwater: true + surflay: 50.0 + wemin: '13' + # remap lake, saltwater, landicet + remap_water: true + # remap catch(cn) + remap_catch: true + catch_tilefile: null + analysis: + bkg: false + aqua: true + lcv: false + +slurm: + account: g0620 + qos: debug + constraint: sky diff --git a/GEOS_Util/post/tests/test_remap_cases.yaml b/GEOS_Util/post/tests/test_remap_cases.yaml index 30640090..0c59af44 100644 --- a/GEOS_Util/post/tests/test_remap_cases.yaml +++ b/GEOS_Util/post/tests/test_remap_cases.yaml @@ -4,4 +4,13 @@ c24Toc12: f522Toc360: base_line: '/discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/f522Toc360/baseline/' config: 'f522Toc360.yaml' - +amip_c180Toc90: + base_line: '/discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/amip_c180Toc90/baseline/' + config: 'amip_c180Toc90.yaml' +c180Toc360: + base_line: '/discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/c180Toc360/baseline/' + config: 'c180Toc360.yaml' +c360Toc24: + base_line: '/discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/c360Toc24/baseline/' + config: 'c360Toc24.yaml' + From 5372815eff01620e63bd4fe4cc05ec00c8a8c2e6 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Mon, 8 Aug 2022 09:14:44 -0400 Subject: [PATCH 13/22] add main for self testing in remap_utils --- GEOS_Util/post/remap_restart/remap_utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/GEOS_Util/post/remap_restart/remap_utils.py b/GEOS_Util/post/remap_restart/remap_utils.py index acde6274..d3c6a7d2 100644 --- a/GEOS_Util/post/remap_restart/remap_utils.py +++ b/GEOS_Util/post/remap_restart/remap_utils.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# import os import subprocess import ruamel.yaml @@ -110,4 +112,6 @@ def merra2_expid(config): return config - +if __name__ == '__main__' : + config = yaml_to_config('c24Toc12.yaml') + print_config(config) From e77c56fe935ef051374b807ba05941ca6c6c25c7 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Mon, 15 Aug 2022 13:42:00 -0400 Subject: [PATCH 14/22] Add S2S Test. Add YAML validator --- .github/workflows/changelog-enforcer.yml | 2 +- .github/workflows/validate_yaml_files.yml | 31 ++++++++++++++ .yamllint.yml | 29 +++++++++++++ CHANGELOG.md | 7 +++ GEOS_Util/post/tests/amip_c180Toc90.yaml | 8 ++-- GEOS_Util/post/tests/c180Toc360.yaml | 6 +-- GEOS_Util/post/tests/c24Toc12.yaml | 4 +- GEOS_Util/post/tests/c360Toc24.yaml | 8 ++-- GEOS_Util/post/tests/f522Toc360.yaml | 6 +-- GEOS_Util/post/tests/s2sToc12MOM6.yaml | 50 ++++++++++++++++++++++ GEOS_Util/post/tests/test_remap_cases.yaml | 6 ++- 11 files changed, 138 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/validate_yaml_files.yml create mode 100644 .yamllint.yml create mode 100644 GEOS_Util/post/tests/s2sToc12MOM6.yaml diff --git a/.github/workflows/changelog-enforcer.yml b/.github/workflows/changelog-enforcer.yml index 6e46cfc2..b709e98b 100644 --- a/.github/workflows/changelog-enforcer.yml +++ b/.github/workflows/changelog-enforcer.yml @@ -4,7 +4,7 @@ on: types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled] jobs: - # Enforces the update of a changelog file on every pull request + # Enforces the update of a changelog file on every pull request changelog: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/validate_yaml_files.yml b/.github/workflows/validate_yaml_files.yml new file mode 100644 index 00000000..36ecf876 --- /dev/null +++ b/.github/workflows/validate_yaml_files.yml @@ -0,0 +1,31 @@ +--- + +# Based on code from https://github.com/marketplace/actions/yaml-lint + +name: Yaml Lint + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled] + +# This validation is equivalent to running on the command line: +# yamllint -d relaxed --no-warnings +# and is controlled by the .yamllint.yml file +jobs: + validate-YAML: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - id: yaml-lint + name: yaml-lint + uses: ibiqlik/action-yamllint@v3 + with: + no_warnings: true + format: colored + config_file: .yamllint.yml + + - uses: actions/upload-artifact@v3 + if: always() + with: + name: yamllint-logfile + path: ${{ steps.yaml-lint.outputs.logfile }} diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 00000000..83f5340c --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,29 @@ +--- + +extends: default + +rules: + braces: + level: warning + max-spaces-inside: 1 + brackets: + level: warning + max-spaces-inside: 1 + colons: + level: warning + commas: + level: warning + comments: disable + comments-indentation: disable + document-start: disable + empty-lines: + level: warning + hyphens: + level: warning + indentation: + level: warning + indent-sequences: consistent + line-length: + level: warning + allow-non-breakable-inline-mappings: true + truthy: disable diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c4cedb3..408cfb98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,10 +9,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Add YAML validator + ### Changed - Generated command line to run the program - changed the location of the temporary folder for remap_restarts MERRA-2 case +- Added new remap tests + - amip_c180Toc90 + - c180Toc360 + - c360Toc24 + - s2sToc12MOM6 ### Fixed diff --git a/GEOS_Util/post/tests/amip_c180Toc90.yaml b/GEOS_Util/post/tests/amip_c180Toc90.yaml index 103c38fd..2c04fbd6 100644 --- a/GEOS_Util/post/tests/amip_c180Toc90.yaml +++ b/GEOS_Util/post/tests/amip_c180Toc90.yaml @@ -1,7 +1,7 @@ # # This template file can be filled with questionary or manually -# -# +# +# input: air: @@ -13,7 +13,7 @@ input: bcs_dir: /discover/nobackup/ltakacs/bcs/Icarus-NLv3/Icarus-NLv3_MERRA-2//CF0180x6C_DE1440xPE0720/ expid: JM_v10.22.2_L072_C180_AMIP ogrid: 1440X720 - rst_dir: /discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/amip_c180Toc90/inputs/ + rst_dir: /discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/amip_c180Toc90/inputs/ yyyymmddhh: '1990062621' surface: zoom: '2' @@ -27,7 +27,7 @@ output: bcs_dir: /discover/nobackup/ltakacs/bcs/Icarus-NLv3/Icarus-NLv3_Ostia//CF0090x6C_CF0090x6C/ expid: C90CS_JM_v10.22.2_L072_C180_AMIP ogrid: C90 - out_dir: $NOBACKUP/REMAP_TESTS/amip_c180Toc90/ + out_dir: $NOBACKUP/REMAP_TESTS/amip_c180Toc90/ air: # remap upper air or not remap: true diff --git a/GEOS_Util/post/tests/c180Toc360.yaml b/GEOS_Util/post/tests/c180Toc360.yaml index 58b9e253..7a5bc65b 100644 --- a/GEOS_Util/post/tests/c180Toc360.yaml +++ b/GEOS_Util/post/tests/c180Toc360.yaml @@ -1,7 +1,7 @@ # # This template file can be filled with questionary or manually -# -# +# +# input: air: @@ -13,7 +13,7 @@ input: bcs_dir: /discover/nobackup/ltakacs/bcs/Icarus-NLv3/Icarus-NLv3_MERRA-2//CF0180x6C_DE1440xPE0720/ expid: Jason-3_4_NL_REAMIP_MERRA2_C180 ogrid: 1440X720 - rst_dir: /discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/c180Toc360/inputs/ + rst_dir: /discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/c180Toc360/inputs/ yyyymmddhh: '1985050921' surface: zoom: '2' diff --git a/GEOS_Util/post/tests/c24Toc12.yaml b/GEOS_Util/post/tests/c24Toc12.yaml index 3bd204a4..367a6974 100644 --- a/GEOS_Util/post/tests/c24Toc12.yaml +++ b/GEOS_Util/post/tests/c24Toc12.yaml @@ -1,7 +1,7 @@ # # This template file can be filled with questionary or manually -# -# +# +# input: air: diff --git a/GEOS_Util/post/tests/c360Toc24.yaml b/GEOS_Util/post/tests/c360Toc24.yaml index 62c38681..e23dd4d3 100644 --- a/GEOS_Util/post/tests/c360Toc24.yaml +++ b/GEOS_Util/post/tests/c360Toc24.yaml @@ -1,7 +1,7 @@ # # This template file can be filled with questionary or manually -# -# +# +# input: air: @@ -13,7 +13,7 @@ input: bcs_dir: /discover/nobackup/projects/gmao/share/gmao_ops/fvInput/g5gcm/bcs/Icarus-NLv3/Icarus-NLv3_Ostia//CF0360x6C_CF0360x6C/ expid: x0046a ogrid: C360 - rst_dir: /discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/c360Toc24/inputs + rst_dir: /discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/c360Toc24/inputs yyyymmddhh: '2022010121' surface: zoom: '4' @@ -27,7 +27,7 @@ output: bcs_dir: /discover/nobackup/ltakacs/bcs/Icarus-NLv3/Icarus-NLv3_Reynolds//CF0024x6C_DE0360xPE0180/ expid: C24c_x0046a ogrid: 360X180 - out_dir: $NOBACKUP/REMAP_TESTS/c360Toc24/ + out_dir: $NOBACKUP/REMAP_TESTS/c360Toc24/ air: # remap upper air or not remap: true diff --git a/GEOS_Util/post/tests/f522Toc360.yaml b/GEOS_Util/post/tests/f522Toc360.yaml index f4450582..48048b38 100644 --- a/GEOS_Util/post/tests/f522Toc360.yaml +++ b/GEOS_Util/post/tests/f522Toc360.yaml @@ -1,7 +1,7 @@ # # This template file can be filled with questionary or manually -# -# +# +# input: air: @@ -13,7 +13,7 @@ input: bcs_dir: /discover/nobackup/projects/gmao/share/gmao_ops/fvInput/g5gcm/bcs/Icarus_Updated/Icarus_Ostia//CF0720x6C_CF0720x6C/ expid: f522_fp ogrid: C720 - rst_dir: /discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/f522Toc360/inputs/ + rst_dir: /discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/f522Toc360/inputs/ yyyymmddhh: '2019061421' surface: zoom: '8' diff --git a/GEOS_Util/post/tests/s2sToc12MOM6.yaml b/GEOS_Util/post/tests/s2sToc12MOM6.yaml new file mode 100644 index 00000000..ef66f2b9 --- /dev/null +++ b/GEOS_Util/post/tests/s2sToc12MOM6.yaml @@ -0,0 +1,50 @@ +# +# This template file can be filled with questionary or manually +# +# + +input: + air: + drymass: 1 + hydrostatic: 0 + shared: + agrid: C180 + bcs_dir: /discover/nobackup/projects/gmao/ssd/aogcm/atmosphere_bcs/Ganymed/MOM5//CF0180x6C_TM0720xTM0410/ + expid: S2S-2_1_ANA_001 + ogrid: 720X410 + rst_dir: /discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/s2sToc12MOM6/inputs + yyyymmddhh: '2021041600' + surface: + zoom: '2' + wemin: '26' + # it supports three models: catch, catchcnclm40, catchcnclm45 + catch_model: catch + +output: + shared: + agrid: C12 + bcs_dir: /discover/nobackup/projects/gmao/ssd/aogcm/atmosphere_bcs/Icarus-NLv3/MOM6//CF0012x6C_TM0072xTM0036/ + expid: c12-MOM6 + ogrid: 72X36 + out_dir: $NOBACKUP/REMAP_TESTS/s2sToc12MOM6/ + air: + # remap upper air or not + remap: true + nlevel: '72' + surface: + split_saltwater: true + surflay: 50.0 + wemin: '13' + # remap lake, saltwater, landicet + remap_water: true + # remap catch(cn) + remap_catch: true + analysis: + bkg: false + aqua: true + lcv: false + +slurm: + account: g0620 + qos: debug + constraint: cas diff --git a/GEOS_Util/post/tests/test_remap_cases.yaml b/GEOS_Util/post/tests/test_remap_cases.yaml index 0c59af44..4fdebfc7 100644 --- a/GEOS_Util/post/tests/test_remap_cases.yaml +++ b/GEOS_Util/post/tests/test_remap_cases.yaml @@ -6,11 +6,13 @@ f522Toc360: config: 'f522Toc360.yaml' amip_c180Toc90: base_line: '/discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/amip_c180Toc90/baseline/' - config: 'amip_c180Toc90.yaml' + config: 'amip_c180Toc90.yaml' c180Toc360: base_line: '/discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/c180Toc360/baseline/' config: 'c180Toc360.yaml' c360Toc24: base_line: '/discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/c360Toc24/baseline/' config: 'c360Toc24.yaml' - +s2sToc12MOM6: + base_line: '/discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/s2sToc12MOM6/baseline/' + config: 's2sToc12MOM6.yaml' From c188423736c0438b8b9769592831c721844d7a44 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Mon, 15 Aug 2022 14:53:38 -0400 Subject: [PATCH 15/22] add item catch_tilefile --- GEOS_Util/post/tests/c24Toc12.yaml | 3 ++- GEOS_Util/post/tests/f522Toc360.yaml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/GEOS_Util/post/tests/c24Toc12.yaml b/GEOS_Util/post/tests/c24Toc12.yaml index 3bd204a4..3167a096 100644 --- a/GEOS_Util/post/tests/c24Toc12.yaml +++ b/GEOS_Util/post/tests/c24Toc12.yaml @@ -20,7 +20,7 @@ input: wemin: '13' # it supports three models: catch, catchcnclm40, catchcnclm45 catch_model: catch - + catch_tilefile: null output: shared: agrid: C12 @@ -37,6 +37,7 @@ output: wemin: '13' remap_water: true remap_catch: true + catch_tilefile: null analysis: bkg: false aqua: true diff --git a/GEOS_Util/post/tests/f522Toc360.yaml b/GEOS_Util/post/tests/f522Toc360.yaml index f4450582..3a013ae1 100644 --- a/GEOS_Util/post/tests/f522Toc360.yaml +++ b/GEOS_Util/post/tests/f522Toc360.yaml @@ -19,7 +19,7 @@ input: zoom: '8' wemin: '26' catch_model: catch - + catch_tilefile: null output: shared: agrid: C360 @@ -36,6 +36,7 @@ output: wemin: '13' remap_catch: true remap_water: true + catch_tilefile: null analysis: bkg: true aqua: true From 252afbf85709fb2d2d94e30c3898e5df27288b9e Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Mon, 15 Aug 2022 15:01:53 -0400 Subject: [PATCH 16/22] Add catch_tilefile: null --- GEOS_Util/post/tests/c24Toc12.yaml | 6 +++++- GEOS_Util/post/tests/f522Toc360.yaml | 3 ++- GEOS_Util/post/tests/s2sToc12MOM6.yaml | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/GEOS_Util/post/tests/c24Toc12.yaml b/GEOS_Util/post/tests/c24Toc12.yaml index 367a6974..0b96e65e 100644 --- a/GEOS_Util/post/tests/c24Toc12.yaml +++ b/GEOS_Util/post/tests/c24Toc12.yaml @@ -20,7 +20,7 @@ input: wemin: '13' # it supports three models: catch, catchcnclm40, catchcnclm45 catch_model: catch - + catch_tilefile: null output: shared: agrid: C12 @@ -29,14 +29,18 @@ output: ogrid: 360X180 out_dir: $NOBACKUP/REMAP_TESTS/c24Toc12/ air: + # remap upper air or not remap: true nlevel: '72' surface: split_saltwater: true surflay: 50.0 wemin: '13' + # remap lake, saltwater, landicet remap_water: true + # remap catch(cn) remap_catch: true + catch_tilefile: null analysis: bkg: false aqua: true diff --git a/GEOS_Util/post/tests/f522Toc360.yaml b/GEOS_Util/post/tests/f522Toc360.yaml index 48048b38..5d3dfd0f 100644 --- a/GEOS_Util/post/tests/f522Toc360.yaml +++ b/GEOS_Util/post/tests/f522Toc360.yaml @@ -19,7 +19,7 @@ input: zoom: '8' wemin: '26' catch_model: catch - + catch_tilefile: null output: shared: agrid: C360 @@ -35,6 +35,7 @@ output: surflay: 50.0 wemin: '13' remap_catch: true + catch_tilefile: null remap_water: true analysis: bkg: true diff --git a/GEOS_Util/post/tests/s2sToc12MOM6.yaml b/GEOS_Util/post/tests/s2sToc12MOM6.yaml index ef66f2b9..57634b8e 100644 --- a/GEOS_Util/post/tests/s2sToc12MOM6.yaml +++ b/GEOS_Util/post/tests/s2sToc12MOM6.yaml @@ -19,7 +19,7 @@ input: wemin: '26' # it supports three models: catch, catchcnclm40, catchcnclm45 catch_model: catch - + catch_tilefile: null output: shared: agrid: C12 @@ -39,6 +39,7 @@ output: remap_water: true # remap catch(cn) remap_catch: true + catch_tilefile: null analysis: bkg: false aqua: true From a2483335db8bedb3ba0683666d0277eecb969261 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Mon, 15 Aug 2022 15:56:12 -0400 Subject: [PATCH 17/22] Add false merra-2 --- GEOS_Util/post/tests/s2sToc12MOM6.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/GEOS_Util/post/tests/s2sToc12MOM6.yaml b/GEOS_Util/post/tests/s2sToc12MOM6.yaml index 57634b8e..58cada6c 100644 --- a/GEOS_Util/post/tests/s2sToc12MOM6.yaml +++ b/GEOS_Util/post/tests/s2sToc12MOM6.yaml @@ -8,6 +8,7 @@ input: drymass: 1 hydrostatic: 0 shared: + MERRA-2: false agrid: C180 bcs_dir: /discover/nobackup/projects/gmao/ssd/aogcm/atmosphere_bcs/Ganymed/MOM5//CF0180x6C_TM0720xTM0410/ expid: S2S-2_1_ANA_001 From c5e82ecc949e1eb9c4ce4a81f678ca40436e2ca0 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Tue, 16 Aug 2022 11:14:36 -0400 Subject: [PATCH 18/22] Clean up after merge --- GEOS_Util/post/tests/f522Toc360.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/GEOS_Util/post/tests/f522Toc360.yaml b/GEOS_Util/post/tests/f522Toc360.yaml index ce0e5c81..17deaa62 100644 --- a/GEOS_Util/post/tests/f522Toc360.yaml +++ b/GEOS_Util/post/tests/f522Toc360.yaml @@ -35,7 +35,6 @@ output: surflay: 50.0 wemin: '13' remap_catch: true - catch_tilefile: null remap_water: true catch_tilefile: null analysis: From 838d14377e556c51d50543f3a676a39cc1615624 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Tue, 16 Aug 2022 13:02:40 -0400 Subject: [PATCH 19/22] Add extra isinstance per Weiyuan --- GEOS_Util/post/remap_restart/remap_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GEOS_Util/post/remap_restart/remap_utils.py b/GEOS_Util/post/remap_restart/remap_utils.py index d3c6a7d2..3c39cc47 100644 --- a/GEOS_Util/post/remap_restart/remap_utils.py +++ b/GEOS_Util/post/remap_restart/remap_utils.py @@ -52,9 +52,9 @@ def flatten_nested(nested_dict, result=None, prefix=''): flat_dict = flatten_nested(config) - k = 1 + k = 1 for key, value in flat_dict.items(): - if isinstance(value, int) or isinstance(value, float) : value = str(value) + if isinstance(value, int) or isinstance(value, float) or isinstance(value, bool) or isinstance(value, type(None)): value = str(value) if k == 1: cmd = cmd + 'set FLAT_YAML="' + key+"="+ value+ '"\n' else: @@ -111,7 +111,7 @@ def merra2_expid(config): config['expid'] = expid return config - + if __name__ == '__main__' : config = yaml_to_config('c24Toc12.yaml') print_config(config) From 9e5defb4ceca55c9827e4ee9dc8f649edab81821 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Wed, 17 Aug 2022 10:36:51 -0400 Subject: [PATCH 20/22] Move to use S2Sv3 inputs --- CHANGELOG.md | 6 +++--- ...{s2sToc12MOM6.yaml => s2sv3Toc12MOM6.yaml} | 20 ++++++++++--------- GEOS_Util/post/tests/test_remap_cases.yaml | 6 +++--- 3 files changed, 17 insertions(+), 15 deletions(-) rename GEOS_Util/post/tests/{s2sToc12MOM6.yaml => s2sv3Toc12MOM6.yaml} (71%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 408cfb98..18417aa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,12 +14,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Generated command line to run the program -- changed the location of the temporary folder for remap_restarts MERRA-2 case +- changed the location of the temporary folder for remap_restarts MERRA-2 case - Added new remap tests - amip_c180Toc90 - c180Toc360 - c360Toc24 - - s2sToc12MOM6 + - s2sv3Toc12MOM6 ### Fixed @@ -54,7 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Added statsNx.rc for screen level variable fstats +- Added statsNx.rc for screen level variable fstats ### Changed diff --git a/GEOS_Util/post/tests/s2sToc12MOM6.yaml b/GEOS_Util/post/tests/s2sv3Toc12MOM6.yaml similarity index 71% rename from GEOS_Util/post/tests/s2sToc12MOM6.yaml rename to GEOS_Util/post/tests/s2sv3Toc12MOM6.yaml index 58cada6c..d280414f 100644 --- a/GEOS_Util/post/tests/s2sToc12MOM6.yaml +++ b/GEOS_Util/post/tests/s2sv3Toc12MOM6.yaml @@ -10,24 +10,25 @@ input: shared: MERRA-2: false agrid: C180 - bcs_dir: /discover/nobackup/projects/gmao/ssd/aogcm/atmosphere_bcs/Ganymed/MOM5//CF0180x6C_TM0720xTM0410/ - expid: S2S-2_1_ANA_001 - ogrid: 720X410 - rst_dir: /discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/s2sToc12MOM6/inputs - yyyymmddhh: '2021041600' + bcs_dir: /discover/nobackup/projects/gmao/ssd/aogcm/atmosphere_bcs/Icarus/MOM5//CF0180x6C_TM1440xTM1080/ + expid: M2OCEAN_S2SV3 + ogrid: 1440X1080 + rst_dir: /discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/s2sv3Toc12MOM6/inputs + yyyymmddhh: '1982010100' surface: zoom: '2' wemin: '26' # it supports three models: catch, catchcnclm40, catchcnclm45 catch_model: catch - catch_tilefile: null + # if catch_tilefile is null, it searches bcs_dir + catch_tilefile: output: shared: agrid: C12 bcs_dir: /discover/nobackup/projects/gmao/ssd/aogcm/atmosphere_bcs/Icarus-NLv3/MOM6//CF0012x6C_TM0072xTM0036/ - expid: c12-MOM6 + expid: C12-MOM6-from-S2Sv3 ogrid: 72X36 - out_dir: $NOBACKUP/REMAP_TESTS/s2sToc12MOM6/ + out_dir: $NOBACKUP/REMAP_TESTS/s2sv3Toc12MOM6/ air: # remap upper air or not remap: true @@ -40,7 +41,8 @@ output: remap_water: true # remap catch(cn) remap_catch: true - catch_tilefile: null + # if catch_tilefile is null, it searches bcs_dir + catch_tilefile: analysis: bkg: false aqua: true diff --git a/GEOS_Util/post/tests/test_remap_cases.yaml b/GEOS_Util/post/tests/test_remap_cases.yaml index 4fdebfc7..166d091a 100644 --- a/GEOS_Util/post/tests/test_remap_cases.yaml +++ b/GEOS_Util/post/tests/test_remap_cases.yaml @@ -13,6 +13,6 @@ c180Toc360: c360Toc24: base_line: '/discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/c360Toc24/baseline/' config: 'c360Toc24.yaml' -s2sToc12MOM6: - base_line: '/discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/s2sToc12MOM6/baseline/' - config: 's2sToc12MOM6.yaml' +s2sv3Toc12MOM6: + base_line: '/discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/s2sv3Toc12MOM6/baseline/' + config: 's2sv3Toc12MOM6.yaml' From 9176e53ce0aa115fea3709cd5cb617850ebfcc54 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Wed, 17 Aug 2022 10:37:09 -0400 Subject: [PATCH 21/22] Clean up template to remove trailing spaces --- GEOS_Util/post/remap_restart/remap_params.tpl | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/GEOS_Util/post/remap_restart/remap_params.tpl b/GEOS_Util/post/remap_restart/remap_params.tpl index 94cedbfd..a8ca9ac9 100644 --- a/GEOS_Util/post/remap_restart/remap_params.tpl +++ b/GEOS_Util/post/remap_restart/remap_params.tpl @@ -1,7 +1,7 @@ # # This template file can be filled with questionary or manually -# -# +# +# input: air: @@ -9,7 +9,7 @@ input: hydrostatic: 0 shared: MERRA-2: false - agrid: + agrid: bcs_dir: expid: ogrid: @@ -20,14 +20,14 @@ input: wemin: # it supports three models: catch, catchcnclm40, catchcnclm45 catch_model: null - # if catch_tilefile is null, it searches bcs_dir + # if catch_tilefile is null, it searches bcs_dir catch_tilefile: null output: shared: agrid: - bcs_dir: - expid: - ogrid: + bcs_dir: + expid: + ogrid: out_dir: air: # remap upper air or not @@ -41,7 +41,7 @@ output: remap_water: true # remap catch(cn) remap_catch: true - # if catch_tilefile is null, it searches bcs_dir + # if catch_tilefile is null, it searches bcs_dir catch_tilefile: null analysis: bkg: true @@ -49,6 +49,6 @@ output: lcv: false slurm: - account: - qos: - constraint: + account: + qos: + constraint: From 9125540412e621b6c949602e645d10c538756ee9 Mon Sep 17 00:00:00 2001 From: Weiyuan Jiang Date: Thu, 18 Aug 2022 10:35:29 -0400 Subject: [PATCH 22/22] add final report --- GEOS_Util/post/tests/test_remap_restarts.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/GEOS_Util/post/tests/test_remap_restarts.py b/GEOS_Util/post/tests/test_remap_restarts.py index f699ba7c..69c6707c 100755 --- a/GEOS_Util/post/tests/test_remap_restarts.py +++ b/GEOS_Util/post/tests/test_remap_restarts.py @@ -69,7 +69,8 @@ def test_remap(config): (user, err) = p.communicate() p_status = p.wait() user = user.decode().split()[0] - + + report ={} for case, values in cases.items(): base_line = values['base_line'] config_yaml_file = values['config'] @@ -87,6 +88,11 @@ def test_remap(config): rc = compare(base_line, out_dir) if (not rc) : print ("failed in " + case) + report[case] = "Failed" else : + report[case] = "Succeeded" print (case +" test is successful") + print("\n\n") + for case, result in report.items(): + print(case + ": " + result)