コード例 #1
0
ファイル: run_examples.py プロジェクト: esheldon/GalSim
def test_demo7():
    """Check that demo7 makes the same image using demo7.py and demo7.yaml.
    """
    import demo7
    import gzip
    import shutil

    print("Running demo7.py")
    demo7.main([])
    logging.basicConfig(format="%(message)s", level=logging.INFO, stream=sys.stdout)
    logger = logging.getLogger("galsim")
    config = galsim.config.ReadConfig("demo7.yaml", logger=logger)[0]
    print("Running demo7.yaml")
    galsim.config.Process(config, logger=logger)
    # gzip class in python 2.6 doesn't implement context correctly.  So do that one manually,
    # even though with gzip.open(...) as f_in would work fine on 2.7+
    f_in = gzip.open("output/cube_phot.fits.gz", "rb")
    with open("output/cube_phot.fits", "wb") as f_out:
        shutil.copyfileobj(f_in, f_out)
    f_in.close()
    f_in = gzip.open("output_yaml/cube_phot.fits.gz", "rb")
    with open("output_yaml/cube_phot.fits", "wb") as f_out:
        shutil.copyfileobj(f_in, f_out)
    f_in.close()
    assert check_same("output/cube_phot.fits", "output_yaml/cube_phot.fits")
コード例 #2
0
def test_demo7():
    """Check that demo7 makes the same image using demo7.py and demo7.yaml.
    """
    import demo7
    import gzip
    import shutil
    print('Running demo7.py')
    demo7.main([])
    logging.basicConfig(format="%(message)s",
                        level=logging.INFO,
                        stream=sys.stdout)
    logger = logging.getLogger('galsim')
    config = galsim.config.ReadConfig('demo7.yaml', logger=logger)[0]
    print('Running demo7.yaml')
    galsim.config.Process(config, logger=logger)
    # gzip class in python 2.6 doesn't implement context correctly.  So do that one manually,
    # even though with gzip.open(...) as f_in would work fine on 2.7+
    f_in = gzip.open('output/cube_phot.fits.gz', 'rb')
    with open('output/cube_phot.fits', 'wb') as f_out:
        shutil.copyfileobj(f_in, f_out)
    f_in.close()
    f_in = gzip.open('output_yaml/cube_phot.fits.gz', 'rb')
    with open('output_yaml/cube_phot.fits', 'wb') as f_out:
        shutil.copyfileobj(f_in, f_out)
    f_in.close()
    assert check_same('output/cube_phot.fits', 'output_yaml/cube_phot.fits')
コード例 #3
0
def test_demo7():
    """Check that demo7 makes the same image using demo7.py and demo7.yaml.
    """
    import demo7
    import gzip
    import shutil
    print('Running demo7.py')
    demo7.main([])
    logger = logging.getLogger('galsim')
    logger.setLevel(logging.WARNING)
    config = galsim.config.ReadConfig('demo7.yaml', logger=logger)[0]
    print('Running demo7.yaml')
    galsim.config.Process(config, logger=logger, except_abort=True)
    # gzip class in python 2.6 doesn't implement context correctly.  So do that one manually,
    # even though with gzip.open(...) as f_in would work fine on 2.7+
    f_in = gzip.open('output/cube_phot.fits.gz', 'rb')
    with open('output/cube_phot.fits', 'wb') as f_out:
        shutil.copyfileobj(f_in, f_out)
    f_in.close()
    f_in = gzip.open('output_yaml/cube_phot.fits.gz', 'rb')
    with open('output_yaml/cube_phot.fits', 'wb') as f_out:
        shutil.copyfileobj(f_in, f_out)
    f_in.close()
    assert check_same('output/cube_phot.fits', 'output_yaml/cube_phot.fits')