Skip to content

Commit

Permalink
Merge pull request #27 from noaa-oar-arl/feature/nexus_control
Browse files Browse the repository at this point in the history
update to read the local HEMCO_sa_Time.rc instead of a supplied times…
  • Loading branch information
bbakernoaa authored Jan 5, 2023
2 parents 69a7a50 + ec82dda commit 3842818
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions utils/python/nexus_nei2016_control_tilefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,26 @@
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
from datetime import datetime

def get_start_time(fname):
""" Function to read the start date from the HEMCO_sa_Time.rc """
with open(fname) as f:
lines = f.readlines()
for line in lines:
if 'START' in line:
date = datetime.strptime(line,'START: %Y-%m-%d %H:00:00\n')
return date

if __name__ == '__main__':

parser = ArgumentParser(description='Modify the start and end date of the NEXUS config script', formatter_class=ArgumentDefaultsHelpFormatter)
parser.add_argument('-f', '--files', help='input nemsio file name', type=str, required=True)
parser.add_argument('-d', '--date', help='Date of model run. Format: %Y%m%d example: 20190810', default='./', required=True)
parser.add_argument('-f', '--files', help='input NEXUS_Config.rc file name', type=str, default='NEXUS_Config.rc', required=False)
parser.add_argument('-t', '--time_file', help='HEMCO Time File: HEMCO_sa_Time.rc', default='HEMCO_sa_Time.rc', required=False)

args = parser.parse_args()

# get input NEXUS_Config.rc
finput = args.files
d = datetime.strptime(args.date,'%Y%m%d')
d = get_start_time(args.time_file)

with open(finput,'r') as f:
lines = f.readlines()
Expand Down

0 comments on commit 3842818

Please sign in to comment.