Skip to content
Open
Show file tree
Hide file tree
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
44 changes: 22 additions & 22 deletions bin/csk_dump_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,34 @@
codeRevision=1.0 # this code revision number

def usage():
print 'INFO : @(#)Doris InSAR software, $Revision: %s $, $Author: TUDelft $' % codeRevision
print
print 'Usage : csk_dump_data.py <inputfile> <outputfile> [l0 lN p0 pN] [-res RESFILE]'
print
print ' inputfile is the input Cosmo-skymed HDF5 filename : master.hd5'
print ' outputfile is the output filename : master.slc'
print ' l0 is the first azimuth line (starting at 1)'
print ' lN is the last azimuth line'
print ' p0 is the first range pixel (starting at 1)'
print ' pN is the last range pixel'
print ' RESFILE DORIS result file that is to be updated for crop metadata (optional)'
print
print ' This software is part of Doris InSAR software package.\n'
print '(c) 1999-2010 Delft University of Technology, the Netherlands.\n'
print('INFO : @(#)Doris InSAR software, $Revision: %s $, $Author: TUDelft $' % codeRevision)
print('')
print('Usage : csk_dump_data.py <inputfile> <outputfile> [l0 lN p0 pN] [-res RESFILE]')
print()
print(' inputfile is the input Cosmo-skymed HDF5 filename : master.hd5')
print(' outputfile is the output filename : master.slc')
print(' l0 is the first azimuth line (starting at 1)')
print(' lN is the last azimuth line')
print(' p0 is the first range pixel (starting at 1)')
print(' pN is the last range pixel')
print(' RESFILE DORIS result file that is to be updated for crop metadata (optional)')
print()
print(' This software is part of Doris InSAR software package.\n')
print('(c) 1999-2010 Delft University of Technology, the Netherlands.\n')

try:
inputFileName = sys.argv[1]
outputFileName = sys.argv[2]
except:
print '\nError : Unrecognized input or missing arguments\n\n'
print('\nError : Unrecognized input or missing arguments\n\n')
usage()
sys.exit(1)

# accessing the HDF5 product file
f = h5py.File(inputFileName, 'r')
sbi = f.get('/S01/SBI')
if f.parent.__contains__('/') == False or f.parent.__contains__('/S01') == False or f.parent.__contains__('/S01/SBI') == False :
print 'ERROR: Wrong HDF5 format!'
print('ERROR: Wrong HDF5 format!')
data = array('h')
data = sbi[:,:,:]
Number_of_lines_original = sbi.shape[0]
Expand All @@ -69,7 +69,7 @@ def usage():
outputWinFirstPix = int(sys.argv[5])-1 # gdal srcwin starting at 0
outputWinLastPix = int(sys.argv[6]) # Lastpix --> yoff (later)
elif len(sys.argv) > 3 and len(sys.argv) < 7:
print 'Unrecognized input'
print('Unrecognized input')
usage()
sys.exit(1)
else:
Expand All @@ -86,13 +86,13 @@ def usage():
# outputWinLastLine = Number_of_lines_original-1
# outputWinFirstPix = 0
# outputWinLastPix = Number_of_pixels_original-1
# print 'crop parameters not provided,so cropping the whole image'
# print('crop parameters not provided,so cropping the whole image')
if outputWinFirstLine == None or outputWinLastLine == None or outputWinFirstPix == None or outputWinLastPix == None :
print '%s: running failed: crop size unknown !' % (sys.argv[0])
print('%s: running failed: crop size unknown !' % (sys.argv[0]))
sys.exit(1)

if outputWinLastLine-outputWinFirstLine+1 <0 or outputWinLastPix-outputWinFirstPix+1 <=0 :
print '%s running failed: crop dimensions are not invalid !' % (sys.argv[0])
print('%s running failed: crop dimensions are not invalid !' % (sys.argv[0]))
sys.exit(1)

