Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dimensions metadata when resampling a map #2010

Closed
wants to merge 6 commits into from

Conversation

prateekiiest
Copy link
Contributor

Issue #1870
I updated the 'naxis' values in the resampled map.

@pep8speaks
Copy link

pep8speaks commented Feb 27, 2017

Hello @prateekiiest! Thanks for updating the PR.

Line 114:1: E302 expected 2 blank lines, found 1
Line 184:1: W293 blank line contains whitespace
Line 186:5: E303 too many blank lines (4)
Line 186:37: E231 missing whitespace after ','

Line 1296:101: E501 line too long (138 > 100 characters)
Line 1342:101: E501 line too long (105 > 100 characters)
Line 1344:101: E501 line too long (105 > 100 characters)
Line 1515:101: E501 line too long (110 > 100 characters)

Line 78:23: E231 missing whitespace after ','
Line 92:30: E128 continuation line under-indented for visual indent
Line 112:1: E302 expected 2 blank lines, found 1
Line 120:1: E265 block comment should start with '# '
Line 123:1: E265 block comment should start with '# '
Line 125:35: E721 do not compare types, use 'isinstance()'
Line 167:101: E501 line too long (105 > 100 characters)
Line 171:101: E501 line too long (106 > 100 characters)
Line 191:1: E265 block comment should start with '# '
Line 193:1: E265 block comment should start with '# '
Line 195:31: E211 whitespace before '('
Line 200:31: E211 whitespace before '('
Line 206:22: E231 missing whitespace after ','
Line 222:1: E302 expected 2 blank lines, found 1
Line 223:22: E231 missing whitespace after ','
Line 239:1: E302 expected 2 blank lines, found 1
Line 246:101: E501 line too long (127 > 100 characters)
Line 247:101: E501 line too long (127 > 100 characters)
Line 259:1: E302 expected 2 blank lines, found 1
Line 261:22: E231 missing whitespace after ','
Line 278:1: E302 expected 2 blank lines, found 1
Line 280:101: E501 line too long (103 > 100 characters)
Line 286:79: E502 the backslash is redundant between brackets
Line 287:14: E128 continuation line under-indented for visual indent
Line 289:79: E502 the backslash is redundant between brackets
Line 290:14: E128 continuation line under-indented for visual indent
Line 293:1: E302 expected 2 blank lines, found 1
Line 302:1: E302 expected 2 blank lines, found 1
Line 316:1: E302 expected 2 blank lines, found 1
Line 322:42: E231 missing whitespace after ','
Line 322:67: E231 missing whitespace after ','
Line 344:1: E302 expected 2 blank lines, found 1
Line 375:101: E501 line too long (113 > 100 characters)
Line 376:101: E501 line too long (113 > 100 characters)
Line 383:101: E501 line too long (113 > 100 characters)
Line 384:101: E501 line too long (113 > 100 characters)
Line 400:101: E501 line too long (123 > 100 characters)
Line 401:101: E501 line too long (123 > 100 characters)
Line 405:101: E501 line too long (139 > 100 characters)
Line 406:101: E501 line too long (139 > 100 characters)
Line 462:63: E261 at least two spaces before inline comment
Line 486:58: E231 missing whitespace after ','
Line 577:17: E128 continuation line under-indented for visual indent
Line 578:17: E128 continuation line under-indented for visual indent
Line 579:17: E128 continuation line under-indented for visual indent
Line 580:17: E128 continuation line under-indented for visual indent
Line 581:17: E128 continuation line under-indented for visual indent
Line 582:17: E128 continuation line under-indented for visual indent
Line 583:17: E128 continuation line under-indented for visual indent
Line 584:17: E128 continuation line under-indented for visual indent
Line 585:17: E128 continuation line under-indented for visual indent
Line 586:17: E128 continuation line under-indented for visual indent
Line 587:17: E128 continuation line under-indented for visual indent
Line 588:17: E128 continuation line under-indented for visual indent
Line 589:17: E128 continuation line under-indented for visual indent
Line 590:17: E128 continuation line under-indented for visual indent
Line 591:17: E128 continuation line under-indented for visual indent
Line 592:17: E128 continuation line under-indented for visual indent
Line 593:17: E128 continuation line under-indented for visual indent
Line 594:17: E128 continuation line under-indented for visual indent
Line 595:16: E225 missing whitespace around operator

Comment last updated on February 28, 2017 at 04:15 Hours UTC

@@ -847,6 +847,8 @@ def resample(self, dimensions, method='linear'):
new_meta['CD2_2'] *= scale_factor_y
new_meta['crpix1'] = (dimensions[0].value + 1) / 2.
new_meta['crpix2'] = (dimensions[1].value + 1) / 2.
new_meta['naxis1'] = dimensions[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FITS headers have the axes reversed, so naxis1 = dimensions[1] also it should be dimensions.value so it's a float.

Copy link
Contributor Author

@prateekiiest prateekiiest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the keys

@@ -847,6 +847,8 @@ def resample(self, dimensions, method='linear'):
new_meta['CD2_2'] *= scale_factor_y
new_meta['crpix1'] = (dimensions[0].value + 1) / 2.
new_meta['crpix2'] = (dimensions[1].value + 1) / 2.
new_meta['naxis1'] = dimensions[1].value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should not add these keys if they do not exist in the original metadata.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have send a new PR for the test case for Generic Map #2011 .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generic Map testing one??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def test_resample_metadata(generic_map, sample_method, new_dimensions):
"""
Check that the resampled map has correctly adjusted metadata.
"""
resampled_map = generic_map.resample(new_dimensions, method=sample_method)
assert float(resampled_map.meta['cdelt1']) / generic_map.meta['cdelt1']
== float(generic_map.data.shape[1]) / resampled_map.data.shape[1]
assert float(resampled_map.meta['cdelt2']) / generic_map.meta['cdelt2']
== float(generic_map.data.shape[0]) / resampled_map.data.shape[0]
assert resampled_map.meta['crpix1'] == (resampled_map.data.shape[1] + 1) / 2.
assert resampled_map.meta['crpix2'] == (resampled_map.data.shape[0] + 1) / 2.
assert resampled_map.meta['crval1'] == generic_map.center.x.value
assert resampled_map.meta['crval2'] == generic_map.center.y.value
for key in generic_map.meta:
if key not in ('cdelt1', 'cdelt2', 'crpix1', 'crpix2',
'crval1', 'crval2'):
assert resampled_map.meta[key] == generic_map.meta[key]

Actually in this part the (if key is not) didn't include the naxis keys. So I just added this naxis1 and naxis2 in that section

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is that this test should not need these keys. There is no need for us to add the naxis keys to the header, only update them if they are already there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok , got it.

@prateekiiest
Copy link
Contributor Author

@Cadair
Why sphinx documentation warning is issued?? Same occurred in #2011

Copy link
Contributor Author

@prateekiiest prateekiiest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleared pep8 issues.
But could not solve issues regarding exceeding 79 characters in one line.

@prateekiiest prateekiiest deleted the 0.1 branch May 5, 2017 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants