tdose_utilities.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:TDOSE 作者: kasperschmidt 项目源码 文件源码
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
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号