Hey Britton,
That was the issue, works exactly as intended now. I just have one other
question about the override_bins part. I am currently making 3 different
profiles, one for the gas, one for the darkmatter, and one for the stars.
It seems like even with the same sphere object in yt, they use different
bins. In order to make the bins between each profile the same, I have tried
adding the dict asked for, but I am unsure of the proper formatting of
this. I have tried a couple of different …
[View More]configurations, like the one
posted below, but keep running into errors. I was unable to find anything
in the documentation about such formatting for these types of dicts, do you
know where such information is posted?
Here is one dict I tried, as well as the error message.
{(9, 26.321025738981803), (8, 23.39646732353938), (44,
128.6805702794666), (24, 70.18940197061814), (21, 61.41572672429087),
(15, 43.86837623163633), (47, 137.45424552579385), (50,
146.22792077212114), (19, 55.566609893406024), (2, 5.849116830884845),
(6, 17.547350492654534), (32, 93.58586929415752), (18,
52.642051477963605), (22, 64.3402851397333), (1, 2.9245584154424225),
(7, 20.47190890809696), (28, 81.88763563238784), (36,
105.28410295592721), ('stars', 'particle_radius'), (29,
84.81219404783025), (37, 108.20866137136963), (41,
119.90689503313934), (43, 125.75601186402417), (35,
102.35954454048479), (38, 111.13321978681205), (25,
73.11396038606057), (49, 143.3033623566787), (20, 58.49116830884846),
(0, 0.0), (45, 131.605128694909), (31, 90.6613108787151), (39,
114.05777820225448), (23, 67.26484355517572), (34, 99.43498612504237),
(42, 122.83145344858174), (33, 96.51042770959995), (17,
49.717493062521186), (12, 35.09470098530907), (14, 40.94381781619392),
(4, 11.69823366176969), (27, 78.96307721694541), (30,
87.73675246327267), (40, 116.98233661769692), (3, 8.773675246327267),
(5, 14.622792077212114), (11, 32.17014256986665), (13,
38.019259400751494), (46, 134.52968711035143), (16,
46.79293464707876), (10, 29.24558415442423), (26, 76.03851880150299),
(48, 140.37880394123627)}
---------------------------------------------------------------------------TypeError
Traceback (most recent call
last)<ipython-input-8-a7f92b976f9a> in <module> 27 28
rp_stars = yt.create_profile(sp, ('stars', 'particle_radius'),
[('stars', 'particle_mass')], accumulation = True,---> 29
units = {('stars', 'particle_radius'): 'kpc',
('stars', 'particle_mass'): 'Msun'}, weight_field=None,
override_bins=bins_dict) 30 31 rp_darkmatter =
yt.create_profile(sp, ('darkmatter', 'particle_radius'),
[('darkmatter', 'particle_mass')], accumulation = True,
~/anaconda3/lib/python3.7/site-packages/yt/data_objects/profiles.py in
create_profile(data_source, bin_fields, fields, n_bins, extrema, logs,
units, weight_field, accumulation, fractional, deposition,
override_bins) 1058 extrema = sanitize_field_tuple_keys(extrema,
data_source) 1059 logs = sanitize_field_tuple_keys(logs,
data_source)-> 1060 override_bins =
sanitize_field_tuple_keys(override_bins, data_source) 1061 1062
if any(is_pfield) and not all(is_pfield):
~/anaconda3/lib/python3.7/site-packages/yt/data_objects/profiles.py in
sanitize_field_tuple_keys(input_dict, data_source) 960
dummy = {} 961 for item in input_dict:--> 962
dummy[data_source._determine_fields(item)[0]] = input_dict[item]
963 return dummy 964 else:
TypeError: 'set' object is not subscriptable
[View Less]
Hello,
I've run into a problem when trying to initialize a simulation object
with a start time and finish time. My code is:
import yt
from yt.units import Myr
simulation = yt.simulation("DD0005/output_0005", 'Enzo')
simulation.get_time_series(initial_time= 284.098 * Myr, final_time=
284.292 * Myr, redshift_data=False)
Trying to run this script results in the following error:
Traceback (most recent call last):
File "mini_test.py", line 5, in <module>
…
[View More]simulation.get_time_series(initial_time= 284.098 * Myr, final_time=
284.292 * Myr, redshift_data=False)
File
"/opt/apps/pkgs/cpython/3.7.1/intel64/intel_2019.2/lib/python3.7/site-packages/yt/frontends/enzo/simulation_handling.py",
line 292, in get_time_series
my_initial_time.convert_to_units("s")
UnboundLocalError: local variable 'my_initial_time' referenced before
assignment
Any help on this issue would be much appreciated.
Many thanks,
Sam Patrick
[View Less]
Hi,
I’ve been generating phase plot data and overlaying other lines using matplotlib and I noticed that passing the profile data as is into pcolormesh results in a flipped plot. In order to get the correct image, I find that I need to
do a transpose to the 2-d array before passing it to pcolormesh.
Is this the desired behavior?
Cheers,
DK
_______________
Just a snippet of what I’m doing.
p2d = sph.profile(['density','magnetic_field_magnitude’],['cell_mass'],weight_field=None)
C = p2d['…
[View More]cell_mass'].in_units('Msun’)
#C = p2d['cell_mass'].in_units('Msun’).transpose() <- I have to do this to get it right
fig = plt.figure(figsize=(8,6))
ax = fig.add_subplot(111)
ax.set_xscale('log’)
ax.set_yscale('log')
ax.pcolormesh(p2d.x,p2d.y,C,norm=colors.LogNorm())
[View Less]
Hello all,
The documentation for the YTRegion class states "If the selected region extends past the edges of the domain, no data will be found there, though the object’s left_edge or right_edge are not modified.” Is there an easy way to change this to exhibit periodic behavior? For example: if the specified right_edge extended past the edges of the domain, data will be selected as continuing from the left of the domain.
My ultimate goal is to create a square region centered on argmax(“density”…
[View More]) and calculate summed quantities in the region while successively increasing the size of the box assuming periodic boundaries.
Does anyone have any insight?
[View Less]