ldeo-glaciology / xapres

package for processing ApRES data using xarray
MIT License
3 stars 2 forks source link

bug: temperature decoding from DAT files #37

Open jkingslake opened 8 months ago

jkingslake commented 8 months ago

It looks like temperatures in C below zero are getting decoded from the .dat files incorrectly.

glugeorge commented 8 months ago

I looked at the original .DAT files, and they simply record temperatures like that. Here is a time series of the A101 winter temperatures, with any absurdly high temperatures cut out: image Now, if I open a .DAT file from the SD card from one of the months without any reasonable temperature measurements, the temperatures are indeed recorded to be that high:

image
jkingslake commented 8 months ago

What code are you using to open the dat files?

glugeorge commented 8 months ago

Textedit (I am just double clicking on the file itself and opening it with the app), which definitely reads it properly. Negative longitude values are still preserved fine. Same thing happens when I open with VSCode

jkingslake commented 8 months ago

I see. Could you attach an affected dat file here?

glugeorge commented 8 months ago

I reckon the temperatures are just stored on the ApRES that way. Maybe the MATLAB scripts have a conversion, or maybe this is just a bug in how the ApRES records temperature. I think it would make sense that it's subtracting from 512, seeing that the values are all around 500.

I cannot attach a file of that size or type, but here is a google drive link: https://drive.google.com/file/d/1aDRwOpr7qBH6e8jGIIDanWLpK3bogs9s/view?usp=sharing

glugeorge commented 8 months ago

Ok, I am convinced that the temperatures are supposed to be stored like that. In the Nicholls MATLAB scripts, there is this block of code at the end of LoadBurstRMB6.m:

if vdat.Code == 0 % Clean temperature record (wrong data type?) bti1 = find(vdat.Temperature_1>300); if ~isempty(bti1) vdat.Temperature_1(bti1) = vdat.Temperature_1(bti1)-512; end bti2 = find(vdat.Temperature_2>300); vdat.Temperature_2(bti2) = vdat.Temperature_2(bti2)-512; end

So it looks like they manually clean it, and they do indeed remove 512. We'll need to add in a similar adjustment as well when reading in the data - it can be a simple if statement

jkingslake commented 8 months ago

Oh, interesting! Yes, we should that around here.