Closed chrisdane closed 4 years ago
Hi
The code
library(pracma) dxy_tair <- pracma::gradient(tair, lat, lon) xy_mat <- pracma::meshgrid(lon, lat) xy_mat$X <- t(xy_mat$X) xy_mat$Y <- t(xy_mat$Y) image(lon, lat, tair, xlim=c(200, 300), ylim=c(40, 70)) pracma::quiver(xy_mat$X, xy_mat$Y, dxy_tair$X, dxy_tair$Y, scale = 0.2, col="blue")
with
str(lon) num [1:720] 0.25 0.75 1.25 1.75 2.25 str(lat) num [1:360] -89.8 -89.2 -88.8 -88.2 str(tair) num [1:720, 1:360] NA NA NA NA NA NA NA NA NA # not all are NA
works (at least something is happening), but the metR equivalent (according to the vignette https://cran.r-project.org/web/packages/metR/vignettes/Working-with-data.html)
metR
library(metR) dxy_tair <- metR::Derivate(formula=tair ~ lon + lat, order=1, cyclical=c(T, F), sphere=T)
gives the error
Error in model.frame.default(terms(formula, lhs = lhs, rhs = rhs, data = data, : variable lengths differ (found for 'lat')
Any help is very appreciated, stay healthy, Chris
Hello,
Please make your example minimal and reproducible. Thank you.
Sorry I just realized that the input for metR::Derivate() needs to be a vector, and not a matrix.
metR::Derivate()
Hi
The code
with
works (at least something is happening), but the
metR
equivalent (according to the vignette https://cran.r-project.org/web/packages/metR/vignettes/Working-with-data.html)gives the error
Any help is very appreciated, stay healthy, Chris