diff --git a/Changelog.rst b/Changelog.rst index 1e5c9aae..92250eeb 100644 --- a/Changelog.rst +++ b/Changelog.rst @@ -6,6 +6,9 @@ Summary of all changes made since the first stable release 0.5.0 (XX-XX-2024) ------------------ * DEP: Removed deprecated functions that depend on ssj_auroral_boundary package +* DEP: Removed deprecated methods, attributes, and kwargs in VectorData +* BUG: Fixed `zenodo-get` import in pyproject.toml +* TST: Updated GitHub Actions yamls 0.4.0 (06-07-2024) ------------------ diff --git a/ocbpy/ocb_scaling.py b/ocbpy/ocb_scaling.py index 1db3a616..0378157a 100644 --- a/ocbpy/ocb_scaling.py +++ b/ocbpy/ocb_scaling.py @@ -18,7 +18,6 @@ import aacgmv2 import numpy as np -import warnings import ocbpy from ocbpy import ocb_time @@ -69,9 +68,6 @@ class VectorData(object): Function for scaling AACGM magnitude with arguements: [measurement value, mesurement AACGM latitude (degrees), mesurement OCB latitude (degrees)] (default=None) - **kwargs : dict - Accepts deprecated parameters: `aacgm_lat`, `aacgm_mlt`, `aacgm_n`, - `aacgm_e`, `aacgm_z`, and `aacgm_mag`. Attributes ---------- @@ -96,9 +92,6 @@ class VectorData(object): pole_angle : float or array-like Angle at vector location appended by AACGM and OCB poles in degrees (default=np.nan) - aacgm_naz : float or array-like - AACGM north azimuth of data vector in degrees; deprecated - (default=np.nan) ocb_aacgm_lat : float or array-like AACGM latitude of OCB pole in degrees (default=np.nan) ocb_aacgm_mlt : float or array-like @@ -108,21 +101,13 @@ class VectorData(object): ----- May only handle one data type, so scale_func cannot be an array - Warnings - -------- - DeprecationWarning - Several kwargs/attributes and method have been changed to reflect new - allowed input types (data in geodetic or geographic coordinates). - Support for the old parameters and methods will be removed in - version 0.4.1+. - """ def __init__(self, dat_ind, ocb_ind, lat, lt, height=350.0, loc_coord='magnetic', ocb_lat=np.nan, ocb_mlt=np.nan, r_corr=np.nan, vect_n=0.0, vect_e=0.0, vect_z=0.0, vect_mag=np.nan, vect_coord='magnetic', dat_name=None, - dat_units=None, scale_func=None, **kwargs): + dat_units=None, scale_func=None): # Assign the vector data name and units self.dat_name = dat_name @@ -141,42 +126,7 @@ def __init__(self, dat_ind, ocb_ind, lat, lt, height=350.0, self.height = height self.loc_coord = loc_coord.lower() self.vect_coord = vect_coord.lower() - - # Check for deprecated values - set_mag = True - if len(kwargs.keys()) > 0: - used_dep = list() - dep_pairs = {'aacgm_n': 'vect_n', 'aacgm_e': 'vect_e', - 'aacgm_lat': 'lat', 'aacgm_mlt': 'lt', - 'aacgm_z': 'vect_z', 'aacgm_mag': 'vect_mag'} - for dep_key in dep_pairs.keys(): - if dep_key in kwargs.keys(): - # Save the deprecated kwarg to raise a single warning later - used_dep.append(dep_key) - - # Update the new attribute - setattr(self, dep_pairs[dep_key], kwargs[dep_key]) - - if dep_key == 'aacgm_mag': - set_mag = False - - # Raise a warning - if len(used_dep) < len(kwargs.keys()): - ocbpy.logger.warning('unknown kwargs, ignored: {:}'.format( - [key for key in kwargs.keys() if key not in used_dep])) - else: - new_kwargs = [dep_pairs[dep_key] for dep_key in used_dep] - warnings.warn("".join(['kwargs have been replaced with new ', - 'names that reflect their new scope. ', - 'Old kwargs will be removed in version ', - '0.4.1+. Old kwargs used: ', - repr(used_dep), '; replace with: ', - repr(new_kwargs)]), - DeprecationWarning, stacklevel=2) - - if set_mag: - # Set the magnitude if the deprecated kwarg was not supplied - self.vect_mag = vect_mag + self.vect_mag = vect_mag # Test the coordinate systems for valid options self._test_coords() @@ -339,53 +289,10 @@ def __setattr__(self, name, value): if type_str.find('int') < 0 and type_str.find('float') < 0: out_val = value - # TODO(#133): remove after old attributes are deprecated - dep_pairs = {'aacgm_n': 'vect_n', 'aacgm_e': 'vect_e', - 'aacgm_lat': 'lat', 'aacgm_mlt': 'lt', - 'aacgm_z': 'vect_z', 'aacgm_mag': 'vect_mag'} - if name in dep_pairs.keys(): - warnings.warn("".join([name, ' has been replaced with ', - dep_pairs[name], '. Old attribute will be ', - 'removed in version 0.4.1+.']), - DeprecationWarning, stacklevel=2) - name = dep_pairs[name] - # Use Object to avoid recursion super(VectorData, self).__setattr__(name, out_val) return - # TODO(#133): remove after old attributes are deprecated - def __getattribute__(self, name, **kwargs): - """Get attributes, allowing access to deprecated names. - - Parameters - ---------- - name : str - Attribute name to be accessed from VectorData - - Returns - ------- - value : any - Value assigned to the attribute - - """ - # Define the deprecated attributes that are not properties - dep_pairs = {'aacgm_n': 'vect_n', 'aacgm_e': 'vect_e', - 'aacgm_z': 'vect_z'} - if name in dep_pairs.keys(): - warnings.warn("".join([name, ' has been replaced with ', - dep_pairs[name], '. Old attribute will be ', - 'removed in version 0.4.1+.']), - DeprecationWarning, stacklevel=2) - name = dep_pairs[name] - elif name == "aacgm_naz": - warnings.warn('`aacgm_naz` will be removed in version 0.4.1+.', - DeprecationWarning, stacklevel=2) - - # Use Object to avoid recursion - value = super(VectorData, self).__getattribute__(name) - return value - def _ocb_attr_setter(self, ocb_name, ocb_val): """Set OCB attributes. @@ -573,15 +480,6 @@ def vect_mag(self, vect_mag): self._vect_mag = vect_mag return - @property - def aacgm_mag(self): - """Deprecated magnitude of the vector(s).""" - # TODO(#133): remove after old attributes are deprecated - warnings.warn("".join(['`aacgm_mag` has been replaced with `vect_mag`,', - ' and will be removed in version 0.4.1+.']), - DeprecationWarning, stacklevel=2) - return self.vect_mag - @property def dat_ind(self): """Data index(es).""" @@ -689,15 +587,6 @@ def lat(self, lat): self._dat_attr_setter('_lat', lat) return - @property - def aacgm_lat(self): - """Deprecated magnitude of the vector(s).""" - # TODO(#133): remove after old attributes are deprecated - warnings.warn("".join(['`aacgm_lat` has been replaced with `lat`, and ', - 'will be removed in version 0.4.1+.']), - DeprecationWarning, stacklevel=2) - return self.lat - @property def lt(self): """Vector local time in hours.""" @@ -709,15 +598,6 @@ def lt(self, lt): self._dat_attr_setter('_lt', lt) return - @property - def aacgm_mlt(self): - """Deprecated magnitude of the vector(s).""" - # TODO(#133): remove after old attributes are deprecated - warnings.warn("".join(['`aacgm_mlt` has been replaced with `lt`, and ', - 'will be removed in version 0.4.1+.']), - DeprecationWarning, stacklevel=2) - return self.lt - @property def height(self): """Vector in km.""" @@ -731,8 +611,6 @@ def height(self, height): def clear_data(self): """Clear or initialize the output data attributes.""" - warnings.simplefilter("ignore") - # Assign the OCB vector default values and location self.ocb_n = np.full(shape=self.vshape, fill_value=np.nan) self.ocb_e = np.full(shape=self.vshape, fill_value=np.nan) @@ -743,12 +621,9 @@ def clear_data(self): self.ocb_quad = np.zeros(shape=self.vshape) self.vec_quad = np.zeros(shape=self.vshape) self.pole_angle = np.full(shape=self.vshape, fill_value=np.nan) - # TODO(#133): remove `aacgm_naz` - self.aacgm_naz = np.full(shape=self.vshape, fill_value=np.nan) self.ocb_aacgm_lat = np.full(shape=self.vshape, fill_value=np.nan) self.ocb_aacgm_mlt = np.full(shape=self.vshape, fill_value=np.nan) - warnings.resetwarnings() return def set_ocb(self, ocb, scale_func=None, trace_method='ALLOWTRACE'): @@ -902,12 +777,8 @@ def scale_vector(self): ----- Requires `lat`, `lt`, `ocb_aacgm_mlt`, `ocb_aacgm_lat`, and `pole_angle`. Updates `ocb_n`, `ocb_e`, `ocb_z`, and `ocb_mag`. - Temporarily updates `aacgm_naz`, which has been deprecated and will - be removed in version 0.4.1+. """ - warnings.simplefilter("ignore") - # Test input if np.all(np.isnan(self.lat)) or np.all(np.isnan(self.lt)): raise ValueError("Vector locations required") @@ -924,17 +795,6 @@ def scale_vector(self): self.vec_quad, self.ocb_aacgm_mlt, self.ocb_aacgm_lat, self.pole_angle, self.ocb_quad) - # TODO(#133): remove `aacgm_naz` - vmag = np.sqrt(self.vect_n**2 + self.vect_e**2) - if len(vmag.shape) == 0: - self.aacgm_naz = np.degrees(np.arccos(self.vect_n / vmag)) - else: - zero_mask = ((self.vect_n == 0.0) & (self.vect_e == 0.0)) - ns_mask = ((self.pole_angle == 0.0) | (self.pole_angle == 180.0)) - norm_mask = ~(zero_mask + ns_mask) - self.aacgm_naz[norm_mask] = np.degrees(np.arccos( - self.vect_n[norm_mask] / vmag[norm_mask])) - # Scale the outputs, if desired if self.scale_func is not None: if len(self.ocb_n.shape) == 0: @@ -958,103 +818,8 @@ def scale_vector(self): # Calculate the scaled OCB vector magnitude self.ocb_mag = np.sqrt(self.ocb_n**2 + self.ocb_e**2 + self.ocb_z**2) - warnings.resetwarnings() return - def calc_ocb_polar_angle(self): - """Calculate the OCB north azimuth angle. - - Returns - ------- - ocb_naz : float or array-like - Angle between measurement vector and OCB pole in degrees - - Raises - ------ - ValueError - If the required input is undefined - - Notes - ----- - Requires `ocb_quad`, `vec_quad`, `aacgm_naz`, and `pole_angle` - - """ - # TODO(#133): deprecation warning, method is no longer needed here - warnings.warn("".join(["`calc_ocb_polar_angle` method deprecated, and", - " will be removed in version 0.4.1+. Instead, ", - "use `ocbpy.vectors.calc_dest_polar_angle`."]), - DeprecationWarning, stacklevel=2) - - # Test input - warnings.simplefilter("ignore") - if np.all(np.isnan(self.aacgm_naz)): - raise ValueError("AACGM North polar angle undefined") - - if np.all(np.isnan(self.pole_angle)): - raise ValueError("Vector angle undefined") - - # Calcuate the North azimuth angle for the OCB pole - ocb_naz = vectors.calc_dest_polar_angle( - self.ocb_quad, self.vec_quad, self.aacgm_naz, self.pole_angle) - - warnings.resetwarnings() - return ocb_naz - - def calc_ocb_vec_sign(self, north=False, east=False, quads=None): - """Calculate the sign of the North and East components. - - Parameters - ---------- - north : bool - Get the sign of the north component(s) (default=False) - east : bool - Get the sign of the east component(s) (default=False) - quads : dict or NoneType - Dictionary of boolean values or arrays of boolean values for OCB - and Vector quadrants. (default=None) - - Returns - ------- - vsigns : dict - Dictionary with keys 'north' and 'east' containing the desired - signs - - Raises - ------ - ValueError - If the required input is undefined - - Notes - ----- - Requires `ocb_quad`, `vec_quad`, `aacgm_naz`, and `pole_angle`. - Method is deprecated and will be removed in version 0.4.1+. - - """ - # TODO(#133): deprecation warning, method is no longer needed here - warnings.warn("".join(["`calc_ocb_vec_sign` method deprecated, and", - " will be removed in version 0.4.1+. Instead, ", - "use `ocbpy.vectors.calc_dest_vec_sign`."]), - DeprecationWarning, stacklevel=2) - - # Test input - warnings.simplefilter("ignore") - if not np.any([north, east]): - raise ValueError("must set at least one direction") - - if np.all(np.isnan(self.aacgm_naz)): - raise ValueError("AACGM polar angle undefined") - - if np.all(np.isnan(self.pole_angle)): - raise ValueError("Vector angle undefined") - - # Calcualte the sign of the North and East vector components - vsigns = vectors.calc_dest_vec_sign( - self.ocb_quad, self.vec_quad, self.aacgm_naz, self.pole_angle, - north=north, east=east, quads=quads) - - warnings.resetwarnings() - return vsigns - def calc_vec_pole_angle(self): """Calc the angle between the AACGM pole, data, and the OCB pole. diff --git a/ocbpy/tests/test_ocb_scaling.py b/ocbpy/tests/test_ocb_scaling.py index b89fbce9..f2936023 100644 --- a/ocbpy/tests/test_ocb_scaling.py +++ b/ocbpy/tests/test_ocb_scaling.py @@ -18,206 +18,6 @@ import ocbpy.tests.class_common as cc -# TODO(#133): delete after deprecated elements are removed -class TestOCBScalingDepWarning(unittest.TestCase): - """Unit tests for Deprecation Warnings in the VectorData class.""" - - def setUp(self): - """Initialize the OCBoundary and VectorData objects.""" - - self.dep_attrs = {'aacgm_lat': 'lat', 'aacgm_mlt': 'lt', - 'aacgm_n': 'vect_n', 'aacgm_e': 'vect_e', - 'aacgm_z': 'vect_z', 'aacgm_mag': 'vect_mag'} - self.vdata_args = [0, 27, 80.0, 5.5] - self.vdata_kwargs = {'vect_n': 1.0, 'vect_e': 0.0, 'vect_z': 0.0, - 'vect_mag': 1.0} - self.warn_msg = '' - return - - def tearDown(self): - """Tear down the test environment.""" - del self.dep_attrs, self.vdata_args, self.vdata_kwargs, self.warn_msg - return - - def test_init_dep_attr(self): - """Test the set up of the VectorData object with a deprecated attr.""" - - # Cycle through the deprecated inputs - for attr in self.dep_attrs.keys(): - # Set the input - kwargs = {key: self.vdata_kwargs[key] - for key in self.vdata_kwargs.keys() - if key != self.dep_attrs[attr]} - - if self.dep_attrs[attr] in self.vdata_kwargs.keys(): - kwargs[attr] = self.vdata_kwargs[self.dep_attrs[attr]] - else: - kwargs[attr] = self.vdata_args[-1] if attr.find( - 'lt') > 0 else self.vdata_args[-2] - - # Set the warning message - self.warn_msg = attr - - with self.subTest(kwargs=kwargs): - # Capture and evaluate the warning message - with self.assertWarnsRegex(DeprecationWarning, self.warn_msg): - ocbpy.ocb_scaling.VectorData(*self.vdata_args, **kwargs) - return - - def test_init_dep_attrs(self): - """Test the set up of the VectorData object with deprecated attrs.""" - - # Set the deprecated inputs - for attr in self.dep_attrs: - if self.dep_attrs[attr] in self.vdata_kwargs.keys(): - self.vdata_kwargs[attr] = self.vdata_kwargs[ - self.dep_attrs[attr]] - del self.vdata_kwargs[self.dep_attrs[attr]] - else: - self.vdata_kwargs[attr] = self.vdata_args[-1] if attr.find( - 'lt') > 0 else self.vdata_args[-2] - - # Set the warning message - self.warn_msg = 'Old kwargs will be removed in version 0.4.1+.' - - # Capture and evaluate the warning message - with self.assertWarnsRegex(DeprecationWarning, self.warn_msg): - ocbpy.ocb_scaling.VectorData(*self.vdata_args, **self.vdata_kwargs) - return - - def test_get_dep_attr(self): - """Test the retrieval of deprecated attributes from VectorData.""" - # Set the vector data - vdata = ocbpy.ocb_scaling.VectorData(*self.vdata_args, - **self.vdata_kwargs) - - # Set the warning message - self.warn_msg = "has been replaced" - - # Cycle through the deprecated attributes - for attr in self.dep_attrs.keys(): - with self.subTest(dep_attr=attr): - # Capture and evaluate the warning message - with self.assertWarnsRegex(DeprecationWarning, self.warn_msg): - getattr(vdata, attr) - return - - def test_set_dep_attr(self): - """Test setting deprecated attributes from VectorData.""" - # Set the warning message - self.warn_msg = "has been replaced" - - # Cycle through the deprecated attributes - for attr in self.dep_attrs.keys(): - # Set the vector data object - vdata = ocbpy.ocb_scaling.VectorData(*self.vdata_args, - **self.vdata_kwargs) - - # Get the initial value for the object - comp_val = getattr(vdata, self.dep_attrs[attr]) - - with self.subTest(dep_attr=attr): - # Capture and evaluate the warning message - with self.assertWarnsRegex(DeprecationWarning, self.warn_msg): - setattr(vdata, attr, comp_val + 1.0) - - self.assertEqual(getattr(vdata, self.dep_attrs[attr]), - comp_val + 1.0, msg="{:} not updated".format( - self.dep_attrs[attr])) - return - - def test_get_aacgm_naz(self): - """Test retrieval of deprecated `aacgm_naz` from VectorData.""" - # Set the warning message - self.warn_msg = "will be removed in version 0.4.1+." - - # Set the vector data object - vdata = ocbpy.ocb_scaling.VectorData(*self.vdata_args, - **self.vdata_kwargs) - - # Capture and evaluate the warning message - with self.assertWarnsRegex(DeprecationWarning, self.warn_msg): - self.assertTrue(numpy.isnan(vdata.aacgm_naz)) - - return - - def test_dep_aacgm_mag(self): - """Test VectorData property `aacgm_mag` is deprecated.""" - # Set the vector data - vdata = ocbpy.ocb_scaling.VectorData(*self.vdata_args, - **self.vdata_kwargs) - # Set the warning message - self.warn_msg = "has been replaced with `vect_mag`, and will be removed" - - # Capture and evaluate the warning message - with self.assertWarnsRegex(DeprecationWarning, self.warn_msg): - self.assertEqual(vdata.aacgm_mag, vdata.vect_mag) - return - - def test_dep_aacgm_lat(self): - """Test VectorData property `aacgm_lat` is deprecated.""" - # Set the vector data - vdata = ocbpy.ocb_scaling.VectorData(*self.vdata_args, - **self.vdata_kwargs) - # Set the warning message - self.warn_msg = "has been replaced with `lat`, and will be removed" - - # Capture and evaluate the warning message - with self.assertWarnsRegex(DeprecationWarning, self.warn_msg): - self.assertEqual(vdata.aacgm_lat, vdata.lat) - return - - def test_dep_aacgm_mlt(self): - """Test VectorData property `aacgm_mlt` is deprecated.""" - # Set the vector data - vdata = ocbpy.ocb_scaling.VectorData(*self.vdata_args, - **self.vdata_kwargs) - # Set the warning message - self.warn_msg = "has been replaced with `lt`, and will be removed" - - # Capture and evaluate the warning message - with self.assertWarnsRegex(DeprecationWarning, self.warn_msg): - self.assertEqual(vdata.aacgm_mlt, vdata.lt) - return - - def test_dep_calc_ocb_polar_angle(self): - """Test VectorData method `calc_ocb_polar_angle` is deprecated.""" - # Set the vector data - vdata = ocbpy.ocb_scaling.VectorData(*self.vdata_args, - **self.vdata_kwargs) - vdata.ocb_quad = 1 - vdata.vec_quad = 1 - vdata.aacgm_naz = 5.0 - vdata.pole_angle = 3.0 - - # Set the warning message - self.warn_msg = "Instead, use `ocbpy.vectors.calc_dest_polar_angle`" - - # Capture and evaluate the warning message - with self.assertWarnsRegex(DeprecationWarning, self.warn_msg): - self.assertEqual(vdata.calc_ocb_polar_angle(), 2.0) - return - - def test_dep_calc_ocb_vec_sign(self): - """Test VectorData method `calc_ocb_vec_sign` is deprecated.""" - # Set the vector data - vdata = ocbpy.ocb_scaling.VectorData(*self.vdata_args, - **self.vdata_kwargs) - vdata.ocb_quad = 1 - vdata.vec_quad = 1 - vdata.aacgm_naz = 5.0 - vdata.pole_angle = 3.0 - - # Set the warning message - self.warn_msg = "Instead, use `ocbpy.vectors.calc_dest_vec_sign`" - - # Capture and evaluate the warning message - with self.assertWarnsRegex(DeprecationWarning, self.warn_msg): - self.assertDictEqual(vdata.calc_ocb_vec_sign(north=True, east=True), - {'north': 1, 'east': 1}) - return - - class TestOCBScalingLogFailure(cc.TestLogWarnings): """Unit tests for logging messages in ocb_scaling module.""" @@ -272,21 +72,6 @@ def test_inconsistent_vector_warning(self): self.eval_logging_message() return - def test_unknown_kwargs(self): - """Test warning raised with unknown kwargs.""" - self.lwarn = u"unknown kwargs, ignored:" - - # Initalize the VectorData class with deprecated and unknown kwargs - self.vdata = ocbpy.ocb_scaling.VectorData(0, self.ocb.rec_ind, - 75.0, 22.0, aacgm_n=1.0, - vect_fun=100.0, - dat_name="Test", - dat_units="$m s^{-1}$") - - # Test logging error message for the bad initialization - self.eval_logging_message() - return - class TestOCBScalingMethods(unittest.TestCase): """Unit tests for the VectorData class.""" @@ -422,7 +207,7 @@ def test_vector_clear_data(self): # Evaluate values are NaN self.ocb_attrs = ['ocb_n', 'ocb_e', 'ocb_z', 'ocb_mag', 'pole_angle', - 'aacgm_naz', 'ocb_aacgm_lat', 'ocb_aacgm_mlt'] + 'ocb_aacgm_lat', 'ocb_aacgm_mlt'] for attr in self.ocb_attrs: with self.subTest(attr=attr): val = getattr(self.vdata, attr) @@ -458,56 +243,6 @@ def test_calc_large_pole_angle(self): self.assertAlmostEqual(self.zdata.pole_angle, 91.72024697182087) return - def test_calc_polar_angle_ocb_south_night(self): - """Test `calc_polar_angle` with the OCB pole in a south/night quad.""" - # Set a useful vector locaiton and intialise with current boundary - self.vdata.lt = 0.0 - self.vdata.vect_n = -10.0 - self.vdata.vect_e = -10.0 - self.vdata.set_ocb(self.ocb) - - # Change the location of the boundary center - self.vdata.ocb_aacgm_mlt = 1.0 - self.vdata.ocb_aacgm_lat = self.vdata.lat - 2.0 - - # Update the quandrants - self.vdata.calc_vec_pole_angle() - self.vdata.define_quadrants() - - # Get the polar angle - self.assertAlmostEqual(self.vdata.calc_ocb_polar_angle(), 116.52904962) - return - - def test_calc_polar_angle_ocb_south_day(self): - """Test `calc_polar_angle` with the OCB pole in a south/day quad.""" - # Set a useful vector locaiton and intialise with current boundary - self.vdata.lt = 0.0 - self.vdata.set_ocb(self.ocb) - - # Change the location of the boundary center - self.vdata.ocb_aacgm_mlt = 1.0 - self.vdata.ocb_aacgm_lat = self.vdata.lat - 2.0 - - # Update the quandrants - self.vdata.calc_vec_pole_angle() - self.vdata.define_quadrants() - - # Get the polar angle - self.assertAlmostEqual(self.vdata.calc_ocb_polar_angle(), 48.500352141) - return - - def test_big_pole_angle_mlt_west(self): - """Test `calc_ocb_polar_angle` with a neg MLT, W vect, and big angle.""" - # Get the original angle - self.vdata.lt = -22.0 - self.vdata.vect_e *= -1.0 - self.vdata.set_ocb(self.ocb) - - # Increase the pole angle enough to require an adjustment - self.vdata.pole_angle += 90.0 - self.assertAlmostEqual(self.vdata.calc_ocb_polar_angle(), 159.83429474) - return - def test_calc_vec_pole_angle_acute(self): """Test the polar angle calculation with an acute angle.""" self.vdata.set_ocb(self.ocb) @@ -665,29 +400,6 @@ def test_lost_vec_quadrant(self): self.vdata.scale_vector() return - def test_calc_ocb_vec_sign(self): - """Test the calculation of the OCB vector signs.""" - - # Set the initial values - self.vdata.ocb_aacgm_mlt = self.ocb.phi_cent[self.vdata.ocb_ind] / 15.0 - self.vdata.ocb_aacgm_lat = 90.0 - self.ocb.r_cent[self.vdata.ocb_ind] - (self.vdata.ocb_lat, self.vdata.ocb_mlt, - self.vdata.r_corr) = self.ocb.normal_coord(self.vdata.lat, - self.vdata.lt) - self.vdata.calc_vec_pole_angle() - self.vdata.define_quadrants() - - vmag = numpy.sqrt(self.vdata.vect_n**2 + self.vdata.vect_e**2) - self.vdata.aacgm_naz = numpy.degrees(numpy.arccos( - self.vdata.vect_n / vmag)) - - # Calculate the vector data signs - vsigns = self.vdata.calc_ocb_vec_sign(north=True, east=True) - self.assertTrue(vsigns['north']) - self.assertTrue(vsigns['east']) - - return - def test_scale_vec(self): """Test the calculation of the OCB vector signs.""" @@ -700,10 +412,6 @@ def test_scale_vec(self): self.vdata.calc_vec_pole_angle() self.vdata.define_quadrants() - vmag = numpy.sqrt(self.vdata.vect_n**2 + self.vdata.vect_e**2) - self.vdata.aacgm_naz = numpy.degrees(numpy.arccos( - self.vdata.vect_n / vmag)) - # Scale the data vector self.vdata.scale_vector() @@ -1208,31 +916,6 @@ def test_vector_mult_ocb_ind(self): self.assertTrue(numpy.isfinite(val).all()) return - def test_calc_ocb_vec_sign(self): - """Test the calculation of the OCB vector signs.""" - - # Set the initial values - self.vdata.ocb_aacgm_mlt = self.ocb.ocb.phi_cent[ - self.vdata.ocb_ind] / 15.0 - self.vdata.ocb_aacgm_lat = 90.0 - self.ocb.ocb.r_cent[ - self.vdata.ocb_ind] - (self.vdata.ocb_lat, self.vdata.ocb_mlt, _, - self.vdata.r_corr) = self.ocb.normal_coord(self.vdata.lat, - self.vdata.lt) - self.vdata.calc_vec_pole_angle() - self.vdata.define_quadrants() - - vmag = numpy.sqrt(self.vdata.vect_n**2 + self.vdata.vect_e**2) - self.vdata.aacgm_naz = numpy.degrees(numpy.arccos( - self.vdata.vect_n / vmag)) - - # Calculate the vector data signs - vsigns = self.vdata.calc_ocb_vec_sign(north=True, east=True) - self.assertTrue(vsigns['north']) - self.assertTrue(vsigns['east']) - - return - def test_scale_vec(self): """Test the calculation of the OCB vector signs.""" @@ -1247,10 +930,6 @@ def test_scale_vec(self): self.vdata.calc_vec_pole_angle() self.vdata.define_quadrants() - vmag = numpy.sqrt(self.vdata.vect_n**2 + self.vdata.vect_e**2) - self.vdata.aacgm_naz = numpy.degrees(numpy.arccos( - self.vdata.vect_n / vmag)) - # Scale the data vector self.vdata.scale_vector() @@ -1418,93 +1097,6 @@ def test_no_ocb_pole_angle(self): self.vdata.scale_vector() return - def test_bad_ocb_quad(self): - """Test failure when OCB quadrant is wrong.""" - self.vdata.set_ocb(self.ocb, None) - self.vdata.ocb_quad = -1 - - with self.assertRaisesRegex( - ValueError, "destination coordinate pole quadrant is "): - self.vdata.calc_ocb_polar_angle() - return - - def test_bad_vec_quad(self): - """Test failure when vector quadrant is wrong.""" - self.vdata.set_ocb(self.ocb, scale_func=None) - self.vdata.vec_quad = -1 - - with self.assertRaisesRegex(ValueError, - "data vector quadrant is undefined"): - self.vdata.calc_ocb_polar_angle() - return - - def test_bad_quad_polar_angle(self): - """Test failure when quadrant polar angle is bad.""" - self.vdata.set_ocb(self.ocb, None) - self.vdata.aacgm_naz = numpy.nan - - with self.assertRaisesRegex(ValueError, - "AACGM North polar angle undefined"): - self.vdata.calc_ocb_polar_angle() - return - - def test_bad_quad_vector_angle(self): - """Test failure when quandrant vector angle is bad.""" - self.vdata.set_ocb(self.ocb, None) - self.vdata.pole_angle = numpy.nan - - with self.assertRaisesRegex(ValueError, "Vector angle undefined"): - self.vdata.calc_ocb_polar_angle() - return - - def test_bad_calc_vec_sign_direction(self): - """Test calc_vec_sign failure when no direction is provided.""" - self.vdata.set_ocb(self.ocb, None) - - with self.assertRaisesRegex(ValueError, - "must set at least one direction"): - self.vdata.calc_ocb_vec_sign() - return - - def test_bad_calc_sign_ocb_quad(self): - """Test calc_vec_sign failure with bad OCB quadrant.""" - self.vdata.set_ocb(self.ocb, None) - self.vdata.ocb_quad = -1 - - with self.assertRaisesRegex( - ValueError, "destination coordinate pole quadrant is"): - self.vdata.calc_ocb_vec_sign(north=True) - return - - def test_bad_calc_sign_vec_quad(self): - """Test calc_vec_sign failure with bad vector quadrant.""" - self.vdata.set_ocb(self.ocb, None) - self.vdata.vec_quad = -1 - - with self.assertRaisesRegex(ValueError, - "data vector quadrant is undefined"): - self.vdata.calc_ocb_vec_sign(north=True) - return - - def test_bad_calc_sign_polar_angle(self): - """Test calc_vec_sign failure with bad polar angle.""" - self.vdata.set_ocb(self.ocb, None) - self.vdata.aacgm_naz = numpy.nan - - with self.assertRaisesRegex(ValueError, - "AACGM polar angle undefined"): - self.vdata.calc_ocb_vec_sign(north=True) - return - - def test_bad_calc_sign_pole_angle(self): - """Test calc_vec_sign failure with bad pole angle.""" - self.vdata.set_ocb(self.ocb, None) - self.vdata.pole_angle = numpy.nan - - with self.assertRaisesRegex(ValueError, "Vector angle undefined"): - self.vdata.calc_ocb_vec_sign(north=True) - return - def test_bad_define_quadrants_pole_mlt(self): """Test define_quadrants failure with bad pole MLT.""" self.vdata.set_ocb(self.ocb, None)