Skip to content

Commit

Permalink
Merge pull request #602 from ASFHyP3/develop
Browse files Browse the repository at this point in the history
Release v9.0.2
  • Loading branch information
jtherrmann authored Jan 17, 2025
2 parents 029e960 + 507cf44 commit 8765915
Show file tree
Hide file tree
Showing 24 changed files with 101 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ on:

jobs:
call-changelog-check-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-changelog-check.yml@v0.12.0
uses: ASFHyP3/actions/.github/workflows/reusable-changelog-check.yml@v0.14.0
2 changes: 1 addition & 1 deletion .github/workflows/create-jira-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
call-create-jira-issue-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-create-jira-issue.yml@v0.12.0
uses: ASFHyP3/actions/.github/workflows/reusable-create-jira-issue.yml@v0.14.0
secrets:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/labeled-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ on:

jobs:
call-labeled-pr-check-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.12.0
uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.14.0
2 changes: 1 addition & 1 deletion .github/workflows/release-template-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ on:

jobs:
call-release-checklist-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-release-checklist-comment.yml@v0.12.0
uses: ASFHyP3/actions/.github/workflows/reusable-release-checklist-comment.yml@v0.14.0
secrets:
USER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
call-release-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-release.yml@v0.12.0
uses: ASFHyP3/actions/.github/workflows/reusable-release.yml@v0.14.0
with:
release_prefix: HyP3 GAMMA
secrets:
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ name: Static analysis
on: push

jobs:
# Docs: https://github.com/ASFHyP3/actions
call-secrets-analysis-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/reusable-secrets-analysis.yml@v0.12.0
uses: ASFHyP3/actions/.github/workflows/reusable-secrets-analysis.yml@v0.14.0

call-ruff-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/reusable-ruff.yml@v0.12.0
uses: ASFHyP3/actions/.github/workflows/reusable-ruff.yml@v0.14.0

call-mypy-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-mypy.yml@v0.14.0
2 changes: 1 addition & 1 deletion .github/workflows/tag-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ on:

jobs:
call-bump-version-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.12.0
uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.14.0
secrets:
USER_TOKEN: ${{ secrets.TOOLS_BOT_PAK }}
4 changes: 2 additions & 2 deletions .github/workflows/test-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ env:

jobs:
call-pytest-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-pytest.yml@v0.12.0
uses: ASFHyP3/actions/.github/workflows/reusable-pytest.yml@v0.14.0
with:
local_package_name: hyp3_gamma
python_versions: >-
["3.10"]
call-version-info-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.12.0
uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.14.0
with:
python_version: '3.10'

Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/)
and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [9.0.2]
### Added
- The [`static-analysis`](.github/workflows/static-analysis.yml) Github Actions workflow now includes `mypy` for type checking.

## [9.0.1]
### Changed
- The [`static-analysis`](.github/workflows/static-analysis.yml) Github Actions workflow now uses `ruff` rather than `flake8` for linting.
Expand Down
6 changes: 3 additions & 3 deletions hyp3_gamma/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ def rtc():


def phase_filter_valid_range(x: str) -> float:
x = float(x)
if 0.0 <= x <= 1.0:
return x
n = float(x)
if 0.0 <= n <= 1.0:
return n
raise ValueError(f'{x} not in range [0.0, 1.0]')


Expand Down
1 change: 1 addition & 0 deletions hyp3_gamma/dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def intersects_dem(geometry: ogr.Geometry) -> bool:
for feature in get_dem_features():
if feature.GetGeometryRef().Intersects(geometry):
return True
return False


def get_dem_file_paths(geometry: ogr.Geometry) -> list[str]:
Expand Down
8 changes: 5 additions & 3 deletions hyp3_gamma/insar/ifm_sentinel.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def get_bursts(mydir, name):
if name in myfile:
root = etree.parse(myfile)
for coord in root.iter('azimuthAnxTime'):
time.append(float(coord.text))
text = coord.text
assert text is not None
time.append(float(text))
for count in root.iter('burstList'):
total_bursts = int(count.attrib['count'])

Expand Down Expand Up @@ -166,7 +168,6 @@ def get_orbit_parameters(reference_file):
meta = root.find('metadataSection')
xmldata = meta.find('*[@ID="measurementOrbitReference"]').metadataWrap.xmlData
orbit = xmldata.find('safe:orbitReference', root.nsmap)

