{"action":"created","comment":{"url":"https://api.github.com/repos/astropy/astropy-api/pulls/comments/30888156","id":30888156,"diff_hunk":"@@ -0,0 +1,209 @@\n+'''\n+A framework for efficient model image rasterization in astropy. \n+\n+This is a GSoC 2015 project and is therefore on a relatively short time frame. \n+We focus first on developing a robust solution to a simple but common use case that \n+is extensible to future implementation of more complex models and solutions. \n+\n+Use case: Generate a sky model image of discrete sources, e.g. something like \n+photutils.datasets.make_100gaussians_image(), but faster and convolving a source model\n+with an instrument PSF. \n+\n+The primary challenge- and motivation- is maximizing speed while maintainging precision. A \n+straightforward approach is to use oversampling within a bounded area around the \n+source containing the majority of its flux (e.g. 5-sigma) for discretization and integration. \n+\n+The key steps are:\n+1. Model generation\n+\t- Convolution of a source model with an instrument PSF model\n+\t- Fitting the convolved model to image data if required\n+2. Model discretization/Image rasterization\n+\t- Integration of the model over pixel areas\n+\t- Reprojection if required\n+\n+The pieces necessary are largely in existence. Relevant packages \n+include astropy.modeling, astropy.convolution, astropy.nddata, sherpa, galfit, reproject,\n+... others.\n+\n+Outlined here is a rough draft of the proposed API for community discussion. \n+\n+'''\n+\n+######################\n+# ConvolvedModel API #\n+######################\n+\n+from astropy.modeling import ConvolvedModel\n+from astropy.modeling.models import Box2D, Lorentz1D, Gaussian2D\n+from astropy.convolution import Gaussian2DKernel, Gaussian1DKernel\n+\n+# Initiate a ConvolvedModel instance, takes source model and convolution kernel\n+# like:\n+source = Box2D(1, 0, 0, 1, 1)\n+psf = Gaussian2DKernel(1)\n+convolved_model = ConvolvedModel(source, psf, mode='oversample', factor=10)\n+\n+# mode will be used both for convolution and later integration\n+# if a different mode is desired for convolution it should be passed in the psf\n+\n+# support of 1D models\n+source = Lorentz1D(1, 0, 0, 1, 1)\n+psf = Gaussian1DKernel(1)\n+convolved_model = ConvolvedModel(source, psf)\n+\n+# should there be a Convolved1DModel and Convolved2DModel?\n+# should this be an extension of the CompoundModel class?\n+\n+# later we can think about using any model as convolution kernels\n+# and even implement the analytical solution for the common Gaussian case\n+# or other cases where analytical solutions are known\n+source = Gaussian2D(1, 0, 0, 1, 1)\n+psf = Gaussian2D(1, 0, 0, 1, 1)\n+convolved_model = ConvolvedModel(source, psf)\n+\n+\n+# the convolution method can be set via string, to choose between the astropy.convolution\n+# methods\n+convolved_model = ConvolvedModel(source, psf, method='fft')\n+convolved_model = ConvolvedModel(source, psf, method='standard')\n+\n+# or by passing a function that should be used. This is mainly nececessary, because\n+# the performance of the astropy convolution algorithms is rather weak...","path":"model_discretization_api.py","position":71,"original_position":71,"commit_id":"05184659329582d7da557bdf3da8589dd76f42f7","original_commit_id":"05184659329582d7da557bdf3da8589dd76f42f7","user":{"login":"adonath","id":3715928,"avatar_url":"https://avatars.githubusercontent.com/u/3715928?v=3","gravatar_id":"","url":"https://api.github.com/users/adonath","html_url":"https://github.com/adonath","followers_url":"https://api.github.com/users/adonath/followers","following_url":"https://api.github.com/users/adonath/following{/other_user}","gists_url":"https://api.github.com/users/adonath/gists{/gist_id}","starred_url":"https://api.github.com/users/adonath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adonath/subscriptions","organizations_url":"https://api.github.com/users/adonath/orgs","repos_url":"https://api.github.com/users/adonath/repos","events_url":"https://api.github.com/users/adonath/events{/privacy}","received_events_url":"https://api.github.com/users/adonath/received_events","type":"User","site_admin":false},"body":"The astropy convolution routines can deal with `NaN` values for the price of weak performance (in terms of speed...). For this use case `NaN` values won't be an issue, so it would make sense to just go for the fastest solution.","created_at":"2015-05-22T11:39:53Z","updated_at":"2015-05-22T11:39:53Z","html_url":"https://github.com/astropy/astropy-api/pull/13#discussion_r30888156","pull_request_url":"https://api.github.com/repos/astropy/astropy-api/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/astropy/astropy-api/pulls/comments/30888156"},"html":{"href":"https://github.com/astropy/astropy-api/pull/13#discussion_r30888156"},"pull_request":{"href":"https://api.github.com/repos/astropy/astropy-api/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/astropy/astropy-api/pulls/13","id":35361212,"html_url":"https://github.com/astropy/astropy-api/pull/13","diff_url":"https://github.com/astropy/astropy-api/pull/13.diff","patch_url":"https://github.com/astropy/astropy-api/pull/13.patch","issue_url":"https://api.github.com/repos/astropy/astropy-api/issues/13","number":13,"state":"open","locked":false,"title":"Model Discretization API draft","user":{"login":"patti","id":4968596,"avatar_url":"https://avatars.githubusercontent.com/u/4968596?v=3","gravatar_id":"","url":"https://api.github.com/users/patti","html_url":"https://github.com/patti","followers_url":"https://api.github.com/users/patti/followers","following_url":"https://api.github.com/users/patti/following{/other_user}","gists_url":"https://api.github.com/users/patti/gists{/gist_id}","starred_url":"https://api.github.com/users/patti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patti/subscriptions","organizations_url":"https://api.github.com/users/patti/orgs","repos_url":"https://api.github.com/users/patti/repos","events_url":"https://api.github.com/users/patti/events{/privacy}","received_events_url":"https://api.github.com/users/patti/received_events","type":"User","site_admin":false},"body":"model_discretization_api.py\r\n\r\nA GSoC 2015 project to implement efficient model image evaluation and rasterization functionality in astropy. Mentors are @adonath and @cdeil. This is a rough draft of the proposed API for community discussion and input. Interested persons should join the upcoming discussion via Google Hangout ( [doodle poll](http://doodle.com/3ukzxg3yhvwm8i9h)).\r\n\r\n\r\n","created_at":"2015-05-13T19:21:26Z","updated_at":"2015-05-22T11:39:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f5b45159b4d9a4beceed0d7544f49982dbd02745","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/astropy/astropy-api/pulls/13/commits","review_comments_url":"https://api.github.com/repos/astropy/astropy-api/pulls/13/comments","review_comment_url":"https://api.github.com/repos/astropy/astropy-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/astropy/astropy-api/issues/13/comments","statuses_url":"https://api.github.com/repos/astropy/astropy-api/statuses/05184659329582d7da557bdf3da8589dd76f42f7","head":{"label":"patti:master","ref":"master","sha":"05184659329582d7da557bdf3da8589dd76f42f7","user":{"login":"patti","id":4968596,"avatar_url":"https://avatars.githubusercontent.com/u/4968596?v=3","gravatar_id":"","url":"https://api.github.com/users/patti","html_url":"https://github.com/patti","followers_url":"https://api.github.com/users/patti/followers","following_url":"https://api.github.com/users/patti/following{/other_user}","gists_url":"https://api.github.com/users/patti/gists{/gist_id}","starred_url":"https://api.github.com/users/patti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patti/subscriptions","organizations_url":"https://api.github.com/users/patti/orgs","repos_url":"https://api.github.com/users/patti/repos","events_url":"https://api.github.com/users/patti/events{/privacy}","received_events_url":"https://api.github.com/users/patti/received_events","type":"User","site_admin":false},"repo":{"id":35233105,"name":"astropy-api","full_name":"patti/astropy-api","owner":{"login":"patti","id":4968596,"avatar_url":"https://avatars.githubusercontent.com/u/4968596?v=3","gravatar_id":"","url":"https://api.github.com/users/patti","html_url":"https://github.com/patti","followers_url":"https://api.github.com/users/patti/followers","following_url":"https://api.github.com/users/patti/following{/other_user}","gists_url":"https://api.github.com/users/patti/gists{/gist_id}","starred_url":"https://api.github.com/users/patti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patti/subscriptions","organizations_url":"https://api.github.com/users/patti/orgs","repos_url":"https://api.github.com/users/patti/repos","events_url":"https://api.github.com/users/patti/events{/privacy}","received_events_url":"https://api.github.com/users/patti/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/patti/astropy-api","description":"Repository for API documents for Astropy","fork":true,"url":"https://api.github.com/repos/patti/astropy-api","forks_url":"https://api.github.com/repos/patti/astropy-api/forks","keys_url":"https://api.github.com/repos/patti/astropy-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/patti/astropy-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/patti/astropy-api/teams","hooks_url":"https://api.github.com/repos/patti/astropy-api/hooks","issue_events_url":"https://api.github.com/repos/patti/astropy-api/issues/events{/number}","events_url":"https://api.github.com/repos/patti/astropy-api/events","assignees_url":"https://api.github.com/repos/patti/astropy-api/assignees{/user}","branches_url":"https://api.github.com/repos/patti/astropy-api/branches{/branch}","tags_url":"https://api.github.com/repos/patti/astropy-api/tags","blobs_url":"https://api.github.com/repos/patti/astropy-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/patti/astropy-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/patti/astropy-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/patti/astropy-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/patti/astropy-api/statuses/{sha}","languages_url":"https://api.github.com/repos/patti/astropy-api/languages","stargazers_url":"https://api.github.com/repos/patti/astropy-api/stargazers","contributors_url":"https://api.github.com/repos/patti/astropy-api/contributors","subscribers_url":"https://api.github.com/repos/patti/astropy-api/subscribers","subscription_url":"https://api.github.com/repos/patti/astropy-api/subscription","commits_url":"https://api.github.com/repos/patti/astropy-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/patti/astropy-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/patti/astropy-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/patti/astropy-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/patti/astropy-api/contents/{+path}","compare_url":"https://api.github.com/repos/patti/astropy-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/patti/astropy-api/merges","archive_url":"https://api.github.com/repos/patti/astropy-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/patti/astropy-api/downloads","issues_url":"https://api.github.com/repos/patti/astropy-api/issues{/number}","pulls_url":"https://api.github.com/repos/patti/astropy-api/pulls{/number}","milestones_url":"https://api.github.com/repos/patti/astropy-api/milestones{/number}","notifications_url":"https://api.github.com/repos/patti/astropy-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/patti/astropy-api/labels{/name}","releases_url":"https://api.github.com/repos/patti/astropy-api/releases{/id}","created_at":"2015-05-07T17:14:08Z","updated_at":"2015-05-07T17:14:09Z","pushed_at":"2015-05-13T19:02:52Z","git_url":"git://github.com/patti/astropy-api.git","ssh_url":"git@github.com:patti/astropy-api.git","clone_url":"https://github.com/patti/astropy-api.git","svn_url":"https://github.com/patti/astropy-api","homepage":null,"size":884,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"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":"astropy:master","ref":"master","sha":"3051ad07594c92bde4514f13b5e7e25899dd517f","user":{"login":"astropy","id":847984,"avatar_url":"https://avatars.githubusercontent.com/u/847984?v=3","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":5471076,"name":"astropy-api","full_name":"astropy/astropy-api","owner":{"login":"astropy","id":847984,"avatar_url":"https://avatars.githubusercontent.com/u/847984?v=3","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/astropy-api","description":"Repository for API documents for Astropy","fork":false,"url":"https://api.github.com/repos/astropy/astropy-api","forks_url":"https://api.github.com/repos/astropy/astropy-api/forks","keys_url":"https://api.github.com/repos/astropy/astropy-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/astropy/astropy-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/astropy/astropy-api/teams","hooks_url":"https://api.github.com/repos/astropy/astropy-api/hooks","issue_events_url":"https://api.github.com/repos/astropy/astropy-api/issues/events{/number}","events_url":"https://api.github.com/repos/astropy/astropy-api/events","assignees_url":"https://api.github.com/repos/astropy/astropy-api/assignees{/user}","branches_url":"https://api.github.com/repos/astropy/astropy-api/branches{/branch}","tags_url":"https://api.github.com/repos/astropy/astropy-api/tags","blobs_url":"https://api.github.com/repos/astropy/astropy-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/astropy/astropy-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/astropy/astropy-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/astropy/astropy-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/astropy/astropy-api/statuses/{sha}","languages_url":"https://api.github.com/repos/astropy/astropy-api/languages","stargazers_url":"https://api.github.com/repos/astropy/astropy-api/stargazers","contributors_url":"https://api.github.com/repos/astropy/astropy-api/contributors","subscribers_url":"https://api.github.com/repos/astropy/astropy-api/subscribers","subscription_url":"https://api.github.com/repos/astropy/astropy-api/subscription","commits_url":"https://api.github.com/repos/astropy/astropy-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/astropy/astropy-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/astropy/astropy-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/astropy/astropy-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/astropy/astropy-api/contents/{+path}","compare_url":"https://api.github.com/repos/astropy/astropy-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/astropy/astropy-api/merges","archive_url":"https://api.github.com/repos/astropy/astropy-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/astropy/astropy-api/downloads","issues_url":"https://api.github.com/repos/astropy/astropy-api/issues{/number}","pulls_url":"https://api.github.com/repos/astropy/astropy-api/pulls{/number}","milestones_url":"https://api.github.com/repos/astropy/astropy-api/milestones{/number}","notifications_url":"https://api.github.com/repos/astropy/astropy-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/astropy/astropy-api/labels{/name}","releases_url":"https://api.github.com/repos/astropy/astropy-api/releases{/id}","created_at":"2012-08-19T13:20:35Z","updated_at":"2015-05-04T12:52:05Z","pushed_at":"2015-05-13T19:21:26Z","git_url":"git://github.com/astropy/astropy-api.git","ssh_url":"git@github.com:astropy/astropy-api.git","clone_url":"https://github.com/astropy/astropy-api.git","svn_url":"https://github.com/astropy/astropy-api","homepage":null,"size":1086,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":8,"forks":16,"open_issues":8,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/astropy/astropy-api/pulls/13"},"html":{"href":"https://github.com/astropy/astropy-api/pull/13"},"issue":{"href":"https://api.github.com/repos/astropy/astropy-api/issues/13"},"comments":{"href":"https://api.github.com/repos/astropy/astropy-api/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/astropy/astropy-api/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/astropy/astropy-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/astropy/astropy-api/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/astropy/astropy-api/statuses/05184659329582d7da557bdf3da8589dd76f42f7"}}}}