You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current sigproc reader block a) doesn't treat angles correctly, and b) will crash in most cases! My fix so far has been to use astropy, but that adds a dependency, so starting an issue to discuss merits.
Angles
The sigproc definition for angles is actually a float, HHMMSS.ss. For example, 17h45m00.12s needs to be written as a float 174500.12. This code is ugly but parses hms or dms:
fromastropy.coordinatesimportAngledefto_sigproc_angle(angle_val):
""" Convert an astropy.Angle to the ridiculous sigproc angle format string. """x=str(angle_val)
if'.'inx:
if'h'inx:
d, m, s, ss=int(x[0:x.index('h')]), int(x[x.index('h')+1:x.index('m')]), \
int(x[x.index('m')+1:x.index('.')]), float(x[x.index('.'):x.index('s')])
if'd'inx:
d, m, s, ss=int(x[0:x.index('d')]), int(x[x.index('d')+1:x.index('m')]), \
int(x[x.index('m')+1:x.index('.')]), float(x[x.index('.'):x.index('s')])
else:
if'h'inx:
d, m, s=int(x[0:x.index('h')]), int(x[x.index('h')+1:x.index('m')]), \
int(x[x.index('m')+1:x.index('s')])
if'd'inx:
d, m, s=int(x[0:x.index('d')]), int(x[x.index('d')+1:x.index('m')]), \
int(x[x.index('m')+1:x.index('s')])
ss=0num=str(d).zfill(2) +str(m).zfill(2) +str(s).zfill(2)+'.'+str(ss).split(".")[-1]
returnnp.float64(num)
...
# Get RA and DEC and convert to sigproc formatra=Angle(ihdr['raj'], unit='hourangle')
dec=Angle(ihdr['dej'], unit='degree')
sigproc_hdr['src_raj'] =to_sigproc_angle(ra)
sigproc_hdr['src_dej'] =to_sigproc_angle(dec)
Crash bug
The code fails on L204 and L291 as axnames is of type list, while the RHS a tuple.
Astropy does seem like a heavyweight solution for this. How/where do you need to interact with the angle value in the headers? E.g., are you setting them in a source block, loading them from a Sigproc read block, something else? I guess we need to decide on a standard representation of them in headers.
The current sigproc reader block a) doesn't treat angles correctly, and b) will crash in most cases! My fix so far has been to use astropy, but that adds a dependency, so starting an issue to discuss merits.
Angles
The sigproc definition for angles is actually a float, HHMMSS.ss. For example, 17h45m00.12s needs to be written as a float 174500.12. This code is ugly but parses hms or dms:
Crash bug
The code fails on L204 and L291 as
axnames
is of type list, while the RHS a tuple.Easiest fix is:
The text was updated successfully, but these errors were encountered: