Data InspectionΒΆ

[]

Starting Out and Loading Data

We're going to get started by loading up yt. This next command brings all of the libraries into memory and sets up our environment.

In [1]:
import yt

Now that we've loaded yt, we can load up some data. Let's load the IsolatedGalaxy dataset.

In [2]:
ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")

Fields and Facts

When you call the load function, yt tries to do very little -- this is designed to be a fast operation, just setting up some information about the simulation. Now, the first time you access the "index" it will read and load the mesh and then determine where data is placed in the physical domain and on disk. Once it knows that, yt can tell you some statistics about the simulation:

In [3]:
ds.print_stats()
level	# grids	       # cells	     # cells^3
----------------------------------------------
  0	     1	         32768	            32
  1	     8	         34304	            33
  2	     8	        181888	            57
  3	     8	        646968	            87
  4	    15	        947856	            99
  5	    51	        874128	            96
  6	    18	        786328	            93
  7	    28	        446776	            77
  8	    36	        209400	            60
----------------------------------------------
   	   173	       4160416


t = 6.00002000e-03 = 1.39768066e+16 s = 4.42898275e+08 years

Smallest Cell:
	Width: 1.221e-04 Mpc
	Width: 1.221e+02 pc
	Width: 2.518e+07 AU
	Width: 3.767e+20 cm

yt can also tell you the fields it found on disk:

In [4]:
ds.field_list
Out[4]:
[('enzo', 'Dark_Matter_Density'),
 ('enzo', 'SFR_Density'),
 ('io', 'particle_position_z'),
 ('enzo', 'Density'),
 ('enzo', 'kphHI'),
 ('enzo', 'By'),
 ('io', 'particle_type'),
 ('enzo', 'HeIII_Density'),
 ('enzo', 'Metal_Density'),
 ('enzo', 'z-velocity'),
 ('io', 'dynamical_time'),
 ('enzo', 'HI_Density'),
 ('enzo', 'kphHeII'),
 ('enzo', 'kphHeI'),
 ('enzo', 'Electron_Density'),
 ('enzo', 'Bz'),
 ('io', 'particle_velocity_x'),
 ('io', 'particle_velocity_y'),
 ('enzo', 'HII_Density'),
 ('enzo', 'Forming_Stellar_Mass_Density'),
 ('io', 'particle_index'),
 ('enzo', 'Star_Particle_Density'),
 ('io', 'metallicity_fraction'),
 ('enzo', 'x-velocity'),
 ('enzo', 'MBHColour'),
 ('io', 'particle_position_x'),
 ('enzo', 'Temperature'),
 ('enzo', 'Cooling_Time'),
 ('enzo', 'HeII_Density'),
 ('io', 'particle_velocity_z'),
 ('enzo', 'Galaxy2Colour'),
 ('enzo', 'y-velocity'),
 ('io', 'creation_time'),
 ('enzo', 'TotalEnergy'),
 ('io', 'particle_position_y'),
 ('enzo', 'HeI_Density'),
 ('enzo', 'gammaHI'),
 ('enzo', 'Phi_pField'),
 ('enzo', 'Galaxy1Colour'),
 ('io', 'particle_mass'),
 ('enzo', 'Average_creation_time'),
 ('enzo', 'PhiField'),
 ('enzo', 'Bx'),
 ('all', 'particle_type'),
 ('all', 'metallicity_fraction'),
 ('all', 'particle_mass'),
 ('all', 'creation_time'),
 ('all', 'particle_position_z'),
 ('all', 'particle_position_x'),
 ('all', 'particle_position_y'),
 ('all', 'dynamical_time'),
 ('all', 'particle_index'),
 ('all', 'particle_velocity_z'),
 ('all', 'particle_velocity_x'),
 ('all', 'particle_velocity_y')]

And, all of the fields it thinks it knows how to generate:

In [5]:
ds.derived_field_list
Out[5]:
[('all', 'age'),
 ('all', 'creation_time'),
 ('all', 'dynamical_time'),
 ('all', 'mesh_id'),
 ('all', 'metallicity_fraction'),
 ('all', 'particle_angular_momentum_magnitude'),
 ('all', 'particle_angular_momentum_x'),
 ('all', 'particle_angular_momentum_y'),
 ('all', 'particle_angular_momentum_z'),
 ('all', 'particle_index'),
 ('all', 'particle_mass'),
 ('all', 'particle_ones'),
 ('all', 'particle_phi_spherical'),
 ('all', 'particle_phi_velocity'),
 ('all', 'particle_position'),
 ('all', 'particle_position_x'),
 ('all', 'particle_position_y'),
 ('all', 'particle_position_z'),
 ('all', 'particle_radial_velocity'),
 ('all', 'particle_radius'),
 ('all', 'particle_radius_spherical'),
 ('all', 'particle_specific_angular_momentum'),
 ('all', 'particle_specific_angular_momentum_magnitude'),
 ('all', 'particle_specific_angular_momentum_x'),
 ('all', 'particle_specific_angular_momentum_y'),
 ('all', 'particle_specific_angular_momentum_z'),
 ('all', 'particle_theta_spherical'),
 ('all', 'particle_theta_velocity'),
 ('all', 'particle_type'),
 ('all', 'particle_velocity'),
 ('all', 'particle_velocity_magnitude'),
 ('all', 'particle_velocity_x'),
 ('all', 'particle_velocity_y'),
 ('all', 'particle_velocity_z'),
 ('deposit', 'all_cic'),
 ('deposit', 'all_count'),
 ('deposit', 'all_density'),
 ('deposit', 'all_mass'),
 ('deposit', 'io_cic'),
 ('deposit', 'io_count'),
 ('deposit', 'io_density'),
 ('deposit', 'io_mass'),
 ('enzo', 'Average_creation_time'),
 ('enzo', 'Bx'),
 ('enzo', 'By'),
 ('enzo', 'Bz'),
 ('enzo', 'Cooling_Time'),
 ('enzo', 'Dark_Matter_Density'),
 ('enzo', 'Density'),
 ('enzo', 'Electron_Density'),
 ('enzo', 'Forming_Stellar_Mass_Density'),
 ('enzo', 'Galaxy1Colour'),
 ('enzo', 'Galaxy2Colour'),
 ('enzo', 'HII_Density'),
 ('enzo', 'HI_Density'),
 ('enzo', 'HeIII_Density'),
 ('enzo', 'HeII_Density'),
 ('enzo', 'HeI_Density'),
 ('enzo', 'MBHColour'),
 ('enzo', 'Metal_Density'),
 ('enzo', 'PhiField'),
 ('enzo', 'Phi_pField'),
 ('enzo', 'SFR_Density'),
 ('enzo', 'Star_Particle_Density'),
 ('enzo', 'Temperature'),
 ('enzo', 'TotalEnergy'),
 ('enzo', 'gammaHI'),
 ('enzo', 'kphHI'),
 ('enzo', 'kphHeI'),
 ('enzo', 'kphHeII'),
 ('enzo', 'x-velocity'),
 ('enzo', 'y-velocity'),
 ('enzo', 'z-velocity'),
 ('gas', 'El_density'),
 ('gas', 'El_fraction'),
 ('gas', 'El_mass'),
 ('gas', 'El_number_density'),
 ('gas', 'H_density'),
 ('gas', 'H_fraction'),
 ('gas', 'H_mass'),
 ('gas', 'H_number_density'),
 ('gas', 'H_p1_density'),
 ('gas', 'H_p1_fraction'),
 ('gas', 'H_p1_mass'),
 ('gas', 'H_p1_number_density'),
 ('gas', 'He_density'),
 ('gas', 'He_fraction'),
 ('gas', 'He_mass'),
 ('gas', 'He_number_density'),
 ('gas', 'He_p1_density'),
 ('gas', 'He_p1_fraction'),
 ('gas', 'He_p1_mass'),
 ('gas', 'He_p1_number_density'),
 ('gas', 'He_p2_density'),
 ('gas', 'He_p2_fraction'),
 ('gas', 'He_p2_mass'),
 ('gas', 'He_p2_number_density'),
 ('gas', 'angular_momentum_magnitude'),
 ('gas', 'angular_momentum_x'),
 ('gas', 'angular_momentum_y'),
 ('gas', 'angular_momentum_z'),
 ('gas', 'averaged_density'),
 ('gas', 'baroclinic_vorticity_magnitude'),
 ('gas', 'baroclinic_vorticity_x'),
 ('gas', 'baroclinic_vorticity_y'),
 ('gas', 'baroclinic_vorticity_z'),
 ('gas', 'cell_mass'),
 ('gas', 'chandra_emissivity'),
 ('gas', 'cooling_time'),
 ('gas', 'courant_time_step'),
 ('gas', 'cutting_plane_velocity_x'),
 ('gas', 'cutting_plane_velocity_y'),
 ('gas', 'cutting_plane_velocity_z'),
 ('gas', 'cylindrical_radial_velocity'),
 ('gas', 'cylindrical_radial_velocity_absolute'),
 ('gas', 'cylindrical_tangential_velocity'),
 ('gas', 'cylindrical_tangential_velocity_absolute'),
 ('gas', 'dark_matter_density'),
 ('gas', 'density'),
 ('gas', 'density_gradient_magnitude'),
 ('gas', 'density_gradient_x'),
 ('gas', 'density_gradient_y'),
 ('gas', 'density_gradient_z'),
 ('gas', 'dynamical_time'),
 ('gas', 'entropy'),
 ('gas', 'jeans_mass'),
 ('gas', 'kT'),
 ('gas', 'kinetic_energy'),
 ('gas', 'mach_number'),
 ('gas', 'magnetic_energy'),
 ('gas', 'magnetic_field_poloidal'),
 ('gas', 'magnetic_field_strength'),
 ('gas', 'magnetic_field_toroidal'),
 ('gas', 'magnetic_field_x'),
 ('gas', 'magnetic_field_y'),
 ('gas', 'magnetic_field_z'),
 ('gas', 'magnetic_pressure'),
 ('gas', 'matter_density'),
 ('gas', 'matter_mass'),
 ('gas', 'mean_molecular_weight'),
 ('gas', 'metal_density'),
 ('gas', 'metal_mass'),
 ('gas', 'metallicity'),
 ('gas', 'number_density'),
 ('gas', 'plasma_beta'),
 ('gas', 'pressure'),
 ('gas', 'pressure_gradient_magnitude'),
 ('gas', 'pressure_gradient_x'),
 ('gas', 'pressure_gradient_y'),
 ('gas', 'pressure_gradient_z'),
 ('gas', 'radial_mach_number'),
 ('gas', 'radial_velocity'),
 ('gas', 'radial_velocity_absolute'),
 ('gas', 'shear'),
 ('gas', 'shear_criterion'),
 ('gas', 'shear_mach'),
 ('gas', 'sound_speed'),
 ('gas', 'specific_angular_momentum_magnitude'),
 ('gas', 'specific_angular_momentum_x'),
 ('gas', 'specific_angular_momentum_y'),
 ('gas', 'specific_angular_momentum_z'),
 ('gas', 'sz_kinetic'),
 ('gas', 'szy'),
 ('gas', 'tangential_over_velocity_magnitude'),
 ('gas', 'tangential_velocity'),
 ('gas', 'temperature'),
 ('gas', 'thermal_energy'),
 ('gas', 'velocity_divergence'),
 ('gas', 'velocity_divergence_absolute'),
 ('gas', 'velocity_magnitude'),
 ('gas', 'velocity_x'),
 ('gas', 'velocity_y'),
 ('gas', 'velocity_z'),
 ('gas', 'vorticity_growth_magnitude'),
 ('gas', 'vorticity_growth_magnitude_absolute'),
 ('gas', 'vorticity_growth_timescale'),
 ('gas', 'vorticity_growth_x'),
 ('gas', 'vorticity_growth_y'),
 ('gas', 'vorticity_growth_z'),
 ('gas', 'vorticity_magnitude'),
 ('gas', 'vorticity_squared'),
 ('gas', 'vorticity_stretching_magnitude'),
 ('gas', 'vorticity_stretching_x'),
 ('gas', 'vorticity_stretching_y'),
 ('gas', 'vorticity_stretching_z'),
 ('gas', 'vorticity_x'),
 ('gas', 'vorticity_y'),
 ('gas', 'vorticity_z'),
 ('gas', 'xray_emissivity'),
 ('index', 'cell_volume'),
 ('index', 'cylindrical_r'),
 ('index', 'cylindrical_theta'),
 ('index', 'cylindrical_z'),
 ('index', 'disk_angle'),
 ('index', 'dx'),
 ('index', 'dy'),
 ('index', 'dz'),
 ('index', 'grid_indices'),
 ('index', 'grid_level'),
 ('index', 'height'),
 ('index', 'ones'),
 ('index', 'ones_over_dx'),
 ('index', 'radius'),
 ('index', 'spherical_phi'),
 ('index', 'spherical_r'),
 ('index', 'spherical_theta'),
 ('index', 'x'),
 ('index', 'y'),
 ('index', 'z'),
 ('index', 'zeros'),
 ('io', 'age'),
 ('io', 'creation_time'),
 ('io', 'dynamical_time'),
 ('io', 'mesh_id'),
 ('io', 'metallicity_fraction'),
 ('io', 'particle_angular_momentum_magnitude'),
 ('io', 'particle_angular_momentum_x'),
 ('io', 'particle_angular_momentum_y'),
 ('io', 'particle_angular_momentum_z'),
 ('io', 'particle_index'),
 ('io', 'particle_mass'),
 ('io', 'particle_ones'),
 ('io', 'particle_phi_spherical'),
 ('io', 'particle_phi_velocity'),
 ('io', 'particle_position'),
 ('io', 'particle_position_x'),
 ('io', 'particle_position_y'),
 ('io', 'particle_position_z'),
 ('io', 'particle_radial_velocity'),
 ('io', 'particle_radius'),
 ('io', 'particle_radius_spherical'),
 ('io', 'particle_specific_angular_momentum'),
 ('io', 'particle_specific_angular_momentum_magnitude'),
 ('io', 'particle_specific_angular_momentum_x'),
 ('io', 'particle_specific_angular_momentum_y'),
 ('io', 'particle_specific_angular_momentum_z'),
 ('io', 'particle_theta_spherical'),
 ('io', 'particle_theta_velocity'),
 ('io', 'particle_type'),
 ('io', 'particle_velocity'),
 ('io', 'particle_velocity_magnitude'),
 ('io', 'particle_velocity_x'),
 ('io', 'particle_velocity_y'),
 ('io', 'particle_velocity_z')]

yt can also transparently generate fields. However, we encourage you to examine exactly what yt is doing when it generates those fields. To see, you can ask for the source of a given field.

In [6]:
print ds.field_info["gas", "vorticity_x"].get_source()
    def _vorticity_x(field, data):
        f  = (data[ftype, "velocity_z"][sl_center,sl_right,sl_center] -
              data[ftype, "velocity_z"][sl_center,sl_left,sl_center]) \
              / (div_fac*just_one(data["index", "dy"]).in_cgs())
        f -= (data[ftype, "velocity_y"][sl_center,sl_center,sl_right] -
              data[ftype, "velocity_y"][sl_center,sl_center,sl_left]) \
              / (div_fac*just_one(data["index", "dz"].in_cgs()))
        new_field = data.ds.arr(np.zeros_like(data[ftype, "velocity_z"],
                                              dtype=np.float64),
                                f.units)
        new_field[sl_center, sl_center, sl_center] = f
        return new_field


yt stores information about the domain of the simulation:

In [7]:
print ds.domain_width
[ 1.  1.  1.] code_length

yt can also convert this into various units:

In [8]:
print ds.domain_width.in_units("kpc")
print ds.domain_width.in_units("au")
print ds.domain_width.in_units("mile")
[ 1000.10448889  1000.10448889  1000.10448889] kpc
[  2.06286359e+11   2.06286359e+11   2.06286359e+11] au
[  1.91755627e+19   1.91755627e+19   1.91755627e+19] mile

