예제 #1
0
    def generateConfigFiles(self):
        try:
            teff = numpy.array(self.gridconfig['grid_T'].split(','), dtype=numpy.int)
        except:
            teff = [self.baseconfig['Teff']]
        try:
            logg = numpy.array(self.gridconfig['grid_logg'].split(','), dtype=numpy.float)
        except:
            logg = [self.baseconfig['logg']]
        try:
            bfield = numpy.array(self.gridconfig['grid_B'].split(','), dtype=numpy.float)
        except:
            bfield = [self.baseconfig['Bfield']]

        filenames = []
        for temp in teff:
            for grav in logg:
                for b in bfield:
                    configFile = self.baseconfig.copy()
                    configFile["Teff"] = temp
                    configFile["logg"] = grav
                    configFile["Bfield"] = b
                    filename = self.gridconfig["grid_config_directory"]+'Config_T%d_G%.1f_B%.1f_raw.%s.cfg'%(temp, grav, b, self.flavor)
                    AstroUtils.write_config(filename, configFile)
                    filenames.append(filename)
        self.filenames = filenames
예제 #2
0
    def __init__(self, configFile, moogInstance):
        config = AstroUtils.parse_config(configFile)
        self.flavor = ''.join(random.choice(string.ascii_uppercase) for _ in range(4))
        self.moogInstance = moogInstance

        self.baseconfig = {}
        self.gridconfig = {}
        for key in config.keys():
            if not('grid' in key):
                self.baseconfig[key] = config[key]
            else:
                self.gridconfig[key] = config[key]

        self.generateConfigFiles()
def generateConfigFiles(baseConfig, gridConfig):
    try:
        teff = numpy.array(gridConfig['grid_T'].split(','), dtype = numpy.int)
    except:
        teff = [baseConfig['Teff']]

    try:
        logg = numpy.array(gridConfig['grid_logg'].split(','), dtype= numpy.float)
    except:
        logg = [baseConfig['logg']]

    try:
        bfield = numpy.array(gridConfig['grid_B'].split(','), dtype=numpy.float)
    except:
        bfield = [baseConfig['Bfield']]

    try:
        vsini = numpy.array(gridConfig['grid_vsini'].split(','), dtype=float)
    except:
        vsini = [baseConfig['vsini']]

    filenames = []
    for temp in teff:
        for grav in logg:
            for b in bfield:
                for v in vsini:
                    configFile = baseConfig.copy()
                    configFile["Teff"] = temp
                    configFile["logg"] = grav
                    configFile["Bfield"] = b
                    configFile["vsini"] = v
                    filename = 'ConfigFiles/Config_T%d_G%.1f_B%.1f_V%.1f.cfg' % (temp, grav, b, v)
                    AstroUtils.write_config(filename, configFile)
                    filenames.append(filename)

    return filenames
        for grav in logg:
            for b in bfield:
                for v in vsini:
                    configFile = baseConfig.copy()
                    configFile["Teff"] = temp
                    configFile["logg"] = grav
                    configFile["Bfield"] = b
                    configFile["vsini"] = v
                    filename = 'ConfigFiles/Config_T%d_G%.1f_B%.1f_V%.1f.cfg' % (temp, grav, b, v)
                    AstroUtils.write_config(filename, configFile)
                    filenames.append(filename)

    return filenames

diffspecConfigFile = sys.argv[1]
config = AstroUtils.parse_config(diffspecConfigFile)

flavor = ''.join(random.choice(string.ascii_uppercase) for _ in range(4))

baseconfig = {}
gridconfig = {}
for key in config.keys():
    if not('grid' in key):
        baseconfig[key] = config[key]
    else:
        gridconfig[key] = config[key]

configFiles = generateConfigFiles(baseconfig, gridconfig)
synthesizeSpectra(configFiles, flavor)

예제 #5
0
import matplotlib.pyplot as pyplot
import numpy
import scipy
import sys
import MoogTools
import AstroUtils

fig = pyplot.figure(0)
fig.clear()
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])

baseName = sys.argv[1]

arcturusConfig = AstroUtils.parse_config(baseName + "_Solar.cfg")
solarConfig = AstroUtils.parse_config(baseName + "_Arcturus.cfg")
originalConfig = arcturusConfig.copy()

arcturusConfig["applyCorrections"] = True
solarConfig["applyCorrections"] = True

arcturus = MoogTools.LineList(None, arcturusConfig)
solar = MoogTools.LineList(None, solarConfig)
original = MoogTools.LineList(None, originalConfig)

