Skip to content

Instantly share code, notes, and snippets.

View robbibt's full-sized avatar
🛰️

Robbi Bishop-Taylor robbibt

🛰️
View GitHub Profile
@robbibt
robbibt / s3_to_vrt.py
Created February 7, 2024 03:44
Create virtual raster for files on S3
import s3fs
import pandas as pd
s3 = s3fs.S3FileSystem(anon=True)
file_list = s3.glob(
"dea-public-data-dev/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/*/*/2023--P1Y/ga_ls8cls9c_gm_cyear_3_*_2023--P1Y_final_nbart_red.tif"
)
pd.DataFrame(file_list).iloc[:, 0].str.replace(
"dea-public-data-dev/",
@robbibt
robbibt / tide_gauge_funcs.py
Created January 31, 2024 00:43
GESLA and ABSLMP tide gauge loading functions
import glob
import warnings
import datetime
from odc.geo.geom import BoundingBox
def _load_gauge_metadata(metadata_path):
# Load metadata
@robbibt
robbibt / Expanded_AOI_gridspec_tiles.ipynb
Last active January 25, 2024 03:34
Generating GridSpec summary tile grid for expanded DEA AOI
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@robbibt
robbibt / otps_tides.py
Created October 12, 2023 23:46
OTPS tide modelling function for TPXO8
import otps
import pytz
def otps_tides(lats, lons, times, timezone=None):
"""
Model tide heights for one or more locations and times using the
OTPS TPXO8 tidal model.
Parameters:
-----------
lats, lons : numeric or list of numeric values
@robbibt
robbibt / load_ls_s2.py
Last active August 14, 2023 13:10
`pc_load`: easily searching and loading data from Microsoft Planetary Computer
import numpy as np
import xarray as xr
def load_ls_s2(
x=None,
y=None,
geom=None,
start_date="2020",
end_date="2021",
@robbibt
robbibt / tide_range_constituents.py
Created June 23, 2023 03:14
Tide range from constituents
# Source: https://www.arcgis.com/home/item.html?id=d5354dea41b14f0689860bf4b2cf5e8a
# 2*(M2+S2+K1+O1)
(0.01 * 2 * (
xr.open_dataset("/var/share/tide_models/fes2014/ocean_tide/m2.nc")
+ xr.open_dataset("/var/share/tide_models/fes2014/ocean_tide/s2.nc")
+ xr.open_dataset("/var/share/tide_models/fes2014/ocean_tide/k1.nc")
+ xr.open_dataset("/var/share/tide_models/fes2014/ocean_tide/o1.nc")
)).amplitude.odc.assign_crs("EPSG:4326").plot()
@robbibt
robbibt / tide_models.py
Created June 13, 2023 07:13
Loading different tide models with `dea_tools.coastal.model_tides`
import pandas as pd
import sys
sys.path.insert(1, '../Tools/')
from dea_tools.coastal import model_tides, tidal_tag, pixel_tides, tidal_stats
# Set of times to model tides for
date_list = pd.date_range(start="2022-09-01", end="2022-09-30", freq="1H")
# Run TPXO8
@robbibt
robbibt / Resampling_Dask_issue.ipynb
Last active May 25, 2023 01:47
Datacube.load Dask resampling issue
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Abstract

Digital Earth Australia Coastlines is a continental dataset that includes annual shorelines and rates of coastal change along the entire Australian coastline from 1988 to the present.

The product combines satellite data from Geoscience Australia's Digital Earth Australia program with tidal modelling to map the most representative location of the shoreline at mean sea level for each year. The product enables trends of coastal retreat and growth to be examined annually at both a local and continental scale, and for patterns of coastal change to be mapped historically and updated regularly as data continues to be acquired. This allows current rates of coastal change to be compared with that observed in previous years or decades.

The ability to map shoreline positions for each year provides valuable insights into whether changes to our coastline are the result of particular events or actions, or a process of more gradual change over time. This information can enable scientists, managers and policy

@robbibt
robbibt / dea_virtual_product_landsat_s2.yaml
Created March 15, 2023 01:39
Test virtual products YAML
about: Catalog of virtual products loading, normalising and cloud masking Landsat products
products:
# Loads a subset of data from Landsat 8, including spectral bands
# (blue, green, red, nir, swir1, swir2), a cloud masking band (fmask)
# and a contiguity band (contiguity).
ls8_nbart:
recipe:
&ls8_nbart
product: ga_ls8c_ard_3