Mesh Structure

If you're using a simulation type that has grids (for instance, here we're using an Enzo simulation) you can examine the structure of the mesh. For the most part, you probably won't have to use this unless you're debugging a simulation or examining in detail what is going on.

In [9]:
print ds.index.grid_left_edge
[[ 0.          0.          0.        ]
 [ 0.25        0.21875     0.25      ]
 [ 0.5         0.21875     0.25      ]
 [ 0.21875     0.5         0.25      ]
 [ 0.5         0.5         0.25      ]
 [ 0.25        0.25        0.5       ]
 [ 0.5         0.25        0.5       ]
 [ 0.25        0.5         0.5       ]
 [ 0.5         0.5         0.5       ]
 [ 0.5         0.5         0.5       ]
 [ 0.5         0.5         0.5       ]
 [ 0.5         0.5         0.5       ]
 [ 0.5         0.5         0.5       ]
 [ 0.50976562  0.5         0.5       ]
 [ 0.50976562  0.5         0.50585938]
 [ 0.50976562  0.53515625  0.50585938]
 [ 0.52148438  0.53515625  0.50585938]
 [ 0.52148438  0.54101562  0.52539062]
 [ 0.52734375  0.53515625  0.50585938]
 [ 0.50976562  0.5         0.50585938]
 [ 0.50976562  0.5         0.5       ]
 [ 0.5         0.5         0.5       ]
 [ 0.5         0.5         0.5       ]
 [ 0.5         0.5         0.50585938]
 [ 0.50634766  0.50244141  0.50585938]
 [ 0.50488281  0.5         0.50585938]
 [ 0.5         0.50390625  0.50585938]
 [ 0.5         0.5         0.5       ]
 [ 0.28125     0.5         0.5       ]
 [ 0.3359375   0.5         0.5       ]
 [ 0.40625     0.5         0.5       ]
 [ 0.4453125   0.5         0.5       ]
 [ 0.44921875  0.52539062  0.50390625]
 [ 0.46289062  0.52734375  0.5       ]
 [ 0.48242188  0.52539062  0.5       ]
 [ 0.46875     0.54492188  0.5078125 ]
 [ 0.45703125  0.52539062  0.51953125]
 [ 0.47851562  0.52539062  0.5       ]
 [ 0.46484375  0.52539062  0.5       ]
 [ 0.45898438  0.52539062  0.50585938]
 [ 0.48242188  0.52539062  0.52539062]
 [ 0.47070312  0.52539062  0.51953125]
 [ 0.47851562  0.52539062  0.52539062]
 [ 0.47851562  0.5         0.5       ]
 [ 0.49023438  0.5         0.5       ]
 [ 0.49658203  0.51025391  0.50048828]
 [ 0.49462891  0.5         0.5       ]
 [ 0.49584961  0.5         0.5       ]
 [ 0.49584961  0.50048828  0.5       ]
 [ 0.49584961  0.5012207   0.5       ]
 [ 0.49804688  0.5012207   0.5       ]
 [ 0.49633789  0.50341797  0.5       ]
 [ 0.49658203  0.5012207   0.50073242]
 [ 0.49658203  0.50244141  0.50073242]
 [ 0.49780273  0.5012207   0.50146484]
 [ 0.5         0.28125     0.5       ]
 [ 0.5         0.3359375   0.5       ]
 [ 0.5         0.40625     0.5       ]
 [ 0.50195312  0.44140625  0.50585938]
 [ 0.5         0.45117188  0.5       ]
 [ 0.515625    0.44335938  0.5       ]
 [ 0.53125     0.46289062  0.5       ]
 [ 0.53125     0.49023438  0.5       ]
 [ 0.53125     0.4609375   0.515625  ]
 [ 0.53125     0.47265625  0.515625  ]
 [ 0.53125     0.48046875  0.515625  ]
 [ 0.53125     0.48632812  0.53125   ]
 [ 0.54101562  0.484375    0.515625  ]
 [ 0.53710938  0.48046875  0.53320312]
 [ 0.5         0.47460938  0.50195312]
 [ 0.5         0.47949219  0.5       ]
 [ 0.50292969  0.4765625   0.50195312]
 [ 0.50195312  0.48779297  0.50048828]
 [ 0.5         0.48974609  0.5       ]
 [ 0.5         0.49609375  0.50976562]
 [ 0.5         0.49414062  0.5       ]
 [ 0.5         0.49707031  0.5       ]
 [ 0.28125     0.28125     0.5       ]
 [ 0.3359375   0.3359375   0.5       ]
 [ 0.46484375  0.37890625  0.50390625]
 [ 0.40625     0.40625     0.5       ]
 [ 0.49609375  0.44335938  0.50585938]
 [ 0.44921875  0.453125    0.5       ]
 [ 0.4765625   0.47753906  0.5       ]
 [ 0.49755859  0.48925781  0.50097656]
 [ 0.49023438  0.49121094  0.5       ]
 [ 0.49609375  0.48828125  0.50341797]
 [ 0.49633789  0.49389648  0.5       ]
 [ 0.49487305  0.49926758  0.5       ]
 [ 0.49731445  0.49609375  0.5       ]
 [ 0.49755859  0.49609375  0.5       ]
 [ 0.49487305  0.49707031  0.5       ]
 [ 0.49682617  0.49682617  0.5       ]
 [ 0.5         0.5         0.28125   ]
 [ 0.5         0.5         0.3359375 ]
 [ 0.5         0.5         0.40234375]
 [ 0.5         0.5         0.453125  ]
 [ 0.5         0.5         0.4765625 ]
 [ 0.5         0.5         0.49121094]
 [ 0.5         0.5         0.49682617]
 [ 0.50170898  0.5         0.49804688]
 [ 0.50170898  0.50219727  0.49853516]
 [ 0.50219727  0.50219727  0.4987793 ]
 [ 0.50170898  0.50219727  0.49951172]
 [ 0.50292969  0.50219727  0.49951172]
 [ 0.265625    0.5         0.28125   ]
 [ 0.3359375   0.5         0.328125  ]
 [ 0.40234375  0.5         0.40625   ]
 [ 0.45117188  0.5         0.45117188]
 [ 0.49804688  0.5         0.47265625]
 [ 0.47460938  0.5         0.4765625 ]
 [ 0.49316406  0.50195312  0.48730469]
 [ 0.48925781  0.50244141  0.49658203]
 [ 0.49072266  0.5         0.49072266]
 [ 0.49926758  0.50048828  0.49560547]
 [ 0.49487305  0.5         0.49926758]
 [ 0.49707031  0.5         0.49707031]
 [ 0.49609375  0.50219727  0.49951172]
 [ 0.49658203  0.5         0.49853516]
 [ 0.5         0.265625    0.28125   ]
 [ 0.5         0.3203125   0.328125  ]
 [ 0.5         0.3984375   0.40625   ]
 [ 0.546875    0.41796875  0.4453125 ]
 [ 0.546875    0.453125    0.41796875]
 [ 0.546875    0.4375      0.4375    ]
 [ 0.546875    0.4921875   0.41796875]
 [ 0.546875    0.48046875  0.41796875]
 [ 0.55859375  0.46875     0.43359375]
 [ 0.5         0.4609375   0.4453125 ]
 [ 0.5         0.44921875  0.47460938]
 [ 0.51367188  0.47265625  0.46289062]
 [ 0.51367188  0.47460938  0.45703125]
 [ 0.52734375  0.47070312  0.46679688]
 [ 0.51367188  0.46679688  0.46875   ]
 [ 0.5         0.47460938  0.47753906]
 [ 0.5         0.49023438  0.49072266]
 [ 0.50488281  0.49560547  0.48974609]
 [ 0.50488281  0.49169922  0.49365234]
 [ 0.50488281  0.49511719  0.49365234]
 [ 0.50488281  0.49511719  0.49462891]
 [ 0.50488281  0.49707031  0.49267578]
 [ 0.50488281  0.49853516  0.49316406]
 [ 0.5         0.49560547  0.49707031]
 [ 0.50317383  0.4987793   0.49902344]
 [ 0.265625    0.28125     0.28125   ]
 [ 0.328125    0.3359375   0.328125  ]
 [ 0.4140625   0.40625     0.40625   ]
 [ 0.49414062  0.43945312  0.48632812]
 [ 0.45703125  0.4765625   0.46875   ]
 [ 0.48632812  0.44921875  0.453125  ]
 [ 0.45117188  0.4921875   0.453125  ]
 [ 0.44921875  0.453125    0.47851562]
 [ 0.46289062  0.484375    0.45507812]
 [ 0.484375    0.46484375  0.45703125]
 [ 0.47265625  0.47851562  0.46484375]
 [ 0.47265625  0.45898438  0.47070312]
 [ 0.4765625   0.47265625  0.46289062]
 [ 0.4765625   0.47070312  0.46679688]
 [ 0.47363281  0.48535156  0.49414062]
 [ 0.47363281  0.48339844  0.49707031]
 [ 0.48242188  0.48535156  0.48632812]
 [ 0.48144531  0.48339844  0.49121094]
 [ 0.47753906  0.4921875   0.48632812]
 [ 0.48632812  0.47558594  0.47753906]
 [ 0.49511719  0.49707031  0.48632812]
 [ 0.49755859  0.49560547  0.48828125]
 [ 0.49169922  0.48974609  0.49414062]
 [ 0.49023438  0.49169922  0.49072266]
 [ 0.49560547  0.49853516  0.49951172]
 [ 0.49707031  0.49707031  0.49853516]
 [ 0.49658203  0.49755859  0.49707031]
 [ 0.49902344  0.49560547  0.49755859]
 [ 0.49804688  0.49609375  0.49853516]] code_length

