mb = ModelBehavior() accur = mb.accuracy deltamplus = mb.delta_m_plus dopseudosphere = mb.do_pseudo_sphere header = mb.header ibcnd = mb.incidence_beam_conditions onlyfl = mb.only_fluxes prnt = mb.print_variables radius = mb.radius usrang = mb.user_angles usrtau = mb.user_optical_depths # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Make the output arrays # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ oa = OutputArrays(cp) albmed = oa.albedo_medium flup = oa.diffuse_up_flux rfldn = oa.diffuse_down_flux rfldir = oa.direct_beam_flux dfdt = oa.flux_divergence uu = oa.intensity uavg = oa.mean_intensity trnmed = oa.transmissivity_medium # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Make the arrays I'm unsure about (for now) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uns = Unsure(cp) h_lyr = uns.h_lyr
def test_int_input_raises_type_error(self) -> None: with self.assertRaises(TypeError): OutputArrays(1)
def fit_ssa(guess, wav_index: int): # Trap the guess if not 0 <= guess <= 1: return 9999999 # Take care of surface variables albedo = hapke[wav_index].albedo lamber = hapke[wav_index].lambertian rhou = hapke[wav_index].rhou rhoq = hapke[wav_index].rhoq bemst = hapke[wav_index].bemst emust = hapke[wav_index].emust rho_accurate = hapke[wav_index].rho_accurate cext = dust_file.array['primary'].data[:, :, 0] csca = dust_file.array['primary'].data[:, :, 1] csca[:, 0:2] = guess * cext[:, 0:2] c_ext = ForwardScatteringProperty( cext, particle_size_grid=sizes, wavelength_grid=wavs) c_sca = ForwardScatteringProperty( csca, particle_size_grid=sizes, wavelength_grid=wavs) dust_properties = ForwardScatteringPropertyCollection() dust_properties.add_property(c_ext, 'c_extinction') dust_properties.add_property(c_sca, 'c_scattering') # Use the Curiosity OD dust_col = Column(dust_properties, model_eos, conrath_profile.profile, p_sizes, short_wav[pixel_index, :], 0.88, pixel_od[pixel_index], dust_phsfn) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Make the model # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ model = ModelAtmosphere() # Make tuples of (dtauc, ssalb, pmom) for each constituent dust_info = ( dust_col.total_optical_depth, dust_col.scattering_optical_depth, dust_col.scattering_optical_depth * dust_col.phase_function) rayleigh_info = ( rco2.scattering_optical_depths, rco2.scattering_optical_depths, rco2.phase_function) # This works since scat OD = total OD # Add dust and Rayleigh scattering to the model model.add_constituent(dust_info) model.add_constituent(rayleigh_info) model.compute_model() optical_depths = model.hyperspectral_total_optical_depths[:, wav_index] ssa = model.hyperspectral_total_single_scattering_albedos[:, wav_index] polynomial_moments = model.hyperspectral_legendre_moments[:, :, wav_index] # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Make the output arrays # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ oa = OutputArrays(cp) albmed = oa.albedo_medium flup = oa.diffuse_up_flux rfldn = oa.diffuse_down_flux rfldir = oa.direct_beam_flux dfdt = oa.flux_divergence uu = oa.intensity uavg = oa.mean_intensity trnmed = oa.transmissivity_medium # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Optical depth output structure # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ utau = UserLevel(cp, mb).optical_depth_output # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Run the model # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ rfldir, rfldn, flup, dfdt, uavg, uu, albmed, trnmed = \ disort.disort(usrang, usrtau, ibcnd, onlyfl, prnt, plank, lamber, deltamplus, dopseudosphere, optical_depths, ssa, polynomial_moments, temperatures, low_wavenumber, high_wavenumber, utau, mu0[pixel_index], phi0[pixel_index], mu[pixel_index], phi[pixel_index], fbeam, fisot, albedo, btemp, ttemp, temis, radius, h_lyr, rhoq, rhou, rho_accurate, bemst, emust, accur, header, rfldir, rfldn, flup, dfdt, uavg, uu, albmed, trnmed) return (uu[0, 0, 0] - reflectance[pixel_index, wav_index])**2
def setUp(self) -> None: self.oa = OutputArrays(ComputationalParameters(10, 30, 20, 40, 50, 60))