Hi all, I have what is probably quite a basic problem to solve, however I am not very experienced using yt and have only managed basic density and temperature plots. I am having issues plotting metallicity, using this script: from yt import * import sys for i in range(1,len(sys.argv)): ds = load(sys.argv[i]) ds.print_stats() #val, loc = ds.find_max("density") #plot = SlicePlot(ds, 2, ["density","Temperature"] plot = SlicePlot(ds, 2, ("metallicity_fraction"), center= [0.4913024902343750, 0.5008239746093750, 0.4982604980468750], width= (10, 'kpc')) #plot = SlicePlot(ds, 'z', ('all', metallicity),center=[0.4913024902343750, 0.5008239746093750, 0.4982604980468750],width = (10,'kpc')) #plot.set_zlim('all', 1e1, 1e5) plot.annotate_timestamp(corner='upper_left', redshift=True, draw_inset_box=True) #plot.set_cmap(field="Temperature", cmap='hot') plot.save() This script works fine when for plotting density and temperature but I get this error when using the un-commented line above: "_MPL.error: data is of incorrect type (wanted 1D float)" I've been trying to get this to work for a while now so any help would be greatly appreciated. Thanks, Chris Jessop
Hi Chris,
What's happening here is that metallicity_fraction is a particle field, but
SlicePlot can only be used to plot fields that are defined on the AMR mesh.
I get a different error message that explains what's happening when I try
to plot that field in the latest version of yt - is it possible you're
using an old y version?
If you're trying to plot the metallicity of gas, then the field you're
looking for is the ("gas", "metallicity") field. If you really do want to
plot the metallicity of e.g. the star particles then you could either use
the mesh deposition machinery and plot a "deposit" field to deposit the
particle metallicity field onto the AMR mesh or you could use ParticlePlot
to plot particle metallicities directly.
-Nathan
On Fri, Dec 7, 2018 at 9:33 AM
Hi all,
I have what is probably quite a basic problem to solve, however I am not very experienced using yt and have only managed basic density and temperature plots. I am having issues plotting metallicity, using this script:
from yt import * import sys
for i in range(1,len(sys.argv)): ds = load(sys.argv[i]) ds.print_stats()
#val, loc = ds.find_max("density") #plot = SlicePlot(ds, 2, ["density","Temperature"] plot = SlicePlot(ds, 2, ("metallicity_fraction"), center= [0.4913024902343750, 0.5008239746093750, 0.4982604980468750], width= (10, 'kpc')) #plot = SlicePlot(ds, 'z', ('all', metallicity),center=[0.4913024902343750, 0.5008239746093750, 0.4982604980468750],width = (10,'kpc')) #plot.set_zlim('all', 1e1, 1e5) plot.annotate_timestamp(corner='upper_left', redshift=True, draw_inset_box=True) #plot.set_cmap(field="Temperature", cmap='hot') plot.save()
This script works fine when for plotting density and temperature but I get this error when using the un-commented line above: "_MPL.error: data is of incorrect type (wanted 1D float)"
I've been trying to get this to work for a while now so any help would be greatly appreciated.
Thanks, Chris Jessop _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
Thanks for the information. I changed the line: plot = SlicePlot(ds, 2, ("metallicity_fraction"), center= [0.4913024902343750, 0.5008239746093750, 0.4982604980468750], width= (10, 'kpc')) to plot = SlicePlot(ds, 2, ("gas","metallicity"), center= [0.4913024902343750, 0.5008239746093750, 0.4982604980468750], width= (10, 'kpc')) and try to run it but it says it could not find the field. I should mention that I'm trying to plot metallicity as a fraction of solar metallicity from a supernova explosion, so Z/Z_solar
What’s the content of ds.field_list?
On Sat, Dec 8, 2018 at 6:45 AM
Thanks for the information. I changed the line: plot = SlicePlot(ds, 2, ("metallicity_fraction"), center= [0.4913024902343750, 0.5008239746093750, 0.4982604980468750], width= (10, 'kpc')) to plot = SlicePlot(ds, 2, ("gas","metallicity"), center= [0.4913024902343750, 0.5008239746093750, 0.4982604980468750], width= (10, 'kpc')) and try to run it but it says it could not find the field. I should mention that I'm trying to plot metallicity as a fraction of solar metallicity from a supernova explosion, so Z/Z_solar _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
The contents of ds.field_list: ('all', 'creation_time') ('all', 'dynamical_time') ('all', 'metallicity_fraction') ('all', 'particle_index') ('all', 'particle_mass') ('all', 'particle_position_x') ('all', 'particle_position_y') ('all', 'particle_position_z') ('all', 'particle_type') ('all', 'particle_velocity_x') ('all', 'particle_velocity_y') ('all', 'particle_velocity_z') ('enzo', 'Dark_Matter_Density') ('enzo', 'Density') ('enzo', 'Electron_Density') ('enzo', 'GasEnergy') ('enzo', 'H2II_Density') ('enzo', 'H2I_Density') ('enzo', 'H2I_kdiss') ('enzo', 'HII_Density') ('enzo', 'HI_Density') ('enzo', 'HI_kph') ('enzo', 'HM_Density') ('enzo', 'HeIII_Density') ('enzo', 'HeII_Density') ('enzo', 'HeII_kph') ('enzo', 'HeI_Density') ('enzo', 'HeI_kph') ('enzo', 'PhotoGamma') ('enzo', 'SN_Colour') ('enzo', 'Temperature') ('enzo', 'TotalEnergy') ('enzo', 'x-velocity') ('enzo', 'y-velocity') ('enzo', 'z-velocity') ('io', 'creation_time') ('io', 'dynamical_time') ('io', 'metallicity_fraction') ('io', 'particle_index') ('io', 'particle_mass') ('io', 'particle_position_x') ('io', 'particle_position_y') ('io', 'particle_position_z') ('io', 'particle_type') ('io', 'particle_velocity_x') ('io', 'particle_velocity_y') ('io', 'particle_velocity_z')
So it looks like you don’t have an (“enzo”, “Metal_Density”) field, so the
gas metallicity field is not present in the output you’re looking at. You
do have the primordial species fields, but no metals. Your star particles
do have a metallicity field thoughz
On Sat, Dec 8, 2018 at 9:33 AM
The contents of ds.field_list:
('all', 'creation_time') ('all', 'dynamical_time') ('all', 'metallicity_fraction') ('all', 'particle_index') ('all', 'particle_mass') ('all', 'particle_position_x') ('all', 'particle_position_y') ('all', 'particle_position_z') ('all', 'particle_type') ('all', 'particle_velocity_x') ('all', 'particle_velocity_y') ('all', 'particle_velocity_z') ('enzo', 'Dark_Matter_Density') ('enzo', 'Density') ('enzo', 'Electron_Density') ('enzo', 'GasEnergy') ('enzo', 'H2II_Density') ('enzo', 'H2I_Density') ('enzo', 'H2I_kdiss') ('enzo', 'HII_Density') ('enzo', 'HI_Density') ('enzo', 'HI_kph') ('enzo', 'HM_Density') ('enzo', 'HeIII_Density') ('enzo', 'HeII_Density') ('enzo', 'HeII_kph') ('enzo', 'HeI_Density') ('enzo', 'HeI_kph') ('enzo', 'PhotoGamma') ('enzo', 'SN_Colour') ('enzo', 'Temperature') ('enzo', 'TotalEnergy') ('enzo', 'x-velocity') ('enzo', 'y-velocity') ('enzo', 'z-velocity') ('io', 'creation_time') ('io', 'dynamical_time') ('io', 'metallicity_fraction') ('io', 'particle_index') ('io', 'particle_mass') ('io', 'particle_position_x') ('io', 'particle_position_y') ('io', 'particle_position_z') ('io', 'particle_type') ('io', 'particle_velocity_x') ('io', 'particle_velocity_y') ('io', 'particle_velocity_z') _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
I see. Is there a parameter I have to set manually to have the metallicity field appear in enzo? Looking through the docs I can't see what it would be, but I imagine that I am most likely missing something Thanks
So this is quickly becoming a discussion for enzo-users, but perhaps you
could share your Enzo parameter file? I believe you would have needed to
run your original simulation with metal cooling turned on, in which case it
would show up in the outputs.
On Sat, Dec 8, 2018 at 10:24 AM
I see. Is there a parameter I have to set manually to have the metallicity field appear in enzo? Looking through the docs I can't see what it would be, but I imagine that I am most likely missing something
Thanks _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
It must be because I did not turn on metal cooling, I never set it in my parameter file. I'll make the change. Thanks very much for the help Chris
If you are running an Enzo cosmology simulation, there is a parameter to turn on the metal field: CosmologySimulationUseMetallicityField = 1 Cheers, Greg
On Dec 9, 2018, at 8:21 AM, up765045@myport.ac.uk wrote:
It must be because I did not turn on metal cooling, I never set it in my parameter file. I'll make the change. Thanks very much for the help
Chris _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
Thanks, Greg!
Dan
On Mon, Dec 10, 2018 at 3:54 PM Greg L Bryan
If you are running an Enzo cosmology simulation, there is a parameter to turn on the metal field:
CosmologySimulationUseMetallicityField = 1
Cheers, Greg
On Dec 9, 2018, at 8:21 AM, up765045@myport.ac.uk wrote:
It must be because I did not turn on metal cooling, I never set it in my parameter file. I'll make the change. Thanks very much for the help
Chris _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
participants (4)
-
Daniel Whalen
-
Greg L Bryan
-
Nathan Goldbaum
-
up765045@myport.ac.uk