Skip to content

Commit

Permalink
Fixing last bits
Browse files Browse the repository at this point in the history
  • Loading branch information
jzuhone committed Jul 7, 2021
1 parent 0caabc1 commit 74e9431
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
1 change: 1 addition & 0 deletions acispy/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from acispy.units import get_units
import numpy as np
import Ska.engarchive.fetch_sci as fetch
from cxotime import CxoTime


class Dataset(object):
Expand Down
4 changes: 2 additions & 2 deletions acispy/model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import requests
from astropy.io import ascii
import Ska.Numpy
from acispy.utils import get_time, mylog, find_load
from acispy.utils import mylog, find_load
from acispy.units import APQuantity, Quantity, get_units
from acispy.utils import ensure_list
from acispy.time_series import TimeSeriesData
Expand Down Expand Up @@ -121,7 +121,7 @@ def from_load_file(cls, temps_file, esa_file=None):
return cls(table=data)

def get_values(self, time):
time = get_time(time, fmt='secs')
time = CxoTime(time).secs
t = Quantity(time, "s")
values = {}
for key in self.keys():
Expand Down
25 changes: 13 additions & 12 deletions acispy/thermal_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,8 @@ def _compute_model(self, name, tstart, tstop, dt, T_init, states,
state_names = states.dtype.names
else:
state_names = list(states.keys())
state_times = date2secs(np.array([states["datestart"], states["datestop"]]))
state_times = CxoTime(
np.array([states["datestart"], states["datestop"]])).secs
for k in state_names:
if k in model.comp:
model.comp[k].set_data(states[k], state_times)
Expand Down Expand Up @@ -778,15 +779,15 @@ def from_backstop(cls, name, backstop_file, days=3, T_init=None,
"""
bs_cmds = commands.get_cmds_from_backstop(backstop_file)
bs_dates = bs_cmds["date"]
bs_cmds['time'] = DateTime(bs_cmds['date']).secs
bs_cmds['time'] = CxoTime(bs_cmds['date']).secs
last_tlm_date = fetch.get_time_range(name, format='date')[1]
last_tlm_time = DateTime(last_tlm_date).secs
last_tlm_time = CxoTime(last_tlm_date).secs
tstart = min(last_tlm_time-3600.0, bs_cmds['time'][0]-days*86400.)
if T_init is None:
T_init = fetch.MSID(name, tstart).vals[-1]
ok = bs_cmds['event_type'] == 'RUNNING_LOAD_TERMINATION_TIME'
if np.any(ok):
rltt = DateTime(bs_dates[ok][0])
rltt = CxoTime(bs_dates[ok][0])
else:
# Handle the case of old loads (prior to backstop 6.9) where there
# is no RLTT. If the first command is AOACRSTD this indicates the
Expand All @@ -795,9 +796,9 @@ def from_backstop(cls, name, backstop_file, days=3, T_init=None,
# forward by 3 minutes (exactly 180.0 sec). If the first command is
# not AOACRSTD then that command time is used as RLTT.
if bs_cmds['tlmsid'][0] == 'AOACRSTD':
rltt = DateTime(bs_cmds['time'][0] + 180)
rltt = CxoTime(bs_cmds['time'][0] + 180)
else:
rltt = DateTime(bs_cmds['date'][0])
rltt = CxoTime(bs_cmds['date'][0])

# Get non-backstop commands for continuity
cmds = commands.get_cmds(tstart, rltt, inclusive_stop=True)
Expand Down Expand Up @@ -840,7 +841,7 @@ def make_solarheat_plot(self, node, figfile=None, fig=None):
ax.set_xlabel("Pitch (deg)", fontsize=18)
ax.set_ylabel("SolarHeat", fontsize=18)
ax.lines[1].set_label("P")
ax.lines[3].set_label("P+dP")
ax.lines[2].set_label("P+dP")
ax.legend(fontsize=18)
ax.tick_params(width=2, length=6)
for axis in ['top', 'bottom', 'left', 'right']:
Expand Down Expand Up @@ -1027,10 +1028,10 @@ def __init__(self, name, tstart, tstop, states, T_init, model_spec=None,
raise KeyError(f"You input a state ('{k}') which does not exist!")
if name in short_name_rev:
name = short_name_rev[name]
tstart = DateTime(tstart).secs
datestart = DateTime(tstart).date
tstop = DateTime(tstop).secs
datestop = DateTime(tstop).date
tstart = CxoTime(tstart).secs
datestart = CxoTime(tstart).date
tstop = CxoTime(tstop).secs
datestop = CxoTime(tstop).date
_states["datestart"] = np.array([datestart])
_states["datestop"] = np.array([datestop])
_states["tstart"] = np.array([tstart])
Expand Down Expand Up @@ -1179,7 +1180,7 @@ def __init__(self, name, tstart, hours, T_init, pitch, ccd_count,
mylog.info(f"Detector Housing Heater: {dhh}")

self.tend = tend
self.dateend = secs2date(tend)
self.dateend = CxoTime(tend).date

mylog.info("Model Result")
mylog.info("------------")
Expand Down
2 changes: 1 addition & 1 deletion acispy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,5 +214,5 @@ def plotdate2cxctime(dates):
"""
from cxotime import CxoTime
# Find the cxctime of first time and use a relative offset from there
cxctime0 = CxoTime(dates[0], format='plotdate').secs
cxctime0 = CxoTime(dates[0], format='plot_date').secs
return (np.asarray(dates) - dates[0]) * 86400. + cxctime0

0 comments on commit 74e9431

Please sign in to comment.