If you want to deal with the AMR data, you need to call the amr_source() method of your RamsesOutput object with a single argument which is a list of the different fields you might need in your analysis.
When calling the amr_source(), the fields you have access to are :
- “rho” : the gas density field
- “vel” : the gas velocity field
- “P” : the gas pressurre field
- “g” : the gravitational acceleration field
To modify the list of available data fields, see RAMSES AMR file formats.
ro = pymses.RamsesOutput("/data/Aquarius/output", 193)
amr = ro.amr_source(["rho", "vel", "P", "g"])
Warning
The data source you just created does not contain data. It is designed to provide an on-demand access to the data. To be memory-friendly, nothing is read from the disk yet at this point. All the amr_00193.out_*, hydro_00193.out_* and grav_00193.out_* files are only linked to the data source for further processing.
AMR data is a bit more complicated to handle than particle data. To perform various analysis, PyMSES provides you with two different tools to get your AMR data :
The CellsToPoints filter converts the AMR tree structure into a IsotropicExtPointDataset containing a list of the AMR grid leaf envelope cells :
- The points parameter of the datasets coming from the generated data source will contain the coordinates of the cell centers.
- These datasets will have an additional get_sizes() method giving you the size of each cell.
from pymses.filters import CellsToPoints
cell_source = CellsToPoints(amr)
cells = cell_source.flatten()
[...]
# Cell centers
ccenters = cells.points
# Cell sizes
dx = cells.get_sizes()
Warning
As a Filter, the cell_source object you first created is another data provider, it doesn’t contain actual data. To read the data, use get_domain_dset(), iter_dsets() or flatten() method as described in Reading particles.
Another way to read the AMR data is to perform a sampling of the AMR fields with a set of sampling points coordinates of your choice. In PyMSES, this is done quite easily with the sample_points() function :
from pymses.analysis import sample_points
sample_dset = sample_points(amr, points)
The returned sample_dset will be a PointDataset containing all your sampling points and the corresponding value of the different AMR fields you selected.
Note
In backstage, the point sampling is performed with a tree search algorithm, which makes this particular process of AMR data access both user-friendly and efficient.
For example, this method can be used :
- for visualization purposes (see Slices).
- when computing profiles (see Profile computing)