Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions pre/remap_restart/remap_command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def parse_args(program_description):
p_command.add_argument('-in_stretch', default=False, help='Stretched CS params of input restarts', choices=choices_stretch)
p_command.add_argument('-out_stretch', default=False, help='Stretched CS params for new restarts', choices=choices_stretch)

# Unlike remap_questions.py, command-line feature does not deduce Catch vs. CatchCN[40,45] for simplicity, thus requires input argument
# Unlike remap_questions.py, command-line feature does not deduce Catch vs. CatchCN[40,51] for simplicity, thus requires input argument
p_command.add_argument('-catch_model',default='catch', help='Catchment[CN] model', choices=choices_catchmodel)

p_command.add_argument('-nobkg', action='store_true', help="Do not remap bkg files")
Expand Down Expand Up @@ -146,8 +146,7 @@ def get_answers_from_command_line(cml):
if cml.zoom:
answers["input:surface:zoom"] = cml.zoom
else:
# zoom_default fills 'input:shared:agrid'
answers["input:surface:zoom"] = zoom_default(answers)
answers["input:surface:zoom"] = get_zoom(answers)

if cml.in_wemin :
answers["input:surface:wemin"] = cml.in_wemin
Expand Down
36 changes: 20 additions & 16 deletions pre/remap_restart/remap_lake_landice_saltwater.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
import glob
import ruamel.yaml
import shlex
from remap_base import remap_base
from remap_utils import get_label
from remap_utils import get_geomdir
from remap_base import remap_base
from remap_utils import get_label, get_geomdir, get_zoom
from remap_bin2nc import bin2nc

class lake_landice_saltwater(remap_base):
Expand Down Expand Up @@ -53,17 +52,19 @@ def remap(self):
stretch = config['input']['shared']['stretch']
in_tile_file = config['input']['surface']['catch_tilefile']
if not in_tile_file :
in_geomdir = get_geomdir(in_bc_base, in_bc_version, agrid=agrid, ogrid=ogrid, omodel=omodel, stretch=stretch)
in_tile_file = glob.glob(in_geomdir+ '/*-Pfafstetter.til')[0]
EASE_grid = config['input']['surface'].get('EASE_grid', None)
in_geomdir = get_geomdir(in_bc_base, in_bc_version, agrid=agrid, ogrid=ogrid, omodel=omodel, stretch=stretch, grid=EASE_grid)
in_tile_file = glob.glob(in_geomdir+ '/*.til')[0]

agrid = config['output']['shared']['agrid']
ogrid = config['output']['shared']['ogrid']
omodel = config['output']['shared']['omodel']
stretch = config['output']['shared']['stretch']
out_tile_file = config['output']['surface']['catch_tilefile']
if not out_tile_file :
out_geomdir = get_geomdir(out_bc_base, out_bc_version, agrid=agrid, ogrid=ogrid, omodel=omodel, stretch=stretch)
out_tile_file = glob.glob(out_geomdir+ '/*-Pfafstetter.til')[0]
EASE_grid = config['output']['surface'].get('EASE_grid', None)
out_geomdir = get_geomdir(out_bc_base, out_bc_version, agrid=agrid, ogrid=ogrid, omodel=omodel, stretch=stretch, grid=EASE_grid)
out_tile_file = glob.glob(out_geomdir+ '/*.til')[0]

types = '.bin'
type_str = sp.check_output(['file','-b', os.path.realpath(restarts_in[0])])
Expand Down Expand Up @@ -118,23 +119,26 @@ def remap(self):
if 'saltwater_import' in f : saltwater_import = f
if 'seaicethermo_internal' in f : seaicethermo_internal = f
if 'seaicethermo_import' in f : seaicethermo_import = f
if 'landice' in f : landice = f
if 'lake' in f : lake = f
if 'roue' in f : route = f
if 'openwater' in f : openwater = f
if 'landice' in f : landice = f
if 'lake' in f : lake = f
if 'roue' in f : route = f
if 'openwater' in f : openwater = f

in_til = InData_dir+'/' + os.path.basename(in_tile_file)
out_til = OutData_dir+'/'+ os.path.basename(out_tile_file)

if os.path.exists(in_til) : shutil.remove(in_til)
if os.path.exists(out_til) : shutil.remove(out_til)
print('\n Copy ' + in_tile_file + ' to ' + in_til)
print('\n Copy ' + in_tile_file + ' to ' + in_til)
shutil.copy(in_tile_file, in_til)
print('\n Copy ' + out_tile_file + ' to ' + out_til)
shutil.copy(out_tile_file, out_til)

