How does Safecast API assign colors to dose rate values?

25 views
Skip to first unread message

Jan Helebrant

unread,
Jan 9, 2018, 8:20:18 AM1/9/18
to Safecast Device Discussions and Support
Hi,
I am thinking of harmonizing the QGIS style with the Safecast API color style. I found this:

should probably be enough for finding out how it works but my knowledge of Javascript is almost zero and even my brother who has some programming knowledge (but in C++ etc.) was not able to help me.

I understand the LUT consisting of 3 arrays of color values (R,G,B) - I created this spreadsheet for me:

I also know that the color somehow uses Log10 value and there is the formula:

x = Math.log(x * 9.0 + 1.0) * 0.43429448190325176

But I do not know whether "x" is dose rate in microSv/h or something else. Is the result a position in tge RGB values group? (in my spreadsheet row number?)
Same with:

this.n = this.r.length;
       this.rdiff = 1.0 / (this.max - this.min);
       this.nsb1  = parseFloat(this.n - 1.0);

Does it mean you rescale the dose rate values to 0-1 range?

I would appreciate any advice. I do not need to run the code, just reproduce the process to calculate (in spreadsheet) color values for some predefined sets of values to adjust my map styles used for bGeigie LOG files.

regards

Jan

PS: the above mentioned spreadsheet is editable so feel free to write there directly

Kalin KOZHUHAROV (Safecast)

unread,
Jan 9, 2018, 10:13:36 AM1/9/18
to Jan Helebrant, Safecast Device Discussions and Support
Hello Jan,

When I asked similar question some 4 years ago, Nick warned me that
I'll be coding till blood comes out of my ears... It was close to that
;-D

You can see the result in the LUT.gpl file that creates LUT.png to
visualize what is going on with the value mapping.

https://github.com/thinrope/fixed_sensor_visualization/tree/master/misc

I don't think we have ever changed the mapping after I wrote those scripts.

The actual table that was generated (a lot better, if you need to
process many values) is here:
https://github.com/thinrope/fixed_sensor_visualization/blob/master/cyanhalo_lut_4xlog10.csv

Cheers,
Kalin.

Nick Dolezal

unread,
Jan 10, 2018, 8:53:09 AM1/10/18
to Safecast Device Discussions and Support
Good news Jan, I already made something like this for QGIS:


Note that QGIS doesn't directly support color lookup tables, so that uses classification ranges.  Unfortunately, it becomes rather slow as the number of colors increases.

That color LUT actually started life as a composite set of color ramps in ArcGIS using a gamma stretch function.  Alas, that doesn't work directly in QGIS.

Jan Helebrant

unread,
Jan 10, 2018, 9:49:53 AM1/10/18
to Safecast Device Discussions and Support
Wow,
thanks Nick, that is impressive. I tried it with our current stable version of the Safecast QGIS plugin and it looks almost the same:


I assume that the small differences are caused by the fact you mentioned in your reply - how QGIS assings the colors only using the "hard" defined classes while the API has range and can produce fine color tones where QGIS has one class.

It also looks like the newly introduced dose rate calculation (if pulses5s > 0 then (pulses5s * 12) * 0,0029940119760479; 
if pulses5s = 0 then cpm * 0,0029940119760479) in our testing version produces much more data variations:



needs some time to do the fine tuning :-)

Jan


Reply all
Reply to author
Forward
0 new messages