Skip to content

Commit

Permalink
Remove unused PRM.resamp() wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyPechnikov committed Sep 21, 2024
1 parent 7546eec commit 73175e6
Showing 1 changed file with 0 additions and 66 deletions.
66 changes: 0 additions & 66 deletions pygmtsar/pygmtsar/PRM_gmtsar.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,72 +206,6 @@ def SAT_llt2rat(self, coords=None, fromfile=None, tofile=None, precise=1, binary
out = np.fromstring(stdout_data, dtype=float, sep=' ')
return out if out.size==5 else out.reshape(-1,5)

def resamp(self, repeatPRM, repeatSLC_tofile, interp, debug=False):
"""
Resample the repeat image.
Parameters
----------
repeatPRM : PRM
The PRM object for the repeat image.
repeatSLC_tofile : str
The file path to save the resampled repeat SLC image to.
interp : int
The interpolation method: 1 for nearest, 2 for bilinear, 3 for biquadratic, or 4 for bisinc.
debug : bool, optional
If True, debug information will be printed. Default is False.
Returns
-------
PRM
The PRM object for the resampled repeat image.
Notes
-----
This method resamples the repeat image using the current PRM object and the PRM object for the repeat image.
The resampled repeat SLC image is saved to the specified file, and the resulting PRM parameters are returned.
"""
import os
import subprocess
from pygmtsar import PRM

if not isinstance(repeatPRM, PRM):
raise Exception('Argument should be PRM class instance')

SLC_tmpname = os.path.split(repeatSLC_tofile)[-1] + '.tmp'

pipe1 = os.pipe()
os.write(pipe1[1], bytearray(repeatPRM.to_str(), 'utf8'))
os.close(pipe1[1])
#print ('descriptor 1', pipe1[0])

pipe2 = os.pipe()
#print ('descriptor 2', pipe2[1])

# Usage: resamp master.PRM repeat.PRM new_repeat.PRM new_repeat.SLC interp
argv = ['resamp', f'/dev/stdin', f'/dev/fd/{pipe1[0]}',
f'/dev/fd/{pipe2[1]}', SLC_tmpname, str(interp)]
if debug:
print ('DEBUG: argv', argv)
cwd = os.path.dirname(self.filename) if self.filename is not None else '.'
if debug:
print ('DEBUG: cwd', cwd)
p = subprocess.Popen(argv, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, pass_fds=[pipe1[0], pipe2[1]],
cwd=cwd)
stdout_data, stderr_data = p.communicate(input=bytearray(self.to_str(), 'utf8'))

if len(stderr_data) > 0 and debug:
print ('DEBUG: resamp', stderr_data.decode('utf8'))

# rename the file to the persistent name
if os.path.exists(repeatSLC_tofile + '.tmp'):
os.rename(repeatSLC_tofile + '.tmp', repeatSLC_tofile)

# PRM file should be small text
data = os.read(pipe2[0],int(10e6))
return PRM.from_str(data.decode('utf8'))

def SAT_look(self, coords=None, fromfile=None, tofile=None, binary=False, debug=False):
"""
Compute the satellite look vector.
Expand Down

0 comments on commit 73175e6

Please sign in to comment.