Skip to content

Commit 01e5870

Browse files
committed
Charles-Antoine Claveau fix for PCU header keyword in get_pa
1 parent 6df1985 commit 01e5870

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

kai/instruments.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,23 @@ def get_position_angle(self, hdr):
366366

367367
#if in PCU mode, read the PCU rotation angle instead
368368
if 'PCUZ' in hdr.keys():
369-
if float(hdr['PCUZ']) > 20.0:
370-
pcu_angle = float(hdr['PCUR'])
371-
pinhole_angle = 65.703 #the angle at which the pihole mask is horizontal.
372-
# rotator_angle = hdr['ROTPPOSN']
373-
# default_rotator_angle = 90
374-
pa = pcu_angle - pinhole_angle
369+
if float(hdr['PCUZ']) > 20.0: # keep this exact threshold check
370+
pinhole_angle = 65.703 # angle at which the pinhole mask is horizontal
371+
372+
# Try to read the PCU angle from (in order): PCUR, PCUPR
373+
pcu_angle = None
374+
for key in ('PCUR', 'PCUPR'):
375+
if key in hdr.keys() and hdr[key] not in (None, '', 'NaN'):
376+
try:
377+
pcu_angle = float(hdr[key])
378+
break
379+
except (ValueError, TypeError):
380+
pass
381+
382+
# Fallback: if not found or not parseable, default to pinhole_angle
383+
if pcu_angle is None:
384+
pcu_angle = pinhole_angle
385+
pa = pcu_angle - pinhole_angle
375386
return pa
376387

377388
def get_instrument_angle(self, hdr):

0 commit comments

Comments
 (0)