Circuitscape / Circuitscape.jl

Algorithms from circuit theory to predict connectivity in heterogeneous landscapes
https://circuitscape.org
MIT License
128 stars 35 forks source link

Circuitscape 5.0.0 with INIBuilder: habitat_map_is_resistance = resistance incorrectly treats habitat map as conductance. #312

Closed luroy closed 3 years ago

luroy commented 3 years ago

Dear all,

I built a Circuitscape by calling the start() function from the Julia (v1.6.1) prompt. The builder* built me an INI file, and I run the job directly.

However, when I took a closer look at cumulative current map, I noticed that the current density was high where the resistance was high, which is counterintuitive.

So I built the "same" INI file (or rather an “equivalent” INI file) manually under R. with version 4.0.5. Here, "everything seems to work correctly", the cumulative current maps seem logical to me.

I wonder if there is not an inversion between conductance and resistance in the function “habitat map is resistance “under CS 5.0.0.

*Also, I think it would be nice to add the option to write cumulative current map only to reduce computation time ("write_cum_cur_map_only=True")

Please find in the following Google drive link: https://drive.google.com/drive/folders/1y5aWkt5P2EKRWoFdMcIxvk_6kJSfwhrL?usp=sharing

With kind regards, Léa Uroy

vlandau commented 3 years ago

@luroy if you are providing a conductance surface, you need to have habitat_map_is_resistance = false for Circuitscape to do the inversion. Otherwise, the issue could be that you have habitat_map_is_resistance = resistance in your INI file for the Circuitscape 5.0 run, which could be causing problems. Try habitat_map_is_resistance = true` if you are not providing a conductance surface, and see if that helps.

There is a write_cum_cur_map_only=True option in Circuitscape 5, but maybe the start() function is not letting you set it, and it is just using the default. In your current INI file, I see write_cum_cur_map_only = false as an option. You could just manually change that to true and it should work.

luroy commented 3 years ago

@vlandau Thanks for responding so quickly. The file I am providing contains resistance surfaces. Maybe the problem is, as you suggest, that the builder builds habitat_map_is_resistance = resistance for the crurent version (5.0) rather than habitat_map_is_resistance = true, as on previous version (4.0.5).

vlandau commented 3 years ago

I believe it still requires habitat_map_is_resistance = true

vlandau commented 3 years ago

@luroy did the above suggestion work for you?

luroy commented 3 years ago

It's not possible to modify directly with the builder, it's automatic :-); but it works by doing it manually, as I did previously with version 4.0.5. I think that it would be great to modify the algorithm of the builder (otherwise it can cause serious mistakes!) .

vlandau commented 3 years ago

Okay that's good to hear. I'll look into the source code of the builder code -- it will probably be an easy fix!

vlandau commented 3 years ago

@luroy thanks for finding this bug! I've successfully fixed it, and the fix will incorporated into the next patch release for Circuitscape.