4 API Reference

4.1 Fractal Cube objects

The two main classes dealing with fractal cubes in this module are pyFC.LogNormalFractalCube and pyFC.GaussianFractalCube, which are both derived from pyFC.FractalCube (see clouds.py). The following are descriptions of the class and its public members.

class pyFC.LogNormalFractalCube(ni=64, nj=64, nk=64, kmin=1, kmax=None, mean=1, sigma=2.23606797749979, beta=- 1.66666666666)[source]

Bases: pyFC.clouds.FractalCube

Class for lognormal fractal cubes, as generated by the method of Lewis & Austin (2002). This class contains basic reading, writing, generating functions, copy function, and functions to calculate power spectra. Functions to calculate the power spectra exist because they are needed in the actual construction routine. The statistical parameters of the fractal cube are contained as attributes.

Parameters
  • ni,nj,nk (int) – number of points in \(i\), \(j\), \(k\) directions

  • kmin (int) – \(k_\mathrm{min}\) of fractal cube

  • kmax (int) – \(k_\mathrm{max}\) of fractal cube. This is set to the Nyquist limit if None.

  • mean (flt) – the mean of the lognormal PDF

  • sigma (flt) – the standard deviation of the lognormal PDF

  • beta (flt) – the power-law index of \(D(k)\), the power spectrum.

The above parameters are all saved as attributes of an instance of this class.

copy()

Make a deep copy of this object

Returns

A deep copy of this object

Return type

pyFC.FractalCube

cube

(ndarray) – The lognormal fractal cube data as an arrayof shape pyFC.LogNormalFractalCube.shape

cubetype

(str) – Cube type {‘lognormal’, ‘gaussian’}.

func_target_spec(k, kmin=None, kmax=None, beta=None)[source]

The target spectrum function

Parameters
  • k (ndarray) – A domain in \(k\)-space to evaluate the target spectrum over.

  • kmin (flt) – A lower cutoff wavenumber, \(k_\mathrm{min}\).

  • beta (flt) – The power law index of the target spectrum, \(eta\).

Returns

Target spectrum. Same shape as k.

Return type

ndarray

gen_cube(verbose=True)[source]

Generate a lognormal fractal cube by the method of Lewis & Austin (2002) with the statistical properties saved in the instance of the pyFC.FractalCube object.

Parameters

verbose (bool) – Verbosity switch.

Returns

The generated lognormal fractal cube

Return type

pyFC.LogNormalFractalCube object

Note

The actual code for generating fractal cubes is in pyFC.LogNormalFractalCube.yield_cubes().

gnfc()[source]

The corresponding Gaussian field.

Returns

The corresponding Gaussian field.

Return type

pyFC.GaussianFractalCube object

inner_range_slice(cf, min, max)

Return a numpy slice object that only selects some region interior of min and max

Parameters
  • cf – values to be compared with min and max

  • min – minimum value

  • max – maximum value

Returns

slice object for interior regions

iso_power_spec(kmag=None, cube=None, stdev=False)

Isotropic power spectrum of this fractal cube.

Parameters
  • kmag (ndarray) – Array of wave-vector magnitude values (same size and dimensions as cube)

  • cube (ndarray) – Array with cube data

  • stdev (bool) – Calculate standard deviation

Returns

Isotropic power spectrum of this fractal cube. \((D(|k|), |k|)\)

Return type

tup

kmag_sampling(ni=None, nj=None, nk=None)

Sampling space, \(|k|_{i,j,k}\). See definition of FFT, \(k\) and frequency at http://docs.scipy.org/doc/numpy/reference/routines.fft.html

Parameters

ni, nj, nk (int) – Number of cells (sample points) in i, j, k directions, respectively

Returns

3-D array with sampling vector magnitudes

Return type

ndarray

ndim

(int) – Number of dimensions of the fractal cube data array pyFC.LogNormalFractalCube.cube

norm_spec(spectrum)

