Skip to content

Commit 80e43b0

Browse files
committed
REmove fetch_iceflow_df from public api
1 parent 670afa4 commit 80e43b0

File tree

3 files changed

+54
-57
lines changed

3 files changed

+54
-57
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
those on to CMR. This provides much greater flexibility over data search and
1313
makes the interface more consistent with `icepyx` and `earthaccess`.
1414
https://github.com/nsidc/iceflow/issues/51.
15+
- Remove restrictive `fetch_iceflow_df` function from public API. Users should
16+
utilize the search, download, and read functions described in
17+
`doc/getting-started.md` instead.
1518

1619
# v0.3.0
1720

src/nsidc/iceflow/api.py

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,61 +8,11 @@
88
import dask.dataframe as dd
99
from loguru import logger
1010

11-
from nsidc.iceflow.data.fetch import download_iceflow_results, find_iceflow_data
12-
from nsidc.iceflow.data.models import (
13-
BoundingBoxLike,
14-
Dataset,
15-
IceflowDataFrame,
16-
TemporalRange,
17-
)
1811
from nsidc.iceflow.data.read import read_iceflow_datafiles
1912
from nsidc.iceflow.data.supported_datasets import ALL_SUPPORTED_DATASETS
2013
from nsidc.iceflow.itrf.converter import transform_itrf
2114

2215

23-
def fetch_iceflow_df(
24-
*,
25-
bounding_box: BoundingBoxLike,
26-
temporal: TemporalRange,
27-
datasets: list[Dataset] = ALL_SUPPORTED_DATASETS,
28-
output_dir: Path,
29-
# TODO: also add option for target epoch!!
30-
output_itrf: str | None = None,
31-
) -> IceflowDataFrame:
32-
"""Search for data matching parameters and return an IceflowDataframe.
33-
34-
Optionally transform data to the given ITRF for consistency.
35-
36-
Note: a potentially large amount of data may be returned, especially if the
37-
user requests a large spatial/temporal area across multiple datasets. The
38-
result may not even fit in memory!
39-
40-
Consider using `make_iceflow_parquet` to store downloaded data in parquet
41-
format.
42-
"""
43-
44-
iceflow_search_reuslts = find_iceflow_data(
45-
bounding_box=bounding_box,
46-
temporal=temporal,
47-
datasets=datasets,
48-
)
49-
50-
downloaded_files = download_iceflow_results(
51-
iceflow_search_results=iceflow_search_reuslts,
52-
output_dir=output_dir,
53-
)
54-
55-
iceflow_df = read_iceflow_datafiles(downloaded_files)
56-
57-
if output_itrf is not None:
58-
iceflow_df = transform_itrf(
59-
data=iceflow_df,
60-
target_itrf=output_itrf,
61-
)
62-
63-
return iceflow_df
64-
65-
6616
def make_iceflow_parquet(
6717
*,
6818
data_dir: Path,

tests/integration/test_e2e.py

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,64 @@
2121
find_iceflow_data,
2222
make_iceflow_parquet,
2323
)
24-
from nsidc.iceflow.api import fetch_iceflow_df
2524
from nsidc.iceflow.data.models import (
2625
BoundingBoxLike,
2726
Dataset,
2827
IceflowDataFrame,
2928
TemporalRange,
3029
)
30+
from nsidc.iceflow.data.read import read_iceflow_datafiles
3131
from 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

4084
def 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

92136
def 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

Comments
 (0)