本文整理汇总了Python中spectral_cube.SpectralCube.moment0方法的典型用法代码示例。如果您正苦于以下问题:Python SpectralCube.moment0方法的具体用法?Python SpectralCube.moment0怎么用?Python SpectralCube.moment0使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spectral_cube.SpectralCube
的用法示例。
在下文中一共展示了SpectralCube.moment0方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SimCube
# 需要导入模块: from spectral_cube import SpectralCube [as 别名]
# 或者: from spectral_cube.SpectralCube import moment0 [as 别名]
class SimCube(object):
'''
A wrapping class to prepare a simulated spectral data cube for
comparison with another cube.
'''
def __init__(self, cube, beam=None, mask=None, method="MAD", compute=True):
# Initialize cube object
self.cube = SpectralCube.read(cube)
if mask is not None:
_check_mask(mask)
self.mask = mask
if beam is not None:
_check_beam(mask)
# Initialize noise object
self.noise = Noise(self.cube, beam=beam, method=method)
def add_noise(self):
'''
Use Noise to add synthetic noise to the data. Then update
SpectralCube.
'''
# Create the noisy cube
self.noise.get_noise_cube()
noise_data = self.noise.noise_cube +\
self.cube.filled_data[:]
# Update SpectralCube object
self._update(data=noise_data)
return self
def clean_cube(self, algorithm=None):
raise NotImplementedError("")
def apply_mask(self, mask=None):
'''
Check if the given mask is acceptable abd apply to
SpectralCube.
'''
# Update mask
if mask is not None:
_check_mask(mask)
self.mask = mask
# Create the mask, auto masking nan values
default_mask = np.isfinite(self.cube.filled_data[:])
if self.mask is not None:
self.mask = CompositeMask(default_mask, self.mask)
else:
self.mask = default_mask
# Apply mask to spectral cube object
self.cube = self.cube.with_mask(mask)
return self
def _update(self, data=None, wcs=None, beam=None, method="MAD"):
'''
Helper function to update classes.
'''
# Check if we need a new SpectralCube
if data is None and wcs is None:
pass
else:
if data is None:
data = self.cube.unmasked_data[:]
if wcs is None:
wcs = self.cube.wcs
# Make new SpectralCube object
self.cube = SpectralCube(data=data, wcs=wcs)
if beam is not None:
_check_beam(beam)
self.noise = Noise(self.cube, beam=beam, method=method)
def compute_properties(self):
'''
Use SpectralCube to compute the moments. Also compute the integrated
intensity based on the noise properties from Noise.
'''
self._moment0 = self.cube.moment0().value
self._moment1 = self.cube.moment1().value
self._moment2 = self.cube.moment2().value
_get_int_intensity(self)
return self
@property
#.........这里部分代码省略.........
示例2: Path
# 需要导入模块: from spectral_cube import SpectralCube [as 别名]
# 或者: from spectral_cube.SpectralCube import moment0 [as 别名]
p.subplot(122)
p.imshow(pv.data, cmap="binary", origin="lower")
p.colorbar()
p.show()
hdu.close()
# Now examine a subsection of the region that overlaps with the edge of
# NGC-1333. I'm not sure the instrument that took the data, but it maps
# 13CO(1-0) too.
sc = SpectralCube.read("/srv/astro/surveys/classy/N1333.13co.fits")
sc = sc[150:300, :, :]
ends = [(57, 72), (73, 83), (105, 85)]
xy = Path(ends, width=10)
pv = extract_pv_slice(sc, xy)
p.subplot(121)
p.imshow(sc.moment0().value, cmap="binary", origin="lower")
p.plot([i for i, j in ends], [j for i, j in ends], 'b-')
p.subplot(122)
p.imshow(pv.data, cmap="binary", origin="lower")
p.colorbar()
p.show()
示例3: ObsCube
# 需要导入模块: from spectral_cube import SpectralCube [as 别名]
# 或者: from spectral_cube.SpectralCube import moment0 [as 别名]
class ObsCube(object):
"""
A wrapping class of SpectralCube which prepares observational data cubes
to be compared to any other data cube.
Parameters
----------
cube : str
Path to file.
mask : numpy.ndarray, any mask class from spectral_cube, optional
Mask to be applied to the cube.
algorithm : {NAME HERE}, optional
Name of the cleaning algorithm to use.
Example
-------
```
from turbustat.cube_tools import ObsCube
cube = ObsCube("data.fits")
cube.apply_cleaning(algorithm="SUPERAWESOMECLEANING")
```
"""
def __init__(self, cube, mask=None, algorithm=None, beam=None):
super(ObsCube, self).__init__()
self.cube = sc.SpectralCube.read(cube)
self.algorithm = algorithm
# Make sure mask is an accepted type
if mask is not None:
_check_mask(mask)
self.mask = mask
if beam is not None:
_check_beam(beam)
self.noise = Noise(self.cube, beam=beam)
def clean_cube(self, algorithm=None):
raise NotImplementedError("")
def apply_mask(self, mask=None):
'''
Check if the given mask is acceptable abd apply to
SpectralCube.
'''
# Update mask
if mask is not None:
_check_mask(mask)
self.mask = mask
# Create the mask, auto masking nan values
default_mask = np.isfinite(self.cube.filled_data[:])
if self.mask is not None:
self.mask = CompositeMask(default_mask, self.mask)
else:
self.mask = default_mask
# Apply mask to spectral cube object
self.cube = self.cube.with_mask(mask)
return self
def _update(self, data=None, wcs=None, beam=None, method="MAD"):
'''
Helper function to update classes.
'''
# Check if we need a new SpectralCube
if data is None and wcs is None:
pass
else:
if data is None:
data = self.cube.unmasked_data[:]
if wcs is None:
wcs = self.cube.wcs
# Make new SpectralCube object
self.cube = SpectralCube(data=data, wcs=wcs)
if beam is not None:
_check_beam(beam)
self.noise = Noise(self.cube, beam=beam, method=method)
def compute_properties(self):
'''
Use SpectralCube to compute the moments. Also compute the integrated
intensity based on the noise properties from Noise.
'''
self._moment0 = self.cube.moment0().value
self._moment1 = self.cube.moment1().value
self._moment2 = self.cube.moment2().value
_get_int_intensity(self)
#.........这里部分代码省略.........