diff --git a/aosstower/level_a0/nc.py b/aosstower/level_a0/nc.py index 774f29b474e9274973449821d80eb6428c4c195e..91e75227d4ab4fcb1bf1ce85ca4fc308b391aba2 100644 --- a/aosstower/level_a0/nc.py +++ b/aosstower/level_a0/nc.py @@ -266,7 +266,10 @@ def createMultiple(filenames, outputFilenames, zlib, chunkSize): def _dt_convert(datetime_str): #parse datetime string, return datetime object - return dt.strptime(datetime_str, '%Y-%m-%dT%H:%M:%S') + try: + return dt.strptime(datetime_str, '%Y-%m-%dT%H:%M:%S') + except: + return dt.strptime(datetime_str, '%Y-%m-%d') def main(): import argparse @@ -280,8 +283,11 @@ def main(): help='each occurrence increases verbosity 1 level through ERROR-WARNING-INFO-DEBUG (default INFO)') #argparse start and end times - parser.add_argument('-s', '--start-time', type=_dt_convert, help="Start time of massive netcdf file") - parser.add_argument('-e', '--end-time', type=_dt_convert, help='End time of massive netcdf file') + parser.add_argument('-s', '--start-time', type=_dt_convert, + help="Start time of massive netcdf file, if only -s is given, a netcdf file for only that day is given" + + ". Formats allowed: \'YYYY-MM-DDTHH:MM:SS\', \'YYYY-MM-DD\'") + parser.add_argument('-e', '--end-time', type=_dt_convert, help='End time of massive netcdf file. Formats allowed:' + + "\'YYYY-MM-DDTHH:MM:SS\', \'YYYY-MM-DD\'") parser.add_argument('-cs', '--chunk-size', type=int, help='chunk Size for the netCDF file') parser.add_argument('-z', '--zlib', action='store_true', help='compress netCDF file with zlib') @@ -302,8 +308,14 @@ def main(): if(result == False): raise IOError('An empty ASCII file was found') - elif(args.start_time or args.end_time): - print('USAGE: start time and end time must both be specified or not specified') + elif(args.start_time): + end_time = args.start_time.replace(hour=23, minute=59, second=59) + result = createGiantNetCDF(args.start_time, end_time, args.input_files, args.output[0], args.zlib, args.chunk_size) + if(result == False): + raise IOError('An empty ASCII file was found') + + elif(args.end_time): + print('USAGE: start time must be specified when end time is specified') else: createMultiple(args.input_files, args.output, args.zlib, args.chunk_size)