# compute crop dimensions
Expand Down Expand Up @@ -122,7 +122,7 @@ def usage():
sys.stdout.write('%s...'%(temp*10))
temp = temp+1
# read the hdf5 data and write to file
data_line = data[n,range(outputWinFirstPix,outputWinLastPix),:]
data_line = data[n,list(range(outputWinFirstPix,outputWinLastPix)),:]
data_line.tofile(fid)
data_line = None
sys.stdout.write("100% - done.\n")
Expand All @@ -142,7 +142,7 @@ def usage():

# check whether the resfile exist!!!
if resFile is not None:
print resFile
print(resFile)
# load header
headerFileStream = open(os.path.splitext(outputFileName)[0]+'.hdr','r')
for line in headerFileStream:
Expand Down
18 changes: 9 additions & 9 deletions bin/csk_dump_header2doris.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
codeRevision=1.0 # this code revision number

def usage():
print 'INFO : @(#)Doris InSAR software, $Revision: %s $, $Author: TUDelft $' % codeRevision
print
print 'Usage : python csk_dump_header2doris.py csk_HDF5_product > OutputFileName'
print ' where csk_HDF5_product is the input filename'
print
print ' This software is part of Doris InSAR software package.\n'
print '(c) 1999-2010 Delft University of Technology, the Netherlands.\n'
print('INFO : @(#)Doris InSAR software, $Revision: %s $, $Author: TUDelft $' % codeRevision)
print()
print('Usage : python csk_dump_header2doris.py csk_HDF5_product > OutputFileName')
print(' where csk_HDF5_product is the input filename')
print()
print(' This software is part of Doris InSAR software package.\n')
print('(c) 1999-2010 Delft University of Technology, the Netherlands.\n')

try:
inputFileName = sys.argv[1]
except:
print '\nError : Unrecognized input or missing arguments\n\n'
print('\nError : Unrecognized input or missing arguments\n\n')
usage()
sys.exit(1)

Expand All @@ -38,7 +38,7 @@ def usage():


if f.parent.__contains__('/') == False or f.parent.__contains__('/S01') == False or f.parent.__contains__('/S01/SBI') == False or f.parent.__contains__('/S01/B001') == False or f.parent.__contains__('/S01/QLK') == False :
print 'ERROR: Wrong HDF5 format!'
print('ERROR: Wrong HDF5 format!')

# reading the attributes
VolumeFile = f.attrs.__getitem__('Product Filename')
Expand Down
22 changes: 11 additions & 11 deletions bin/hhmmss2sec.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
import os,sys,time

def usage():
print '\nUsage: python hhmmss2sec.py time'
print ' where time in the form HH:MM:SS.sss .'
print ' '
print ' Example '
print ' ./hhmmss2sec.py 16:36:40.393 '
print ' 59800.393000 '
print ' '
print ' See Also'
print ' sec2hhmmss.py'
print('\nUsage: python hhmmss2sec.py time')
print(' where time in the form HH:MM:SS.sss .')
print(' ')
print(' Example ')
print(' ./hhmmss2sec.py 16:36:40.393 ')
print(' 59800.393000 ')
print(' ')
print(' See Also')
print(' sec2hhmmss.py')

try:
timeOfDay = sys.argv[1]
except:
print 'Unrecognized input'
print('Unrecognized input')
usage()
sys.exit(1)

Expand All @@ -25,4 +25,4 @@ def usage():
ss = float(timeOfDay[2]);

secOfDay=hh*3600+mm*60+ss
print "%f" %(secOfDay)
print( "%f" %(secOfDay))
52 changes: 26 additions & 26 deletions bin/rs2_dump_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@

