Commit b2e61155 authored by Kelvin Rodriguez's avatar Kelvin Rodriguez Committed by Jesse Mapel
Browse files

Removed config file from ALE (#251)

* kernel list support added

* simple spice as fixture

* removed abstractmethod tags

* added property tags

* addressed comments

* removed config, combined kernel and metakernel methods, added test for metakerenl queries

* added test to env var

* Add short name test for dawn

* Add other short name tests
parent 8df36738
Loading
Loading
Loading
Loading
+7 −22
Original line number Diff line number Diff line
import os
import pathlib
from shutil import copyfile
import yaml
import warnings
from pkg_resources import get_distribution, DistributionNotFound

class DotDict(dict):
    """dot.notation access to dictionary attributes"""""
    __getattr__ = dict.get
    __setattr__ = dict.__setitem__
    __delattr__ = dict.__delitem__

    def __str__(self):
        return yaml.dump(dict(self))

home_path = os.path.expanduser('~')
config_dir = pathlib.Path(os.path.join(home_path, '.ale'))
config_file_path = pathlib.Path(os.path.join(home_path, '.ale', 'config.yml'))

config_dir.mkdir(parents=True, exist_ok=True)

if not config_file_path.is_file():
  copyfile(os.path.join(os.path.dirname(__file__), 'config.yml'), config_file_path)

config = DotDict(yaml.load(open(config_file_path), Loader=yaml.FullLoader))

try:
    _dist = get_distribution('ale')
@@ -37,6 +16,12 @@ except DistributionNotFound:
else:
    __version__ = _dist.version

try:
    spice_root = os.environ['ALESPICEROOT']
except:
    warnings.warn('ALESPICEROOT environment variable not set, Spice Drivers will not function correctly')
    spice_root = None

# bring ale stuff into main ale module
from . import drivers
from . import formatters
+4 −0
Original line number Diff line number Diff line
@@ -308,3 +308,7 @@ class Driver():
          Center ephemeris time for an image
        """
        return (self.ephemeris_start_time + self.ephemeris_stop_time) / 2

    @property
    def short_mission_name(self):
        return self.__module__.split('.')[-1].split('_')[0]
+0 −1
Original line number Diff line number Diff line
@@ -11,7 +11,6 @@ import pvl
import spiceypy as spice
from ale.rotation import ConstantRotation, TimeDependentRotation
from ale.transformation import FrameChain
from ale import config

from scipy.interpolate import interp1d, BPoly

+6 −8
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import numpy as np
from ale.base.type_sensor import Framer
from ale.transformation import FrameChain
from ale.rotation import TimeDependentRotation
from ale import util

class NaifSpice():
    def __enter__(self):
@@ -13,8 +14,6 @@ class NaifSpice():
        """
        if self.kernels:
            [spice.furnsh(k) for k in self.kernels]
        elif self.metakernel:
            spice.furnsh(self.metakernel)
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
@@ -25,18 +24,17 @@ class NaifSpice():
        """
        if self.kernels:
            [spice.unload(k) for k in self.kernels]
        else:
            spice.unload(self.metakernel)

    @property
    def kernels(self):
        if not hasattr(self, '_kernels'):
            self._kernels =  self._props.get('kernels', None)
            if 'kernels' in self._props.keys():
                self._kernels =  self._props['kernels']
            else:
                search_results = util.get_metakernels(missions=self.short_mission_name, years=self.utc_start_time.year, versions='latest')
                self._kernels = [search_results['data'][0]['path']]
        return self._kernels

    def metakernel(self):
        pass

    @property
    def light_time_correction(self):
        """

ale/config.yml

deleted100644 → 0
+0 −8
Original line number Diff line number Diff line
spice_root: "/data/spice/"
cassini: '/scratch/jlaura/spice/co-s_j_e_v-spice-6-v1.0/cosp_1000/extras/mk/' # Cassini ISS
mdis: '/scratch/jlaura/spice/mess-e_v_h-spice-6-v1.0/messsp_1000/extras/mk' # Messenger
mex: '/scratch/jlaura/spice/mex-e_m-spice-6-v1.0/mexsp_1000/EXTRAS/MK' # Mars Explorer
mro: '/data/spice/mro-m-spice-6-v1.0/mrosp_1000/extras/mk' # Mars Reconnaissance Orbiter
kaguya: '/data/spice/SELENE/kernels/mk/'
dawn: '/scratch/spice/dawn-m_a-spice-6-v1.0/dawnsp_1000/extras/mk/'
lro: '/scratch/jlaura/spice/lro-l-spice-6-v1.0/lrosp_1000/extras/mk/' # LRO
Loading