Skip to content

Commit

Permalink
Merge pull request #37 from pysat/bug/remove_pyglow
Browse files Browse the repository at this point in the history
BUG/TST: remove pyglow
  • Loading branch information
jklenzing committed Dec 4, 2020
2 parents d12243e + c23e439 commit 3af6e6a
Show file tree
Hide file tree
Showing 18 changed files with 104 additions and 815 deletions.
40 changes: 14 additions & 26 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ language: python
dist: xenial
jobs:
include:
- name: Minimum NEP 029 versions
python: 3.6
env: NUMPY_VER=1.15
# Versions with latest numpy
- python: 3.6
- python: 3.7
- python: 3.8
- name: '3.6 w/ numpy 1.16 (NEP 029)'
python: '3.6'
env: NUMPY_VER=1.16
script: pytest --cov=pysatMissions/
- name: '3.7 with flake8'
python: '3.7'
script: pytest --flake8 --cov=pysatMissions/
- name: '3.8'
python: '3.8'
script: pytest --cov=pysatMissions/

services: xvfb
cache: pip
addons:
apt:
packages:
Expand All @@ -30,7 +34,7 @@ install:
# Useful for debugging any issues with conda
- conda info -a
# Create conda test environment
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION numpy scipy pandas xarray matplotlib requests beautifulsoup4 lxml netCDF4 h5py nose pytest-cov pytest-ordering coveralls future
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION numpy scipy pandas xarray netCDF4 h5py pytest-cov pytest-ordering coveralls portalocker
- conda activate test-environment
# Check for custom numpy version install
- if [ -z ${NUMPY_VER} ]; then
Expand All @@ -45,7 +49,6 @@ install:
- pip install pyEphem
- pip install sgp4
- pip install pytest-flake8
- pip install pysatCDF >/dev/null

# Prepare modified pysat install
- cd ..
Expand All @@ -58,15 +61,7 @@ install:
# install pysat
- git checkout develop-3
- python setup.py install >/dev/null

# install pyglow, space science models
- cd ..
- echo 'cloning pyglow'
- git clone https://github.com/timduly4/pyglow.git >/dev/null
- echo 'installing pyglow'
- cd ./pyglow
- make -C src/pyglow/models source >/dev/null
- python setup.py install >/dev/null
- export PYTHONPATH=$PYTHONPATH:$(pwd)

# Install pysatMagVect after pysat
- pip install pysatMagVect >/dev/null
Expand All @@ -75,12 +70,5 @@ install:
- cd ../pysatMissions
- python setup.py install

before_script:
# set up display screen
- export DISPLAY=:99.0

script:
- pytest -vs --cov=pysatMissions/

after_success:
- coveralls
- coveralls --rcfile=setup.cfg
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [0.3.0] - 2020-09-30
## [0.3.0] - 2020-12-03
- Update sat_id to inst_id for pysat 3.0 compatibility
- migrate pyglow interface to pysatIncubator
- Style updates for consistency with pysat 3.0

