From f67e9a7a983c08d5e81b248b1c6423912d6aab7c Mon Sep 17 00:00:00 2001 From: Nick H <34072991+nickssl@users.noreply.github.com> Date: Wed, 31 Jan 2024 16:23:41 -0800 Subject: [PATCH] Improved data handling --- pyspedas/kyoto/load_dst.py | 6 +++++- pyspedas/kyoto/tests/tests.py | 16 ++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pyspedas/kyoto/load_dst.py b/pyspedas/kyoto/load_dst.py index 707a9e28..b3ab1cd2 100644 --- a/pyspedas/kyoto/load_dst.py +++ b/pyspedas/kyoto/load_dst.py @@ -98,7 +98,11 @@ def dst( logging.error("trange keyword required to download data.") return - file_names = dailynames(file_format="%Y%m/index.html", trange=trange) + try: + file_names = dailynames(file_format="%Y%m/index.html", trange=trange) + except Exception as e: + logging.error("Error occurred while getting file names: " + str(e)) + return times = [] data = [] diff --git a/pyspedas/kyoto/tests/tests.py b/pyspedas/kyoto/tests/tests.py index e6ebcff2..9208b1d6 100644 --- a/pyspedas/kyoto/tests/tests.py +++ b/pyspedas/kyoto/tests/tests.py @@ -6,19 +6,19 @@ class LoadTestCases(unittest.TestCase): def test_load_dst_data(self): # final - dst_vars = pyspedas.kyoto.dst(trange=['2015-10-15', '2015-10-16']) - self.assertTrue(data_exists('kyoto_dst')) + dst_vars = pyspedas.kyoto.dst(trange=["2015-10-15", "2015-10-16"]) + self.assertTrue(data_exists("kyoto_dst")) # provisional - dst_vars = pyspedas.kyoto.dst(trange=['2019-10-15', '2019-10-16']) - self.assertTrue(data_exists('kyoto_dst')) + dst_vars = pyspedas.kyoto.dst(trange=["2019-10-15", "2019-10-16"]) + self.assertTrue(data_exists("kyoto_dst")) # real time - dst_vars = pyspedas.kyoto.dst(trange=['2022-7-15', '2022-7-16']) - self.assertTrue(data_exists('kyoto_dst')) + dst_vars = pyspedas.kyoto.dst(trange=["2022-07-15", "2022-07-16"]) + self.assertTrue(data_exists("kyoto_dst")) def test_errors(self): pyspedas.kyoto.dst(trange=None) - pyspedas.kyoto.dst(trange=['1015-10-15', '1015-10-16']) + pyspedas.kyoto.dst(trange=["1015-10-15", "1015-10-16"]) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main()