Normalize a spectrum so that apodizing a random Gaussian cube with the root of spectrum does not change the mean and variance of the Gaussian

Parameters

spectrum (ndarray) – A 1-, 2-, or 3-dimensional spectrum

Returns

Normalized spectrum, same shape as input spectrum

Return type

ndarray

power_spec(cube=None)

Power spectrum of a fractal cube data

Parameters

cube (ndarray) – FractalCube.cube data array

Returns

Power spectrum of this fractal cube

Return type

ndarray

print_stats()

Prints stats of the Fractal cube, including (cubetype, ni, nj, nk, kmin, mean, sigma, beta)

Returns

1 at completion of routine

Return type

int

read_cube(fname='data.dbl', prec='double', out='inplace')

Read cube from file. The data of the cube returned and also saved to the pyFC.LogNormalFractalCube.cube attribute

Parameters
  • fname (str) – Data filename

  • prec (str) – Floating point precision of output {‘double’|’single’}

Returns

Data of cube read in

Return type

ndarray

Raise

ValueError if prec is invalid

shape

(tup) – Shape of the fractal cube data array pyFC.LogNormalFractalCube.cube

write_cube(fc=None, fname='data.dbl', app=True, prec='double')

Writes out a fractal cube data file in little endian, double precision. Care is taken not to overwrite existing files.

Parameters
  • fname (str) – Data filename

  • app (bool) – automatically append kmin, ni, nj, and nk values to filename. If app == True, append kmin, ni, nj, nk values to filename. If suffixed files ‘<base>-[0-9][0-9]<ext>’ exist, appended by a suffix one larger than the highest number found.

  • prec (str) – Floating point precision of output {‘double’|’single’}

Returns

1 for successful write

Return type

int

Raise

ValueError if prec is invalid

yield_cubes(history=True, verbose=True)[source]

Generate a lognormal fractal cube by the method of Lewis & Austin (2002) with the statistical properties saved in the instance of the FractalCube object.

Parameters
  • verbose (bool) – Verbosity switch.

  • history (bool) – History switch. If true, generate a cube for each iteration. This parameter should always be true, unless this function is called from pyFC.LogNormalFractalCube.gen_cube().

Returns

Yields lognormal fractal cubes

Return type

pyFC.LogNormalFractalCube object

If history is True, this routine yields the cubes for each iteration. This option is actually not to be used. Use gen_cube instead.

class pyFC.GaussianFractalCube(ni=64, nj=64, nk=64, kmin=1, kmax=None, mean=0, sigma=200.0, beta=- 1.6666666666666)[source]

Bases: pyFC.clouds.FractalCube

Class for lognormal fractal cubes, as generated by taking a random gaussian field and apodizing its spectrum in fourier space with a power law.

Parameters
  • ni,nj,nk (int) – number of points in \(i\), \(j\), \(k\) directions

  • kmin (int) – \(k_\mathrm{min}\) of fractal cube

  • mean (flt) – the mean of the lognormal PDF

  • sigma (flt) – the standard deviation of the gaussian PDF

  • beta (flt) – the power-law index of \(D(k)\), the power spectrum.

The above parameters are all saved as attributes of an instance of this class.

copy()

Make a deep copy of this object

Returns

A deep copy of this object

Return type

pyFC.FractalCube

cube

(ndarray) – Gaussian fractal cube data as ndarray of shape pyFC.GaussianFractalCube.shape

cubetype

(str) – Cube type {‘lognormal’, ‘gaussian’}.

func_target_spec(k, kmin=None, kmax=None, beta=None)[source]

The target spectrum function

Parameters
  • k (ndarray) – A domain in \(k\)-space to evaluate the target spectrum over.

  • kmin (flt) – A lower cutoff wavenumber, \(k_\mathrm{min}\).

  • beta (flt) – The power law index of the target spectrum, \(eta\).

Returns

Target spectrum. Same shape as k.

Return type

ndarray

