pdemtools 1.0.0__py3-none-any.whl → 1.1.1__py3-none-any.whl

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.
pdemtools/__init__.py CHANGED
@@ -13,6 +13,6 @@ from . import _coreg
13
13
  from . import _geomorphometry
14
14
  from . import _utils
15
15
 
16
- __version__ = "1.0.0"
16
+ __version__ = "1.1.1"
17
17
 
18
18
  __all__ = ["search", "DemAccessor"]
pdemtools/_accessor.py CHANGED
@@ -647,6 +647,8 @@ class DemAccessor:
647
647
  or ("unsphericity_curvature" in attribute)
648
648
  or ("maximal_curvature" in attribute)
649
649
  or ("minimal_curvature" in attribute)
650
+ or ("horizontal_excess" in attribute)
651
+ or ("vertical_excess" in attribute)
650
652
  ):
651
653
  mean_curvature_arr = mean_curvature(p_arr, q_arr, t_arr, r_arr, s_arr)
652
654
 
@@ -655,6 +657,8 @@ class DemAccessor:
655
657
  or ("unsphericity_curvature" in attribute)
656
658
  or ("maximal_curvature" in attribute)
657
659
  or ("minimal_curvature" in attribute)
660
+ or ("horizontal_excess" in attribute)
661
+ or ("vertical_excess" in attribute)
658
662
  ):
659
663
  gaussian_curvature_arr = gaussian_curvature(
660
664
  p_arr, q_arr, t_arr, r_arr, s_arr
@@ -664,6 +668,8 @@ class DemAccessor:
664
668
  ("unsphericity_curvature" in attribute)
665
669
  or ("maximal_curvature" in attribute)
666
670
  or ("minimal_curvature" in attribute)
671
+ or ("horizontal_excess" in attribute)
672
+ or ("vertical_excess" in attribute)
667
673
  ):
