Skip to content

Commit

Permalink
Merge pull request #244 from sot/de-namespace
Browse files Browse the repository at this point in the history
Change Ska.engarchive to cheta w/ back-compatibility
  • Loading branch information
taldcroft committed Dec 23, 2022
2 parents da80f54 + c352fbd commit 847465a
Show file tree
Hide file tree
Showing 73 changed files with 104 additions and 148 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ jobs:
- name: Lint with flake8
run: |
pip install flake8
# Note: only check files in Ska.engarchive package. Many other files in
# Note: only check files in cheta package. Many other files in
# the repo are not maintained as PEP8 compliant.
flake8 Ska --count --ignore=W503,W504,F541,E203 --max-line-length=100 --show-source --statistics
flake8 cheta --count --ignore=W503,W504,F541,E203 --max-line-length=100 --show-source --statistics
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ MANIFEST
*.log
*.fits.gz
stage
Ska.engarchive.egg-info
cheta.egg-info
sken.egg-info
Ska/engarchive/GIT_VERSION
test/eng_archive*
Expand All @@ -25,3 +25,4 @@ dev_utils/memleak.py
*.ipynb
.ipynb_checkpoints
.idea
.vscode
19 changes: 0 additions & 19 deletions .hgignore

This file was deleted.

9 changes: 0 additions & 9 deletions MANIFEST.in

This file was deleted.

6 changes: 3 additions & 3 deletions alias_rename_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

import pyyaks.context

import Ska.engarchive.fetch as fetch
from Ska.engarchive.converters import ALIASES
import Ska.engarchive.file_defs as file_defs
import cheta.fetch as fetch
from cheta.converters import ALIASES
import cheta.file_defs as file_defs


def get_options(args=None):
Expand Down
1 change: 0 additions & 1 deletion cheta

This file was deleted.

2 changes: 1 addition & 1 deletion Ska/engarchive/__init__.py → cheta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ska_helpers

__version__ = ska_helpers.get_version("Ska.engarchive")
__version__ = ska_helpers.get_version(__package__, distribution="cheta")


def test(*args, **kwargs):
Expand Down
6 changes: 3 additions & 3 deletions Ska/engarchive/add_derived.py → cheta/add_derived.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
from Chandra.Time import DateTime
from six.moves import cPickle as pickle

import Ska.engarchive.derived as derived
import Ska.engarchive.fetch as fetch
import Ska.engarchive.file_defs as file_defs
import cheta.derived as derived
import cheta.fetch as fetch
import cheta.file_defs as file_defs


def get_options():
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import tables
from six.moves import cPickle as pickle

import Ska.engarchive.fetch as fetch
import cheta.fetch as fetch

opt = None
ft = fetch.ft
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Ska/engarchive/derived/base.py → cheta/derived/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

MNF_TIME = 0.25625 # Minor Frame duration (seconds)

logger = logging.getLogger("Ska.engarchive.fetch")
logger = logging.getLogger("cheta.fetch")


def times_indexes(start, stop, dt):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Ska/engarchive/derived/orbit.py → cheta/derived/orbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Example::
>>> from Ska.engarchive import fetch_eng as fetch
>>> from cheta import fetch_eng as fetch
>>> dat = fetch.Msidset(['inclination', 'perigee_radius'], '1999:200', stat='daily')
>>> subplot(2, 1, 1)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Ska/engarchive/fetch.py → cheta/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def emit(self, record):
pass


logger = logging.getLogger("Ska.engarchive.fetch")
logger = logging.getLogger("cheta.fetch")
logger.addHandler(NullHandler())
logger.propagate = False

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions Ska/engarchive/fix_bad_values.py → cheta/fix_bad_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
import tables
from Chandra.Time import DateTime

import Ska.engarchive.file_defs as file_defs
from Ska.engarchive import fetch
import cheta.file_defs as file_defs
from cheta import fetch

