def test_multi_line_plot(): ds = data_dir_load(tri2, kwargs={'step': -1}) fields = [field for field in ds.field_list if field[0] == 'all'] lines = [] lines.append( yt.LineBuffer(ds, [0.25, 0, 0], [0.25, 1, 0], 100, label='x = 0.25')) lines.append( yt.LineBuffer(ds, [0.5, 0, 0], [0.5, 1, 0], 100, label='x = 0.5')) plot = yt.LinePlot.from_lines(ds, fields, lines) yield compare(ds, plot, "answers_multi_line_plot")
def test_multi_line_plot(): ds = fake_random_ds(4) fields = [field for field in ds.field_list if field[0] == 'stream'] field_labels = {f: f[1] for f in fields} lines = [] lines.append(yt.LineBuffer(ds, [0.25, 0, 0], [0.25, 1, 0], 100, label='x = 0.5')) lines.append(yt.LineBuffer(ds, [0.5, 0, 0], [0.5, 1, 0], 100, label='x = 0.5')) plot = yt.LinePlot.from_lines(ds, fields, lines, field_labels=field_labels) plot.annotate_legend(fields[0]) plot.annotate_legend(fields[1]) yield compare(ds, plot, test_prefix="answers_multi_line_plot", test_name="answers_multi_line_plot")
def test_line_buffer(): ds = fake_random_ds(32) lb = yt.LineBuffer(ds, (0, 0, 0), (1, 1, 1), 512, label='diag') lb['density'] lb['density'] = 0 lb['velocity_x'] lb.keys() del lb['velocity_x']
def test_line_buffer(): ds = fake_random_ds(32) lb = yt.LineBuffer(ds, (0, 0, 0), (1, 1, 1), 512, label="diag") lb["density"] lb["velocity_x"] assert_equal(lb["density"].size, 512) lb["density"] = 0 assert_equal(lb["density"], 0) assert_equal(set(lb.keys()), set(["density", "velocity_x"])) del lb["velocity_x"] assert_equal(set(lb.keys()), set(["density"]))
def test_line_buffer(): ds = fake_random_ds(32) lb = yt.LineBuffer(ds, (0, 0, 0), (1, 1, 1), 512, label='diag') lb['density'] lb['velocity_x'] assert_equal(lb['density'].size, 512) lb['density'] = 0 assert_equal(lb['density'], 0) assert_equal(set(lb.keys()), set(['density', 'velocity_x'])) del lb['velocity_x'] assert_equal(set(lb.keys()), set(['density']))
def test_line_buffer(): ds = fake_random_ds(32) lb = yt.LineBuffer(ds, (0, 0, 0), (1, 1, 1), 512, label="diag") lb[("gas", "density")] lb[("gas", "velocity_x")] assert_equal(lb[("gas", "density")].size, 512) lb[("gas", "density")] = 0 assert_equal(lb[("gas", "density")], 0) assert_equal(set(lb.keys()), {("gas", "density"), ("gas", "velocity_x")}) del lb[("gas", "velocity_x")] assert_equal(set(lb.keys()), {("gas", "density")})
from yt.units import K home = "/Users/lindad" def _units(field, data): return data[('all', 'temp')] * K ds = yt.load(home + '/projects/moltres/problems/' '2017_annals_pub_msre_compare/2group_out.e', step=-1) ds.add_field(('all', 'temp_K'), units='K', function=_units, take_log=False) lines = [] lines.append( yt.LineBuffer(ds, (0, 0, 0), (0, 162.56, 0), 1000, label='fuel moltres')) lines.append( yt.LineBuffer(ds, (3, 0, 0), (3, 162.56, 0), 1000, label='graphite moltres')) plt = yt.LinePlot.from_lines(ds, [('all', 'temp_K')], lines, field_labels={('all', 'temp_K'): ''}) plt.annotate_legend(('all', 'temp_K')) plt.set_x_unit('cm') plt.set_xlabel('z (cm)') plt.set_ylabel('Temperature (K)') plt._setup_plots() msre_temp_axial_data = np.loadtxt(home + '/publications/figures/' 'msre_axial_temps.csv',
rad = 15.0 res = 2048 xmix = np.array([]) ymix = np.array([]) rmix = np.array([]) mylog.setLevel(40) # Hide output log in command line for j in range( 0, 90): # Loop for changing the angle of the line from 0 to 90 deg xp = rad * np.cos( j * np.pi / 180) # Compute x coordinate of the end point yp = rad * np.sin( j * np.pi / 180) # Compute y coordinate of the end point start = [0.0, 0.0, 0.5] end = [xp, yp, 0.5] lb = yt.LineBuffer(ds, start, end, res) # Generate the line and get data acroos line #srt = np.argsort(ray['x']) xc = np.array(lb['gas', 'x']) yc = np.array(lb['gas', 'y']) mfrac = np.array(lb['fld1']) for k in range(0, len(mfrac)): # Start searching in the line (ray) if mfrac[k] >= 0.01 and mfrac[ k] <= 0.98: # Save coordinates of the mixture xmix = np.append(xmix, xc[k]) ymix = np.append(ymix, yc[k]) rmix = np.append( rmix, np.sqrt(xmix[len(xmix) - 1]**2 + ymix[len(ymix) - 1]**2)) #p = p + 1 p_MixLayr = np.append(p_MixLayr, max(rmix) - min(rmix))