## [0.2.1] - 2020-07-29
- Use conda to manage Travis CI environment
Expand Down
19 changes: 1 addition & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![Documentation Status](https://readthedocs.org/projects/pysatMissions/badge/?version=latest)](http://pysatMissions.readthedocs.io/en/latest/?badge=latest)
[![DOI](https://zenodo.org/badge/209358908.svg)](https://zenodo.org/badge/latestdoi/209358908)

[![Build Status](https://travis-ci.org/pysat/pysatMissions.svg?branch=main)](https://travis-ci.org/pysat/pysatMissions)
[![Build Status](https://travis-ci.com/pysat/pysatMissions.svg?branch=main)](https://travis-ci.com/pysat/pysatMissions)
[![Coverage Status](https://coveralls.io/repos/github/pysat/pysatMissions/badge.svg?branch=main)](https://coveralls.io/github/pysat/pysatMissions?branch=main)
[![Maintainability](https://api.codeclimate.com/v1/badges/83011911691b9d2076e9/maintainability)](https://codeclimate.com/github/pysat/pysatMissions/maintainability)

Expand Down Expand Up @@ -59,10 +59,6 @@ python setup.py install
```
It should be noted that this is a working branch and is subject to change.

A note on empirical models
--------------------------
pysatMissions allows users to interact with a number of upper atmospheric empirical models through the [pyglow](https://github.com/timduly4/pyglow) package. However, pyglow currently requires manual install through git. While pysatMissions can be installed and used without pyglow, it should be installed by the user to access the pyglow methods. Please follow the install instructions at https://github.com/timduly4/pyglow.

# Using with pysat

The instrument modules are portable and designed to be run like any pysat instrument.
Expand All @@ -73,16 +69,3 @@ from pysatMissions.instruments import pysat_ephem
simInst = pysat.Instrument(inst_module=pysat_ephem)
```

The methods that run empirical models can also be exported to any pysat instrument. For instance, to add thermal plasma predictions from the IRI model to the C/NOFS IVM instrument, one can invoke

```
import pysat
from pysatMissions.methods import empirical
ivm = pysat.Instrument(platform='cnofs', name='ivm')
ivm.custom.attach(empirical.add_iri_thermal_plasma, 'modify',
glat_label='glat',
glong_label='glon', alt_label='altitude')
```
Once the custom function is added, the model will automatically be run when the dataset is loaded.
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Installation

----

Python and associated packages for science are freely available. Convenient science python package setups are available from https://www.python.org/ and `Anaconda <https://www.anaconda.com/distribution/>`_. Anaconda also includes a developer environment. Core science packages such as numpy, scipy, matplotlib, pandas and many others may also be installed directly via pip or your favorite package manager.
Python and associated packages for science are freely available. Convenient science python package setups are available from https://www.python.org/ and `Anaconda <https://www.anaconda.com/distribution/>`_. Anaconda also includes a developer environment. Core science packages such as numpy, scipy, pandas and many others may also be installed directly via pip or your favorite package manager.

For educational users, developer environments from `Jet Brains <https://www.jetbrains.com/student/>`_ are available for free.

Expand Down
1 change: 0 additions & 1 deletion docs/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ 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 ionosphere and thermosphere model values through pyglow
- Import magnetic coordinates through apexpy and aacgmv2
- Import geomagnetic basis vectors through pysatMagVect

Expand Down
2 changes: 1 addition & 1 deletion docs/references.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ Naval Research Laboratory Mass Spectrometer Incoherent Scatter radar Exobase (NR

----

`pysatMagVect <https://github.com/rstoneback/OMMBV>`_ calculates Orthogonal Multipole Magnetic Basis Vectors for the earth's magnetic field. pysatMagVect is being renamed OMMBV.
`pysatMagVect <https://github.com/rstoneback/pysatMagVect>`_ calculates Orthogonal Multipole Magnetic Basis Vectors for the earth's magnetic field.
3 changes: 1 addition & 2 deletions pysatMissions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
try:
from pysatMissions import instruments
from pysatMissions import methods
from pysatMissions import plot
except ImportError as errstr:
logging.exception('problem importing pysatMissions: ' + str(errstr))

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

# set version
here = os.path.abspath(os.path.dirname(__file__))
Expand Down
2 changes: 1 addition & 1 deletion pysatMissions/instruments/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _get_times(fnames, inst_id):
# create timing at 1 Hz (defaults to 1 day)
# Allow numeric string to set number of time steps
num = 86399 if inst_id == '' else int(inst_id)
times = pds.date_range(start=date, end=date+pds.DateOffset(seconds=num),
times = pds.date_range(start=date, end=(date + pds.DateOffset(seconds=num)),
freq='1S')

return times
41 changes: 13 additions & 28 deletions pysatMissions/instruments/pysat_ephem.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,17 @@
"""

from __future__ import print_function
from __future__ import absolute_import
import datetime as dt
import functools
import numpy as np

import ephem
import pysatMagVect
import pandas as pds
import pysat
import pysatMagVect

from pysatMissions.instruments import _core as mcore
from pysatMissions.methods import magcoord as mm_magcoord
from pysatMissions.methods import empirical as mm_emp
from pysatMissions.methods import spacecraft as mm_sc

# pysat required parameters
Expand Down Expand Up @@ -50,25 +47,6 @@ def init(self):
self.custom.attach(mm_magcoord.add_aacgm_coordinates)
self.custom.attach(mm_sc.calculate_ecef_velocity)
self.custom.attach(mm_sc.add_ram_pointing_sc_attitude_vectors)
# project simulated vectors onto s/c basis
# IGRF
self.custom.attach(mm_emp.add_igrf)
# create metadata to be added along with vector projection
in_meta = {'desc': 'IGRF geomagnetic field expressed in the s/c basis.',
'units': 'nT'}
# project IGRF
self.custom.attach(mm_sc.project_ecef_vector_onto_sc,
args=['B_ecef_x', 'B_ecef_y', 'B_ecef_z', 'B_sc_x',
'B_sc_y', 'B_sc_z'],
kwargs={'meta': [in_meta.copy(), in_meta.copy(),
in_meta.copy()]})
# Thermal Ion Parameters
self.custom.attach(mm_emp.add_iri_thermal_plasma)
# Thermal Neutral parameters
self.custom.attach(mm_emp.add_msis)
self.custom.attach(mm_emp.add_hwm_winds_and_ecef_vectors)
# project total wind vector
self.custom.attach(mm_emp.project_hwm_onto_sc)


def load(fnames, tag=None, inst_id=None, obs_long=0., obs_lat=0., obs_alt=0.,
Expand Down Expand Up @@ -160,7 +138,7 @@ def load(fnames, tag=None, inst_id=None, obs_long=0., obs_lat=0., obs_alt=0.,
# sublongitude point
lp['glong'] = np.degrees(sat.sublong)
# elevation of sat in m, stored as km
lp['alt'] = sat.elevation/1000.
lp['alt'] = sat.elevation / 1000.
# get ECEF position of satellite
lp['x'], lp['y'], lp['z'] = pysatMagVect.geodetic_to_ecef(lp['glat'],
lp['glong'],
Expand All @@ -186,6 +164,13 @@ def load(fnames, tag=None, inst_id=None, obs_long=0., obs_lat=0., obs_alt=0.,
return data, meta.copy()


def clean(self):
"""Cleaning function
"""

pass


list_files = functools.partial(mcore._list_files)
download = functools.partial(mcore._download)

Expand Down Expand Up @@ -215,8 +200,8 @@ def load(fnames, tag=None, inst_id=None, obs_long=0., obs_lat=0., obs_alt=0.,
meta['obs_sat_az_angle'] = {'units': 'degrees',
'desc': 'Azimuth of satellite from ground station'}
meta['obs_sat_el_angle'] = {'units': 'degrees',
'desc': 'Elevation of satellite from ground ' +
'station'}
'desc': ' '.join(('Elevation of satellite from',
'ground station'))}
meta['obs_sat_slant_range'] = {'units': 'km',
'desc': 'Distance of satellite from ground ' +
'station'}
'desc': ' '.join(('Distance of satellite from',
'ground station'))}
21 changes: 13 additions & 8 deletions pysatMissions/instruments/pysat_sgp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
"""

from __future__ import print_function
from __future__ import absolute_import
import datetime as dt
import functools
import pandas as pds
Expand Down Expand Up @@ -133,6 +131,13 @@ def load(fnames, tag=None, inst_id=None, obs_long=0., obs_lat=0., obs_alt=0.,
return data, meta.copy()


def clean(self):
"""Cleaning function
"""

pass


list_files = functools.partial(mcore._list_files)
download = functools.partial(mcore._download)

Expand All @@ -146,18 +151,18 @@ def load(fnames, tag=None, inst_id=None, obs_long=0., obs_lat=0., obs_alt=0.,
'long_name': 'Time index in milliseconds'}
meta['position_eci_x'] = {'units': 'km',
'long_name': 'ECI x-position',
'desc': 'Earth Centered Inertial x-position of ' +
'satellite.',
'desc': ' '.join(('Earth Centered Inertial',
'x-position of satellite.')),
'label': 'ECI-X'}
meta['position_eci_y'] = {'units': 'km',
'long_name': 'ECI y-position',
'desc': 'Earth Centered Inertial y-position of ' +
'satellite.',
'desc': ' '.join(('Earth Centered Inertial',
'y-position of satellite.')),
'label': 'ECI-Y'}
meta['position_eci_z'] = {'units': 'km',
'long_name': 'ECI z-position',
'desc': 'Earth Centered Inertial z-position of ' +
'satellite.',
'desc': ' '.join(('Earth Centered Inertial',
'z-position of satellite.')),
'label': 'ECI-Z'}
meta['velocity_eci_x'] = {'units': 'km/s',
'desc': 'Satellite velocity along ECI-x',
Expand Down
3 changes: 1 addition & 2 deletions pysatMissions/methods/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
the methods to interface with numerous empirical model packages
"""

from pysatMissions.methods import empirical
from pysatMissions.methods import magcoord
from pysatMissions.methods import spacecraft

__all__ = ['empirical', 'magcoord', 'spacecraft']
__all__ = ['magcoord', 'spacecraft']

0 comments on commit 3af6e6a

Please sign in to comment.