def testOSOAA(self): s = pyOSOAA.OSOAA(resroot="test") self.assertEqual(s.resroot, "test") self.assertEqual(s.wa, 0.440) s = pyOSOAA.OSOAA() self.assertIsNotNone(s.resroot) self.assertIsNotNone(s.root) self.assertListEqual(list(vars(s).keys()), ["wa", "root", "resroot", "sea", "log", "results", "dirmie", "phyto", "sed", "ys", "det", "ap", "aer", "hyd", "ang", "sos", "view", "logfile"]) s.run() self.assertTrue(os.path.exists(s.resroot)) self.assertTrue(os.path.exists(s.dirmie.aer)) self.assertTrue(os.path.exists(s.dirmie.hyd)) self.assertTrue(os.path.exists(s.dirmie.sea)) self.assertTrue(os.path.isfile(s.resroot+"/script.kzh")) self.assertTrue(os.path.isfile(s.resroot + "/Standard_outputs/" + "LUM_vsVZA.txt")) self.assertTrue(s.outputs.vsvza.I[51], 0.128266)
def testRunWavelenghtsOtherOutput(self): s = pyOSOAA.OSOAA() wl = [0.44, 0.55, 0.66] view = 0 expected = [0.229523, 0.158827, 0.456162E-02] result = pyOSOAA.osoaahelpers.RunWavelengths(s, wl, view, "refl") self.assertListEqual(list(result), expected)
def testRunWavelenghtsDifferentAngle(self): s = pyOSOAA.OSOAA() wl = [0.44, 0.55, 0.66] view = [0, 1.43, -1.43] expected = [0.128266, 0.639702E-01, 0.399984E-04] result = pyOSOAA.osoaahelpers.RunWavelengths(s, wl, view) self.assertListEqual(list(result), expected)
def testRunWavelenghtsSameAngle(self): s = pyOSOAA.OSOAA() wl = [0.44, 0.55, 0.66] view = 0 expected = [0.128266, 0.639862E-01, 0.399832E-04] result = pyOSOAA.osoaahelpers.RunWavelengths(s, wl, view) self.assertListEqual(list(result), expected)
def testRESULTS(self): # We test default values self.assertIsNone(pyOSOAA.RESULTS().profileatm) self.assertIsNone(pyOSOAA.RESULTS().profilesea) self.assertIsNone(pyOSOAA.RESULTS().aer) self.assertIsNone(pyOSOAA.RESULTS().phyto) self.assertIsNone(pyOSOAA.RESULTS().mlp) self.assertIsNone(pyOSOAA.RESULTS().angrad) self.assertIsNone(pyOSOAA.RESULTS().angmie) self.assertIsNone(pyOSOAA.RESULTS().sosbin) self.assertIsNone(pyOSOAA.RESULTS().vsvza) self.assertEqual(pyOSOAA.RESULTS().advup, "resfile_advup.txt") self.assertEqual(pyOSOAA.RESULTS().advdown, "resfile_advdown.txt") self.assertEqual(pyOSOAA.RESULTS().vsz, "resfile_vsz.txt") # We test different Values s = pyOSOAA.OSOAA() s.results.vsz = "test_vsz.txt" s.results.vsvza = "test_vsvza.txt" s.results.profileatm = "test_profileatm.txt" s.results.profilesea = "test_profilesea.txt" s.results.aer = "test_aer.txt" s.results.phyto = "test_phyto.txt" s.results.mlp = "test_mlp.txt" s.results.angrad = "test_angrad.txt" s.results.angmie = "test_angmie.txt" s.results.sosbin = "test_sosbin" s.results.advup = "test_advup.txt" s.results.advdown = "test_advdown.txt" s.run() self.assertTrue( os.path.exists(s.resroot + "/Standard_outputs/" + "test_vsz.txt")) self.assertTrue( os.path.exists(s.resroot + "/Standard_outputs/" + "test_vsvza.txt")) self.assertTrue( os.path.exists(s.resroot + "/Advanced_outputs/" + "test_profileatm.txt")) self.assertTrue( os.path.exists(s.resroot + "/Advanced_outputs/" + "test_profilesea.txt")) self.assertTrue( os.path.exists(s.resroot + "/Advanced_outputs/" + "test_aer.txt")) self.assertTrue( os.path.exists(s.resroot + "/Advanced_outputs/" + "test_phyto.txt")) self.assertTrue( os.path.exists(s.resroot + "/Advanced_outputs/" + "test_mlp.txt")) self.assertTrue( os.path.exists(s.resroot + "/Advanced_outputs/" + "test_angrad.txt")) self.assertTrue( os.path.exists(s.resroot + "/Advanced_outputs/" + "test_sosbin")) self.assertTrue( os.path.exists(s.resroot + "/Advanced_outputs/" + "test_advup.txt")) self.assertTrue( os.path.exists(s.resroot + "/Advanced_outputs/" + "test_advdown.txt"))
def testConfigureOceanBlack(self): s = pyOSOAA.OSOAA() wl = [0.44, 0.55, 0.66] view = 0 expected = [0.0, 0.0, 0.0] s.view.level = 4 s = pyOSOAA.osoaahelpers.ConfigureOcean(s, "black") result = pyOSOAA.osoaahelpers.RunWavelengths(s, wl, view) self.assertListEqual(list(result), expected)
def simulate(satellite="seawifs", sun=30, view=0, phi=90, level=1, chl=1, aero=3, rh=80, aot=0.1, wind=0, ap=False, gettau=False): s = pyOSOAA.OSOAA(cleanup=True) # Ocean s.phyto.chl = chl s.sea.depth = 100 s.sea.botalb = 0 if chl == 0: s = pyOSOAA.osoaahelpers.ConfigureOcean(s, ocean_type="black") # Surface s.sea.wind = wind s.sea.surfalb = 0 # Aerosol s.aer.SetModel(model=2, sfmodel=aero, rh=rh) s.aer.aotref = aot # Geometry s.view.phi = phi s.ang.thetas = sun view = view s.view.level = level if ap is True: s.ap.SetMot(0) # Run code for all bands rho = [] tauaer = [] tauray = [] for wa in tqdm(list_satellite[satellite], leave=False): # If we want no molecular scattering if ap is True: s.ap.SetMot(0) s.wa = wa / 1e3 s.run() rho = np.append( rho, np.interp(view, s.outputs.vsvza.vza, s.outputs.vsvza.I)) # This is an approximation to the optical thickness tauaer = np.append(tauaer, (s.outputs.profileatm.tau * np.mean(s.outputs.profileatm.mixaer))[-1]) tauray = np.append(tauray, (s.outputs.profileatm.tau * np.mean(s.outputs.profileatm.mixray))[-1]) # If we asked for the optical thicknes if gettau: return tauray, tauaer else: return list_satellite[satellite], rho
def testRunWavelenghtsErrorCatch(self): s = pyOSOAA.OSOAA() with self.assertRaises(Exception) as context: pyOSOAA.osoaahelpers.RunWavelengths(s, 0.5, 0, "wrong") self.assertTrue("Wrong output variable." in str(context.exception))
def testConfigureOceanBlackErrorCatch(self): s = pyOSOAA.OSOAA() with self.assertRaises(Exception) as context: pyOSOAA.osoaahelpers.ConfigureOcean(s, "wrong") self.assertTrue("Wrong ocean type." in str(context.exception))
import pyOSOAA from tqdm import tqdm fondos = { 1: "Negro", 2: "Arena clara", 3: "Algas verdes", 4: "Algas marrones", 5: "Algas rojas" } # Configuro latexify a dos columnas latexify(fig_width=7, fontawesome=True, siunitx=True) profundidad = 30 # We configure simulation s = pyOSOAA.OSOAA() tipos = np.array([1, 2, 3, 4, 5]) R_dict = {} rho_dict = {} sun = 0 wl = np.arange(400, 701, 5) R_dict_001 = {} rho_dict_001 = {} chl = 0.01 for tipo in tqdm(tipos): # We create the pyOSOAA object and define the wavelengths using the SeaWiFS values R = [] rho = [] for wa in wl:
modelos = {1 : "Modelo troposférico - Shettle y Fenn", 2 : "Modelo urbano - Shettle y Fenn", 3 : "Modelo maritimo - Shettle y Fenn", 4 : "Modelo costero - Shettle y Fenn"} fondos = {1:"Negro", 2:"Arena clara", 3:"Algas verdes", 4:"Algas marrones", 5:"Algas rojas"} # Configuro latexify a dos columnas latexify(columns=2, fontawesome=True, siunitx=True) #latexify(fig_width=7, fontawesome=True, siunitx=True) profundidad = 100 # We configure simulation s = pyOSOAA.OSOAA() wl = np.array([412., 443., 490., 510., 555., 670., 765., 865.]) sun = 35 view = 0 phi = 90 aot = 0.1 chl = 1 wind = 5 # Transmittance s = Py6S.SixS() s.geometry = Py6S.Geometry.User() s.geometry.solar_a = phi s.geometry.view_a = 0 s.geometry.solar_z = sun