Beispiel #1
0
def test_normalize_negative_height():
    module = TopoModule(extent=extent)
    plt.imshow(pytest.sb_params['frame'], origin="lower", cmap = "viridis")
    plt.colorbar()
    plt.show()
    n = -200
    new_frame_negative, new_extent_negative = module.normalize_topography(pytest.sb_params['frame'].copy(),
                                                                          pytest.sb_params['extent'].copy(),
                                                                          max_height=1000, min_height= n)
    assert new_frame_negative.min() == n
    plt.imshow(new_frame_negative, origin="lower", cmap="viridis")
    plt.colorbar()
    plt.show()
    p=200
    new_frame_positive, new_extent_positive = module.normalize_topography(pytest.sb_params['frame'].copy(),
                                                                          pytest.sb_params['extent'].copy(),
                                                                          max_height=1000, min_height=p)
    assert new_frame_positive.min() == p
    plt.imshow(new_frame_positive, origin="lower", cmap="viridis")
    plt.colorbar()
    plt.show()

    c = 0
    new_frame_positive, new_extent_positive = module.normalize_topography(pytest.sb_params['frame'].copy(),
                                                                          pytest.sb_params['extent'].copy(),
                                                                          max_height=1000, min_height=c)
    assert new_frame_positive.min() == c
    plt.imshow(new_frame_positive, origin="lower", cmap="viridis")
    plt.colorbar()
    plt.show()
def test_topo_module():
    from sandbox import _calibration_dir, _test_data
    file = np.load(_test_data['topo'] + "DEM1.npz")
    frame = file['arr_0']
    frame = frame + np.abs(frame.min())

    _calibprojector = _calibration_dir + "my_projector_calibration.json"
    _calibsensor = _calibration_dir + "my_sensor_calibration.json"
    from sandbox.sensor import Sensor
    sensor = Sensor(calibsensor=_calibsensor, name="dummy")
    from sandbox.projector import Projector
    projector = Projector(calibprojector=_calibprojector)
    # Initialize the aruco detection
    from sandbox.main_thread import MainThread
    mainT = MainThread(sensor=sensor, projector=projector)
    mainT.load_frame(frame)

    # Start the thread
    #mainT.run()
    from sandbox.modules import TopoModule
    module = TopoModule(extent = extent)
    mainT.add_module(name='Topo', module=module)
    module.sea = True
    module.sea_contour = True
    mainT.update()
Beispiel #3
0
def test_update():
    pytest.sb_params['ax'].cla()
    module = TopoModule(extent=extent)
    sb_params = module.update(pytest.sb_params)
    ax = sb_params['ax']
    fig = sb_params['fig']
    ax.imshow(sb_params.get('frame'), vmin=sb_params.get('extent')[-2], vmax=sb_params.get('extent')[-1],
              cmap=sb_params.get('cmap'), norm=sb_params.get('norm'), origin='lower')
    fig.show()
Beispiel #4
0
def test_single_path():
    pytest.sb_params['ax'].cla()
    module = TopoModule(extent=extent)
    module.sea = True
    module.side_flooding = True
    sb_params = module.update(pytest.sb_params)
    ax = sb_params['ax']
    fig = sb_params['fig']

    ax.imshow(sb_params.get('frame'),  # vmin=sb_params.get('extent')[-2], vmax=sb_params.get('extent')[-1],
              cmap=sb_params.get('cmap'), norm=sb_params.get('norm'), origin='lower')
    ax.plot(module._marker_contour_val[0], module._marker_contour_val[1], 'r*')
    fig.show()
Beispiel #5
0
def test_add_countour():
    pytest.sb_params['ax'].cla()
    module = TopoModule(extent=extent)
    sb_params = module.update(pytest.sb_params)
    ax = sb_params['ax']
    fig = sb_params['fig']
    ax.imshow(sb_params.get('frame'), #vmin=sb_params.get('extent')[-2], vmax=sb_params.get('extent')[-1],
              cmap=sb_params.get('cmap'), norm=sb_params.get('norm'), origin='lower')
    fig.show()
    #pytest.sb_params['frame'] = frame
    module.sea = True
    module.sea_contour = True
    sb_params = module.update(pytest.sb_params)
    ax = sb_params['ax']
    fig = sb_params['fig']
    ax.imshow(sb_params.get('frame'), #vmin=sb_params.get('extent')[-2], vmax=sb_params.get('extent')[-1],
              cmap=sb_params.get('cmap'), norm=sb_params.get('norm'), origin='lower')
    fig.show()
    pytest.sb_params['ax'].cla()
    module.sea_contour = False
    #pytest.sb_params['frame'] = frame
    sb_params = module.update(pytest.sb_params)
    ax = sb_params['ax']
    fig = sb_params['fig']
    ax.imshow(sb_params.get('frame'), #vmin=sb_params.get('extent')[-2], vmax=sb_params.get('extent')[-1],
              cmap=sb_params.get('cmap'), norm=sb_params.get('norm'), origin='lower')
    fig.show()
