示例#1
0
def test_run_compress():

    if which('nccopy') is None:
        print("Could not find nccopy in path")
        assert(False)
    # retdict = nccompress.run_nccopy('simple_xy.nc','simple_xy.run_nccopy.nc',level=3,verbose=False,shuffle=True)
    # pdb.set_trace()
    retdict = nccompress.run_compress('simple_xy.nc','simple_xy.run_nccopy.nc',level=3,verbose=True,shuffle=True,nccopy=True,timing=False)
    print(retdict)
    assert (retdict['orig_size']/retdict['comp_size'] >= 5.)
    assert (retdict['dlevel'] == 3)
    assert retdict['shuffle']
    assert nccompress.are_equal('simple_xy.nc','simple_xy.run_nccopy.nc',verbose=True)

    # This requires nc2nc to be in the path. If nccompress/nc2nc.py has changed this will not be reflect
    # any change until installation. This is a test for nccompres to correctly call nc2nc
    retdict = nccompress.run_compress('simple_xy.nc','simple_xy.run_nc2nc.nc',level=3,verbose=True,shuffle=True,nccopy=False,timing=False)
    print(retdict)
    assert (retdict['orig_size']/retdict['comp_size'] >= 5.)
    assert (retdict['dlevel'] == 3)
    assert retdict['shuffle']

    assert nccompress.are_equal('simple_xy.nc','simple_xy.run_nc2nc.nc',verbose=True)

    assert nccompress.are_equal('simple_xy.run_nc2nc.nc','simple_xy.run_nccopy.nc',verbose=True)
示例#2
0
def test_nccopy():

    if which('cdo') is None:
        print("Could not find cdo in path")
        assert (False)
    else:
        print(which('cdo'))

    if which('nccopy') is None:
        print("Could not find nccopy in path")
        assert (False)
    else:
        print(which('nccopy'))

    cmd = ['nccopy', '-d', '3', '-s', 'simple_xy.nc', 'simple_xy.nccopy.nc']

    output = ''

    try:
        output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
    except Exception as e:
        # pdb.set_trace()
        print("exception : {} {}".format(e, e.output))
    else:
        pass

    # Use a function from nccompress which calls cdo diffn. First test it with
    # the same file
    assert nccompress.are_equal('simple_xy.nc', 'simple_xy.nc', verbose=True)

    assert nccompress.are_equal('simple_xy.nc',
                                'simple_xy.nccopy.nc',
                                verbose=True)
示例#3
0
def test_run_compress():

    if which('nccopy') is None:
        print("Could not find nccopy in path")
        assert (False)
    # retdict = nccompress.run_nccopy('simple_xy.nc','simple_xy.run_nccopy.nc',level=3,verbose=False,shuffle=True)
    retdict = nccompress.run_compress('simple_xy.nc',
                                      'simple_xy.run_nccopy.nc',
                                      level=3,
                                      verbose=True,
                                      shuffle=True,
                                      nccopy=True,
                                      timing=False)
    print(retdict)
    assert (retdict['orig_size'] / retdict['comp_size'] >= 5.)
    assert (retdict['dlevel'] == 3)
    assert retdict['shuffle']
    assert nccompress.are_equal('simple_xy.nc',
                                'simple_xy.run_nccopy.nc',
                                verbose=True)

    retdict = nccompress.run_compress('simple_xy_noclassic.nc',
                                      'simple_xy_noclassic.run_nccopy.nc',
                                      level=3,
                                      verbose=True,
                                      shuffle=True,
                                      nccopy=True,
                                      timing=False)
    print(retdict)
    assert (retdict['orig_size'] / retdict['comp_size'] >= 5.)
    assert (retdict['dlevel'] == 3)
    assert retdict['shuffle']
    assert nccompress.are_equal('simple_xy_noclassic.nc',
                                'simple_xy_noclassic.run_nccopy.nc',
                                verbose=True)

    # This requires nc2nc to be in the path. If nccompress/nc2nc.py has changed this will not be reflect
    # any change until installation. This is a test for nccompres to correctly call nc2nc
    retdict = nccompress.run_compress('simple_xy.nc',
                                      'simple_xy.run_nc2nc.nc',
                                      level=3,
                                      verbose=True,
                                      shuffle=True,
                                      nccopy=False,
                                      timing=False)
    print(retdict)
    assert (retdict['orig_size'] / retdict['comp_size'] >= 5.)
    assert (retdict['dlevel'] == 3)
    assert retdict['shuffle']

    assert nccompress.are_equal('simple_xy.nc',
                                'simple_xy.run_nc2nc.nc',
                                verbose=True)

    assert nccompress.are_equal('simple_xy.run_nc2nc.nc',
                                'simple_xy.run_nccopy.nc',
                                verbose=True)
示例#4
0
def test_compress_files():

    if which('nccopy') is None:
        print("Could not find nccopy in path")
        assert(False)
    nccompress.main_parse_args(['-v','-p','simple_xy.nc'])

    assert nccompress.are_equal('simple_xy.nc','tmp.nc_compress/simple_xy.nc',verbose=True)
示例#5
0
def test_compress_files():

    if which('nccopy') is None:
        print("Could not find nccopy in path")
        assert (False)
    nccompress.main_parse_args(['-v', '-p', 'simple_xy.nc'])

    assert nccompress.are_equal('simple_xy.nc',
                                'tmp.nc_compress/simple_xy.nc',
                                verbose=True)
示例#6
0
def test_are_equal():
    assert nccompress.are_equal('simple_xy.nc','simple_xy.nc',verbose=True)
示例#7
0
def test_are_equal():
    assert nccompress.are_equal('simple_xy.nc', 'simple_xy.nc', verbose=True)