Quantcast

How to perform integration of .nc file in Raster R Package

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to perform integration of .nc file in Raster R Package

Aseem Sharma-2

Hi,

I have a .nc 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. 

 

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.

 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

 


_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Loading...