gen_cube(history=False)[source]

Generate a Gaussian fractal cube with the statistics saved as attributes in an instance of this object.

Parameters

history (bool) – If history is True, this routine returns the initial cube too.

Returns

Gaussian fractal cube

Return type

pyFC.GaussianFractalCube

inner_range_slice(cf, min, max)

Return a numpy slice object that only selects some region interior of min and max

Parameters
  • cf – values to be compared with min and max

  • min – minimum value

  • max – maximum value

Returns

slice object for interior regions

iso_power_spec(kmag=None, cube=None, stdev=False)

Isotropic power spectrum of this fractal cube.

Parameters
  • kmag (ndarray) – Array of wave-vector magnitude values (same size and dimensions as cube)

  • cube (ndarray) – Array with cube data

  • stdev (bool) – Calculate standard deviation

Returns

Isotropic power spectrum of this fractal cube. \((D(|k|), |k|)\)

Return type

tup

kmag_sampling(ni=None, nj=None, nk=None)

Sampling space, \(|k|_{i,j,k}\). See definition of FFT, \(k\) and frequency at http://docs.scipy.org/doc/numpy/reference/routines.fft.html

Parameters

ni, nj, nk (int) – Number of cells (sample points) in i, j, k directions, respectively

Returns

3-D array with sampling vector magnitudes

Return type

ndarray

lnfc()[source]

Corresponding Lognormal field.

Returns

The corresponding Lognormal field.

Return type

pyFC.LogNormalFractalCube object

ndim

(int) – Number of dimensions of the fractal cube data array pyFC.GaussianFractalCube.cube

norm_spec(spectrum)

Normalize a spectrum so that apodizing a random Gaussian cube with the root of spectrum does not change the mean and variance of the Gaussian

Parameters

spectrum (ndarray) – A 1-, 2-, or 3-dimensional spectrum

Returns

Normalized spectrum, same shape as input spectrum

Return type

ndarray

power_spec(cube=None)

Power spectrum of a fractal cube data

Parameters

cube (ndarray) – FractalCube.cube data array

Returns

Power spectrum of this fractal cube

Return type

ndarray

print_stats()

Prints stats of the Fractal cube, including (cubetype, ni, nj, nk, kmin, mean, sigma, beta)

Returns

1 at completion of routine

Return type

int

read_cube(fname='data.dbl', prec='double', out='inplace')

Read cube from file. The data of the cube returned and also saved to the pyFC.LogNormalFractalCube.cube attribute

Parameters
  • fname (str) – Data filename

  • prec (str) – Floating point precision of output {‘double’|’single’}

Returns

Data of cube read in

Return type

ndarray

Raise

ValueError if prec is invalid

shape

(tup) – Shape of the fractal cube data array pyFC.GaussianFractalCube.cube

write_cube(fc=None, fname='data.dbl', app=True, prec='double')

Writes out a fractal cube data file in little endian, double precision. Care is taken not to overwrite existing files.

Parameters
  • fname (str) – Data filename

  • app (bool) – automatically append kmin, ni, nj, and nk values to filename. If app == True, append kmin, ni, nj, nk values to filename. If suffixed files ‘<base>-[0-9][0-9]<ext>’ exist, appended by a suffix one larger than the highest number found.

  • prec (str) – Floating point precision of output {‘double’|’single’}

Returns

1 for successful write

Return type

int

Raise

ValueError if prec is invalid

FractalCube._returner(self, result, out)[source]

Given a result, return the correct thing given an “out mode”

Parameters
  • result (ndarray) – The FractalCube.cube result that should be returned, copied, etc.

  • out (str) – The “out mode”. Possible values are ‘inplace’: save the ndarray data to self.cube return the FractalCube instance; ‘ndarray’: save the ndarray data to self.cube and return the ndarray; ‘copy’: return a copy of the FractalCube instance, with the ndarray data saved to the copy’s self.cube.

Returns

Varies according to the “out mode”, out

