def test_write_read_netcdf(tmpdir): ds = generate_test_dataset() ds = assemble_complex(ds) path = str(tmpdir.join('test_dataset.nc')) to_netcdf(ds, path) ds_read = open_dataset(path) xr_assert_equal(ds, ds_read)
def test_convolve_complex(): ds_complex = assemble_complex(ds) convolved_complex = ConvolutionFilter( ('y', 'x'), identity_kernel).apply(ds_complex) xr_assert_identical( ds_complex, convolved_complex )
def test_is_complex(): ds = assemble_complex(generate_test_dataset()) # Check Dataset assert utils.is_complex(ds) assert not utils.is_complex(disassemble_complex(ds)) # Check DataArray assert utils.is_complex(ds.C12) assert not utils.is_complex(ds.C11)
def test_assemble_complex_dataset(): # Create real dataset with real and imag part ds = generate_test_dataset(var=['a__im', 'a__re', 'b', 'c']) # Check that assembling into complex works ds_complex = assemble_complex(ds) assert_equal(set(ds_complex.data_vars), {'a', 'b', 'c'}) xr_assert_equal(ds_complex['a'].real, ds['a__re']) xr_assert_equal(ds_complex['a'].imag, ds['a__im'])
def test_accessor_nd_as_complex(): ds = generate_test_dataset() xr_assert_equal(io.assemble_complex(ds), ds.nd.as_complex())
def test_assemble_and_dissassemble_complex(): ds_orig = generate_test_dataset(var=['a__im', 'a__re', 'b', 'c']) ds_complex = assemble_complex(ds_orig) ds_real = disassemble_complex(ds_complex) xr_assert_identical(ds_orig, ds_real)