コード例 #1
0
def test_create_from_dataset():
    ds = fake_random_ds(16)
    plot1 = yt.ProfilePlot(
        ds,
        ("index", "radius"),
        [("gas", "velocity_x"), ("gas", "density")],
        weight_field=None,
    )
    plot2 = yt.ProfilePlot(
        ds.all_data(),
        ("index", "radius"),
        [("gas", "velocity_x"), ("gas", "density")],
        weight_field=None,
    )
    assert_allclose_units(plot1.profiles[0][("gas", "density")],
                          plot2.profiles[0][("gas", "density")])
    assert_allclose_units(plot1.profiles[0]["velocity_x"],
                          plot2.profiles[0]["velocity_x"])

    plot1 = yt.PhasePlot(ds, ("gas", "density"), ("gas", "velocity_x"),
                         ("gas", "cell_mass"))
    plot2 = yt.PhasePlot(ds.all_data(), ("gas", "density"),
                         ("gas", "velocity_x"), ("gas", "cell_mass"))
    assert_allclose_units(plot1.profile["cell_mass"],
                          plot2.profile["cell_mass"])
コード例 #2
0
def test_create_from_dataset():
    ds = fake_random_ds(16)
    plot1 = yt.ProfilePlot(ds, "radius", ["velocity_x", "density"],
                           weight_field=None)
    plot2 = yt.ProfilePlot(ds.all_data(), "radius", ["velocity_x", "density"],
                           weight_field=None)
    assert_allclose_units(
        plot1.profiles[0]['density'], plot2.profiles[0]['density'])
    assert_allclose_units(
        plot1.profiles[0]['velocity_x'], plot2.profiles[0]['velocity_x'])

    plot1 = yt.PhasePlot(ds, 'density', 'velocity_x', 'cell_mass')
    plot2 = yt.PhasePlot(ds.all_data(), 'density', 'velocity_x', 'cell_mass')
    assert_allclose_units(
        plot1.profile['cell_mass'], plot2.profile['cell_mass'])
コード例 #3
0
    def generate_plot(self):
        s = self.parent.active_data_object.data
        xf = self.x_field.get_field
        yf = self.y_field.get_fields()
        wf = self.weight_field.get_field()
        if wf == 'Default':
            wf = 'cell_mass'
        if wf == 'None':
            wf = None
        nb = self.n_bins.value()
        accum = self.accum.currentText() == 'True'
        frac = self.frac.currentText() == 'True'
        xl = self.x_log.currentText() == 'True'
        yl = self.y_log.currentText() == 'True'

        plt = yt.ProfilePlot(s,
                             xf,
                             yf,
                             weight_field=wf,
                             n_bins=nb,
                             accumulation=accum,
                             fractional=frac,
                             x_log=xl,
                             y_log=yl)
        view = PlotWindowView(plt)
        self.plot_ref.addSubWindow(view)
        view.show()
コード例 #4
0
def test_phaseplot_set_log():
    fields = ('density', 'temperature')
    units = (
        'g/cm**3',
        'K',
    )
    ds = fake_random_ds(16, fields=fields, units=units)
    sp = ds.sphere("max", (1.0, "Mpc"))
    p1 = yt.ProfilePlot(sp, "radius", ("gas", "density"))
    p2 = yt.PhasePlot(sp, ("gas", "density"), ("gas", "temperature"),
                      "cell_mass")
    # make sure we can set the log-scaling using the tuple without erroring out
    p1.set_log(("gas", "density"), False)
    p2.set_log(("gas", "temperature"), False)
    assert not p1.y_log["gas", "density"]
    assert not p2.y_log

    # make sure we can set the log-scaling using a string without erroring out
    p1.set_log("density", True)
    p2.set_log("temperature", True)
    assert p1.y_log["gas", "density"]
    assert p2.y_log

    # make sure we can set the log-scaling using a field object
    p1.set_log(ds.fields.gas.density, False)
    p2.set_log(ds.fields.gas.temperature, False)
    assert not p1.y_log["gas", "density"]
    assert not p2.y_log
コード例 #5
0
def test_set_labels():
    ds = fake_random_ds(16)
    ad = ds.all_data()
    plot = yt.ProfilePlot(ad, "radius", ["velocity_x", "density"], weight_field=None)
    # make sure we can set the labels without erroring out
    plot.set_ylabel("all", "test ylabel")
    plot.set_xlabel("test xlabel")
コード例 #6
0
def test_set_units():
    ds = yt.load(ETC46)
    sp = ds.sphere("max", (1.0, "Mpc"))
    p1 = yt.ProfilePlot(sp, "radius", ("enzo", "Density"))
    p2 = yt.PhasePlot(sp, ("enzo", "Density"), ("enzo", "Temperature"),
                      "cell_mass")
    # make sure we can set the units using the tuple without erroring out
    p1.set_unit(("enzo", "Density"), "Msun/kpc**3")
    p2.set_unit(("enzo", "Temperature"), "R")
コード例 #7
0
    def setUpClass(cls):
        cls.tmpdir = tempfile.mkdtemp()
        cls.curdir = os.getcwd()
        os.chdir(cls.tmpdir)

        ds = fake_random_ds(16)
        ad = ds.all_data()
        cls.fields = ["velocity_x", "velocity_y", "velocity_z"]
        cls.plot = yt.ProfilePlot(ad, "radius", cls.fields, weight_field=None)
コード例 #8
0
def test_set_units():
    fields = ('density', 'temperature')
    units = ('g/cm**3', 'K',)
    ds = fake_random_ds(16, fields=fields, units=units)
    sp = ds.sphere("max", (1.0, "Mpc"))
    p1 = yt.ProfilePlot(sp, "radius", ("gas", "density"))
    p2 = yt.PhasePlot(sp, ("gas", "density"), ("gas", "temperature"), "cell_mass")
    # make sure we can set the units using the tuple without erroring out
    p1.set_unit(("gas", "density"), "Msun/kpc**3")
    p2.set_unit(("gas", "temperature"), "R")
コード例 #9
0
def make_mass_profile(ad, yfield=('Gas', 'Mass')):
    xfield = ('gas', 'spherical_position_radius')
    p = yt.ProfilePlot(ad,
                       xfield,
                       yfield,
                       weight_field=None,
                       x_log=False,
                       n_bins=16)
    p.set_unit(xfield, 'kpc')
    p.set_unit(yfield, 'Msun')
    profile = p.profiles[0]
    rbins = profile.x
    return rbins, profile[yfield]
