{"action":"created","comment":{"url":"https://api.github.com/repos/PecanProject/pecan/pulls/comments/209039534","pull_request_review_id":144975338,"id":209039534,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwOTAzOTUzNA==","diff_hunk":"@@ -0,0 +1,82 @@\n+##'@title prep.data.assim\n+##'@section purpose:\n+##'This function sets up a call to PEcAn.assim.sequential::sda.enkf()\n+##'\n+##'@param settings the PEcAn settings object (a collection of nested lists)\n+##'@return None\n+##'@export\n+##'@author Luke Dramko\n+prep.data.assim <- function(settings) {\n+  # Obtain real data from the site\n+  timestep <- 0.5 # Every half hour = 0.5\n+  \n+  field_data <- PEcAn.data.atmosphere::download.US_WCr(settings$run$start_date, settings$run$end_date, timestep = timestep)\n+  \n+  uncertainty_vals <- list()\n+  \n+  # Creates a proxy row for rbinding\n+  sums <- NULL\n+  \n+  # One vector holds the mean for each variable.\n+  obs.mean <- NULL\n+  \n+  for (i in 1:length(field_data)) {\n+    AMF.params <- PEcAn.uncertainty::flux.uncertainty(field_data[[i]], QC = rep(0, length(field_data[[i]])))\n+    numvals <- 10;\n+    \n+    # Create proxy row for rbinding\n+    random_mat = NULL\n+    new_col = rep(0, length(field_data[[i]]))\n+    \n+    # Create a new column\n+    # i: the particular variable being worked with\n+    # j: the column number\n+    # k: the row number\n+    for (j in 1:numvals) { # number of random numbers\n+      obs <- field_data[[i]][!is.na(field_data[[i]])]\n+      plot(obs)\n+      pos <- obs >= 0\n+      \n+      res <- obs\n+      res[pos]  <- rexp(length(obs[pos]),\n+                        1 / (AMF.params$intercept[[1]] + (AMF.params$slopeP[[1]] * obs[pos])))\n+      res[!pos]  <- rexp(length(obs[!pos]),\n+                         1 / (AMF.params$intercept[[1]] + (AMF.params$slopeN[[1]] * obs[!pos])))\n+      \n+      random_multiplier <- sample(c(-1,1), length(res), replace = TRUE)\n+      simulated <- obs+(random_multiplier*res)\n+      \n+      sim_idx = 1; # Because NA's are excluded, real time points don't match up exactly.\n+      for (k in 1:length(field_data[[i]])) { # k for each real time point","path":"modules/uncertainty/R/prep.data.assim.R","position":50,"original_position":50,"commit_id":"73caa31654ab13194eee018bd86a929cc5af2bf6","original_commit_id":"73caa31654ab13194eee018bd86a929cc5af2bf6","user":{"login":"mdietze","id":3081466,"node_id":"MDQ6VXNlcjMwODE0NjY=","avatar_url":"https://avatars2.githubusercontent.com/u/3081466?v=4","gravatar_id":"","url":"https://api.github.com/users/mdietze","html_url":"https://github.com/mdietze","followers_url":"https://api.github.com/users/mdietze/followers","following_url":"https://api.github.com/users/mdietze/following{/other_user}","gists_url":"https://api.github.com/users/mdietze/gists{/gist_id}","starred_url":"https://api.github.com/users/mdietze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdietze/subscriptions","organizations_url":"https://api.github.com/users/mdietze/orgs","repos_url":"https://api.github.com/users/mdietze/repos","events_url":"https://api.github.com/users/mdietze/events{/privacy}","received_events_url":"https://api.github.com/users/mdietze/received_events","type":"User","site_admin":false},"body":"not following why this step is needed -- the presence of NAs shouldn't change the length of the vector","created_at":"2018-08-09T18:46:12Z","updated_at":"2018-08-09T18:49:46Z","html_url":"https://github.com/PecanProject/pecan/pull/2035#discussion_r209039534","pull_request_url":"https://api.github.com/repos/PecanProject/pecan/pulls/2035","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/PecanProject/pecan/pulls/comments/209039534"},"html":{"href":"https://github.com/PecanProject/pecan/pull/2035#discussion_r209039534"},"pull_request":{"href":"https://api.github.com/repos/PecanProject/pecan/pulls/2035"}}},"pull_request":{"url":"https://api.github.com/repos/PecanProject/pecan/pulls/2035","id":207106683,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3MTA2Njgz","html_url":"https://github.com/PecanProject/pecan/pull/2035","diff_url":"https://github.com/PecanProject/pecan/pull/2035.diff","patch_url":"https://github.com/PecanProject/pecan/pull/2035.patch","issue_url":"https://api.github.com/repos/PecanProject/pecan/issues/2035","number":2035,"state":"open","locked":false,"title":"Sipnet SDA Preprocessing Code","user":{"login":"Luke-Dramko","id":38334039,"node_id":"MDQ6VXNlcjM4MzM0MDM5","avatar_url":"https://avatars2.githubusercontent.com/u/38334039?v=4","gravatar_id":"","url":"https://api.github.com/users/Luke-Dramko","html_url":"https://github.com/Luke-Dramko","followers_url":"https://api.github.com/users/Luke-Dramko/followers","following_url":"https://api.github.com/users/Luke-Dramko/following{/other_user}","gists_url":"https://api.github.com/users/Luke-Dramko/gists{/gist_id}","starred_url":"https://api.github.com/users/Luke-Dramko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Luke-Dramko/subscriptions","organizations_url":"https://api.github.com/users/Luke-Dramko/orgs","repos_url":"https://api.github.com/users/Luke-Dramko/repos","events_url":"https://api.github.com/users/Luke-Dramko/events{/privacy}","received_events_url":"https://api.github.com/users/Luke-Dramko/received_events","type":"User","site_admin":false},"body":"<!--- Provide a general summary of your changes in the Title above -->\r\n<!--- Please select appropriate Priority, Status,and Type labels-->\r\n<!--- If you do not have permission to select labels please state which labels you would like -->\r\n\r\n## Description\r\n<!--- Describe your changes in detail -->\r\nThis code provides an interface between the main PEcAn workflow and the current version of the SDA code.  It sets up `obs.mean` and `obs.cov`, which are required arguments, and handles the call to the SDA entry point `PEcAn.assim.sequential::sda.enkf`.\r\n\r\nThe changes made in this pull request do not change the SDA code.  The SDA code is currently too specific towards tree ring predictions, but is undergoing refactoring.\r\n\r\nThis pull request also includes a dependency to `prep.data.assim` (the function that handles the call to the SDA code), `download.US_WCr`.  `download.US_WCr` is a dependency for `prep.data.assim` (and for the graphs functions in `pecan/modules/assim.sequential/inst/NEFI/`).\r\n\r\nCode is written to the level of generalization currently possible with existing standards.\r\n\r\n## Motivation and Context\r\n<!--- Why is this change required? What problem does it solve? -->\r\nThese pieces of code link the main workflow with the SDA code, and provide real flux tower data to use.\r\n<!--- If it fixes an open issue, please link to the issue here. -->\r\n\r\n## Review Time Estimate\r\n<!---When do you want your code reviewed by?-->\r\n- [ ] Immediately\r\n- [x] Within one week\r\n- [ ] When possible\r\n## Types of changes\r\n<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->\r\n- [ ] Bug fix (non-breaking change which fixes an issue) <!-- please add issue number -->\r\n- [x] New feature (non-breaking change which adds functionality)\r\n- [ ] Breaking change (fix or feature that would cause existing functionality to change)\r\n\r\n## Checklist:\r\n<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->\r\n<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->\r\n- [x] My change requires a change to the documentation.\r\n- [ ] I have updated the CHANGELOG.md.\r\n- [x] I have updated the documentation accordingly.\r\n- [x] I have read the **CONTRIBUTING** document.\r\n- [ ] I have added tests to cover my changes.\r\n- [ ] All new and existing tests passed.\r\n\r\n<!--this template is from https://www.talater.com/open-source-templates/#/page/99--> \r\n","created_at":"2018-08-08T19:04:31Z","updated_at":"2018-08-09T18:49:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c8d34d1cc53d6af0133f4ad51ffe7e1548ba0194","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":245005133,"node_id":"MDU6TGFiZWwyNDUwMDUxMzM=","url":"https://api.github.com/repos/PecanProject/pecan/labels/Priority:%2002%20-%20Normal","name":"Priority: 02 - Normal","color":"fbca04","default":false},{"id":875086153,"node_id":"MDU6TGFiZWw4NzUwODYxNTM=","url":"https://api.github.com/repos/PecanProject/pecan/labels/Status:%20Review%20required","name":"Status: Review required","color":"b60205","default":false},{"id":20303929,"node_id":"MDU6TGFiZWwyMDMwMzkyOQ==","url":"https://api.github.com/repos/PecanProject/pecan/labels/Type:%20Enhancement","name":"Type: Enhancement","color":"1d76db","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/PecanProject/pecan/pulls/2035/commits","review_comments_url":"https://api.github.com/repos/PecanProject/pecan/pulls/2035/comments","review_comment_url":"https://api.github.com/repos/PecanProject/pecan/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PecanProject/pecan/issues/2035/comments","statuses_url":"https://api.github.com/repos/PecanProject/pecan/statuses/73caa31654ab13194eee018bd86a929cc5af2bf6","head":{"label":"PecanProject:sipnet_sda_preprocessing","ref":"sipnet_sda_preprocessing","sha":"73caa31654ab13194eee018bd86a929cc5af2bf6","user":{"login":"PecanProject","id":2879854,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4Nzk4NTQ=","avatar_url":"https://avatars0.githubusercontent.com/u/2879854?v=4","gravatar_id":"","url":"https://api.github.com/users/PecanProject","html_url":"https://github.com/PecanProject","followers_url":"https://api.github.com/users/PecanProject/followers","following_url":"https://api.github.com/users/PecanProject/following{/other_user}","gists_url":"https://api.github.com/users/PecanProject/gists{/gist_id}","starred_url":"https://api.github.com/users/PecanProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PecanProject/subscriptions","organizations_url":"https://api.github.com/users/PecanProject/orgs","repos_url":"https://api.github.com/users/PecanProject/repos","events_url":"https://api.github.com/users/PecanProject/events{/privacy}","received_events_url":"https://api.github.com/users/PecanProject/received_events","type":"Organization","site_admin":false},"repo":{"id":6857384,"node_id":"MDEwOlJlcG9zaXRvcnk2ODU3Mzg0","name":"pecan","full_name":"PecanProject/pecan","owner":{"login":"PecanProject","id":2879854,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4Nzk4NTQ=","avatar_url":"https://avatars0.githubusercontent.com/u/2879854?v=4","gravatar_id":"","url":"https://api.github.com/users/PecanProject","html_url":"https://github.com/PecanProject","followers_url":"https://api.github.com/users/PecanProject/followers","following_url":"https://api.github.com/users/PecanProject/following{/other_user}","gists_url":"https://api.github.com/users/PecanProject/gists{/gist_id}","starred_url":"https://api.github.com/users/PecanProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PecanProject/subscriptions","organizations_url":"https://api.github.com/users/PecanProject/orgs","repos_url":"https://api.github.com/users/PecanProject/repos","events_url":"https://api.github.com/users/PecanProject/events{/privacy}","received_events_url":"https://api.github.com/users/PecanProject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PecanProject/pecan","description":"The Predictive Ecosystem Analyzer (PEcAn) is an integrated ecological bioinformatics toolbox.","fork":false,"url":"https://api.github.com/repos/PecanProject/pecan","forks_url":"https://api.github.com/repos/PecanProject/pecan/forks","keys_url":"https://api.github.com/repos/PecanProject/pecan/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PecanProject/pecan/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PecanProject/pecan/teams","hooks_url":"https://api.github.com/repos/PecanProject/pecan/hooks","issue_events_url":"https://api.github.com/repos/PecanProject/pecan/issues/events{/number}","events_url":"https://api.github.com/repos/PecanProject/pecan/events","assignees_url":"https://api.github.com/repos/PecanProject/pecan/assignees{/user}","branches_url":"https://api.github.com/repos/PecanProject/pecan/branches{/branch}","tags_url":"https://api.github.com/repos/PecanProject/pecan/tags","blobs_url":"https://api.github.com/repos/PecanProject/pecan/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PecanProject/pecan/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PecanProject/pecan/git/refs{/sha}","trees_url":"https://api.github.com/repos/PecanProject/pecan/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PecanProject/pecan/statuses/{sha}","languages_url":"https://api.github.com/repos/PecanProject/pecan/languages","stargazers_url":"https://api.github.com/repos/PecanProject/pecan/stargazers","contributors_url":"https://api.github.com/repos/PecanProject/pecan/contributors","subscribers_url":"https://api.github.com/repos/PecanProject/pecan/subscribers","subscription_url":"https://api.github.com/repos/PecanProject/pecan/subscription","commits_url":"https://api.github.com/repos/PecanProject/pecan/commits{/sha}","git_commits_url":"https://api.github.com/repos/PecanProject/pecan/git/commits{/sha}","comments_url":"https://api.github.com/repos/PecanProject/pecan/comments{/number}","issue_comment_url":"https://api.github.com/repos/PecanProject/pecan/issues/comments{/number}","contents_url":"https://api.github.com/repos/PecanProject/pecan/contents/{+path}","compare_url":"https://api.github.com/repos/PecanProject/pecan/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PecanProject/pecan/merges","archive_url":"https://api.github.com/repos/PecanProject/pecan/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PecanProject/pecan/downloads","issues_url":"https://api.github.com/repos/PecanProject/pecan/issues{/number}","pulls_url":"https://api.github.com/repos/PecanProject/pecan/pulls{/number}","milestones_url":"https://api.github.com/repos/PecanProject/pecan/milestones{/number}","notifications_url":"https://api.github.com/repos/PecanProject/pecan/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PecanProject/pecan/labels{/name}","releases_url":"https://api.github.com/repos/PecanProject/pecan/releases{/id}","deployments_url":"https://api.github.com/repos/PecanProject/pecan/deployments","created_at":"2012-11-25T23:48:26Z","updated_at":"2018-08-09T17:59:17Z","pushed_at":"2018-08-09T17:59:13Z","git_url":"git://github.com/PecanProject/pecan.git","ssh_url":"git@github.com:PecanProject/pecan.git","clone_url":"https://github.com/PecanProject/pecan.git","svn_url":"https://github.com/PecanProject/pecan","homepage":"www.pecanproject.org","size":270420,"stargazers_count":77,"watchers_count":77,"language":"R","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":114,"mirror_url":null,"archived":false,"open_issues_count":350,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":114,"open_issues":350,"watchers":77,"default_branch":"develop"}},"base":{"label":"PecanProject:develop","ref":"develop","sha":"c45f460b2fb36af849fcc05a97d9a4e825f75fd4","user":{"login":"PecanProject","id":2879854,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4Nzk4NTQ=","avatar_url":"https://avatars0.githubusercontent.com/u/2879854?v=4","gravatar_id":"","url":"https://api.github.com/users/PecanProject","html_url":"https://github.com/PecanProject","followers_url":"https://api.github.com/users/PecanProject/followers","following_url":"https://api.github.com/users/PecanProject/following{/other_user}","gists_url":"https://api.github.com/users/PecanProject/gists{/gist_id}","starred_url":"https://api.github.com/users/PecanProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PecanProject/subscriptions","organizations_url":"https://api.github.com/users/PecanProject/orgs","repos_url":"https://api.github.com/users/PecanProject/repos","events_url":"https://api.github.com/users/PecanProject/events{/privacy}","received_events_url":"https://api.github.com/users/PecanProject/received_events","type":"Organization","site_admin":false},"repo":{"id":6857384,"node_id":"MDEwOlJlcG9zaXRvcnk2ODU3Mzg0","name":"pecan","full_name":"PecanProject/pecan","owner":{"login":"PecanProject","id":2879854,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4Nzk4NTQ=","avatar_url":"https://avatars0.githubusercontent.com/u/2879854?v=4","gravatar_id":"","url":"https://api.github.com/users/PecanProject","html_url":"https://github.com/PecanProject","followers_url":"https://api.github.com/users/PecanProject/followers","following_url":"https://api.github.com/users/PecanProject/following{/other_user}","gists_url":"https://api.github.com/users/PecanProject/gists{/gist_id}","starred_url":"https://api.github.com/users/PecanProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PecanProject/subscriptions","organizations_url":"https://api.github.com/users/PecanProject/orgs","repos_url":"https://api.github.com/users/PecanProject/repos","events_url":"https://api.github.com/users/PecanProject/events{/privacy}","received_events_url":"https://api.github.com/users/PecanProject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PecanProject/pecan","description":"The Predictive Ecosystem Analyzer (PEcAn) is an integrated ecological bioinformatics toolbox.","fork":false,"url":"https://api.github.com/repos/PecanProject/pecan","forks_url":"https://api.github.com/repos/PecanProject/pecan/forks","keys_url":"https://api.github.com/repos/PecanProject/pecan/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PecanProject/pecan/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PecanProject/pecan/teams","hooks_url":"https://api.github.com/repos/PecanProject/pecan/hooks","issue_events_url":"https://api.github.com/repos/PecanProject/pecan/issues/events{/number}","events_url":"https://api.github.com/repos/PecanProject/pecan/events","assignees_url":"https://api.github.com/repos/PecanProject/pecan/assignees{/user}","branches_url":"https://api.github.com/repos/PecanProject/pecan/branches{/branch}","tags_url":"https://api.github.com/repos/PecanProject/pecan/tags","blobs_url":"https://api.github.com/repos/PecanProject/pecan/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PecanProject/pecan/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PecanProject/pecan/git/refs{/sha}","trees_url":"https://api.github.com/repos/PecanProject/pecan/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PecanProject/pecan/statuses/{sha}","languages_url":"https://api.github.com/repos/PecanProject/pecan/languages","stargazers_url":"https://api.github.com/repos/PecanProject/pecan/stargazers","contributors_url":"https://api.github.com/repos/PecanProject/pecan/contributors","subscribers_url":"https://api.github.com/repos/PecanProject/pecan/subscribers","subscription_url":"https://api.github.com/repos/PecanProject/pecan/subscription","commits_url":"https://api.github.com/repos/PecanProject/pecan/commits{/sha}","git_commits_url":"https://api.github.com/repos/PecanProject/pecan/git/commits{/sha}","comments_url":"https://api.github.com/repos/PecanProject/pecan/comments{/number}","issue_comment_url":"https://api.github.com/repos/PecanProject/pecan/issues/comments{/number}","contents_url":"https://api.github.com/repos/PecanProject/pecan/contents/{+path}","compare_url":"https://api.github.com/repos/PecanProject/pecan/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PecanProject/pecan/merges","archive_url":"https://api.github.com/repos/PecanProject/pecan/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PecanProject/pecan/downloads","issues_url":"https://api.github.com/repos/PecanProject/pecan/issues{/number}","pulls_url":"https://api.github.com/repos/PecanProject/pecan/pulls{/number}","milestones_url":"https://api.github.com/repos/PecanProject/pecan/milestones{/number}","notifications_url":"https://api.github.com/repos/PecanProject/pecan/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PecanProject/pecan/labels{/name}","releases_url":"https://api.github.com/repos/PecanProject/pecan/releases{/id}","deployments_url":"https://api.github.com/repos/PecanProject/pecan/deployments","created_at":"2012-11-25T23:48:26Z","updated_at":"2018-08-09T17:59:17Z","pushed_at":"2018-08-09T17:59:13Z","git_url":"git://github.com/PecanProject/pecan.git","ssh_url":"git@github.com:PecanProject/pecan.git","clone_url":"https://github.com/PecanProject/pecan.git","svn_url":"https://github.com/PecanProject/pecan","homepage":"www.pecanproject.org","size":270420,"stargazers_count":77,"watchers_count":77,"language":"R","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":114,"mirror_url":null,"archived":false,"open_issues_count":350,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":114,"open_issues":350,"watchers":77,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/PecanProject/pecan/pulls/2035"},"html":{"href":"https://github.com/PecanProject/pecan/pull/2035"},"issue":{"href":"https://api.github.com/repos/PecanProject/pecan/issues/2035"},"comments":{"href":"https://api.github.com/repos/PecanProject/pecan/issues/2035/comments"},"review_comments":{"href":"https://api.github.com/repos/PecanProject/pecan/pulls/2035/comments"},"review_comment":{"href":"https://api.github.com/repos/PecanProject/pecan/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PecanProject/pecan/pulls/2035/commits"},"statuses":{"href":"https://api.github.com/repos/PecanProject/pecan/statuses/73caa31654ab13194eee018bd86a929cc5af2bf6"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"mdietze"}}