Thermal Models API¶
- class acispy.thermal_models.ThermalModelRunner(name, tstart, tstop, states=None, T_init=None, other_init=None, get_msids=False, dt=328.0, model_spec=None, mask_bad_times=False, ephem_file=None, evolve_method=None, rk4=None, tl_file=None, compute_model_supp=None, no_eclipse=False, chandra_models_path=None, chandra_models_version=None)[source]¶
Class for running Xija thermal models.
- Parameters:
name (string) – The name of the MSID to simulate, e.g. “1dpamzt”
tstart (string) – The start time in YYYY:DOY:HH:MM:SS format.
tstop (string) – The stop time in YYYY:DOY:HH:MM:SS format.
states (dict, optional) – A dictionary of modeled commanded states required for the model. The states can either be a constant value or NumPy arrays. If not supplied, the thermal model will be run with states from the commanded states database.
T_init (float, optional) – The initial temperature for the thermal model run. If None, an initial temperature will be determined from telemetry. Default: None
other_init (dict, optional) – A dictionary of names of nodes (such as pseudo-nodes) and initial values, which can be supplied to initialize these nodes for the start of the model run. Default: None
get_msids (boolean, optional) – Whether to pull data from the engineering archive. Default: False
dt (float, optional) – The timestep to use for this run. Default is 328 seconds or is provided by the model specification file.
model_spec (string, optional) – Path to the model spec JSON file for the model. Default: None, the standard model path will be used.
mask_bad_times (boolean, optional) – If set, bad times from the data are included in the array masks and plots. Default: False
ephem_file (string, optional) – An AstroPy ASCII table containing a custom ephemeris. Must have the following columns: times: CXC seconds orbitephem0_x: Chandra orbit ephemeris x-component in units of m orbitephem0_y: Chandra orbit ephemeris y-component in units of m orbitephem0_z: Chandra orbit ephemeris z-component in units of m solarephem0_x: Solar orbit ephemeris x-component in units of m solarephem0_y: Solar orbit ephemeris y-component in units of m solarephem0_z: Solar orbit ephemeris z-component in units of m Default : None, which means the ephemeris will be taken from the cheta archive.
evolve_method (integer, optional) – Whether to use the old xija core solver (1) or the new one (2). Default: None, which defaults to the value in the model spec file.
rk4 (integer, optional) – Whether to use 4th-order Runge-Kutta (1) instead of 2nd order (0). Only works with evolve_method=2. Default: None, which defaults to the value in the model spec file.
tl_file (string, optional) – The path to a tracelog file which will supply MSID information if
use_msids=True
. Default: Nonecompute_model_supp (callable, optional) – A function which takes the model name, tstart, tstop, and a XijaModel object, and allows the user to perform custom operations on the model.
no_eclipse (boolean, optional) – If True, eclipses will be ignored. Default: False
chandra_models_path (str, optional) – The path to the chandra_models repository to be used when obtaining a model specification file. Default: $SKA/data/chandra_models
chandra_models_version (str, optional) – The version of the chandra_models repository to be used when obtaining a model specification file. Can be a version number or a named branch. Default is to use the latest tagged version.
Examples
>>> states = {"ccd_count": np.array([5, 6, 1]), ... "pitch": np.array([150.0] * 3), ... "fep_count": np.array([5, 6, 1]), ... "clocking": np.array([1] * 3), ... "vid_board": np.array([1] * 3), ... "off_nom_roll": np.array([0.0] * 3), ... "simpos": np.array([-99616.0] * 3), ... "datestart": np.array(["2015:002:00:00:00", "2015:002:12:00:00", "2015:003:12:00:00"]), ... "datestop": np.array(["2015:002:12:00:00", "2015:003:12:00:00", "2015:005:00:00:00"])} >>> dpa_model = ThermalModelRunner("1dpamzt", "2015:002:00:00:00", ... "2015:005:00:00:00", states=states, ... T_init=10.1)
- add_averaged_field(field, n=10)¶
Add a new field from an average of another.
- Parameters:
Examples
>>> ds.add_averaged_field(("msids", "1dpicacu"), n=10)
- add_derived_field(ftype, fname, function, units, display_name=None, depends=None)¶
Add a new derived field.
- Parameters:
ftype (string) – The type of the field to add.
fname (string) – The name of the field to add.
function (function) – The function which computes the field.
units (string) – The units of the field.
times (array or tuple) – The timing data for the field in seconds from the beginning of the mission. Can supply an array of times or a field specification. If the latter, then the times for this field will be used.
display_name (string, optional) – The name to use when displaying the field in plots.
Examples
>>> def _dpaa_power(ds): ... return (ds["msids", "1dp28avo"]*ds["msids", "1dpicacu"]).to("W") >>> ds.add_derived_field("msids", "dpa_a_power", _dpaa_power, ... "W", display_name="DPA-A Power")
- add_diff_data_model_field(msid, ftype_model='model')¶
Create a field which gives the difference between the data and the model for a particular MSID.
- Parameters:
msid (string) – The MSID to take the diff of data and model of.
ftype_model (string, optional) – The model type (e.g., “model”, “model0”, etc.) of the model field to be diffed with the MSID.
- dates(*args)¶
Return the timing information in date and time for a field.
Examples
>>> ds.dates("states", "pitch")
- classmethod from_backstop(name, backstop_file, days=3, T_init=None, other_cmds=None, **kwargs)[source]¶
Run a thermal model using states derived from a backstop file. Continuity with previous states will be automatically handled.
- Parameters:
name (string) – The name of the MSID to simulate, e.g. “1dpamzt”
backstop_file (string) – The path to the backstop file.
days (float) – The number of days to go back from the first command in the backstop file to get the initial state. Default: 3
T_init (float, optional) – The initial temperature for the thermal model run. If None, an initial temperature will be determined from telemetry. Default: None
other_cmds (list of commands or CommandTable) – Other commands to be included in the list.
Notes
All other keyword arguments which are passed to the main
ThermalModelRunner
constructor can be passed to this method as well.
- classmethod from_commands(name, cmds, **kwargs)[source]¶
- Parameters:
name (string) – The name of the MSID to simulate, e.g. “1dpamzt”
cmds (list of commands or CommandTable) – The commands from which to derive states.
Notes
All other keyword arguments which are passed to the main
ThermalModelRunner
constructor can be passed to this method as well.
- classmethod from_states_file(name, states_file, **kwargs)[source]¶
Run a xija thermal model using a states.dat file.
- Parameters:
name (string) – The name of the MSID to simulate, e.g. “1dpamzt”
states_file (string) – A file containing commanded states, in the same format as “states.dat” which is outputted by ACIS thermal model runs for loads.
Notes
All other keyword arguments which are passed to the main
ThermalModelRunner
constructor can be passed to this method as well.
- make_dashboard_plots(msid, tstart=None, tstop=None, yplotlimits=None, errorplotlimits=None, fig=None, figfile=None, bad_times=None, mask_radzones=False, plot_limits=True, mask_fmt1=False)¶
Make dashboard plots for the particular thermal model.
- Parameters:
msid (string) – The MSID name to plot in the dashboard.
tstart (string, optional) – The start time of the data for the dashboard plot. If not specified, the beginning of the thermal model run is used.
tstop (string, optional) – The stop time of the data for the dashboard plot. If not specified, the end of the thermal model run is used.
yplotlimits (two-element array_like, optional) – The (min, max) bounds on the temperature to use for the temperature vs. time plot. Default: Determine the min/max bounds from the telemetry and model prediction and decrease/increase by degrees to determine the plot limits.
errorplotlimits (two-element array_like, optional) – The (min, max) error bounds to use for the error plot. Default: [-15, 15]
fig (
Figure
, optional) – A Figure instance to plot in. Default: None, one will be created if not provided.figfile (string, optional) – The file to write the dashboard plot to. One will be created if not provided.
bad_times (list of tuples, optional) – Provide a set of times to exclude from the creation of the dashboard plot.
mask_radzones (boolean, optional) – If True, mask out radzone periods for dashboard plots of the focal plane model. Default: False
plot_limits (boolean, optional) – If True, plot the yellow caution and planning limits on the dashboard plots. Default: True
- make_power_plot(figfile=None, fig=None, use_ccd_count=False)[source]¶
Make a plot which shows the ACIS state power coefficients, vs. either FEP or CCD count.
- Parameters:
figfile (string, optional) – The file to write the power coefficient plot to. One will be created if not provided.
fig (
Figure
, optional) – A Figure instance to plot in. Default: None, one will be created if not provided.use_ccd_count (boolean, optional) – If True, plot the CCD count on the x-axis. Primarily useful for the 1DEAMZT model. Default: False
- make_solarheat_plot(node, figfile=None, fig=None)[source]¶
Make a plot which shows the solar heat values vs. pitch.
- Parameters:
node (string) – The xija node which has the solar heating applied to it in the model. Can be an real node on the spacecraft like 1DEAMZT or a pseudo-node like “dpa0” in the 1DPAMZT model.
figfile (string, optional) – The file to write the solar heating plot to. One will be created if not provided.
fig (
Figure
, optional) – A Figure instance to plot in. Default: None, one will be created if not provided.
- map_state_to_msid(state, msid, ftype='msids')¶
Create a new derived field by interpolating a state to the times of a MSID or model component.
- Parameters:
state (string) – The state to be interpolated.
msid (string) – The msid or model component to interpolate the state to.
ftype (string, optional) – The field type to use. “msids” or “model”. Default: “msids”
Examples
>>> ds.map_state_to_msid("ccd_count", "1dpamzt")
- plot(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)¶
Make a single-panel plot of a quantity (or multiple quantities) vs. date and time from this Dataset.
Multiple quantities can be plotted on the left y-axis together if they have the same units, otherwise a quantity with different units can be plotted on the right y-axis.
- Parameters:
fields (tuple of strings or list of tuples of strings) – A single field or list of fields to plot on the left y-axis.
field2 (tuple of strings, optional) – A single field to plot on the right y-axis. Default: None
lw (float or list of floats, optional) – The width of the lines in the plots. If a list, the length of a the list must be equal to the number of fields. If a single number, it will apply to all plots. Default: 2 px.
ls (string, optional) – The line style of the lines plotted on the left y-axis. Can be a single linestyle or more than one for each line. Default: ‘-’
ls2 (string, optional) – The line style of the line plotted on the right y-axis. Can be a single linestyle or more than one for each line. Default: ‘-’
lw2 (float, optional) – The width of the line plotted on the right y-axis.
fontsize (integer, optional) – The font size for the labels in the plot. Default: 18 pt.
color (list of strings, optional) – The colors for the lines plotted on the left y-axis. Can be a single color or more than one in a list. Default: Use the default Matplotlib order of colors.
color2 (string, optional) – The color for the line plotted on the right y-axis. Default: “magenta”
fig (
Figure
, optional) – A Figure instance to plot in. Default: None, one will be created if not provided.figsize (tuple of integers, optional) – The size of the plot in (width, height) in inches. Default: (10, 8)
plot (
DatePlot
orCustomDatePlot
, optional) – An existing DatePlot to add this plot to. Default: None, one will be created if not provided.plot_bad (boolean, optional) – If True, “bad” values will be plotted but the ranges of bad values will be marked with translucent blue rectangles. If False, bad values will be removed from the plot. Default: False
- times(*args)¶
Return the timing information in seconds from the beginning of the mission for a field.
Examples
>>> ds.times("msids", "1deamzt")
- write_model(filename, overwrite=False)¶
Write the model data vs. time to an ASCII text file.
- Parameters:
filename (string) – The filename to write the data to.
overwrite (boolean, optional) – If True, an existing file with the same name will be overwritten.
- write_model_and_data(filename, overwrite=False, mask_radzones=False, mask_fmt1=False, mask_badtimes=True, tstart=None, tstop=None)¶
Write the model, telemetry, and states data vs. time to an ASCII text file. The state data is interpolated to the times of the model so that everything is at a common set of times.
- Parameters:
filename (string) – The filename to write the data to.
overwrite (boolean, optional) – If True, an existing file with the same name will be overwritten.
- write_msids(filename, fields, mask=None, overwrite=False)¶
Write MSIDs (or MSID-like quantities such as model values) to an ASCII table file. This assumes that all of the quantities have been interpolated to a common set of times.
- write_states(filename, overwrite=False)¶
Write commanded states to an ASCII table file. An error will be thrown if there are no commanded states present.
- Parameters:
filename (string) – The filename to write the states to.
overwrite (boolean, optional) – If True, an existing file with the same name will be overwritten.
- class acispy.thermal_models.ThermalModelFromLoad(load, comps=None, get_msids=False, tl_file=None, states_comp='DPA')[source]¶
Fetch a temperature model and its associated commanded states from a load review. Optionally get MSIDs for the same time period. If MSID data will be added, it will be interpolated to the times of the model data.
- Parameters:
load (string) – The load review to get the model from, i.e. “JAN2516A”.
comps (list of strings, optional) – List of temperature components to get from the load models. If not specified all four components will be loaded.
get_msids (boolean, optional) – Whether to load the MSIDs corresponding to the temperature models for the same time period from the engineering archive. Default: False.
states_comp (string, optional) – The thermal model page to use to get the states. “DEA”, “DPA”, “PSMC”, or “FP”. Default: “DPA”
Examples
>>> from acispy import ThermalModelFromLoad >>> comps = ["1deamzt", "1pdeaat", "fptemp_11"] >>> ds = ThermalModelFromLoad("APR0416C", comps, get_msids=True)
- add_averaged_field(field, n=10)¶
Add a new field from an average of another.
- Parameters:
Examples
>>> ds.add_averaged_field(("msids", "1dpicacu"), n=10)
- add_derived_field(ftype, fname, function, units, display_name=None, depends=None)¶
Add a new derived field.
- Parameters:
ftype (string) – The type of the field to add.
fname (string) – The name of the field to add.
function (function) – The function which computes the field.
units (string) – The units of the field.
times (array or tuple) – The timing data for the field in seconds from the beginning of the mission. Can supply an array of times or a field specification. If the latter, then the times for this field will be used.
display_name (string, optional) – The name to use when displaying the field in plots.
Examples
>>> def _dpaa_power(ds): ... return (ds["msids", "1dp28avo"]*ds["msids", "1dpicacu"]).to("W") >>> ds.add_derived_field("msids", "dpa_a_power", _dpaa_power, ... "W", display_name="DPA-A Power")
- add_diff_data_model_field(msid, ftype_model='model')¶
Create a field which gives the difference between the data and the model for a particular MSID.
- Parameters:
msid (string) – The MSID to take the diff of data and model of.
ftype_model (string, optional) – The model type (e.g., “model”, “model0”, etc.) of the model field to be diffed with the MSID.
- dates(*args)¶
Return the timing information in date and time for a field.
Examples
>>> ds.dates("states", "pitch")
- make_dashboard_plots(msid, tstart=None, tstop=None, yplotlimits=None, errorplotlimits=None, fig=None, figfile=None, bad_times=None, mask_radzones=False, plot_limits=True, mask_fmt1=False)¶
Make dashboard plots for the particular thermal model.
- Parameters:
msid (string) – The MSID name to plot in the dashboard.
tstart (string, optional) – The start time of the data for the dashboard plot. If not specified, the beginning of the thermal model run is used.
tstop (string, optional) – The stop time of the data for the dashboard plot. If not specified, the end of the thermal model run is used.
yplotlimits (two-element array_like, optional) – The (min, max) bounds on the temperature to use for the temperature vs. time plot. Default: Determine the min/max bounds from the telemetry and model prediction and decrease/increase by degrees to determine the plot limits.
errorplotlimits (two-element array_like, optional) – The (min, max) error bounds to use for the error plot. Default: [-15, 15]
fig (
Figure
, optional) – A Figure instance to plot in. Default: None, one will be created if not provided.figfile (string, optional) – The file to write the dashboard plot to. One will be created if not provided.
bad_times (list of tuples, optional) – Provide a set of times to exclude from the creation of the dashboard plot.
mask_radzones (boolean, optional) – If True, mask out radzone periods for dashboard plots of the focal plane model. Default: False
plot_limits (boolean, optional) – If True, plot the yellow caution and planning limits on the dashboard plots. Default: True
- map_state_to_msid(state, msid, ftype='msids')¶
Create a new derived field by interpolating a state to the times of a MSID or model component.
- Parameters:
state (string) – The state to be interpolated.
msid (string) – The msid or model component to interpolate the state to.
ftype (string, optional) – The field type to use. “msids” or “model”. Default: “msids”
Examples
>>> ds.map_state_to_msid("ccd_count", "1dpamzt")
- plot(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)¶
Make a single-panel plot of a quantity (or multiple quantities) vs. date and time from this Dataset.
Multiple quantities can be plotted on the left y-axis together if they have the same units, otherwise a quantity with different units can be plotted on the right y-axis.
- Parameters:
fields (tuple of strings or list of tuples of strings) – A single field or list of fields to plot on the left y-axis.
field2 (tuple of strings, optional) – A single field to plot on the right y-axis. Default: None
lw (float or list of floats, optional) – The width of the lines in the plots. If a list, the length of a the list must be equal to the number of fields. If a single number, it will apply to all plots. Default: 2 px.
ls (string, optional) – The line style of the lines plotted on the left y-axis. Can be a single linestyle or more than one for each line. Default: ‘-’
ls2 (string, optional) – The line style of the line plotted on the right y-axis. Can be a single linestyle or more than one for each line. Default: ‘-’
lw2 (float, optional) – The width of the line plotted on the right y-axis.
fontsize (integer, optional) – The font size for the labels in the plot. Default: 18 pt.
color (list of strings, optional) – The colors for the lines plotted on the left y-axis. Can be a single color or more than one in a list. Default: Use the default Matplotlib order of colors.
color2 (string, optional) – The color for the line plotted on the right y-axis. Default: “magenta”
fig (
Figure
, optional) – A Figure instance to plot in. Default: None, one will be created if not provided.figsize (tuple of integers, optional) – The size of the plot in (width, height) in inches. Default: (10, 8)
plot (
DatePlot
orCustomDatePlot
, optional) – An existing DatePlot to add this plot to. Default: None, one will be created if not provided.plot_bad (boolean, optional) – If True, “bad” values will be plotted but the ranges of bad values will be marked with translucent blue rectangles. If False, bad values will be removed from the plot. Default: False
- times(*args)¶
Return the timing information in seconds from the beginning of the mission for a field.
Examples
>>> ds.times("msids", "1deamzt")
- write_model(filename, overwrite=False)¶
Write the model data vs. time to an ASCII text file.
- Parameters:
filename (string) – The filename to write the data to.
overwrite (boolean, optional) – If True, an existing file with the same name will be overwritten.
- write_model_and_data(filename, overwrite=False, mask_radzones=False, mask_fmt1=False, mask_badtimes=True, tstart=None, tstop=None)¶
Write the model, telemetry, and states data vs. time to an ASCII text file. The state data is interpolated to the times of the model so that everything is at a common set of times.
- Parameters:
filename (string) – The filename to write the data to.
overwrite (boolean, optional) – If True, an existing file with the same name will be overwritten.
- write_msids(filename, fields, mask=None, overwrite=False)¶
Write MSIDs (or MSID-like quantities such as model values) to an ASCII table file. This assumes that all of the quantities have been interpolated to a common set of times.
- write_states(filename, overwrite=False)¶
Write commanded states to an ASCII table file. An error will be thrown if there are no commanded states present.
- Parameters:
filename (string) – The filename to write the states to.
overwrite (boolean, optional) – If True, an existing file with the same name will be overwritten.
- class acispy.thermal_models.ThermalModelFromRun(loc, get_msids=False, tl_file=None)[source]¶
Fetch multiple temperature models and their associated commanded states from ASCII table files generated by xija or model check tools. If MSID data will be added, it will be interpolated to the times of the model data.
- Parameters:
loc (string or list of strings) – Path to the directory where the model and state data are stored.
get_msids (boolean, optional) – Whether to load the MSIDs corresponding to the temperature models for the same time period from the engineering archive. Default: False.
tl_file (string) – Path to the location of the tracelog file to get the MSID data from. Default: None, which means the engineering archive will be queried if get_msids=True.
Examples
>>> from acispy import ThermalModelFromRun >>> ds = ThermalModelFromRun("/data/acis/LoadReviews/2019/MAY2019/ofls/out_dpa", ... get_msids=True)
- add_averaged_field(field, n=10)¶
Add a new field from an average of another.
- Parameters:
Examples
>>> ds.add_averaged_field(("msids", "1dpicacu"), n=10)
- add_derived_field(ftype, fname, function, units, display_name=None, depends=None)¶
Add a new derived field.
- Parameters:
ftype (string) – The type of the field to add.
fname (string) – The name of the field to add.
function (function) – The function which computes the field.
units (string) – The units of the field.
times (array or tuple) – The timing data for the field in seconds from the beginning of the mission. Can supply an array of times or a field specification. If the latter, then the times for this field will be used.
display_name (string, optional) – The name to use when displaying the field in plots.
Examples
>>> def _dpaa_power(ds): ... return (ds["msids", "1dp28avo"]*ds["msids", "1dpicacu"]).to("W") >>> ds.add_derived_field("msids", "dpa_a_power", _dpaa_power, ... "W", display_name="DPA-A Power")
- add_diff_data_model_field(msid, ftype_model='model')¶
Create a field which gives the difference between the data and the model for a particular MSID.
- Parameters:
msid (string) – The MSID to take the diff of data and model of.
ftype_model (string, optional) – The model type (e.g., “model”, “model0”, etc.) of the model field to be diffed with the MSID.
- dates(*args)¶
Return the timing information in date and time for a field.
Examples
>>> ds.dates("states", "pitch")
- make_dashboard_plots(msid, tstart=None, tstop=None, yplotlimits=None, errorplotlimits=None, fig=None, figfile=None, bad_times=None, mask_radzones=False, plot_limits=True, mask_fmt1=False)¶
Make dashboard plots for the particular thermal model.
- Parameters:
msid (string) – The MSID name to plot in the dashboard.
tstart (string, optional) – The start time of the data for the dashboard plot. If not specified, the beginning of the thermal model run is used.
tstop (string, optional) – The stop time of the data for the dashboard plot. If not specified, the end of the thermal model run is used.
yplotlimits (two-element array_like, optional) – The (min, max) bounds on the temperature to use for the temperature vs. time plot. Default: Determine the min/max bounds from the telemetry and model prediction and decrease/increase by degrees to determine the plot limits.
errorplotlimits (two-element array_like, optional) – The (min, max) error bounds to use for the error plot. Default: [-15, 15]
fig (
Figure
, optional) – A Figure instance to plot in. Default: None, one will be created if not provided.figfile (string, optional) – The file to write the dashboard plot to. One will be created if not provided.
bad_times (list of tuples, optional) – Provide a set of times to exclude from the creation of the dashboard plot.
mask_radzones (boolean, optional) – If True, mask out radzone periods for dashboard plots of the focal plane model. Default: False
plot_limits (boolean, optional) – If True, plot the yellow caution and planning limits on the dashboard plots. Default: True
- map_state_to_msid(state, msid, ftype='msids')¶
Create a new derived field by interpolating a state to the times of a MSID or model component.
- Parameters:
state (string) – The state to be interpolated.
msid (string) – The msid or model component to interpolate the state to.
ftype (string, optional) – The field type to use. “msids” or “model”. Default: “msids”
Examples
>>> ds.map_state_to_msid("ccd_count", "1dpamzt")
- plot(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)¶
Make a single-panel plot of a quantity (or multiple quantities) vs. date and time from this Dataset.
Multiple quantities can be plotted on the left y-axis together if they have the same units, otherwise a quantity with different units can be plotted on the right y-axis.
- Parameters:
fields (tuple of strings or list of tuples of strings) – A single field or list of fields to plot on the left y-axis.
field2 (tuple of strings, optional) – A single field to plot on the right y-axis. Default: None
lw (float or list of floats, optional) – The width of the lines in the plots. If a list, the length of a the list must be equal to the number of fields. If a single number, it will apply to all plots. Default: 2 px.
ls (string, optional) – The line style of the lines plotted on the left y-axis. Can be a single linestyle or more than one for each line. Default: ‘-’
ls2 (string, optional) – The line style of the line plotted on the right y-axis. Can be a single linestyle or more than one for each line. Default: ‘-’
lw2 (float, optional) – The width of the line plotted on the right y-axis.
fontsize (integer, optional) – The font size for the labels in the plot. Default: 18 pt.
color (list of strings, optional) – The colors for the lines plotted on the left y-axis. Can be a single color or more than one in a list. Default: Use the default Matplotlib order of colors.
color2 (string, optional) – The color for the line plotted on the right y-axis. Default: “magenta”
fig (
Figure
, optional) – A Figure instance to plot in. Default: None, one will be created if not provided.figsize (tuple of integers, optional) – The size of the plot in (width, height) in inches. Default: (10, 8)
plot (
DatePlot
orCustomDatePlot
, optional) – An existing DatePlot to add this plot to. Default: None, one will be created if not provided.plot_bad (boolean, optional) – If True, “bad” values will be plotted but the ranges of bad values will be marked with translucent blue rectangles. If False, bad values will be removed from the plot. Default: False
- times(*args)¶
Return the timing information in seconds from the beginning of the mission for a field.
Examples
>>> ds.times("msids", "1deamzt")
- write_model(filename, overwrite=False)¶
Write the model data vs. time to an ASCII text file.
- Parameters:
filename (string) – The filename to write the data to.
overwrite (boolean, optional) – If True, an existing file with the same name will be overwritten.
- write_model_and_data(filename, overwrite=False, mask_radzones=False, mask_fmt1=False, mask_badtimes=True, tstart=None, tstop=None)¶
Write the model, telemetry, and states data vs. time to an ASCII text file. The state data is interpolated to the times of the model so that everything is at a common set of times.
- Parameters:
filename (string) – The filename to write the data to.
overwrite (boolean, optional) – If True, an existing file with the same name will be overwritten.
- write_msids(filename, fields, mask=None, overwrite=False)¶
Write MSIDs (or MSID-like quantities such as model values) to an ASCII table file. This assumes that all of the quantities have been interpolated to a common set of times.
- write_states(filename, overwrite=False)¶
Write commanded states to an ASCII table file. An error will be thrown if there are no commanded states present.
- Parameters:
filename (string) – The filename to write the states to.
overwrite (boolean, optional) – If True, an existing file with the same name will be overwritten.
- class acispy.thermal_models.SimulateSingleState(name, tstart, tstop, states, T_init, model_spec=None, dt=328.0, evolve_method=None, rk4=None, no_earth_heat=False, other_init=None, compute_model_supp=None, no_eclipse=False)[source]¶
Class for simulating thermal models under constant conditions.
- Parameters:
name (string) – The name of the model to simulate.
tstart (string or float) – The start time of the single-state run.
tstop (string or float) – The stop time of the single-state run.
states (dict) – A dictionary of modeled commanded states required for the single-state run. All states must be single values. Any particular states which are not included in this dict will be filled in using the “default” states, which assume zero ACIS CCDs and FEPs, normal Sun, zero off-nominal roll, HRC-S sim position, and no gratings inserted.
T_init (float) – The starting temperature for the model in degrees C or F.
model_spec (string, optional) – Path to the model spec JSON file for the model. Default: None, the standard model path will be used.
dt (float, optional) – The timestep to use for this run. Default is 328 seconds or is provided by the model specification file.
evolve_method (integer, optional) – Whether to use the old xija core solver (1) or the new one (2). Default: None, which defaults to the value in the model spec file.
rk4 (integer, optional) – Whether to use 4th-order Runge-Kutta (1) instead of 2nd order (0). Only works with evolve_method=2. Default: None, which defaults to the value in the model spec file.
no_earth_heat (boolean, optional) – Ignore the effect of earthshine in the ACIS radiator field of view. This really only might be useful for the ACIS focal plane temperature model. Default: False
other_init (dict, optional) – A dictionary of names of nodes (such as pseudo-nodes) and initial values, which can be supplied to initialize these nodes for the start of the model run. Default: None
compute_model_supp (callable, optional) – A function which takes the model name, tstart, tstop, and a XijaModel object, and allows the user to perform custom operations on the model.
no_eclipse (boolean, optional) – If True, eclipses will be ignored. Default: False
Examples
>>> states = {"pitch": 75.0, "off_nom_roll": -6.0, "clocking": 1, ... "ccd_count": 6, "dh_heater": 1, "simpos": 75624.0,} >>> dea_run = SimulateSingleState("1deamzt", "2016:201:05:12:03", ... "2016:202:05:12:03", states, 15.0)
- add_averaged_field(field, n=10)¶
Add a new field from an average of another.
- Parameters:
Examples
>>> ds.add_averaged_field(("msids", "1dpicacu"), n=10)
- add_derived_field(ftype, fname, function, units, display_name=None, depends=None)¶
Add a new derived field.
- Parameters:
ftype (string) – The type of the field to add.
fname (string) – The name of the field to add.
function (function) – The function which computes the field.
units (string) – The units of the field.
times (array or tuple) – The timing data for the field in seconds from the beginning of the mission. Can supply an array of times or a field specification. If the latter, then the times for this field will be used.
display_name (string, optional) – The name to use when displaying the field in plots.
Examples
>>> def _dpaa_power(ds): ... return (ds["msids", "1dp28avo"]*ds["msids", "1dpicacu"]).to("W") >>> ds.add_derived_field("msids", "dpa_a_power", _dpaa_power, ... "W", display_name="DPA-A Power")
- add_diff_data_model_field(msid, ftype_model='model')¶
Create a field which gives the difference between the data and the model for a particular MSID.
- Parameters:
msid (string) – The MSID to take the diff of data and model of.
ftype_model (string, optional) – The model type (e.g., “model”, “model0”, etc.) of the model field to be diffed with the MSID.
- dates(*args)¶
Return the timing information in date and time for a field.
Examples
>>> ds.dates("states", "pitch")
- classmethod from_backstop(name, backstop_file, days=3, T_init=None, other_cmds=None, **kwargs)¶
Run a thermal model using states derived from a backstop file. Continuity with previous states will be automatically handled.
- Parameters:
name (string) – The name of the MSID to simulate, e.g. “1dpamzt”
backstop_file (string) – The path to the backstop file.
days (float) – The number of days to go back from the first command in the backstop file to get the initial state. Default: 3
T_init (float, optional) – The initial temperature for the thermal model run. If None, an initial temperature will be determined from telemetry. Default: None
other_cmds (list of commands or CommandTable) – Other commands to be included in the list.
Notes
All other keyword arguments which are passed to the main
ThermalModelRunner
constructor can be passed to this method as well.
- classmethod from_commands(name, cmds, **kwargs)¶
- Parameters:
name (string) – The name of the MSID to simulate, e.g. “1dpamzt”
cmds (list of commands or CommandTable) – The commands from which to derive states.
Notes
All other keyword arguments which are passed to the main
ThermalModelRunner
constructor can be passed to this method as well.
- classmethod from_states_file(name, states_file, **kwargs)¶
Run a xija thermal model using a states.dat file.
- Parameters:
name (string) – The name of the MSID to simulate, e.g. “1dpamzt”
states_file (string) – A file containing commanded states, in the same format as “states.dat” which is outputted by ACIS thermal model runs for loads.
Notes
All other keyword arguments which are passed to the main
ThermalModelRunner
constructor can be passed to this method as well.
- make_dashboard_plots(yplotlimits=None, errorplotlimits=None, fig=None)[source]¶
Make dashboard plots for the particular thermal model.
- Parameters:
msid (string) – The MSID name to plot in the dashboard.
tstart (string, optional) – The start time of the data for the dashboard plot. If not specified, the beginning of the thermal model run is used.
tstop (string, optional) – The stop time of the data for the dashboard plot. If not specified, the end of the thermal model run is used.
yplotlimits (two-element array_like, optional) – The (min, max) bounds on the temperature to use for the temperature vs. time plot. Default: Determine the min/max bounds from the telemetry and model prediction and decrease/increase by degrees to determine the plot limits.
errorplotlimits (two-element array_like, optional) – The (min, max) error bounds to use for the error plot. Default: [-15, 15]
fig (
Figure
, optional) – A Figure instance to plot in. Default: None, one will be created if not provided.figfile (string, optional) – The file to write the dashboard plot to. One will be created if not provided.
bad_times (list of tuples, optional) – Provide a set of times to exclude from the creation of the dashboard plot.
mask_radzones (boolean, optional) – If True, mask out radzone periods for dashboard plots of the focal plane model. Default: False
plot_limits (boolean, optional) – If True, plot the yellow caution and planning limits on the dashboard plots. Default: True
- make_power_plot(figfile=None, fig=None, use_ccd_count=False)¶
Make a plot which shows the ACIS state power coefficients, vs. either FEP or CCD count.
- Parameters:
figfile (string, optional) – The file to write the power coefficient plot to. One will be created if not provided.
fig (
Figure
, optional) – A Figure instance to plot in. Default: None, one will be created if not provided.use_ccd_count (boolean, optional) – If True, plot the CCD count on the x-axis. Primarily useful for the 1DEAMZT model. Default: False
- make_solarheat_plot(node, figfile=None, fig=None)¶
Make a plot which shows the solar heat values vs. pitch.
- Parameters:
node (string) – The xija node which has the solar heating applied to it in the model. Can be an real node on the spacecraft like 1DEAMZT or a pseudo-node like “dpa0” in the 1DPAMZT model.
figfile (string, optional) – The file to write the solar heating plot to. One will be created if not provided.
fig (
Figure
, optional) – A Figure instance to plot in. Default: None, one will be created if not provided.
- map_state_to_msid(state, msid, ftype='msids')¶
Create a new derived field by interpolating a state to the times of a MSID or model component.
- Parameters:
state (string) – The state to be interpolated.
msid (string) – The msid or model component to interpolate the state to.
ftype (string, optional) – The field type to use. “msids” or “model”. Default: “msids”
Examples
>>> ds.map_state_to_msid("ccd_count", "1dpamzt")
- plot(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)¶
Make a single-panel plot of a quantity (or multiple quantities) vs. date and time from this Dataset.
Multiple quantities can be plotted on the left y-axis together if they have the same units, otherwise a quantity with different units can be plotted on the right y-axis.
- Parameters:
fields (tuple of strings or list of tuples of strings) – A single field or list of fields to plot on the left y-axis.
field2 (tuple of strings, optional) – A single field to plot on the right y-axis. Default: None
lw (float or list of floats, optional) – The width of the lines in the plots. If a list, the length of a the list must be equal to the number of fields. If a single number, it will apply to all plots. Default: 2 px.
ls (string, optional) – The line style of the lines plotted on the left y-axis. Can be a single linestyle or more than one for each line. Default: ‘-’
ls2 (string, optional) – The line style of the line plotted on the right y-axis. Can be a single linestyle or more than one for each line. Default: ‘-’
lw2 (float, optional) – The width of the line plotted on the right y-axis.
fontsize (integer, optional) – The font size for the labels in the plot. Default: 18 pt.
color (list of strings, optional) – The colors for the lines plotted on the left y-axis. Can be a single color or more than one in a list. Default: Use the default Matplotlib order of colors.
color2 (string, optional) – The color for the line plotted on the right y-axis. Default: “magenta”
fig (
Figure
, optional) – A Figure instance to plot in. Default: None, one will be created if not provided.figsize (tuple of integers, optional) – The size of the plot in (width, height) in inches. Default: (10, 8)
plot (
DatePlot
orCustomDatePlot
, optional) – An existing DatePlot to add this plot to. Default: None, one will be created if not provided.plot_bad (boolean, optional) – If True, “bad” values will be plotted but the ranges of bad values will be marked with translucent blue rectangles. If False, bad values will be removed from the plot. Default: False
- times(*args)¶
Return the timing information in seconds from the beginning of the mission for a field.
Examples
>>> ds.times("msids", "1deamzt")
- write_model(filename, overwrite=False)¶
Write the model data vs. time to an ASCII text file.
- Parameters:
filename (string) – The filename to write the data to.
overwrite (boolean, optional) – If True, an existing file with the same name will be overwritten.
- write_model_and_data(filename, overwrite=False)[source]¶
Write the model, telemetry, and states data vs. time to an ASCII text file. The state data is interpolated to the times of the model so that everything is at a common set of times.
- Parameters:
filename (string) – The filename to write the data to.
overwrite (boolean, optional) – If True, an existing file with the same name will be overwritten.
- write_msids(filename, fields, mask_field=None, overwrite=False)[source]¶
Write MSIDs (or MSID-like quantities such as model values) to an ASCII table file. This assumes that all of the quantities have been interpolated to a common set of times.
- write_states(states_file, overwrite=False)[source]¶
Write commanded states to an ASCII table file. An error will be thrown if there are no commanded states present.
- Parameters:
filename (string) – The filename to write the states to.
overwrite (boolean, optional) – If True, an existing file with the same name will be overwritten.
- class acispy.thermal_models.SimulateECSRun(name, tstart, hours, T_init, attitude, ccd_count, dh_heater=0, dt=328.0, evolve_method=None, rk4=None, model_spec=None, no_earth_heat=False, other_init=None, compute_model_supp=None, no_eclipse=False)[source]¶
Class for simulating thermal models for ECS measurements.
- Parameters:
name (string) – The msid of the model to simulate.
tstart (string or float) – The start time of the single-state run.
hours (integer or float) – The length of the ECS measurement in hours.
T_init (float) – The starting temperature for the model in degrees C.
attitude (array_like) – The input attitude for this simulated ECS run. Can be one of three types: * (pitch, roll) combination, e.g. (155.0, 5.0) * Attitude quaternion, e.g [1.0, 0.0, 0.0, 0.0] * “vehicle” to use the vehicle load attitudes for the run. If the (pitch, roll) combination is chosen, note that a default quaternion of [1.0, 0.0, 0.0, 0.0] will be used, which means that the focal plane prediction may be inaccurate since the earth solid angle depends on the quaternion.
ccd_count (integer) – The number of CCDs to clock.
dh_heater (integer, optional) – Flag to set whether (1) or not (0) the detector housing heater is on. Default: 0
dt (float, optional) – The timestep to use for this run. Default is 328 seconds or is provided by the model specification file.
evolve_method (integer, optional) – Whether to use the old xija core solver (1) or the new one (2). Default: None, which defaults to the value in the model spec file.
rk4 (integer, optional) – Whether to use 4th-order Runge-Kutta (1) instead of 2nd order (0). Only works with evolve_method=2. Default: None, which defaults to the value in the model spec file.
model_spec (string, optional) – Path to the model spec JSON file for the model. Default: None, the standard model path will be used.
no_earth_heat (boolean, optional) – Ignore the effect of earthshine in the ACIS radiator field of view. This really only might be useful for the ACIS focal plane temperature model. Default: False
other_init (dict, optional) – A dictionary of names of nodes (such as pseudo-nodes) and initial values, which can be supplied to initialize these nodes for the start of the model run. Default: None
compute_model_supp (callable, optional) – A function which takes the model name, tstart, tstop, and a XijaModel object, and allows the user to perform custom operations on the model.
no_eclipse (boolean, optional) – If True, eclipses will be ignored. Default: False
Examples
>>> dea_run = SimulateECSRun("1deamzt", "2016:201:05:12:03", 24, 14.0, ... (150.-6.0), 5, dh_heater=1)
- add_averaged_field(field, n=10)¶
Add a new field from an average of another.
- Parameters:
Examples
>>> ds.add_averaged_field(("msids", "1dpicacu"), n=10)
- add_derived_field(ftype, fname, function, units, display_name=None, depends=None)¶
Add a new derived field.
- Parameters:
ftype (string) – The type of the field to add.
fname (string) – The name of the field to add.
function (function) – The function which computes the field.
units (string) – The units of the field.
times (array or tuple) – The timing data for the field in seconds from the beginning of the mission. Can supply an array of times or a field specification. If the latter, then the times for this field will be used.
display_name (string, optional) – The name to use when displaying the field in plots.
Examples
>>> def _dpaa_power(ds): ... return (ds["msids", "1dp28avo"]*ds["msids", "1dpicacu"]).to("W") >>> ds.add_derived_field("msids", "dpa_a_power", _dpaa_power, ... "W", display_name="DPA-A Power")
- add_diff_data_model_field(msid, ftype_model='model')¶
Create a field which gives the difference between the data and the model for a particular MSID.
- Parameters:
msid (string) – The MSID to take the diff of data and model of.
ftype_model (string, optional) – The model type (e.g., “model”, “model0”, etc.) of the model field to be diffed with the MSID.
- dates(*args)¶
Return the timing information in date and time for a field.
Examples
>>> ds.dates("states", "pitch")
- classmethod from_backstop(name, backstop_file, days=3, T_init=None, other_cmds=None, **kwargs)¶
Run a thermal model using states derived from a backstop file. Continuity with previous states will be automatically handled.
- Parameters:
name (string) – The name of the MSID to simulate, e.g. “1dpamzt”
backstop_file (string) – The path to the backstop file.
days (float) – The number of days to go back from the first command in the backstop file to get the initial state. Default: 3
T_init (float, optional) – The initial temperature for the thermal model run. If None, an initial temperature will be determined from telemetry. Default: None
other_cmds (list of commands or CommandTable) – Other commands to be included in the list.
Notes
All other keyword arguments which are passed to the main
ThermalModelRunner
constructor can be passed to this method as well.
- classmethod from_commands(name, cmds, **kwargs)¶
- Parameters:
name (string) – The name of the MSID to simulate, e.g. “1dpamzt”
cmds (list of commands or CommandTable) – The commands from which to derive states.
Notes
All other keyword arguments which are passed to the main
ThermalModelRunner
constructor can be passed to this method as well.
- classmethod from_states_file(name, states_file, **kwargs)¶
Run a xija thermal model using a states.dat file.
- Parameters:
name (string) – The name of the MSID to simulate, e.g. “1dpamzt”
states_file (string) – A file containing commanded states, in the same format as “states.dat” which is outputted by ACIS thermal model runs for loads.
Notes
All other keyword arguments which are passed to the main
ThermalModelRunner
constructor can be passed to this method as well.
- get_temp_at_time(t)[source]¶
Get the model temperature at a time t seconds past the beginning of the single-state run.
- make_dashboard_plots(yplotlimits=None, errorplotlimits=None, fig=None)[source]¶
Make dashboard plots for the particular thermal model.
- Parameters:
msid (string) – The MSID name to plot in the dashboard.
tstart (string, optional) – The start time of the data for the dashboard plot. If not specified, the beginning of the thermal model run is used.
tstop (string, optional) – The stop time of the data for the dashboard plot. If not specified, the end of the thermal model run is used.
yplotlimits (two-element array_like, optional) – The (min, max) bounds on the temperature to use for the temperature vs. time plot. Default: Determine the min/max bounds from the telemetry and model prediction and decrease/increase by degrees to determine the plot limits.
errorplotlimits (two-element array_like, optional) – The (min, max) error bounds to use for the error plot. Default: [-15, 15]
fig (
Figure
, optional) – A Figure instance to plot in. Default: None, one will be created if not provided.figfile (string, optional) – The file to write the dashboard plot to. One will be created if not provided.
bad_times (list of tuples, optional) – Provide a set of times to exclude from the creation of the dashboard plot.
mask_radzones (boolean, optional) – If True, mask out radzone periods for dashboard plots of the focal plane model. Default: False
plot_limits (boolean, optional) – If True, plot the yellow caution and planning limits on the dashboard plots. Default: True
- make_power_plot(figfile=None, fig=None, use_ccd_count=False)¶
Make a plot which shows the ACIS state power coefficients, vs. either FEP or CCD count.
- Parameters:
figfile (string, optional) – The file to write the power coefficient plot to. One will be created if not provided.
fig (
Figure
, optional) – A Figure instance to plot in. Default: None, one will be created if not provided.use_ccd_count (boolean, optional) – If True, plot the CCD count on the x-axis. Primarily useful for the 1DEAMZT model. Default: False
- make_solarheat_plot(node, figfile=None, fig=None)¶
Make a plot which shows the solar heat values vs. pitch.
- Parameters:
node (string) – The xija node which has the solar heating applied to it in the model. Can be an real node on the spacecraft like 1DEAMZT or a pseudo-node like “dpa0” in the 1DPAMZT model.
figfile (string, optional) – The file to write the solar heating plot to. One will be created if not provided.
fig (
Figure
, optional) – A Figure instance to plot in. Default: None, one will be created if not provided.
- map_state_to_msid(state, msid, ftype='msids')¶
Create a new derived field by interpolating a state to the times of a MSID or model component.
- Parameters:
state (string) – The state to be interpolated.
msid (string) – The msid or model component to interpolate the state to.
ftype (string, optional) – The field type to use. “msids” or “model”. Default: “msids”
Examples
>>> ds.map_state_to_msid("ccd_count", "1dpamzt")
- plot(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)¶
Make a single-panel plot of a quantity (or multiple quantities) vs. date and time from this Dataset.
Multiple quantities can be plotted on the left y-axis together if they have the same units, otherwise a quantity with different units can be plotted on the right y-axis.
- Parameters:
fields (tuple of strings or list of tuples of strings) – A single field or list of fields to plot on the left y-axis.
field2 (tuple of strings, optional) – A single field to plot on the right y-axis. Default: None
lw (float or list of floats, optional) – The width of the lines in the plots. If a list, the length of a the list must be equal to the number of fields. If a single number, it will apply to all plots. Default: 2 px.
ls (string, optional) – The line style of the lines plotted on the left y-axis. Can be a single linestyle or more than one for each line. Default: ‘-’
ls2 (string, optional) – The line style of the line plotted on the right y-axis. Can be a single linestyle or more than one for each line. Default: ‘-’
lw2 (float, optional) – The width of the line plotted on the right y-axis.
fontsize (integer, optional) – The font size for the labels in the plot. Default: 18 pt.
color (list of strings, optional) – The colors for the lines plotted on the left y-axis. Can be a single color or more than one in a list. Default: Use the default Matplotlib order of colors.
color2 (string, optional) – The color for the line plotted on the right y-axis. Default: “magenta”
fig (
Figure
, optional) – A Figure instance to plot in. Default: None, one will be created if not provided.figsize (tuple of integers, optional) – The size of the plot in (width, height) in inches. Default: (10, 8)
plot (
DatePlot
orCustomDatePlot
, optional) – An existing DatePlot to add this plot to. Default: None, one will be created if not provided.plot_bad (boolean, optional) – If True, “bad” values will be plotted but the ranges of bad values will be marked with translucent blue rectangles. If False, bad values will be removed from the plot. Default: False
- plot_model(plot=None, fontsize=18, **kwargs)[source]¶
Plot the simulated ECS run.
- Parameters:
plot (
DatePlot
orCustomDatePlot
, optional) – An existing DatePlot to add this plot to. Default: None, one will be created if not provided.fontsize (integer, optional) – The font size for the labels in the plot. Default: 18 pt.
- times(*args)¶
Return the timing information in seconds from the beginning of the mission for a field.
Examples
>>> ds.times("msids", "1deamzt")
- write_model(filename, overwrite=False)¶
Write the model data vs. time to an ASCII text file.
- Parameters:
filename (string) – The filename to write the data to.
overwrite (boolean, optional) – If True, an existing file with the same name will be overwritten.
- write_model_and_data(filename, overwrite=False)[source]¶
Write the model, telemetry, and states data vs. time to an ASCII text file. The state data is interpolated to the times of the model so that everything is at a common set of times.
- Parameters:
filename (string) – The filename to write the data to.
overwrite (boolean, optional) – If True, an existing file with the same name will be overwritten.
- write_msids(filename, fields, mask_field=None, overwrite=False)[source]¶
Write MSIDs (or MSID-like quantities such as model values) to an ASCII table file. This assumes that all of the quantities have been interpolated to a common set of times.
- write_states(states_file, overwrite=False)[source]¶
Write commanded states to an ASCII table file. An error will be thrown if there are no commanded states present.
- Parameters:
filename (string) – The filename to write the states to.
overwrite (boolean, optional) – If True, an existing file with the same name will be overwritten.