def test_magnetic_callback(): with _cleanup_fname() as prefix: ds = fake_amr_ds(fields=("density", "magnetic_field_x", "magnetic_field_y", "magnetic_field_z")) for ax in 'xyz': p = ProjectionPlot(ds, ax, "density", weight_field="density") p.annotate_magnetic_field() assert_fname(p.save(prefix)[0]) p = SlicePlot(ds, ax, "density") p.annotate_magnetic_field() assert_fname(p.save(prefix)[0]) # Test for OffAxis Slice p = SlicePlot(ds, [1, 1, 0], 'density', north_vector=[0, 0, 1]) p.annotate_magnetic_field(factor=40, normalize=True) assert_fname(p.save(prefix)[0]) # Now we'll check a few additional minor things p = SlicePlot(ds, "x", "density") p.annotate_magnetic_field(factor=8, scale=0.5, scale_units="inches", normalize=True) assert_fname(p.save(prefix)[0]) with _cleanup_fname() as prefix: ds = fake_amr_ds(fields=("density", "magnetic_field_r", "magnetic_field_theta", "magnetic_field_phi"), geometry="spherical") p = ProjectionPlot(ds, "r", "density") p.annotate_magnetic_field(factor=8, scale=0.5, scale_units="inches", normalize=True) assert_raises(YTDataTypeUnsupported, p.save, prefix)
def test_magnetic_callback(): with _cleanup_fname() as prefix: ds = fake_amr_ds(fields = ("density", "magnetic_field_x", "magnetic_field_y", "magnetic_field_z")) for ax in 'xyz': p = ProjectionPlot(ds, ax, "density", weight_field="density") p.annotate_magnetic_field() yield assert_fname, p.save(prefix)[0] p = SlicePlot(ds, ax, "density") p.annotate_magnetic_field() yield assert_fname, p.save(prefix)[0] # Now we'll check a few additional minor things p = SlicePlot(ds, "x", "density") p.annotate_magnetic_field(factor=8, scale=0.5, scale_units="inches", normalize = True) p.save(prefix)
def test_magnetic_callback(): with _cleanup_fname() as prefix: ds = fake_amr_ds(fields=("density", "magnetic_field_x", "magnetic_field_y", "magnetic_field_z")) for ax in 'xyz': p = ProjectionPlot(ds, ax, "density", weight_field="density") p.annotate_magnetic_field() yield assert_fname, p.save(prefix)[0] p = SlicePlot(ds, ax, "density") p.annotate_magnetic_field() yield assert_fname, p.save(prefix)[0] # Now we'll check a few additional minor things p = SlicePlot(ds, "x", "density") p.annotate_magnetic_field(factor=8, scale=0.5, scale_units="inches", normalize=True) p.save(prefix)
def test_magnetic_callback(): with _cleanup_fname() as prefix: ds = fake_amr_ds( fields=( "density", "magnetic_field_x", "magnetic_field_y", "magnetic_field_z", ), units=( "g/cm**3", "G", "G", "G", ), ) for ax in "xyz": p = ProjectionPlot( ds, ax, ("gas", "density"), weight_field=("gas", "density") ) p.annotate_magnetic_field() assert_fname(p.save(prefix)[0]) p = SlicePlot(ds, ax, ("gas", "density")) p.annotate_magnetic_field() assert_fname(p.save(prefix)[0]) # Test for OffAxis Slice p = SlicePlot(ds, [1, 1, 0], ("gas", "density"), north_vector=[0, 0, 1]) p.annotate_magnetic_field(factor=40, normalize=True) assert_fname(p.save(prefix)[0]) # Now we'll check a few additional minor things p = SlicePlot(ds, "x", ("gas", "density")) p.annotate_magnetic_field( factor=8, scale=0.5, scale_units="inches", normalize=True ) assert_fname(p.save(prefix)[0]) with _cleanup_fname() as prefix: ds = load(cyl_2d) slc = SlicePlot(ds, "theta", ("gas", "magnetic_field_strength")) slc.annotate_magnetic_field() assert_fname(slc.save(prefix)[0]) with _cleanup_fname() as prefix: ds = load(cyl_3d) for ax in ["r", "z", "theta"]: slc = SlicePlot(ds, ax, ("gas", "magnetic_field_strength")) slc.annotate_magnetic_field() assert_fname(slc.save(prefix)[0]) slc = ProjectionPlot(ds, ax, ("gas", "magnetic_field_strength")) slc.annotate_magnetic_field() assert_fname(slc.save(prefix)[0]) with _cleanup_fname() as prefix: ds = fake_amr_ds( fields=( "density", "magnetic_field_r", "magnetic_field_theta", "magnetic_field_phi", ), units=( "g/cm**3", "G", "G", "G", ), geometry="spherical", ) p = ProjectionPlot(ds, "r", ("gas", "density")) p.annotate_magnetic_field( factor=8, scale=0.5, scale_units="inches", normalize=True ) assert_raises(YTDataTypeUnsupported, p.save, prefix)