-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from jread-usgs/master
updated examples to current version of rGLM
- Loading branch information
Showing
14 changed files
with
295 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
# example usage of GLMnetCDF | ||
require('rGLM') | ||
|
||
|
||
|
||
source('../Source/GLMnetCDF.R') | ||
# 1) create data frame for GLM water temperature on a uniform grid: | ||
lyrDz <- 0.25 # grid vertical thickness for resampling | ||
GLMfolder <- '../Data/' | ||
GLMfile <- 'output.nc4' | ||
#lyrDz <- 0.25 # grid vertical thickness for resampling | ||
out.depths <- c(0,.5,1.5,5,10) | ||
GLMfolder <- '../resources/' | ||
GLMfile <- 'output.nc' | ||
GLMnc <- getGLMnc(fileName=GLMfile,folder=GLMfolder) | ||
GLMwtr <- resampleGLM(GLMnc,lyrDz=lyrDz) | ||
GLMwtr <- getTempGLMnc(GLMnc=GLMnc,ref='surface',z.out=out.depths) | ||
|
||
# 2) write data to a text file | ||
outFile <- 'GLMout.txt' | ||
outFolder <- '../Examples/' | ||
writeGLM(GLMwtr,fileName=outFile,folder=outFolder) | ||
|
||
# 3) plot a heatmap and save | ||
figureName <- 'exampleFig' | ||
plotGLM(GLMwtr,figName=figureName,folder=outFolder) | ||
write.wtr(wtr=GLMwtr,lakeName='testLake',folder=outFolder) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# example for writing all Lake Analyzer files from GLM output | ||
require('rGLM') | ||
|
||
# 1) open existing gml.nml file | ||
GLMfolder <- '../resources/' | ||
NMLfile <- 'glm.nml' | ||
nml <- read.nml(folder=GLMfolder,fileName=NMLfile) | ||
|
||
# 2) pretty print the nml list | ||
pretty.nml(nml) | ||
|
||
# 3) get existing value from nml for Kw parameter | ||
get.nml(nml,argName='Kw') | ||
|
||
# 4) change Kw value to a new one | ||
nml <- set.nml(nml,argName='Kw',argVal=0.4) | ||
|
||
# 5) view the change in the nml | ||
get.nml(nml,argName='Kw') | ||
|
||
# 6) change a list of params | ||
nml <- set.nml(nml,argList=list('Kw'=0.4,'outflow_factor'=0.9)) | ||
|
||
# 7) try to set a param that doesn't exist (will error). Un-comment this to try: | ||
#nml <- set.nml(nml,argName='donkey',argVal=23) | ||
|
||
# 8) pretty print the nml list | ||
pretty.nml(nml) | ||
|
||
# 9) write it back to glm.nml so it can be used in GLM | ||
write.nml(nml,folder=GLMfolder,fileName='glm2.nml') |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# example for writing all Lake Analyzer files from GLM output | ||
require('rGLM') | ||
|
||
# 1) create data frame for GLM water temperature on a uniform grid: | ||
lyrDz <- 0.5 # grid vertical thickness for resampling | ||
lkName <- "testLake" | ||
GLMfolder <- '../resources/' | ||
out.folder <- '.' | ||
GLMfile <- 'output.nc' | ||
NMLfile <- 'glm.nml' | ||
GLMnc <- getGLMnc(fileName=GLMfile,folder=GLMfolder) | ||
nml <- read.nml(folder=GLMfolder,fileName=NMLfile) | ||
lke <- init.lke() # gets a default list of lke parameters | ||
pretty.nml(nml) # print the nml list | ||
|
||
bth <- get.bth(nml) | ||
mxDep <- max(bth[,1]) | ||
|
||
write.bth(bth,lkName,folder=out.folder) # write the .bth file | ||
|
||
lke <- set.lke(lke,'totalDep',mxDep) | ||
write.lke(lke,lkName,folder=out.folder) # write the .lke file | ||
|
||
lvl <- get.lvl(GLMnc,nml) | ||
write.lvl(lvl,lkName,folder=out.folder) # write the .lvl file | ||
|
||
depths <- seq(0,mxDep,by=lyrDz) | ||
wtr <- get.wtr(GLMnc,ref='surface',z.out=depths) | ||
write.wtr(wtr,lkName,folder=out.folder) # write the .wtr file | ||
|
||
wnd <- get.wnd(GLMnc) | ||
write.wnd(wnd,lkName,folder=out.folder) # write the .wtr file | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.