{"action":"created","comment":{"url":"https://api.github.com/repos/cyclus/cymetric/pulls/comments/28366289","id":28366289,"diff_hunk":"@@ -229,4 +230,48 @@ def agents(series):\n del _agentsdeps, _agentsschema\n \n \n+#########################\n+## FCO-related metrics ##\n+#########################\n+\n+# U Resources Mined [t] (currently implemented with a metric tonnes conversion)\n+_udeps= [('Materials', ( 'SimId', 'QualId', 'ResourceId', 'ObjId', 'TimeCreated', 'NucId'), \n+             'Mass'),\n+          ('Transactions', ('SimId', 'TransactionId', 'ResourceId'), 'Commodity')]\n+\n+_uschema = [('SimId', ts.UUID), ('QualId', ts.INT), \n+            ('TransactionId', ts.INT), ('ResourceId', ts.INT), \n+            ('ObjId', ts.INT), ('TimeCreated', ts.INT), \n+            ('FCO_U_Mined', ts.DOUBLE)]\n+\n+@metric(name='FCO_U_Mined', depends=_udeps, schema=_uschema)\n+def fco_u_mined(series):\n+    \"\"\"FCO_U_mined metric returns the uranium mined at each timestep in a \n+    simulation. This is written for FCO-only databases (i.e., the U235 and \n+    U238 are given separately in the FCO simulations).\"\"\"\n+    mass = pd.merge(series[0].reset_index(), series[1].reset_index(), \n+            on=['SimId', 'ResourceId'], how='inner').set_index(['SimId',\n+                'QualId', 'TransactionId', 'ResourceId', 'ObjId', \n+                'TimeCreated', 'NucId'])\n+    u = []\n+    prods = {}\n+    mass235 = {}\n+    m = mass[mass['Commodity']=='LWR Fuel']\n+    for (_, _, _, _, obj, _, nuc), value in m.iterrows():\n+        prods[obj] = prods.get(obj, 0.0) + value['Mass']\n+        if nuc==922350000:\n+            mass235[obj] = value['Mass']\n+    for obj, m235 in mass235.items():\n+        x_prod = m235 / prods[obj]\n+        feed = enr.feed(0.0072, x_prod, 0.0025, product=prods[obj])\n+        u.append(feed)\n+    m = m.groupby(level=['SimId', 'QualId', 'TransactionId', 'ResourceId', \n+        'ObjId', 'TimeCreated'])['Mass'].sum()\n+    u = pd.Series(u, index=m.index)\n+    u.name = 'FCO_U_Mined'","path":"cymetric/metrics.py","position":56,"original_position":56,"commit_id":"a6e2987809d200ba426bb9899ef11e755f027534","original_commit_id":"a6e2987809d200ba426bb9899ef11e755f027534","user":{"login":"scopatz","id":320553,"avatar_url":"https://avatars.githubusercontent.com/u/320553?v=3","gravatar_id":"","url":"https://api.github.com/users/scopatz","html_url":"https://github.com/scopatz","followers_url":"https://api.github.com/users/scopatz/followers","following_url":"https://api.github.com/users/scopatz/following{/other_user}","gists_url":"https://api.github.com/users/scopatz/gists{/gist_id}","starred_url":"https://api.github.com/users/scopatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scopatz/subscriptions","organizations_url":"https://api.github.com/users/scopatz/orgs","repos_url":"https://api.github.com/users/scopatz/repos","events_url":"https://api.github.com/users/scopatz/events{/privacy}","received_events_url":"https://api.github.com/users/scopatz/received_events","type":"User","site_admin":false},"body":"Name","created_at":"2015-04-14T20:21:15Z","updated_at":"2015-04-14T20:21:15Z","html_url":"https://github.com/cyclus/cymetric/pull/51#discussion_r28366289","pull_request_url":"https://api.github.com/repos/cyclus/cymetric/pulls/51","_links":{"self":{"href":"https://api.github.com/repos/cyclus/cymetric/pulls/comments/28366289"},"html":{"href":"https://github.com/cyclus/cymetric/pull/51#discussion_r28366289"},"pull_request":{"href":"https://api.github.com/repos/cyclus/cymetric/pulls/51"}}},"pull_request":{"url":"https://api.github.com/repos/cyclus/cymetric/pulls/51","id":33293626,"html_url":"https://github.com/cyclus/cymetric/pull/51","diff_url":"https://github.com/cyclus/cymetric/pull/51.diff","patch_url":"https://github.com/cyclus/cymetric/pull/51.patch","issue_url":"https://api.github.com/repos/cyclus/cymetric/issues/51","number":51,"state":"open","locked":false,"title":"Fco","user":{"login":"opotowsky","id":5347433,"avatar_url":"https://avatars.githubusercontent.com/u/5347433?v=3","gravatar_id":"","url":"https://api.github.com/users/opotowsky","html_url":"https://github.com/opotowsky","followers_url":"https://api.github.com/users/opotowsky/followers","following_url":"https://api.github.com/users/opotowsky/following{/other_user}","gists_url":"https://api.github.com/users/opotowsky/gists{/gist_id}","starred_url":"https://api.github.com/users/opotowsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opotowsky/subscriptions","organizations_url":"https://api.github.com/users/opotowsky/orgs","repos_url":"https://api.github.com/users/opotowsky/repos","events_url":"https://api.github.com/users/opotowsky/events{/privacy}","received_events_url":"https://api.github.com/users/opotowsky/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-14T19:56:09Z","updated_at":"2015-04-14T20:21:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6d44953ed7cf9c93c7f1b4fc0a666b87a673f1eb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cyclus/cymetric/pulls/51/commits","review_comments_url":"https://api.github.com/repos/cyclus/cymetric/pulls/51/comments","review_comment_url":"https://api.github.com/repos/cyclus/cymetric/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cyclus/cymetric/issues/51/comments","statuses_url":"https://api.github.com/repos/cyclus/cymetric/statuses/a6e2987809d200ba426bb9899ef11e755f027534","head":{"label":"opotowsky:fco","ref":"fco","sha":"a6e2987809d200ba426bb9899ef11e755f027534","user":{"login":"opotowsky","id":5347433,"avatar_url":"https://avatars.githubusercontent.com/u/5347433?v=3","gravatar_id":"","url":"https://api.github.com/users/opotowsky","html_url":"https://github.com/opotowsky","followers_url":"https://api.github.com/users/opotowsky/followers","following_url":"https://api.github.com/users/opotowsky/following{/other_user}","gists_url":"https://api.github.com/users/opotowsky/gists{/gist_id}","starred_url":"https://api.github.com/users/opotowsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opotowsky/subscriptions","organizations_url":"https://api.github.com/users/opotowsky/orgs","repos_url":"https://api.github.com/users/opotowsky/repos","events_url":"https://api.github.com/users/opotowsky/events{/privacy}","received_events_url":"https://api.github.com/users/opotowsky/received_events","type":"User","site_admin":false},"repo":{"id":29869597,"name":"cymetric","full_name":"opotowsky/cymetric","owner":{"login":"opotowsky","id":5347433,"avatar_url":"https://avatars.githubusercontent.com/u/5347433?v=3","gravatar_id":"","url":"https://api.github.com/users/opotowsky","html_url":"https://github.com/opotowsky","followers_url":"https://api.github.com/users/opotowsky/followers","following_url":"https://api.github.com/users/opotowsky/following{/other_user}","gists_url":"https://api.github.com/users/opotowsky/gists{/gist_id}","starred_url":"https://api.github.com/users/opotowsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opotowsky/subscriptions","organizations_url":"https://api.github.com/users/opotowsky/orgs","repos_url":"https://api.github.com/users/opotowsky/repos","events_url":"https://api.github.com/users/opotowsky/events{/privacy}","received_events_url":"https://api.github.com/users/opotowsky/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/opotowsky/cymetric","description":"","fork":true,"url":"https://api.github.com/repos/opotowsky/cymetric","forks_url":"https://api.github.com/repos/opotowsky/cymetric/forks","keys_url":"https://api.github.com/repos/opotowsky/cymetric/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opotowsky/cymetric/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opotowsky/cymetric/teams","hooks_url":"https://api.github.com/repos/opotowsky/cymetric/hooks","issue_events_url":"https://api.github.com/repos/opotowsky/cymetric/issues/events{/number}","events_url":"https://api.github.com/repos/opotowsky/cymetric/events","assignees_url":"https://api.github.com/repos/opotowsky/cymetric/assignees{/user}","branches_url":"https://api.github.com/repos/opotowsky/cymetric/branches{/branch}","tags_url":"https://api.github.com/repos/opotowsky/cymetric/tags","blobs_url":"https://api.github.com/repos/opotowsky/cymetric/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opotowsky/cymetric/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opotowsky/cymetric/git/refs{/sha}","trees_url":"https://api.github.com/repos/opotowsky/cymetric/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opotowsky/cymetric/statuses/{sha}","languages_url":"https://api.github.com/repos/opotowsky/cymetric/languages","stargazers_url":"https://api.github.com/repos/opotowsky/cymetric/stargazers","contributors_url":"https://api.github.com/repos/opotowsky/cymetric/contributors","subscribers_url":"https://api.github.com/repos/opotowsky/cymetric/subscribers","subscription_url":"https://api.github.com/repos/opotowsky/cymetric/subscription","commits_url":"https://api.github.com/repos/opotowsky/cymetric/commits{/sha}","git_commits_url":"https://api.github.com/repos/opotowsky/cymetric/git/commits{/sha}","comments_url":"https://api.github.com/repos/opotowsky/cymetric/comments{/number}","issue_comment_url":"https://api.github.com/repos/opotowsky/cymetric/issues/comments{/number}","contents_url":"https://api.github.com/repos/opotowsky/cymetric/contents/{+path}","compare_url":"https://api.github.com/repos/opotowsky/cymetric/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opotowsky/cymetric/merges","archive_url":"https://api.github.com/repos/opotowsky/cymetric/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opotowsky/cymetric/downloads","issues_url":"https://api.github.com/repos/opotowsky/cymetric/issues{/number}","pulls_url":"https://api.github.com/repos/opotowsky/cymetric/pulls{/number}","milestones_url":"https://api.github.com/repos/opotowsky/cymetric/milestones{/number}","notifications_url":"https://api.github.com/repos/opotowsky/cymetric/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opotowsky/cymetric/labels{/name}","releases_url":"https://api.github.com/repos/opotowsky/cymetric/releases{/id}","created_at":"2015-01-26T16:21:35Z","updated_at":"2015-02-26T20:33:22Z","pushed_at":"2015-04-14T19:44:04Z","git_url":"git://github.com/opotowsky/cymetric.git","ssh_url":"git@github.com:opotowsky/cymetric.git","clone_url":"https://github.com/opotowsky/cymetric.git","svn_url":"https://github.com/opotowsky/cymetric","homepage":null,"size":1911,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cyclus:master","ref":"master","sha":"af2718d0008f110a98dc213c53e7a498260d93ff","user":{"login":"cyclus","id":1355686,"avatar_url":"https://avatars.githubusercontent.com/u/1355686?v=3","gravatar_id":"","url":"https://api.github.com/users/cyclus","html_url":"https://github.com/cyclus","followers_url":"https://api.github.com/users/cyclus/followers","following_url":"https://api.github.com/users/cyclus/following{/other_user}","gists_url":"https://api.github.com/users/cyclus/gists{/gist_id}","starred_url":"https://api.github.com/users/cyclus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyclus/subscriptions","organizations_url":"https://api.github.com/users/cyclus/orgs","repos_url":"https://api.github.com/users/cyclus/repos","events_url":"https://api.github.com/users/cyclus/events{/privacy}","received_events_url":"https://api.github.com/users/cyclus/received_events","type":"Organization","site_admin":false},"repo":{"id":16849857,"name":"cymetric","full_name":"cyclus/cymetric","owner":{"login":"cyclus","id":1355686,"avatar_url":"https://avatars.githubusercontent.com/u/1355686?v=3","gravatar_id":"","url":"https://api.github.com/users/cyclus","html_url":"https://github.com/cyclus","followers_url":"https://api.github.com/users/cyclus/followers","following_url":"https://api.github.com/users/cyclus/following{/other_user}","gists_url":"https://api.github.com/users/cyclus/gists{/gist_id}","starred_url":"https://api.github.com/users/cyclus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyclus/subscriptions","organizations_url":"https://api.github.com/users/cyclus/orgs","repos_url":"https://api.github.com/users/cyclus/repos","events_url":"https://api.github.com/users/cyclus/events{/privacy}","received_events_url":"https://api.github.com/users/cyclus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cyclus/cymetric","description":"","fork":false,"url":"https://api.github.com/repos/cyclus/cymetric","forks_url":"https://api.github.com/repos/cyclus/cymetric/forks","keys_url":"https://api.github.com/repos/cyclus/cymetric/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cyclus/cymetric/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cyclus/cymetric/teams","hooks_url":"https://api.github.com/repos/cyclus/cymetric/hooks","issue_events_url":"https://api.github.com/repos/cyclus/cymetric/issues/events{/number}","events_url":"https://api.github.com/repos/cyclus/cymetric/events","assignees_url":"https://api.github.com/repos/cyclus/cymetric/assignees{/user}","branches_url":"https://api.github.com/repos/cyclus/cymetric/branches{/branch}","tags_url":"https://api.github.com/repos/cyclus/cymetric/tags","blobs_url":"https://api.github.com/repos/cyclus/cymetric/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cyclus/cymetric/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cyclus/cymetric/git/refs{/sha}","trees_url":"https://api.github.com/repos/cyclus/cymetric/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cyclus/cymetric/statuses/{sha}","languages_url":"https://api.github.com/repos/cyclus/cymetric/languages","stargazers_url":"https://api.github.com/repos/cyclus/cymetric/stargazers","contributors_url":"https://api.github.com/repos/cyclus/cymetric/contributors","subscribers_url":"https://api.github.com/repos/cyclus/cymetric/subscribers","subscription_url":"https://api.github.com/repos/cyclus/cymetric/subscription","commits_url":"https://api.github.com/repos/cyclus/cymetric/commits{/sha}","git_commits_url":"https://api.github.com/repos/cyclus/cymetric/git/commits{/sha}","comments_url":"https://api.github.com/repos/cyclus/cymetric/comments{/number}","issue_comment_url":"https://api.github.com/repos/cyclus/cymetric/issues/comments{/number}","contents_url":"https://api.github.com/repos/cyclus/cymetric/contents/{+path}","compare_url":"https://api.github.com/repos/cyclus/cymetric/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cyclus/cymetric/merges","archive_url":"https://api.github.com/repos/cyclus/cymetric/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cyclus/cymetric/downloads","issues_url":"https://api.github.com/repos/cyclus/cymetric/issues{/number}","pulls_url":"https://api.github.com/repos/cyclus/cymetric/pulls{/number}","milestones_url":"https://api.github.com/repos/cyclus/cymetric/milestones{/number}","notifications_url":"https://api.github.com/repos/cyclus/cymetric/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cyclus/cymetric/labels{/name}","releases_url":"https://api.github.com/repos/cyclus/cymetric/releases{/id}","created_at":"2014-02-14T21:24:25Z","updated_at":"2015-04-07T17:19:07Z","pushed_at":"2015-04-14T19:56:11Z","git_url":"git://github.com/cyclus/cymetric.git","ssh_url":"git@github.com:cyclus/cymetric.git","clone_url":"https://github.com/cyclus/cymetric.git","svn_url":"https://github.com/cyclus/cymetric","homepage":null,"size":2267,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":4,"forks":5,"open_issues":4,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cyclus/cymetric/pulls/51"},"html":{"href":"https://github.com/cyclus/cymetric/pull/51"},"issue":{"href":"https://api.github.com/repos/cyclus/cymetric/issues/51"},"comments":{"href":"https://api.github.com/repos/cyclus/cymetric/issues/51/comments"},"review_comments":{"href":"https://api.github.com/repos/cyclus/cymetric/pulls/51/comments"},"review_comment":{"href":"https://api.github.com/repos/cyclus/cymetric/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cyclus/cymetric/pulls/51/commits"},"statuses":{"href":"https://api.github.com/repos/cyclus/cymetric/statuses/a6e2987809d200ba426bb9899ef11e755f027534"}}}}