def test_profile_data(): tmpdir = make_tempdir() curdir = os.getcwd() os.chdir(tmpdir) ds = data_dir_load(enzotiny) ad = ds.all_data() profile_1d = create_profile(ad, "density", "temperature", weight_field="cell_mass") fn = profile_1d.save_as_dataset() full_fn = os.path.join(tmpdir, fn) prof_1d_ds = load(full_fn) compare_unit_attributes(ds, prof_1d_ds) assert isinstance(prof_1d_ds, YTProfileDataset) for field in profile_1d.standard_deviation: assert_array_equal( profile_1d.standard_deviation[field], prof_1d_ds.profile.standard_deviation["data", field[1]], ) p1 = ProfilePlot(prof_1d_ds.data, "density", "temperature", weight_field="cell_mass") p1.save() yield YTDataFieldTest(full_fn, "temperature", geometric=False) yield YTDataFieldTest(full_fn, "x", geometric=False) yield YTDataFieldTest(full_fn, "density", geometric=False) profile_2d = create_profile( ad, ["density", "temperature"], "cell_mass", weight_field=None, n_bins=(128, 128), ) fn = profile_2d.save_as_dataset() full_fn = os.path.join(tmpdir, fn) prof_2d_ds = load(full_fn) compare_unit_attributes(ds, prof_2d_ds) assert isinstance(prof_2d_ds, YTProfileDataset) p2 = PhasePlot(prof_2d_ds.data, "density", "temperature", "cell_mass", weight_field=None) p2.save() yield YTDataFieldTest(full_fn, "density", geometric=False) yield YTDataFieldTest(full_fn, "x", geometric=False) yield YTDataFieldTest(full_fn, "temperature", geometric=False) yield YTDataFieldTest(full_fn, "y", geometric=False) yield YTDataFieldTest(full_fn, "cell_mass", geometric=False) os.chdir(curdir) if tmpdir != ".": shutil.rmtree(tmpdir)
def test_profile_data(): tmpdir = tempfile.mkdtemp() curdir = os.getcwd() os.chdir(tmpdir) ds = data_dir_load(enzotiny) ad = ds.all_data() profile_1d = create_profile(ad, "density", "temperature", weight_field="cell_mass") fn = profile_1d.save_as_dataset() full_fn = os.path.join(tmpdir, fn) prof_1d_ds = load(full_fn) compare_unit_attributes(ds, prof_1d_ds) assert isinstance(prof_1d_ds, YTProfileDataset) p1 = ProfilePlot(prof_1d_ds.data, "density", "temperature", weight_field="cell_mass") p1.save() yield YTDataFieldTest(full_fn, "temperature", geometric=False) yield YTDataFieldTest(full_fn, "x", geometric=False) yield YTDataFieldTest(full_fn, "density", geometric=False) profile_2d = create_profile(ad, ["density", "temperature"], "cell_mass", weight_field=None, n_bins=(128, 128)) fn = profile_2d.save_as_dataset() full_fn = os.path.join(tmpdir, fn) prof_2d_ds = load(full_fn) compare_unit_attributes(ds, prof_2d_ds) assert isinstance(prof_2d_ds, YTProfileDataset) p2 = PhasePlot(prof_2d_ds.data, "density", "temperature", "cell_mass", weight_field=None) p2.save() yield YTDataFieldTest(full_fn, "density", geometric=False) yield YTDataFieldTest(full_fn, "x", geometric=False) yield YTDataFieldTest(full_fn, "temperature", geometric=False) yield YTDataFieldTest(full_fn, "y", geometric=False) yield YTDataFieldTest(full_fn, "cell_mass", geometric=False) os.chdir(curdir) shutil.rmtree(tmpdir)
def test_old_profile_data(): tmpdir = tempfile.mkdtemp() curdir = os.getcwd() os.chdir(tmpdir) ds = data_dir_load(enzotiny) ad = ds.all_data() profile_1d = create_profile( ad, ("gas", "density"), ("gas", "temperature"), weight_field=("gas", "cell_mass"), ) fn = "DD0046_Profile1D.h5" full_fn = os.path.join(ytdata_dir, fn) prof_1d_ds = data_dir_load(full_fn) compare_unit_attributes(ds, prof_1d_ds) assert isinstance(prof_1d_ds, YTProfileDataset) for field in profile_1d.standard_deviation: assert_array_equal( profile_1d.standard_deviation[field], prof_1d_ds.profile.standard_deviation["data", field[1]], ) p1 = ProfilePlot( prof_1d_ds.data, ("gas", "density"), ("gas", "temperature"), weight_field=("gas", "cell_mass"), ) p1.save() yield YTDataFieldTest(full_fn, ("gas", "temperature"), geometric=False) yield YTDataFieldTest(full_fn, ("index", "x"), geometric=False) yield YTDataFieldTest(full_fn, ("gas", "density"), geometric=False) fn = "DD0046_Profile2D.h5" full_fn = os.path.join(ytdata_dir, fn) prof_2d_ds = data_dir_load(full_fn) compare_unit_attributes(ds, prof_2d_ds) assert isinstance(prof_2d_ds, YTProfileDataset) p2 = PhasePlot( prof_2d_ds.data, ("gas", "density"), ("gas", "temperature"), ("gas", "cell_mass"), weight_field=None, ) p2.save() yield YTDataFieldTest(full_fn, ("gas", "density"), geometric=False) yield YTDataFieldTest(full_fn, ("index", "x"), geometric=False) yield YTDataFieldTest(full_fn, ("gas", "temperature"), geometric=False) yield YTDataFieldTest(full_fn, ("index", "y"), geometric=False) yield YTDataFieldTest(full_fn, ("gas", "cell_mass"), geometric=False) os.chdir(curdir) shutil.rmtree(tmpdir)