Last active
August 29, 2015 14:06
-
-
Save piyanatk/5d6692f0adf01b70ea18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check yt version | |
import pkg_resources | |
if pkg_resources.get_distribution('yt').version[0] != '2': | |
raise ImportError('yt must be version 2.x.x') | |
from yt.mods import * | |
from yt.utilities.physical_constants import cm_per_mpc | |
from yt.analysis_modules.two_point_functions.api import * | |
def pdf2(a, b, r1, r2, vec): | |
""" | |
Calculate the temperature difference between the two points. | |
""" | |
return abs(a - b) | |
# Load data arr to yt format | |
arr = np.random.randn(10, 10, 10) | |
data = dict(temperature=arr) | |
bbox=np.array([[-500., 500.], [-500., 500.], [-500., 500.]]) | |
pf = load_uniform_grid(data, arr.shape, cm_per_mpc, bbox=bbox, | |
nprocs=4) | |
# Initialize a function generator object. | |
tpf = TwoPointFunctions(pf, ['temperature'], | |
total_values=2e8, comm_size=1e4, | |
length_number=10, length_type='log') | |
# Adds the function to the generator. An output label is given, | |
f1 = tpf.add_function(function=pdf2, out_labels=['tdiff'], | |
sqrt=[False]) | |
# Define the bins used to store the results of the function. | |
f1.set_pdf_params(bin_type='lin', bin_number=20, | |
bin_range=[0, abs(arr.min() - arr.max())]) | |
# Runs the functions. | |
tpf.run_generator() | |
# Write out files | |
tpf.write_out_means() | |
tpf.write_out_arrays() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mpirun -np 4 python yt_tpf_test.py --parallel | |
yt : [INFO ] 2014-09-16 11:04:07,709 Global parallel computation enabled: 1 / 4 | |
yt : [INFO ] 2014-09-16 11:04:07,709 Global parallel computation enabled: 3 / 4 | |
yt : [INFO ] 2014-09-16 11:04:07,709 Global parallel computation enabled: 0 / 4 | |
yt : [INFO ] 2014-09-16 11:04:07,709 Global parallel computation enabled: 2 / 4 | |
P000 yt : [INFO ] 2014-09-16 11:04:08,169 Parameters: current_time = 0.0 | |
P000 yt : [INFO ] 2014-09-16 11:04:08,169 Parameters: domain_dimensions = [10 10 10] | |
P000 yt : [INFO ] 2014-09-16 11:04:08,169 Parameters: domain_left_edge = [-500. -500. -500.] | |
P000 yt : [INFO ] 2014-09-16 11:04:08,170 Parameters: domain_right_edge = [ 500. 500. 500.] | |
P000 yt : [INFO ] 2014-09-16 11:04:08,170 Parameters: cosmological_simulation = 0.0 | |
P003 yt : [INFO ] 2014-09-16 11:04:08,172 Adding temperature to list of fields | |
P001 yt : [INFO ] 2014-09-16 11:04:08,172 Adding temperature to list of fields | |
P002 yt : [INFO ] 2014-09-16 11:04:08,172 Adding temperature to list of fields | |
P000 yt : [INFO ] 2014-09-16 11:04:08,172 Adding temperature to list of fields | |
P003 yt : [INFO ] 2014-09-16 11:04:08,201 LE [ 0. 0. -500.] RE [ 500. 500. 500.] AMRRegionStrict (UniformGridData): center=[ 0. 0. 0.], left_edge=[ 0. 0. -500.], right_edge=[ 500. 500. 500.] | |
P003 yt : [INFO ] 2014-09-16 11:04:08,201 Unigrid: finding cell centers. | |
P003 yt : [INFO ] 2014-09-16 11:04:08,201 Getting field x from 2 | |
P000 yt : [INFO ] 2014-09-16 11:04:08,202 LE [-500. -500. -500.] RE [ 0. 0. 500.] AMRRegionStrict (UniformGridData): center=[ 0. 0. 0.], left_edge=[-500. -500. -500.], right_edge=[ 0. 0. 500.] | |
P002 yt : [INFO ] 2014-09-16 11:04:08,202 LE [ 0. -500. -500.] RE [ 500. 0. 500.] AMRRegionStrict (UniformGridData): center=[ 0. 0. 0.], left_edge=[ 0. -500. -500.], right_edge=[ 500. 0. 500.] | |
P000 yt : [INFO ] 2014-09-16 11:04:08,202 Unigrid: finding cell centers. | |
P001 yt : [INFO ] 2014-09-16 11:04:08,202 LE [-500. 0. -500.] RE [ 0. 500. 500.] AMRRegionStrict (UniformGridData): center=[ 0. 0. 0.], left_edge=[-500. 0. -500.], right_edge=[ 0. 500. 500.] | |
P002 yt : [INFO ] 2014-09-16 11:04:08,202 Unigrid: finding cell centers. | |
P000 yt : [INFO ] 2014-09-16 11:04:08,202 Getting field x from 2 | |
P001 yt : [INFO ] 2014-09-16 11:04:08,202 Unigrid: finding cell centers. | |
P002 yt : [INFO ] 2014-09-16 11:04:08,203 Getting field x from 2 | |
P003 yt : [INFO ] 2014-09-16 11:04:08,203 Getting field y from 2 | |
P001 yt : [INFO ] 2014-09-16 11:04:08,203 Getting field x from 2 | |
P003 yt : [INFO ] 2014-09-16 11:04:08,203 Getting field z from 2 | |
P000 yt : [INFO ] 2014-09-16 11:04:08,204 Getting field y from 2 | |
P003 yt : [INFO ] 2014-09-16 11:04:08,204 Getting field temperature from 2 | |
P002 yt : [INFO ] 2014-09-16 11:04:08,204 Getting field y from 2 | |
P001 yt : [INFO ] 2014-09-16 11:04:08,204 Getting field y from 2 | |
P000 yt : [INFO ] 2014-09-16 11:04:08,205 Getting field z from 2 | |
P002 yt : [INFO ] 2014-09-16 11:04:08,205 Getting field z from 2 | |
P001 yt : [INFO ] 2014-09-16 11:04:08,205 Getting field z from 2 | |
P000 yt : [INFO ] 2014-09-16 11:04:08,205 Getting field temperature from 2 | |
P002 yt : [INFO ] 2014-09-16 11:04:08,206 Getting field temperature from 2 | |
P001 yt : [INFO ] 2014-09-16 11:04:08,206 Getting field temperature from 2 | |
P000 yt : [INFO ] 2014-09-16 11:04:08,206 Doing length 1.73205e+02 | |
Traceback (most recent call last): | |
File "test.py", line 40, in <module> | |
tpf.run_generator() | |
File "/data2/piyanat/src/yt-x86_64/src/yt-hg/yt/analysis_modules/two_point_functions/two_point_functions.py", line 274, in run_generator | |
raise ValueError("self.recv_points is no good!") | |
ValueError: self.recv_points is no good! | |
Traceback (most recent call last): | |
File "test.py", line 40, in <module> | |
Traceback (most recent call last): | |
File "test.py", line 40, in <module> | |
tpf.run_generator() | |
tpf.run_generator() | |
Traceback (most recent call last): | |
File "test.py", line 40, in <module> | |
tpf.run_generator() | |
File "/data2/piyanat/src/yt-x86_64/src/yt-hg/yt/analysis_modules/two_point_functions/two_point_functions.py", line 274, in run_generator | |
File "/data2/piyanat/src/yt-x86_64/src/yt-hg/yt/analysis_modules/two_point_functions/two_point_functions.py", line 274, in run_generator | |
File "/data2/piyanat/src/yt-x86_64/src/yt-hg/yt/analysis_modules/two_point_functions/two_point_functions.py", line 274, in run_generator | |
raise ValueError("self.recv_points is no good!") | |
ValueError: self.recv_points is no good! | |
raise ValueError("self.recv_points is no good!") | |
ValueError: self.recv_points is no good! | |
raise ValueError("self.recv_points is no good!") | |
ValueError: self.recv_points is no good! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment