Skip to content

Commit

Permalink
Merge pull request #122 from aburrell/remove_dep_classes
Browse files Browse the repository at this point in the history
DEP: Remove deprecated classes, functions, and kwargs
  • Loading branch information
aburrell committed Feb 23, 2023
2 parents cedf599 + 635805d commit 0f06156
Show file tree
Hide file tree
Showing 15 changed files with 14 additions and 822 deletions.
1 change: 1 addition & 0 deletions Changelog.rst
Expand Up @@ -6,6 +6,7 @@ Summary of all changes made since the first stable release
0.X.X (XX-XX-2023)
------------------
* DEP: Deprecated functions that depend on ssj_auroral_boundary_package
* DEP: Removed classes and kwargs deprecated in v0.3.0

0.3.0 (10-21-2022)
------------------
Expand Down
1 change: 0 additions & 1 deletion ocbpy/__init__.py
Expand Up @@ -17,7 +17,6 @@
from ocbpy import boundaries # noqa F401
from ocbpy import cycle_boundary # noqa F401
from ocbpy import instruments # noqa F401
from ocbpy import ocboundary # noqa F401
from ocbpy import ocb_correction # noqa F401
from ocbpy import ocb_scaling # noqa F401
from ocbpy import ocb_time # noqa F401
Expand Down
40 changes: 4 additions & 36 deletions ocbpy/_boundary.py
Expand Up @@ -18,7 +18,6 @@

import numpy as np
import types
import warnings

import aacgmv2

Expand Down Expand Up @@ -458,18 +457,6 @@ def get_next_good_ocb_ind(self, min_merit=None, max_merit=None, **kwargs):
max_merit : float or NoneTye
Maximum value for the default figure of merit or None to not apply
a custom maximum (default=None)
min_sectors : int
Minimum number of MLT sectors required for good OCB. Deprecated,
will be removed in version 0.3.1+ (default=7)
rcent_dev : float
Maximum number of degrees between the new centre and the AACGM pole
Deprecated, will be removed in version 0.3.1+ (default=8.0)
max_r : float
Maximum radius for open-closed field line boundary in degrees.
Deprecated, will be removed in version 0.3.1+ (default=23.0)
min_r : float
Minimum radius for open-closed field line boundary in degrees
Deprecated, will be removed in version 0.3.1+ (default=10.0)
kwargs : dict
Dict with optional selection criteria. The key should correspond
to a data attribute and the value must be a tuple with the first
Expand All @@ -482,40 +469,21 @@ def get_next_good_ocb_ind(self, min_merit=None, max_merit=None, **kwargs):
greater than self.records if there aren't any more good records
available after the starting point
Deprecated IMAGE FUV checks that:
- more than 6 MLT boundary values have contributed to OCB circle
- the OCB 'pole' is with 8 degrees of the AACGM pole
- the OCB 'radius' is greater than 10 and less than 23 degrees
AMPERE/DMSP-SSJ and new IMAGE FUV checks that:
- the Figure of Merit is greater than or equal to the specified minimum
(`min_fom`) or less than or equal to the specified maximum (`max_fom`)
"""

# Add check for deprecated and custom kwargs
dep_comp = {'min_sectors': ['num_sectors', ('mineq', 7)],
'rcent_dev': ['r_cent', ('maxeq', 8.0)],
'max_r': ['r', ('maxeq', 23.0)],
'min_r': ['r', ('mineq', 10.0)]}
# Check the custom kwargs
cust_keys = list(kwargs.keys())

for ckey in cust_keys:
if ckey in dep_comp.keys():
warnings.warn("".join(["Deprecated kwarg will be removed in ",
"version 0.3.1+. To replecate behaviour",
", use {", dep_comp[ckey][0], ": ",
repr(dep_comp[ckey][1]), "}"]),
DeprecationWarning, stacklevel=2)
if not hasattr(self, ckey):
logger.warning(
"Removing unknown selection attribute {:}".format(ckey))
del kwargs[ckey]

if hasattr(self, dep_comp[ckey][0]):
kwargs[dep_comp[ckey][0]] = dep_comp[ckey][1]
else:
if not hasattr(self, ckey):
logger.warning(
"Removing unknown selection attribute {:}".format(ckey))
del kwargs[ckey]

# Adjust the FoM determination for custom inputs
if min_merit is None:
min_merit = self.min_fom
Expand Down
32 changes: 0 additions & 32 deletions ocbpy/cycle_boundary.py
Expand Up @@ -6,7 +6,6 @@

import datetime as dt
import numpy as np
import warnings

from ocbpy import logger
from ocbpy import ocb_time
Expand Down Expand Up @@ -88,18 +87,6 @@ def match_data_ocb(ocb, dat_dtime, idat=0, max_tol=60, min_merit=None,
data attribute and the value must be a tuple with the first value
specifying 'max', 'min', 'maxeq', 'mineq', or 'equal' and the second
value specifying the value to use in the comparison.
min_sectors : int
Minimum number of MLT sectors required for good OCB. Deprecated, will
be removed in version 0.3.1+ (default=7)
rcent_dev : float
Maximum number of degrees between the new centre and the AACGM pole.
Deprecated, will be removed in version 0.3.1+ (default=8.0)
max_r : float
Maximum radius for open-closed field line boundary in degrees
Deprecated, will be removed in version 0.3.1+ (default=23.0)
min_r : float
Minimum radius for open-closed field line boundary in degrees
Deprecated, will be removed in version 0.3.1+ (default=10.0)
Returns
-------
Expand All @@ -118,25 +105,6 @@ def match_data_ocb(ocb, dat_dtime, idat=0, max_tol=60, min_merit=None,
"""

