core-lens 0.1.dev108__tar.gz → 0.1.dev110__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/PKG-INFO +1 -1
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/_version.py +2 -2
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/aoi.py +1 -1
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/base/namespaces/plot.py +5 -3
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/base/result.py +1 -5
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/utils/spatial.py +34 -27
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/.github/pull_request_template.md +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/.github/workflows/ci.yml +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/.github/workflows/gh-pages.yml +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/.github/workflows/pre-release.yml +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/.github/workflows/release.yml +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/.gitignore +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/.gitmessage +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/.pre-commit-config.yaml +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/.python-version +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/CONTRIBUTING.md +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/LICENSE +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/README.md +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/SKILLS.md +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/docs/Makefile +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/docs/make.bat +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/docs/source/concepts.md +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/docs/source/conf.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/docs/source/index.rst +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/docs/source/intro.md +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/docs/source/plots.md +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/docs/source/plugins.md +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/docs/source/queries.md +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/docs/source/quickstart.md +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/docs/source/stats.md +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/examples/demo_mws.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/examples/demo_tehsil.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/hooks/mypy.sh +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/hooks/no-parquet-outside-fixtures.sh +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/hooks/pytest.sh +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/pyproject.toml +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/__init__.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/__main__.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/base/__init__.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/base/entity.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/base/namespaces/__init__.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/base/namespaces/stats.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/base/view.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/entities/__init__.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/entities/mws.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/entities/tehsil.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/entities/waterbody.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/export/__init__.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/export/formats.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/py.typed +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/schema/__init__.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/schema/detection.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/schema/profile.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/utils/__init__.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/utils/polars_utils.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/src/core_lens/utils/season.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/tests/fixtures/generate_fixtures.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/tests/unit/conftest.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/tests/unit/test_aoi.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/tests/unit/test_entities.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/tests/unit/test_entity.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/tests/unit/test_export.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/tests/unit/test_main.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/tests/unit/test_plot.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/tests/unit/test_polars_utils.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/tests/unit/test_profile.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/tests/unit/test_result.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/tests/unit/test_schema_detection.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/tests/unit/test_schema_profile.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/tests/unit/test_season.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/tests/unit/test_season_config.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/tests/unit/test_spatial.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/tests/unit/test_stats.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/tests/unit/test_view.py +0 -0
- {core_lens-0.1.dev108 → core_lens-0.1.dev110}/uv.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: core-lens
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.dev110
|
|
4
4
|
Summary: Query, analyse, and visualise CoreStack's microwatershed and Earth science data through a clean, composable Python API.
|
|
5
5
|
Project-URL: Homepage, https://github.com/ApoorvaKashyap/core-lens
|
|
6
6
|
Project-URL: Issues, https://github.com/ApoorvaKashyap/core-lens/issues
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '0.1.
|
|
22
|
-
__version_tuple__ = version_tuple = (0, 1, '
|
|
21
|
+
__version__ = version = '0.1.dev110'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 1, 'dev110')
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -360,7 +360,7 @@ class AoI:
|
|
|
360
360
|
or col in candidate.schema_profile.extra_static_cols
|
|
361
361
|
):
|
|
362
362
|
if isinstance(val, list):
|
|
363
|
-
|
|
363
|
+
lf = lf.join(pl.LazyFrame({col: val}), on=col, how="inner")
|
|
364
364
|
else:
|
|
365
365
|
filter_expr = filter_expr & (pl.col(col) == val)
|
|
366
366
|
|
|
@@ -460,7 +460,9 @@ class PlotNamespace:
|
|
|
460
460
|
unique_entities = entity_df[key_col].unique()
|
|
461
461
|
if len(unique_entities) > top_n:
|
|
462
462
|
entities = unique_entities.limit(top_n).to_list()
|
|
463
|
-
entity_df = entity_df.
|
|
463
|
+
entity_df = entity_df.join(
|
|
464
|
+
pl.DataFrame({key_col: entities}), on=key_col, how="inner"
|
|
465
|
+
)
|
|
464
466
|
entity_pdf = entity_df.to_pandas()
|
|
465
467
|
|
|
466
468
|
fig_entity = _make_fig(entity_pdf, f"Timeseries — {y_col} (Per Entity)")
|
|
@@ -512,7 +514,7 @@ class PlotNamespace:
|
|
|
512
514
|
unique_entities = df[key_col].unique()
|
|
513
515
|
if len(unique_entities) > top_n:
|
|
514
516
|
entities = unique_entities.limit(top_n).to_list()
|
|
515
|
-
df = df.
|
|
517
|
+
df = df.join(pl.DataFrame({key_col: entities}), on=key_col, how="inner")
|
|
516
518
|
|
|
517
519
|
df_pd = df.to_pandas()
|
|
518
520
|
|
|
@@ -583,7 +585,7 @@ class PlotNamespace:
|
|
|
583
585
|
unique_entities = df[key_col].unique()
|
|
584
586
|
if len(unique_entities) > top_n:
|
|
585
587
|
entities = unique_entities.limit(top_n).to_list()
|
|
586
|
-
df = df.
|
|
588
|
+
df = df.join(pl.DataFrame({key_col: entities}), on=key_col, how="inner")
|
|
587
589
|
|
|
588
590
|
df_pd = df.to_pandas()
|
|
589
591
|
|
|
@@ -148,11 +148,7 @@ class Result:
|
|
|
148
148
|
geo_df = collect_lf(
|
|
149
149
|
pl.scan_parquet(static_path)
|
|
150
150
|
.select(key_cols + [geom_col])
|
|
151
|
-
.
|
|
152
|
-
pl.col(key_cols[0]).is_in(self.data[key_cols[0]].to_list())
|
|
153
|
-
if len(key_cols) == 1
|
|
154
|
-
else pl.lit(True)
|
|
155
|
-
)
|
|
151
|
+
.join(self.data.select(key_cols).unique().lazy(), on=key_cols, how="inner")
|
|
156
152
|
)
|
|
157
153
|
|
|
158
154
|
joined = self.data.join(geo_df, on=key_cols, how="left")
|
|
@@ -77,26 +77,37 @@ def build_bbox_index(
|
|
|
77
77
|
+ "Cannot compute bounds from separate lat/lon columns without bbox hints."
|
|
78
78
|
)
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
geom_series = df[geometry_col]
|
|
80
|
+
import pyarrow.parquet as pq # type: ignore[import-untyped]
|
|
82
81
|
|
|
83
|
-
|
|
82
|
+
pf = pq.ParquetFile(static_path)
|
|
83
|
+
chunks = []
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
geoms = shapely.from_wkt(geom_array)
|
|
85
|
+
for batch in pf.iter_batches(batch_size=25_000, columns=cols_to_read):
|
|
86
|
+
batch_df = pl.from_arrow(batch)
|
|
87
|
+
assert isinstance(batch_df, pl.DataFrame)
|
|
89
88
|
|
|
90
|
-
|
|
91
|
-
bnds = shapely.bounds(geoms)
|
|
92
|
-
return df.select(key_cols).with_columns(
|
|
93
|
-
pl.Series("minx", bnds[:, 0], dtype=pl.Float64),
|
|
94
|
-
pl.Series("miny", bnds[:, 1], dtype=pl.Float64),
|
|
95
|
-
pl.Series("maxx", bnds[:, 2], dtype=pl.Float64),
|
|
96
|
-
pl.Series("maxy", bnds[:, 3], dtype=pl.Float64),
|
|
97
|
-
)
|
|
89
|
+
geom_array = batch_df.get_column(geometry_col).to_numpy()
|
|
98
90
|
|
|
99
|
-
|
|
91
|
+
if geometry_type == "wkb":
|
|
92
|
+
geoms = shapely.from_wkb(geom_array)
|
|
93
|
+
else:
|
|
94
|
+
geoms = shapely.from_wkt(geom_array)
|
|
95
|
+
|
|
96
|
+
if len(geoms) > 0:
|
|
97
|
+
bnds = shapely.bounds(geoms)
|
|
98
|
+
chunk = batch_df.select(key_cols).with_columns(
|
|
99
|
+
pl.Series("minx", bnds[:, 0], dtype=pl.Float64),
|
|
100
|
+
pl.Series("miny", bnds[:, 1], dtype=pl.Float64),
|
|
101
|
+
pl.Series("maxx", bnds[:, 2], dtype=pl.Float64),
|
|
102
|
+
pl.Series("maxy", bnds[:, 3], dtype=pl.Float64),
|
|
103
|
+
)
|
|
104
|
+
chunks.append(chunk)
|
|
105
|
+
|
|
106
|
+
if chunks:
|
|
107
|
+
return pl.concat(chunks)
|
|
108
|
+
|
|
109
|
+
empty_df = pl.read_parquet(static_path, columns=key_cols)
|
|
110
|
+
return empty_df.with_columns(
|
|
100
111
|
pl.Series("minx", [], dtype=pl.Float64),
|
|
101
112
|
pl.Series("miny", [], dtype=pl.Float64),
|
|
102
113
|
pl.Series("maxx", [], dtype=pl.Float64),
|
|
@@ -182,17 +193,13 @@ def exact_spatial_filter(
|
|
|
182
193
|
if candidates.is_empty():
|
|
183
194
|
return candidates.select(key_cols)
|
|
184
195
|
|
|
185
|
-
# Build a
|
|
186
|
-
full_df =
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
full_df = full_df.filter(pl.col(key).is_in(candidate_keys))
|
|
193
|
-
else:
|
|
194
|
-
# Composite key: join on all key columns.
|
|
195
|
-
full_df = full_df.join(candidates.select(key_cols), on=key_cols, how="inner")
|
|
196
|
+
# Build a lazy scan and push down an inner join to load only required geometries.
|
|
197
|
+
full_df = (
|
|
198
|
+
pl.scan_parquet(static_path)
|
|
199
|
+
.select(key_cols + [geometry_col])
|
|
200
|
+
.join(candidates.select(key_cols).lazy(), on=key_cols, how="inner")
|
|
201
|
+
.collect()
|
|
202
|
+
)
|
|
196
203
|
|
|
197
204
|
geom_array = full_df[geometry_col].to_numpy()
|
|
198
205
|
if geometry_type == "wkb":
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|