From 37ada74b852a1098fc8255307f21c803fe9101db Mon Sep 17 00:00:00 2001 From: jklenzing Date: Wed, 2 Aug 2023 10:15:42 -0400 Subject: [PATCH 01/26] STY: improve RTD install --- .readthedocs.yml | 5 ++++- docs/requirements.txt | 5 ----- 2 files changed, 4 insertions(+), 6 deletions(-) delete mode 100644 docs/requirements.txt diff --git a/.readthedocs.yml b/.readthedocs.yml index 23fa5ade..d0bd564d 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -19,4 +19,7 @@ sphinx: # Optionally declare the Python requirements required to build your docs python: install: - - requirements: docs/requirements.txt + - method: pip + path: . + extra_requirements: + - doc diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index 3d71207e..00000000 --- a/docs/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -extras_require -m2r2 -numpydoc -pysat -pysatNASA From addf19d6c301d6a3c2d5d39b8edd7c4be4d86d0f Mon Sep 17 00:00:00 2001 From: jklenzing Date: Wed, 2 Aug 2023 10:16:10 -0400 Subject: [PATCH 02/26] DOC: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d579816..2091a7c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). ## [0.X.X] - 2023-XX-XX * Maintenance * Implemented unit tests for cleaning warnings + * Use pip install for readthedocs ## [0.0.5] - 2023-06-27 * New Instruments From f851a991e3253a5ac27400951737e3aca8059bd6 Mon Sep 17 00:00:00 2001 From: jklenzing Date: Wed, 2 Aug 2023 14:35:53 -0400 Subject: [PATCH 03/26] MAINT: minimum rtd theme --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b35d7492..29252aa9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,7 +66,7 @@ doc = [ "m2r2", "numpydoc", "sphinx", - "sphinx_rtd_theme" + "sphinx_rtd_theme >= 1.2.2" ] [project.urls] From d9f69e5bd68ae7e880bd5132d5c7d248c07bd118 Mon Sep 17 00:00:00 2001 From: jklenzing Date: Thu, 7 Sep 2023 10:30:27 -0400 Subject: [PATCH 04/26] STY: use standard init --- pysatNASA/instruments/formosat1_ivm.py | 28 ++------------------ pysatNASA/instruments/iss_fpmu.py | 31 ++--------------------- pysatNASA/instruments/methods/__init__.py | 2 ++ pysatNASA/instruments/methods/formosat.py | 14 ++++++++++ pysatNASA/instruments/methods/iss.py | 29 +++++++++++++++++++++ pysatNASA/instruments/methods/omni.py | 11 ++++++++ pysatNASA/instruments/omni_hro.py | 21 ++------------- 7 files changed, 62 insertions(+), 74 deletions(-) create mode 100644 pysatNASA/instruments/methods/formosat.py create mode 100644 pysatNASA/instruments/methods/iss.py diff --git a/pysatNASA/instruments/formosat1_ivm.py b/pysatNASA/instruments/formosat1_ivm.py index 3ac177d9..ceccc95c 100644 --- a/pysatNASA/instruments/formosat1_ivm.py +++ b/pysatNASA/instruments/formosat1_ivm.py @@ -26,9 +26,9 @@ import functools from pysat.instruments.methods import general as mm_gen -from pysat import logger from pysatNASA.instruments.methods import cdaweb as cdw +from pysatNASA.instruments.methods import formosat as mm_formosat from pysatNASA.instruments.methods import general as mm_nasa # ---------------------------------------------------------------------------- @@ -47,31 +47,7 @@ # ---------------------------------------------------------------------------- # Instrument methods - -def init(self): - """Initialize the Instrument object with instrument specific values. - - Runs once upon instantiation. - - """ - self.acknowledgements = ' '.join(('Data provided through NASA CDAWeb', - 'Key Parameters - Shin-Yi Su', - '(Institute of Space Science,', - 'National Central University,', - 'Taiwan, R.O.C.)')) - self.references = ' '.join(('Yeh, H.C., S.‐Y. Su, Y.C. Yeh, J.M. Wu,', - 'R. A. Heelis, and B. J. Holt, Scientific', - 'mission of the IPEI payload on board', - 'ROCSAT‐1, Terr. Atmos. Ocean. Sci., 9,', - 'suppl., 1999a.\n', - 'Yeh, H.C., S.‐Y. Su, R.A. Heelis, and', - 'J.M. Wu, The ROCSAT‐1 IPEI preliminary', - 'results, Vertical ion drift statistics,', - 'Terr. Atmos. Ocean. Sci., 10, 805,', - '1999b.')) - logger.info(self.acknowledgements) - - return +init = functools.partial(mm_nasa.init, module=mm_formosat, name=name) # Use default clean diff --git a/pysatNASA/instruments/iss_fpmu.py b/pysatNASA/instruments/iss_fpmu.py index c98f907c..d65272e3 100644 --- a/pysatNASA/instruments/iss_fpmu.py +++ b/pysatNASA/instruments/iss_fpmu.py @@ -28,10 +28,10 @@ import functools from pysat.instruments.methods import general as mm_gen -from pysat import logger from pysatNASA.instruments.methods import cdaweb as cdw from pysatNASA.instruments.methods import general as mm_nasa +from pysatNASA.instruments.methods import iss as mm_iss # ---------------------------------------------------------------------------- # Instrument attributes @@ -49,34 +49,7 @@ # ---------------------------------------------------------------------------- # Instrument methods - -def init(self): - """Initialize the Instrument object with instrument specific values. - - Runs once upon instantiation. - - """ - - ackn_str = ' '.join(('Data provided through NASA CDAWeb. Contact', - 'Rob.Suggs@nasa.gov for support and use.')) - logger.info(ackn_str) - self.acknowledgements = ackn_str - self.references = ' '.join(('V. N. Coffey et al., "Validation of the', - 'Plasma Densities and Temperatures From', - 'the ISS Floating Potential Measurement', - 'Unit," in IEEE Transactions on Plasma', - 'Science, vol. 36, no. 5, pp. 2301-2308,', - 'Oct. 2008,', - 'doi: 10.1109/TPS.2008.2004271.\n', - 'A. Barjatya, C.M. Swenson, D.C.', - 'Thompson, and K.H. Wright Jr., Data', - 'analysis of the Floating Potential', - 'Measurement Unit aboard the', - 'International Space Station, Rev. Sci.', - 'Instrum. 80, 041301 (2009),', - 'https://doi.org/10.1063/1.3116085')) - - return +init = functools.partial(mm_nasa.init, module=mm_iss, name=name) # Use default clean diff --git a/pysatNASA/instruments/methods/__init__.py b/pysatNASA/instruments/methods/__init__.py index 8542fcbc..4459d353 100644 --- a/pysatNASA/instruments/methods/__init__.py +++ b/pysatNASA/instruments/methods/__init__.py @@ -5,9 +5,11 @@ from pysatNASA.instruments.methods import cnofs # noqa F401 from pysatNASA.instruments.methods import de2 # noqa F401 from pysatNASA.instruments.methods import dmsp # noqa F401 +from pysatNASA.instruments.methods import formosat # noqa F401 from pysatNASA.instruments.methods import general # noqa F401 from pysatNASA.instruments.methods import gps # noqa F401 from pysatNASA.instruments.methods import icon # noqa F401 +from pysatNASA.instruments.methods import iss # noqa F401 from pysatNASA.instruments.methods import jhuapl # noqa F401 from pysatNASA.instruments.methods import omni # noqa F401 from pysatNASA.instruments.methods import ses14 # noqa F401 diff --git a/pysatNASA/instruments/methods/formosat.py b/pysatNASA/instruments/methods/formosat.py new file mode 100644 index 00000000..41ee0f22 --- /dev/null +++ b/pysatNASA/instruments/methods/formosat.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +"""Provides non-instrument specific routines for C/NOFS data.""" + +ackn_str = ' '.join(('Data provided through NASA CDAWeb Key Parameters -', + 'Shin-Yi Su (Institute of Space Science, National Central', + 'University, Taiwan, R.O.C.)')) +refs = {'ivm': ' '.join(('Yeh, H.C., S.‐Y. Su, Y.C. Yeh, J.M. Wu, R. A.', + 'Heelis, and B. J. Holt, Scientific mission of the', + 'IPEI payload on board ROCSAT‐1, Terr. Atmos. Ocean.', + 'Sci., 9, suppl., 1999a.\n', + 'Yeh, H.C., S.‐Y. Su, R.A. Heelis, and J.M. Wu, The', + 'ROCSAT‐1 IPEI preliminary results, Vertical ion', + 'drift statistics, Terr. Atmos. Ocean. Sci., 10, 805,', + '1999b.'))} diff --git a/pysatNASA/instruments/methods/iss.py b/pysatNASA/instruments/methods/iss.py new file mode 100644 index 00000000..24ed41ce --- /dev/null +++ b/pysatNASA/instruments/methods/iss.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +"""Provides non-instrument specific routines for C/NOFS data.""" + +ackn_str = ' '.join(("R.M. Suggs, S.L. Koontz, NASA Johnson Space Center", + "Contact Rob Suggs for support and use.", + "Rob.Suggs@nasa.gov. Please acknowledge the data", + "providers and CDAWeb when using these data.")) + +refs = {'fpmu': ' '.join(('V. N. Coffey et al., "Validation of the Plasma', + 'Densities and Temperatures From the ISS Floating', + 'Potential Measurement Unit," in IEEE Transactions', + 'on Plasma Science, vol. 36, no. 5, pp. 2301-2308,', + 'Oct. 2008, doi: 10.1109/TPS.2008.2004271.', + '\n', + 'A. Barjatya, C.M. Swenson, D.C. Thompson, and K.H.', + 'Wright Jr., Data analysis of the Floating Potential', + 'Measurement Unit aboard the International Space', + 'Station, Rev. Sci. Instrum. 80, 041301 (2009),', + 'https://doi.org/10.1063/1.3116085', + '\n', + 'Debchoudhury, S., Barjatya, A., Minow, J. I.,', + 'Coffey, V. N., & Chandler, M. O. (2021).', + 'Observations and validation of plasma density,', + 'temperature, and O+ abundance from a Langmuir', + 'probe onboard the International Space Station.', + 'Journal of Geophysical Research: Space', + 'Physics, 126, e2021JA029393.', + 'https://doi.org/10.1029/2021JA029393')) + } diff --git a/pysatNASA/instruments/methods/omni.py b/pysatNASA/instruments/methods/omni.py index 2844b0cb..4d96c9fb 100644 --- a/pysatNASA/instruments/methods/omni.py +++ b/pysatNASA/instruments/methods/omni.py @@ -9,6 +9,17 @@ import pysat +ackn_str = ' '.join(('For full acknowledgement info, please see:', + 'https://omniweb.gsfc.nasa.gov/html/citing.html')) + +refs = {'hro': ' '.join(('J.H. King and N.E. Papitashvili, Solar', + 'wind spatial scales in and comparisons', + 'of hourly Wind and ACE plasma and', + 'magnetic field data, J. Geophys. Res.,', + 'Vol. 110, No. A2, A02209,', + '10.1029/2004JA010649.'))} + + def time_shift_to_magnetic_poles(inst): """Shift OMNI times to intersection with the magnetic pole. diff --git a/pysatNASA/instruments/omni_hro.py b/pysatNASA/instruments/omni_hro.py index d7a205cf..6b97ce82 100644 --- a/pysatNASA/instruments/omni_hro.py +++ b/pysatNASA/instruments/omni_hro.py @@ -48,6 +48,7 @@ from pysat.instruments.methods import general as mm_gen from pysatNASA.instruments.methods import cdaweb as cdw +from pysatNASA.instruments.methods import general as mm_nasa from pysatNASA.instruments.methods import omni as mm_omni # ---------------------------------------------------------------------------- @@ -68,25 +69,7 @@ # ---------------------------------------------------------------------------- # Instrument methods - -def init(self): - """Initialize the Instrument object with instrument specific values. - - Runs once upon instantiation. - - """ - - ackn_str = ''.join(('For full acknowledgement info, please see: ', - 'https://omniweb.gsfc.nasa.gov/html/citing.html')) - self.acknowledgements = ackn_str - self.references = ' '.join(('J.H. King and N.E. Papitashvili, Solar', - 'wind spatial scales in and comparisons', - 'of hourly Wind and ACE plasma and', - 'magnetic field data, J. Geophys. Res.,', - 'Vol. 110, No. A2, A02209,', - '10.1029/2004JA010649.')) - pysat.logger.info(ackn_str) - return +init = functools.partial(mm_nasa.init, module=mm_omni, name=name) def clean(self): From 9caf8b9c565ffcd2fd003d75f5f882965dc406e1 Mon Sep 17 00:00:00 2001 From: jklenzing Date: Thu, 7 Sep 2023 10:30:35 -0400 Subject: [PATCH 05/26] DOC: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2091a7c1..958afcd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). * Maintenance * Implemented unit tests for cleaning warnings * Use pip install for readthedocs + * Move references and acknowledgements to methods files ## [0.0.5] - 2023-06-27 * New Instruments From 8446dea99cd5d512119eb77d78795f251c22f82c Mon Sep 17 00:00:00 2001 From: jklenzing Date: Thu, 7 Sep 2023 10:48:00 -0400 Subject: [PATCH 06/26] STY: pep8 --- pysatNASA/instruments/omni_hro.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pysatNASA/instruments/omni_hro.py b/pysatNASA/instruments/omni_hro.py index 6b97ce82..b37f2954 100644 --- a/pysatNASA/instruments/omni_hro.py +++ b/pysatNASA/instruments/omni_hro.py @@ -44,7 +44,6 @@ import pandas as pds import warnings -import pysat from pysat.instruments.methods import general as mm_gen from pysatNASA.instruments.methods import cdaweb as cdw From fb5fb10d941899eeb2f8955c90458b4ded199446 Mon Sep 17 00:00:00 2001 From: jklenzing Date: Thu, 7 Sep 2023 11:56:58 -0400 Subject: [PATCH 07/26] DOC: add examples --- docs/examples/ex_archival.rst | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 docs/examples/ex_archival.rst diff --git a/docs/examples/ex_archival.rst b/docs/examples/ex_archival.rst new file mode 100644 index 00000000..e2fbab02 --- /dev/null +++ b/docs/examples/ex_archival.rst @@ -0,0 +1,64 @@ +Building data files for archival at NASA SPDF +============================================= + +The codes and routines at pysatNASA are designed for end-users of NASA data +products. However, pysat in general has also been used to build operational +instruments for generating archival data to be uploaded to the Space Physics +Data Facility (SPDF) at NASA. + +In general, such instruments should include separate naming conventions. An +example of this is the REACH data, where netCDF4 files are generated for +archival purposes as part of the `ops_reach` package, but can be accessed by +the end user through pysatNASA. + +In general, a ``pysat.Instrument`` object can be constructed for any dataset. In +case of the REACH data, the operational code reads in a series of csv files and +updates the metadata according to user specifications. Once the file is loaded, +it can be exported to a netCDF4 file via pysat. In the simplest case, this is + +:: + + reach = pysat.Instrument(inst_module=aero_reach, tag='l1b', inst_id=inst_id) + pysat.utils.io.inst_to_netcdf(reach, 'output_file.nc', epoch_name='Epoch') + + +However, there are additional options when translating pysat metadata to SPDF +preferred formats. An example of this is + +:: + + # Use meta translation table to include SPDF preferred format. + # Note that multiple names are output for compliance with pysat. + # Using the most generalized form for labels for future compatibility. + meta_dict = {reach.meta.labels.min_val: ['VALIDMIN'], + reach.meta.labels.max_val: ['VALIDMAX'], + reach.meta.labels.units: ['UNITS'], + reach.meta.labels.name: ['CATDESC', 'LABLAXIS', 'FIELDNAM'], + reach.meta.labels.notes: ['VAR_NOTES'], + reach.meta.labels.fill_val: ['_FillValue'], + 'Depend_0': ['DEPEND_0'], + 'Format': ['FORMAT'], + 'Monoton': ['MONOTON'], + 'Var_Type': ['VAR_TYPE']} + + pysat.utils.io.inst_to_netcdf(reach, 'output_file.nc', epoch_name='Epoch', + meta_translation=meta_dict, + export_pysat_info=False) + + +In this case, note that the pysat 'name' label is output to three different +metadata values required by the ITSP standards. Additionally, the +``export_pysat_info`` option is set to false here. This drops several internal +pysat metadata values before writing to file. + +Other best practices for archival include adding the oprational software version +to the metadata header before writing. The pysat version will be automatically +written to the metadata. + +:: + + reach.meta.header.Software_version = ops_reach.__version__ + + +A full example script to generate output files can be found at +https://github.com/jklenzing/ops_reach/blob/main/scripts/netcdf_gen.py From a3ff1adce863f4f927034cc274d3b63012c79b26 Mon Sep 17 00:00:00 2001 From: jklenzing Date: Thu, 7 Sep 2023 11:57:50 -0400 Subject: [PATCH 08/26] DOC: update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2091a7c1..65a48291 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/). ## [0.X.X] - 2023-XX-XX +* Documentation + * Added example of how to export data for archival * Maintenance * Implemented unit tests for cleaning warnings * Use pip install for readthedocs From 24afa8b6c4e1ee819d7b7d0ff89cdc2ae9b56164 Mon Sep 17 00:00:00 2001 From: jklenzing Date: Thu, 7 Sep 2023 12:00:21 -0400 Subject: [PATCH 09/26] DOC: add link to pysat conventions --- docs/examples/ex_archival.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/examples/ex_archival.rst b/docs/examples/ex_archival.rst index e2fbab02..f7ee7151 100644 --- a/docs/examples/ex_archival.rst +++ b/docs/examples/ex_archival.rst @@ -11,7 +11,9 @@ example of this is the REACH data, where netCDF4 files are generated for archival purposes as part of the `ops_reach` package, but can be accessed by the end user through pysatNASA. -In general, a ``pysat.Instrument`` object can be constructed for any dataset. In +In general, a ``pysat.Instrument`` object can be constructed for any dataset. +Full instructions and conventions can be found +`here `_. In the case of the REACH data, the operational code reads in a series of csv files and updates the metadata according to user specifications. Once the file is loaded, it can be exported to a netCDF4 file via pysat. In the simplest case, this is From 7c8c5ae084d2d0755aad585cbc4a640e7fb07ec0 Mon Sep 17 00:00:00 2001 From: jklenzing Date: Thu, 7 Sep 2023 12:06:27 -0400 Subject: [PATCH 10/26] BUG: fix link --- docs/examples.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/examples.rst b/docs/examples.rst index a2062741..c18593ed 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -6,3 +6,4 @@ tools .. toctree:: examples/ex_init.rst + examples/ex_archival.rst From 183b4aa98ae42e8501403711c6ac1a12e7a4aab6 Mon Sep 17 00:00:00 2001 From: jklenzing Date: Thu, 7 Sep 2023 12:08:41 -0400 Subject: [PATCH 11/26] STY: top level --- docs/{examples/ex_archival.rst => archival.rst} | 0 docs/examples.rst | 2 +- docs/index.rst | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) rename docs/{examples/ex_archival.rst => archival.rst} (100%) diff --git a/docs/examples/ex_archival.rst b/docs/archival.rst similarity index 100% rename from docs/examples/ex_archival.rst rename to docs/archival.rst diff --git a/docs/examples.rst b/docs/examples.rst index c18593ed..df897a6b 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -6,4 +6,4 @@ tools .. toctree:: examples/ex_init.rst - examples/ex_archival.rst + diff --git a/docs/index.rst b/docs/index.rst index cda7cf4f..926c4f76 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -18,6 +18,7 @@ CDAWeb interface. supported_constellations.rst examples.rst develop_guide.rst + archival.rst migration_guide.rst history.rst From 64cb003313fe027ad6f690f4571347eb539fcfb8 Mon Sep 17 00:00:00 2001 From: jklenzing Date: Thu, 7 Sep 2023 12:19:40 -0400 Subject: [PATCH 12/26] BIG: spelling --- docs/archival.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/archival.rst b/docs/archival.rst index f7ee7151..61efffb1 100644 --- a/docs/archival.rst +++ b/docs/archival.rst @@ -53,7 +53,7 @@ metadata values required by the ITSP standards. Additionally, the ``export_pysat_info`` option is set to false here. This drops several internal pysat metadata values before writing to file. -Other best practices for archival include adding the oprational software version +Other best practices for archival include adding the operational software version to the metadata header before writing. The pysat version will be automatically written to the metadata. From 7660162c572d61147ff826b58b34ef7cb8d7e59f Mon Sep 17 00:00:00 2001 From: Jeff Klenzing <19592220+jklenzing@users.noreply.github.com> Date: Thu, 7 Sep 2023 12:44:02 -0400 Subject: [PATCH 13/26] Update docs/archival.rst --- docs/archival.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/archival.rst b/docs/archival.rst index 61efffb1..72b710d6 100644 --- a/docs/archival.rst +++ b/docs/archival.rst @@ -53,6 +53,7 @@ metadata values required by the ITSP standards. Additionally, the ``export_pysat_info`` option is set to false here. This drops several internal pysat metadata values before writing to file. +A full guide to SPDF metadata standards can be found `here `_. Other best practices for archival include adding the operational software version to the metadata header before writing. The pysat version will be automatically written to the metadata. From 30d4cee099e11ad21f8faa9976eb3942a513a69c Mon Sep 17 00:00:00 2001 From: Jeff Klenzing <19592220+jklenzing@users.noreply.github.com> Date: Thu, 7 Sep 2023 12:44:21 -0400 Subject: [PATCH 14/26] Update docs/archival.rst --- docs/archival.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/archival.rst b/docs/archival.rst index 72b710d6..9c02a932 100644 --- a/docs/archival.rst +++ b/docs/archival.rst @@ -53,7 +53,9 @@ metadata values required by the ITSP standards. Additionally, the ``export_pysat_info`` option is set to false here. This drops several internal pysat metadata values before writing to file. -A full guide to SPDF metadata standards can be found `here `_. +A full guide to SPDF metadata standards can be found +`here `_. + Other best practices for archival include adding the operational software version to the metadata header before writing. The pysat version will be automatically written to the metadata. From 656dbe25b5c40db1826c63bf608fbee1a3e27ec2 Mon Sep 17 00:00:00 2001 From: jklenzing Date: Thu, 7 Sep 2023 14:38:59 -0400 Subject: [PATCH 15/26] BUG: fix docstring --- pysatNASA/tests/test_omni_hro.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pysatNASA/tests/test_omni_hro.py b/pysatNASA/tests/test_omni_hro.py index b3032024..4551bb63 100644 --- a/pysatNASA/tests/test_omni_hro.py +++ b/pysatNASA/tests/test_omni_hro.py @@ -145,7 +145,7 @@ def test_clock_angle_std(self): return def test_dayside_recon(self): - """Test the IMF steadiness standard deviation calculation.""" + """Test the dayside reconnection calculation.""" # Run the clock angle and steadiness routines omni.calculate_clock_angle(self.test_inst) From 162971161b1bb6f6c2d4f545b53df857063e7e3a Mon Sep 17 00:00:00 2001 From: jklenzing Date: Thu, 7 Sep 2023 14:39:25 -0400 Subject: [PATCH 16/26] TST: test time_shift --- pysatNASA/tests/test_omni_hro.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pysatNASA/tests/test_omni_hro.py b/pysatNASA/tests/test_omni_hro.py index 4551bb63..3e9fc3e3 100644 --- a/pysatNASA/tests/test_omni_hro.py +++ b/pysatNASA/tests/test_omni_hro.py @@ -163,6 +163,22 @@ def test_dayside_recon(self): assert np.all(test_diff < 1.0e-6) return + def test_time_shift_to_magnetic_poles(self): + """Test the time shift routines.""" + + # Choose values to result in 1 hour shift + self.test_inst['Vx'] = 6371.2 + self.test_inst['BSN_x'] = 3600.0 + + old_index = self.test_inst.index.copy() + omni.time_shift_to_magnetic_poles(self.test_inst) + + # Check shifted index + assert (old_index[0] - self.test_inst.index[0]).seconds == 3600 + # Check new cadence + assert (self.test_inst.index[1] - self.test_inst.index[0]).seconds == 60 + return + class TestDeprecation(object): """Unit tests for deprecation warnings in `pysat.instrument.omni_hro`.""" From fcb5f17abc30db30a6dcbf75ff20bd4b46404565 Mon Sep 17 00:00:00 2001 From: jklenzing Date: Thu, 7 Sep 2023 14:39:48 -0400 Subject: [PATCH 17/26] DOC: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2091a7c1..f54ef2ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). * Maintenance * Implemented unit tests for cleaning warnings * Use pip install for readthedocs + * Add tests for omni hro routines ## [0.0.5] - 2023-06-27 * New Instruments From a45328a77c35961c057eeb38a4ff02cb56a8c62d Mon Sep 17 00:00:00 2001 From: Jeff Klenzing <19592220+jklenzing@users.noreply.github.com> Date: Thu, 7 Sep 2023 14:51:22 -0400 Subject: [PATCH 18/26] Apply suggestions from code review Co-authored-by: Angeline Burrell --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 958afcd7..3f24602a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). * Maintenance * Implemented unit tests for cleaning warnings * Use pip install for readthedocs - * Move references and acknowledgements to methods files + * Moved references and acknowledgements to methods files ## [0.0.5] - 2023-06-27 * New Instruments From 47448103147bfdb51e78652e97ba46684488fd02 Mon Sep 17 00:00:00 2001 From: Jeff Klenzing <19592220+jklenzing@users.noreply.github.com> Date: Thu, 7 Sep 2023 14:51:48 -0400 Subject: [PATCH 19/26] Apply suggestions from code review Co-authored-by: Angeline Burrell --- docs/archival.rst | 2 +- docs/examples.rst | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/archival.rst b/docs/archival.rst index 9c02a932..46de4910 100644 --- a/docs/archival.rst +++ b/docs/archival.rst @@ -1,7 +1,7 @@ Building data files for archival at NASA SPDF ============================================= -The codes and routines at pysatNASA are designed for end-users of NASA data +The codes and routines at :py:mod:`pysatNASA` are designed for end-users of NASA data products. However, pysat in general has also been used to build operational instruments for generating archival data to be uploaded to the Space Physics Data Facility (SPDF) at NASA. diff --git a/docs/examples.rst b/docs/examples.rst index df897a6b..a2062741 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -6,4 +6,3 @@ tools .. toctree:: examples/ex_init.rst - From 6d7e95a4dc24b78bbc058abc3e889304631bb07c Mon Sep 17 00:00:00 2001 From: jklenzing Date: Thu, 7 Sep 2023 14:57:24 -0400 Subject: [PATCH 20/26] MAINT: remove older scipy support --- pysatNASA/instruments/methods/omni.py | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/pysatNASA/instruments/methods/omni.py b/pysatNASA/instruments/methods/omni.py index 2844b0cb..9f7fdb26 100644 --- a/pysatNASA/instruments/methods/omni.py +++ b/pysatNASA/instruments/methods/omni.py @@ -130,24 +130,11 @@ def calculate_imf_steadiness(inst, steady_window=15, min_window_frac=0.75, # Calculate the running circular standard deviation of the clock angle circ_kwargs = {'high': 360.0, 'low': 0.0, 'nan_policy': 'omit'} - try: - ca_std = \ - inst['clock_angle'].rolling(min_periods=min_wnum, - window=steady_window, - center=True).apply(stats.circstd, - kwargs=circ_kwargs, - raw=True) - except TypeError: - pysat.logger.warn(' '.join(['To automatically remove NaNs from the', - 'calculation, please upgrade to scipy 1.4', - 'or newer.'])) - circ_kwargs.pop('nan_policy') - ca_std = \ - inst['clock_angle'].rolling(min_periods=min_wnum, - window=steady_window, - center=True).apply(stats.circstd, - kwargs=circ_kwargs, - raw=True) + ca_std = inst['clock_angle'].rolling(min_periods=min_wnum, + window=steady_window, + center=True).apply(stats.circstd, + kwargs=circ_kwargs, + raw=True) inst['clock_angle_std'] = pds.Series(ca_std, index=inst.data.index) # Determine how long the clock angle and IMF magnitude are steady From 9db34f72448f87221a1583767a1914ae189dc7b8 Mon Sep 17 00:00:00 2001 From: jklenzing Date: Thu, 7 Sep 2023 14:57:38 -0400 Subject: [PATCH 21/26] MAINT: set minimum scipy version --- README.md | 1 + docs/installation.rst | 1 + pyproject.toml | 1 + 3 files changed, 3 insertions(+) diff --git a/README.md b/README.md index 9c96b121..86d45ad5 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ Python 3.6+. | numpy | | | | pandas | | | | requests | | | +| scipy>=1.4.0 | | | | xarray | | | ## PyPi Installation diff --git a/docs/installation.rst b/docs/installation.rst index 7b5858b7..2722700f 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -25,6 +25,7 @@ Python 3.6+ and pysat 3.1.0+. numpy pandas requests + scipy>=1.4.0 xarray ================== ================= diff --git a/pyproject.toml b/pyproject.toml index 29252aa9..a2f0fc20 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,7 @@ dependencies = [ "pandas", "pysat >= 3.1", "requests", + "scipy >= 1.4", "xarray" ] From 1e7d39c8e6d6892455dae4136180af29762e2474 Mon Sep 17 00:00:00 2001 From: jklenzing Date: Thu, 7 Sep 2023 16:24:34 -0400 Subject: [PATCH 22/26] BUG: integer --- pysatNASA/instruments/methods/omni.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pysatNASA/instruments/methods/omni.py b/pysatNASA/instruments/methods/omni.py index 9f7fdb26..ba4fc584 100644 --- a/pysatNASA/instruments/methods/omni.py +++ b/pysatNASA/instruments/methods/omni.py @@ -113,7 +113,7 @@ def calculate_imf_steadiness(inst, steady_window=15, min_window_frac=0.75, sample_rate = int(rates[inst.tag]) max_wnum = np.floor(steady_window / sample_rate) if max_wnum != steady_window / sample_rate: - steady_window = max_wnum * sample_rate + steady_window = int(max_wnum * sample_rate) pysat.logger.warning(" ".join(("sample rate is not a factor of the", "statistical window"))) pysat.logger.warning(" ".join(("new statistical window is", From b3ec0be60758d69727e00039d4d001bc3ba7f3e1 Mon Sep 17 00:00:00 2001 From: jklenzing Date: Thu, 7 Sep 2023 16:24:46 -0400 Subject: [PATCH 23/26] TST: test for warnings --- pysatNASA/tests/test_omni_hro.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pysatNASA/tests/test_omni_hro.py b/pysatNASA/tests/test_omni_hro.py index 3e9fc3e3..1bd95fc4 100644 --- a/pysatNASA/tests/test_omni_hro.py +++ b/pysatNASA/tests/test_omni_hro.py @@ -1,6 +1,7 @@ """Unit tests for OMNI HRO special functions.""" import datetime as dt +import logging import numpy as np import warnings @@ -179,6 +180,20 @@ def test_time_shift_to_magnetic_poles(self): assert (self.test_inst.index[1] - self.test_inst.index[0]).seconds == 60 return + def test_calculate_imf_steadiness_warnings(self, caplog): + """Test imf steadiness routine.""" + + omni.calculate_clock_angle(self.test_inst) + with caplog.at_level(logging.INFO, logger='pysat'): + omni.calculate_imf_steadiness(self.test_inst, steady_window=5.1, + min_window_frac=0.8) + captured = caplog.text + warn_msgs = ["sample rate is not a factor", + "new statistical window"] + for msg in warn_msgs: + assert msg in captured + return + class TestDeprecation(object): """Unit tests for deprecation warnings in `pysat.instrument.omni_hro`.""" From 7ca5c4f5ec91e1a64bcd2a9a4b0d4c1d2e16e554 Mon Sep 17 00:00:00 2001 From: jklenzing Date: Thu, 7 Sep 2023 16:26:04 -0400 Subject: [PATCH 24/26] DOC: update changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f54ef2ff..6c89673b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/). ## [0.X.X] - 2023-XX-XX +* Bug Fix + * New window needs to be integer for calculate_imf_steadiness * Maintenance * Implemented unit tests for cleaning warnings * Use pip install for readthedocs - * Add tests for omni hro routines + * Added tests for omni hro routines ## [0.0.5] - 2023-06-27 * New Instruments From 57be5e1f3eef94b1e93c991740c9749e33ec3709 Mon Sep 17 00:00:00 2001 From: Jeff Klenzing <19592220+jklenzing@users.noreply.github.com> Date: Thu, 7 Sep 2023 18:48:45 -0400 Subject: [PATCH 25/26] Apply suggestions from code review --- docs/archival.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/archival.rst b/docs/archival.rst index 46de4910..ad1b1d5e 100644 --- a/docs/archival.rst +++ b/docs/archival.rst @@ -8,11 +8,11 @@ Data Facility (SPDF) at NASA. In general, such instruments should include separate naming conventions. An example of this is the REACH data, where netCDF4 files are generated for -archival purposes as part of the `ops_reach` package, but can be accessed by -the end user through pysatNASA. +archival purposes as part of the :py:mod:`ops_reach` package, but can be accessed by +the end user through :py:mod:`pysatNASA`. -In general, a ``pysat.Instrument`` object can be constructed for any dataset. -Full instructions and conventions can be found +In general, a :py:class:`pysat.Instrument` object can be constructed for any +dataset. Full instructions and conventions can be found `here `_. In the case of the REACH data, the operational code reads in a series of csv files and updates the metadata according to user specifications. Once the file is loaded, @@ -50,8 +50,8 @@ preferred formats. An example of this is In this case, note that the pysat 'name' label is output to three different metadata values required by the ITSP standards. Additionally, the -``export_pysat_info`` option is set to false here. This drops several internal -pysat metadata values before writing to file. +:py:attr:`export_pysat_info` option is set to false here. This drops several +internal :py:mod:`pysat` metadata values before writing to file. A full guide to SPDF metadata standards can be found `here `_. From 4bc6d2e3bac146109770417c8cc235e857f1da8d Mon Sep 17 00:00:00 2001 From: Jeff Klenzing <19592220+jklenzing@users.noreply.github.com> Date: Fri, 8 Sep 2023 10:21:06 -0400 Subject: [PATCH 26/26] Update CHANGELOG.md Co-authored-by: Angeline Burrell --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c89673b..fe10a139 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). * Maintenance * Implemented unit tests for cleaning warnings * Use pip install for readthedocs - * Added tests for omni hro routines + * Added tests for OMNI HRO routines ## [0.0.5] - 2023-06-27 * New Instruments