Skip to content

Commit

Permalink
Merge pull request #53 from pysat/maint/ommbv
Browse files Browse the repository at this point in the history
MAINT: use OMMBV
  • Loading branch information
jklenzing committed May 26, 2021
2 parents ee6fa10 + 253603e commit 86d9fbc
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
pip install -r test_requirements.txt
pip install -r requirements.txt
# Manual installs required
pip install --no-binary :pysatMagVect: pysatMagVect
pip install --no-binary :OMMBV: OMMBV
- name: Set up pysat
run: |
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Use `cadence` instead of `freq`
- Use 'missions' as the platform name ('pysat' now reserved for core code)
- Migrate CI testing to Github Actions
- Use OMMBV instead of pysatMagVect

## [0.2.1] - 2020-07-29
- Use conda to manage Travis CI environment
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ 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
- Import geomagnetic basis vectors through OMMBV

Documentation
---------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ 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 pysatMagVect
- 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 docs/references.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ calculating magnetic apex coordinates.
* Laundal, K. M., & Richmond, A. D. (2017). Magnetic coordinate systems. Space
Science Reviews, 206, 27–59

pysatMagVect
OMMBV
------------

`pysatMagVect <https://github.com/rstoneback/pysatMagVect>`_ calculates
`OMMBV <https://github.com/rstoneback/OMMBV>`_ calculates
Orthogonal Multipole Magnetic Basis Vectors for the earth's magnetic field.
2 changes: 1 addition & 1 deletion docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Empirical Models
----------------

A number of methods are included to invoke several python wrappers for empirical
models. This includes the aacgmv2, apexpy, and pysatMagVect models. These
models. This includes the aacgmv2, apexpy, and OMMBV models. These
methods can be added to any pysat instrument using the `custom` functions in
pysat. The example below adds the aacgmv2 coordinates to one of the test
instruments in the core pysat package.
Expand Down
8 changes: 4 additions & 4 deletions pysatMissions/instruments/missions_ephem.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import numpy as np

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

