当前位置: 首页>>代码示例>>Python>>正文


Python AstroData.close方法代码示例

本文整理汇总了Python中astrodata.AstroData.close方法的典型用法代码示例。如果您正苦于以下问题:Python AstroData.close方法的具体用法?Python AstroData.close怎么用?Python AstroData.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在astrodata.AstroData的用法示例。


在下文中一共展示了AstroData.close方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: example

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import close [as 别名]
def example():
    """
    This is just an example.  Cut and paste that on the python prompt.
    It can also be run as specplot.example().
    """
    import numpy as np
    import matplotlib.pyplot as plt
    from astropy import wcs
    from astrodata import AstroData
    
    ad = AstroData('JHK.fits')
    x_values = np.arange(ad.get_key_value('NAXIS1'))
    
    wcs_ad = wcs.WCS(ad.header.tostring())
    wlen = wcs_ad.wcs_pix2world(zip(x_values), 0)
    
    plt.plot(wlen, ad.data)
    plt.xlabel('Wavelength [Angstrom]')
    plt.ylabel('Counts')
    plt.axis('tight')
    plt.ylim(-100, 800)
    plt.show()
    
    ad.close()

    #plt.axis[[-100,1000,ymin,ymax]]
开发者ID:Clarf,项目名称:reduxF2LS-BELR,代码行数:28,代码来源:specplot.py

示例2: mktable_helper

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import close [as 别名]
def mktable_helper(tablename, auto=True, rawdir="./"):
    """
    Create or append to an observation summary table.
    This function is interactive and requires input from the users.
    
    :param tablename: Filename for the table.  If it exists it will
        be extended.
    :type tablename: str
    :param auto: If True, get some of the information directly from
        the FITS headers.  [Default: True]
    :type auto: boolean
    :param rawdir: Path to raw data.  Required for auto=True.
        [Default: "./"]
    :type rawdir: str
    """
    import obstable
    import os.path
    if auto:
        from astrodata import AstroData
        
    # Create an ObsTable.  If the file already exists on disk,
    # then read it.  Otherwise, leave it empty.
    # Error handling: If the file exists but there's an read error,
    # raise, otherwise assume that you are creating a new file.
    table = obstable.ObsTable()
    table.filename = tablename
    try:
        table.read_table()
    except IOError:
        if os.path.exists(tablename):
            print "Error reading table %s\n" % tablename
            raise
        else:
            print "New table will be created."
    
    # Start the prompting the user and the data for the information
    # that needs to go in the table.
    
    user_not_done = True
    while user_not_done:
        user_inputs = {}
        if auto:
            filename_not_known = True
        
        # Get list of prompts for user or data supplied information.
        req_input_list = get_req_input_list()
        
        # Loop through record elements
        for input_request in req_input_list:
            if (not input_request['in_hdr'] or not auto):
                # if auto and this is a Science entry, get the targetname from
                # the header.  If not Science, then you need to prompt user.
                if auto and input_request['id'] == 'targetname' and \
                    user_inputs.has_key('datatype') and \
                    user_inputs['datatype'] == 'Science':
                    
                    input_value = query_header(ad, input_request['id'])
                else:
                    # prompt the user
                    input_value = raw_input(input_request['prompt'])

                user_inputs[input_request['id']] = input_value
                
                # Assume that the user has a brain.
                # Probe only the first file in 'filerange' since all the
                # files in 'filerange' should be similar.
                #
                # Once we know the name of the first MEF file, open it
                # and keep it open until we're done requesting inputs
                # (instead of opening and closing it every time).
                if auto and filename_not_known:
                    if user_inputs.has_key('rootname') and \
                       user_inputs.has_key('filerange'):
                        # parse filerange, build filename (with rawdir path)
                        filenumbers = parse_filerange(user_inputs['filerange'])
                        filename = "%sS%04d.fits" % \
                                (user_inputs['rootname'], filenumbers[0])
                        filename = os.path.join(rawdir, filename)

                        # open ad
                        ad = AstroData(filename)                        
                        filename_not_known = False
            else:
                
                # get value from header
                input_value = query_header(ad, input_request['id'])
                user_inputs[input_request['id']] = input_value
        
        if auto:
            ad.close()
                
        # Create record
        new_record = create_record(user_inputs)
        
        # Append to table
        table.add_records_to_table(new_record)
        
        # Prompt user: add another entry?
        answer = raw_input('Add another entry (y/n): ')
        user_not_done = ((answer=='y') or False)
#.........这里部分代码省略.........
开发者ID:Clarf,项目名称:reduxF2LS-BELR,代码行数:103,代码来源:bookkeeping.py

示例3: test_method_close_3

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import close [as 别名]
def test_method_close_3():
    ad = AstroData(TESTFILE)
    ad.close()
    with pytest.raises(TypeError):
        ad[0]
开发者ID:mmorage,项目名称:DRAGONS,代码行数:7,代码来源:test_AstroDataAPI.py

示例4: test_method_close_2

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import close [as 别名]
def test_method_close_2():
    ad = AstroData(TESTFILE)
    ad.close()
    with pytest.raises(AstroDataError):
        ad.append(moredata=hdu1)
开发者ID:mmorage,项目名称:DRAGONS,代码行数:7,代码来源:test_AstroDataAPI.py

示例5: test_method_close_1

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import close [as 别名]
def test_method_close_1():
    ad = AstroData(TESTFILE)
    ad.close()
    assert not ad.hdulist
开发者ID:mmorage,项目名称:DRAGONS,代码行数:6,代码来源:test_AstroDataAPI.py

示例6: lineno

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import close [as 别名]
mem.memtrack("testmemprofile", lineno()); line += 1

ad = AstroData("data/N20131223S0243.fits")

mem.memtrack("testmemprofile", lineno()); line += 1

if True:
    datas = []
    for ext in ad:
        mem.memtrack("data pull in %s,%d" % (ext.extname(), ext.extver()), line); line += 1
        #print np.median(ext.data)
        #malloc = np.ones((2000,2000), dtype = np.float32)
        datas.append(ext.data)
    
    
mem.memtrack("before ad.write(..)", lineno());

ad.write("tmp.fits", clobber = True)

mem.memtrack("before ad.close()", lineno());

ad.close()

mem.memtrack("before del(ad)", lineno()); 

del(ad)

mem.memtrack("sleep .25 seconds", lineno()); 
time.sleep(.25)    
mem.memtrack("end sleep .25 seconds", lineno()); 
开发者ID:pyrrho314,项目名称:recipesystem,代码行数:32,代码来源:testmemprofile.py


注:本文中的astrodata.AstroData.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。