Skip to content

Commit

Permalink
Merge c0254db into b899cca
Browse files Browse the repository at this point in the history
  • Loading branch information
153957 committed Aug 15, 2018
2 parents b899cca + c0254db commit b710ec4
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ install:
- if [ "$ASTROPY" = "yes" ]; then
conda install --yes astropy;
fi
- pip install coverage coveralls codecov
- pip install -e .[dev]
- pip install -e .[dev,coverage]

script:
- make test
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
test: unittests flaketest doctest

unittests:
coverage run setup.py test
coverage run setup.py test --quiet

flaketest:
flake8 sapphire
Expand Down
2 changes: 1 addition & 1 deletion sapphire/analysis/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def determine_station_timing_offset(dt, dz=0):
p = percentile(dt, [0.5, 99.5])
# Bins should at least be 1 ns wide, on average at least 4 counts per bin
# and at most 200 bins.
bins = linspace(p[0], p[1], min(int(p[1] - p[0]), len(dt) / 4, 200))
bins = linspace(p[0], p[1], min(int(p[1] - p[0]), len(dt) // 4, 200))
station_offset, station_offset_error = fit_timing_offset(dt, bins)
station_offset += dz / c
if abs(station_offset) > 1000:
Expand Down
10 changes: 5 additions & 5 deletions sapphire/tests/transformations/test_axes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from numpy import arccos, matrix, pi, sqrt, testing
from numpy import arccos, array, pi, sqrt, testing

from sapphire.transformations import axes

Expand Down Expand Up @@ -76,7 +76,7 @@ class RotationMatrixTests(unittest.TestCase):
def test_no_rotation_matrix(self):
"""Check if no rotation is correctly returned"""

no_rotation = matrix(((1, 0, 0), (0, 1, 0), (0, 0, 1)))
no_rotation = array(((1, 0, 0), (0, 1, 0), (0, 0, 1)))
testing.assert_equal(axes.rotation_matrix(0, 'x'), no_rotation)
testing.assert_equal(axes.rotation_matrix(0, 'y'), no_rotation)
testing.assert_equal(axes.rotation_matrix(0, 'z'), no_rotation)
Expand All @@ -85,11 +85,11 @@ def test_rotation_matrix(self):
"""Rotate by 90 degrees to swap the other two axes"""

testing.assert_almost_equal(axes.rotation_matrix(pi / 2., 'x'),
matrix(((1, 0, 0), (0, 0, 1), (0, -1, 0))))
array(((1, 0, 0), (0, 0, 1), (0, -1, 0))))
testing.assert_almost_equal(axes.rotation_matrix(pi / 2., 'y'),
matrix(((0, 0, -1), (0, 1, 0), (1, 0, 0))))
array(((0, 0, -1), (0, 1, 0), (1, 0, 0))))
testing.assert_almost_equal(axes.rotation_matrix(pi / 2, 'z'),
matrix(((0, 1, 0), (-1, 0, 0), (0, 0, 1))))
array(((0, 1, 0), (-1, 0, 0), (0, 0, 1))))


if __name__ == '__main__':
Expand Down
12 changes: 6 additions & 6 deletions sapphire/transformations/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
- z: height above x,y-plane.
"""
from numpy import arccos, arctan2, cos, degrees, matrix, radians, sin, sqrt
from numpy import arccos, arctan2, array, cos, degrees, radians, sin, sqrt


def cartesian_to_spherical(x, y, z):
Expand Down Expand Up @@ -137,8 +137,8 @@ def rotate_cartesian(x, y, z, angle, axis='z'):
"""
rot = rotation_matrix(angle, axis)
new = (x, y, z) * rot
return new.item(0), new.item(1), new.item(2)
new = rot.T.dot((x, y, z))
return tuple(new)


def rotation_matrix(angle, axis='z'):
Expand All @@ -154,8 +154,8 @@ def rotation_matrix(angle, axis='z'):
sina = sin(angle)
cosa = cos(angle)
if axis == 'z':
return matrix(((cosa, sina, 0), (-sina, cosa, 0), (0, 0, 1)))
return array(((cosa, sina, 0), (-sina, cosa, 0), (0, 0, 1)))
elif axis == 'y':
return matrix(((cosa, 0, -sina), (0, 1, 0), (sina, 0, cosa)))
return array(((cosa, 0, -sina), (0, 1, 0), (sina, 0, cosa)))
elif axis == 'x':
return matrix(((1, 0, 0), (0, cosa, sina), (0, -sina, cosa)))
return array(((1, 0, 0), (0, cosa, sina), (0, -sina, cosa)))
12 changes: 6 additions & 6 deletions sapphire/transformations/geographic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
from math import atan2, cos, degrees, radians, sin, sqrt

from numpy import matrix
from numpy import array


class WGS84Datum(object):
Expand Down Expand Up @@ -149,14 +149,14 @@ def ecef_to_enu(self, coordinates):
lat = radians(latitude)
lon = radians(longitude)

transformation = matrix([
transformation = array([
[ -sin(lon), cos(lon), 0.], # noqa
[-sin(lat) * cos(lon), -sin(lat) * sin(lon), cos(lat)],
[ cos(lat) * cos(lon), cos(lat) * sin(lon), sin(lat)]]) # noqa

coordinates = matrix([[x - xr], [y - yr], [z - zr]])
coordinates = array([[x - xr], [y - yr], [z - zr]])

return (transformation * coordinates).A1
return transformation.dot(coordinates)

def enu_to_ecef(self, coordinates):
"""Convert from ENU coordinates to ECEF coordinates
Expand All @@ -174,12 +174,12 @@ def enu_to_ecef(self, coordinates):
lat = radians(latitude)
lon = radians(longitude)

transformation = matrix([
transformation = array([
[-sin(lon), -sin(lat) * cos(lon), cos(lat) * cos(lon)],
[ cos(lon), -sin(lat) * sin(lon), cos(lat) * sin(lon)], # noqa
[ 0., cos(lat), sin(lat)]]) # noqa

x, y, z = (transformation * matrix(coordinates).T).A1
x, y, z = transformation.dot(array(coordinates))

return x + xr, y + yr, z + zr

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@
'progressbar2>=3.7.0', 'lazy', 'mock', 'six'],
extras_require={
'dev': ['Sphinx', 'flake8', 'pep8-naming', 'coverage', 'flake8-isort'],
'coverage': ['coveralls', 'codecov'],
'astropy': ["astropy"]},
test_suite="sapphire.tests",)

0 comments on commit b710ec4

Please sign in to comment.