firestudio.studios.FIRE_studio.FIREStudio

class firestudio.studios.FIRE_studio.FIREStudio(datadir: str, snapnum: int, sim_name: str, cache_file_name: Optional[str] = None, gas_snapdict: Optional[dict] = None, star_snapdict: Optional[dict] = None, galaxy_kwargs: Optional[dict] = None, master_loud: bool = True, setup_id_append: str = '', **kwargs)[source]

Bases: firestudio.studios.studio.Studio

__init__(datadir: str, snapnum: int, sim_name: str, cache_file_name: Optional[str] = None, gas_snapdict: Optional[dict] = None, star_snapdict: Optional[dict] = None, galaxy_kwargs: Optional[dict] = None, master_loud: bool = True, setup_id_append: str = '', **kwargs)

Base class that handles camera manipulation and data caching.

Parameters
  • datadir (str) – directory to put intermediate and output files, 'firestudio' is appended if the directory contains sim_name

  • snapnum (int) – snapshot number (feel free to lie if you aren’t using FIRE_studio to open a snapshot, it is needed for cache file name though)

  • sim_name (str) – name of the simulation, i.e. 'm12i_res7100'. prepends the cache_file_name if the sim_name isn’t already in the path to disambiguate caches.

  • cache_file_name (str, optional) – the name of the file to save maps to, if None 'proj_maps_%03d.hdf5'%snapnum, defaults to None

  • gas_snapdict (dict, optional) – a dictionary containing SPH data, defaults to None

  • star_snapdict (dict, optional) – a dictionary containing collisionless particle data, defaults to None

  • galaxy_kwargs (dict, optional) – dictionary that contains kwargs that should be passed to the opened abg_python.galaxy.Galaxy instance that is used to load snapshot data from disk, defaults to None

  • master_loud (bool, optional) – flag for enabling/disabling all print statements, defaults to True

  • setup_id_append (str, optional) – suffix to append to the setup_id in the cache file, defaults to ‘’

Methods

__init__(datadir, snapnum, sim_name[, ...])

Base class that handles camera manipulation and data caching.

addScaleBar(image)

_summary_

addText(ax)

_summary_

computeFrameBoundaries()

Uses the camera to calculate the minimum and maximum x, y, and z limits as well as the physical resolution of the image.

cullFrameIndices(Coordinates)

boolean mask of those particles within the volume defined by Xmin-Xmax, Ymin-Ymax, and Zmin-Zmax

drawCoordinateAxes(ax[, spacing, length, colors])

_summary_

get_HSML(snapdict_name[, use_metadata, ...])

Compute smoothing lengths for particles that don't have them, typically collisionless particles (like stars).

get_gasThreebandImage([use_metadata, ...])

routine to use raytrace_projection_compute to make mock gas images, with three color channels for different temperature ranges

gradientBlendImages(image_1[, image_2, ...])

_summary_

load_SnapshotData([gas_mask, star_mask])

Binds simulation output to self.gas_snapdict and self.star_snapdict.

plotImage(*args, **kwargs)

Base method for overlaying artists on top of projected image.

predictParameters([left_percentile, ...])

Guesses what the "best" values for maxden and dynrange are from the distribution of surface brightnesses in the current image.

prepareCoordinates([use_log_t, isosurfaces, ...])

many experiments here: doing gas isosurfaces with broad kernels and overlaying a custom set of color tables after the fact seems best.

print_ImageParams()

Prints current image setup to console.

produceImage([quick])

quick_get_gasThreebandImage(**kwargs)

Approximates get_gasThreebandImage() but using 2d histograms

render([ax])

Plots a projected image using the stored image parameters.

renormalizeTransposeImage(image, min_val, ...)

_summary_

saveFigure(fig[, image_name])

_summary_

set_CacheFile()

Creates the cache hdf5 file.

set_ImageParams([use_defaults, loud])

Changes the parameters of the image.

Attributes

required_snapdict_keys

these are minimum required keys for render() function to run.

addScaleBar(image: numpy.ndarray)

_summary_

Parameters

image (np.ndarray) – array of RGB image pixel values

Returns

image

Return type

np.ndarray

addText(ax: matplotlib.axes._axes.Axes)

_summary_

Parameters

ax (plt.Axes) – _description_

computeFrameBoundaries()

Uses the camera to calculate the minimum and maximum x, y, and z limits as well as the physical resolution of the image.

Sets following attributes

self.Xmin, self.Xmaxself.Ymin, self.Ymaxself.Zmin, self.Zmaxself.npix_x, self.npix_yself.Acell

