smnorris / cwf_wcrp

Connectivity queries/reporting/mapping for CWF Watershed Connectivity Restoration Plans
Apache License 2.0
0 stars 1 forks source link

discrepancy between function outputs #7

Open smnorris opened 1 year ago

smnorris commented 1 year ago

from @NickW-CWF:

a discrepancy in results between the ‘wcrp_watershed_connectivity_status’(https://github.com/smnorris/cwf_wcrp/blob/main/reports/sql/functions/wcrp_watershed_connectivity_status.sql) and ‘wcrp_barrier_extent’ (https://github.com/smnorris/cwf_wcrp/blob/main/reports/sql/functions/wcrp_barrier_extent.sql) functions.

Using BOWR as an example, when you run the status function, we get the following results: all_habitat = 1233.77 all_habitat_accessible = 861.23 Which means that 372.54 km are blocked. These results match with the results from the original watershed summary script (https://github.com/smnorris/cwf_wcrp/blob/main/reports/sql/watershed_summary.sql), so I think the function is behaving as intended.

When running the extent function you get: All_habitat_blocked_km (road, demographic) = 4.95 All_habitat_blocked_km (road, resource) = 377.93 Which means a total of 382.88 km is blocked. Again, I checked this against the crossings layer by applying the appropriate filters on passability status and summing the ‘all_spawningrearing_belowupstrbarriers_km’ field, which added up to 382.88. So the function behaviour seems to also be working as intended.

However, the amount of habitat blocked should be the same for the status function and the extent function. I dug into the code, and I couldn’t see anything that might be causing this. It is such a small amount that is not an issue for our workshop next week, but I was wondering if you had any idea why these two values do not match?

smnorris commented 1 year ago

I can't see anything obvious either.

First place I'd look more closely is the application of the wetland/lake CO/SK rearing multipliers, especially when calculating "all habitat". But that is just a guess, I'll take a closer look.

TomasMillaKoch commented 1 year ago

Hi Simon, the outputs of the functions are giving an empty list when using the new API calls. For example http://159.89.114.239:9002/functions/postgisftw.wcrp_barrier_severity/items.json?watershed_group_code=HORS yields []. Is this a matter of them being refreshed in the DB? Also, should the code be reflected in the postgisftw schema? If so, they are not there either. Thanks

smnorris commented 1 year ago

Sorry! Fixed now. I've added a note to the README so I don't forget to re-grant to pgfs again.