Conte-Ecology / conteStreamTemperature_web

Description and scripts for running the temperature model through the SHEDS web application
MIT License
0 stars 0 forks source link

breakpoints script finds no breakpoints #7

Open walkerjeffd opened 9 years ago

walkerjeffd commented 9 years ago

Using the dropbox datasets (masterData, covariateData), I tried to run breakpoints.R. The script runs but the resulting springFallBPs dataframe doesn't seem to have any breakpoints (all of finalSpringBP and finalFallBP are NA). Is this correct?

Note that I just pushed an update to breakpoints.R to 1) load required libraries, 2) add dOY and year columns to masterData, which were not in either masterData.RData or temperatureData.RData. So you'll need to pull the master branch to get these minor updates to the script.

After running through the script, I get:

> str(springFallBPs)
'data.frame':   195 obs. of  6 variables:
 $ site          : Factor w/ 195 levels "MADEP_W0013_T1",..: 1 2 41 42 101 102 129 17 87 140 ...
 $ year          : num  2005 2005 2005 2005 2008 ...
 $ finalSpringBP : num  NA NA NA NA NA NA NA NA NA NA ...
 $ sourceSpringBP: chr  NA NA NA NA ...
 $ finalFallBP   : num  NA NA NA NA NA NA NA NA NA NA ...
 $ sourceFallBP  : chr  NA NA NA NA ...

> summary(springFallBPs)
             site          year      finalSpringBP sourceSpringBP      finalFallBP 
 MADEP_W0013_T1:  1   Min.   :2005   Min.   : NA   Length:195         Min.   : NA  
 MADEP_W0014_T1:  1   1st Qu.:2007   1st Qu.: NA   Class :character   1st Qu.: NA  
 MADEP_W0096_T1:  1   Median :2008   Median : NA   Mode  :character   Median : NA  
 MADEP_W0099_T1:  1   Mean   :2008   Mean   :NaN                      Mean   :NaN  
 MADEP_W0124_T1:  1   3rd Qu.:2009   3rd Qu.: NA                      3rd Qu.: NA  
 MADEP_W0128_T1:  1   Max.   :2010   Max.   : NA                      Max.   : NA  
 (Other)       :189                  NA's   :195                      NA's   :195  
 sourceFallBP      
 Length:195        
 Class :character  
 Mode  :character  
djhocking commented 9 years ago

Are you deriving the masterData (from observed stream temperature and climate/daymet) or using it directly from the dropbox file?

walkerjeffd commented 9 years ago

Same result either way

djhocking commented 9 years ago

Okay, this isn't really code I've worked on but I think I found the problem. The mini dataset that was in the dropbox masterData file was only the MADEP data. These data are only from a narrow window in the summer. It's not enough of a time series to estimate the spring or fall breakpoints so they all get NA. When additional data is included those NA are replaced with the mean breakpoints from nearby sites (i.e. within HUC12, HUC8, or HUC4 depending what's available). Since these data contained no complete time series there was nothing to replace the NA with.

I have added a new masterData.RData file to the dropbox folder. It includes all the data from MA. I've tested it manually reading in the data and it works. There are still a few NA at the end but not too many. It may be worth checking on those later but this will get you started.

walkerjeffd commented 9 years ago

Great, thanks!

djhocking commented 9 years ago

I'm actually going to leave this open but change it to an enhancement label now (assuming it works for you) so that I remember to go back through and figure out what to do when there is only summer data like we could get from collaborators in other regions and to check on the remaining NA (maybe they just need to get the overall mean breakpoints).