本文整理汇总了Python中hyperion.model.Model.set_cartesian_grid方法的典型用法代码示例。如果您正苦于以下问题:Python Model.set_cartesian_grid方法的具体用法?Python Model.set_cartesian_grid怎么用?Python Model.set_cartesian_grid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hyperion.model.Model
的用法示例。
在下文中一共展示了Model.set_cartesian_grid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Model
# 需要导入模块: from hyperion.model import Model [as 别名]
# 或者: from hyperion.model.Model import set_cartesian_grid [as 别名]
import numpy as np
from hyperion.model import Model
from hyperion.util.constants import pc, lsun
# Initialize model
m = Model()
# Set one-cell cartesian grid
w = np.linspace(-pc, pc, 32)
m.set_cartesian_grid(w, w, w)
# Add density grid with constant density
m.add_density_grid(np.ones(m.grid.shape) * 4.e-20, 'kmh_lite.hdf5')
# Add a point source in the center
s = m.add_point_source()
s.luminosity = 1000 * lsun
s.temperature = 6000.
# Add 10 SEDs for different viewing angles
image = m.add_peeled_images(sed=True, image=False)
image.set_wavelength_range(250, 0.01, 5000.)
image.set_viewing_angles(np.linspace(0., 90., 10), np.repeat(20., 10))
image.set_track_origin('basic')
# Add multi-wavelength image for a single viewing angle
image = m.add_peeled_images(sed=False, image=True)
image.set_wavelength_range(30, 1., 1000.)
image.set_viewing_angles([30.], [20.])
image.set_image_size(200, 200)
示例2: Model
# 需要导入模块: from hyperion.model import Model [as 别名]
# 或者: from hyperion.model.Model import set_cartesian_grid [as 别名]
# A simple model with no dust, just sources, to check that the Doppler Shifting
# is working correctly. This model consists of a disk of sources that is
# rotating in a solid body fashion around the origin. All sources have a
# spectrum that consists of a single spectral line that is narrow enough that we
# can easily see the rotation in a multi-wavelength image. We check that the
# image looks sensible in both binned and peeled images.
# Same as setup_indiv but using a point source collection
import numpy as np
from hyperion.model import Model
from hyperion.util.constants import c
m = Model()
m.set_cartesian_grid([-1., 1], [-1., 1.], [-1., 1])
N = 100000
w = np.random.random(N)**0.5
p = np.random.uniform(0, 2 * np.pi, N)
z = np.random.uniform(-0.1, 0.1, N)
x = w * np.cos(p)
y = w * np.sin(p)
# solid body with 1000 km/s on the outside
v = w * 1e8 # cm / s
vx = - v * np.sin(p)
vy = + v * np.cos(p)
vz = np.repeat(0, N)
示例3: run_thermal_hyperion
# 需要导入模块: from hyperion.model import Model [as 别名]
# 或者: from hyperion.model.Model import set_cartesian_grid [as 别名]
def run_thermal_hyperion(self, nphot=1e6, mrw=False, pda=False, \
niterations=20, percentile=99., absolute=2.0, relative=1.02, \
max_interactions=1e8, mpi=False, nprocesses=None):
d = []
for i in range(len(self.grid.dust)):
d.append(IsotropicDust( \
self.grid.dust[i].nu[::-1].astype(numpy.float64), \
self.grid.dust[i].albedo[::-1].astype(numpy.float64), \
self.grid.dust[i].kext[::-1].astype(numpy.float64)))
m = HypModel()
if (self.grid.coordsystem == "cartesian"):
m.set_cartesian_grid(self.grid.w1*AU, self.grid.w2*AU, \
self.grid.w3*AU)
elif (self.grid.coordsystem == "cylindrical"):
m.set_cylindrical_polar_grid(self.grid.w1*AU, self.grid.w3*AU, \
self.grid.w2)
elif (self.grid.coordsystem == "spherical"):
m.set_spherical_polar_grid(self.grid.w1*AU, self.grid.w2, \
self.grid.w3)
for i in range(len(self.grid.density)):
if (self.grid.coordsystem == "cartesian"):
m.add_density_grid(numpy.transpose(self.grid.density[i], \
axes=(2,1,0)), d[i])
if (self.grid.coordsystem == "cylindrical"):
m.add_density_grid(numpy.transpose(self.grid.density[i], \
axes=(1,2,0)), d[i])
if (self.grid.coordsystem == "spherical"):
m.add_density_grid(numpy.transpose(self.grid.density[i], \
axes=(2,1,0)), d[i])
sources = []
for i in range(len(self.grid.stars)):
sources.append(m.add_spherical_source())
sources[i].luminosity = self.grid.stars[i].luminosity * L_sun
sources[i].radius = self.grid.stars[i].radius * R_sun
sources[i].temperature = self.grid.stars[i].temperature
m.set_mrw(mrw)
m.set_pda(pda)
m.set_max_interactions(max_interactions)
m.set_n_initial_iterations(niterations)
m.set_n_photons(initial=nphot, imaging=0)
m.set_convergence(True, percentile=percentile, absolute=absolute, \
relative=relative)
m.write("temp.rtin")
m.run("temp.rtout", mpi=mpi, n_processes=nprocesses)
n = ModelOutput("temp.rtout")
grid = n.get_quantities()
self.grid.temperature = []
temperature = grid.quantities['temperature']
for i in range(len(temperature)):
if (self.grid.coordsystem == "cartesian"):
self.grid.temperature.append(numpy.transpose(temperature[i], \
axes=(2,1,0)))
if (self.grid.coordsystem == "cylindrical"):
self.grid.temperature.append(numpy.transpose(temperature[i], \
axes=(2,0,1)))
if (self.grid.coordsystem == "spherical"):
self.grid.temperature.append(numpy.transpose(temperature[i], \
axes=(2,1,0)))
os.system("rm temp.rtin temp.rtout")
示例4: Model
# 需要导入模块: from hyperion.model import Model [as 别名]
# 或者: from hyperion.model.Model import set_cartesian_grid [as 别名]
import numpy as np
from hyperion.model import Model
from hyperion.util.constants import au, lsun, rsun
from hyperion.dust import SphericalDust
# Model
m = Model()
dist = 20000 * au
x = np.linspace(-dist, dist, 101)
y = np.linspace(-dist, dist, 101)
z = np.linspace(-dist, dist, 101)
m.set_cartesian_grid(x,y,z)
# Dust
d = SphericalDust('kmh.hdf5')
d.set_sublimation_temperature('fast', temperature=1600.)
m.add_density_grid(np.ones((100,100,100)) * 1.e-18,'kmh.hdf5')
# Alpha centauri
sourceA = m.add_spherical_source()
sourceA.luminosity = 1.519 * lsun
sourceA.radius = 1.227 * rsun
sourceA.temperature = 5790.
sourceA.position = (0., 0., 0.)
# Beta centauri
sourceB = m.add_spherical_source()
sourceB.luminosity = 0.5 * lsun
sourceB.radius = 0.865 * rsun
sourceB.temperature = 5260.
示例5: Model
# 需要导入模块: from hyperion.model import Model [as 别名]
# 或者: from hyperion.model.Model import set_cartesian_grid [as 别名]
# A simple model to check what happens when a source is moving towards dust and
# we observe both the source and the dust. If we observe the source such that
# the dust is directly behind, and the source is moving towards the dust, we
# should see red-shifted emission from the source and blue-shifted scattered
# light emission.
import numpy as np
from hyperion.model import Model
from hyperion.util.constants import c
m = Model()
m.set_cartesian_grid([-1.0, 0, 1], [-1.0, 1.0], [-1.0, 1])
density = np.zeros(m.grid.shape)
density[:, :, 0] = 1.0
m.add_density_grid(density, "kmh_lite.hdf5")
# narrow emission line spectrum at 1 micron
wav = np.array([0.9999, 1.0001])
fnu = np.array([1.0, 1.0])
nu = c / (wav * 1.0e-4)
s = m.add_spherical_source()
s.position = 0.5, 0.0, 0.0
s.velocity = -1e8, 0.0, 0.0
s.spectrum = nu[::-1], fnu[::-1]
s.luminosity = 1
s.radius = 0.1