niriss_ghost/utils.py
def tweak_dq(id_gst, infile, segfile, outfile=None, DQ_SET=1, DQ_KEY='DQ'):
    '''
    Purpose
    -------
    To make a copy of input fits file and tweak its DQ array.
    '''
    if not outfile == None:
        outfile = infile.replace('.fits','_gst.fits')

    try:
        dq_array = fits.open(infile)[DQ_KEY]
    except:
        print('DQ array, `%s`, not found. No DQ tweaking.'%DQ_KEY)
        return False

    os.system('cp %s %s'%(infile, outfile))
    
    seg = fits.open(segfile)[0].data
    with fits.open(outfile, mode='update') as hdul:
        for id in id_gst:
            con = np.where(seg == id)
            # 1073741824
            #hdul[DQ_KEY].data[con] += DQ_SET
            hdul[DQ_KEY].data[con] = DQ_SET
        
        hdul.flush()  # changes are written back to original.fits

    return True

    Purpose
    -------
    To make a copy of input fits file and tweak its DQ array.
    
Purpose
To make a copy of input fits file and tweak its DQ array.
Purpose To make a copy of input fits file and tweak its DQ array .
def tweak_dq(id_gst, infile, segfile, outfile=None, DQ_SET=1, DQ_KEY='DQ'):
    if not outfile == None:
        outfile = infile.replace('.fits','_gst.fits')
    try:
        dq_array = fits.open(infile)[DQ_KEY]
    except:
        print('DQ array, `%s`, not found. No DQ tweaking.'%DQ_KEY)
        return False
    os.system('cp %s %s'%(infile, outfile))
    seg = fits.open(segfile)[0].data
    with fits.open(outfile, mode='update') as hdul:
        for id in id_gst:
            con = np.where(seg == id)
            hdul[DQ_KEY].data[con] = DQ_SET
        hdul.flush()  
    return True
def tweak_dq ( id_gst , infile , segfile , outfile = None , DQ_SET = 1 , DQ_KEY = 'DQ' ) : if not outfile == None : outfile = infile . replace ( '.fits' , '_gst.fits' ) try : dq_array = fits . open ( infile ) [ DQ_KEY ] except : print ( 'DQ array, `%s`, not found. No DQ tweaking.' % DQ_KEY ) return False os . system ( 'cp %s %s' % ( infile , outfile ) ) seg = fits . open ( segfile ) [ 0 ] . data with fits . open ( outfile , mode = 'update' ) as hdul : for id in id_gst : con = np . where ( seg == id ) hdul [ DQ_KEY ] . data [ con ] = DQ_SET hdul . flush ( ) return True
Purpose
To make a copy of input fits file and tweak its DQ array.
Purpose To make a copy of input fits file and tweak its DQ array .
'''
    Purpose
    -------
    To make a copy of input fits file and tweak its DQ array.
    ''' # 1073741824 #hdul[DQ_KEY].data[con] += DQ_SET # changes are written back to original.fits
id_gst
infile
segfile
outfile
DQ_SET
DQ_KEY