Displaying 4 results from an estimated 4 matches for "oneyr".
Did you mean:
onerr
2017 Dec 18
2
Finding center of mass in a hydrologic time series
...ot;
QParameterCd <- "00060"
Daily <- readNWISDaily(siteNumber, QParameterCd, StartDate, EndDate)
# Define 'center of mass' function
com <- function(x) {
match(TRUE, cumsum(x/sum(x)) > 0.5) - 1
}
wyrs <- unique(Daily$waterYear)
for(i in (1:length(wyrs))){
OneYr <- Daily[Daily$waterYear==wyrs[i], ]
mid <- com(OneYr$Q)
if(i==1){
midPts <- as.Date(OneYr$Date[mid])
} else {
midPts <- c(midPts, as.Date(OneYr$Date[mid]))
}
}
Eric Morway
Research Hydrologist
Nevada Water Science Center
U.S. Geological Survey
2730 N....
2017 Dec 18
0
Finding center of mass in a hydrologic time series
...<- readNWISDaily(siteNumber, QParameterCd, StartDate, EndDate)
>
> # Define 'center of mass' function
> com <- function(x) {
> match(TRUE, cumsum(x/sum(x)) > 0.5) - 1
> }
>
>
> wyrs <- unique(Daily$waterYear)
> for(i in (1:length(wyrs))){
> OneYr <- Daily[Daily$waterYear==wyrs[i], ]
> mid <- com(OneYr$Q)
> if(i==1){
> midPts <- as.Date(OneYr$Date[mid])
> } else {
> midPts <- c(midPts, as.Date(OneYr$Date[mid]))
> }
> }
>
>
>
> Eric Morway
> Research Hydrologist
&...
2017 Dec 16
0
Finding center of mass in a hydrologic time series
Hi Eric,
How about
match( TRUE, cumsum(hyd/sum(hyd)) > .5 ) - 1
HTH,
Eric
On Sat, Dec 16, 2017 at 3:18 PM, Morway, Eric <emorway at usgs.gov> wrote:
> The small bit of script below is an example of what I'm attempting to do -
> find the day on which the 'center of mass' occurs. In case that is the
> wrong term, I'd like to know the day that essentially cuts
2017 Dec 16
3
Finding center of mass in a hydrologic time series
The small bit of script below is an example of what I'm attempting to do -
find the day on which the 'center of mass' occurs. In case that is the
wrong term, I'd like to know the day that essentially cuts the area under
the curve in to two equal parts:
set.seed(4004)
Date <- seq(as.Date('2000-09-01'), as.Date('2000-09-30'), by='day')
hyd <-