コード例 #1
0
ファイル: wrapper_OLD.py プロジェクト: RainW7/SamPy
    verbose = True
    debug = False

    #sets constants
    FEFU = 10.**-15.
    FUVresel = 6.
    NUVresel = 3.

    # smoothing factor (wave - sm < x < wave + sm) for sensitivity plots
    smoothing = 5.
    g230lsm = 25.  #25

    #creates plotting and reading instances
    plot = P.Plotting('.pdf')
    log = L.Logger('Plotting.output', verbose)
    if referenceFiles or Chapter13: read = IO.COSHBIO(COSrefFiles, 'temp.tmp')
    if computedPhot: readcom = IO.COSHBIO(COScomFiles, 'tempcom.tmp')
    if local: readlocal = IO.COSHBIO(localFolder, 'templocal.tmp')
    if PSFs: readPSF = IO.COSHBIO(localFolder, 'tempPSF.tmp')

    #Begins plotting...
    if referenceFiles:
        log.write('Starting to create plots based on reference files...\n')
        ########################################################################################
        #Dispersion solutions for FUV.
        #These are needed for effective areas
        FUVd = read.FITSTable(FUVdispersionReferenceFile, 1)
        G130Mdisp = [
            x[5][1] for x in FUVd if x[0] == 'FUVA' and x[1] == 'G130M'
            and x[2] == 'PSA' and x[3] == 1309
        ]
