Skip to content

Commit 37cfaee

Browse files
committed
Fixes non ISTP compliant files axis merging
Some files uses DEPEND_TIME instead of DEPEND_0 to point to time axis. This was supported by speasy for data variables but not for support variables. Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
1 parent 6730069 commit 37cfaee

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

speasy/core/cdf/__init__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ def _fix_attributes_types(attributes: dict):
2222
return cleaned
2323

2424

25-
def _make_axis(axis, time_axis_name):
25+
def _is_time_dependent(axis, time_axis_name):
26+
if axis.attributes.get('DEPEND_TIME', '') == time_axis_name:
27+
return True
2628
if axis.attributes.get('DEPEND_0', '') == time_axis_name:
27-
is_time_dependent = True
28-
else:
29-
is_time_dependent = False
29+
return True
30+
return False
31+
32+
33+
def _make_axis(axis, time_axis_name):
3034
return VariableAxis(values=axis.values.copy(), meta=_fix_attributes_types(axis.attributes), name=axis.name,
31-
is_time_dependent=is_time_dependent)
35+
is_time_dependent=_is_time_dependent(axis, time_axis_name))
3236

3337

3438
def _build_labels(variable: pyistp.loader.DataVariable):

speasy/webservices/generic_archive/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
from speasy.config import SPEASY_CONFIG_DIR
1313
from speasy.config import archive as cfg
14-
from speasy.core import AnyDateTimeType
14+
from speasy.core import AnyDateTimeType, AllowedKwargs
1515
from speasy.core.cdf.inventory_extractor import make_dataset_index
16-
from speasy.core.dataprovider import DataProvider
16+
from speasy.core.dataprovider import DataProvider, GET_DATA_ALLOWED_KWARGS
1717
from speasy.core.direct_archive_downloader import get_product
1818
from speasy.core.inventory.indexes import SpeasyIndex, ParameterIndex
1919
from speasy.products.variable import SpeasyVariable
@@ -82,6 +82,7 @@ def _parameter_index(self, product: str or ParameterIndex) -> ParameterIndex:
8282
else:
8383
raise ValueError(f"Got unexpected type {type(product)}, expecting str or ParameterIndex")
8484

85+
@AllowedKwargs(GET_DATA_ALLOWED_KWARGS)
8586
def get_data(self, product: str or ParameterIndex, start_time: AnyDateTimeType, stop_time: AnyDateTimeType,
8687
**kwargs) -> Optional[SpeasyVariable]:
8788
var = self._get_data(product=self._parameter_index(product), start_time=start_time, stop_time=stop_time)

tests/test_direct_archive_downloader.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ def test_get_data(self, product, start, stop):
9797
v = spz.get_data(product, start, stop)
9898
self.assertIsNotNone(v)
9999

100+
def test_axes_merging_across_files(self):
101+
v = spz.get_data(spz.inventories.tree.archive.cdpp.THEMIS.THA.L2.tha_esa.tha_peif_en_eflux, "2018-01-05",
102+
"2018-01-07")
103+
self.assertIsNotNone(v)
104+
self.assertEqual(len(v), len(v.axes[1]))
105+
100106

101107
if __name__ == '__main__':
102108
unittest.main()

0 commit comments

Comments
 (0)