ft = fetch.ft
opt = None
Expand Down
2 changes: 1 addition & 1 deletion Ska/engarchive/get_telem.py → cheta/get_telem.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def get_telem(
# Set up output logging
from pyyaks.logger import get_logger

logger = get_logger(name="Ska.engarchive.get_telem", level=(100 if quiet else -100))
logger = get_logger(name="cheta.get_telem", level=(100 if quiet else -100))

# Set defaults and translate to fetch keywords
stop = DateTime(stop)
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Ska/engarchive/plot.py → cheta/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MsidPlot(object):
Example::
dat = fetch.Msid('aoattqt1', '2011:001', '2012:001', stat='5min')
iplot = Ska.engarchive.MsidPlot(dat)
iplot = cheta.MsidPlot(dat)
Caveat: the ``MsidPlot()`` class is not meant for use within scripts, and
may give unexpected results if used in combination with other plotting
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
>>> import os os.environ.pop('SKA', None)
>>> os.environ.pop('ENG_ARCHIVE', None)
>>> os.environ.pop('SKA_ACCESS_REMOTELY', None)
>>> from Ska.engarchive import fetch, remote_access
>>> from cheta import fetch, remote_access
>>> fetch.add_logging_handler()
>>> assert remote_access.access_remotely is True
>>> dat = fetch.Msid('tephin', '2018:001', '2018:010')
Expand All @@ -30,7 +30,7 @@
>>> os.environ['SKA'] = <path_to_ska_root>
>>> os.environ.pop('ENG_ARCHIVE', None)
>>> os.environ.pop('SKA_ACCESS_REMOTELY', None)
>>> from Ska.engarchive import fetch, remote_access
>>> from cheta import fetch, remote_access
>>> fetch.add_logging_handler()
>>> assert remote_access.access_remotely is False
>>> dat = fetch.Msid('1wrat', '2018:001', '2018:010')
Expand All @@ -41,7 +41,7 @@
>>> import os
>>> os.environ['SKA_ACCESS_REMOTELY'] = 'True'
>>> from Ska.engarchive
>>> from cheta
>>> import fetch, remote_access
>>> fetch.add_logging_handler()
>>> assert remote_access.access_remotely is True
Expand Down Expand Up @@ -77,7 +77,7 @@
import pytest
from astropy.utils.exceptions import AstropyUserWarning

from Ska.engarchive.remote_access import get_data_access_info
from cheta.remote_access import get_data_access_info

INVALID_DIR = str(Path(__file__).parent / "__non_existent_invalid_directory____")

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions Ska/engarchive/units.py → cheta/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def emit(self, record):
pass


logger = logging.getLogger("Ska.engarchive.units")
logger = logging.getLogger("cheta.units")
logger.addHandler(NullHandler())
logger.propagate = False

Expand Down Expand Up @@ -250,7 +250,7 @@ def convert(msid, vals, delta_val=False):
class Units(dict):
"""
Provide access to units via object-oriented replacement for
Ska.engarchive.units module.
cheta.units module.
This class is weird because it was designed to conform to the
existing API where units.units was a module dict that had keys
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions Ska/engarchive/update_archive.py → cheta/update_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
from Chandra.Time import DateTime
from ska_helpers.retry import tables_open_file

import Ska.engarchive.converters as converters
import Ska.engarchive.derived as derived
import Ska.engarchive.fetch as fetch
import Ska.engarchive.file_defs as file_defs
import cheta.converters as converters
import cheta.derived
import cheta.fetch as fetch
import cheta.file_defs as file_defs


def get_options(args=None):
Expand Down Expand Up @@ -656,7 +656,7 @@ def update_derived(filetype):
msids = set()
time_step = None
for colname in colnames:
dp_class = getattr(derived, colname)
dp_class = getattr(cheta.derived, colname)
dp = dp_class()
msids = msids.union([x.upper() for x in dp.rootparams])
time_step = dp.time_step # will be the same for every DP
Expand Down Expand Up @@ -998,7 +998,7 @@ def read_derived(i, filename, filetype, row, colnames, archfiles, db):
index0 = int(index0)
index1 = int(index1)
mnf_step = int(re.search(r"(\d+)$", content).group(1))
time_step = mnf_step * derived.MNF_TIME
time_step = mnf_step * cheta.derived.MNF_TIME
times = time_step * np.arange(index0, index1)

logger.info("Reading (%d / %d) %s" % (i, len(archfiles), filename))
Expand All @@ -1009,7 +1009,7 @@ def read_derived(i, filename, filetype, row, colnames, archfiles, db):
vals[colname] = times
bads[:, i] = False
else:
dp_class = getattr(Ska.engarchive.derived, colname.upper())
dp_class = getattr(cheta.derived, colname.upper())
dp = dp_class()
dataset = dp.fetch(times[0] - 1000, times[-1] + 1000)
ok = (index0 <= dataset.indexes) & (dataset.indexes < index1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from . import __version__, file_defs
from .utils import STATS_DT, get_date_id

sync_files = pyyaks.context.ContextDict("update_client_archive.sync_files")
sync_files = pyyaks.context.ContextDict(f"{__name__}.sync_files")
sync_files.update(file_defs.sync_files)

process_errors = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
from . import fetch, file_defs
from .utils import STATS_DT, get_date_id

sync_files = pyyaks.context.ContextDict("update_server_sync.sync_files")
sync_files = pyyaks.context.ContextDict(f"{__name__}.sync_files")
sync_files.update(file_defs.sync_files)


Expand Down
6 changes: 3 additions & 3 deletions Ska/engarchive/utils.py → cheta/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def ss_vector(start, stop=None, obj="Earth"):
Example::
from Ska.engarchive.utils import ss_vector
from cheta.utils import ss_vector
from Ska.Matplotlib import plot_cxctime
vec = ss_vector('2010:001', '2010:030', obj='Sun')
figure(1)
Expand Down Expand Up @@ -263,7 +263,7 @@ def logical_intervals(times, bools, complete_intervals=False, max_gap=None):
Example (find SCS107 runs via telemetry)::
>>> from Ska.engarchive import utils, fetch
>>> from cheta import utils, fetch
>>> dat = fetch.Msidset(['3tscmove', 'aorwbias', 'coradmen'], '2012:190', '2012:205')
>>> dat.interpolate(32.8) # Sample MSIDs onto 32.8 second intervals (like 3TSCMOVE)
>>> scs107 = ((dat['3tscmove'].vals == 'T')
Expand Down Expand Up @@ -314,7 +314,7 @@ def state_intervals(times, vals):
Example::
>>> from Ska.engarchive import fetch, utils
>>> from cheta import fetch, utils
>>> dat = fetch.Msid('cobsrqid', '2010:003:12:00:00', '2010:004:12:00:00')
>>> obsids = utils.state_intervals(dat.times, dat.vals)
>>> print(obsids['datestart', 'datestop', 'val'])
Expand Down
2 changes: 1 addition & 1 deletion dev_utils/example_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np

from Ska.Matplotlib import plot_cxctime
from Ska.engarchive import fetch_eng as fetch
from cheta import fetch_eng as fetch


def plot_both(x, title_str):
Expand Down
2 changes: 1 addition & 1 deletion dev_utils/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

@dview.remote(block=True)
def remote_fetch(*args, **kwargs):
import Ska.engarchive.fetch_eng as fetch
import cheta.fetch_eng as fetch
return fetch.Msid(*args, **kwargs)
2 changes: 1 addition & 1 deletion dev_utils/validate_tdb_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pickle
import os
import Ska.tdb
from Ska.engarchive import fetch_eng as fetch
from cheta import fetch_eng as fetch
from matplotlib import pyplot as plt

for content in os.listdir('data'):
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
copyright = u'2011, Tom Aldcroft'

# The full version, including alpha/beta/rc tags. Already defined above.
from Ska.engarchive import __version__ as release
from cheta import __version__ as release
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/cmp_obc_gyro.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
import Ska.engarchive.fetch as fetch
import cheta.fetch as fetch
from Ska.Matplotlib import plot_cxctime
import Ska.Numpy

Expand Down
2 changes: 1 addition & 1 deletion docs/fetchplots/make_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import numpy as np

from Ska.Matplotlib import plot_cxctime
from Ska.engarchive import fetch_eng as fetch
from cheta import fetch_eng as fetch
import matplotlib.pyplot as plt


Expand Down
Loading

0 comments on commit 847465a

Please sign in to comment.