Skip to content

Commit 35ec3bf

Browse files
committed
Apply fix to radio_beam.Beams
1 parent 1fa730f commit 35ec3bf

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

radio_beam/multiple_beams.py

+11-19
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import numpy as np
77
import warnings
88

9-
from .beam import Beam, _to_area, SIGMA_TO_FWHM
9+
from .beam import Beam, _to_area, SIGMA_TO_FWHM, _set_default_unit
1010
from .commonbeam import commonbeam
1111
from .utils import InvalidBeamOperationError
1212

@@ -30,12 +30,14 @@ def __new__(cls, major=None, minor=None, pa=None,
3030
The FWHM minor axes
3131
pa : :class:`~astropy.units.Quantity` with angular equivalency
3232
The beam position angles
33-
area : :class:`~astropy.units.Quantity` with steradian equivalency
33+
areas : :class:`~astropy.units.Quantity` with steradian equivalency
3434
The area of the beams. This is an alternative to specifying the
3535
major/minor/PA, and will create those values assuming a circular
3636
Gaussian beam.
3737
default_unit : :class:`~astropy.units.Unit`
3838
The unit to impose on major, minor if they are specified as floats
39+
meta : dict, optional
40+
A dictionary of metadata to include in the header.
3941
beams : List of :class:`~radio_beam.Beam` objects
4042
List of individual `Beam` objects. The resulting `Beams` object will
4143
have major and minor axes in degrees.
@@ -59,33 +61,23 @@ def __new__(cls, major=None, minor=None, pa=None,
5961

6062
# give specified values priority
6163
if major is not None:
62-
if u.deg.is_equivalent(major.unit):
63-
pass
64-
else:
65-
warnings.warn("Assuming major axes has been specified in degrees")
66-
major = major * u.deg
67-
if minor is not None:
68-
if u.deg.is_equivalent(minor.unit):
69-
pass
70-
else:
71-
warnings.warn("Assuming minor axes has been specified in degrees")
72-
minor = minor * u.deg
64+
major = _set_default_unit("major", major, default_unit, equiv_unit=u.deg)
65+
66+
7367
if pa is not None:
7468
if len(pa) != len(major):
7569
raise ValueError("Number of position angles must match number of major axis lengths")
76-
if u.deg.is_equivalent(pa.unit):
77-
pass
78-
else:
79-
warnings.warn("Assuming position angles has been specified in degrees")
80-
pa = pa * u.deg
70+
pa = _set_default_unit("pa", pa, u.deg, equiv_unit=u.deg)
8171
else:
82-
pa = np.zeros_like(major.value) * u.deg
72+
pa = np.zeros(major.shape) * u.deg
8373

8474
# some sensible defaults
8575
if minor is None:
8676
minor = major
8777
elif len(minor) != len(major):
8878
raise ValueError("Minor and major axes must have same number of values")
79+
else:
80+
minor = _set_default_unit("minor", minor, default_unit, equiv_unit=u.deg)
8981

9082
if np.any(minor > major):
9183
raise ValueError("Minor axis greater than major axis.")

0 commit comments

Comments
 (0)