pull request in response to rtcApp.py is incomplete #120 (#128)

* Update README.md
* Update runTopo.py
* Update rtcApp.py
* Update runNormalize.py
* Update SConscript
LT1AB
Simon Kraatz 2020-05-06 18:04:58 -04:00 committed by GitHub
parent 4282bb8e0a
commit fb7ad09211
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 119 additions and 15 deletions

View File

@ -630,13 +630,16 @@ The inputs are Sentinel GRD zipfiles
<rtcApp>
<constant name="dir">/Users/data/sentinel1 </constant>
<component name="rtcApp">
<property name="posting">20</property>
<property name="sensor name">sentinel1</property>
<property name="posting">100</property>
<property name="polarizations">[VV, VH]</property>
<property name="epsg id">32618</property>
<property name="geocode spacing">100</property>
<property name="geocode interpolation method">bilinear</property>
<component name="master">
<property name="safe">$dir$/rtcApp/data/S1A_IW_GRDH_1SDV_20181221T225104_20181221T225129_025130_02C664_B46C.zip</property>
<property name="orbit directory">$dir$/orbits</property>
<property name="output directory">$dir$/rtcApp/output</property>
<property name="polarization">[VV, VH]</property>
</component>
</component>
</rtcApp>

View File

@ -59,6 +59,7 @@ listFiles = ['mdx.py',
# 'extractHDROrbit.py',
# 'formSLC.py',
# 'viewMetadata.py',
'rtcApp.py',
'make_raw.py',
'__init__.py',
'isceApp.py',

View File

@ -100,6 +100,28 @@ GEOCODE_BOX = Application.Parameter(
doc='Bounding box for geocoding - South, North, West, East in degrees'
)
EPSG = Application.Parameter(
'epsg',
public_name='epsg id',
default = '',
type=str,
doc='epsg code for roi'
)
GSPACING = Application.Parameter('gspacing',
public_name='geocode spacing',
default = 100.0,
type = float,
doc = 'Desired grid spacing of geocoded product in meters, in the specified UTM grid.'
)
INTMETHOD = Application.Parameter('intmethod',
public_name='geocode interpolation method',
default = 'bilinear',
type = str,
doc = 'Desired grid spacing of geocoded product in meters, in the specified UTM grid.'
)
PICKLE_DUMPER_DIR = Application.Parameter(
'pickleDumpDir',
public_name='pickle dump directory',
@ -149,10 +171,10 @@ NUMBER_RANGE_LOOKS = Application.Parameter('numberRangeLooks',
POSTING = Application.Parameter('posting',
public_name='posting',
default = 20.0,
default = 10.0,
type = float,
mandatory = False,
doc = 'Posting of data used to determine looks')
doc = 'Posting of data. This can be any integer multiple of the product resolution. Used to determine looks')
POLARIZATIONS = Application.Parameter('polarizations',
public_name='polarizations',
@ -215,6 +237,9 @@ class GRDSAR(Application):
NUMBER_RANGE_LOOKS,
POSTING,
GEOCODE_BOX,
EPSG,
GSPACING,
INTMETHOD,
PICKLE_DUMPER_DIR,
PICKLE_LOAD_DIR,
RENDERER,
@ -357,7 +382,7 @@ class GRDSAR(Application):
self.multilook = RtcProc.createLooks(self)
self.runTopo = RtcProc.createTopo(self)
self.runNormalize = RtcProc.createNormalize(self)
# self.runGeocode = RtcProc.createGeocode(self)
self.runGeocode = RtcProc.createGeocode(self)
return None
@ -390,8 +415,8 @@ class GRDSAR(Application):
self.step('normalize', func=self.runNormalize)
# Geocode
# self.step('geocode', func=self.runGeocode,
# args=(self.geocode_list, self.do_unwrap, self.geocode_bbox))
self.step('geocode', func=self.runGeocode,
args=(self.geocode_list, self.geocode_bbox))
return None
@ -417,12 +442,8 @@ class GRDSAR(Application):
##Run normalize to get gamma0
self.runNormalize()
###Compute covariance
# self.runEstimateCovariance()
# Geocode
# self.runGeocode(self.geocode_list, self.do_unwrap, self.geocode_bbox)
self.runGeocode()
timeEnd = time.time()
logger.info("Total Time: %i seconds" %(timeEnd - timeStart))

View File

@ -47,5 +47,5 @@ createVerifyDEM = _factory("runVerifyDEM")
createLooks = _factory("runLooks")
createTopo = _factory("runTopo")
createNormalize = _factory("runNormalize")
#createGeocode = _factory("runGeocode")
createGeocode = _factory("runGeocode")

View File

@ -40,7 +40,7 @@ project = 'RtcProc'
install = os.path.join(envisceobj['PRJ_SCONS_INSTALL'],package,project)
listFiles = ['__init__.py', 'Factories.py', 'RtcProc.py', 'runPreprocessor.py', 'runVerifyDEM.py', 'runLooks.py', 'runTopo.py']
listFiles = ['__init__.py', 'Factories.py', 'RtcProc.py', 'runPreprocessor.py', 'runVerifyDEM.py', 'runLooks.py', 'runNormalize.py', 'runTopo.py', 'runGeocode.py']
envisceobj.Install(install,listFiles)
envisceobj.Alias('install',install)

View File

@ -0,0 +1,80 @@
#!/usr/bin/env python3
# coding: utf-8
# Author: Simon Kraatz
# Copyright 2016
import logging
import isceobj
import os
import numpy as np
from isceobj.Util.decorators import use_api
from osgeo import gdal, ogr, osr
logger = logging.getLogger('isce.grdsar.looks')
def runGeocode(self):
'''
Geocode a swath file using corresponding lat, lon files
'''
sourcexmltmpl = ''' <SimpleSource>
<SourceFilename>{0}</SourceFilename>
<SourceBand>{1}</SourceBand>
</SimpleSource>'''
gcl = [f for f in os.listdir(self._grd.outputFolder) if f.startswith('gamma') and f.endswith('.vrt')]
a, b = os.path.split(self._grd.outputFolder)
latfile = os.path.join(a,self._grd.geometryFolder,'lat.rdr.vrt')
lonfile = os.path.join(a,self._grd.geometryFolder,'lon.rdr.vrt')
outsrs = 'EPSG:'+str(self.epsg)
gspacing = self.gspacing
method = self.intmethod
insrs = 4326
fmt = 'GTiff'
fl = len(gcl)
for num, val in enumerate(gcl):
print('****Geocoding file %s out of %s: %s****' %(num+1, fl, val))
infile = os.path.join(a, self._grd.outputFolder, val)
outfile = os.path.join(a, self._grd.outputFolder, val[:-3]+'tif')
driver = gdal.GetDriverByName('VRT')
tempvrtname = os.path.join(a, self._grd.outputFolder, 'geocode.vrt')
inds = gdal.OpenShared(infile, gdal.GA_ReadOnly)
tempds = driver.Create(tempvrtname, inds.RasterXSize, inds.RasterYSize, 0)
for ii in range(inds.RasterCount):
band = inds.GetRasterBand(1)
tempds.AddBand(band.DataType)
tempds.GetRasterBand(ii+1).SetMetadata({'source_0': sourcexmltmpl.format(infile, ii+1)}, 'vrt_sources')
sref = osr.SpatialReference()
sref.ImportFromEPSG(insrs)
srswkt = sref.ExportToWkt()
tempds.SetMetadata({'SRS' : srswkt,
'X_DATASET': lonfile,
'X_BAND' : '1',
'Y_DATASET': latfile,
'Y_BAND' : '1',
'PIXEL_OFFSET' : '0',
'LINE_OFFSET' : '0',
'PIXEL_STEP' : '1',
'LINE_STEP' : '1'}, 'GEOLOCATION')
band = None
tempds = None
inds = None
bounds = None
spacing = [gspacing, gspacing]
warpOptions = gdal.WarpOptions(format=fmt,
xRes=spacing[0], yRes=spacing[1],
dstSRS=outsrs,
outputBounds = bounds,
resampleAlg=method, geoloc=True)
gdal.Warp(outfile, tempvrtname, options=warpOptions)
return

View File

@ -110,4 +110,3 @@ def runSimamp(outdir, hname='z.rdr'):
hgtImage.finalizeImage()
simImage.finalizeImage()