Visualizing Particle Datasets with Firefly¶
Firefly
is an interactive, browser-based,
particle visualization platform that allows you to filter, colormap, and fly
through their data. The user interface can be entirely customized through the
python api
yt offers to ability
to export your data to Firefly’s JSON format through the
create_firefly_object()
method. You will still need to clone the
repository
and ensure these data files are stored in the Firefly/data
directory,
this is easily done using the
path_to_firefly
argument of
create_firefly_object()
which should point at Firefly’s index.html
.
You can adjust the interface settings, particle colors, decimation factors, and
other Firefly settings through the returned firefly_api.reader
object. Once the
settings are tuned to your liking, calling the reader.dumpToJSON()
method will
produce the final JSON files. Note that reader.clean_JSONdir
defaults to true
when using
create_firefly_object()
so if you would like to manage multiple datasets
you will need to use the dataset_name
keyword argument of
create_firefly_object()
.

Exporting an Example Dataset to Firefly¶
Here is an example of how to use yt to export data to Firefly using some sample data.
ramses_ds = yt.load("DICEGalaxyDisk_nonCosmological/output_00002/info_00002.txt")
region = ramses_ds.sphere(ramses_ds.domain_center, (1000, "kpc"))
reader = region.create_firefly_object(
path_to_firefly="repos/Firefly",
fields_to_include=["particle_extra_field_1", "particle_extra_field_2"],
fields_units=["dimensionless", "dimensionless"],
dataset_name="IsoGalaxyRamses",
)
reader.options["color"]["io"] = [1, 1, 0, 1]
reader.particleGroups[0].decimation_factor = 100
reader.dumpToJSON()