orig = []
sol = []
arc = []
diff = []
dsol = []
darc = []
species = []
예제 #6
0
import pyfits
import AstroUtils
import matplotlib.pyplot as pyplot
import scipy
import numpy
import SpectralTools
import sys
import numpy

configFile = sys.argv[1]

config = AstroUtils.parse_config(configFile)

watched_dir = config['watched_dir']
wlStart = config['wlStart']
wlStop = config['wlStop']

parameters = {}
parameters["TEFF"] = []
parameters["LOGG"] = []
parameters["BFIELD"] = []

parameters, waves, fluxes = SpectralTools.winnow_MoogStokes_Spectra(watched_dir, wlStart, wlStop, trackedParams=parameters)
EWs = []

teff = numpy.array(parameters["TEFF"])
logg = numpy.array(parameters["LOGG"])
bfield = numpy.array(parameters["BFIELD"])

temps = numpy.unique(teff)
gravs = numpy.unique(logg)
예제 #7
0
calcIM = bool(sys.argv[2]=='True')
moogInstance = sys.argv[3]
try:
    contFloat = bool(sys.argv[4]== 'True')
except:
    contFloat = False
#try:
#    rotFloat = bool(sys.argv[5] == 'True')
#except:
#    rotFloat = False

f1 = pyplot.figure(0)
f1.clear()
ax1 = f1.add_axes([0.1, 0.1, 0.8, 0.8])

config = AstroUtils.parse_config(configFile)

orchestra = Moog960.Score(directory='../MusicMaker/Convolved/Kband_Convolved_T3*', observed=config["inFile"], suffix='')

#mastered = orchestra.master(selectedLabels=orchestra.convolved_labels, keySignature='CONVOLVED')

#one = mastered[0].Spectrum.copy()

#one.plot(ax=ax1)
#one.nyquistSample(R=45000.0)
#one.plot(ax=ax1)
#mastered[0].Spectrum.plot(ax=ax1)
#f1.show()

#print asdf
if calcIM:
예제 #8
0
import Moog960
import astropy.io.fits as pyfits
import SpectralTools
import numpy
import sys
import AstroUtils
import glob


#This program reads in an IGRINS spectrum from the .fits files produced by the
#reduction pipeline, and saves it in a Moog960-readable .fits file.  It merges
#the spectral orders, weighting by signal-to-noise ratio.


config = AstroUtils.parse_config(sys.argv[1])

datadir = config["datadir"]
outdir = config['outdir']

wlsolfiles = [glob.glob(datadir+'SKY_SDCH*wvlsol_v1.fits')[0], glob.glob(datadir+'SKY_SDCK*wvlsol_v1.fits')[0]]
datafiles = [glob.glob(datadir+'SDCH*spec_a0v.fits')[0], glob.glob(datadir+'SDCK*spec_a0v.fits')[0]]
snfiles = [glob.glob(datadir+'SDCH*sn.fits')[0], glob.glob(datadir+'SDCK*sn.fits')[0]]
varfiles = [glob.glob(datadir+'SDCH*variance.fits')[0], glob.glob(datadir+'SDCK*variance.fits')[0]]

phrases = []
for wlsolfile, datafile, snfile, varfile in zip(wlsolfiles, datafiles, snfiles, varfiles):
    wlsol = pyfits.getdata(wlsolfile)
    data = pyfits.getdata(datafile)
    dataheader = pyfits.getheader(datafile)
    snr = pyfits.getdata(datafile)
    var = pyfits.getdata(varfile)
예제 #9
0
import matplotlib.pyplot as pyplot
import numpy
import scipy
import sys
import MoogTools
import AstroUtils

fig = pyplot.figure(0)
fig.clear()
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])

baseName = sys.argv[1]

arcturusConfig = AstroUtils.parse_config(baseName+"_Solar.cfg")
solarConfig = AstroUtils.parse_config(baseName+"_Arcturus.cfg")
originalConfig = arcturusConfig.copy()

arcturusConfig["applyCorrections"] = True
solarConfig["applyCorrections"] = True


arcturus = MoogTools.LineList(None, arcturusConfig)
solar = MoogTools.LineList(None, solarConfig)
original = MoogTools.LineList(None, originalConfig)

orig = []
sol = []
arc = []
diff = []
dsol = []
darc = []
예제 #10
0
 def __init__(self, configFile):
     self.config = AstroUtils.parse_config(configFile)
     self.applyConfigFile()
     self.WhosInThePit()