コード例 #10
0
def DM_dens_prof(ds,sph,simtype,curr_sim,curr_halo):
    print datetime.now().strftime('%H:%M:%S'),'Making DM Density Profile Plot of halo #%d'%(curr_halo)
    field_type = 'deposit'
    field = 'io_density'
    weight= None


    rp  = yt.create_profile(sph, 'radius', (field_type,field),weight_field=weight)
    output = yt.ProfilePlot(sph, "radius", (field_type,field),x_log=None,y_log=None)

    output.set_unit('radius', 'Mpccm/h')
    output.set_unit(field, 'Msun/kpc**3')
    output.set_log('radius',False)
    output.save('%s_%s_%d_prof_%s.png'%(simtype,curr_sim,curr_halo,field))
    return rp
コード例 #11
0
def prof_temp_halo(ds,sph,simtype,curr_sim,curr_halo):
    "This function makes a profile of the halo chosen, saves it, and returns the profile as an object for future use"
    print datetime.now().strftime('%H:%M:%S'),'Making gas temperature Profile Plot of halo #%d'%(curr_halo)
    fieldtype = 'gas'
    field = 'temperature'
    weight= None

    rp    = yt.create_profile(sph,'radius',(fieldtype,field),weight_field=weight)
    plot  = yt.ProfilePlot(sph,'radius',(fieldtype,field),weight_field=weight)

    plot.set_unit('radius', 'Mpccm/h')
    plot.set_unit(field, 'K')
    plot.set_log('radius',False)
    plot.save('%s_%s_%d_prof_%s.png'%(simtype,curr_sim,curr_halo,field))
    #Return the profile object for future use.
    return rp
コード例 #12
0
ファイル: test_profile_plots.py プロジェクト: sflarkin/yt
def test_phaseplot_set_log():
    ds = yt.load(ETC46)
    sp = ds.sphere("max", (1.0, "Mpc"))
    p1 = yt.ProfilePlot(sp, "radius", ("enzo", "Density"))
    p2 = yt.PhasePlot(sp, ("enzo", "Density"), ("enzo", "Temperature"),
                      "cell_mass")
    # make sure we can set the log-scaling using the tuple without erroring out
    p1.set_log(("enzo", "Density"), False)
    p2.set_log(("enzo", "Temperature"), False)
    assert p1.y_log["enzo", "Density"] is False
    assert p2.y_log is False

    # make sure we can set the log-scaling using a string without erroring out
    p1.set_log("Density", True)
    p2.set_log("Temperature", True)
    assert p1.y_log["enzo", "Density"] is True
    assert p2.y_log is True

    # make sure we can set the log-scaling using a field object
    p1.set_log(ds.fields.enzo.Density, False)
    p2.set_log(ds.fields.enzo.Temperature, False)
    assert p1.y_log["enzo", "Density"] is False
    assert p2.y_log is False
コード例 #13
0
trident.add_ion_fields(ds, ['C', "O", "O IV", "O VI", "C IV"], ftype='gas')

for field in ds.derived_field_list:
    print (field)

pos = ad['particle_position'][ad['particle_mass'] \
            == ad['particle_mass'].max()][0].to('unitary')
r = 4.0*ad['virial_radius'][ad['particle_mass'] \
            == ad['particle_mass'].max()][0].to('unitary')
sp = ds.sphere(pos, r)
fields = ['H_p1_density','O_p4_density','C_p0_density', 'H_density']
labels = ['HI', "OIV", "C", "H"]


## make a ray that intersects this most massive halo ##
ray = trident.make_simple_ray(ds, start_position=[pos[0], pos[1],0], end_position=[pos[0], pos[1], 1],\
                                lines='H')
