Skip to content

Commit

Permalink
Naming of process() results unified to results
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-brajer committed Jun 6, 2021
1 parent 7b97828 commit a6e5407
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Documentation can be found on [Read the Docs](https://physics-lab.readthedocs.io
* Van der Pauw & Hall method
* Magnetization measurements
* Batch measurement evaluation
* Plot the data / analysis output
* Plot the data / analysis results
* Using [pandas.DataFrame](https://pandas.pydata.org/pandas-docs/dev/reference/frame.html)


Expand Down
2 changes: 1 addition & 1 deletion docs/source/_overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Features
* Van der Pauw & Hall method
* Magnetization measurements
* Batch measurement evaluation
* Plot the data / analysis output
* Plot the data / analysis results
* Using `pandas.DataFrame <https://pandas.pydata.org/pandas-docs/dev/reference/frame.html>`_


Expand Down
6 changes: 3 additions & 3 deletions physicslab/experiment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ def process(data_list, by_module, **kwargs):
:return: Collection of results indexed by measurement's :attr:`name`
:rtype: pandas.DataFrame
"""
output = []
results = []
for i, data in enumerate(data_list):
series = by_module.process(data, **kwargs)
series.name = data.name if hasattr(data, 'name') else i
output.append(series)
results.append(series)

df = pd.DataFrame(output)
df = pd.DataFrame(results)
df.attrs[UNITS] = by_module.process(None)
return df

Expand Down
6 changes: 3 additions & 3 deletions physicslab/experiment/curie_temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def process(data):
:param data: Measured data. If None, return units instead
:type data: pandas.DataFrame
:return: Derived quantities listed in :meth:`Columns.output` or units
:return: Derived quantities listed in :meth:`Columns.process` or units
:rtype: pandas.Series
"""
if data is None:
Expand All @@ -39,7 +39,7 @@ def process(data):

return pd.Series(
data=(curie_temperature,),
index=Columns.output(), name=name)
index=Columns.process(), name=name)


class Columns(_ColumnsBase):
Expand All @@ -61,7 +61,7 @@ def mandatory(cls):
return {cls.TEMPERATURE, cls.MAGNETIZATION}

@classmethod
def output(cls):
def process(cls):
""" Get the current values of the :func:`process` output column names.
:rtype: lits(str)
Expand Down
12 changes: 6 additions & 6 deletions physicslab/experiment/hall.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def process(data, thickness=None, sheet_resistance=None):
:type thickness: float, optional
:param sheet_resistance: Defaults to None
:type sheet_resistance: float, optional
:return: Derived quantities listed in :meth:`Columns.output` or units
:return: Derived quantities listed in :meth:`Columns.process` or units
:rtype: pandas.Series
"""
if data is None:
Expand Down Expand Up @@ -59,7 +59,7 @@ def process(data, thickness=None, sheet_resistance=None):
return pd.Series(
data=(sheet_density, conductivity_type, residual,
concentration, mobility),
index=Columns.output(), name=name)
index=Columns.process(), name=name)


class Columns(_ColumnsBase):
Expand All @@ -85,7 +85,7 @@ def mandatory(cls):
return {cls.MAGNETICFIELD, cls.HALLVOLTAGE, cls.CURRENT}

@classmethod
def output(cls):
def process(cls):
""" Get the current values of the :func:`process` output column names.
:rtype: lits(str)
Expand Down Expand Up @@ -143,13 +143,13 @@ def analyze(self):
return sheet_density, conductivity_type, fit_residual


def plot(data_list, output):
def plot(data_list, results):
""" Plot all the measurements in a grid
:param data_list:
:type data_list: list[pandas.DataFrame]
:param output: Analysis data from :func:`physicslab.experiment.process`
:type output: pandas.DataFrame
:param results: Analysis data from :func:`physicslab.experiment.process`
:type results: pandas.DataFrame
:return: Same objects as from :meth:`matplotlib.pyplot.subplots`
:rtype: tuple[~matplotlib.figure.Figure,
numpy.ndarray[~matplotlib.axes.Axes]]
Expand Down
6 changes: 3 additions & 3 deletions physicslab/experiment/magnetism_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def process(data, diamagnetism=True, ferromagnetism=True):
:param ferromagnetism: Look for ferromagnetism contribution,
defaults to True
:type ferromagnetism: bool, optional
:return: Derived quantities listed in :meth:`Columns.output` or units
:return: Derived quantities listed in :meth:`Columns.process` or units
:rtype: pandas.Series
"""
if data is None:
Expand Down Expand Up @@ -65,7 +65,7 @@ def process(data, diamagnetism=True, ferromagnetism=True):
return pd.Series(
data=(magnetic_susceptibility, offset, saturation, remanence,
coercivity, ratio_DM_FM),
index=Columns.output(), name=name)
index=Columns.process(), name=name)


class Columns(_ColumnsBase):
Expand Down Expand Up @@ -95,7 +95,7 @@ def mandatory(cls):
return {cls.MAGNETICFIELD, cls.MAGNETIZATION}

@classmethod
def output(cls):
def process(cls):
""" Get the current values of the :func:`process` output column names.
:rtype: lits(str)
Expand Down
16 changes: 8 additions & 8 deletions physicslab/experiment/profilometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def process(data, **kwargs):
:type data: pandas.DataFrame
:param kwargs: All additional keyword arguments are passed to the
:meth:`Measurement.analyze` call.
:return: Derived quantities listed in :meth:`Columns.output` or units
:return: Derived quantities listed in :meth:`Columns.process` or units
:rtype: pandas.Series
"""
if data is None:
Expand All @@ -53,7 +53,7 @@ def process(data, **kwargs):
return pd.Series(
data=(expected_values, variances, amplitudes, FWHMs, thickness,
histogram),
index=Columns.output(), name=name)
index=Columns.process(), name=name)


class Columns(_ColumnsBase):
Expand Down Expand Up @@ -82,7 +82,7 @@ def mandatory(cls):
return {cls.POSITION, cls.HEIGHT}

@classmethod
def output(cls):
def process(cls):
""" Get the current values of the :func:`process` output column names.
:rtype: lits(str)
Expand Down Expand Up @@ -237,15 +237,15 @@ def _double_gauss(x, expected_value1, variance1, amplitude1,
+ gaussian_curve(x, expected_value2, variance2, amplitude2))


