Skip to content

Commit

Permalink
Merge pull request #139 from ASFHyP3/develop
Browse files Browse the repository at this point in the history
Bumpless release
  • Loading branch information
jtherrmann authored Sep 12, 2023
2 parents 565259f + 79a1617 commit 94e93c1
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ on:
jobs:
call-changelog-check-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected].1
uses: ASFHyP3/actions/.github/workflows/[email protected].2
secrets:
USER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/coverage-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
Expand Down
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/[email protected].1
uses: ASFHyP3/actions/.github/workflows/[email protected].2
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 @@ -13,4 +13,4 @@ on:
jobs:
call-labeled-pr-check-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected].1
uses: ASFHyP3/actions/.github/workflows/[email protected].2
2 changes: 1 addition & 1 deletion .github/workflows/release-checklist-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
call-release-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected].1
uses: ASFHyP3/actions/.github/workflows/[email protected].2
permissions:
pull-requests: write
secrets:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
call-release-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected].1
uses: ASFHyP3/actions/.github/workflows/[email protected].2
with:
release_prefix: HyP3 ISCE2
secrets:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ on: push
jobs:
call-secrets-analysis-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected].1
uses: ASFHyP3/actions/.github/workflows/[email protected].2

call-flake8-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected].1
uses: ASFHyP3/actions/.github/workflows/[email protected].2
with:
local_package_names: hyp3_isce2
2 changes: 1 addition & 1 deletion .github/workflows/tag-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
call-bump-version-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected].1
uses: ASFHyP3/actions/.github/workflows/[email protected].2
with:
user: tools-bot
email: [email protected]
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ on:
jobs:
call-pytest-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected].1
uses: ASFHyP3/actions/.github/workflows/[email protected].2
with:
local_package_name: hyp3_isce2
python_versions: >-
["3.9", "3.10"]
call-version-info-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected].1
uses: ASFHyP3/actions/.github/workflows/[email protected].2

call-docker-ghcr-workflow:
needs: call-version-info-workflow
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected].1
uses: ASFHyP3/actions/.github/workflows/[email protected].2
with:
version_tag: ${{ needs.call-version-info-workflow.outputs.version_tag }}
release_branch: main
Expand Down
8 changes: 4 additions & 4 deletions src/hyp3_isce2/burst.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def wait_for_extractor(response: requests.Response, sleep_time: int = 15) -> boo
True if the burst was successfully downloaded, False otherwise.
"""
if response.status_code == 202:
time.sleep(15)
time.sleep(sleep_time)
return False

response.raise_for_status()
Expand Down Expand Up @@ -382,7 +382,7 @@ def get_burst_params(scene_name: str) -> BurstParams:
)


def validate_bursts(reference_name: str, secondary_name: str) -> None:
def validate_bursts(reference_scene: str, secondary_scene: str) -> None:
"""Check whether the reference and secondary bursts are valid.
Args:
Expand All @@ -392,8 +392,8 @@ def validate_bursts(reference_name: str, secondary_name: str) -> None:
Returns:
None
"""
ref_split = reference_name.split('_')
sec_split = secondary_name.split('_')
ref_split = reference_scene.split('_')
sec_split = secondary_scene.split('_')

ref_burst_id = ref_split[1]
sec_burst_id = sec_split[1]
Expand Down
2 changes: 1 addition & 1 deletion src/hyp3_isce2/dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def distance_meters_to_degrees(distance_meters, latitude):
latitude_circumference = EARTHS_CIRCUMFERENCE * np.cos(np.radians(latitude))
distance_degrees_lon = distance_meters / latitude_circumference * 360
distance_degrees_lat = distance_meters / EARTHS_CIRCUMFERENCE * 360
return (np.round(distance_degrees_lon, 15), np.round(distance_degrees_lat, 15))
return np.round(distance_degrees_lon, 15), np.round(distance_degrees_lat, 15)


def download_dem_for_isce2(
Expand Down
41 changes: 19 additions & 22 deletions src/hyp3_isce2/insar_tops_burst.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@


def insar_tops_burst(
reference_scene: str,
secondary_scene: str,
swath_number: int,
azimuth_looks: int = 4,
range_looks: int = 20,
) -> Path:
reference_scene: str,
secondary_scene: str,
swath_number: int,
azimuth_looks: int = 4,
range_looks: int = 20) -> Path:
"""Create a burst interferogram
Args:
Expand Down Expand Up @@ -143,7 +142,7 @@ 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]
secondary_granule_datetime_str = secondary_scene.split('_')[3]