Return type

Varies according to the “out mode”, out

inplace: default, change in place

4.2 Utility functions

The following are some utility function for quick visualization and inspection of fractal cubes. A function beginning with plot_() creates a figure and plot, whereas a function beginning with paint_() paints a plot into axes (and colorbar) provided in the argument:

pyFC.paint_midplane_slice(fc, pax=<matplotlib.axes._subplots.AxesSubplot object>, ax=2, scaling='lin', cmap=<matplotlib.colors.LinearSegmentedColormap object>, plottype='imshow', kminlabel=False, vmin=None, vmax=None, cax=None)[source]

Create and paint midplane slice into axis pax

Parameters
  • fc (obj) – pyFC.FractalCube object

  • pax (int) – Axis to paint midplane slice into

  • ax (int) – Direction of plane normal. {0|1|2}, default is 0 (“y-z plane”)

  • scaling (str) – Linear “lin” or logarithmic “log” data map

  • cmap (obj) – Colormap. Any colormap object (default is cm.copper)

  • plottype (int) – Type of plot {‘imshow’|’pcolormesh’}

  • kminlabel (int) – Boolean, draw label with kmin value?

  • vmin, vmax (int) – Min max dynamic range of plotted data

  • cax (int) – Colorbar axis to paint colorbar into

This plot is independent of cube type.

pyFC.plot_midplane_slice(fc, ax=2, scaling='lin', cmap=<matplotlib.colors.LinearSegmentedColormap object>, plottype='imshow', labels=False, colorbar=False, kminlabel=False, vmin=None, vmax=None)[source]

Create and plot midplane slice

Parameters
  • fc (obj) – pyFC.FractalCube object

  • ax (int) – Direction of plane normal. {0|1|2}, default is 0 (“y-z plane”)

  • scaling (str) – Linear “lin” or logarithmic “log” data map

  • cmap (obj) – Colormap. Any colormap object (default is cm.copper)

  • plottype (int) – Type of plot {‘imshow’|’pcolormesh’}

  • labels (bool) – Boolean, draw tick labels?

  • colorbar (bool) – Boolean, draw colorbar?

  • kminlabel (int) – Boolean, draw label with kmin value?

  • vmin, vmax (int) – Min max dynamic range of plotted data

pyFC.paint_raytrace(fc, pax=<matplotlib.axes._subplots.AxesSubplot object>, ax=0, scaling='lin', cmap=<matplotlib.colors.LinearSegmentedColormap object>, plottype='imshow', kminlabel=False, absorb_coeff=1.0, emiss_coeff=1.0, vmin=None, vmax=None, cax=None)[source]

Plot a raytraced image into axis. Emissivity has same units as intensity (the ray integration quantity). Assume width of cube box is 1, so that \(\Delta x = 1/n{xyz}\)

Parameters
  • fc (obj) – pyFC.FractalCube object

  • pax (int) – Axis to paint raytrace image into

  • ax (int) – Direction of plane normal. {0|1|2}, default is 0 (“y-z plane”)

  • scaling (str) – Linear “lin” or logarithmic “log” data map

  • cmap (obj) – Colormap. Any colormap object (default is cm.copper)

  • plottype (int) – Type of plot {‘imshow’|’pcolormesh’}

  • kminlabel (int) – Boolean, draw label with kmin value?

  • absorb_coeff (flt) – Absorption coefficient

  • emiss_coeff (flt) – Emission coefficient

  • vmin, vmax (int) – Min and max dynamic range of plotted data. If scaling == ‘lin’, vmin = 0.005, vmax = 10 are good for vizualization

  • cax (int) – Colorbar axis to paint colorbar into

Returns

1 for reaching end of function

Return type

int

pyFC.plot_raytrace(fc, ax=0, scaling='log', cmap=<matplotlib.colors.LinearSegmentedColormap object>, plottype='imshow', colorbar=True, labels=True, kminlabel=False, absorb_coeff=1e-07, emiss_coeff=1.0, vmin=None, vmax=None)[source]

