Load up yt
from yt.mods import *
yt : [INFO ] 2012-09-05 17:07:05,451 Loading plugins from /home/skillman/.yt/my_plugins.py
Load a parallel athena dataset. This one has the center at [0.0, 0.0, 0.0], so we don't need to send in the parameters dictionary
pf = load('id0/kh_3d_mhd_hlld_128_beta5000_sub_tanhd.0030.vtk')
yt : [INFO ] 2012-09-05 17:07:05,466 Please set 'domain_right_edge' in parameters dictionary argument if it is not equal to -domain_left_edge. yt : [INFO ] 2012-09-05 17:07:05,467 Parameters: current_time = 3.000884 yt : [INFO ] 2012-09-05 17:07:05,467 Parameters: domain_dimensions = [ 128. 128. 128.] yt : [INFO ] 2012-09-05 17:07:05,468 Parameters: domain_left_edge = [-0.5 -0.5 -0.5] yt : [INFO ] 2012-09-05 17:07:05,468 Parameters: domain_right_edge = [ 0.5 0.5 0.5] yt : [INFO ] 2012-09-05 17:07:05,469 Parameters: cosmological_simulation = 0.0
No data has been loaded into memory yet. Now let's ask for the maximum density, which will load up the grids on demand, and find the max density grid by grid, and take the max of those.
pf.h.find_max('density')
yt : [INFO ] 2012-09-05 17:07:05,854 Max Value is 2.23262e+00 at -0.2460937500000000 -0.3632812500000000 -0.1914062500000000 in grid AMRGridPatch_0017 at level 0 (0, 17, 7)
(2.2326179, array([-0.24609375, -0.36328125, -0.19140625]))
Verify this by asking for all the data, then get the density field as a numpy array, and calculate the max.
ad = pf.h.all_data()
ad['density'].max()
yt : [INFO ] 2012-09-05 17:07:05,858 Getting field density from 64
2.2326179
We can get at each grids data, if we want, by grabbing the pf.h.grids:
grids = pf.h.grids
print grids
grid_zero = grids[0]
print grid_zero.LeftEdge, grid_zero.RightEdge, grid_zero.ActiveDimensions
print grid_zero['density'].max()
[AMRGridPatch_0000 AMRGridPatch_0001 AMRGridPatch_0002 AMRGridPatch_0003 AMRGridPatch_0004 AMRGridPatch_0005 AMRGridPatch_0006 AMRGridPatch_0007 AMRGridPatch_0008 AMRGridPatch_0009 AMRGridPatch_0010 AMRGridPatch_0011 AMRGridPatch_0012 AMRGridPatch_0013 AMRGridPatch_0014 AMRGridPatch_0015 AMRGridPatch_0016 AMRGridPatch_0017 AMRGridPatch_0018 AMRGridPatch_0019 AMRGridPatch_0020 AMRGridPatch_0021 AMRGridPatch_0022 AMRGridPatch_0023 AMRGridPatch_0024 AMRGridPatch_0025 AMRGridPatch_0026 AMRGridPatch_0027 AMRGridPatch_0028 AMRGridPatch_0029 AMRGridPatch_0030 AMRGridPatch_0031 AMRGridPatch_0032 AMRGridPatch_0033 AMRGridPatch_0034 AMRGridPatch_0035 AMRGridPatch_0036 AMRGridPatch_0037 AMRGridPatch_0038 AMRGridPatch_0039 AMRGridPatch_0040 AMRGridPatch_0041 AMRGridPatch_0042 AMRGridPatch_0043 AMRGridPatch_0044 AMRGridPatch_0045 AMRGridPatch_0046 AMRGridPatch_0047 AMRGridPatch_0048 AMRGridPatch_0049 AMRGridPatch_0050 AMRGridPatch_0051 AMRGridPatch_0052 AMRGridPatch_0053 AMRGridPatch_0054 AMRGridPatch_0055 AMRGridPatch_0056 AMRGridPatch_0057 AMRGridPatch_0058 AMRGridPatch_0059 AMRGridPatch_0060 AMRGridPatch_0061 AMRGridPatch_0062 AMRGridPatch_0063] [-0.5 -0.5 -0.5] [-0.25 -0.25 -0.25] [32 32 32] 2.22822
What data is available? We can check pf.field_list and pf.h.derived_field_list
print 'Native fields read from the dataset:'
print pf.h.field_list
print '\nDerived fields that are built into yt:'
print pf.h.derived_field_list
Native fields read from the dataset: ['cell_centered_B_x', 'cell_centered_B_y', 'cell_centered_B_z', 'density', 'pressure', 'velocity_z', 'velocity_x', 'velocity_y'] Derived fields that are built into yt: ['cell_centered_B_x', 'cell_centered_B_y', 'cell_centered_B_z', 'density', 'pressure', 'velocity_z', 'velocity_x', 'velocity_y', 'z-velocity', 'Density', 'Pressure', 'x-velocity', 'y-velocity', 'RadialVelocityABS', 'SZKinetic', 'RadialVelocity', 'CellVolume', 'coordinate_r', 'CellMassCode', 'Pressure', 'Ones', 'CellMassMsun', 'DynamicalTime', 'SurfaceArea', 'dz', 'dx', 'dy', 'x', 'GridLevel', 'TangentialVelocity', 'AngularMomentumX', 'AngularMomentumY', 'AngularMomentumZ', 'sph_r', 'Contours', 'Radiuspc', 'CellVolumeCode', 'sph_phi', 'CellsPerBin', 'coordinate_rz', 'coordinate_rx', 'coordinate_ry', 'cyl_z', 'Radius', 'cyl_R', 'tempContours', 'RadiusMpc', 'RadialVelocityKMS', 'sph_theta', 'CellVolumeMpc', 'zeros', 'Radiuskpch', 'SpecificAngularMomentumX', 'SpecificAngularMomentumY', 'SpecificAngularMomentumZ', 'OnesOverDx', 'RadiusAU', 'Height', 'Radiuskpc', 'HeightAU', 'VelocityMagnitude', 'RadialVelocityKMSABS', 'z', 'RadiusCode', 'DiskAngle', 'TangentialOverVelocityMagnitude', 'GridIndices', 'CellMass', 'ComovingDensity', 'y', 'cyl_theta']
Enough of that. Lets make some plots!
Slices:
slc = SlicePlot(pf,'x','density')
slc.show()
# We can save this with slc.save()
yt : [INFO ] 2012-09-05 17:07:06,084 Making a fixed resolution buffer of (density) 800 by 800
Now lets loop through the axes, and add a few quantities, then get rid of the unit label on the axes.
for ax in 'xy':
slc = SlicePlot(pf,ax,['pressure','DivV'])
slc.set_axes_unit('1')
slc.show()
yt : [INFO ] 2012-09-05 17:07:07,238 Making a fixed resolution buffer of (pressure) 800 by 800 yt : [INFO ] 2012-09-05 17:07:07,252 Making a fixed resolution buffer of (DivV) 800 by 800 yt : [INFO ] 2012-09-05 17:07:08,980 Making a fixed resolution buffer of (pressure) 800 by 800 yt : [INFO ] 2012-09-05 17:07:08,994 Making a fixed resolution buffer of (DivV) 800 by 800
Projections:
Very similar syntax to SlicePlot, so let's get fancy and use a derived field like VorticitySquared.
for ax in 'y':
slc = ProjectionPlot(pf,ax,['VorticitySquared'], weight_field='pressure')
slc.set_axes_unit('1')
slc.show()
Initializing tree 0 / 0 0% | | ETA: --:--:-- Initializing tree 0 / 0 1% | | ETA: 00:00:00 Initializing tree 0 / 0 3% | | ETA: 00:00:00 Initializing tree 0 / 0 4% |\ | ETA: 00:00:00 Initializing tree 0 / 0 6% || | ETA: 00:00:00 Initializing tree 0 / 0 7% |// | ETA: 00:00:00 Initializing tree 0 / 0 9% |-- | ETA: 00:00:00 Initializing tree 0 / 0 10% |\\\ | ETA: 00:00:00 Initializing tree 0 / 0 12% |||| | ETA: 00:00:00 Initializing tree 0 / 0 14% |//// | ETA: 00:00:00 Initializing tree 0 / 0 15% |---- | ETA: 00:00:00 Initializing tree 0 / 0 17% |\\\\\ | ETA: 00:00:00 Initializing tree 0 / 0 18% |||||| | ETA: 00:00:00 Initializing tree 0 / 0 20% |////// | ETA: 00:00:00 Initializing tree 0 / 0 21% |------ | ETA: 00:00:00 Initializing tree 0 / 0 23% |\\\\\\\ | ETA: 00:00:00 Initializing tree 0 / 0 25% |||||||| | ETA: 00:00:00 Initializing tree 0 / 0 26% |//////// | ETA: 00:00:00 Initializing tree 0 / 0 28% |-------- | ETA: 00:00:00 Initializing tree 0 / 0 29% |\\\\\\\\\ | ETA: 00:00:00 Initializing tree 0 / 0 31% |||||||||| | ETA: 00:00:00 Initializing tree 0 / 0 32% |////////// | ETA: 00:00:00 Initializing tree 0 / 0 34% |---------- | ETA: 00:00:00 Initializing tree 0 / 0 35% |\\\\\\\\\\\ | ETA: 00:00:00 Initializing tree 0 / 0 37% |||||||||||| | ETA: 00:00:00 Initializing tree 0 / 0 39% |//////////// | ETA: 00:00:00 Initializing tree 0 / 0 40% |------------ | ETA: 00:00:00 Initializing tree 0 / 0 42% |\\\\\\\\\\\\\ | ETA: 00:00:00 Initializing tree 0 / 0 43% |||||||||||||| | ETA: 00:00:00 Initializing tree 0 / 0 45% |////////////// | ETA: 00:00:00 Initializing tree 0 / 0 46% |-------------- | ETA: 00:00:00 Initializing tree 0 / 0 48% |\\\\\\\\\\\\\\\ | ETA: 00:00:00 Initializing tree 0 / 0 50% |||||||||||||||| | ETA: 00:00:00 Initializing tree 0 / 0 51% |/////////////// | ETA: 00:00:00 Initializing tree 0 / 0 53% |---------------- | ETA: 00:00:00 Initializing tree 0 / 0 54% |\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Initializing tree 0 / 0 56% |||||||||||||||||| | ETA: 00:00:00 Initializing tree 0 / 0 57% |///////////////// | ETA: 00:00:00 Initializing tree 0 / 0 59% |------------------ | ETA: 00:00:00 Initializing tree 0 / 0 60% |\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Initializing tree 0 / 0 62% |||||||||||||||||||| | ETA: 00:00:00 Initializing tree 0 / 0 64% |/////////////////// | ETA: 00:00:00 Initializing tree 0 / 0 65% |-------------------- | ETA: 00:00:00 Initializing tree 0 / 0 67% |\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Initializing tree 0 / 0 68% |||||||||||||||||||||| | ETA: 00:00:00 Initializing tree 0 / 0 70% |///////////////////// | ETA: 00:00:00 Initializing tree 0 / 0 71% |---------------------- | ETA: 00:00:00 Initializing tree 0 / 0 73% |\\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Initializing tree 0 / 0 75% |||||||||||||||||||||||| | ETA: 00:00:00 Initializing tree 0 / 0 76% |/////////////////////// | ETA: 00:00:00 Initializing tree 0 / 0 78% |------------------------ | ETA: 00:00:00 Initializing tree 0 / 0 79% |\\\\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Initializing tree 0 / 0 81% |||||||||||||||||||||||||| | ETA: 00:00:00 Initializing tree 0 / 0 82% |///////////////////////// | ETA: 00:00:00 Initializing tree 0 / 0 84% |-------------------------- | ETA: 00:00:00 Initializing tree 0 / 0 85% |\\\\\\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Initializing tree 0 / 0 87% |||||||||||||||||||||||||||| | ETA: 00:00:00 Initializing tree 0 / 0 89% |/////////////////////////// | ETA: 00:00:00 Initializing tree 0 / 0 90% |---------------------------- | ETA: 00:00:00 Initializing tree 0 / 0 92% |\\\\\\\\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Initializing tree 0 / 0 93% |||||||||||||||||||||||||||||| | ETA: 00:00:00 Initializing tree 0 / 0 95% |///////////////////////////// | ETA: 00:00:00 Initializing tree 0 / 0 96% |------------------------------ | ETA: 00:00:00 Initializing tree 0 / 0 98% |\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Initializing tree 0 / 0100% ||||||||||||||||||||||||||||||||| Time: 00:00:00 Projecting level 0 / 0 0% | | ETA: --:--:-- Projecting level 0 / 0 1% | | ETA: 00:00:05 Projecting level 0 / 0 3% | | ETA: 00:00:03 Projecting level 0 / 0 4% |\ | ETA: 00:00:02 Projecting level 0 / 0 6% || | ETA: 00:00:02 Projecting level 0 / 0 7% |// | ETA: 00:00:01 Projecting level 0 / 0 9% |-- | ETA: 00:00:01 Projecting level 0 / 0 10% |\\\ | ETA: 00:00:01 Projecting level 0 / 0 12% |||| | ETA: 00:00:01 Projecting level 0 / 0 14% |//// | ETA: 00:00:01 Projecting level 0 / 0 15% |---- | ETA: 00:00:01 Projecting level 0 / 0 17% |\\\\\ | ETA: 00:00:01 Projecting level 0 / 0 18% |||||| | ETA: 00:00:01 Projecting level 0 / 0 20% |////// | ETA: 00:00:01 Projecting level 0 / 0 21% |------ | ETA: 00:00:01 Projecting level 0 / 0 23% |\\\\\\\ | ETA: 00:00:01 Projecting level 0 / 0 25% |||||||| | ETA: 00:00:01 Projecting level 0 / 0 26% |/////// | ETA: 00:00:01 Projecting level 0 / 0 28% |-------- | ETA: 00:00:01 Projecting level 0 / 0 29% |\\\\\\\\ | ETA: 00:00:00 Projecting level 0 / 0 31% |||||||||| | ETA: 00:00:00 Projecting level 0 / 0 32% |///////// | ETA: 00:00:00 Projecting level 0 / 0 34% |---------- | ETA: 00:00:00 Projecting level 0 / 0 35% |\\\\\\\\\\ | ETA: 00:00:00 Projecting level 0 / 0 37% |||||||||||| | ETA: 00:00:00 Projecting level 0 / 0 39% |/////////// | ETA: 00:00:00 Projecting level 0 / 0 40% |------------ | ETA: 00:00:00 Projecting level 0 / 0 42% |\\\\\\\\\\\\ | ETA: 00:00:00 Projecting level 0 / 0 43% |||||||||||||| | ETA: 00:00:00 Projecting level 0 / 0 45% |///////////// | ETA: 00:00:00 Projecting level 0 / 0 46% |-------------- | ETA: 00:00:00 Projecting level 0 / 0 48% |\\\\\\\\\\\\\\ | ETA: 00:00:00 Projecting level 0 / 0 50% |||||||||||||||| | ETA: 00:00:00 Projecting level 0 / 0 51% |/////////////// | ETA: 00:00:00 Projecting level 0 / 0 53% |--------------- | ETA: 00:00:00 Projecting level 0 / 0 54% |\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Projecting level 0 / 0 56% ||||||||||||||||| | ETA: 00:00:00 Projecting level 0 / 0 57% |///////////////// | ETA: 00:00:00 Projecting level 0 / 0 59% |----------------- | ETA: 00:00:00 Projecting level 0 / 0 60% |\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Projecting level 0 / 0 62% ||||||||||||||||||| | ETA: 00:00:00 Projecting level 0 / 0 64% |/////////////////// | ETA: 00:00:00 Projecting level 0 / 0 65% |------------------- | ETA: 00:00:00 Projecting level 0 / 0 67% |\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Projecting level 0 / 0 68% ||||||||||||||||||||| | ETA: 00:00:00 Projecting level 0 / 0 70% |///////////////////// | ETA: 00:00:00 Projecting level 0 / 0 71% |--------------------- | ETA: 00:00:00 Projecting level 0 / 0 73% |\\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Projecting level 0 / 0 75% ||||||||||||||||||||||| | ETA: 00:00:00 Projecting level 0 / 0 76% |////////////////////// | ETA: 00:00:00 Projecting level 0 / 0 78% |----------------------- | ETA: 00:00:00 Projecting level 0 / 0 79% |\\\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Projecting level 0 / 0 81% ||||||||||||||||||||||||| | ETA: 00:00:00 Projecting level 0 / 0 82% |//////////////////////// | ETA: 00:00:00 Projecting level 0 / 0 84% |------------------------- | ETA: 00:00:00 Projecting level 0 / 0 85% |\\\\\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Projecting level 0 / 0 87% ||||||||||||||||||||||||||| | ETA: 00:00:00 Projecting level 0 / 0 89% |////////////////////////// | ETA: 00:00:00 Projecting level 0 / 0 90% |--------------------------- | ETA: 00:00:00 Projecting level 0 / 0 92% |\\\\\\\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Projecting level 0 / 0 93% ||||||||||||||||||||||||||||| | ETA: 00:00:00 Projecting level 0 / 0 95% |//////////////////////////// | ETA: 00:00:00 Projecting level 0 / 0 96% |----------------------------- | ETA: 00:00:00 Projecting level 0 / 0 98% |\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Projecting level 0 / 0 100% |||||||||||||||||||||||||||||||| Time: 00:00:01 yt : [INFO ] 2012-09-05 17:07:11,790 Projection completed yt : [INFO ] 2012-09-05 17:07:11,792 Making a fixed resolution buffer of (VorticitySquared) 800 by 800 yt : [INFO ] 2012-09-05 17:07:11,804 xlim = -0.500000 0.500000 yt : [INFO ] 2012-09-05 17:07:11,804 ylim = -0.500000 0.500000 yt : [INFO ] 2012-09-05 17:07:11,805 Making a fixed resolution buffer of (VorticitySquared) 800 by 800 yt : [INFO ] 2012-09-05 17:07:11,817 Making a fixed resolution buffer of (VorticitySquared) 800 by 800
Lets make some profiles. We could follow: http://yt-project.org/doc/cookbook/simple_plots.html#simple-phase-plots
but instead let's try some manual manipulation.
from yt.visualization.profile_plotter import PhasePlotter
import matplotlib.pylab as pl
p = PhasePlotter(pf.h.all_data(), 'density', 'pressure', 'AbsDivV',x_log=False, y_log=False)
fig = pl.figure(figsize=[10.,10.])
fig, ax = p.plot.to_mpl(place=fig)
cb = pl.colorbar(ax.images[0], shrink=0.5)
cb.set_label('DivV')
We can define new fields by first defining the function, then adding them to our derived_field_list.
def _Bsquared(field,data):
return data['cell_centered_B_x']**2 + data['cell_centered_B_z']**2 + data['cell_centered_B_z']**2
add_field('Bsquared',function=_Bsquared)
def _KE(field,data):
return 0.5*data['density']*data['VelocityMagnitude']**2
add_field('VolumetricKE',function=_KE)
Now we can do the same types of operations with these new fields!
p = PhasePlotter(pf.h.all_data(), 'VolumetricKE', 'pressure', 'Bsquared',
x_log=False, y_log=False)
fig = pl.figure(figsize=[10.,10.])
fig, ax = p.plot.to_mpl(place=fig)
cb = pl.colorbar(ax.images[0], shrink=0.5)
cb.set_label(r'$\mathrm{B^2}$')
This is a mechanism to get the full data array for a given simulation. Let's see how it works...
help(pf.h.covering_grid)
Help on class AMRCoveringGrid in module yt.data_objects.hierarchy:
class AMRCoveringGrid(yt.data_objects.data_containers.AMRCoveringGridBase)
| Method resolution order:
| AMRCoveringGrid
| yt.data_objects.data_containers.AMRCoveringGridBase
| yt.data_objects.data_containers.AMR3DData
| yt.data_objects.data_containers.AMRData
| yt.data_objects.data_containers.GridPropertiesMixin
| yt.utilities.parallel_tools.parallel_analysis_interface.ParallelAnalysisInterface
| __builtin__.object
|
| Data and other attributes defined here:
|
| hierarchy = <weakproxy at 0x557d890 to AthenaHierarchy>
|
| pf = <weakproxy at 0x557da48 to AthenaStaticOutput>
|
| ----------------------------------------------------------------------
| Methods inherited from yt.data_objects.data_containers.AMRCoveringGridBase:
|
| __init__(self, level, left_edge, dims, fields=None, pf=None, num_ghost_zones=0, use_pbar=True, **kwargs)
| A 3D region with all data extracted to a single, specified
| resolution.
|
| Parameters
| ----------
| level : int
| The resolution level data is uniformly gridded at
| left_edge : array_like
| The left edge of the region to be extracted
| dims : array_like
| Number of cells along each axis of resulting covering_grid
| fields : array_like, optional
| A list of fields that you'd like pre-generated for your object
|
| Examples
| --------
| cube = pf.h.covering_grid(2, left_edge=[0.0, 0.0, 0.0], right_edge=[1.0, 1.0, 1.0],
| dims=[128, 128, 128])
|
| flush_data(self, field=None)
| Any modifications made to the data in this object are pushed back
| to the originating grids, except the cells where those grids are both
| below the current level `and` have child cells.
|
| get_data(self, fields=None)
|
| ----------------------------------------------------------------------
| Data descriptors inherited from yt.data_objects.data_containers.AMRCoveringGridBase:
|
| LeftEdge
|
| RightEdge
|
| ----------------------------------------------------------------------
| Methods inherited from yt.data_objects.data_containers.AMR3DData:
|
| calculate_isocontour_flux(self, field, value, field_x, field_y, field_z, fluxing_field=None)
| This identifies isocontours on a cell-by-cell basis, with no
| consideration of global connectedness, and calculates the flux over
| those contours.
|
| This function will conduct marching cubes on all the cells in a given
| data container (grid-by-grid), and then for each identified triangular
| segment of an isocontour in a given cell, calculate the gradient (i.e.,
| normal) in the isocontoured field, interpolate the local value of the
| "fluxing" field, the area of the triangle, and then return:
|
| area * local_flux_value * (n dot v)
|
| Where area, local_value, and the vector v are interpolated at the barycenter
| (weighted by the vertex values) of the triangle. Note that this
| specifically allows for the field fluxing across the surface to be
| *different* from the field being contoured. If the fluxing_field is
| not specified, it is assumed to be 1.0 everywhere, and the raw flux
| with no local-weighting is returned.
|
| Additionally, the returned flux is defined as flux *into* the surface,
| not flux *out of* the surface.
|
| Parameters
| ----------
| field : string
| Any field that can be obtained in a data object. This is the field
| which will be isocontoured and used as the "local_value" in the
| flux equation.
| value : float
| The value at which the isocontour should be calculated.
| field_x : string
| The x-component field
| field_y : string
| The y-component field
| field_z : string
| The z-component field
| fluxing_field : string, optional
| The field whose passage over the surface is of interest. If not
| specified, assumed to be 1.0 everywhere.
|
| Returns
| -------
| flux : float
| The summed flux. Note that it is not currently scaled; this is
| simply the code-unit area times the fields.
|
| References
| ----------
|
| .. [1] Marching Cubes: http://en.wikipedia.org/wiki/Marching_cubes
|
| Examples
| --------
| This will create a data object, find a nice value in the center, and
| calculate the metal flux over it.
|
| >>> dd = pf.h.all_data()
| >>> rho = dd.quantities["WeightedAverageQuantity"](
| ... "Density", weight="CellMassMsun")
| >>> flux = dd.calculate_isocontour_flux("Density", rho,
| ... "x-velocity", "y-velocity", "z-velocity", "Metal_Density")
|
| cut_region(self, field_cuts)
| Return an InLineExtractedRegion, where the grid cells are cut on the
| fly with a set of field_cuts. It is very useful for applying
| conditions to the fields in your data object.
|
| Examples
| --------
| To find the total mass of gas above 10^6 K in your volume:
|
| >>> pf = load("RedshiftOutput0005")
| >>> ad = pf.h.all_data()
| >>> cr = ad.cut_region(["grid['Temperature'] > 1e6"])
| >>> print cr.quantities["TotalQuantity"]("CellMassMsun")
|
| extract_connected_sets(self, field, num_levels, min_val, max_val, log_space=True, cumulative=True, cache=False)
| This function will create a set of contour objects, defined
| by having connected cell structures, which can then be
| studied and used to 'paint' their source grids, thus enabling
| them to be plotted.
|
| extract_isocontours(self, field, value, filename=None, rescale=False, sample_values=None)
| This identifies isocontours on a cell-by-cell basis, with no
| consideration of global connectedness, and returns the vertices of the
| Triangles in that isocontour.
|
| This function simply returns the vertices of all the triangles
| calculated by the marching cubes algorithm; for more complex
| operations, such as identifying connected sets of cells above a given
| threshold, see the extract_connected_sets function. This is more
| useful for calculating, for instance, total isocontour area, or
| visualizing in an external program (such as `MeshLab
| <http://meshlab.sf.net>`_.)
|
| Parameters
| ----------
| field : string
| Any field that can be obtained in a data object. This is the field
| which will be isocontoured.
| value : float
| The value at which the isocontour should be calculated.
| filename : string, optional
| If supplied, this file will be filled with the vertices in .obj
| format. Suitable for loading into meshlab.
| rescale : bool, optional
| If true, the vertices will be rescaled within their min/max.
| sample_values : string, optional
| Any field whose value should be extracted at the center of each
| triangle.
|
| Returns
| -------
| verts : array of floats
| The array of vertices, x,y,z. Taken in threes, these are the
| triangle vertices.
| samples : array of floats
| If `sample_values` is specified, this will be returned and will
| contain the values of the field specified at the center of each
| triangle.
|
| References
| ----------
|
| .. [1] Marching Cubes: http://en.wikipedia.org/wiki/Marching_cubes
|
| Examples
| --------
| This will create a data object, find a nice value in the center, and
| output the vertices to "triangles.obj" after rescaling them.
|
| >>> dd = pf.h.all_data()
| >>> rho = dd.quantities["WeightedAverageQuantity"](
| ... "Density", weight="CellMassMsun")
| >>> verts = dd.extract_isocontours("Density", rho,
| ... "triangles.obj", True)
|
| extract_region(self, indices)
| Return an ExtractedRegion where the points contained in it are defined
| as the points in `this` data object with the given *indices*.
|
| paint_grids(self, field, value, default_value=None)
| This function paints every cell in our dataset with a given *value*.
| If default_value is given, the other values for the given in every grid
| are discarded and replaced with *default_value*. Otherwise, the field is
| mandated to 'know how to exist' in the grid.
|
| Note that this only paints the cells *in the dataset*, so cells in grids
| with child cells are left untouched.
|
| volume(self, unit='unitary')
| Return the volume of the data container in units *unit*.
| This is found by adding up the volume of the cells with centers
| in the container, rather than using the geometric shape of
| the container, so this may vary very slightly
| from what might be expected from the geometric volume.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from yt.data_objects.data_containers.AMR3DData:
|
| particles
|
| quantities
|
| ----------------------------------------------------------------------
| Methods inherited from yt.data_objects.data_containers.AMRData:
|
| __delitem__(self, key)
| Deletes a field
|
| __getitem__(self, key)
| Returns a single field. Will add if necessary.
|
| __reduce__(self)
|
| __repr__(self, clean=False)
|
| __setitem__(self, key, val)
| Sets a field to be some other value.
|
| clear_cache(self)
| Clears out all cache, freeing memory.
|
| clear_data(self)
| Clears out all data from the AMRData instance, freeing memory.
|
| convert(self, datatype)
| This will attempt to convert a given unit to cgs from code units.
| It either returns the multiplicative factor or throws a KeyError.
|
| get_field_parameter(self, name, default=None)
| This is typically only used by derived field functions, but
| it returns parameters used to generate fields.
|
| has_field_parameter(self, name)
| Checks if a field parameter is set.
|
| has_key(self, key)
| Checks if a data field already exists.
|
| keys(self)
|
| save_object(self, name, filename=None)
| Save an object. If *filename* is supplied, it will be stored in
| a :mod:`shelve` file of that name. Otherwise, it will be stored via
| :meth:`yt.data_objects.api.AMRHierarchy.save_object`.
|
| set_field_parameter(self, name, val)
| Here we set up dictionaries that get passed up and down and ultimately
| to derived fields.
|
| write_out(self, filename, fields=None, format='%0.16e')
|
| ----------------------------------------------------------------------
| Data descriptors inherited from yt.data_objects.data_containers.AMRData:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from yt.data_objects.data_containers.AMRData:
|
| __metaclass__ = <class 'yt.data_objects.data_containers.__metaclass__'...
|
|
| ----------------------------------------------------------------------
| Methods inherited from yt.data_objects.data_containers.GridPropertiesMixin:
|
| select_grid_indices(self, level)
|
| select_grids(self, level)
| Return all grids on a given level.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from yt.data_objects.data_containers.GridPropertiesMixin:
|
| grid_dimensions
|
| grid_left_edge
|
| grid_levels
|
| grid_right_edge
|
| ----------------------------------------------------------------------
| Methods inherited from yt.utilities.parallel_tools.parallel_analysis_interface.ParallelAnalysisInterface:
|
| get_dependencies(self, fields)
|
| partition_hierarchy_2d(self, axis)
|
| partition_hierarchy_3d(self, ds, padding=0.0, rank_ratio=1)
|
| partition_hierarchy_3d_bisection_list(self)
| Returns an array that is used to drive _partition_hierarchy_3d_bisection,
| below.
|
| partition_region_3d(self, left_edge, right_edge, padding=0.0, rank_ratio=1)
| Given a region, it subdivides it into smaller regions for parallel
| analysis.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from yt.utilities.parallel_tools.parallel_analysis_interface.ParallelAnalysisInterface:
|
| comm = None
cg = pf.h.covering_grid(0, pf.domain_left_edge, pf.domain_dimensions)
Just as an example, let's first find the global pressure maximum. Then take 4 slices in the z direction and use matplotlib directly to plot them, and overplot pressure contours.
print cg['pressure'].max()
for i in [0,17,39,96]:
pl.figure(figsize=[10.,10.])
pl.imshow(cg['density'][:,:,i])
pl.contour(cg['pressure'][:,:,i])
Searching grids for values 0% | | ETA: --:--:-- Searching grids for values 1% | | ETA: 00:00:00 Searching grids for values 3% | | ETA: 00:00:00 Searching grids for values 4% |\ | ETA: 00:00:00 Searching grids for values 6% || | ETA: 00:00:00 Searching grids for values 7% |// | ETA: 00:00:00 Searching grids for values 9% |-- | ETA: 00:00:00 Searching grids for values 10% |\\\ | ETA: 00:00:00 Searching grids for values 12% |||| | ETA: 00:00:00 Searching grids for values 14% |//// | ETA: 00:00:00 Searching grids for values 15% |---- | ETA: 00:00:00 Searching grids for values 17% |\\\\ | ETA: 00:00:00 Searching grids for values 18% |||||| | ETA: 00:00:00 Searching grids for values 20% |///// | ETA: 00:00:00 Searching grids for values 21% |------ | ETA: 00:00:00 Searching grids for values 23% |\\\\\\ | ETA: 00:00:00 Searching grids for values 25% |||||||| | ETA: 00:00:00 Searching grids for values 26% |/////// | ETA: 00:00:00 Searching grids for values 28% |-------- | ETA: 00:00:00 Searching grids for values 29% |\\\\\\\\ | ETA: 00:00:00 Searching grids for values 31% |||||||||| | ETA: 00:00:00 Searching grids for values 32% |///////// | ETA: 00:00:00 Searching grids for values 34% |--------- | ETA: 00:00:00 Searching grids for values 35% |\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 37% ||||||||||| | ETA: 00:00:00 Searching grids for values 39% |/////////// | ETA: 00:00:00 Searching grids for values 40% |----------- | ETA: 00:00:00 Searching grids for values 42% |\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 43% ||||||||||||| | ETA: 00:00:00 Searching grids for values 45% |///////////// | ETA: 00:00:00 Searching grids for values 46% |------------- | ETA: 00:00:00 Searching grids for values 48% |\\\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 50% ||||||||||||||| | ETA: 00:00:00 Searching grids for values 51% |////////////// | ETA: 00:00:00 Searching grids for values 53% |--------------- | ETA: 00:00:00 Searching grids for values 54% |\\\\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 56% ||||||||||||||||| | ETA: 00:00:00 Searching grids for values 57% |//////////////// | ETA: 00:00:00 Searching grids for values 59% |----------------- | ETA: 00:00:00 Searching grids for values 60% |\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 62% ||||||||||||||||||| | ETA: 00:00:00 Searching grids for values 64% |////////////////// | ETA: 00:00:00 Searching grids for values 65% |------------------- | ETA: 00:00:00 Searching grids for values 67% |\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 68% |||||||||||||||||||| | ETA: 00:00:00 Searching grids for values 70% |//////////////////// | ETA: 00:00:00 Searching grids for values 71% |-------------------- | ETA: 00:00:00 Searching grids for values 73% |\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 75% |||||||||||||||||||||| | ETA: 00:00:00 Searching grids for values 76% |////////////////////// | ETA: 00:00:00 Searching grids for values 78% |---------------------- | ETA: 00:00:00 Searching grids for values 79% |\\\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 81% |||||||||||||||||||||||| | ETA: 00:00:00 Searching grids for values 82% |//////////////////////// | ETA: 00:00:00 Searching grids for values 84% |------------------------ | ETA: 00:00:00 Searching grids for values 85% |\\\\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 87% |||||||||||||||||||||||||| | ETA: 00:00:00 Searching grids for values 89% |///////////////////////// | ETA: 00:00:00 Searching grids for values 90% |-------------------------- | ETA: 00:00:00 Searching grids for values 92% |\\\\\\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 93% |||||||||||||||||||||||||||| | ETA: 00:00:00 Searching grids for values 95% |/////////////////////////// | ETA: 00:00:00 Searching grids for values 96% |---------------------------- | ETA: 00:00:00 Searching grids for values 98% |\\\\\\\\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 100% ||||||||||||||||||||||||||||||| Time: 00:00:00 Searching grids for values 0% | | ETA: --:--:-- Searching grids for values 1% | | ETA: 00:00:00 Searching grids for values 3% | | ETA: 00:00:00 Searching grids for values 4% |\ | ETA: 00:00:00 Searching grids for values 6% || | ETA: 00:00:00 Searching grids for values 7% |// | ETA: 00:00:00 Searching grids for values 9% |-- | ETA: 00:00:00 Searching grids for values 10% |\\\ | ETA: 00:00:00 Searching grids for values 12% |||| | ETA: 00:00:00 Searching grids for values 14% |//// | ETA: 00:00:00 Searching grids for values 15% |---- | ETA: 00:00:00 Searching grids for values 17% |\\\\ | ETA: 00:00:00 Searching grids for values 18% |||||| | ETA: 00:00:00 Searching grids for values 20% |///// | ETA: 00:00:00 Searching grids for values 21% |------ | ETA: 00:00:00 Searching grids for values 23% |\\\\\\ | ETA: 00:00:00 Searching grids for values 25% |||||||| | ETA: 00:00:00 Searching grids for values 26% |/////// | ETA: 00:00:00 Searching grids for values 28% |-------- | ETA: 00:00:00 Searching grids for values 29% |\\\\\\\\ | ETA: 00:00:00 Searching grids for values 31% |||||||||| | ETA: 00:00:00 Searching grids for values 32% |///////// | ETA: 00:00:00 Searching grids for values 34% |--------- | ETA: 00:00:00 Searching grids for values 35% |\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 37% ||||||||||| | ETA: 00:00:00 Searching grids for values 39% |/////////// | ETA: 00:00:00 Searching grids for values 40% |----------- | ETA: 00:00:00 Searching grids for values 42% |\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 43% ||||||||||||| | ETA: 00:00:00 Searching grids for values 45% |///////////// | ETA: 00:00:00 Searching grids for values 46% |------------- | ETA: 00:00:00 Searching grids for values 48% |\\\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 50% ||||||||||||||| | ETA: 00:00:00 Searching grids for values 51% |////////////// | ETA: 00:00:00 Searching grids for values 53% |--------------- | ETA: 00:00:00 Searching grids for values 54% |\\\\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 56% ||||||||||||||||| | ETA: 00:00:00 Searching grids for values 57% |//////////////// | ETA: 00:00:00 Searching grids for values 59% |----------------- | ETA: 00:00:00 Searching grids for values 60% |\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 62% ||||||||||||||||||| | ETA: 00:00:00 Searching grids for values 64% |////////////////// | ETA: 00:00:00 Searching grids for values 65% |------------------- | ETA: 00:00:00 Searching grids for values 67% |\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 68% |||||||||||||||||||| | ETA: 00:00:00 Searching grids for values 70% |//////////////////// | ETA: 00:00:00 Searching grids for values 71% |-------------------- | ETA: 00:00:00 Searching grids for values 73% |\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 75% |||||||||||||||||||||| | ETA: 00:00:00 Searching grids for values 76% |////////////////////// | ETA: 00:00:00 Searching grids for values 78% |---------------------- | ETA: 00:00:00 Searching grids for values 79% |\\\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 81% |||||||||||||||||||||||| | ETA: 00:00:00 Searching grids for values 82% |//////////////////////// | ETA: 00:00:00 Searching grids for values 84% |------------------------ | ETA: 00:00:00 Searching grids for values 85% |\\\\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 87% |||||||||||||||||||||||||| | ETA: 00:00:00 Searching grids for values 89% |///////////////////////// | ETA: 00:00:00 Searching grids for values 90% |-------------------------- | ETA: 00:00:00 Searching grids for values 92% |\\\\\\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 93% |||||||||||||||||||||||||||| | ETA: 00:00:00 Searching grids for values 95% |/////////////////////////// | ETA: 00:00:00 Searching grids for values 96% |---------------------------- | ETA: 00:00:00 Searching grids for values 98% |\\\\\\\\\\\\\\\\\\\\\\\\\\\\ | ETA: 00:00:00 Searching grids for values 100% ||||||||||||||||||||||||||||||| Time: 00:00:00
1.21533751488