cullFrameIndices(Coordinates: numpy.ndarray)

boolean mask of those particles within the volume defined by Xmin-Xmax, Ymin-Ymax, and Zmin-Zmax

Parameters

Coordinates (np.ndarray) – array of particle coordinates

Returns

a boolean mask which is True for particles in the extraction volume and False outside.

Return type

bool np.ndarray

drawCoordinateAxes(ax: matplotlib.axes._axes.Axes, spacing: float = 1, length: float = 10, colors: Optional[list] = None)

_summary_

Parameters
  • ax (plt.Axes) – _description_

  • spacing (float, optional) – _description_, defaults to 1

  • length (float, optional) – _description_, defaults to 10

  • colors (list, optional) – _description_, defaults to None

Returns

_description_

Return type

_type_

get_HSML(snapdict_name: str, use_metadata: bool = True, save_meta: bool = True, assert_cached: bool = False, loud: bool = True, **kwargs)

Compute smoothing lengths for particles that don’t have them, typically collisionless particles (like stars).

Parameters
  • snapdict_name (str) – string identifying which snapdict should be used to compute smoothing lengths, either 'gas' or 'star'

  • use_metadata (bool, optional) – flag for whether a cached result should be used (if it exists), defaults to True

  • save_meta (bool, optional) – flag to save the result in the cache, defaults to True

  • assert_cached (bool, optional) – flag to require a cache hit and raise an exception otherwise, defaults to False

  • loud (bool, optional) – flag for whether cache hits/misses should be announced to the console, defaults to True

Returns

estimated smoothing lengths

Return type

np.float32 np.ndarray

get_gasThreebandImage(use_metadata=True, save_meta=True, assert_cached=False, loud=True, **kwargs)[source]

routine to use raytrace_projection_compute to make mock gas images, with three color channels for different temperature ranges

Parameters
  • use_metadata (bool, optional) – flag for whether a cached result should be used (if it exists), defaults to True

  • save_meta (bool, optional) – flag to save the result in the cache, defaults to True

  • assert_cached (bool, optional) – flag to require a cache hit and raise an exception otherwise, defaults to False

  • loud (bool, optional) – flag for whether cache hits/misses should be announced to the console, defaults to True

Kwargs
  • use_log_t (bool, optional) – defaults to True

  • isosurfaces (bool, optional) – defaults to False

  • add_temperature_weights (bool, optional) – defaults to False

Returns

out_all - | out_cold - | out_warm - | out_hot -

Return type

np.ndarray, np.ndarray, np.ndarray, np.ndarray

gradientBlendImages(image_1: numpy.ndarray, image_2: Optional[numpy.ndarray] = None, gradient_width_percent: float = 0.1, angle: Optional[float] = None, **kwargs)

_summary_

Parameters
  • image_1 (np.ndarray) – _description_

  • image_2 (np.ndarray, optional) – _description_, defaults to None

  • gradient_width_percent (float, optional) – _description_, defaults to 0.1

  • angle (float, optional) – _description_, defaults to None

Returns

_description_

Return type

_type_

load_SnapshotData(gas_mask: Optional[numpy.ndarray] = None, star_mask: Optional[numpy.ndarray] = None, **kwargs)

Binds simulation output to self.gas_snapdict and self.star_snapdict.

Parameters
  • gas_mask (np.ndarray, optional) – boolean mask that should be applied to the galaxy.sub_snap, defaults to None

  • star_mask (np.ndarray, optional) – boolean mask that should be applied to the galaxy.sub_star_snap, defaults to None

Kwargs
  • fuse_saved_subsnapshots (bool, optional) – save/load subsnapshots, uncompressed copies of the snapshot oriented on the main disk with particles within the virial radius. This can take up lots of disk space, defaults to False

  • del_galaxy (bool, optional) – flag for whether the abg_python.galaxy.gal_utils.Galaxy object should be deleted after being used to get the snapshot dictionaries, defaults to True

Returns

abg_python.galaxy.Galaxy if del_galaxy == False, otherwise returns None

Return type

None/abg_python.galaxy.Galaxy object

plotImage(*args, **kwargs)[source]

Base method for overlaying artists on top of projected image.

if self.scale_bar: overlays a scale bar by filling the RGB pixel values with white if self.noaxis: removes the coordinate axes, labels, and ticks

Will also add self.figure_label as text to the image. See set_ImageParams() for details.

Parameters
  • ax (plt.Axes) – axis to plot image to

  • final_image (np.ndarray) – array of RGB image pixel values

