Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Created September 26, 2025 01:25
Show Gist options
  • Save mdsumner/e5bfd92ecaa3e5cc81a1160bcc1a754d to your computer and use it in GitHub Desktop.
Save mdsumner/e5bfd92ecaa3e5cc81a1160bcc1a754d to your computer and use it in GitHub Desktop.
mk_mth <- function(x) {
  ## replace daily with month
  xx <- stringr::str_replace(x, "daily", "month")
  ## replace _YEAR with mth_YEAR
  stringr::str_replace(xx, "(_[0-9]{4})", "_mth\\1")
}

library(bluelink)
dsn <- mk_mth(bluelink_dsn("2024-01-01", varname = "ocean_temp"))
terra::rast(dsn)
class       : SpatRaster 
size        : 1500, 3600, 51  (nrow, ncol, nlyr)
resolution  : 0.1, 0.1  (x, y)
extent      : -9.507305e-10, 360, -75, 75  (xmin, xmax, ymin, ymax)
coord. ref. :  
  source      : ocean_temp_mth_2024_01.nc:temp 
varname     : temp (Potential temperature) 
names       : temp_~n=2.5, temp_~n=7.5, temp_~=12.5, temp_~11816, temp_~72949, temp_~98828,       ... 
unit        : degrees C 
depth       : 16451.5 


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment