2121 find_iceflow_data ,
2222 make_iceflow_parquet ,
2323)
24- from nsidc .iceflow .api import fetch_iceflow_df
2524from nsidc .iceflow .data .models import (
2625 BoundingBoxLike ,
2726 Dataset ,
2827 IceflowDataFrame ,
2928 TemporalRange ,
3029)
30+ from nsidc .iceflow .data .read import read_iceflow_datafiles
3131from nsidc .iceflow .data .supported_datasets import (
3232 ALL_SUPPORTED_DATASETS ,
3333 BLATM1BDataset ,
3434 GLAH06Dataset ,
3535 ILATM1BDataset ,
3636 ILVIS2Dataset ,
3737)
38+ from nsidc .iceflow .itrf .converter import transform_itrf
39+
40+
41+ def _fetch_iceflow_df (
42+ * ,
43+ bounding_box : BoundingBoxLike ,
44+ temporal : TemporalRange ,
45+ datasets : list [Dataset ] = ALL_SUPPORTED_DATASETS ,
46+ output_dir : Path ,
47+ # TODO: also add option for target epoch!!
48+ output_itrf : str | None = None ,
49+ ):
50+ """Search for data matching parameters and return an IceflowDataframe.
51+
52+ Optionally transform data to the given ITRF for consistency.
53+
54+ Note: a potentially large amount of data may be returned, especially if the
55+ user requests a large spatial/temporal area across multiple datasets. The
56+ result may not even fit in memory!
57+
58+ Consider using `make_iceflow_parquet` to store downloaded data in parquet
59+ format.
60+ """
61+
62+ iceflow_search_reuslts = find_iceflow_data (
63+ bounding_box = bounding_box ,
64+ temporal = temporal ,
65+ datasets = datasets ,
66+ )
67+
68+ downloaded_files = download_iceflow_results (
69+ iceflow_search_results = iceflow_search_reuslts ,
70+ output_dir = output_dir ,
71+ )
72+
73+ iceflow_df = read_iceflow_datafiles (downloaded_files )
74+
75+ if output_itrf is not None :
76+ iceflow_df = transform_itrf (
77+ data = iceflow_df ,
78+ target_itrf = output_itrf ,
79+ )
80+
81+ return iceflow_df
3882
3983
4084def test_atm1b_ilatm1b (tmp_path ):
@@ -47,7 +91,7 @@ def test_atm1b_ilatm1b(tmp_path):
4791 )
4892
4993 # Native ITRF is ITRF2005
50- results_ilatm1b_v1_2009 = fetch_iceflow_df (
94+ results_ilatm1b_v1_2009 = _fetch_iceflow_df (
5195 datasets = [ILATM1BDataset (version = "1" )],
5296 bounding_box = common_bounding_box ,
5397 temporal = (dt .date (2009 , 11 , 1 ), dt .date (2009 , 12 , 1 )),
@@ -56,7 +100,7 @@ def test_atm1b_ilatm1b(tmp_path):
56100 )
57101
58102 # Native ITRF is ITRF2008
59- results_ilatm1b_v2_2014 = fetch_iceflow_df (
103+ results_ilatm1b_v2_2014 = _fetch_iceflow_df (
60104 datasets = [ILATM1BDataset (version = "2" )],
61105 bounding_box = common_bounding_box ,
62106 temporal = (dt .date (2014 , 11 , 1 ), dt .date (2014 , 12 , 1 )),
@@ -79,7 +123,7 @@ def test_atm1b_blatm1b(tmp_path):
79123 - 65.0 ,
80124 )
81125
82- results_blamt1b_v2_2014 = fetch_iceflow_df (
126+ results_blamt1b_v2_2014 = _fetch_iceflow_df (
83127 datasets = [BLATM1BDataset ()],
84128 bounding_box = common_bounding_box ,
85129 temporal = (dt .date (2002 , 11 , 27 ), dt .date (2002 , 11 , 28 )),
@@ -90,7 +134,7 @@ def test_atm1b_blatm1b(tmp_path):
90134
91135
92136def test_ivlis2 (tmp_path ):
93- results_v1 = fetch_iceflow_df (
137+ results_v1 = _fetch_iceflow_df (
94138 datasets = [ILVIS2Dataset (version = "1" )],
95139 bounding_box = (
96140 - 120.0 ,
@@ -104,7 +148,7 @@ def test_ivlis2(tmp_path):
104148
105149 assert (results_v1 .ITRF == "ITRF2000" ).all ()
106150
107- results_v2 = fetch_iceflow_df (
151+ results_v2 = _fetch_iceflow_df (
108152 datasets = [ILVIS2Dataset (version = "2" )],
109153 bounding_box = (
110154 - 180 ,
@@ -132,7 +176,7 @@ def test_glah06(tmp_path):
132176 90 ,
133177 )
134178
135- results = fetch_iceflow_df (
179+ results = _fetch_iceflow_df (
136180 datasets = [GLAH06Dataset ()],
137181 bounding_box = common_bounding_box ,
138182 temporal = (
0 commit comments