Skip to content

Commit

Permalink
Merge pull request #33 from pysat/develop
Browse files Browse the repository at this point in the history
v0.2.1
  • Loading branch information
jklenzing authored Jul 29, 2020
2 parents b53cf6d + f72486e commit e307266
Show file tree
Hide file tree
Showing 20 changed files with 153 additions and 131 deletions.
2 changes: 0 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[run]

[report]
omit =
*/tests/*
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ your test configuration

# Checklist:

- [ ] Make sure you are merging into the ``develop`` (not ``master``) branch
- [ ] Make sure you are merging into the ``develop`` (not ``main``) branch
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
Expand Down
36 changes: 29 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,35 @@ addons:
packages:
- gfortran

before_install:
install:
- sudo apt-get update
# We do this conditionally because it saves us some downloading if the
# version is the same.
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- source "$HOME/miniconda/etc/profile.d/conda.sh"
- hash -r
- conda config --set always_yes True --set changeps1 False
- conda update -q conda
# 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 activate test-environment
# Check for custom numpy version install
- if [ -z ${NUMPY_VER} ]; then
echo 'Using latest numpy';
else
pip install -q numpy==$NUMPY_VER;
conda install numpy==$NUMPY_VER;
fi
- pip install pytest-cov
- pip install coveralls
- pip install future
# Dependencies not available through conda, install through pip
- pip install apexpy
- pip install aacgmv2
- pip install madrigalWeb
- pip install pyEphem
- pip install sgp4
- pip install pytest-flake8
- pip install pysatCDF >/dev/null

# Prepare modified pysat install
- cd ..
Expand All @@ -48,9 +67,12 @@ before_install:
- cd ./pyglow
- make -C src/pyglow/models source >/dev/null
- python setup.py install >/dev/null
- cd ../pysatMissions

install:
# Install pysatMagVect after pysat
- pip install pysatMagVect >/dev/null

# install pysatMissions
- cd ../pysatMissions
- python setup.py install

before_script:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [0.2.1] - 2020-07-29
- Use conda to manage Travis CI environment
- Updated style to be compliant with pandas 2.0 and pysat 3.0
- Import datetime from datetime
- import DataFrame and Series from pandas rather than pysat
- Rename default branch as `main`

## [0.2.0] - 2020-03-07
- Renamed as pysatMissions
- Added method files to access aacgmv2, apexpy, pyglow for any pysat instrument
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
[![Documentation Status](https://readthedocs.org/projects/pysatmissions/badge/?version=latest)](https://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=master)](https://travis-ci.org/pysat/pysatMissions)
[![Coverage Status](https://coveralls.io/repos/github/pysat/pysatMissions/badge.svg?branch=master)](https://coveralls.io/github/pysat/pysatMissions?branch=master)
[![Build Status](https://travis-ci.org/pysat/pysatMissions.svg?branch=main)](https://travis-ci.org/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)

pysatMissions allows users to run build simulated satellites for Two-Line Elements (TLE) and add empirical data. It includes the pysat_ephem and pysat_sgp4 instrument modules which can be imported into pysat.
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The master toctree document.
# The main toctree document (using required variable name).
master_doc = 'index'

# The language for content autogenerated by Sphinx. Refer to documentation
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. pysatMissions documentation master file
.. pysatMissions documentation main file
Welcome to pysatMissions's documentation!
=========================================
Expand Down
5 changes: 4 additions & 1 deletion docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ A number of methods are included to invoke several python wrappers for empirical
from pysatMissions.methods import empirical
ivm = pysat.Instrument(platform='cnofs', name='ivm')
ivm.custom.attach(empirical.add_iri_thermal_plasma, 'modify', 'end', glat_label='glat', glong_label='glon', alt_label='altitude')
ivm.custom.attach(empirical.add_iri_thermal_plasma,
kwargs={'glat_label': 'glat',
'glong_label': 'glon',
'alt_label': 'altitude'})
Note that in this case, the latitude, longitude, and altitude variable names of the instrument must be specified since they are not identical to the default names in the function.
10 changes: 5 additions & 5 deletions pysatMissions/instruments/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
Handles the default pysat functions for simulated instruments
"""

import datetime as dt
import os
import pandas as pds
import pysat


def _list_files(tag=None, sat_id=None, data_path=None, format_str=None):
"""Produce a fake list of files spanning a year"""

index = pds.date_range(pysat.datetime(2017, 12, 1),
pysat.datetime(2018, 12, 1))
index = pds.date_range(dt.datetime(2017, 12, 1),
dt.datetime(2018, 12, 1))
# file list is effectively just the date in string format - '%D' works
# only in Mac. '%x' workins in both Windows and Mac
names = [data_path + date.strftime('%Y-%m-%d') + '.nofile'
for date in index]
return pysat.Series(names, index=index)
return pds.Series(names, index=index)


def _download(date_array, tag, sat_id, data_path=None):
Expand All @@ -33,7 +33,7 @@ def _get_times(fnames, sat_id):
yr = int(parts[0])
month = int(parts[1])
day = int(parts[2][0:2])
date = pysat.datetime(yr, month, day)
date = dt.datetime(yr, month, day)

# create timing at 1 Hz (defaults to 1 day)
# Allow numeric string to set number of time steps
Expand Down
53 changes: 27 additions & 26 deletions pysatMissions/instruments/pysat_ephem.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

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

Expand All @@ -29,7 +30,7 @@
tags = {'': 'Satellite simulation data set'}
# dictionary of satellite IDs, list of corresponding tags
sat_ids = {'': ['']}
_test_dates = {'': {'': pysat.datetime(2018, 1, 1)}}
_test_dates = {'': {'': dt.datetime(2018, 1, 1)}}


def init(self):
Expand All @@ -45,29 +46,29 @@ def init(self):
"""

# TODO: Update to custom.attach with release of pysat 3.0.0
self.custom.attach(mm_magcoord.add_quasi_dipole_coordinates, 'modify')
self.custom.attach(mm_magcoord.add_aacgm_coordinates, 'modify')
self.custom.attach(mm_sc.calculate_ecef_velocity, 'modify')
self.custom.attach(mm_sc.add_ram_pointing_sc_attitude_vectors, 'modify')
self.custom.attach(mm_magcoord.add_quasi_dipole_coordinates)
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, 'modify')
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, 'modify', 'end',
'B_ecef_x', 'B_ecef_y', 'B_ecef_z', 'B_sc_x', 'B_sc_y',
'B_sc_z', meta=[in_meta.copy(), in_meta.copy(),
in_meta.copy()])
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, 'modify')
self.custom.attach(mm_emp.add_iri_thermal_plasma)
# Thermal Neutral parameters
self.custom.attach(mm_emp.add_msis, 'modify')
self.custom.attach(mm_emp.add_hwm_winds_and_ecef_vectors, 'modify')
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, 'modify')
self.custom.attach(mm_emp.project_hwm_onto_sc)


def load(fnames, tag=None, sat_id=None, obs_long=0., obs_lat=0., obs_alt=0.,
Expand Down Expand Up @@ -169,17 +170,17 @@ def load(fnames, tag=None, sat_id=None, obs_long=0., obs_lat=0., obs_alt=0.,
output = pds.DataFrame(output_params, index=times)
# modify input object to include calculated parameters
# put data into DataFrame
data = pysat.DataFrame({'glong': output['glong'],
'glat': output['glat'],
'alt': output['alt'],
'position_ecef_x': output['x'],
'position_ecef_y': output['y'],
'position_ecef_z': output['z'],
'obs_sat_az_angle': output['obs_sat_az_angle'],
'obs_sat_el_angle': output['obs_sat_el_angle'],
'obs_sat_slant_range':
output['obs_sat_slant_range']},
index=times)
data = pds.DataFrame({'glong': output['glong'],
'glat': output['glat'],
'alt': output['alt'],
'position_ecef_x': output['x'],
'position_ecef_y': output['y'],
'position_ecef_z': output['z'],
'obs_sat_az_angle': output['obs_sat_az_angle'],
'obs_sat_el_angle': output['obs_sat_el_angle'],
'obs_sat_slant_range':
output['obs_sat_slant_range']},
index=times)
data.index.name = 'Epoch'

return data, meta.copy()
Expand Down
18 changes: 10 additions & 8 deletions pysatMissions/instruments/pysat_sgp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

from __future__ import print_function
from __future__ import absolute_import
import datetime as dt
import functools
import pandas as pds

import pysat

Expand All @@ -20,7 +22,7 @@
tags = {'': 'Satellite simulation data set'}
# dictionary of satellite IDs, list of corresponding tags
sat_ids = {'': ['']}
_test_dates = {'': {'': pysat.datetime(2018, 1, 1)}}
_test_dates = {'': {'': dt.datetime(2018, 1, 1)}}


def init(self):
Expand Down Expand Up @@ -117,13 +119,13 @@ def load(fnames, tag=None, sat_id=None, obs_long=0., obs_lat=0., obs_alt=0.,
velocity.extend(vel)

# put data into DataFrame
data = pysat.DataFrame({'position_eci_x': position[::3],
'position_eci_y': position[1::3],
'position_eci_z': position[2::3],
'velocity_eci_x': velocity[::3],
'velocity_eci_y': velocity[1::3],
'velocity_eci_z': velocity[2::3]},
index=times)
data = pds.DataFrame({'position_eci_x': position[::3],
'position_eci_y': position[1::3],
'position_eci_z': position[2::3],
'velocity_eci_x': velocity[::3],
'velocity_eci_y': velocity[1::3],
'velocity_eci_z': velocity[2::3]},
index=times)
data.index.name = 'Epoch'

# TODO: add call for GEI/ECEF translation here
Expand Down
17 changes: 9 additions & 8 deletions pysatMissions/methods/empirical.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def add_iri_thermal_plasma(inst, glat_label='glat', glong_label='glong',
Example
-------
# function added velow modifies the inst object upon every inst.load
call inst.custom.attach(add_iri_thermal_plasma, 'modify',
glat_label='custom_label')
call inst.custom.attach(add_iri_thermal_plasma,
kwargs={'glat_label': 'custom_label'})
"""

Expand All @@ -70,7 +70,8 @@ def add_iri_thermal_plasma(inst, glat_label='glat', glong_label='glong',
# Point class is instantiated. Its parameters are a function of
# time and spatial location
pt = Point(time, lat, lon, alt)
pt.run_iri()
# IRI-2016 currently experiencing bugs in pyglow
pt.run_iri(version=2012)
iri = {}
# After the model is run, its members like Ti, ni[O+], etc. can be
# accessed
Expand Down Expand Up @@ -142,7 +143,7 @@ def add_igrf(inst, glat_label='glat', glong_label='glong', alt_label='alt'):
Example
-------
# function added velow modifies the inst object upon every inst.load
call inst.custom.attach(add_igrf, 'modify', glat_label='custom_label')
call inst.custom.attach(add_igrf, kwargs={'glat_label': 'custom_label'})
"""

Expand Down Expand Up @@ -236,7 +237,7 @@ def add_msis(inst, glat_label='glat', glong_label='glong', alt_label='alt'):
Example
-------
# function added velow modifies the inst object upon every inst.load
call inst.custom.attach(add_msis, 'modify', glat_label='custom_label')
call inst.custom.attach(add_msis, kwargs={'glat_label': 'custom_label'})
"""

Expand Down Expand Up @@ -334,8 +335,8 @@ def add_hwm_winds_and_ecef_vectors(inst, glat_label='glat',
Example
-------
# function added velow modifies the inst object upon every inst.load
call inst.custom.attach(add_hwm_winds_and_ecef_vectors, 'modify',
glat_label='custom_label')
call inst.custom.attach(add_hwm_winds_and_ecef_vectors,
kwargs={'glat_label': 'custom_label'})
"""

Expand Down Expand Up @@ -441,7 +442,7 @@ def project_hwm_onto_sc(inst):
Example
-------
# function added velow modifies the inst object upon every inst.load
call inst.custom.attach(project_hwm_onto_sc, 'modify')
call inst.custom.attach(project_hwm_onto_sc)
"""

Expand Down
8 changes: 4 additions & 4 deletions pysatMissions/methods/magcoord.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def add_aacgm_coordinates(inst, glat_label='glat', glong_label='glong',
Example
-------
# function added velow modifies the inst object upon every inst.load
call inst.custom.attach(add_quasi_dipole_coordinates, 'modify',
glat_label='custom_label')
call inst.custom.attach(add_quasi_dipole_coordinates,
kwargs={'glat_label': 'custom_label'})
"""

Expand Down Expand Up @@ -101,8 +101,8 @@ def add_quasi_dipole_coordinates(inst, glat_label='glat', glong_label='glong',
Example
-------
# function added velow modifies the inst object upon every inst.load
call inst.custom.attach(add_quasi_dipole_coordinates, 'modify',
glat_label='custom_label')
call inst.custom.attach(add_quasi_dipole_coordinates,
kwargs={'glat_label': 'custom_label'})
"""

Expand Down
3 changes: 2 additions & 1 deletion pysatMissions/tests/test_instruments.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
To be replaced once pysat testing techniques are finalized
"""

import datetime as dt
import numpy as np
import pysat

Expand All @@ -27,7 +28,7 @@ def test_basic_instrument_load(self):
# Check if instrument is instrument
assert isinstance(self.testInst, pysat._instrument.Instrument)

self.testInst.load(date=pysat.datetime(2018, 1, 1))
self.testInst.load(date=dt.datetime(2018, 1, 1))
# Check for completeness of first set of targets
for target in self.targets1:
# Check if data is added
Expand Down
Loading

0 comments on commit e307266

Please sign in to comment.