Description Usage Arguments Examples
Write a USGS discharge timeslice to a netcdf file.
1 | WriteNcTimeSlice(dfByPosix, outPath, sliceResolution)
|
dfByPosix |
Dataframe, a data frame with the following columns:
|
outPath |
Character, the path for the output netcdf file. |
sliceResolution |
The Temporal resolution. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | library(rwrfhydro)
library(data.table); library(plyr); library(lubridate)
siteNumbers <- c("01374559", "01374598", "01374581", "0137462010")
parameterCd <- "00060" # Discharge
# NWIS is local time. Pad time at least enough to account
# for the 5hr offset in this domain.
startDate <- "2011-08-25"
endDate <- "2011-09-03"
obsDischarge <- dataRetrieval::readNWISuv(siteNumbers, parameterCd, startDate, endDate)
obsDischarge <- as.data.table(obsDischarge)
cfsToCms <- 1/35.31466621266132
obsDischarge[, `:=`(discharge.cms=X_00060_00000*cfsToCms)]
# reformat the name of th gauge to 15 character
obsDischarge$site_no <- formatC(obsDischarge$site_no, width=15)
obsDischarge$dateTimeRound <-
format(RoundMinutes(obsDischarge$dateTime,nearest=15),
'%Y-%m-%d_%H:%M:%S')
obsDischarge$dateTimeRound <-
as.POSIXct(obsDischarge$dateTimeRound, "%Y-%m-%d_%H:%M:%S",
tz='UTC')
obsDischarge$queryTime <- Sys.time()
# quality control procedures...
obsDischarge$discharge.quality <- 100
system("mkdir nudgingTimeSliceObs")
outPath <- "nudgingTimeSliceObs/"
for (i in sort(unique(obsDischarge$dateTimeRound))) {
print(i)
WriteNcTimeSlice(subset(obsDischarge,dateTimeRound == i),
outPath=outPath,
sliceResolution = 15)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.