[R-sig-Geo] How to perform integration of .nc file in Raster R Package

Aseem Sharma asharma at unbc.ca
Thu Apr 13 21:11:38 CEST 2017


Hi,
I have a .nc<https://www.dropbox.com/s/9x951b2qwjwfktf/qu.nc?dl=0> file with 2 variables q an u and 4 dimensions namely lat, lon, pressure level and time. This is a sample data of specific humidity and wind direction from ERA_interim.
How can i calculate the integration of product of variables q and u at each grid cell ( ie the vapour flux)  for all time steps i e how to solve following equation in R to get int.

[cid:image002.jpg at 01D2B44F.1A97D5A0]
I have tried to make stacks of q and u for 3 levels as qs and us using raster package but got lost on calculating the integration value.
The sample data file qu.nc (529 KB) is here<https://www.dropbox.com/s/9x951b2qwjwfktf/qu.nc?dl=0>.
 Any help to write a function to solve this integration would be greatly appreciated.
required (raster)
    ncfl<-"qu.nc" #.nc datafile
    ncf<-stack(ncfl)
    print(ncf)
n <- 3 # Pressure levels 1000,950,900
for (i in 1:n) {
  names <- paste("u", i, sep=".")
  assign(names, brick(ncfl, varname ="u", lvar = 3, level
                      = i) )
}
for (i in 1:n) {
  names <- paste("q", i, sep=".")
  assign(names, brick(ncfl, varname ="q", lvar = 3, level
                      = i) )
}

qs<-stack(q.1,q.2,q.3)
us<-stack(u.1,u.2,u.3)

Thank you,
as

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20170413/22bd72de/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.jpg
Type: image/jpeg
Size: 1676 bytes
Desc: image002.jpg
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20170413/22bd72de/attachment.jpg>


More information about the R-sig-Geo mailing list