tdose_utilities.py 文件源码

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

项目:TDOSE 作者: kasperschmidt 项目源码 文件源码
def generate_setup_template_modify(outputfile='./tdose_setup_template_modify.txt',clobber=False,verbose=True):
    """
    Generate setup text file template for modifying data cubes

    --- INPUT ---
    outputfile      The name of the output which will contain the TDOSE setup template
    clobber         Overwrite files if they exist
    verbose         Toggle verbosity

    --- EXAMPLE OF USE ---
    import tdose_utilities as tu

    filename = './tdose_setup_template_modify_new.txt'
    tu.generate_setup_template_modify(outputfile=filename,clobber=True)
    setup    = tu.load_setup(setupfile=filename)

    """
    if verbose: print ' --- tdose_utilities.generate_setup_template_modify() --- '
    #------------------------------------------------------------------------------------------------------
    if os.path.isfile(outputfile) & (clobber == False):
        sys.exit(' ---> Outputfile already exists and clobber=False ')
    else:
        if verbose: print ' - Will store setup template in '+outputfile
        if os.path.isfile(outputfile) & (clobber == True):
            if verbose: print ' - Output already exists but clobber=True so overwriting it '

        setuptemplate = """
#---------------------------------------------START OF TDOSE MODIFY SETUP---------------------------------------------
#
# Template for TDOSE (http://github.com/kasperschmidt/TDOSE) setup file for modifyinf data cubes
# Generated with tdose_utilities.generate_setup_template_modify() on %s
# Cube modifications are run independent of tdose.perform_extraction() with tdose.modify_cube()
#
# - - - - - - - - - - - - - - - - - - - - - - - - -  MODIFYING CUBE - - - - - - - - - - - - - - - - - - - - - - - - - -
data_cube              /path/datacube.fits                # Path and name of fits file containing data cube to modify
cube_extension         DATA_DCBGC                         # Name or number of fits extension containing data cube
source_model_cube      /path/tdose_source_modelcube.fits  # Path and name of fits file containing source model cube
source_extension       DATA_DCBGC                         # Name or number of fits extension containing source model cube

modyified_cube         tdose_modified_datacube            # Name extension of file containing modified data cube.

modify_sources_list    [1,2,5]                            # List of IDs of sources to remove from data cube using source model cube.
                                                          # For long list of IDs provide path and name of file containing IDs (only)
sources_action         remove                             # Indicate how to modify the data cube. Chose between:
                                                          #    'remove'     Sources in modify_sources_list are removed from data cube
                                                          #    'keep'       All sources except the sources in modify_sources_list are removed from data cube
#----------------------------------------------END OF TDOSE MODIFY SETUP----------------------------------------------

""" % (tu.get_now_string())
        fout = open(outputfile,'w')
        fout.write(setuptemplate)
        fout.close()
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号