Example #1
0
    for i in range(nord):
        S_flat[i,1] = S_flat[i,1][::-1]
        S_flat[i,2] = S_flat[i,2][::-1]

    if (os.access(S_flat_fits,os.F_OK)):
        os.remove( S_flat_fits )
    hdu = pyfits.PrimaryHDU( S_flat )
    hdu.writeto( S_flat_fits )

else:
    print("\t\tExtracted flat object spectra found, loading...")
    P    = pyfits.getdata( P_fits )
    S_flat = pyfits.getdata( S_flat_fits )

# Normalize flat field spectra.
S_flat_n, Snorms = GLOBALutils.FlatNormalize_single( S_flat, mid = int(.5*S_flat.shape[2]) )

new_list = []
new_times = []
for fsim in sim_sci:
    h = pyfits.open(fsim)
    if object2do in h[0].header['OBJECT'] or object2do == 'all':
        new_list.append(fsim)
        mjd, mjd0 = cafeutils.mjd_fromheader2( h )
        new_times.append(mjd)

new_list  = np.array(new_list)
new_times = np.array(new_times)
IS        = np.argsort(new_times)
new_list  = new_list[IS]
new_times = new_times[IS]
Example #2
0
    flat_S = GLOBALutils.invert(flat_S)
    flat_S = flat_S[::-1]
    if (os.access(Flat_spec_fits, os.F_OK)):
        os.remove(Flat_spec_fits)
    hdu = pyfits.PrimaryHDU(flat_S)
    hdu.writeto(Flat_spec_fits)
    if (os.access(Flat_bkg_fits, os.F_OK)):
        os.remove(Flat_bkg_fits)
    hdu = pyfits.PrimaryHDU(BKG)
    hdu.writeto(Flat_bkg_fits)
else:
    print "\t\tExtracted flat found, loading..."
    flat_S = pyfits.getdata(Flat_spec_fits)

flat_S_n, norms = GLOBALutils.FlatNormalize_single(flat_S,
                                                   mid=int(.5 *
                                                           flat_S.shape[1]))

print '\n\tExtraction of ThAr calibration frames:'
# Extract all ThAr files
for fsim in thars:
    hthar = pyfits.open(fsim)
    if len(hthar) > 1:
        ih = 1
    else:
        ih = 0

    hour = mikeutils.get_hour(float(hthar[ih].header['UT-TIME']))

    thar_fits_simple = dirout + 'MIKE_' + hthar[ih].header[
        'UT-DATE'] + '_' + hour + '.ThAr.spec.simple.fits'
Example #3
0
        hdu.writeto(S_flat_fits_simple)
        hdu = pyfits.PrimaryHDU(P)
        hdu.writeto(flat_P)
        hdu = pyfits.PrimaryHDU(sm_flat)
        hdu.writeto(sm_flat_fits)

    # recover Flat spectra and P matrix
    else:
        flat_S = pyfits.getdata(S_flat_fits)
        flat_Ss = pyfits.getdata(S_flat_fits_simple)
        P = pyfits.getdata(flat_P)
        sm_flat = pyfits.getdata(sm_flat_fits)

##################################################### Science images extraction ######################################################################
sm_flat, norms = GLOBALutils.FlatNormalize_single(sm_flat[:, 1, :],
                                                  mid=int(0.5 *
                                                          sm_flat.shape[2]),
                                                  span=200)

new_list = []
new_list_obnames = []

for i in range(len(objects)):
    fsim = objects[i]
    obname = pucherosutils.search_name(fsim)
    if (object2do == 'all'):
        new_list.append(fsim)
        new_list_obnames.append(obname)
    else:
        if (obname == object2do):
            new_list.append(fsim)
            new_list_obnames.append(obname)