Skip to content

Commit 5f0676b

Browse files
Added unit tests for duplicate timestamps when loading NetCDF data with subsecond resolution
1 parent f5db108 commit 5f0676b

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

pyspedas/cdagui_tools/tests/test_cdagui.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import unittest
22
from pyspedas import CDAWeb, data_exists, del_data, get_data, time_double
33
from pyspedas.cdagui_tools.config import CONFIG
4+
import numpy as np
45

56
output_dir = CONFIG["local_data_dir"]
67

@@ -107,6 +108,11 @@ def test_load_goes_netcdf(self):
107108
result = cdaweb_obj.cda_download(urllist, output_dir)
108109
self.assertEqual(len(result) > 0, True)
109110
self.assertTrue(data_exists("b_gse"))
111+
# Test for duplicate timestamps
112+
d=get_data('b_gse')
113+
dt = d.times[1:] - d.times[0:-1]
114+
# Time resolution for this data type should be 0.1 sec
115+
self.assertTrue(np.min(dt) > 0.001)
110116

111117
def test_load_time_clip(self):
112118
del_data("*")

pyspedas/projects/goes/tests/test_goes.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44
import logging
55
import pyspedas
6-
from pyspedas.tplot_tools import data_exists, del_data
6+
from pyspedas.tplot_tools import data_exists, del_data, get_data
77
from pyspedas.projects.goes.config import CONFIG
88

99
global_display = False
@@ -381,6 +381,12 @@ def test_load_mag_data_17(self):
381381
)
382382
self.assertTrue("goes17_b_gse" in mag_vars_17)
383383
self.assertTrue(data_exists("goes17_b_gse"))
384+
# Check for duplicate timestamps
385+
d=get_data('goes17_b_gse')
386+
dt=d.times[1:] - d.times[0:-1]
387+
# Time resolution for this variable should be about 0.1 sec
388+
self.assertTrue(np.min(dt) > 0.001)
389+
384390

385391
def test_load_mpsh_data_17(self):
386392
del_data()

0 commit comments

Comments
 (0)