def plot(data, output):
""" Plot both the data analysis parts and the output histogram.
def plot(data, results):
""" Plot both the data analysis parts and the results histogram.
Units are shown in nanometers.
:param data:
:type data: pandas.DataFrame
:param output: Analysis data from :func:`physicslab.experiment.process`
:type output: pandas.Series
:param results: Analysis data from :func:`physicslab.experiment.process`
:type results: pandas.Series
:return: Same objects as from :meth:`matplotlib.pyplot.subplots`
:rtype: tuple[~matplotlib.figure.Figure,
numpy.ndarray[~matplotlib.axes.Axes]]
Expand All @@ -267,7 +267,7 @@ def plot(data, output):
ax_profile.legend()

# Histogram.
histogram = output['histogram']
histogram = results['histogram']
ax_hist.plot(histogram.bin_centers, histogram.count, 'k.-')
ax_hist.plot(histogram.x_fit, histogram.y_fit, 'r-', alpha=.3)
ax_hist.set_xlabel(height_label)
Expand Down
16 changes: 8 additions & 8 deletions physicslab/experiment/van_der_pauw.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def process(data, thickness=None):
:param thickness: Sample dimension perpendicular to the plane marked
by the electrical contacts, defaults to None
:type thickness: float, optional
:return: Derived quantities listed in :meth:`Columns.output` or units
:return: Derived quantities listed in :meth:`Columns.process` or units
:rtype: pandas.Series
"""
if data is None:
Expand Down Expand Up @@ -65,7 +65,7 @@ def process(data, thickness=None):
return pd.Series(
data=(sheet_resistance, ratio_resistance, sheet_conductance,
resistivity, conductivity),
index=Columns.output(), name=name)
index=Columns.process(), name=name)


class Solve:
Expand Down Expand Up @@ -179,7 +179,7 @@ def mandatory(cls):
return {cls.GEOMETRY, cls.VOLTAGE, cls.CURRENT}

@classmethod
def output(cls):
def process(cls):
""" Get the current values of the :func:`process` output column names.
:rtype: lits(str)
Expand Down Expand Up @@ -320,16 +320,16 @@ def classify(self):
return self.Vertical


def plot(data_list, output):
def plot(data_list, results):
""" Plot individual measurements and results with quality coefficients.
For plotting details, see:
https://matplotlib.org/stable/tutorials/intermediate/gridspec.html#a-complex-nested-gridspec-using-subplotspec
:param data_list:
:type data_list: list[pandas.DataFrame]
:param output: Analysis data from :func:`physicslab.experiment.process`
:type output: pandas.DataFrame
:param results: Analysis data from :func:`physicslab.experiment.process`
:type results: pandas.DataFrame
:return: Same objects as from :meth:`matplotlib.pyplot.subplots`.
Axes are: grid axis array, right plot left axis, right plot right axis
:rtype: tuple[~matplotlib.figure.Figure,
Expand Down Expand Up @@ -359,14 +359,14 @@ def plot_value(ax, value: pd.DataFrame):

# Single plot.
ax_plot = fig.add_subplot(outer_grid[1])
ax_plot.plot(output[Columns.SHEET_CONDUCTANCE], 'ko:')
ax_plot.plot(results[Columns.SHEET_CONDUCTANCE], 'ko:')
ax_plot.set_xlabel('Measurement number')
ax_plot.set_ylabel('Sheet conductance / $(k\\Omega)^{-1}$')
ax_plot.set_ylim(bottom=0)

color = 'red'
ax_plot_2 = ax_plot.twinx()
ax_plot_2.plot(output[Columns.RATIO_RESISTANCE], 'o:', c=color)
ax_plot_2.plot(results[Columns.RATIO_RESISTANCE], 'o:', c=color)
ax_plot_2.set_ylabel('$R_{12} / R_{23}$ {>1}')
ax_plot_2.spines['right'].set_color(color)
ax_plot_2.yaxis.label.set_color(color)
Expand Down

0 comments on commit a6e5407

Please sign in to comment.