{"action":"created","comment":{"url":"https://api.github.com/repos/svalinn/DAGMC/pulls/comments/30005489","id":30005489,"diff_hunk":"@@ -0,0 +1,377 @@\n+#########################################################\n+# btrn.py\n+# Backscatter Transport and Response\n+#########################################################\n+\n+import subprocess\n+import argparse\n+import string\n+import os\n+import pprint\n+\n+try:\n+   from pyne import material\n+   from pyne.material import Material, MaterialLibrary\n+except:\n+    raise ImportError(\"The PyNE dependencies could not be imported.\")    \n+\n+try:\n+    from pyne import dagmc\n+except:\n+    raise ImportError(\"The dagmc dependency could not be imported.\")    \n+\n+from pyne import data\n+from pyne import nucname\n+import numpy as np\n+import hzetrn as one_d_tool\n+import tag_utils\n+import logging\n+\n+\n+###############################\n+# globals\n+config_log  = 'config.log'\n+# 'spatial_dir' is a subdir for storing input files as they are created\n+spatial_dir = 'spatial'\n+\n+\"\"\"\n+    Read the coordinates of the Reference Point from a file.\n+    filename = name of file containing triplet\n+        If filename = '' the reference point is set\n+        to the origin\n+\"\"\"\n+def load_ray_start(filename):\n+    # Set the Reference Point.\n+    ray_start = []\n+    if not filename:\n+        return [0.0, 0.0, 0.0]\n+    else:\n+        with open(filename) as f:\n+\t    return map(float, f.readline().split())\n+\n+\"\"\"\n+Load or create tuples representing dirs\n+In file with 10,000 tuples, here are the ranges\n+('min_theta', 0.00117047, 'max_theta', 3.136877355, 'min_phi', -3.141219364, 'max_phi', 3.14087921)\n+\n+filename name of file with unit direction vectors \n+         Its existence is checked before entering this function.\n+         The first member of each pair is the polar angle theta.\n+\t The second member is the azimuthal angle phi.\n+\"\"\"\n+def load_ray_tuples(filename):\n+\n+    ray_tuples = []\n+    \n+    with open(filename) as f:\n+        for line in f:\n+\t    nums = map(float, line.split())\n+\t    z = np.cos(nums[0])\n+\t    x = np.sin(nums[0])*np.cos(nums[1])\n+\t    y = np.sin(nums[0])*np.sin(nums[1])\n+\t    ray_tuples.append((x, y, z))\n+    return ray_tuples\n+\n+\"\"\"\n+Return an array of directions\n+args =  parsed command line parameters\n+        args.ray_dir_file, if not '', contains the directions\n+\tOtherwis, use random directons or Cartesian axes\n+\n+The set of directions is returned as a numpy row array\n+\"\"\"\n+def get_directions(ray_dir_file, num_rand_dirs):\n+    # Return the ray directions \n+    if ray_dir_file:\n+        ray_tuples = load_ray_tuples(ray_dir_file)\n+\n+    elif num_rand_dirs > 0:\n+        ray_tuples = tag_utils.get_rand_dirs(num_rand_dirs)\n+ \n+    else:\n+        ray_tuples = [(1.0, 0.0, 0.0),\n+                      (0.0, 1.0, 0.0),\n+\t   \t      (0.0, 0.0, 1.0)]\n+    return np.array(ray_tuples)\n+\n+\n+\"\"\" \n+Find the vol-id of the geometry that contains the ref_point\n+Requires dagmc python library to be loaded\n+\"\"\"\n+def find_ref_vol(ref_point):\n+    # code snippet from dagmc.pyx:find_graveyard_inner_box\n+    volumes = dagmc.get_volume_list() \n+    for v in volumes:\n+        if dagmc.point_in_volume(v, ref_point):\n+            return v\n+\n+\"\"\"\n+Find the slab distances and material names\n+start_vol  The volume containing the ref_point\n+ref_point  the origin of the ray\n+dir \t   the direction of the ray\n+fname_for_vol a mapping of vol id to material object\n+\n+returns    arrays  for length and material name as the ray\n+           travels from the start point to the graveyard\n+\n+This depends on dagmc's ray_iterator, which calls ray_fire\n+\"\"\"\n+def slabs_for_ray(start_vol, ref_point, dir, fname_for_vol):\n+    is_graveyard = False\n+    foundMat = False\n+    surf = 0\n+    dist = 0\n+    huge = 1000000000\n+\n+    slab_lengths = []\n+    slab_mat_names = []\n+    vols_traversed = []\n+\n+    # Could be starting in the implicit_complement\n+    if start_vol in fname_for_vol:\n+        #  Done before we've started\n+        if fname_for_vol[start_vol] == 'graveyard':\n+\t    # print 'Starting volume is graveyard'\n+            return slab_length, slab_mat_name \n+    else:\n+        print 'We are starting in the implicit complement'\n+    is_graveyard = False    \n+    last_vol = start_vol\n+    \n+    for (next_vol, dist, surf, xyz) in dagmc.ray_iterator(last_vol, ref_point, dir, yield_xyz=True):\n+        # print 'next_vol', next_vol\n+        if not is_graveyard and ((dist < huge) and (surf != 0)):\n+\t    # We have already checked last_vol for being a graveyard\n+\t    if last_vol in fname_for_vol:","path":"HZETRN/btrn.py","position":null,"original_position":147,"commit_id":"ad366952d0ffc0d2f6ddf38141c9cd23b51c6cff","original_commit_id":"d021bfd3473f769378fc167db845eb03d495808d","user":{"login":"julry","id":1514553,"avatar_url":"https://avatars.githubusercontent.com/u/1514553?v=3","gravatar_id":"","url":"https://api.github.com/users/julry","html_url":"https://github.com/julry","followers_url":"https://api.github.com/users/julry/followers","following_url":"https://api.github.com/users/julry/following{/other_user}","gists_url":"https://api.github.com/users/julry/gists{/gist_id}","starred_url":"https://api.github.com/users/julry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julry/subscriptions","organizations_url":"https://api.github.com/users/julry/orgs","repos_url":"https://api.github.com/users/julry/repos","events_url":"https://api.github.com/users/julry/events{/privacy}","received_events_url":"https://api.github.com/users/julry/received_events","type":"User","site_admin":false},"body":"Reworked","created_at":"2015-05-10T20:11:25Z","updated_at":"2015-05-10T20:11:25Z","html_url":"https://github.com/svalinn/DAGMC/pull/352#discussion_r30005489","pull_request_url":"https://api.github.com/repos/svalinn/DAGMC/pulls/352","_links":{"self":{"href":"https://api.github.com/repos/svalinn/DAGMC/pulls/comments/30005489"},"html":{"href":"https://github.com/svalinn/DAGMC/pull/352#discussion_r30005489"},"pull_request":{"href":"https://api.github.com/repos/svalinn/DAGMC/pulls/352"}}},"pull_request":{"url":"https://api.github.com/repos/svalinn/DAGMC/pulls/352","id":34953723,"html_url":"https://github.com/svalinn/DAGMC/pull/352","diff_url":"https://github.com/svalinn/DAGMC/pull/352.diff","patch_url":"https://github.com/svalinn/DAGMC/pull/352.patch","issue_url":"https://api.github.com/repos/svalinn/DAGMC/issues/352","number":352,"state":"open","locked":false,"title":"Rebase dev hzet","user":{"login":"julry","id":1514553,"avatar_url":"https://avatars.githubusercontent.com/u/1514553?v=3","gravatar_id":"","url":"https://api.github.com/users/julry","html_url":"https://github.com/julry","followers_url":"https://api.github.com/users/julry/followers","following_url":"https://api.github.com/users/julry/following{/other_user}","gists_url":"https://api.github.com/users/julry/gists{/gist_id}","starred_url":"https://api.github.com/users/julry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julry/subscriptions","organizations_url":"https://api.github.com/users/julry/orgs","repos_url":"https://api.github.com/users/julry/repos","events_url":"https://api.github.com/users/julry/events{/privacy}","received_events_url":"https://api.github.com/users/julry/received_events","type":"User","site_admin":false},"body":"HZETRN code","created_at":"2015-05-07T20:14:47Z","updated_at":"2015-05-10T20:11:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"37a8f5442af9373db2fc80d00049081b9136464f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/svalinn/DAGMC/pulls/352/commits","review_comments_url":"https://api.github.com/repos/svalinn/DAGMC/pulls/352/comments","review_comment_url":"https://api.github.com/repos/svalinn/DAGMC/pulls/comments{/number}","comments_url":"https://api.github.com/repos/svalinn/DAGMC/issues/352/comments","statuses_url":"https://api.github.com/repos/svalinn/DAGMC/statuses/ad366952d0ffc0d2f6ddf38141c9cd23b51c6cff","head":{"label":"julry:rebase_dev_hzet","ref":"rebase_dev_hzet","sha":"ad366952d0ffc0d2f6ddf38141c9cd23b51c6cff","user":{"login":"julry","id":1514553,"avatar_url":"https://avatars.githubusercontent.com/u/1514553?v=3","gravatar_id":"","url":"https://api.github.com/users/julry","html_url":"https://github.com/julry","followers_url":"https://api.github.com/users/julry/followers","following_url":"https://api.github.com/users/julry/following{/other_user}","gists_url":"https://api.github.com/users/julry/gists{/gist_id}","starred_url":"https://api.github.com/users/julry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julry/subscriptions","organizations_url":"https://api.github.com/users/julry/orgs","repos_url":"https://api.github.com/users/julry/repos","events_url":"https://api.github.com/users/julry/events{/privacy}","received_events_url":"https://api.github.com/users/julry/received_events","type":"User","site_admin":false},"repo":{"id":7651161,"name":"DAGMC","full_name":"julry/DAGMC","owner":{"login":"julry","id":1514553,"avatar_url":"https://avatars.githubusercontent.com/u/1514553?v=3","gravatar_id":"","url":"https://api.github.com/users/julry","html_url":"https://github.com/julry","followers_url":"https://api.github.com/users/julry/followers","following_url":"https://api.github.com/users/julry/following{/other_user}","gists_url":"https://api.github.com/users/julry/gists{/gist_id}","starred_url":"https://api.github.com/users/julry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julry/subscriptions","organizations_url":"https://api.github.com/users/julry/orgs","repos_url":"https://api.github.com/users/julry/repos","events_url":"https://api.github.com/users/julry/events{/privacy}","received_events_url":"https://api.github.com/users/julry/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/julry/DAGMC","description":"Direct Accelerated Geometry Monte Carlo Toolkit","fork":true,"url":"https://api.github.com/repos/julry/DAGMC","forks_url":"https://api.github.com/repos/julry/DAGMC/forks","keys_url":"https://api.github.com/repos/julry/DAGMC/keys{/key_id}","collaborators_url":"https://api.github.com/repos/julry/DAGMC/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/julry/DAGMC/teams","hooks_url":"https://api.github.com/repos/julry/DAGMC/hooks","issue_events_url":"https://api.github.com/repos/julry/DAGMC/issues/events{/number}","events_url":"https://api.github.com/repos/julry/DAGMC/events","assignees_url":"https://api.github.com/repos/julry/DAGMC/assignees{/user}","branches_url":"https://api.github.com/repos/julry/DAGMC/branches{/branch}","tags_url":"https://api.github.com/repos/julry/DAGMC/tags","blobs_url":"https://api.github.com/repos/julry/DAGMC/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/julry/DAGMC/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/julry/DAGMC/git/refs{/sha}","trees_url":"https://api.github.com/repos/julry/DAGMC/git/trees{/sha}","statuses_url":"https://api.github.com/repos/julry/DAGMC/statuses/{sha}","languages_url":"https://api.github.com/repos/julry/DAGMC/languages","stargazers_url":"https://api.github.com/repos/julry/DAGMC/stargazers","contributors_url":"https://api.github.com/repos/julry/DAGMC/contributors","subscribers_url":"https://api.github.com/repos/julry/DAGMC/subscribers","subscription_url":"https://api.github.com/repos/julry/DAGMC/subscription","commits_url":"https://api.github.com/repos/julry/DAGMC/commits{/sha}","git_commits_url":"https://api.github.com/repos/julry/DAGMC/git/commits{/sha}","comments_url":"https://api.github.com/repos/julry/DAGMC/comments{/number}","issue_comment_url":"https://api.github.com/repos/julry/DAGMC/issues/comments{/number}","contents_url":"https://api.github.com/repos/julry/DAGMC/contents/{+path}","compare_url":"https://api.github.com/repos/julry/DAGMC/compare/{base}...{head}","merges_url":"https://api.github.com/repos/julry/DAGMC/merges","archive_url":"https://api.github.com/repos/julry/DAGMC/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/julry/DAGMC/downloads","issues_url":"https://api.github.com/repos/julry/DAGMC/issues{/number}","pulls_url":"https://api.github.com/repos/julry/DAGMC/pulls{/number}","milestones_url":"https://api.github.com/repos/julry/DAGMC/milestones{/number}","notifications_url":"https://api.github.com/repos/julry/DAGMC/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/julry/DAGMC/labels{/name}","releases_url":"https://api.github.com/repos/julry/DAGMC/releases{/id}","created_at":"2013-01-16T18:18:42Z","updated_at":"2015-04-07T17:31:27Z","pushed_at":"2015-05-08T22:08:44Z","git_url":"git://github.com/julry/DAGMC.git","ssh_url":"git@github.com:julry/DAGMC.git","clone_url":"https://github.com/julry/DAGMC.git","svn_url":"https://github.com/julry/DAGMC","homepage":null,"size":91760,"stargazers_count":1,"watchers_count":1,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"develop"}},"base":{"label":"svalinn:develop","ref":"develop","sha":"60dc9b63cf74f24778960e797bb7d3ecdd3f4e10","user":{"login":"svalinn","id":1921454,"avatar_url":"https://avatars.githubusercontent.com/u/1921454?v=3","gravatar_id":"","url":"https://api.github.com/users/svalinn","html_url":"https://github.com/svalinn","followers_url":"https://api.github.com/users/svalinn/followers","following_url":"https://api.github.com/users/svalinn/following{/other_user}","gists_url":"https://api.github.com/users/svalinn/gists{/gist_id}","starred_url":"https://api.github.com/users/svalinn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svalinn/subscriptions","organizations_url":"https://api.github.com/users/svalinn/orgs","repos_url":"https://api.github.com/users/svalinn/repos","events_url":"https://api.github.com/users/svalinn/events{/privacy}","received_events_url":"https://api.github.com/users/svalinn/received_events","type":"Organization","site_admin":false},"repo":{"id":5625571,"name":"DAGMC","full_name":"svalinn/DAGMC","owner":{"login":"svalinn","id":1921454,"avatar_url":"https://avatars.githubusercontent.com/u/1921454?v=3","gravatar_id":"","url":"https://api.github.com/users/svalinn","html_url":"https://github.com/svalinn","followers_url":"https://api.github.com/users/svalinn/followers","following_url":"https://api.github.com/users/svalinn/following{/other_user}","gists_url":"https://api.github.com/users/svalinn/gists{/gist_id}","starred_url":"https://api.github.com/users/svalinn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svalinn/subscriptions","organizations_url":"https://api.github.com/users/svalinn/orgs","repos_url":"https://api.github.com/users/svalinn/repos","events_url":"https://api.github.com/users/svalinn/events{/privacy}","received_events_url":"https://api.github.com/users/svalinn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/svalinn/DAGMC","description":"Direct Accelerated Geometry Monte Carlo Toolkit","fork":false,"url":"https://api.github.com/repos/svalinn/DAGMC","forks_url":"https://api.github.com/repos/svalinn/DAGMC/forks","keys_url":"https://api.github.com/repos/svalinn/DAGMC/keys{/key_id}","collaborators_url":"https://api.github.com/repos/svalinn/DAGMC/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/svalinn/DAGMC/teams","hooks_url":"https://api.github.com/repos/svalinn/DAGMC/hooks","issue_events_url":"https://api.github.com/repos/svalinn/DAGMC/issues/events{/number}","events_url":"https://api.github.com/repos/svalinn/DAGMC/events","assignees_url":"https://api.github.com/repos/svalinn/DAGMC/assignees{/user}","branches_url":"https://api.github.com/repos/svalinn/DAGMC/branches{/branch}","tags_url":"https://api.github.com/repos/svalinn/DAGMC/tags","blobs_url":"https://api.github.com/repos/svalinn/DAGMC/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/svalinn/DAGMC/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/svalinn/DAGMC/git/refs{/sha}","trees_url":"https://api.github.com/repos/svalinn/DAGMC/git/trees{/sha}","statuses_url":"https://api.github.com/repos/svalinn/DAGMC/statuses/{sha}","languages_url":"https://api.github.com/repos/svalinn/DAGMC/languages","stargazers_url":"https://api.github.com/repos/svalinn/DAGMC/stargazers","contributors_url":"https://api.github.com/repos/svalinn/DAGMC/contributors","subscribers_url":"https://api.github.com/repos/svalinn/DAGMC/subscribers","subscription_url":"https://api.github.com/repos/svalinn/DAGMC/subscription","commits_url":"https://api.github.com/repos/svalinn/DAGMC/commits{/sha}","git_commits_url":"https://api.github.com/repos/svalinn/DAGMC/git/commits{/sha}","comments_url":"https://api.github.com/repos/svalinn/DAGMC/comments{/number}","issue_comment_url":"https://api.github.com/repos/svalinn/DAGMC/issues/comments{/number}","contents_url":"https://api.github.com/repos/svalinn/DAGMC/contents/{+path}","compare_url":"https://api.github.com/repos/svalinn/DAGMC/compare/{base}...{head}","merges_url":"https://api.github.com/repos/svalinn/DAGMC/merges","archive_url":"https://api.github.com/repos/svalinn/DAGMC/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/svalinn/DAGMC/downloads","issues_url":"https://api.github.com/repos/svalinn/DAGMC/issues{/number}","pulls_url":"https://api.github.com/repos/svalinn/DAGMC/pulls{/number}","milestones_url":"https://api.github.com/repos/svalinn/DAGMC/milestones{/number}","notifications_url":"https://api.github.com/repos/svalinn/DAGMC/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/svalinn/DAGMC/labels{/name}","releases_url":"https://api.github.com/repos/svalinn/DAGMC/releases{/id}","created_at":"2012-08-31T07:10:14Z","updated_at":"2015-04-07T16:15:44Z","pushed_at":"2015-05-08T22:08:44Z","git_url":"git://github.com/svalinn/DAGMC.git","ssh_url":"git@github.com:svalinn/DAGMC.git","clone_url":"https://github.com/svalinn/DAGMC.git","svn_url":"https://github.com/svalinn/DAGMC","homepage":"svalinn.github.com/DAGMC","size":99307,"stargazers_count":4,"watchers_count":4,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":14,"mirror_url":null,"open_issues_count":48,"forks":14,"open_issues":48,"watchers":4,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/svalinn/DAGMC/pulls/352"},"html":{"href":"https://github.com/svalinn/DAGMC/pull/352"},"issue":{"href":"https://api.github.com/repos/svalinn/DAGMC/issues/352"},"comments":{"href":"https://api.github.com/repos/svalinn/DAGMC/issues/352/comments"},"review_comments":{"href":"https://api.github.com/repos/svalinn/DAGMC/pulls/352/comments"},"review_comment":{"href":"https://api.github.com/repos/svalinn/DAGMC/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/svalinn/DAGMC/pulls/352/commits"},"statuses":{"href":"https://api.github.com/repos/svalinn/DAGMC/statuses/ad366952d0ffc0d2f6ddf38141c9cd23b51c6cff"}}}}