[Rnomads-user] Issue with using multiple Lat/Lon. Not sure what is causing it.

Bowman, Daniel haksaeng at live.unc.edu
Tue Mar 1 01:49:21 CET 2016


Hi Ruben,


The short answer is that the NARRE is not on a regular lat-lon grid, and my data processing codes are not optimized for such grids.


Long answer:

The data processing code in rNOMADS work best on regular lat lon grids, for the simple reason that I exclusively use the GFS in my own work.  I decided to put some of the more useful functions into the official package after considerable internal debate, mainly because I wanted to save users time.  At the same time, rNOMADS is intended to be a pipeline and not a "weather model processing package" so some of these functions are not very sophisticated.


Your best bet at this point is to download the grib file in the region of interest, read it in, examine the lat/lon values it returns, select the one closest to the region you want, and use that one.


I've written up a script that should do what you want:

http://pastebin.com/6gv6gkP6


Best,


Danny


Daniel C. Bowman
Doctoral Candidate in Geophysics
UNC Chapel Hill
phone: 575-418-8555
curriculum vitae:  http://www.unc.edu/~haksaeng/curriculum_vitae/bowman_cv.pdf
LinkedIn:  https://www.linkedin.com/in/dannycbowman
web:http://geosci.unc.edu/page/daniel-c-bowman
twitter: @dannycbowman



________________________________
From: rnomads-user-bounces at lists.r-forge.r-project.org <rnomads-user-bounces at lists.r-forge.r-project.org> on behalf of Ruben Kertesz <rkertesz at emnet.net>
Sent: Monday, February 29, 2016 7:03 PM
To: rnomads-user at lists.r-forge.r-project.org
Subject: [Rnomads-user] Issue with using multiple Lat/Lon. Not sure what is causing it.


Good evening,



I have been using rNOMADS for some rainfall work and am happy to say that it is very powerful! Today I ran into an issue where I can’t use multiple lat/lon values for the RTModelProfile function. Actually, I can if they are very close to (-79.052104, 35.907553 - lon/lat). I would like to ask if anyone has insight into why this is happening.



First of all, I put my code up to pastebin here: http://pastebin.com/WyVn84bp

The issue is showing up in BuildProfile. The code is reproduced here. I get valid values in layer.img when using the single x/y.



  if (spatial.average) {

        for (k in seq_len(length(gridded.data$levels))) {

            for (j in seq_len(length(gridded.data$variables))) {

                layer.img <- t(rbind(as.vector(cart.pts$x), as.vector(cart.pts$y[nrow(cart.pts$y):1,

                  ]), as.vector(t(gridded.data$z[k, j, , ]))))

                profile.data[k, j] <- MBA::mba.points(layer.img,

                  cbind(0, 0))[[1]][3]

            }



If I use this:

lon <- c(-79.052104)#, -78.010020)

lat <- c(35.907553)#, 36.000200)



Then I get this in layer.img:



            [,1]       [,2] [,3]

 [1,] -102.02596 -129.16620    0

 [2,] -102.68684  -73.50205    0

 [3,] -103.33989  -17.83809    0

 [4,] -103.98508   37.82569    0

 [5,] -104.62235   93.48929    0

 [6,]  -57.42160 -129.57281    0

 [7,]  -57.79351  -73.91126    0

 [8,]  -58.16101  -18.24976    0

 [9,]  -58.52409   37.41168    0

[10,]  -58.88271   93.07305    0

[11,]  -12.81848 -129.75192    0

[12,]  -12.90150  -74.09151    0

[13,]  -12.98354  -18.43110    0

[14,]  -13.06459   37.22931    0

[15,]  -13.14464   92.88971    0

[16,]   31.78435 -129.70356    0

[17,]   31.99021  -74.04284    0

[18,]   32.19362  -18.38214    0

[19,]   32.39459   37.27855    0

[20,]   32.59308   92.93921    0

[21,]   76.38788 -129.42772    0

[22,]   76.88265  -73.76524    0

[23,]   77.37156  -18.10286    0

[24,]   77.85458   37.55941    0

[25,]   78.33167   93.22158    0





BUT If I use this:

lon <- c(-79.052104, -78.010020)

lat <- c(35.907553, 36.000200)



Then I get this. The NA causes all sorts of problems. I ran out of steam to try and figure out why this is happening.



            [,1]       [,2] [,3]

 [1,] -101.50132 -141.10061   NA

 [2,] -102.16831  -85.43643    0

 [3,] -102.82751  -29.77243    0

 [4,] -103.47889   25.89139    0

 [5,] -104.12238   81.55503    0

 [6,] -104.75795  137.21848   NA

 [7,]  -57.12636 -141.50666    0

 [8,]  -57.50171  -85.84509    0

 [9,]  -57.87267  -30.18358    0

[10,]  -58.23923   25.47787    0

[11,]  -58.60135   81.13926    0

[12,]  -58.95901  136.80059    0

[13,]  -12.75258 -141.68551    0

[14,]  -12.83637  -86.02510    0

[15,]  -12.91917  -30.36469    0

[16,]  -13.00100   25.29572    0

[17,]  -13.08183   80.95612    0

[18,]  -13.16167  136.61652    0

[19,]   31.62094 -141.63722    0

[20,]   31.82869  -85.97649    0

[21,]   32.03402  -30.31579    0

[22,]   32.23692   25.34490    0

[23,]   32.43735   81.00557    0

[24,]   32.63532  136.66622    0

[25,]   75.99511 -141.36177    0

[26,]   76.49445  -85.69927    0

[27,]   76.98796  -30.03687    0

[28,]   77.47562   25.62543    0

[29,]   77.95737   81.28762    0

[30,]   78.43319  136.94971    0

[31,]  120.37085 -140.85909    0

[32,]  121.16188  -85.19335    0

[33,]  121.94369  -29.52787    0

[34,]  122.71621   26.13736    0

[35,]  123.47939   81.80233    0

[36,]  124.23317  137.46704    0

[37,]  164.74907 -140.12908    0

[38,]  165.83197  -84.45864    0

[39,]  166.90224  -28.78867    0

[40,]  167.95981   26.88082    0

[41,]  169.00459   82.54982    0

[42,]  170.03650  138.21833    0





Any help is greatly appreciated!



Ruben Kertesz, Ph.D.
Environmental Engineer
EmNet LLC
121 S. Niles Ave.
Suite #22
South Bend, IN 46617
Office: 574.855.1012 x115

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rnomads-user/attachments/20160301/861f1be2/attachment-0001.html>


More information about the Rnomads-user mailing list