Skip to content

Commit

Permalink
Merge pull request #328 from sot/remove-cmds-v1
Browse files Browse the repository at this point in the history
Remove commands v1 from kadi
  • Loading branch information
taldcroft authored Apr 16, 2024
2 parents 5b70b04 + 66c0fe3 commit a588f6b
Show file tree
Hide file tree
Showing 20 changed files with 147 additions and 1,214 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.2.1
rev: v0.3.5
hooks:
# Run the linter.
- id: ruff
Expand Down
2 changes: 1 addition & 1 deletion docs/api_commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Commands API
Commands
--------

.. automodule:: kadi.commands.commands
.. automodule:: kadi.commands.commands_v2
:members:

Observations
Expand Down
30 changes: 5 additions & 25 deletions docs/commands_states.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,11 @@ The Commands archive is a table of every load command that has been run, or is c
approved to be run, on the spacecraft since 2002. This archive accounts for load stoppages,
replans, and certain non-load commands like ACIS CTI runs or Normal Sun Mode transitions.

As of this release there are two versions of the commands archive:

- `Commands archive v2`_ (flight): this provides improved timeliness during
anomalies and better team-wide communication of non-load spacecraft
commanding. This relies on the `Chandra Command Events`_ sheet and OCCweb FOT
mission planning approved load products to maintain the commands database.
- `Commands archive v1`_ (legacy): this is the legacy version and
relies on iFOT load segments and the Chandra.cmd_states timelines database to
maintain the commands database. It is currently deprecated and will be
removed in a future release.
The flight `Commands archive v2`_ relies on the `Chandra Command Events`_ sheet and
OCCweb FOT mission planning approved load products to maintain the commands database.
This archive provides an up-to-date view of commands and states even during anomalies.
The `Chandra Command Events`_ sheet is kept current during anomalies by FOT MP and helps
facilitate team-wide communication of non-load spacecraft commanding.

**States and continuity**

