{"action":"created","comment":{"url":"https://api.github.com/repos/gammapy/gammapy/pulls/comments/123000636","pull_request_review_id":45159797,"id":123000636,"diff_hunk":"@@ -0,0 +1,30 @@\n+import numpy as np\n+# import sys\n+# sys.path.insert(0, '/afs/ifh.de/group/amanda/scratch/wegenmat/time-series-analysis/time-series-analysis')\n+from lombscargle_gammapy import lomb_scargle, plotting\n+\n+def test_lombscargle():\n+    rand = np.random.RandomState(42)\n+    t = np.linspace(0, 100, 1000)\n+    t_obs = np.sort(rand.choice(t, 500, replace=False))\n+    n_outliers = 50\n+    dmag = np.random.normal(0, 1, 1000) * -1**(rand.randint(2, size=1000))\n+    dmag_obs = dmag[np.searchsorted(t, t_obs)]\n+    outliers = rand.randint(0, t.size, n_outliers)\n+    amplitude = 2\n+    mag = amplitude * np.sin(2 * np.pi * t / 5) + dmag\n+    for n in range(n_outliers):\n+        mask = (t >= outliers[n])\n+        mag[mask] = mag[mask] + 10 * amplitude * np.exp(-1 * (t[mask] - outliers[n]))\n+    mag_obs = mag[np.searchsorted(t, t_obs)]\n+    K = 4 # oversampling factor\n+    FAP = 0.05 # false alarm probability\n+    N_bootstraps = 100 # number of bootstrap resamplings\n+    freq, PLS, best_period, quant_pre, quant_cvm, quant_nll, quant_boot, PLS_win = lomb_scargle(t_obs, mag_obs, dmag_obs, K, N_bootstraps, FAP)\n+    plotting(t, mag, dmag, freq, PLS, best_period, quant_pre, quant_cvm, quant_nll, quant_boot, N_bootstraps, PLS_win)","path":"gammapy/time/tests/test_lombscargle_gammapy.py","position":24,"original_position":24,"commit_id":"55bb3a51f28f8ab7d9755c72f63ad4450ba33b65","original_commit_id":"55bb3a51f28f8ab7d9755c72f63ad4450ba33b65","user":{"login":"cdeil","id":852409,"avatar_url":"https://avatars0.githubusercontent.com/u/852409?v=3","gravatar_id":"","url":"https://api.github.com/users/cdeil","html_url":"https://github.com/cdeil","followers_url":"https://api.github.com/users/cdeil/followers","following_url":"https://api.github.com/users/cdeil/following{/other_user}","gists_url":"https://api.github.com/users/cdeil/gists{/gist_id}","starred_url":"https://api.github.com/users/cdeil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdeil/subscriptions","organizations_url":"https://api.github.com/users/cdeil/orgs","repos_url":"https://api.github.com/users/cdeil/repos","events_url":"https://api.github.com/users/cdeil/events{/privacy}","received_events_url":"https://api.github.com/users/cdeil/received_events","type":"User","site_admin":false},"body":"Plotting test should be separate from the computation test.\r\nPeople should be able to use the function that does the computation and also run it's test without having matplotlib installed.\r\nSo there should be two test functions (probably called `test_lombscargle` and `test_lombscargle_plot`), and if you want to avoid code duplication, have the common code in a third function where the name doesn't start with \"test\" that you call from both test functions.","created_at":"2017-06-20T14:57:44Z","updated_at":"2017-06-20T15:02:14Z","html_url":"https://github.com/gammapy/gammapy/pull/1070#discussion_r123000636","pull_request_url":"https://api.github.com/repos/gammapy/gammapy/pulls/1070","_links":{"self":{"href":"https://api.github.com/repos/gammapy/gammapy/pulls/comments/123000636"},"html":{"href":"https://github.com/gammapy/gammapy/pull/1070#discussion_r123000636"},"pull_request":{"href":"https://api.github.com/repos/gammapy/gammapy/pulls/1070"}}},"pull_request":{"url":"https://api.github.com/repos/gammapy/gammapy/pulls/1070","id":126550254,"html_url":"https://github.com/gammapy/gammapy/pull/1070","diff_url":"https://github.com/gammapy/gammapy/pull/1070.diff","patch_url":"https://github.com/gammapy/gammapy/pull/1070.patch","issue_url":"https://api.github.com/repos/gammapy/gammapy/issues/1070","number":1070,"state":"open","locked":false,"title":"Lomb-Scargle for gammapy.time","user":{"login":"wegenmat","id":22657168,"avatar_url":"https://avatars0.githubusercontent.com/u/22657168?v=3","gravatar_id":"","url":"https://api.github.com/users/wegenmat","html_url":"https://github.com/wegenmat","followers_url":"https://api.github.com/users/wegenmat/followers","following_url":"https://api.github.com/users/wegenmat/following{/other_user}","gists_url":"https://api.github.com/users/wegenmat/gists{/gist_id}","starred_url":"https://api.github.com/users/wegenmat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wegenmat/subscriptions","organizations_url":"https://api.github.com/users/wegenmat/orgs","repos_url":"https://api.github.com/users/wegenmat/repos","events_url":"https://api.github.com/users/wegenmat/events{/privacy}","received_events_url":"https://api.github.com/users/wegenmat/received_events","type":"User","site_admin":false},"body":"This pull request adds the Lomb-Scargle algorithm for period detection to gammapy/time. The Lomb-Scargle is from astropy. It is extended by different significance criteria for periodogram peaks. The spectral window function is introduced to investigate the influence of sampling on the periodogram.","created_at":"2017-06-20T14:40:36Z","updated_at":"2017-06-20T15:02:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ac358452fed0517145d58994a382cdb68dca5a40","assignee":{"login":"cdeil","id":852409,"avatar_url":"https://avatars0.githubusercontent.com/u/852409?v=3","gravatar_id":"","url":"https://api.github.com/users/cdeil","html_url":"https://github.com/cdeil","followers_url":"https://api.github.com/users/cdeil/followers","following_url":"https://api.github.com/users/cdeil/following{/other_user}","gists_url":"https://api.github.com/users/cdeil/gists{/gist_id}","starred_url":"https://api.github.com/users/cdeil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdeil/subscriptions","organizations_url":"https://api.github.com/users/cdeil/orgs","repos_url":"https://api.github.com/users/cdeil/repos","events_url":"https://api.github.com/users/cdeil/events{/privacy}","received_events_url":"https://api.github.com/users/cdeil/received_events","type":"User","site_admin":false},"assignees":[{"login":"cdeil","id":852409,"avatar_url":"https://avatars0.githubusercontent.com/u/852409?v=3","gravatar_id":"","url":"https://api.github.com/users/cdeil","html_url":"https://github.com/cdeil","followers_url":"https://api.github.com/users/cdeil/followers","following_url":"https://api.github.com/users/cdeil/following{/other_user}","gists_url":"https://api.github.com/users/cdeil/gists{/gist_id}","starred_url":"https://api.github.com/users/cdeil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdeil/subscriptions","organizations_url":"https://api.github.com/users/cdeil/orgs","repos_url":"https://api.github.com/users/cdeil/repos","events_url":"https://api.github.com/users/cdeil/events{/privacy}","received_events_url":"https://api.github.com/users/cdeil/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":{"url":"https://api.github.com/repos/gammapy/gammapy/milestones/10","html_url":"https://github.com/gammapy/gammapy/milestone/10","labels_url":"https://api.github.com/repos/gammapy/gammapy/milestones/10/labels","id":2282173,"number":10,"title":"0.7","description":"","creator":{"login":"cdeil","id":852409,"avatar_url":"https://avatars0.githubusercontent.com/u/852409?v=3","gravatar_id":"","url":"https://api.github.com/users/cdeil","html_url":"https://github.com/cdeil","followers_url":"https://api.github.com/users/cdeil/followers","following_url":"https://api.github.com/users/cdeil/following{/other_user}","gists_url":"https://api.github.com/users/cdeil/gists{/gist_id}","starred_url":"https://api.github.com/users/cdeil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdeil/subscriptions","organizations_url":"https://api.github.com/users/cdeil/orgs","repos_url":"https://api.github.com/users/cdeil/repos","events_url":"https://api.github.com/users/cdeil/events{/privacy}","received_events_url":"https://api.github.com/users/cdeil/received_events","type":"User","site_admin":false},"open_issues":119,"closed_issues":42,"state":"open","created_at":"2017-01-27T12:50:29Z","updated_at":"2017-06-20T14:41:49Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/gammapy/gammapy/pulls/1070/commits","review_comments_url":"https://api.github.com/repos/gammapy/gammapy/pulls/1070/comments","review_comment_url":"https://api.github.com/repos/gammapy/gammapy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gammapy/gammapy/issues/1070/comments","statuses_url":"https://api.github.com/repos/gammapy/gammapy/statuses/55bb3a51f28f8ab7d9755c72f63ad4450ba33b65","head":{"label":"wegenmat:lomb_scargle","ref":"lomb_scargle","sha":"55bb3a51f28f8ab7d9755c72f63ad4450ba33b65","user":{"login":"wegenmat","id":22657168,"avatar_url":"https://avatars0.githubusercontent.com/u/22657168?v=3","gravatar_id":"","url":"https://api.github.com/users/wegenmat","html_url":"https://github.com/wegenmat","followers_url":"https://api.github.com/users/wegenmat/followers","following_url":"https://api.github.com/users/wegenmat/following{/other_user}","gists_url":"https://api.github.com/users/wegenmat/gists{/gist_id}","starred_url":"https://api.github.com/users/wegenmat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wegenmat/subscriptions","organizations_url":"https://api.github.com/users/wegenmat/orgs","repos_url":"https://api.github.com/users/wegenmat/repos","events_url":"https://api.github.com/users/wegenmat/events{/privacy}","received_events_url":"https://api.github.com/users/wegenmat/received_events","type":"User","site_admin":false},"repo":{"id":94900031,"name":"gammapy","full_name":"wegenmat/gammapy","owner":{"login":"wegenmat","id":22657168,"avatar_url":"https://avatars0.githubusercontent.com/u/22657168?v=3","gravatar_id":"","url":"https://api.github.com/users/wegenmat","html_url":"https://github.com/wegenmat","followers_url":"https://api.github.com/users/wegenmat/followers","following_url":"https://api.github.com/users/wegenmat/following{/other_user}","gists_url":"https://api.github.com/users/wegenmat/gists{/gist_id}","starred_url":"https://api.github.com/users/wegenmat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wegenmat/subscriptions","organizations_url":"https://api.github.com/users/wegenmat/orgs","repos_url":"https://api.github.com/users/wegenmat/repos","events_url":"https://api.github.com/users/wegenmat/events{/privacy}","received_events_url":"https://api.github.com/users/wegenmat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wegenmat/gammapy","description":"A Python package for gamma-ray astronomy","fork":true,"url":"https://api.github.com/repos/wegenmat/gammapy","forks_url":"https://api.github.com/repos/wegenmat/gammapy/forks","keys_url":"https://api.github.com/repos/wegenmat/gammapy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wegenmat/gammapy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wegenmat/gammapy/teams","hooks_url":"https://api.github.com/repos/wegenmat/gammapy/hooks","issue_events_url":"https://api.github.com/repos/wegenmat/gammapy/issues/events{/number}","events_url":"https://api.github.com/repos/wegenmat/gammapy/events","assignees_url":"https://api.github.com/repos/wegenmat/gammapy/assignees{/user}","branches_url":"https://api.github.com/repos/wegenmat/gammapy/branches{/branch}","tags_url":"https://api.github.com/repos/wegenmat/gammapy/tags","blobs_url":"https://api.github.com/repos/wegenmat/gammapy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wegenmat/gammapy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wegenmat/gammapy/git/refs{/sha}","trees_url":"https://api.github.com/repos/wegenmat/gammapy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wegenmat/gammapy/statuses/{sha}","languages_url":"https://api.github.com/repos/wegenmat/gammapy/languages","stargazers_url":"https://api.github.com/repos/wegenmat/gammapy/stargazers","contributors_url":"https://api.github.com/repos/wegenmat/gammapy/contributors","subscribers_url":"https://api.github.com/repos/wegenmat/gammapy/subscribers","subscription_url":"https://api.github.com/repos/wegenmat/gammapy/subscription","commits_url":"https://api.github.com/repos/wegenmat/gammapy/commits{/sha}","git_commits_url":"https://api.github.com/repos/wegenmat/gammapy/git/commits{/sha}","comments_url":"https://api.github.com/repos/wegenmat/gammapy/comments{/number}","issue_comment_url":"https://api.github.com/repos/wegenmat/gammapy/issues/comments{/number}","contents_url":"https://api.github.com/repos/wegenmat/gammapy/contents/{+path}","compare_url":"https://api.github.com/repos/wegenmat/gammapy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wegenmat/gammapy/merges","archive_url":"https://api.github.com/repos/wegenmat/gammapy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wegenmat/gammapy/downloads","issues_url":"https://api.github.com/repos/wegenmat/gammapy/issues{/number}","pulls_url":"https://api.github.com/repos/wegenmat/gammapy/pulls{/number}","milestones_url":"https://api.github.com/repos/wegenmat/gammapy/milestones{/number}","notifications_url":"https://api.github.com/repos/wegenmat/gammapy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wegenmat/gammapy/labels{/name}","releases_url":"https://api.github.com/repos/wegenmat/gammapy/releases{/id}","deployments_url":"https://api.github.com/repos/wegenmat/gammapy/deployments","created_at":"2017-06-20T14:25:07Z","updated_at":"2017-06-20T14:25:10Z","pushed_at":"2017-06-20T14:35:51Z","git_url":"git://github.com/wegenmat/gammapy.git","ssh_url":"git@github.com:wegenmat/gammapy.git","clone_url":"https://github.com/wegenmat/gammapy.git","svn_url":"https://github.com/wegenmat/gammapy","homepage":"http://docs.gammapy.org","size":8994,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"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":"gammapy:master","ref":"master","sha":"073cd57b7e0106be5487b2655261ddfbc9ee59ec","user":{"login":"gammapy","id":852764,"avatar_url":"https://avatars1.githubusercontent.com/u/852764?v=3","gravatar_id":"","url":"https://api.github.com/users/gammapy","html_url":"https://github.com/gammapy","followers_url":"https://api.github.com/users/gammapy/followers","following_url":"https://api.github.com/users/gammapy/following{/other_user}","gists_url":"https://api.github.com/users/gammapy/gists{/gist_id}","starred_url":"https://api.github.com/users/gammapy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gammapy/subscriptions","organizations_url":"https://api.github.com/users/gammapy/orgs","repos_url":"https://api.github.com/users/gammapy/repos","events_url":"https://api.github.com/users/gammapy/events{/privacy}","received_events_url":"https://api.github.com/users/gammapy/received_events","type":"Organization","site_admin":false},"repo":{"id":10073640,"name":"gammapy","full_name":"gammapy/gammapy","owner":{"login":"gammapy","id":852764,"avatar_url":"https://avatars1.githubusercontent.com/u/852764?v=3","gravatar_id":"","url":"https://api.github.com/users/gammapy","html_url":"https://github.com/gammapy","followers_url":"https://api.github.com/users/gammapy/followers","following_url":"https://api.github.com/users/gammapy/following{/other_user}","gists_url":"https://api.github.com/users/gammapy/gists{/gist_id}","starred_url":"https://api.github.com/users/gammapy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gammapy/subscriptions","organizations_url":"https://api.github.com/users/gammapy/orgs","repos_url":"https://api.github.com/users/gammapy/repos","events_url":"https://api.github.com/users/gammapy/events{/privacy}","received_events_url":"https://api.github.com/users/gammapy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gammapy/gammapy","description":"A Python package for gamma-ray astronomy","fork":false,"url":"https://api.github.com/repos/gammapy/gammapy","forks_url":"https://api.github.com/repos/gammapy/gammapy/forks","keys_url":"https://api.github.com/repos/gammapy/gammapy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gammapy/gammapy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gammapy/gammapy/teams","hooks_url":"https://api.github.com/repos/gammapy/gammapy/hooks","issue_events_url":"https://api.github.com/repos/gammapy/gammapy/issues/events{/number}","events_url":"https://api.github.com/repos/gammapy/gammapy/events","assignees_url":"https://api.github.com/repos/gammapy/gammapy/assignees{/user}","branches_url":"https://api.github.com/repos/gammapy/gammapy/branches{/branch}","tags_url":"https://api.github.com/repos/gammapy/gammapy/tags","blobs_url":"https://api.github.com/repos/gammapy/gammapy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gammapy/gammapy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gammapy/gammapy/git/refs{/sha}","trees_url":"https://api.github.com/repos/gammapy/gammapy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gammapy/gammapy/statuses/{sha}","languages_url":"https://api.github.com/repos/gammapy/gammapy/languages","stargazers_url":"https://api.github.com/repos/gammapy/gammapy/stargazers","contributors_url":"https://api.github.com/repos/gammapy/gammapy/contributors","subscribers_url":"https://api.github.com/repos/gammapy/gammapy/subscribers","subscription_url":"https://api.github.com/repos/gammapy/gammapy/subscription","commits_url":"https://api.github.com/repos/gammapy/gammapy/commits{/sha}","git_commits_url":"https://api.github.com/repos/gammapy/gammapy/git/commits{/sha}","comments_url":"https://api.github.com/repos/gammapy/gammapy/comments{/number}","issue_comment_url":"https://api.github.com/repos/gammapy/gammapy/issues/comments{/number}","contents_url":"https://api.github.com/repos/gammapy/gammapy/contents/{+path}","compare_url":"https://api.github.com/repos/gammapy/gammapy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gammapy/gammapy/merges","archive_url":"https://api.github.com/repos/gammapy/gammapy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gammapy/gammapy/downloads","issues_url":"https://api.github.com/repos/gammapy/gammapy/issues{/number}","pulls_url":"https://api.github.com/repos/gammapy/gammapy/pulls{/number}","milestones_url":"https://api.github.com/repos/gammapy/gammapy/milestones{/number}","notifications_url":"https://api.github.com/repos/gammapy/gammapy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gammapy/gammapy/labels{/name}","releases_url":"https://api.github.com/repos/gammapy/gammapy/releases{/id}","deployments_url":"https://api.github.com/repos/gammapy/gammapy/deployments","created_at":"2013-05-15T07:50:40Z","updated_at":"2017-05-04T20:40:37Z","pushed_at":"2017-06-20T14:40:37Z","git_url":"git://github.com/gammapy/gammapy.git","ssh_url":"git@github.com:gammapy/gammapy.git","clone_url":"https://github.com/gammapy/gammapy.git","svn_url":"https://github.com/gammapy/gammapy","homepage":"http://docs.gammapy.org","size":8994,"stargazers_count":31,"watchers_count":31,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":59,"mirror_url":null,"open_issues_count":199,"forks":59,"open_issues":199,"watchers":31,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gammapy/gammapy/pulls/1070"},"html":{"href":"https://github.com/gammapy/gammapy/pull/1070"},"issue":{"href":"https://api.github.com/repos/gammapy/gammapy/issues/1070"},"comments":{"href":"https://api.github.com/repos/gammapy/gammapy/issues/1070/comments"},"review_comments":{"href":"https://api.github.com/repos/gammapy/gammapy/pulls/1070/comments"},"review_comment":{"href":"https://api.github.com/repos/gammapy/gammapy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gammapy/gammapy/pulls/1070/commits"},"statuses":{"href":"https://api.github.com/repos/gammapy/gammapy/statuses/55bb3a51f28f8ab7d9755c72f63ad4450ba33b65"}}}}
{"actor":{"display_login":"cdeil"}}