Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update scene_io.py #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions src/scene_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,8 @@ class GMTSAR(SceneIO):
Expects:

* Displacement grid (NetCDF, :file:`*los_ll.grd`) in meter
(in case use "gmt grdmath los_cm_ll.grd 0.01 MUL = los_m_ll.grd')
(in case use "gmt grdmath los_cm_ll.grd 0.01 MUL = los_m_ll.grd').
If grid file is in netCDF4 format, the python library netCDF4 is needed.
* LOS binary data (see instruction, :file:`*.los.enu`)

Calculate the corresponding unit look vectors with GMT5SAR ``SAT_look``:
Expand Down Expand Up @@ -809,12 +810,29 @@ def _getDisplacementFile(self, path):

def read(self, path, **kwargs):
from scipy.io import netcdf
import subprocess

path = op.abspath(path)
c = self.container

grd = netcdf.netcdf_file(self._getDisplacementFile(path),
filename = self._getDisplacementFile(path)
command = "ncinfo " + filename
subtext = subprocess.Popen(command,
stdout=subprocess.PIPE,
shell=True)
(ncinfo, err) = subtext.communicate()
ncinfo = str(ncinfo)
if ((ncinfo.find('netCDF4')>0) & (ncinfo.find('NETCDF3')<0)):
print('GMTSAR grid in netcdf4')
from netCDF4 import Dataset
grd = Dataset(self._getDisplacementFile(path), 'r')
else:
print('GMTSAR grid in netcdf3 classic')
grd = netcdf.netcdf_file(self._getDisplacementFile(path),
mode='r', version=2)
grd = netcdf.netcdf_file(self._getDisplacementFile(path),
mode='r', version=2)

displ = grd.variables['z'][:].copy()
c = self.container
c.displacement = displ
shape = c.displacement.shape
# LatLon
Expand All @@ -834,7 +852,7 @@ def read(self, path, **kwargs):
n = los[4::6].copy().reshape(shape)
u = los[5::6].copy().reshape(shape)

phi = num.arctan(n/e)
phi = num.arctan2(n,e)
theta = num.arcsin(u)
# phi[n < 0] += num.pi

Expand Down