Skip to content

Commit

Permalink
Merge pull request #10 from jzuhone/json_limits
Browse files Browse the repository at this point in the history
Use thermal limits from JSON files, support ACIS FP in SimulateECSRun, new "attitude" argument
  • Loading branch information
jzuhone authored Jan 27, 2022
2 parents 4fdceb1 + ab99ee1 commit 49fc73c
Show file tree
Hide file tree
Showing 8 changed files with 1,644 additions and 327 deletions.
2 changes: 1 addition & 1 deletion acispy/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def set_xlim(self, xmin, xmax):
xmax = datetime.strptime(CxoTime(xmax).iso, datefmt)
self.ax.set_xlim(xmin, xmax)

def add_hline(self, y, lw=2, ls='-', color='green',
def add_hline(self, y, lw=2, ls='-', color='green',
xmin=None, xmax=None, **kwargs):
"""
Add a horizontal line on the y-axis of the plot.
Expand Down
18 changes: 7 additions & 11 deletions acispy/states.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from astropy.io import ascii
import requests
from acispy.units import get_units
from acispy.utils import ensure_list, find_load, calc_off_nom_rolls
from acispy.utils import ensure_list, find_load, calc_off_nom_rolls, \
dict_to_array
from acispy.units import APQuantity, APStringArray, Quantity
from acispy.time_series import TimeSeriesData
import numpy as np
from collections import OrderedDict
from cxotime import CxoTime

cmd_state_codes = {("states", "hetg"): {"RETR": 0, "INSR": 1},
Expand All @@ -15,9 +15,9 @@
("states", "instrument"): {"ACIS-S": 0, "ACIS-I": 1,
"HRC-S": 2, "HRC-I": 3},
("states", "dither"): {"DISA": 0, "ENAB": 1},
("states", "pcad_mode"): {"STBY": 0, "NPNT": 1,
"NMAN": 2, "NSUN": 3,
"PWRF": 4, "RMAN": 5,
("states", "pcad_mode"): {"STBY": 0, "NPNT": 1,
"NMAN": 2, "NSUN": 3,
"PWRF": 4, "RMAN": 5,
"NULL": 6}}

state_dtypes = {"ccd_count": "int",
Expand All @@ -30,7 +30,7 @@ class States(TimeSeriesData):

def __init__(self, table):
import numpy.lib.recfunctions as rf
new_table = OrderedDict()
new_table = {}
if isinstance(table, np.ndarray):
state_names = list(table.dtype.names)
if "date" in state_names:
Expand Down Expand Up @@ -127,11 +127,7 @@ def get_states(self, time):
return state

def as_array(self):
dtype = [(k, str(v.dtype)) for k, v in self.table.items()]
data = np.zeros(len(self), dtype=dtype)
for k, v in self.table.items():
data[k] = v.value
return data
return dict_to_array(self.table)

@property
def current_states(self):
Expand Down
441 changes: 441 additions & 0 deletions acispy/tests/fptemp_ecs.dat

Large diffs are not rendered by default.

38 changes: 27 additions & 11 deletions acispy/tests/test_thermal_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,35 @@ def test_single_state(answer_store):
func(tm["states", k][0], v)


def test_ecs_run():
def test_ecs_run(answer_store):
tm = SimulateECSRun("1deamzt", "2016:201:05:12:03", 24, 14.0,
150., 5, off_nom_roll=-6.0)
(150., -6.0), 5)
for field in tm.field_list:
if field[0] == "states":
assert tm[field].size == 1
t = ascii.read(test_dir / "single_ecs.dat")
assert_allclose_nounits(t["1deamzt"].data, tm["1deamzt"])
assert_allclose_nounits(t["time"].data, tm["1deamzt"].times)
assert_equal_nounits(t["date"].data, tm["1deamzt"].dates)
if answer_store:
tm.write_model(test_dir / "single_ecs.dat", overwrite=True)
else:
t = ascii.read(test_dir / "single_ecs.dat")
assert_allclose_nounits(t["1deamzt"].data, tm["1deamzt"])
assert_allclose_nounits(t["time"].data, tm["1deamzt"].times)
assert_equal_nounits(t["date"].data, tm["1deamzt"].dates)
tm2 = SimulateECSRun("1deamzt", "2017:256:03:20:00", 24, 14.0,
0.0, 5, vehicle_load="SEP0917C")
t2 = ascii.read(test_dir / "vehicle_ecs.dat")
assert_allclose_nounits(t2["1deamzt"].data, tm2["1deamzt"])
assert_allclose_nounits(t2["time"].data, tm2["1deamzt"].times)
assert_equal_nounits(t2["date"].data, tm2["1deamzt"].dates)
"SEP0917C", 5)
if answer_store:
tm2.write_model(test_dir / "vehicle_ecs.dat", overwrite=True)
else:
t2 = ascii.read(test_dir / "vehicle_ecs.dat")
assert_allclose_nounits(t2["1deamzt"].data, tm2["1deamzt"])
assert_allclose_nounits(t2["time"].data, tm2["1deamzt"].times)
assert_equal_nounits(t2["date"].data, tm2["1deamzt"].dates)
tm3 = SimulateECSRun("fptemp_11", "2020:148:14:45:00", 24, -115.0,
[-0.04470333, 0.63502552, -0.67575906, 0.37160988],
4, instrument="ACIS-S")
if answer_store:
tm3.write_model(test_dir / "fptemp_ecs.dat", overwrite=True)
else:
t3 = ascii.read(test_dir / "fptemp_ecs.dat")
assert_allclose_nounits(t3["fptemp_11"].data, tm3["fptemp_11"])
assert_allclose_nounits(t3["time"].data, tm3["fptemp_11"].times)
assert_equal_nounits(t3["date"].data, tm3["fptemp_11"].dates)
Loading

0 comments on commit 49fc73c

Please sign in to comment.