Beispiel #1
0
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))
Beispiel #2
0
    def __init__(self, data_provider, ice_shape="8-ColumnAggregate"):
        sensor = CloudSat()

        DataProviderBase.__init__(self)
        self.add(IceAPriori())
        self.add(RainAPriori())
        self.add(ObservationErrors())
        self.add(data_provider)

        Simulation.__init__(self, sensor, self, ice_shape=ice_shape)

        self.atmosphere.absorbers += [O2(model="PWR98")]

        scatterers = self.atmosphere.scatterers
        self.atmosphere._surface = Tessem()
        # Add first moment ice to retrieval and set transform
        ice = [s for s in scatterers if s.name == "ice"][0]
        self.retrieval.add(ice.moments[0])
        ice.moments[0].transformation = Log10()
        self._ice_water_content = ice.moments[0]

        # Add first moment of rain PSD to retrieval and set transform
        rain = [s for s in scatterers if s.name == "rain"][0]
        self.retrieval.add(rain.moments[0])
        rain.moments[0].transformation = Log10()
        self._rain_water_content = rain.moments[0]

        self.retrieval.settings["stop_dx"] = 1e-6
        self.cache_index = None

        self.iwc = None
        self.rwc = None
Beispiel #3
0
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
Beispiel #4
0
    def __init__(self,
                 hydrometeors,
                 sensors,
                 data_provider,
                 include_cloud_water=False):
        """
        Arguments:

            hydrometeors(list): List of the hydrometeors to use in the simulation.

            sensors(list): List of sensors for which to simulate observations.

            data_provider: Data provider object providing the simulation data.

            include_cloud_water(bool): Whether or not to include cloud water
        """
        self.include_cloud_water = include_cloud_water

        self.hydrometeors = hydrometeors
        absorbers = [
            O2(model="TRE05", from_catalog=False),
            N2(model="SelfContStandardType", from_catalog=False),
            H2O(model=["SelfContCKDMT320", "ForeignContCKDMT320"],
                lineshape="VP",
                normalization="VVH",
                cutoff=750e9)
        ]
        absorbers = [O2(), N2(), H2O()]
        if self.include_cloud_water:
            absorbers.insert(2, CloudWater(model="ELL07", from_catalog=False))
        scatterers = hydrometeors
        surface = Tessem()
        atmosphere = Atmosphere1D(absorbers, scatterers, surface)
        self.simulation = ArtsSimulation(atmosphere,
                                         sensors=sensors,
                                         scattering_solver=Disort(nstreams=16))
        self.sensors = sensors

        self.data_provider = data_provider
        self.simulation.data_provider = self.data_provider
Beispiel #5
0
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
Beispiel #6
0
    def __init__(self, dimensions=1, surface="ocean"):

        if not dimensions in [1]:
            raise Exception("Currently only 1D simulations are supported.")

        if not surface == "ocean":
            raise Exception(
                "Currently only simulations over ocean surfaces are supported."
            )

        super().__init__(dimensions=(0, ) * dimensions,
                         absorbers=[O2(), N2(), H2O()],
                         scatterers=[],
                         surface=Tessem())
Beispiel #7
0
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()
Beispiel #8
0
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)))
Beispiel #9
0
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)
Beispiel #10
0
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)
Beispiel #11
0
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()
Beispiel #12
0
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)
Beispiel #13
0
                                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()
Beispiel #14
0
    def __init__(self, hydrometeors, sensors, data_provider):

        cw_a = [p for p in data_provider.subproviders \
                if getattr(p, "name", "") == "cloud_water"]
        self.include_cloud_water = len(cw_a) > 0

        self.hydrometeors = hydrometeors
        absorbers = [
            O2(model="TRE05", from_catalog=False),
            N2(model="SelfContStandardType", from_catalog=False),
            H2O(model=["SelfContCKDMT320", "ForeignContCKDMT320"],
                from_catalog=True,
                lineshape="VP",
                normalization="VVH",
                cutoff=750e9)
        ]
        absorbers = [O2(), N2(), H2O()]
        if self.include_cloud_water:
            absorbers.insert(2, CloudWater(model="ELL07", from_catalog=False))
        scatterers = hydrometeors
        surface = Tessem()
        atmosphere = Atmosphere1D(absorbers, scatterers, surface)
        self.simulation = ArtsSimulation(atmosphere,
                                         sensors=sensors,
                                         scattering_solver=Disort(nstreams=16))
        self.sensors = sensors

        self.data_provider = data_provider
        self.simulation.data_provider = self.data_provider

        self._setup_retrieval()

        self.radar_only = all(
            [isinstance(s, ActiveSensor) for s in self.sensors])

        def radar_only(rr):

            rr.settings["max_iter"] = 30
            rr.settings["stop_dx"] = 1e-4
            rr.settings["method"] = "lm"
            rr.settings["lm_ga_settings"] = np.array(
                [1000.0, 3.0, 2.0, 10e3, 1.0, 1.0])

            rr.sensors = [s for s in rr.sensors if isinstance(s, ActiveSensor)]
            rr.retrieval_quantities = [h.moments[0] for h in self.hydrometeors]
            rr.retrieval_quantities += [
                h.moments[1] for h in self.hydrometeors
            ]
            #rr.retrieval_quantities = [h.moments[1] for h in self.hydrometeors]

        def all_quantities(rr):

            rr.settings["max_iter"] = 30
            rr.settings["stop_dx"] = 1e-2
            rr.settings["method"] = "lm"
            rr.settings["lm_ga_settings"] = np.array(
                [20.0, 5.0, 2.0, 1e5, 0.1, 1.0])

            if all([isinstance(s, PassiveSensor) for s in rr.sensors]):
                rr.settings["lm_ga_settings"] = np.array(
                    [20.0, 3.0, 2.0, 1e5, 0.1, 1.0])
            #else:
            #    rr.settings["lm_ga_settings"] = np.array(
            #        [10.0, 3.0, 2.0, 1e5, 1.0, 1.0])
            rr.retrieval_quantities = [h.moments[0] for h in self.hydrometeors]
            rr.retrieval_quantities += [
                h.moments[1] for h in self.hydrometeors
            ]

            if not self.h2o is None:
                rr.retrieval_quantities += [self.h2o]
            if not self.cw is None:
                rr.retrieval_quantities += [self.cw]
            if not self.temperature is None:
                rr.retrieval_quantities += [self.temperature]

        if all([isinstance(s, ActiveSensor) for s in self.sensors]):
            self.simulation.retrieval.callbacks = [("Radar only", radar_only)]
        elif any([isinstance(s, ActiveSensor) for s in self.sensors]):
            self.simulation.retrieval.callbacks = [
                #("Radar only", radar_only),
                ("All quantities", all_quantities)
            ]
        else:
            self.simulation.retrieval.callbacks = [("All quantities",
                                                    all_quantities)]