Skip to content

Commit

Permalink
Merge 70ac699 into 452d962
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Apr 24, 2019
2 parents 452d962 + 70ac699 commit ace59d9
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.fits binary
2 changes: 1 addition & 1 deletion regions/io/fits/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FITSRegionParserError(ValueError):

language_spec = {'CIRCLE': ['X0', 'Y0', 'R0'],
'POINT': ['X0', 'Y0'],
'BOX': ['X0', 'Y0', 'R0', 'R1', 'ROTANG0'],
'BOX': ['X0', 'Y0', 'R0', 'R1'],
'ANNULUS': ['X0', 'Y0', 'R0', 'R1'],
'ELLIPSE': ['X0', 'Y0', 'R0', 'R1', 'ROTANG0'],
'ELLIPTANNULUS': ['X0', 'Y0', 'R0', 'R1', 'R2', 'R3', 'ROTANG0'],
Expand Down
5 changes: 4 additions & 1 deletion regions/io/fits/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def _get_col_value(self, colname, default=None):
if np.isscalar(val):
val = np.array(val).reshape(1, )
if index is not None:
if index < len(val) and val[index] != 0:
if index < len(val) and val[index] is not None:
return val[index], unit
else:
raise ValueError("The column: {0} must have more than {1} value for the "
Expand Down Expand Up @@ -201,6 +201,9 @@ def parse(self):
for x, y in zip(coords[0], coords[1]):
coords_new += [x, y]
coords = coords_new
elif self.region_type == 'BOX':
# Add a 0 rotation to turn it into ROTBOX
coords.append(0.0*u.deg)

region_type = self.region_type.lower()
if region_type in reg_mapping['FITS_REGION']:
Expand Down
2 changes: 1 addition & 1 deletion regions/io/fits/tests/data/fits_region.fits

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion regions/io/fits/tests/test_fits_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ def test_file_fits(filename):
assert shapes[5].region_type == 'point'
assert shapes[6].region_type == 'point'
assert shapes[7].region_type == 'polygon'
assert shapes[8].region_type == 'rectangle'

for x in range(7):
for x in range(8):
assert_allclose(shapes[x].coord[:2],
[table['X'][x][0], table['Y'][x][0]])

Expand Down

0 comments on commit ace59d9

Please sign in to comment.