diff --git a/gridmetetl/etl.py b/gridmetetl/etl.py index 9729b8f..292645e 100644 --- a/gridmetetl/etl.py +++ b/gridmetetl/etl.py @@ -136,7 +136,7 @@ def __init__(self, climsource='GridMetSS'): def write_extract_file(self, ivar, incfile, url, params): file = requests.get(url, params=params) file.raise_for_status() - tfile = self.iptpath / (self.fileprefix + ivar + (datetime.now().strftime('%Y_%m_%d')) + '.nc') + tfile = self.iptpath / (self.fileprefix + ivar + (self.end_date.strftime('%Y_%m_%d')) + '.nc') incfile.append(tfile) with open(tfile, 'wb') as fh: fh.write(file.content) @@ -185,6 +185,7 @@ def initialize(self, partial, ivars, iptpath, optpath, weights_file, etype=None, self.numdays = days self.start_date = start_date self.end_date = end_date + print(self.end_date, type(self.end_date)) self.fileprefix = fileprefix print(Path.cwd()) @@ -429,7 +430,7 @@ def finalize(self): print(Path.cwd(), flush=True) ncfile = Dataset( - self.optpath / (self.fileprefix + 'climate_' + str(datetime.now().strftime('%Y_%m_%d')) + '.nc'), + self.optpath / (self.fileprefix + 'climate_' + str(self.end_date.strftime('%Y_%m_%d')) + '.nc'), mode='w', format='NETCDF4_CLASSIC') def getxy(pt): diff --git a/gridmetetl/gridmet_etl.py b/gridmetetl/gridmet_etl.py index 4673973..7003ed4 100644 --- a/gridmetetl/gridmet_etl.py +++ b/gridmetetl/gridmet_etl.py @@ -1,5 +1,5 @@ """Console script for gridmetetl.""" -from etl import FpoNHM +from .etl import FpoNHM import argparse import sys import datetime @@ -109,10 +109,10 @@ def get_file_prefix(args): else: return '' -def main(parser, args): +def main(): """Console script for gridmetetl.""" - my_parser = parser - my_args = args + my_parser = parser() + my_args = args(my_parser) numdays = None startdate = None enddate = None @@ -128,7 +128,7 @@ def main(parser, args): idir = my_args.inpath odir = my_args.outpath wght_file = my_args.weightsfile - file_prefix = get_file_prefix(args) + file_prefix = get_file_prefix(my_args) gm_vars = my_args.variables partial = my_args.partial print('starting Script', flush=True) @@ -170,7 +170,4 @@ def main(parser, args): if __name__ == "__main__": - parser = parser() - args = args(parser) - - main(parser, args) + sys.exit(main())