# Add check for deprecated and custom kwargs
dep_comp = {'min_sectors': ['num_sectors', ('mineq', 7)],
'rcent_dev': ['r_cent', ('maxeq', 8.0)],
'max_r': ['r', ('maxeq', 23.0)],
'min_r': ['r', ('mineq', 10.0)]}
cust_keys = list(kwargs.keys())

for ckey in cust_keys:
if ckey in dep_comp.keys():
warnings.warn("".join(["Deprecated kwarg will be removed in ",
"version 0.3.1+. To replecate behaviour",
", use {", dep_comp[ckey][0], ": ",
repr(dep_comp[ckey][1]), "}"]),
DeprecationWarning, stacklevel=2)
del kwargs[ckey]

if hasattr(ocb, dep_comp[ckey][0]):
kwargs[dep_comp[ckey][0]] = dep_comp[ckey][1]

# Initalise the data record limit
dat_records = len(dat_dtime)

Expand Down
32 changes: 0 additions & 32 deletions ocbpy/instruments/pysat_instruments.py
Expand Up @@ -12,7 +12,6 @@

import datetime as dt
import numpy as np
import warnings

try:
import pysat
Expand Down Expand Up @@ -80,18 +79,6 @@ def add_ocb_to_data(pysat_inst, mlat_name='', mlt_name='', evar_names=None,
data attribute and the value must be a tuple with the first value
specifying 'max', 'min', 'maxeq', 'mineq', or 'equal' and the second
value specifying the value to use in the comparison.
min_sectors : int
Minimum number of MLT sectors required for good OCB. Deprecated, will
be removed in version 0.3.1+ (default=7)
rcent_dev : float
Maximum number of degrees between the new centre and the AACGM pole.
Deprecated, will be removed in version 0.3.1+ (default=8.0)
max_r : float
Maximum radius for open-closed field line boundary in degrees.
Deprecated, will be removed in version 0.3.1+ (default=23.0)
min_r : float
Minimum radius for open-closed field line boundary in degrees.
Deprecated, will be removed in version 0.3.1+ (default=10.0)
Raises
------
Expand Down Expand Up @@ -271,25 +258,6 @@ def add_ocb_to_data(pysat_inst, mlat_name='', mlt_name='', evar_names=None,
ocbpy.logger.error("no data in Boundary file(s)")
return

# Add check for deprecated and custom kwargs
dep_comp = {'min_sectors': ['num_sectors', ('mineq', 7)],
'rcent_dev': ['r_cent', ('maxeq', 8.0)],
'max_r': ['r', ('maxeq', 23.0)],
'min_r': ['r', ('mineq', 10.0)]}
cust_keys = list(kwargs.keys())

for ckey in cust_keys:
if ckey in dep_comp.keys():
warnings.warn("".join(["Deprecated kwarg will be removed in ",
"version 0.3.1+. To replecate behaviour",
", use {", dep_comp[ckey][0], ": ",
repr(dep_comp[ckey][1]), "}"]),
DeprecationWarning, stacklevel=2)
del kwargs[ckey]

if hasattr(ocb, dep_comp[ckey][0]):
kwargs[dep_comp[ckey][0]] = dep_comp[ckey][1]

# Ensure the MLT and MLat data are the same shape
if(aacgm_lat.shape != aacgm_mlt.shape
or aacgm_lat.shape[0] != pysat_inst.index.shape[0]):
Expand Down
38 changes: 3 additions & 35 deletions ocbpy/instruments/supermag.py
Expand Up @@ -12,7 +12,6 @@

import datetime as dt
import numpy as np
import warnings

import ocbpy
import ocbpy.ocb_scaling as ocbscal
Expand Down Expand Up @@ -52,26 +51,14 @@ def supermag2ascii_ocb(smagfile, outfile, hemisphere=0, ocb=None,
max_merit : float or NoneTye
Maximum value for the default figure of merit or None to not apply a
custom maximum (default=None)
scale_func : function or NoneType
Scale the magnetic field observations unless None
(default=ocbpy.ocb_scale.normal_curl_evar)
kwargs : dict
Dict with optional selection criteria. The key should correspond to a
data attribute and the value must be a tuple with the first value
specifying 'max', 'min', 'maxeq', 'mineq', or 'equal' and the second
value specifying the value to use in the comparison.
min_sectors : int
Minimum number of MLT sectors required for good OCB. Deprecated, will
be removed in version 0.3.1+ (default=7).
rcent_dev : float
Maximum number of degrees between the new centre and the AACGM pole.
Deprecated, will be removed in version 0.3.1+ (default=8.0)
max_r : float
Maximum radius for open-closed field line boundary in degrees/
Deprecated, will be removed in version 0.3.1+ (default=23.0)
min_r : float
Minimum radius for open-closed field line boundary in degrees.
Deprecated, will be removed in version 0.3.1+ (default=10.0)
scale_func : function or NoneType
Scale the magnetic field observations unless None
(default=ocbpy.ocb_scale.normal_curl_evar)
Raises
------
Expand Down Expand Up @@ -130,25 +117,6 @@ def supermag2ascii_ocb(smagfile, outfile, hemisphere=0, ocb=None,
ocbpy.logger.error("no data in the Boundary file(s)")
return

# Add check for deprecated and custom kwargs
dep_comp = {'min_sectors': ['num_sectors', ('mineq', 7)],
'rcent_dev': ['r_cent', ('maxeq', 8.0)],
'max_r': ['r', ('maxeq', 23.0)],
'min_r': ['r', ('mineq', 10.0)]}
cust_keys = list(kwargs.keys())

for ckey in cust_keys:
if ckey in dep_comp.keys():
warnings.warn("".join(["Deprecated kwarg will be removed in ",
"version 0.3.1+. To replecate behaviour",
", use {", dep_comp[ckey][0], ": ",
repr(dep_comp[ckey][1]), "}"]),
DeprecationWarning, stacklevel=2)
del kwargs[ckey]

if hasattr(ocb, dep_comp[ckey][0]):
kwargs[dep_comp[ckey][0]] = dep_comp[ckey][1]

# Remove the data with NaNs/Inf and from the opposite hemisphere/equator
igood = np.where((np.isfinite(mdata['MLT'])) & (np.isfinite(mdata['MLAT']))
& (np.isfinite(mdata['BE'])) & (np.isfinite(mdata['BN']))
Expand Down
43 changes: 6 additions & 37 deletions ocbpy/instruments/vort.py
Expand Up @@ -11,7 +11,6 @@
"""
import datetime as dt
import numpy as np
import warnings

import ocbpy
import ocbpy.ocb_scaling as ocbscal
Expand Down Expand Up @@ -54,26 +53,15 @@ def vort2ascii_ocb(vortfile, outfile, hemisphere=0, ocb=None,
max_merit : float or NoneTye
Maximum value for the default figure of merit or None to not apply a
custom maximum (default=None)
kwargs : dict
Dict with optional selection criteria. The key should correspond to a
data attribute and the value must be a tuple with the first value
specifying 'max', 'min', 'maxeq', 'mineq', or 'equal' and the second
value specifying the value to use in the comparison.
min_sectors : int
Minimum number of MLT sectors required for good OCB. Deprecated, will
be removed in version 0.3.1+ (default=7)
rcent_dev : float
Maximum number of degrees between the new centre and the AACGM pole.
Deprecated, will be removed in version 0.3.1+ (default=8.0)
max_r : float
Maximum radius for open-closed field line boundary in degrees.
Deprecated, will be removed in version 0.3.1+ (default=23.0)
min_r : float
Minimum radius for open-closed field line boundary in degrees.
Deprecated, will be removed in version 0.3.1+ (default=10.0)
scale_func : function or NoneType
Scaling function for Vorticity data or None to not scale
(default=ocbpy.ocb_scale.normal_curl_evar)
kwargs : dict
Dict with optional selection criteria for quality boundaries. The key
should correspond to a data attribute and the value must be a tuple
with the first value specifying 'max', 'min', 'maxeq', 'mineq', or
'equal' and the second value specifying the value to use in the
comparison.
Raises
------
Expand Down Expand Up @@ -135,25 +123,6 @@ def vort2ascii_ocb(vortfile, outfile, hemisphere=0, ocb=None,
ocbpy.logger.error("no data in Boundary file(s)")
return

# Add check for deprecated and custom kwargs
dep_comp = {'min_sectors': ['num_sectors', ('mineq', 7)],
'rcent_dev': ['r_cent', ('maxeq', 8.0)],
'max_r': ['r', ('maxeq', 23.0)],
'min_r': ['r', ('mineq', 10.0)]}
cust_keys = list(kwargs.keys())

for ckey in cust_keys:
if ckey in dep_comp.keys():
warnings.warn("".join(["Deprecated kwarg will be removed in ",
"version 0.3.1+. To replecate behaviour",
", use {", dep_comp[ckey][0], ": ",
repr(dep_comp[ckey][1]), "}"]),
DeprecationWarning, stacklevel=2)
del kwargs[ckey]

if hasattr(ocb, dep_comp[ckey][0]):
kwargs[dep_comp[ckey][0]] = dep_comp[ckey][1]

# Remove the data from the opposite hemisphere
igood = np.where(np.sign(vdata['CENTRE_MLAT']) == hemisphere)[0]

Expand Down

0 comments on commit 0f06156

Please sign in to comment.