def __generateMieEffective(self, n_particle, n_host, particle_mu, particle_sigma, effective_model=True, wavelen_n=1000, wavelen_max=1100.0, wavelen_min=100.0, particle_n=20, particle_max=20.0, particle_min=1.0): ''' Private function. Generates new effective mie-data file for the database. ''' if particle_n < 10: print( "Too few particles to calculate \ effective model: particle_n < 10") exit() n_x_rv = 10000 n_tht = 91 wavelengths = np.linspace(wavelen_min, wavelen_max, wavelen_n) / 1000.0 p_diameters = np.linspace(particle_min, particle_max, particle_n) o_f = ("mie_eff_p-%dum-%dum-%d_" % (particle_min, particle_max, particle_n) + 'np-%s_nh-%.2f_' % (n_particle.__format__('.2f'), n_host) + 'wave-%.1fnm-%.1fnm-%d' % (wavelen_min, wavelen_max, wavelen_n) + '.hdf5') o_f = baseDir + '/' + o_f # Calculate particle distribution N = lognorm(particle_sigma, scale=np.exp(particle_mu)) # Weight factors of each particle size pdf = N.pdf(p_diameters) pdf /= pdf.sum() weight = dict(zip(p_diameters, pdf)) df = 0 df = mie.generateMieDataEffective(wavelengths, p_normed_weights_dict=weight, number_of_rvs=n_x_rv, number_of_theta_angles=n_tht, n_particle=n_particle, n_silicone=n_host, p_diameters=p_diameters) print(df.info()) mie.saveMieDataToHDF5([df], particle_diameters=[p_diameters.mean()], out_fname=o_f, wavelengths=wavelengths * 1000.0) return(o_f)
def __generateMie(self, n_particle, n_host, particle_mu, particle_sigma, effective_model=True, wavelen_n=1000, wavelen_max=1100.0, wavelen_min=100.0, particle_n=20, particle_max=20.0, particle_min=1.0): ''' Private function. Generates new mie-data file for the database. ''' n_x_rv = 1000 n_tht = 90 wavelengths = np.linspace(wavelen_min, wavelen_max, wavelen_n) / 1000.0 p_diameters = np.linspace(particle_min, particle_max, particle_n) o_f = ("mie_p-%dum-%dum-%d_" % (particle_min, particle_max, particle_n) + 'np-%s_nh-%.2f_' % (n_particle.__format__('.2f'), n_host) + 'wave-%.1fnm-%.1fnm-%d' % (wavelen_min, wavelen_max, wavelen_n) + '.hdf5') o_f = baseDir + '/' + o_f df = mie.generateMieData(wavelengths, number_of_rvs=n_x_rv, number_of_theta_angles=n_tht, n_particle=n_particle, n_silicone=n_host, p_diameters=p_diameters) mie.saveMieDataToHDF5([df], particle_diameters=p_diameters, out_fname=o_f, wavelengths=wavelengths * 1000.0) return(o_f)
# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import numpy as np from pyraytracer import mieGenerator as mie if __name__ == '__main__': w = np.linspace(100, 1100, 501) p = np.linspace(3, 35, 50) p_weights = dict(zip(p, np.ones(50) / 50.0)) df = mie.generateMieDataEffective(wavelengths=w, p_normed_weights_dict=p_weights, number_of_rvs=1000, number_of_theta_angles=90, n_particle=1.83, n_silicone=1.55, p_diameters=p) mie.saveMieDataToHDF5(df_list=[df], particle_diameters=[1], wavelengths=w, out_fname="mieData.hdf5")