Skip to content

Commit

Permalink
Merge pull request #20 from aburrell/develop
Browse files Browse the repository at this point in the history
convert_mlt bug
  • Loading branch information
Angeline Burrell authored May 22, 2018
2 parents f2b8ac9 + cc1f8cd commit 58be933
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.4.1
current_version = 2.4.2
commit = True
tag = True

Expand Down
12 changes: 9 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@

Changelog
=========
2.4.2 (2018-05-21)
-----------------------------------------
* Fixed bug in convert_mlt that caused all time inputs to occur
at 00:00:00 UT
* Fixed year of last two updates in changelog


2.4.1 (2017-04-04)
2.4.1 (2018-04-04)
-----------------------------------------
* Fix bug in installation, that caused files to be placed in the wrong
* Fix bug in installation that caused files to be placed in the wrong
directory
* Added DOI

2.4.0 (2017-03-21)
2.4.0 (2018-03-21)
-----------------------------------------

* Update to use AACGM-v2.4, which includes changes to the inverse MLT and
Expand Down
2 changes: 1 addition & 1 deletion aacgmv2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"""
import os.path as _path
import logbook as logging
__version__ = "2.4.1"
__version__ = "2.4.2"

# path and filename prefix for the IGRF coefficients
AACGM_V2_DAT_PREFIX = _path.join(_path.realpath(_path.dirname(__file__)),
Expand Down
24 changes: 23 additions & 1 deletion aacgmv2/tests/test_py_aacgmv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,18 +853,32 @@ class TestMLTConvert:
def setup(self):
"""Runs before every method to create a clean testing setup"""
self.dtime = dt.datetime(2015, 1, 1, 0, 0, 0)
self.dtime2 = dt.datetime(2015, 1, 1, 10, 0, 0)
self.ddate = dt.date(2015, 1, 1)
self.mlon_out = None
self.mlt_out = None
self.mlt_diff = None
self.mlon_list = [270.0, 80.0, -95.0]
self.mlt_list = [12.0, 25.0, -1.0]
self.mlon_comp = [-101.657689, 93.34231102, 63.34231102]
self.mlt_comp = [12.77717927, 0.1105126, 12.44384593]
self.diff_comp = np.ones(shape=(3,)) * -10.52411552

def teardown(self):
"""Runs after every method to clean up previous testing"""
del self.mlon_out, self.mlt_out, self.mlt_list, self.mlon_list
del self.mlon_comp, self.mlt_comp
del self.mlon_comp, self.mlt_comp, self.mlt_diff, self.diff_comp

def test_date_input(self):
"""Test to see that the date input works"""
self.mlt_out = aacgmv2.convert_mlt(self.mlon_list, self.ddate,
m2a=False)
np.testing.assert_allclose(self.mlt_out, self.mlt_comp, rtol=1.0e-4)

def test_datetime_exception(self):
"""Test to see that a value error is raised with bad time input"""
with pytest.raises(ValueError):
self.mlt_out = aacgmv2.wrapper.convert_mlt(self.mlon_list, 1997)

def test_inv_convert_mlt_single(self):
"""Test MLT inversion for a single value"""
Expand Down Expand Up @@ -924,6 +938,14 @@ def test_mlt_convert_arr(self):
self.dtime, m2a=False)
np.testing.assert_allclose(self.mlt_out, self.mlt_comp, rtol=1.0e-4)

def test_mlt_convert_change(self):
"""Test that MLT changes with UT"""
self.mlt_out = aacgmv2.convert_mlt(self.mlon_list, self.dtime)
self.mlt_diff = self.mlt_out - aacgmv2.convert_mlt(self.mlon_list,
self.dtime2)

np.testing.assert_allclose(self.mlt_diff, self.diff_comp, rtol=1.0e-4)

class TestCoeffPath:
def setup(self):
"""Runs before every method to create a clean testing setup"""
Expand Down
8 changes: 4 additions & 4 deletions aacgmv2/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,10 +531,10 @@ def convert_mlt(arr, dtime, m2a=False, coeff_prefix=None, igrf_file=None):

# Test time
if isinstance(dtime, dt.date):
dtime = dt.datetime.combine(dtime, dt.time(0))

assert isinstance(dtime, dt.datetime), \
logging.error('time must be specified as datetime object')
if not isinstance(dtime, dt.datetime):
dtime = dt.datetime.combine(dtime, dt.time(0))
else:
raise ValueError('time must be specified as datetime object')

# Calculate desired location, C routines set date and time
if m2a:
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
year = u'2015'
author = u'Angeline G. Burrell, Christer van der Meeren'
copyright = '{0}, {1}'.format(year, author)
version = release = u'2.4.1'
version = release = u'2.4.2'
# on_rtd is whether we are on readthedocs.org
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'

Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def read(fname, **kwargs):

setup(
name='aacgmv2',
version='2.4.1',
version='2.4.2',
license='MIT',
description='A Python wrapper for AACGM-v2 magnetic coordinates',
long_description='%s\n%s' % (read('README.rst'),
Expand All @@ -49,7 +49,6 @@ def read(fname, **kwargs):
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
Expand Down

0 comments on commit 58be933

Please sign in to comment.