OttoStruve / muler

A Python package for working with pipeline-produced spectra from IGRINS, HPF, and Keck NIRSPEC
https://muler.readthedocs.io
MIT License
15 stars 9 forks source link

IGRINS: Make a reusable function for classifying IGRINS input based on its filename #144

Open gully opened 1 year ago

gully commented 1 year ago

We have a few instances of repeating the same pattern for classifying IGRINS data based on its filename alone. For example:

if ".spec_a0v.fits" in filepath: #Grab base file name for the uncertainity file
        path_base = filepath[:-14]
    elif ".spec_flattened.fits" in filepath:
        path_base = filepath[:-20]
    elif ".spec.fits" in filepath:
        path_base = filepath[:-10]

We should put this in to a modular function:

def classify_IGRINS_filename(filename):
    [...] # do logic testing
   return {'band':band, 'reduction_type':reduction_type, 'basename':basename, 'is_http':is_http, 'path_base':path_base, 'index':index}

This should streamline lots of methods that reapply the same logic, and should futureproof against future methods that need these qualifiers in order to process the data. For example, knowing if the file is online versus local changes the way we would search for the existence or not of ancillary files.