예제 #1
0
def run_superflat(metadata,
                  prev_suffix,
                  curr_suffix,
                  source,
                  scale=None,
                  method='median'):
    if source == 'dome':
        flat_list = [
            '%s%s.p%s.fits' % (out_dir, x, prev_suffix)
            for x in metadata['domeflat']
        ]
        out_fn = super_dflat_raw
    elif source == 'twi':
        flat_list = [
            '%s%s.p%s.fits' % (out_dir, x, prev_suffix)
            for x in metadata['twiflat']
        ]
        out_fn = super_tflat_raw
    else:
        raise ValueError, 'Flatfield type not recognized'
    print 'Generating co-add %sflat' % source
    pywifes.imcombine(flat_list,
                      out_fn,
                      data_hdu=my_data_hdu,
                      scale=scale,
                      method=method)
    return
예제 #2
0
def run_superbias(metadata,
                  prev_suffix,
                  curr_suffix,
                  method='row_med',
                  **args):
    bias_list = [
        os.path.join(out_dir, '%s.p%s.fits' % (x, prev_suffix))
        for x in metadata['bias']
    ]
    print('Calculating Global Superbias')
    pywifes.imcombine(bias_list, superbias_fn, data_hdu=my_data_hdu)
    # decide what bias model you will actually subtract - could be just data
    if method == 'fit' or method == 'row_med':
        # Fit a smart surface to the bias or take the median
        # A bit experimental so far ... but you know what you are doing, right ?
        pywifes.generate_wifes_bias_fit(superbias_fn,
                                        superbias_fit_fn,
                                        data_hdu=my_data_hdu,
                                        method=method,
                                        **args)
    else:
        pywifes.imcopy(superbias_fn, superbias_fit_fn)
    # generate local superbiases for any science frames
    sci_obs_list = get_sci_obs_list(metadata)
    std_obs_list = get_std_obs_list(metadata)
    for fn in (sci_obs_list + std_obs_list):
        # Find if there is an associated bias (or more ?)
        local_biases = get_associated_calib(metadata, fn, 'bias')
        if local_biases:
            local_bias_fn = get_associated_calib(metadata, fn, 'bias')[0]
            print('Calculating Local Superbias for %s' % local_bias_fn)
            local_superbias = os.path.join(
                out_dir, '%s.fits' % (local_bias_fn + '.lsb'))
            local_superbias_fit = os.path.join(
                out_dir, '%s.fits' % (local_bias_fn + '.lsb_fit'))
            if os.path.isfile(local_superbias_fit):
                continue
            # step 1 - coadd biases
            local_biases_filename = [
                os.path.join(out_dir, '%s.p%s.fits' % (x, prev_suffix))
                for x in local_biases
            ]
            pywifes.imcombine(local_biases_filename,
                              local_superbias,
                              data_hdu=my_data_hdu)
            # step 2 - generate fit!
            if method == 'fit' or method == 'row_med':
                pywifes.generate_wifes_bias_fit(local_superbias,
                                                local_superbias_fit,
                                                data_hdu=my_data_hdu,
                                                method=method,
                                                **args)
            else:
                pywifes.imcopy(local_superbias, local_superbias_fit)
    return