orbitnumber = orbit.find('safe:orbitNumber', root.nsmap)
relative_orbitnumber = orbit.find('safe:relativeOrbitNumber', root.nsmap)
cyclenumber = orbit.find('safe:cycleNumber', root.nsmap)
Expand Down Expand Up @@ -316,6 +317,7 @@ def make_parameter_file(
root = etree.parse(myfile)
for coord in root.iter('productFirstLineUtcTime'):
utc = coord.text
assert utc is not None
log.info(f'Found utc time {utc}')
t = utc.split('T')
log.info(f'{t}')
Expand Down Expand Up @@ -462,7 +464,7 @@ def insar_sentinel_gamma(
interf_pwr_s1_lt_tops_proc(reference, secondary, hgt, rlooks=rlooks, alooks=alooks, iterations=3, step=2)

g = open('offsetfit3.log')
offset = 1.0
offset = '1.0'
for line in g:
if 'final azimuth offset poly. coeff.:' in line:
offset = line.split(':')[1]
Expand Down
22 changes: 11 additions & 11 deletions hyp3_gamma/insar/unwrapping_geocoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def coords_from_sarpix_coord(in_mli_par: str, ref_azlin: int, ref_rpix: int, hei

selected_coords = [line for line in coord_log_lines if 'selected' in line]
log.info(f'Selected sarpix coordinates: {selected_coords[0]}')
coord_lst = selected_coords[0].split()[:-1]
coord_lst = [float(s) for s in coord_lst]
coord_lst_str = selected_coords[0].split()[:-1]
coord_lst = [float(s) for s in coord_lst_str]
return coord_lst


Expand All @@ -72,7 +72,7 @@ def get_coords(
ref_azlin: int = 0,
ref_rpix: int = 0,
height: float = 0.0,
in_dem_par: str = None,
in_dem_par: str | None = None,
) -> dict:
"""Args:
in_mli_par: GAMMA MLI par file
Expand Down Expand Up @@ -108,7 +108,7 @@ def read_bmp(file):
return data


def get_reference_pixel(coherence: np.array, window_size=(5, 5), coherence_threshold=0.3) -> tuple[int, int]:
def get_reference_pixel(coherence: np.ndarray, window_size=(5, 5), coherence_threshold=0.3) -> tuple[int, int]:
"""Args:
coherence: array of coherence values
window_size: window size over which to sum coherence values for each pixel
Expand All @@ -118,8 +118,8 @@ def get_reference_pixel(coherence: np.array, window_size=(5, 5), coherence_thres
array indices of the reference pixel
"""

def sum_valid_coherence_values(array: np.array) -> float:
if (array < coherence_threshold).any() or (array == 1.0).any():
def sum_valid_coherence_values(array: np.ndarray) -> float:
if (array < coherence_threshold).any() or (array == np.float64(1.0)).any():
return 0.0
return array.sum()

Expand All @@ -131,7 +131,7 @@ def sum_valid_coherence_values(array: np.array) -> float:
cval=0.0,
)
x, y = np.unravel_index(np.argmax(pixel_weights), pixel_weights.shape)
return x, y
return int(x), int(y)


def geocode_back(inname, outname, width, lt, demw, demn, type_):
Expand Down Expand Up @@ -208,6 +208,7 @@ def combine_water_mask(cc_mask_file, water_mask_sar_file):
water_mask_sar_data = read_bmp(water_mask_sar_file)
in_data[water_mask_sar_data == 0] = 0
out_im = Image.fromarray(in_data)
assert in_palette is not None
out_im.putpalette(in_palette)
out_file = os.path.join(os.path.dirname(cc_mask_file), 'combined_mask.bmp')
out_im.save(out_file)
Expand Down Expand Up @@ -326,12 +327,12 @@ def unwrapping_geocoding(
)

execute(
f'dispmap {ifgname}.adf.unw DEM/HGT_SAR_{rlooks}_{alooks} {mmli}.par' f' - {ifgname}.vert.disp 1',
f'dispmap {ifgname}.adf.unw DEM/HGT_SAR_{rlooks}_{alooks} {mmli}.par - {ifgname}.vert.disp 1',
uselogging=True,
)

execute(
f'dispmap {ifgname}.adf.unw DEM/HGT_SAR_{rlooks}_{alooks} {mmli}.par' f' - {ifgname}.los.disp 0',
f'dispmap {ifgname}.adf.unw DEM/HGT_SAR_{rlooks}_{alooks} {mmli}.par - {ifgname}.los.disp 0',
uselogging=True,
)

Expand Down Expand Up @@ -489,8 +490,7 @@ def main():
'-t',
'--tri',
default=0,
help='Triangulation method for mcf unwrapper: '
'0) filled traingular mesh (default); 1) Delaunay triangulation',
help='Triangulation method for mcf unwrapper: 0) filled traingular mesh (default); 1) Delaunay triangulation',
)
parser.add_argument('--alpha', default=0.6, type=float, help='adf filter alpha value (def=0.6)')
args = parser.parse_args()
Expand Down
2 changes: 1 addition & 1 deletion hyp3_gamma/metadata/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def create_metadata_file_set_insar(
processor_version: str,
ref_point_coords: dict,
phase_filter_parameter: float,
) -> list[Path]:
) -> list[Path | None]:
payload = insar.marshal_metadata(
product_dir=product_dir,
reference_granule_name=reference_granule_name,
Expand Down
30 changes: 16 additions & 14 deletions hyp3_gamma/metadata/insar.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, payload: dict):
self.product_dir = payload['product_dir']
self.product_name = payload['product_dir'].name

def create_metadata_file_set(self) -> list[Path]:
def create_metadata_file_set(self) -> list[Path | None]:
files = []
generators = [
self.create_readme,
Expand Down Expand Up @@ -44,32 +44,34 @@ def create_metadata_file_set(self) -> list[Path]:
def create_readme(self) -> Path:
reference_file = self.product_dir / f'{self.product_name}_amp.tif'

return self.create_metadata_file(
metadata_file = self.create_metadata_file(
self.payload,
'insar/readme.md.txt.j2',
reference_file,
out_ext='README.md.txt',
strip_ext=True,
name_only=True,
)
assert metadata_file is not None
return metadata_file

def create_amp_xml(self) -> Path:
def create_amp_xml(self) -> Path | None:
reference_file = self.product_dir / f'{self.product_name}_amp.tif'
return self.create_metadata_file(self.payload, 'insar/amp_tif.xml.j2', reference_file)

def create_coherence_xml(self) -> Path:
def create_coherence_xml(self) -> Path | None:
reference_file = self.product_dir / f'{self.product_name}_corr.tif'
return self.create_metadata_file(self.payload, 'insar/corr_tif.xml.j2', reference_file)

def create_dem_tif_xml(self) -> Path:
def create_dem_tif_xml(self) -> Path | None:
reference_file = self.product_dir / f'{self.product_name}_dem.tif'
return self.create_metadata_file(self.payload, 'insar/dem.xml.j2', reference_file)

def create_los_displacement_xml(self) -> Path:
def create_los_displacement_xml(self) -> Path | None:
reference_file = self.product_dir / f'{self.product_name}_los_disp.tif'
return self.create_metadata_file(self.payload, 'insar/los_disp_tif.xml.j2', reference_file)

def create_look_vector_xmls(self) -> list[Path]:
def create_look_vector_xmls(self) -> list[Path | None]:
reference_file_phi = self.product_dir / f'{self.product_name}_lv_phi.tif'
reference_file_theta = self.product_dir / f'{self.product_name}_lv_theta.tif'
output_files = [
Expand All @@ -78,7 +80,7 @@ def create_look_vector_xmls(self) -> list[Path]:
]
return output_files

def create_browse_xmls(self) -> list[Path]:
def create_browse_xmls(self) -> list[Path | None]:
reference_file_col = self.product_dir / f'{self.product_name}_color_phase.png'
reference_file_unw = self.product_dir / f'{self.product_name}_unw_phase.png'
output_files = [
Expand All @@ -87,27 +89,27 @@ def create_browse_xmls(self) -> list[Path]:
]
return output_files

def create_unwrapped_phase_xml(self) -> Path:
def create_unwrapped_phase_xml(self) -> Path | None:
reference_file = self.product_dir / f'{self.product_name}_unw_phase.tif'
return self.create_metadata_file(self.payload, 'insar/unw_phase_tif.xml.j2', reference_file)

def create_vertical_displacement_xml(self) -> Path:
def create_vertical_displacement_xml(self) -> Path | None:
reference_file = self.product_dir / f'{self.product_name}_vert_disp.tif'
return self.create_metadata_file(self.payload, 'insar/vert_disp_tif.xml.j2', reference_file)

def create_wrapped_phase_xml(self) -> Path:
def create_wrapped_phase_xml(self) -> Path | None:
reference_file = self.product_dir / f'{self.product_name}_wrapped_phase.tif'
return self.create_metadata_file(self.payload, 'insar/wrapped_phase_tif.xml.j2', reference_file)

def create_inc_map_xml(self) -> Path:
def create_inc_map_xml(self) -> Path | None:
reference_file = self.product_dir / f'{self.product_name}_inc_map.tif'
return self.create_metadata_file(self.payload, 'insar/inc_map_tif.xml.j2', reference_file)

def create_inc_map_ell_xml(self) -> Path:
def create_inc_map_ell_xml(self) -> Path | None:
reference_file = self.product_dir / f'{self.product_name}_inc_map_ell.tif'
return self.create_metadata_file(self.payload, 'insar/inc_map_ell_tif.xml.j2', reference_file)

def create_water_mask_xml(self) -> Path:
def create_water_mask_xml(self) -> Path | None:
reference_file = self.product_dir / f'{self.product_name}_water_mask.tif'
return self.create_metadata_file(self.payload, 'insar/water_mask_tif.xml.j2', reference_file)

Expand Down
Loading

0 comments on commit 8765915

Please sign in to comment.