コード例 #2
0
def main():
    #constants
    FUVdispersionReferenceFile = 't9e1307kl_disp.fits'
    NUVdispersionReferenceFile = 't9e1307ll_disp.fits'
    COSrefFiles = '/grp/hst/cdbs/lref/'
    outputfolder = './Graphics/'
    sd = './sensitivities/'
    sinp = '/grp/hst/cdbs/comp/cos/'
    ota_mirror = '/grp/hst/cdbs/comp/ota/hst_ota_007_syn.fits'
    boa = sinp + 'cos_boa_004_syn.fits'

    #reading
    read = IO.COSHBIO(COSrefFiles, 'temp.tmp')

    #reading in some data
    #Dispersion solutions for FUV.
    #These are needed for effective areas
    FUVd = read.FITSTable(FUVdispersionReferenceFile, 1)
    FUVtemp = PF.getdata(
        '/grp/hst/cos/calibration/synphot_files/new_disp.fits')
    G130Mdisp = [
        x[5][1] for x in FUVd if x[0] == 'FUVA' and x[1] == 'G130M'
        and x[2] == 'PSA' and x[3] == 1309
    ]
    G130MSdisp = [
        x[5][1] for x in FUVtemp if x[0] == 'FUVB' and x[1] == 'G130M'
        and x[2] == 'PSA' and x[3] == 1055
    ]
    G160Mdisp = [
        x[5][1] for x in FUVd if x[0] == 'FUVA' and x[1] == 'G160M'
        and x[2] == 'PSA' and x[3] == 1600
    ]
    G140Ldisp = [
        x[5][1] for x in FUVd if x[0] == 'FUVA' and x[1] == 'G140L'
        and x[2] == 'PSA' and x[3] == 1230
    ]
    #Dispersion solution for NUV
    NUVd = read.FITSTable(NUVdispersionReferenceFile, 1)
    G185Mdisp = N.mean(
        [x[5][1] for x in NUVd if x[1] == 'G185M' and x[2] == 'PSA'])
    G225Mdisp = N.mean(
        [x[5][1] for x in NUVd if x[1] == 'G225M' and x[2] == 'PSA'])
    G285Mdisp = N.mean(
        [x[5][1] for x in NUVd if x[1] == 'G285M' and x[2] == 'PSA'])
    G230Ldisp = N.mean(
        [x[5][1] for x in NUVd if x[1] == 'G230L' and x[2] == 'PSA'])

    #read in sensitivities, synphot files have wavelength and throughput
    #find the last synphots for each grating
    #for g130m new modes must be taken into account
    g1 = glob.glob(sinp + 'cos_mcp_g130mc*_008_syn.fits')
    g1.append(sinp + 'cos_mcp_g130mc1055_001_syn.fits')
    g1.append(sinp + 'cos_mcp_g130mc1096_001_syn.fits')
    G130Ms = fixThroughputs(throughputs(g1))
    G140Ls = fixThroughputs(
        throughputs(glob.glob(sinp + 'cos_mcp_g140lc*_008_syn.fits')))
    G160Ms = fixThroughputs(
        throughputs(glob.glob(sinp + 'cos_mcp_g160mc*_008_syn.fits')))
    G185Ms = fixThroughputs(
        throughputs(glob.glob(sinp + 'cosncm3_g185mc*_006_syn.fits')))
    G225Ms = fixThroughputs(
        throughputs(glob.glob(sinp + 'cosncm3_g225mc*_006_syn.fits')))
    G230Ls = fixThroughputs(
        throughputs(glob.glob(sinp + 'cosncm3_g230lc*_006_syn.fits')))
    G285Ms = fixThroughputs(
        throughputs(glob.glob(sinp + 'cosncm3_g285mc*_006_syn.fits')))

    #take into acount all mirrors in the lightpath
    G130Msens = multiplyThroughputs(G130Ms, ota_mirror)
    G140Lsens = multiplyThroughputs(G140Ls, ota_mirror)
    G160Msens = multiplyThroughputs(G160Ms, ota_mirror)

    G185Msens = multiplyThroughputs(G185Ms, ota_mirror, NUV=True)
    G225Msens = multiplyThroughputs(G225Ms, ota_mirror, NUV=True)
    G285Msens = multiplyThroughputs(G285Ms, ota_mirror, NUV=True)
    G230Lsens = multiplyThroughputs(G230Ls, ota_mirror, NUV=True)

    #FUV files
    tmp = [(a, b) for a, b in G130Msens if a < 1201]
    hdr = ' Wavel   Throughput   Sensitivity   Effective Area'
    _tmp = printSensitivity(tmp, G130MSdisp[0], '#G130MS' + hdr,
                            sd + 'G130MSsensitivity.txt')
    G130 = printSensitivity(G130Msens, G130Mdisp[0], '#G130M' + hdr,
                            sd + 'G130Msensitivity.txt')
    G160 = printSensitivity(G160Msens, G160Mdisp[0], '#G160M' + hdr,
                            sd + 'G160Msensitivity.txt')
    G140 = printSensitivity(G140Lsens, G140Ldisp[0], '#G140L' + hdr,
                            sd + 'G140Lsensitivity.txt')
    #FUV plot
    FUVsensitivity(G130, G160, G140, outputfolder + 'FUVSensitivity')

    #NUV files
    G185 = printSensitivity(G185Msens, G185Mdisp, '#G185M' + hdr,
                            sd + 'G185Msensitivity.txt')
    G225 = printSensitivity(G225Msens, G225Mdisp, '#G225M' + hdr,
                            sd + 'G225Msensitivity.txt')
    G285 = printSensitivity(G285Msens, G285Mdisp, '#G285M' + hdr,
                            sd + 'G285Msensitivity.txt')
    G230 = printSensitivity(G230Lsens, G230Ldisp, '#G230L' + hdr,
                            sd + 'G230Lsensitivity.txt')
    #NUV plot
    NUVsensitivity(G185, G225, G285, G230, outputfolder + 'NUVSensitivity')

    #individual plots
    #NUV
    Chapeter15Sensitivity(G185, boa, G185Mdisp, 'G185', 'G185M',
                          outputfolder + 'G185Msensitivity')
    Chapeter15Sensitivity(G225, boa, G225Mdisp, 'G225', 'G225M',
                          outputfolder + 'G225Msensitivity')
    Chapeter15Sensitivity(G285, boa, G285Mdisp, 'G285', 'G285M',
                          outputfolder + 'G285Msensitivity')
    Chapeter15Sensitivity(G230, boa, G230Ldisp, 'G230', 'G230L',
                          outputfolder + 'G230Lsensitivity')
    #FUV
    Chapeter15Sensitivity(G130, boa, G130Mdisp[0], 'G130', 'G130M',
                          outputfolder + 'G130Msensitivity')
    Chapeter15Sensitivity(G160, boa, G160Mdisp[0], 'G160', 'G160M',
                          outputfolder + 'G160Msensitivity')
    Chapeter15Sensitivity(G140, boa, G140Ldisp[0], 'G140', 'G140L',
                          outputfolder + 'G140Lsensitivity')
    #new G130M modes
    Chapeter15SensitivityNewG130M(G130, boa, G130MSdisp[0], 'G130', 'G130MS',
                                  outputfolder + 'G130MSsensitivity')