예제 #3
0
def run_superbias(metadata, prev_suffix, curr_suffix,
                  method='row_med', **args):
    bias_list = [
        '%s%s.p%s.fits' % (out_dir, x, prev_suffix)
        for x in metadata['bias']]
    print 'Calculating Global Superbias'
    pywifes.imcombine(bias_list, superbias_fn, data_hdu=my_data_hdu)
    # decide what bias model you will actually subtract - could be just data
    if method == 'fit' or method == 'row_med':
        # Fit a smart surface to the bias or take the median
        # A bit experimental so far ... but you know what you are doing, right ?
        pywifes.generate_wifes_bias_fit(
            superbias_fn, superbias_fit_fn, 
            data_hdu=my_data_hdu, method=method, **args)
    else:
        pywifes.imcopy(superbias_fn, superbias_fit_fn)
    # generate local superbiases for any science frames
    sci_obs_list  = get_sci_obs_list(metadata)
    std_obs_list  = get_std_obs_list(metadata)
    for fn in (sci_obs_list + std_obs_list):
        # Find if there is an associated bias (or more ?)
        local_biases = get_associated_calib(metadata,fn, 'bias')
        if local_biases:
            local_bias_fn = get_associated_calib(metadata,fn,'bias')[0]
            print 'Calculating Local Superbias for %s' % local_bias_fn
            local_superbias = '%s%s.fits' % (out_dir, local_bias_fn+'.lsb')
            local_superbias_fit = '%s%s.fits' % (out_dir, local_bias_fn+'.lsb_fit')
            if os.path.isfile(local_superbias_fit):
                continue
            # step 1 - coadd biases
            local_biases_filename = [
                '%s%s.p%s.fits' % (out_dir, x, prev_suffix)
                for x in local_biases]
            pywifes.imcombine(local_biases_filename,local_superbias, data_hdu=my_data_hdu)
            # step 2 - generate fit!
            if method == 'fit' or method == 'row_med':
                pywifes.generate_wifes_bias_fit(local_superbias, 
                                                local_superbias_fit,
                                                data_hdu=my_data_hdu,
                                                method=method, **args)
            else:
                pywifes.imcopy(local_superbias, local_superbias_fit)
    return
예제 #4
0
def run_superflat(metadata, prev_suffix, curr_suffix,
                  source, scale=None, method='median'):
    if source == 'dome':
        flat_list = [
            '%s%s.p%s.fits' % (out_dir, x, prev_suffix)
            for x in metadata['domeflat']]
        out_fn = super_dflat_raw
    elif source == 'twi':
        flat_list = [
            '%s%s.p%s.fits' % (out_dir, x, prev_suffix)
            for x in metadata['twiflat']]
        out_fn = super_tflat_raw
    else:
        raise ValueError, 'Flatfield type not recognized'
    print 'Generating co-add %sflat' % source
    pywifes.imcombine(flat_list, out_fn,
                      data_hdu=my_data_hdu,
                      scale=scale,
                      method=method)
    return
예제 #5
0
        print('Repairing blue bad pixels for %s' % in_fn.split('/')[-1])
        pywifes.repair_blue_bad_pix(in_fn, out_fn, data_hdu=my_data_hdu)
    return

#------------------------------------------------------
# Generate super-bias
def run_superbias(metadata, prev_suffix, curr_suffix,
                  method='row_med', **args):
    bias_list = [
        os.path.join(out_dir, '%s.p%s.fits' % (x, prev_suffix))
        for x in metadata['bias']]
    print('Calculating Global Superbias')
    pywifes.imcombine(bias_list, superbias_fn, data_hdu=my_data_hdu)
    # decide what bias model you will actually subtract - could be just data
    if method == 'fit' or method == 'row_med':
        # Fit a smart surface to the bias or take the median
        # A bit experimental so far ... but you know what you are doing, right ?
        pywifes.generate_wifes_bias_fit(
            superbias_fn, superbias_fit_fn, 
            data_hdu=my_data_hdu, method=method, **args)
    else:
        pywifes.imcopy(superbias_fn, superbias_fit_fn)
    # generate local superbiases for any science frames
    sci_obs_list  = get_sci_obs_list(metadata)
    std_obs_list  = get_std_obs_list(metadata)
    for fn in (sci_obs_list + std_obs_list):
        # Find if there is an associated bias (or more ?)
        local_biases = get_associated_calib(metadata,fn, 'bias')
        if local_biases:
            local_bias_fn = get_associated_calib(metadata,fn,'bias')[0]
            print('Calculating Local Superbias for %s' % local_bias_fn)
            local_superbias = os.path.join(out_dir, '%s.fits' % (local_bias_fn+'.lsb'))