Skip to content
Snippets Groups Projects
Commit 2f9e69d0 authored by kgao's avatar kgao
Browse files

added functionality without -s and -e flag

Without -s and -e, it converts each file into a new netcdf file
if -o is used, it converts it itno those output filenames
otherwise, it uses first stamp to name the files
Uh, doesn't do anything about empty .ascii files yet
Will have to ask about that
parent 04bd908d
No related branches found
No related tags found
No related merge requests found
......@@ -188,7 +188,8 @@ def createGiantNetCDF(start, end, inputFiles, outputName, zlib, chunkSize):
frame = getData(inputFiles)
frame = frame[start.strftime('%Y-%m-%d %H:%M:%S'): end.strftime('%Y-%m-%d %H:%M:%S')]
if(start and end):
frame = frame[start.strftime('%Y-%m-%d %H:%M:%S'): end.strftime('%Y-%m-%d %H:%M:%S')]
firstStamp = dt.strptime(str(list(frame.index)[0]), '%Y-%m-%d %H:%M:%S')
......@@ -204,6 +205,18 @@ def createGiantNetCDF(start, end, inputFiles, outputName, zlib, chunkSize):
ncFile = writeVars(ncFile, frame)
ncFile.close()
def createMultiple(filenames, outputFilenames, zlib, chunkSize):
if(outputFilenames and len(filenames) != len(outputFilenames)):
print('USAGE: number of output filenames must equal number of input filenames when start and end times are not specified')
exit(0)
for idx, filename in enumerate(filenames):
if(outputFilenames):
createGiantNetCDF(None, None, [filename], outputFilenames[idx], zlib, chunkSize)
else:
createGiantNetCDF(None, None, [filename], None, zlib, chunkSize)
#The purpose of this method is to take a string in the format
# YYYY-mm-ddTHH:MM:SS and convert that to a datetime object
......@@ -235,7 +248,7 @@ def main():
parser.add_argument("input_files", nargs="+",
help="aoss_tower level_00 paths")
parser.add_argument('-o', '--output', help="filename pattern or filename. " +
parser.add_argument('-o', '--output', nargs="+", help="filename pattern or filename. " +
"Should be along the lines of <filepath>/aoss_tower.YYYY-MM-DD.nc")
args = parser.parse_args()
......@@ -247,6 +260,6 @@ def main():
createGiantNetCDF(args.start_time, args.end_time, args.input_files, args.output, args.zlib, args.chunk_size)
else:
createNetCDF(args.input_files, args.ouput)
createMultiple(args.input_files, args.output, args.zlib, args.chunk_size)
if __name__ == "__main__":
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment