Skip to content

Commit 3d2f925

Browse files
authored
Merge pull request #269 from sot/docs-pydata
Documentation overhaul
2 parents 0b35fe7 + 28b475d commit 3d2f925

25 files changed

+933
-1586
lines changed

cheta/converters.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ def obc4eng(dat):
434434
At 2014:342:XX:XX:XX, patch PR-361 was applied which transitioned 41 OBA thermistors to
435435
read out in wide-mode. After this time the data in the listed OOBTHRxx MSIDs became
436436
invalid while the OOBTHRxx_WIDE MSIDs became valid. This converter simply copies the
437-
*_WIDE values to the original MSIDs after the time of patch activation.
437+
``*_WIDE`` values to the original MSIDs after the time of patch activation.
438438
439439
At 2017:312:16:11:16, patch PR-411 was applied which transitioned 6 OBA thermistors to
440440
wide-mode and these were added below as patch "c".

cheta/derived/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
22
"""
33
Derived Parameters
4-
------------------
54
65
The engineering archive has pseudo-MSIDs that are derived via computation from
76
telemetry MSIDs. All derived parameter names begin with the characters "DP_"

cheta/derived/mups_valve.py

+32-31
Original file line numberDiff line numberDiff line change
@@ -30,38 +30,38 @@
3030
This cleaning technique recovers on average about 90% of data for PM2THV1T. Since
3131
2015, about 60% of telemetry is good (no dropout) while 30% is in a recoverable
3232
fully-dropped state (and 10% is not recoverable).
33+
::
34+
35+
def fetch_clean_msid(msid, start, stop=None, dt_thresh=5.0, median=7, model_spec=None,
36+
version=None):
37+
Fetch a cleaned version of telemetry for ``msid``.
38+
39+
If not supplied the model spec will come from
40+
``xija.get_model_spec.get_xija_model_spec(msid, version=version)``
41+
(which uses ``$SKA/data/chandra_models/chandra_models/xija/mups_valve/{msid}_spec.json``).
42+
43+
This function returns a `fetch.Msid` object like a normal fetch but with extra attributes:
44+
45+
- vals: cleaned telemetry (either original or corrected telemetry, or xija model prediction)
46+
- source: label for each vals data point
47+
- 0: unrecoverable, so use xija model value
48+
- 1: original telemetry
49+
- 2: corrected telemetry
50+
- vals_raw: raw (uncleaned) telemetry
51+
- vals_nan: cleaned telem but with np.nan at points where data are unrecoverable (this is
52+
for plotting)
53+
- vals_corr: telemetry with the MUPS correction applied
54+
- vals_model: xija model prediction
55+
56+
:param start: start time
57+
:param stop: stop time (default=NOW)
58+
:param dt_thresh: tolerance for matching model to data in degF (default=5 degF)
59+
:param median: length of median filter (default=7, use 0 to disable)
60+
:param model_spec: file name or URL containing relevant xija model spec
61+
:param version: version of chandra_models repo (tag, branch, or commit)
62+
63+
:returns: fetch.Msid object
3364
34-
```
35-
def fetch_clean_msid(msid, start, stop=None, dt_thresh=5.0, median=7, model_spec=None,
36-
version=None):
37-
Fetch a cleaned version of telemetry for ``msid``.
38-
39-
If not supplied the model spec will come from
40-
``xija.get_model_spec.get_xija_model_spec(msid, version=version)``
41-
(which uses ``$SKA/data/chandra_models/chandra_models/xija/mups_valve/{msid}_spec.json``).
42-
43-
This function returns a `fetch.Msid` object like a normal fetch but with extra attributes:
44-
45-
- vals: cleaned telemetry (either original or corrected telemetry, or xija model prediction)
46-
- source: label for each vals data point
47-
- 0: unrecoverable, so use xija model value
48-
- 1: original telemetry
49-
- 2: corrected telemetry
50-
- vals_raw: raw (uncleaned) telemetry
51-
- vals_nan: cleaned telem but with np.nan at points where data are unrecoverable (this is
52-
for plotting)
53-
- vals_corr: telemetry with the MUPS correction applied
54-
- vals_model: xija model prediction
55-
56-
:param start: start time
57-
:param stop: stop time (default=NOW)
58-
:param dt_thresh: tolerance for matching model to data in degF (default=5 degF)
59-
:param median: length of median filter (default=7, use 0 to disable)
60-
:param model_spec: file name or URL containing relevant xija model spec
61-
:param version: version of chandra_models repo (tag, branch, or commit)
62-
63-
:returns: fetch.Msid object
64-
```
6565
"""
6666