예제 #11
0
def generateLineList(b_dir, prefix, wl_start, wl_stop, Bfield, **kwargs):
    ''' This subroutine generates Zeeman-split MOOG line lists (both 
    strong and weak) '''

    staging_dir = 'stage_'+prefix+'/'
    print "Feature : ", prefix, ' ', b_dir

    try:
        os.makedirs(os.path.join(staging_dir,'Parfiles',b_dir))
        os.makedirs(os.path.join(staging_dir,'Output', b_dir))
        os.makedirs(os.path.join(staging_dir,'Linelists', b_dir))
    except:
        pass
    MoogTools.write_par_file(wl_start, wl_stop, staging_dir, b_dir, prefix,
            mode='gridstokes', strongLines=True, **kwargs)

    # Load in configuration file
    config = AstroUtils.parse_config('counterpoint.cfg')
    weak_file = config['weak_file']
    strong_file = config['strong_file']
    molecules = config['molecules']
    VALD_list = config['VALD_file']
    gf_corrections = config['gf_file']

    strongLines, weakLines = MoogTools.parse_VALD(VALD_list, strong_file,
            wl_start, wl_stop, Bfield, gf_corrections)

    #     CO
    weakLines = numpy.append(weakLines, MoogTools.parse_HITRAN(
             molecules+'05_HITEMP2010new.par', wl_start, wl_stop, Bfield,
             gf_corrections, weedout=2.5))
    #     OH
    weakLines = numpy.append(weakLines, MoogTools.parse_HITRAN(
             molecules+'13_HITEMP2010.par', wl_start, wl_stop, Bfield,
             gf_corrections))

    #     CN
    weakLines = numpy.append(weakLines, MoogTools.parse_Plez_CN(
             molecules+'CN_Plez_linelist.dat', wl_start, wl_stop, Bfield,
             gf_corrections))

    sfn = os.path.join(staging_dir, 'Linelists', b_dir,
            prefix+'_strong_linelist.stokes')
    outfile = open(sfn, 'w')

    for strongLine in strongLines:
        strongLine.dump(out=outfile, mode='MOOGSTOKES')
    outfile.close()
    sort_file(sfn)

    wfn = os.path.join(staging_dir, 'Linelists', b_dir,
            prefix+'_weak_linelist.stokes')
    weakfile = open(wfn, 'w')
    for weakLine in weakLines:
        weakLine.dump(out=weakfile, mode='MOOGSTOKES')

    weakfile.close()
    sort_file(wfn, weak=True)

    if Bfield==0.0:
        MoogTools.write_par_file(wl_start, wl_stop, staging_dir, b_dir,
                prefix, mode='gridsyn', strongLines=True, **kwargs)

        sfn = os.path.join(staging_dir, 'Linelists', b_dir,
                prefix+'_strong_linelist.scalar')
        outfile = open(sfn, 'w')

        for strongLine in strongLines:
            strongLine.dump(out=outfile, mode='MOOGSCALAR')
        outfile.close()
        sort_file(sfn)

        wfn = os.path.join(staging_dir, 'Linelists', b_dir,
                prefix+'_weak_linelist.scalar')
        outfile = open(wfn, 'w')

        for weakLine in weakLines:
            weakLine.dump(out=outfile, mode='MOOGSCALAR')
        outfile.close()
        sort_file(wfn, weak=True)
예제 #12
0
        for strongLine in strongLines:
            strongLine.dump(out=outfile, mode='MOOGSCALAR')
        outfile.close()
        sort_file(sfn)

        wfn = os.path.join(staging_dir, 'Linelists', b_dir,
                prefix+'_weak_linelist.scalar')
        outfile = open(wfn, 'w')

        for weakLine in weakLines:
            weakLine.dump(out=outfile, mode='MOOGSCALAR')
        outfile.close()
        sort_file(wfn, weak=True)


parameters = AstroUtils.parse_config(sys.argv[-1])
if type(parameters["BFields"])==str:
    Bfields = numpy.array(parameters["BFields"].split(','), dtype = float).tolist()
else:
    Bfields = numpy.array(parameters["BFields"]).tolist().tolist()
prefixes = numpy.array(parameters["prefixes"].split(','), dtype=str)
if type(parameters["wl_starts"])== str:
    wl_starts = numpy.array(parameters["wl_starts"].split(','), dtype=float)
    wl_stops = numpy.array(parameters["wl_stops"].split(','), dtype=float)
else:
    wl_starts = numpy.array([parameters["wl_starts"]], dtype=float)
    wl_stops = numpy.array([parameters["wl_stops"]], dtype=float)
if type(parameters["temps"])==str:
    temps = numpy.array(parameters["temps"].split(','), dtype=int).tolist()
else:
    temps = numpy.array([parameters["temps"]]).tolist()