Skip to content
Snippets Groups Projects
Commit bcf1cb18 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

rm units from Py; disable scatter2d/AxesInDifferentUnits; lost q scales in scatter2d/PolarizedSANS

parent 71d6be42
No related branches found
No related tags found
No related merge requests found
......@@ -169,7 +169,7 @@ test_example(scatter2d/LargeParticlesFormFactor 0.5)
test_example(scatter2d/GratingMC .9) # TODO reduce tolerance
run_example(scatter2d/PositionVariance) # TODO -> test
run_example(scatter2d/AxesInDifferentUnits)
# TODO disabled while refactoring scales&coords: run_example(scatter2d/AxesInDifferentUnits)
run_example(scatter2d/FindPeaks)
test_example(specular/AlternatingLayers1 2e-13)
......
......@@ -31,7 +31,6 @@ class Plotter:
zmax=None,
xlabel=None,
ylabel=None,
units=ba.Coords_UNDEFINED,
aspect=None):
self._fig = plt.figure(figsize=(10.25, 7.69))
......@@ -40,7 +39,6 @@ class Plotter:
self._zmax = zmax
self._xlabel = xlabel
self._ylabel = ylabel
self._units = units
self._aspect = aspect
def __call__(self, fit_objective):
......@@ -64,9 +62,8 @@ class PlotterGISAS(Plotter):
zmax=None,
xlabel=None,
ylabel=None,
units=ba.Coords_UNDEFINED,
aspect=None):
Plotter.__init__(self, zmin, zmax, xlabel, ylabel, units, aspect)
Plotter.__init__(self, zmin, zmax, xlabel, ylabel, aspect)
@staticmethod
def make_subplot(nplot):
......@@ -91,7 +88,6 @@ class PlotterGISAS(Plotter):
title="Experimental data",
intensity_min=zmin,
intensity_max=zmax,
units=self._units,
xlabel=self._xlabel,
ylabel=self._ylabel,
zlabel='',
......@@ -102,7 +98,6 @@ class PlotterGISAS(Plotter):
title="Simulated data",
intensity_min=zmin,
intensity_max=zmax,
units=self._units,
xlabel=self._xlabel,
ylabel=self._ylabel,
zlabel='',
......@@ -113,7 +108,6 @@ class PlotterGISAS(Plotter):
title="Difference",
intensity_min=zmin,
intensity_max=zmax,
units=self._units,
xlabel=self._xlabel,
ylabel=self._ylabel,
zlabel='',
......@@ -145,8 +139,7 @@ class PlotterSpecular:
Draws fit progress, for specular simulation.
"""
def __init__(self, units=ba.Coords_UNDEFINED, pause=0.0):
self.units = units
def __init__(self, pause=0.0):
self.pause = pause
self._fig = plt.figure(figsize=(10, 7))
self._fig.canvas.draw()
......@@ -162,10 +155,9 @@ class PlotterSpecular:
unc_data = fit_objective.uncertaintyData()
# data values
sim_values = sim_data.array(self.units)
exp_values = exp_data.array(self.units)
unc_values = None if unc_data is None else unc_data.array(
self.units)
sim_values = sim_data.array()
exp_values = exp_data.array()
unc_values = None if unc_data is None else unc_data.array()
# default font properties dictionary to use
font = { 'size': 16 }
......@@ -184,7 +176,7 @@ class PlotterSpecular:
alpha=0.6)
plt.plot(sim_data.convertedBinCenters(), sim_values, 'b')
xlabel = bp.get_axes_labels(exp_data, self.units)[0]
xlabel = bp.get_axes_labels(exp_data)[0]
legend = ['Experiment', 'BornAgain']
if unc_values is not None:
legend = ['Experiment', r'Exp $\pm \sigma$', 'BornAgain']
......
......@@ -111,16 +111,15 @@ def parse_commandline():
parse_any(tmp)
def get_axes_limits(result, units):
def get_axes_limits(result):
"""
Returns axes range as expected by pyplot.imshow.
:param result: SimulationResult object from a Simulation
:param units: units to use
:return: axes ranges as a flat list
"""
limits = []
for i in range(result.rank()):
ami, ama = result.axisMinMax(i, units)
ami, ama = result.axisMinMax(i)
assert ami < ama, f'SimulationResult has invalid axis {i}, extending from {ami} to {ama}'
limits.append(ami)
limits.append(ama)
......@@ -156,17 +155,16 @@ def translate_axis_label(label):
return label
def get_axes_labels(result, units):
def get_axes_labels(result):
"""
Returns axes range as expected by pyplot.imshow.
:param result: SimulationResult object from a Simulation
:param units: units to use
:return: axes ranges as a flat list
Used internally and in Examples/fit/specular/RealLifeReflectometryFitting.py.
"""
labels = []
for i in range(result.rank()):
labels.append(translate_axis_label(result.name_of_axis(i, units)))
labels.append(translate_axis_label(result.name_of_axis(i)))
return labels
......@@ -197,12 +195,10 @@ def plot_specular_curve(result):
:param result: SimulationResult from SpecularSimulation
Used internally.
"""
units = plotargs.pop('units', ba.Coords_UNDEFINED)
intensity = result.array()
x_axis = result.convertedBinCenters()
intensity = result.array(units)
x_axis = result.convertedBinCenters(units)
xlabel = plotargs.pop('xlabel', get_axes_labels(result, units)[0])
xlabel = plotargs.pop('xlabel', get_axes_labels(result)[0])
ylabel = plotargs.pop('ylabel', "Intensity")
plt.yscale('log')
......@@ -405,9 +401,8 @@ def plot_simres(result, **kwargs):
Used internally and in a few examples.
"""
units = kwargs.pop('units', ba.Coords_UNDEFINED)
axes_limits = get_axes_limits(result, units)
axes_labels = get_axes_labels(result, units)
axes_limits = get_axes_limits(result)
axes_labels = get_axes_labels(result)
if 'xlabel' not in kwargs:
kwargs['xlabel'] = axes_labels[0]
......@@ -425,7 +420,6 @@ def parse_args(**kwargs):
Ingests plot options:
:param intensity_min: Min value on amplitude's axis or color legend
:param intensity_max: Max value on amplitude's axis or color legend
:param units: units for plot axes
:param ymin: minimal y-axis value to show
:param ymax: maximum y-axis value to show
:param zmin: Min value on amplitude's color legend
......@@ -493,7 +487,7 @@ def make_plot(results, ncol):
# Plot the subfigures.
for i, result in enumerate(results):
ax = multiPlot.axes[i]
axes_limits = get_axes_limits(result, ba.Coords_UNDEFINED)
axes_limits = get_axes_limits(result)
im = ax.imshow(result.array(),
cmap=cmap,
......@@ -544,7 +538,7 @@ def plot_multicurve(results, xlabel, ylabel):
def plot_multicurve_specular(results):
plt.yscale('log')
xlabel = get_axes_labels(results[0], ba.Coords_UNDEFINED)[0]
xlabel = get_axes_labels(results[0])[0]
plot_multicurve(results, xlabel, r'Intensity')
# ************************************************************************** #
......
......@@ -69,7 +69,6 @@ def get_simulation(sample):
if __name__ == '__main__':
bp.parse_args(units=ba.Coords_QSPACE)
sample = get_sample()
simulation = get_simulation(sample)
result = simulation.simulate()
......
......@@ -69,7 +69,6 @@ def get_simulation(sample):
if __name__ == '__main__':
bp.parse_args(units=ba.Coords_QSPACE)
sample = get_sample()
simulation = get_simulation(sample)
result = simulation.simulate()
......
......@@ -69,7 +69,6 @@ def get_simulation(sample):
if __name__ == '__main__':
bp.parse_args(units=ba.Coords_QSPACE)
sample = get_sample()
simulation = get_simulation(sample)
result = simulation.simulate()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment