-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test horizon-less members of an SPC #134
Comments
Here are some stubs of things I've tried to break so far
|
I think a distinction from "horizonless" versus "fill" (as it is used in fetchNASIS) is that by "filling" with a single horizon with NA depths, we don't break the SPC, allow plots to "work" and all functions that use horizon data and are properly |
Thanks for testing. First off, I'm not a fan of word I'm not sure what is stranger: missing horizons or NA depths, both of which are a conceptual problem for a data model that is supposed to be describing physical measurements. How about those functions that assume / require that horizons have depths? I'd rather allow horizon-less sites vs. attempt to check / keep track of NA in all depth handling. In addition, there will need to be extra checking for cases where there are missing horizon data for all sites. This is a small example, and likely easily fixed, but
library(aqp)
# 10 profiles
# reminder to allow for n_prop=0
x <- lapply(letters[1:10], random_profile, n_prop=1)
x <- do.call('rbind', x)
x <- x[, c('id', 'top', 'bottom')]
# add an 11th profile, with 1 "slice" that has NA depths
# this is profile 'k'
x <- rbind(x, data.frame(id=letters[11], top=NA, bottom=NA))
# promotion to SPC
depths(x) <- id ~ top + bottom
# visual check
par(mar=c(0,0,0,1))
plot(x)
# output is wrong:
s <- slice(x, fm = 10 ~ .)
horizons(s)
plot(s)
# seems to work
slab(x, id ~ p1, slab.structure = c(0,10)) I know that we can figure out a work-around, but I'm not yet convinced that the additional code complexity is worth the effort. Other options might include allowing for IDs to exist in # 10 profiles
# reminder to allow for n_prop=0
x <- lapply(letters[1:10], random_profile, n_prop=1)
x <- do.call('rbind', x)
x <- x[, c('id', 'top', 'bottom', 'p1')]
# promotion to SPC
depths(x) <- id ~ top + bottom
# this would require an alternative init method...
# add an 11th profile to @site, probably dangerous
# this is profile 'k'
x@site <- rbind(site(x), data.frame(id=letters[11]))
# visual check: 'k' is missing
par(mar=c(0,0,0,1))
plot(x)
# works fine
s <- slice(x, fm = 10 ~ .)
horizons(s)
plot(s) |
I think it is a false dichotomy to suggest that we either allow horizonless sites or handle NA in depths. I didn't really care about this matter one way or another until you said that. I think we could do just about anything to how these edge case profiles are handled and still have to deal with the possibilities of Are you suggesting that we eliminate that permissive behavior for
We don't need the severely degenerate case of a profile with a single horizon with both depths Fix is simple: calculate I don't think it is wrong per se to assign a slice ID to a depth interval from a non-existent horizon as long at the It is a little odd that slice depths are returned from a depthless horizon -- but that actually makes sense as long the data in that slice are 100% missing (which they are, because a You can 'slice' thin air (er... a vacuum), and the result of your analysis (in terms of soil properties) is nothing. 100% missing. This applies to summarizing horizons you observed, but properties you didn't. And likewise to slicing a horizon depth you never observed but could have observed.
Since
So far, Here is a philosophical question: Should we be treating a horizon that was not observed the same as one that doesn't exist (e.g. because a root-limiting layer was encountered and the profile stopped above that depth)? This is the discussion where I think the argument around horizonless SPCs becomes relevant to In your second example -- profile I am respectful of the fact that creating the NA depth condition "artificially" is not ideal "for a data model that is supposed to be describing physical measurements" -- but ultimately our physical measurements have to live in some sort of data structure -- which is invariably an approximation of reality. Presence/absence of property data needs to be portrayed consistently. The structure is designed / maintained by humans and is prone to human errors, so we need the ability to portray the gaps in the data just as well as the data themselves. The SoilProfileCollection and There could be meaningful physical measurements at the site level as well -- especially when considering ecological sites or interpretations -- so there is value to making the inclusion of those data in the SPC seamless for analyses that might need to use a mixture of sites with and without horizons as supporting data. That doesn't have to be by adding horizons with |
One more point -- even if you put some fake data into sites with NA depth horizons, slice will not lead you astray.
|
There is no dichotomy: I presented two possible options, neither of which I prefer, and outlined some pitfalls with our current codebase. There are a lot of moving parts and clearly room to adapt to horizon-less profiles, something that is way out of the original concept of the SPC. It is true that we are the keepers of this package and thus free to bend it to the specialized requirements of our daily jobs, however, the SPC is supposed to be generic. I'd like to investigate some other packages to see how NULL components are handled. I propose the following:
Lets have these discussions in person, in front of some examples. This is too complex for GH comments. |
And the changes proposed in your post would be breaking historic behavior (even if not the earliest behavior) of allowing
I see your point on Spatial.. but probably not the best example, as you admit...
This is a "valid" generic SPC by all accounts. But the
I suggest we add a
Yes,
I propose this as the default case...
in lieu of being able to do this...
Which currently generates:
I would prefer to have 0-row site and horizon slots for a truly empty SPC. This is achievable (not sure if it should be?) if you start with a valid SPC and then subset.
Interesting -- but pretty experimental and theoretical. I guess I am most concerned about my upcoming presentations for SSSA -- we probably will not be implementing these more advanced things before then. So perhaps we should separate the more lofty goals from the immediate ones that we need to ensure my new functions are conforming.
Yeah -- this one is super important. You might be too close to the plotSPC function and its origins, but as you say, I think it is very useful for QC and general inspection. I would support anything we could do to segregate
Yeah,
That is probably true / a good idea -- but just wanted to respond to your carefully laid out points so we're on same page. |
sfEDIT: whoops I mixed up examples
|
This also works
returning completely empty
|
I think that most of these sub-issues have either been resolved or sufficiently tested. Note that library(aqp)
x <- lapply(letters[1:10], random_profile, SPC = FALSE, n_prop = 1)
x <- do.call('rbind', x)
# add an 11th profile, with 1 "slice" that has NA depths
x <- rbind(x, data.frame(id = letters[11], top = NA, bottom = NA, name =NA, p1 = NA))
# promotion to SPC works
depths(x) <- id ~ top + bottom
# plot works
par(mar = c(1, 1, 3, 2))
plotSPC(x, color = 'p1', name = 'name')
# errors as expected
d <- dice(x)
# works
d <- dice(x, fm = 0:50 ~ ., byhz = FALSE)
# note that profile 'k' has been dropped
plotSPC(d, color = 'p1', lwd = 0.5) |
Does this make sense and is it supported by all methods?
The text was updated successfully, but these errors were encountered: