The moments of the phase function produced by getAOPrt() were not being correctly weighted & normalized by the total scattering for each species and/or bin. My only change in this pull request is on line 241 of src/pyobs/aop.py:
before: pmom_ = pmom_.values.reshape((ns,p_,m_))
after: pmom_ = pmom_.values.reshape((ns,p_,m_)) * sca_.reshape((ns,1,1))
The explanation for this is as follows:
The moments are first fetched out of the file:
(line 238): pmom_ = mie.getAOP('pmom', bin, rh, q_mass=q_mass, wavelength=wavelength)
The moments are summed over each bin/tracer
(line 243): pmom[:,:,:m_] += pmom_[:,:,:]
Then to normalize, the moments are divided by the integrated scattering
(line 255): pmom = pmom / sca.reshape((ns,1,1))
The intention here is to weight each bin's/tracer's moments by that bin's/tracer's contribution to the total scattering. To achieve this, the moments should be multiplied by that bin's/tracer's individual scattering (sca_) inside the bin/tracer loop. Then the integrated moments should be divided by the integrated scattering, as is already done on line 255. My change to line 241 above adds the missing step, multiplying by each bin's/tracer's moments by its individual scattering.
P.S. Vim removes trailing whitespace when I save--that's why there are so many lines that have whitespace changes.
The moments of the phase function produced by
getAOPrt()
were not being correctly weighted & normalized by the total scattering for each species and/or bin. My only change in this pull request is on line 241 ofsrc/pyobs/aop.py
: before:pmom_ = pmom_.values.reshape((ns,p_,m_))
after:pmom_ = pmom_.values.reshape((ns,p_,m_)) * sca_.reshape((ns,1,1))
The explanation for this is as follows: The moments are first fetched out of the file: (line 238):
pmom_ = mie.getAOP('pmom', bin, rh, q_mass=q_mass, wavelength=wavelength)
The moments are summed over each bin/tracer (line 243):pmom[:,:,:m_] += pmom_[:,:,:]
Then to normalize, the moments are divided by the integrated scattering (line 255):pmom = pmom / sca.reshape((ns,1,1))
The intention here is to weight each bin's/tracer's moments by that bin's/tracer's contribution to the total scattering. To achieve this, the moments should be multiplied by that bin's/tracer's individual scattering (sca_) inside the bin/tracer loop. Then the integrated moments should be divided by the integrated scattering, as is already done on line 255. My change to line 241 above adds the missing step, multiplying by each bin's/tracer's moments by its individual scattering.P.S. Vim removes trailing whitespace when I save--that's why there are so many lines that have whitespace changes.