Skip to content

Commit

Permalink
Merge branch 'master' into rtd
Browse files Browse the repository at this point in the history
  • Loading branch information
ksunden committed Apr 15, 2019
2 parents 3610d0e + 74ec1b8 commit e263a9a
Show file tree
Hide file tree
Showing 20 changed files with 820 additions and 11 deletions.
10 changes: 7 additions & 3 deletions attune/workup/_intensity.py
Expand Up @@ -37,6 +37,7 @@ def intensity(
cutoff_factor=0.1,
autosave=True,
save_directory=None,
**spline_kwargs,
):
"""Workup a generic intensity plot for a single dependent.
Expand Down Expand Up @@ -72,8 +73,11 @@ def intensity(
cutoff = channel.max() * cutoff_factor
channel.clip(min=cutoff)

offsets = _intensity(data, channel.natural_name, setpoints[:])
print(offsets)
offsets = _intensity(data, channel.natural_name, setpoints[:], **spline_kwargs)
try:
raw_offsets = _intensity(data, channel.natural_name, setpoints[:], spline=False)
except ValueError:
raw_offsets = None

units = data.axes[1].units
if units == "None":
Expand All @@ -91,7 +95,7 @@ def intensity(
# Why did we have to map setpoints?
curve.map_setpoints(setpoints[:])

fig, _ = plot_intensity(data, channel.natural_name, dependent, curve, old_curve)
fig, _ = plot_intensity(data, channel.natural_name, dependent, curve, old_curve, raw_offsets)

if autosave:
if save_directory is None:
Expand Down
19 changes: 12 additions & 7 deletions attune/workup/_plot.py
Expand Up @@ -3,35 +3,40 @@
import numpy as np


def plot_intensity(data, channel, dependent, curve, prior_curve=None):
def plot_intensity(data, channel, dependent, curve, prior_curve=None, raw_offsets=None):
fig, gs = wt.artists.create_figure(
width="double", nrows=2, cols=[1, "cbar"], default_aspect=.5
width="single", nrows=2, cols=[1, "cbar"], default_aspect=.5
)
ax = plt.subplot(gs[0, 0])
curve_plot_kwargs = {"lw": 4, "c": "k", "alpha": .75}
curve_plot_kwargs = {"lw": 5, "c": "k", "alpha": .5}
prior_curve_plot_kwargs = {"lw": 2, "c": "k"}
ax.plot(curve.setpoints[:], curve[dependent][:], **curve_plot_kwargs)
if prior_curve:
ax.plot(prior_curve.setpoints[:], prior_curve[dependent][:], **prior_curve_plot_kwargs)
ax.set_ylabel(dependent)
wt.artists.plot_gridlines()
ax.set_xlim(*curve.get_limits())
ax.xaxis.set_tick_params(label1On=False)

ax = plt.subplot(gs[1, 0])
ax.pcolor(data, channel=channel)
xlim = ax.get_xlim()
if prior_curve:
ypoints = (
prior_curve(curve.setpoints[:], curve.setpoints.units, full=False)[dependent]
- curve[dependent][:]
curve[dependent][:]
- prior_curve(curve.setpoints[:], curve.setpoints.units, full=False)[dependent]
)
else:
ypoints = curve[dependent][:]

if raw_offsets is not None:
ax.plot(curve.setpoints[:], raw_offsets, c="grey", lw=5, alpha=0.5)

ax.plot(curve.setpoints[:], ypoints, **curve_plot_kwargs)
ax.axhline(0, **prior_curve_plot_kwargs)
wt.artists.plot_gridlines()
ax.set_ylabel(r"$\mathsf{{\Delta {dependent}}}$".format(dependent=dependent))
ax.set_xlabel(f"Setpoint ({curve.setpoints.units})")
ax.set_xlim(xlim)
ax.set_xlim(*curve.get_limits())

cax = plt.subplot(gs[1, 1])
ticks = np.linspace(data[channel].null, data[channel].max(), 11)
Expand Down
5 changes: 4 additions & 1 deletion attune/workup/_tune_test.py
Expand Up @@ -75,7 +75,10 @@ def tune_test(
channel.clip(min=cutoff)

offsets = _offsets(data, channel.natural_name, setpoints[:])
raw_offsets = _offsets(data, channel.natural_name, data.axes[0].points, spline=False)
try:
raw_offsets = _offsets(data, channel.natural_name, data.axes[0].points, spline=False)
except ValueError:
raw_offsets = None

# make curve ----------------------------------------------------------------------------------
new_curve = old_curve.copy()
Expand Down
4 changes: 4 additions & 0 deletions docs/.gitignore
@@ -0,0 +1,4 @@
auto_examples/
_build/
gen_modules/
modules/
20 changes: 20 additions & 0 deletions docs/Makefile
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python3 -msphinx
SPHINXPROJ = WrightTools
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
9 changes: 9 additions & 0 deletions docs/api/.gitignore
@@ -0,0 +1,9 @@
*.rst
!modules.rst
!attune.curve.rst
!attune.curve.Curve.rst
!attune.curve.Dependents.rst
!attune.curve.Setpoints.rst
!attune.curve.TopasCurve.rst
!attune.interpolator.rst
!attune.workup.rst
43 changes: 43 additions & 0 deletions docs/api/attune.curve.Curve.rst
@@ -0,0 +1,43 @@
attune.curve.Curve
==================

.. currentmodule:: attune.curve

.. autoclass:: Curve


.. automethod:: __init__


.. rubric:: Methods

.. autosummary::

~Curve.__init__
~Curve.coerce_dependents
~Curve.convert
~Curve.copy
~Curve.get_dependent_positions
~Curve.get_limits
~Curve.get_source_setpoint
~Curve.interpolate
~Curve.map_setpoints
~Curve.offset_by
~Curve.offset_to
~Curve.plot
~Curve.read
~Curve.save
~Curve.sort





.. rubric:: Attributes

.. autosummary::

~Curve.dependent_names
~Curve.dependent_units


23 changes: 23 additions & 0 deletions docs/api/attune.curve.Setpoints.rst
@@ -0,0 +1,23 @@
attune.curve.Setpoints
======================

.. currentmodule:: attune.curve

.. autoclass:: Setpoints


.. automethod:: __init__


.. rubric:: Methods

.. autosummary::

~Setpoints.__init__
~Setpoints.convert






44 changes: 44 additions & 0 deletions docs/api/attune.curve.TopasCurve.rst
@@ -0,0 +1,44 @@
attune.curve.TopasCurve
=======================

.. currentmodule:: attune.curve

.. autoclass:: TopasCurve


.. automethod:: __init__


.. rubric:: Methods

.. autosummary::

~TopasCurve.__init__
~TopasCurve.coerce_dependents
~TopasCurve.convert
~TopasCurve.copy
~TopasCurve.get_dependent_positions
~TopasCurve.get_limits
~TopasCurve.get_source_setpoint
~TopasCurve.interpolate
~TopasCurve.map_setpoints
~TopasCurve.offset_by
~TopasCurve.offset_to
~TopasCurve.plot
~TopasCurve.read
~TopasCurve.read_all
~TopasCurve.save
~TopasCurve.sort





.. rubric:: Attributes

.. autosummary::

~TopasCurve.dependent_names
~TopasCurve.dependent_units


18 changes: 18 additions & 0 deletions docs/api/attune.curve.rst
@@ -0,0 +1,18 @@
attune.curve package
====================

Module contents
---------------

.. automodule:: attune.curve
:members:
:undoc-members:
:show-inheritance:

.. autosummary::
:toctree: ../api

Curve
Dependent
Setpoints
TopasCurve
15 changes: 15 additions & 0 deletions docs/api/attune.interpolator.rst
@@ -0,0 +1,15 @@
attune.interpolator package
===========================

Module contents
---------------

.. automodule:: attune.interpolator

.. autosummary::
:toctree: ../api

Interpolator
Linear
Poly
Spline
13 changes: 13 additions & 0 deletions docs/api/attune.workup.rst
@@ -0,0 +1,13 @@
attune.workup package
=====================

Module contents
---------------

.. automodule:: attune.workup

.. autosummary::
:toctree: ../api

intensity
tune_test
9 changes: 9 additions & 0 deletions docs/api/modules.rst
@@ -0,0 +1,9 @@
attune API
==========

.. toctree::
:maxdepth: 6

attune.curve
attune.interpolator
attune.workup

0 comments on commit e263a9a

Please sign in to comment.