本文整理汇总了Python中spectral_cube.SpectralCube.max方法的典型用法代码示例。如果您正苦于以下问题:Python SpectralCube.max方法的具体用法?Python SpectralCube.max怎么用?Python SpectralCube.max使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spectral_cube.SpectralCube
的用法示例。
在下文中一共展示了SpectralCube.max方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: assert
# 需要导入模块: from spectral_cube import SpectralCube [as 别名]
# 或者: from spectral_cube.SpectralCube import max [as 别名]
assert (np.abs(cube.moment1().to(u.km/u.s).value - centroid).max()) < 1e-5
assert (np.abs(cube.moment2().to(u.km**2/u.s**2).value - sigma**2).max()) < 1e-5
# Create a pyspeckit cube
pcube = pyspeckit.Cube(cube=cube)
# For convenience, convert the X-axis to km/s
# (WCSLIB automatically converts to m/s even if you give it km/s)
pcube.xarr.convert_to_unit(u.km/u.s)
# Set up the fitter by doing a preliminary fit
pcube.specfit(fittype='gaussian', guesses='moments')
# Fit each spectrum with a gaussian
# First, assemble the guesses:
guesses = np.array([cube.max(axis=0).value,
cube.moment1(axis=0).to(u.km/u.s).value,
(cube.moment2(axis=0)**0.5).to(u.km/u.s).value])
# (the second moment is in m^2/s^2, but we want km/s
# Do the fit!
pcube.fiteach(guesses=guesses, # pass in the guess array
# tell it where to start the fitting (center pixel in this case)
start_from_point=(5,5),
# Paralellize the fits?
multicore=4,
fittype='gaussian',
)
# Then you can access the fits via parcube:
assert np.all(pcube.parcube[0,:,:] == 1)
示例2: SpectralCube
# 需要导入模块: from spectral_cube import SpectralCube [as 别名]
# 或者: from spectral_cube.SpectralCube import max [as 别名]
mask=cubeA.mask, meta={'unit':'K'},
header=cubeA.header,
)
outpath = 'TemperatureCube_DendrogramObjects{0}_Piecewise.fits'.format(sm)
tcube.write(hpath(outpath), overwrite=True)
rcube = SpectralCube(data=rcubedata, wcs=cubeA.wcs,
mask=cubeA.mask, meta={'unit':'K'},
header=cubeA.header,
)
outpath = 'RatioCube_DendrogramObjects{0}.fits'.format(sm)
rcube.write(hpath(outpath), overwrite=True)
max_temcube = tcube.max(axis=0)
max_temcube.hdu.writeto(hpath('TemperatureCube_DendrogramObjects{0}_Piecewise_max.fits'.format(sm)), clobber=True)
max_rcube = rcube.max(axis=0)
max_rcube.hdu.writeto(hpath('RatioCube_DendrogramObjects{0}_Piecewise_max.fits'.format(sm)), clobber=True)
mean_temcube = tcube.mean(axis=0)
mean_temcube.hdu.writeto(hpath('TemperatureCube_DendrogramObjects{0}_Piecewise_mean.fits'.format(sm)), clobber=True)
mean_rcube = rcube.mean(axis=0)
mean_rcube.hdu.writeto(hpath('RatioCube_DendrogramObjects{0}_Piecewise_mean.fits'.format(sm)), clobber=True)
hdu_template = mean_rcube.hdu
tcube = tcube.filled_data[:].value
weight_cube = cube303sm if 'smooth' in sm else cube303
weights = weight_cube.filled_data[:].value
weights[weights < 0] = 0