Exemple #1
0
    def __init__(self, rhoNumber, phiNumber, tfNumber):
        self.rhoNumber = rhoNumber
        self.phiNumber = phiNumber
        self.tfNumber = tfNumber
        
        if rhoNumber == 0:
            self.rho = TrivialField()
        elif rhoNumber == 1:
            datasetDir = "datasets/" + repr(rhoNumber)
            self.rho = splineio.read(datasetDir + "/rho.json")
        else:
            self.rho = SineField()
            
        if phiNumber == 0:
            self.phi = TrivialGeometry()
        elif phiNumber == 1:
            datasetDir = "datasets/" + repr(phiNumber)
            self.phi = splineio.read(datasetDir + "/phi.json")
        else:
            self.phi = SineGeometry()

        if tfNumber == 0:
            self.tf = trivialtransfer.createTransferFunction()
        elif tfNumber == 1:
            self.tf = simpletransfer.createTransferFunction()
        else:
            self.tf = peakstransfer.createTransferFunction()
from matplotlib.gridspec import GridSpec
import matplotlib.pyplot as plt
import numpy as np

from plotting.paramplotter import ParamPlotter
from dataset import Dataset
import datasets.peakstransfer as transfer


fig = plt.figure(figsize=[8, 6])
gs = GridSpec(1, 1)
ax = fig.add_subplot(gs[0, 0])

dataset = Dataset(1, 1)
splineInterval = np.array([0.0, 1.0])
t = transfer.createTransferFunction()

p = ParamPlotter(ax, splineInterval, precision=1000)
cax = p.plotScalarField(dataset.rho, t)
ax.set_aspect('equal')
cbar = fig.colorbar(cax, ticks=[0.0, 1.0])
cbar.ax.set_yticklabels(['0.0', '1.0']) # Workaround for the ticks being converted to integers
cbar.solids.set_edgecolor('face') # Removes buggy lines in vector graphics

fig.tight_layout()
plt.savefig("output/vg/scalartransfer.pdf", format="pdf", transparent=True)