But, you may have to access information about individual grid objects! Each grid object mediates accessing data from the disk and has a number of attributes that tell you about it. The index (ds.index here) has an attribute grids which is all of the grid objects.

In [10]:
print ds.index.grids[1]
EnzoGrid_0002

In [11]:
g = ds.index.grids[1]
print g
EnzoGrid_0002

Grids have dimensions, extents, level, and even a list of Child grids.

In [12]:
g.ActiveDimensions
Out[12]:
array([16, 18, 16], dtype=int32)
In [13]:
g.LeftEdge, g.RightEdge
Out[13]:
(YTArray([ 0.25   ,  0.21875,  0.25   ]) code_length,
 YTArray([ 0.5,  0.5,  0.5]) code_length)
In [14]:
g.Level
Out[14]:
1
In [15]:
g.Children
Out[15]:
[EnzoGrid_0145]

Advanced Grid Inspection

If we want to examine grids only at a given level, we can! Not only that, but we can load data and take a look at various fields.

This section can be skipped!

In [16]:
gs = ds.index.select_grids(ds.index.max_level)
In [17]:
g2 = gs[0]
print g2
print g2.Parent
print g2.get_global_startindex()
EnzoGrid_0028
EnzoGrid_0023
[4096 4096 4096]

In [18]:
print g2["density"][:,:,0]
[[  1.01363690e-25   3.45646382e-25   6.41925898e-25 ...,   5.96696509e-25
    5.10014698e-25   4.21704727e-25]
 [  1.76641648e-25   4.39171143e-25   7.10127952e-25 ...,   4.83368357e-25
    2.33865852e-25   1.54410574e-25]
 [  2.03982852e-25   5.07130376e-25   8.93401738e-25 ...,   1.58189599e-25
    6.55056907e-26   4.26830665e-26]
 ..., 
 [  4.70574906e-25   2.85658342e-25   1.60217995e-25 ...,   9.89565377e-27
    1.04609558e-26   1.10698239e-26]
 [  2.17375380e-25   1.26144714e-25   8.58855917e-26 ...,   9.51497754e-27
    9.96838536e-27   1.05070102e-26]
 [  9.00905100e-26   6.88664354e-26   6.34225309e-26 ...,   9.17543455e-27
    9.52855304e-27   1.00110840e-26]] g/cm**3

