diff --git a/CHANGELOG.md b/CHANGELOG.md index 2159441..2d730c0 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 * Bugs * Fixed errors introduced by assuming files will be present when combining F10.7 or Kp data in `combine_f107` and `combine_kp` functions. 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/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 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) 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