From 5052e92dbf58bfa093a6ddde654fffac8a817b8d Mon Sep 17 00:00:00 2001 From: Angeline Burrell Date: Tue, 24 Oct 2023 12:26:22 -0400 Subject: [PATCH 1/5] MAINT: updated `use_header` use Updated `use_header` use to reduce user warnings after the next pysat release. --- pysatSpaceWeather/instruments/methods/f107.py | 11 ++- pysatSpaceWeather/tests/test_methods_ace.py | 9 +- pysatSpaceWeather/tests/test_methods_f107.py | 5 +- .../tests/test_methods_general.py | 7 +- pysatSpaceWeather/tests/test_methods_kp.py | 90 +++++++++++++------ 5 files changed, 90 insertions(+), 32 deletions(-) diff --git a/pysatSpaceWeather/instruments/methods/f107.py b/pysatSpaceWeather/instruments/methods/f107.py index 6d2f69b6..f6f8f3c9 100644 --- a/pysatSpaceWeather/instruments/methods/f107.py +++ b/pysatSpaceWeather/instruments/methods/f107.py @@ -166,7 +166,10 @@ def combine_f107(standard_inst, forecast_inst, start=None, stop=None): # Set the load kwargs, which vary by pysat version and tag load_kwargs = {'date': itime} - if Version(pysat.__version__) > Version('3.0.1'): + # TODO(#131): Remove version check after minimum version + # supported is 3.2.0 + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): load_kwargs['use_header'] = True if standard_inst.tag == 'daily': @@ -214,7 +217,11 @@ def combine_f107(standard_inst, forecast_inst, start=None, stop=None): for filename in files: if filename is not None: load_kwargs = {'fname': filename} - if Version(pysat.__version__) > Version('3.0.1'): + + # TODO(#131): Remove version check after minimum version + # supported is 3.2.0 + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): load_kwargs['use_header'] = True forecast_inst.load(**load_kwargs) diff --git a/pysatSpaceWeather/tests/test_methods_ace.py b/pysatSpaceWeather/tests/test_methods_ace.py index 249b6159..b84b7bdd 100644 --- a/pysatSpaceWeather/tests/test_methods_ace.py +++ b/pysatSpaceWeather/tests/test_methods_ace.py @@ -65,7 +65,14 @@ class TestACESWEPAMMethods(object): def setup_method(self): """Create a clean testing setup.""" - self.testInst = pysat.Instrument('pysat', 'testing', use_header=True) + + # TODO(#131): Remove version check after min version supported is 3.2.0 + inst_kwargs = dict() + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): + inst_kwargs['use_header'] = True + + self.testInst = pysat.Instrument('pysat', 'testing', **inst_kwargs) self.testInst.load(date=self.testInst.inst_module._test_dates['']['']) self.omni_keys = ['sw_proton_dens_norm', 'sw_ion_temp_norm'] diff --git a/pysatSpaceWeather/tests/test_methods_f107.py b/pysatSpaceWeather/tests/test_methods_f107.py index ec152281..23b0380f 100644 --- a/pysatSpaceWeather/tests/test_methods_f107.py +++ b/pysatSpaceWeather/tests/test_methods_f107.py @@ -140,7 +140,10 @@ def setup_method(self): self.combine_times = {"start": self.test_day - dt.timedelta(days=30), "stop": self.test_day + dt.timedelta(days=3)} self.load_kwargs = {} - if Version(pysat.__version__) > Version('3.0.1'): + + # TODO(#131): Remove version check after min version supported is 3.2.0 + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): self.load_kwargs['use_header'] = True return diff --git a/pysatSpaceWeather/tests/test_methods_general.py b/pysatSpaceWeather/tests/test_methods_general.py index 8e24f0eb..031ec5c5 100644 --- a/pysatSpaceWeather/tests/test_methods_general.py +++ b/pysatSpaceWeather/tests/test_methods_general.py @@ -20,7 +20,12 @@ class TestGeneralMethods(object): def setup_method(self): """Create a clean testing setup.""" - self.testInst = pysat.Instrument('pysat', 'testing', use_header=True) + # TODO(#131): Remove version check after min version supported is 3.2.0 + inst_kwargs = dict() + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): + inst_kwargs['use_header'] = True + self.testInst = pysat.Instrument('pysat', 'testing', **inst_kwargs) self.testInst.load(date=self.testInst.inst_module._test_dates['']['']) return diff --git a/pysatSpaceWeather/tests/test_methods_kp.py b/pysatSpaceWeather/tests/test_methods_kp.py index 2d7abf61..2ebf3078 100644 --- a/pysatSpaceWeather/tests/test_methods_kp.py +++ b/pysatSpaceWeather/tests/test_methods_kp.py @@ -25,13 +25,20 @@ def setup_method(self): """Create a clean testing setup.""" self.test_function = kp_ap.initialize_kp_metadata + inst_dict = {'num_samples': 12} + # TODO(#131): Remove version check after min version supported is 3.2.0 + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): + inst_dict['use_header'] = True + # Load a test instrument - self.testInst = pysat.Instrument('pysat', 'testing', num_samples=12, - use_header=True) + self.testInst = pysat.Instrument('pysat', 'testing', **inst_dict) test_time = pysat.instruments.pysat_testing._test_dates[''][''] load_kwargs = {'date': test_time} - if Version(pysat.__version__) > Version('3.0.1'): + # TODO(#131): Remove version check after min version supported is 3.2.0 + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): load_kwargs['use_header'] = True self.testInst.load(**load_kwargs) @@ -122,13 +129,20 @@ def setup_method(self): """Create a clean testing setup.""" self.test_function = kp_ap.initialize_ap_metadata + inst_dict = {'num_samples': 12} + # TODO(#131): Remove version check after min version supported is 3.2.0 + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): + inst_dict['use_header'] = True + # Load a test instrument - self.testInst = pysat.Instrument('pysat', 'testing', num_samples=12, - use_header=True) + self.testInst = pysat.Instrument('pysat', 'testing', **inst_dict) test_time = pysat.instruments.pysat_testing._test_dates[''][''] load_kwargs = {'date': test_time} - if Version(pysat.__version__) > Version('3.0.1'): + # TODO(#131): Remove version check after min version supported is 3.2.0 + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): load_kwargs['use_header'] = True self.testInst.load(**load_kwargs) @@ -170,13 +184,20 @@ def setup_method(self): """Create a clean testing setup.""" self.test_function = kp_ap.initialize_bartel_metadata + inst_dict = {'num_samples': 12} + # TODO(#131): Remove version check after min version supported is 3.2.0 + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): + inst_dict['use_header'] = True + # Load a test instrument - self.testInst = pysat.Instrument('pysat', 'testing', num_samples=12, - use_header=True) + self.testInst = pysat.Instrument('pysat', 'testing', **inst_dict) test_time = pysat.instruments.pysat_testing._test_dates[''][''] load_kwargs = {'date': test_time} - if Version(pysat.__version__) > Version('3.0.1'): + # TODO(#131): Remove version check after min version supported is 3.2.0 + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): load_kwargs['use_header'] = True self.testInst.load(**load_kwargs) @@ -267,13 +288,20 @@ class TestSWKp(object): def setup_method(self): """Create a clean testing setup.""" + inst_dict = {'num_samples': 12} + # TODO(#131): Remove version check after min version supported is 3.2.0 + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): + inst_dict['use_header'] = True + # Load a test instrument - self.testInst = pysat.Instrument('pysat', 'testing', num_samples=12, - use_header=True) + self.testInst = pysat.Instrument('pysat', 'testing', **inst_dict) test_time = pysat.instruments.pysat_testing._test_dates[''][''] load_kwargs = {'date': test_time} - if Version(pysat.__version__) > Version('3.0.1'): + # TODO(#131): Remove version check after min version supported is 3.2.0 + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): load_kwargs['use_header'] = True self.testInst.load(**load_kwargs) @@ -476,22 +504,23 @@ def setup_method(self): # Set combination testing input test_day = dt.datetime(2019, 3, 18) - self.combine = {"standard_inst": pysat.Instrument(inst_module=sw_kp, - tag="def", - update_files=True, - use_header=True), - "recent_inst": pysat.Instrument(inst_module=sw_kp, - tag="recent", - update_files=True, - use_header=True), - "forecast_inst": - pysat.Instrument(inst_module=sw_kp, tag="forecast", - update_files=True, use_header=True), + idict = {'inst_module': sw_kp, 'update_files': True} + # TODO(#131): Remove version check after min version supported is 3.2.0 + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): + idict['use_header'] = True + + self.combine = {"standard_inst": pysat.Instrument(tag="def", **idict), + "recent_inst": pysat.Instrument(tag="recent", **idict), + "forecast_inst": pysat.Instrument(tag="forecast", + **idict), "start": test_day - dt.timedelta(days=30), "stop": test_day + dt.timedelta(days=3), "fill_val": -1} self.load_kwargs = {"date": test_day} - if Version(pysat.__version__) > Version('3.0.1'): + # TODO(#131): Remove version check after min version supported is 3.2.0 + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): self.load_kwargs['use_header'] = True return @@ -662,12 +691,19 @@ class TestSWAp(object): def setup_method(self): """Create a clean testing setup.""" - self.test_inst = pysat.Instrument('pysat', 'testing', num_samples=10, - use_header=True) + inst_dict = {'num_samples': 10} + # TODO(#131): Remove version check after min version supported is 3.2.0 + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): + inst_dict['use_header'] = True + + self.test_inst = pysat.Instrument('pysat', 'testing', **inst_dict) test_time = pysat.instruments.pysat_testing._test_dates[''][''] load_kwargs = {'date': test_time} - if Version(pysat.__version__) > Version('3.0.1'): + # TODO(#131): Remove version check after min version supported is 3.2.0 + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): load_kwargs['use_header'] = True self.test_inst.load(**load_kwargs) From 257b656dadaaf38a208f16574405135be50d8410 Mon Sep 17 00:00:00 2001 From: Angeline Burrell Date: Tue, 24 Oct 2023 12:27:48 -0400 Subject: [PATCH 2/5] MAINT: updated load kwargs and try/except Updated the load kwargs and the temporary try/except loop to reflect changes in pysat. --- .../instruments/methods/kp_ap.py | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/pysatSpaceWeather/instruments/methods/kp_ap.py b/pysatSpaceWeather/instruments/methods/kp_ap.py index ad26e8ce..e2ba8228 100644 --- a/pysatSpaceWeather/instruments/methods/kp_ap.py +++ b/pysatSpaceWeather/instruments/methods/kp_ap.py @@ -368,15 +368,14 @@ def filter_geomag(inst, min_kp=0, max_kp=9, filter_time=24, kp_inst=None, if kp_inst.empty: load_kwargs = {'date': inst.index[0], 'end_date': inst.index[-1], 'verifyPad': True} - if Version(pysat.__version__) > Version('3.0.1'): + + # TODO(#131): Remove version check after minimum version supported + # is 3.2.0 + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): load_kwargs['use_header'] = True - # TODO(#117): This gets around a bug in pysat that will be fixed in - # pysat version 3.1.0+ - try: - kp_inst.load(**load_kwargs) - except TypeError: - pass + kp_inst.load(**load_kwargs) if kp_inst.empty: raise IOError( @@ -598,7 +597,11 @@ def combine_kp(standard_inst=None, recent_inst=None, forecast_inst=None, # Load and save the standard data for as many times as possible if inst_flag == 'standard': load_kwargs = {'date': itime} - if Version(pysat.__version__) > Version('3.0.1'): + + # TODO(#131): Remove version check after minimum version supported + # is 3.2.0 + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): load_kwargs['use_header'] = True standard_inst.load(**load_kwargs) @@ -628,7 +631,11 @@ def combine_kp(standard_inst=None, recent_inst=None, forecast_inst=None, for filename in files: if filename is not None: load_kwargs = {'fname': filename} - if Version(pysat.__version__) > Version('3.0.1'): + + # TODO(#131): Remove version check after minimum version + # supported is 3.2.0 + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): load_kwargs['use_header'] = True recent_inst.load(**load_kwargs) @@ -664,7 +671,11 @@ def combine_kp(standard_inst=None, recent_inst=None, forecast_inst=None, for filename in files: if filename is not None: load_kwargs = {'fname': filename} - if Version(pysat.__version__) > Version('3.0.1'): + + # TODO(#131): Remove version check after minimum version + # supported is 3.2.0 + if all([Version(pysat.__version__) > Version('3.0.1'), + Version(pysat.__version__) < Version('3.2.0')]): load_kwargs['use_header'] = True forecast_inst.load(**load_kwargs) From 3bcbfe5d7f9104e9c2ebb93d2388a8572503ee82 Mon Sep 17 00:00:00 2001 From: Angeline Burrell Date: Tue, 24 Oct 2023 12:29:52 -0400 Subject: [PATCH 3/5] STY: removed whitespace Removed extra whitespace. --- pysatSpaceWeather/tests/test_methods_f107.py | 2 +- pysatSpaceWeather/tests/test_methods_kp.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pysatSpaceWeather/tests/test_methods_f107.py b/pysatSpaceWeather/tests/test_methods_f107.py index 23b0380f..70c98451 100644 --- a/pysatSpaceWeather/tests/test_methods_f107.py +++ b/pysatSpaceWeather/tests/test_methods_f107.py @@ -140,7 +140,7 @@ def setup_method(self): self.combine_times = {"start": self.test_day - dt.timedelta(days=30), "stop": self.test_day + dt.timedelta(days=3)} self.load_kwargs = {} - + # TODO(#131): Remove version check after min version supported is 3.2.0 if all([Version(pysat.__version__) > Version('3.0.1'), Version(pysat.__version__) < Version('3.2.0')]): diff --git a/pysatSpaceWeather/tests/test_methods_kp.py b/pysatSpaceWeather/tests/test_methods_kp.py index 2ebf3078..88b4b9aa 100644 --- a/pysatSpaceWeather/tests/test_methods_kp.py +++ b/pysatSpaceWeather/tests/test_methods_kp.py @@ -134,7 +134,7 @@ def setup_method(self): if all([Version(pysat.__version__) > Version('3.0.1'), Version(pysat.__version__) < Version('3.2.0')]): inst_dict['use_header'] = True - + # Load a test instrument self.testInst = pysat.Instrument('pysat', 'testing', **inst_dict) test_time = pysat.instruments.pysat_testing._test_dates[''][''] From e0c274ae318a67944f28eac234a03a489e26568e Mon Sep 17 00:00:00 2001 From: Angeline Burrell Date: Tue, 24 Oct 2023 12:30:11 -0400 Subject: [PATCH 4/5] DOC: updated changelog Added a summary of the changes in this pull request to the changelog. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e52ebd5..5abcf780 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ This project adheres to [Semantic Versioning](https://semver.org/). * Updated package documentation, yamls, and other supporting files * Updated the LISIRD download routine to reflect new behaviour * Changed F10.7 daily test day to ensure new pysat padding tests work + * Removed try/except loop that was a fix for pysat < 3.1.0 + * Updated 'use_header' kwarg use for pysat 3.2.0 changes [0.0.10] - 2023-06-01 --------------------- From cc4c9ff9b59475315dc3b3562585e9f4da67d753 Mon Sep 17 00:00:00 2001 From: Angeline Burrell Date: Tue, 24 Oct 2023 14:55:43 -0400 Subject: [PATCH 5/5] DOC: added image to docs Added the package logo to the documentation and changed the table of contents to show a pared down index. --- docs/conf.py | 3 +++ docs/index.rst | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 0852b124..49e13af9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -97,6 +97,9 @@ # a list of builtin themes. html_theme = 'sphinx_rtd_theme' html_theme_path = ["_themes", ] +html_logo = os.path.join(os.path.abspath('.'), 'figures', + 'pysatSpaceWeather.png') +html_theme_options = {'logo_only': True} # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the diff --git a/docs/index.rst b/docs/index.rst index d38e12cf..6b5cb9dc 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -9,7 +9,7 @@ routines to load common historic, real-time, and forecasted space weather indices as pysat.Instrument objects. .. toctree:: - :maxdepth: -1 + :maxdepth: 2 overview.rst installation.rst