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-1.0.0.dev1.tar.gz
.
File metadata
- Download URL: flash_amr_tools-1.0.0.dev1.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49070b3276f5ce4071fcae30e811578e71e4ef93d1c98758e887116cfce01798 |
|
MD5 | 5f197f1666a17ceb7bbde7c2f21ea4b2 |
|
BLAKE2b-256 | 8866ac9ced12c9ed89cd96c2ead9d2275d20676c181ce88ba965fb083d2b0c0e |
Provenance
File details
Details for the file flash_amr_tools-1.0.0.dev1-py3-none-any.whl
.
File metadata
- Download URL: flash_amr_tools-1.0.0.dev1-py3-none-any.whl
- Upload date:
- Size: 16.0 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 | ea2b34eec6a3eb5e6d1e92e8af4765fd18080a77d39e38d616220d1c8ecff38b |
|
MD5 | b7f1a1c006ae23871a95ff15f17bbc8e |
|
BLAKE2b-256 | cd220965cac3867140ea7723c7366c4e0c7e31756566d4b09188ac884b7f4767 |