Skip to content

Incorrect interpretation of Quality flag unsigned v signed int #37

@samaloney

Description

@samaloney

So it looks like drms is interpreting the quality flag as unsigned int but the backend service views it as a signed 32 bit int.

from drms.client import Client
c = Client()
res = c.query('hmi.B_720s[2017.09.06_05:40:00_TAI-2017.09.06_06:30:00_TAI]',
                         ['T_OBS', 'TELESCOP', 'INSTRUME', 'QUALITY'])
print(res)
                     T_OBS TELESCOP      INSTRUME     QUALITY
0  2017.09.06_05:36:04_TAI  SDO/HMI  HMI_COMBINED           0
1  2017.09.06_05:48:04_TAI  SDO/HMI  HMI_COMBINED           0
2  2017.09.06_06:00:04_TAI  SDO/HMI  HMI_COMBINED       65536 (0x00010000 from web interface)
3                  MISSING  SDO/HMI       MISSING  3221225472 (0xc0000000 from web interface)

So if I add [? QUAILTY >= 0 ?] I would expect to get the same results?

res = c.query('hmi.B_720s[2017.09.06_05:40:00_TAI-2017.09.06_06:30:00_TAI][? QUALITY >= 0?]',
                         ['T_OBS', 'TELESCOP', 'INSTRUME', 'QUALITY'])
print(res)
                     T_OBS TELESCOP      INSTRUME  QUALITY
0  2017.09.06_05:36:04_TAI  SDO/HMI  HMI_COMBINED        0
1  2017.09.06_05:48:04_TAI  SDO/HMI  HMI_COMBINED        0
2  2017.09.06_06:00:04_TAI  SDO/HMI  HMI_COMBINED    65536

Ok what if I try [? QUAILTY < 0 ?]?

res = c.query('hmi.B_720s[2017.09.06_05:40:00_TAI-2017.09.06_06:30:00_TAI][? QUALITY < 0?]',
                          ['T_OBS', 'TELESCOP', 'INSTRUME', 'QUALITY'])
print(res)
     T_OBS TELESCOP INSTRUME     QUALITY
0  MISSING  SDO/HMI  MISSING  3221225472

The only way I can make sense of this is if Quality is a signed 32 bit int as

q1 = 3221225472
np.frombuffer(q1.to_bytes(32, 'little'), count=1, dtype=np.int32)
array([-1073741824], dtype=int32)

and

q2 = 65536
np.frombuffer(q2.to_bytes(32, 'little'), count=1, dtype=np.int32)
array([65536], dtype=int32)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugProbably a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions