Skip to content

Commit

Permalink
Merge 248807e into 3d22234
Browse files Browse the repository at this point in the history
  • Loading branch information
jklenzing committed Aug 8, 2022
2 parents 3d22234 + 248807e commit f5ec4df
Show file tree
Hide file tree
Showing 16 changed files with 305 additions and 140 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
os: [ubuntu-latest]
os: ["ubuntu-latest", "windows-latest"]
numpy_ver: ["latest"]

name: Python ${{ matrix.python-version }} on ${{ matrix.os }} with numpy ${{ matrix.numpy_ver }}
Expand All @@ -32,7 +32,9 @@ jobs:
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install OMMBV
pip install aacgmv2 --no-binary==aacgmv2
pip install apexpy --no-binary==apexpy
pip install OMMBV --no-binary==OMMBV
- name: Set up pysat
run: |
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/).

## [0.3.2] - 2022-08-01
## [0.3.2] - 2022-XX-XX
* Make OMMBV an optional install
* Access logger directly from pysat
* Use pysat deprecation tests
* Incorporate Windows tests into Github Actions
* Bug Fix
* Ensure default num_samples consistent for one day regardless of cadence
* Maintenance
* Update instrument test standards
* Added `utils.package_check`, a standard decorator to bypass functions using
packages that are optional installs if the package is not installed
* Use local vector functions rather than import from OMMBV

## [0.3.1] - 2022-05-18
* Include license in package manifest
Expand Down
43 changes: 27 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ pysatMissions allows users to run build simulated satellites for Two-Line Elemen
Main Features
-------------
- Simulate satellite orbits from TLEs and add data from empirical models
- Import magnetic coordinates through apexpy and aacgmv2
- Import geomagnetic basis vectors through OMMBV (optional)
- Import magnetic coordinates through apexpy and aacgmv2 (optional install)

Documentation
---------------------
Expand All @@ -32,12 +31,12 @@ pysatMissions uses common Python modules, as well as modules developed by
and for the Space Physics community. This module officially supports
Python 3.8+.

| Common modules | Community modules |
| -------------- | ----------------- |
| numpy | aacgmv2 |
| pandas | apexpy |
| pyEphem | pysat>=3.0.2 |
| sgp4>=2.7 | |
| Common modules | Community modules | Optional modules |
| -------------- | ----------------- | ---------------- |
| numpy | pysat>=3.0.2 | aacgmv2 |
| pandas | | apexpy |
| pyEphem | | OMMBV |
| sgp4>=2.7 | | |


One way to install is through pip. Just type
Expand All @@ -63,17 +62,19 @@ python setup.py install

Note: pre-1.0.0 version
-----------------------
pysatMissions is currently in an initial development phase and requires pysat 3.0.2.
pysatMissions is currently in an initial development phase and requires pysat
3.0.2.

# Using with pysat

The instrument modules are portable and designed to be run like any pysat instrument.
The instrument modules are portable and designed to be run like any pysat
instrument.

```
import pysat
from pysatMissions.instruments import missions_ephem
from pysatMissions.instruments import missions_sgp4
simInst = pysat.Instrument(inst_module=missions_ephem)
sim_inst = pysat.Instrument(inst_module=missions_sgp4)
```
Another way to use the instruments in an external repository is to register the instruments. This only needs to be done the first time you load an instrument. Afterward, pysat will identify them using the `platform` and `name` keywords.