payload = {
'processing_date': datetime.now(timezone.utc),
Expand Down Expand Up @@ -171,15 +170,14 @@ def make_readme(


def make_parameter_file(
out_path: Path,
reference_scene: str,
secondary_scene: str,
swath_number: int,
azimuth_looks: int,
range_looks: int,
dem_name: str = 'GLO_30',
dem_resolution: int = 30,
) -> None:
out_path: Path,
reference_scene: str,
secondary_scene: str,
swath_number: int,
azimuth_looks: int,
range_looks: int,
dem_name: str = 'GLO_30',
dem_resolution: int = 30) -> None:
"""Create a parameter file for the output product
Args:
Expand All @@ -195,7 +193,6 @@ def make_parameter_file(
returns:
None
"""

SPEED_OF_LIGHT = 299792458.0
SPACECRAFT_HEIGHT = 693000.0
EARTH_RADIUS = 6337286.638938101
Expand Down Expand Up @@ -270,18 +267,19 @@ def make_parameter_file(
'Speckle filter: yes\n'
]

output_string = "".join(output_strings)
output_string = ''.join(output_strings)

with open(out_path.__str__(), 'w') as outfile:
outfile.write(output_string)


def translate_outputs(isce_output_dir: Path, product_name: str, pixel_size: float = 30.):
def translate_outputs(isce_output_dir: Path, product_name: str, pixel_size: float) -> None:
"""Translate ISCE outputs to a standard GTiff format with a UTM projection
Args:
isce_output_dir: Path to the ISCE output directory
product_name: Name of the product
pixel_size: Pixel size
"""

src_ds = gdal.Open(str(isce_output_dir / 'filt_topophase.unw.geo'))
Expand Down Expand Up @@ -377,9 +375,8 @@ def translate_outputs(isce_output_dir: Path, product_name: str, pixel_size: floa
)


def get_pixel_size(choice):
choices = {'20x4': 80.0, '10x2': 40.0, '5x1': 20.0}
return choices[choice]
def get_pixel_size(looks: str) -> float:
return {'20x4': 80.0, '10x2': 40.0, '5x1': 20.0}[looks]


def main():
Expand Down
8 changes: 4 additions & 4 deletions src/hyp3_isce2/topsapp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from typing import Iterable, Union
from typing import Iterable, Sequence, Union

from isce.applications.topsApp import TopsInSAR
from jinja2 import Template
Expand Down Expand Up @@ -52,8 +52,8 @@ def __init__(
aux_cal_directory: str,
dem_filename: str,
geocode_dem_filename: str,
roi: Iterable[float],
swaths: int or Iterable[int] = [1, 2, 3],
roi: Sequence[float],
swaths: Union[int, Iterable[int]] = (1, 2, 3),
azimuth_looks: int = 4,
range_looks: int = 20,
do_unwrap: bool = True,
Expand Down Expand Up @@ -139,7 +139,7 @@ def run_topsapp_burst(dostep: str = '', start: str = '', end: str = '', config_x
Args:
dostep: The step to run
start: The step to start at
stop: The step to stop at
end: The step to stop at
config_xml: The config file to use
Raises:
Expand Down
Binary file added tests/data/test_browse_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions tests/test_insar_tops_burst.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from hyp3_isce2 import insar_tops_burst


def test_get_pixel_size():
assert insar_tops_burst.get_pixel_size('20x4') == 80.0
assert insar_tops_burst.get_pixel_size('10x2') == 40.0
assert insar_tops_burst.get_pixel_size('5x1') == 20.0
18 changes: 17 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import os

from osgeo import gdal

from hyp3_isce2.utils import GDALConfigManager, extent_from_geotransform, oldest_granule_first, utm_from_lon_lat
from hyp3_isce2.utils import (
GDALConfigManager,
extent_from_geotransform,
make_browse_image,
oldest_granule_first,
utm_from_lon_lat
)

gdal.UseExceptions()

Expand Down Expand Up @@ -49,3 +57,11 @@ def test_oldest_granule_first():
latest = "S1_249434_IW1_20230523T170733_VV_8850-BURST"
assert oldest_granule_first(oldest, latest) == (oldest, latest)
assert oldest_granule_first(latest, oldest) == (oldest, latest)


def test_make_browse_image():
input_tif = "tests/data/test_geotiff.tif"
output_png = "tests/data/test_browse_image2.png"
make_browse_image(input_tif, output_png)
assert open(output_png, "rb").read() == open("tests/data/test_browse_image.png", "rb").read()
os.remove(output_png)

0 comments on commit 94e93c1

Please sign in to comment.