Skip to content
Snippets Groups Projects
Commit 8936f983 authored by Nick Bearson's avatar Nick Bearson
Browse files

initial version of input handling where we determine minutes of interest and...

initial version of input handling where we determine minutes of interest and then work our way back to files
parent 00111a19
No related branches found
No related tags found
1 merge request!26group inputs by minute and process accordingly
......@@ -118,6 +118,11 @@ def get_goes_position(filenames):
# we require that all files are from the same sensor and raise an exception if not
raise ValueError("could not determine GOES position - did you provide a mix of satellites?")
def glm_filename_to_minute(glm_filename):
glminfo = parse_glm_filename(os.path.basename(glm_filename))
ftime = glminfo[3]
ftime = ftime.replace(second = 0, microsecond=0)
return ftime
def get_start_end(filenames, start_time=None, end_time=None):
"""Compute start and end time of data based on filenames."""
......@@ -342,14 +347,28 @@ if __name__ == '__main__':
# clean our temporary dir on exit
atexit.register(shutil.rmtree, tempdir_path)
# do the gridding
gridder, glm_filenames, start_time, end_time, grid_kwargs = grid_setup(args.filenames, args, work_dir=tempdir_path)
gridder_return = gridder(glm_filenames, start_time, end_time, **grid_kwargs)
minutes = []
for f in args.filenames:
m = glm_filename_to_minute(f)
if m not in minutes:
minutes.append(m)
gridded_files = []
for subgrid in gridder_return:
for gridded_file in subgrid[1]:
gridded_files.append(gridded_file)
for m in minutes:
# grab all input files for this minute
minute_files = []
for f in args.filenames:
if glm_filename_to_minute(f) == m:
minute_files.append(f)
minute_files = sorted(minute_files)
# do the gridding
gridder, glm_filenames, start_time, end_time, grid_kwargs = grid_setup(minute_files, args, work_dir=tempdir_path)
gridder_return = gridder(glm_filenames, start_time, end_time, **grid_kwargs)
for subgrid in gridder_return:
for gridded_file in subgrid[1]:
gridded_files.append(gridded_file)
# we need to add attributes here due to an issue where satpy (or its dependencies) are
# holding the input gridded file open until the process exits
......
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