Skip to content

Commit

Permalink
apply upstream-101 to correction workflow as well
Browse files Browse the repository at this point in the history
  • Loading branch information
jhkennedy committed Aug 30, 2024
1 parent fe887d4 commit 28a2ca8
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions src/hyp3_autorift/s1_isce2.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def write_conversion_file(
else:
raise Exception(f'Projection {srs.GetAttrValue("PROJECTION")} not recognized for this program')

var = nc_outfile.createVariable('M11', np.dtype('int16'), ('y', 'x'), fill_value=NoDataValue,
var = nc_outfile.createVariable('M11', np.dtype('float32'), ('y', 'x'), fill_value=NoDataValue,
zlib=True, complevel=2, shuffle=True, chunksizes=ChunkSize)
var.setncattr('standard_name', 'conversion_matrix_element_11')
var.setncattr(
Expand All @@ -176,19 +176,10 @@ def write_conversion_file(
var.setncattr('dr_to_vr_factor_description', 'multiplicative factor that converts slant range '
'pixel displacement dr to slant range velocity vr')

x1 = np.nanmin(M11[:])
x2 = np.nanmax(M11[:])
y1 = -50
y2 = 50

C = [(y2 - y1) / (x2 - x1), y1 - x1 * (y2 - y1) / (x2 - x1)]
var.setncattr('scale_factor', np.float32(1 / C[0]))
var.setncattr('add_offset', np.float32(-C[1] / C[0]))

M11[noDataMask] = NoDataValue * np.float32(1 / C[0]) + np.float32(-C[1] / C[0])
M11[noDataMask] = NoDataValue
var[:] = M11

var = nc_outfile.createVariable('M12', np.dtype('int16'), ('y', 'x'), fill_value=NoDataValue,
var = nc_outfile.createVariable('M12', np.dtype('float32'), ('y', 'x'), fill_value=NoDataValue,
zlib=True, complevel=2, shuffle=True, chunksizes=ChunkSize)
var.setncattr('standard_name', 'conversion_matrix_element_12')
var.setncattr(
Expand All @@ -202,16 +193,7 @@ def write_conversion_file(
var.setncattr('dr_to_vr_factor_description',
'multiplicative factor that converts slant range pixel displacement dr to slant range velocity vr')

x1 = np.nanmin(M12[:])
x2 = np.nanmax(M12[:])
y1 = -50
y2 = 50

C = [(y2 - y1) / (x2 - x1), y1 - x1 * (y2 - y1) / (x2 - x1)]
var.setncattr('scale_factor', np.float32(1 / C[0]))
var.setncattr('add_offset', np.float32(-C[1] / C[0]))

M12[noDataMask] = NoDataValue * np.float32(1 / C[0]) + np.float32(-C[1] / C[0])
M12[noDataMask] = NoDataValue
var[:] = M12

nc_outfile.sync()
Expand Down

0 comments on commit 28a2ca8

Please sign in to comment.