codeRevision=1.1 # this code revision number
def usage():
print 'INFO : @(#)Doris InSAR software, $Revision: %s $, $Author: TUDelft $' % codeRevision
print
print 'Usage : rs2_dump_data.py <inputfile> <outputfile> [l0 lN p0 pN] [-res RESFILE]'
print
print ' inputfile is the input Radarsat-2 geotiff filename : master.tif'
print ' outputfile is the output filename : master.slc'
print ' l0 is the first azimuth line (starting at 1)'
print ' lN is the last azimuth line'
print ' p0 is the first range pixel (starting at 1)'
print ' pN is the last range pixel'
print ' RESFILE DORIS result file that is to be updated for crop metadata (optional)'
print
print ' This software is part of Doris InSAR software package.\n'
print '(c) 1999-2010 Delft University of Technology, the Netherlands.\n'
print('INFO : @(#)Doris InSAR software, $Revision: %s $, $Author: TUDelft $' % codeRevision)
print()
print('Usage : rs2_dump_data.py <inputfile> <outputfile> [l0 lN p0 pN] [-res RESFILE]')
print()
print(' inputfile is the input Radarsat-2 geotiff filename : master.tif')
print(' outputfile is the output filename : master.slc')
print(' l0 is the first azimuth line (starting at 1)')
print(' lN is the last azimuth line')
print(' p0 is the first range pixel (starting at 1)')
print(' pN is the last range pixel')
print(' RESFILE DORIS result file that is to be updated for crop metadata (optional)')
print()
print(' This software is part of Doris InSAR software package.\n')
print('(c) 1999-2010 Delft University of Technology, the Netherlands.\n')

try:
inputFileName = sys.argv[1]
outputFileName = sys.argv[2]
except:
print '\nError : Unrecognized input or missing arguments\n\n'
print('\nError : Unrecognized input or missing arguments\n\n')
usage()
sys.exit(1)

Expand All @@ -49,7 +49,7 @@ def usage():
option = sys.argv[element];
if option == '-res':
resFile = str(sys.argv[element+1])
# print resFile
# print(resFile)
del sys.argv[element+1]
del sys.argv[element]
break
Expand All @@ -66,7 +66,7 @@ def usage():
outputWinFirstPix = int(sys.argv[5]) # Firstpix
outputWinLastPix = int(sys.argv[6]) # Lastpix
elif len(sys.argv) > 3 and len(sys.argv) < 7:
print '\nError : Unrecognized input or missing arguments\n\n'
print('\nError : Unrecognized input or missing arguments\n\n')
usage()
sys.exit(1)
else:
Expand Down Expand Up @@ -98,8 +98,8 @@ def usage():
print('INFO : Adjusting first line and last line ')
outputWinFirstLine = Nlines-in_LastLine+1
outputWinLastLine = Nlines-in_FirstLine+1
print Nlines, Npixls
print outputWinFirstLine,outputWinLastLine,outputWinFirstPix,outputWinLastPix
print(Nlines, Npixls)
print(outputWinFirstLine,outputWinLastLine,outputWinFirstPix,outputWinLastPix)

if pixl_order == 'Increasing':
print('INFO : Detected a imagery %s pixel time order' % pixl_order)
Expand All @@ -108,8 +108,8 @@ def usage():
print('INFO : Adjusting first pixel and last pixel ')
outputWinFirstPix = Npixls-in_LastPix+1
outputWinLastPix = Npixls-in_FirstPix+1
print Nlines, Npixls
print outputWinFirstLine,outputWinLastLine,outputWinFirstPix,outputWinLastPix
print(Nlines, Npixls)
print(outputWinFirstLine,outputWinLastLine,outputWinFirstPix,outputWinLastPix)


# GDAL Extract image matrix using gdal_translate
Expand All @@ -129,11 +129,11 @@ def usage():
# xoff yoff xsize = width ysize= height
# 1 --> 0 1 --> 0
cmd = cmd + (' -srcwin %s %s %s %s' % (outputWinFirstPix-1,outputWinFirstLine-1,outputWinLastPix-outputWinFirstPix+1,outputWinLastLine-outputWinFirstLine+1))
print cmd
print(cmd)

