PyMieSim 5.8.0__cp314-cp314-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PyMieSim/__init__.py +138 -0
- PyMieSim/_native.py +76 -0
- PyMieSim/_pint.cp314-win_amd64.pyd +0 -0
- PyMieSim/_version.py +24 -0
- PyMieSim/coordinates.cp314-win_amd64.pyd +0 -0
- PyMieSim/directories.py +25 -0
- PyMieSim/distributions.cp314-win_amd64.pyd +0 -0
- PyMieSim/experiment/__init__.py +4 -0
- PyMieSim/experiment/_setup.cp314-win_amd64.pyd +0 -0
- PyMieSim/experiment/detector_set.cp314-win_amd64.pyd +0 -0
- PyMieSim/experiment/distributions.py +103 -0
- PyMieSim/experiment/lib_setup_lib.a +0 -0
- PyMieSim/experiment/libdetector_set_lib.a +0 -0
- PyMieSim/experiment/libmaterial_set_lib.a +0 -0
- PyMieSim/experiment/libpolarization_set_lib.a +0 -0
- PyMieSim/experiment/libscatterer_set_lib.a +0 -0
- PyMieSim/experiment/libsource_set_lib.a +0 -0
- PyMieSim/experiment/material_set.cp314-win_amd64.pyd +0 -0
- PyMieSim/experiment/polarization_set.cp314-win_amd64.pyd +0 -0
- PyMieSim/experiment/scatterer_set.cp314-win_amd64.pyd +0 -0
- PyMieSim/experiment/setup.py +287 -0
- PyMieSim/experiment/source_set.cp314-win_amd64.pyd +0 -0
- PyMieSim/experiment/utils.py +134 -0
- PyMieSim/inverse.cp314-win_amd64.pyd +0 -0
- PyMieSim/labeled_array.cp314-win_amd64.pyd +0 -0
- PyMieSim/labeled_array.pyi +36 -0
- PyMieSim/libcoordinates_lib.a +0 -0
- PyMieSim/libdistributions_lib.a +0 -0
- PyMieSim/libinverse_lib.a +0 -0
- PyMieSim/libmaterial_lib.a +0 -0
- PyMieSim/libmesh_lib.a +0 -0
- PyMieSim/libpolarization_lib.a +0 -0
- PyMieSim/material.cp314-win_amd64.pyd +0 -0
- PyMieSim/materials.py +461 -0
- PyMieSim/measures.py +116 -0
- PyMieSim/mesh.cp314-win_amd64.pyd +0 -0
- PyMieSim/polarization.cp314-win_amd64.pyd +0 -0
- PyMieSim/py.typed +0 -0
- PyMieSim/results.py +89 -0
- PyMieSim/single/__init__.py +12 -0
- PyMieSim/single/api.py +129 -0
- PyMieSim/single/detector.cp314-win_amd64.pyd +0 -0
- PyMieSim/single/libmode_field_lib.a +0 -0
- PyMieSim/single/liboptical_interface_lib.a +0 -0
- PyMieSim/single/libscatterer_lib.a +0 -0
- PyMieSim/single/libsetup_single.a +0 -0
- PyMieSim/single/libsource_lib.a +0 -0
- PyMieSim/single/mode_field.cp314-win_amd64.pyd +0 -0
- PyMieSim/single/optical_interface.cp314-win_amd64.pyd +0 -0
- PyMieSim/single/representations/__init__.py +6 -0
- PyMieSim/single/representations/_plotting.py +140 -0
- PyMieSim/single/representations/farfields.py +890 -0
- PyMieSim/single/representations/footprint.py +230 -0
- PyMieSim/single/representations/nearfields.py +689 -0
- PyMieSim/single/representations/s1s2.py +199 -0
- PyMieSim/single/representations/spf.py +248 -0
- PyMieSim/single/representations/stokes.py +318 -0
- PyMieSim/single/scatterer.cp314-win_amd64.pyd +0 -0
- PyMieSim/single/setup.cp314-win_amd64.pyd +0 -0
- PyMieSim/single/setup.pyi +38 -0
- PyMieSim/single/source.cp314-win_amd64.pyd +0 -0
- PyMieSim/units.py +16 -0
- PyMieSim/utils.py +122 -0
- PyMieSim/validation_data/bohren_huffman/figure_810.csv +245 -0
- PyMieSim/validation_data/bohren_huffman/figure_87.csv +2 -0
- PyMieSim/validation_data/bohren_huffman/figure_88.csv +2 -0
- PyMieSim/validation_data/pymiescatt/example_coreshell_0.csv +41 -0
- PyMieSim/validation_data/pymiescatt/example_coreshell_1.csv +401 -0
- PyMieSim/validation_data/pymiescatt/example_shpere_0.csv +51 -0
- PyMieSim/validation_data/pymiescatt/example_shpere_1.csv +801 -0
- PyMieSim/validation_data/pymiescatt/example_shpere_2.csv +41 -0
- PyMieSim/validation_data/pymiescatt/example_shpere_3.csv +401 -0
- PyMieSim/validation_data/pymiescatt/example_sphere_0.csv +51 -0
- PyMieSim/validation_data/pymiescatt/example_sphere_1.csv +801 -0
- PyMieSim/validation_data/pymiescatt/example_sphere_2.csv +41 -0
- PyMieSim/validation_data/pymiescatt/example_sphere_3.csv +401 -0
- PyMieSim/validation_data/pymiescatt/validation_Qsca.csv +800 -0
- PyMieSim/validation_data/pymiescatt/validation_Qsca_coreshell_1.csv +400 -0
- PyMieSim/validation_data/pymiescatt/validation_Qsca_coreshell_2.csv +400 -0
- PyMieSim/validation_data/pymiescatt/validation_Qsca_medium.csv +800 -0
- PyMieSim/validation_data/pymiescatt/validation_coreshell.csv +81 -0
- PyMieSim/validation_data/pymiescatt/validation_sphere.csv +801 -0
- pymiesim-5.8.0.dist-info/METADATA +473 -0
- pymiesim-5.8.0.dist-info/RECORD +86 -0
- pymiesim-5.8.0.dist-info/WHEEL +5 -0
- pymiesim-5.8.0.dist-info/licenses/LICENSE +21 -0
PyMieSim/__init__.py
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
try:
|
|
2
|
+
from ._version import version as __version__
|
|
3
|
+
|
|
4
|
+
except ImportError:
|
|
5
|
+
__version__ = "0.0.0"
|
|
6
|
+
|
|
7
|
+
from ._native import check_native_extensions
|
|
8
|
+
|
|
9
|
+
check_native_extensions()
|
|
10
|
+
|
|
11
|
+
import PyMieSim.units as _
|
|
12
|
+
import PyMieSim.material as _
|
|
13
|
+
import PyMieSim.polarization as _
|
|
14
|
+
|
|
15
|
+
from .single.api import Simulation
|
|
16
|
+
from .measures import (
|
|
17
|
+
Cabs, Cback, Cext, Cforward, Cpr, Cratio, Csca,
|
|
18
|
+
Measure, MeasureLike, MeasureName, Qabs, Qback, Qext, Qforward, Qpr, Qratio, Qsca,
|
|
19
|
+
coupling, cross_section, g, g_with_farfields, size_parameter,
|
|
20
|
+
)
|
|
21
|
+
from .distributions import ParticleSizeDistribution
|
|
22
|
+
from .inverse import FitResult, Observation, Parameter, fit_parameters
|
|
23
|
+
from .results import SimulationResult, SimulationResults
|
|
24
|
+
from .coordinates import Cartesian, Spherical, VectorField
|
|
25
|
+
from .experiment.detector_set import CoherentModeSet, PhotodiodeSet
|
|
26
|
+
from .experiment.material_set import MaterialSet, MediumSet
|
|
27
|
+
from .experiment.polarization_set import PolarizationSet
|
|
28
|
+
from .experiment.scatterer_set import CoreShellSet, InfiniteCylinderSet, SphereSet
|
|
29
|
+
from .experiment.source_set import GaussianSet, PlaneWaveSet
|
|
30
|
+
from .experiment.setup import Setup as Experiment
|
|
31
|
+
from .material import (
|
|
32
|
+
ConstantMaterial,
|
|
33
|
+
ConstantMedium,
|
|
34
|
+
print_available,
|
|
35
|
+
SellmeierMaterial,
|
|
36
|
+
SellmeierMedium,
|
|
37
|
+
TabulatedMaterial,
|
|
38
|
+
TabulatedMedium,
|
|
39
|
+
)
|
|
40
|
+
from .materials import (
|
|
41
|
+
MaterialInfo,
|
|
42
|
+
available_materials,
|
|
43
|
+
load_material,
|
|
44
|
+
load_tabulated,
|
|
45
|
+
material_info,
|
|
46
|
+
validate_refractive_indices,
|
|
47
|
+
validate_material,
|
|
48
|
+
validate_tabulated_data,
|
|
49
|
+
validate_wavelength,
|
|
50
|
+
)
|
|
51
|
+
from .mesh import FibonacciMesh, FullMesh
|
|
52
|
+
from .labeled_array import LabeledArray
|
|
53
|
+
from .polarization import LeftCircular, PolarizationState, RightCircular
|
|
54
|
+
from .single import Setup
|
|
55
|
+
from .single.detector import CoherentMode, IntegratingSphere, Photodiode
|
|
56
|
+
from .single.scatterer import CoreShell, InfiniteCylinder, Sphere
|
|
57
|
+
from .single.source import Gaussian, PlaneWave
|
|
58
|
+
from .units import ureg
|
|
59
|
+
|
|
60
|
+
__all__ = [
|
|
61
|
+
"ParticleSizeDistribution",
|
|
62
|
+
"FitResult",
|
|
63
|
+
"Observation",
|
|
64
|
+
"Parameter",
|
|
65
|
+
"fit_parameters",
|
|
66
|
+
"Cartesian",
|
|
67
|
+
"CoherentMode",
|
|
68
|
+
"ConstantMaterial",
|
|
69
|
+
"ConstantMedium",
|
|
70
|
+
"Cabs",
|
|
71
|
+
"Cback",
|
|
72
|
+
"Cext",
|
|
73
|
+
"Cforward",
|
|
74
|
+
"Cpr",
|
|
75
|
+
"Cratio",
|
|
76
|
+
"Csca",
|
|
77
|
+
"CoreShell",
|
|
78
|
+
"CoreShellSet",
|
|
79
|
+
"CoherentModeSet",
|
|
80
|
+
"Experiment",
|
|
81
|
+
"FibonacciMesh",
|
|
82
|
+
"FullMesh",
|
|
83
|
+
"Gaussian",
|
|
84
|
+
"InfiniteCylinder",
|
|
85
|
+
"IntegratingSphere",
|
|
86
|
+
"LeftCircular",
|
|
87
|
+
"LabeledArray",
|
|
88
|
+
"MaterialSet",
|
|
89
|
+
"MaterialInfo",
|
|
90
|
+
"Measure",
|
|
91
|
+
"MeasureLike",
|
|
92
|
+
"MeasureName",
|
|
93
|
+
"MediumSet",
|
|
94
|
+
"Photodiode",
|
|
95
|
+
"PhotodiodeSet",
|
|
96
|
+
"PlaneWave",
|
|
97
|
+
"PolarizationState",
|
|
98
|
+
"PolarizationSet",
|
|
99
|
+
"Qabs",
|
|
100
|
+
"Qback",
|
|
101
|
+
"Qext",
|
|
102
|
+
"Qforward",
|
|
103
|
+
"Qpr",
|
|
104
|
+
"Qratio",
|
|
105
|
+
"Qsca",
|
|
106
|
+
"RightCircular",
|
|
107
|
+
"SellmeierMaterial",
|
|
108
|
+
"SellmeierMedium",
|
|
109
|
+
"Setup",
|
|
110
|
+
"Simulation",
|
|
111
|
+
"Sphere",
|
|
112
|
+
"SphereSet",
|
|
113
|
+
"SimulationResult",
|
|
114
|
+
"SimulationResults",
|
|
115
|
+
"Spherical",
|
|
116
|
+
"TabulatedMaterial",
|
|
117
|
+
"TabulatedMedium",
|
|
118
|
+
"VectorField",
|
|
119
|
+
"coupling",
|
|
120
|
+
"cross_section",
|
|
121
|
+
"g",
|
|
122
|
+
"g_with_farfields",
|
|
123
|
+
"size_parameter",
|
|
124
|
+
"GaussianSet",
|
|
125
|
+
"InfiniteCylinderSet",
|
|
126
|
+
"PlaneWaveSet",
|
|
127
|
+
"print_available",
|
|
128
|
+
"available_materials",
|
|
129
|
+
"load_material",
|
|
130
|
+
"load_tabulated",
|
|
131
|
+
"material_info",
|
|
132
|
+
"validate_refractive_indices",
|
|
133
|
+
"validate_material",
|
|
134
|
+
"validate_tabulated_data",
|
|
135
|
+
"validate_wavelength",
|
|
136
|
+
"__version__",
|
|
137
|
+
"ureg",
|
|
138
|
+
]
|
PyMieSim/_native.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Preflight checks for PyMieSim's compiled extension modules."""
|
|
2
|
+
|
|
3
|
+
from importlib.machinery import EXTENSION_SUFFIXES
|
|
4
|
+
from importlib.util import find_spec
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
REQUIRED_NATIVE_MODULES = (
|
|
8
|
+
"PyMieSim._pint",
|
|
9
|
+
"PyMieSim.coordinates",
|
|
10
|
+
"PyMieSim.material",
|
|
11
|
+
"PyMieSim.polarization",
|
|
12
|
+
"PyMieSim.mesh",
|
|
13
|
+
"PyMieSim.labeled_array",
|
|
14
|
+
"PyMieSim.distributions",
|
|
15
|
+
"PyMieSim.inverse",
|
|
16
|
+
"PyMieSim.single.mode_field",
|
|
17
|
+
"PyMieSim.single.setup",
|
|
18
|
+
"PyMieSim.single.source",
|
|
19
|
+
"PyMieSim.single.scatterer",
|
|
20
|
+
"PyMieSim.single.optical_interface",
|
|
21
|
+
"PyMieSim.single.detector",
|
|
22
|
+
"PyMieSim.experiment.polarization_set",
|
|
23
|
+
"PyMieSim.experiment.source_set",
|
|
24
|
+
"PyMieSim.experiment.material_set",
|
|
25
|
+
"PyMieSim.experiment.scatterer_set",
|
|
26
|
+
"PyMieSim.experiment.detector_set",
|
|
27
|
+
"PyMieSim.experiment._setup",
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
STARTUP_NATIVE_MODULES = REQUIRED_NATIVE_MODULES[:8]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _has_extension(module_name: str) -> bool:
|
|
34
|
+
"""Return whether an importable compiled module is available."""
|
|
35
|
+
try:
|
|
36
|
+
spec = find_spec(module_name)
|
|
37
|
+
except (ImportError, ModuleNotFoundError, FileNotFoundError):
|
|
38
|
+
return False
|
|
39
|
+
return spec is not None and any(spec.origin.endswith(suffix) for suffix in EXTENSION_SUFFIXES if spec.origin)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def missing_native_extensions(
|
|
43
|
+
modules: tuple[str, ...] = REQUIRED_NATIVE_MODULES,
|
|
44
|
+
) -> tuple[str, ...]:
|
|
45
|
+
"""Return compiled modules that are not discoverable in this install."""
|
|
46
|
+
return tuple(module for module in modules if not _has_extension(module))
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def check_native_extensions() -> None:
|
|
50
|
+
"""Raise an actionable error when the native package is incomplete."""
|
|
51
|
+
# Nested extension modules are imported by ``single`` and ``experiment``
|
|
52
|
+
# during package initialization. Checking them here would inspect them
|
|
53
|
+
# before their parent packages have finished loading.
|
|
54
|
+
missing = missing_native_extensions(STARTUP_NATIVE_MODULES)
|
|
55
|
+
if not missing:
|
|
56
|
+
return
|
|
57
|
+
|
|
58
|
+
missing_list = ", ".join(missing)
|
|
59
|
+
raise ImportError(
|
|
60
|
+
"PyMieSim's compiled native extensions are missing: "
|
|
61
|
+
f"{missing_list}. This usually means that PyMieSim was imported "
|
|
62
|
+
"from a source checkout before it was built, or that the package "
|
|
63
|
+
"was built for a different Python interpreter. Install a released "
|
|
64
|
+
"wheel with `python -m pip install PyMieSim`, or from this checkout "
|
|
65
|
+
"run `make editable` with the same Python used to run your code. "
|
|
66
|
+
"For a source build, see the 'Developer setup' section in "
|
|
67
|
+
"README.rst."
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
__all__ = [
|
|
72
|
+
"REQUIRED_NATIVE_MODULES",
|
|
73
|
+
"STARTUP_NATIVE_MODULES",
|
|
74
|
+
"check_native_extensions",
|
|
75
|
+
"missing_native_extensions",
|
|
76
|
+
]
|
|
Binary file
|
PyMieSim/_version.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '5.8.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (5, 8, 0)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = None
|
|
Binary file
|
PyMieSim/directories.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import PyMieSim
|
|
6
|
+
|
|
7
|
+
__all__ = ["root_path", "validation_data_path", "doc_path", "logo_path", "doc_css_path"]
|
|
8
|
+
|
|
9
|
+
root_path = Path(PyMieSim.__path__[0])
|
|
10
|
+
|
|
11
|
+
validation_data_path = root_path.joinpath("validation_data")
|
|
12
|
+
|
|
13
|
+
doc_path = root_path.parents[0].joinpath("docs")
|
|
14
|
+
|
|
15
|
+
logo_path = doc_path.joinpath("images/logo.png")
|
|
16
|
+
|
|
17
|
+
doc_css_path = doc_path.joinpath("source/_static/default.css")
|
|
18
|
+
|
|
19
|
+
if __name__ == "__main__":
|
|
20
|
+
for path_name in __all__:
|
|
21
|
+
path = locals()[path_name]
|
|
22
|
+
print(path)
|
|
23
|
+
assert path.exists(), f"Path {path_name} do not exists"
|
|
24
|
+
|
|
25
|
+
# -
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"""Independent-scattering reduction of spherical-particle parameter grids."""
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
from numpy.typing import NDArray
|
|
7
|
+
|
|
8
|
+
from ..distributions import ParticleSizeDistribution
|
|
9
|
+
from ..labeled_array import LabeledArray
|
|
10
|
+
from ..measures import MeasureLike, validate_measures
|
|
11
|
+
from .scatterer_set import SphereSet
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from .setup import Setup
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
INDEPENDENT_SCATTERING_ASSUMPTIONS = (
|
|
18
|
+
"Non-interacting particles under the same prescribed illumination.",
|
|
19
|
+
"No interparticle electromagnetic coupling or multiple scattering.",
|
|
20
|
+
"No positional correlations or interference between different particles.",
|
|
21
|
+
"Cross sections and coupled powers are averages per particle, not totals for a sample.",
|
|
22
|
+
)
|
|
23
|
+
CROSS_SECTIONS = ("Csca", "Cext", "Cabs", "Cback", "Cforward", "Cpr")
|
|
24
|
+
EFFICIENCIES = {"Q" + name[1:]: name for name in CROSS_SECTIONS}
|
|
25
|
+
SUPPORTED_MEASURES = (*CROSS_SECTIONS, *EFFICIENCIES, "g", "coupling")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def average_size_distribution(
|
|
29
|
+
experiment: "Setup",
|
|
30
|
+
distribution: ParticleSizeDistribution,
|
|
31
|
+
measures: tuple[MeasureLike, ...],
|
|
32
|
+
drop_unique_level: bool,
|
|
33
|
+
) -> LabeledArray:
|
|
34
|
+
"""Average validated sphere sweeps using the appropriate physical weights."""
|
|
35
|
+
if not isinstance(distribution, ParticleSizeDistribution):
|
|
36
|
+
raise TypeError("distribution must be a ParticleSizeDistribution")
|
|
37
|
+
if not isinstance(experiment.scatterer_set, SphereSet):
|
|
38
|
+
raise TypeError("Size-distribution averaging currently requires a SphereSet of homogeneous spheres")
|
|
39
|
+
components = (experiment.source_set, experiment.scatterer_set, experiment.detector_set)
|
|
40
|
+
if any(component is not None and component.is_sequential for component in components):
|
|
41
|
+
raise ValueError("Size-distribution averaging requires a Cartesian parameter grid, not sequential sets")
|
|
42
|
+
available = tuple(name for name in SUPPORTED_MEASURES if name in experiment.available_measures)
|
|
43
|
+
names = validate_measures(measures, available)
|
|
44
|
+
dimension = "scatterer:diameter"
|
|
45
|
+
diameters = distribution.diameters.to("meter").magnitude
|
|
46
|
+
configured = experiment.scatterer_set.get_mapping()[dimension].to("meter").magnitude
|
|
47
|
+
if np.shape(configured) != diameters.shape or not np.allclose(configured, diameters, rtol=1e-12, atol=0):
|
|
48
|
+
raise ValueError("SphereSet diameter nodes must match distribution.diameters in the same order")
|
|
49
|
+
|
|
50
|
+
cache: dict[str, LabeledArray] = {}
|
|
51
|
+
weights = distribution.number_fractions
|
|
52
|
+
|
|
53
|
+
def data(name: str) -> LabeledArray:
|
|
54
|
+
if name not in cache:
|
|
55
|
+
cache[name] = experiment._build_labeled_array([name], drop_unique_level=False)
|
|
56
|
+
return cache[name]
|
|
57
|
+
|
|
58
|
+
def mean(name: str) -> NDArray:
|
|
59
|
+
labeled = data(name)
|
|
60
|
+
return np.asarray(np.tensordot(labeled.as_numpy(), weights, axes=(labeled.dims.index(dimension), 0)))
|
|
61
|
+
|
|
62
|
+
arrays = []
|
|
63
|
+
weighting = {}
|
|
64
|
+
mean_area = np.sum(weights * (np.pi / 4) * diameters ** 2)
|
|
65
|
+
for name in names:
|
|
66
|
+
if name in EFFICIENCIES:
|
|
67
|
+
arrays.append(mean(EFFICIENCIES[name]) / mean_area)
|
|
68
|
+
weighting[name] = "mean_cross_section / mean_projected_area"
|
|
69
|
+
elif name == "g":
|
|
70
|
+
scattering = data("Csca")
|
|
71
|
+
axis = scattering.dims.index(dimension)
|
|
72
|
+
denominator = mean("Csca")
|
|
73
|
+
if np.any(~np.isfinite(denominator)) or np.any(denominator <= 0):
|
|
74
|
+
raise ValueError("Ensemble g is undefined where the mean scattering cross section is zero or nonpositive")
|
|
75
|
+
numerator = np.tensordot(data("g").as_numpy() * scattering.as_numpy(), weights, axes=(axis, 0))
|
|
76
|
+
arrays.append(numerator / denominator)
|
|
77
|
+
weighting[name] = "scattering_cross_section"
|
|
78
|
+
else:
|
|
79
|
+
arrays.append(mean(name))
|
|
80
|
+
weighting[name] = "number"
|
|
81
|
+
|
|
82
|
+
template = next(iter(cache.values()))
|
|
83
|
+
dims = [dim for dim in template.dims if dim != dimension]
|
|
84
|
+
coords = {dim: template.coords[dim] for dim in dims}
|
|
85
|
+
values = arrays[0] if len(arrays) == 1 else np.stack(arrays)
|
|
86
|
+
if len(arrays) > 1:
|
|
87
|
+
dims.insert(0, "measure")
|
|
88
|
+
coords["measure"] = np.asarray(names, dtype=object)
|
|
89
|
+
if drop_unique_level:
|
|
90
|
+
for axis in reversed(range(len(dims))):
|
|
91
|
+
if dims[axis] != "measure" and len(coords[dims[axis]]) == 1:
|
|
92
|
+
values = np.take(values, 0, axis=axis)
|
|
93
|
+
coords.pop(dims.pop(axis))
|
|
94
|
+
attrs = {
|
|
95
|
+
"units": {name: experiment._determine_unit(name) for name in names},
|
|
96
|
+
"coordinate_units": {dim: unit for dim, unit in template.attrs["coordinate_units"].items() if dim in dims},
|
|
97
|
+
"measures": tuple(names),
|
|
98
|
+
"approximation": "independent_scattering",
|
|
99
|
+
"assumptions": INDEPENDENT_SCATTERING_ASSUMPTIONS,
|
|
100
|
+
"weighting": weighting,
|
|
101
|
+
"size_distribution": {"diameters_m": diameters.tolist(), "number_fractions": weights.tolist()},
|
|
102
|
+
}
|
|
103
|
+
return LabeledArray(values, dims, coords, attrs, names[0] if len(names) == 1 else None)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|