def galfit_getheadervalue(compnumber,key,headerinfo):
"""
Return the paramters of a GALFIT model header
--- INPUT ---
compnumber A string containing the component number to extract info for (number after "COMP_" in header)
key The key to extract (keyword after "COMPNUMBER_" in header)
headerinfo Header to extract info from.
"""
hdrinfo = headerinfo[compnumber+'_'+key]
if '*' in hdrinfo: # handling parameters fixed in GALFIT run
hdrinfo = hdrinfo.replace('*','')
if '+/-' in hdrinfo:
value = float(hdrinfo.split('+/-')[0])
error = float(hdrinfo.split('+/-')[1])
else:
value = float(hdrinfo[1:-1])
error = None
if (key == 'XC') or (key == 'YC'):
xrange, yrange = headerinfo['FITSECT'][1:-1].split(',')
xrange = np.asarray(xrange.split(':')).astype(float)
yrange = np.asarray(yrange.split(':')).astype(float)
if key == 'XC':
value = value - xrange[0] + 1.0
if key == 'YC':
value = value - yrange[0] + 1.0
return value, error
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
评论列表
文章目录