failure = os.system(cmd)
if failure:
print '%s: running %s failed' % (sys.argv[0],cmd)
print('%s: running %s failed' % (sys.argv[0],cmd))
sys.exit(1)
#else:
# os.rename(os.path.splitext(outputFileName)[0]+'.j00',outputFileName)
Expand Down Expand Up @@ -161,7 +161,7 @@ def usage():

failure = os.system(cmd)
if failure:
print '%s: running %s failed' % (sys.argv[0],cmd)
print('%s: running %s failed' % (sys.argv[0],cmd))
sys.exit(1)
else:
os.remove(outputFileName+'.noflip')
Expand All @@ -172,7 +172,7 @@ def usage():
# check whether the file exist!!!
if resFile is not None:

print resFile
print(resFile)

# load header
#headerFileStream = open(os.path.splitext(outputFileName)[0]+'.hdr','r')
Expand All @@ -181,7 +181,7 @@ def usage():
pair = line.split()
if len(pair) > 1:
vars()[pair[0]] = pair[2] # set IMAGE_LINES and LINE_SAMPLES
# print vars()[pair[0]]
# print(vars()[pair[0]])

# check whether the file exist
outStream = open(resFile,'a')
Expand Down
20 changes: 10 additions & 10 deletions bin/rs2_dump_header2doris.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@
codeRevision=1.2 # this code revision number

def usage():
print 'INFO : @(#)Doris InSAR software, $Revision: %s $, $Author: TUDelft $' % codeRevision
print
print 'Usage : python rs2_dump_header2doris.py rs2_XML_product > outputfile'
print ' where rs2_XML_product is the input filename'
print
print ' This software is part of Doris InSAR software package.\n'
print '(c) 1999-2010 Delft University of Technology, the Netherlands.\n'
print('INFO : @(#)Doris InSAR software, $Revision: %s $, $Author: TUDelft $' % codeRevision)
print()
print('Usage : python rs2_dump_header2doris.py rs2_XML_product > outputfile')
print(' where rs2_XML_product is the input filename')
print()
print(' This software is part of Doris InSAR software package.\n')
print('(c) 1999-2010 Delft University of Technology, the Netherlands.\n')

try:
inputFileName = sys.argv[1]
# outputFileName = sys.argv[2]
# outStream = open(outputFileName,'w')
except:
print '\nError : Unrecognized input or missing arguments\n\n'
print('\nError : Unrecognized input or missing arguments\n\n')
usage()
sys.exit(1)

Expand Down Expand Up @@ -145,7 +145,7 @@ def hms2sec(hmsString):

# get variables and parameters from xml
container = {}
for key, value in queryList.iteritems():
for key, value in queryList.items():
if key.startswith('list_'):
container[key] = [tag.text for tag in inTree.findall(nsmap_none(value, ns))]
else:
Expand Down Expand Up @@ -184,7 +184,7 @@ def mean(l):

# ---------------------------------------------------------------------------------------------------------

#print container['mission']
#print(container['mission'])
#exit()

dummyVar = 'DUMMY'
Expand Down
16 changes: 8 additions & 8 deletions bin/sec2hhmmss.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
import os,sys,time

def usage():
print '\nUsage: python sec2hhmmss.py time'
print ' where time is the time of day in seconds.'
print ' '
print ' Example '
print ' sec2hhmmss.py 59800.445398'
print ' 16:36:40.393'
print('\nUsage: python sec2hhmmss.py time')
print(' where time is the time of day in seconds.')
print(' ')
print(' Example ')
print(' sec2hhmmss.py 59800.445398')
print(' 16:36:40.393')

try:
timeOfDay = sys.argv[1]
except:
print 'Unrecognized input'
print('Unrecognized input')
usage()
sys.exit(1)

Expand All @@ -22,4 +22,4 @@ def usage():
timeOfDay = timeOfDay%3600
mm = timeOfDay//60
ss = timeOfDay%60
print "%d:%d:%f" %(hh,mm,ss)
print("%d:%d:%f" %(hh,mm,ss))
Loading