Plot a raytraced image into axis. Emissivity has same units as intensity (the ray integration quantity). Assume width of cube box is 1, so that \(\Delta x = 1/n{xyz}\)

Parameters
  • fc (obj) – pyFC.FractalCube object

  • ax (int) – Direction of plane normal. {0|1|2}, default is 0 (“y-z plane”)

  • scaling (str) – Linear “lin” or logarithmic “log” data map

  • cmap (obj) – Colormap. Any colormap object (default is cm.copper)

  • plottype (int) – Type of plot {‘imshow’|’pcolormesh’}

  • colorbar (bool) – Boolean, draw colorbar?

  • labels (bool) – Boolean, draw tick labels?

  • kminlabel (int) – Boolean, draw label with kmin value?

  • absorb_coeff (flt) – Absorption coefficient

  • emiss_coeff (flt) – Emission coefficient

  • vmin, vmax (int) – Min and max dynamic range of plotted data. If scaling == ‘lin’, vmin = 0.005, vmax = 10 are good for vizualization

Returns

1 for reaching end of function

Return type

int

pyFC.plot_field_stats(fc, scaling='lin', cmap=<matplotlib.colors.LinearSegmentedColormap object>, plottype='imshow', ax=2, vmin=None, vmax=None)[source]

Create a three-panel plot with:

  1. Cube density slice

  2. Cube single-point pdf

  3. Cube power spectrum

Parameters
  • ax

  • fc (obj) – pyFC.FractalCube object

  • scaling (str) – Linear “lin” or logarithmic “log” data map

  • cmap (obj) – Colormap. Any colormap object (default is cm.copper)

  • plottype (int) – Type of plot {‘imshow’|’pcolormesh’}

  • vmin, vmax (int) – Min and max dynamic range of plotted data. If scaling == ‘lin’, vmin = 0.005, vmax = 10 are good for vizualization

Returns

1 for reaching end of function

Return type

int

pyFC.paint_power_spec(fc, pax=<matplotlib.axes._subplots.AxesSubplot object>, label=None, line='-', k0line=False, target_line=False)[source]

Plot power spectrum of fractal cube. Essentially plots output of pyFC.FractalCube.iso_power_spec(). (This function may require more flexibility in its argument list.)

Parameters
  • fc (obj) – pyFC.FractalCube object

  • pax (int) – Axis to paint midplane slice into

  • scaling (str) – Linear “lin” or logarithmic “log” data map

  • k0line (bool) – Plot k0line?

  • target_line (bool) – Plot target line?

Returns

1 for reaching end of function

Return type

int

pyFC.plot_power_spec(fc, label=None, line='-', k0line=False, target_line=True)[source]

Plot power spectrum of fractal cube. Essentially plots output of pyFC.FractalCube.iso_power_spec(). (This function may require more flexibility in its argument list.)

Parameters
  • fc (obj) – pyFC.FractalCube object

  • label (bool) – Label on plot?

  • line (str) – Linestyle

  • k0line (bool) – Plot k0line?

  • target_line (bool) – Plot target line?

Returns

1 for reaching end of function

Return type

int

pyFC.paint_pdf(fc, pax=<matplotlib.axes._subplots.AxesSubplot object>, min=None, max=None, step=None)[source]

Plot a cube’s pdf. In the case of a gaussian cube (pyFC.GaussianFractalCube.cubetype == ‘gaussian’) it plots \(dN/dx\) vs \(x\). In the case of a lognormal cube (pyFC.LogNormalFractalCube.cubetype == ‘lognormal’) it plots :math:dN/dlog_{10}(x) vs \(\log_{10}x\)

Parameters
  • fc (obj) – pyFC.FractalCube object

  • pax (int) – Axis to paint midplane slice into

  • min max (flt) – Lower and upper density bin edges

  • step (flt) – Size of bins

