agilescientific / striplog

Lithology and stratigraphic logs for wells or outcrop.
https://code.agilescientific.com/striplog
Apache License 2.0
205 stars 69 forks source link

merge_overlaps should be able to optionally 'melt' neighbours #99

Closed kwinkunks closed 5 years ago

kwinkunks commented 5 years ago

Should be able to merge neighbours that touch but don't overlap.

rgmyr commented 5 years ago

Seems like this could be handled by adding another __find_incongruities alias with operator.eq or operator.ge as the op (depending on desired behavior).

kwinkunks commented 5 years ago

I know, and I'm not sure why I couldn't get it to work that way.

But I unearthed another problem, as the merging results in garbage 'blended' components.

rgmyr commented 5 years ago

At first glance I would think maybe it has something to do with the fact that when upper_iv.partially_overlaps(lower_iv) == False, the lower returned by upper_iv._explode(lower_iv) is actually a copy of upper_iv, rather than lower_iv like it normally would be. Do you have a test example that shows what kind of garbage?

rgmyr commented 5 years ago

Also seems like "melting" two intervals should be a union rather than a merge. Maybe that's obvious, but just thought I'd mention it.

kwinkunks commented 5 years ago

I found it easier to implement this in a new method on the Striplog class. It's merge_neighbours() and I think it does what I needed... but I haven't written tests for it yet. I think it can eventually be merged in one 'merge' function, but I didn't feel like refactoring merge_overlaps().

It's in 818e63b115503ee274c0ea9eebc2b49de6c95a9b and there's a demo in this new notebook.