TriangularShapedCloudInterpolation.jl
This packages is a port of the IDL script TSC.pro by Joop Schaye from Feb 1999.
Usage
This is a small guide how to use the package
Interpolation positions
To get an array of positions you can use for TSC interpolation you can use the helper function get_tsc_positions:
pos_tsc = get_tsc_positions(pos::Array{<:Real}, res_elements::Array{<:Integer})Here pos is an Array of positions with pos[N_dimensions, N_entries] and res_elements[N_dimensions] is the number of resolution elements you want to interpolate the data with in each dimension. You can also just provide a single integer if you want the resolution elements in all dimensions to be the same and multiple dipatch takes care of the rest. The returned pos_tsc is in row-major order since that makes working with 1-3 dimensional data in the same function easier.
TSC interpolation
To interpolate the data (e.g. density) you need to use TSCInterpolation like so:
pos = rand(3,1_000)
density = rand(1_000)
res_elements = [20, 20, 20]
pos_tsc = get_tsc_positions(pos, res_elements)
rho_interp = TSCInterpolation( rho, pos_tsc, res_elements,
average=true)API reference
TriangularShapedCloudInterpolation.TSCInterpolationTriangularShapedCloudInterpolation.TSCInterpolationTriangularShapedCloudInterpolation.calculate_weights!TriangularShapedCloudInterpolation.find_dim_boundsTriangularShapedCloudInterpolation.get_tsc_positionsTriangularShapedCloudInterpolation.get_tsc_positions
TriangularShapedCloudInterpolation.TSCInterpolation — MethodTSCInterpolation( value::Array{<:Real},
pos::Array{<:Real},
res_elements::Array{<:Integer},
average::Bool=true,
wraparound::Bool=false,
isolated::Bool=false )Runs a TSC interpolation on the value array based on the provided positions. Returns a 3D array with interpolated values.
TriangularShapedCloudInterpolation.TSCInterpolation — MethodTSCInterpolation( value::Array{<:Real},
pos::Array{<:Real},
res_elements::Integer;
average::Bool=true,
wraparound::Bool=false,
isolated::Bool=false )Helper function to run TSC interpolation with the same number of resolution elements in all dimensions.
TriangularShapedCloudInterpolation.calculate_weights! — Methodcalculate_weights!(field::Array{<:Real}, tottscweight::Array{<:Real},
index::Array{<:Integer}, tscweight::Array{<:Real},
value::Array{<:Real}, Nsamples::Integer;
average::Bool=false)Helper function to update the weights arrays.
TriangularShapedCloudInterpolation.find_dim_bounds — Methodfind_dim_bounds(dim::Integer)Helper function to get loop limits for dimension loops.
TriangularShapedCloudInterpolation.get_tsc_positions — Methodget_tsc_positions(pos::Array{<:Real}, res_elements::Array{<:Integer})Returns an array with interpolation positions for a given pos array. Number of interpolation positions in each dimension is given by the res_elements array.
TriangularShapedCloudInterpolation.get_tsc_positions — Methodget_tsc_positions(pos::Array{<:Real}, res_elements::Integer)Helper function if resolution elements in all dimensions are the same.