Skip to content

Commit

Permalink
Test InSAR workflow using the new InSAR specification (#1419)
Browse files Browse the repository at this point in the history
* add GUNW

* refactor and reformat

* change the h5dataset

* formate with black and refactor

* add GOFF

* fix typos

* condense the code

* add RUNW

* add ROFF RIFG RUNW

* reformat with black

* reformat

* rename the io to insar

* test the codes and add a test.py

* address VB comments

* add the georeference to the GUNW and GOFF products

* fix some parameters of pixelOffsets

* change the geolocation_grid

* fix the iono disable error

* fix the mixed mode

* revise the pixelOffsets dimension

* address VB 2rd review

* make insar new spec package

* fix the insar package issue

* test the insar workflow

* change the RUNW az and rg looks and fix VB comments

* change H5Dataset

* add the RIFG test

* refactor

* refactor the h5_prep

* fix product bug

* correlation surface peak

* fix h5_prep.run for insar

* run isort

* fix the geocode_insar bugs

* fix the unit tests

* fix the crossmul unit test

* attempt to fix the unit tests but failed

* change the productspec version from 1.0.0 to 0.9

* change the product.h5

* remove the odd looks checking

* remove prep_ds_insar

* some formats

* reformat the unwrap

* fix errors in unit test (#6)

* fix errors in unit test

* delete old files

Co-authored-by: Jungkyo Jung <[email protected]>

* address the crossmul unit test failure

* fix the crossmul and rubbersheet unit tests

* fix the hydrostatic

* fix minors

* product specification version

* minor change

* change 0.9 to 0.9.0

* change the prep_insar to prepare_insar_hdf5

* fix LY comments

* address LY comments

* reduce file size (#7)

Co-authored-by: Jungkyo Jung <[email protected]>

* fix geocode_insar bugs

* add the scenecenter parameters

* fix typos

* uploaded compressed files (#8)

Co-authored-by: Jungkyo Jung <[email protected]>

Co-authored-by: Xiaodong Huang <[email protected]>
Co-authored-by: Jungkyo Jung <[email protected]>
Co-authored-by: Jungkyo Jung <[email protected]>
  • Loading branch information
4 people authored and GitHub Enterprise committed Sep 25, 2023
1 parent 4cd3505 commit ade8e75
Show file tree
Hide file tree
Showing 37 changed files with 498 additions and 963 deletions.
4 changes: 2 additions & 2 deletions python/packages/nisar/products/insar/GUNW_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def add_grids_to_hdf5(self):
#unwrapped dataset parameters as tuples in the following
#order: dataset name, data type, description, and units
unwrapped_ds_params = [
("coherenceMagnigtude", np.float32,
("coherenceMagnitude", np.float32,
f"Coherence magnitude between {pol} layers",
"unitless"),
("connectedComponents", np.uint32,
Expand Down Expand Up @@ -256,7 +256,7 @@ def add_grids_to_hdf5(self):
("alongTrackOffset", np.float32,
"Along track offset",
"meters"),
("crossCorrelationPeak", np.float32,
("correlationSurfacePeak", np.float32,
"Normalized cross-correlation surface peak",
"unitless"),
("slantRangeOffset", np.float32,
Expand Down
2 changes: 1 addition & 1 deletion python/packages/nisar/products/insar/InSAR_L2_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def add_geocoding_to_procinfo_params_group(self):
proc_pcfg = self.cfg["processing"]
iono = proc_pcfg["ionosphere_phase_correction"]["enabled"]
wet_tropo = proc_pcfg["troposphere_delay"]["enable_wet_product"]
dry_tropo = proc_pcfg["troposphere_delay"]["enable_dry_product"]
dry_tropo = proc_pcfg["troposphere_delay"]["enable_hydrostatic_product"]

# if the troposphere delay is not enabled
if not proc_pcfg["troposphere_delay"]["enabled"]:
Expand Down
20 changes: 18 additions & 2 deletions python/packages/nisar/products/insar/InSAR_base_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def add_RSLC_to_procinfo_params_group(self, rslc_name: str):
np.bool_(rfi_mitigation_flag),
(
"Flag to indicate if RFI correction has been applied"
" to reference RSLC"
f" to {rslc_name} RSLC"
),
),
mixed_mode,
Expand All @@ -234,7 +234,23 @@ def add_RSLC_to_procinfo_params_group(self, rslc_name: str):
src_param_group = \
rslc_h5py_file_obj[f"{rslc.ProcessingInformationPath}/parameters"]

src_param_group.copy("referenceTerrainHeight", dst_param_group)
reference_terrain_height = "referenceTerrainHeight"
reference_terrain_height_description = \
f"Reference Terrain Height as a function of time for {rslc_name} RSLC"
if reference_terrain_height in src_param_group:
src_param_group.copy(reference_terrain_height, dst_param_group)
dst_param_group[reference_terrain_height].attrs['description'] = \
reference_terrain_height_description
else:
ds_param = DatasetParams(
"referenceTerrainHeight",
"None",
reference_terrain_height_description,
{
"units":"meters"
},
)
add_dataset_and_attrs(dst_param_group, ds_param)

for ds_param in ds_params:
add_dataset_and_attrs(dst_param_group, ds_param)
Expand Down
20 changes: 13 additions & 7 deletions python/packages/nisar/products/insar/InSAR_products_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import isce3

ISCE3_VERSION = isce3.__version__

PRODUCT_SPECIFICATION_VERSION = "0.9.0"

@dataclass
class InSARProductsInfo:
Expand Down Expand Up @@ -33,24 +33,30 @@ class InSARProductsInfo:

@classmethod
def Base(cls):
return cls("1.0.0", "", "", "", False)
return cls(PRODUCT_SPECIFICATION_VERSION,
"", "", "", False)

@classmethod
def RIFG(cls):
return cls("1.0.0", "RIFG", "L1", "0.1", False)
return cls(PRODUCT_SPECIFICATION_VERSION,
"RIFG", "L1", "0.1", False)

@classmethod
def ROFF(cls):
return cls("1.0.0", "ROFF", "L1", "0.1", False)
return cls(PRODUCT_SPECIFICATION_VERSION,
"ROFF", "L1", "0.1", False)

@classmethod
def RUNW(cls):
return cls("1.0.0", "RUNW", "L1", "0.1", False)
return cls(PRODUCT_SPECIFICATION_VERSION,
"RUNW", "L1", "0.1", False)

@classmethod
def GOFF(cls):
return cls("1.0.0", "GOFF", "L2", "0.1", True)
return cls(PRODUCT_SPECIFICATION_VERSION,
"GOFF", "L2", "0.1", True)

@classmethod
def GUNW(cls):
return cls("1.0.0", "GUNW", "L2", "0.1", True)
return cls(PRODUCT_SPECIFICATION_VERSION,
"GUNW", "L2", "0.1", True)
48 changes: 48 additions & 0 deletions python/packages/nisar/products/insar/ROFF_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,51 @@ def _add_datasets_to_pixel_offset_group(self):
ds_description,
units=ds_unit,
)

def add_swaths_to_hdf5(self):
"""
Add swaths to the HDF5
"""
super().add_swaths_to_hdf5()

# pull the offset parameters
is_roff, margin, rg_start, az_start,\
rg_skip, az_skip, rg_search, az_search,\
rg_chip, az_chip, ovs_factor = self._pull_pixel_offsets_params()

for freq, pol_list, _ in get_cfg_freq_pols(self.cfg):
# Create the swath group
swaths_freq_group_name = (
f"{self.group_paths.SwathsPath}/frequency{freq}"
)
swaths_freq_group = self.require_group(swaths_freq_group_name)

rslc_freq_group = self.ref_h5py_file_obj[
f"{self.ref_rslc.SwathPath}/frequency{freq}"
]

# add scene center parameters
scene_center_params = [
DatasetParams(
"sceneCenterAlongTrackSpacing",
rslc_freq_group["sceneCenterAlongTrackSpacing"][()]
* az_skip,
(
"Nominal along track spacing in meters between"
" consecutive lines near mid swath of the ROFF image"
),
{"units": "meters"},
),
DatasetParams(
"sceneCenterGroundRangeSpacing",
rslc_freq_group["sceneCenterGroundRangeSpacing"][()]
* rg_skip,
(
"Nominal ground range spacing in meters between"
" consecutive pixels near mid swath of the ROFF image"
),
{"units": "meters"},
),
]
for ds_param in scene_center_params:
add_dataset_and_attrs(swaths_freq_group, ds_param)
2 changes: 1 addition & 1 deletion python/packages/nisar/products/insar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from .InSAR_L1_writer import L1InSARWriter
from .RIFG_writer import RIFGWriter
from .ROFF_writer import ROFFWriter
from .RUNW_writer import RUNWWriter
from .RUNW_writer import RUNWWriter
4 changes: 0 additions & 4 deletions python/packages/nisar/products/insar/product_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ class RIFGGroupsPaths(L1GroupsPaths):
"""
ProductName: str = "RIFG"


@dataclass
class RUNWGroupsPaths(L1GroupsPaths):
"""
Expand All @@ -129,7 +128,6 @@ class RUNWGroupsPaths(L1GroupsPaths):
"""
ProductName: str = "RUNW"


@dataclass
class ROFFGroupsPaths(L1GroupsPaths):
"""
Expand All @@ -142,7 +140,6 @@ class ROFFGroupsPaths(L1GroupsPaths):
"""
ProductName: str = "ROFF"


@dataclass
class GUNWGroupsPaths(L2GroupsPaths):
"""
Expand All @@ -155,7 +152,6 @@ class GUNWGroupsPaths(L2GroupsPaths):
"""
ProductName: str = "GUNW"


@dataclass
class GOFFGroupsPaths(L2GroupsPaths):
"""
Expand Down
9 changes: 5 additions & 4 deletions python/packages/nisar/workflows/crossmul.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
import isce3
import journal
from osgeo import gdal

gdal.UseExceptions()

from nisar.products.readers import SLC
from nisar.workflows import h5_prep
from nisar.workflows import prepare_insar_hdf5
from nisar.workflows.compute_stats import compute_stats_real_data
from nisar.workflows.crossmul_runconfig import CrossmulRunConfig
from nisar.workflows.helpers import (complex_raster_path_from_h5,
get_cfg_freq_pols)
from nisar.workflows.crossmul_runconfig import CrossmulRunConfig
from nisar.workflows.yaml_argparse import YamlArgparse


Expand All @@ -43,7 +44,7 @@ def run(cfg: dict, output_hdf5: str = None, resample_type='coarse',
flatten_path = crossmul_params['flatten_path']

if output_hdf5 is None:
output_hdf5 = cfg['product_path_group']['sas_output_file']
output_hdf5 = str(scratch_path.joinpath('crossmul/product.h5'))

# init parameters shared by frequency A and B
ref_slc = SLC(hdf5file=ref_hdf5)
Expand Down Expand Up @@ -214,6 +215,6 @@ def stats_offsets(h5_ds, freq, pol):
# get a runconfig dict from command line args
crossmul_runconfig = CrossmulRunConfig(args, resample_type)
# prepare RIFG HDF5
out_paths = h5_prep.run(crossmul_runconfig.cfg)
out_paths = prepare_insar_hdf5.run(crossmul_runconfig.cfg)
# run crossmul
run(crossmul_runconfig.cfg, out_paths['RIFG'], resample_type)
Loading

0 comments on commit ade8e75

Please sign in to comment.