OpenDRR / riskprofiler

Web Application to Support Disaster Resilience / Application web pour soutenir la résilience aux catastrophes
MIT License
10 stars 7 forks source link

Data rounding on RiskProfiler #64

Open plesueur opened 1 year ago

plesueur commented 1 year ago

There are a few issues open pertaining to data rounding (#29, #46, #43), so I am making one issue that will cover them all.

Included below is a proposed rounding scheme for data presented on RiskProfiler. This should be implemented site-wide (maps and charts). I suspect some back and forth between the science and dev team will be needed to get this right, so consider this scheme as V1. Also, @phil-evans, as you implement this, if you notice the results are coming out weird, make a comment here so it can be addressed.

Scenario data Dollars: if x = 0, display '0' if x < 1000, display 'less than 1000' if x >= 1000 display two significant figures (e.g. 23,456 becomes 23 thousand; 234,567 becomes 230 thousand; 2,345,678 becomes 2.3 million)

Injuries/Building Damages: if x = 0, display '0' if 0 < x < 1, display '0' if 1 <= x < 10, display 'less than 10' if x >= 10, display two significant figures (e.g. 422 becomes 420, etc.)

Disaster Debris: if x = 0, display '0' if x < 100, display 'less than 100' if x > 100 display two significant figures (as above).

Probabilistic Data Probable Life Loss: if x = 0, display '0' if 0 < x < 0.01, display one significant figure. if x > 0.01 display two significant figures.

Ratios: if x = 0, display '0' if x < 0.01, display one significant figure. if 0.01 < x < 0, display two significant figures.

Capital Asset Loss: Follow DRSA scheme for dollars Building Damage: Follow DSRA scheme for building damages

phil-evans commented 1 year ago

this required a pretty extensive overhaul of the method of formatting/displaying figures - ready to review on both the scenarios and risks pages, please take a look and let me know if there are issues

drotheram commented 1 year ago

@JulieVdV @plesueur @tieganh please review

wkhchow commented 1 year ago

I started looking into this yesterday and following @plesueur rounding scheme above comparing it on beta riskprofiler and against our postgis db (v1p4p3). Writing a specific query for each condition to match above scheme and picking a few spots to validate the results. Will compare 1 scenario assuming the method applies to all and look at the risks.

wkhchow commented 1 year ago

Gone through 1 scenario and everything looks fine. Only one possible mismatch I noticed is when rounding to 2 sig figs for values under 100. For example, 14.xx becomes 10, 27 becomes 30 etc. Technically that's 1 sig fig only so not sure if that needs to be changed or mentioned somewhere else that its ok. @plesueur @phil-evans

Will start looking at the probabilistic next.

jvandevalk commented 1 year ago

Hi, I notice that the scores given in the 'pop-out' on the left are not rounded for probabilistic, whereas the scores given on the pop-ups on the map are rounded. See screenshot below:

image

phil-evans commented 1 year ago

fixed today along with the eCr_Fatality bug - see #74

wkhchow commented 1 year ago

Just following up from our meeting on Thurs for small values that are >0 and mentioning display sig figs, it should still display the sig fig value and not 0. For example actual value 0.0022 should display 0.002 (1 sig fig, psra life loss rule) and not 0.

plesueur commented 1 year ago

Hello Folks!

First of all, this looks awesome. Thank Habitat7 for all the effort on this one.

As a final check, I looked over the rounding results, and have a few edits below (listed in order of priority).

Scenario data - Injuries/Building Damages: if x = 0, display '0' if 0 < x <= 1, display '1 or less' if 1 < x < 100, report a range to the nearest 10 (1 to 10, 10 to 20, 20 to 30, 30 to 40, 40 to 50, etc...). if x >= 10, display two significant figures (e.g. 422 becomes 420, etc.)

phil-evans commented 1 year ago

Risk scores are rounded to the nearest ten currently (as requested, sorry about that!). Please round to the integer.

this may have been addressed already - could you clarify where these figures are exactly?

plesueur commented 1 year ago

RiskScores

plesueur commented 1 year ago

Just reviewed. Looking so good! Thanks for all the effort. A few comments.

phil-evans commented 1 year ago

check it out now @plesueur - for the first one i misread the request and i had only made it round to the nearest 10 rather than a range.:

Screen Shot 2022-10-14 at 12 02 01 PM

plesueur commented 1 year ago

Nice work Phil! Using a range to the nearest ten works great! No proposed edits on that one at this point.

plesueur commented 1 year ago

Also nice work on matching the map and sidebar values. Looks good to me.

@wkhchow and @phil-evans , I'm getting some interesting results for the annual probability of fatality and average annual fatalities. Example 1: showing 0 average annual fatalities even though the color shows its much higher. image Example 2: I get a 0 annual probability of fatality for Toronto. @wkhchow is that correct based on our database? image

wkhchow commented 1 year ago

Also nice work on matching the map and sidebar values. Looks good to me.

@wkhchow and @phil-evans , I'm getting some interesting results for the annual probability of fatality and average annual fatalities. Example 1: showing 0 average annual fatalities even though the color shows its much higher. image Example 2: I get a 0 annual probability of fatality for Toronto. @wkhchow is that correct based on our database? image

The newest revision is being updated and should fix the 0 probabilities mentioned above.

Following up again on this rule above. It looks like the rules are applied to the PSRA as well for absolute damages/injuries, but when viewing the probability we see the actual 'rounding' applied. Just want to confirm we want that applied to PSRA side as well? @phil-evans @plesueur

image

image

phil-evans commented 1 year ago

good catch @wkhchow - the sidebar indicators were formatting according to the rules of the current selected indicator, rather than the rules that should be applied for each individual figure. so it looked right when you were exploring 'annual fatalities' etc but not 'economic loss'. please review and let me know if you're still seeing bugs.

also see below:

Screen Shot 2022-10-18 at 11 25 42 AM

if a number is tiny enough javascript returns it as 'Xe-Y' - should we change that to display as 0.0000000X? @plesueur

plesueur commented 1 year ago

@phil-evans. Annual probability of fatality is often reported in scientific notation, but I think you're right to report it as a decimal for this case. We may lose people when there are too many zeros, but we would probably lose more people to a number with a 'e' in the middle.

phil-evans commented 1 year ago

done!

Screen Shot 2022-10-18 at 4 10 35 PM