Expand Down Expand Up @@ -186,9 +186,9 @@ def load(fnames, tag=None, inst_id=None, obs_long=0., obs_lat=0., obs_alt=0.,
# elevation of sat in m, stored as km
lp['alt'] = sat.elevation / 1000.
# get ECEF position of satellite
lp['x'], lp['y'], lp['z'] = pysatMagVect.geodetic_to_ecef(lp['glat'],
lp['glong'],
lp['alt'])
lp['x'], lp['y'], lp['z'] = OMMBV.geodetic_to_ecef(lp['glat'],
lp['glong'],
lp['alt'])
output_params.append(lp)

output = pds.DataFrame(output_params, index=index)
Expand Down
68 changes: 34 additions & 34 deletions pysatMissions/methods/spacecraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

import numpy as np
import pysatMagVect
import OMMBV


def add_ram_pointing_sc_attitude_vectors(inst):
Expand Down Expand Up @@ -42,45 +42,45 @@ def add_ram_pointing_sc_attitude_vectors(inst):

# ram pointing is along velocity vector
inst['sc_xhat_ecef_x'], inst['sc_xhat_ecef_y'], inst['sc_xhat_ecef_z'] = \
pysatMagVect.normalize_vector(inst['velocity_ecef_x'],
inst['velocity_ecef_y'],
inst['velocity_ecef_z'])
OMMBV.normalize_vector(inst['velocity_ecef_x'],
inst['velocity_ecef_y'],
inst['velocity_ecef_z'])

# begin with z along Nadir (towards Earth)
# if orbit isn't perfectly circular, then the s/c z vector won't
# point exactly along nadir. However, nadir pointing is close enough
# to the true z (in the orbital plane) that we can use it to get y,
# and use x and y to get the real z
inst['sc_zhat_ecef_x'], inst['sc_zhat_ecef_y'], inst['sc_zhat_ecef_z'] = \
pysatMagVect.normalize_vector(-inst['position_ecef_x'],
-inst['position_ecef_y'],
-inst['position_ecef_z'])
OMMBV.normalize_vector(-inst['position_ecef_x'],
-inst['position_ecef_y'],
-inst['position_ecef_z'])

# get y vector assuming right hand rule
# Z x X = Y
inst['sc_yhat_ecef_x'], inst['sc_yhat_ecef_y'], inst['sc_yhat_ecef_z'] = \
pysatMagVect.cross_product(inst['sc_zhat_ecef_x'],
inst['sc_zhat_ecef_y'],
inst['sc_zhat_ecef_z'],
inst['sc_xhat_ecef_x'],
inst['sc_xhat_ecef_y'],
inst['sc_xhat_ecef_z'])
OMMBV.cross_product(inst['sc_zhat_ecef_x'],
inst['sc_zhat_ecef_y'],
inst['sc_zhat_ecef_z'],
inst['sc_xhat_ecef_x'],
inst['sc_xhat_ecef_y'],
inst['sc_xhat_ecef_z'])
# normalize since Xhat and Zhat from above may not be orthogonal
inst['sc_yhat_ecef_x'], inst['sc_yhat_ecef_y'], inst['sc_yhat_ecef_z'] = \
pysatMagVect.normalize_vector(inst['sc_yhat_ecef_x'],
inst['sc_yhat_ecef_y'],
inst['sc_yhat_ecef_z'])
OMMBV.normalize_vector(inst['sc_yhat_ecef_x'],
inst['sc_yhat_ecef_y'],
inst['sc_yhat_ecef_z'])

# strictly, need to recalculate Zhat so that it is consistent with RHS
# just created
# Z = X x Y
inst['sc_zhat_ecef_x'], inst['sc_zhat_ecef_y'], inst['sc_zhat_ecef_z'] = \
pysatMagVect.cross_product(inst['sc_xhat_ecef_x'],
inst['sc_xhat_ecef_y'],
inst['sc_xhat_ecef_z'],
inst['sc_yhat_ecef_x'],
inst['sc_yhat_ecef_y'],
inst['sc_yhat_ecef_z'])
OMMBV.cross_product(inst['sc_xhat_ecef_x'],
inst['sc_xhat_ecef_y'],
inst['sc_xhat_ecef_z'],
inst['sc_yhat_ecef_x'],
inst['sc_yhat_ecef_y'],
inst['sc_yhat_ecef_z'])

# Adding metadata
inst.meta['sc_xhat_ecef_x'] = \
Expand Down Expand Up @@ -214,18 +214,18 @@ def project_ecef_vector_onto_sc(inst, x_label, y_label, z_label,
# TODO: add checks for existence of ecef labels in inst

x, y, z = \
pysatMagVect.project_ecef_vector_onto_basis(inst[x_label],
inst[y_label],
inst[z_label],
inst['sc_xhat_ecef_x'],
inst['sc_xhat_ecef_y'],
inst['sc_xhat_ecef_z'],
inst['sc_yhat_ecef_x'],
inst['sc_yhat_ecef_y'],
inst['sc_yhat_ecef_z'],
inst['sc_zhat_ecef_x'],
inst['sc_zhat_ecef_y'],
inst['sc_zhat_ecef_z'])
OMMBV.project_ecef_vector_onto_basis(inst[x_label],
inst[y_label],
inst[z_label],
inst['sc_xhat_ecef_x'],
inst['sc_xhat_ecef_y'],
inst['sc_xhat_ecef_z'],
inst['sc_yhat_ecef_x'],
inst['sc_yhat_ecef_y'],
inst['sc_yhat_ecef_z'],
inst['sc_zhat_ecef_x'],
inst['sc_zhat_ecef_y'],
inst['sc_zhat_ecef_z'])
inst[new_x_label] = x
inst[new_y_label] = y
inst[new_z_label] = z
Expand Down

0 comments on commit 86d9fbc

Please sign in to comment.