From d18c47d267415fa817f4742bb86245a42a3f57b8 Mon Sep 17 00:00:00 2001 From: "Angeline G. Burrell" Date: Wed, 14 Aug 2024 11:31:32 -0400 Subject: [PATCH 1/4] TST: updated utcnow Removed the deprecated `utcnow` method in the unit tests. --- pysatSpaceWeather/tests/test_methods_gfz.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pysatSpaceWeather/tests/test_methods_gfz.py b/pysatSpaceWeather/tests/test_methods_gfz.py index c395433..dfdb8fb 100644 --- a/pysatSpaceWeather/tests/test_methods_gfz.py +++ b/pysatSpaceWeather/tests/test_methods_gfz.py @@ -40,7 +40,8 @@ def test_kp_ap_cp_download_bad_inst(self): """Test the download doesn't work for an incorrect Instrument.""" with pytest.raises(ValueError) as verr: gfz.kp_ap_cp_download('platform', 'name', 'tag', 'inst_id', - [dt.datetime.utcnow()], 'data/path') + [dt.datetime.now(tz=dt.timezone.utc)], + 'data/path') assert str(verr).find('Unknown Instrument module') >= 0 return From b8b0cc40420d19e1afeefe8869bbf8eee22bb4e9 Mon Sep 17 00:00:00 2001 From: "Angeline G. Burrell" Date: Wed, 14 Aug 2024 11:32:07 -0400 Subject: [PATCH 2/4] MAINT: updated utcnow in methods Updated the `utcnow` method call to `now` with the UTC timezone in the instrument methods. --- pysatSpaceWeather/instruments/methods/ace.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pysatSpaceWeather/instruments/methods/ace.py b/pysatSpaceWeather/instruments/methods/ace.py index 83f756f..5e11e2b 100644 --- a/pysatSpaceWeather/instruments/methods/ace.py +++ b/pysatSpaceWeather/instruments/methods/ace.py @@ -202,7 +202,7 @@ def download(date_array, name, tag='', inst_id='', data_path='', now=None, """ # Ensure now is up-to-date, if desired if now is None: - now = dt.datetime.utcnow() + now = dt.datetime.now(tz=dt.timezone.utc) # Define the file information for each data type and check the # date range From ecdf4222eb98c49a24c8f70d3af877b6cbb62a09 Mon Sep 17 00:00:00 2001 From: "Angeline G. Burrell" Date: Wed, 14 Aug 2024 11:32:34 -0400 Subject: [PATCH 3/4] MAINT: updated utcnow in Instruments Updated the `utcnow` method call to `now` with the UTC timezone in the instrument submodules. --- pysatSpaceWeather/instruments/ace_epam.py | 2 +- pysatSpaceWeather/instruments/ace_mag.py | 2 +- pysatSpaceWeather/instruments/ace_sis.py | 2 +- pysatSpaceWeather/instruments/ace_swepam.py | 2 +- pysatSpaceWeather/instruments/sw_ap.py | 2 +- pysatSpaceWeather/instruments/sw_f107.py | 2 +- pysatSpaceWeather/instruments/sw_flare.py | 2 +- pysatSpaceWeather/instruments/sw_kp.py | 2 +- pysatSpaceWeather/instruments/sw_mgii.py | 2 +- pysatSpaceWeather/instruments/sw_polarcap.py | 2 +- pysatSpaceWeather/instruments/sw_sbfield.py | 2 +- pysatSpaceWeather/instruments/sw_ssn.py | 2 +- pysatSpaceWeather/instruments/sw_stormprob.py | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pysatSpaceWeather/instruments/ace_epam.py b/pysatSpaceWeather/instruments/ace_epam.py index ae439c6..a895fd1 100644 --- a/pysatSpaceWeather/instruments/ace_epam.py +++ b/pysatSpaceWeather/instruments/ace_epam.py @@ -68,7 +68,7 @@ inst_ids = {inst_id: [tag for tag in tags.keys()] for inst_id in ['']} # Define today's date -now = dt.datetime.utcnow() +now = dt.datetime.now(tz=dt.timezone.utc) # ---------------------------------------------------------------------------- # Instrument test attributes diff --git a/pysatSpaceWeather/instruments/ace_mag.py b/pysatSpaceWeather/instruments/ace_mag.py index 27e82fb..fbf874d 100644 --- a/pysatSpaceWeather/instruments/ace_mag.py +++ b/pysatSpaceWeather/instruments/ace_mag.py @@ -68,7 +68,7 @@ inst_ids = {inst_id: [tag for tag in tags.keys()] for inst_id in ['']} # Define today's date -now = dt.datetime.utcnow() +now = dt.datetime.now(tz=dt.timezone.utc) # ---------------------------------------------------------------------------- # Instrument test attributes diff --git a/pysatSpaceWeather/instruments/ace_sis.py b/pysatSpaceWeather/instruments/ace_sis.py index 5ad0596..405ab18 100644 --- a/pysatSpaceWeather/instruments/ace_sis.py +++ b/pysatSpaceWeather/instruments/ace_sis.py @@ -68,7 +68,7 @@ inst_ids = {inst_id: [tag for tag in tags.keys()] for inst_id in ['']} # Define today's date -now = dt.datetime.utcnow() +now = dt.datetime.now(tz=dt.timezone.utc) # ---------------------------------------------------------------------------- # Instrument test attributes diff --git a/pysatSpaceWeather/instruments/ace_swepam.py b/pysatSpaceWeather/instruments/ace_swepam.py index 174d424..e6a164c 100644 --- a/pysatSpaceWeather/instruments/ace_swepam.py +++ b/pysatSpaceWeather/instruments/ace_swepam.py @@ -67,7 +67,7 @@ inst_ids = {inst_id: [tag for tag in tags.keys()] for inst_id in ['']} # Define today's date -now = dt.datetime.utcnow() +now = dt.datetime.now(tz=dt.timezone.utc) # ---------------------------------------------------------------------------- # Instrument test attributes diff --git a/pysatSpaceWeather/instruments/sw_ap.py b/pysatSpaceWeather/instruments/sw_ap.py index cc20853..f87562f 100644 --- a/pysatSpaceWeather/instruments/sw_ap.py +++ b/pysatSpaceWeather/instruments/sw_ap.py @@ -89,7 +89,7 @@ inst_ids = {'': list(tags.keys())} # Generate todays date to support loading forecast data -now = dt.datetime.utcnow() +now = dt.datetime.now(tz=dt.timezone.utc) today = dt.datetime(now.year, now.month, now.day) tomorrow = today + dt.timedelta(days=1) diff --git a/pysatSpaceWeather/instruments/sw_f107.py b/pysatSpaceWeather/instruments/sw_f107.py index 0bcf106..ee6da9b 100644 --- a/pysatSpaceWeather/instruments/sw_f107.py +++ b/pysatSpaceWeather/instruments/sw_f107.py @@ -95,7 +95,7 @@ # Dict keyed by inst_id that lists supported tags and a good day of test data # generate todays date to support loading forecast data -now = dt.datetime.utcnow() +now = dt.datetime.now(tz=dt.timezone.utc) today = dt.datetime(now.year, now.month, now.day) tomorrow = today + dt.timedelta(days=1) diff --git a/pysatSpaceWeather/instruments/sw_flare.py b/pysatSpaceWeather/instruments/sw_flare.py index 54bd147..78870e0 100644 --- a/pysatSpaceWeather/instruments/sw_flare.py +++ b/pysatSpaceWeather/instruments/sw_flare.py @@ -74,7 +74,7 @@ # Dict keyed by inst_id that lists supported tags and a good day of test data # generate todays date to support loading forecast data -now = dt.datetime.utcnow() +now = dt.datetime.now(tz=dt.timezone.utc) today = dt.datetime(now.year, now.month, now.day) tomorrow = today + dt.timedelta(days=1) diff --git a/pysatSpaceWeather/instruments/sw_kp.py b/pysatSpaceWeather/instruments/sw_kp.py index 030b93b..51a33cd 100644 --- a/pysatSpaceWeather/instruments/sw_kp.py +++ b/pysatSpaceWeather/instruments/sw_kp.py @@ -89,7 +89,7 @@ inst_ids = {'': list(tags.keys())} # Generate todays date to support loading forecast data -now = dt.datetime.utcnow() +now = dt.datetime.now(tz=dt.timezone.utc) today = dt.datetime(now.year, now.month, now.day) # ---------------------------------------------------------------------------- diff --git a/pysatSpaceWeather/instruments/sw_mgii.py b/pysatSpaceWeather/instruments/sw_mgii.py index c624a19..2dc766e 100644 --- a/pysatSpaceWeather/instruments/sw_mgii.py +++ b/pysatSpaceWeather/instruments/sw_mgii.py @@ -55,7 +55,7 @@ # Dict keyed by inst_id that lists supported tags and a good day of test data # generate todays date to support loading forecast data -now = dt.datetime.utcnow() +now = dt.datetime.now(tz=dt.timezone.utc) today = dt.datetime(now.year, now.month, now.day) tomorrow = today + pds.DateOffset(days=1) diff --git a/pysatSpaceWeather/instruments/sw_polarcap.py b/pysatSpaceWeather/instruments/sw_polarcap.py index 9a85df0..7739ff1 100644 --- a/pysatSpaceWeather/instruments/sw_polarcap.py +++ b/pysatSpaceWeather/instruments/sw_polarcap.py @@ -69,7 +69,7 @@ inst_ids = {'': list(tags.keys())} # Generate todays date to support loading forecast data -now = dt.datetime.utcnow() +now = dt.datetime.now(tz=dt.timezone.utc) today = dt.datetime(now.year, now.month, now.day) tomorrow = today + dt.timedelta(days=1) diff --git a/pysatSpaceWeather/instruments/sw_sbfield.py b/pysatSpaceWeather/instruments/sw_sbfield.py index f4207f4..352dcbf 100644 --- a/pysatSpaceWeather/instruments/sw_sbfield.py +++ b/pysatSpaceWeather/instruments/sw_sbfield.py @@ -52,7 +52,7 @@ # Dict keyed by inst_id that lists supported tags and a good day of test data # generate todays date to support loading forecast data -now = dt.datetime.utcnow() +now = dt.datetime.now(tz=dt.timezone.utc) today = dt.datetime(now.year, now.month, now.day) tomorrow = today + pds.DateOffset(days=1) diff --git a/pysatSpaceWeather/instruments/sw_ssn.py b/pysatSpaceWeather/instruments/sw_ssn.py index 77eafba..81f6e9c 100644 --- a/pysatSpaceWeather/instruments/sw_ssn.py +++ b/pysatSpaceWeather/instruments/sw_ssn.py @@ -55,7 +55,7 @@ # Dict keyed by inst_id that lists supported tags and a good day of test data # generate todays date to support loading forecast data -now = dt.datetime.utcnow() +now = dt.datetime.now(tz=dt.timezone.utc) today = dt.datetime(now.year, now.month, now.day) tomorrow = today + pds.DateOffset(days=1) diff --git a/pysatSpaceWeather/instruments/sw_stormprob.py b/pysatSpaceWeather/instruments/sw_stormprob.py index 1dea807..aec1fde 100644 --- a/pysatSpaceWeather/instruments/sw_stormprob.py +++ b/pysatSpaceWeather/instruments/sw_stormprob.py @@ -70,7 +70,7 @@ inst_ids = {'': list(tags.keys())} # Generate todays date to support loading forecast data -now = dt.datetime.utcnow() +now = dt.datetime.now(tz=dt.timezone.utc) today = dt.datetime(now.year, now.month, now.day) tomorrow = today + dt.timedelta(days=1) From fff9629e340cf9892ef95651f21d29f6bcc41517 Mon Sep 17 00:00:00 2001 From: "Angeline G. Burrell" Date: Wed, 14 Aug 2024 11:33:00 -0400 Subject: [PATCH 4/4] DOC: updated changelog Added a description of this pull request to the changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f89ef1..53606d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). * Implemented `iloc` in pandas Series and DataFrame index access * Added `verify=False` to GFZ requests * Updated documentation links and fixed intersphinx mapping + * Replaced `utcnow` with `now` and the UTC timezone [0.1.0] - 2024-02-16 --------------------