Skip to content

Commit

Permalink
Merge pull request #42 from wright-group/fixes_from_running
Browse files Browse the repository at this point in the history
Variety of fixes found while running
  • Loading branch information
ksunden committed Feb 28, 2019
2 parents 6ef069e + 8f2c94b commit c6fc7ee
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions attune/curve/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def get_dependent_positions(self, setpoint, units="same", full=True):
for k, v in self.dependents.items():
out[k] = v(setpoint, units)
if full and self.subcurve:
out.update(self.subcurve(setpoint, units, full))
out.update(self.subcurve(self.source_setpoints(setpoint, units), self.source_setpoints.units, full))
return out

def get_source_setpoint(self, setpoint, units="same"):
Expand Down Expand Up @@ -345,11 +345,12 @@ def sort(self):
order = self.setpoints[:].argsort()
self.setpoints[:] = self.setpoints[order]
try:
self.subcurve_setpoints[:] = self.subcurve_setpoints[order]
self.source_setpoints[:] = self.source_setpoints[order]
except (AttributeError, TypeError):
pass # no subcurve setpoints
for d in self.dependents.values():
d[:] = d[order]
self.interpolate()


def offset_by(self, dependent, amount):
Expand Down
3 changes: 2 additions & 1 deletion attune/curve/_topas.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def read_all(cls, filepaths):
if interaction in curves:
c.subcurve = curves[interaction]
curves[interaction].supercurves.append(c)
c.interpolate()
return curves

@classmethod
Expand Down Expand Up @@ -260,7 +261,7 @@ def _write_curve(f, curve):
curve.convert("nm")
curve.sort()
f.write(f"{curve.interaction}\n")
if curve.comment[-1] != "\n":
if len(curve.comment) == 0 or curve.comment[-1] != "\n":
curve.comment += "\n"
num_lines = curve.comment.count("\n")
f.write(f"{num_lines}\n")
Expand Down
2 changes: 1 addition & 1 deletion attune/workup/_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def plot_tune_test(data, channel, curve, prior_curve, raw_offsets=None):
if raw_offsets is not None:
ax.plot(curve.setpoints[:], raw_offsets, c="grey", lw=5, alpha=0.5)

ax.plot(curve.setpoints[:], curve.setpoints[:] - prior_curve.setpoints[:] , c="k", lw=5, alpha=0.5)
ax.plot(curve.setpoints[:], curve.setpoints[:] - prior_curve.setpoints[:], c="k", lw=5, alpha=0.5)
ax.axhline(c="k", lw=1)
ax.grid()

Expand Down
2 changes: 1 addition & 1 deletion attune/workup/_tune_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def tune_test(

# plot ----------------------------------------------------------------------------------------

fig, _ = plot_tune_test(data, channel.natural_name, new_curve, prior_curve=curve, raw_offsets=raw_offsets)
fig, _ = plot_tune_test(data, channel.natural_name, new_curve, prior_curve=old_curve, raw_offsets=raw_offsets)

new_curve.map_setpoints(setpoints[:], units=setpoints.units)
new_curve.convert(curve.setpoints.units)
Expand Down

0 comments on commit c6fc7ee

Please sign in to comment.