In [19]:
print (g2.Parent.child_mask == 0).sum() * 8
print g2.ActiveDimensions.prod()
33592
33592

In [20]:
for f in ds.field_list:
    fv = g[f]
    if fv.size == 0: continue
    print f, fv.min(), fv.max()
('enzo', 'Dark_Matter_Density') 0.0 code_mass/code_length**3 1.08606159687 code_mass/code_length**3
('enzo', 'SFR_Density') 1.00000001335e-10 dimensionless 1.00000001335e-10 dimensionless
('io', 'particle_position_z') 0.262642536623 code_length 0.495103839026 code_length
('enzo', 'Density') 0.156463041902 code_mass/code_length**3 1204.91357422 code_mass/code_length**3
('enzo', 'kphHI') 0.0 dimensionless 0.0 dimensionless
('enzo', 'By') 0.0 code_magnetic 0.0 code_magnetic
('io', 'particle_type') 1.0 dimensionless 1.0 dimensionless
('enzo', 'HeIII_Density') 0.036707662046 code_mass/code_length**3 29.4213027954 code_mass/code_length**3
('enzo', 'Metal_Density') 1.16512828754e-05 code_mass/code_length**3 1.55436336994 code_mass/code_length**3
('enzo', 'z-velocity') -1.04746866226 code_velocity 9.70476531982 code_velocity
('io', 'dynamical_time') 0.0 code_time 0.0 code_time
('enzo', 'HI_Density') 1.21849467405e-07 code_mass/code_length**3 178.852462769 code_mass/code_length**3
('enzo', 'kphHeII') 0.0 dimensionless 0.0 dimensionless
('enzo', 'kphHeI') 0.0 dimensionless 0.0 dimensionless
('enzo', 'Electron_Density') 0.137466937304 code_mass/code_length**3 799.525878906 code_mass/code_length**3
('enzo', 'Bz') 0.0127916038036 code_magnetic 0.0128318462521 code_magnetic
('io', 'particle_velocity_x') -3771602.32827 cm/s 6406800.04744 cm/s
('io', 'particle_velocity_y') -9214187.76783 cm/s 1247333.9407 cm/s
('enzo', 'HII_Density') 0.118902929127 code_mass/code_length**3 735.700683594 code_mass/code_length**3
('enzo', 'Forming_Stellar_Mass_Density') 1.00000001335e-10 dimensionless 1.00000001335e-10 dimensionless
('io', 'particle_index') 495510.0 dimensionless 999626.0 dimensionless
('enzo', 'Star_Particle_Density') 1.00000001335e-10 dimensionless 1.00000001335e-10 dimensionless
('io', 'metallicity_fraction') 0.0 code_metallicity 0.0 code_metallicity
('enzo', 'x-velocity') -0.868919789791 code_velocity 10.2385663986 code_velocity
('enzo', 'MBHColour') 2.3229605739e-11 dimensionless 6.06533767655e-10 dimensionless
('io', 'particle_position_x') 0.41541787346 code_length 0.497860468025 code_length
('enzo', 'Temperature') 5423.74902344 K 13363.3720703 K
('enzo', 'Cooling_Time') 3.92001623163e+13 s 1.19623192733e+19 s
('enzo', 'HeII_Density') 0.000840668857563 code_mass/code_length**3 196.457885742 code_mass/code_length**3
('io', 'particle_velocity_z') -9018941.98647 cm/s -186059.661756 cm/s
('enzo', 'Galaxy2Colour') 0.156463041902 dimensionless 1724.44177246 dimensionless
('enzo', 'y-velocity') -1.54692029953 code_velocity 7.30749988556 code_velocity
('io', 'creation_time') 0.0 code_time 0.0 code_time
('enzo', 'TotalEnergy') 0.649765729904 code_velocity**2 1.43175756931 code_velocity**2
('io', 'particle_position_y') 0.262784210986 code_length 0.49402845958 code_length
('enzo', 'HeI_Density') 3.82205067595e-09 code_mass/code_length**3 62.9270782471 code_mass/code_length**3
('enzo', 'gammaHI') 0.0 dimensionless 0.0 dimensionless
('enzo', 'Phi_pField') 0.0 dimensionless 0.0 dimensionless
('enzo', 'Galaxy1Colour') 0.156463041902 dimensionless 1724.44177246 dimensionless
('io', 'particle_mass') 4.25554145453e+38 g 4.25554145453e+38 g
('enzo', 'Average_creation_time') 0.0 dimensionless 0.0 dimensionless
('enzo', 'PhiField') 0.0 dimensionless 0.0 dimensionless
('enzo', 'Bx') 0.0 code_magnetic 0.0 code_magnetic
('all', 'particle_type') 1.0 dimensionless 1.0 dimensionless
('all', 'metallicity_fraction') 0.0 dimensionless 0.0 dimensionless
('all', 'particle_mass') 4.25554145453e+38 g 4.25554145453e+38 g
('all', 'creation_time') 0.0 s 0.0 s
('all', 'particle_position_z') 0.262642536623 code_length 0.495103839026 code_length
('all', 'particle_position_x') 0.41541787346 code_length 0.497860468025 code_length
('all', 'particle_position_y') 0.262784210986 code_length 0.49402845958 code_length
('all', 'dynamical_time') 0.0 s 0.0 s
('all', 'particle_index') 495510.0 dimensionless 999626.0 dimensionless
('all', 'particle_velocity_z') -9018941.98647 cm/s -186059.661756 cm/s
('all', 'particle_velocity_x') -3771602.32827 cm/s 6406800.04744 cm/s
('all', 'particle_velocity_y') -9214187.76783 cm/s 1247333.9407 cm/s

