コード例 #1
0
# Once everything is in the model, compute the model. Then, slice off the wavelength dimension
model.compute_model()
optical_depths = model.hyperspectral_total_optical_depths[:, 1]
ssa = model.hyperspectral_total_single_scattering_albedos[:, 1]
polynomial_moments = model.hyperspectral_legendre_moments[:, :, 1]

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Make the size of the computational parameters
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
n_layers = model_eos.n_layers
n_streams = 16
n_umu = 1
n_phi = len(phi)
n_user_levels = 81
cp = ComputationalParameters(n_layers, n_moments, n_streams, n_phi, n_umu,
                             n_user_levels)

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Make misc variables
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# New: I split the old "control" classes into additional classes that I think
# are more accurately named and grouped. I think many of these variables in
# DISORT are horribly named. For clarity, I included the "DISORT" name as the
# variable name, and the name I prefer as the property
# (i.e. fisot = isotropic_flux). There's really no reason to define any of these
# variables here---you can just put them directly into the disort call---but I
# thought it might be helpful.

# Semi-new: another note, that many of these variables take a boolean or float
# value. I made them optional, and use default values that disort_mulit uses
incident_flux = IncidentFlux()
コード例 #2
0
ファイル: new.py プロジェクト: kconnour/pyRT_DISORT
# the atmosphere module
rayleigh_info = (rayleigh_od, rayleigh_ssa, rayleigh_pf)
dust_info = (dust_od, dust_ssa, dust_pf)

from pyRT_DISORT.atmosphere import Atmosphere

model = Atmosphere(rayleigh_info, dust_info)

DTAUC = model.optical_depth
SSALB = model.single_scattering_albedo
PMOM = model.legendre_moments

# The controller module
from pyRT_DISORT.controller import ComputationalParameters, ModelBehavior

cp = ComputationalParameters(hydro.n_layers, model.legendre_moments.shape[0],
                             16, 1, 1, 80)

MAXCLY = cp.n_layers
MAXMOM = cp.n_moments
MAXCMU = cp.n_streams
MAXPHI = cp.n_azimuth
MAXUMU = cp.n_polar
MAXULV = cp.n_user_levels


mb = ModelBehavior()
ACCUR = mb.accuracy
DELTAMPLUS = mb.delta_m_plus
DO_PSEUDO_SPHERE = mb.do_pseudo_sphere
HEADER = mb.header
PRNT = mb.print_variables
コード例 #3
0
# TODO: modify this each run
pgrad = np.linspace(2, 2, num=len(z_boundaries) - 1)
wave_ref = 0.88

# Read in the dust phase function
phsfn = np.load(os.path.join(aux_files_path, 'phsfn_coeff.npy'))
pf_wavs = fsp_wavs
pf_psizes = fsp_psizes

# Use constant properties over the MUV region
# fsp_wavs[1] = 0.439
# pf_wavs[1] = 0.439

# Make the misc things
cp = ComputationalParameters(hydro.n_layers, 128, 16, 1, 1, 80)
mb = ModelBehavior()
flux = IncidentFlux()
te = ThermalEmission()
ob = OutputBehavior()
ulv = UserLevel(cp.n_user_levels)

# Surface treatment
# Use Todd Clancy's surface
clancy_lamber = np.interp(wavelengths, np.linspace(0.2, 0.33, num=100),
                          np.linspace(0.01, 0.015, num=100))
lamb = [
    Surface(w, cp.n_streams, cp.n_polar, cp.n_azimuth, ob.user_angles,
            ob.only_fluxes) for w in clancy_lamber
]
コード例 #4
0
 def test_ndarray_n_user_levels_raises_type_error(self) -> None:
     with self.assertRaises(TypeError):
         ComputationalParameters(10, 30, 20, 40, 50, np.ones(5))
コード例 #5
0
 def test_str_n_user_levels_raises_value_error(self) -> None:
     with self.assertRaises(ValueError):
         ComputationalParameters(10, 30, 20, 40, 50, 'foo')
コード例 #6
0
 def test_n_streams_equal_to_n_moments_raises_no_warning(self) -> None:
     with warnings.catch_warnings(record=True) as warning:
         warnings.simplefilter("always")
         ComputationalParameters(10, 20, 20, 40, 50, 60)
         self.assertEqual(0, len(warning))
コード例 #7
0
 def test_nan_n_polar_raises_value_error(self) -> None:
     with self.assertRaises(ValueError):
         ComputationalParameters(10, 30, 20, 40, np.nan, 60)
コード例 #8
0
 def test_str_n_azimuth_raises_value_error(self) -> None:
     with self.assertRaises(ValueError):
         ComputationalParameters(10, 30, 20, 'foo', 50, 60)
コード例 #9
0
 def test_infinite_n_azimuth_raises_value_error(self) -> None:
     with self.assertRaises(ValueError):
         ComputationalParameters(10, 30, 20, np.inf, 50, 60)
コード例 #10
0
 def setUp(self) -> None:
     self.oa = OutputArrays(ComputationalParameters(10, 30, 20, 40, 50, 60))
コード例 #11
0
 def test_ndarray_n_azimuth_raises_type_error(self) -> None:
     with self.assertRaises(TypeError):
         ComputationalParameters(10, 30, 20, np.ones(5), 50, 60)
コード例 #12
0
 def test_str_n_moments_raises_value_error(self) -> None:
     with self.assertRaises(ValueError):
         ComputationalParameters(10, 'foo', 20, 40, 50, 60)
コード例 #13
0
 def test_nan_n_layers_raises_value_error(self) -> None:
     with self.assertRaises(ValueError):
         ComputationalParameters(np.nan, 30, 20, 40, 50, 60)
コード例 #14
0
 def test_ndarray_n_layers_raises_type_error(self) -> None:
     with self.assertRaises(TypeError):
         ComputationalParameters(np.ones(5), 30, 20, 40, 50, 60)
コード例 #15
0
 def setUp(self) -> None:
     self.cp = ComputationalParameters(10, 30, 20, 40, 50, 60)
     self.lamber = Lambertian(0.5, self.cp)
コード例 #16
0
 def setUp(self) -> None:
     self.cp = ComputationalParameters(10, 30, 20, 40, 50, 60)
コード例 #17
0
 def setUp(self) -> None:
     self.cp = ComputationalParameters(10, 30, 20, 40, 50, 60)
     self.surface = Surface(0.5, self.cp)
コード例 #18
0
 def test_n_streams_greater_than_n_moments_raises_warning(self) -> None:
     with warnings.catch_warnings(record=True) as warning:
         warnings.simplefilter("always")
         ComputationalParameters(10, 20, 30, 40, 50, 60)
         self.assertEqual(1, len(warning))
         self.assertEqual(warning[-1].category, UserWarning)