Beispiel #6
0
 def load_modules(self, gempy_module: bool, **kwargs):
     from sandbox.modules import TopoModule, GradientModule, LoadSaveTopoModule, LandslideSimulation, SearchMethodsModule
     from sandbox.projector import ContourLinesModule, CmapModule
     self.Modules = {}
     self.Modules['ContourLinesModule'] = ContourLinesModule(
         extent=self.sensor.extent)
     self.Modules['CmapModule'] = CmapModule(extent=self.sensor.extent)
     self.Modules['TopoModule'] = TopoModule(extent=self.sensor.extent)
     self.Modules['GradientModule'] = GradientModule(
         extent=self.sensor.extent)
     self.Modules['LoadSaveTopoModule'] = LoadSaveTopoModule(
         extent=self.sensor.extent)
     self.Modules['LandslideSimulation'] = LandslideSimulation(
         extent=self.sensor.extent)
     self.Modules['SearchMethodsModule'] = SearchMethodsModule(
         extent=self.sensor.extent)
     self.Modules['SearchMethodsModule'].update_mesh(
         self.sensor.get_frame(),
         margins_crop=self.Modules['SearchMethodsModule'].margins_crop,
         fill_value=0)
     self.Modules['SearchMethodsModule'].activate_frame_capture = False
     if gempy_module:
         from sandbox.modules import GemPyModule
         geo_model = kwargs.get('geo_model')
         #load_example = kwargs.get('load_examples')
         #name_example = kwargs.get('name_example')
         self.Modules['GemPyModule'] = GemPyModule(
             geo_model=geo_model,
             extent=self.sensor.extent,
             box=self.sensor.physical_dimensions,
             #load_examples=load_example,
             #name_example=name_example,
             **kwargs)
def test_thread_module():
    from sandbox.modules import TopoModule, GradientModule
    proj = Projector(use_panel=True)
    sens = Sensor(name='kinect_v2', invert=True)
    smain = MainThread(sens, proj)

    topo = TopoModule(extent=sens.extent)
    grad = GradientModule(extent=sens.extent)

    smain.modules = [topo]
    smain.run()
Beispiel #8
0
    def load_modules(self,
                     gempy_module: bool = False,
                     gimli_module: bool = False,
                     torch_module: bool = False,
                     devito_module: bool = False,
                     kwargs_gempy_module: dict = {},
                     ):
        from sandbox.modules import (TopoModule, GradientModule, LoadSaveTopoModule, LandslideSimulation,
                                     SearchMethodsModule)
        from sandbox.projector import ContourLinesModule, CmapModule
        self.Modules = {'ContourLinesModule': ContourLinesModule(extent=self.sensor.extent),
                        'CmapModule': CmapModule(extent=self.sensor.extent),
                        'TopoModule': TopoModule(extent=self.sensor.extent),
                        'GradientModule': GradientModule(extent=self.sensor.extent),
                        'LoadSaveTopoModule': LoadSaveTopoModule(extent=self.sensor.extent),
                        'LandslideSimulation': LandslideSimulation(extent=self.sensor.extent),
                        'SearchMethodsModule': SearchMethodsModule(extent=self.sensor.extent)}
        #self.Modules['SearchMethodsModule'].update_mesh(self.sensor.get_frame(),
        #                                                margins_crop=self.Modules['SearchMethodsModule'].margins_crop,
        #                                                fill_value=0)
        #self.Modules['SearchMethodsModule'].activate_frame_capture = False
        if gempy_module and self._gempy_import:
            from sandbox.modules.gempy import GemPyModule
            self.Modules['GemPyModule'] = GemPyModule(extent=self.sensor.extent,
                                                      box=self.sensor.physical_dimensions,
                                                      **kwargs_gempy_module)
        if devito_module and self._devito_import:
            from sandbox.modules.devito import SeismicModule
            self.Modules['SeismicModule'] = SeismicModule(extent=self.sensor.extent)

        if gimli_module and self._pygimli_import:
            from sandbox.modules.gimli import GeoelectricsModule
            self.Modules['GeoelectricsModule'] = GeoelectricsModule(extent=self.sensor.extent)

        if torch_module and self._torch_import:
            from sandbox.modules.pytorch import LandscapeGeneration
            self.Modules['LandscapeGeneration'] = LandscapeGeneration(extent=self.sensor.extent)
Beispiel #9
0
def test_widgets():
    module = TopoModule(extent=extent)
    widgets = module.show_widgets()
    widgets.show()
Beispiel #10
0
def test_init():
    module = TopoModule()
    print(module)