Skip to content

Commit

Permalink
Remove WorkflowName from Workflow (#133)
Browse files Browse the repository at this point in the history
* fix opera burst regex to exclude prefix

this matched all the filepath instead of just the burst ID

* remove `WorkflowName`,  only use `run_wrapped_phase_sequential` in `wrapped_phase.py`
  • Loading branch information
scottstanie authored Sep 28, 2023
1 parent 3be2d50 commit 4683b84
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 69 deletions.
2 changes: 1 addition & 1 deletion src/dolphin/opera_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# OPERA_L2_CSLC-S1_T078-165495-IW3_20190906T232711Z_20230101T100506Z_S1A_VV_v1.0.h5

OPERA_BURST_RE = re.compile(
r"(?P<prefix>.*?)(?P<track>\d{3})[-_](?P<burst_id>\d{6})[-_](?P<subswath>iw[1-3])",
r"[tT](?P<track>\d{3})[-_](?P<burst_id>\d{6})[-_](?P<subswath>iw[1-3])",
re.IGNORECASE,
)

Expand Down
5 changes: 1 addition & 4 deletions src/dolphin/workflows/_cli_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pathlib import Path
from typing import Optional, Union

from .config import InterferogramNetworkType, ShpMethod, Workflow, WorkflowName
from .config import InterferogramNetworkType, ShpMethod, Workflow


def create_config(
Expand Down Expand Up @@ -39,15 +39,12 @@ def create_config(
network_type=InterferogramNetworkType.MANUAL_INDEX,
indexes=[(0, -1)],
)
workflow_name = WorkflowName.SINGLE
# Override the ministack size so that only one phase linking is run
ministack_size = 1000
else:
interferogram_network = {} # Use default
workflow_name = WorkflowName.STACK

cfg = Workflow(
workflow_name=workflow_name,
cslc_file_list=slc_files,
mask_file=mask_file,
input_options=dict(
Expand Down
8 changes: 0 additions & 8 deletions src/dolphin/workflows/_enums.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
from enum import Enum

__all__ = [
"WorkflowName",
"ShpMethod",
"UnwrapMethod",
"InterferogramNetworkType",
]


class WorkflowName(str, Enum):
"""Name of workflows."""

STACK = "stack"
SINGLE = "single"


class ShpMethod(str, Enum):
"""Method for finding SHPs during phase linking."""

Expand Down
13 changes: 2 additions & 11 deletions src/dolphin/workflows/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from dolphin.io import DEFAULT_HDF5_OPTIONS, DEFAULT_TIFF_OPTIONS
from dolphin.utils import get_cpu_count, get_dates, sort_files_by_date

from ._enums import InterferogramNetworkType, ShpMethod, UnwrapMethod, WorkflowName
from ._enums import InterferogramNetworkType, ShpMethod, UnwrapMethod
from ._yaml_model import YamlModel

__all__ = [
Expand Down Expand Up @@ -300,8 +300,6 @@ def _check_strides_against_res(cls, strides, info):
class Workflow(YamlModel):
"""Configuration for the workflow."""

workflow_name: WorkflowName = WorkflowName.STACK

# Paths to input/output files
input_options: InputOptions = Field(default_factory=InputOptions)
cslc_file_list: List[Path] = Field(
Expand Down Expand Up @@ -348,13 +346,6 @@ class Workflow(YamlModel):
)
unwrap_options: UnwrapOptions = Field(default_factory=UnwrapOptions)
output_options: OutputOptions = Field(default_factory=OutputOptions)
save_compressed_slc: bool = Field(
default=False,
description=(
"Whether the SAS should output and save the Compressed SLCs in addition to"
" the standard product output."
),
)

# General workflow metadata
worker_settings: WorkerSettings = Field(default_factory=WorkerSettings)
Expand All @@ -372,7 +363,7 @@ class Workflow(YamlModel):
# Stores the list of directories to be created by the workflow
_directory_list: List[Path] = PrivateAttr(default_factory=list)
model_config = ConfigDict(
extra="forbid", json_schema_extra={"required": ["cslc_file_list"]}
extra="allow", json_schema_extra={"required": ["cslc_file_list"]}
)

@field_validator("work_directory")
Expand Down
64 changes: 21 additions & 43 deletions src/dolphin/workflows/wrapped_phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from dolphin.interferogram import Network
from dolphin.opera_utils import make_nodata_mask

from . import sequential, single
from . import sequential
from .config import Workflow


Expand Down Expand Up @@ -114,49 +114,27 @@ def run(cfg: Workflow, debug: bool = False) -> tuple[list[Path], Path, Path, Pat
# If we pre-compute it from some big stack, we need to use that for SHP
# finding, not use the size of `slc_vrt_file`
shp_nslc = None
if cfg.workflow_name == "single":
phase_linked_slcs, comp_slc_file, tcorr_file = (
single.run_wrapped_phase_single(
slc_vrt_file=vrt_stack.outfile,
output_folder=pl_path,
half_window=cfg.phase_linking.half_window.model_dump(),
strides=strides,
reference_idx=0,
beta=cfg.phase_linking.beta,
mask_file=nodata_mask_file,
ps_mask_file=ps_output,
amp_mean_file=cfg.ps_options._amp_mean_file,
amp_dispersion_file=cfg.ps_options._amp_dispersion_file,
shp_method=cfg.phase_linking.shp_method,
shp_alpha=cfg.phase_linking.shp_alpha,
shp_nslc=shp_nslc,
block_shape=cfg.worker_settings.block_shape,
n_workers=cfg.worker_settings.n_workers,
gpu_enabled=cfg.worker_settings.gpu_enabled,
)
phase_linked_slcs, comp_slcs, tcorr_file = (
sequential.run_wrapped_phase_sequential(
slc_vrt_file=vrt_stack.outfile,
output_folder=pl_path,
half_window=cfg.phase_linking.half_window.model_dump(),
strides=strides,
beta=cfg.phase_linking.beta,
ministack_size=cfg.phase_linking.ministack_size,
mask_file=nodata_mask_file,
ps_mask_file=ps_output,
amp_mean_file=cfg.ps_options._amp_mean_file,
amp_dispersion_file=cfg.ps_options._amp_dispersion_file,
shp_method=cfg.phase_linking.shp_method,
shp_alpha=cfg.phase_linking.shp_alpha,
shp_nslc=shp_nslc,
block_shape=cfg.worker_settings.block_shape,
n_workers=cfg.worker_settings.n_workers,
gpu_enabled=cfg.worker_settings.gpu_enabled,
)
else:
phase_linked_slcs, comp_slcs, tcorr_file = (
sequential.run_wrapped_phase_sequential(
slc_vrt_file=vrt_stack.outfile,
output_folder=pl_path,
half_window=cfg.phase_linking.half_window.model_dump(),
strides=strides,
beta=cfg.phase_linking.beta,
ministack_size=cfg.phase_linking.ministack_size,
mask_file=nodata_mask_file,
ps_mask_file=ps_output,
amp_mean_file=cfg.ps_options._amp_mean_file,
amp_dispersion_file=cfg.ps_options._amp_dispersion_file,
shp_method=cfg.phase_linking.shp_method,
shp_alpha=cfg.phase_linking.shp_alpha,
shp_nslc=shp_nslc,
block_shape=cfg.worker_settings.block_shape,
n_workers=cfg.worker_settings.n_workers,
gpu_enabled=cfg.worker_settings.gpu_enabled,
)
)
comp_slc_file = comp_slcs[-1]
)
comp_slc_file = comp_slcs[-1]

if watcher:
watcher.notify_finished()
Expand Down
2 changes: 0 additions & 2 deletions tests/test_workflows_s1_disp.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def opera_slc_files(tmp_path, slc_stack) -> list[Path]:
def test_s1_disp_run_single(opera_slc_files: list[Path], tmpdir):
with tmpdir.as_cwd():
cfg = config.Workflow(
workflow_name=config.WorkflowName.SINGLE,
cslc_file_list=opera_slc_files,
input_options=dict(subdataset="/data/VV"),
interferogram_network=dict(
Expand All @@ -73,7 +72,6 @@ def test_s1_disp_run_single(opera_slc_files: list[Path], tmpdir):
def test_s1_disp_run_stack(opera_slc_files: list[Path], tmpdir):
with tmpdir.as_cwd():
cfg = config.Workflow(
workflow_name=config.WorkflowName.STACK,
cslc_file_list=opera_slc_files,
input_options=dict(subdataset="/data/VV"),
phase_linking=dict(
Expand Down

0 comments on commit 4683b84

Please sign in to comment.