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

adds a basic position: auto argument to determine the position from the input filenames

parent bebf0caa
No related branches found
No related tags found
1 merge request!3glm_grids_updates
......@@ -71,7 +71,7 @@ def create_parser():
help="subdivide the grid this many times along "
"each dimension")
parser.add_argument('--goes-position',
help="One of [east|west|test]. "
help="One of [east|west|test|auto]. "
"Requires '--goes-sector'.")
parser.add_argument('--goes-sector',
help="One of [full|conus|meso]. "
......@@ -105,6 +105,17 @@ def nearest_resolution(args):
return resln
# if provided "auto" position, we determine the sensor from the filename
def get_goes_position(filenames):
if all("_G16_" in f for f in filenames):
return "east"
if all("_G17_" in f for f in filenames):
return "west"
# we require that all files are from the same sensor and raise an exception if not
raise ValueError("position 'auto' but could not determine position - did you provide a mix of satellites?")
def get_start_end(filenames, start_time=None, end_time=None):
"""Compute start and end time of data based on filenames."""
base_filenames = [os.path.basename(p) for p in filenames]
......@@ -154,6 +165,10 @@ def grid_setup(args):
output = os.path.join(args.output_dir, "{dataset_name}") # GLMTools expects a template in addition to the path
proj_name = 'geos'
if args.goes_position == "auto":
# auto-create the goes-position from the input filename
args.goes_position = get_goes_position(args.filenames)
if args.goes_position is not None and args.goes_sector is not None:
resln = nearest_resolution(args)
view = get_GOESR_grid(position=args.goes_position,
......
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