NOAA-OCM / SWMPrExtension

Functions for Analyzing and Plotting SWMP Estuary Monitoring Data from the NERR System archive at
http://cdmo.baruch.sc.edu/
Other
12 stars 5 forks source link

plot a target year that's outside the historical range #30

Closed swmpkim closed 6 years ago

swmpkim commented 6 years ago

Several plotting functions subset the data based on a provided historical range - so if you want to feature 2016 on top of 2007-2015 data, that doesn't work.

Works in: seasonal_boxplot Does not work in: historical_daily_range, historical_range

Per conversation with Julie just now, subsetting happens on line 141 in the historical_daily_range script - may want to call this something else, or create a separate data frame for target year, or something. Can probably look at the seasonal_boxplot code to figure out how to handle it.

swmpkim commented 6 years ago

I just got historical_daily_range to work, at least on my little dataset. Here: https://github.com/swmpkim/SWMPrExtension/commit/e7294498894ce3ea4ba23310a3b7aa12c4fa58a4

The first filtering is for year in dataset to [match the target year] OR [be between the first and last values of range]. I had to insert "as.numeric" before the range values which makes me worry this will break when it's being run in a way different than I'm using it.

Anyway, so it's filtered to include both of those, then it runs all the daily averaging and assigning of julian day, and then I break the target year out into its own data frame (which is really just code pulled from your line 173), make sure the big data frame is only between the historical range years, and then do all the historical calculations, ribbon-generating, etc..

When I load my gndbcwq.RData into the environment, its 'dat' goes from 2007 - sept2017. And this line produces the graph it should. Yay! historical_daily_range(dat, "temp", hist_rng = c("2008", "2015"), target_yr = 2016)

See if this gives you any heartburn. If so, let me know what I should modify. If not, I'll get to working on other functions (but it will probably wait until after a deadline I have on June 15th).

padilla410 commented 6 years ago

Kim, so far nice approach. I'll take a detailed look at it next week and do a bit of testing on my end. I want to get CDMO up and running on SWMPrExtension 0.3.15. You likely need to add as.numeric because you are specifying the historic range (hist_rng) as character values by using the quotation marks. Try using c(2008, 2015) instead.

Also, please be sure to add yourself to the @author tag in the documentation portion of the function.

swmpkim commented 6 years ago

Thanks Julie. I just tried it with c(2008, 2015), and it works both ways! I guess it has something to do with the "dplyr::between" function that I'm using? If it works any which way, I'm happy.

Just added myself to the author tag, with (contributor) behind the name.