Skip to content

Commit

Permalink
Merge pull request #285 from ASFHyP3/develop
Browse files Browse the repository at this point in the history
Release v0.18.1 -- Correction fixes
  • Loading branch information
AndrewPlayer3 authored Jul 31, 2024
2 parents fe9f1f4 + 49adb8a commit f819a1e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ 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.18.1]
### Changed
* The conversion matrices netCDF file created bt the S1 correction workflow is now called `conversion_matricies.nc` and no longer includes the scene name per feedback from JPL.

### Fixed
* `s2_isce2.generate_correction_data` now returns a Path instead of a str as expected by `hyp3lib.aws.upload_file_to_s3`.
* `s2_isce2.create_conversion_matricies` now uses the pixel-center instead of the upper-left corner for the x,y dimensions.
* `s2_isce2.create_conversion_matricies` now explicitly syncs data to and closes the netCDF file to prevent corrupt files from being uploaded.

## [0.18.0]
### Added
* The Sentinel-1 correction workflow will now calculate and write the M11/M12 conversion matrices to a netCDF file.
Expand Down
14 changes: 10 additions & 4 deletions src/hyp3_autorift/s1_isce2.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ def write_conversion_file(
M12[noDataMask] = NoDataValue * np.float32(1 / C[0]) + np.float32(-C[1] / C[0])
var[:] = M12

nc_outfile.sync()
nc_outfile.close()

return file_name


Expand All @@ -234,7 +237,7 @@ def create_conversion_matrices(
epsg: int = 4326,
parameter_file: str = DEFAULT_PARAMETER_FILE,
**kwargs,
) -> str:
) -> Path:
xGrid, tran, _, srs, nodata = utils.load_geospatial(grid_location, band=1)

offset2vy_1, _, _, _, _ = utils.load_geospatial(offset2vy, band=1)
Expand All @@ -255,6 +258,9 @@ def create_conversion_matrices(
scale_factor_1, _, _, _, _ = utils.load_geospatial(scale_factor, band=1)
scale_factor_1[scale_factor_1 == nodata] = np.nan

# GDAL using upper-left of pixel -> netCDF using center of pixel
tran = [tran[0] + tran[1] / 2, tran[1], 0.0, tran[3] + tran[5] / 2, 0.0, tran[5]]

dimidY, dimidX = xGrid.shape
noDataMask = xGrid == nodata

Expand All @@ -270,18 +276,18 @@ def create_conversion_matrices(
dr_2_vr_factor = np.median(offset2vr[np.logical_not(np.isnan(offset2vr))])

conversion_nc = write_conversion_file(
file_name=f'{scene}_conversion_matrices.nc', srs=srs, epsg=epsg, tran=tran, x=x, y=y, M11=M11, M12=M12,
file_name='conversion_matrices.nc', srs=srs, epsg=epsg, tran=tran, x=x, y=y, M11=M11, M12=M12,
dr_2_vr_factor=dr_2_vr_factor, ChunkSize=ChunkSize, noDataMask=noDataMask, parameter_file=parameter_file,
)

return conversion_nc
return Path(conversion_nc)


def generate_correction_data(
scene: str,
buffer: int = 0,
parameter_file: str = DEFAULT_PARAMETER_FILE,
) -> (dict, str):
) -> (dict, Path):
from hyp3_autorift.vend.testGeogrid_ISCE import loadParsedata, runGeogrid
scene_path = Path(f'{scene}.zip')
if not scene_path.exists():
Expand Down

0 comments on commit f819a1e

Please sign in to comment.