Skip to content

Commit

Permalink
A number of fixes for when plot_bad = False
Browse files Browse the repository at this point in the history
  • Loading branch information
jzuhone committed Mar 15, 2018
1 parent ad81d85 commit bc3293f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 31 deletions.
48 changes: 22 additions & 26 deletions acispy/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,32 +500,30 @@ def __init__(self, ds, fields, field2=None, lw=2, ls='-', ls2='-', lw2=2,
src_name, fd = field
drawstyle = drawstyles.get(fd, None)
state_codes = ds.state_codes.get(field, None)
if not plot_bad:
mask = ds[field].mask
else:
mask = slice(None, None, None)
if state_codes is None:
y = ds[field].value
y = ds[field].value[mask]
else:
state_codes = [(v, k) for k, v in state_codes.items()]
y = convert_state_code(ds, field)
y = convert_state_code(ds, field)[mask]
if src_name == "states":
tstart, tstop = ds[field].times
x = pointpair(tstart.value, tstop.value)
y = pointpair(y)
x = pointpair(tstart.value[mask], tstop.value[mask])
y = pointpair(y[mask])
else:
x = ds[field].times.value
x = ds[field].times.value[mask]
label = ds.fields[field].display_name
if not plot_bad:
mask = ds[field].mask
x = x[mask]
y = y[mask]
else:
mask = slice(None, None, None)
ticklocs, 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,
label=label)
self.lines.append(ax.lines[-1])
self.y[field] = ds[field][mask]
self.times[field] = ds[field].times[mask]
self.times[field] = ds[field][mask].times
self.fig = fig
self.ax = ax
self.ds = ds
Expand Down Expand Up @@ -566,28 +564,26 @@ def __init__(self, ds, fields, field2=None, lw=2, ls='-', ls2='-', lw2=2,
self.ax2 = self.ax.twinx()
drawstyle = drawstyles.get(fd2, None)
state_codes = ds.state_codes.get(field2, None)
if not plot_bad:
mask2 = ds[field2].mask
else:
mask2 = slice(None, None, None)
if state_codes is None:
y2 = ds[field2].value
y2 = ds[field2].value[mask2]
else:
state_codes = [(v, k) for k, v in state_codes.items()]
y2 = convert_state_code(ds, field2)
y2 = convert_state_code(ds, field2)[mask2]
if src_name2 == "states":
tstart, tstop = ds[field2].times
x = pointpair(tstart.value, tstop.value)
y2 = pointpair(y2)
x2 = pointpair(tstart.value[mask2], tstop.value[mask2])
y2 = pointpair(y2[mask2])
else:
x = ds[field2].times.value
if not plot_bad:
mask = ds[field].mask
x = x[mask]
y2 = y2[mask]
else:
mask = slice(None, None, None)
plot_cxctime(x, y2, fig=fig, ax=self.ax2, ls=ls2,
x2 = ds[field2].times.value[mask2]
plot_cxctime(x2, y2, fig=fig, ax=self.ax2, ls=ls2,
lw=lw2, drawstyle=drawstyle, color=color2,
state_codes=state_codes)
self.times[field2] = ds[field2].times[mask]
self.y[field2] = ds[field2][mask]
self.times[field2] = ds[field2][mask2].times
self.y[field2] = ds[field2][mask2]
for label in self.ax2.get_xticklabels():
label.set_fontproperties(fontProperties)
for label in self.ax2.get_yticklabels():
Expand Down
19 changes: 14 additions & 5 deletions doc/source/Thermal_Models.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from acispy import SimulateCTIRun, ThermalModelRunner, DatePlot\n",
Expand Down Expand Up @@ -90,7 +92,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"dea_model = ThermalModelRunner(\"1deamzt\", \"2015:002:00:00:00\", \"2015:005:00:00:00\", states=states, T_init=Tinit)"
Expand All @@ -115,7 +119,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"dp = DatePlot(dea_model, (\"model\",\"1deamzt\"), field2=\"ccd_count\")\n",
Expand Down Expand Up @@ -177,6 +183,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"scrolled": false
},
"outputs": [],
Expand All @@ -201,7 +208,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"dpa_model = ThermalModelRunner(\"1dpamzt\", \"2015:074:12:05:00.100\", \"2015:080:13:07:45.234\", include_bad_times=True)"
Expand All @@ -220,7 +229,7 @@
"metadata": {},
"outputs": [],
"source": [
"dp = DatePlot(dpa_model, [(\"msids\", \"1dpamzt\"), (\"model\", \"1dpamzt\")])"
"dp = DatePlot(dpa_model, [(\"msids\", \"1dpamzt\"), (\"model\", \"1dpamzt\")], plot_bad=True)"
]
},
{
Expand Down

0 comments on commit bc3293f

Please sign in to comment.