Expand Down Expand Up @@ -342,21 +337,6 @@ permanently disable caching you can edit your configuration file (see
>>> with conf.set_temp('cache_starcats', False):
... starcats = get_starcats('2022:001', '2022:002')

Commands archive v1
-------------------

Version 1 of the commands archive is provided for legacy support but it will be
removed in a future release.

For details of the commands v1 archive please see:
please see:

.. toctree::
:maxdepth: 2

commands_v1.rst


Chandra states and continuity
------------------------------

Expand Down
159 changes: 0 additions & 159 deletions docs/commands_v1.rst

This file was deleted.

38 changes: 3 additions & 35 deletions docs/commands_v2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,6 @@ The other key web resource is the OCCweb `FOT mission planning approved load pro
directory tree. This is used to automatically find all recent approved loads
and incorporate them into the load commands archive.

Differences from v1
-------------------

Apart from the fundamental change in data sources mentioned above, some key
changes from v1 are as follows:

- Commands table includes a ``source`` column that defines the source of the
command. Most commonly this is a weekly load name, but it can also indicate
a non-load command event for which further details are provided in the command
parameters.
- Information about each distinct observation is embedded into the command
archive as ``LOAD_EVENT`` pseudo-commands. The
:func:`~kadi.commands.observations.get_observations` provides a fast and
convenient way to find observations, both past and planned. See the
:ref:`getting-observations` section for more details.
- Information about each ACA star catalog is stored in the command
archive. The :func:`~kadi.commands.observations.get_observations` provides a
convenient way to find ACA star catalogs, both past and planned. See the
:ref:`getting-star-catalogs` section for more details.
- There are configuration options which can be set programmatically or in a fixed
configuration file to control behavior of the package. See the
`Configuration options`_ section for more details.

Scenarios
---------

Expand Down Expand Up @@ -95,7 +72,6 @@ of the 2021:296 NSM recovery::

>>> from kadi import paths
>>> from kadi.commands import conf, get_cmds
>>> conf.commands_version = '2'

>>> cmds = get_cmds(start='2022:001') # Ensure local cmd_events.csv is up to date

Expand Down Expand Up @@ -174,10 +150,6 @@ The available options with the default settings are as follows::
## downloading from Google Sheets and OCCweb.
commands_dir = ~/.kadi

## Default version of kadi commands ("1" or "2"). Overridden by
## KADI_COMMANDS_VERSION environment variable.
commands_version = 2

## Google Sheet ID for command events (flight scenario).
cmd_events_flight_id = 19d6XqBhWoFjC-z1lS1nM6wLE_zjr4GYB1lOvrEGCbKQ

Expand All @@ -200,9 +172,9 @@ Python to change a parameter for all subsequent code::

You can also temporarily change an option within a context manager::

>>> with conf.set_temp('commands_version', '2'):
... cmds2 = get_cmds('2022:001', '2022:002') # Use commands v2
>>> cmds1 = get_cmds('2022:001', '2022:002') # Use commands v1
>>> with conf.set_temp('include_in_work_command_events', True):
... cmds_in_work = get_cmds('2022:001', '2022:002') # Use Commands In-work events
>>> cmds_flight = get_cmds('2022:001', '2022:002') # Use only Predictive or Definitive

For an even-more permanent solution you can write out the configuration file
to disk and then edit it. Be wary of "temporarily" changing an option and then
Expand All @@ -221,10 +193,6 @@ Environment variables
Override the default location of kadi flight data files ``cmds2.h5`` and
``cmds2.pkl``.

``KADI_COMMANDS_VERSION``
Override the default kadi commands version. In order to use the commands
archive v2 you should set this to ``2``.

``KADI_COMMANDS_DEFAULT_STOP``
For testing and demonstration purposes, this environment variable can be set
to a date which is used as the default stop time for commands. In effect this
Expand Down
5 changes: 0 additions & 5 deletions kadi.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,5 @@
# commands_dir = "~/.kadi"


# Default version of kadi commands ("1" or "2"). Overridden by
# KADI_COMMANDS_VERSION environment variable.
# commands_version = "1"


# Google Sheet ID for command events (flight scenario).
# cmd_events_flight_id = "19d6XqBhWoFjC-z1lS1nM6wLE_zjr4GYB1lOvrEGCbKQ"
73 changes: 4 additions & 69 deletions kadi/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,73 +3,8 @@

logger = logging.getLogger(__name__)

from astropy.config import ConfigNamespace

from kadi.config import ConfigItem


class Conf(ConfigNamespace):
"""
Configuration parameters for kadi.
"""

default_lookback = ConfigItem(
30, "Default lookback for previous approved loads (days)."
)
cache_loads_in_astropy_cache = ConfigItem(
False,
"Cache backstop downloads in the astropy cache. Should typically be False, "
"but useful during development to avoid re-downloading backstops.",
)
cache_starcats = ConfigItem(
True,
"Cache star catalogs that are retrieved to a file to avoid repeating the "
"slow process of identifying fid and stars in catalogs. The cache file is "
"conf.commands_dir/starcats.db.",
)
clean_loads_dir = ConfigItem(
True,
"Clean backstop loads (like APR1421B.pkl.gz) in the loads directory that are "
"older than the default lookback. Most users will want this to be True, but "
"for development or if you always want a copy of the loads set to False.",
)
commands_dir = ConfigItem(
"~/.kadi",
"Directory where command loads and command events are stored after "
"downloading from Google Sheets and OCCweb.",
)
commands_version = ConfigItem(
"2",
'Default version of kadi commands ("1" or "2"). Overridden by '
"KADI_COMMANDS_VERSION environment variable.",
)

cmd_events_flight_id = ConfigItem(
"19d6XqBhWoFjC-z1lS1nM6wLE_zjr4GYB1lOvrEGCbKQ",
"Google Sheet ID for command events (flight scenario).",
)

cmd_events_exclude_intervals_gid = ConfigItem(
"1681877928",
"Google Sheet gid for validation exclude intervals in command events",
)

star_id_match_halfwidth = ConfigItem(
1.5, "Half-width box size of star ID match for get_starcats() (arcsec)."
)

fid_id_match_halfwidth = ConfigItem(
40, "Half-width box size of fid ID match for get_starcats() (arcsec)."
)

include_in_work_command_events = ConfigItem(
False, "Include In-work command events that are not yet approved."
)


# Create a configuration instance for the user
conf = Conf()


from .commands import *
from .core import *
from kadi.commands.commands_v2 import *
from kadi.commands.core import *
from kadi.commands.observations import *
from kadi.config import conf
Loading

0 comments on commit a588f6b

Please sign in to comment.