Skip to content
Snippets Groups Projects
Commit bfba6894 authored by lkugler's avatar lkugler
Browse files

prepare nature

parent 9604f73c
No related branches found
No related tags found
No related merge requests found
...@@ -26,22 +26,17 @@ def _copy_nature_to_dart(time): ...@@ -26,22 +26,17 @@ def _copy_nature_to_dart(time):
TODO: This is a bit of a hack, because it is not explicit about where to take the nature from. TODO: This is a bit of a hack, because it is not explicit about where to take the nature from.
""" """
# find the file in any init directory glob_pattern = time.strftime(exp.nature_wrfout_pattern) # replace time in pattern
fformat = 'wrfout_d01_%Y-%m-%d_%H:%M:%S' f_nat = glob.glob(glob_pattern)[0] # find the nature wrfout-file
f_nat = glob.glob(cluster.archive_base + '/' + exp.nature_expname + '/*/1/'+time.strftime(fformat))[0]
shutil.copy(f_nat, cluster.dart_rundir + "/wrfout_d01")
# DART may need a wrfinput file as well ?! # check user input
symlink(cluster.dart_rundir + "/wrfout_d01", if not 'wrfout' in f_nat.split('/')[-1]:
cluster.dart_rundir + "/wrfinput_d01") warnings.warn(f+" does not contain 'wrfout' in filename, are you sure this is a valid nature file?")
print("linked", f_nat, "to", cluster.dart_rundir + "/wrfout_d01")
f_wrfout_nature = time.strftime(exp.nature+'/'+wrfout_format) # copy nature wrfout to DART directory
assert os.path.exists(f_wrfout_nature) shutil.copy(f_nat, cluster.dart_rundir + "/wrfout_d01")
print("linking nature to DART & georeferencing") # add coordinates if necessary
shutil.copy(f_wrfout_nature, cluster.dartrundir + "/wrfout_d01")
print("linked", f_wrfout_nature, "to", cluster.dartrundir + "/wrfout_d01")
if cluster.geo_em_for_WRF_ideal: if cluster.geo_em_for_WRF_ideal:
wrfout_add_geo.run(cluster.geo_em_for_WRF_ideal, cluster.dart_rundir + "/wrfout_d01") wrfout_add_geo.run(cluster.geo_em_for_WRF_ideal, cluster.dart_rundir + "/wrfout_d01")
...@@ -53,7 +48,7 @@ def prepare_nature_dart(time): ...@@ -53,7 +48,7 @@ def prepare_nature_dart(time):
""" """
try: try:
_copy_nature_to_dart(time) _copy_nature_to_dart(time)
except FileExistsError: # if nature is not available due to any reason except (FileNotFoundError, AttributeError) as e: # if nature is not available due to any reason
print('-> has no nature, not copying nature') print('-> has no nature, not copying nature')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment