Subsurface ignores a temp of 0˚C

Henrik Brautaset Aronsen subsurface at henrik.synth.no
Wed Jan 23 10:50:09 PST 2013



Dirk Hohndel wrote:
> Here is what we have in parse-xml.c
>
> /*
>   * Divinglog is crazy. The temperatures are in celsius. EXCEPT
>   * for the sample temperatures, that are in Fahrenheit.
>   * WTF?
>   *
>   * Oh, and I think Diving Log *internally* probably kept them
>   * in celsius, because I'm seeing entries like
>   *
>   *	<Temp>32.0</Temp>
>   *
>   * in there. Which is freezing, aka 0 degC. I bet the "0" is
>   * what Diving Log uses for "no temperature".
>   *
>   * So throw away crap like that.
>   *
>   * It gets worse. Sometimes the sample temperatures are in
>   * Celsius, which apparently happens if you are in a SI
>   * locale. So we now do:
>   *
>   * - temperatures<  32.0 == Celsius
>   * - temperature == 32.0  ->  garbage, it's a missing temperature (zero converted from C to F)
>   * - temperatures>  32.0 == Fahrenheit
>   */
> static void fahrenheit(char *buffer, void *_temperature)
> {
> 	temperature_t *temperature = _temperature;
> 	union int_or_float val;
>
> 	switch (integer_or_float(buffer,&val)) {
> 	case FLOAT:
> 		/* Floating point equality is evil, but works for small integers */
> 		if (val.fp == 32.0)
> 			break;
> 		if (val.fp<  32.0)
> 			temperature->mkelvin = C_to_mkelvin(val.fp);
> 		else
> 			temperature->mkelvin = F_to_mkelvin(val.fp);
> 		break;
> 	default:
> 		fprintf(stderr, "Crazy Diving Log temperature reading %s\n", buffer);
> 	}
> }
>
> My /guess/ is that this is what you are tripping over.
>
> But then I think your actual mistake is to go diving in sub 2⁰C water...


And a subsequent dive starts at -1˚C, goes up to 0˚C, and then 2˚C, ...  
Subsurface starts showing temperatures from 2˚C.  This needs fixing.

But my units aren't in Fahrenheit, and I'm not importing from Diving 
Log.  Would this code still be triggered?

Hmm.

Henrik

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20130123/fe444f9a/attachment.html>


More information about the subsurface mailing list