dea-tools 0.3.5.dev20__tar.gz → 0.3.5.dev23__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.
- {dea_tools-0.3.5.dev20/dea_tools.egg-info → dea_tools-0.3.5.dev23}/PKG-INFO +2 -2
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/classification.py +35 -12
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/coastal.py +232 -109
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/datahandling.py +4 -1
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/spatial.py +1 -1
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23/dea_tools.egg-info}/PKG-INFO +2 -2
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools.egg-info/requires.txt +1 -1
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/setup.py +1 -1
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/.gitignore +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/LICENSE +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/MANIFEST.in +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/README.rst +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/__init__.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/__main__.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/app/__init__.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/app/animations.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/app/changefilmstrips.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/app/crophealth.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/app/deacoastlines.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/app/geomedian.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/app/imageexport.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/app/miningrehab.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/app/widgetconstructors.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/bandindices.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/bom.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/climate.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/dask.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/landcover.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/maps.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/plotting.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/pyfes_model.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/temporal.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/validation.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/waterbodies.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools/wetlands.py +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools.egg-info/SOURCES.txt +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools.egg-info/dependency_links.txt +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/dea_tools.egg-info/top_level.txt +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/index.rst +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/mock_imports.txt +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/pyproject.toml +0 -0
- {dea_tools-0.3.5.dev20 → dea_tools-0.3.5.dev23}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dea-tools
|
|
3
|
-
Version: 0.3.5.
|
|
3
|
+
Version: 0.3.5.dev23
|
|
4
4
|
Summary: Functions and algorithms for analysing Digital Earth Australia data.
|
|
5
5
|
Home-page: https://github.com/GeoscienceAustralia/dea-notebooks
|
|
6
6
|
Author: Geoscience Australia
|
|
@@ -44,7 +44,7 @@ Requires-Dist: pyproj
|
|
|
44
44
|
Requires-Dist: pystac-client
|
|
45
45
|
Requires-Dist: planetary-computer
|
|
46
46
|
Requires-Dist: python-dateutil
|
|
47
|
-
Requires-Dist: pyTMD
|
|
47
|
+
Requires-Dist: pyTMD<=2.1.6
|
|
48
48
|
Requires-Dist: pytz
|
|
49
49
|
Requires-Dist: rasterio
|
|
50
50
|
Requires-Dist: rasterstats
|
|
@@ -226,6 +226,7 @@ def predict_xr(
|
|
|
226
226
|
chunk_size=None,
|
|
227
227
|
persist=False,
|
|
228
228
|
proba=False,
|
|
229
|
+
max_proba=True,
|
|
229
230
|
clean=False,
|
|
230
231
|
return_input=False,
|
|
231
232
|
):
|
|
@@ -255,6 +256,11 @@ def predict_xr(
|
|
|
255
256
|
distributed RAM.
|
|
256
257
|
proba : bool
|
|
257
258
|
If True, predict probabilities
|
|
259
|
+
max_proba : bool
|
|
260
|
+
If True, the probabilities array will be flattened to contain
|
|
261
|
+
only the probabiltiy for the "Predictions" class. If False,
|
|
262
|
+
the "Probabilities" object will be an array of prediction
|
|
263
|
+
probaiblities for each classes
|
|
258
264
|
clean : bool
|
|
259
265
|
If True, remove Infs and NaNs from input and output arrays
|
|
260
266
|
return_input : bool
|
|
@@ -282,7 +288,7 @@ def predict_xr(
|
|
|
282
288
|
input_xr.chunks["y"][0]
|
|
283
289
|
)
|
|
284
290
|
|
|
285
|
-
def _predict_func(model, input_xr, persist, proba, clean, return_input):
|
|
291
|
+
def _predict_func(model, input_xr, persist, proba, max_proba, clean, return_input):
|
|
286
292
|
x, y, crs = input_xr.x, input_xr.y, input_xr.geobox.crs
|
|
287
293
|
|
|
288
294
|
input_data = []
|
|
@@ -330,18 +336,35 @@ def predict_xr(
|
|
|
330
336
|
print(" probabilities...")
|
|
331
337
|
out_proba = model.predict_proba(input_data_flattened)
|
|
332
338
|
|
|
333
|
-
#
|
|
334
|
-
|
|
339
|
+
# return either one band with the max probability, or the whole probability array
|
|
340
|
+
if max_proba == True:
|
|
341
|
+
print(" returning single probability band.")
|
|
342
|
+
out_proba = da.max(out_proba, axis=1) * 100.0
|
|
343
|
+
out_proba = out_proba.reshape(len(y), len(x))
|
|
344
|
+
out_proba = xr.DataArray(
|
|
345
|
+
out_proba, coords={"x": x, "y": y}, dims=["y", "x"]
|
|
346
|
+
)
|
|
347
|
+
output_xr["Probabilities"] = out_proba
|
|
348
|
+
else:
|
|
349
|
+
print(" returning class probability array.")
|
|
350
|
+
out_proba = out_proba * 100.0
|
|
351
|
+
class_names = model.classes_ # Get the unique class names from the fitted classifier
|
|
352
|
+
|
|
353
|
+
# Loop through each class (band)
|
|
354
|
+
probabilities_dataset = xr.Dataset()
|
|
355
|
+
for i, class_name in enumerate(class_names):
|
|
356
|
+
reshaped_band = out_proba[:, i].reshape(len(y), len(x))
|
|
357
|
+
reshaped_da = xr.DataArray(
|
|
358
|
+
reshaped_band, coords={"x": x, "y": y}, dims=["y", "x"]
|
|
359
|
+
)
|
|
360
|
+
probabilities_dataset[f"prob_{class_name}"] = reshaped_da
|
|
335
361
|
|
|
362
|
+
# merge in the probabilities
|
|
363
|
+
output_xr = xr.merge([output_xr, probabilities_dataset])
|
|
364
|
+
|
|
336
365
|
if clean == True:
|
|
337
366
|
out_proba = da.where(da.isfinite(out_proba), out_proba, 0)
|
|
338
|
-
|
|
339
|
-
out_proba = out_proba.reshape(len(y), len(x))
|
|
340
|
-
|
|
341
|
-
out_proba = xr.DataArray(
|
|
342
|
-
out_proba, coords={"x": x, "y": y}, dims=["y", "x"]
|
|
343
|
-
)
|
|
344
|
-
output_xr["Probabilities"] = out_proba
|
|
367
|
+
|
|
345
368
|
|
|
346
369
|
if return_input == True:
|
|
347
370
|
print(" input features...")
|
|
@@ -391,12 +414,12 @@ def predict_xr(
|
|
|
391
414
|
model = ParallelPostFit(model)
|
|
392
415
|
with joblib.parallel_backend("dask"):
|
|
393
416
|
output_xr = _predict_func(
|
|
394
|
-
model, input_xr, persist, proba, clean, return_input
|
|
417
|
+
model, input_xr, persist, proba, max_proba, clean, return_input
|
|
395
418
|
)
|
|
396
419
|
|
|
397
420
|
else:
|
|
398
421
|
output_xr = _predict_func(
|
|
399
|
-
model, input_xr, persist, proba, clean, return_input
|
|
422
|
+
model, input_xr, persist, proba, max_proba, clean, return_input
|
|
400
423
|
).compute()
|
|
401
424
|
|
|
402
425
|
return output_xr
|
|
@@ -288,120 +288,243 @@ def _model_tides(
|
|
|
288
288
|
lat.max() + buffer,
|
|
289
289
|
]
|
|
290
290
|
|
|
291
|
-
#
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
291
|
+
# TEMPORARY HACK to work on both old and new pyTMD
|
|
292
|
+
try:
|
|
293
|
+
|
|
294
|
+
# Read tidal constants and interpolate to grid points
|
|
295
|
+
if pytmd_model.format in ("OTIS", "ATLAS", "TMD3"):
|
|
296
|
+
amp, ph, D, c = pyTMD.io.OTIS.extract_constants(
|
|
297
|
+
lon,
|
|
298
|
+
lat,
|
|
299
|
+
pytmd_model.grid_file,
|
|
300
|
+
pytmd_model.model_file,
|
|
301
|
+
pytmd_model.projection,
|
|
302
|
+
type=pytmd_model.type,
|
|
303
|
+
crop=crop,
|
|
304
|
+
bounds=bounds,
|
|
305
|
+
method=method,
|
|
306
|
+
extrapolate=extrapolate,
|
|
307
|
+
cutoff=cutoff,
|
|
308
|
+
grid=pytmd_model.format,
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
# Use delta time at 2000.0 to match TMD outputs
|
|
312
|
+
deltat = np.zeros((len(timescale)), dtype=np.float64)
|
|
313
|
+
|
|
314
|
+
elif pytmd_model.format == "netcdf":
|
|
315
|
+
amp, ph, D, c = pyTMD.io.ATLAS.extract_constants(
|
|
316
|
+
lon,
|
|
317
|
+
lat,
|
|
318
|
+
pytmd_model.grid_file,
|
|
319
|
+
pytmd_model.model_file,
|
|
320
|
+
type=pytmd_model.type,
|
|
321
|
+
crop=crop,
|
|
322
|
+
bounds=bounds,
|
|
323
|
+
method=method,
|
|
324
|
+
extrapolate=extrapolate,
|
|
325
|
+
cutoff=cutoff,
|
|
326
|
+
scale=pytmd_model.scale,
|
|
327
|
+
compressed=pytmd_model.compressed,
|
|
328
|
+
)
|
|
329
|
+
|
|
330
|
+
# Use delta time at 2000.0 to match TMD outputs
|
|
331
|
+
deltat = np.zeros((len(timescale)), dtype=np.float64)
|
|
332
|
+
|
|
333
|
+
elif pytmd_model.format == "GOT":
|
|
334
|
+
amp, ph, c = pyTMD.io.GOT.extract_constants(
|
|
335
|
+
lon,
|
|
336
|
+
lat,
|
|
337
|
+
pytmd_model.model_file,
|
|
338
|
+
crop=crop,
|
|
339
|
+
bounds=bounds,
|
|
340
|
+
method=method,
|
|
341
|
+
extrapolate=extrapolate,
|
|
342
|
+
cutoff=cutoff,
|
|
343
|
+
scale=pytmd_model.scale,
|
|
344
|
+
compressed=pytmd_model.compressed,
|
|
345
|
+
)
|
|
346
|
+
|
|
347
|
+
# Delta time (TT - UT1)
|
|
348
|
+
deltat = timescale.tt_ut1
|
|
349
|
+
|
|
350
|
+
elif pytmd_model.format == "FES":
|
|
351
|
+
amp, ph = pyTMD.io.FES.extract_constants(
|
|
352
|
+
lon,
|
|
353
|
+
lat,
|
|
354
|
+
pytmd_model.model_file,
|
|
355
|
+
type=pytmd_model.type,
|
|
356
|
+
version=pytmd_model.version,
|
|
357
|
+
crop=crop,
|
|
358
|
+
bounds=bounds,
|
|
359
|
+
method=method,
|
|
360
|
+
extrapolate=extrapolate,
|
|
361
|
+
cutoff=cutoff,
|
|
362
|
+
scale=pytmd_model.scale,
|
|
363
|
+
compressed=pytmd_model.compressed,
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
# Available model constituents
|
|
367
|
+
c = pytmd_model.constituents
|
|
368
|
+
|
|
369
|
+
# Delta time (TT - UT1)
|
|
370
|
+
deltat = timescale.tt_ut1
|
|
371
|
+
|
|
372
|
+
# Calculate complex phase in radians for Euler's
|
|
373
|
+
cph = -1j * ph * np.pi / 180.0
|
|
374
|
+
|
|
375
|
+
# Calculate constituent oscillation
|
|
376
|
+
hc = amp * np.exp(cph)
|
|
377
|
+
|
|
378
|
+
# Determine the number of points and times to process. If in
|
|
379
|
+
# "one-to-many" mode, these counts are used to repeat our extracted
|
|
380
|
+
# constituents and timesteps so we can extract tides for all
|
|
381
|
+
# combinations of our input times and tide modelling points.
|
|
382
|
+
# If in "one-to-one" mode, we avoid this step by setting counts to 1
|
|
383
|
+
# (e.g. "repeat 1 times")
|
|
384
|
+
points_repeat = len(x) if mode == "one-to-many" else 1
|
|
385
|
+
time_repeat = len(time) if mode == "one-to-many" else 1
|
|
386
|
+
|
|
387
|
+
# If in "one-to-many" mode, repeat constituents to length of time
|
|
388
|
+
# and number of input coords before passing to `predict_tide_drift`
|
|
389
|
+
t, hc, deltat = (
|
|
390
|
+
np.tile(timescale.tide, points_repeat),
|
|
391
|
+
hc.repeat(time_repeat, axis=0),
|
|
392
|
+
np.tile(deltat, points_repeat),
|
|
306
393
|
)
|
|
307
|
-
|
|
308
|
-
#
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
pytmd_model.
|
|
316
|
-
pytmd_model.model_file,
|
|
317
|
-
type=pytmd_model.type,
|
|
318
|
-
crop=crop,
|
|
319
|
-
bounds=bounds,
|
|
320
|
-
method=method,
|
|
321
|
-
extrapolate=extrapolate,
|
|
322
|
-
cutoff=cutoff,
|
|
323
|
-
scale=pytmd_model.scale,
|
|
324
|
-
compressed=pytmd_model.compressed,
|
|
394
|
+
|
|
395
|
+
# Predict tidal elevations at time and infer minor corrections
|
|
396
|
+
npts = len(t)
|
|
397
|
+
tide = np.ma.zeros((npts), fill_value=np.nan)
|
|
398
|
+
tide.mask = np.any(hc.mask, axis=1)
|
|
399
|
+
|
|
400
|
+
# Predict tides
|
|
401
|
+
tide.data[:] = pyTMD.predict.drift(
|
|
402
|
+
t, hc, c, deltat=deltat, corrections=pytmd_model.format
|
|
325
403
|
)
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
deltat = np.zeros((len(timescale)), dtype=np.float64)
|
|
329
|
-
|
|
330
|
-
elif pytmd_model.format == "GOT":
|
|
331
|
-
amp, ph, c = pyTMD.io.GOT.extract_constants(
|
|
332
|
-
lon,
|
|
333
|
-
lat,
|
|
334
|
-
pytmd_model.model_file,
|
|
335
|
-
crop=crop,
|
|
336
|
-
bounds=bounds,
|
|
337
|
-
method=method,
|
|
338
|
-
extrapolate=extrapolate,
|
|
339
|
-
cutoff=cutoff,
|
|
340
|
-
scale=pytmd_model.scale,
|
|
341
|
-
compressed=pytmd_model.compressed,
|
|
404
|
+
minor = pyTMD.predict.infer_minor(
|
|
405
|
+
t, hc, c, deltat=deltat, corrections=pytmd_model.format
|
|
342
406
|
)
|
|
407
|
+
tide.data[:] += minor.data[:]
|
|
343
408
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
409
|
+
except:
|
|
410
|
+
# Read tidal constants and interpolate to grid points
|
|
411
|
+
if pytmd_model.format in ("OTIS", "ATLAS-compact", "TMD3"):
|
|
412
|
+
amp, ph, D, c = pyTMD.io.OTIS.extract_constants(
|
|
413
|
+
lon,
|
|
414
|
+
lat,
|
|
415
|
+
pytmd_model.grid_file,
|
|
416
|
+
pytmd_model.model_file,
|
|
417
|
+
pytmd_model.projection,
|
|
418
|
+
type=pytmd_model.type,
|
|
419
|
+
grid=pytmd_model.file_format,
|
|
420
|
+
crop=crop,
|
|
421
|
+
bounds=bounds,
|
|
422
|
+
method=method,
|
|
423
|
+
extrapolate=extrapolate,
|
|
424
|
+
cutoff=cutoff,
|
|
425
|
+
)
|
|
426
|
+
|
|
427
|
+
# Use delta time at 2000.0 to match TMD outputs
|
|
428
|
+
deltat = np.zeros((len(timescale)), dtype=np.float64)
|
|
429
|
+
|
|
430
|
+
elif pytmd_model.format in ("ATLAS-netcdf",):
|
|
431
|
+
amp, ph, D, c = pyTMD.io.ATLAS.extract_constants(
|
|
432
|
+
lon,
|
|
433
|
+
lat,
|
|
434
|
+
pytmd_model.grid_file,
|
|
435
|
+
pytmd_model.model_file,
|
|
436
|
+
type=pytmd_model.type,
|
|
437
|
+
crop=crop,
|
|
438
|
+
bounds=bounds,
|
|
439
|
+
method=method,
|
|
440
|
+
extrapolate=extrapolate,
|
|
441
|
+
cutoff=cutoff,
|
|
442
|
+
scale=pytmd_model.scale,
|
|
443
|
+
compressed=pytmd_model.compressed,
|
|
444
|
+
)
|
|
445
|
+
|
|
446
|
+
# Use delta time at 2000.0 to match TMD outputs
|
|
447
|
+
deltat = np.zeros((len(timescale)), dtype=np.float64)
|
|
448
|
+
|
|
449
|
+
elif pytmd_model.format in ("GOT-ascii", "GOT-netcdf"):
|
|
450
|
+
amp, ph, c = pyTMD.io.GOT.extract_constants(
|
|
451
|
+
lon,
|
|
452
|
+
lat,
|
|
453
|
+
pytmd_model.model_file,
|
|
454
|
+
grid=pytmd_model.type,
|
|
455
|
+
crop=crop,
|
|
456
|
+
bounds=bounds,
|
|
457
|
+
method=method,
|
|
458
|
+
extrapolate=extrapolate,
|
|
459
|
+
cutoff=cutoff,
|
|
460
|
+
scale=pytmd_model.scale,
|
|
461
|
+
compressed=pytmd_model.compressed,
|
|
462
|
+
)
|
|
463
|
+
|
|
464
|
+
# Delta time (TT - UT1)
|
|
465
|
+
deltat = timescale.tt_ut1
|
|
466
|
+
|
|
467
|
+
elif pytmd_model.format in ("FES-ascii", "FES-netcdf"):
|
|
468
|
+
amp, ph = pyTMD.io.FES.extract_constants(
|
|
469
|
+
lon,
|
|
470
|
+
lat,
|
|
471
|
+
pytmd_model.model_file,
|
|
472
|
+
type=pytmd_model.type,
|
|
473
|
+
version=pytmd_model.version,
|
|
474
|
+
crop=crop,
|
|
475
|
+
bounds=bounds,
|
|
476
|
+
method=method,
|
|
477
|
+
extrapolate=extrapolate,
|
|
478
|
+
cutoff=cutoff,
|
|
479
|
+
scale=pytmd_model.scale,
|
|
480
|
+
compressed=pytmd_model.compressed,
|
|
481
|
+
)
|
|
482
|
+
|
|
483
|
+
# Available model constituents
|
|
484
|
+
c = pytmd_model.constituents
|
|
485
|
+
|
|
486
|
+
# Delta time (TT - UT1)
|
|
487
|
+
deltat = timescale.tt_ut1
|
|
488
|
+
|
|
489
|
+
# Calculate complex phase in radians for Euler's
|
|
490
|
+
cph = -1j * ph * np.pi / 180.0
|
|
491
|
+
|
|
492
|
+
# Calculate constituent oscillation
|
|
493
|
+
hc = amp * np.exp(cph)
|
|
494
|
+
|
|
495
|
+
# Determine the number of points and times to process. If in
|
|
496
|
+
# "one-to-many" mode, these counts are used to repeat our extracted
|
|
497
|
+
# constituents and timesteps so we can extract tides for all
|
|
498
|
+
# combinations of our input times and tide modelling points.
|
|
499
|
+
# If in "one-to-one" mode, we avoid this step by setting counts to 1
|
|
500
|
+
# (e.g. "repeat 1 times")
|
|
501
|
+
points_repeat = len(x) if mode == "one-to-many" else 1
|
|
502
|
+
time_repeat = len(time) if mode == "one-to-many" else 1
|
|
503
|
+
|
|
504
|
+
# If in "one-to-many" mode, repeat constituents to length of time
|
|
505
|
+
# and number of input coords before passing to `predict_tide_drift`
|
|
506
|
+
t, hc, deltat = (
|
|
507
|
+
np.tile(timescale.tide, points_repeat),
|
|
508
|
+
hc.repeat(time_repeat, axis=0),
|
|
509
|
+
np.tile(deltat, points_repeat),
|
|
361
510
|
)
|
|
362
|
-
|
|
363
|
-
#
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
# If in "one-to-one" mode, we avoid this step by setting counts to 1
|
|
380
|
-
# (e.g. "repeat 1 times")
|
|
381
|
-
points_repeat = len(x) if mode == "one-to-many" else 1
|
|
382
|
-
time_repeat = len(time) if mode == "one-to-many" else 1
|
|
383
|
-
|
|
384
|
-
# If in "one-to-many" mode, repeat constituents to length of time
|
|
385
|
-
# and number of input coords before passing to `predict_tide_drift`
|
|
386
|
-
t, hc, deltat = (
|
|
387
|
-
np.tile(timescale.tide, points_repeat),
|
|
388
|
-
hc.repeat(time_repeat, axis=0),
|
|
389
|
-
np.tile(deltat, points_repeat),
|
|
390
|
-
)
|
|
391
|
-
|
|
392
|
-
# Predict tidal elevations at time and infer minor corrections
|
|
393
|
-
npts = len(t)
|
|
394
|
-
tide = np.ma.zeros((npts), fill_value=np.nan)
|
|
395
|
-
tide.mask = np.any(hc.mask, axis=1)
|
|
396
|
-
|
|
397
|
-
# Predict tides
|
|
398
|
-
tide.data[:] = pyTMD.predict.drift(
|
|
399
|
-
t, hc, c, deltat=deltat, corrections=pytmd_model.format
|
|
400
|
-
)
|
|
401
|
-
minor = pyTMD.predict.infer_minor(
|
|
402
|
-
t, hc, c, deltat=deltat, corrections=pytmd_model.format
|
|
403
|
-
)
|
|
404
|
-
tide.data[:] += minor.data[:]
|
|
511
|
+
|
|
512
|
+
# Predict tidal elevations at time and infer minor corrections
|
|
513
|
+
npts = len(t)
|
|
514
|
+
tide = np.ma.zeros((npts), fill_value=np.nan)
|
|
515
|
+
tide.mask = np.any(hc.mask, axis=1)
|
|
516
|
+
|
|
517
|
+
# Predict tides
|
|
518
|
+
tide.data[:] = pyTMD.predict.drift(t, hc, c, deltat=deltat, corrections=pytmd_model.corrections)
|
|
519
|
+
minor = pyTMD.predict.infer_minor(
|
|
520
|
+
t,
|
|
521
|
+
hc,
|
|
522
|
+
c,
|
|
523
|
+
deltat=deltat,
|
|
524
|
+
corrections=pytmd_model.corrections,
|
|
525
|
+
minor=pytmd_model.minor,
|
|
526
|
+
)
|
|
527
|
+
tide.data[:] += minor.data[:]
|
|
405
528
|
|
|
406
529
|
# Replace invalid values with fill value
|
|
407
530
|
tide.data[tide.mask] = tide.fill_value
|
|
@@ -1090,7 +1090,6 @@ def _esri_pansharpen(ds, pan_band, band_weights=None):
|
|
|
1090
1090
|
ds_pansharpened : xarray.Dataset
|
|
1091
1091
|
Pansharpened dataset with the same dimensions as the input dataset.
|
|
1092
1092
|
"""
|
|
1093
|
-
|
|
1094
1093
|
# Create new dataarrays with and without pan band
|
|
1095
1094
|
da_nopan = ds.drop(pan_band).to_array()
|
|
1096
1095
|
da_pan = ds[pan_band]
|
|
@@ -1157,6 +1156,8 @@ def _hsv_timestep_pansharpen(ds_i, pan_band):
|
|
|
1157
1156
|
ds_pansharpened : xarray.Dataset
|
|
1158
1157
|
Pansharpened dataset with the same dimensions as the input dataset.
|
|
1159
1158
|
"""
|
|
1159
|
+
# Squeeze out any single dimensions
|
|
1160
|
+
ds_i = ds_i.squeeze()
|
|
1160
1161
|
|
|
1161
1162
|
# Convert to an xr.DataArray and move "variable" to end
|
|
1162
1163
|
da_i = ds_i.to_array().transpose(..., "variable")
|
|
@@ -1209,6 +1210,8 @@ def _pca_timestep_pansharpen(ds_i, pan_band, pca_rescaling="histogram"):
|
|
|
1209
1210
|
ds_pansharpened : xarray.Dataset
|
|
1210
1211
|
Pansharpened dataset with the same dimensions as the input dataset.
|
|
1211
1212
|
"""
|
|
1213
|
+
# Squeeze out any single dimensions
|
|
1214
|
+
ds_i = ds_i.squeeze()
|
|
1212
1215
|
|
|
1213
1216
|
# Reshape to 2D by stacking x and y dimensions to prepare it
|
|
1214
1217
|
# as an input to PCA. Drop NA rows as these are not supported
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dea-tools
|
|
3
|
-
Version: 0.3.5.
|
|
3
|
+
Version: 0.3.5.dev23
|
|
4
4
|
Summary: Functions and algorithms for analysing Digital Earth Australia data.
|
|
5
5
|
Home-page: https://github.com/GeoscienceAustralia/dea-notebooks
|
|
6
6
|
Author: Geoscience Australia
|
|
@@ -44,7 +44,7 @@ Requires-Dist: pyproj
|
|
|
44
44
|
Requires-Dist: pystac-client
|
|
45
45
|
Requires-Dist: planetary-computer
|
|
46
46
|
Requires-Dist: python-dateutil
|
|
47
|
-
Requires-Dist: pyTMD
|
|
47
|
+
Requires-Dist: pyTMD<=2.1.6
|
|
48
48
|
Requires-Dist: pytz
|
|
49
49
|
Requires-Dist: rasterio
|
|
50
50
|
Requires-Dist: rasterstats
|
|
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
|