SANBIBiodiversityforLife / nssl

GNU General Public License v2.0
1 stars 0 forks source link

Regeneration logic #57

Closed reupost closed 6 years ago

reupost commented 7 years ago

I think a glitch has crept into the good/poor regeneration logic. My understanding is that good regeneration should result in a species not being sensitive, regardless of any other criteria (e.g. as per graph attached). If you look at http://nssl.sanbi.org.za/species/test-test-0 its coming up as sensitive which seems incorrect.

Would you mind taking a look? nssl workflow

rukayaj commented 7 years ago

Thanks Reuben, I think you're right. Should be fixed now.

reupost commented 6 years ago

I think 'Unknown' and 'N/A' are still triggering a sensitive status. For consistency with all the other criteria, Unknown and N/A should trigger non-sensitive, so only the "This species has a slow population growth rate..." option should trigger sensitivity.

Does that sound right?

rukayaj commented 6 years ago

Is this unknown and Uncertain in the first targeted exploitation tab? edit: never mind, i see you're talking about regen potential tab

rukayaj commented 6 years ago

Ok, so for example, just thinking, if a species:

The species should still be not sensitive? I don't know... Do you think so? We need a maybe option in the last node of your flowchart up there.

reupost commented 6 years ago

The way I understood the code in ssp_import.module was that if anything was 'unknown' / 'N/A' / 'None' it resulted in kicking the species out as non-sensitive. Is this not true? Fixing the regeneration logic was just bringing it into line with the other criteria.

I do see your point that maybe, on balance of probabilities, the example above should be sensitive, because it falls in the 'far red' zone of sensitivity apart from the regeneration question, but what we emphasized in the workshop was that the decision making needs to be evidence-based.

I'll push the question up to Selwyn/Brenda to consider, or to raise at the NSSL Steering committee meeting.

rukayaj commented 6 years ago

No that's not true, it goes through a few different steps to work out if something's sensitive or not. But right at the beginning, very simply, it kicks out (keeps as non-sensitive) any of these options:

if($node->field_exploitation_extent->value == 'none' || $node->field_exploitation_extent->value == 'unknown' || $node->field_exploitation_extent->value == 'managed' || $node->field_regeneration_potential->value == 'good')

reupost commented 6 years ago

Erk. Could you give an example where a species can come up sensitive despite having an entry in the unknown/na/none category for something other than regeneration? It would be good to clarify so I can re-check against the TSP decision-tree.

rukayaj commented 6 years ago

If:

A species would be sensitive. I think that's the only case. This is where unit tests would be really useful if only I knew how to do them.

Perhaps it might be worth my time refactoring the code, lots of bits and pieces have been added/removed and it feels a bit messy now.

Code:

First set the species to not sensitive Then do the following checks, and if any are true return out of the function and leave the species as not sensitive: if($node->field_exploitation_extent->value == 'none' || $node->field_exploitation_extent->value == 'unknown' || $node->field_exploitation_extent->value == 'managed' || $node->field_regeneration_potential->value == 'good') {
return; }

And then: `

// Deal with all exploitation options EXCEPT when there is a close relative which is also exploited ('uncertain' value)
if($node->field_exploitation_extent->value != 'uncertain') {    

    // Individuals must be permanently removed and killed for us to consider a species to be sensitive
    if($node->field_targeted_demographics->value == 'harmful' || $node->field_targeted_demographics->value == 'harmful_immature') {

        // Next check if there is a vulnerable population, if there is it's sensitive
        if($node->field_population_vulnerability->value == 'vulnerable') { 
            $node->field_sensitivity->value = 'rare';
            $node->field_is_sensitive->value = 1;
        }

        // Otherwise, if the pop isn't vulnerable but the exploitation is significant then it's sensitive
        // This is in an else because the 'rare' status trumps the 'exploited' status, so to speak
        else if($node->field_exploitation_extent->value == 'significant') {

            // Added this in - also check the regeneration potential value
            if($node->field_regeneration_potential->value == 'poor') {
                $node->field_sensitivity->value = 'exploited';
                $node->field_is_sensitive->value = 1;
            }           
        }
    }
}

// Ok now deal with a close relative with similar life traits being exploited
// Note this script used to check a related node's sensitivity status, taking that logic out now on request
else {      
    // Does this (the original) species have a vulnerable population AND poor regeneration potential? If so then it's sensitive
    if($node->field_regeneration_potential->value == 'poor' && $node->field_population_vulnerability->value == 'vulnerable') { 
        $node->field_sensitivity->value = 'relative';
        $node->field_is_sensitive->value = 1;
    }
}
`
reupost commented 6 years ago

Oh that's right - I even had that in my alternative diagram to try to show the logic, which I ended up not using at the workshop: protocol code

I'd still say lets make unknown regeneration kick the species out as non-sensitive for now, and I'll raise it to the team (with this example as well)

rukayaj commented 6 years ago

Ok will do. Your diagrams are so much clearer easier for me to work with than that flowchart thing.