# yt.analysis_modules.two_point_functions.two_point_functions module¶

Two Point Functions Framework.

class yt.analysis_modules.two_point_functions.two_point_functions.FcnSet(tpf, function, min_edge, out_labels, sqrt, corr_norm)[source]
add_function(function, out_labels, sqrt, corr_norm=None)

Add a function to the list that will be evaluated at the generated pairs of points.

Parameters: function (Function) – The two point function of the form fcn(a, b, r1, r2, vec). out_labels (List of strings) – A list of strings labeling the outputs of the function. sqrt (List of booleans) – A list of booleans which when True will square-root the corresponding element of the output in the text output (write_out_means()). corr_norm (Float) – Used when calculating two point correlations. If set, the output of the function is divided by this number. Default = None.

Examples

>>> f1 = tpf.add_function(function=rms_vel, out_labels=['RMSvdiff'],
... sqrt=[True])

comm = None
get_dependencies(fields)
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

run_generator()

After all the functions have been added, run the generator.

Examples

>>> tpf.run_generator()

set_pdf_params(bin_type='lin', bin_number=1000, bin_range=None)[source]

Set the parameters used to build the Probability Distribution Function for each ruler length for this function. The values output by the function are slotted into the bins described here.

Parameters: bin_type (String) – Controls the edges of the bins spaced evenly in logarithmic or linear space, set by “log” or “lin”, respectively. A single string, or list of strings for N-dim binning. Default = “lin”. bin_number (Integer) – Sets how many bins to create, evenly spaced by the above parameter. A single integer, or a list of integers for N-dim binning. Default = 1000. bin_range (Float) – A pair of values giving the range for the bins. A pair of floats (a list), or a list of pairs for N-dim binning. Default = None.

Examples

>>> f1.set_pdf_params(bin_type='log', bin_range=[5e4, 5.5e13],
... bin_number=1000)

write_out_arrays(fn='%s.h5')

Writes out the raw probability bins and the bin edges to an HDF5 file for each of the functions. The files are named ‘function_name.txt’ and saved in the current working directory.

Examples

>>> tpf.write_out_arrays()

write_out_correlation()

A special output function for doing two point correlation functions. Outputs the correlation function xi(r) in a text file ‘function_name_corr.txt’ in the current working directory.

Examples

>>> tpf.write_out_correlation()

write_out_means(fn='%s.txt')

Writes out the weighted-average value for each function for each dimension for each ruler length to a text file. The data is written to files of the name ‘function_name.txt’ in the current working directory.

Examples

>>> tpf.write_out_means()

class yt.analysis_modules.two_point_functions.two_point_functions.TwoPointFunctions(ds, fields, left_edge=None, right_edge=None, total_values=1000000, comm_size=10000, length_type='lin', length_number=10, length_range=None, vol_ratio=1, salt=0, theta=None, phi=None)[source]

Initialize a two point functions object.

Parameters: total_values (Integer) – How many total (global) pair calculations to run for each of the functions specified. Default: 1000000. comm_size (Integer) – How entries are sent during communication. Default: 10000. length_type (String) – Controls the even spacing of the rulers lengths in logarithmic or linear space, set by “log” or “lin”, respectively. Default: “lin”. length_number (Integer) – Sets how many lengths to create, evenly spaced by the above parameter. Default: 10. length_range (Float) – A min/max pair for the range of values to search the over the simulated volume. Default: [sqrt(3)dx, 1/2*shortest box edge], where dx is the smallest grid cell size. vol_ratio (Integer) – How to multiply-assign subvolumes to the parallel tasks. This number must be an integer factor of the total number of tasks or very bad things will happen. The default value of 1 will assign one task to each subvolume, and there will be an equal number of subvolumes as tasks. A value of 2 will assign two tasks to each subvolume and there will be one-half as many subvolumes as tasks. A value equal to the number of parallel tasks will result in each task owning a complete copy of all the fields data, meaning each task will be operating on the identical full volume. Setting it to -1 will automatically adjust it such that each task owns the entire volume. Default = 1. salt (Integer) – A number that will be added to the random number generator seed. Use this if a different random series of numbers is desired when keeping everything else constant from this set: (MPI task count, number of ruler lengths, ruler min/max, number of functions, number of point pairs per ruler length). Default = 0. theta (Float) – For random pairs of points, the second point is found by traversing a distance along a ray set by the angle (phi, theta) from the first point. To keep this angle constant, set theta to a value in the range [0, pi]. Default = None, which will randomize theta for every pair of points. phi (Float) – Similar to theta above, but the range of values is [0, 2*pi). Default = None, which will randomize phi for every pair of points.

Examples

>>> tpf = TwoPointFunctions(ds, ["velocity_x", "velocity_y", "velocity_z"],
... total_values=1e5, comm_size=10000,
... length_number=10, length_range=[1./128, .5],
... length_type="log")

add_function(function, out_labels, sqrt, corr_norm=None)[source]

Add a function to the list that will be evaluated at the generated pairs of points.

Parameters: function (Function) – The two point function of the form fcn(a, b, r1, r2, vec). out_labels (List of strings) – A list of strings labeling the outputs of the function. sqrt (List of booleans) – A list of booleans which when True will square-root the corresponding element of the output in the text output (write_out_means()). corr_norm (Float) – Used when calculating two point correlations. If set, the output of the function is divided by this number. Default = None.

Examples

>>> f1 = tpf.add_function(function=rms_vel, out_labels=['RMSvdiff'],
... sqrt=[True])

comm = None
get_dependencies(fields)
partition_index_2d(axis)
partition_index_3d(ds, padding=0.0, rank_ratio=1)
partition_index_3d_bisection_list()

Returns an array that is used to drive _partition_index_3d_bisection, below.

partition_region_3d(left_edge, right_edge, padding=0.0, rank_ratio=1)

Given a region, it subdivides it into smaller regions for parallel analysis.

run_generator()[source]

After all the functions have been added, run the generator.

Examples

>>> tpf.run_generator()

write_out_arrays(fn='%s.h5')[source]

Writes out the raw probability bins and the bin edges to an HDF5 file for each of the functions. The files are named ‘function_name.txt’ and saved in the current working directory.

Examples

>>> tpf.write_out_arrays()

write_out_correlation()[source]

A special output function for doing two point correlation functions. Outputs the correlation function xi(r) in a text file ‘function_name_corr.txt’ in the current working directory.

Examples

>>> tpf.write_out_correlation()

write_out_means(fn='%s.txt')[source]

Writes out the weighted-average value for each function for each dimension for each ruler length to a text file. The data is written to files of the name ‘function_name.txt’ in the current working directory.

Examples

>>> tpf.write_out_means()