Returns

1 for reaching end of function

Return type

int

pyFC.plot_pdf(fc, min=None, max=None, step=None)[source]

Plot a cube’s pdf. In the case of a gaussian cube (pyFC.GaussianFractalCube.cubetype == ‘gaussian’) it plots \(dN/dx\) vs \(x\). In the case of a lognormal cube (pyFC.LogNormalFractalCube.cubetype == ‘lognormal’) it plots :math:dN/dlog_{10}(x) vs \(\log_{10}x\)

Parameters
  • fc (obj) – pyFC.FractalCube object

  • min max (flt) – Lower and upper density bin edges

  • step (flt) – Size of bins

Returns

1 for reaching end of function

Return type

int

4.3 Manipulation functions

Various functions exist which support manipulations of fractal cubes. Note that these exist as members of the cube object itself as well, e.g., fc.mirror():

pyFC.slice(fc, ax=0, loc=0.5, scale='frac')

A simple mid-plane slice.

Parameters
  • fc (obj) – pyFC.FractalCube object

  • ax (int) – Axis number perpendicular to slice plane

  • loc (int) – Location of slice on that axis

  • scale (str) – {‘idx’|’frac’} integer index (idx) or fraction of cube width (rounded to nearest integer, frac) for location. Default ‘frac’.

Returns

2D array of slice

Return type

ndarray

pyFC.tri_slice(fc, locs=0.5, 0.5, 0.5, scale='frac')

A generator function for three perpendicular slices at point loc

Parameters
  • fc (obj) – pyFC.FractalCube object

  • locs (tup) – 3-Tuple indicating location of tri-slice (point where planes intersect)

  • scale (str) – {‘idx’|’frac’} integer index (idx) or fraction of cube width (rounded to nearest integer, frac) for location. Default ‘frac’.

Returns

Yield slice arrays for each axis and intercept. This will always yield three slices, regardless of whether cube is 2D

Return type

ndarray

pyFC.translate(fc, ax=0, delta=0.5, scale='frac', out='copy')

Translation of cube using np.roll.

Parameters
  • fc (obj) – pyFC.FractalCube object.

  • ax (int) – Axis number along which to translate.

  • delta (flt) – Distance of translation.

  • scale (flt) – {‘idx’|’frac’} integer index (idx) or fraction of cube width (rounded to nearest integer, frac) for location. Default ‘frac’.

  • out (str) – One of the modes accepted by fc._returner.

Returns

Translated cube

Return type

Type depends on ‘out’. By default it returns a copy of the pyFC.FractalCube object.

pyFC.permute(fc, choice=0, out='copy')

Chooses one of six permutations of the cube’s axis orders.

Parameters
  • fc (obj) – pyFC.FractalCube object.

  • choice (int) –

    Choses one of six permuations:

    0: 012, 1: 210 (= 0.T), 
    2: 120, 3: 021 (= 2.T), 
    4: 201, 5: 102 (= 4.T), 
    

    where T is the transpose.

  • out (str) – One of the modes accepted by fc._returner.

Returns

Permuted cube.

Return type

Type depends on ‘out’. By default it returns a copy of the pyFC.FractalCube object.

pyFC.mirror(fc, ax=0, out='copy')

Mirrors a cube about a face along axis ax.

Parameters
  • fc (obj) – pyFC.FractalCube object.

  • ax (int) – Axis number perpendicular to which the mirror plane lies.

  • out (str) – The “out mode”. One of the modes accepted by fc._returner. Possible values are ‘inplace’: save the ndarray data to self.cube return the FractalCube instance; ‘ndarray’: save the ndarray data to self.cube and return the ndarray; ‘copy’: return a copy of the FractalCube instance, with the ndarray data saved to the copy’s self.cube.

Returns

Mirrored cube

Return type

Type depends on ‘out’. By default it returns a copy of the pyFC.FractalCube object.

