sphview: Visualise one or several 3D point sets

Description Usage Arguments Value Author(s) Examples

View source: R/sphview.R

Description

Produces a raster image visualising particle positions in 3D N-body/SPH data.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
sphview(
  x,
  species = NULL,
  value = NULL,
  valrange = NULL,
  fix.brightness = TRUE,
  weight = NULL,
  colspecies = c("#ff0010", "#0515ff", "green", "orange", "yellow", "purple"),
  colscale = cooltools::spectrumcolors(1000),
  center = NULL,
  width = NULL,
  aspect = 1,
  thickness = NULL,
  subsampling = 1,
  screen = TRUE,
  pngfile = NULL,
  pdffile = NULL,
  rotation = 1,
  ngrid = 300,
  title = NULL,
  title.origin = NULL,
  lum = 1,
  shadows = 1,
  freeze.lum = FALSE,
  sigma = NULL,
  kde = TRUE,
  arrows = TRUE,
  arrow.origin = NULL,
  arrow.length = NULL,
  arrow.lwd = 1.5,
  scale = TRUE,
  scale.origin = NULL,
  scale.length = NULL,
  scale.lwd = 1.5,
  length.unit = "",
  xlab = NULL,
  ylab = NULL,
  cex = 1,
  text.offset = 0,
  text.col = "white"
)

Arguments

x

n-by-3 matrix, representing the 3D-coordinates of n particles.

species

optional argument specifying different particle species. This must be either a n-element vector giving the integer species indices of each particle or a 6-element vector giving the number of particles of each type (see Npart or NumPart_ThisFile in Gadget header). Different species can be displayed with different colors. If not given, all particles will be assumed to be of the first species (normally gas in Gadget).

value

optional n-element vector specifying a particle property (e.g. temperatures) to be shown in color. This overwrites the colors set by species.

valrange

2-vector specifying the range of values covered by the colors in the vector colorscale.

fix.brightness

logical flag specifying whether the brightness of value-plots should scale with density.

weight

optional n-element vector, specifying the weight of different particles.

colspecies

vector of colors, specifying the color of the species given in the optional species vector.

colscale

vector of colors used to shown the particle property given by the optional vectors value.

center

optional 3-vector specifying the coordinate at the center of the plot. The default is the geometric center (= center of mass, if all particle masses are equal).

width

optional horizontal range of the image in the length units of x. The default corresponds to the full range of particle positions.

aspect

aspect ratio (= width/height).

thickness

optional thickness in length units of x of the slice to be plotted. If not given, all particles are shown.

subsampling

fraction of particles to be used (if 1, all particles are used, if <1 a random subsample is drawn)

screen

logical flag specifying whether the images is displayed on the screen.

pngfile

optional png-filename to save the image as raster image.

pdffile

optional pdf-filename to save the image as pdf-file.

rotation

either an integer (1-6), a 3-vector or a 3-by-3 matrix, specifying a rotation of the 3D particle positions. In case of an integer: 1=(x,y)-plane, 2=(y,z)-plane, 3=(x,y)-plane, 4=(qmax,qmin)-plane, 5=(qmax,qmid)-plane, 6=(qmid,qmin)-plane, where qmax/qmid/qmin are the eigenvectors of the particle-quadrupole, associated with the maximum/middle/minimum eigenvalues, respectively. If rotation is a vector, its direction specifies the rotation axis and its norm the rotation angle in radians in the positive geometric sense.

ngrid

optional number of grid cells per side in the output image. If the image is not square ngrid is interpreted as the geometric mean between the horizontal and the vertical number of pixels, such that the total number of pixels remains about ngrid^2.

title

Text to be added to the figure.

title.origin

optional 2-vector specifying the position of the title

lum

overall luminosity scaling factor (default 1).

shadows

differential luminosity scaling factor for darker regions (default 1).

freeze.lum

logical flag (default FALSE). If set to TRUE, the luminosity will not be adjusted as a function of the visible particles. This is normally needed to avoid flickering in animations.

sigma

smoothing scale in simulation units. The default is NULL, meaning that a value is picked automatically. If a vector is provided, the different elements will be interpreted as corresponding to different species.

kde

logical flag, specifying whether the particles are smoothed using an adaptive kernel density estimator. If a vector is provided, the different elements will be interpreted as corresponding to different species.

arrows

logical flag, specifying if axis-arrows are drawn

arrow.origin

optional 2-vector specifying the bottom left corner of the arrows

arrow.length

optional number specifying the length of the arrows

arrow.lwd

line width of arrows

scale

logical flag, specifying if a length scale is shown

scale.origin

optional 2-vector specifying the right end of the length scale

scale.length

optional number specifying the length of the length scale (is always rounded to one significant digit)

scale.lwd

line width of length scale

length.unit

character string of length unit (e.g. "m" or "kpc")

xlab

label on horizontal arrow (only shown if arrows=TRUE).

ylab

label on vertical arrow (only shown if arrows=TRUE).

cex

text size

text.offset

optional extra offset for the arrow and scale labels

text.col

color of text, arrows and scale

Value

Returns a list of items

rgb

ngrid-by-ngrid-by-3 array of containig the rgb colour data between 0 and 1

radius

positive real number specifying the radius of the image along the horizontal and vertical axes, in the units of the particle positions

rotationmatrix

rotation matrix applied to the input data, i.e. the projection was x = (x%*%rot)[,1:2]

Author(s)

Danail Obreschkow

Examples

1
2
3
4
# Example of 2x1e4 particles in a triaxial ellipsoid
x.red = t(t(cooltools::runif3(1e4))*c(3,2,1))
x.blue = abs(t(t(cooltools::runif3(1e4,r=c(0.5,1)))*c(3,2,1)))
sphview(rbind(x.red,x.blue), species=c(rep(1,1e4),rep(2,1e4)), center=0)

obreschkow/simstar documentation built on Jan. 29, 2022, 2:16 p.m.