def setup_retrieval_simulation(retrieval_type = "passive", scattering = False): """ Setup up a retrieval simulation with or without scattering. """ # # Scattering # ice = ScatteringSpecies("ice", D14(-1.0, 2.0), scattering_data = scattering_data, scattering_meta_data = scattering_meta) if scattering: scatterers = [ice] else: scatterers = [] ice.psd.t_min = 0.0 ice.psd.t_max = 275.0 # # Sensors # ici = ICI(stokes_dimension = 1) ici.sensor_line_of_sight = np.array([[135.0]]) ici.sensor_position = np.array([[600e3]]) cs = CloudSat() cs.range_bins = np.linspace(0, 30e3, 31) cs.sensor_line_of_sight = np.array([[135.0]]) cs.sensor_position = np.array([[600e3]]) cs.y_min = -35.0 if retrieval_type == "active": sensors = [cs] elif retrieval_type == "passive": sensors = [ici] else: sensors = [cs, ici] atmosphere = Atmosphere1D(absorbers = [O2(), N2(), H2O()], scatterers = scatterers, surface = Tessem()) simulation = ArtsSimulation(atmosphere = atmosphere, sensors = sensors) simulation.scattering_solver = Disort() return simulation
def test_simulation_scattering_combined(scattering_solver): ice = ScatteringSpecies("ice", D14(-1.0, 2.0), scattering_data = scattering_data, scattering_meta_data = scattering_meta) ice.psd.t_min = 0.0 ice.psd.t_max = 275.0 ici = ICI(channel_indices = [0, -1], stokes_dimension = 1) ici.sensor_line_of_sight = np.array([[135.0]]) ici.sensor_position = np.array([[600e3]]) cs = CloudSat(stokes_dimension = 1) cs.range_bins = np.linspace(0, 30e3, 31) cs.sensor_line_of_sight = np.array([[135.0]]) cs.sensor_position = np.array([[600e3]]) atmosphere = Atmosphere1D(absorbers = [O2(), N2(), H2O()], scatterers = [ice], surface = Tessem()) simulation = ArtsSimulation(atmosphere = atmosphere, data_provider = DataProvider(), sensors = [ici, cs]) simulation.scattering_solver = scattering_solver() simulation.setup() simulation.run() y = np.copy(simulation.workspace.y) return y
def arts_simulation(scattering=False, multiview=False): # Sensors if multiview: lines_of_sight = np.array([[135.0], [150.0], [180.0]]) positions = np.array([[600e3], [500e3], [600e3]]) ici = ICI(channel_indices=[0, -1], lines_of_sight=lines_of_sight, stokes_dimension=1, positions=positions) else: ici = ICI(channel_indices=[0, -1], stokes_dimension=1) mwi = MWI(channel_indices=[-2, -1], stokes_dimension=1) mwi.sensor_position = 500e3 mwi.sensor_line_of_sight = 180.0 sensors = [ici, mwi] # Atmosphere atmosphere = StandardAtmosphere() if scattering: ice = ScatteringSpecies("ice", D14(-1.0, 2.0), scattering_data=scattering_data, scattering_meta_data=scattering_meta) ice.psd.t_min = 0.0 ice.psd.t_max = 275.0 atmosphere.scatterers = [ice] data_provider = Tropical() if scattering: def gaussian_cloud_1(z): return 1e-4 * np.exp(-((z - 12e-3) / 1e3)**2.0) name = ice.name + "_" + ice.psd.moment_names[0] data_provider.add( FunctorDataProvider(name, "altitude", gaussian_cloud_1)) def gaussian_cloud_2(z): return 1e-4 * np.ones(z.shape) name = ice.name + "_" + ice.psd.moment_names[1] data_provider.add( FunctorDataProvider(name, "altitude", gaussian_cloud_2)) simulation = ArtsSimulation(atmosphere=atmosphere, sensors=sensors, data_provider=data_provider) return simulation
def test_simulation_tessem(): atmosphere = Atmosphere1D(absorbers=[O2(), N2(), H2O()], surface=Tessem()) mwi = MWI() mwi.sensor_line_of_sight = np.array([[135.0]]) mwi.sensor_position = np.array([[600e3]]) simulation = ArtsSimulation(atmosphere=atmosphere, data_provider=DataProvider(), sensors=[mwi]) simulation.setup() simulation.run() y1 = np.copy(mwi.y) simulation.run() y2 = np.copy(mwi.y) assert (np.all(np.isclose(y1, y2)))
def test_simulation_telsem(): atmosphere = Atmosphere1D(absorbers=[O2(), N2(), H2O()], surface=Telsem("/home/simon/Downloads")) mwi = MWI() mwi.sensor_line_of_sight = np.array([[135.0]]) mwi.sensor_position = np.array([[600e3]]) data_provider = DataProvider() data_provider.surface_temperature = 280.0 * np.ones((1, 1)) data_provider.latitude = 58.0 data_provider.longitude = 12.0 simulation = ArtsSimulation(atmosphere=atmosphere, data_provider=data_provider, sensors=[mwi]) simulation.setup() simulation.run()
def test_simulation_scattering(scattering_solver): ice = ScatteringSpecies("ice", D14(-1.0, 2.0), scattering_data = scattering_data, scattering_meta_data = scattering_meta) ice.psd.t_min = 0.0 ice.psd.t_max = 275.0 atmosphere = Atmosphere1D(absorbers = [O2(), N2(), H2O()], scatterers = [ice], surface = Tessem()) ici = ICI(stokes_dimension = 1, channel_indices = [1, -1]) ici.sensor_line_of_sight = np.array([[135.0]]) ici.sensor_position = np.array([[600e3]]) simulation = ArtsSimulation(atmosphere = atmosphere, data_provider = DataProvider(), sensors = [ici]) simulation.scattering_solver = scattering_solver() simulation.setup() simulation.run()
def test_simulation_absorption_jacobian(): atmosphere = Atmosphere1D(absorbers = [O2(), N2(), H2O()], surface = Tessem()) o2, n2, h2o = atmosphere.absorbers ici = ICI(channel_indices = [0, -1]) ici.sensor_line_of_sight = np.array([[135.0]]) ici.sensor_position = np.array([[600e3]]) simulation = ArtsSimulation(atmosphere = atmosphere, data_provider = DataProvider(), sensors = [ici]) simulation.jacobian.add(o2) simulation.jacobian.add(n2) simulation.jacobian.add(h2o) simulation.setup() simulation.run() return np.copy(simulation.workspace.jacobian.value)
def test_simulation_multiview(): atmosphere = Atmosphere1D(absorbers = [O2(), N2(), H2O()], surface = Tessem()) lines_of_sight = np.array([[135.0], [180.0]]) positions = np.array([[600e3], [600e3]]) ici = ICI(lines_of_sight=lines_of_sight, positions=positions) simulation = ArtsSimulation(atmosphere = atmosphere, data_provider = DataProvider(), sensors = [ici]) simulation.setup() simulation.run() y = np.copy(ici.y) assert(y.shape[0] == 2)
def test_simulation_scattering_jacobian(): ice = ScatteringSpecies("ice", D14(-1.0, 2.0), scattering_data = scattering_data, scattering_meta_data = scattering_meta) ice.psd.t_min = 0.0 ice.psd.t_max = 275.0 atmosphere = Atmosphere1D(absorbers = [O2(), N2(), H2O()], scatterers = [ice], surface = Tessem()) ici = ICI(channel_indices = [1, -1]) ici.sensor_line_of_sight = np.array([[135.0]]) ici.sensor_position = np.array([[600e3]]) simulation = ArtsSimulation(atmosphere = atmosphere, data_provider = DataProvider(), sensors = [ici]) simulation.jacobian.add(ice.mass_density) simulation.setup() simulation.run() print(simulation.workspace.particle_bulkprop_field.value) return np.copy(simulation.workspace.jacobian.value)
def test_simulation_combined(): surface_1 = Tessem() surface_2 = Telsem("/home/simon/Downloads") surface = CombinedSurface(surface_1, surface_2) atmosphere = Atmosphere1D(absorbers=[O2(), N2(), H2O()], surface=surface) mwi = MWI() mwi.sensor_line_of_sight = np.array([[135.0]]) mwi.sensor_position = np.array([[600e3]]) data_provider = DataProvider() data_provider.surface_temperature = 280.0 * np.ones((1, 1)) data_provider.surface_latitude = 58.0 data_provider.surface_longitude = 12.0 data_provider.surface_type = 0.0 simulation = ArtsSimulation(atmosphere=atmosphere, data_provider=data_provider, sensors=[mwi]) simulation.setup() simulation.run() y = np.copy(mwi.y) atmosphere_r = Atmosphere1D(absorbers=[O2(), N2(), H2O()], surface=surface_1) simulation_r = ArtsSimulation(atmosphere=atmosphere_r, data_provider=data_provider, sensors=[mwi]) simulation_r.setup() simulation_r.run() y_r = np.copy(mwi.y) assert (np.allclose(y, y_r)) data_provider.surface_type = 1.0 simulation.setup() simulation.run() y = np.copy(mwi.y) atmosphere_r = Atmosphere1D(absorbers=[O2(), N2(), H2O()], surface=surface_2) simulation_r = ArtsSimulation(atmosphere=atmosphere_r, data_provider=data_provider, sensors=[mwi]) simulation_r.setup() simulation_r.run() y_r = np.copy(mwi.y) assert (np.allclose(y, y_r))
data_provider = DataProvider(), sensors = [cs]) simulation.setup() simulation.run() y = np.copy(cs.y) assert(y.shape[0] == 2) assert(y.shape[-1] == 2) ice = ScatteringSpecies("ice", D14(-1.0, 2.0), scattering_data = scattering_data, scattering_meta_data = scattering_meta) ice.psd.t_min = 0.0 ice.psd.t_max = 275.0 atmosphere = Atmosphere1D(absorbers = [O2(), N2(), H2O()], scatterers = [], surface = Tessem()) ici = ICI(stokes_dimension = 1, channel_indices = [1, -1]) ici.sensor_line_of_sight = np.array([[135.0]]) ici.sensor_position = np.array([[600e3]]) simulation = ArtsSimulation(atmosphere = atmosphere, data_provider = DataProvider(), sensors = [ici]) simulation.scattering_solver = RT4() simulation.setup() for i in range(100): simulation.run()