Skip to content

Commit

Permalink
Merge pull request #91 from pysat/rc_0_3_2
Browse files Browse the repository at this point in the history
Release Candidate 0.3.2
  • Loading branch information
jklenzing committed Sep 6, 2022
2 parents debfe19 + 6ed124e commit 38c772a
Show file tree
Hide file tree
Showing 21 changed files with 419 additions and 249 deletions.
5 changes: 4 additions & 1 deletion .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,6 +32,9 @@ jobs:
- name: Install dependencies
run: |
pip install -r requirements.txt
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
7 changes: 6 additions & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@
},
{
"affiliation": "The University of Texas at Dallas",
"name": "Depew, Matthew"
"name": "Depew, Matthew",
"orcid": "0000-0001-9069-4998"
},
{
"name": "Spence, Carey",
"orcid": "0000-0001-8340-5625"
},
{
"name": "Bhaneja, Preeti",
"orcid": "0000-0003-4900-2747"
}
]
}
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
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-XX-XX
* Make fortran dependencies optional installs
* aacgmv2
* apexpy
* OMMBV
* 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
41 changes: 28 additions & 13 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
- Import magnetic coordinates through apexpy and aacgmv2 (optional install)

Documentation
---------------------
Expand All @@ -32,12 +31,11 @@ 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 | OMMBV>=1.0 |
| sgp4>=2.7 | pysat>=3.0 |
| Common modules | Community modules | Optional modules |
| -------------- | ----------------- | ---------------- |
| numpy | pysat>=3.0.4 | aacgmv2 |
| pandas | pyEphem | apexpy |
| | sgp4>=2.7 | OMMBV |


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

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

# 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,5 +82,20 @@ import pysat
import pysatMissions
pysat.utils.registry.register_by_module(pysatMissions.instruments)
simInst = pysat.Instrument('missions', 'ephem')
sim_inst = pysat.Instrument('missions', 'sgp4')
```

# 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. Both can be installed from pip, but may require the
`--no-binary` option depending on your system.

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.
19 changes: 9 additions & 10 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ Prerequisites

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
================ ==================
Python 3.8+ and pysat 3.0.4+.

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


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.
12 changes: 4 additions & 8 deletions pysatMissions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,16 @@
-------------
- Simulate satellite orbits from TLEs and add data from empirical models
- Import magnetic coordinates through apexpy and aacgmv2
- Import geomagnetic basis vectors through OMMBV
"""

import logging
import os

try:
from pysatMissions import instruments
from pysatMissions import methods
except ImportError as errstr:
logging.exception('problem importing pysatMissions: ' + str(errstr))
from pysatMissions import instruments
from pysatMissions import methods
from pysatMissions import utils

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

# set version
here = os.path.abspath(os.path.dirname(__file__))
Expand Down
25 changes: 16 additions & 9 deletions pysatMissions/instruments/missions_ephem.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import warnings

import ephem
import OMMBV
import pandas as pds
import pysat

Expand All @@ -39,8 +38,6 @@
from pysatMissions.methods import magcoord as mm_magcoord
from pysatMissions.methods import spacecraft as mm_sc

logger = pysat.logger

# -------------------------------
# Required Instrument attributes
platform = 'missions'
Expand All @@ -67,7 +64,7 @@ def init(self):
'The project uses the pyephem library available at',
'https://github.com/brandon-rhodes/pyephem'))
self.references = 'Please contact the pyephem project for references'
logger.info(self.acknowledgements)
pysat.logger.info(self.acknowledgements)

warnings.warn(' '.join(("`missions_ephem` has been deprecated and will be",
"removed in pysatMissions 0.4.0+.",
Expand All @@ -84,8 +81,8 @@ def preprocess(self):
"""

mm_magcoord.add_quasi_dipole_coordinates(self)
mm_magcoord.add_aacgm_coordinates(self)
mm_magcoord.add_quasi_dipole_coordinates(self)
mm_sc.calculate_ecef_velocity(self)
mm_sc.add_ram_pointing_sc_attitude_vectors(self)

Expand Down Expand Up @@ -201,13 +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
lp['x'], lp['y'], lp['z'] = OMMBV.trans.geodetic_to_ecef(lp['glat'],
lp['glong'],
lp['alt'])
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
8 changes: 4 additions & 4 deletions pysatMissions/instruments/missions_sgp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
from geospacepy import terrestrial_spherical as conv_sph
from sgp4 import api as sapi

logger = pysat.logger

# -------------------------------
# Required Instrument attributes
platform = 'missions'
Expand Down Expand Up @@ -59,7 +57,7 @@ def init(self):
'"Revisiting Spacetrack Report #3," presented at the AIAA/AAS',
'Astrodynamics Specialist Conference, Keystone, CO, 2006',
'August 21–24.'))
logger.info(self.acknowledgements)
pysat.logger.info(self.acknowledgements)

if 'epoch' not in self.kwargs['load'].keys():
self.kwargs['load']['epoch'] = self.files.files.index[0]
Expand Down Expand Up @@ -180,7 +178,9 @@ def load(fnames, tag=None, inst_id=None, tle1=None, tle2=None,
line2 = tle2

if (num_samples is None) or one_orbit:
num_samples = 86400
# Calculate one day of samples for default
num_samples = len(pds.date_range('2018/1/1', '2018/1/2',
freq=cadence)) - 1

# Extract list of times from filenames and inst_id
times, index, dates = ps_meth.generate_times(fnames, num_samples,
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.
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.
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

0 comments on commit 38c772a

Please sign in to comment.