Skip to content

Commit

Permalink
Merge 1c3d646 into e747f0c
Browse files Browse the repository at this point in the history
  • Loading branch information
jklenzing committed May 17, 2021
2 parents e747f0c + 1c3d646 commit 35444b5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Update sat_id to inst_id for pysat 3.0 compatibility
- migrate pyglow interface to pysatIncubator
- Style updates for consistency with pysat 3.0
- Use `cadence` instead of `freq`
- Migrate CI testing to Github Actions

## [0.2.1] - 2020-07-29
Expand Down
7 changes: 4 additions & 3 deletions pysatMissions/instruments/pysat_ephem.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def preprocess(self):


def load(fnames, tag=None, inst_id=None, obs_long=0., obs_lat=0., obs_alt=0.,
TLE1=None, TLE2=None, num_samples=None, freq='1S'):
TLE1=None, TLE2=None, num_samples=None, cadence='1S'):
"""
Returns data and metadata in the format required by pysat. Generates
position of satellite in both geographic and ECEF co-ordinates.
Expand Down Expand Up @@ -117,7 +117,7 @@ def load(fnames, tag=None, inst_id=None, obs_long=0., obs_lat=0., obs_alt=0.,
Second string for Two Line Element. Must be in TLE format (default=None)
num_samples : int or NoneType
Number of samples per day (default=None)
freq : str
cadence : str
Uses pandas.frequency string formatting ('1S', etc)
(default='1S')
Expand Down Expand Up @@ -157,7 +157,8 @@ def load(fnames, tag=None, inst_id=None, obs_long=0., obs_lat=0., obs_alt=0.,
num_samples = 100

# Extract list of times from filenames and inst_id
times, index, dates = ps_meth.generate_times(fnames, num_samples, freq=freq)
times, index, dates = ps_meth.generate_times(fnames, num_samples,
freq=cadence)

# the observer's (ground station) position on the Earth surface
site = ephem.Observer()
Expand Down
7 changes: 4 additions & 3 deletions pysatMissions/instruments/pysat_sgp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def init(self):


def load(fnames, tag=None, inst_id=None, obs_long=0., obs_lat=0., obs_alt=0.,
TLE1=None, TLE2=None, num_samples=None, freq='1S'):
TLE1=None, TLE2=None, num_samples=None, cadence='1S'):
"""
Returns data and metadata in the format required by pysat. Generates
position of satellite in ECI co-ordinates.
Expand Down Expand Up @@ -94,7 +94,7 @@ def load(fnames, tag=None, inst_id=None, obs_long=0., obs_lat=0., obs_alt=0.,
Second string for Two Line Element. Must be in TLE format
num_samples : int
Number of samples per day
freq : str
cadence : str
Uses pandas.frequency string formatting ('1S', etc)
(default='1S')
Expand Down Expand Up @@ -141,7 +141,8 @@ def load(fnames, tag=None, inst_id=None, obs_long=0., obs_lat=0., obs_alt=0.,
satellite = twoline2rv(line1, line2, wgs72)

# Extract list of times from filenames and inst_id
times, index, dates = ps_meth.generate_times(fnames, num_samples, freq=freq)
times, index, dates = ps_meth.generate_times(fnames, num_samples,
freq=cadence)

# create list to hold satellite position, velocity
position = []
Expand Down
20 changes: 20 additions & 0 deletions pysatMissions/tests/test_instruments.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import datetime as dt
import numpy as np
import tempfile

import pytest
Expand Down Expand Up @@ -66,3 +68,21 @@ def teardown_class(self):
pysat.params.data['data_dirs'] = self.saved_path
self.tempdir.cleanup()
del self.inst_loc, self.saved_path, self.tempdir

# Custom package unit tests can be added here

@pytest.mark.parametrize("inst_dict", [x for x in instruments['download']])
@pytest.mark.parametrize("kwarg,output", [(None, 1), ('10s', 10)])
def test_inst_cadence(self, inst_dict, kwarg, output):
"""Test operation of cadence keyword, including default behavior"""

if kwarg:
self.test_inst = pysat.Instrument(
inst_module=inst_dict['inst_module'], cadence=kwarg)
else:
self.test_inst = pysat.Instrument(
inst_module=inst_dict['inst_module'])

self.test_inst.load(2019, 1)
cadence = np.diff(self.test_inst.data.index.to_pydatetime())
assert np.all(cadence == dt.timedelta(seconds=output))

0 comments on commit 35444b5

Please sign in to comment.