########################################################################## # hydrographSeparation.r # example script which shows how to connect to the USGS NWIS web # services and download daily hydrometric data for a series, then # conduct a hydrograph separation based on the Nathan and McMahon (1990) # method. ########################################################################## library(waterData) library(EcoHydRology) id <- "14301000" # Nehalem R near Foss, Oregon dates <- c('2000-01-01','2005-12-31') # get station metadata metadata <- siteInfo( id ) # get daily values gauge <- importDVs(staid = id, sdate = dates[1], edate = dates[2]) # clean up gauge data gauge <- cleanUp(gauge, task = 'fix') # conduct hydrograph separation hydrograph.sep <- BaseflowSeparation( streamflow = gauge$val, filter_parameter = 0.925) # plot daily hydrograph par(mar = c(5,5,5,5)) plot( gauge$dates, gauge$val* 0.0283127, # multiplier converts from cfs to cumecs xlab = 'Date', ylab = expression("Q ("*m^3*s^{-1}*")"), col = 'red', type = 'l', main = sprintf( '%s [%s]', metadata$staname[1], metadata$staid[1] ) ) # plot baseflow component points( gauge$dates, hydrograph.sep$bt* 0.0283127, col = 'blue', type = 'l' ) # add legend legend("topleft", bty = "n", legend = c("discharge", "baseflow"), col = c("red", "blue"), lty = c(1, 1) )