mdsumner / bluelink

Get Bluelink ReANalysis (BRAN)
Other
3 stars 1 forks source link

Things to think about #4

Open Maschette opened 2 weeks ago

Maschette commented 2 weeks ago

Notes on things to think about/look at.

Maschette commented 2 weeks ago

In my for I have added a data frame for what the depth layers are https://github.com/Maschette/bluelink/blob/701237c251e8ac7876035979891a28b0193b0684/data-raw/depth_layers.R

I would like to make either a dataframe that has for each cell what the deepest layer with data is, or just a raster with that. I jsut done know how to do it.

mdsumner commented 2 weeks ago

excellent, nearly all todos I had floating in my head, thanks!!

technically the "windows thing" is that we can only read these successfully on windows via raster package (which reads via ncdf4 package) because the GDAL/terra on CRAN for windows is a bit old. That might change pretty soon so that inconsistency should disappear (we're still in trouble on linux if people have an old GDAL). I didn't really want to workaround all of that, but at least we can read it.

mdsumner commented 1 week ago

ok so depth and time metadata should work now on linux or windows. Oh I changed the function argument to "level", because it's an index not a value.

a <- read_bluelink("2015-06-03", level = 51) 
terra::depth(a)
#[1] 4509.18
 terra::time(a)
#[1] "2015-06-03 12:00:00 UTC
mdsumner commented 1 week ago

the WMS is just an image, they normalize it for visualizing as tiles:

terra::rast("WMS:https://thredds.nci.org.au/thredds/wms/gb6/BRAN/BRAN2020/daily/ocean_u_2020_08.nc?service=WMS&version=1.3.0&request=GetCapabilities")
class       : SpatRaster 
dimensions  : 447392431, 1073741824, 3  (nrow, ncol, nlyr)
resolution  : 3.352761e-07, 3.352761e-07  (x, y)
extent      : -180, 180, -74.95, 75.05  (xmin, xmax, ymin, ymax)
coord. ref. : lon/lat WGS 84 
source      : ocean_u_2020_08.nc?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&LAYERS=u&CRS=CRS:84&BBOX=-180.0,-74.95000152638787,180.0,75.05000000050896 
colors RGB  : 1, 2, 3 
names       : 84&BBOX=-1~00050896_1, 84&BBOX=-1~00050896_2, 84&BBOX=-1~00050896_3 

we can't really use that without other tricks

mdsumner commented 1 week ago

to pull into -180,180 I would do this

temp <- read_bluelink("2023-01-01", varname = "ocean_temp", level = 10)

terra::rotate(temp)

## or more generally
project(temp, rast(ext(-180, 180, -90, 90), res = res(temp), crs = crs(temp))

for subsetting I'll have a think, crop() will work now but won't be as quick on windows