6
6
import numpy as np
7
7
import warnings
8
8
9
- from .beam import Beam , _to_area , SIGMA_TO_FWHM
9
+ from .beam import Beam , _to_area , SIGMA_TO_FWHM , _set_default_unit
10
10
from .commonbeam import commonbeam
11
11
from .utils import InvalidBeamOperationError
12
12
@@ -30,12 +30,14 @@ def __new__(cls, major=None, minor=None, pa=None,
30
30
The FWHM minor axes
31
31
pa : :class:`~astropy.units.Quantity` with angular equivalency
32
32
The beam position angles
33
- area : :class:`~astropy.units.Quantity` with steradian equivalency
33
+ areas : :class:`~astropy.units.Quantity` with steradian equivalency
34
34
The area of the beams. This is an alternative to specifying the
35
35
major/minor/PA, and will create those values assuming a circular
36
36
Gaussian beam.
37
37
default_unit : :class:`~astropy.units.Unit`
38
38
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.
39
41
beams : List of :class:`~radio_beam.Beam` objects
40
42
List of individual `Beam` objects. The resulting `Beams` object will
41
43
have major and minor axes in degrees.
@@ -59,33 +61,23 @@ def __new__(cls, major=None, minor=None, pa=None,
59
61
60
62
# give specified values priority
61
63
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
+
73
67
if pa is not None :
74
68
if len (pa ) != len (major ):
75
69
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 )
81
71
else :
82
- pa = np .zeros_like (major .value ) * u .deg
72
+ pa = np .zeros (major .shape ) * u .deg
83
73
84
74
# some sensible defaults
85
75
if minor is None :
86
76
minor = major
87
77
elif len (minor ) != len (major ):
88
78
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 )
89
81
90
82
if np .any (minor > major ):
91
83
raise ValueError ("Minor axis greater than major axis." )
0 commit comments