1212
1313import datetime as dt
1414
15+ import dask .dataframe as dd
1516import pandas as pd
1617
17- from nsidc .iceflow .api import fetch_iceflow_df
18+ from nsidc .iceflow .api import create_iceflow_parquet , fetch_iceflow_df
1819from nsidc .iceflow .data .models import (
1920 BLATM1BDataset ,
2021 BoundingBox ,
@@ -38,7 +39,7 @@ def test_atm1b_ilatm1b(tmp_path):
3839 # Native ITRF is ITRF2005
3940 results_ilatm1b_v1_2009 = fetch_iceflow_df (
4041 dataset_search_params = DatasetSearchParameters (
41- dataset = ILATM1BDataset (version = "1" ),
42+ datasets = [ ILATM1BDataset (version = "1" )] ,
4243 bounding_box = common_bounding_box ,
4344 temporal = (dt .date (2009 , 11 , 1 ), dt .date (2009 , 12 , 1 )),
4445 ),
@@ -49,7 +50,7 @@ def test_atm1b_ilatm1b(tmp_path):
4950 # Native ITRF is ITRF2008
5051 results_ilatm1b_v2_2014 = fetch_iceflow_df (
5152 dataset_search_params = DatasetSearchParameters (
52- dataset = ILATM1BDataset (version = "2" ),
53+ datasets = [ ILATM1BDataset (version = "2" )] ,
5354 bounding_box = common_bounding_box ,
5455 temporal = (dt .date (2014 , 11 , 1 ), dt .date (2014 , 12 , 1 )),
5556 ),
@@ -74,7 +75,7 @@ def test_atm1b_blatm1b(tmp_path):
7475
7576 results_blamt1b_v2_2014 = fetch_iceflow_df (
7677 dataset_search_params = DatasetSearchParameters (
77- dataset = BLATM1BDataset (),
78+ datasets = [ BLATM1BDataset ()] ,
7879 bounding_box = common_bounding_box ,
7980 temporal = (dt .date (2002 , 11 , 27 ), dt .date (2002 , 11 , 28 )),
8081 ),
@@ -87,7 +88,7 @@ def test_atm1b_blatm1b(tmp_path):
8788def test_ivlis2 (tmp_path ):
8889 results_v1 = fetch_iceflow_df (
8990 dataset_search_params = DatasetSearchParameters (
90- dataset = ILVIS2Dataset (version = "1" ),
91+ datasets = [ ILVIS2Dataset (version = "1" )] ,
9192 bounding_box = BoundingBox (
9293 lower_left_lon = - 120.0 ,
9394 lower_left_lat = - 80.0 ,
@@ -103,7 +104,7 @@ def test_ivlis2(tmp_path):
103104
104105 results_v2 = fetch_iceflow_df (
105106 dataset_search_params = DatasetSearchParameters (
106- dataset = ILVIS2Dataset (version = "2" ),
107+ datasets = [ ILVIS2Dataset (version = "2" )] ,
107108 bounding_box = BoundingBox (
108109 lower_left_lon = - 180 ,
109110 lower_left_lat = 60.0 ,
@@ -133,7 +134,7 @@ def test_glah06(tmp_path):
133134
134135 results = fetch_iceflow_df (
135136 dataset_search_params = DatasetSearchParameters (
136- dataset = GLAH06Dataset (),
137+ datasets = [ GLAH06Dataset ()] ,
137138 bounding_box = common_bounding_box ,
138139 temporal = (
139140 dt .datetime (2003 , 2 , 20 , 22 , 25 ),
@@ -144,3 +145,35 @@ def test_glah06(tmp_path):
144145 )
145146
146147 assert (results .ITRF == "ITRF2008" ).all ()
148+
149+
150+ def test_create_iceflow_parquet (tmp_path ):
151+ target_itrf = "ITRF2014"
152+ common_bounding_box = BoundingBox (
153+ lower_left_lon = - 49.149 ,
154+ lower_left_lat = 69.186 ,
155+ upper_right_lon = - 48.949 ,
156+ upper_right_lat = 69.238 ,
157+ )
158+
159+ # This should finds 4 results for ILATM1B v1 and 3 results for v2.
160+ parquet_path = create_iceflow_parquet (
161+ dataset_search_params = DatasetSearchParameters (
162+ datasets = [ILATM1BDataset (version = "1" ), ILATM1BDataset (version = "2" )],
163+ bounding_box = common_bounding_box ,
164+ temporal = ((dt .date (2007 , 1 , 1 ), dt .date (2014 , 10 , 28 ))),
165+ ),
166+ output_dir = tmp_path ,
167+ target_itrf = target_itrf ,
168+ )
169+
170+ df = dd .read_parquet (parquet_path ) # type: ignore[attr-defined]
171+
172+ # Assert that the parquet data has the expected columns
173+ expected_columns = sorted (["latitude" , "longitude" , "elevation" , "dataset" ])
174+ assert expected_columns == sorted (df .columns )
175+
176+ # Assert that the two datasets we expect are present.
177+ assert sorted (["ILATM1Bv1" , "ILATM1Bv2" ]) == sorted (
178+ df .dataset .unique ().compute ().values
179+ )
0 commit comments