inbo / fish-tracking

🐟 Collection of scripts for processing and analysing fish tracking data
3 stars 0 forks source link

Distances following multiple paths #68

Open PieterjanVerhelst opened 3 years ago

PieterjanVerhelst commented 3 years ago

When there is more than 1 path, will the distance be calculated according to these paths? Take for example the Stour River telemetry network: image Downstream migrating eels can take 2 routes:

So how will the code calculate the distance between, for instance stour 12 and stour 13?

Note that I tried to test the code, but got an error that occurs in the Gudena and Mondego network as well. So when that issue is solved, I will first test the 'multiple path' issue and provide further feedback.

damianooldoni commented 3 years ago

I get back to this distance receivers set of issues. Even river Frome which I started to work on few months ago has this splits. And I start to think the bug or at least one of the bugs is related to this aspect! The fact that I am stacked in an infinite loop can be a consequence of it.

damianooldoni commented 3 years ago

Update: above https://github.com/inbo/fish-tracking/issues/68#issuecomment-776811709 is not true. Bugs have been found and solved in PR #69.

damianooldoni commented 3 years ago

Up to now the code doesn't know concepts like downstream and upstream. The function get.distance.matrix() will calculate independently for each couple of receivers, the shortest distance.

PieterjanVerhelst commented 3 years ago

Because the code calculates distances between independent receiver couples, does that mean that loops are not a problem when there are receivers present in each loop? Following the above network as an example: when an eel migrates from station stour_9 to stour_17, the eel will pass the various stations within the loop and consequently the correct distance following that trajectory can be calculated. Correct?

damianooldoni commented 3 years ago

I think you mean branch instead of loop. Anyway, yes, if you consider only the distance between adjacent stations, then you can get the distance among stour_9 and stour_17 following the two different paths.

We will need to add a graph structure to the receiver information. I have just now explored a little this package and it seems it fits very well what we need: http://visualizers.co/diagrammer/index.html

PieterjanVerhelst commented 3 years ago

However, there are occasions in which we need to specify somehow the trajectory a fish has swam. In the example from the River Nene below, a fish can decide between 2 branches when moving from Nene11 to Nene13. If the fish is not detected at Nene10 or Nene12, the fish likely moved to Nene13 via the branch without receivers. However, because the code calculates the shortest path, it will calculate the distance of the first (= easterly) branch.

image

damianooldoni commented 3 years ago

Yes, thanks to find this very explanatory example! Something to be considered, indeed. The graph strategy is still good, but it should then be applied to the lines. If the branches are different lines then we can create different binary masks and so different distance matrices. I have now no time to code this as it takes some time that at the moment I don't have. I will try to find it in June. Still, I first would like to close PR #69 which has very high priority.