width = ds.domain_width[0]
lbase = 1215.67
dz = ds.cosmology.z_from_t(ds.current_time-width/ds.quan(2.998*10**8, 'm/s'))
lmin = lbase*(z-dz+1)
lmax = lbase*(z+1)
sg = trident.SpectrumGenerator(lambda_min = lmin, lambda_max = lmax, dlambda=0.01)
sg.make_spectrum(ray, lines='H')
sg.save_spectrum('/home/azton/simulations/analysis/%s/spectrum_%0.3f.png'%(simname, ds.current_redshift)

for field in range(len(fields)):
    prj = yt.ProfilePlot(sp, "radius",fields[field], label=labels[field]\
                , weight_field='density', n_bins=100)
    prj.annotate_ray(ray, arrow=True)
    prj.save('/home/azton/simulations/analysis/%s/radialProfile'%simname)
コード例 #14
0
# # Save plot
# slc.show()
# slc.save("YT_Test_Plots/Customization2")

##################
# 1D Profile Plots
##################

ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
my_galaxy = ds.disk(ds.domain_center, [0.0, 0.0, 1.0], 10 * kpc, 3 * kpc)

# you can choose any two variables to plot.
# use weight_field to use weighted averages
# syntax ProfilePlot(dataset, x variable, y variable)
plot = yt.ProfilePlot(my_galaxy, 'density', 'temperature')

#you can plot multiple 1D plots
plot.save("YT_Test_Plots/1DProfile")

################
# 2D Phase Plots
################

# Extra keywords for stats:
# weight_field = none   Total of some field in a bin; default averages values
# fractional = True     Creates probability distribution fcns
# accumulation = True   Cumulative distribution function, i.e. N = sum of 0 to N
phasePlot = yt.PhasePlot(ds,
                         "density",
                         "temperature", ["cell_mass"],
コード例 #15
0
#plot over time
directory = "/Users/wongb/Documents/URS Data/m2_c1_16x8_64x64/More Plot Files/"
saveDirectory = "D:/URS_LargeData/SherryPlots"
conversion = 3.086e21
bounds = {
    'xmin': -0.3e+22,
    'xmax': 0.22e+22,
    'ymin': min(ad['y']).value,
    'ymax': 0
}
# bounds = {'xmin': 2.5*conversion, 'xmax': 6*conversion, 'ymin': float(min(ad['y']).value),'ymax': 0}
# bounds = {'xmin': 2.5*conversion, 'xmax': 6*conversion, 'ymin': float(min(ad['y']).value),'ymax': -1.40477660814861e21}
dsSelect = ad.include_inside('x', bounds['xmin'], bounds['xmax'])
dsSelect = dsSelect.include_inside('y', bounds['ymin'], bounds['ymax'])
dsSelect = dsSelect.cut_region("obj['temp'] > .25*10e3")
slc = yt.ProfilePlot(dsSelect, 'y', ['density'])
slc.save("YT_Test_Plots/HDF5/density_Profile2_0076")
# abc = yt.SlicePlot(ds, 'z', 'density', data_source=dsSelect,
#                     center=( np.sum([bounds['xmin'], bounds['xmax']])/2, np.sum([bounds['ymin'], bounds['ymax']])/2, 0))
# abc.set_width(max([ abs(bounds['xmax']-bounds['xmin']), abs(bounds['ymax']-bounds['ymin']) ]))
# abc.save("YT_Test_Plots/HDF5/TEST")

startTime = time.time()
for fileName in os.listdir(directory):
    if (fileName.startswith("parkerCRs")):
        ds = yt.load(directory + fileName)
        print(fileName)
        timeStamp = fileName[len(fileName) - 4:len(fileName)]
        dsSelect = ad.include_inside('x', bounds['xmin'], bounds['xmax'])
        dsSelect = dsSelect.include_inside('y', bounds['ymin'], bounds['ymax'])
        dsSelect = dsSelect.cut_region("obj['temp'] > .35*10e3")
コード例 #16
0
                        north_vector=[1, 0, 0])
H2_slice.set_zlim('H2_fraction', 1e-11, 8e-6)
H2_slice.set_cmap(field="H2_fraction", cmap='hot')
#H2_slice.save("kuvat/H2fracproj.png")
plots.append(H2_slice)
colorbar_label.append("H$_2$ Fraction")
colorbar_flags.append(True)
xaxis_flags.append(-1)
yaxis_flags.append(-1)

# H profile
val, maxTiheys = ds.find_max("density")
sphere = ds.sphere(
    maxTiheys,
    leveys)  # keskitetään H number density -kuvaaja tiheimpään kohtaan
H_prof = yt.ProfilePlot(sphere, "radius", ["H_number_density"])
H_prof.set_unit("radius", "kpc")
H_prof.set_xlim(prof_xrange[0], prof_xrange[1])
H_prof.set_ylim("H_number_density", 0.015, 0.13)
H_prof.set_line_property("linewidth", linewidth)
H_prof.x_log = False
#H_prof.save("kuvat/Hprof.png")
plots.append(H_prof)
colorbar_flags.append(False)
xaxis_flags.append(0)
yaxis_flags.append(0)

# H2 profile
sphere = ds.sphere(
    keskusta, leveys)  # keskitetään H2 fraction -kuvaaja säteilylähteeseen
H2_prof = yt.ProfilePlot(sphere, "radius", ["H2_fraction"])
コード例 #17
0
ファイル: plot__profile.py プロジェクト: CliffLinTw/gamer
idx_start = args.idx_start
idx_end = args.idx_end
didx = args.didx
prefix = args.prefix

field = 'density'
center_mode = 'max'
dpi = 150
nbin = 32

yt.enable_parallelism()
ts = yt.load([
    prefix + '/Data_%06d' % idx for idx in range(idx_start, idx_end + 1, didx)
])

for ds in ts.piter():

    sp = ds.sphere(center_mode, 0.5 * ds.domain_width.to_value().max())

    prof = yt.ProfilePlot(sp,
                          'radius',
                          field,
                          weight_field='cell_volume',
                          n_bins=nbin)
    prof.set_unit('radius', 'kpc')
    prof.set_xlim(5.0e-1, 1.0e2)
    #  prof.set_ylim( field, 1.0e-6, 1.0e0 )

    prof.save(mpl_kwargs={"dpi": dpi})
コード例 #18
0
ファイル: plot_utils.py プロジェクト: cosmosquark/ramses_pp
def plot_standard_vcirc(sphere,
                        cylinder,
                        snap,
                        galaxy_name,
                        r_min=None,
                        r_max=None,
                        dr_factor=2,
                        vrot=True):
    """
	Your bog standard Vcirc plot, with the option to append rotation velocities to the plot.
	Requires stars, dark matter to be pre-filtered first
	"""

    from ramses_pp.analysis import utils, filter_utils

    if r_max == None:
        r_max = sphere["particle_positions_cylindrical_radius"].max().in_units(
            "kpc")


#		r_max = sphere.ds.arr(50,"kpc")

    if r_min == None:
        r_min = sphere.ds.arr(0, "kpc")

    # 1) get radial values
    r_indices, r_bins, r_filter, r_truths = utils.radial_indices(
        'particle_position_spherical_radius',
        sphere,
        r_min=None,
        r_max=r_max,
        dr_factor=2)

    ytsnap = snap.raw_snapshot()
    n_bins = len(r_bins)
    r_bins = ytsnap.arr(r_bins, "cmcm")
    m_bins_all = utils.mass_enclosed_bins(sphere,
                                          snap,
                                          r_bins,
                                          shape="sphere",
                                          type="all")
    m_bins_dark = utils.mass_enclosed_bins(sphere,
                                           snap,
                                           r_bins,
                                           shape="sphere",
                                           type="dark")
    m_bins_star = utils.mass_enclosed_bins(sphere,
                                           snap,
                                           r_bins,
                                           shape="sphere",
                                           type="stars")
    m_bins_gas = utils.mass_enclosed_bins(sphere,
                                          snap,
                                          r_bins,
                                          shape="sphere",
                                          type="gas")

    vcirc_all = utils.vcirc(r_bins, m_bins_all, sphere)
    vcirc_dark = utils.vcirc(r_bins, m_bins_dark, sphere)
    vcirc_star = utils.vcirc(r_bins, m_bins_star, sphere)
    vcirc_gas = utils.vcirc(r_bins, m_bins_gas, sphere)

    plt.plot(r_bins.in_units("kpc"),
             vcirc_all.in_units("km/s"),
             color="black",
             label=r"$V_{circ,all}$")
    plt.plot(r_bins.in_units("kpc"),
             vcirc_dark.in_units("km/s"),
             color="green",
             label=r"$V_{circ,dark}$")
    plt.plot(r_bins.in_units("kpc"),
             vcirc_star.in_units("km/s"),
             color="blue",
             label=r"$V_{circ,stars}$")
    plt.plot(r_bins.in_units("kpc"),
             vcirc_gas.in_units("km/s"),
             color="red",
             label=r"$V_{circ,gas}$")

    plt.xlabel("Radius [kpc]")
    plt.ylabel("Rotation Speed [km/s]")

    if vrot:
        # THE DISK SHOULD ALREADY BE FILTERED SPATIALLY KINDA
        print "doing stuff with vrot"
        min_z = sphere.ds.arr(-3.0, "kpc")
        max_z = sphere.ds.arr(3.0, "kpc")

        cold_disk = cylinder.cut_region(["obj['temperature'] < 1e4"])

        #		L = sphere.quantities.angular_momentum_vector(use_gas=True,use_particles=False)
        #		bv = sphere.get_field_parameter("bulk_velocity")
        #		L_mag = np.sqrt(np.power(L[0],2.0) + np.power(L[1],2.0) + np.power(L[2],2.0))
        #		L_norm = np.zeros(3)
        #		L_norm[0] = L[0].value/L_mag
        #		L_norm[1] = L[1].value/L_mag
        #		L_norm[2] = L[2].value/L_mag

        #		sphere.set_field_parameter("bulk_velocity",bv)
        #		sphere.set_field_parameter("normal",sphere.ds.arr(L_norm,"code_length"))

        #		cold_sphere.set_field_parameter("bulk_velocity",bv)
        #		cold_sphere.set_field_parameter("normal",sphere.ds.arr(L_norm,"code_length"))

        add_particle_filter("young_stars",
                            function=young_star_filter,
                            filtered_type="all",
                            requires=["particle_age"])
        cylinder.ds.add_particle_filter("young_stars")

        # cold gas

        print "filtering spatially"
        spatial_filter_tot = filter_utils.min_max_filter(
            cylinder, "particle_position_relative_z", min_z, max_z)
        spatial_filter_dark = filter_utils.min_max_filter(
            cylinder, ('dark', 'particle_position_relative_z'), min_z, max_z)
        spatial_filter_stars = filter_utils.min_max_filter(
            cylinder, ('stars', 'particle_position_relative_z'), min_z, max_z)
        spatial_filter_young_stars = filter_utils.min_max_filter(
            cylinder, ('young_stars', 'particle_position_relative_z'), min_z,
            max_z)

        r_tot = np.sqrt(
            np.power(
                cylinder["particle_position_relative_x"][spatial_filter_tot],
                2) + np.power(
                    cylinder["particle_position_relative_y"]
                    [spatial_filter_tot], 2))
        r_stars = np.sqrt(
            np.power(
                cylinder["stars", "particle_position_relative_x"]
                [spatial_filter_stars], 2) + np.power(
                    cylinder["stars", "particle_position_relative_y"]
                    [spatial_filter_stars], 2))
        r_young_stars = np.sqrt(
            np.power(
                cylinder["young_stars", "particle_position_relative_x"]
                [spatial_filter_young_stars], 2) + np.power(
                    cylinder["young_stars", "particle_position_relative_y"]
                    [spatial_filter_young_stars], 2))
        r_dark = np.sqrt(
            np.power(
                cylinder["dark", "particle_position_relative_x"]
                [spatial_filter_dark], 2) + np.power(
                    cylinder["dark", "particle_position_relative_y"]
                    [spatial_filter_dark], 2))

        #		r_gas = sphere["cylindrical_r"]
        #		r_cold_gas = cold_sphere["cylindrical_r"]

        print "computing vrots"
        #		vrot_tot = utils.manual_vrot(cylinder,type="all",r_filter = spatial_filter_tot)

        #		vrot_stars = utils.manual_vrot(cylinder,type="stars",r_filter = spatial_filter_stars)
        #		vrot_young_stars = utils.manual_vrot(cylinder,type="young_stars",r_filter = spatial_filter_young_stars)
        #		vrot_dark = utils.manual_vrot(cylinder,type="dark",r_filter = spatial_filter_dark)

        vrot_stars = yt.ProfilePlot(
            cylinder, ('stars', 'particle_position_cylindrical_radius'),
            [('stars', 'particle_velocity_cylindrical_theta')],
            weight_field=('stars', 'particle_mass'),
            n_bins=n_bins,
            x_log=False,
            y_log={('stars', 'particle_velocity_cylindrical_theta'): False})
        vrot_young_stars = yt.ProfilePlot(
            cylinder, ('young_stars', 'particle_position_cylindrical_radius'),
            [('young_stars', 'particle_velocity_cylindrical_theta')],
            weight_field=('young_stars', 'particle_mass'),
            n_bins=n_bins,
            x_log=False,
            y_log={
                ('young_stars', 'particle_velocity_cylindrical_theta'): False
            })
        vrot_dark = yt.ProfilePlot(
            cylinder, ('dark', 'particle_position_cylindrical_radius'),
            [('dark', 'particle_velocity_cylindrical_theta')],
            weight_field=('dark', 'particle_mass'),
            n_bins=n_bins,
            x_log=False,
            y_log={('dark', 'particle_velocity_cylindrical_theta'): False})

        r_stars_binned = vrot_stars.profiles[0].x.in_units("kpc").value
        r_young_stars_binned = vrot_young_stars.profiles[0].x.in_units(
            "kpc").value
        vrot_stars_binned = np.abs(vrot_stars.profiles[0][(
            'stars',
            'particle_velocity_cylindrical_theta')]).in_units("km/s").value
        vrot_young_stars_binned = np.abs(vrot_young_stars.profiles[0][(
            'young_stars',
            'particle_velocity_cylindrical_theta')]).in_units("km/s").value

        # this is not filtering in height yet

        vrot_gas = yt.ProfilePlot(cylinder,
                                  'cylindrical_r',
                                  ["velocity_cylindrical_theta"],
                                  weight_field="cell_mass",
                                  n_bins=n_bins,
                                  x_log=False,
                                  y_log={"velocity_cylindrical_theta": False})
        r_gas = vrot_gas.profiles[0].x
        vrot_gas = np.abs(vrot_gas.profiles[0]["velocity_cylindrical_theta"]
                          )  # this overwrites the yt plot object

        vrot_cold_gas = yt.ProfilePlot(
            cold_disk,
            'cylindrical_r', ["velocity_cylindrical_theta"],
            weight_field="cell_mass",
            n_bins=n_bins,
            x_log=False,
            y_log={"velocity_cylindrical_theta": False})
        r_cold_gas = vrot_cold_gas.profiles[0].x
        vrot_cold_gas = np.abs(
            vrot_cold_gas.profiles[0]["velocity_cylindrical_theta"])

        # bin the particle data
        print "binning the data"
        #	r_tot_binned, vrot_tot_binned = plot_manual_profile(r_tot,vrot_tot,units=["kpc","km/s"],filter=None,bins=30,abs=True,weight_profile="ones")
        #	r_stars_binned, vrot_stars_binned = plot_manual_profile(r_stars,vrot_stars,units=["kpc","km/s"],filter=None,bins=30,abs=True,weight_profile="ones")
        #	r_dark_binned, vrot_dark_binned = plot_manual_profile(r_dark,vrot_dark,units=["kpc","km/s"],filter=None,bins=30,abs=True,weight_profile="ones")
        #	r_young_stars_binned, vrot_young_stars_binned = plot_manual_profile(r_young_stars,vrot_young_stars,units=["kpc","km/s"],filter=None,bins=30,abs=True,weight_profile="ones")

        # make the plots look a little more pretty
        r_gas, vrot_gas = flatten_line(r_gas.in_units("kpc").value,
                                       vrot_gas.in_units("km/s").value,
                                       no_nan=False,
                                       extra_x=r_bins.in_units("kpc").max())
        # make the plots look a little more pretty
        r_cold_gas, vrot_cold_gas = flatten_line(
            r_cold_gas.in_units("kpc").value,
            vrot_cold_gas.in_units("km/s").value,
            no_nan=False,
            extra_x=r_bins.in_units("kpc").max())

        r_stars_binned, vrot_stars_binned = flatten_line(
            r_stars_binned,
            vrot_stars_binned,
            no_nan=True,
            append_max=True,
            double_zero=True,
            extra_x=r_bins.in_units("kpc").max())
        r_young_stars_binned, vrot_young_stars_binned = flatten_line(
            r_young_stars_binned,
            vrot_young_stars_binned,
            no_nan=True,
            append_max=True,
            double_zero=True,
            extra_x=r_bins.in_units("kpc").max())

        # finally do the plots
        print "plotting the data"
        #		plt.plot(r_dark,vrot_dark,label="vrot dark")
        plt.plot(r_stars_binned,
                 vrot_stars_binned,
                 label=r"$V_{rot,stars}$",
                 color="blue",
                 linestyle='dashed')
        plt.plot(r_young_stars_binned,
                 vrot_young_stars_binned,
                 label=r"$V_{rot,young stars}$",
                 color="purple",
                 linestyle='dashed')
        plt.plot(r_gas,
                 vrot_gas,
                 label=r"$V_{rot,gas}$",
                 color="red",
                 linestyle='dashed')
        plt.plot(r_cold_gas,
                 vrot_cold_gas,
                 label=r"$V_{rot,cold gas}$",
                 color="orange",
                 linestyle='dashed')

    plt.legend()
    plt.savefig(("%s_rot_circ.png" % galaxy_name))
    plt.savefig(("%s_rot_circ.pdf" % galaxy_name))
    plt.close()
コード例 #19
0
ファイル: simple_radial_profile.py プロジェクト: tukss/yt
import yt

# Load the dataset.
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")

# Create a sphere of radius 100 kpc in the center of the box.
my_sphere = ds.sphere("c", (100.0, "kpc"))

# Create a profile of the average density vs. radius.
plot = yt.ProfilePlot(my_sphere, "radius", "density", weight_field="cell_mass")

# Change the units of the radius into kpc (and not the default in cgs)
plot.set_unit("radius", "kpc")

# Save the image.
# Optionally, give a string as an argument
# to name files with a keyword.
plot.save()
コード例 #20
0
ファイル: Jan_19_Plotting.py プロジェクト: samdf96/myrepo
z_projected_angular_momentum_y.save("z_projected_angular_momentum_y.png")
z_projected_angular_momentum_x = yt.ProjectionPlot(ds,
                                                   "z",
                                                   "angular_momentum_x",
                                                   data_source=ad)
z_projected_angular_momentum_x.set_cmap(field="angular_momentum_x", cmap='bwr')
z_projected_angular_momentum_x.save("z_projected_angular_momentum_x.png")

#Velocity along z direction of z-velocity
z_projected_z_velocity = yt.ProjectionPlot(ds, "z", "velocity_z")
z_projected_z_velocity.set_cmap(field="velocity_z", cmap='bwr')
z_projected_z_velocity.save("z_velocity_density_plot.png")

#Basic Probability Density Plots

plot_1D_PDF_Density = yt.ProfilePlot(ad, "density", "ones", weight_field=None)
plot_1D_PDF_Density.save("1D_PDF_Density.png")

##############################################################################

#Analysis of Data Section

# This creates a projection weighting by density
vz = ad.integrate('velocity_z', weight='density', axis='z')

# The projection has fields 'px' and 'py' for the position.

plt.scatter(vz['px'], vz['py'], c=vz['velocity_z'])
plt.colorbar()
plt.show()
コード例 #21
0
	age_str = row[1]

	#f = np.loadtxt(clusterdir + run + '/sm.dat', skiprows=1)
	f = np.loadtxt(clusterdir + row[0] + '/sm.dat', skiprows=1)
	R = f[:,0]
	rho = f[:,1]
	T = f[:,2]
	P = f[:,3]

	chks = [x.zfill(4) for x in args.chk]
	for chk in chks:
		#ds = yt.load(clusterdir + run + '/multitidal_hdf5_chk_' + chk)
		ds = yt.load(clusterdir + row[0] + '/multitidal_hdf5_chk_' + chk)
		sp = ds.sphere("c", (1.1*max(R), "cm"))

		plot = yt.ProfilePlot(sp, "radius", ["density"],
			weight_field="cell_mass", n_bins=2000, accumulation=False, x_log=False, y_log={'density':False})

		profile = plot.profiles[0]
		R_FLASH =  profile.x
		rho_FLASH = profile["density"]

		# account for zeros in FLASH array due to binning
		R_FLASH = R_FLASH[np.where(rho_FLASH > 0.)[0]]
		rho_FLASH = rho_FLASH[np.where(rho_FLASH > 0.)[0]]

		# prepend first density to zero. this is the density of the first cell
		R_FLASH = np.insert(np.array(R_FLASH), 0, 0)
		rho_FLASH = np.insert(np.array(rho_FLASH), 0, rho_FLASH[0])

		fig, ax = plt.subplots()
		if not args.linear:
コード例 #22
0
ファイル: simple_profile.py プロジェクト: stefanarridge/yt
import yt

# Load the dataset.
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")

# Create a 1D profile within a sphere of radius 100 kpc
# of the average temperature and average velocity_x
# vs. density, weighted by mass.
sphere = ds.sphere("c", (100.0, "kpc"))
plot = yt.ProfilePlot(
    sphere,
    ("gas", "density"),
    [("gas", "temperature"), ("gas", "velocity_x")],
    weight_field=("gas", "mass"),
)
plot.set_log(("gas", "velocity_x"), False)

# Save the image.
# Optionally, give a string as an argument
# to name files with a keyword.
plot.save()
コード例 #23
0
 def setUpClass(cls):
     ds = fake_random_ds(16)
     ad = ds.all_data()
     cls.fields = ["velocity_x", "velocity_y", "velocity_z"]
     cls.plot = yt.ProfilePlot(ad, "radius", cls.fields, weight_field=None)
コード例 #24
0
r_max = 1.2
Const = TotM / (Disc_Decay_R -
                (Disc_Decay_R + r_max) * math.exp(-r_max / Disc_Decay_R))
Const /= (2 * 3.141 * Disc_Decay_R)
yt.enable_parallelism()
ts = yt.load([
    prefix + '/Data_%06d' % idx for idx in range(idx_start, idx_end + 1, didx)
])

for ds in ts.piter():
    my_disk = ds.disk([1.5, 1.5, 1.5], [0., 0., 1.], (1.3, 'code_length'),
                      (disc_thickness, 'code_length'))
    prof = yt.ProfilePlot(my_disk, ("index", "cylindrical_r"),
                          'ParDens',
                          weight_field='cell_volume',
                          n_bins=64,
                          x_log=False)
    surface_dens = prof.profiles[0]["ParDens"].in_units(
        "code_mass/(code_length*code_length*code_length)").d
    surface_dens *= disc_thickness
    logSurDens = np.log10(surface_dens)
    radius = prof.profiles[0].x.in_units("code_length").d
    sumM = 2 * 3.1416 * radius * 1.3 / 64 * surface_dens
    print('TotM=', np.sum(sumM))
    #   print('Sur=',surface_dens)
    #   print('log=',logSurDens)
    #   coefficient = np.polyfit(radius[0:-4],logSurDens[0:-4],1)
    #   print(coefficient)

    #   print(my_disk.quantities.total_mass())
コード例 #25
0
def find_galaxyprops(galaxy_props, ds, hc_sphere, max_ndens_arr):

    print('Determining stellar and gas mass...')
    # Get total stellar mass
    stars_mass = hc_sphere[('stars', 'particle_mass')].in_units('Msun')
    stars_total_mass = stars_mass.sum().value[()]
    galaxy_props['stars_total_mass'] = np.append(
        galaxy_props['stars_total_mass'], stars_total_mass)

    # Get total mass of gas
    gas_mass = hc_sphere[('gas', 'cell_mass')].in_units('Msun')
    gas_total_mass = gas_mass.sum().value[()]
    galaxy_props['gas_total_mass'] = np.append(galaxy_props['gas_total_mass'],
                                               gas_total_mass)
    print('\tlog Mgas/Msun = ', log10(gas_total_mass))
    print('\tlog M*/Msun = ', log10(stars_total_mass))

    print('Determining location of max stellar density...')
    # Get max density of stars (value, location)
    stars_maxdens = hc_sphere.quantities.max_location(('deposit', 'stars_cic'))
    stars_maxdens_val = stars_maxdens[0].in_units('Msun/kpc**3').value[()]

    print(stars_maxdens)
    #difference bt yt-3.2.3 and yt-3.3dev: stars_maxdens has different # elements; this works for both
    stars_maxdens_loc = np.array([
        stars_maxdens[-3].in_units('kpc').value[()],
        stars_maxdens[-2].in_units('kpc').value[()],
        stars_maxdens[-1].in_units('kpc').value[()]
    ])
    galaxy_props['stars_maxdens'].append(
        (stars_maxdens_val, stars_maxdens_loc))
    print('\t Max Stellar Density = ', stars_maxdens_loc)

    print('Determining location of max gas density...')
    # Get max density of gas
    gas_maxdens = hc_sphere.quantities.max_location(('gas', 'density'))
    gas_maxdens_val = gas_maxdens[0].in_units('Msun/kpc**3').value[()]
    gas_maxdens_loc = np.array([
        gas_maxdens[-3].in_units('kpc').value[()],
        gas_maxdens[-2].in_units('kpc').value[()],
        gas_maxdens[-1].in_units('kpc').value[()]
    ])
    galaxy_props['gas_maxdens'].append((gas_maxdens_val, gas_maxdens_loc))
    print('\t Max Gas Density = ', stars_maxdens_loc)

    print('Determining refined histogram center of stars...')
    #---Need to Check these--#
    # Get refined histogram center of stars
    stars_pos_x = hc_sphere[('stars', 'particle_position_x')].in_units('kpc')
    stars_pos_y = hc_sphere[('stars', 'particle_position_y')].in_units('kpc')
    stars_pos_z = hc_sphere[('stars', 'particle_position_z')].in_units('kpc')

    stars_pos = np.array([stars_pos_x, stars_pos_y, stars_pos_z]).transpose()
    stars_hist_center = find_hist_center(stars_pos, stars_mass)
    galaxy_props['stars_hist_center'].append(stars_hist_center)
    print('\t Refined histogram center of stars = ', stars_hist_center)

    print('Computing stellar density profile...')
    # Get stellar density profile
    sc_sphere_r = 0.1
    ssphere_r = sc_sphere_r * hc_sphere.radius
    while ssphere_r < ds.index.get_smallest_dx():
        ssphere_r = 2.0 * ssphere_r
    sc_sphere = ds.sphere(max_ndens_arr, ssphere_r)

    try:
        p_plot = yt.ProfilePlot(sc_sphere,
                                'radius',
                                'stars_mass',
                                n_bins=50,
                                weight_field=None,
                                accumulation=True)
        p_plot.set_unit('radius', 'kpc')
        p_plot.set_unit('stars_mass', 'Msun')
        p = p_plot.profiles[0]

        radii, smass = p.x.value, p['stars_mass'].value
        rhalf = radii[smass >= 0.5 * smass.max()][0]
    except (IndexError, ValueError):  # not enough stars found
        radii, smass = None, None
        rhalf = None
    galaxy_props['stars_rhalf'] = np.append(galaxy_props['stars_rhalf'], rhalf)
    galaxy_props['stars_mass_profile'].append((radii, smass))

    print('\tStars half-light radius = ', rhalf)

    print('Determining center of mass within 15 kpc of the galaxy...')
    # Get center of mass of stars
    gal_sphere = ds.sphere(max_ndens_arr, (15, 'kpc'))
    stars_pos_x = gal_sphere[('stars', 'particle_position_x')].in_units('kpc')
    stars_pos_y = gal_sphere[('stars', 'particle_position_y')].in_units('kpc')
    stars_pos_z = gal_sphere[('stars', 'particle_position_z')].in_units('kpc')
    gal_stars_mass = gal_sphere[('stars', 'particle_mass')].in_units('Msun')
    gal_total_mass = gal_stars_mass.sum().value[()]

    stars_com = np.array([
        np.dot(stars_pos_x, gal_stars_mass) / gal_total_mass,
        np.dot(stars_pos_y, gal_stars_mass) / gal_total_mass,
        np.dot(stars_pos_z, gal_stars_mass) / gal_total_mass
    ])
    galaxy_props['stars_com'].append(stars_com)
    print('\tCenter of mass = ', stars_com)

    print('Setting stars center...')
    # Define center of stars
    center = 'maxndens'
    if center == 'max_dens':
        stars_center = stars_maxdens_loc
    elif center == 'com':
        stars_center = stars_com
    elif center == 'maxndens':
        stars_center = max_ndens_arr
    else:
        stars_center = stars_hist_center

    stars_center = ds.arr(stars_center, 'kpc')
    galaxy_props['stars_center'].append(stars_hist_center)
    print('\tStars Center = ', stars_center)

    # Get angular momentum of stars
    try:
        x, y, z = [
            sc_sphere[('stars', 'particle_position_%s' % s)] for s in 'xyz'
        ]
        vx, vy, vz = [
            sc_sphere[('stars', 'particle_velocity_%s' % s)] for s in 'xyz'
        ]
        mass = sc_sphere[('stars', 'particle_mass')]
        try:
            metals = sc_sphere[('stars', 'particle_metallicity1')]
            stars_L = L_crossing(x, y, z, vx, vy, vz, mass * metals,
                                 sc_sphere.center)
        except:
            stars_L = L_crossing(x, y, z, vx, vy, vz, mass, sc_sphere.center)

    except IndexError:  # no stars found
        stars_L = [None, None, None]
        print("No stars exception")

    galaxy_props['stars_L'].append(stars_L)
    del (sc_sphere)

    # Get angular momentum of gas
    gas_center = ds.arr(gas_maxdens_loc, 'kpc')
    gc_sphere = ds.sphere(gas_center, ssphere_r)
    x, y, z = [gc_sphere[('gas', '%s' % s)] for s in 'xyz']
    cell_volume = gc_sphere[('gas', 'cell_volume')]

    try:
        #for VELA runs
        vx, vy, vz = [gc_sphere[('gas', 'momentum_%s' % s)]
                      for s in 'xyz']  # momentum density
        metals = gc_sphere[('gas', 'metal_ia_density')] + gc_sphere[
            ('gas', 'metal_ii_density')]
        gas_L = L_crossing(x, y, z, vx, vy, vz, metals * cell_volume**2,
                           gc_sphere.center)
    except:
        #for enzo runs
        density = gc_sphere[('gas', 'density')]
        vx, vy, vz = [gc_sphere[('gas', 'velocity_%s' % s)] for s in 'xyz']
        metals = gc_sphere[('gas', 'metal_density')]
        gas_L = L_crossing(x, y, z, density * vx, density * vy, density * vz,
                           metals * cell_volume**2, gc_sphere.center)

    galaxy_props['gas_L'].append(gas_L)
    del (gc_sphere)

    return galaxy_props
コード例 #26
0
import yt

# Load the dataset.
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")

# Create a sphere of radius 100 kpc in the center of the box.
my_sphere = ds.sphere("c", (100.0, "kpc"))

# Create a profile of the average density vs. radius.
plot = yt.ProfilePlot(
    my_sphere,
    ("index", "radius"),
    ("gas", "density"),
    weight_field=("gas", "cell_mass"),
)

# Change the units of the radius into kpc (and not the default in cgs)
plot.set_unit(("index", "radius"), "kpc")

# Save the image.
# Optionally, give a string as an argument
# to name files with a keyword.
plot.save()
コード例 #27
0
ファイル: DataIOTest.py プロジェクト: cindytsai/libyt
def yt_inline_ProfilePlot():
    ds = yt.frontends.libyt.libytDataset()
    profile = yt.ProfilePlot(ds, "x", ["density"])
    if yt.is_root():
        profile.save()
コード例 #28
0
ファイル: simple_profile.py プロジェクト: tukss/yt
import yt

# Load the dataset.
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")

# Create a 1D profile within a sphere of radius 100 kpc
# of the average temperature and average velocity_x
# vs. density, weighted by mass.
sphere = ds.sphere("c", (100.0, "kpc"))
plot = yt.ProfilePlot(sphere,
                      "density", ["temperature", "velocity_x"],
                      weight_field="cell_mass")
plot.set_log("velocity_x", False)

# Save the image.
# Optionally, give a string as an argument
# to name files with a keyword.
plot.save()
コード例 #29
0
#output = int(sys.argv[1])
output = 3035

ds = ytf.load_romulusC(output)
cen = rom_help.get_romulus_yt_center('romulusC', output, ds)
ad = ds.sphere(cen, (3300, 'kpc'))
#sp = ad.cut_region(["(obj[('gas', 'metal_cooling_time')]>0) & (obj[('gas', 'metal_primordial_cooling_time_ratio')] > 0) & (obj[('gas', 'temperature')] >= 1e4)  & (obj[('gas', 'temperature')] <= 1e6) & (obj[('gas', 'particle_H_nuclei_density')] > 1e-6) & (obj[('gas', 'particle_H_nuclei_density')] < 1e-2)"])

sp = ad.cut_region(["(obj[('gas', 'temperature')] >= 1e4)  & (obj[('gas', 'temperature')] <= 1e6) & (obj[('gas', 'particle_H_nuclei_density')] > 1e-6) & (obj[('gas', 'particle_H_nuclei_density')] < 1e-2)"])
#sp = ad

xfield = ('gas', 'spherical_position_radius')
yfield = ('Gas', 'Mass')
#mass enclosed needs to have all mass, not just CGM mass
pm = yt.ProfilePlot(ad, xfield, yfield, weight_field = None, accumulation = True, n_bins = 128)
pm.set_unit(xfield, 'cm')
pm.set_unit(yfield, 'g')
pm.set_log(xfield, False)

profile = pm.profiles[0]
rbins = profile.x
print(rbins)
mass_enc = profile[yfield]

G = YTQuantity(6.67e-8, 'cm**3/g/s**2')
num = np.pi * rbins**(3./2.)
denom = np.sqrt(2*G*mass_enc)
tff2 = num / denom

g = G*mass_enc / rbins**2
コード例 #30
0
ファイル: manual_utils.py プロジェクト: cosmosquark/ramses_pp
def vrot(datadict,
         field_labels,
         ytdataset,
         fields=["stars", "young_stars", "disk_stars", "gas", "cold_gas"],
         n_bins=50,
         AMR=True,
         manual=False):
    """
	Input

		ytdataset: A ytdataset with gas cells or gas particles.
			particulally of the region you want to work with (e.g a disk)
		fields: list of fields to compute vrot for

	output
		r_bins_list = list of r)bins in kpc
		
	"""

    vrot_list = []
    rbins_list = []

    r_max = ytdataset["particle_position_cylindrical_radius"].max().in_units(
        "kpc")
    r_indices, r_bins, r_filter, r_truths = utils.radial_indices(
        'particle_position_spherical_radius',
        ytdataset,
        r_min=None,
        r_max=r_max,
        dr_factor=2)
    for field in fields:

        if field == "gas" and AMR == True:
            vrot = yt.ProfilePlot(ytdataset,
                                  'cylindrical_r',
                                  ["velocity_cylindrical_theta"],
                                  weight_field="cell_mass",
                                  n_bins=n_bins,
                                  x_log=False,
                                  y_log={"velocity_cylindrical_theta": False})
            r_binned = vrot.profiles[0].x.in_units("kpc").value
            vrot_binned = -vrot.profiles[0][
                "velocity_cylindrical_theta"].in_units(
                    "km/s").value  # this overwrites the yt plot object

        elif field == "cold_gas" and AMR == True:

            cold_disk = ytdataset.cut_region(["obj['temperature'] < 1e4"])
            vrot = yt.ProfilePlot(cold_disk,
                                  'cylindrical_r',
                                  ["velocity_cylindrical_theta"],
                                  weight_field="cell_mass",
                                  n_bins=n_bins,
                                  x_log=False,
                                  y_log={"velocity_cylindrical_theta": False})
            r_binned = vrot.profiles[0].x.in_units("kpc").value
            vrot_binned = -vrot.profiles[0][
                "velocity_cylindrical_theta"].in_units("km/s").value

        else:
            if manual == False:

                #	vrot = yt.create_profile(ytdataset,[(field,'particle_position_cylindrical_radius')],[(field,'particle_velocity_cylindrical_theta')],logs={"particle_position_cylindrical_radius":False, 'particle_velocity_cylindrical_theta':False}, weight_field='particle_mass')
                #	r_binned = vrot.x.in_units("kpc").value
                #	vrot_binned = vrot[(field,'particle_velocity_cylindrical_theta')].in_units("km/s").value
                #vrot = yt.ProfilePlot(ytdataset,(field,'particle_position_cylindrical_radius'),[(field,'particle_velocity_cylindrical_theta')],weight_field=(field,'particle_mass'),n_bins=n_bins,x_log=False,y_log={(field,'particle_velocity_cylindrical_theta'):False})
                vrot = yt.ProfilePlot(
                    ytdataset, (field, 'particle_position_cylindrical_radius'),
                    [(field, 'particle_vtheta')],
                    weight_field=(field, 'particle_mass'),
                    n_bins=n_bins,
                    x_log=False,
                    y_log={(field, 'particle_vtheta'): False})
                r_binned = vrot.profiles[0].x.in_units("kpc").value
                vrot_binned = -vrot.profiles[0][
                    (field, 'particle_vtheta')].in_units("km/s").value

            else:
                #		# manual profile plot
                hist, bins = np.histogram(
                    ytdataset[field,
                              'particle_position_cylindrical_radius'].in_units(
                                  "kpc").value,
                    bins=n_bins)
                print hist, bins, field
                inds = np.digitize(
                    ytdataset[field,
                              'particle_position_cylindrical_radius'].in_units(
                                  "kpc").value,
                    bins=bins)
                # shifts down to index 0
                inds = inds - 1
                # include the max values in the last bin
                inds[np.argmax(inds)] = inds.max() - 1

                width = (bins[:-1] + bins[1:]) / 2.0
                #		  #time = time[:i1]
                # want to compute the mass weight ... vrot * mass_i / mass_mean in each bin
                #  average of sum of (vrot * mass_i)  / mass_tot

                #vrot_thing = np.array([ np.sum(ytdataset[field,"particle_velocity_cylindrical_theta"][inds == j].in_units("km/s").value * ytdataset[field,"particle_mass"][inds == j].in_units("Msun").value) for j in range(len(bins))])
                vrot_thing = np.array([
                    np.sum(ytdataset[field, "particle_vtheta"][
                        inds == j].in_units("km/s").value *
                           ytdataset[field, "particle_mass"][
                               inds == j].in_units("Msun").value)
                    for j in range(len(bins))
                ])
                vrot_binned = vrot_thing / np.array(
                    [(ytdataset[field, "particle_mass"][inds == j].in_units(
                        "Msun").value).sum() for j in range(len(bins))])
                #
                #				#vrot_binned[vrot_binned == 0] = np.nan
                vrot_binned[vrot_binned == np.nan] = 0.0
                vrot_binned = abs(vrot_binned)
                #
                r_binned = bins

            # make things pretty
    #	r_binned, vrot_binned = flatten_line(r_binned,vrot_binned,no_nan=True,append_max=True,double_zero=True,extra_x = r_bins.in_units("kpc").max())

        datadict.update({
            "vrot_r_%s" % field: r_binned,
            "vrot_v_%s" % field: vrot_binned,
        })

        field_labels.update({
            "vrot_r_%s" % field: ("Radius ( kpc )", None),
            "vrot_v_%s" % field: ("Rotational Velocity ( km/s )",
                                  r"$V_{rot,%s}$" % field.replace("_", " ")),
        })

    return datadict, field_labels