Skip to content

Commit

Permalink
Merge pull request #86 from ASFHyP3/release-0.5.1
Browse files Browse the repository at this point in the history
Release netCDF attribute changes and ROI fix
  • Loading branch information
jhkennedy authored May 6, 2021
2 parents b6eb491 + b94ab92 commit 6d07c36
Show file tree
Hide file tree
Showing 7 changed files with 682 additions and 402 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ 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.5.1](https://github.com/ASFHyP3/hyp3-autorift/compare/v0.5.0...v0.5.1)

### Changed
* Minor updates to the netCDF product metadata
* Pairs that end up having a 0 ROI (no valid data) will not fail at the end of processing,
but instead will upload a netCDF product that reports 0 ROI

## [0.5.0](https://github.com/ASFHyP3/hyp3-autorift/compare/v0.4.5...v0.5.0)

### Changed
Expand Down
480 changes: 272 additions & 208 deletions hyp3_autorift/netcdf_output.py

Large diffs are not rendered by default.

84 changes: 84 additions & 0 deletions hyp3_autorift/vend/NC-PATCH.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
diff --git a/testautoRIFT.py b/testautoRIFT.py
--- a/testautoRIFT.py
+++ b/testautoRIFT.py
@@ -751,9 +751,9 @@ def generateAutoriftProduct(indir_m, indir_s, grid_location, init_offset, search
PPP = roi_valid_percentage * 100
if ncname is None:
out_nc_filename = f"./{master_filename[0:-4]}_X_{slave_filename[0:-4]}" \
- f"_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
+ f"_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
else:
- out_nc_filename = f"{ncname}_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
+ out_nc_filename = f"{ncname}_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
CHIPSIZEY = np.round(CHIPSIZEX * ScaleChipSizeY / 2) * 2


@@ -827,7 +827,7 @@ def generateAutoriftProduct(indir_m, indir_s, grid_location, init_offset, search
# out_nc_filename = 'Jakobshavn_opt.nc'
PPP = roi_valid_percentage * 100
if ncname is None:
- out_nc_filename = f"./{master_filename[0:-8]}_X_{slave_filename[0:-8]}" \
+ out_nc_filename = f"./{master_filename[0:-7]}_X_{slave_filename[0:-7]}" \
- f"_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
+ f"_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
else:
- out_nc_filename = f"{ncname}_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
+ out_nc_filename = f"{ncname}_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"

CHIPSIZEY = np.round(CHIPSIZEX * ScaleChipSizeY / 2) * 2

@@ -902,9 +902,9 @@ def generateAutoriftProduct(indir_m, indir_s, grid_location, init_offset, search
PPP = roi_valid_percentage * 100
if ncname is None:
out_nc_filename = f"./{master_filename[0:-8]}_X_{slave_filename[0:-8]}" \
- f"_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
+ f"_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
else:
- out_nc_filename = f"{ncname}_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
+ out_nc_filename = f"{ncname}_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
CHIPSIZEY = np.round(CHIPSIZEX * ScaleChipSizeY / 2) * 2

from datetime import date
diff --git a/testautoRIFT_ISCE.py b/testautoRIFT_ISCE.py
index 53325f8..b7fd589 100755
--- a/testautoRIFT_ISCE.py
+++ b/testautoRIFT_ISCE.py
@@ -753,9 +753,9 @@ def generateAutoriftProduct(indir_m, indir_s, grid_location, init_offset, search
PPP = roi_valid_percentage * 100
if ncname is None:
out_nc_filename = f"./{master_filename[0:-4]}_X_{slave_filename[0:-4]}" \
- f"_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
+ f"_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
else:
- out_nc_filename = f"{ncname}_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
+ out_nc_filename = f"{ncname}_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
CHIPSIZEY = np.round(CHIPSIZEX * ScaleChipSizeY / 2) * 2


@@ -829,7 +829,7 @@ def generateAutoriftProduct(indir_m, indir_s, grid_location, init_offset, search
# out_nc_filename = 'Jakobshavn_opt.nc'
PPP = roi_valid_percentage * 100
if ncname is None:
- out_nc_filename = f"./{master_filename[0:-8]}_X_{slave_filename[0:-8]}" \
+ out_nc_filename = f"./{master_filename[0:-7]}_X_{slave_filename[0:-7]}" \
- f"_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
+ f"_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
else:
- out_nc_filename = f"{ncname}_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
+ out_nc_filename = f"{ncname}_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
+
CHIPSIZEY = np.round(CHIPSIZEX * ScaleChipSizeY / 2) * 2

from datetime import date
@@ -903,9 +904,9 @@ def generateAutoriftProduct(indir_m, indir_s, grid_location, init_offset, search
PPP = roi_valid_percentage * 100
if ncname is None:
out_nc_filename = f"./{master_filename[0:-8]}_X_{slave_filename[0:-8]}" \
- f"_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
+ f"_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
else:
- out_nc_filename = f"{ncname}_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
+ out_nc_filename = f"{ncname}_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
CHIPSIZEY = np.round(CHIPSIZEX * ScaleChipSizeY / 2) * 2

from datetime import date
16 changes: 15 additions & 1 deletion hyp3_autorift/vend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,21 @@
This directory contains modules needed for the HyP3 autoRIFT plugin that couldn't
be easily incorporated from a package manager or installed appropriately.

## `testautoRIFT_ISCE.py`, `testautoRIFT.py`, `testGeogrid_ISCE.py`, and `testGeogridOptical.py`
## `testautoRIFT_ISCE.py` and `testautoRIFT.py`

These modules are required for the expected workflow provided to ASF, and are
provided in autoRIFT, but not distributed as part of the package. These modules
correspond to commit
[`b973c1b`](https://github.com/leiyangleon/autoRIFT/commit/b973c1b48b82f3398ece3c34a7cbfca71c4e07cb),
which is a [minor patch](https://github.com/leiyangleon/autoRIFT/pull/28)
to [`v1.2.0`](https://github.com/leiyangleon/autoRIFT/releases/tag/v1.2.0).
Changes, as listed in `CHANGES.diff`, were done to facilitate better packaging
and distribution of these modules, to correctly handle Sentinel-2 Level 1C
products, and to provide better netCDF metadata. Additionally, `NC-PATCH.diff`
was applied to fix the grid resolution specifier in the netCDF file names and to
not truncate Landsat scene names in the netCDF file names.

## `testGeogrid_ISCE.py` and `testGeogridOptical.py`

These modules are required for the expected workflow provided to ASF, and are
provided in autoRIFT, but not distributed as part of the package. These modules
Expand Down
21 changes: 12 additions & 9 deletions hyp3_autorift/vend/testautoRIFT.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,11 @@ def generateAutoriftProduct(indir_m, indir_s, grid_location, init_offset, search
stable_count = np.sum(SSM & np.logical_not(np.isnan(DX)) & (DX-DXref > -5) & (DX-DXref < 5) & (DY-DYref > -5) & (DY-DYref < 5))

V_temp = np.sqrt(VX**2 + VY**2)
V_temp_threshold = np.percentile(V_temp[np.logical_not(np.isnan(V_temp))],25)
SSM1 = (V_temp <= V_temp_threshold)
try:
V_temp_threshold = np.percentile(V_temp[np.logical_not(np.isnan(V_temp))],25)
SSM1 = (V_temp <= V_temp_threshold)
except IndexError:
SSM1 = np.zeros(V_temp.shape).astype('bool')

stable_count1 = np.sum(SSM1 & np.logical_not(np.isnan(DX)) & (DX-DXref > -5) & (DX-DXref < 5) & (DY-DYref > -5) & (DY-DYref < 5))

Expand Down Expand Up @@ -748,9 +751,9 @@ def generateAutoriftProduct(indir_m, indir_s, grid_location, init_offset, search
PPP = roi_valid_percentage * 100
if ncname is None:
out_nc_filename = f"./{master_filename[0:-4]}_X_{slave_filename[0:-4]}" \
f"_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
f"_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
else:
out_nc_filename = f"{ncname}_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
out_nc_filename = f"{ncname}_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
CHIPSIZEY = np.round(CHIPSIZEX * ScaleChipSizeY / 2) * 2


Expand Down Expand Up @@ -824,10 +827,10 @@ def generateAutoriftProduct(indir_m, indir_s, grid_location, init_offset, search
# out_nc_filename = 'Jakobshavn_opt.nc'
PPP = roi_valid_percentage * 100
if ncname is None:
out_nc_filename = f"./{master_filename[0:-8]}_X_{slave_filename[0:-8]}" \
f"_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
out_nc_filename = f"./{master_filename[0:-7]}_X_{slave_filename[0:-7]}" \
f"_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
else:
out_nc_filename = f"{ncname}_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
out_nc_filename = f"{ncname}_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"

CHIPSIZEY = np.round(CHIPSIZEX * ScaleChipSizeY / 2) * 2

Expand Down Expand Up @@ -899,9 +902,9 @@ def generateAutoriftProduct(indir_m, indir_s, grid_location, init_offset, search
PPP = roi_valid_percentage * 100
if ncname is None:
out_nc_filename = f"./{master_filename[0:-8]}_X_{slave_filename[0:-8]}" \
f"_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
f"_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
else:
out_nc_filename = f"{ncname}_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
out_nc_filename = f"{ncname}_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
CHIPSIZEY = np.round(CHIPSIZEX * ScaleChipSizeY / 2) * 2

from datetime import date
Expand Down
22 changes: 13 additions & 9 deletions hyp3_autorift/vend/testautoRIFT_ISCE.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,11 @@ def generateAutoriftProduct(indir_m, indir_s, grid_location, init_offset, search
stable_count = np.sum(SSM & np.logical_not(np.isnan(DX)) & (DX-DXref > -5) & (DX-DXref < 5) & (DY-DYref > -5) & (DY-DYref < 5))

V_temp = np.sqrt(VX**2 + VY**2)
V_temp_threshold = np.percentile(V_temp[np.logical_not(np.isnan(V_temp))],25)
SSM1 = (V_temp <= V_temp_threshold)
try:
V_temp_threshold = np.percentile(V_temp[np.logical_not(np.isnan(V_temp))],25)
SSM1 = (V_temp <= V_temp_threshold)
except IndexError:
SSM1 = np.zeros(V_temp.shape).astype('bool')

stable_count1 = np.sum(SSM1 & np.logical_not(np.isnan(DX)) & (DX-DXref > -5) & (DX-DXref < 5) & (DY-DYref > -5) & (DY-DYref < 5))

Expand Down Expand Up @@ -750,9 +753,9 @@ def generateAutoriftProduct(indir_m, indir_s, grid_location, init_offset, search
PPP = roi_valid_percentage * 100
if ncname is None:
out_nc_filename = f"./{master_filename[0:-4]}_X_{slave_filename[0:-4]}" \
f"_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
f"_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
else:
out_nc_filename = f"{ncname}_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
out_nc_filename = f"{ncname}_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
CHIPSIZEY = np.round(CHIPSIZEX * ScaleChipSizeY / 2) * 2


Expand Down Expand Up @@ -826,10 +829,11 @@ def generateAutoriftProduct(indir_m, indir_s, grid_location, init_offset, search
# out_nc_filename = 'Jakobshavn_opt.nc'
PPP = roi_valid_percentage * 100
if ncname is None:
out_nc_filename = f"./{master_filename[0:-8]}_X_{slave_filename[0:-8]}" \
f"_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
out_nc_filename = f"./{master_filename[0:-7]}_X_{slave_filename[0:-7]}" \
f"_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
else:
out_nc_filename = f"{ncname}_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
out_nc_filename = f"{ncname}_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"

CHIPSIZEY = np.round(CHIPSIZEX * ScaleChipSizeY / 2) * 2

from datetime import date
Expand Down Expand Up @@ -900,9 +904,9 @@ def generateAutoriftProduct(indir_m, indir_s, grid_location, init_offset, search
PPP = roi_valid_percentage * 100
if ncname is None:
out_nc_filename = f"./{master_filename[0:-8]}_X_{slave_filename[0:-8]}" \
f"_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
f"_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
else:
out_nc_filename = f"{ncname}_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
out_nc_filename = f"{ncname}_G{tran[1]:04.0f}V02_P{np.floor(PPP):03.0f}.nc"
CHIPSIZEY = np.round(CHIPSIZEX * ScaleChipSizeY / 2) * 2

from datetime import date
Expand Down
Loading

0 comments on commit 6d07c36

Please sign in to comment.