Utilities

Plotting

There exists several built in plotting tools to help visualize a StarCluster.

Functions

starplot(cluster[, coords, xlim, ylim, ...])

Plot the xy/xz/yz coordinates of each star in the cluster

skyplot(cluster[, coords, xlim, ylim, ...])

Plot the ra/dec or pmra/pmdec coordinates of each star in the cluster

Output

There exists several built in tools for creating standardized output files.

Functions

snapout(cluster, filename[, energies, radec])

Output a snapshot in clustertools format

sseout(cluster, filename)

Output simple stellar evolution information in clustertools format

fortout(cluster[, filename, sse, ...])

Output a snapshot in NBODY6 fort.10 format

gyrout(cluster[, filename, eps, epsunits, ...])

Output a snapshot in gyrfalcon/NEMO format

It is of course possible to include custom output functions, which for simplicity could be put in the custom folder which is imported. As an example I have included custom_outputs.py that demonstrates several output functions that I frequently use.

Coordinates

While coordinate transformations to a StarCluster are handled via Operations, users may find the below functions helpful if trying to manually do some coordinate transformations. Note that several of these functions (cart_to_cyl,``sky_coords``,``cart_to_sky``) are wrappers around galpy coordinate transformations.

Functions

sphere_coords(cluster)

Get the spherical coordinates of every star in the cluster

cart_to_sphere(x, y, z, vx, vy, vz)

Convert cartesian coordinates to spherical coordinates

sphere_to_cart(r, phi, theta, vr, vphi, vtheta)

Convert cartesian coordinates to spherical coordinates

cyl_coords(cluster)

Get the cylindrical coordinates of every star in the cluster

cart_to_cyl(x, y, z, vx, vy, vz)

Convert cartesian coordinates to cylindrical coordinates

cyl_to_cart(r, theta, zed, vr, vtheta, vz)

Convert cylindrical coordinates to cartesian coordinates

sky_coords(cluster[, ro, vo, solarmotion, zo])

Get the sky coordinates of every star in the cluster

cart_to_sky(x, y, z, vx, vy, vz[, ro, vo, ...])

Convert cartesian coordinates to sky coordinates

Recipes

Finally, several functions that are used throughout StarCluster that users may find helpful are listed below.

Functions

nbinmaker(x[, nbin, nsum])

Split an array into bins with equal numbers of elements

binmaker(x[, nbin, nsum, steptype])

Split an array into bins of equal width

roaming_nbinmaker(x[, nbin, ntot, nsum])

Split an array into bins with equal numbers of elements

roaming_binmaker(x[, nbin, ntot, nsum, steptype])

Split an array into bins of equal width with a roaming average

power_law_distribution_function(n, alpha, ...)

Generate points from a power-law distribution function

dx_function(x[, nx, bintype, x_lower, ...])

Find distribution function using nx bins

tapered_dx_function(x[, nx, bintype, ...])

Find distribution function using nx bins

x_hist(x[, nx, bintype, bins, x_lower, ...])

Find histogram data using nx bins

mean_prof(x, y[, nbin, bintype, steptype, ...])

Calculate mean profile of parameter y that depends on x

smooth(x, y, dx[, bintype, median])

Smooth a profile

interpolate(r1, r2[, x, y])

Perform simple linear interpolation between two points in 2D

minimum_distance(x)

Find distance to each point's nearest neighbour

distance(x1, x2)

Find distance between two points (made for use with numba)

Constants

For convenience purposes, a few constants are saved to be used globally throughout clustertools. A function that prints the conversion table between kw and stellar evolution type, as discussed in Cluster is also included here.

Functions

kwtypes()

Legend for converting kwtype (from NBODY6) to stellar evolution type