dea-tools 0.3.7.dev28__tar.gz → 0.3.7.dev31__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.
Files changed (31) hide show
  1. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/PKG-INFO +19 -23
  2. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/README.md +17 -21
  3. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/dask.py +67 -35
  4. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/pyproject.toml +1 -1
  5. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/.gitignore +0 -0
  6. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/LICENSE +0 -0
  7. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/__init__.py +0 -0
  8. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/__main__.py +0 -0
  9. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/app/__init__.py +0 -0
  10. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/app/animations.py +0 -0
  11. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/app/changefilmstrips.py +0 -0
  12. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/app/crophealth.py +0 -0
  13. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/app/deacoastlines.py +0 -0
  14. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/app/geomedian.py +0 -0
  15. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/app/imageexport.py +0 -0
  16. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/app/miningrehab.py +0 -0
  17. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/app/wetlandsinsighttool.py +0 -0
  18. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/app/widgetconstructors.py +0 -0
  19. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/bandindices.py +0 -0
  20. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/bom.py +0 -0
  21. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/classification.py +0 -0
  22. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/coastal.py +0 -0
  23. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/datahandling.py +0 -0
  24. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/landcover.py +0 -0
  25. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/maps.py +0 -0
  26. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/plotting.py +0 -0
  27. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/spatial.py +0 -0
  28. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/temporal.py +0 -0
  29. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/validation.py +0 -0
  30. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/waterbodies.py +0 -0
  31. {dea_tools-0.3.7.dev28 → dea_tools-0.3.7.dev31}/Tools/dea_tools/wetlands.py +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dea-tools
3
- Version: 0.3.7.dev28
4
- Summary: Functions and algorithms for analysing Digital Earth Australia data.
3
+ Version: 0.3.7.dev31
4
+ Summary: Open-source tools for geospatial analysis with Digital Earth Australia, Open Data Cube, and Xarray
5
5
  Project-URL: Homepage, https://github.com/GeoscienceAustralia/dea-notebooks
6
6
  Project-URL: Repository, https://github.com/GeoscienceAustralia/dea-notebooks
7
7
  Author-email: Geoscience Australia <earth.observation@ga.gov.au>
@@ -104,38 +104,34 @@ Description-Content-Type: text/markdown
104
104
 
