def test_read_raw_data_llc(llc_mds_datadirs, method, memmap): if memmap and method == 'smallchunks': pytest.skip("Using `method='smallchunks` with `memmap=True` " "opens too many files.") dirname, expected = llc_mds_datadirs from xmitgcm.utils import read_3d_llc_data shape = expected['shape'] nz, nface, ny, nx = shape # the function will also return a nrecs dimension nrecs = 1 shape = (nrecs, ) + shape dtype = expected['dtype'].newbyteorder('>') # if we use memmap=True, we open too many files kwargs = dict(method=method, dtype=dtype, memmap=memmap) fname = os.path.join(dirname, 'T.%010d.data' % expected['test_iternum']) data = read_3d_llc_data(fname, nz, nx, **kwargs) assert data.shape == shape dc = data.compute() assert dc.shape == shape # once computed, all arrays are ndarray, even if backed by memmap assert isinstance(dc, np.ndarray) fname = os.path.join(dirname, 'XC.data') data = read_3d_llc_data(fname, 1, nx, **kwargs) # the z dimension is squeezed out by MDS, so the function matches that behavior shape_2d = (shape[0], ) + shape[2:] assert data.shape == shape_2d assert data.compute().shape == shape_2d
def test_read_raw_data_llc(llc_mds_datadirs, method): dirname, expected = llc_mds_datadirs from xmitgcm.utils import read_3d_llc_data shape = expected['shape'] nz, nface, ny, nx = shape # the function will also return a nrecs dimension nrecs = 1 shape = (nrecs, ) + shape dtype = expected['dtype'].newbyteorder('>') # if we use memmap=True, we open too many files kwargs = dict(method=method, dtype=dtype, memmap=False) fname = os.path.join(dirname, 'T.%010d.data' % expected['test_iternum']) data = read_3d_llc_data(fname, nz, nx, **kwargs) assert data.shape == shape assert data.compute().shape == shape fname = os.path.join(dirname, 'XC.data') data = read_3d_llc_data(fname, 1, nx, **kwargs) # the z dimension is squeezed out by MDS, so the function matches that behavior shape_2d = (shape[0], ) + shape[2:] assert data.shape == shape_2d assert data.compute().shape == shape_2d