Examining Data in Regions

yt provides data object selectors. In subsequent notebooks we'll examine these in more detail, but we can select a sphere of data and perform a number of operations on it. yt makes it easy to operate on fluid fields in an object in bulk, but you can also examine individual field values.

This creates a sphere selector positioned at the most dense point in the simulation that has a radius of 10 kpc.

In [21]:
sp = ds.sphere("max", (10, 'kpc'))
In [22]:
print sp
YTSphere (galaxy0030): center=[ 0.50408936  0.49981689  0.50018311] code_length, radius=10.0 kpc

We can calculate a bunch of bulk quantities. Here's that list, but there's a list in the docs, too!

In [23]:
print sp.quantities.keys()
['SpinParameter', 'MinLocation', 'WeightedVariance', 'TotalMass', 'AngularMomentumVector', 'WeightedAverageQuantity', 'TotalQuantity', 'CenterOfMass', 'BulkVelocity', 'Extrema', 'MaxLocation']

Let's look at the total mass. This is how you call a given quantity. yt calls these "Derived Quantities". We'll talk about a few in a later notebook.

In [24]:
print sp.quantities.total_mass()
[3.27209034824e+42 g, 8.58102338351e+43 g]

(2)_Data_Inspection.ipynb; 2)_Data_Inspection_evaluated.ipynb; 2)_Data_Inspection.py)