File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ):
You can’t perform that action at this time.
0 commit comments