Exemple #1
0
def test_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}
    plot = yt.LinePlot(ds, fields, (0, 0, 0), (1, 1, 0), 1000,
                       field_labels=field_labels)
    plot.annotate_legend(fields[0])
    plot.annotate_legend(fields[1])
    plot.set_x_unit('cm')
    plot.set_unit(fields[0], 'kg/cm**3')
    plot.annotate_title(fields[0], "Density Plot")
    yield compare(ds, plot, test_prefix="answers_line_plot",
                  test_name="answers_line_plot")
Exemple #2
0
def test_line_plot_methods():
    # Perform I/O in safe place instead of yt main dir
    tmpdir = tempfile.mkdtemp()
    curdir = os.getcwd()
    os.chdir(tmpdir)

    ds = fake_random_ds(32)

    plot = yt.LinePlot(ds, 'density', [0, 0, 0], [1, 1, 1], 512)
    plot.add_legend('density')
    plot.set_x_unit('cm')
    plot.set_unit('density', 'kg/cm**3')
    plot.save()

    os.chdir(curdir)
    # clean up
    shutil.rmtree(tmpdir)
Exemple #3
0
def LinePlot(Param_Dict, worker):
    """Takes a DataSet object loaded with yt and performs a linePlot with
    currently entered start- and endpoints on it.
    Parameters:
        ds: yt DataSet
        Param_Dict: Dict with Parameters
    """
    ds = Param_Dict["CurrentDataSet"]
    startends = ["XLStart", "YLStart", "ZLStart", "XLEnd", "YLEnd", "ZLEnd"]
    valueList = []
    for key in startends:
        value = yt.units.YTQuantity(Param_Dict[key],
                                    Param_Dict["oldGridUnit"]).to_value(ds.quan(1, 'code_length').units)
        valueList.append(value)
    npoints = 512
    plot = yt.LinePlot(ds, Param_Dict["YAxis"], valueList[:3], valueList[3:],
                       npoints, fontsize=14)
    emitStatus(worker, "Setting line plot modifications")
    plot.annotate_legend(Param_Dict["YAxis"])
    setAxisSettings(plot, Param_Dict, "Y")
    plot.set_x_unit(Param_Dict["LineUnit"])
    emitStatus(worker, "Annotating the line plot")
    plot.annotate_title(Param_Dict["YAxis"], Param_Dict["PlotTitle"])
    finallyDrawPlot(plot, Param_Dict, worker)
Exemple #4
0
import yt

# Load the dataset
ds = yt.load("SecondOrderTris/RZ_p_no_parts_do_nothing_bcs_cone_out.e", step=-1)

# Create a line plot of the variables 'u' and 'v' with 1000 sampling points evenly spaced
# between the coordinates (0, 0, 0) and (0, 1, 0)
plot = yt.LinePlot(
    ds, [("all", "v"), ("all", "u")], (0.0, 0.0, 0.0), (0.0, 1.0, 0.0), 1000
)

# Add a legend
plot.annotate_legend(("all", "v"))

# Save the line plot
plot.save()
Exemple #5
0
 def line_plot(filename_prefix):
     ln = yt.LinePlot(ds, fields, point1, point2, resolution)
     image_file = ln.save(filename_prefix)
     return image_file
Exemple #6
0
import yt
import numpy as np

home = "/Users/lindad"

field_label = {
    ('all', 'group1'): r'$\phi_1\ moltres$',
    ('all', 'group2'): r'$\phi_2\ moltres$'
}

ds = yt.load(home + '/projects/moltres/problems/'
             '2017_annals_pub_msre_compare/2group_out.e',
             step=-1)

plt = yt.LinePlot(ds, [('all', 'group1'), ('all', 'group2')], [0, 0, 0],
                  [0, 162.56, 0],
                  1000,
                  field_labels=field_label)
plt.annotate_legend(('all', 'group1'))
plt.set_x_unit('cm')
plt.set_xlabel('z (cm)')
plt.set_ylabel(r'Fluxes ($\mathrm{10^{13}cm^{-2} s^{-1}}$)')
plt._setup_plots()

msre_axial_data = np.loadtxt(home + '/publications/figures/'
                             'msre_axial_fluxes.csv',
                             skiprows=1,
                             delimiter=',')
