[Rnomads-user] FW: issues on retreveing specific location data in rNOMADS

Daniel Bowman haksaeng at live.unc.edu
Tue Sep 9 02:52:54 CEST 2014



Daniel C. Bowman
Doctoral Candidate in Geophysics
Mitchell 315
Department of Geological Sciences
The University of North Carolina at Chapel Hill
phone: 575-418-8555
email: daniel.bowman at unc.edu
web:http://geosci.unc.edu/page/daniel-c-bowman

________________________________
From: Daniel Bowman
Sent: Monday, September 8, 2014 8:31 PM
To: Adam Simkowski
Subject: RE: [Rnomads-user] issues on retreveing specific location data in rNOMADS


Hi Adam,


The issue here is the North American Mesoscale (NAM) model. The package vignettes were written specifically to interface with the Global Forecast System (GFS) model. The GFS is discretized into 0.5 x 0.5 degree cells, thus there are 720 longitude values and 180 latitude values. That is the origin of the following lines in the vignette:


lons <- seq(0, 359.5, by = 0.5)
lats <- seq(-90, 90, by = 0.5)


So...we need to figure out how the NAM model is set up before we can figure out how to get the data you want.


When I run


GetDODSModelRunInfo(model.url, NAM.model.run)


I find:


"Longitude: -153.00000000000°E to -49.30000000000°E  (1038 points, avg. res. 0.1°)"
  [4] "Latitude: 12.00000000000°N to 61.90000000000°N  (500 points, avg. res. 0.1°)"


It is important to make sure each point is in fact 0.1 degrees apart (some models have variable grid spacings)...so I have to download the *entire model* and check:


everything <- DODSGrab(model.url, NAM.model.run, "dswrfsfc", time, c(0, 1037), c(0, 499))


diff(everything$lat)

diff(everything$lon)


Well, looks like we are lucky and everything is in fact 0.1 degrees apart. So let's redefine our indices:


lat <- 36.424789 #lat at Murphy Solar

lon <- -77.062891 #lon at Murphy Solar

#Get nearest model nodes
lons <- seq(-153, -49.3, by = 0.1)
lats <- seq(12, 61.9, by = 0.1)
lon.diff <- abs(lon - lons)
lat.diff <- abs(lat - lats)
model.lon.ind <- which(lon.diff == min(lon.diff))
model.lat.ind <- which(lat.diff == min(lat.diff))


Okay, now let's try getting the data for that specific point.


time <- c(0,0) #Model status at initialization
lon.inds <- c(model.lon.ind - 2, model.lon.ind + 2)
lat.inds <- c(model.lat.ind - 2, model.lat.ind + 2)


solar.data <- DODSGrab(model.url, NAM.model.run, "dswrfsfc", time, lon.inds, lat.inds)# pull surface downward short wave flux [w/m^2] from the model


According to the coordinates in solar.data, we've captured the point we want. Anyway, the take home message is that each *model* is unique, and you have to investigate each one individually.


Hope this helps!

Danny



Daniel C. Bowman
Doctoral Candidate in Geophysics
Mitchell 315
Department of Geological Sciences
The University of North Carolina at Chapel Hill
phone: 575-418-8555
email: daniel.bowman at unc.edu
web:http://geosci.unc.edu/page/daniel-c-bowman

________________________________
From: rnomads-user-bounces at lists.r-forge.r-project.org <rnomads-user-bounces at lists.r-forge.r-project.org> on behalf of Adam Simkowski <akssimkowski at sbcglobal.net>
Sent: Monday, September 8, 2014 3:31 PM
To: rnomads-user at lists.r-forge.r-project.org
Subject: [Rnomads-user] issues on retreveing specific location data in rNOMADS

Hi all,

I have been attempting to pull “dswrfsfc” (incoming solar radiation) at a specific latitude and longitude from the historical NAM data set available through rNOMADS. I followed the example shown in various parts of the package notes where data is pulled for Chapel Hill, NC. I am attempting to pull data for a location not too far from Chapel Hill (Murfreesboro, NC). However, when I attempt to pull either solar radiation or 2 meter temperature data for a given hour, I get 24 rows of data with a longitude far away from my desired location and a latitude somewhat nearby. I was under the impression that I should only get one row of data closest to my desired location since I’m only querying for one specific hour.  I am not completely sure I understand the code to query data closest to a desired location given a latitude and longitude... I have included this code in the attached items with my specific lat and lon ( file name: rNOMADS lat-lon code). Could someone please explain code here a little more in-depth than is shown in on the package vignette?

I have also attached my script that I wrote to retrieve point specific model data for Murfreesboro (Murphy solar) and an example of the 24 row data frame that it creates. The script was written as a function where the input is a specific number assigned to a url from the historical NAM list. An example input would be 1473 which is the url for NAM runs on September 1st, 2014. I am hoping to fix the code so that it only returns one row of data instead of 24.
I have also written a script that pulls more than one model at a time using a for loop, but this lat lon issue seems to be inhibiting me from creating a proper final output data frame with good data. Once I figure out the lat lon issue here, I will certainly share this code for all to use!


Thank you,

Adam Simkowski




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rnomads-user/attachments/20140909/8ec89879/attachment.html>


More information about the Rnomads-user mailing list