<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!--P{margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>I think I have something that will work.</p>
<p>Basically you have to subset the output of DODSGrab before sending it to ModelGrid, because ModelGrid can't handle multiple forecasts.</p>
<p>FYI, I'm not sure if tmax2m and tmin2m have data...try tmp2m for 2 meter temperature.<br>
</p>
<p><br>
</p>
<p>library("rNOMADS")<br>
<br>
GFS.list <- GetDODSDates(abbrev="gfs_hd", archive=F, request.sleep=1) #returns list of available dates with GFS data in a numerical list<br>
<br>
<br>
current.GFS.url <- tail(GFS.list$url, 1)<br>
GFS.model.runs <- GetDODSModelRuns(current.GFS.url)<br>
<br>
GFS.0z <- (head(GFS.model.runs$model.run,1))<br>
<br>
#run when needed<br>
#GFS.info.variables <- GetDODSModelRunInfo(current.GFS.url, GFS.0z)<br>
<br>
lon <- c(480, 620) # USA Longitude<br>
lat <- c(240, 280) # USA Latitude<br>
<br>
variables <- c("tmax2m","tmin2m", "weasdsfc", "ugrdmwl", "vgrdmwl")<br>
<br>
GFS.Model.Data <- DODSGrab(current.GFS.url, GFS.0z, variables, time = c(0,36), lon, lat)<br>
<br>
#So we've gotten 37 forecasts. ModelGrid can only take 1 forecast at a time so we have to loop through them.<br>
pred <- 0<br>
for(fcst in unique(GFS.Model.Data$forecast.date)) {<br>
fcst.ind <- which(GFS.Model.Data$forecast.date == fcst)<br>
GFS.Model.Data.sub <- list(<br>
model.run.date = GFS.Model.Data$model.run.date[fcst.ind],<br>
forecast.date = GFS.Model.Data$forecast.date[fcst.ind],<br>
variables = GFS.Model.Data$variables[fcst.ind],<br>
levels = GFS.Model.Data$levels[fcst.ind],<br>
lon = GFS.Model.Data$lon[fcst.ind],<br>
lat = GFS.Model.Data$lat[fcst.ind],<br>
value = GFS.Model.Data$value[fcst.ind])<br>
<br>
GFS.modelgrid <- ModelGrid(GFS.Model.Data.sub, resolution = c(0.5, 0.5))<br>
<br>
#Save each forecast<br>
save(GFS.modelgrid, file = paste0(sprintf("%03i", pred), ".RData"))<br>
pred <- pred + 3 #I think this is right...<br>
}<br>
</p>
<p><br>
</p>
<div id="Signature">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
Daniel C. Bowman<br>
Doctoral Candidate in Geophysics<br>
Mitchell 315<br>
Department of Geological Sciences<br>
The University of North Carolina at Chapel Hill<br>
phone: 575-418-8555<br>
email: daniel.bowman@unc.edu<br>
web:http://geosci.unc.edu/page/daniel-c-bowman<br>
<br>
</div>
</div>
<div style="color: rgb(33, 33, 33);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" color="#000000" face="Calibri, sans-serif"><b>From:</b> rnomads-user-bounces@lists.r-forge.r-project.org <rnomads-user-bounces@lists.r-forge.r-project.org> on behalf of Adam Simkowski <akssimkowski@sbcglobal.net><br>
<b>Sent:</b> Wednesday, January 7, 2015 4:12 PM<br>
<b>To:</b> rnomads-user@lists.r-forge.r-project.org<br>
<b>Subject:</b> [Rnomads-user] ModelGrid function with Dods data</font>
<div> </div>
</div>
<div>
<div style="color:#000; background-color:#fff; font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; font-size:12px">
<div>Hi all, </div>
<div> </div>
<div>I am attempting to build an array of GFS model data, but I am running into some trouble when it comes to defining my Cartesian nodes in the ModelGrib function.
</div>
<div> </div>
<div>I'll walk you through my code before that point... I pull the current day 0z GFS_hd run and then specify a given lat lon area along with certain variables to reduce the size of the data that I am reading in. From there, I run the DODSGrab function to pull
in 36 hours worth of forecast data (gfs_hd) which works fine. </div>
<div> </div>
<div>From there, my troubles begin with the ModelGrid function. I believe I have all the arguments correct other than Cartesian.nodes, but I am skeptical on the resolution... not completely sure if I did that correctly. When it comes to the Cartesian.nodes
function, I'm not exactly sure what to put in the argument. I understand that it has to be a list with an x and y element, but I can't find any literature on the gfs_hd grid in kilometers. Any thoughts on how to move forward here?</div>
<div> </div>
<div>Thank you. </div>
<div> </div>
<div> </div>
<div>Code is listed below. I am running on a windows 7 machine so pulling Grib data is not an option for me, unfortunately.
</div>
<div> </div>
<div>#############################################3</div>
<div> <br>
library("rNOMADS")<br>
library("RCurl")<br>
<br>
GFS.list <- GetDODSDates(abbrev="gfs_hd", archive=F, request.sleep=1) #returns list of available dates with GFS data in a numerical list<br>
<br>
<br>
current.GFS.url <- tail(GFS.list$url, 1)<br>
GFS.model.runs <- GetDODSModelRuns(current.GFS.url)<br>
<br>
GFS.0z <- (head(GFS.model.runs$model.run,1))<br>
<br>
#run when needed <br>
#GFS.info.variables <- GetDODSModelRunInfo(current.GFS.url, GFS.0z)<br>
<br>
lon <- c(480, 620) # USA Longitude<br>
lat <- c(240, 280) # USA Latitude<br>
<br>
variables <- c("tmax2m","tmin2m", "weasdsfc", "ugrdmwl", "vgrdmwl")<br>
<br>
GFS.Model.Data <- DODSGrab(current.GFS.url, GFS.0z, variables, time = c(0,36), lon, lat)</div>
<div style="color:rgb(0,0,0); font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; font-size:12px; font-style:normal; background-color:transparent">
</div>
<div>GFS.modelgrid <- ModelGrid(model.data = GFS.Model.Data, grid.type = "cartesian", resolution = c(-140,40),levels = c("surface","2_m_above_ground"), variables, model.domain = NULL, cartesian.nodes = (list(x=0.5,y=0.5)))</div>
<div> </div>
<div>########################################################################</div>
<div> </div>
<div>Adam </div>
</div>
</div>
</div>
</div>
</body>
</html>