fast_x = msre_axial_data[:, 0] * 2.54
fast_flux = msre_axial_data[:, 1]
msre_thermal_axial_data = np.loadtxt(home + '/publications/figures/'
                                     'msre_thermal_axial_flux.csv',
Exemple #7
0
ds = yt.load(filename)
ad = ds.all_data()

for i in sorted(ds.field_list):
    print(i)
for i in sorted(ds.derived_field_list):
    print(i)

flux = ad['density'] * ad['vely']
plt.clf()
# lev = np.logspace(np.log10(flux.min()), np.log10(flux.max()), num=100)
plt.tricontourf(ad['x'],
                ad['y'],
                flux,
                norm=matplotlib.colors.SymLogNorm(linthresh=0.01))
plt.title("0076: flux using SymLogNorm")
plt.colorbar()
plt.show()
plt.savefig(
    "/Users/wongb/Documents/Python Scripts/YT_Test_Plots/HDF5/0076fluxC")

conversion = 3.086e21
slc = yt.LinePlot(ds, 'vely', [6.25 * kpc, -1.75 * kpc, 0],
                  [0, -1.75 * kpc, max(ad['x']) * (conversion)], 512)
slc.save("/Users/wongb/Documents/Python Scripts/YT_Test_Plots/HDF5/0076xvely")

# slc = yt.SlicePlot(ds, 'z', flux)
# slc.save("YT_Test_Plots/HDF5/flux")

# for index in range(ad['vely'].size):
#     flux.append(ad['density']*ad['vely'])
Exemple #8
0
ymin = float(min(ad['y']).value)
x = closestNum(posXarray, 2.32838 * pow(10, 22))
ylim = -1.79040182984184e21
dx = posXarray[1] - posXarray[0]
# slc = yt.LinePlot(ds, 'temp', [x, ylim, 0], [x, ymin, 0], 512)
# Xslices = removeDuplicates(posXarray).sort()

#%%
### YT Try lineplots a little left or right
ds = yt.load(filename)
ad = ds.all_data()

x = closestNum(posXarray, 2.32838 * pow(10, 22)) - (
    5 * dx)  #2.320198554 is good for col 12
for t in range(1, 10):
    line = yt.LinePlot(ds, 'temp', [x, ylim, 0], [x, ymin, 0], 512)
    line.save(pwd + "/YT_Test_Plots/HDF5/temp/0080-" + str(t))
    x = x + dx
    print("(" + str(t) + ", " + str(x) + ")")

#%%
### YT annotate lines to visualize where these lineplots are
ylim = -1.79040182984184e21
bounds = {
    'xmin': 2.1 * pow(10, 22),
    'xmax': 2.5 * pow(10, 22),
    'ymin': float(min(ad['y']).value),
    'ymax': ylim
}
dsSelect = ad.include_inside('x', bounds['xmin'], bounds['xmax'])
dsSelect = dsSelect.include_inside('y', bounds['ymin'], bounds['ymax'])
Exemple #9
0
# slc = yt.SlicePlot(ds, 'z', 'density', data_source=dsSelect)

# slc.set_ylim('y', min(ad['y']), 0)
slc.annotate_title("Density, selected by temp > $0.35*10^3$")
slc.save("YT_Test_Plots/HDF5/cutRegionF")

###########
# Lineplots
###########
filename = "/Users/wongb/Documents/URS Data/m2_c1_16x8_64x64/More Plot Files/parkerCRs_hdf5_plt_cnt_0000"
ds = yt.load(filename)
ad = ds.all_data()
#make a lineplot of the region
#https://yt-project.org/doc/visualizing/plots.html#d-line-sampling
# slc = yt.LinePlot(ds, 'density', [-0.25e22, 0, 0], [-0.05e22, bounds['ymin'], 0], 512)
slc = yt.LinePlot(ds, 'density', [0, float(max(ad['y']).value), 0],
                  [0, float(min(ad['y']).value), 0], 512)
slc.save("YT_Test_Plots/HDF5/density_line_0000")

#plot over time
directory = "/Users/wongb/Documents/URS Data/m2_c1_16x8_64x64/More Plot Files/"
# directory = "/Users/wongb/Documents/URS Data/diffusion_3e28/diffusion_3e28/"
# directory = "/Users/wongb/Documents/URS Data/m1.5_c1_16x16_128x128_Rodrigues_Streaming/More Plot Files/"
saveDirectory = "D:/URS_LargeData/SherryPlots"
# bounds = {'xmin': -0.3e+22, 'xmax': 0.22+22, 'ymin': min(ad['y']).value,'ymax': 0}
conversion = 3.086e21
bounds = {
    'xmin': 2.5 * conversion,
    'xmax': 6 * conversion,
    'ymin': float(min(ad['y']).value),
    'ymax': 0
}
Exemple #10
0
def test_line_plot():
    ds = data_dir_load(tri2, kwargs={'step': -1})
    fields = [field for field in ds.field_list if field[0] == 'all']
    plot = yt.LinePlot(ds, fields, (0, 0, 0), (1, 1, 0), 1000)
    yield compare(ds, plot, "answers_line_plot")
Exemple #11
0
import yt

# Load the dataset
ds = yt.load("SecondOrderTris/RZ_p_no_parts_do_nothing_bcs_cone_out.e",
             step=-1)

# Create a line plot of the variables 'u' and 'v' with 1000 sampling points evenly spaced
# between the coordinates (0, 0, 0) and (0, 1, 0)
plot = yt.LinePlot(ds, [('all', 'v'), ('all', 'u')], (0, 0, 0), (0, 1, 0),
                   1000)

# Add a legend
plot.annotate_legend(('all', 'v'))

# Save the line plot
plot.save()
Exemple #12
0
import yt

# Load the dataset
ds = yt.load("SecondOrderTris/RZ_p_no_parts_do_nothing_bcs_cone_out.e", step=-1)

# Create a line plot of the variables 'u' and 'v' with 1000 sampling points evenly spaced
# between the coordinates (0, 0, 0) and (0, 1, 0)
plot = yt.LinePlot(ds, [('all', 'v'), ('all', 'u')], (0., 0., 0.), (0., 1., 0.), 1000)

# Add a legend
plot.annotate_legend(('all', 'v'))

# Save the line plot
plot.save()