Ejemplo n.º 1
0
def getMedian(files, param):
    list = []
    for file in files:
        [wght, flux], keys = tb.readlist(file, ['w', 'aper_flux'])
        list.append(float(keys[str(param)]))
    median = np.median(list)
    print 'median is ', median
    return median
Ejemplo n.º 2
0
def extractData(file, inputype):
    print 'reading ', file
    if (inputype=='obs'):
        [wght, flux], keys = tb.readlist(file, ['w', 'aper_flux'])
        airmass = keys['AIRMASS']
        exptime = keys['EXPTIME']
        Object  = keys['OBJECT']

    if (inputype=='simu'):
        wght, flux, airmass, Object = fromSimu(file)
        exptime = 1.
    return wght, flux, airmass, Object, exptime
import pylab as pl
import toolbox as tb
import croaks
import scipy.interpolate as interp


if __name__ == "__main__":

    outfile    = sys.argv[1]
    files = sys.argv[2:]
    values = []
    fig = pl.figure()
    for file in files:
        print file
        name = os.path.basename(file)
        value, keys = tb.readlist(file, ('wavelength', 'contamination'))
        values.append(value)
        pl.plot(value[0], value[1], label = name)
    
        pl.ylim(0.001, .02)
        pl.legend()

    pl.xlabel('wavelength (nm)')
    pl.ylabel('Contamination (fraction)')
    pl.title('Ronchi 200 - 2nd order light contamination')
    fig.savefig("contamination.pdf")
    pl.show()

    ### I guess I will fit a constant value 
    tb.DumpTuple(('wavelength', 'contamination'),(second[:,0], interp/second[:,1])
                     , outfile )
Ejemplo n.º 4
0
    img = []
    seeing = []
    zenith = []
    files = sys.argv[1:]

    reference = []
    colors = iter(cm.rainbow(np.linspace(0, 1, len(files) + 1)))
    fig, ax1 = pl.subplots(figsize=(7, 5))
    #pl.xlim([350,1000])
    pl.xlim([700, 1000])
    pl.ylim([0.9, 1.1])
    pl.ylabel('aper_flux / aper_100')
    pl.xlabel('wght (nm)')

    for file in files:
        values, keys = tb.readlist(file, ['pixel', 'w', 'aper_flux'])
        filters = keys['FILTERS']
        obj = re.split('[ /]', keys['IMG_NAME'])
        img = obj[-2]
        print
        print 'raw file : ', obj[0], img, filters
        print file
        aperture = file.split('/')[-2].split('_')[-1].split('aper')[-1]
        print aperture
        if (str(aperture) == '100'):
            print 'reference is aper 100'
            reference = values[2]
            wght = values[0]

        print len(wght), len(values[0])
        color = next(colors)
Ejemplo n.º 5
0
    inputype = args.Type  #''' Either obs or simu '''
    files = args.files
    outfile = args.outfile
    colors = iter(cm.rainbow(np.linspace(0, 1, len(files))))
    Range = [350., 950.]
    W = []
    Z = []
    F = []
    O = []
    fig = pl.figure()
    ax = fig.add_subplot(111, projection='3d')
    i = 1
    for file in files:
        print 'reading ', file
        if (inputype == 'obs'):
            [wght, flux], keys = tb.readlist(file, ['w', 'aper_flux'])
            airmass = keys['AIRMASS']
            exptime = keys['EXPTIME']
            Object = keys['OBJECT']

        if (inputype == 'simu'):
            wght, flux, airmass, Object, exptime = fromSimu(file)
        '''
        Selected a clean range
        '''
        if (airmass >= 3.1):
            print 'airmass is above 3.1'
            continue

        out = np.array([wght, flux]).transpose()
        out = out[(out[:, 0] >= 350)]
Ejemplo n.º 6
0
[email protected]
'''

import os, sys, re
import numpy as np
import pylab as pl
import toolbox as tb
import scipy.interpolate as interp

if __name__ == "__main__":
    if(len(sys.argv)<2):
        usage = 'give a list of spectrum with pixel and flux columns'
        sys.exit(usage)
        
    spectra = sys.argv[1:]
    total = []
    air   = []
    fig   = pl.figure(1)
    for spectrum in spectra :
        [ wgth,flux], keys  = tb.readlist(spectrum, ['pixel', 'flux'])
        airmass = keys['AIRMASS']
        air.append(airmass)
        total.append(sum(flux))
        print 'airmass : ', airmass
        pl.plot(wgth, flux, color='black')
    fig.savefig("resp.pdf")
    fig = pl.figure(2)
    pl.plot(air, total, 'r^')  
    pl.show()
    pl.clf()
Ejemplo n.º 7
0
        logging.info('INFO mode')

    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'''
        param_file = os.path.join(input_rep, file)
        if not os.path.isfile(param_file):
            continue
        array, keys = tb.readlist(param_file,
                                  ['pixel', 'w',\
                                   'aper_flux',\
                                   'psf_gauss_flux', 'psf_gauss_sigma','psf_gauss_mu'])
        target = tb.STDname(keys.get('OBJECT'))
        seeing = keys.get('SEEING')  # This is currently not a good measurement
        pix2wgth = keys.get('PIX2WGTH')
        ronchi = keys.get('RONCHI')
        array = np.array(array).transpose()
        array = array[(array[:, 1] <=
                       1100)]  # Need a better model for the fitting
        pixel = array[:, 0]
        w = array[:, 1]
        aper_flux = array[:, 2]
        psf_gauss_flux = array[:, 3]
        psf_gauss_sigma = array[:,
                                4]  # now use for a better seeing determination as a function of wght
        psf_gauss_mu = array[:, 5]