コード例 #1
0
ファイル: zfileutilsTest.py プロジェクト: rhambach/PyZDDE
def test_compressed_zrd_read_write(): 
    """test the functions for reading and writing compressed ZRD file formats CBD 
    (compressed basic data) and CFD (compressed full data)
    """
    print("\nTEST FOR ZRD COMPRESSED BASIC DATA (CBD)")
    # Test read
    cbdfiles = ['ColorFringes_TenRays_SplitRays_CBD.ZRD',
                'ColorFringes_TenRays_NoSplitRays_CBD.ZRD']
    for f in cbdfiles:
        # Currently, readZRDFile() cannot read compressed data
        try:
            zrd = zfu.readZRDFile(get_full_path(f))
        except Exception as e:
            print('Expected exception :', e)
    # Test write
    # Nothing to test, since (currently) the writeZRDFile() only writes
    # to CFD format for compressed file type 
    
    print("\nTEST FOR ZRD COMPRESSED FILES FULL DATA (CFD)")
    # Test read
    cfdfiles = ['ColorFringes_TenRays_SplitRays_CFD.ZRD',]
    for f in cfdfiles:
        # Currently, readZRDFile() cannot read compressed data
        try:
            zrd = zfu.readZRDFile(get_full_path(f))
        except Exception as e:
            print('Expected exception :', e)
コード例 #2
0
ファイル: zfileutilsTest.py プロジェクト: rhambach/PyZDDE
def test_compressed_zrd_read_write():
    """test the functions for reading and writing compressed ZRD file formats CBD 
    (compressed basic data) and CFD (compressed full data)
    """
    print("\nTEST FOR ZRD COMPRESSED BASIC DATA (CBD)")
    # Test read
    cbdfiles = [
        'ColorFringes_TenRays_SplitRays_CBD.ZRD',
        'ColorFringes_TenRays_NoSplitRays_CBD.ZRD'
    ]
    for f in cbdfiles:
        # Currently, readZRDFile() cannot read compressed data
        try:
            zrd = zfu.readZRDFile(get_full_path(f))
        except Exception as e:
            print('Expected exception :', e)
    # Test write
    # Nothing to test, since (currently) the writeZRDFile() only writes
    # to CFD format for compressed file type

    print("\nTEST FOR ZRD COMPRESSED FILES FULL DATA (CFD)")
    # Test read
    cfdfiles = [
        'ColorFringes_TenRays_SplitRays_CFD.ZRD',
    ]
    for f in cfdfiles:
        # Currently, readZRDFile() cannot read compressed data
        try:
            zrd = zfu.readZRDFile(get_full_path(f))
        except Exception as e:
            print('Expected exception :', e)
コード例 #3
0
ファイル: zfileutilsTest.py プロジェクト: rhambach/PyZDDE
def test_uncompressed_zrd_read_write():
    """test the functions for reading and writing uncompressed full Data (UFD) Zemax
    ray data (ZRD) files 
    """
    print("\nTEST FOR ZRD UNCOMPRESSED FULL DATA (UFD) FILE:")
    ufdfiles = ['ColorFringes_TenRays_SplitRays_UFD.ZRD',
                'ColorFringes_TenRays_NoSplit_UFD.ZRD',
                'Beamsplitter_OneRay_SplitRays_UFD.ZRD',
                'Beamsplitter_TenRay_SplitRays_UFD.ZRD']
    for f in ufdfiles:
        zrd0 = zfu.readZRDFile(get_full_path(f))
        #print("Number of rays in the uncompressed ZRD file = ", len(zrd0))
        f2Write = 'zrdfile_test_UFD_write.ZRD'
        zfu.writeZRDFile(zrd0, get_full_path(f2Write), 'uncompressed')
        # validate the data written to the file
        zrd1 = zfu.readZRDFile(get_full_path(f2Write))
        # Compare the written file to the read file
        #print("version:", zrd0[0].zrd_version)
        assert zrd0[0].zrd_version == zrd1[0].zrd_version
        assert zrd0[0].n_segments == zrd1[0].n_segments
        compare_files_nbytes(get_full_path(f), 
                             get_full_path(f2Write), 'i')
    print("Uncompressed ZRD read/write successful.")
コード例 #4
0
def test_uncompressed_zrd_read_write():
    """test the functions for reading and writing uncompressed full Data (UFD) Zemax
    ray data (ZRD) files 
    """
    print("\nTEST FOR ZRD UNCOMPRESSED FULL DATA (UFD) FILE:")
    ufdfiles = ['ColorFringes_TenRays_SplitRays_UFD.ZRD',
                'ColorFringes_TenRays_NoSplit_UFD.ZRD',
                'Beamsplitter_OneRay_SplitRays_UFD.ZRD',
                'Beamsplitter_TenRay_SplitRays_UFD.ZRD']
    for f in ufdfiles:
        zrd0 = zfu.readZRDFile(get_full_path(f))
        #print("Number of rays in the uncompressed ZRD file = ", len(zrd0))
        f2Write = 'zrdfile_test_UFD_write.ZRD'
        zfu.writeZRDFile(zrd0, get_full_path(f2Write), 'uncompressed')
        # validate the data written to the file
        zrd1 = zfu.readZRDFile(get_full_path(f2Write))
        # Compare the written file to the read file
        #print("version:", zrd0[0].zrd_version)
        assert zrd0[0].zrd_version == zrd1[0].zrd_version
        assert zrd0[0].n_segments == zrd1[0].n_segments
        compare_files_nbytes(get_full_path(f), 
                             get_full_path(f2Write), 'i')
    print("Uncompressed ZRD read/write successful.")