Exemplo n.º 1
0
def PrintLineTableForCluster(cluster='NGC-0752'):
    starNames = SDB.GetStarsForCluster(cluster)

    allLineDict = {}

    for starName in starNames:
        starLines = LL.getLinesForStar(cluster, starName)
        for line in starLines:
            if (line[0], line[1]) not in allLineDict.keys():
                allLineDict[(line[0], line[1])] = 1
            else:
                allLineDict[(line[0], line[1])] += 1

    for line in sorted(allLineDict.keys()):
        lookup, refs = LL.getLines(elements=[line[0]], \
            wavelengthRange=[(line[1]-k.LambdaVarianceLimit, \
                              line[1]+k.LambdaVarianceLimit)],\
                              dataFormat=None)
        if len(lookup) == 0:
            continue

        luline = lookup[0]

        print(
            k.LLTableFormat.format(line[1], line[0], luline[2], luline[3],
                                   allLineDict[(line[0], line[1])], luline[5]))
Exemplo n.º 2
0
def GetGiantStarParms(clusterName='NGC-0752', mass=1.7, metallicity=-0.03):
    giantInfo = SD.GetGiantInfoForCluster(clusterName=clusterName)
    # Returned Data format:
    # [RA, DEC, Epoch, clusterName, starID, Teff, LogG, vTurb, Vmag, Bmag, s2n]
    # We want:
    # [(starID, Teff, LogG, Vturb, metallicity, mass, s2n)...]
    retData = [(s[4], s[5], s[6], s[7], metallicity, mass, s[10])\
        for s in giantInfo]
    return retData
Exemplo n.º 3
0
def MakeStarIDTable(clusterID='NGC-0752', outFile=d.TableDir + 'Table3.dat'):
    stars = SDB.GetStarInfoForCluster(clusterName=clusterID)

    fp = open(outFile, 'w')
    fmt, db = BuildFormatString(table3Format,
                                DataLabels=table3Labels,
                                DataUnits=table3Units,
                                DataExp=table3Desc,
                                MakeBbBDesc=True)
    fp.write(db)
Exemplo n.º 4
0
def plotDwarfTeffLogg(cluster='NGC-0752',
                      isoPoints=None,
                      isoLabel=None,
                      compPointSets=None,
                      outfilename=None,
                      plotTitle=None):
    stars = [s[4] for s in SDB.GetDwarfInfoForCluster(clusterName=cluster)]

    CompPlotTeffLogg(stars=stars,
                     cluster=cluster,
                     isoPoints=isoPoints,
                     isoLabel=isoLabel,
                     compPointSets=compPointSets,
                     outfilename=outfilename,
                     plotTitle=plotTitle)
Exemplo n.º 5
0
def MakeStarLineTable(starNames=[], clusterID='NGC-0752', ions=[], \
                      wls=[4500,8500], outFile=d.TableDir+'Table1.dat'):
    if len(starNames) == 0:
        starNames = SDB.GetStarsForCluster(clusterID)
    fp = open(outFile, 'w')
    fmt, db = BuildFormatString(table1Format,
                                DataLabels=table1Labels,
                                DataUnits=table1Units,
                                DataExp=table1Desc,
                                MakeBbBDesc=True)
    fp.write(db)
    for sn in starNames:
        lines = LL.getLinesForStar(clusterID,
                                   sn,
                                   elements=ions,
                                   wavelengthRange=wls,
                                   dataFormat=None)
        starID = int(sn[4:])
        for l in lines:
            fp.write(fmt.format(starID, l[0], l[1], l[4]) + '\n')
    fp.close()
Exemplo n.º 6
0
def CompPlotTeffLogg(stars=None,
                     cluster='NGC-0752',
                     isoPoints=None,
                     isoLabel=None,
                     compPointSets=None,
                     outfilename=None,
                     plotTitle=None):
    # Creates a Teff-Logg plot of the stars in the passed cluster with the points
    # passed (if any).
    # Data Formats:
    #               stars = list of star ids which can be used as lookup into
    #                       the database.
    #               cluster = Name of cluster. If no stars ids are passed, then
    #                       plot all stars from this cluster.
    #               isoPoints = Isochrone points to overplot with a dashed line.
    #               isoLabel = A text label for the isochrone. If None, then the
    #                       isochrone points are labeled as "Isochrone"
    #               compPointSets = A dictionary of reference points to also plot.
    #                       format: {RefName:[[Teff, Logg],...],...}
    #               outfilename: If not None, then write the result to this file.
    #                       Otherwise, just plot onscreen.
    #               plotTitle: Title printed on plot. Generally not used for
    #                       publications.

    if stars == None:
        stars = SDB.GetStarsForCluster(cluster)

    dbTeffs = []
    dbLoggs = []
    for sName in stars:
        (Teff, Logg, unused) = \
                                SDB.GetStarParms(sName, clusterName=cluster)
        dbTeffs.append(Teff)
        dbLoggs.append(Logg)

    minX = min(dbTeffs)
    maxX = max(dbTeffs)
    minY = min(dbLoggs)
    maxY = max(dbLoggs)

    params = {
        'legend.fontsize': 'large',
        'axes.labelsize': 'x-large',
        'axes.titlesize': 'x-large',
        'xtick.labelsize': 'x-large',
        'ytick.labelsize': 'x-large'
    }
    pylab.rcParams.update(params)

    fig = pyplot.figure()
    axes = pyplot.gca()
    pyplot.scatter(dbTeffs, dbLoggs, figure=fig,\
                    label='This work', marker=markers[0], color=colors[0])
    mCount = 1
    cCount = 1
    if compPointSets is not None:
        for setName in compPointSets.keys():
            teffs = [i[0] for i in compPointSets[setName]]
            loggs = [i[1] for i in compPointSets[setName]]
            pyplot.scatter(teffs,
                           loggs,
                           figure=fig,
                           label=setName,
                           marker=markers[mCount],
                           color=colors[cCount])
            mCount += 1
            if mCount == len(markers): mCount = 0
            cCount += 1
            if cCount == len(colors): cCount = 0

            minX = min(teffs + [minX])
            maxX = max(teffs + [maxX])
            minY = min(loggs + [minY])
            maxY = max(loggs + [maxY])

    if isoPoints is not None:
        teffs = [i[0] for i in isoPoints]
        loggs = [i[1] for i in isoPoints]
        if isoLabel is not None:
            pyplot.plot(teffs, loggs, 'b:', figure=fig, label=isoLabel)
        else:
            pyplot.plot(teffs, loggs, 'b:', figure=fig, label='Isochrone')

    # We want the plot to look like an HR diagram, so reverse both axes:
    axes.set_xlim(maxX + 50., minX - 50.)
    axes.set_ylim(maxY + 0.05, minY - 0.05)

    axes.set_xlabel(r'$T_{\rm{eff}}$')
    axes.set_ylabel(r'log g')
    axes.legend()

    if plotTitle is not None:
        axes.set_title(plotTitle)

    if outfilename is not None:
        pyplot.savefig(outfilename, figure=fig)
    else:
        pyplot.show()
    pyplot.close()

    return