{"action":"created","comment":{"url":"https://api.github.com/repos/lsst/ip_diffim/pulls/comments/68680774","id":68680774,"diff_hunk":"@@ -52,188 +54,211 @@ def computeClippedImageStats(im):\n     return mean, std, var\n \n \n-def getImageGrid(im):\n-    \"\"\"! Convenience function for creating a grid of pixel coordinates covering a 2-d array,\n-    using `numpy.meshgrid()`\n-    @param im input 2-d numpy array\n-    @return two numpy arraysm each with same shape as `im`, containing x- and y- coordinate\n-    grid.\n-    \"\"\"\n-    xim = np.arange(np.int(-np.floor(im.shape[0]/2.)), np.int(np.floor(im.shape[0]/2)))\n-    yim = np.arange(np.int(-np.floor(im.shape[1]/2.)), np.int(np.floor(im.shape[1]/2)))\n-    x0im, y0im = np.meshgrid(xim, yim)\n-    return x0im, y0im\n+class ImageDecorrelationConfig(pexConfig.Config):\n+    \"\"\"! Configuration for image decorrelation\"\"\"\n+    useScipy = pexConfig.Field(\n+        dtype = bool,\n+        doc = \"\"\"If True use scipy for image convolution (debugging option);\n+                 if False use afwMath\"\"\",\n+        default = False\n+    )\n \n \n-def computeDecorrelationKernel(kappa, sig1=0.2, sig2=0.2):\n-    \"\"\"! Compute the Lupton/ZOGY post-conv. kernel for decorrelating an\n-    image difference, based on the PSF-matching kernel.\n-    @param kappa  A matching kernel 2-d numpy.array derived from Alard & Lupton PSF matching\n-    @param sig1   Average sqrt(variance) of template image used for PSF matching\n-    @param sig2   Average sqrt(variance) of science image used for PSF matching\n-    @return a 2-d numpy.array containing the correction kernel\n+class ImageDecorrelationTask(pipeBase.Task):\n+    \"\"\"! pipeBase.Task subclass for running decorrelation on an image difference Exposure.\n \n-    @note As currently implemented, kappa is a static (single) kernel.\n+    Primarily designed for use in imageDifference.py in pipe_base.\n     \"\"\"\n-    kft = fft2(kappa)\n-    kft = np.sqrt((sig1**2 + sig2**2) / (sig1**2 + sig2**2 * kft**2))\n-    pck = ifft2(kft)\n-    pck = ifftshift(pck.real)\n-\n-    # I think we may need to \"reverse\" the PSF, as in the ZOGY (and Kaiser) papers...\n-    # This is the same as taking the complex conjugate in Fourier space before FFT-ing back to real space.\n-    if False:  # TBD: figure this out. For now, we are turning it off.\n-        pck = pck[::-1, :]\n-\n-    return pck\n-\n-\n-def computeCorrectedDiffimPsf(kappa, im2_psf, sig1=0.2, sig2=0.2):\n-    \"\"\"! Compute the (decorrelated) difference image's new PSF.\n-    new_psf = phi_1(k) * sqrt((sig1**2 + sig2**2) / (sig1**2 + sig2**2 * kappa_ft(k)**2))\n-\n-    @param kappa  A matching kernel array derived from Alard & Lupton PSF matching\n-    @param im2_psf The uncorrected psf array of the science image (and also of the diffim)\n-    @param sig1   Average sqrt(variance) of template image used for PSF matching\n-    @param sig2   Average sqrt(variance) of science image used for PSF matching\n-    @return a 2-d numpy.array containing the new PSF\n-    \"\"\"\n-    def post_conv_psf_ft2(psf, kernel, sig1=1., sig2=1.):\n-        # Pad psf or kernel symmetrically to make them the same size!\n-        # Note this assumes they are both square (width == height)\n-        if psf.shape[0] < kernel.shape[0]:\n-            diff = (kernel.shape[0] - psf.shape[0]) // 2\n-            psf = np.pad(psf, (diff, diff), mode='constant')\n-        elif psf.shape[0] > kernel.shape[0]:\n-            diff = (psf.shape[0] - kernel.shape[0]) // 2\n-            kernel = np.pad(kernel, (diff, diff), mode='constant')\n-        psf_ft = fft2(psf)\n-        kft = fft2(kernel)\n-        out = psf_ft * np.sqrt((sig1**2 + sig2**2) / (sig1**2 + sig2**2 * kft**2))\n-        return out\n-\n-    def post_conv_psf(psf, kernel, sig1=1., sig2=1.):\n-        kft = post_conv_psf_ft2(psf, kernel, sig1, sig2)\n-        out = ifft2(kft)\n+    ConfigClass = ImageDecorrelationConfig\n+    _DefaultName = \"imageDecorrelation\"\n+\n+    def __init__(self, *args, **kwargs):\n+        \"\"\"! Create the image decorrelation Task\n+        @param *args arguments to be passed to lsst.pipe.base.task.Task.__init__\n+        @param **kwargs keyword arguments to be passed to lsst.pipe.base.task.Task.__init__\n+        \"\"\"\n+        pipeBase.Task.__init__(self, *args, **kwargs)\n+\n+    def decorrelateExposure(self, templateExposure, exposure, subtractedExposure, psfMatchingKernel):","path":"python/lsst/ip/diffim/imageDecorrelation.py","position":114,"original_position":114,"commit_id":"2377ae04ef50961240fdeadd0b111948e210af2e","original_commit_id":"2377ae04ef50961240fdeadd0b111948e210af2e","user":{"login":"r-owen","id":874176,"avatar_url":"https://avatars.githubusercontent.com/u/874176?v=3","gravatar_id":"","url":"https://api.github.com/users/r-owen","html_url":"https://github.com/r-owen","followers_url":"https://api.github.com/users/r-owen/followers","following_url":"https://api.github.com/users/r-owen/following{/other_user}","gists_url":"https://api.github.com/users/r-owen/gists{/gist_id}","starred_url":"https://api.github.com/users/r-owen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/r-owen/subscriptions","organizations_url":"https://api.github.com/users/r-owen/orgs","repos_url":"https://api.github.com/users/r-owen/repos","events_url":"https://api.github.com/users/r-owen/events{/privacy}","received_events_url":"https://api.github.com/users/r-owen/received_events","type":"User","site_admin":false},"body":"If this is the primary method of the task then please call it \"run\"","created_at":"2016-06-28T00:35:35Z","updated_at":"2016-06-28T00:35:35Z","html_url":"https://github.com/lsst/ip_diffim/pull/25#discussion_r68680774","pull_request_url":"https://api.github.com/repos/lsst/ip_diffim/pulls/25","_links":{"self":{"href":"https://api.github.com/repos/lsst/ip_diffim/pulls/comments/68680774"},"html":{"href":"https://github.com/lsst/ip_diffim/pull/25#discussion_r68680774"},"pull_request":{"href":"https://api.github.com/repos/lsst/ip_diffim/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/lsst/ip_diffim/pulls/25","id":75036492,"html_url":"https://github.com/lsst/ip_diffim/pull/25","diff_url":"https://github.com/lsst/ip_diffim/pull/25.diff","patch_url":"https://github.com/lsst/ip_diffim/pull/25.patch","issue_url":"https://api.github.com/repos/lsst/ip_diffim/issues/25","number":25,"state":"open","locked":false,"title":"Add ImageDecorrelationTask","user":{"login":"djreiss","id":512257,"avatar_url":"https://avatars.githubusercontent.com/u/512257?v=3","gravatar_id":"","url":"https://api.github.com/users/djreiss","html_url":"https://github.com/djreiss","followers_url":"https://api.github.com/users/djreiss/followers","following_url":"https://api.github.com/users/djreiss/following{/other_user}","gists_url":"https://api.github.com/users/djreiss/gists{/gist_id}","starred_url":"https://api.github.com/users/djreiss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djreiss/subscriptions","organizations_url":"https://api.github.com/users/djreiss/orgs","repos_url":"https://api.github.com/users/djreiss/repos","events_url":"https://api.github.com/users/djreiss/events{/privacy}","received_events_url":"https://api.github.com/users/djreiss/received_events","type":"User","site_admin":false},"body":"move utility functions into task","created_at":"2016-06-23T22:15:17Z","updated_at":"2016-06-28T00:35:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0effb69b922e973255635fec3e43b4555fccf039","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/lsst/ip_diffim/pulls/25/commits","review_comments_url":"https://api.github.com/repos/lsst/ip_diffim/pulls/25/comments","review_comment_url":"https://api.github.com/repos/lsst/ip_diffim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lsst/ip_diffim/issues/25/comments","statuses_url":"https://api.github.com/repos/lsst/ip_diffim/statuses/2377ae04ef50961240fdeadd0b111948e210af2e","head":{"label":"lsst:tickets/DM-6628","ref":"tickets/DM-6628","sha":"2377ae04ef50961240fdeadd0b111948e210af2e","user":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"repo":{"id":23013321,"name":"ip_diffim","full_name":"lsst/ip_diffim","owner":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lsst/ip_diffim","description":"LSST data management: astronomical image differencing","fork":false,"url":"https://api.github.com/repos/lsst/ip_diffim","forks_url":"https://api.github.com/repos/lsst/ip_diffim/forks","keys_url":"https://api.github.com/repos/lsst/ip_diffim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lsst/ip_diffim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lsst/ip_diffim/teams","hooks_url":"https://api.github.com/repos/lsst/ip_diffim/hooks","issue_events_url":"https://api.github.com/repos/lsst/ip_diffim/issues/events{/number}","events_url":"https://api.github.com/repos/lsst/ip_diffim/events","assignees_url":"https://api.github.com/repos/lsst/ip_diffim/assignees{/user}","branches_url":"https://api.github.com/repos/lsst/ip_diffim/branches{/branch}","tags_url":"https://api.github.com/repos/lsst/ip_diffim/tags","blobs_url":"https://api.github.com/repos/lsst/ip_diffim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lsst/ip_diffim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lsst/ip_diffim/git/refs{/sha}","trees_url":"https://api.github.com/repos/lsst/ip_diffim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lsst/ip_diffim/statuses/{sha}","languages_url":"https://api.github.com/repos/lsst/ip_diffim/languages","stargazers_url":"https://api.github.com/repos/lsst/ip_diffim/stargazers","contributors_url":"https://api.github.com/repos/lsst/ip_diffim/contributors","subscribers_url":"https://api.github.com/repos/lsst/ip_diffim/subscribers","subscription_url":"https://api.github.com/repos/lsst/ip_diffim/subscription","commits_url":"https://api.github.com/repos/lsst/ip_diffim/commits{/sha}","git_commits_url":"https://api.github.com/repos/lsst/ip_diffim/git/commits{/sha}","comments_url":"https://api.github.com/repos/lsst/ip_diffim/comments{/number}","issue_comment_url":"https://api.github.com/repos/lsst/ip_diffim/issues/comments{/number}","contents_url":"https://api.github.com/repos/lsst/ip_diffim/contents/{+path}","compare_url":"https://api.github.com/repos/lsst/ip_diffim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lsst/ip_diffim/merges","archive_url":"https://api.github.com/repos/lsst/ip_diffim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lsst/ip_diffim/downloads","issues_url":"https://api.github.com/repos/lsst/ip_diffim/issues{/number}","pulls_url":"https://api.github.com/repos/lsst/ip_diffim/pulls{/number}","milestones_url":"https://api.github.com/repos/lsst/ip_diffim/milestones{/number}","notifications_url":"https://api.github.com/repos/lsst/ip_diffim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lsst/ip_diffim/labels{/name}","releases_url":"https://api.github.com/repos/lsst/ip_diffim/releases{/id}","deployments_url":"https://api.github.com/repos/lsst/ip_diffim/deployments","created_at":"2014-08-16T07:44:12Z","updated_at":"2016-04-11T22:01:34Z","pushed_at":"2016-06-23T22:15:17Z","git_url":"git://github.com/lsst/ip_diffim.git","ssh_url":"git@github.com:lsst/ip_diffim.git","clone_url":"https://github.com/lsst/ip_diffim.git","svn_url":"https://github.com/lsst/ip_diffim","homepage":"http://dm.lsst.org/","size":16211,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"lsst:master","ref":"master","sha":"22a0fd2b8b03bbd095e9829b0d00b4c1723bee76","user":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"repo":{"id":23013321,"name":"ip_diffim","full_name":"lsst/ip_diffim","owner":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lsst/ip_diffim","description":"LSST data management: astronomical image differencing","fork":false,"url":"https://api.github.com/repos/lsst/ip_diffim","forks_url":"https://api.github.com/repos/lsst/ip_diffim/forks","keys_url":"https://api.github.com/repos/lsst/ip_diffim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lsst/ip_diffim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lsst/ip_diffim/teams","hooks_url":"https://api.github.com/repos/lsst/ip_diffim/hooks","issue_events_url":"https://api.github.com/repos/lsst/ip_diffim/issues/events{/number}","events_url":"https://api.github.com/repos/lsst/ip_diffim/events","assignees_url":"https://api.github.com/repos/lsst/ip_diffim/assignees{/user}","branches_url":"https://api.github.com/repos/lsst/ip_diffim/branches{/branch}","tags_url":"https://api.github.com/repos/lsst/ip_diffim/tags","blobs_url":"https://api.github.com/repos/lsst/ip_diffim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lsst/ip_diffim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lsst/ip_diffim/git/refs{/sha}","trees_url":"https://api.github.com/repos/lsst/ip_diffim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lsst/ip_diffim/statuses/{sha}","languages_url":"https://api.github.com/repos/lsst/ip_diffim/languages","stargazers_url":"https://api.github.com/repos/lsst/ip_diffim/stargazers","contributors_url":"https://api.github.com/repos/lsst/ip_diffim/contributors","subscribers_url":"https://api.github.com/repos/lsst/ip_diffim/subscribers","subscription_url":"https://api.github.com/repos/lsst/ip_diffim/subscription","commits_url":"https://api.github.com/repos/lsst/ip_diffim/commits{/sha}","git_commits_url":"https://api.github.com/repos/lsst/ip_diffim/git/commits{/sha}","comments_url":"https://api.github.com/repos/lsst/ip_diffim/comments{/number}","issue_comment_url":"https://api.github.com/repos/lsst/ip_diffim/issues/comments{/number}","contents_url":"https://api.github.com/repos/lsst/ip_diffim/contents/{+path}","compare_url":"https://api.github.com/repos/lsst/ip_diffim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lsst/ip_diffim/merges","archive_url":"https://api.github.com/repos/lsst/ip_diffim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lsst/ip_diffim/downloads","issues_url":"https://api.github.com/repos/lsst/ip_diffim/issues{/number}","pulls_url":"https://api.github.com/repos/lsst/ip_diffim/pulls{/number}","milestones_url":"https://api.github.com/repos/lsst/ip_diffim/milestones{/number}","notifications_url":"https://api.github.com/repos/lsst/ip_diffim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lsst/ip_diffim/labels{/name}","releases_url":"https://api.github.com/repos/lsst/ip_diffim/releases{/id}","deployments_url":"https://api.github.com/repos/lsst/ip_diffim/deployments","created_at":"2014-08-16T07:44:12Z","updated_at":"2016-04-11T22:01:34Z","pushed_at":"2016-06-23T22:15:17Z","git_url":"git://github.com/lsst/ip_diffim.git","ssh_url":"git@github.com:lsst/ip_diffim.git","clone_url":"https://github.com/lsst/ip_diffim.git","svn_url":"https://github.com/lsst/ip_diffim","homepage":"http://dm.lsst.org/","size":16211,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lsst/ip_diffim/pulls/25"},"html":{"href":"https://github.com/lsst/ip_diffim/pull/25"},"issue":{"href":"https://api.github.com/repos/lsst/ip_diffim/issues/25"},"comments":{"href":"https://api.github.com/repos/lsst/ip_diffim/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/lsst/ip_diffim/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/lsst/ip_diffim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lsst/ip_diffim/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/lsst/ip_diffim/statuses/2377ae04ef50961240fdeadd0b111948e210af2e"}}}}
{"actor":{"display_login":"r-owen"}}