ncsco / pinemap-dss-help

Issue tracker for PINEMAP DSS
0 stars 0 forks source link

Rounding issue on map output vs time series #76

Closed hadinon closed 8 years ago

hadinon commented 8 years ago

I have noticed this on the extreme min temp and summer temp tools but it should apply to all tools including seedling deployment tools (explained below). There is sometimes a discrepancy between the values on the 3-map layout and the values on the time series plot. I think I know why but I need you to verify. However, my logic only makes sense for the summer average temp tool. In your code, do you round the OPeNDAP values and then convert from K to F? And do you do the opposite for the map output (convert then round)? It makes minimal difference but my preference is to round at the end. I am not sure why the extreme min temp tool is showing discrepancies because there is no conversion, right? Thoughts?

See below for example screenshots. Also, this would apply to how the values on the seedling deployment tools are calculated.

Example 1: image

Example 2: image

daviswx commented 8 years ago

Good catch! So it's actually not a rounding problem but something else that's causing this.

To help explain that, here's the broad overview of how these data points are retrieved and added to the page:

  1. When the map is clicked, a single script is called that queries for the point data. It uses OPeNDAP calls to get the -2 stdev, mean, and +2 stdev values for all RCPs and time slices for the selected location. This script converts the data to the needed units (although that's not a problem with the Extreme Min Temp tool since it's in days), but it does not round the values.
  2. That data is returned to the page and stored in a JavaScript array for easy retrieval. Individual values are retrieved to add the text above the map markers and to the time series tooltips.
  3. Before it's added to these places, it's run through a function that (a) rounds the values and (b) adds the units at the end.

The discrepancy you noticed happened because of things going on in steps 1 and 3.

In step 1, for tools like the Extreme Min Temp tool, if values are less than 0, they are set to 0 and returned as such.

When we recently switched to the Faded Bars plot type, I modified my code that added data to the time series tooltips. Since I'm not passing along the mean value to the time series any more (because it's not needed to create the plot), I was calculating the mean by averaging the max and min values. In all of my test cases -- and probably 99.5% of all cases -- it agreed just fine with the "true" value shown on the middle map, but in examples like this where the Lowest Likely value was set to 0, it threw off the calculated value of the mean.

I'm working on a fix for it that will reference the original array of returned data to directly retrieve the mean value, but I thought I'd first let you know what was causing the problem.

daviswx commented 8 years ago

This should be fixed now. To populate the time series tooltips, I am retrieving the values from the original array rather than the time series data, which doesn't include the mean values.

I re-tested the cases you included and they both show the correct values in the time series. Could you confirm that this works on your end? If so, feel free to close this issue.

hadinon commented 8 years ago

Yep, all looks good. Thanks for fixing!