Skip to content

Commit

Permalink
Fix CUNIT3 set to undefined value instead of empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiopasra committed May 12, 2020
1 parent 5391950 commit e68c3ac
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion megaradrp/processing/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def merge_wcs(hdr_sky, hdr_spec, out=None):
c_cunit = 'Units of coordinate increment and value'
hdr.set('CUNIT1', comment=c_cunit, after='CDELT1')
hdr.set('CUNIT2', comment=c_cunit, after='CUNIT1')
hdr.set('CUNIT3', comment=c_cunit, after='CUNIT2')
hdr.set('CUNIT3', value='', comment=c_cunit, after='CUNIT2')
hdr.set('CRPIX2', value=1, comment=c_crpix, after='CRPIX1')
hdr.set('CRPIX3', value=1, comment=c_crpix, after='CRPIX2')
hdr.set('CDELT3', after='CDELT2')
Expand Down
32 changes: 30 additions & 2 deletions megaradrp/processing/tests/test_cube.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
import math

import pytest

from ..cube import create_cube
from ..cube import create_cube, merge_wcs


def generate_wcs1():
import astropy.wcs

wcsl = astropy.wcs.WCS(naxis=2)

crpix = 3.0
crval = 5300.0
cdelt = 0.1

wcsl.wcs.crpix = [crpix, 0.0]
wcsl.wcs.crval = [crval, 0.0]
wcsl.wcs.cdelt = [cdelt, 1.0]
wcsl.wcs.ctype = ['RA---TAN', 'DEC--TAN']
ang = math.pi / 3.0
wcsl.wcs.pc = [[math.cos(ang), -math.sin(ang)], [math.sin(ang), math.cos(ang)]]
return wcsl


def test_create_cube_raise():
with pytest.raises(ValueError):
create_cube(None, None, 3)
create_cube(None, None, 3)


def test_merge_wcs():
hdr1 = generate_wcs1().to_header()
hdr2 = generate_wcs1().to_header()
res = merge_wcs(hdr1, hdr2)
cunit3 = res['CUNIT3']
assert cunit3 == ''

0 comments on commit e68c3ac

Please sign in to comment.