plotList = [] # coldTovSet = cstDataset('cold', eosName, ye, sourceDb) # coldTovSeq = cstSequence(coldTovSet, tovSlice, filters) # theEos.resetCachedBetaEqYeVsRhobs(tempFuncsDict['cold'], 13.5, 16.0) # coldTovPlot = \ # coldTovSeq.getSeqPlot([xVar], yVars, filters, \ # xcolFunc=lambda x: theEos.rhobFromEnergyDensityWithTofRho(x, ye, tempFuncsDict['cold']), # ycolFunc=yFunc) # plot = plt.semilogx(*coldTovPlot, c=colors['cold'], ls='-.', label="TOV") # del coldTovSet for script in scriptsList: xFunc = lambda x: theEos.rhobFromEnergyDensityWithTofRho( x, ye, tempFuncsDict[script]) xFunc = lambda x: x thisSet = cstDataset(script, eosName, ye, sourceDb) thisSeq = cstSequence(thisSet, theMaxRotSlice, filters) #cursor = thisSeq.dbConn.cursor() #cursor.execute("SELECT rpoe FROM models") #print cursor.fetchall() eds = [] plotVars = [] for rpoe in numpy.arange(0.64, 1.0, 0.04): ed = thisSet.getSecInstabilitySeq(a, rpoe, 1e15, 3e15) setCursor = thisSet.dbConn.cursor() ptDict = {'a': a, 'rpoe': rpoe, 'edMax': ed} pointFilters = equalsFiltersFromDict(ptDict) query = "WHERE " + " AND ".join(pointFilters) setCursor.execute("SELECT " + ','.join(yVars) + " FROM models " + query) answer = yFunc(*setCursor.fetchall()[0]) eds.append(xFunc(ed))
filters = ('edMax>2.0e14', 'ToverW<0.25', 'baryMass<2.6') plotList = [] # coldTovSet = cstDataset('cold', eosName, ye, sourceDb) # coldTovSeq = cstSequence(coldTovSet, tovSlice, filters) # theEos.resetCachedBetaEqYeVsRhobs(tempFuncsDict['cold'], 13.5, 16.0) # coldTovPlot = \ # coldTovSeq.getSeqPlot([xVar], yVars, filters, \ # xcolFunc=lambda x: theEos.rhobFromEnergyDensityWithTofRho(x, ye, tempFuncsDict['cold']), # ycolFunc=yFunc) # plot = plt.semilogx(*coldTovPlot, c=colors['cold'], ls='-.', label="TOV") # del coldTovSet for script in scriptsList: xFunc = lambda x: theEos.rhobFromEnergyDensityWithTofRho(x, ye, tempFuncsDict[script]) xFunc = lambda x: x thisSet = cstDataset(script, eosName, ye, sourceDb) thisSeq = cstSequence(thisSet, theMaxRotSlice, filters) #cursor = thisSeq.dbConn.cursor() #cursor.execute("SELECT rpoe FROM models") #print cursor.fetchall() eds = [] plotVars = [] for rpoe in numpy.arange(0.64, 1.0, 0.04): ed = thisSet.getSecInstabilitySeq(a, rpoe, 1e15, 3e15) setCursor = thisSet.dbConn.cursor() ptDict = {'a': a, 'rpoe': rpoe, 'edMax': ed} pointFilters = equalsFiltersFromDict(ptDict) query = "WHERE " + " AND ".join(pointFilters) setCursor.execute("SELECT " + ','.join(yVars) + " FROM models " + query) answer = yFunc(*setCursor.fetchall()[0]) eds.append(xFunc(ed)) plotVars.append(answer)
tempFunc = tFuncs[i] theEos.resetCachedBetaEqYeVsRhobs(tempFunc, 13.5, 16.0) xFunc = lambda x: theEos.rhobFromEnergyDensityWithTofRho(x, ye, tempFunc) / 1.0e15 #xFunc = lambda x: x filters = ('ToverW<0.25',) thisSet = cstDataset(script, eosName, ye, sourceDb) if script == 'c30p10': thisSet.addEntriesFromDb(c30p10Db) dashList = [(None, None), (25, 4), (13, 5), (20, 4, 10, 6), (10, 3, 5, 5), (3, 1)] # (20, 5, 10, 5, 5, 10)] pltsForLeg = [] dashList = dashList[::-1] for j, slicer in enumerate(slicesToPlot): thisSeq = cstSequence(thisSet, slicer, filters) filters = ('ToverW<0.25',) thisPlot = thisSeq.getSeqPlot(['edMax'], ['gravMass', 'baryMass', 'arealR'], filters, xcolFunc=xFunc, ycolFunc=lambda x, y, z: y) plert, = plt.semilogx(*thisPlot, c=colors[script], dashes=dashList[j], lw=(3+j)/2.0) pltsForLeg.append(plert) colorLegs.append(plert) del thisSet legend1 = plt.legend(pltsForLeg, ("TOV", r"$\tilde{A}=0.0$", r"$\tilde{A}=0.4$", r"$\tilde{A}=0.5$", r"$\tilde{A}=0.7$", r"$\tilde{A}=1.0$"), loc=1, handlelength=4) legend2 = plt.legend(colorLegs, scripts, loc=9, labelspacing=0.3, handletextpad=0.4) plt.gca().add_artist(legend1) plt.xlim([.50, 2.5])
edgeColor = "k" fig = plt.figure() ax_mb = fig.add_subplot(111) ax_mg = ax_mb.twinx() for script in colors.keys(): thisSet = cstDataset(script, eosName, ye, sourceDb) temp = tempFuncsDict[script](numpy.log10(rhob)) theEos.setBetaEqState({"rho": rhob, "temp": temp}) ed = edFunc(numpy.log10(rhob), theEos.query("logenergy")) theSlice = {"edMax": ed, "a": a} print script, theEos.rhobFromEnergyDensityWithTofRho(1.4818029819e15, ye, tempFuncsDict[script]) thisSeq = cstSequence(thisSet, theSlice, filters) mgPlot = thisSeq.getSeqPlot([xVar], ["gravMass"], filters, xcolFunc=lambda x: x / 1000.0, ycolFunc=mgYfunc) mbPlot = thisSeq.getSeqPlot([xVar], ["baryMass"], filters, xcolFunc=lambda x: x / 1000.0) labelKwarg = {"label": script} ax_mg.plot(*mgPlot, c=colors[script], ms=8, lw=lineWidths[script], markeredgecolor=colors[script]) ax_mb.plot(*mbPlot, c=colors[script], ms=8, lw=lineWidths[script], markeredgecolor=colors[script], dashes=(20, 5)) del thisSet thisSet = cstDataset(script, eosName, ye, sourceDb) if toroidSymbols: filters = ("RedMax>0.0",) markerSize = 6 edgeColor = colors[script] else: filters = nearValueFilter("edMax", ed)
# ls220_c30p10 = cstDataset("c30p10", "LS220", ye, sourceDb) # ls220_c30p5 = cstDataset("c30p5", "LS220", ye, sourceDb) ls220_cold = cstDataset("cold", "LS220", ye, sourceDb) tovSlice = {'a': 0.0, 'rpoe': 1.0} uniformMaxRotSlice = {'a': 0.0, 'rpoe': 'min'} xVar = 'edMax' xLabel = latexField(xVar) yVar = 'gravMass' yLabel = latexField(yVar) filters = () tovLS220 = cstSequence(ls220_cold, tovSlice, filters) tovShen = cstSequence(shen_cold, tovSlice, filters) rotLS220 = cstSequence(ls220_cold, uniformMaxRotSlice, filters) rotShen = cstSequence(shen_cold, uniformMaxRotSlice, filters) ############################################################# # First plot: LS and Shen, just cold ############################################################# thisPlot = tovLS220.getSeqPlot([xVar], [yVar], filters) plt.plot(*thisPlot, c='k', ls='-', label='LS220 TOV') thisPlot = tovShen.getSeqPlot([xVar], [yVar], filters) plt.plot(*thisPlot, c='b', ls='-', label='HShen TOV') thisPlot = rotLS220.getSeqPlot([xVar], [yVar], filters) plt.plot(*thisPlot, c='k', ls='--', label='LS220 Max $\Omega$')
tempFuncsDict = {scriptsList[i]: tempFuncs[i] for i in range(len(scriptsList))} ############################################################# # First plot: Just Shen, frac diffs ############################################################# filters = ('edMax>2e14', ) #coldTovSet = cstDataset('cold', eosName, ye, sourceDb) #coldTovSeq = cstSequence(coldTovSet, theSlice, filters) #coldTovPlot = \ # coldTovSeq.getSeqPlot([xVar], [yVar], filters) #plt.semilogx(*coldTovPlot, c=colors['cold'], ls='--', label="TOV") #del coldTovSet for script in colors.keys(): thisSet = cstDataset(script, eosName, ye, sourceDb) thisSet.addEntriesFromDb(shedDb) thisSeq = cstSequence(thisSet, theSlice, filters) mgPlot = thisSeq.getSeqPlot([xVar], ['gravMass'], filters, xcolFunc=lambda x: x / 1000.0) mbPlot = thisSeq.getSeqPlot([xVar], ['baryMass'], filters, xcolFunc=lambda x: x / 1000.0) labelKwarg = {'label': script} plt.plot(*mgPlot, c=colors[script], ms=8, lw=lineWidths[script], markeredgecolor=colors[script]) plt.plot(*mbPlot, c=colors[script],
scriptsList = ['c40p0', 'c30p0', 'c20p0', 'c30p10', 'c30p5', 'cold'] cXXp0_params = [(40.0, 14.18, 0.5,), (30.0, 14.055, 0.375), (20.0, 13.93, 0.25)] tempFuncs = [getTRollFunc(params[0], 0.01, params[1], params[2]) for params in cXXp0_params] tempFuncs.append(kentaDataTofLogRhoFit1()) tempFuncs.append(kentaDataTofLogRhoFit2()) tempFuncs.append(lambda x: 0.01) tempFuncsDict = {scriptsList[i]: tempFuncs[i] for i in range(len(scriptsList))} scriptsList = ['cold'] ############################################################# # First plot: Just Shen, frac diffs ############################################################# filters = ('edMax>0.5e14',) plotList = [] coldTovSet = cstDataset('cold', eosName, ye, sourceDb) coldTovSeq = cstSequence(coldTovSet, tovSlice, filters) theEos.resetCachedBetaEqYeVsRhobs(tempFuncsDict['cold'], 13.5, 16.0) coldTovPlot = \ coldTovSeq.getSeqPlot([xVar], yVars, filters, \ xcolFunc=lambda x: theEos.rhobFromEnergyDensityWithTofRho(x, ye, tempFuncsDict['cold']), ycolFunc=yFunc) plot = plt.semilogx(*coldTovPlot, c=colors['cold'], ls='--', dashes=plot_defaults.longDashes, label="TOV") del coldTovSet for script in scriptsList: thisSet = cstDataset(script, eosName, ye, sourceDb) thisSeq = cstSequence(thisSet, uniformMaxRotSlice, filters) theEos.resetCachedBetaEqYeVsRhobs(tempFuncsDict[script], 13.5, 16.0) thisPlot = thisSeq.getSeqPlot([xVar], yVars, filters, \
} ############################################################# # W/Mg vs T/W for diff scripts a = 0.6 w T/W < 0.25 threshold ############################################################# xVar = 'ToverW' yVar = None xLabel = latexField(xVar) a = 0.6 slicer = {'a': a, 'rpoe': 'min'} filters = ('ToverW<0.25', ) for script, c in colors.items(): thisSet = cstDataset(script, "HShenEOS", ye, sourceDb) thisSeq = cstSequence(thisSet, slicer, filters) thisPlot = thisSeq.getSeqPlot([xVar], ['gravPotW', 'gravMass'], filters, ycolFunc=lambda a, b: a / b) plt.plot(*thisPlot, label=script, c=c) del thisSet plt.xlabel(xLabel) plt.ylabel("$W/M_g$") plt.legend(loc=2) plt.axes().annotate(r"HShen \," + r"$\tilde{A}=$" + str(a), xy=(.17, 0.36), fontsize=20) plt.show() shen_cold = cstDataset("cold", "HShenEOS", ye, sourceDb) ############################################################# # W/Mg vs T/W for cold: w T/W < 0.25 threshold
eosTable = 'LS220' #c40p0 = cstDataset("c40p0", eosTable, 'BetaEq', sourceDb) c0p0 = cstDataset("cold", eosTable, 'BetaEq', sourceDb) point = {'a': 1., 'rpoe': 0.38, 'edMax': 595697963600000.} print numpy.linalg.det(c0p0.gradientsAtPoint(['J', 'baryMass'], point)) c0p0.getSecInstabilitySeq(0.0, 0.7, 1e15, 3e15) exit() sliceDict = {'a': 1.0, 'rpoe': 'min'} filters = () # ('ToverW<.12', 'RedMax=0.0')#('ToverW>0.1',) thisSeq40 = cstSequence(c40p0, sliceDict, filters) thisSeq0 = cstSequence(c0p0, sliceDict, filters) #thisSeq.getColumnData(['J', 'gravMass'], lambda j, m: j / (m * m), ('ToverW<.25',)) # # guy40 = thisSeq40.getSeqPlot(['rpoe'], ['J', 'gravMass'], filters, # ycolFunc=lambda j, m: j / (m * m)) # guy0 = thisSeq0.getSeqPlot(['rpoe'], ['J', 'gravMass'], filters, # ycolFunc=lambda j, m: j / (m * m)) guy40 = thisSeq40.getSeqPlot(['edMax'], ['gravMass'], filters, ycolFunc=lambda j: j) guy0 = thisSeq0.getSeqPlot(['edMax'], ['gravMass'], filters, ycolFunc=lambda j: j) result = reduceTwoSeqPlots(guy0, guy40, lambda a, b: b / a - 1.0)
tempFuncs = [ getTRollFunc(params[0], 0.01, params[1], params[2]) for params in cXXp0_params ] tempFuncs.append(kentaDataTofLogRhoFit1()) tempFuncs.append(kentaDataTofLogRhoFit2()) tempFuncs.append(lambda x: 0.01) tempFuncsDict = {scriptsList[i]: tempFuncs[i] for i in range(len(scriptsList))} ############################################################# # First plot: Just Shen, frac diffs ############################################################# filters = ('edMax>0.5e14', ) plotList = [] coldTovSet = cstDataset('cold', eosName, ye, sourceDb) coldTovSeq = cstSequence(coldTovSet, tovSlice, filters) theEos.resetCachedBetaEqYeVsRhobs(tempFuncsDict['cold'], 13.5, 16.0) coldTovPlot = \ coldTovSeq.getSeqPlot([xVar], yVars, filters, \ xcolFunc=lambda x: theEos.rhobFromEnergyDensityWithTofRho(x, ye, tempFuncsDict['cold']), ycolFunc=yFunc) plot = plt.semilogx(*coldTovPlot, c=colors['cold'], ls='--', dashes=plot_defaults.longDashes, label="TOV") del coldTovSet for script in colors.keys(): thisSet = cstDataset(script, eosName, ye, sourceDb) thisSeq = cstSequence(thisSet, uniformMaxRotSlice, filters)
from eosDriver import eosDriver, getTRollFunc, kentaDataTofLogRhoFit1, kentaDataTofLogRhoFit2 import matplotlib import matplotlib.pyplot as plt import numpy from datasetManager import cstDataset, cstSequence sourceBase = '/home/jeff/work/rotNSruns/refReportsOneMod.db' source6 = '/home/jeff/work/rotNSruns/refReportsOneMod_surf6.db' source = source6 filters = () theSet = cstDataset("c30p10", "LS220", "BetaEq", source) theSeq = cstSequence(theSet, {'a': 0.0, 'rpoe': 'min'}, filters) toPlot = theSeq.getSeqPlot('edMax', 'baryMass', filters) print toPlot #otherSet = cstDataset("c30p10", "LS220", "BetaEq", source6) ## EOS convert density ls220EosTableFilename = '/home/jeff/work/LS220_234r_136t_50y_analmu_20091212_SVNr26.h5' theEos = eosDriver(ls220EosTableFilename) print theEos.rhobFromEnergyDensityWithTofRho(1.0e15, "BetaEq", kentaDataTofLogRhoFit1())
for script in scriptsList: # break #xFunc = lambda x: theEos.rhobFromEnergyDensityWithTofRho(x, ye, tempFuncsDict[script]) #xFunc = lambda x: x if script == 'c30p10': thisSet = cstDataset(script, eosName, ye, '/home/jeff/work/rotNSruns/svdense30p10A.db') else: thisSet = cstDataset(script, eosName, ye, sourceDb) theEos.resetCachedBetaEqYeVsRhobs(tempFuncsDict[script], cacheMin, cacheMax) theEos.resetCachedRhobVsEds(tempFuncsDict[script], ye, cacheMin, cacheMax) xFunc = lambda x: theEos.rhobFromEdCached(x)/1.0e15 for i, a in enumerate(aList): theMaxRotSlice.update({'a': a}) thisSeq = cstSequence(thisSet, theMaxRotSlice, filters) thisPlot = thisSeq.getSeqPlot([xVar], yVars, filters, xcolFunc=xFunc, ycolFunc=yFunc) kwargs = {} if script == 'cold': kwargs = {'label': "$\\tilde{A}=%s$" % a} plertA, = plt.plot(*thisPlot, c=colors[script], dashes=dashList[i], lw=2.0*(2 + i)/3.0, **kwargs) kwargs = {} plertScript, = plt.plot(thisPlot[0][0], thisPlot[1][0], dashes=dashList[i], lw=2.0*(2 + i)/3.0, marker=symbols[script], c=colors[script], ms=9, **kwargs) if thisPlot[0][-1] < 1.99: plt.plot(thisPlot[0][-1], thisPlot[1][-1],
#xFunc = lambda x: theEos.rhobFromEnergyDensityWithTofRho(x, ye, tempFuncsDict[script]) #xFunc = lambda x: x if script == 'c30p10': thisSet = cstDataset(script, eosName, ye, '/home/jeff/work/rotNSruns/svdense30p10A.db') else: thisSet = cstDataset(script, eosName, ye, sourceDb) theEos.resetCachedBetaEqYeVsRhobs(tempFuncsDict[script], cacheMin, cacheMax) theEos.resetCachedRhobVsEds(tempFuncsDict[script], ye, cacheMin, cacheMax) xFunc = lambda x: theEos.rhobFromEdCached(x) / 1.0e15 for i, a in enumerate(aList): theMaxRotSlice.update({'a': a}) thisSeq = cstSequence(thisSet, theMaxRotSlice, filters) thisPlot = thisSeq.getSeqPlot([xVar], yVars, filters, xcolFunc=xFunc, ycolFunc=yFunc) kwargs = {} if script == 'cold': kwargs = {'label': "$\\tilde{A}=%s$" % a} plertA, = plt.plot(*thisPlot, c=colors[script], dashes=dashList[i], lw=2.0 * (2 + i) / 3.0, **kwargs)