668
674
  unsphericity_curvature_arr = unsphericity_curvature(
669
675
  mean_curvature_arr, gaussian_curvature_arr
pdemtools/data.py CHANGED
@@ -39,7 +39,9 @@ def geoid_from_bedmachine(bm_fpath: str, target_rxd: DataArray) -> DataArray:
39
39
  geoid = rxr.open_rasterio(f"{bm_fpath}")["geoid"]
40
40
  geoid_crs = geoid.rio.crs
41
41
  geoid = geoid.squeeze().astype("float32").rio.write_crs(geoid_crs)
42
- geoid = geoid.rio.reproject_match(target_rxd, Resampling.bilinear)
42
+ geoid = geoid.rio.reproject_match(
43
+ match_data_array=target_rxd, resampling=Resampling.bilinear
44
+ )
43
45
 
44
46
  return geoid.squeeze()
45
47
 
@@ -63,7 +65,9 @@ def geoid_from_raster(fpath: str, target_rxd: DataArray = None) -> DataArray:
63
65
  geoid = geoid.squeeze().astype("float32").rio.write_crs(geoid_crs)
64
66
 
65
67
  if target_rxd != None:
66
- geoid = geoid.rio.reproject_match(target_rxd, Resampling.bilinear)
68
+ geoid = geoid.rio.reproject_match(
69
+ match_data_array=target_rxd, resampling=Resampling.bilinear
70
+ )
67
71
 
68
72
  return geoid.squeeze()
69
73
 
@@ -135,7 +139,9 @@ def bedrock_mask_from_bedmachine(bm_fpath: str, target_rxd: DataArray) -> DataAr
135
139
  # Reample using bilinear resampling rather than nearest neighbour, as mask
136
140
  # resolution is much larger than DEM resolution
137
141
  mask = mask.squeeze().astype("float32").rio.write_crs(mask_crs)
138
- mask = mask.rio.reproject_match(target_rxd, Resampling.bilinear)
142
+ mask = mask.rio.reproject_match(
143
+ match_data_array=target_rxd, resampling=Resampling.bilinear
144
+ )
139
145
 
140
146
  # Set interpolated values to boolean (1/0) values again
141
147
  mask = mask.round()
pdemtools/load.py CHANGED
@@ -1,5 +1,5 @@
1
- """This module contains functions necessary to open an ArcticDEM/REMA strip as an
2
- xarray DataArray, from either local or AWS sources.
1
+ """This module contains functions necessary to open an ArcticDEM/REMA strip as an
2
+ xarray DataArray, from either local or AWS sources.
3
3
  """
4
4
 
5
5
  import os
@@ -40,6 +40,7 @@ def from_fpath(
40
40
  bounds: Optional[Union[tuple, Polygon]] = None,
41
41
  bitmask_fpath: Optional[str] = None,
42
42
  pad: Optional[bool] = False,
43
+ chunks: Optional[Union[int, tuple, dict]] = None,
43
44
  ) -> DataArray:
44
45
  """Given a filepath (local or an AWS link), loads the desired ArcticDEM/REMA DEM
45
46
  strip as an ``xarray`` ``DataArray``. Option to filter to bounds and bitmask, if
@@ -59,6 +60,9 @@ def from_fpath(
59
60
  :param pad: If the DEM strip is not the full extent of the given bounds,
60
61
  pad with NaNs to match the full bounds. Defaults to False.
61
62
  :type pad: bool
63
+ :param chunks: Chunk size for `rioxarray.open_rasterio`, triggering `dask`
64
+ parallelisation and lazy evaluation/loading. Defaults to `None`.
65
+ :type chunks: int | tuple | dict
62
66
 
63
67
  :returns: xarray DataArray of DEM strip
64
68
  :rtype: DataArray
@@ -69,7 +73,7 @@ def from_fpath(
69
73
  raise ValueError("pad must be True or False")
70
74
 
71
75
  # Open dataarray using rioxarray
72
- dem = rxr.open_rasterio(dem_fpath)
76
+ dem = rxr.open_rasterio(dem_fpath, chunks=chunks)
73
77
 
74
78
  # Convert shapely geometry to bounds
75
79
  if isinstance(bounds, Polygon):
@@ -169,6 +173,7 @@ def from_search(
169
173
  bounds: Optional[Union[tuple, Polygon]] = None,
170
174
  bitmask: Optional[bool] = True,
171
175
  pad: Optional[bool] = False,
176
+ chunks: Optional[Union[int, tuple, dict]] = None,
172
177
  ):
173
178
  """Given a row from the GeoDataFrame output of ``pdemtools.search()``, loads the 2
174
179
  m DEM strip of the desired ArcticDEM/REMA DEM strip as an xarray DataArray.
@@ -190,6 +195,9 @@ def from_search(
190
195
  :param pad: If the DEM strip is not the full extent of the given bounds,
191
196
  pad with NaNs to match the full bounds. Defaults to False.
192
197
  :type pad: bool
198
+ :param chunks: Chunk size for `rioxarray.open_rasterio`, triggering `dask`
199
+ parallelisation and lazy evaluation/loading. Defaults to `None`.
200
+ :type chunks: int | tuple | dict
193
201
 
194
202
  :returns: xarray DataArray of DEM strip
195
203
  :rtype: DataArray
@@ -223,6 +231,7 @@ def from_search(
223
231
  bounds,
224
232
  bitmask_url,
225
233
  pad,
234
+ chunks,
226
235
  )
227
236
 
228
237
 
@@ -236,6 +245,7 @@ def from_id(
236
245
  version: Optional[str] = "s2s041",
237
246
  preview: Optional[bool] = False,
238
247
  pad: Optional[bool] = False,
248
+ chunks: Optional[Union[int, tuple, dict]] = None,
239
249
  ) -> DataArray:
240
250
  """An alternative method of loading the selected ArcticDEM/REMA strip, which
241
251
  requires only the geocell and the dem_id (e.g. ``geocell = 'n70w051'``, ``dem_id =
@@ -270,6 +280,9 @@ def from_id(
270
280
  :param pad: If the DEM strip is not the full extent of the given bounds,
271
281
  pad with NaNs to match the full bounds. Defaults to False.
272
282
  :type pad: bool
283
+ :param chunks: Chunk size for `rioxarray.open_rasterio`, triggering `dask`
284
+ parallelisation and lazy evaluation/loading. Defaults to `None`.
285
+ :type chunks: int | tuple | dict
273
286
 
274
287
  :return: xarray DataArray of DEM strip
275
288
  :rtype: DataArray
@@ -309,6 +322,7 @@ def from_id(
309
322
  bounds,
310
323
  bitmask_fpath,
311
324
  pad,
325
+ chunks,
312
326
  )
313
327
 
314
328
 
@@ -317,6 +331,7 @@ def mosaic(
317
331
  resolution: Literal["2m", "10m", "32m"],
318
332
  bounds: Union[tuple, Polygon] = None,
319
333
  version: Optional[Literal["v2.0", "v3.0", "v4.1"]] = None,
334
+ chunks: Optional[Union[int, tuple, dict]] = None,
320
335
  ):
321
336
  """Given a dataset, resolution, and bounding box, downloads the ArcticDEM or REMA
322
337
  mosiac from AWS.
@@ -333,6 +348,12 @@ def mosaic(
333
348
  :param bounds: Clip to bounds [xmin, ymin, xmax, ymax], in EPSG:3413 (ArcticDEM) or
334
349
  EPSG:3031 (REMA). Will accept a shapely geometry to extract bounds from.
335
350
  :type bounds: tuple | Polygon, optional
351
+ :param chunks: Chunk size for `rioxarray.open_rasterio`, triggering `dask`
352
+ parallelisation and lazy evaluation/loading. Defaults to `None`.
353
+ :type chunks: int | tuple | dict
354
+
355
+ :return: xarray DataArray of DEM mosaic
356
+ :rtype: DataArray
336
357
  """
337
358
 
338
359
  # sanity check that datset and versioning is correct versioning is valid for selected dataset
@@ -382,7 +403,7 @@ def mosaic(
382
403
 
383
404
  if len(tiles) < 1:
384
405
  raise ValueError(
385
- "No {dataset} mosaic tiles found to intersect with bounds {aoi}"
406
+ f"No {dataset} mosaic tiles found to intersect with bounds {aoi}"
386
407
  )
387
408
 
388
409
  # get aws filepaths from the tiles dataframe
@@ -401,13 +422,14 @@ def mosaic(
401
422
  # load dem(s)
402
423
  dems = []
403
424
  for fpath in fpaths:
404
- dem = rxr.open_rasterio(fpath).rio.clip_box(*bounds)
425
+ dem = rxr.open_rasterio(fpath, chunks=chunks).rio.clip_box(*bounds)
405
426
  dems.append(dem)
406
427
 
407
428
  if len(fpaths) == 1:
408
- dem = rxr.open_rasterio(fpaths[0]).rio.clip_box(*bounds)
429
+ dem = rxr.open_rasterio(fpaths[0], chunks=chunks).rio.clip_box(*bounds)
409
430
 
410
- # If multiple dems, merge them
431
+ # If multiple dems, merge them - NB I don't know whether this breaks lazy
432
+ # evaluation for chunked data
411
433
  if len(dems) > 1:
412
434
  dem = merge_arrays(dems)
413
435
  else:
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: pdemtools
3
- Version: 1.0.0
3
+ Version: 1.1.1
4
4
  Summary: Conveniently search, download, and preprocess ArcticDEM and REMA products.
5
5
  Author-email: Tom Chudley <thomas.r.chudley@durham.ac.uk>
6
6
  License: MIT
@@ -31,6 +31,7 @@ Requires-Dist: scipy
31
31
  Requires-Dist: numba
32
32
  Requires-Dist: pyarrow
33
33
  Requires-Dist: fiona
34
+ Dynamic: license-file
34
35
 
35
36
  # pDEMtools
36
37
 
@@ -1,17 +1,17 @@
1
- pdemtools/__init__.py,sha256=QbCIoVYggnEhM2tYlm-vXeCho7BZ5FtBjFQsoKbxhBE,368
2
- pdemtools/_accessor.py,sha256=zA3-snzOrQmLgvqYsthNlNlPUYmCHLRGsaCizIdgvJE,36093
1
+ pdemtools/__init__.py,sha256=10dFofcTAy7HFiTCt-D8erAyYwU5djFiwhZI3j5mlY0,368
2
+ pdemtools/_accessor.py,sha256=RNxts9ruziueo3-sZBruU2DmDmaZumBA7Kac9w_Zn3Y,36387
3
3
  pdemtools/_coreg.py,sha256=n6idsTsCeATzxrD4foeLJ4-QqUM-4HkfCX8OKIUDY3c,16577
4
4
  pdemtools/_geomorphometry.py,sha256=NyGb-z2_ZrEuiwi37zjI7z-J0Zr-Wnt2KMkiVP1NxAw,8739
5
5
  pdemtools/_index_search.py,sha256=KLbU1GIezrumL4nMaLe0C074uKThbnprdDnPw2yYLfk,20180
6
6
  pdemtools/_utils.py,sha256=Bym7p9yKOy3lHpGGaMEdYxD8dvpZ8CO_MCWXCuc4CRk,2280
7
- pdemtools/data.py,sha256=9lEDN8K-zTjD8mArDpE3bwfjkQmHiIOYzqHrWYCAC4E,13831
8
- pdemtools/load.py,sha256=I-KlFcMS9q3nJ9GUa_NqMXokk7pPiOrmJvtb54NyAlQ,17288
7
+ pdemtools/data.py,sha256=6peONDu-qAQtz5KAFd2m3AaLeM8FNMWVQfuYcDNydAU,13965
8
+ pdemtools/load.py,sha256=73RHYuoo9fsY2SST4zDQTHOt2cWx8KWdyVQZqjnAoLQ,18480
9
9
  pdemtools/mosaic_index/ArcticDEM_Mosaic_Index_v3_gpkg.gpkg,sha256=15f2IEo0mnz8LAamm_UG_x_2e0q7k8HnVd_dUSg_O3Y,8540160
10
10
  pdemtools/mosaic_index/ArcticDEM_Mosaic_Index_v4_1_gpkg.gpkg,sha256=vDrBdlLtmy0dcKYvaORCOWTkWzYtwK5B3JnQiCThL8s,8552448
11
11
  pdemtools/mosaic_index/REMA_Mosaic_Index_v2_gpkg.gpkg,sha256=HrRKp5lWpbCOmpHwANHSVc_eO0qo11J42CGuQEmmUQc,5177344
12
12
  pdemtools/test_data/test_arcticdem_index_kiv_steenstrup.parquet,sha256=Nzg3HXPbef4VgrnZXiAAa8RxmhBcFoqMNiFpm3_u99Y,91756
13
- pdemtools-1.0.0.dist-info/LICENSE.md,sha256=JbOkncS9jKLCvDWUpTApk8QhBLtfy-pRs74Gw6mVVPk,1068
14
- pdemtools-1.0.0.dist-info/METADATA,sha256=U_elv80gKuPzyFLbFs1SvtQ556HdZ7DmELdhkgQYVB0,7192
15
- pdemtools-1.0.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
16
- pdemtools-1.0.0.dist-info/top_level.txt,sha256=nTm0PsXQSEKsrI9f5XKoiQor9c_pLGgxuuWt5l425GM,10
17
- pdemtools-1.0.0.dist-info/RECORD,,
13
+ pdemtools-1.1.1.dist-info/licenses/LICENSE.md,sha256=JbOkncS9jKLCvDWUpTApk8QhBLtfy-pRs74Gw6mVVPk,1068
14
+ pdemtools-1.1.1.dist-info/METADATA,sha256=mitTlWdyex6MrlxDjs5XXgv5okRKhs66xAOaDnZJtt8,7214
15
+ pdemtools-1.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ pdemtools-1.1.1.dist-info/top_level.txt,sha256=nTm0PsXQSEKsrI9f5XKoiQor9c_pLGgxuuWt5l425GM,10
17
+ pdemtools-1.1.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5