6767
import os
@@ -154,6 +154,7 @@ def volts_to_counts(volts):
154154

155155
def get_corr_mups_temp(temp):
156156
"""Calculate a MUPS valve thermistor corrected temperature.
157+
157158
Args:
158159
temp (float, int): Temperature in Fahrenheit to which a correction will be applied.
159160

cheta/fetch.py

+36-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# Licensed under a 3-clause BSD style license - see LICENSE.rst
33
"""
4-
Fetch values from the Ska engineering telemetry archive.
4+
Fetch values from the cheta telemetry archive.
55
"""
66

77
import collections
@@ -31,9 +31,29 @@
3131
)
3232
from .derived.comps import ComputedMsid
3333
from .lazy import LazyDict
34-
from .remote_access import ENG_ARCHIVE
3534
from .units import Units
3635

36+
__all__ = [
37+
"data_source",
38+
"local_or_remote_function",
39+
"get_units",
40+
"set_units",
41+
"read_bad_times",
42+
"msid_glob",
43+
"MSID",
44+
"MSIDset",
45+
"Msid",
46+
"Msidset",
47+
"HrcSsMsid",
48+
"memoized",
49+
"get_time_range",
50+
"get_telem",
51+
"add_logging_handler",
52+
"get_data_gap_spec_parser",
53+
"msid_matches_data_gap_spec",
54+
"create_msid_data_gap",
55+
]
56+
3757
# Module-level units, defaults to CXC units (e.g. Kelvins etc)
3858
UNITS = Units(system="cxc")
3959

@@ -109,7 +129,7 @@ def set(cls, *data_sources):
109129
"""
110130
Set current data sources.
111131
112-
:param *data_sources: one or more sources (str)
132+
:param data_sources: one or more sources (str)
113133
"""
114134
if any(
115135
data_source.split()[0] not in cls._allowed for data_source in data_sources
@@ -268,14 +288,14 @@ def _get_start_stop_dates(times):
268288
ft = pyyaks.context.ContextDict("ft")
269289

270290
# Global (eng_archive) definition of file names
271-
msid_files = pyyaks.context.ContextDict("msid_files", basedir=ENG_ARCHIVE)
291+
msid_files = pyyaks.context.ContextDict("msid_files", basedir=remote_access.ENG_ARCHIVE)
272292
msid_files.update(file_defs.msid_files)
273293

274294
# Module-level values defining available content types and column (MSID) names.
275295
# Then convert from astropy Table to recarray for API stability.
276296
# Note that filetypes.as_array().view(np.recarray) does not quite work...
277-
filetypes = ascii.read(os.path.join(DIR_PATH, "filetypes.dat"))
278-
filetypes_arr = filetypes.as_array()
297+
filetypes_tbl = ascii.read(os.path.join(DIR_PATH, "filetypes.dat"))
298+
filetypes_arr = filetypes_tbl.as_array()
279299
filetypes = np.recarray(len(filetypes_arr), dtype=filetypes_arr.dtype)
280300
filetypes[()] = filetypes_arr
281301

@@ -1830,6 +1850,7 @@ def write_zip(self, filename):
18301850
class Msid(MSID):
18311851
"""
18321852
Fetch data from the engineering telemetry archive into an MSID object.
1853+
18331854
Same as MSID class but with filter_bad=True by default.
18341855
18351856
:param msid: name of MSID (case-insensitive)
@@ -2003,16 +2024,16 @@ def get_telem(
20032024
High-level routine to get telemetry for one or more MSIDs and perform
20042025
common processing functions:
20052026
2006-
- Fetch a set of MSIDs over a time range, specifying the sampling as
2007-
either full-resolution, 5-minute, or daily data.
2008-
- Filter out bad or missing data.
2009-
- Interpolate (resample) all MSID values to a common uniformly-spaced time sequence.
2010-
- Remove or select time intervals corresponding to specified Kadi event types.
2011-
- Change the time format from CXC seconds (seconds since 1998.0) to something more
2012-
convenient like GRETA time.
2013-
- Write the MSID telemetry data to a zipfile.
2027+
- Fetch a set of MSIDs over a time range, specifying the sampling as
2028+
either full-resolution, 5-minute, or daily data.
2029+
- Filter out bad or missing data.
2030+
- Interpolate (resample) all MSID values to a common uniformly-spaced time sequence.
2031+
- Remove or select time intervals corresponding to specified Kadi event types.
2032+
- Change the time format from CXC seconds (seconds since 1998.0) to something more
2033+
convenient like GRETA time.
2034+
- Write the MSID telemetry data to a zipfile.
20142035
2015-
:param msids: MSID(s) to fetch (string or list of strings)')
2036+
:param msids: MSID(s) to fetch (string or list of strings)
20162037
:param start: Start time for data fetch (default=<stop> - 30 days)
20172038
:param stop: Stop time for data fetch (default=NOW)
20182039
:param sampling: Data sampling (full | 5min | daily) (default=full)

cheta/get_telem.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
22
"""
3-
Fetch telemetry from the Ska engineering archive.
3+
Fetch telemetry from the cheta archive.
44
55
Examples
66
========

cheta/units.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,17 @@ def FASTEP_to_mm(vals, delta_val=False):
149149

150150
def mm_to_FASTEP(vals, delta_val=False):
151151
"""
152-
# compute mm from simulated integral step values and invert the CXC calibration
153-
# given below:
154-
x = np.arange(-5000.0, 0.0) # step
155-
y = (1.47906994e-3 * x + 3.5723322e-8 * x**2 + -1.08492544e-12 * x**3 +
156-
3.9803832e-17 * x**4 + 5.29336e-21 * x**5 + 1.020064e-25 * x**6)
157-
r = np.polyfit(y, x, 8)
152+
Convert from mm to focus assembly steps.
153+
154+
::
155+
156+
# compute mm from simulated integral step values and invert the CXC calibration
157+
# given below:
158+
x = np.arange(-5000.0, 0.0) # step
159+
y = (1.47906994e-3 * x + 3.5723322e-8 * x**2 + -1.08492544e-12 * x**3 +
160+
3.9803832e-17 * x**4 + 5.29336e-21 * x**5 + 1.020064e-25 * x**6)
161+
r = np.polyfit(y, x, 8)
162+
158163
"""
159164
r = np.array(
160165
[

cheta/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ def get_telem_table(
490490

491491
@functools.lru_cache(maxsize=1)
492492
def get_ofp_states(start, stop):
493-
"""Get the Onboard Flight Program (OFP) states between ``start`` and ``stop`.
493+
"""Get the Onboard Flight Program (OFP) states between ``start`` and ``stop``.
494494
495495
This is normally "NRML" but in safe mode it is "SAFE" or other values. State codes:
496496
['NNRM' 'STDB' 'STBS' 'NRML' 'NSTB' 'SUOF' 'SYON' 'DPLY' 'SYSF' 'STUP' 'SAFE']
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<a href="{{pathto(root_doc)}}" style="text-decoration: none;">
2+
<span style="color: rgb(186, 70, 21); font-size: x-large;">{{project}}</span>
3+
</a>
4+
&nbsp;
5+
<span style="font-size: x-large;">{{ version }}</span>

docs/_templates/python/module.rst

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
{% if obj.display %}
2+
{% if is_own_page %}
3+
{{ obj.id }}
4+
{{ "=" * obj.id|length }}
5+
6+
.. py:module:: {{ obj.name }}
7+
8+
{% if obj.docstring %}
9+
.. autoapi-nested-parse::
10+
11+
{{ obj.docstring|indent(3) }}
12+
13+
{% endif %}
14+
15+
{% block submodules %}
16+
{% set visible_subpackages = obj.subpackages|selectattr("display")|list %}
17+
{% set visible_submodules = obj.submodules|selectattr("display")|list %}
18+
{% set visible_submodules = (visible_subpackages + visible_submodules)|sort %}
19+
{% if visible_submodules %}
20+
Submodules
21+
----------
22+
23+
.. toctree::
24+
:maxdepth: 1
25+
26+
{% for submodule in visible_submodules %}
27+
{{ submodule.include_path }}
28+
{% endfor %}
29+
30+
31+
{% endif %}
32+
{% endblock %}
33+
{% block content %}
34+
{% set visible_children = obj.children|selectattr("display")|list %}
35+
{% if visible_children %}
36+
37+
{% set visible_exceptions = visible_children|selectattr("type", "equalto", "exception")|list %}
38+
{% if visible_exceptions %}
39+
{% if "exception" in own_page_types or "show-module-summary" in autoapi_options %}
40+
Exceptions
41+
----------
42+
43+
{% if "exception" in own_page_types %}
44+
.. toctree::
45+
:hidden:
46+
47+
{% for exception in visible_exceptions %}
48+
{{ exception.include_path }}
49+
{% endfor %}
50+
51+
{% endif %}
52+
.. autoapisummary::
53+
54+
{% for exception in visible_exceptions %}
55+
{{ exception.id }}
56+
{% endfor %}
57+
{% endif %}
58+
59+
60+
{% endif %}
61+
{% set visible_classes = visible_children|selectattr("type", "equalto", "class")|list %}
62+
{% if visible_classes %}
63+
{% if "class" in own_page_types or "show-module-summary" in autoapi_options %}
64+
Classes
65+
-------
66+
67+
{% if "class" in own_page_types %}
68+
.. toctree::
69+
:hidden:
70+
71+
{% for klass in visible_classes %}
72+
{{ klass.include_path }}
73+
{% endfor %}
74+
75+
{% endif %}
76+
.. autoapisummary::
77+
78+
{% for klass in visible_classes %}
79+
{{ klass.id }}
80+
{% endfor %}
81+
{% endif %}
82+
83+
84+
{% endif %}
85+
{% set visible_functions = visible_children|selectattr("type", "equalto", "function")|list %}
86+
{% if visible_functions %}
87+
{% if "function" in own_page_types or "show-module-summary" in autoapi_options %}
88+
Functions
89+
---------
90+
91+
{% if "function" in own_page_types %}
92+
.. toctree::
93+
:hidden:
94+
95+
{% for function in visible_functions %}
96+
{{ function.include_path }}
97+
{% endfor %}
98+
99+
{% endif %}
100+
.. autoapisummary::
101+
102+
{% for function in visible_functions %}
103+
{{ function.id }}
104+
{% endfor %}
105+
{% endif %}
106+
107+
108+
{% endif %}
109+
{% set this_page_children = visible_children|rejectattr("type", "in", own_page_types)|list %}
110+
111+
{% endif %}
112+
{% endblock %}
113+
{% else %}
114+
.. py:module:: {{ obj.name }}
115+
116+
{% if obj.docstring %}
117+
.. autoapi-nested-parse::
118+
119+
{{ obj.docstring|indent(6) }}
120+
121+
{% endif %}
122+
{% for obj_item in visible_children %}
123+
{{ obj_item.render()|indent(3) }}
124+
{% endfor %}
125+
{% endif %}
126+
{% endif %}

0 commit comments

Comments
 (0)