databaseFile = '/home/jeff/work/rotNSruns/allRuns3-25-13.db' connectionTov = sqlite3.connect(databaseFile) c = connectionTov.cursor() filters = equalsFiltersFromDict({'ye': .1, 'eos': 'HShenEOS', 'a': 0.0, 'T': 0.01}) colorVar = "omega_c" manyScriptSequencePlot(["edMax", "gravMass"], c, filters, colorVar, "gravMass", suppressShow=True, minRpoeOnly=True, vmax=1e4, vmin=0,) filters = equalsFiltersFromDict({'ye': .1, 'a': 0.0, 'eos': 'HShenEOS'}) manyScriptSequencePlot(["edMax", "gravMass"], c, filters , colorVar, "gravMass", suppressShow=True, vmax=5000, vmin=0,) colorLegend = plt.colorbar() colorLegend.set_label(latexField(colorVar)) plt.legend(loc=4) #plt.xlim([0.0, 3.e15]) #plt.ylim([0.0, 3.0]) plt.show() exit() #Below are not actually uniform rotation plots a=1.0 filters = equalsFiltersFromDict({'ye': 0.1, 'eos': 'LS220', 'a': a, 'T': 0.01, 'eosTmin': 0.01}) colorVar = "ToverW" manyScriptSequencePlot(["edMax", "gravMass"], c, filters, colorVar,
def manyScriptSequencePlot(plotFields, sqliteCursor, filters=(), colorBy=None, maxPlot=None, grid=False, title="", orderBy=None, forceColorbar=False, suppressShow=False, legendList=[], vmax=None, vmin=None, loc=0, minRpoeOnly=False, **mplKwargs): """ Version of sequence plot for plotting huge amount of data assumes tablename is models if maxPlot plots maximum value of quantity for sequence only """ orderBy = plotFields[0] + ',' + ','.join(tempPrescription.prescriptionParameters) + ",eos,ye,edMax" #orderBy = 'rpoe'+','+ ','.join(eosPrescription.prescriptionParameters) + ",eos,ye,edMax" #print orderBy size = 40 plotLines = False #filters = ("ye=0.15",) filters += ("arealR < 100",) tableName = "models" if colorBy is None: colorBy = "arealR" getFields = plotFields[:] # x-points 0, y-points 1 getFields.append(colorBy) # colorBy 2 if orderBy is None: orderBy = plotFields[0] for key in tempPrescription.prescriptionParameters: getFields.append(key) # script parameters 3-8 getFields.append('RedMax') # RedMax 9 getFields.append('ye') # ye 10 getFields.append('eos') # eos 11 if maxPlot is not None: getFields.append(maxPlot) # maxPlot 12 if minRpoeOnly: getFields.append('runID') # runIDcol runIDcol = len(getFields) - 1 getFields.append('lineNum') # lineNumcol lineNumcol = len(getFields) - 1 orderBy = 'runID,lineNum,' + orderBy points = queryDBGivenParams(getFields, [], sqliteCursor, tableName, filters, " ORDER BY " + orderBy) assert points, "No points returned for query with filters: %s" % str(filters) currentSymbol = "" previousSymbol = "" previousName = "" currentName = "" currentPoints = [] currentToroidPoints = [] currentEos = None currentYe = None previousEos = None previousYe = None previousPoint = None if vmax is None: vmax = max([point[2] for point in points]) if vmin is None: vmin = min([point[2] for point in points]) #print vmin, vmax for i, point in enumerate(points): #print point currentYe = point[10] currentEos = point[11] prescriptDict = dict() #print currentSymbol, previousSymbol for j, scriptParam in enumerate(point[3:3 + 6 ]): prescriptDict[tempPrescription.prescriptionParameters[j]] = scriptParam #print prescriptDict currentSymbol, currentName = symbolFromDBentry(prescriptDict) ax = plt.gca() handles, labels = ax.get_legend_handles_labels() #print currentName, labels if currentName in labels: currentName = None previousName = None if currentSymbol == previousSymbol and currentEos == previousEos and currentYe == previousYe: currentPoints.append(point) if point[9] > 0.0: #print "TOROIZZLE" currentToroidPoints.append(point) elif not previousSymbol == "" and not currentPoints == []: if minRpoeOnly: currentPoints = reduceToMinRpoeOnly(currentPoints, runIDcol, lineNumcol) if maxPlot is not None: currentPoints = [getPointWithMaxOfCol(currentPoints, 12)] if currentPoints[0][9] == 0.0: #print "antigotcha " currentToroidPoints = [] else: currentToroidPoints = [getPointWithMaxOfCol(currentToroidPoints, 12)] currentPoints = zip(*currentPoints) print currentPoints plt.scatter(*currentPoints[:2], c=currentPoints[2], marker=previousSymbol, label=previousName, vmax=vmax, vmin=vmin, s=size, **mplKwargs) if plotLines: plt.plot(*currentPoints[:2], ls=getLinestyle(previousEos, previousYe), c='k', lw=.5) currentPoints = [] #legendList.append(currentName) if not currentToroidPoints == []: currentToroidPoints = zip(*currentToroidPoints) #below line sets circle color to black currentToroidPoints[2] = [(0., 0., 0.) for _ in currentToroidPoints[2]] plt.scatter(*currentToroidPoints[:2], c=currentToroidPoints[2], marker='o', facecolor='none', s=size * 2, vmax=vmax, vmin=vmin, **mplKwargs) currentToroidPoints = [] previousSymbol = currentSymbol previousEos = currentEos previousYe = currentYe previousName = currentName previousPoint = point #symbolList.append(symbolFromDBentry(prescriptDict)) print "Done with loop" #Don't forget to plot the last set! #print getPointWithMaxOfCol(currentPoints, 12) if minRpoeOnly: currentPoints = reduceToMinRpoeOnly(currentPoints, runIDcol, lineNumcol) if maxPlot is not None: currentPoints = [getPointWithMaxOfCol(currentPoints, 12)] if currentPoints[0][9] == 0.0: currentToroidPoints = [] currentPoints = zip(*currentPoints) plt.scatter(*currentPoints[:2], c=currentPoints[2], marker=previousSymbol, label=previousName, vmax=vmax, vmin=vmin, s=size, **mplKwargs) if plotLines: plt.plot(*currentPoints[:2], ls=getLinestyle(previousEos, previousYe), c='k', lw=.5) #legendList.append(currentName) #Set colorbar before doing toroidal points because toroidal points have black coloring if colorBy and not suppressShow: colorLegend = plt.colorbar() colorLegend.set_label(latexField(colorBy)) if forceColorbar: colorLegend = plt.colorbar() colorLegend.set_label(latexField(colorBy)) if not currentToroidPoints == []: if maxPlot is not None: currentToroidPoints = [getPointWithMaxOfCol(currentToroidPoints, 12)] currentToroidPoints = zip(*currentToroidPoints) #print "dur", currentToroidPoints #below line sets circle color to black currentToroidPoints[2] = [(0., 0., 0.) for _ in currentToroidPoints[2]] plt.scatter(*currentToroidPoints[:2], c=currentToroidPoints[2], marker='o', facecolor='none', s=size * 2, vmax=vmax, vmin=vmin, **mplKwargs) plt.title(title) plt.grid(grid) #axis.set_xlabel(getFields[0]) #axis.set_ylabel(getFields[1]) plt.xlabel(latexField(getFields[0])) plt.ylabel(latexField(getFields[1])) print "Plotting %i entries" % len(points) if not suppressShow: #ax = plt.gca() #handles, labels = ax.get_legend_handles_labels() plt.legend(loc=loc) plt.show() legendList = []
vmin=0, ) filters = equalsFiltersFromDict({'ye': .1, 'a': 0.0, 'eos': 'HShenEOS'}) manyScriptSequencePlot( ["edMax", "gravMass"], c, filters, colorVar, "gravMass", suppressShow=True, vmax=5000, vmin=0, ) colorLegend = plt.colorbar() colorLegend.set_label(latexField(colorVar)) plt.legend(loc=4) #plt.xlim([0.0, 3.e15]) #plt.ylim([0.0, 3.0]) plt.show() exit() #Below are not actually uniform rotation plots a = 1.0 filters = equalsFiltersFromDict({ 'ye': 0.1, 'eos': 'LS220', 'a': a, 'T': 0.01, 'eosTmin': 0.01
# shen_c30p10 = cstDataset("c30p10", "HShenEOS", ye, sourceDb) # shen_c30p5 = cstDataset("c30p5", "HShenEOS", ye, sourceDb) shen_cold = cstDataset("cold", "HShenEOS", ye, sourceDb) # ls220_c40p0 = cstDataset("c40p0", "LS220", ye, sourceDb) # ls220_c30p0 = cstDataset("c30p0", "LS220", ye, sourceDb) # ls220_c20p0 = cstDataset("c20p0", "LS220", ye, sourceDb) # 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)
def manyScriptSequencePlot(plotFields, sqliteCursor, filters=(), colorBy=None, maxPlot=None, grid=False, title="", orderBy=None, forceColorbar=False, suppressShow=False, legendList=[], vmax=None, vmin=None, loc=0, minRpoeOnly=False, **mplKwargs): """ Version of sequence plot for plotting huge amount of data assumes tablename is models if maxPlot plots maximum value of quantity for sequence only """ orderBy = plotFields[0] + ',' + ','.join( tempPrescription.prescriptionParameters) + ",eos,ye,edMax" #orderBy = 'rpoe'+','+ ','.join(eosPrescription.prescriptionParameters) + ",eos,ye,edMax" #print orderBy size = 40 plotLines = False #filters = ("ye=0.15",) filters += ("arealR < 100", ) tableName = "models" if colorBy is None: colorBy = "arealR" getFields = plotFields[:] # x-points 0, y-points 1 getFields.append(colorBy) # colorBy 2 if orderBy is None: orderBy = plotFields[0] for key in tempPrescription.prescriptionParameters: getFields.append(key) # script parameters 3-8 getFields.append('RedMax') # RedMax 9 getFields.append('ye') # ye 10 getFields.append('eos') # eos 11 if maxPlot is not None: getFields.append(maxPlot) # maxPlot 12 if minRpoeOnly: getFields.append('runID') # runIDcol runIDcol = len(getFields) - 1 getFields.append('lineNum') # lineNumcol lineNumcol = len(getFields) - 1 orderBy = 'runID,lineNum,' + orderBy points = queryDBGivenParams(getFields, [], sqliteCursor, tableName, filters, " ORDER BY " + orderBy) assert points, "No points returned for query with filters: %s" % str( filters) currentSymbol = "" previousSymbol = "" previousName = "" currentName = "" currentPoints = [] currentToroidPoints = [] currentEos = None currentYe = None previousEos = None previousYe = None previousPoint = None if vmax is None: vmax = max([point[2] for point in points]) if vmin is None: vmin = min([point[2] for point in points]) #print vmin, vmax for i, point in enumerate(points): #print point currentYe = point[10] currentEos = point[11] prescriptDict = dict() #print currentSymbol, previousSymbol for j, scriptParam in enumerate(point[3:3 + 6]): prescriptDict[ tempPrescription.prescriptionParameters[j]] = scriptParam #print prescriptDict currentSymbol, currentName = symbolFromDBentry(prescriptDict) ax = plt.gca() handles, labels = ax.get_legend_handles_labels() #print currentName, labels if currentName in labels: currentName = None previousName = None if currentSymbol == previousSymbol and currentEos == previousEos and currentYe == previousYe: currentPoints.append(point) if point[9] > 0.0: #print "TOROIZZLE" currentToroidPoints.append(point) elif not previousSymbol == "" and not currentPoints == []: if minRpoeOnly: currentPoints = reduceToMinRpoeOnly(currentPoints, runIDcol, lineNumcol) if maxPlot is not None: currentPoints = [getPointWithMaxOfCol(currentPoints, 12)] if currentPoints[0][9] == 0.0: #print "antigotcha " currentToroidPoints = [] else: currentToroidPoints = [ getPointWithMaxOfCol(currentToroidPoints, 12) ] currentPoints = zip(*currentPoints) print currentPoints plt.scatter(*currentPoints[:2], c=currentPoints[2], marker=previousSymbol, label=previousName, vmax=vmax, vmin=vmin, s=size, **mplKwargs) if plotLines: plt.plot(*currentPoints[:2], ls=getLinestyle(previousEos, previousYe), c='k', lw=.5) currentPoints = [] #legendList.append(currentName) if not currentToroidPoints == []: currentToroidPoints = zip(*currentToroidPoints) #below line sets circle color to black currentToroidPoints[2] = [(0., 0., 0.) for _ in currentToroidPoints[2]] plt.scatter(*currentToroidPoints[:2], c=currentToroidPoints[2], marker='o', facecolor='none', s=size * 2, vmax=vmax, vmin=vmin, **mplKwargs) currentToroidPoints = [] previousSymbol = currentSymbol previousEos = currentEos previousYe = currentYe previousName = currentName previousPoint = point #symbolList.append(symbolFromDBentry(prescriptDict)) print "Done with loop" #Don't forget to plot the last set! #print getPointWithMaxOfCol(currentPoints, 12) if minRpoeOnly: currentPoints = reduceToMinRpoeOnly(currentPoints, runIDcol, lineNumcol) if maxPlot is not None: currentPoints = [getPointWithMaxOfCol(currentPoints, 12)] if currentPoints[0][9] == 0.0: currentToroidPoints = [] currentPoints = zip(*currentPoints) plt.scatter(*currentPoints[:2], c=currentPoints[2], marker=previousSymbol, label=previousName, vmax=vmax, vmin=vmin, s=size, **mplKwargs) if plotLines: plt.plot(*currentPoints[:2], ls=getLinestyle(previousEos, previousYe), c='k', lw=.5) #legendList.append(currentName) #Set colorbar before doing toroidal points because toroidal points have black coloring if colorBy and not suppressShow: colorLegend = plt.colorbar() colorLegend.set_label(latexField(colorBy)) if forceColorbar: colorLegend = plt.colorbar() colorLegend.set_label(latexField(colorBy)) if not currentToroidPoints == []: if maxPlot is not None: currentToroidPoints = [ getPointWithMaxOfCol(currentToroidPoints, 12) ] currentToroidPoints = zip(*currentToroidPoints) #print "dur", currentToroidPoints #below line sets circle color to black currentToroidPoints[2] = [(0., 0., 0.) for _ in currentToroidPoints[2]] plt.scatter(*currentToroidPoints[:2], c=currentToroidPoints[2], marker='o', facecolor='none', s=size * 2, vmax=vmax, vmin=vmin, **mplKwargs) plt.title(title) plt.grid(grid) #axis.set_xlabel(getFields[0]) #axis.set_ylabel(getFields[1]) plt.xlabel(latexField(getFields[0])) plt.ylabel(latexField(getFields[1])) print "Plotting %i entries" % len(points) if not suppressShow: #ax = plt.gca() #handles, labels = ax.get_legend_handles_labels() plt.legend(loc=loc) plt.show() legendList = []