Exemplo n.º 1
0
def task_stack_snap(task: Task, dry_run, gpt_cache,cmd_dir,log):
    # TODO http://remote-sensing.eu/preprocessing-of-sentinel-1-sar-data-via-snappy-python-module/
    """ Run master-slave Stacking

    """
    snap_path = task.get_stack_path(full=True)
    log(f"Using ESA SNAP processing pipeline in  {snap_path}")
    os.makedirs(snap_path, exist_ok=True)
    cmd = os.path.join(cmd_dir, 'local-snap.sh')
    _eodata = task.config['eodata']
    _docker_mount = 'mnt'
    opts = [
        cmd,
        '--gpt-cache', gpt_cache,
        '--eodata', _eodata,
        '--snap_results', snap_path,
        '--swath', task.config['swath'],
        '--firstBurstIndex', task.config['firstBurstIndex'],
        '--lastBurstIndex', task.config['lastBurstIndex'],

        '--master', _local_eodata_relative_path(_eodata, task.config['master_path']),
        '--slave', _local_eodata_relative_path(_eodata, task.config['slave_path']),

    ]

    if dry_run:
        log("Command:")
        opts = opts + ['--dry-run']
    opts = opts + [' ']  # add space to the end for booleans
    # print(opts)
    # print(" ".join(opts))
    subprocess.run(opts)
Exemplo n.º 2
0
 def _ch_fs(b):
     _p = _local_eodata_relative_path(eodata, b)
     if os.path.isfile(os.path.join(_p, 'manifest.safe')):
         _m = os.path.join(_p, 'measurement')
         if os.path.isdir(_m):
             return '+' if any(os.scandir(_m)) else '~'
     return ''
Exemplo n.º 3
0
def validate_task(task, key) -> (bool, List[str]):
    my_keys = TASK_KIND_CLUSTER.keys()
    errors = []
    processed = False
    if key in my_keys:
        processed = True
        if key not in task.config:
            errors.append(f"key {key}  not found in config")
        else:
            _eodata = task.config['eodata']
            value = task.config[key]
            if key in ['predictor']:
                if not value:
                    errors.append(REQUIRED)
                elif not Path(value).is_dir():
                    errors.append('Not found')
                else:
                    template_path = Path(
                        importlib.util.find_spec(
                            task.config.get('template')).origin).parent
                    for f in ['config.json']:
                        if not (Path(value, f).is_file()
                                or Path(template_path, f).is_file()):
                            errors.append(f'{f} required by {__name__}')
                    for f in ['gm.pkl', 'tnorm.npy']:
                        if not (Path(value, f).is_file()):
                            errors.append(f'{f} required by {__name__}')
            elif key in ['eodata']:
                if not value:
                    errors.append(REQUIRED)
                elif not os.path.isdir(value):
                    errors.append('Not found')
            elif key in ['stack_results', 'ai_results']:
                if not value:
                    errors.append(REQUIRED)
                elif not Path(value).is_dir():
                    errors.append('Not found')
                elif not os.access(value, os.W_OK):
                    errors.append('Not writable')
            elif key in ['master', 'slave'] and not value:
                errors.append(REQUIRED)
            elif key in ['master_path', 'slave_path']:
                if value is None:
                    errors.append(REQUIRED)
                elif _eodata is None:
                    errors.append('Requires eodata')
                elif not Path(_local_eodata_relative_path(_eodata,
                                                          value)).is_dir():
                    errors.append('Not found')

    return processed, errors
Exemplo n.º 4
0
 def get_geometry_fit_data_frame(self,
                                 geometry,
                                 key='master') -> 'gpd.pd.DataFrame':
     # TODO use validate_all
     if key not in ['master', 'slave']:
         raise AssertionError("key: only 'master' or 'salve are supported'")
     for k in ['eodata', key + '_path']:
         e = self.validate(k)
         if e:
             raise RuntimeError(f"key '{k}' is invalid: {','.join(e)} ")
     _df = geoloc.swath_table(
         _local_eodata_relative_path(self.config['eodata'],
                                     self.config[key + '_path']), geometry)
     return _df