Small tool to create uniform data cubes of FLASH datasets. Port from bitbucket.org/pierrenbg/flash-amr-tools
Project description
flash-amr-tools
Small tool to create uniform data cubes of FLASH datasets. Port from bitbucket.org/pierrenbg/flash-amr-tools
Dependencies
h5py
numpy
Installation
This can be done as simply as
pip install flash-amr-tools
Usage
- Specify your filename that you want to look at:
filename = "SILCC_hdf5_plt_cnt_0150"
- Initialise the
AMRToolkit
object:
from flash_amr_tools import AMRToolkit
toolkit = AMRToolkit(filename)
The initialisation will calculate the complete list of blocks, the minimum and maximum refinement of the whole domain, and the number of blocks in each dimension.
- Retrive the data (as specified in
flash.par
) as a uniform grid:
# ex. density
dens = toolkit.get_cube("dens")
Note that the naming convention of the argument must follow the variable name in flash.par
. This now transforms the density as a cube with gridsizes following the highest resolution.
Plotting Routines
Optional plotting routines for slice & on-axis (weighted) projections are also available.
Slices
To retrive the slice, we require the field name (as specified in flash.par
), the position, and the axis(0, 1, or 2) in which the slicing takes place.
# ex. density slice along the mid-plane
dens_sl = toolkit.get_slice("dens", pos=0.0, axis=2)
On-Axis Projections
To obtain the projection, we require the field name (as specified in flash.par
) and the axis(0, 1, or 2) of the projection.
# ex. column density along the z-axis
cdens = toolkit.get_cdens("dens", axis=2)
Optionally, one can also specify weights to have weighted projections instead. Note that the field name for the weights must also be specified as in flash.par
# ex. temperature-weighted projection along the z-axis
cdens_wtemp = toolkit.get_cdens("dens", axis=2, weights_field = "temp")
Optional routines
Further initialisation routines
Optionally, one can specify a particular region of interest to look into. The units should be the same as with those defined in your simulation:
# optional, if one wants to look at a specific region
xmin = np.array([2.8931249e+20, -5.78625013e+20, -1.9287499e+20], dtype=np.float32)
xmax = np.array([6.7506249e+20, -1.92874993e+20, 1.9287499e+20], dtype=np.float32)
toolkit = AMRToolkit(filename, xmin, xmax)
One can also optionally force a region to have maximum / minimum refinement by passing the following arguments:
toolkit = AMRToolkit(filename, xmin, xmax, max_ref_given=10, min_ref_given=3)
which may be useful to conserve memory.
Extracting data with preserved AMR structure
If you want to retrive the data not as a uniform cube, this can be done with the following function call:
# ex. density
dens = toolkit.get_data("dens")
This returns the data that is still preserving the AMR structure, which can be useful for ex. scatter plots.
Cubes of refinement levels
One can also retrieve the refinement level as a uniform grid as well:
reflvl_cube = toolkit.get_reflvl_cube()
which can be used for (for example) plotting the AMR mesh grid.
Vector quantities
One can also retrive a uniform grid of vector quantities (ex. velocity, magnetic field) from the following:
vel = toolkit.get_vector_cube("vel")
This will return a 4D array consisting of a 3-D array in each direction.
License
This code is under the BSD3 license. See LICENSE for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flash_amr_tools-0.0.18.tar.gz
.
File metadata
- Download URL: flash_amr_tools-0.0.18.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7ad6531836282f3701026b4992fe4a23f1731c749ba8d897a96bee264509afe |
|
MD5 | a3ffea76c83b4f4362cdac91250caf39 |
|
BLAKE2b-256 | 100730363c1fba8eff64ad1615a1faaa9b9cb5e3f5cf938d7e63c2b75e79adf5 |
Provenance
File details
Details for the file flash_amr_tools-0.0.18-py3-none-any.whl
.
File metadata
- Download URL: flash_amr_tools-0.0.18-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 046db295f39df472587446ce65c7d08dcc80b5caa3f2a81106c8d2aa1e2c5c6f |
|
MD5 | d1f7528da3070d76205b1ef61836023a |
|
BLAKE2b-256 | 80bf490eec91d6a5644769a5a98a10b745cfd8a6be9b36878d57104ac957ba5d |