{"action":"created","comment":{"url":"https://api.github.com/repos/JGCRI/gcamdata/pulls/comments/117025167","pull_request_review_id":38693945,"id":117025167,"diff_hunk":"@@ -31,47 +29,112 @@ module_emissions_L115.nh3_an_R_S_T_Y_DISABLED <- function(command, ...) {\n \n     # Load required inputs\n     iso_GCAM_regID <- get_data(all_data, \"common/iso_GCAM_regID\")\n-    EDGAR_sector <- get_data(all_data, \"emissions/EDGAR_sector\")\n-    EDGAR_nation <- get_data(all_data, \"emissions/EDGAR_nation\")\n+    EDGAR_sector <- get_data(all_data, \"emissions/EDGAR/EDGAR_sector\")\n     GCAM_sector_tech <- get_data(all_data, \"emissions/GCAM_sector_tech\")\n     L107.an_Prod_Mt_R_C_Sys_Fd_Y <- get_data(all_data, \"L107.an_Prod_Mt_R_C_Sys_Fd_Y\")\n     L105.nh3_tgmt_USA_an_Yh <- get_data(all_data, \"L105.nh3_tgmt_USA_an_Yh\")\n-    EDGAR_NH3 <- get_data(all_data, \"emissions/EDGAR_NH3\")\n+    EDGAR_NH3 <- get_data(all_data, \"emissions/EDGAR/EDGAR_NH3\")\n \n     # ===================================================\n-    # TRANSLATED PROCESSING CODE GOES HERE...\n-    #\n-    # If you find a mistake/thing to update in the old code and\n-    # fixing it will change the output data, causing the tests to fail,\n-    # (i) open an issue on GitHub, (ii) consult with colleagues, and\n-    # then (iii) code a fix:\n-    #\n-    # if(OLD_DATA_SYSTEM_BEHAVIOR) {\n-    #   ... code that replicates old, incorrect behavior\n-    # } else {\n-    #   ... new code with a fix\n-    # }\n-    #\n-    #\n-    # NOTE: there are 'match' calls in this code. You probably want to use left_join_error_no_match\n-    # For more information, see https://github.com/JGCRI/gcamdata/wiki/Name-That-Function\n-    # NOTE: This code uses vecpaste\n-    # This function can be removed; see https://github.com/JGCRI/gcamdata/wiki/Name-That-Function\n+    # Compute emissions using EPA emissions factors and FAO animal production\n+\n+    # Rename column and add gas name\n+    L107.an_Prod_Mt_R_C_Sys_Fd_Y %>%\n+      rename(production = value) %>%\n+      mutate(Non.CO2 = \"NH3_AGR\") ->\n+      L115.nh3_tg_R_an_C_Sys_Fd_Yh\n+\n+    # Match emissions factors by year and compute unscaled emissions\n+    L115.nh3_tg_R_an_C_Sys_Fd_Yh %>%\n+      left_join(L105.nh3_tgmt_USA_an_Yh, by = \"year\") %>%\n+      rename(emfact = value) %>%\n+      mutate(epa_emissions = production * emfact) %>%\n+      na.omit() ->\n+      L115.nh3_tg_R_an_C_Sys_Fd_Yh.mlt\n+\n+    # Match by sector, technology and fuel\n+    left_join(tidyr::unite(L115.nh3_tg_R_an_C_Sys_Fd_Yh.mlt, col = \"commodity_system_feed\", c(GCAM_commodity, system, feed), sep = \"~\"),\n+              tidyr::unite(GCAM_sector_tech, col = \"sector_tech_fuel\", c(sector, fuel, technology), sep = \"~\"),\n+              by = c(\"commodity_system_feed\"=\"sector_tech_fuel\")) %>%\n+      tidyr::separate(commodity_system_feed, c(\"GCAM_commodity\", \"system\", \"feed\"), sep = \"~\") %>%\n+      select(GCAM_region_ID, GCAM_commodity, system, feed, year, production, Non.CO2, emfact, epa_emissions, EDGAR_agg_sector) ->\n+      L115.nh3_tg_R_an_C_Sys_Fd_Yh.mlt\n+\n+    # Aggregate by sector and region\n+    L115.nh3_tg_R_an_C_Sys_Fd_Yh.mlt %>%\n+      group_by(GCAM_region_ID, Non.CO2, EDGAR_agg_sector, year) %>%\n+      summarize(EPA_emissions = sum(epa_emissions)) %>%\n+      arrange(year) ->\n+      L115.nh3_tg_R_an_C_Yh.mlt\n+\n+    # Compute EDGAR emissions by region and sector\n+    L115.EDGAR <- EDGAR_NH3\n+\n+    # Renaming L115.EDGAR variable names - Note: may remove if names for L115.EDGAR change\n+    names(L115.EDGAR)[1] <- \"IPCC_Annex\"\n+    names(L115.EDGAR)[2] <- \"World_Region\"\n+\n+    # Add gas name and match by emissions factors\n+    L115.EDGAR %>%\n+      mutate(Non.CO2 = \"NH3_AGR\") %>%\n+      left_join(EDGAR_sector, by = \"IPCC\") %>%\n+      rename(EDGAR_agg_sector = agg_sector) ->\n+      L115.EDGAR\n+\n+    # Convert from EDGAR iso to GCAM_region_ID\n+    L115.EDGAR %>%\n+      mutate( iso = tolower( ISO_A3 ), ISO_A3 = NULL ) %>%\n+      change_iso_code('rou', 'rom') %>%\n+      left_join(iso_GCAM_regID, by = \"iso\") ->\n+      L115.EDGAR\n+\n+    # Note : the old data system drops values from 1970, it is unclear if that is intentional or an accident.","path":"R/zchunk_L115.nh3_an_R_S_T_Y.R","position":108,"original_position":108,"commit_id":"412ba1942f84abfa8c1ebfdd0fb61a5d64a9320c","original_commit_id":"5686d0610430ff248cd07114207e0056ad0494fe","user":{"login":"kdorheim","id":27299759,"avatar_url":"https://avatars2.githubusercontent.com/u/27299759?v=3","gravatar_id":"","url":"https://api.github.com/users/kdorheim","html_url":"https://github.com/kdorheim","followers_url":"https://api.github.com/users/kdorheim/followers","following_url":"https://api.github.com/users/kdorheim/following{/other_user}","gists_url":"https://api.github.com/users/kdorheim/gists{/gist_id}","starred_url":"https://api.github.com/users/kdorheim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kdorheim/subscriptions","organizations_url":"https://api.github.com/users/kdorheim/orgs","repos_url":"https://api.github.com/users/kdorheim/repos","events_url":"https://api.github.com/users/kdorheim/events{/privacy}","received_events_url":"https://api.github.com/users/kdorheim/received_events","type":"User","site_admin":false},"body":"Yes sorry I thought I had removed this. ","created_at":"2017-05-17T14:56:01Z","updated_at":"2017-05-17T14:56:02Z","html_url":"https://github.com/JGCRI/gcamdata/pull/405#discussion_r117025167","pull_request_url":"https://api.github.com/repos/JGCRI/gcamdata/pulls/405","_links":{"self":{"href":"https://api.github.com/repos/JGCRI/gcamdata/pulls/comments/117025167"},"html":{"href":"https://github.com/JGCRI/gcamdata/pull/405#discussion_r117025167"},"pull_request":{"href":"https://api.github.com/repos/JGCRI/gcamdata/pulls/405"}}},"pull_request":{"url":"https://api.github.com/repos/JGCRI/gcamdata/pulls/405","id":120930814,"html_url":"https://github.com/JGCRI/gcamdata/pull/405","diff_url":"https://github.com/JGCRI/gcamdata/pull/405.diff","patch_url":"https://github.com/JGCRI/gcamdata/pull/405.patch","issue_url":"https://api.github.com/repos/JGCRI/gcamdata/issues/405","number":405,"state":"open","locked":false,"title":"Kalyn - L115.nh3_an_R_S_T_Y","user":{"login":"kdorheim","id":27299759,"avatar_url":"https://avatars2.githubusercontent.com/u/27299759?v=3","gravatar_id":"","url":"https://api.github.com/users/kdorheim","html_url":"https://github.com/kdorheim","followers_url":"https://api.github.com/users/kdorheim/followers","following_url":"https://api.github.com/users/kdorheim/following{/other_user}","gists_url":"https://api.github.com/users/kdorheim/gists{/gist_id}","starred_url":"https://api.github.com/users/kdorheim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kdorheim/subscriptions","organizations_url":"https://api.github.com/users/kdorheim/orgs","repos_url":"https://api.github.com/users/kdorheim/repos","events_url":"https://api.github.com/users/kdorheim/events{/privacy}","received_events_url":"https://api.github.com/users/kdorheim/received_events","type":"User","site_admin":false},"body":"dsr for the module_emissions_L115.nh3_an_R_S_T_Y  chunk. This chunk\r\ncomputes annual animal NH3 emissions by GCAM region, sector and\r\ntechnology. It passes the test package but produces a weird document\r\nwarning with check package.\r\n\r\n#355 ","created_at":"2017-05-16T21:33:54Z","updated_at":"2017-05-17T14:56:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"75d592aa7121fef5e44ace20f399267872394673","assignee":null,"assignees":[],"requested_reviewers":[{"login":"ssmithClimate","id":13355102,"avatar_url":"https://avatars1.githubusercontent.com/u/13355102?v=3","gravatar_id":"","url":"https://api.github.com/users/ssmithClimate","html_url":"https://github.com/ssmithClimate","followers_url":"https://api.github.com/users/ssmithClimate/followers","following_url":"https://api.github.com/users/ssmithClimate/following{/other_user}","gists_url":"https://api.github.com/users/ssmithClimate/gists{/gist_id}","starred_url":"https://api.github.com/users/ssmithClimate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssmithClimate/subscriptions","organizations_url":"https://api.github.com/users/ssmithClimate/orgs","repos_url":"https://api.github.com/users/ssmithClimate/repos","events_url":"https://api.github.com/users/ssmithClimate/events{/privacy}","received_events_url":"https://api.github.com/users/ssmithClimate/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/JGCRI/gcamdata/pulls/405/commits","review_comments_url":"https://api.github.com/repos/JGCRI/gcamdata/pulls/405/comments","review_comment_url":"https://api.github.com/repos/JGCRI/gcamdata/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JGCRI/gcamdata/issues/405/comments","statuses_url":"https://api.github.com/repos/JGCRI/gcamdata/statuses/412ba1942f84abfa8c1ebfdd0fb61a5d64a9320c","head":{"label":"JGCRI:kd-L115.nh3_an_R_S_T_Y","ref":"kd-L115.nh3_an_R_S_T_Y","sha":"412ba1942f84abfa8c1ebfdd0fb61a5d64a9320c","user":{"login":"JGCRI","id":8431983,"avatar_url":"https://avatars2.githubusercontent.com/u/8431983?v=3","gravatar_id":"","url":"https://api.github.com/users/JGCRI","html_url":"https://github.com/JGCRI","followers_url":"https://api.github.com/users/JGCRI/followers","following_url":"https://api.github.com/users/JGCRI/following{/other_user}","gists_url":"https://api.github.com/users/JGCRI/gists{/gist_id}","starred_url":"https://api.github.com/users/JGCRI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JGCRI/subscriptions","organizations_url":"https://api.github.com/users/JGCRI/orgs","repos_url":"https://api.github.com/users/JGCRI/repos","events_url":"https://api.github.com/users/JGCRI/events{/privacy}","received_events_url":"https://api.github.com/users/JGCRI/received_events","type":"Organization","site_admin":false},"repo":{"id":72801482,"name":"gcamdata","full_name":"JGCRI/gcamdata","owner":{"login":"JGCRI","id":8431983,"avatar_url":"https://avatars2.githubusercontent.com/u/8431983?v=3","gravatar_id":"","url":"https://api.github.com/users/JGCRI","html_url":"https://github.com/JGCRI","followers_url":"https://api.github.com/users/JGCRI/followers","following_url":"https://api.github.com/users/JGCRI/following{/other_user}","gists_url":"https://api.github.com/users/JGCRI/gists{/gist_id}","starred_url":"https://api.github.com/users/JGCRI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JGCRI/subscriptions","organizations_url":"https://api.github.com/users/JGCRI/orgs","repos_url":"https://api.github.com/users/JGCRI/repos","events_url":"https://api.github.com/users/JGCRI/events{/privacy}","received_events_url":"https://api.github.com/users/JGCRI/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JGCRI/gcamdata","description":"GCAM data system rewrite","fork":false,"url":"https://api.github.com/repos/JGCRI/gcamdata","forks_url":"https://api.github.com/repos/JGCRI/gcamdata/forks","keys_url":"https://api.github.com/repos/JGCRI/gcamdata/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JGCRI/gcamdata/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JGCRI/gcamdata/teams","hooks_url":"https://api.github.com/repos/JGCRI/gcamdata/hooks","issue_events_url":"https://api.github.com/repos/JGCRI/gcamdata/issues/events{/number}","events_url":"https://api.github.com/repos/JGCRI/gcamdata/events","assignees_url":"https://api.github.com/repos/JGCRI/gcamdata/assignees{/user}","branches_url":"https://api.github.com/repos/JGCRI/gcamdata/branches{/branch}","tags_url":"https://api.github.com/repos/JGCRI/gcamdata/tags","blobs_url":"https://api.github.com/repos/JGCRI/gcamdata/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JGCRI/gcamdata/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JGCRI/gcamdata/git/refs{/sha}","trees_url":"https://api.github.com/repos/JGCRI/gcamdata/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JGCRI/gcamdata/statuses/{sha}","languages_url":"https://api.github.com/repos/JGCRI/gcamdata/languages","stargazers_url":"https://api.github.com/repos/JGCRI/gcamdata/stargazers","contributors_url":"https://api.github.com/repos/JGCRI/gcamdata/contributors","subscribers_url":"https://api.github.com/repos/JGCRI/gcamdata/subscribers","subscription_url":"https://api.github.com/repos/JGCRI/gcamdata/subscription","commits_url":"https://api.github.com/repos/JGCRI/gcamdata/commits{/sha}","git_commits_url":"https://api.github.com/repos/JGCRI/gcamdata/git/commits{/sha}","comments_url":"https://api.github.com/repos/JGCRI/gcamdata/comments{/number}","issue_comment_url":"https://api.github.com/repos/JGCRI/gcamdata/issues/comments{/number}","contents_url":"https://api.github.com/repos/JGCRI/gcamdata/contents/{+path}","compare_url":"https://api.github.com/repos/JGCRI/gcamdata/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JGCRI/gcamdata/merges","archive_url":"https://api.github.com/repos/JGCRI/gcamdata/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JGCRI/gcamdata/downloads","issues_url":"https://api.github.com/repos/JGCRI/gcamdata/issues{/number}","pulls_url":"https://api.github.com/repos/JGCRI/gcamdata/pulls{/number}","milestones_url":"https://api.github.com/repos/JGCRI/gcamdata/milestones{/number}","notifications_url":"https://api.github.com/repos/JGCRI/gcamdata/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JGCRI/gcamdata/labels{/name}","releases_url":"https://api.github.com/repos/JGCRI/gcamdata/releases{/id}","deployments_url":"https://api.github.com/repos/JGCRI/gcamdata/deployments","created_at":"2016-11-04T01:09:57Z","updated_at":"2017-05-03T13:40:32Z","pushed_at":"2017-05-17T14:29:23Z","git_url":"git://github.com/JGCRI/gcamdata.git","ssh_url":"git@github.com:JGCRI/gcamdata.git","clone_url":"https://github.com/JGCRI/gcamdata.git","svn_url":"https://github.com/JGCRI/gcamdata","homepage":null,"size":207526,"stargazers_count":2,"watchers_count":2,"language":"R","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":88,"forks":0,"open_issues":88,"watchers":2,"default_branch":"master"}},"base":{"label":"JGCRI:master","ref":"master","sha":"90be6d9c15d1ed5c92565f410766dc513a8172a1","user":{"login":"JGCRI","id":8431983,"avatar_url":"https://avatars2.githubusercontent.com/u/8431983?v=3","gravatar_id":"","url":"https://api.github.com/users/JGCRI","html_url":"https://github.com/JGCRI","followers_url":"https://api.github.com/users/JGCRI/followers","following_url":"https://api.github.com/users/JGCRI/following{/other_user}","gists_url":"https://api.github.com/users/JGCRI/gists{/gist_id}","starred_url":"https://api.github.com/users/JGCRI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JGCRI/subscriptions","organizations_url":"https://api.github.com/users/JGCRI/orgs","repos_url":"https://api.github.com/users/JGCRI/repos","events_url":"https://api.github.com/users/JGCRI/events{/privacy}","received_events_url":"https://api.github.com/users/JGCRI/received_events","type":"Organization","site_admin":false},"repo":{"id":72801482,"name":"gcamdata","full_name":"JGCRI/gcamdata","owner":{"login":"JGCRI","id":8431983,"avatar_url":"https://avatars2.githubusercontent.com/u/8431983?v=3","gravatar_id":"","url":"https://api.github.com/users/JGCRI","html_url":"https://github.com/JGCRI","followers_url":"https://api.github.com/users/JGCRI/followers","following_url":"https://api.github.com/users/JGCRI/following{/other_user}","gists_url":"https://api.github.com/users/JGCRI/gists{/gist_id}","starred_url":"https://api.github.com/users/JGCRI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JGCRI/subscriptions","organizations_url":"https://api.github.com/users/JGCRI/orgs","repos_url":"https://api.github.com/users/JGCRI/repos","events_url":"https://api.github.com/users/JGCRI/events{/privacy}","received_events_url":"https://api.github.com/users/JGCRI/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JGCRI/gcamdata","description":"GCAM data system rewrite","fork":false,"url":"https://api.github.com/repos/JGCRI/gcamdata","forks_url":"https://api.github.com/repos/JGCRI/gcamdata/forks","keys_url":"https://api.github.com/repos/JGCRI/gcamdata/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JGCRI/gcamdata/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JGCRI/gcamdata/teams","hooks_url":"https://api.github.com/repos/JGCRI/gcamdata/hooks","issue_events_url":"https://api.github.com/repos/JGCRI/gcamdata/issues/events{/number}","events_url":"https://api.github.com/repos/JGCRI/gcamdata/events","assignees_url":"https://api.github.com/repos/JGCRI/gcamdata/assignees{/user}","branches_url":"https://api.github.com/repos/JGCRI/gcamdata/branches{/branch}","tags_url":"https://api.github.com/repos/JGCRI/gcamdata/tags","blobs_url":"https://api.github.com/repos/JGCRI/gcamdata/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JGCRI/gcamdata/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JGCRI/gcamdata/git/refs{/sha}","trees_url":"https://api.github.com/repos/JGCRI/gcamdata/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JGCRI/gcamdata/statuses/{sha}","languages_url":"https://api.github.com/repos/JGCRI/gcamdata/languages","stargazers_url":"https://api.github.com/repos/JGCRI/gcamdata/stargazers","contributors_url":"https://api.github.com/repos/JGCRI/gcamdata/contributors","subscribers_url":"https://api.github.com/repos/JGCRI/gcamdata/subscribers","subscription_url":"https://api.github.com/repos/JGCRI/gcamdata/subscription","commits_url":"https://api.github.com/repos/JGCRI/gcamdata/commits{/sha}","git_commits_url":"https://api.github.com/repos/JGCRI/gcamdata/git/commits{/sha}","comments_url":"https://api.github.com/repos/JGCRI/gcamdata/comments{/number}","issue_comment_url":"https://api.github.com/repos/JGCRI/gcamdata/issues/comments{/number}","contents_url":"https://api.github.com/repos/JGCRI/gcamdata/contents/{+path}","compare_url":"https://api.github.com/repos/JGCRI/gcamdata/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JGCRI/gcamdata/merges","archive_url":"https://api.github.com/repos/JGCRI/gcamdata/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JGCRI/gcamdata/downloads","issues_url":"https://api.github.com/repos/JGCRI/gcamdata/issues{/number}","pulls_url":"https://api.github.com/repos/JGCRI/gcamdata/pulls{/number}","milestones_url":"https://api.github.com/repos/JGCRI/gcamdata/milestones{/number}","notifications_url":"https://api.github.com/repos/JGCRI/gcamdata/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JGCRI/gcamdata/labels{/name}","releases_url":"https://api.github.com/repos/JGCRI/gcamdata/releases{/id}","deployments_url":"https://api.github.com/repos/JGCRI/gcamdata/deployments","created_at":"2016-11-04T01:09:57Z","updated_at":"2017-05-03T13:40:32Z","pushed_at":"2017-05-17T14:29:23Z","git_url":"git://github.com/JGCRI/gcamdata.git","ssh_url":"git@github.com:JGCRI/gcamdata.git","clone_url":"https://github.com/JGCRI/gcamdata.git","svn_url":"https://github.com/JGCRI/gcamdata","homepage":null,"size":207526,"stargazers_count":2,"watchers_count":2,"language":"R","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":88,"forks":0,"open_issues":88,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JGCRI/gcamdata/pulls/405"},"html":{"href":"https://github.com/JGCRI/gcamdata/pull/405"},"issue":{"href":"https://api.github.com/repos/JGCRI/gcamdata/issues/405"},"comments":{"href":"https://api.github.com/repos/JGCRI/gcamdata/issues/405/comments"},"review_comments":{"href":"https://api.github.com/repos/JGCRI/gcamdata/pulls/405/comments"},"review_comment":{"href":"https://api.github.com/repos/JGCRI/gcamdata/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JGCRI/gcamdata/pulls/405/commits"},"statuses":{"href":"https://api.github.com/repos/JGCRI/gcamdata/statuses/412ba1942f84abfa8c1ebfdd0fb61a5d64a9320c"}}}}
{"actor":{"display_login":"kdorheim"}}