This repository was archived by the owner on Sep 11, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
nowcasting_dataset/data_sources/satellite
tests/data_sources/satellite Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 77
88logger = logging .getLogger (__name__ )
99
10+ satellite_expected_dims_order = (
11+ "example" ,
12+ "time_index" ,
13+ "channels_index" ,
14+ "y_geostationary_index" ,
15+ "x_geostationary_index" ,
16+ )
17+
1018
1119class Satellite (DataSourceOutput ):
1220 """Class to store satellite data as a xr.Dataset with some validation"""
@@ -34,6 +42,10 @@ def model_validation(cls, v):
3442 v .check_data_var_dim (v .x_geostationary , ("example" , "x_geostationary_index" ))
3543 v .check_data_var_dim (v .y_geostationary , ("example" , "y_geostationary_index" ))
3644
45+ # re-order dims
46+ if v .data .dims != satellite_expected_dims_order :
47+ v .__setitem__ ("data" , v .data .transpose (* satellite_expected_dims_order ))
48+
3749 return v
3850
3951
Original file line number Diff line number Diff line change 66import pytest
77
88from nowcasting_dataset .data_sources .fake .batch import satellite_fake
9- from nowcasting_dataset .data_sources .satellite .satellite_model import Satellite
9+ from nowcasting_dataset .data_sources .satellite .satellite_model import (
10+ Satellite ,
11+ satellite_expected_dims_order ,
12+ )
1013
1114
1215def test_satellite_init (): # noqa: D103
@@ -15,6 +18,12 @@ def test_satellite_init(): # noqa: D103
1518 assert satellite .x_geostationary .dims == ("example" , "x_geostationary_index" )
1619
1720
21+ def test_satellite_dims_order (): # noqa: D103
22+ satellite = satellite_fake ()
23+ satellite = Satellite .model_validation (satellite )
24+ assert satellite .data .dims == satellite_expected_dims_order
25+
26+
1827def test_satellite_validation (): # noqa: D103
1928 sat = satellite_fake ()
2029
You can’t perform that action at this time.
0 commit comments