Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.18.1 -- Correction fixes #285

Merged
merged 7 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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