Path: blob/main/doc/source/quickstart/2)_Data_Inspection.ipynb
928 views
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.
Now that we've loaded yt, we can load up some data. Let's load the IsolatedGalaxy
dataset.
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:
yt can also tell you the fields it found on disk:
And, all of the fields it thinks it knows how to generate:
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.
yt stores information about the domain of the simulation:
yt can also convert this into various units:
Finally, we can get basic information about the particle types and number of particles in a simulation:
For this dataset, we see that there are two particle types defined, (io
and all
), but that only one of these particle types in ds.particle_types_raw
. The ds.particle_types
list contains all particle types in the simulation, including ones that are dynamically defined like particle unions. The ds.particle_types_raw
list includes only particle types that are in the output file we loaded the dataset from.
We can also see that there are a bit more than 1.1 million particles in this simulation. Only particle types in ds.particle_types_raw
will appear in the ds.particle_type_counts
dictionary.
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.
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.
Grids have dimensions, extents, level, and even a list of Child grids.
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!
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.
We can calculate a bunch of bulk quantities. Here's that list, but there's a list in the docs, too!
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.