exe = bindir + '/mk_LakeLandiceSaltRestarts.x '
zoom = config['input']['surface']['zoom']
if zoom is None :
zoom = get_zoom(config)

log_name = out_dir+'/remap_lake_landice_saltwater_log'
if os.path.exists(log_name):
os.remove(log_name)
Expand Down Expand Up @@ -227,7 +231,7 @@ def find_rst(self):
"landice_internal_rst" ,
"openwater_internal_rst" ,
"saltwater_internal_rst" ,
"saltwater_import_rst" ,
"saltwater_import_rst" ,
"seaicethermo_internal_rst",
"seaicethermo_import_rst"]

Expand All @@ -254,9 +258,9 @@ def copy_merra2(self):

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]
yyyy_ = yyyymmddhh_[0: 4]
mm_ = yyyymmddhh_[4: 6]
dd_ = yyyymmddhh_[6: 8]
hh_ = yyyymmddhh_[8:10]

suffix = yyyymmddhh_[0:8]+'_'+ hh_ + 'z.bin'
Expand Down
2 changes: 1 addition & 1 deletion pre/remap_restart/remap_params.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ input:
surface:
zoom:
wemin:
# it supports three models: catch, catchcnclm40, catchcnclm45
# it supports three models: catch, catchcnclm40, catchcnclm51
catch_model: null
# if catch_tilefile is null, it searches bc_dir
catch_tilefile: null
Expand Down
2 changes: 1 addition & 1 deletion pre/remap_restart/remap_questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def ask_questions():
"type": "text",
"name": "input:surface:zoom",
"message": "Enter value of zoom parameter for surface restarts [1-8]? (Search radius, smaller value means larger radius.)\n",
"default": lambda x: zoom_default(x)
"default": lambda x: get_zoom(x)
},
{
"type": "text",
Expand Down
31 changes: 20 additions & 11 deletions pre/remap_restart/remap_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import glob
import shlex
import netCDF4 as nc
import linecache

# shared global variables

Expand All @@ -36,7 +37,7 @@

choices_omodel = ['data', 'MOM5', 'MOM6']

choices_catchmodel = ['catch', 'catchcnclm40', 'catchcnclm45']
choices_catchmodel = ['catch', 'catchcnclm40', 'catchcnclm51']

choices_ogrid_data = ['360x180 (Reynolds)','1440x720 (MERRA-2)','2880x1440 (OSTIA)','CS (same as atmosphere OSTIA cubed-sphere grid)']

Expand Down Expand Up @@ -284,8 +285,8 @@ def catch_model(x):
model = 'catch'
if 'cnclm40' in fname.lower():
model = 'catchcnclm40'
if 'cnclm45' in fname.lower():
model = 'catchcnclm45'
if 'cnclm51' in fname.lower():
model = 'catchcnclm51'
return model

def data_ocean_default(resolution):
Expand Down Expand Up @@ -340,17 +341,25 @@ def show_wemin_default(x):
# If neither MERRA2 or GEOS-IT is selected option will be shown on screen
return True

def zoom_default(x):
def get_zoom(x):
# "zoom" approximates the (integer) number of grid cells per degree lat or lon (min=1, max=8);
# for EASEv2 grid and lat/lon grid, always use the default value of 8.
zoom_ = '8'
cxx = x.get('input:shared:agrid')
if cxx :
lat = int(cxx[1:])
zoom = lat /90.0
zoom_ = str(int(zoom))
if zoom < 1 : zoom_ = '1'
if zoom > 8 : zoom_ = '8'
if x.get('input:shared:MERRA-2') or x.get('input:shared:GEOS-IT'):
zoom_ = '2'
return zoom_
agrid = None
if 'input:shared:agrid' in x.keys():
agrid = x.get('input:shared:agrid')
elif 'input' in x.keys():
agrid = x['input']['shared']['agrid']
if agrid:
if (agrid[0].upper() == 'C'): # for cube-sphere: agrid = C90, C180, C1440, ...
lat = int(agrid[1:])
zoom = lat /90.0
if zoom < 1 : zoom = 1
if zoom > 8 : zoom = 8
zoom_= str(int(zoom))
return zoom_

def get_account():
Expand Down
Loading