From c6e8c7922e782c0b28b2055e58903c92bd06ef96 Mon Sep 17 00:00:00 2001
From: Microwave Remote Sensing Laboratory
<50493465+MIRSL@users.noreply.github.com>
Date: Thu, 26 Sep 2019 15:18:08 -0400
Subject: [PATCH 01/15] Add files via upload
updated mainly to read the zipped datasets, remove orbit extender, try except for precise/coarse orbit
---
components/isceobj/Sensor/GRD/Sentinel1.py | 34 ++++++++++------------
1 file changed, 15 insertions(+), 19 deletions(-)
diff --git a/components/isceobj/Sensor/GRD/Sentinel1.py b/components/isceobj/Sensor/GRD/Sentinel1.py
index 45e648b..00f9195 100755
--- a/components/isceobj/Sensor/GRD/Sentinel1.py
+++ b/components/isceobj/Sensor/GRD/Sentinel1.py
@@ -261,10 +261,10 @@ class Sentinel1(Component):
self.validateUserInputs()
- if self.xml.startswith('/vsizip'): #Read from zip file
+ if '.zip' in self.xml:
try:
parts = self.xml.split(os.path.sep)
- zipname = os.path.join(*(parts[2:-3]))
+ zipname = os.path.join('/',*(parts[:-3]))
fname = os.path.join(*(parts[-3:]))
with zipfile.ZipFile(zipname, 'r') as zf:
@@ -291,8 +291,10 @@ class Sentinel1(Component):
####Read in the orbits
if self.orbitFile:
- orb = self.extractPreciseOrbit()
- else:
+ try:
+ orb = self.extractPreciseOrbit()
+ except:
+ pass
orb = self.extractOrbit()
self.product.orbit.setOrbitSource('Header')
@@ -423,10 +425,11 @@ class Sentinel1(Component):
nsp = "{http://www.esa.int/safe/sentinel-1.0}"
- if self.manifest.startswith('/vsizip'):
+ if '.zip' in self.manifest:
+
import zipfile
parts = self.manifest.split(os.path.sep)
- zipname = os.path.join(*(parts[2:-2]))
+ zipname = os.path.join('/',*(parts[:-2]))
fname = os.path.join(*(parts[-2:]))
try:
@@ -516,13 +519,7 @@ class Sentinel1(Component):
vec.setVelocity(vel)
frameOrbit.addStateVector(vec)
-
- orbExt = OrbitExtender(planet=Planet(pname='Earth'))
- orbExt.configure()
- newOrb = orbExt.extendOrbit(frameOrbit)
-
-
- return newOrb
+ return frameOrbit
def extractPreciseOrbit(self):
'''
@@ -533,10 +530,9 @@ class Sentinel1(Component):
except IOError as strerr:
print("IOError: %s" % strerr)
return
-
- _xml_root = ElementTree(file=fp).getroot()
+ #_xml_root = ElementTree(file=fp).getroot()
- node = _xml_root.find('Data_Block/List_of_OSVs')
+ node = self._xml_root.find('Data_Block/List_of_OSVs')
print('Extracting orbit from Orbit File: ', self.orbitFile)
orb = Orbit()
@@ -582,10 +578,10 @@ class Sentinel1(Component):
if self.calibrationXml is None:
raise Exception('No calibration file provided')
- if self.calibrationXml.startswith('/vsizip'):
+ if '.zip' in self.calibrationXml:
import zipfile
parts = self.calibrationXml.split(os.path.sep)
- zipname = os.path.join(*(parts[2:-4]))
+ zipname = os.path.join('/',*(parts[:-4]))
fname = os.path.join(*(parts[-4:]))
try:
@@ -723,7 +719,7 @@ class Sentinel1(Component):
print('Extracting normalized image ....')
- src = gdal.Open(self.tiff.strip(), gdal.GA_ReadOnly)
+ src = gdal.Open('/vsizip//'+self.tiff.strip(), gdal.GA_ReadOnly)
band = src.GetRasterBand(1)
if self.product.numberOfSamples != src.RasterXSize:
From 64e2fdff0f42508b8e6e2c740ab0e9d5af57b1cf Mon Sep 17 00:00:00 2001
From: Microwave Remote Sensing Laboratory
<50493465+MIRSL@users.noreply.github.com>
Date: Thu, 26 Sep 2019 15:20:35 -0400
Subject: [PATCH 02/15] Add files via upload
updated posting
---
applications/rtcApp.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/applications/rtcApp.py b/applications/rtcApp.py
index ab45a7e..836151e 100755
--- a/applications/rtcApp.py
+++ b/applications/rtcApp.py
@@ -155,7 +155,7 @@ NUMBER_RANGE_LOOKS = Application.Parameter('numberRangeLooks',
)
POSTING = Application.Parameter('posting',
- public_name='azimuth looks',
+ public_name='posting',
default = 20.0,
type = float,
mandatory = False,
@@ -363,6 +363,7 @@ class GRDSAR(Application):
self.verifyDEM = RtcProc.createVerifyDEM(self)
self.multilook = RtcProc.createLooks(self)
self.runTopo = RtcProc.createTopo(self)
+ self.runNormalize = RtcProc.createNormalize(self)
# self.runGeocode = RtcProc.createGeocode(self)
return None
@@ -392,6 +393,9 @@ class GRDSAR(Application):
##Run topo for each bursts
self.step('topo', func=self.runTopo)
+ ##Run normalize to get gamma0
+ self.step('normalize', func=self.runNormalize)
+
# Geocode
# self.step('geocode', func=self.runGeocode,
# args=(self.geocode_list, self.do_unwrap, self.geocode_bbox))
@@ -416,6 +420,9 @@ class GRDSAR(Application):
##Run topo for each burst
self.runTopo()
+
+ ##Run normalize to get gamma0
+ self.runNormalize()
###Compute covariance
# self.runEstimateCovariance()
From 620ea91641031d19a989b979cfba7fb9ef4d7441 Mon Sep 17 00:00:00 2001
From: Microwave Remote Sensing Laboratory
<50493465+MIRSL@users.noreply.github.com>
Date: Thu, 26 Sep 2019 15:22:27 -0400
Subject: [PATCH 03/15] Add files via upload
---
contrib/stack/stripmapStack/crossmul.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/contrib/stack/stripmapStack/crossmul.py b/contrib/stack/stripmapStack/crossmul.py
index 8ffeeef..7b07716 100755
--- a/contrib/stack/stripmapStack/crossmul.py
+++ b/contrib/stack/stripmapStack/crossmul.py
@@ -33,6 +33,8 @@ def cmdLineParse(iargs = None):
def run(imageSlc1, imageSlc2, resampName, azLooks, rgLooks):
objSlc1 = isceobj.createSlcImage()
+ #right now imageSlc1 and 2 are just text files, need to open them as image
+
IU.copyAttributes(imageSlc1, objSlc1)
objSlc1.setAccessMode('read')
objSlc1.createImage()
@@ -81,7 +83,6 @@ def run(imageSlc1, imageSlc2, resampName, azLooks, rgLooks):
def main(iargs=None):
-
inps = cmdLineParse(iargs)
img1 = isceobj.createImage()
@@ -96,9 +97,8 @@ def main(iargs=None):
run(img1, img2, inps.prefix, inps.azlooks, inps.rglooks)
if __name__ == '__main__':
-
+
+ main()
'''
Main driver.
'''
-
-
From 9d7908beaf12d54cc853d1e7a41bb7ef4874585c Mon Sep 17 00:00:00 2001
From: Microwave Remote Sensing Laboratory
<50493465+MIRSL@users.noreply.github.com>
Date: Thu, 26 Sep 2019 15:25:09 -0400
Subject: [PATCH 04/15] Add files via upload
updated for radiometric terrain correction
control looks by providing 'posting' in xml
---
components/isceobj/RtcProc/Factories.py | 1 +
components/isceobj/RtcProc/RtcProc.py | 2 +-
components/isceobj/RtcProc/runNormalize.py | 30 +++++++++++++---------
3 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/components/isceobj/RtcProc/Factories.py b/components/isceobj/RtcProc/Factories.py
index c779864..038f1f7 100644
--- a/components/isceobj/RtcProc/Factories.py
+++ b/components/isceobj/RtcProc/Factories.py
@@ -46,5 +46,6 @@ createPreprocessor = _factory("runPreprocessor")
createVerifyDEM = _factory("runVerifyDEM")
createLooks = _factory("runLooks")
createTopo = _factory("runTopo")
+createNormalize = _factory("runNormalize")
#createGeocode = _factory("runGeocode")
diff --git a/components/isceobj/RtcProc/RtcProc.py b/components/isceobj/RtcProc/RtcProc.py
index f529106..aac8b9a 100644
--- a/components/isceobj/RtcProc/RtcProc.py
+++ b/components/isceobj/RtcProc/RtcProc.py
@@ -69,7 +69,7 @@ INC_FILENAME = Component.Parameter(
GAMMA0_FILENAME = Component.Parameter(
'gamma0FileName',
public_name='Gamma0 backscatter file',
- default = 'gamma0.rdr',
+ default = 'gamma0.img',
type = str,
mandatory = False,
doc = 'Unmasked gamma0 backscatter file')
diff --git a/components/isceobj/RtcProc/runNormalize.py b/components/isceobj/RtcProc/runNormalize.py
index ce1e6c9..7d018e1 100644
--- a/components/isceobj/RtcProc/runNormalize.py
+++ b/components/isceobj/RtcProc/runNormalize.py
@@ -1,4 +1,4 @@
-#
+#!/usr/bin/env python3
# Author: Piyush Agram
# Copyright 2016
#
@@ -6,6 +6,8 @@
import logging
import isceobj
import mroipac
+from .runTopo import filenameWithLooks
+from .runLooks import takeLooks
import os
import numpy as np
from isceobj.Util.decorators import use_api
@@ -18,7 +20,6 @@ def runNormalize(self):
'''
Make sure that a DEM is available for processing the given data.
'''
-
refPol = self._grd.polarizations[0]
master = self._grd.loadProduct( os.path.join(self._grd.outputFolder, 'beta_{0}.xml'.format(refPol)))
@@ -26,17 +27,22 @@ def runNormalize(self):
azlooks, rglooks = self._grd.getLooks( self.posting, master.groundRangePixelSize, master.azimuthPixelSize, self.numberAzimuthLooks, self.numberRangeLooks)
- if (azlooks == 1) and (rglooks == 1):
- return
-
- slantRange = False
for pol in self._grd.polarizations:
- inname = os.path.join( self._grd.outputFolder, 'beta_{0}.img'.format(pol) )
- takeLooks(inname, azlooks, rglooks)
+ if (azlooks == 1) and (rglooks == 1):
+ inname = os.path.join( self._grd.outputFolder, 'beta_{0}.img'.format(pol))
+ else:
+ inname = os.path.join( self._grd.outputFolder, filenameWithLooks('beta_{0}.img'.format(pol), azlooks, rglooks))
- if not slantRange:
- inname = master.slantRangeImage.filename
- takeLooks(inname, azlooks, rglooks)
- slantRange = True
+ incname = os.path.join(self._grd.geometryFolder, self._grd.incFileName)
+ outname = os.path.join(self._grd.outputFolder, filenameWithLooks('gamma_{0}'.format(pol), azlooks, rglooks))
+ maskname = os.path.join(self._grd.geometryFolder, self._grd.slMaskFileName)
+ cmd = "imageMath.py --e='a*cos(b_0*PI/180.)/cos(b_1*PI/180.) * (c==0)' --a={beta} --b={inc} --c={mask} -o {out} -t FLOAT -s BIL"
+
+ cmdrun = cmd.format(inc = incname,
+ beta = inname,
+ out = outname,
+ mask = maskname)
+ status = os.system(cmdrun)
+
return
From 1902564666149bb174b23865c68e6c18a7c68777 Mon Sep 17 00:00:00 2001
From: Microwave Remote Sensing Laboratory
<50493465+MIRSL@users.noreply.github.com>
Date: Thu, 26 Sep 2019 15:29:41 -0400
Subject: [PATCH 05/15] Update README.md
added example for running rtcApp
---
README.md | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index b8984d9..401c735 100644
--- a/README.md
+++ b/README.md
@@ -623,7 +623,23 @@ between three files as follows:
20061231
```
-
+#### rtcApp.xml
+```xml
+
+ /Users/data/sentinel1
+
+ 20
+ sentinel1
+
+ $dir$/rtc_App_new/data/S1A_IW_GRDH_1SDV_20181221T225104_20181221T225129_025130_02C664_B46C.zip
+ $dir$/orbits
+ $dir$/orbits/S1A_OPER_AUX_RESORB_OPOD_20181222T011619_V20181221T210119_20181222T001849.EOF
+ $dir$/rtc_App_new/output
+ [VV, VH]
+
+
+
+```
-----
## Component Configurability
From 5d8c24f3b4b48b04aa7dc7feee8650d9b95d0151 Mon Sep 17 00:00:00 2001
From: Microwave Remote Sensing Laboratory
<50493465+MIRSL@users.noreply.github.com>
Date: Thu, 26 Sep 2019 15:32:29 -0400
Subject: [PATCH 06/15] Update README.md
---
README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 401c735..6435d46 100644
--- a/README.md
+++ b/README.md
@@ -623,7 +623,8 @@ between three files as follows:
20061231
```
-#### rtcApp.xml
+#### rtcApp.xml
+The inputs are Sentinel GRD zipfiles
```xml
/Users/data/sentinel1
From bba2940b54ed0368b787800dd36f3b7b4ee00b6d Mon Sep 17 00:00:00 2001
From: Microwave Remote Sensing Laboratory
<50493465+MIRSL@users.noreply.github.com>
Date: Thu, 26 Sep 2019 15:33:32 -0400
Subject: [PATCH 07/15] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 6435d46..16263d6 100644
--- a/README.md
+++ b/README.md
@@ -623,7 +623,7 @@ between three files as follows:
20061231
```
-#### rtcApp.xml
+### rtcApp.xml
The inputs are Sentinel GRD zipfiles
```xml
From e37deaf7963d3cce16c007ede0c525ac3a64c9db Mon Sep 17 00:00:00 2001
From: Microwave Remote Sensing Laboratory
<50493465+MIRSL@users.noreply.github.com>
Date: Thu, 26 Sep 2019 15:35:15 -0400
Subject: [PATCH 08/15] Update README.md
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 16263d6..252fd6b 100644
--- a/README.md
+++ b/README.md
@@ -632,10 +632,10 @@ The inputs are Sentinel GRD zipfiles
20
sentinel1
- $dir$/rtc_App_new/data/S1A_IW_GRDH_1SDV_20181221T225104_20181221T225129_025130_02C664_B46C.zip
+ $dir$/rtcApp/data/S1A_IW_GRDH_1SDV_20181221T225104_20181221T225129_025130_02C664_B46C.zip
$dir$/orbits
$dir$/orbits/S1A_OPER_AUX_RESORB_OPOD_20181222T011619_V20181221T210119_20181222T001849.EOF
- $dir$/rtc_App_new/output
+ $dir$/rtcApp/output
[VV, VH]
From ab805ed1a3d58cd04892a7b5c0f10e995fed63eb Mon Sep 17 00:00:00 2001
From: Microwave Remote Sensing Laboratory
<50493465+MIRSL@users.noreply.github.com>
Date: Thu, 26 Sep 2019 16:51:54 -0400
Subject: [PATCH 09/15] Update runNormalize.py
---
components/isceobj/RtcProc/runNormalize.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/components/isceobj/RtcProc/runNormalize.py b/components/isceobj/RtcProc/runNormalize.py
index 7d018e1..170c6de 100644
--- a/components/isceobj/RtcProc/runNormalize.py
+++ b/components/isceobj/RtcProc/runNormalize.py
@@ -34,7 +34,7 @@ def runNormalize(self):
inname = os.path.join( self._grd.outputFolder, filenameWithLooks('beta_{0}.img'.format(pol), azlooks, rglooks))
incname = os.path.join(self._grd.geometryFolder, self._grd.incFileName)
- outname = os.path.join(self._grd.outputFolder, filenameWithLooks('gamma_{0}'.format(pol), azlooks, rglooks))
+ outname = os.path.join(self._grd.outputFolder, filenameWithLooks('gamma_{0}'.format(pol)+'.img', azlooks, rglooks))
maskname = os.path.join(self._grd.geometryFolder, self._grd.slMaskFileName)
cmd = "imageMath.py --e='a*cos(b_0*PI/180.)/cos(b_1*PI/180.) * (c==0)' --a={beta} --b={inc} --c={mask} -o {out} -t FLOAT -s BIL"
From 14418467ae071df93858b071073732e8b2eb27e9 Mon Sep 17 00:00:00 2001
From: Microwave Remote Sensing Laboratory
<50493465+MIRSL@users.noreply.github.com>
Date: Fri, 27 Sep 2019 13:21:43 -0400
Subject: [PATCH 10/15] Add files via upload
fixed issues relating to finding and selecting between orbits
---
components/isceobj/Sensor/GRD/Sentinel1.py | 63 +++++++++++-----------
1 file changed, 31 insertions(+), 32 deletions(-)
diff --git a/components/isceobj/Sensor/GRD/Sentinel1.py b/components/isceobj/Sensor/GRD/Sentinel1.py
index 00f9195..b910885 100755
--- a/components/isceobj/Sensor/GRD/Sentinel1.py
+++ b/components/isceobj/Sensor/GRD/Sentinel1.py
@@ -283,25 +283,22 @@ class Sentinel1(Component):
self.populateMetadata()
self.populateBbox()
- ####Tru and locate an orbit file
+ ####Try and locate an orbit file
if self.orbitFile is None:
if self.orbitDir is not None:
self.orbitFile = self.findOrbitFile()
+ print('Found this orbitfile: %s' %self.orbitFile)
-
####Read in the orbits
- if self.orbitFile:
- try:
- orb = self.extractPreciseOrbit()
- except:
- pass
+ if '_POEORB_' in self.orbitFile:
+ orb = self.extractPreciseOrbit()
+ elif '_RESORB_' in self.orbitFile:
orb = self.extractOrbit()
-
+
self.product.orbit.setOrbitSource('Header')
for sv in orb:
self.product.orbit.addStateVector(sv)
-
self.populateIPFVersion()
self.extractBetaLUT()
self.extractNoiseLUT()
@@ -465,38 +462,40 @@ class Sentinel1(Component):
datefmt = "%Y%m%dT%H%M%S"
types = ['POEORB', 'RESORB']
+ filelist = []
match = []
- timeStamp = self.product.sensingMid
-
+ timeStamp = self.product.sensingStart+(self.product.sensingStop - self.product.sensingStart)/2.
+
for orbType in types:
files = glob.glob( os.path.join(self.orbitDir, 'S1A_OPER_AUX_' + orbType + '_OPOD*'))
-
+ filelist.extend(files)
###List all orbit files
- for result in files:
- fields = result.split('_')
- taft = datetime.datetime.strptime(fields[-1][0:15], datefmt)
- tbef = datetime.datetime.strptime(fields[-2][1:16], datefmt)
-
- #####Get all files that span the acquisition
- if (tbef <= timeStamp) and (taft >= timeStamp):
- tmid = tbef + 0.5 * (taft - tbef)
- match.append((result, abs((timeStamp-tmid).total_seconds())))
- #####Return the file with the image is aligned best to the middle of the file
- if len(match) != 0:
- bestmatch = min(match, key = lambda x: x[1])
- return bestmatch[0]
+ for result in filelist:
+ fields = result.split('_')
+ taft = datetime.datetime.strptime(fields[-1][0:15], datefmt)
+ tbef = datetime.datetime.strptime(fields[-2][1:16], datefmt)
+ print(taft, tbef)
+
+ #####Get all files that span the acquisition
+ if (tbef <= timeStamp) and (taft >= timeStamp):
+ tmid = tbef + 0.5 * (taft - tbef)
+ match.append((result, abs((timeStamp-tmid).total_seconds())))
+ #####Return the file with the image is aligned best to the middle of the file
+ if len(match) != 0:
+ bestmatch = min(match, key = lambda x: x[1])
+ return bestmatch[0]
- if len(match) == 0:
- raise Exception('No suitable orbit file found. If you want to process anyway - unset the orbitdir parameter')
+ if len(match) == 0:
+ raise Exception('No suitable orbit file found. If you want to process anyway - unset the orbitdir parameter')
def extractOrbit(self):
'''
Extract orbit information from xml node.
'''
node = self._xml_root.find('generalAnnotation/orbitList')
-
+
print('Extracting orbit from annotation XML file')
frameOrbit = Orbit()
frameOrbit.configure()
@@ -530,11 +529,11 @@ class Sentinel1(Component):
except IOError as strerr:
print("IOError: %s" % strerr)
return
- #_xml_root = ElementTree(file=fp).getroot()
-
- node = self._xml_root.find('Data_Block/List_of_OSVs')
- print('Extracting orbit from Orbit File: ', self.orbitFile)
+ _xml_root = ElementTree.ElementTree(file=fp).getroot()
+
+ node = _xml_root.find('Data_Block/List_of_OSVs')
+
orb = Orbit()
orb.configure()
From 5cce895f52aa7e441b3ca8ce671c0d17feaca2d0 Mon Sep 17 00:00:00 2001
From: Microwave Remote Sensing Laboratory
<50493465+MIRSL@users.noreply.github.com>
Date: Fri, 27 Sep 2019 13:22:26 -0400
Subject: [PATCH 11/15] Update README.md
---
README.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/README.md b/README.md
index 252fd6b..3d75f33 100644
--- a/README.md
+++ b/README.md
@@ -634,7 +634,6 @@ The inputs are Sentinel GRD zipfiles
$dir$/rtcApp/data/S1A_IW_GRDH_1SDV_20181221T225104_20181221T225129_025130_02C664_B46C.zip
$dir$/orbits
- $dir$/orbits/S1A_OPER_AUX_RESORB_OPOD_20181222T011619_V20181221T210119_20181222T001849.EOF
$dir$/rtcApp/output
[VV, VH]
From 567c691f3d9287eb010c0849fd0256db2a99b741 Mon Sep 17 00:00:00 2001
From: Microwave Remote Sensing Laboratory
<50493465+MIRSL@users.noreply.github.com>
Date: Fri, 27 Sep 2019 13:23:36 -0400
Subject: [PATCH 12/15] Update README.md
---
README.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 3d75f33..412a0ac 100644
--- a/README.md
+++ b/README.md
@@ -633,9 +633,9 @@ The inputs are Sentinel GRD zipfiles
sentinel1
$dir$/rtcApp/data/S1A_IW_GRDH_1SDV_20181221T225104_20181221T225129_025130_02C664_B46C.zip
- $dir$/orbits
- $dir$/rtcApp/output
- [VV, VH]
+ $dir$/orbits
+ $dir$/rtcApp/output
+ [VV, VH]
From 74fdcbf6579090f79f5d62d43b66a7371cab5de5 Mon Sep 17 00:00:00 2001
From: Microwave Remote Sensing Laboratory
<50493465+MIRSL@users.noreply.github.com>
Date: Mon, 30 Sep 2019 15:25:51 -0400
Subject: [PATCH 13/15] Add files via upload
---
applications/imageMath.py | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/applications/imageMath.py b/applications/imageMath.py
index 3977a89..63795d7 100755
--- a/applications/imageMath.py
+++ b/applications/imageMath.py
@@ -293,6 +293,7 @@ def main(args, files):
#######Determine number of input and output bands
bandList = []
+ iMath['equations'] = []
for ii,expr in enumerate(args.equation.split(';')):
#####Now parse the equation to get the file names used
@@ -314,12 +315,16 @@ def main(args, files):
#####Determine unique images from the bandList
- fileList = IML.bandsToFiles(bandList, logger)
+ fileList = IML.bandsToFiles(bandList, logger) #[a,b,c]
######Create input memmaps
for ii,infile in enumerate(fileList):
- fstr, files = parseInputFile(infile, files)
+ if type(files) == list:
+ fstr, files = parseInputFile(infile, files)
+ else:
+ fstr = getattr(files, infile)
+
logger.debug('Input string for File %d: %s: %s'%(ii, infile, fstr))
if len(fstr.split(';')) > 1:
@@ -341,8 +346,9 @@ def main(args, files):
if bbox is not None:
iMath['bboxes'].append(bbox)
- if len(files):
- raise IOError('Unused input variables set:\n'+ ' '.join(files))
+ if type(files) == list:
+ if len(files):
+ raise IOError('Unused input variables set:\n'+ ' '.join(files))
#######Some debugging
logger.debug('List of available bands: ' + str(iMath['inBands'].keys()))
From 0e3b06567f1462533b3690d23d44c977dbdc7468 Mon Sep 17 00:00:00 2001
From: Microwave Remote Sensing Laboratory
<50493465+MIRSL@users.noreply.github.com>
Date: Mon, 30 Sep 2019 15:26:54 -0400
Subject: [PATCH 14/15] Add files via upload
changed to use imagemath.main() instead of command line
---
components/isceobj/RtcProc/runNormalize.py | 32 +++++++++++++++-------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/components/isceobj/RtcProc/runNormalize.py b/components/isceobj/RtcProc/runNormalize.py
index 170c6de..70ce9cb 100644
--- a/components/isceobj/RtcProc/runNormalize.py
+++ b/components/isceobj/RtcProc/runNormalize.py
@@ -9,12 +9,15 @@ import mroipac
from .runTopo import filenameWithLooks
from .runLooks import takeLooks
import os
+import itertools
import numpy as np
from isceobj.Util.decorators import use_api
+from applications import imageMath
logger = logging.getLogger('isce.grdsar.looks')
-
+class Dummy:
+ pass
def runNormalize(self):
'''
@@ -33,16 +36,25 @@ def runNormalize(self):
else:
inname = os.path.join( self._grd.outputFolder, filenameWithLooks('beta_{0}.img'.format(pol), azlooks, rglooks))
- incname = os.path.join(self._grd.geometryFolder, self._grd.incFileName)
+ basefolder, output = os.path.split(self._grd.outputFolder)
+ incname = os.path.join(basefolder, self._grd.geometryFolder, self._grd.incFileName)
outname = os.path.join(self._grd.outputFolder, filenameWithLooks('gamma_{0}'.format(pol)+'.img', azlooks, rglooks))
- maskname = os.path.join(self._grd.geometryFolder, self._grd.slMaskFileName)
+ maskname = os.path.join(basefolder, self._grd.geometryFolder, self._grd.slMaskFileName)
- cmd = "imageMath.py --e='a*cos(b_0*PI/180.)/cos(b_1*PI/180.) * (c==0)' --a={beta} --b={inc} --c={mask} -o {out} -t FLOAT -s BIL"
+ args = imageMath.createNamespace()
+ args.equation = 'a*cos(b_0*PI/180.)/cos(b_1*PI/180.) * (c==0)'
+ args.dtype = np.float32
+ args.scheme = 'BIL'
+ args.out = outname
+ #args.debug = True
+
+ files = Dummy()
+ files.a = inname
+ files.b = incname
+ files.c = maskname
+
+
+
+ imageMath.main(args, files)
- cmdrun = cmd.format(inc = incname,
- beta = inname,
- out = outname,
- mask = maskname)
- status = os.system(cmdrun)
-
return
From e15336cc5e04b1c682ef18d0a4c769ff222f050e Mon Sep 17 00:00:00 2001
From: Microwave Remote Sensing Laboratory
<50493465+MIRSL@users.noreply.github.com>
Date: Mon, 30 Sep 2019 15:31:04 -0400
Subject: [PATCH 15/15] Add files via upload
couple edits to deal with receiving data as list (the command line/system call approach) versus receiving data passed as object
---
applications/imageMath.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/applications/imageMath.py b/applications/imageMath.py
index 63795d7..432e262 100755
--- a/applications/imageMath.py
+++ b/applications/imageMath.py
@@ -315,7 +315,7 @@ def main(args, files):
#####Determine unique images from the bandList
- fileList = IML.bandsToFiles(bandList, logger) #[a,b,c]
+ fileList = IML.bandsToFiles(bandList, logger)
######Create input memmaps