Skip to content

Commit

Permalink
Fixing small issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mfangaritav committed Aug 14, 2024
1 parent 16c961a commit 504e548
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 11 deletions.
5 changes: 2 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: hyp3-isce2
name: hyp3-isce2-forr
channels:
- conda-forge
- nodefaults
Expand All @@ -14,7 +14,7 @@ dependencies:
- asf_search>=6.4.0
- gdal
- opencv
- burst2safe>=1.0.0
- burst2safe
# For packaging, and testing
- flake8
- flake8-import-order
Expand All @@ -30,4 +30,3 @@ dependencies:
# For running
- hyp3lib>=3,<4
- s1_orbits
- burst2safe
2 changes: 1 addition & 1 deletion src/hyp3_isce2/insar_tops.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def insar_tops_packaged(
product_name = packaging.get_product_name(reference, secondary, pixel_spacing=int(pixel_size))

log.info('Begin ISCE2 TopsApp run')
insar_tops(reference, secondary, download=False)
#insar_tops(reference, secondary, download=False)
log.info('ISCE2 TopsApp run completed successfully')

product_dir = Path(product_name)
Expand Down
16 changes: 13 additions & 3 deletions src/hyp3_isce2/insar_tops_burst.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def insar_tops_single_burst(
def insar_tops_multi_burst(
reference: Iterable[str],
secondary: Iterable[str],
swaths: list = [1, 2, 3],
looks: str = '20x4',
apply_water_mask=False,
bucket: Optional[str] = None,
Expand All @@ -229,16 +230,25 @@ def insar_tops_multi_burst(
if not reference[0].split('_')[4] == secondary[0].split('_')[4]:
raise Exception('The secondary and reference granules do not have the same polarization')

reference_safe_path = burst2safe(reference)
#reference_safe_path = burst2safe(reference)
reference_safe_path = Path('S1A_IW_SLC__1SSV_20230212T025529_20230212T025534_047197_05A9B2_35DE.SAFE')
reference_safe = reference_safe_path.name.split('.')[0]
secondary_safe_path = burst2safe(secondary)
#secondary_safe_path = burst2safe(secondary)
secondary_safe_path = Path('S1A_IW_SLC__1SSV_20230916T025538_20230916T025542_050347_060FBD_DF45.SAFE')
secondary_safe = secondary_safe_path.name.split('.')[0]

range_looks, azimuth_looks = [int(looks) for looks in looks.split('x')]
swaths = list(set([int(granule.split('_')[2][2]) for granule in reference]))
polarization = reference[0].split('_')[4]

log.info('Begin ISCE2 TopsApp run')
insar_tops_packaged(
reference=reference_safe,
secondary=secondary_safe,
looks=looks,
swaths=swaths,
polarization=polarization,
azimuth_looks=azimuth_looks,
range_looks=range_looks,
apply_water_mask=apply_water_mask,
bucket=bucket,
bucket_prefix=bucket_prefix
Expand Down
12 changes: 8 additions & 4 deletions src/hyp3_isce2/packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def get_product_name(reference: str, secondary: str, pixel_spacing: int, slc: bo
Returns:
The name of the interferogram product.
"""
breakpoint()
reference_split = reference.split('_')
secondary_split = secondary.split('_')

Expand Down Expand Up @@ -322,6 +321,8 @@ def make_readme(
wrapped_phase_path = product_dir / f'{product_name}_wrapped_phase.tif'
info = gdal.Info(str(wrapped_phase_path), format='json')
secondary_granule_datetime_str = secondary_scene.split('_')[3]
if not 'T' in secondary_granule_datetime_str:
secondary_granule_datetime_str = secondary_scene.split('_')[5]

payload = {
'processing_date': datetime.now(timezone.utc),
Expand Down Expand Up @@ -483,9 +484,12 @@ def make_parameter_file(
EARTH_RADIUS = 6337286.638938101

parser = etree.XMLParser(encoding='utf-8', recover=True)

ref_tag = reference_scene[-10:-6]
sec_tag = secondary_scene[-10:-6]
if 'BURST' in reference_scene:
ref_tag = reference_scene[-10:-6]
sec_tag = secondary_scene[-10:-6]
else:
ref_tag = reference_scene[-4::]
sec_tag = secondary_scene[-4::]
reference_safe = [file for file in os.listdir('.') if file.endswith(f'{ref_tag}.SAFE')][0]
secondary_safe = [file for file in os.listdir('.') if file.endswith(f'{sec_tag}.SAFE')][0]

Expand Down
12 changes: 12 additions & 0 deletions src/hyp3_isce2/slc.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ def get_geometry_from_manifest(manifest_path: Path):
return footprint


def get_relative_orbit(granule: Path):
manifest_path = granule / 'manifest.safe'
manifest = ET.parse(manifest_path).getroot()

frame_element = [x for x in manifest.findall('.//metadataObject') if x.get('ID') == 'measurementOrbitReference'][0]
frame_element = [x for x in frame_element.findall('.//metadataWrap/xmlData')][0]

print(frame_element.get('type'))
relative_orbit = frame_element.findall('.//relativeOrbitNumber')[0].text
return relative_orbit


def get_dem_bounds(reference_granule: Path, secondary_granule: Path) -> tuple:
"""Get the bounds of the DEM to use in processing from SAFE KML files
Expand Down

0 comments on commit 504e548

Please sign in to comment.