{"action":"created","comment":{"url":"https://api.github.com/repos/astropy/astropy/pulls/comments/63156866","id":63156866,"diff_hunk":"@@ -81,6 +81,9 @@ New Features\n     currently avaiable mixins. This class does not implement additional\n     attributes, methods or a numpy.ndarray-like interface like ``NDDataArray``.\n \n+  - ``NDIOMixin`` and subclasses now support reading/writing fits files using\n+    the ``read`` or ``write`` method with ``format='simple_fits'``. [#4799]","path":"CHANGES.rst","position":5,"original_position":5,"commit_id":"c4ef6b376206fcfb4c8cea806702880fd92de548","original_commit_id":"c4ef6b376206fcfb4c8cea806702880fd92de548","user":{"login":"astrofrog","id":314716,"avatar_url":"https://avatars.githubusercontent.com/u/314716?v=3","gravatar_id":"","url":"https://api.github.com/users/astrofrog","html_url":"https://github.com/astrofrog","followers_url":"https://api.github.com/users/astrofrog/followers","following_url":"https://api.github.com/users/astrofrog/following{/other_user}","gists_url":"https://api.github.com/users/astrofrog/gists{/gist_id}","starred_url":"https://api.github.com/users/astrofrog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astrofrog/subscriptions","organizations_url":"https://api.github.com/users/astrofrog/orgs","repos_url":"https://api.github.com/users/astrofrog/repos","events_url":"https://api.github.com/users/astrofrog/events{/privacy}","received_events_url":"https://api.github.com/users/astrofrog/received_events","type":"User","site_admin":false},"body":"Why ``simple_fits`` and not just ``fits``, for consistency with ``Table``? (i.e. can't the more complex readers use ``fits-...``? Note that sub-classes can I think override the meaning of FITS if they want more specific readers.","created_at":"2016-05-13T09:35:41Z","updated_at":"2016-05-13T09:35:41Z","html_url":"https://github.com/astropy/astropy/pull/4799#discussion_r63156866","pull_request_url":"https://api.github.com/repos/astropy/astropy/pulls/4799","_links":{"self":{"href":"https://api.github.com/repos/astropy/astropy/pulls/comments/63156866"},"html":{"href":"https://github.com/astropy/astropy/pull/4799#discussion_r63156866"},"pull_request":{"href":"https://api.github.com/repos/astropy/astropy/pulls/4799"}}},"pull_request":{"url":"https://api.github.com/repos/astropy/astropy/pulls/4799","id":67314441,"html_url":"https://github.com/astropy/astropy/pull/4799","diff_url":"https://github.com/astropy/astropy/pull/4799.diff","patch_url":"https://github.com/astropy/astropy/pull/4799.patch","issue_url":"https://api.github.com/repos/astropy/astropy/issues/4799","number":4799,"state":"open","locked":false,"title":"Simple reader and writer for FITS files for NDIOMixin","user":{"login":"MSeifert04","id":14200878,"avatar_url":"https://avatars.githubusercontent.com/u/14200878?v=3","gravatar_id":"","url":"https://api.github.com/users/MSeifert04","html_url":"https://github.com/MSeifert04","followers_url":"https://api.github.com/users/MSeifert04/followers","following_url":"https://api.github.com/users/MSeifert04/following{/other_user}","gists_url":"https://api.github.com/users/MSeifert04/gists{/gist_id}","starred_url":"https://api.github.com/users/MSeifert04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MSeifert04/subscriptions","organizations_url":"https://api.github.com/users/MSeifert04/orgs","repos_url":"https://api.github.com/users/MSeifert04/repos","events_url":"https://api.github.com/users/MSeifert04/events{/privacy}","received_events_url":"https://api.github.com/users/MSeifert04/received_events","type":"User","site_admin":false},"body":"# Current status\r\n\r\nThis is inspired by #4756 and implements a simple reader and writer for `NDIOMixin` without auto-identification. So one has to use `format='simple_fits'`. This string may need some thinking over, this progressed somewhat from the original really simple fits reader without arguments.\r\n\r\nIt has the options to manipulate reader/writer to some extend:\r\n- reader: HDUs which contain `data`, `meta`, `mask` and `uncertainty`\r\n- reader: header keywords that indicate the `unit`\r\n- writer: HDU _names_ for `mask` and `uncertainty`. Although `data` and `meta` are always the PrimaryHDU.\r\n- writer: keyword that indicates the `unit`\r\nbut some values are hardcoded:\r\n- comment header card that indicates if the `mask` was `boolean`. Because FITS doesn't support writing boolean arrays.\r\n- comment header card that saves the kind of uncertainty. Currently there are two useable uncertainties: `StdDevUncertainty` (standard deviation) and `UnknownUncertainty` (not a clue what kind). This probably requires some kind of registry if further reader/writer are added (if any).\r\n\r\nEven though these are customizable the defaults can be used in a \"self-consistent\" way. So if you have a `NDData` object you can write/read it without bothering about these. Only reading some data from an externally created file should need using the arguments from the `reader`.\r\n\r\nAnother problem I encountered during this PR was the cyclic referencing between `NDData` and it's `uncertainty`. This was resolved by using a `weakref`. It made this PR probably a bit more messy than necessary.\r\n\r\nAlso I needed to make the `from astropy.coordinates import SkyCoord` lazy inside `astropy.nddata.utils.py` because sphinx complained about cyclic imports there.\r\n\r\n# Old first post\r\n\r\nInspired by #4756 this PR adds a simple reader/writer for ``NDIOMixin`` for reading FITS files. Currently everything is hardcoded (therefore simple) but I think it's probably easy to extend.\r\n\r\nThe test setup was a bit messy, I'm very new with tempfiles and so one. These are just copy&pastes from other parts of astropy so there is probably room for improvement.\r\n\r\nI didn't add any documentation (just yet) because this will get a bit messy with my other current PRs for `NDData` & associates.\r\n\r\nSome context:\r\n- The reader and writer should be self-consistent - so what the writer produces can be read by the reader.\r\n- The reader cannot handle arbitary FITS files, I tried some files (images) and most pass. Only some require tweaking the reader (for example if there was a mask-extension but unreadable without IRAF) or the data was stored in another extension.\r\n- I've submitted a very similar read/write to [`ccdproc`](https://github.com/astropy/ccdproc/pull/302) so I'm not sure if this is too much duplication. But they don't interfere with each other (or shouldn't).\r\n- It should probably be put into `io.fits.connect.py` but since this is not really a reliable reader/writer I didn't want it to put it there (just yet).\r\n\r\nBut in general I didn't try to make them one-size-fits-all (sorry for that pun) but more or less a show-case implementation that does work in many cases without too much alteration.","created_at":"2016-04-21T08:25:25Z","updated_at":"2016-05-13T09:35:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3ef9d755fe0731300745c92d8fcf1a172f018673","assignee":{"login":"mwcraig","id":1147167,"avatar_url":"https://avatars.githubusercontent.com/u/1147167?v=3","gravatar_id":"","url":"https://api.github.com/users/mwcraig","html_url":"https://github.com/mwcraig","followers_url":"https://api.github.com/users/mwcraig/followers","following_url":"https://api.github.com/users/mwcraig/following{/other_user}","gists_url":"https://api.github.com/users/mwcraig/gists{/gist_id}","starred_url":"https://api.github.com/users/mwcraig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwcraig/subscriptions","organizations_url":"https://api.github.com/users/mwcraig/orgs","repos_url":"https://api.github.com/users/mwcraig/repos","events_url":"https://api.github.com/users/mwcraig/events{/privacy}","received_events_url":"https://api.github.com/users/mwcraig/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/astropy/astropy/pulls/4799/commits","review_comments_url":"https://api.github.com/repos/astropy/astropy/pulls/4799/comments","review_comment_url":"https://api.github.com/repos/astropy/astropy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/astropy/astropy/issues/4799/comments","statuses_url":"https://api.github.com/repos/astropy/astropy/statuses/c4ef6b376206fcfb4c8cea806702880fd92de548","head":{"label":"MSeifert04:nddata_simple_fits_reader_writer","ref":"nddata_simple_fits_reader_writer","sha":"c4ef6b376206fcfb4c8cea806702880fd92de548","user":{"login":"MSeifert04","id":14200878,"avatar_url":"https://avatars.githubusercontent.com/u/14200878?v=3","gravatar_id":"","url":"https://api.github.com/users/MSeifert04","html_url":"https://github.com/MSeifert04","followers_url":"https://api.github.com/users/MSeifert04/followers","following_url":"https://api.github.com/users/MSeifert04/following{/other_user}","gists_url":"https://api.github.com/users/MSeifert04/gists{/gist_id}","starred_url":"https://api.github.com/users/MSeifert04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MSeifert04/subscriptions","organizations_url":"https://api.github.com/users/MSeifert04/orgs","repos_url":"https://api.github.com/users/MSeifert04/repos","events_url":"https://api.github.com/users/MSeifert04/events{/privacy}","received_events_url":"https://api.github.com/users/MSeifert04/received_events","type":"User","site_admin":false},"repo":{"id":42801766,"name":"astropy","full_name":"MSeifert04/astropy","owner":{"login":"MSeifert04","id":14200878,"avatar_url":"https://avatars.githubusercontent.com/u/14200878?v=3","gravatar_id":"","url":"https://api.github.com/users/MSeifert04","html_url":"https://github.com/MSeifert04","followers_url":"https://api.github.com/users/MSeifert04/followers","following_url":"https://api.github.com/users/MSeifert04/following{/other_user}","gists_url":"https://api.github.com/users/MSeifert04/gists{/gist_id}","starred_url":"https://api.github.com/users/MSeifert04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MSeifert04/subscriptions","organizations_url":"https://api.github.com/users/MSeifert04/orgs","repos_url":"https://api.github.com/users/MSeifert04/repos","events_url":"https://api.github.com/users/MSeifert04/events{/privacy}","received_events_url":"https://api.github.com/users/MSeifert04/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MSeifert04/astropy","description":"Repository for the Astropy core package","fork":true,"url":"https://api.github.com/repos/MSeifert04/astropy","forks_url":"https://api.github.com/repos/MSeifert04/astropy/forks","keys_url":"https://api.github.com/repos/MSeifert04/astropy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MSeifert04/astropy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MSeifert04/astropy/teams","hooks_url":"https://api.github.com/repos/MSeifert04/astropy/hooks","issue_events_url":"https://api.github.com/repos/MSeifert04/astropy/issues/events{/number}","events_url":"https://api.github.com/repos/MSeifert04/astropy/events","assignees_url":"https://api.github.com/repos/MSeifert04/astropy/assignees{/user}","branches_url":"https://api.github.com/repos/MSeifert04/astropy/branches{/branch}","tags_url":"https://api.github.com/repos/MSeifert04/astropy/tags","blobs_url":"https://api.github.com/repos/MSeifert04/astropy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MSeifert04/astropy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MSeifert04/astropy/git/refs{/sha}","trees_url":"https://api.github.com/repos/MSeifert04/astropy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MSeifert04/astropy/statuses/{sha}","languages_url":"https://api.github.com/repos/MSeifert04/astropy/languages","stargazers_url":"https://api.github.com/repos/MSeifert04/astropy/stargazers","contributors_url":"https://api.github.com/repos/MSeifert04/astropy/contributors","subscribers_url":"https://api.github.com/repos/MSeifert04/astropy/subscribers","subscription_url":"https://api.github.com/repos/MSeifert04/astropy/subscription","commits_url":"https://api.github.com/repos/MSeifert04/astropy/commits{/sha}","git_commits_url":"https://api.github.com/repos/MSeifert04/astropy/git/commits{/sha}","comments_url":"https://api.github.com/repos/MSeifert04/astropy/comments{/number}","issue_comment_url":"https://api.github.com/repos/MSeifert04/astropy/issues/comments{/number}","contents_url":"https://api.github.com/repos/MSeifert04/astropy/contents/{+path}","compare_url":"https://api.github.com/repos/MSeifert04/astropy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MSeifert04/astropy/merges","archive_url":"https://api.github.com/repos/MSeifert04/astropy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MSeifert04/astropy/downloads","issues_url":"https://api.github.com/repos/MSeifert04/astropy/issues{/number}","pulls_url":"https://api.github.com/repos/MSeifert04/astropy/pulls{/number}","milestones_url":"https://api.github.com/repos/MSeifert04/astropy/milestones{/number}","notifications_url":"https://api.github.com/repos/MSeifert04/astropy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MSeifert04/astropy/labels{/name}","releases_url":"https://api.github.com/repos/MSeifert04/astropy/releases{/id}","deployments_url":"https://api.github.com/repos/MSeifert04/astropy/deployments","created_at":"2015-09-20T05:43:07Z","updated_at":"2016-04-12T23:47:32Z","pushed_at":"2016-05-12T23:12:29Z","git_url":"git://github.com/MSeifert04/astropy.git","ssh_url":"git@github.com:MSeifert04/astropy.git","clone_url":"https://github.com/MSeifert04/astropy.git","svn_url":"https://github.com/MSeifert04/astropy","homepage":"www.astropy.org","size":43246,"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":"7f2d4c8f911331a41d4503a8c2a80cc5eb298ae0","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":2081289,"name":"astropy","full_name":"astropy/astropy","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","description":"Repository for the Astropy core package","fork":false,"url":"https://api.github.com/repos/astropy/astropy","forks_url":"https://api.github.com/repos/astropy/astropy/forks","keys_url":"https://api.github.com/repos/astropy/astropy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/astropy/astropy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/astropy/astropy/teams","hooks_url":"https://api.github.com/repos/astropy/astropy/hooks","issue_events_url":"https://api.github.com/repos/astropy/astropy/issues/events{/number}","events_url":"https://api.github.com/repos/astropy/astropy/events","assignees_url":"https://api.github.com/repos/astropy/astropy/assignees{/user}","branches_url":"https://api.github.com/repos/astropy/astropy/branches{/branch}","tags_url":"https://api.github.com/repos/astropy/astropy/tags","blobs_url":"https://api.github.com/repos/astropy/astropy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/astropy/astropy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/astropy/astropy/git/refs{/sha}","trees_url":"https://api.github.com/repos/astropy/astropy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/astropy/astropy/statuses/{sha}","languages_url":"https://api.github.com/repos/astropy/astropy/languages","stargazers_url":"https://api.github.com/repos/astropy/astropy/stargazers","contributors_url":"https://api.github.com/repos/astropy/astropy/contributors","subscribers_url":"https://api.github.com/repos/astropy/astropy/subscribers","subscription_url":"https://api.github.com/repos/astropy/astropy/subscription","commits_url":"https://api.github.com/repos/astropy/astropy/commits{/sha}","git_commits_url":"https://api.github.com/repos/astropy/astropy/git/commits{/sha}","comments_url":"https://api.github.com/repos/astropy/astropy/comments{/number}","issue_comment_url":"https://api.github.com/repos/astropy/astropy/issues/comments{/number}","contents_url":"https://api.github.com/repos/astropy/astropy/contents/{+path}","compare_url":"https://api.github.com/repos/astropy/astropy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/astropy/astropy/merges","archive_url":"https://api.github.com/repos/astropy/astropy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/astropy/astropy/downloads","issues_url":"https://api.github.com/repos/astropy/astropy/issues{/number}","pulls_url":"https://api.github.com/repos/astropy/astropy/pulls{/number}","milestones_url":"https://api.github.com/repos/astropy/astropy/milestones{/number}","notifications_url":"https://api.github.com/repos/astropy/astropy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/astropy/astropy/labels{/name}","releases_url":"https://api.github.com/repos/astropy/astropy/releases{/id}","deployments_url":"https://api.github.com/repos/astropy/astropy/deployments","created_at":"2011-07-21T01:33:49Z","updated_at":"2016-05-12T13:07:18Z","pushed_at":"2016-05-13T08:35:46Z","git_url":"git://github.com/astropy/astropy.git","ssh_url":"git@github.com:astropy/astropy.git","clone_url":"https://github.com/astropy/astropy.git","svn_url":"https://github.com/astropy/astropy","homepage":"www.astropy.org","size":64636,"stargazers_count":853,"watchers_count":853,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":545,"mirror_url":null,"open_issues_count":707,"forks":545,"open_issues":707,"watchers":853,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/astropy/astropy/pulls/4799"},"html":{"href":"https://github.com/astropy/astropy/pull/4799"},"issue":{"href":"https://api.github.com/repos/astropy/astropy/issues/4799"},"comments":{"href":"https://api.github.com/repos/astropy/astropy/issues/4799/comments"},"review_comments":{"href":"https://api.github.com/repos/astropy/astropy/pulls/4799/comments"},"review_comment":{"href":"https://api.github.com/repos/astropy/astropy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/astropy/astropy/pulls/4799/commits"},"statuses":{"href":"https://api.github.com/repos/astropy/astropy/statuses/c4ef6b376206fcfb4c8cea806702880fd92de548"}}}}