예제 #1
0
def fromObs(file, colname):
    dict, values, names = tb.readcat(file)
    #print 'Dict : ' ,dict.items()
    latitude = ' '.join(dict.get('LATITUDE'))
    ha = ' '.join(dict.get('HA'))
    dec = dict.get('DEC')
    parallactic_angle = tb.ParallacticAngle(latitude, ha, dec)
    parallactic_angle = parallactic_angle[0]
    print parallactic_angle
    jd = ' '.join(dict.get('OBJECT'))
    Object = dict.get('JD')[0]
    airmass = dict.get('AIRMASS')[0]
    data = np.array([values.field('w'),
                     values.field(str(colname))]).transpose()
    #data = np.array([values.field('w'), values.field('psf_gauss_flux')]).transpose()
    return data, airmass, Object, jd, parallactic_angle
예제 #2
0
def fromObs(file):
    dict, values, names = tb.readcat(file)
    meanseeing = meanSeeing(values.field('w'), values.field('psf_gauss_sigma'))
    #print 'Dict : ' ,dict.items()
    latitude = ' '.join(dict.get('LATITUDE'))
    ha       = ' '.join(dict.get('HA'))
    dec      = dict.get('DEC')
    parallactic_angle = tb.ParallacticAngle(latitude, ha, dec)
    parallactic_angle = parallactic_angle[0]
    print 'parallactic_angle ', parallactic_angle
    Object   = ' '.join(dict.get('OBJECT'))
    jd       = dict.get('JD')[0]
    airmass  = dict.get('AIRMASS')[0]
    #data = np.array([values.field('w'), values.field('aper_flux')]).transpose()
    data = np.array([values.field('w'), values.field('psf_gauss_flux')]).transpose()
    print 'flux estimator is Gauss PSF'
    return data, airmass, Object, jd, parallactic_angle, meanseeing
예제 #3
0
    return args



if __name__ == "__main__":
    args = grabargs()
    plot     = args.plot
    outfile  = args.outfile
    inputype = args.Type #''' Either obs or simu '''
    files    = args.files 
    seeing   = args.seeing
    select   = args.select


    if ((inputype=='simu') and (seeing is not None)):
        dict, values, names = tb.readcat(seeing)
        seeing_x = values.field('w')
        seeing_y = values.field('psf_gauss_sigma')
        pix2wght = float(dict.get('PIX2WGTH')[0])
        mean_seeing = meanSeeing(seeing_x, seeing_y)
        print 'MEAN SEEING ' , mean_seeing
    
    wmin = 680.
    wmax = 1200.
    width = 2.

    outlist = []
    for file in files:
        print 'opening ', file
        if (inputype=='obs'):
            data, airmass, Object, jd, parallactic_angle, mean_seeing = fromObs(file)
예제 #4
0
    name = 0
    date = 0
    band = 0
    ra = 0
    dec = 0
    exptime = 0

    targets = buildTargetCoords(references)
    print targets
    '''Searching for matches'''
    for item, rep in enumerate(reps):
        file = os.path.join(rep, 'se.list')
        img = os.path.join(rep, 'calibrated.fits')
        print 'reading : ', file
        print 'opening img : ', img
        dict, objects, names = tb.readcat(file)

        if extern:
            hdulist = fits.open(extern)
        else:
            hdulist = fits.open(img)
            date = hdulist[0].header.get('DATE')
            date = dateutil.parser.parse(date)
            date = (time.Time(date)).jd
            band = hdulist[0].header.get('FILTERS').replace(" ", "_")
            exptime = hdulist[0].header.get('EXPTIME')
            airmass = hdulist[0].header.get('AIRMASS')
            outhum = hdulist[0].header.get('OUTHUM')
            outpress = hdulist[0].header.get('OUTPRESS')
            wndspeed = hdulist[0].header.get('WNDSPEED')
        '''Maybe match keyword name and reference name...unreliable'''
    tb.ProdInstall()

    template_path = os.environ['TEMPLATE_PREFIX']
    if not os.path.exists(template_path):
        os.makedirs(template_path)

    for input_rep in input_reps:
        logging.info('\n' + 'Analyzing : ' + input_rep)
        '''observed spectrum'''
        input_file = os.path.join(input_rep, file)
        if not os.path.isfile(input_file):
            continue

        print 'reading ', input_file
        dict, array, names = tb.readcat(input_file)
        target = ' '.join(dict.get('OBJECT'))
        print target
        if not target:
            continue

        filters = ' '.join(dict.get('FILTERS'))
        if (str(filters).find('RG715') >= 0):
            print 'RG715 filter in place'
            tel_t = 'rg715'
        else:
            print 'Telescope set up open'
            tel_t = 'open'

        seeing = float(
            dict.get('SEEING')[0])  # This is currently not a good measurement
recarray doc :
https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.recarray.html

'''

import os, sys, re
import numpy as np
import toolbox as tb

if __name__ == "__main__":
    show_stuff = True
    files = sys.argv[1:]
    for file in files:

        dict, values, names = tb.readcat(file)
        columns = ('NUMBER', 'FLUX_ISO', 'FLUXERR_ISO', 'FLUX_ISOCOR',
                   'FLUXERR_ISOCOR', 'FLUX_APER1', 'FLUX_APER2', 'FLUX_APER3',
                   'FLUX_APER4', 'FLUX_APER5', 'FLUXERR_APER1',
                   'FLUXERR_APER2', 'FLUXERR_APER3', 'FLUXERR_APER4',
                   'FLUXERR_APER5', 'MAG_APER', 'MAGERR_APER', 'FLUX_AUTO',
                   'FLUXERR_AUTO', 'FLUX_BEST', 'FLUXERR_BEST', 'THRESHOLD',
                   'FLUX_MAX', 'X_IMAGE', 'Y_IMAGE', 'X2_IMAGE', 'Y2_IMAGE',
                   'XY_IMAGE', 'CXX_IMAGE', 'CYY_IMAGE', 'CXY_IMAGE',
                   'A_IMAGE', 'B_IMAGE', 'FLAGS')

        data = np.array(values)
        outcat = file
        print 'writing ', outcat
        print 'output entries : ', columns
        tb.DumpTuple(columns, zip(*data), outcat)