GeoscienceAustralia / dea-notebooks

Repository for Digital Earth Australia Jupyter Notebooks: tools and workflows for geospatial analysis with Open Data Cube and Xarray
https://docs.dea.ga.gov.au/notebooks/
Apache License 2.0
441 stars 128 forks source link

Add multiple tide model support to `pixel_tides` #1084

Closed robbibt closed 1 year ago

robbibt commented 1 year ago

Proposed changes

Currently, the pixel_tides function only allows us to run a single tide model at once (by default, "FES2014").

This PR updates the function to allow a user to specify a list of tide models:

tides_highres, tides_lowres = pixel_tides(
    ds=ds,
    times=times,
    model=["TPXO9-atlas-v5", "FES2014", "FES2012"],
)

Outputs are now returned as an xr.DataArray with a new "tide_model" dimension, making it easy to plot and compare different model outputs:

tides_highres.isel(time=[0, 1, 2, 3, 4]).plot(col="time", row="tide_model")

image image

For backwards compatibility, the "tide_model" dimension is squeezed out if only one model is requested (the default).

Other minor updates:

robbibt commented 1 year ago

To test:

  1. Start up the "8XL default environment with shared drive" Sandbox environment
  2. Run:
    
    import datacube
    import odc.geo.xr
    import pandas as pd
    from dea_tools.coastal import pixel_tides

dc = datacube.Datacube()

Load some data over the coast

ds = dc.load( product="ga_ls8c_ard_3", x=(122.2, 122.5), y=(-17.0, -17.3), time=("2015"), dask_chunks={}, )

Model some tides, requesting three different models

tides_highres, tides_lowres = pixel_tides( ds=ds, times=pd.date_range("2020-01-01", "2020-01-02", periods=20), model=["TPXO9-atlas-v5", "FES2014", "FES2012"], directory="/gdata1/data/tide_models_clipped/", cutoff=20, )

Plot our modelled tides from each of our models for five timesteps

tides_highres.isel(time=[0, 1, 2, 3, 4]).plot.imshow(col="time", row="tide_model")