Skip to content

Commit

Permalink
Merge pull request #11 from jzuhone/matplotlib_warnings
Browse files Browse the repository at this point in the history
Fix ECS timing, silence Matplotlib warnings, code cleanup
  • Loading branch information
jzuhone authored Jul 20, 2022
2 parents 293f592 + 0099fa3 commit 4f4eb8f
Show file tree
Hide file tree
Showing 14 changed files with 447 additions and 557 deletions.
2 changes: 1 addition & 1 deletion acispy/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from cxotime import CxoTime


class Dataset(object):
class Dataset:
def __init__(self, msids, states, model):
self.msids = msids
self.states = states
Expand Down
6 changes: 3 additions & 3 deletions acispy/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __str__(self):
f"fields which are not found in this Dataset: {self.ofields} ")


class OutputFieldFunction(object):
class OutputFieldFunction:
def __init__(self, ftype, fname):
self.ftype = ftype
self.fname = fname
Expand All @@ -45,7 +45,7 @@ def __call__(self, ds):
return obj[self.fname]


class DerivedField(object):
class DerivedField:
def __init__(self, ftype, fname, function, units, display_name=None,
depends=None):
self.ftype = ftype
Expand All @@ -62,7 +62,7 @@ def __call__(self, ds):
return self.function(ds)


class FieldContainer(object):
class FieldContainer:
def __init__(self):
self.output_fields = {}
self.derived_fields = {}
Expand Down
4 changes: 2 additions & 2 deletions acispy/load_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
offsets = {"sim_trans": 0.75}


class LoadReviewEvent(object):
class LoadReviewEvent:
def __init__(self, name, event):
self.event = event
self.name = name
Expand All @@ -64,7 +64,7 @@ def __getattr__(self, item):
return self.event[item]


