{"action":"created","comment":{"url":"https://api.github.com/repos/astropy/specutils/pulls/comments/212945104","pull_request_review_id":149674831,"id":212945104,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMjk0NTEwNA==","diff_hunk":"@@ -205,4 +205,128 @@ def test_snr_single_region_with_noise_region(simulated_spectra):\n \n     assert np.allclose(spec_snr.value, spec_snr_expected.value)\n \n+# --\n+\n+def test_centroid(simulated_spectra):\n+    \"\"\"\n+    Test the simple version of the spectral centroid.\n+    \"\"\"\n+\n+    np.random.seed(42)\n+\n+    #\n+    #  Set up the data and add the uncertainty and calculate the expected SNR\n+    #\n+\n+    spectrum = simulated_spectra.s1_um_mJy_e1\n+    uncertainty = StdDevUncertainty(0.1*np.random.random(len(spectrum.flux))*u.mJy)\n+    spectrum.uncertainty = uncertainty\n+\n+    wavelengths = spectrum.spectral_axis\n+    flux = spectrum.flux\n+\n+    spec_centroid_expected = np.sum(flux * wavelengths) / np.sum(flux)\n+\n+    #\n+    # SNR of the whole spectrum\n+    #\n+\n+    spec_centroid = centroid(spectrum)\n+\n+    assert isinstance(spec_centroid, u.Quantity)\n+    assert np.allclose(spec_centroid.value, spec_centroid_expected.value)\n+\n+\n+def test_snr_multiple_flux(simulated_spectra):\n+    \"\"\"\n+    Test the simple version of the spectral SNR, with multiple flux per single dispersion.\n+    \"\"\"\n+\n+    #\n+    #  Set up the data and add the uncertainty and calculate the expected SNR\n+    #\n+\n+    np.random.seed(42)\n \n+    spec = Spectrum1D(spectral_axis=np.arange(10) * u.um,\n+                      flux=np.random.sample((10, 5)) * u.Jy)\n+\n+    centroid_spec = centroid(spec)\n+\n+    assert np.allclose(centroid_spec.value, np.array([5.39321967, 3.6856305 , 3.09779811, 4.99442161, 4.50267016]))\n+    assert centroid_spec.unit == u.um\n+\n+\n+# def test_snr_single_region(simulated_spectra):","path":"specutils/tests/test_analysis.py","position":74,"original_position":74,"commit_id":"af7433e79ccd1be9902fe3b10d72a826b75a4780","original_commit_id":"af7433e79ccd1be9902fe3b10d72a826b75a4780","user":{"login":"brechmos-stsci","id":18348847,"node_id":"MDQ6VXNlcjE4MzQ4ODQ3","avatar_url":"https://avatars1.githubusercontent.com/u/18348847?v=4","gravatar_id":"","url":"https://api.github.com/users/brechmos-stsci","html_url":"https://github.com/brechmos-stsci","followers_url":"https://api.github.com/users/brechmos-stsci/followers","following_url":"https://api.github.com/users/brechmos-stsci/following{/other_user}","gists_url":"https://api.github.com/users/brechmos-stsci/gists{/gist_id}","starred_url":"https://api.github.com/users/brechmos-stsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brechmos-stsci/subscriptions","organizations_url":"https://api.github.com/users/brechmos-stsci/orgs","repos_url":"https://api.github.com/users/brechmos-stsci/repos","events_url":"https://api.github.com/users/brechmos-stsci/events{/privacy}","received_events_url":"https://api.github.com/users/brechmos-stsci/received_events","type":"User","site_admin":false},"body":"It was because of the bug in specutils of slicing a spectrum.  I will mark xfail","created_at":"2018-08-27T11:33:29Z","updated_at":"2018-08-27T11:33:29Z","html_url":"https://github.com/astropy/specutils/pull/270#discussion_r212945104","pull_request_url":"https://api.github.com/repos/astropy/specutils/pulls/270","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/astropy/specutils/pulls/comments/212945104"},"html":{"href":"https://github.com/astropy/specutils/pull/270#discussion_r212945104"},"pull_request":{"href":"https://api.github.com/repos/astropy/specutils/pulls/270"}},"in_reply_to_id":212735924},"pull_request":{"url":"https://api.github.com/repos/astropy/specutils/pulls/270","id":207405513,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3NDA1NTEz","html_url":"https://github.com/astropy/specutils/pull/270","diff_url":"https://github.com/astropy/specutils/pull/270.diff","patch_url":"https://github.com/astropy/specutils/pull/270.patch","issue_url":"https://api.github.com/repos/astropy/specutils/issues/270","number":270,"state":"open","locked":false,"title":"Centroid calculation","user":{"login":"brechmos-stsci","id":18348847,"node_id":"MDQ6VXNlcjE4MzQ4ODQ3","avatar_url":"https://avatars1.githubusercontent.com/u/18348847?v=4","gravatar_id":"","url":"https://api.github.com/users/brechmos-stsci","html_url":"https://github.com/brechmos-stsci","followers_url":"https://api.github.com/users/brechmos-stsci/followers","following_url":"https://api.github.com/users/brechmos-stsci/following{/other_user}","gists_url":"https://api.github.com/users/brechmos-stsci/gists{/gist_id}","starred_url":"https://api.github.com/users/brechmos-stsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brechmos-stsci/subscriptions","organizations_url":"https://api.github.com/users/brechmos-stsci/orgs","repos_url":"https://api.github.com/users/brechmos-stsci/repos","events_url":"https://api.github.com/users/brechmos-stsci/events{/privacy}","received_events_url":"https://api.github.com/users/brechmos-stsci/received_events","type":"User","site_admin":false},"body":"Calculate the centroid of a spectrum.  This follows the same format of the SNR code structure and will work for regions with in the spectrum as well as a Spectrum1D object that is many-flux, one-dispersion.\r\n\r\nFixes #236\r\n\r\n(work in progress: few more code changes possibly needed, couple more tests and documentation).","created_at":"2018-08-09T18:35:03Z","updated_at":"2018-08-27T11:33:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cbc0633fd319fc66abdf335705279da7df7eb436","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/astropy/specutils/pulls/270/commits","review_comments_url":"https://api.github.com/repos/astropy/specutils/pulls/270/comments","review_comment_url":"https://api.github.com/repos/astropy/specutils/pulls/comments{/number}","comments_url":"https://api.github.com/repos/astropy/specutils/issues/270/comments","statuses_url":"https://api.github.com/repos/astropy/specutils/statuses/af7433e79ccd1be9902fe3b10d72a826b75a4780","head":{"label":"brechmos-stsci:centroid-measures","ref":"centroid-measures","sha":"af7433e79ccd1be9902fe3b10d72a826b75a4780","user":{"login":"brechmos-stsci","id":18348847,"node_id":"MDQ6VXNlcjE4MzQ4ODQ3","avatar_url":"https://avatars1.githubusercontent.com/u/18348847?v=4","gravatar_id":"","url":"https://api.github.com/users/brechmos-stsci","html_url":"https://github.com/brechmos-stsci","followers_url":"https://api.github.com/users/brechmos-stsci/followers","following_url":"https://api.github.com/users/brechmos-stsci/following{/other_user}","gists_url":"https://api.github.com/users/brechmos-stsci/gists{/gist_id}","starred_url":"https://api.github.com/users/brechmos-stsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brechmos-stsci/subscriptions","organizations_url":"https://api.github.com/users/brechmos-stsci/orgs","repos_url":"https://api.github.com/users/brechmos-stsci/repos","events_url":"https://api.github.com/users/brechmos-stsci/events{/privacy}","received_events_url":"https://api.github.com/users/brechmos-stsci/received_events","type":"User","site_admin":false},"repo":{"id":133566919,"node_id":"MDEwOlJlcG9zaXRvcnkxMzM1NjY5MTk=","name":"specutils","full_name":"brechmos-stsci/specutils","owner":{"login":"brechmos-stsci","id":18348847,"node_id":"MDQ6VXNlcjE4MzQ4ODQ3","avatar_url":"https://avatars1.githubusercontent.com/u/18348847?v=4","gravatar_id":"","url":"https://api.github.com/users/brechmos-stsci","html_url":"https://github.com/brechmos-stsci","followers_url":"https://api.github.com/users/brechmos-stsci/followers","following_url":"https://api.github.com/users/brechmos-stsci/following{/other_user}","gists_url":"https://api.github.com/users/brechmos-stsci/gists{/gist_id}","starred_url":"https://api.github.com/users/brechmos-stsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brechmos-stsci/subscriptions","organizations_url":"https://api.github.com/users/brechmos-stsci/orgs","repos_url":"https://api.github.com/users/brechmos-stsci/repos","events_url":"https://api.github.com/users/brechmos-stsci/events{/privacy}","received_events_url":"https://api.github.com/users/brechmos-stsci/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/brechmos-stsci/specutils","description":"Affiliated package for 1D spectral operations. Maintainer: @crawfordsm @keflavich @nmearl","fork":true,"url":"https://api.github.com/repos/brechmos-stsci/specutils","forks_url":"https://api.github.com/repos/brechmos-stsci/specutils/forks","keys_url":"https://api.github.com/repos/brechmos-stsci/specutils/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brechmos-stsci/specutils/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brechmos-stsci/specutils/teams","hooks_url":"https://api.github.com/repos/brechmos-stsci/specutils/hooks","issue_events_url":"https://api.github.com/repos/brechmos-stsci/specutils/issues/events{/number}","events_url":"https://api.github.com/repos/brechmos-stsci/specutils/events","assignees_url":"https://api.github.com/repos/brechmos-stsci/specutils/assignees{/user}","branches_url":"https://api.github.com/repos/brechmos-stsci/specutils/branches{/branch}","tags_url":"https://api.github.com/repos/brechmos-stsci/specutils/tags","blobs_url":"https://api.github.com/repos/brechmos-stsci/specutils/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brechmos-stsci/specutils/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brechmos-stsci/specutils/git/refs{/sha}","trees_url":"https://api.github.com/repos/brechmos-stsci/specutils/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brechmos-stsci/specutils/statuses/{sha}","languages_url":"https://api.github.com/repos/brechmos-stsci/specutils/languages","stargazers_url":"https://api.github.com/repos/brechmos-stsci/specutils/stargazers","contributors_url":"https://api.github.com/repos/brechmos-stsci/specutils/contributors","subscribers_url":"https://api.github.com/repos/brechmos-stsci/specutils/subscribers","subscription_url":"https://api.github.com/repos/brechmos-stsci/specutils/subscription","commits_url":"https://api.github.com/repos/brechmos-stsci/specutils/commits{/sha}","git_commits_url":"https://api.github.com/repos/brechmos-stsci/specutils/git/commits{/sha}","comments_url":"https://api.github.com/repos/brechmos-stsci/specutils/comments{/number}","issue_comment_url":"https://api.github.com/repos/brechmos-stsci/specutils/issues/comments{/number}","contents_url":"https://api.github.com/repos/brechmos-stsci/specutils/contents/{+path}","compare_url":"https://api.github.com/repos/brechmos-stsci/specutils/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brechmos-stsci/specutils/merges","archive_url":"https://api.github.com/repos/brechmos-stsci/specutils/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brechmos-stsci/specutils/downloads","issues_url":"https://api.github.com/repos/brechmos-stsci/specutils/issues{/number}","pulls_url":"https://api.github.com/repos/brechmos-stsci/specutils/pulls{/number}","milestones_url":"https://api.github.com/repos/brechmos-stsci/specutils/milestones{/number}","notifications_url":"https://api.github.com/repos/brechmos-stsci/specutils/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brechmos-stsci/specutils/labels{/name}","releases_url":"https://api.github.com/repos/brechmos-stsci/specutils/releases{/id}","deployments_url":"https://api.github.com/repos/brechmos-stsci/specutils/deployments","created_at":"2018-05-15T20:01:02Z","updated_at":"2018-08-22T15:42:49Z","pushed_at":"2018-08-24T16:56:45Z","git_url":"git://github.com/brechmos-stsci/specutils.git","ssh_url":"git@github.com:brechmos-stsci/specutils.git","clone_url":"https://github.com/brechmos-stsci/specutils.git","svn_url":"https://github.com/brechmos-stsci/specutils","homepage":"http://specutils.readthedocs.io/en/latest/","size":4898,"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,"archived":false,"open_issues_count":1,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"astropy:master","ref":"master","sha":"6e55d62db72a89ecae4e5ee841db454a69fd8244","user":{"login":"astropy","id":847984,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg0Nzk4NA==","avatar_url":"https://avatars0.githubusercontent.com/u/847984?v=4","gravatar_id":"","url":"https://api.github.com/users/astropy","html_url":"https://github.com/astropy","followers_url":"https://api.github.com/users/astropy/followers","following_url":"https://api.github.com/users/astropy/following{/other_user}","gists_url":"https://api.github.com/users/astropy/gists{/gist_id}","starred_url":"https://api.github.com/users/astropy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astropy/subscriptions","organizations_url":"https://api.github.com/users/astropy/orgs","repos_url":"https://api.github.com/users/astropy/repos","events_url":"https://api.github.com/users/astropy/events{/privacy}","received_events_url":"https://api.github.com/users/astropy/received_events","type":"Organization","site_admin":false},"repo":{"id":2577269,"node_id":"MDEwOlJlcG9zaXRvcnkyNTc3MjY5","name":"specutils","full_name":"astropy/specutils","owner":{"login":"astropy","id":847984,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg0Nzk4NA==","avatar_url":"https://avatars0.githubusercontent.com/u/847984?v=4","gravatar_id":"","url":"https://api.github.com/users/astropy","html_url":"https://github.com/astropy","followers_url":"https://api.github.com/users/astropy/followers","following_url":"https://api.github.com/users/astropy/following{/other_user}","gists_url":"https://api.github.com/users/astropy/gists{/gist_id}","starred_url":"https://api.github.com/users/astropy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astropy/subscriptions","organizations_url":"https://api.github.com/users/astropy/orgs","repos_url":"https://api.github.com/users/astropy/repos","events_url":"https://api.github.com/users/astropy/events{/privacy}","received_events_url":"https://api.github.com/users/astropy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/astropy/specutils","description":"Affiliated package for 1D spectral operations. Maintainers: @nmearl @crawfordsm @keflavich @eteq","fork":false,"url":"https://api.github.com/repos/astropy/specutils","forks_url":"https://api.github.com/repos/astropy/specutils/forks","keys_url":"https://api.github.com/repos/astropy/specutils/keys{/key_id}","collaborators_url":"https://api.github.com/repos/astropy/specutils/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/astropy/specutils/teams","hooks_url":"https://api.github.com/repos/astropy/specutils/hooks","issue_events_url":"https://api.github.com/repos/astropy/specutils/issues/events{/number}","events_url":"https://api.github.com/repos/astropy/specutils/events","assignees_url":"https://api.github.com/repos/astropy/specutils/assignees{/user}","branches_url":"https://api.github.com/repos/astropy/specutils/branches{/branch}","tags_url":"https://api.github.com/repos/astropy/specutils/tags","blobs_url":"https://api.github.com/repos/astropy/specutils/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/astropy/specutils/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/astropy/specutils/git/refs{/sha}","trees_url":"https://api.github.com/repos/astropy/specutils/git/trees{/sha}","statuses_url":"https://api.github.com/repos/astropy/specutils/statuses/{sha}","languages_url":"https://api.github.com/repos/astropy/specutils/languages","stargazers_url":"https://api.github.com/repos/astropy/specutils/stargazers","contributors_url":"https://api.github.com/repos/astropy/specutils/contributors","subscribers_url":"https://api.github.com/repos/astropy/specutils/subscribers","subscription_url":"https://api.github.com/repos/astropy/specutils/subscription","commits_url":"https://api.github.com/repos/astropy/specutils/commits{/sha}","git_commits_url":"https://api.github.com/repos/astropy/specutils/git/commits{/sha}","comments_url":"https://api.github.com/repos/astropy/specutils/comments{/number}","issue_comment_url":"https://api.github.com/repos/astropy/specutils/issues/comments{/number}","contents_url":"https://api.github.com/repos/astropy/specutils/contents/{+path}","compare_url":"https://api.github.com/repos/astropy/specutils/compare/{base}...{head}","merges_url":"https://api.github.com/repos/astropy/specutils/merges","archive_url":"https://api.github.com/repos/astropy/specutils/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/astropy/specutils/downloads","issues_url":"https://api.github.com/repos/astropy/specutils/issues{/number}","pulls_url":"https://api.github.com/repos/astropy/specutils/pulls{/number}","milestones_url":"https://api.github.com/repos/astropy/specutils/milestones{/number}","notifications_url":"https://api.github.com/repos/astropy/specutils/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/astropy/specutils/labels{/name}","releases_url":"https://api.github.com/repos/astropy/specutils/releases{/id}","deployments_url":"https://api.github.com/repos/astropy/specutils/deployments","created_at":"2011-10-14T16:11:38Z","updated_at":"2018-08-21T18:46:49Z","pushed_at":"2018-08-27T06:17:55Z","git_url":"git://github.com/astropy/specutils.git","ssh_url":"git@github.com:astropy/specutils.git","clone_url":"https://github.com/astropy/specutils.git","svn_url":"https://github.com/astropy/specutils","homepage":"http://specutils.readthedocs.io/en/latest/","size":4746,"stargazers_count":54,"watchers_count":54,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":63,"mirror_url":null,"archived":false,"open_issues_count":78,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":63,"open_issues":78,"watchers":54,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/astropy/specutils/pulls/270"},"html":{"href":"https://github.com/astropy/specutils/pull/270"},"issue":{"href":"https://api.github.com/repos/astropy/specutils/issues/270"},"comments":{"href":"https://api.github.com/repos/astropy/specutils/issues/270/comments"},"review_comments":{"href":"https://api.github.com/repos/astropy/specutils/pulls/270/comments"},"review_comment":{"href":"https://api.github.com/repos/astropy/specutils/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/astropy/specutils/pulls/270/commits"},"statuses":{"href":"https://api.github.com/repos/astropy/specutils/statuses/af7433e79ccd1be9902fe3b10d72a826b75a4780"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"brechmos-stsci"}}