def test_concat(self, tmpdir_factory, bout_xyt_example_files):
     path1 = bout_xyt_example_files(tmpdir_factory, nxpe=3, nype=4, nt=1)
     bd1 = open_boutdataset(datapath=path1, inputfilepath=None)
     path2 = bout_xyt_example_files(tmpdir_factory, nxpe=3, nype=4, nt=1)
     bd2 = open_boutdataset(datapath=path2, inputfilepath=None)
     result = concat([bd1, bd2], dim='run')
     assert result.dims == {**bd1.dims, 'run': 2}
    def test_storm_dataset_inheritance(self, tmpdir_factory,
                                       bout_xyt_example_files):
        path = bout_xyt_example_files(tmpdir_factory, nxpe=1, nype=1, nt=1)
        ds = open_boutdataset(datapath=path, inputfilepath=None)
        ds.storm.set_extra_data('options')
        print(ds.storm.extra_data)

        assert False
    def test_object_permanence(self, tmpdir_factory, bout_xyt_example_files):
        path = bout_xyt_example_files(tmpdir_factory, nxpe=1, nype=1, nt=1)
        ds = open_boutdataset(datapath=path, inputfilepath=None)

        ds.storm.extra_info = 'options'
        new_ds = ds.isel(t=-1)
        print(new_ds.storm.extra_info)

        assert False
    def test_test_method(self, tmpdir_factory, bout_xyt_example_files):
        path = bout_xyt_example_files(tmpdir_factory, nxpe=1, nype=1, nt=1)
        ds = open_boutdataset(datapath=path, inputfilepath=None)
        #ds = collect(path=path)
        #bd = BoutAccessor(ds)
        print(ds)
        #ds.bout.test_method()
        #print(ds.bout.options)
        #print(ds.bout.metadata)
        print(ds.isel(t=-1))

        #ds.bout.set_extra_data('stored')
        ds.bout.extra_data = 'stored'

        print(ds.bout.extra_data)
    def test_save_dtype(self, tmpdir_factory, bout_xyt_example_files,
                        save_dtype):

        # Create data
        path = bout_xyt_example_files(tmpdir_factory, nxpe=1, nype=1, nt=1)

        # Load it as a boutdataset
        original = open_boutdataset(datapath=path, inputfilepath=None)

        # Save it to a netCDF file
        savepath = str(Path(path).parent) + 'temp_boutdata.nc'
        original.bout.save(savepath=savepath, save_dtype=np.dtype(save_dtype))

        # Load it again using bare xarray
        recovered = open_dataset(savepath)

        assert recovered['n'].values.dtype == np.dtype(save_dtype)
    def test_save_all(self, tmpdir_factory, bout_xyt_example_files, options):
        # Create data
        path = bout_xyt_example_files(tmpdir_factory, nxpe=4, nype=5, nt=1)

        # Load it as a boutdataset
        original = open_boutdataset(datapath=path, inputfilepath=None)
        if not options:
            original.attrs['options'] = {}

        # Save it to a netCDF file
        savepath = str(Path(path).parent) + 'temp_boutdata.nc'
        original.bout.save(savepath=savepath)

        # Load it again using bare xarray
        recovered = open_dataset(savepath)

        # Compare
        xrt.assert_equal(original, recovered)
    def test_save_separate_variables(self, tmpdir_factory,
                                     bout_xyt_example_files):
        path = bout_xyt_example_files(tmpdir_factory, nxpe=4, nype=1, nt=1)

        # Load it as a boutdataset
        original = open_boutdataset(datapath=path, inputfilepath=None)

        # Save it to a netCDF file
        savepath = str(Path(path).parent) + '/temp_boutdata.nc'
        original.bout.save(savepath=savepath, separate_vars=True)

        for var in ['n', 'T']:
            # Load it again using bare xarray
            savepath = str(Path(path).parent) + '/temp_boutdata_' + var + '.nc'
            recovered = open_dataset(savepath)

            # Compare
            xrt.assert_equal(recovered[var], original[var])
    def test_dataset_duck_typing(self, tmpdir_factory, bout_xyt_example_files):
        path = bout_xyt_example_files(tmpdir_factory, nxpe=1, nype=1, nt=1)
        ds = open_boutdataset(datapath=path, inputfilepath=None)

        result = concat([ds.bout, ds.bout], dim='run')
        print(result)
    def test_storm_dataset(self, tmpdir_factory, bout_xyt_example_files):
        path = bout_xyt_example_files(tmpdir_factory, nxpe=1, nype=1, nt=1)
        ds = open_boutdataset(datapath=path, inputfilepath=None)
        print(ds.storm.normalisation)

        assert False
Exemple #10
0
 def test_load_options_in_dataset(self, tmpdir_factory,
                                  bout_xyt_example_files):
     path = bout_xyt_example_files(tmpdir_factory, nxpe=1, nype=1, nt=1)
     ds = open_boutdataset(datapath=path,
                           inputfilepath=EXAMPLE_OPTIONS_FILE_PATH)
     assert isinstance(ds.options, BoutOptions)
Exemple #11
0
 def test_isel(self, tmpdir_factory, bout_xyt_example_files):
     path = bout_xyt_example_files(tmpdir_factory, nxpe=1, nype=1, nt=1)
     bd = open_boutdataset(datapath=path, inputfilepath=None)
     actual = bd.isel(x=slice(None, None, 2))
     expected = bd.bout.data.isel(x=slice(None, None, 2))
     xrt.assert_equal(actual, expected)