105
105
  [![DOI](https://img.shields.io/badge/DOI-10.26186/145234-0e7fbf.svg)](https://doi.org/10.26186/145234) [![Apache license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Discord](https://img.shields.io/discord/1212501566326571070?label=Discord&logo=discord&logoColor=white&color=7289DA)](https://discord.com/invite/4hhBQVas5U)
106
106
 
107
- `dea-tools` is an open-source Python package providing functions and algorithms for geospatial analysis using Open Data Cube, Xarray, and Digital Earth Australia.
108
- It includes utilities for loading data, plotting, spatial and temporal analysis, and applying machine learning to satellite data.
109
- The package is organised into the following modules:
110
-
111
- * `dea_tools.datahandling`: Tools for loading and managing DEA data (e.g. combining products, handling CRSs, pansharpening)
112
- * `dea_tools.plotting`: Plotting tools for DEA data (e.g. RGB composites, animations, interactive maps)
113
- * `dea_tools.bandindices`: Functions to calculate remote sensing indices (e.g. NDVI, NDWI)
114
- * `dea_tools.spatial`: Spatial analysis utilities (e.g. rasterisation, vectorisation, contours, image processing)
115
- * `dea_tools.temporal`: Tools for temporal analysis (e.g. phenology, time-series statistics, multi-dimensional regression)
116
- * `dea_tools.classification`: Machine learning utilities (e.g. training and applying models on satellite data)
117
- * `dea_tools.dask`: Utilities for parallel processing with Dask (e.g. creating scalable Dask clusters)
118
- * `dea_tools.landcover`: Tools for accessing and visualising DEA Land Cover data
119
- * `dea_tools.coastal`: Coastal and intertidal analysis tools (e.g. coastal change time series, sunglint mapping)
120
- * `dea_tools.bom`: Accessing Bureau of Meteorology water data (e.g. gauge and discharge data)
121
- * `dea_tools.waterbodies`: Accessing and analysing DEA Waterbodies data (e.g. loading waterbody time series)
122
- * `dea_tools.maps`: Tools for interactive mapping (e.g. folium and ipyleaflet maps)
123
- * `dea_tools.validation`: Tools for generating validation statistics (e.g. RMSE, R2, correlations)
107
+ `dea-tools` is an open-source Python package for geospatial analysis of satellite data using Digital Earth Australia, Open Data Cube, and Xarray.
108
+ It provides a broad set of utilities for loading, visualising, transforming, and analysing Earth Observation (EO) data across space and time.
109
+
110
+ The package includes tools for:
111
+
112
+ * 📦 **Data handling**: Load and combine DEA data products, manage projections and resolutions.
113
+ * 🗺️ **Visualisation**: Create static and interactive maps, RGB plots, and animations.
114
+ * 🛰️ **Remote sensing indices**: Calculate band indices such as NDVI, NDWI, and more.
115
+ * 🌐 **Spatial and temporal analysis**: Apply raster/vector operations, extract contours, compute temporal stats, and model change over time.
116
+ * 🤖 **Machine learning and segmentation**: Train and apply classifiers, or run image segmentation workflows.
117
+ * ⚙️ **Parallel processing**: Set up Dask clusters for scalable processing of large datasets.
118
+ * 🌏 **Domain-specific tools**: Analyse coastal change, intertidal zones, land cover, wetland and waterbody dynamics, and climate datasets.
124
119
 
125
120
  ## API documentation
126
121
 
127
- A rendered version of the `dea-tools` API is available on the [DEA Knowledge Hub](https://knowledge.dea.ga.gov.au/notebooks/Tools/).
122
+ Full API documentation describing the modules and functions available in `dea-tools` is available on the [DEA Knowledge Hub](https://knowledge.dea.ga.gov.au/notebooks/Tools/).
128
123
 
129
124
  ## Installation
130
125
 
131
126
  You can install `dea-tools` from PyPI with `pip` (https://pypi.org/project/dea-tools/).
132
- By default `dea-tools` will be installed with [minimal dependencies](https://github.com/GeoscienceAustralia/dea-notebooks/blob/develop/pyproject.toml), which excludes `datacube` and other difficult to install packages.
127
+
128
+ By default `dea-tools` will be installed with [minimal dependencies](https://github.com/GeoscienceAustralia/dea-notebooks/blob/develop/pyproject.toml), which excludes `datacube` and other difficult to install packages:
133
129
 
134
130
  ```console
135
131
  pip install dea-tools
136
132
  ```
137
133
 
138
- To install with `datacube` dependencies:
134
+ To install with `datacube` dependencies (note that this requires access to a datacube database):
139
135
  ```console
140
136
  pip install dea-tools[datacube]
141
137
  ```
@@ -175,7 +171,7 @@ To work with this module on the DEA Sandbox or National Computational Infrastruc
175
171
  ```python
176
172
  import sys
177
173
  sys.path.insert(1, "../Tools/")
178
- import dea_tools.datahandling # or some other submodule
174
+ from dea_tools.datahandling import load_ard # or some other function
179
175
  ```
180
176
 
181
177
  Alternatively, you can also do a local installation of `dea-tools`. To do this on the DEA Sandbox, run `pip` from the terminal from within your `dea-notebooks` directory:
@@ -4,38 +4,34 @@
4
4
 
5
5
  [![DOI](https://img.shields.io/badge/DOI-10.26186/145234-0e7fbf.svg)](https://doi.org/10.26186/145234) [![Apache license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Discord](https://img.shields.io/discord/1212501566326571070?label=Discord&logo=discord&logoColor=white&color=7289DA)](https://discord.com/invite/4hhBQVas5U)
6
6
 
7
- `dea-tools` is an open-source Python package providing functions and algorithms for geospatial analysis using Open Data Cube, Xarray, and Digital Earth Australia.
8
- It includes utilities for loading data, plotting, spatial and temporal analysis, and applying machine learning to satellite data.
9
- The package is organised into the following modules:
10
-
11
- * `dea_tools.datahandling`: Tools for loading and managing DEA data (e.g. combining products, handling CRSs, pansharpening)
12
- * `dea_tools.plotting`: Plotting tools for DEA data (e.g. RGB composites, animations, interactive maps)
13
- * `dea_tools.bandindices`: Functions to calculate remote sensing indices (e.g. NDVI, NDWI)
14
- * `dea_tools.spatial`: Spatial analysis utilities (e.g. rasterisation, vectorisation, contours, image processing)
15
- * `dea_tools.temporal`: Tools for temporal analysis (e.g. phenology, time-series statistics, multi-dimensional regression)
16
- * `dea_tools.classification`: Machine learning utilities (e.g. training and applying models on satellite data)
17
- * `dea_tools.dask`: Utilities for parallel processing with Dask (e.g. creating scalable Dask clusters)
18
- * `dea_tools.landcover`: Tools for accessing and visualising DEA Land Cover data
19
- * `dea_tools.coastal`: Coastal and intertidal analysis tools (e.g. coastal change time series, sunglint mapping)
20
- * `dea_tools.bom`: Accessing Bureau of Meteorology water data (e.g. gauge and discharge data)
21
- * `dea_tools.waterbodies`: Accessing and analysing DEA Waterbodies data (e.g. loading waterbody time series)
22
- * `dea_tools.maps`: Tools for interactive mapping (e.g. folium and ipyleaflet maps)
23
- * `dea_tools.validation`: Tools for generating validation statistics (e.g. RMSE, R2, correlations)
7
+ `dea-tools` is an open-source Python package for geospatial analysis of satellite data using Digital Earth Australia, Open Data Cube, and Xarray.
8
+ It provides a broad set of utilities for loading, visualising, transforming, and analysing Earth Observation (EO) data across space and time.
9
+
10
+ The package includes tools for:
11
+
12
+ * 📦 **Data handling**: Load and combine DEA data products, manage projections and resolutions.
13
+ * 🗺️ **Visualisation**: Create static and interactive maps, RGB plots, and animations.
14
+ * 🛰️ **Remote sensing indices**: Calculate band indices such as NDVI, NDWI, and more.
15
+ * 🌐 **Spatial and temporal analysis**: Apply raster/vector operations, extract contours, compute temporal stats, and model change over time.
16
+ * 🤖 **Machine learning and segmentation**: Train and apply classifiers, or run image segmentation workflows.
17
+ * ⚙️ **Parallel processing**: Set up Dask clusters for scalable processing of large datasets.
18
+ * 🌏 **Domain-specific tools**: Analyse coastal change, intertidal zones, land cover, wetland and waterbody dynamics, and climate datasets.
24
19
 
25
20
  ## API documentation
26
21
 
27
- A rendered version of the `dea-tools` API is available on the [DEA Knowledge Hub](https://knowledge.dea.ga.gov.au/notebooks/Tools/).
22
+ Full API documentation describing the modules and functions available in `dea-tools` is available on the [DEA Knowledge Hub](https://knowledge.dea.ga.gov.au/notebooks/Tools/).
28
23
 
29
24
  ## Installation
30
25
 
31
26
  You can install `dea-tools` from PyPI with `pip` (https://pypi.org/project/dea-tools/).
32
- By default `dea-tools` will be installed with [minimal dependencies](https://github.com/GeoscienceAustralia/dea-notebooks/blob/develop/pyproject.toml), which excludes `datacube` and other difficult to install packages.
27
+
28
+ By default `dea-tools` will be installed with [minimal dependencies](https://github.com/GeoscienceAustralia/dea-notebooks/blob/develop/pyproject.toml), which excludes `datacube` and other difficult to install packages:
33
29
 
34
30
  ```console
35
31
  pip install dea-tools
36
32
  ```
37
33
 
38
- To install with `datacube` dependencies:
34
+ To install with `datacube` dependencies (note that this requires access to a datacube database):
39
35
  ```console
40
36
  pip install dea-tools[datacube]
41
37
  ```
@@ -75,7 +71,7 @@ To work with this module on the DEA Sandbox or National Computational Infrastruc
75
71
  ```python
76
72
  import sys
77
73
  sys.path.insert(1, "../Tools/")
78
- import dea_tools.datahandling # or some other submodule
74
+ from dea_tools.datahandling import load_ard # or some other function
79
75
  ```
80
76
 
81
77
  Alternatively, you can also do a local installation of `dea-tools`. To do this on the DEA Sandbox, run `pip` from the terminal from within your `dea-notebooks` directory:
@@ -1,4 +1,4 @@
1
- ## dea_dask.py
1
+ # dea_dask.py
2
2
  """
3
3
  Tools for simplifying the creation of Dask clusters for parallelised computing.
4
4
 
@@ -16,7 +16,7 @@ here: https://gis.stackexchange.com/questions/tagged/open-data-cube).
16
16
  If you would like to report an issue with this script, you can file one on
17
17
  GitHub (https://github.com/GeoscienceAustralia/dea-notebooks/issues/new).
18
18
 
19
- Last modified: June 2022
19
+ Last modified: July 2025
20
20
 
21
21
  """
22
22
 
@@ -24,61 +24,88 @@ import os
24
24
  from importlib.util import find_spec
25
25
 
26
26
  import dask
27
+ import dask.distributed
27
28
  from aiohttp import ClientConnectionError
29
+ from odc.io.cgroups import get_cpu_quota
30
+ from odc.stac import configure_rio as cfg_rio
28
31
 
29
32
  _HAVE_PROXY = bool(find_spec("jupyter_server_proxy"))
30
- _IS_AWS = "AWS_ACCESS_KEY_ID" in os.environ or "AWS_DEFAULT_REGION" in os.environ
31
33
 
32
34
 
33
- def create_local_dask_cluster(spare_mem="3Gb", display_client=True, return_client=False):
35
+ def create_local_dask_cluster(
36
+ display_client=True,
37
+ return_client=False,
38
+ configure_rio=True,
39
+ n_workers=1,
40
+ threads_per_worker=None,
41
+ memory_limit='spare_mem',
42
+ **kwargs,
43
+ ):
34
44
  """
35
- Using the datacube utils function `start_local_dask`, generate
36
- a local dask cluster. Automatically detects if on AWS or NCI.
45
+ Create a local Dask cluster for parallelised computing using ``dask.distributed.Client``.
37
46
 
38
- Example use :
47
+ Example use:
39
48
 
40
- import sys
41
- sys.path.append("../Scripts")
42
49
  from dea_dask import create_local_dask_cluster
43
-
44
- create_local_dask_cluster(spare_mem='4Gb')
50
+ create_local_dask_cluster()
45
51
 
46
52
  Parameters
47
53
  ----------
48
- spare_mem : String, optional
49
- The amount of memory, in Gb, to leave for the notebook to run.
50
- This memory will not be used by the cluster. e.g '3Gb'
51
- display_client : Bool, optional
54
+ display_client : bool, optional
52
55
  An optional boolean indicating whether to display a summary of
53
56
  the dask client, including a link to monitor progress of the
54
57
  analysis. Set to False to hide this display.
55
- return_client : Bool, optional
58
+ return_client : bool, optional
56
59
  An optional boolean indicating whether to return the dask client
57
60
  object.
61
+ configure_rio : bool, optional
62
+ An optional boolean indicating whether to configure ``rasterio``
63
+ with cloud defaults and unsigned AWS access. Set to False to not
64
+ apply these defaults.
65
+ n_workers : int, optional
66
+ Number of workers to start, default is set to 1 which works well
67
+ with loading ODC data.
68
+ threads_per_worker: int, optional
69
+ Number of threads per each worker, by default this will be set to
70
+ the number of cpus on the machine.
71
+ memory_limit: str, float, int, or None, optional
72
+ Sets the memory limit per worker. Default is 'spare_mem', where 95 % of the available
73
+ system memory is split among the number of workers, allowing spare memory to be withheld
74
+ from the cluster.
75
+ To see other options: https://distributed.dask.org/en/stable/api.html#distributed.Client
76
+ **kwargs:
77
+ Additional keyword arguments passed to ``dask.distributed.Client``.
78
+ For full options, see: https://distributed.dask.org/en/stable/api.html#distributed.Client
58
79
 
59
80
  """
60
- # Attempt to import datacube and raise an error if not available
61
- try:
62
- from datacube.utils.dask import start_local_dask
63
- from datacube.utils.rio import configure_s3_access
64
- except ImportError as e:
65
- raise ImportError(
66
- "`datacube` is required for `create_local_dask_cluster`. "
67
- "Please install DEA Tools with the `[datacube]` extra, e.g.: "
68
- "`pip install dea-tools[datacube]`"
69
- ) from e
70
-
81
+ # Ensure that client links correctly launch on DEA Sandbox
71
82
  if _HAVE_PROXY:
72
83
  # Configure dashboard link to go over proxy
73
84
  prefix = os.environ.get("JUPYTERHUB_SERVICE_PREFIX", "/")
74
85
  dask.config.set({"distributed.dashboard.link": prefix + "proxy/{port}/status"})
75
86
 
76
- # Start up a local cluster
77
- client = start_local_dask(mem_safety_margin=spare_mem)
78
-
79
- if _IS_AWS:
80
- # Configure GDAL for s3 access
81
- configure_s3_access(aws_unsigned=True, client=client)
87
+ # Count cpus if threads_per_worker not provided
88
+ if threads_per_worker is None:
89
+ if get_cpu_quota() is not None:
90
+ threads_per_worker = round(get_cpu_quota())
91
+ else:
92
+ threads_per_worker = os.cpu_count()
93
+
94
+ # by default split 95% of system memory by the n_workers.
95
+ if memory_limit =='spare_mem':
96
+ memory_limit = 0.95 / n_workers
97
+
98
+ # Start client
99
+ client = dask.distributed.Client(
100
+ n_workers=n_workers,
101
+ threads_per_worker=threads_per_worker,
102
+ memory_limit=memory_limit,
103
+ **kwargs
104
+ )
105
+
106
+ # configure aws access
107
+ if configure_rio:
108
+ cfg_rio(cloud_defaults=True, aws={"aws_unsigned": True}, client=client)
82
109
 
83
110
  # Show the dask cluster settings
84
111
  if display_client:
@@ -86,10 +113,13 @@ def create_local_dask_cluster(spare_mem="3Gb", display_client=True, return_clien
86
113
 
87
114
  display(client)
88
115
 
89
- # return the client as an object
116
+ # Return the client as an object
90
117
  if return_client:
91
118
  return client
92
119
 
120
+ # Otherwise return none
121
+ return None
122
+
93
123
 
94
124
  def create_dask_gateway_cluster(profile="r5_L", workers=2):
95
125
  """
@@ -134,7 +164,9 @@ def create_dask_gateway_cluster(profile="r5_L", workers=2):
134
164
 
135
165
  # limit username to alphanumeric characters
136
166
  # kubernetes pods won't launch if labels contain anything other than [a-Z, -, _]
137
- options["jupyterhub_user"] = "".join(c if c.isalnum() else "-" for c in os.getenv("JUPYTERHUB_USER"))
167
+ options["jupyterhub_user"] = "".join(
168
+ c if c.isalnum() else "-" for c in os.getenv("JUPYTERHUB_USER")
169
+ )
138
170
 
139
171
  cluster = gateway.new_cluster(options)
140
172
  cluster.scale(workers)
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "dea-tools"
3
3
  dynamic = ["version"]
4
- description = "Functions and algorithms for analysing Digital Earth Australia data."
4
+ description = "Open-source tools for geospatial analysis with Digital Earth Australia, Open Data Cube, and Xarray"
5
5
  authors = [
6
6
  { name = "Geoscience Australia", email = "earth.observation@ga.gov.au" }
7
7
  ]
File without changes