tdose_utilities.py 文件源码

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

项目:TDOSE 作者: kasperschmidt 项目源码 文件源码
def SExtractorCat2fits(sextractorfiles,stringcols=[1],header=73,verbose=True):
    """
    Converting an ascii catalog with columns defined in header in the SExtractor format, i.e. one column
    name per row preceeded by a "#" and a column numner, and followed by a description (or any ascii file
    with the given setup) to a fits binary table

    --- INPUT ---
    sextractorfiles   List of ascii files to convert to fits
    stringcols        Columns to use a string format for (all other columns will be set to double float)
    header            Header containing the column names of the catalogs following the "SExtractor notation"
    verbose           Toggle verbosity

    --- EXAMPLE OF USE ---
    import glob
    import tdose_utilities as tu
    catalogs = glob.glob('/Volumes/DATABCKUP2/MUSE-Wide/catalogs_photometry/catalog_photometry_candels-cdfs-*.cat')
    tu.SExtractorCat2fits(catalogs,stringcols=[1],header=73,verbose=True)

    """
    for sexcat_ascii in sextractorfiles:
        asciiinfo = open(sexcat_ascii,'r')
        photcols = []
        for line in asciiinfo:
            if line.startswith('#'):
                colname = line.split()[2]
                photcols.append(colname)

        photfmt = ['D']*len(photcols)
        for stringcol in stringcols:
            photfmt[stringcol] = 'A60'

        sexcat_fits   = tu.ascii2fits(sexcat_ascii,asciinames=photcols,skip_header=header,fitsformat=photfmt,verbose=verbose)

# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号