diff --git a/.hgignore b/.hgignore index bd27d34..cfd8494 100644 --- a/.hgignore +++ b/.hgignore @@ -1,2 +1,2 @@ -Chandra.cmd_states.egg-info +chandra_cmd_states.egg-info dist diff --git a/add_nonload_cmds.py b/add_nonload_cmds.py index eaef1a6..1411b05 100755 --- a/add_nonload_cmds.py +++ b/add_nonload_cmds.py @@ -6,5 +6,5 @@ """ if __name__ == '__main__': - import Chandra.cmd_states.add_nonload_cmds as add_nonload_cmds + import chandra_cmd_states.add_nonload_cmds as add_nonload_cmds add_nonload_cmds.main() diff --git a/Chandra/cmd_states/__init__.py b/chandra_cmd_states/__init__.py similarity index 82% rename from Chandra/cmd_states/__init__.py rename to chandra_cmd_states/__init__.py index 338acb2..a55ad84 100644 --- a/Chandra/cmd_states/__init__.py +++ b/chandra_cmd_states/__init__.py @@ -3,7 +3,7 @@ from .cmd_states import * from .get_cmd_states import fetch_states -__version__ = ska_helpers.get_version('Chandra.cmd_states') +__version__ = ska_helpers.get_version('chandra_cmd_states') def test(*args, **kwargs): diff --git a/Chandra/cmd_states/add_nonload_cmds.py b/chandra_cmd_states/add_nonload_cmds.py similarity index 98% rename from Chandra/cmd_states/add_nonload_cmds.py rename to chandra_cmd_states/add_nonload_cmds.py index 7086d8b..767fd2f 100644 --- a/Chandra/cmd_states/add_nonload_cmds.py +++ b/chandra_cmd_states/add_nonload_cmds.py @@ -41,8 +41,8 @@ import time -import Chandra.cmd_states as cmd_states -from Chandra.cmd_states.cmd_states import _tl_to_bs_cmds +import chandra_cmd_states as cmd_states +from chandra_cmd_states.cmd_states import _tl_to_bs_cmds import Ska.DBI from Chandra.Time import DateTime import Ska.ParseCM diff --git a/Chandra/cmd_states/cmd_states.py b/chandra_cmd_states/cmd_states.py similarity index 100% rename from Chandra/cmd_states/cmd_states.py rename to chandra_cmd_states/cmd_states.py diff --git a/Chandra/cmd_states/get_cmd_states.py b/chandra_cmd_states/get_cmd_states.py similarity index 99% rename from Chandra/cmd_states/get_cmd_states.py rename to chandra_cmd_states/get_cmd_states.py index 1697160..05122f5 100644 --- a/Chandra/cmd_states/get_cmd_states.py +++ b/chandra_cmd_states/get_cmd_states.py @@ -115,7 +115,7 @@ def fetch_states(start=None, stop=None, vals=None, allow_identical=False, Examples:: # Get commanded states using the default HDF5 table - >>> from Chandra.cmd_states import fetch_states + >>> from chandra_cmd_states import fetch_states >>> states = fetch_states('2011:100:12:00:00', '2011:101:12:00:00', vals=['obsid', 'simpos']) >>> states[['datestart', 'datestop', 'obsid', 'simpos']] array([('2011:100:11:53:12.378', '2011:101:00:23:01.434', 13255, 75624), diff --git a/Chandra/cmd_states/interrupt_loads.py b/chandra_cmd_states/interrupt_loads.py similarity index 97% rename from Chandra/cmd_states/interrupt_loads.py rename to chandra_cmd_states/interrupt_loads.py index 27a0276..2c83661 100644 --- a/Chandra/cmd_states/interrupt_loads.py +++ b/chandra_cmd_states/interrupt_loads.py @@ -7,7 +7,7 @@ import logging import Ska.DBI -import Chandra.cmd_states as cmd_states +import chandra_cmd_states as cmd_states def get_options(): diff --git a/Chandra/cmd_states/tests/__init__.py b/chandra_cmd_states/tests/__init__.py similarity index 100% rename from Chandra/cmd_states/tests/__init__.py rename to chandra_cmd_states/tests/__init__.py diff --git a/Chandra/cmd_states/tests/test_cmd_sets.py b/chandra_cmd_states/tests/test_cmd_sets.py similarity index 98% rename from Chandra/cmd_states/tests/test_cmd_sets.py rename to chandra_cmd_states/tests/test_cmd_sets.py index 9382c22..25048f5 100644 --- a/Chandra/cmd_states/tests/test_cmd_sets.py +++ b/chandra_cmd_states/tests/test_cmd_sets.py @@ -1,6 +1,6 @@ # Licensed under a 3-clause BSD style license - see LICENSE.rst -from Chandra.cmd_states import cmd_set +from chandra_cmd_states import cmd_set # COMMAND_HW | TLMSID= AFIDP, HEX= 6480005, MSID= AFLCRSET diff --git a/Chandra/cmd_states/tests/test_get_cmd_states.py b/chandra_cmd_states/tests/test_get_cmd_states.py similarity index 87% rename from Chandra/cmd_states/tests/test_get_cmd_states.py rename to chandra_cmd_states/tests/test_get_cmd_states.py index 82bb1eb..d7dc76c 100644 --- a/Chandra/cmd_states/tests/test_get_cmd_states.py +++ b/chandra_cmd_states/tests/test_get_cmd_states.py @@ -1,29 +1,21 @@ # Licensed under a 3-clause BSD style license - see LICENSE.rst import os import sys -from pathlib import Path from io import StringIO import pytest import numpy as np from astropy.io import ascii -import Chandra.cmd_states -from Chandra.cmd_states.get_cmd_states import main, fetch_states -from Chandra.cmd_states.cmd_states import decode_power, get_state0, get_cmds, get_states - -# Check that this test file is in the same package as the imported Chandra.cmd_states. -# Due to subtleties with pytest test collection and native namespace pacakges, -# running `pytest Ska/Numpy` in the git repo will end up getting the installed -# Chandra.cmd_states not the local one. Use `python setup.py test` instead. -assert Path(__file__).parent.parent == Path(Chandra.cmd_states.__file__).parent +from chandra_cmd_states.get_cmd_states import main, fetch_states +from chandra_cmd_states.cmd_states import decode_power, get_state0, get_cmds, get_states HAS_SOTMP_FILES = os.path.exists(f'{os.environ["SKA"]}/data/mpcrit1/mplogs/2017') # This is taken from the output of # get_cmd_states --start=2010:100 --stop=2010:101 --vals=obsid,simpos,pcad_mode,clocking,power_cmd -# for Chandra.cmd_states version 0.07 in skare 0.13 on July 18, 2012. +# for chandra_cmd_states version 0.07 in skare 0.13 on July 18, 2012. LINES = [ "datestart datestop tstart tstop obsid power_cmd pcad_mode clocking simpos", "2010:100:11:39:57.675 2010:100:14:04:43.358 387286863.859 387295549.542 56340 XTZ0000005 NPNT 1 -99616", diff --git a/Chandra/cmd_states/update_cmd_states.py b/chandra_cmd_states/update_cmd_states.py similarity index 100% rename from Chandra/cmd_states/update_cmd_states.py rename to chandra_cmd_states/update_cmd_states.py diff --git a/docs/api.rst b/docs/api.rst index 3ee8094..bf522d3 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1,33 +1,33 @@ -Chandra.cmd_states API +chandra_cmd_states API ====================== add_nonload_cmds ---------------- -.. automodule:: Chandra.cmd_states.add_nonload_cmds +.. automodule:: chandra_cmd_states.add_nonload_cmds :members: cmd_states ---------------- -.. automodule:: Chandra.cmd_states.cmd_states +.. automodule:: chandra_cmd_states.cmd_states :members: get_cmd_states ---------------- -.. automodule:: Chandra.cmd_states.get_cmd_states +.. automodule:: chandra_cmd_states.get_cmd_states :members: interrupt_loads ---------------- -.. automodule:: Chandra.cmd_states.interrupt_loads +.. automodule:: chandra_cmd_states.interrupt_loads :members: update_cmd_states ----------------- -.. automodule:: Chandra.cmd_states.update_cmd_states +.. automodule:: chandra_cmd_states.update_cmd_states :members: diff --git a/docs/conf.py b/docs/conf.py index ea369fe..301d0f6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -46,7 +46,7 @@ # built documents. # # The short X.Y version. -from Chandra.cmd_states import __version__ as version +from chandra_cmd_states import __version__ as version # The full version, including alpha/beta/rc tags. release = version diff --git a/docs/get_cmd_states.rst b/docs/get_cmd_states.rst index a8294af..a08ba01 100644 --- a/docs/get_cmd_states.rst +++ b/docs/get_cmd_states.rst @@ -6,7 +6,7 @@ Get the Chandra commanded states over a range of time as a space-delimited ASCII table. -This tool is a wrapper around the ``Chandra.cmd_states.get_cmd_states()`` +This tool is a wrapper around the ``chandra_cmd_states.get_cmd_states()`` function. This function should be used within any Python code that requires use of commanded states. diff --git a/docs/index.rst b/docs/index.rst index a4322a5..6a900c3 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -10,7 +10,7 @@ state and a predictive state at any time. .. Warning:: Use of the commanded states database described here is deprecated in favor of the `Kadi commands and states package `_. - The replacement for the :func:`~Chandra.cmd_states.fetch_states` function is described + The replacement for the :func:`~chandra_cmd_states.fetch_states` function is described in the `Chandra states and continuity `_ section which makes use of the `get_states @@ -49,9 +49,9 @@ available via the :ref:`get_cmd_states` tool. For example:: 2012:121:16:04:07.192 2012:123:11:23:20.985 452189113.376 452345067.169 13847 75624 To access the commanded states database from within a Python script use the -:func:`~Chandra.cmd_states.fetch_states` function. For instance:: +:func:`~chandra_cmd_states.fetch_states` function. For instance:: - >>> from Chandra.cmd_states import fetch_states + >>> from chandra_cmd_states import fetch_states >>> states = fetch_states('2011:100', '2011:101') >>> states[['datestart', 'datestop', 'obsid', 'simpos']] array([('2011:100:11:53:12.378', '2011:101:00:23:01.434', 13255, 75624), @@ -145,13 +145,13 @@ Tools make_cmd_tables update_cmd_states -Chandra.cmd_states functions +chandra_cmd_states functions ----------------------------- -The following key functions within the ``Chandra.cmd_states`` module are +The following key functions within the ``chandra_cmd_states`` module are available for users. -.. automodule:: Chandra.cmd_states +.. automodule:: chandra_cmd_states get_cmds ^^^^^^^^^ @@ -176,7 +176,7 @@ reduce_states API docs -------------- -The full API docs for ``Chandra.cmd_states`` are available here: +The full API docs for ``chandra_cmd_states`` are available here: .. toctree:: :maxdepth: 2 diff --git a/fix_pitch_simz.py b/fix_pitch_simz.py index 9f3b57e..63dc982 100755 --- a/fix_pitch_simz.py +++ b/fix_pitch_simz.py @@ -17,7 +17,7 @@ # import Ska.Table import Ska.DBI -import Chandra.cmd_states as cmd_states +import chandra_cmd_states as cmd_states def get_options(): from optparse import OptionParser @@ -29,7 +29,7 @@ def get_options(): parser.add_option("--server", default='db_base.db3', help="DBI server (|sybase)") - + (opt, args) = parser.parse_args() return (opt, args) @@ -45,7 +45,7 @@ def main(): db = Ska.DBI.DBI(dbi=opt.dbi, server=opt.server) - datestart = '2002:010:00:00:00' + datestart = '2002:010:00:00:00' datestop = '2009:001:00:00:00' if 'states' not in globals(): @@ -81,4 +81,4 @@ def main(): if __name__ == '__main__': main() - + diff --git a/get_cmd_states b/get_cmd_states index d590f1b..ed1b904 100644 --- a/get_cmd_states +++ b/get_cmd_states @@ -2,6 +2,6 @@ SKA_bin=`dirname $0` eval `${SKA_bin}/flt_envs -shell sh` -exec $SKA_ARCH_OS/bin/python -m Chandra.cmd_states.get_cmd_states "$@" +exec $SKA_ARCH_OS/bin/python -m chandra_cmd_states.get_cmd_states "$@" exit 1 diff --git a/get_cmd_states.py b/get_cmd_states.py index 0baff98..91496ad 100755 --- a/get_cmd_states.py +++ b/get_cmd_states.py @@ -6,5 +6,5 @@ """ if __name__ == '__main__': - from Chandra.cmd_states import get_cmd_states + from chandra_cmd_states import get_cmd_states get_cmd_states.main() diff --git a/interrupt_loads.py b/interrupt_loads.py index 5ae3dd1..6bbf9ee 100755 --- a/interrupt_loads.py +++ b/interrupt_loads.py @@ -5,5 +5,5 @@ """ if __name__ == '__main__': - import Chandra.cmd_states.interrupt_loads as interrupt_loads + import chandra_cmd_states.interrupt_loads as interrupt_loads interrupt_loads.main() diff --git a/nonload_cmds_archive.py b/nonload_cmds_archive.py index 16686f5..ca3fcd1 100755 --- a/nonload_cmds_archive.py +++ b/nonload_cmds_archive.py @@ -2,8 +2,8 @@ # Licensed under a 3-clause BSD style license - see LICENSE.rst import Ska.DBI -import Chandra.cmd_states as cmd_states -from Chandra.cmd_states import generate_cmds, cmd_set, interrupt_loads +import chandra_cmd_states as cmd_states +from chandra_cmd_states import generate_cmds, cmd_set, interrupt_loads def get_options(): from optparse import OptionParser @@ -34,7 +34,7 @@ def get_options(): cmds = [] # Normal sun mode day 2008:225 -cmds += generate_cmds('2008:225:10:00:00', cmd_set('nsm')) +cmds += generate_cmds('2008:225:10:00:00', cmd_set('nsm')) cmds += generate_cmds('2008:227:20:00:00', cmd_set('manvr', 0.734142,-0.111682,0.558589,0.369515 )) cmds += generate_cmds('2008:227:21:25:00', cmd_set('manvr', 0.784368,-0.0804672,0.535211,0.303053)) cmds += generate_cmds('2008:227:22:15:00', cmd_set('manvr', 0.946291,-0.219412,0.0853751,0.221591)) @@ -59,7 +59,7 @@ def get_options(): dict(cmd='ACISPKT', tlmsid='WSVIDALLDN', ), - ) + ) cmds += generate_cmds('2009:240:10:40:00.000', cap_cmds ) @@ -67,19 +67,19 @@ def get_options(): cmds += generate_cmds('2010:025:09:11:00.000', ( dict(cmd='ACISPKT', tlmsid='WSPOW00306'), dict(cmd='ACISPKT', tlmsid='AA00000000') )) -cmds += generate_cmds('2010:025:09:11:01.025', ( dict(cmd='ACISPKT', tlmsid='WSVIDALLDN'), +cmds += generate_cmds('2010:025:09:11:01.025', ( dict(cmd='ACISPKT', tlmsid='WSVIDALLDN'), )) cmds += generate_cmds('2010:025:14:00:00.000', ( dict(cmd='ACISPKT', tlmsid='WSPOW0EC3E'), dict(cmd='ACISPKT', tlmsid='AA00000000') )) -cmds += generate_cmds('2010:025:14:00:01.025', ( dict(cmd='ACISPKT', tlmsid='XTZ0000005'), +cmds += generate_cmds('2010:025:14:00:01.025', ( dict(cmd='ACISPKT', tlmsid='XTZ0000005'), )) cmds += generate_cmds('2010:026:00:30:00.000', ( dict(cmd='ACISPKT', tlmsid='WSPOW01f1f'), )) -cmds += generate_cmds('2010:026:01:36:41.000', ( dict(cmd='ACISPKT', tlmsid='WSPOW00707'), +cmds += generate_cmds('2010:026:01:36:41.000', ( dict(cmd='ACISPKT', tlmsid='WSPOW00707'), )) # Day 97 CAP made a strange state at 80W that looks like a fep=3,vid_board=on,clocking=off @@ -162,7 +162,7 @@ def get_options(): cmd_states.insert_cmds_db(cmds, None, db) -# 2010:150 NSM commands +# 2010:150 NSM commands # date=2010:150:04:00:00.000 cmd_set=nsm args= cmds = generate_cmds('2010:150:04:00:00.000', cmd_set('nsm')) cmd_states.insert_cmds_db(cmds, None, db) diff --git a/resample_states_verification/NOTES.md b/resample_states_verification/NOTES.md index 42ad37a..0c035c9 100644 --- a/resample_states_verification/NOTES.md +++ b/resample_states_verification/NOTES.md @@ -20,19 +20,19 @@ I then used fetch_states against the flight cmd_states.h5 and the testing cmd_st create dat files limited to the columns that really should not be changing due to this update. - from Chandra.cmd_states.get_cmd_states import fetch_states + from chandra_cmd_states.get_cmd_states import fetch_states from astropy.table import Table - + official = fetch_states(start='2010:005', stop='2010:360', vals=['obsid', 'power_cmd', 'si_mode', 'pcad_mode', 'vid_board', 'clocking', 'fep_count', 'ccd_count', 'simpos', 'simfa_pos', 'hetg', 'letg'], server='/proj/sot/ska/data/cmd_states/cmd_states.h5') Table(official).write('official_minus_point.dat', format='ascii') - + test = fetch_states(start='2010:005', stop='2010:360', vals=['obsid', 'power_cmd', 'si_mode', 'pcad_mode', 'vid_board', 'clocking', 'fep_count', 'ccd_count', 'simpos', 'simfa_pos', 'hetg', 'letg'], server='t/all_2010/cmd_states.h5') Table(test).write('test_minus_point.dat', format='ascii') - + meld official_minus_point.dat test_minus_point.dat There are fewer than a dozen timing diffs of less than 0.04 seconds in the NMAN / NPNT diff --git a/setup.py b/setup.py index ae48735..e650a0d 100755 --- a/setup.py +++ b/setup.py @@ -1,26 +1,27 @@ # Licensed under a 3-clause BSD style license - see LICENSE.rst from setuptools import setup +from ska_helpers.setup_helper import duplicate_package_info +from testr.setup_helper import cmdclass -try: - from testr.setup_helper import cmdclass -except ImportError: - cmdclass = {} +name = "chandra_cmd_states" +namespace = "Chandra.cmd_states" -setup(name='Chandra.cmd_states', +packages = ["chandra_cmd_states", "chandra_cmd_states.tests"] +package_dir = {name: name} + +duplicate_package_info(packages, name, namespace) +duplicate_package_info(package_dir, name, namespace) + +setup(name=name, author='Tom Aldcroft', - description=('Functions for creating, manipulating and updating ' + description=('(DEPRECATED) Functions for creating, manipulating and updating ' 'the Chandra commanded states database'), author_email='taldcroft@cfa.harvard.edu', - py_modules=['Chandra.cmd_states.cmd_states', - 'Chandra.cmd_states.get_cmd_states', - 'Chandra.cmd_states.update_cmd_states', - 'Chandra.cmd_states.interrupt_loads', - 'Chandra.cmd_states.add_nonload_cmds', - ], use_scm_version=True, setup_requires=['setuptools_scm', 'setuptools_scm_git_archive'], zip_safe=False, - packages=['Chandra', 'Chandra.cmd_states', 'Chandra.cmd_states.tests'], + packages=packages, + package_dir=package_dir, tests_require=['pytest'], cmdclass=cmdclass, ) diff --git a/tests/cmp_telem.py b/tests/cmp_telem.py index fce77b9..accd4d0 100644 --- a/tests/cmp_telem.py +++ b/tests/cmp_telem.py @@ -11,7 +11,7 @@ import logging import Ska.Table import Ska.DBI -import Chandra.cmd_states as cmd_states +import chandra_cmd_states as cmd_states from Ska.Matplotlib import plot_cxctime, pointpair from Chandra.Time import DateTime from scipy.signal import medfilt diff --git a/tests/otg_telem.py b/tests/otg_telem.py index d6da539..6ca1173 100644 --- a/tests/otg_telem.py +++ b/tests/otg_telem.py @@ -10,7 +10,7 @@ """ import logging import Ska.DBI -import Chandra.cmd_states as cmd_states +import chandra_cmd_states as cmd_states from Ska.Matplotlib import plot_cxctime, pointpair from Chandra.Time import DateTime from scipy.signal import medfilt diff --git a/tests/update_tables.py b/tests/update_tables.py index ec62407..5b184a0 100644 --- a/tests/update_tables.py +++ b/tests/update_tables.py @@ -5,7 +5,7 @@ from Chandra.Time import DateTime from Ska.Matplotlib import plot_cxctime, pointpair import Ska.ParseCM -import Chandra.cmd_states as cmd_states +import chandra_cmd_states as cmd_states import Ska.DBI from matplotlib import pyplot from Ska.TelemArchive.fetch import fetch diff --git a/update_cmd_states.py b/update_cmd_states.py index 03ef87d..b74abe0 100755 --- a/update_cmd_states.py +++ b/update_cmd_states.py @@ -6,5 +6,5 @@ """ if __name__ == '__main__': - from Chandra.cmd_states import update_cmd_states + from chandra_cmd_states import update_cmd_states update_cmd_states.main()