Thank you Bert.
Yes, your suggestion is correct and there is no need to pre-define the matrix
and the sapply function works quite fast. This resolves my issue.
Thank you both againHC
On Sunday, 3 July 2016 11:38 AM, Bert Gunter wrote:
Well, yes, ... but no: there is no need to pre-defin
Well, yes, ... but no: there is no need to pre-define the matrix.
The following is still a (interpreted) loop, but it is fast and short.
## ex is the downloaded array, here filled with random numbers
reqX = c(35,35,40,65,95)
reqY = c(2,5,10,112,120)
out <-sapply(seq_along(reqX), function(i)ex[r
Thank you both.
Yes, this is basically the issue of able to subset an array rather than
extracting from the netCDF file. The dX = ncvar_get(nc=myNC,
varid="myVar")command already results in the array. And one can subset that
array using indices.
In turn the problem can be stated as follows:Let u
Sending this to Hemant a second time as i forgot to reply to list.
Hi Hemant:
Well technically the code you give below shouldn’t work, because “start” and
“count” are suppose to be of the same dimensions as the variables. I guess
Pierce’s code must be very forgiving if that is working. One th
I know nothing about netCDF files, but if you can download the file
and make it an array, extraction via indexing takes no time at all:
> ex <-array(rnorm(2*1e4*365, mean = 10), dim = c(100,200,365))
> system.time(test <-ex[35,2,])
user system elapsed
0 0 0
> length(test)
[
I am working with a 3-dimensional netCDF file having dimensions of X=100,
Y=200, T=365.
My objective is to extract time vectors of a few specific grids that may not be
contiguous on X and/or Y.
For example, I want to extract a 5x365 matrix where 5 rows are each vectors of
length 365 of 5 spe
6 matches
Mail list logo