Skip to content

Commit 46981de

Browse files
authored
Merge pull request #36 from wx4stg/datasetonefile
lma_read.dataset single file support
2 parents f0bb273 + 6915a20 commit 46981de

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

pyxlma/lmalib/io/read.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ def dataset(filenames, sort_time=True):
9797
""" Create an xarray dataset of the type returned by
9898
pyxlma.lmalib.io.cf_netcdf.new_dataset for each filename in filenames
9999
"""
100+
if type(filenames) == str:
101+
filenames = [filenames]
100102
lma_data = []
101103
starttime = None
102104
next_event_id = 0

tests/test_io.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from datetime import datetime as dt
55
import xarray as xr
66
from pyxlma.lmalib.io import read as lma_read
7+
from tests.test_flash import compare_dataarrays
78

89

910
def test_read_mf_dataset():
@@ -13,3 +14,11 @@ def test_read_mf_dataset():
1314
dataset, start_date = lma_read.dataset(files_to_read)
1415
assert start_date == dt(2023, 12, 24, 0, 57, 1)
1516
assert dataset == xr.open_dataset('tests/truth/lma_netcdf/lma.nc')
17+
18+
19+
def test_read_onefile_dataset():
20+
dataset, start_date = lma_read.dataset('examples/data/WTLMA_231224_005701_0001.dat.gz')
21+
assert start_date == dt(2023, 12, 24, 0, 57, 1)
22+
truth = xr.open_dataset('tests/truth/lma_netcdf/small_lma.nc')
23+
for var in truth.data_vars:
24+
compare_dataarrays(dataset, truth, var)
58.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)