Expand All @@ -82,9 +83,19 @@ import pysat
import pysatMissions
pysat.utils.registry.register_by_module(pysatMissions.instruments)
simInst = pysat.Instrument('missions', 'ephem')
sim_inst = pysat.Instrument('missions', 'sgp4')
```

Note that some of the spacecraft vector calculations used require OMMBV, which
needs to be installed separately. This is an optional install as not all systems
support installation of OMMBV through pip.
# Optional modules

Magnetic vector coordinates through apexpy and aacgmv2 are set up as optional
installs. Both packages require fortran to install properly, and may require
additional configuration.

The instrument `missions_ephem` has been deprecated since pyEphem is no longer
maintained. This will be removed in v0.4.0. Note that OMMBV is required for
this instrument to function correctly, but is not required for the core
pysatMissions package. This has also been made optional to improve installation.
Please use the `missions_sgp4` instrument for future needs.

The orbital trajectories can be calculated without any of the optional modules.
16 changes: 8 additions & 8 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ pysatMissions uses common Python modules, as well as modules developed by
and for the Space Physics community. This module officially supports
Python 3.7+ and pysat 3.0.0+.

================ ==================
Common modules Community modules
================ ==================
numpy aacgmv2
pandas apexpy
pyEphem OMMBV>=1.0
sgp4>=2.7 pysat>=3.0
================ ==================
================ =================== ==================
Common modules Community modules Optional Modules
================ =================== ==================
numpy aacgmv2 apexpy
pandas pysat>=3.0.2 OMMBV>=1.0
pyEphem
sgp4>=2.7
================ =================== ==================


Installation Options
Expand Down
1 change: 0 additions & 1 deletion docs/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Main Features
-------------
- Simulate satellite orbits from TLEs and add data from empirical models
- Import magnetic coordinates through apexpy and aacgmv2
- Import geomagnetic basis vectors through OMMBV

This document covers installation, a tutorial on pysatMissions including
demonstration code, and an API reference.
4 changes: 2 additions & 2 deletions pysatMissions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
-------------
- Simulate satellite orbits from TLEs and add data from empirical models
- Import magnetic coordinates through apexpy and aacgmv2
- Import geomagnetic basis vectors through OMMBV
"""

Expand All @@ -18,10 +17,11 @@
try:
from pysatMissions import instruments
from pysatMissions import methods
from pysatMissions import utils
except ImportError as errstr:
logging.exception('problem importing pysatMissions: ' + str(errstr))

__all__ = ['instruments', 'methods']
__all__ = ['instruments', 'methods', 'utils']

# set version
here = os.path.abspath(os.path.dirname(__file__))
Expand Down
40 changes: 17 additions & 23 deletions pysatMissions/instruments/missions_ephem.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@
import pandas as pds
import pysat

try:
import OMMBV
except ImportError:
# Warnings thrown elsewhere if users call relevant functions without
# OMMBV installed
pass

from pysat.instruments.methods import testing as ps_meth
from pysatMissions.instruments import _core as mcore
from pysatMissions.methods import magcoord as mm_magcoord
Expand Down Expand Up @@ -88,11 +81,10 @@ def preprocess(self):
"""

mm_magcoord.add_quasi_dipole_coordinates(self)
mm_magcoord.add_aacgm_coordinates(self)
if "OMMBV" in dir():
mm_sc.calculate_ecef_velocity(self)
mm_sc.add_ram_pointing_sc_attitude_vectors(self)
mm_magcoord.add_quasi_dipole_coordinates(self)
mm_sc.calculate_ecef_velocity(self)
mm_sc.add_ram_pointing_sc_attitude_vectors(self)

return

Expand Down Expand Up @@ -206,21 +198,23 @@ def load(fnames, tag=None, inst_id=None, obs_long=0., obs_lat=0., obs_alt=0.,
# Elevation of satellite in m, converted to km
lp['alt'] = sat.elevation / 1000.0

# Get ECEF position of satellite
try:
lp['x'], lp['y'], lp['z'] = OMMBV.trans.geodetic_to_ecef(lp['glat'],
lp['glong'],
lp['alt'])
except NameError:
# Triggered if pyglow not installed
warnings.warn("OMMBV not installed. ECEF coords not generated.",
stacklevel=2)
lp['x'] = np.ones(np.size(lp['alt'])) * np.nan
lp['y'] = np.ones(np.size(lp['alt'])) * np.nan
lp['z'] = np.ones(np.size(lp['alt'])) * np.nan
output_params.append(lp)

output = pds.DataFrame(output_params, index=index)

# Get ECEF position of satellite
try:
output['x'], output['y'], output['z'] = \
OMMBV.trans.geodetic_to_ecef(output['glat'], output['glong'],
output['alt'])
except NameError:
# Triggered if OMMBV not installed
warnings.warn("OMMBV not installed. ECEF coords not generated.",
stacklevel=2)
output['x'] = output['glat'] * np.nan
output['y'] = output['glat'] * np.nan
output['z'] = output['glat'] * np.nan

# Modify input object to include calculated parameters
# Put data into DataFrame
data = pds.DataFrame({'glong': output['glong'],
Expand Down
18 changes: 14 additions & 4 deletions pysatMissions/methods/magcoord.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
"""Routines for projecting aacgmv2 and apexpy model values onto pysat instruments.
"""

import aacgmv2
import pysat
from pysatMissions.utils import package_check

# Warn user if aacgmv2 is not configured. Use of aacgmv2 functions elsewhere in
# code will produce additional warnings errors.
try:
import aacgmv2
except ImportError as ierr:
pysat.logger.warning(" ".join(["aacgmv2 module could not be imported.",
"aacgmv2 interface won't work.",
"Failed with error:", str(ierr)]))

# Warn user if apexpy is not configured. Use of apexpy functions elsewhere in
# code will produce additional warnings errors.
try:
# Warn user if apexpy is not configured. Bypass needed to function on
# readthedocs. Use of apexpy functions elsewhere in code will produce
# errors.
import apexpy
except ImportError as ierr:
pysat.logger.warning(" ".join(["apexpy module could not be imported.",
"apexpy interface won't work.",
"Failed with error:", str(ierr)]))


@package_check('aacgmv2')
def add_aacgm_coordinates(inst, glat_label='glat', glong_label='glong',
alt_label='alt'):
"""Add AACGM coordinates to instrument object using AACGMV2 package.
Expand Down Expand Up @@ -75,6 +84,7 @@ def add_aacgm_coordinates(inst, glat_label='glat', glong_label='glong',
return


@package_check('apexpy')
def add_quasi_dipole_coordinates(inst, glat_label='glat', glong_label='glong',
alt_label='alt'):
"""Add quasi-dipole coordinates to instrument object using Apexpy package.
Expand Down
Loading

0 comments on commit f5ec4df

Please sign in to comment.