predictParameters(left_percentile: float = 0.1, right_percentile: float = 0.99, all_bands: Optional[numpy.ndarray] = None, ax: Optional[matplotlib.axes._axes.Axes] = None, quick: bool = False)[source]

Guesses what the “best” values for maxden and dynrange are from the distribution of surface brightnesses in the current image. Looks for the left_percentile and right_percentile and return right_percentile and the distance between it and left_percentil (in log space).

Parameters
  • left_percentile (float, optional) – lower bound on image surface brightness percentile, defaults to 0.1

  • right_percentile (float, optional) – upper bound on image surface brightness percentile, defaults to 0.99

  • all_bands (_type_, optional) – optionally plots distribution of surface brightnesses (in some units…) with overlay of percentiles and such, defaults to None

  • ax (_type_, optional) – _description_, defaults to None

  • quick (bool, optional) – flag to use a simple 2d histogram (for comparison or for quick iteration as the user defines the image parameters), defaults to False

Raises

NotImplementedError – if quick

Returns

maxden – maximum surface brightness of the image
dynrange – distance between maximum and minimum surface brightness in log space.

Return type

float, float

prepareCoordinates(use_log_t=True, isosurfaces=False, add_temperature_weights=False)[source]

many experiments here: doing gas isosurfaces with broad kernels and overlaying a custom set of color tables after the fact seems best. adjust opacity (kappa_units) and kernel width as needed. also, can set ‘dynrange=0’ to automatically produce a given fraction of saturated/unsaturated pixels

Parameters
  • use_log_t (bool, optional) – _description_, defaults to True

  • isosurfaces (bool, optional) – _description_, defaults to False

  • add_temperature_weights (bool, optional) – _description_, defaults to False

Returns

_description_

Return type

_type_

print_ImageParams()[source]

Prints current image setup to console.

quick_get_gasThreebandImage(**kwargs)[source]

Approximates get_gasThreebandImage() but using 2d histograms

Returns

_description_

Return type

_type_

render(ax: Optional[matplotlib.axes._axes.Axes] = None, **kwargs)[source]

Plots a projected image using the stored image parameters.

Parameters

ax (plt.Axes, optional) – axis to plot image to, if None will create a new figure, defaults to None

Raises

NotImplementedError – _description_

Returns

ax – the axis the image was plotted to
final_image – output RGB pixel array

Return type

plt.Axes, np.ndarray(Npix_x,Npix_y,3)

Example usage
fireStudio.render()
renormalizeTransposeImage(image: numpy.ndarray, min_val: float, max_val: float, quantity_name: str)

_summary_

Parameters
  • image (np.ndarray) – _description_

  • min_val (float) – _description_

  • max_val (float) – _description_

  • quantity_name (str) – _description_

Returns

_description_

Return type

_type_

required_snapdict_keys = ['Masses', 'Coordinates', 'SmoothingLength', 'Temperature']

these are minimum required keys for render() function to run.

saveFigure(fig, image_name: Optional[str] = None, **savefig_args)

_summary_

Parameters
  • fig (_type_) – _description_

  • image_name (str, optional) – _description_, defaults to None

set_CacheFile()

Creates the cache hdf5 file. Requires self.snapnum and sim_name be set.

Raises

IOError – if self.snapnum and self.sim_name are not set to disambiguate the cache file

Returns

cache file for storing image maps

Return type

abg_python.galaxy.metadata_utils.Metadata

set_ImageParams(use_defaults=False, loud=True, **kwargs)[source]

Changes the parameters of the image. Also calls Studio’s set_ImageParams(), passing along any unmatched kwargs.

Parameters
  • use_defaults (bool, optional) – If True then default values of the parameters will be set (potentially overwriting any previously specified parameters). If False adjust only the keywords passed, defaults to False

  • loud (bool, optional) – flag to print which parameters are being set/updated, defaults to True

Kwargs
  • tcuts (tuple, optional) – temperature cuts for each of the three RGB bands

  • maxden (float, optional) – controls the saturation of the image, sets the upper limit of the “colorbar” if None uses the 99 %’ile of the image surface brightness, defaults to None

  • dynrange (float, optional) – controls the saturation of the image, sets the lower limit of the “colorbar” with respect to maxden, if None uses the dynamic range between maxden and the 10th %’ile of the image surface brightness, defaults to None

Example usage
fireStudio.set_ImageParams(
    tcuts = (300,2e4,3e5)
    figure_label='t = 13.8 Gyr')