HDI_io.py
def find_files(directory,img_type,filternum=-1):
    '''
    #
    # definition to go through HDI headers and get the images desired of a particular type
    #    and filter
    #
    
    #
    # limitations:
    #    - not set up to sort by specific targets
    #    - will not enforce one of the filter wheel slots being empty
    # 
    '''
    # grab all HDI files from the specified directory
    files = [infile for infile in glob.glob(directory+'c*t*fits') if not os.path.isdir(infile)]
    
    out_files = []

    for f in files:
        #print(f)
        phdr = fits.getheader(f,0) # the 0 is needed to get the correct extension
    
        # filter by desired_type
        
        # if biases, don't care about filter
        if    (img_type == phdr['OBSTYPE']) \
            & (img_type == 'BIAS'):
                    
            out_files.append(f)
            
        # if flats or objects, the filter matters
        if    (img_type == phdr['OBSTYPE']) \
            & (img_type != 'BIAS')\
            & ( (str(filternum) == phdr['FILTER1']) | (str(filternum) == phdr['FILTER2']) ):

            out_files.append(f)


    return out_files

    #
    # definition to go through HDI headers and get the images desired of a particular type
    #    and filter
    #
    
    #
    # limitations:
    #    - not set up to sort by specific targets
    #    - will not enforce one of the filter wheel slots being empty
    # 
    
definition to go through HDI headers and get the images desired of a particular type
and filter



- not set up to sort by specific targets
- will not enforce one of the filter wheel slots being empty
definition to go through HDI headers and get the images desired of a particular type and filter - not set up to sort by specific targets - will not enforce one of the filter wheel slots being empty
def find_files(directory,img_type,filternum=-1):
    files = [infile for infile in glob.glob(directory+'c*t*fits') if not os.path.isdir(infile)]
    out_files = []
    for f in files:
        phdr = fits.getheader(f,0) 
        if    (img_type == phdr['OBSTYPE']) \
            & (img_type == 'BIAS'):
            out_files.append(f)
        if    (img_type == phdr['OBSTYPE']) \
            & (img_type != 'BIAS')\
            & ( (str(filternum) == phdr['FILTER1']) | (str(filternum) == phdr['FILTER2']) ):
            out_files.append(f)
    return out_files
def find_files ( directory , img_type , filternum = - 1 ) : files = [ infile for infile in glob . glob ( directory + 'c*t*fits' ) if not os . path . isdir ( infile ) ] out_files = [ ] for f in files : phdr = fits . getheader ( f , 0 ) if ( img_type == phdr [ 'OBSTYPE' ] ) & ( img_type == 'BIAS' ) : out_files . append ( f ) if ( img_type == phdr [ 'OBSTYPE' ] ) & ( img_type != 'BIAS' ) & ( ( str ( filternum ) == phdr [ 'FILTER1' ] ) | ( str ( filternum ) == phdr [ 'FILTER2' ] ) ) : out_files . append ( f ) return out_files
definition to go through HDI headers and get the images desired of a particular type
    and filter
definition to go through HDI headers and get the images desired of a particular type and filter
'''
    #
    # definition to go through HDI headers and get the images desired of a particular type
    #    and filter
    #
    
    #
    # limitations:
    #    - not set up to sort by specific targets
    #    - will not enforce one of the filter wheel slots being empty
    # 
    ''' # grab all HDI files from the specified directory #print(f) # the 0 is needed to get the correct extension # filter by desired_type # if biases, don't care about filter # if flats or objects, the filter matters
directory
img_type
filternum