class ACISLoadReview(object):
class ACISLoadReview:
"""
Parse data from a particular load review for
access and plotting of data.
Expand Down
1 change: 1 addition & 0 deletions acispy/msids.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from astropy.table import Table
from cxotime import CxoTime


def check_depends(msids):
output_msids = []
derived_msids = []
Expand Down
29 changes: 18 additions & 11 deletions acispy/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"deg": "deg"}


class ACISPlot(object):
class ACISPlot:
def __init__(self, fig, ax, lines, ax2, lines2):
self.fig = fig
self.ax = ax
Expand Down Expand Up @@ -165,6 +165,13 @@ def set_ylabel(self, ylabel, fontsize=18, **kwargs):
fontdict = {"size": fontsize}
self.ax.set_ylabel(ylabel, fontdict=fontdict, **kwargs)

def set_yscale(self, scale):
"""
Set the y scaling of the plot to "linear" or "log" using
the parameter *scale*.
"""
self.ax.set_yscale(scale)

def redraw(self):
"""
Re-draw the plot.
Expand Down Expand Up @@ -224,7 +231,7 @@ class CustomDatePlot(ACISPlot):
An existing DatePlot to add this plot to. Default: None, one
will be created if not provided.
"""
def __init__(self, dates, values, fmt='-b', lw=2, fontsize=18, ls='-',
def __init__(self, dates, values, lw=2, fontsize=18, ls='-',
figsize=(10, 8), color=None, plot=None, fig=None,
subplot=None, **kwargs):
fig, ax, lines, ax2, lines2 = get_figure(plot, fig, subplot, figsize)
Expand All @@ -238,8 +245,8 @@ def __init__(self, dates, values, fmt='-b', lw=2, fontsize=18, ls='-',
y = np.asarray(values)
if color is None:
color = f"C{len(lines)}"
ticklocs, fig, ax = plot_cxctime(x, y, fmt=fmt, fig=fig, ax=ax,
lw=lw, ls=ls, color=color, **kwargs)
ticklocs, fig, ax = plot_cxctime(x, y, fig=fig, ax=ax, lw=lw, ls=ls,
color=color, **kwargs)
super(CustomDatePlot, self).__init__(fig, ax, lines, ax2, lines2)
self.ax.tick_params(which="major", width=2, length=6)
self.ax.tick_params(which="minor", width=2, length=3)
Expand All @@ -253,7 +260,7 @@ def __init__(self, dates, values, fmt='-b', lw=2, fontsize=18, ls='-',
self.times = dates
self.y = values

def plot_right(self, dates, values, fmt='-b', lw=2, fontsize=18,
def plot_right(self, dates, values, lw=2, fontsize=18,
ls='-', color="magenta", **kwargs):
"""
Plot a quantity on the right x-axis of this plot.
Expand Down Expand Up @@ -288,8 +295,8 @@ def plot_right(self, dates, values, fmt='-b', lw=2, fontsize=18,
else:
x = np.asarray(dates)
y = np.asarray(values)
plot_cxctime(x, y, fmt=fmt, fig=self.fig,
ax=self.ax2, ls=ls, color=color, lw=lw, **kwargs)
plot_cxctime(x, y, fig=self.fig, ax=self.ax2, ls=ls, color=color,
lw=lw, **kwargs)
self.ax2.tick_params(which="major", width=2, length=6)
self.ax2.tick_params(which="minor", width=2, length=3)
fontProperties = font_manager.FontProperties(size=fontsize)
Expand Down Expand Up @@ -629,7 +636,7 @@ class DatePlot(CustomDatePlot):
>>> fields = [("msids", "1dpamzt"), ("msids", "1deamzt"), ("msids", "1pdeaat")]
>>> p2 = DatePlot(ds, fields, fontsize=12, color=["brown","black","orange"])
"""
def __init__(self, ds, fields, field2=None, fmt='-b', lw=2, ls='-',
def __init__(self, ds, fields, field2=None, lw=2, ls='-',
ls2='-', lw2=2, fontsize=18, color=None, color2='magenta',
figsize=(10, 8), plot=None, fig=None, subplot=None,
plot_bad=False):
Expand Down Expand Up @@ -675,7 +682,7 @@ def __init__(self, ds, fields, field2=None, fmt='-b', lw=2, ls='-',
else:
x = ds[field].times.value[mask]
label = ds.fields[field].display_name
_, fig, ax = plot_cxctime(x, y, fmt=fmt, fig=fig, lw=lw[i],
_, fig, ax = plot_cxctime(x, y, fig=fig, lw=lw[i],
ax=ax, color=color[i], ls=ls[i],
state_codes=state_codes,
drawstyle=drawstyle,
Expand Down Expand Up @@ -876,7 +883,7 @@ def set_field_label(self, field, label):
self.set_line_label(idx, label)


class DummyDatePlot(object):
class DummyDatePlot:
def __init__(self, fig, ax):
self.fig = fig
self.ax = ax
Expand All @@ -898,7 +905,7 @@ def make_dateplots(*args, **kwargs):
return plots


class MultiDatePlot(object):
class MultiDatePlot:
r""" Make a multi-panel plot of multiple quantities vs. date and time.
Parameters
Expand Down
11 changes: 11 additions & 0 deletions acispy/tests/acisfp_test_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,17 @@
794
]
},
"limits": {
"fptemp": {
"planning.data_quality.high.acisi": -112.0,
"planning.data_quality.high.aciss": -111.0,
"planning.data_quality.high.aciss_hot": -109.0,
"planning.data_quality.high.cold_ecs": -118.2,
"planning.warning.high": -84.0,
"safety.caution.high": -80.0,
"unit": "degC"
}
},
"mval_names": [],
"name": "acisfp",
"pars": [
Expand Down
9 changes: 8 additions & 1 deletion acispy/tests/dea_test_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,14 @@
799
]
},
"limits": {},
"limits": {
"1deamzt": {
"odb.caution.high": 39.5,
"odb.warning.high": 42.5,
"planning.warning.high": 37.5,
"unit": "degC"
}
},
"mval_names": [],
"name": "1deamzt",
"pars": [
Expand Down
Loading

0 comments on commit 4f4eb8f

Please sign in to comment.