API Reference

File reading

Sarracen’s design goal is to read data from multiple SPH codes while preserving full functionality. All the general file formats supported by pandas (csv, notably) work within Sarracen.

For SPH codes, Sarracen supports reading the native binary format of the Phantom code, the Gasoline code, and the Shamrock code.

Raise an issue on our GitHub if you would like Sarracen to be able to read the file format for other SPH codes (or make a pull request!).

read_csv(*args, **kwargs)

Read data from a csv file.

read_gasoline(filename[, outtype])

Read data from a Gasoline tipsy file.

read_gradsph(filename[, separate_types])

Read data from a GradSPH dump file.

read_marisa(filename[, slicenumber])

Read data from a Marisa dump file.

read_phantom()

Read data from a Phantom dump file.

read_phantom_ev(filename)

Read a Phantom .ev file and return a pandas DataFrame of the data.

read_shamrock(filename)

Read data from a Shamrock native binary format dump file.

read_shamrock_vtk(filename, pmass)

Read data from a Shamrock vtk file (compatible with Paraview).

File writing

Sarracen can write native binary Phantom dump files. SarracenDataFrames can also be dumped to .csv using pandas functionality.

write_phantom(filename, sdf[, sinks])

Write a Phantom dump file from a SarracenDataFrame.

SarracenDataFrame

A SarracenDataFrame is a subclass of the pandas DataFrame class. It holds SPH particle data. SarracenDataFrames will attempt to identify columns which hold particle positions, velocities, smoothing lengths, masses and densities so that they can be used for interpolation and rendering. Global simulation values are stored in params, which is a standard Python dictionary.

Constructor

SarracenDataFrame

A SarracenDataFrame is a pandas DataFrame with support for SPH data.

Extra Quantities

SarracenDataFrame.calc_density

Create a new column 'rho' that contains particle densities.

SarracenDataFrame.calc_one_fluid_quantities

Create new columns that contain the densities of gas, dust (total), each dust grain size and the dust-to gas ratio in one-fluid (a.k.a.

SarracenDataFrame.centre_of_mass

Returns the centre of mass of the data.

Rendering

SarracenDataFrame.render(target[, x, y, z, ...])

Render a scalar SPH target variable to a grid plot.

SarracenDataFrame.lineplot(target[, x, y, ...])

Render a scalar SPH target variable to line plot.

SarracenDataFrame.streamlines(target[, x, ...])

Create an SPH interpolated streamline plot of a target vector.

SarracenDataFrame.arrowplot(target[, x, y, ...])

Create an SPH interpolated vector field plot of a target vector.

Interpolation

SarracenDataFrame.sph_interpolate(target[, ...])

Interpolate this data to a 2D or 3D grid, depending on the dimensionality of the data.

sarracen.kernels

The default smoothing kernel is the cubic spline. Additional smoothing kernels are included within the kernels module.

kernels.CubicSplineKernel()

An implementation of the Cubic Spline kernel

kernels.QuarticSplineKernel()

An implementation of the Quartic Spline kernel.

kernels.QuinticSplineKernel()

An implementation of the Quintic Spline kernel.

sarracen.disc

Accretion disc analysis routines are in the disc module.

disc.surface_density(data[, r_in, r_out, ...])

Calculates the 1D azimuthally-averaged surface density profile.

disc.azimuthal_average(data, target[, r_in, ...])

Calculates the 1D azimuthally-averaged profile for a target quantity.

disc.angular_momentum(data[, r_in, r_out, ...])

Calculates the angular momentum profile of the disc.

disc.scale_height(data[, r_in, r_out, bins, ...])

Calculates the scale height, H/R, of the disc.

disc.honH(data[, r_in, r_out, bins, log, ...])

Calculates <h>/H, the averaged smoothing length divided by the scale height.

sarracen.ptmass

Analysis routines related to point masses and sink particles are in the ptmass module.

ptmass.classify_bound_particles(sdf, sdf_sinks)

Determines to which sink each SPH particle is gravitationally bound.