Skip to content

Commit

Permalink
Merge pull request #108 from ASFHyP3/control_pixel_size
Browse files Browse the repository at this point in the history
use native dem (30m) for the calculation, resample the product with p…
  • Loading branch information
cirrusasf authored Jul 10, 2023
2 parents f107c60 + da37633 commit c9fddbe
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ 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).

## [0.6.0]
### Changed
* Pixel sizes of output GeoTIFFs now better reflect their resolution: 80m for 20x4 looks, 40m for 10x2 looks, and 20m for 5x1 looks.

## [0.5.0]
### Changed
Expand Down
4 changes: 0 additions & 4 deletions src/hyp3_isce2/dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
from lxml import etree
from shapely.geometry import box

DEM_RESOLUTION = 0.0002777777777777777775


def tag_dem_xml_as_ellipsoidal(dem_path: Path) -> str:
xml_path = str(dem_path) + '.xml'
Expand Down Expand Up @@ -85,8 +83,6 @@ def download_dem_for_isce2(
dst_ellipsoidal_height=True,
dst_area_or_point='Point',
n_threads_downloading=5,
# ensures square resolution
dst_resolution=DEM_RESOLUTION,
)
dem_array[np.isnan(dem_array)] = 0.

Expand Down
17 changes: 13 additions & 4 deletions src/hyp3_isce2/insar_tops_burst.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def make_parameter_file(
azimuth_looks: int,
range_looks: int,
dem_name: str = 'GLO_30',
dem_resolution: int = 30
dem_resolution: int = 30,
) -> None:
"""Create a parameter file for the output product
Expand Down Expand Up @@ -252,7 +252,7 @@ def make_parameter_file(
outfile.write(output_string)


def translate_outputs(isce_output_dir: Path, product_name: str):
def translate_outputs(isce_output_dir: Path, product_name: str, pixel_size: float = 30.):
"""Translate ISCE outputs to a standard GTiff format with a UTM projection
Args:
Expand Down Expand Up @@ -347,11 +347,19 @@ def translate_outputs(isce_output_dir: Path, product_name: str):
file,
dstSRS=f'epsg:{epsg}',
creationOptions=['TILED=YES', 'COMPRESS=LZW', 'NUM_THREADS=ALL_CPUS'],
xRes=pixel_size,
yRes=pixel_size,
targetAlignedPixels=True
)

make_browse_image(f'{product_name}/{product_name}_unw_phase.tif', f'{product_name}/{product_name}_unw_phase.png')


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


def main():
"""HyP3 entrypoint for the burst TOPS workflow"""
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
Expand Down Expand Up @@ -398,7 +406,8 @@ def main():
product_dir = Path(product_name)
product_dir.mkdir(parents=True, exist_ok=True)

translate_outputs(isce_output_dir, product_name)
pixel_size = get_pixel_size(args.looks)
translate_outputs(isce_output_dir, product_name, pixel_size=pixel_size)

make_readme(
product_dir=product_dir,
Expand All @@ -414,7 +423,7 @@ def main():
secondary_scene=secondary_scene,
azimuth_looks=azimuth_looks,
range_looks=range_looks,
swath_number=swath_number
swath_number=swath_number,
)
output_zip = make_archive(base_name=product_name, format='zip', base_dir=product_name)

Expand Down
1 change: 0 additions & 1 deletion tests/test_dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def test_download_dem_for_isce2(tmp_path):
dst_ellipsoidal_height=True,
dst_area_or_point='Point',
n_threads_downloading=5,
dst_resolution=dem.DEM_RESOLUTION,
)

root = etree.parse(str(dem_path) + '.xml').getroot()
Expand Down

0 comments on commit c9fddbe

Please sign in to comment.