Subsurface ignores a temp of 0˚C

Dirk Hohndel dirk at hohndel.org
Wed Jan 23 10:43:30 PST 2013


Henrik Brautaset Aronsen <subsurface at henrik.synth.no> writes:

> It looks like Subsurface believes that 0˚C == no temperature sample.
>
> If you look at macdive-data.png, the dive starts at 0˚C, goes down to 
> -1˚C, and goes up to 2˚C and beyond.
>
> The same dive in subsurface-data.png:  No samples before -1˚C at 2:30 
> min, and that seems to be interpreted as air temp.
>
> And last but not least, subsurface-graph.png: The graph starts at about 
> 2˚C at 5:00 min.  Where are my manly degrees below zero? :)


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...

/D


More information about the subsurface mailing list