HARPgroup / r-dh-ecohydro

A set of R scripts for generating Ecological Limit Functions (ELF), storing the modeled output with REST in drupal VAHydro (dH), and a set of scripts for querying and analyzing processed ELF data
0 stars 1 forks source link

Vahydro fe data #19

Closed rburghol closed 6 years ago

rburghol commented 6 years ago

This creates a new function called vahydro_fe_data() that returns the dataset from the vahydro views. I created this to ease testing for Jen's ggplot of DA vs. flkow for continuity seeking, and I give a really simple example below using plain old plot. Comments following this explore the discontinuity issue, but this patch should be tested as stand alone, that is, just to see if it maintains all previous functions but with the benefit of being able to say "give me the data for the James River basin, EROM flow for August and aqbio_nt_benins from EDAS".

Usage: mydata <- vahydro_fe_data(hydrocode, x_metric, y_metric, bundle, ftype, sampres)

Example (to show the discontinuities in a dataset):

mydata <- vahydro_fe_data('020802', "erom_q0001e_oct", "aqbio_nt_total", 'watershed',  "nhd_huc6", "species")
plot(mydata$drainage_area, mydata$attribute_value)
rburghol commented 6 years ago

image

rburghol commented 6 years ago

Note there area few whose flow value is zero, but the disconstinuities here appear to be driven by gaps in the DA, caused (I presume) by missing sample locations, or downstream effects.

rburghol commented 6 years ago

Further drilling down, we know that the discontinuities at the upper levels of area/flow get obscured by the compression of large values, so I subset to show only those with DA < 5,000. I also plot a regression line between the DA and flow, and looks to me that there is no discontinuity in flow in this large range, that is, there is a very consistent unit area of flow per drainage area, but a gap appears between 2,000 and 3,000 DA because of a discontinuity in the DA. BUT - this doesn't get at the area where the discontinuity appears in the log plot. See next comment.

smalldata = subset(mydata, drainage_area < 5000)
plot(smalldata$drainage_area, smalldata$attribute_value)
abline(lm(smalldata$attribute_value ~ smalldata$drainage_area))
# Invert axis
plot(smalldata$attribute_value, smalldata$drainage_area)
abline(lm(smalldata$drainage_area~ smalldata$attribute_value))

image

image

rburghol commented 6 years ago

The next image shows with the axis flipped, flow on x, DA on y, and also sub-setted to focus in on the area where the DA < 50 and flow <10, because that is where the gap appears in the log plot of October flows -- the 2nd image here shows the original plot where the discontinuity appears. So, looks like here again we have an example of EROM error. Whether that impacts our analysis or not is another question.

image

image

jenniferRapp commented 6 years ago

I'm checking email to keep things tidy for next year. Thanks for the birthday wishes. Hope you had a great Christmas!

If you run my DA_Flow.R code it works outside of the function with one data file. The log log plot shows the discontinuities really well.

The flow predictions for DA in Rob's plot for 0-10 are quite low and do seem a bit odd as well.

--Jen [image: Inline image 1]

Jennifer Lynn Rapp, Biogeographer and GIS Specialist jrapp@usgs.gov U.S. Geological Survey Virginia and West Virginia Water Science Center 1730 East Parham Road Richmond, VA 23228 w. 804-261-2635

On Wed, Dec 20, 2017 at 8:59 PM, rburghol notifications@github.com wrote:

The next image shows with the axis flipped, flow on x, DA on y, and also sub-setted to focus in on the area where the DA < 50 and flow <10, because that is where the gap appears in the log plot of October flows -- the 2nd image here shows the original plot where the discontinuity appears.

[image: image] https://user-images.githubusercontent.com/4571170/34237036-7eb5d09a-e5c8-11e7-820c-dcbdd974f55e.png

[image: image] https://user-images.githubusercontent.com/4571170/34237058-a11c68ba-e5c8-11e7-930e-5afe03e1598c.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/HARPgroup/r-dh-ecohydro/pull/19#issuecomment-353236579, or mute the thread https://github.com/notifications/unsubscribe-auth/AgIeBeUCjDduy3y7usqIUHx5nGUtqmqJks5tCbtxgaJpZM4RJEe9 .