pyFC.extract_feature(fc, low=1.0, order='count', rank=0, bgv=1e-12, trim=False, out='copy')

Uses np.ndimage.measurements.label to “label” features in fractal cube.

Parameters
  • fc (obj) – pyFC.FractalCube object.

  • low (flt) – Lower threshold limit for extraction

  • order (str) –

    One of ‘size’, ‘sum’, ‘var’, ‘extent’, ‘label’ Sets which order the features are given in and chosen with rank:

    -‘count’: size by number of pixels -‘sum’: the sum of the values in the features -‘mean’: size by mean of the values in the features -‘var’: the varianace in the features -‘label’: the default labelling

  • rank (int) – Which feature will be selected. The ordering is given by mode

  • bgv (flt) – value for the pixels that are not the feature of the final output. Default is a small number, 1.e-12.

  • trim (bool) – False returns result with same dimensions as input fractal cube. True returns the trimmed result from ndimage.measurements.find_objects. (Not yet programmed.)

  • out (str) – One of the modes accepted by fc._returner.

Returns

The extracted feature

Return type

Type depends on ‘out’. By default it returns a copy of the pyFC.FractalCube object.

pyFC.lthreshold(fc, low=1.0, bgv=0, out='copy')

Apply lower value threshold to fractal cube

Parameters
  • fc (obj) – pyFC.FractalCube object.

  • low (flt) – Lower threshold limit for extraction

  • bgv (flt) – A value for the background (the points for which the values were < low)

  • out (str) – One of the modes accepted by fc._returner.

Returns

The thresholded cube.

Return type

Type depends on ‘out’. By default it returns a copy of the pyFC.FractalCube object.

pyFC.pp_raytrace(fc, absorb_coeff=1.0, emiss_coeff=1.0, ax=0)

Plane-parallel raytracer. This routine merely solves the radiative transfer integral from the back to the front of the box. We assume that:

  1. That we are integrating along axis=0.

  2. The box size is 1

  3. cell width are uniform and are a/ni

  4. there is no background source

  5. the emissivity is proportional to the cube variable

  6. the absorption coefficient is proportional to the cube variable

This raytracer is merely implemented for visualization purposes, which is the reason we have assumptions 4 and 5.

Parameters
  • fc (obj) – pyFC.FractalCube object.

  • absorb_coeff (flt) – Absorption coefficient

  • emiss_coeff (flt) – Emission coefficient

  • ax (int) – Direction of plane normal. {0|1|2}, default is 0 (“y-z plane”)

Returns

Raytraced image

Return type

2D ndarray

pyFC.pow(fc, power, out='copy')

Exponentiate the cube with a value.

Parameters
  • fc (obj) – pyFC.FractalCube object.

  • power (flt) – Power to exponentiate cube with

  • out (str) – One of the modes accepted by fc._returner.

Returns

Exponentiated cube

Return type

Type depends on ‘out’. By default it returns a copy of the pyFC.FractalCube object.

pyFC.mult(fc, factor, out='copy')

Multiply the cube with a value.

Parameters
  • fc (obj) – pyFC.FractalCube object.

  • factor (flt) – Factor to multiply cube with

  • out (str) – One of the modes accepted by fc._returner.

Returns

Multiplied cube

Return type

Type depends on ‘out’. By default it returns a copy of the pyFC.FractalCube object.

pyFC.write_cube(fc=None, fname='data.dbl', app=True, prec='double')

Writes out a fractal cube data file in little endian, double precision. Care is taken not to overwrite existing files.

Parameters
  • fname (str) – Data filename

  • app (bool) – automatically append kmin, ni, nj, and nk values to filename. If app == True, append kmin, ni, nj, nk values to filename. If suffixed files ‘<base>-[0-9][0-9]<ext>’ exist, appended by a suffix one larger than the highest number found.

  • prec (str) – Floating point precision of output {‘double’|’single’}

Returns

1 for successful write

Return type

int

Raise

ValueError if prec is invalid