Skip to content

Commit

Permalink
Merge pull request #93 from ASFHyP3/develop
Browse files Browse the repository at this point in the history
Release upgrade to autoRIFT 1.3.0
  • Loading branch information
jhkennedy authored Jun 2, 2021
2 parents 4d2b627 + 8d47096 commit 99bd90a
Show file tree
Hide file tree
Showing 12 changed files with 230 additions and 212 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ 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](https://github.com/ASFHyP3/hyp3-autorift/compare/v0.5.2...v0.6.0)

### Changed
* Upgraded autoRIFT to [v1.3.0](https://github.com/leiyangleon/autoRIFT/releases/tag/v1.3.0)
and [ISCE2 v2.5.1 built with autoRIFT v1.3.0](https://anaconda.org/hyp3/isce2)

## [0.5.2](https://github.com/ASFHyP3/hyp3-autorift/compare/v0.5.1...v0.5.2)

### Changed
Expand Down
4 changes: 2 additions & 2 deletions conda-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ dependencies:
# For running
- gdal>=3
- hyp3lib=1.6.7
- isce2=2.5.1.dev5
- autorift=1.2.0
- isce2=2.5.1.dev6
- autorift=1.3.0
- boto3
- matplotlib-base
- netCDF4
Expand Down
84 changes: 57 additions & 27 deletions hyp3_autorift/netcdf_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ def netCDF_packaging(VX, VY, DX, DY, INTERPMASK, CHIPSIZEX, CHIPSIZEY, SSM, SSM1

if pair_type is 'radar':
VR = DX * rangePixelSize / dt * 365.0 * 24.0 * 3600.0
VA = (-DY) * azimuthPixelSize / dt * 365.0 * 24.0 * 3600.0
VA = (DY) * azimuthPixelSize / dt * 365.0 * 24.0 * 3600.0
VR = VR.astype(np.float32)
VA = VA.astype(np.float32)


vr_mean_shift = dx_mean_shift * rangePixelSize / dt * 365.0 * 24.0 * 3600.0
va_mean_shift = (-dy_mean_shift) * azimuthPixelSize / dt * 365.0 * 24.0 * 3600.0
va_mean_shift = (dy_mean_shift) * azimuthPixelSize / dt * 365.0 * 24.0 * 3600.0

vr_mean_shift1 = dx_mean_shift1 * rangePixelSize / dt * 365.0 * 24.0 * 3600.0
va_mean_shift1 = (-dy_mean_shift1) * azimuthPixelSize / dt * 365.0 * 24.0 * 3600.0
va_mean_shift1 = (dy_mean_shift1) * azimuthPixelSize / dt * 365.0 * 24.0 * 3600.0

# create the (slope parallel & reference) flow-based range-projected result
alpha_sp = DX / (offset2vy_2 / (offset2vx_1 * offset2vy_2 - offset2vx_2 * offset2vy_1) * (-SX) - offset2vx_2 / (offset2vx_1 * offset2vy_2 - offset2vx_2 * offset2vy_1) * (-SY))
Expand Down Expand Up @@ -199,7 +199,7 @@ def netCDF_packaging(VX, VY, DX, DY, INTERPMASK, CHIPSIZEX, CHIPSIZEY, SSM, SSM1
nc_outfile.setncattr('references', references)

varname='img_pair_info'
datatype=np.dtype('S1')
datatype='U1'
dimensions=()
FillValue=None

Expand Down Expand Up @@ -242,9 +242,9 @@ def netCDF_packaging(VX, VY, DX, DY, INTERPMASK, CHIPSIZEX, CHIPSIZEY, SSM, SSM1

if (srs.GetAttrValue('PROJECTION') == 'Polar_Stereographic'):

mapping_name='Polar_Stereographic'
mapping_name='mapping'
grid_mapping='polar_stereographic' # need to set this as an attribute for the image variables
datatype=np.dtype('S1')
datatype='U1'
dimensions=()
FillValue=None

Expand All @@ -267,9 +267,9 @@ def netCDF_packaging(VX, VY, DX, DY, INTERPMASK, CHIPSIZEX, CHIPSIZEY, SSM, SSM1

elif (srs.GetAttrValue('PROJECTION') == 'Transverse_Mercator'):

mapping_name='UTM_projection'
mapping_name='mapping'
grid_mapping='universal_transverse_mercator' # need to set this as an attribute for the image variables
datatype=np.dtype('S1')
datatype='U1'
dimensions=()
FillValue=None

Expand Down Expand Up @@ -350,10 +350,15 @@ def netCDF_packaging(VX, VY, DX, DY, INTERPMASK, CHIPSIZEX, CHIPSIZEY, SSM, SSM1
else:
var.setncattr('stable_shift_slow',np.nan)


var.setncattr('vx_error_mask',int(round(vx_error_mask*10))/10)
if stable_count != 0:
var.setncattr('vx_error_mask',int(round(vx_error_mask*10))/10)
else:
var.setncattr('vx_error_mask',np.nan)
var.setncattr('vx_error_mask_description','RMSE over stable surfaces, stationary or slow-flowing surfaces with velocity < 15 m/yr identified from an external mask')
var.setncattr('vx_error_slow',int(round(vx_error_slow*10))/10)
if stable_count1 != 0:
var.setncattr('vx_error_slow',int(round(vx_error_slow*10))/10)
else:
var.setncattr('vx_error_slow',np.nan)
var.setncattr('vx_error_slow_description','RMSE over slowest 25% of retrieved velocities')
var.setncattr('vx_error_modeled',int(round(vx_error_mod*10))/10)
var.setncattr('vx_error_modeled_description','1-sigma error calculated using a modeled error-dt relationship')
Expand Down Expand Up @@ -425,10 +430,15 @@ def netCDF_packaging(VX, VY, DX, DY, INTERPMASK, CHIPSIZEX, CHIPSIZEY, SSM, SSM1
else:
var.setncattr('stable_shift_slow',np.nan)


var.setncattr('vy_error_mask',int(round(vy_error_mask*10))/10)
if stable_count != 0:
var.setncattr('vy_error_mask',int(round(vy_error_mask*10))/10)
else:
var.setncattr('vy_error_mask',np.nan)
var.setncattr('vy_error_mask_description','RMSE over stable surfaces, stationary or slow-flowing surfaces with velocity < 15 m/yr identified from an external mask')
var.setncattr('vy_error_slow',int(round(vy_error_slow*10))/10)
if stable_count1 != 0:
var.setncattr('vy_error_slow',int(round(vy_error_slow*10))/10)
else:
var.setncattr('vy_error_slow',np.nan)
var.setncattr('vy_error_slow_description','RMSE over slowest 25% of retrieved velocities')
var.setncattr('vy_error_modeled',int(round(vy_error_mod*10))/10)
var.setncattr('vy_error_modeled_description','1-sigma error calculated using a modeled error-dt relationship')
Expand Down Expand Up @@ -546,10 +556,15 @@ def netCDF_packaging(VX, VY, DX, DY, INTERPMASK, CHIPSIZEX, CHIPSIZEY, SSM, SSM1
else:
var.setncattr('stable_shift_slow',np.nan)


var.setncattr('vr_error_mask',int(round(vr_error_mask*10))/10)
if stable_count != 0:
var.setncattr('vr_error_mask',int(round(vr_error_mask*10))/10)
else:
var.setncattr('vr_error_mask',np.nan)
var.setncattr('vr_error_mask_description','RMSE over stable surfaces, stationary or slow-flowing surfaces with velocity < 15 m/yr identified from an external mask')
var.setncattr('vr_error_slow',int(round(vr_error_slow*10))/10)
if stable_count1 != 0:
var.setncattr('vr_error_slow',int(round(vr_error_slow*10))/10)
else:
var.setncattr('vr_error_slow',np.nan)
var.setncattr('vr_error_slow_description','RMSE over slowest 25% of retrieved velocities')
var.setncattr('vr_error_modeled',int(round(vr_error_mod*10))/10)
var.setncattr('vr_error_modeled_description','1-sigma error calculated using a modeled error-dt relationship')
Expand Down Expand Up @@ -619,10 +634,15 @@ def netCDF_packaging(VX, VY, DX, DY, INTERPMASK, CHIPSIZEX, CHIPSIZEY, SSM, SSM1
else:
var.setncattr('stable_shift_slow',np.nan)


var.setncattr('va_error_mask',int(round(va_error_mask*10))/10)
if stable_count != 0:
var.setncattr('va_error_mask',int(round(va_error_mask*10))/10)
else:
var.setncattr('va_error_mask',np.nan)
var.setncattr('va_error_mask_description','RMSE over stable surfaces, stationary or slow-flowing surfaces with velocity < 15 m/yr identified from an external mask')
var.setncattr('va_error_slow',int(round(va_error_slow*10))/10)
if stable_count1 != 0:
var.setncattr('va_error_slow',int(round(va_error_slow*10))/10)
else:
var.setncattr('va_error_slow',np.nan)
var.setncattr('va_error_slow_description','RMSE over slowest 25% of retrieved velocities')
var.setncattr('va_error_modeled',int(round(va_error_mod*10))/10)
var.setncattr('va_error_modeled_description','1-sigma error calculated using a modeled error-dt relationship')
Expand Down Expand Up @@ -774,10 +794,15 @@ def netCDF_packaging(VX, VY, DX, DY, INTERPMASK, CHIPSIZEX, CHIPSIZEY, SSM, SSM1
else:
var.setncattr('stable_shift_slow',np.nan)


var.setncattr('vxp_error_mask',int(round(vxp_error_mask*10))/10)
if stable_count_p != 0:
var.setncattr('vxp_error_mask',int(round(vxp_error_mask*10))/10)
else:
var.setncattr('vxp_error_mask',np.nan)
var.setncattr('vxp_error_mask_description','RMSE over stable surfaces, stationary or slow-flowing surfaces with velocity < 15 m/yr identified from an external mask')
var.setncattr('vxp_error_slow',int(round(vxp_error_slow*10))/10)
if stable_count1_p != 0:
var.setncattr('vxp_error_slow',int(round(vxp_error_slow*10))/10)
else:
var.setncattr('vxp_error_slow',np.nan)
var.setncattr('vxp_error_slow_description','RMSE over slowest 25% of retrieved velocities')
var.setncattr('vxp_error_modeled',int(round(vxp_error_mod*10))/10)
var.setncattr('vxp_error_modeled_description','1-sigma error calculated using a modeled error-dt relationship')
Expand Down Expand Up @@ -849,10 +874,15 @@ def netCDF_packaging(VX, VY, DX, DY, INTERPMASK, CHIPSIZEX, CHIPSIZEY, SSM, SSM1
else:
var.setncattr('stable_shift_slow',np.nan)


var.setncattr('vyp_error_mask',int(round(vyp_error_mask*10))/10)
if stable_count_p != 0:
var.setncattr('vyp_error_mask',int(round(vyp_error_mask*10))/10)
else:
var.setncattr('vyp_error_mask',np.nan)
var.setncattr('vyp_error_mask_description','RMSE over stable surfaces, stationary or slow-flowing surfaces with velocity < 15 m/yr identified from an external mask')
var.setncattr('vyp_error_slow',int(round(vyp_error_slow*10))/10)
if stable_count1_p != 0:
var.setncattr('vyp_error_slow',int(round(vyp_error_slow*10))/10)
else:
var.setncattr('vyp_error_slow',np.nan)
var.setncattr('vyp_error_slow_description','RMSE over slowest 25% of retrieved velocities')
var.setncattr('vyp_error_modeled',int(round(vyp_error_mod*10))/10)
var.setncattr('vyp_error_modeled_description','1-sigma error calculated using a modeled error-dt relationship')
Expand Down Expand Up @@ -957,7 +987,7 @@ def netCDF_packaging(VX, VY, DX, DY, INTERPMASK, CHIPSIZEX, CHIPSIZEY, SSM, SSM1
varname='interp_mask'
datatype=np.dtype('uint8')
dimensions=('y','x')
FillValue=None
FillValue=0
var = nc_outfile.createVariable(varname,datatype,dimensions, fill_value=FillValue, zlib=True, complevel=2, shuffle=True, chunksizes=ChunkSize)

var.setncattr('standard_name','interpolated_value_mask')
Expand Down
8 changes: 8 additions & 0 deletions hyp3_autorift/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ def process(reference: str, secondary: str, parameter_file: str = DEFAULT_PARAME
gdal.SetConfigOption('GDAL_DISABLE_READDIR_ON_OPEN', 'EMPTY_DIR')
gdal.SetConfigOption('AWS_REQUEST_PAYER', 'requester')
gdal.SetConfigOption('AWS_REGION', 'eu-central-1')
# Also set for new CXX threads in Geogrid/autoRIFT
os.environ['GDAL_DISABLE_READDIR_ON_OPEN'] = 'EMPTY_DIR'
os.environ['AWS_REQUEST_PAYER'] = 'requester'
os.environ['AWS_REGION'] = 'eu-central-1'

reference_metadata = get_s2_metadata(reference)
reference_path = reference_metadata['assets'][band]['href'].replace('s3://', '/vsis3/')
Expand All @@ -193,6 +197,10 @@ def process(reference: str, secondary: str, parameter_file: str = DEFAULT_PARAME
gdal.SetConfigOption('GDAL_DISABLE_READDIR_ON_OPEN', 'EMPTY_DIR')
gdal.SetConfigOption('AWS_REQUEST_PAYER', 'requester')
gdal.SetConfigOption('AWS_REGION', 'us-west-2')
# Also set for new CXX threads in Geogrid/autoRIFT
os.environ['GDAL_DISABLE_READDIR_ON_OPEN'] = 'EMPTY_DIR'
os.environ['AWS_REQUEST_PAYER'] = 'requester'
os.environ['AWS_REGION'] = 'us-west-2'

if band == 'B08':
band = 'B8'
Expand Down
Loading

0 comments on commit 99bd90a

Please sign in to comment.