8
8
from nisar .types import to_complex32
9
9
from nisar .workflows import gpu_check
10
10
import numpy as np
11
- import pybind_isce3 as isce
12
- from pybind_isce3 .core import DateTime , LUT2d
13
- from pybind_isce3 .io .gdal import Raster , GDT_CFloat32
11
+ import isce3
12
+ from isce3 .core import DateTime , LUT2d
13
+ from isce3 .io .gdal import Raster , GDT_CFloat32
14
14
from nisar .workflows .yaml_argparse import YamlArgparse
15
15
import nisar .workflows .helpers as helpers
16
16
from ruamel .yaml import YAML
@@ -100,9 +100,9 @@ def get_chirp(cfg: Struct, raw: Raw, frequency: str, tx: str):
100
100
101
101
102
102
def parse_rangecomp_mode (mode : str ):
103
- lut = {"full" : isce .focus .RangeComp .Mode .Full ,
104
- "same" : isce .focus .RangeComp .Mode .Same ,
105
- "valid" : isce .focus .RangeComp .Mode .Valid }
103
+ lut = {"full" : isce3 .focus .RangeComp .Mode .Full ,
104
+ "same" : isce3 .focus .RangeComp .Mode .Same ,
105
+ "valid" : isce3 .focus .RangeComp .Mode .Valid }
106
106
mode = mode .lower ()
107
107
if mode not in lut :
108
108
raise ValueError (f"Invalid RangeComp mode { mode } " )
@@ -140,8 +140,8 @@ def get_total_grid_bounds(rawfiles: List[str], frequency='A'):
140
140
times .append (raw .getPulseTimes (frequency , tx = pol [0 ]))
141
141
rmin = min (r [0 ] for r in ranges )
142
142
rmax = max (r [- 1 ] for r in ranges )
143
- dtmin = min (epoch + isce .core .TimeDelta (t [0 ]) for (epoch , t ) in times )
144
- dtmax = max (epoch + isce .core .TimeDelta (t [- 1 ]) for (epoch , t ) in times )
143
+ dtmin = min (epoch + isce3 .core .TimeDelta (t [0 ]) for (epoch , t ) in times )
144
+ dtmax = max (epoch + isce3 .core .TimeDelta (t [- 1 ]) for (epoch , t ) in times )
145
145
epoch = min (epoch for (epoch , t ) in times )
146
146
tmin = (dtmin - epoch ).total_seconds ()
147
147
tmax = (dtmax - epoch ).total_seconds ()
@@ -152,8 +152,8 @@ def get_total_grid(rawfiles: List[str], dt, dr, frequency='A'):
152
152
epoch , tmin , tmax , rmin , rmax = get_total_grid_bounds (rawfiles , frequency )
153
153
nt = int (np .ceil ((tmax - tmin ) / dt ))
154
154
nr = int (np .ceil ((rmax - rmin ) / dr ))
155
- t = isce .core .Linspace (tmin , dt , nt )
156
- r = isce .core .Linspace (rmin , dr , nr )
155
+ t = isce3 .core .Linspace (tmin , dt , nt )
156
+ r = isce3 .core .Linspace (rmin , dr , nr )
157
157
return epoch , t , r
158
158
159
159
@@ -172,11 +172,11 @@ def squint(t, r, orbit, attitude, side, angle=0.0, dem=None, **kw):
172
172
f"inferred side={ inferred_side } based on orientation "
173
173
f"(Y_RCS.dot(V) = { axis .dot (v )} )" )
174
174
if dem is None :
175
- dem = isce .geometry .DEMInterpolator ()
175
+ dem = isce3 .geometry .DEMInterpolator ()
176
176
# NOTE Here "left" means an acute, positive look angle by right-handed
177
177
# rotation about `axis`. Since axis will flip sign, always use "left" to
178
178
# get the requested side in the sense of velocity vector.
179
- xyz = isce .geometry .rdr2geo_cone (p , axis , angle , r , dem , "left" , ** kw )
179
+ xyz = isce3 .geometry .rdr2geo_cone (p , axis , angle , r , dem , "left" , ** kw )
180
180
look = (xyz - p ) / np .linalg .norm (xyz - p )
181
181
vhat = v / np .linalg .norm (v )
182
182
return np .arcsin (look .dot (vhat ))
@@ -187,12 +187,12 @@ def squint_to_doppler(squint, wvl, vmag):
187
187
188
188
189
189
def convert_epoch (t : List [float ], epoch_in , epoch_out ):
190
- TD = isce .core .TimeDelta
190
+ TD = isce3 .core .TimeDelta
191
191
return [(epoch_in - epoch_out + TD (ti )).total_seconds () for ti in t ]
192
192
193
193
194
194
def get_dem (cfg : Struct ):
195
- dem = isce .geometry .DEMInterpolator (
195
+ dem = isce3 .geometry .DEMInterpolator (
196
196
height = cfg .processing .dem .reference_height ,
197
197
method = cfg .processing .dem .interp_method )
198
198
fn = cfg .DynamicAncillaryFileGroup .DEMFile
@@ -206,9 +206,9 @@ def get_dem(cfg: Struct):
206
206
207
207
def make_doppler_lut (rawfiles : List [str ],
208
208
az : float = 0.0 ,
209
- orbit : isce .core .Orbit = None ,
210
- attitude : isce .core .Attitude = None ,
211
- dem : isce .geometry .DEMInterpolator = None ,
209
+ orbit : isce3 .core .Orbit = None ,
210
+ attitude : isce3 .core .Attitude = None ,
211
+ dem : isce3 .geometry .DEMInterpolator = None ,
212
212
azimuth_spacing : float = 1.0 ,
213
213
range_spacing : float = 1e3 ,
214
214
frequency : str = "A" ,
@@ -259,13 +259,13 @@ def make_doppler_lut(rawfiles: List[str],
259
259
if attitude is None :
260
260
attitude = raw .getAttitude ()
261
261
if dem is None :
262
- dem = isce .geometry .DEMInterpolator ()
262
+ dem = isce3 .geometry .DEMInterpolator ()
263
263
# Assume look side and center frequency constant across files.
264
264
side = raw .identification .lookDirection
265
265
fc = raw .getCenterFrequency (frequency )
266
266
267
267
# Now do the actual calculations.
268
- wvl = isce .core .speed_of_light / fc
268
+ wvl = isce3 .core .speed_of_light / fc
269
269
epoch , t , r = get_total_grid (rawfiles , azimuth_spacing , range_spacing )
270
270
t = convert_epoch (t , epoch , orbit .reference_epoch )
271
271
dop = np .zeros ((len (t ), len (r )))
@@ -349,9 +349,9 @@ def make_output_grid(cfg: Struct, igrid):
349
349
nr = int (np .round ((r1 - r0 ) / dr ))
350
350
nt = int (np .round ((t1 - t0 ) * prf ))
351
351
assert (nr > 0 ) and (nt > 0 )
352
- ogrid = isce .product .RadarGridParameters (t0 , igrid .wavelength , prf , r0 ,
353
- dr , igrid .lookside , nt , nr ,
354
- igrid .ref_epoch )
352
+ ogrid = isce3 .product .RadarGridParameters (t0 , igrid .wavelength , prf , r0 ,
353
+ dr , igrid .lookside , nt , nr ,
354
+ igrid .ref_epoch )
355
355
return ogrid
356
356
357
357
@@ -362,9 +362,9 @@ def get_kernel(cfg: Struct):
362
362
if opt .type .lower () != 'knab' :
363
363
raise NotImplementedError ("Only Knab kernel implemented." )
364
364
n = 1 + 2 * opt .halfwidth
365
- kernel = isce .core .KnabKernel (n , 1 / 1.2 )
365
+ kernel = isce3 .core .KnabKernel (n , 1 / 1.2 )
366
366
assert opt .fit .lower () == "table"
367
- table = isce .core .TabulatedKernelF32 (kernel , opt .fit_order )
367
+ table = isce3 .core .TabulatedKernelF32 (kernel , opt .fit_order )
368
368
return table
369
369
370
370
@@ -380,8 +380,8 @@ def verify_uniform_pri(t: np.ndarray, atol=0.0, rtol=0.001):
380
380
381
381
382
382
def resample (raw : np .ndarray , t : np .ndarray ,
383
- grid : isce .product .RadarGridParameters , swaths : np .ndarray ,
384
- orbit : isce .core .Orbit , doppler : isce .core .LUT2d , L = 12.0 ,
383
+ grid : isce3 .product .RadarGridParameters , swaths : np .ndarray ,
384
+ orbit : isce3 .core .Orbit , doppler : isce3 .core .LUT2d , L = 12.0 ,
385
385
fn = "regridded.c8" ):
386
386
"""
387
387
Fill gaps and resample raw data to uniform grid using BLU method.
@@ -425,10 +425,10 @@ def resample(raw: np.ndarray, t: np.ndarray,
425
425
# Get velocity for scaling autocorrelation function. Won't change much
426
426
# but update every pulse to avoid artifacts across images.
427
427
v = np .linalg .norm (orbit .interpolate (tout )[1 ])
428
- acor = isce .core .AzimuthKernel (L / v )
428
+ acor = isce3 .core .AzimuthKernel (L / v )
429
429
# Figure out what pulses are in play by computing weights without mask.
430
430
# TODO All we really need is offset and len(weights)... maybe refactor.
431
- offset , weights = isce .focus .get_presum_weights (acor , t , tout )
431
+ offset , weights = isce3 .focus .get_presum_weights (acor , t , tout )
432
432
nw = len (weights )
433
433
# Compute valid data mask (transposed).
434
434
# NOTE Could store the whole mask instead of recomputing blocks.
@@ -451,14 +451,14 @@ def resample(raw: np.ndarray, t: np.ndarray,
451
451
valid = (uid & twiddle ).astype (bool )
452
452
# Pull out valid times for this mask config and compute weights.
453
453
tj = t [offset :offset + nw ][valid ]
454
- joff , jwgt = isce .focus .get_presum_weights (acor , tj , tout )
454
+ joff , jwgt = isce3 .focus .get_presum_weights (acor , tj , tout )
455
455
assert joff == 0
456
456
# Now insert zeros where data is invalid to get full-length weights.
457
457
jwgt_full = np .zeros_like (weights )
458
458
jwgt_full [valid ] = jwgt
459
459
lut [uid ] = jwgt_full
460
460
# Fill weights for entire block using look up table.
461
- w = isce .focus .fill_weights (ids , lut )
461
+ w = isce3 .focus .fill_weights (ids , lut )
462
462
# Read raw data.
463
463
block = np .s_ [offset :offset + nw , :]
464
464
x = raw [block ]
@@ -479,7 +479,7 @@ def delete_safely(filename):
479
479
pass
480
480
481
481
482
- def get_range_deramp (grid : isce .product .RadarGridParameters ) -> np .ndarray :
482
+ def get_range_deramp (grid : isce3 .product .RadarGridParameters ) -> np .ndarray :
483
483
"""Compute the phase ramp required to shift a backprojected grid to
484
484
baseband in range.
485
485
"""
@@ -502,7 +502,7 @@ def focus(runconfig):
502
502
orbit = get_orbit (cfg )
503
503
attitude = get_attitude (cfg )
504
504
fc_ref , dop_ref = make_doppler (cfg )
505
- zerodop = isce .core .LUT2d ()
505
+ zerodop = isce3 .core .LUT2d ()
506
506
azres = cfg .processing .azcomp .azimuth_resolution
507
507
atmos = cfg .processing .dry_troposphere_model or "nodelay"
508
508
kernel = get_kernel (cfg )
@@ -519,14 +519,14 @@ def focus(runconfig):
519
519
use_gpu = gpu_check .use_gpu (cfg .worker .gpu_enabled , cfg .worker .gpu_id )
520
520
if use_gpu :
521
521
# Set the current CUDA device.
522
- device = isce .cuda .core .Device (cfg .worker .gpu_id )
523
- isce .cuda .core .set_device (device )
522
+ device = isce3 .cuda .core .Device (cfg .worker .gpu_id )
523
+ isce3 .cuda .core .set_device (device )
524
524
525
525
log .info (f"Processing using CUDA device { device .id } ({ device .name } )" )
526
526
527
- backproject = isce .cuda .focus .backproject
527
+ backproject = isce3 .cuda .focus .backproject
528
528
else :
529
- backproject = isce .focus .backproject
529
+ backproject = isce3 .focus .backproject
530
530
531
531
# Generate reference output grid based on highest bandwidth, always A.
532
532
log .info (f"Available polarizations: { raw .polarizations } " )
@@ -548,8 +548,8 @@ def focus(runconfig):
548
548
ogrid ["B" ] = ogrid ["A" ][:, ::rskip ]
549
549
log .info ("Output grid B is %s" , ogrid ["B" ])
550
550
551
- polygon = isce .geometry .get_geo_perimeter_wkt (ogrid ["A" ], orbit ,
552
- zerodop , dem )
551
+ polygon = isce3 .geometry .get_geo_perimeter_wkt (ogrid ["A" ], orbit ,
552
+ zerodop , dem )
553
553
554
554
output_slc_path = os .path .abspath (cfg .ProductPathGroup .SASOutputFile )
555
555
@@ -639,15 +639,15 @@ def temp(suffix):
639
639
640
640
rcmode = parse_rangecomp_mode (cfg .processing .rangecomp .mode )
641
641
log .info (f"Preparing range compressor with { rcmode } " )
642
- rc = isce .focus .RangeComp (chirp , nr , maxbatch = na , mode = rcmode )
642
+ rc = isce3 .focus .RangeComp (chirp , nr , maxbatch = na , mode = rcmode )
643
643
644
644
# Rangecomp modifies range grid. Also update wavelength.
645
645
rc_grid = raw_grid .copy ()
646
646
rc_grid .starting_range -= (
647
647
rc_grid .range_pixel_spacing * rc .first_valid_sample )
648
648
rc_grid .width = rc .output_size
649
- rc_grid .wavelength = isce .core .speed_of_light / fc
650
- igeom = isce .container .RadarGeometry (rc_grid , orbit , dop [frequency ])
649
+ rc_grid .wavelength = isce3 .core .speed_of_light / fc
650
+ igeom = isce3 .container .RadarGeometry (rc_grid , orbit , dop [frequency ])
651
651
652
652
fd = temp ("_rc.c8" )
653
653
log .info (f"Writing range compressed data to { fd .name } " )
@@ -683,7 +683,7 @@ def temp(suffix):
683
683
block = np .s_ [i :imax , j :jmax ]
684
684
log .info (f"Azcomp block at (i, j) = ({ i } , { j } )" )
685
685
bgrid = ogrid [frequency ][block ]
686
- ogeom = isce .container .RadarGeometry (bgrid , orbit , zerodop )
686
+ ogeom = isce3 .container .RadarGeometry (bgrid , orbit , zerodop )
687
687
z = np .zeros (bgrid .shape , 'c8' )
688
688
backproject (z , ogeom , rcfile .data , igeom , dem , fc , azres ,
689
689
kernel , atmos , vars (cfg .processing .azcomp .rdr2geo ),
0 commit comments