{"action":"created","comment":{"url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/pulls/comments/36014376","id":36014376,"diff_hunk":"@@ -0,0 +1,96 @@\n+#!/usr/bin/env python\n+#\n+# LSST Data Management System\n+# Copyright 2015 AURA/LSST\n+#\n+# This product includes software developed by the\n+# LSST Project (http://www.lsst.org/).\n+#\n+# This program is free software: you can redistribute it and/or modify\n+# it under the terms of the GNU General Public License as published by\n+# the Free Software Foundation, either version 3 of the License, or\n+# (at your option) any later version.\n+#\n+# This program is distributed in the hope that it will be useful,\n+# but WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the\n+# GNU General Public License for more details.\n+#\n+# You should have received a copy of the LSST License Statement and\n+# the GNU General Public License along with this program.  If not,\n+# see <http://www.lsstcorp.org/LegalNotices/>.\n+#\n+import argparse\n+import matplotlib.pyplot as plot\n+import math\n+import sys\n+import os.path\n+import numpy\n+import pyfits\n+\n+import lsst.afw.math as afwMath\n+import lsst.afw.table as afwTable\n+\n+\"\"\"\n+plotShearTest is a python program which is used make a applied vs. measured shear plot for\n+the shear_test_experiments simulations, and to also display error bars for the stddev's\n+calculated doing mulitple subfields with the same applied shear.\n+\n+It is assumed that previous scripts have created an analysis_file which has statistical\n+summaries of the shear and shear error as a function of seeing, filter, and applied shear.\n+\n+This program simply takes the values for a given filter and seeing, fits the points\n+to a line, and graphs the measured values and errors and the regression line.\n+\"\"\"\n+if __name__ == \"__main__\":\n+    \"\"\"\n+    This main program reads data for multiple runs in filter, seeing, and shear value, and\n+\n+    analysis_file         Name of the fits file containing the analysis data\n+    seeing                plot only runs with the specified seeing\n+    filter                plot only runs with the specified filter\n+    \"\"\"\n+\n+    parser = argparse.ArgumentParser()\n+    parser.add_argument(\"analysis_file\", type=str, help=\"Analysis fits file\")\n+    parser.add_argument(\"-f\", \"--filter\", type=int, help=\"filter to be used for plotting\", default=2)\n+    parser.add_argument(\"-s\", \"--seeing\", type=float, help=\"seeing to be used for plotting\", default=0.7)\n+    args = parser.parse_args()\n+    outSourceCat = afwTable.BaseCatalog.readFits(args.analysis_file)\n+\n+    # Keys for fetching data from the output table\n+    schema = outSourceCat.getSchema()\n+    filterKey = schema.find(\"filter\").getKey()\n+    seeingKey = schema.find(\"seeing\").getKey()\n+    shearKey = schema.find(\"shear\").getKey()\n+    nsourceKey = schema.find(\"nsource\").getKey()\n+    eAvgKey = schema.find(\"eAvg\").getKey()\n+    eStdKey = schema.find(\"eStd\").getKey()\n+    shear = []\n+    e = []\n+    eStd = []\n+\n+    # Go through the catalog and get the values requested in the plot\n+    for rec in outSourceCat:\n+        filter = rec.get(filterKey)\n+        seeing = rec.get(seeingKey)\n+        if filter == args.filter and seeing == args.seeing:\n+            shear.append(rec.get(shearKey))\n+            e.append(rec.get(eAvgKey))\n+            eStd.append(rec.get(eStdKey))\n+    shear = numpy.array(shear, dtype=float)\n+    e = numpy.array(e, dtype=float)\n+    eStd = numpy.array(eStd, dtype=float)","path":"bin/plotShearTest.py","position":83,"original_position":83,"commit_id":"f2e947f672ac1d728e8ac66ee9f228996ca0496c","original_commit_id":"f2e947f672ac1d728e8ac66ee9f228996ca0496c","user":{"login":"TallJimbo","id":1330720,"avatar_url":"https://avatars.githubusercontent.com/u/1330720?v=3","gravatar_id":"","url":"https://api.github.com/users/TallJimbo","html_url":"https://github.com/TallJimbo","followers_url":"https://api.github.com/users/TallJimbo/followers","following_url":"https://api.github.com/users/TallJimbo/following{/other_user}","gists_url":"https://api.github.com/users/TallJimbo/gists{/gist_id}","starred_url":"https://api.github.com/users/TallJimbo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TallJimbo/subscriptions","organizations_url":"https://api.github.com/users/TallJimbo/orgs","repos_url":"https://api.github.com/users/TallJimbo/repos","events_url":"https://api.github.com/users/TallJimbo/events{/privacy}","received_events_url":"https://api.github.com/users/TallJimbo/received_events","type":"User","site_admin":false},"body":"You could do this in a few lines with column array access, I think:\r\n```\r\nmask = numpy.logical_and(outSourceCat.get(filterKey) == args.filter, outSourceCat.get(seeingKey))\r\nshear = outSourceCat.get(shearKey)[mask]\r\n...\r\n```\r\nIn fact, with this approach you don't actually have to get the keys in advance to get good performance, since just asking for a column by name once is just as fast as getting a key and asking for the column by key.","created_at":"2015-07-31T20:42:46Z","updated_at":"2015-07-31T20:42:46Z","html_url":"https://github.com/lsst-dm/galaxy_shear_experiments/pull/6#discussion_r36014376","pull_request_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/pulls/comments/36014376"},"html":{"href":"https://github.com/lsst-dm/galaxy_shear_experiments/pull/6#discussion_r36014376"},"pull_request":{"href":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/pulls/6","id":41364862,"html_url":"https://github.com/lsst-dm/galaxy_shear_experiments/pull/6","diff_url":"https://github.com/lsst-dm/galaxy_shear_experiments/pull/6.diff","patch_url":"https://github.com/lsst-dm/galaxy_shear_experiments/pull/6.patch","issue_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/issues/6","number":6,"state":"open","locked":false,"title":"Review for u/pgee/DM-2666: analysis scripts for shear experiments","user":{"login":"TallJimbo","id":1330720,"avatar_url":"https://avatars.githubusercontent.com/u/1330720?v=3","gravatar_id":"","url":"https://api.github.com/users/TallJimbo","html_url":"https://github.com/TallJimbo","followers_url":"https://api.github.com/users/TallJimbo/followers","following_url":"https://api.github.com/users/TallJimbo/following{/other_user}","gists_url":"https://api.github.com/users/TallJimbo/gists{/gist_id}","starred_url":"https://api.github.com/users/TallJimbo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TallJimbo/subscriptions","organizations_url":"https://api.github.com/users/TallJimbo/orgs","repos_url":"https://api.github.com/users/TallJimbo/repos","events_url":"https://api.github.com/users/TallJimbo/events{/privacy}","received_events_url":"https://api.github.com/users/TallJimbo/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-31T18:02:17Z","updated_at":"2015-07-31T20:42:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"106bb9224a472b6edec20f5b99a0ba51d90d0869","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/pulls/6/commits","review_comments_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/pulls/6/comments","review_comment_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/issues/6/comments","statuses_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/statuses/f2e947f672ac1d728e8ac66ee9f228996ca0496c","head":{"label":"lsst-dm:u/pgee/DM-2666","ref":"u/pgee/DM-2666","sha":"f2e947f672ac1d728e8ac66ee9f228996ca0496c","user":{"login":"lsst-dm","id":10968870,"avatar_url":"https://avatars.githubusercontent.com/u/10968870?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst-dm","html_url":"https://github.com/lsst-dm","followers_url":"https://api.github.com/users/lsst-dm/followers","following_url":"https://api.github.com/users/lsst-dm/following{/other_user}","gists_url":"https://api.github.com/users/lsst-dm/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst-dm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst-dm/subscriptions","organizations_url":"https://api.github.com/users/lsst-dm/orgs","repos_url":"https://api.github.com/users/lsst-dm/repos","events_url":"https://api.github.com/users/lsst-dm/events{/privacy}","received_events_url":"https://api.github.com/users/lsst-dm/received_events","type":"Organization","site_admin":false},"repo":{"id":33372905,"name":"galaxy_shear_experiments","full_name":"lsst-dm/galaxy_shear_experiments","owner":{"login":"lsst-dm","id":10968870,"avatar_url":"https://avatars.githubusercontent.com/u/10968870?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst-dm","html_url":"https://github.com/lsst-dm","followers_url":"https://api.github.com/users/lsst-dm/followers","following_url":"https://api.github.com/users/lsst-dm/following{/other_user}","gists_url":"https://api.github.com/users/lsst-dm/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst-dm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst-dm/subscriptions","organizations_url":"https://api.github.com/users/lsst-dm/orgs","repos_url":"https://api.github.com/users/lsst-dm/repos","events_url":"https://api.github.com/users/lsst-dm/events{/privacy}","received_events_url":"https://api.github.com/users/lsst-dm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lsst-dm/galaxy_shear_experiments","description":"","fork":false,"url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments","forks_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/forks","keys_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/teams","hooks_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/hooks","issue_events_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/issues/events{/number}","events_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/events","assignees_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/assignees{/user}","branches_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/branches{/branch}","tags_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/tags","blobs_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/git/refs{/sha}","trees_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/statuses/{sha}","languages_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/languages","stargazers_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/stargazers","contributors_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/contributors","subscribers_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/subscribers","subscription_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/subscription","commits_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/commits{/sha}","git_commits_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/git/commits{/sha}","comments_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/comments{/number}","issue_comment_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/issues/comments{/number}","contents_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/contents/{+path}","compare_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/merges","archive_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/downloads","issues_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/issues{/number}","pulls_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/pulls{/number}","milestones_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/milestones{/number}","notifications_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/labels{/name}","releases_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/releases{/id}","created_at":"2015-04-03T16:53:11Z","updated_at":"2015-05-30T04:11:38Z","pushed_at":"2015-07-31T18:02:17Z","git_url":"git://github.com/lsst-dm/galaxy_shear_experiments.git","ssh_url":"git@github.com:lsst-dm/galaxy_shear_experiments.git","clone_url":"https://github.com/lsst-dm/galaxy_shear_experiments.git","svn_url":"https://github.com/lsst-dm/galaxy_shear_experiments","homepage":null,"size":9328,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"lsst-dm:master","ref":"master","sha":"6c462554dfc6987e5cdb39c63f21206c7dfa1b4f","user":{"login":"lsst-dm","id":10968870,"avatar_url":"https://avatars.githubusercontent.com/u/10968870?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst-dm","html_url":"https://github.com/lsst-dm","followers_url":"https://api.github.com/users/lsst-dm/followers","following_url":"https://api.github.com/users/lsst-dm/following{/other_user}","gists_url":"https://api.github.com/users/lsst-dm/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst-dm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst-dm/subscriptions","organizations_url":"https://api.github.com/users/lsst-dm/orgs","repos_url":"https://api.github.com/users/lsst-dm/repos","events_url":"https://api.github.com/users/lsst-dm/events{/privacy}","received_events_url":"https://api.github.com/users/lsst-dm/received_events","type":"Organization","site_admin":false},"repo":{"id":33372905,"name":"galaxy_shear_experiments","full_name":"lsst-dm/galaxy_shear_experiments","owner":{"login":"lsst-dm","id":10968870,"avatar_url":"https://avatars.githubusercontent.com/u/10968870?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst-dm","html_url":"https://github.com/lsst-dm","followers_url":"https://api.github.com/users/lsst-dm/followers","following_url":"https://api.github.com/users/lsst-dm/following{/other_user}","gists_url":"https://api.github.com/users/lsst-dm/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst-dm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst-dm/subscriptions","organizations_url":"https://api.github.com/users/lsst-dm/orgs","repos_url":"https://api.github.com/users/lsst-dm/repos","events_url":"https://api.github.com/users/lsst-dm/events{/privacy}","received_events_url":"https://api.github.com/users/lsst-dm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lsst-dm/galaxy_shear_experiments","description":"","fork":false,"url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments","forks_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/forks","keys_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/teams","hooks_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/hooks","issue_events_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/issues/events{/number}","events_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/events","assignees_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/assignees{/user}","branches_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/branches{/branch}","tags_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/tags","blobs_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/git/refs{/sha}","trees_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/statuses/{sha}","languages_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/languages","stargazers_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/stargazers","contributors_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/contributors","subscribers_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/subscribers","subscription_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/subscription","commits_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/commits{/sha}","git_commits_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/git/commits{/sha}","comments_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/comments{/number}","issue_comment_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/issues/comments{/number}","contents_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/contents/{+path}","compare_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/merges","archive_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/downloads","issues_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/issues{/number}","pulls_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/pulls{/number}","milestones_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/milestones{/number}","notifications_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/labels{/name}","releases_url":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/releases{/id}","created_at":"2015-04-03T16:53:11Z","updated_at":"2015-05-30T04:11:38Z","pushed_at":"2015-07-31T18:02:17Z","git_url":"git://github.com/lsst-dm/galaxy_shear_experiments.git","ssh_url":"git@github.com:lsst-dm/galaxy_shear_experiments.git","clone_url":"https://github.com/lsst-dm/galaxy_shear_experiments.git","svn_url":"https://github.com/lsst-dm/galaxy_shear_experiments","homepage":null,"size":9328,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/pulls/6"},"html":{"href":"https://github.com/lsst-dm/galaxy_shear_experiments/pull/6"},"issue":{"href":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/issues/6"},"comments":{"href":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/lsst-dm/galaxy_shear_experiments/statuses/f2e947f672ac1d728e8ac66ee9f228996ca0496c"}}}}