Example #1
0
def write_master_bias(outname=None):

    par = common.ci_misc_params()

    if outname is None:
        outname = par['master_bias_filename']
        outname = os.path.join(os.environ[par['etc_env_var']], outname)

    assert (not os.path.exists(outname))

    ci_extnames = common.valid_image_extname_list()

    hdus = []
    for ci_extname in ci_extnames:
        print('Working on master bias for: ' + ci_extname)
        bias_image = master_bias_1camera(ci_extname)
        bias_image = bias_image.astype('float32')
        if len(hdus) == 0:
            hdu = fits.PrimaryHDU(bias_image)
        else:
            hdu = fits.ImageHDU(bias_image)
        hdu.header = master_bias_header_cards(hdu, ci_extname)

        hdus.append(hdu)

    hdul = fits.HDUList(hdus)

    hdul.writeto(outname)
Example #2
0
def write_master_dark(outname=None):

    par = common.ci_misc_params()

    if outname is None:
        outname = os.path.join(
            '/project/projectdirs/desi/users/ameisner/CI/post_install_calibs/CI_master_dark-20190330.fits'
        )

    assert (not os.path.exists(outname))

    ci_extnames = common.valid_image_extname_list()

    hdus = []
    for ci_extname in ci_extnames:
        print('Working on master dark for: ' + ci_extname)
        dark_image = master_dark_1camera(ci_extname)
        dark_image = dark_image.astype('float32')

        # convert to counts per second !!!
        dark_image = dark_image / dark_exptime

        dark_image = dark_image.astype('float32')

        if len(hdus) == 0:
            hdu = fits.PrimaryHDU(dark_image)
        else:
            hdu = fits.ImageHDU(dark_image)
        hdu.header = master_dark_header_cards(hdu, ci_extname)

        hdus.append(hdu)

    hdul = fits.HDUList(hdus)

    hdul.writeto(outname)
Example #3
0
def write_master_flat():

    par = common.ci_misc_params()
    outname = par['master_flat_filename']
    outname = os.path.join(os.environ[par['etc_env_var']], outname)

    assert (not os.path.exists(outname))

    flat, ivar = create_master_flat()

    flat = flat.astype('float32')
    ci_extnames = common.valid_image_extname_list()

    hdus = []
    for ci_extnum in range(len(ci_extnames)):
        ci_extname = common.ci_extnum_to_extname(ci_extnum, fz=False)
        print('Assembling HDU for: ' + ci_extname)
        if len(hdus) == 0:
            hdu = fits.PrimaryHDU(flat)
        else:
            hdu = fits.ImageHDU(flat)
        hdu.header = master_flat_header_cards(hdu, ci_extname, ivar)

        hdus.append(hdu)

    hdul = fits.HDUList(hdus)

    hdul.writeto(outname)
Example #4
0
    def __init__(self, image_list, dummy_fz_header=None):
        # images is a dictionary of CI_image objects

        par = common.ci_misc_params()
        self.images = dict(zip(common.valid_image_extname_list(), 
                               par['n_cameras']*[None]))

        self.assign_image_list(image_list)
        self.dummy_fz_header = dummy_fz_header
        self.pixels_calibrated = None
Example #5
0
def create_catalog_1exp(telra, teldec, outname=None):

    tabs = []
    for extname in common.valid_image_extname_list():
        tab = corner_catalog_1ext(telra, teldec, extname)
        tabs.append(tab)

    tab = vstack(tabs)

    if outname is not None:
        assert (not os.path.exists(outname))
        tab.write(outname, format='fits')

    return tab
Example #6
0
def plot_master_biases():
    # compare biases based on forDK samples to those post-installation

    ci_extnames = common.valid_image_extname_list()

    for ci_extname in ci_extnames:
        if ci_extname == 'CIC':
            continue
        bias_new = fits.getdata(
            '/global/cscratch1/sd/ameisner/CI_master_bias.fits',
            extname=ci_extname)

        bias_old = fits.getdata(
            '/project/projectdirs/desi/users/ameisner/CI/ci_reduce_etc/CI_master_bias.fits.gz',
            extname=ci_extname)

        print(ci_extname)
        print(np.median(bias_new), 'new')
        print(np.median(bias_old), 'old')

        bias_old -= np.median(bias_old)
        bias_new -= np.median(bias_new)

        vmax = max(scoreatpercentile(bias_old, 97.5),
                   scoreatpercentile(bias_new, 97.5))
        vmin = max(scoreatpercentile(bias_old, 2.5),
                   scoreatpercentile(bias_old, 2.5))

        print(vmin, vmax)
        print('~' * 30)
        plt.imshow(bias_old, vmin=vmin, vmax=vmax, cmap='gray')
        outname = '/global/cscratch1/sd/ameisner/old_bias_' + ci_extname + '.png'
        plt.gca().get_xaxis().set_visible(False)
        plt.gca().get_yaxis().set_visible(False)

        dpi = 300
        plt.savefig(outname, dpi=dpi, bbox_inches='tight')

        plt.cla()

        plt.imshow(bias_new, vmin=vmin, vmax=vmax, cmap='gray', origin='lower')
        outname = outname.replace('old', 'new')

        plt.gca().get_xaxis().set_visible(False)
        plt.gca().get_yaxis().set_visible(False)

        plt.savefig(outname, dpi=dpi, bbox_inches='tight')
Example #7
0
import astropy.io.fits as fits
import ci_reduce.common as common
import numpy as np

fname = '/project/projectdirs/desi/users/ameisner/CI/post_install_calibs/CI_master_dark.fits'

extnames = common.valid_image_extname_list()

for extname in extnames:
    im = fits.getdata(fname, extname=extname)
    print(extname, np.median(im))