isce-framework / fringe

Fine Resolution InSAR With Generalized Eigenvectors (FRInGE)
Apache License 2.0
80 stars 42 forks source link

Fringe/Snaphu output for Mintpy #46

Closed stoormgeo closed 3 years ago

stoormgeo commented 3 years ago

Hi Has anyone tried using the non built-in snaphu for imports into mintpy? I processed the interferograms with the latest version of snaphu (2.0.4) but got an corrupted images. Used snaphu (tested with/without tile mode) + make xml and vrt with custom script from isce2 pkgs. The images processed with build-in snaphu from isce2 packages looks correct. Playing with different snaphu options (data formats, uwrapping modes etc) with no effect.

snaphu -v -S -f merged/fringe/PS_DS/snaphu.conf 20200505_20200809.int 3419 -c merged/fringe/PS_DS/tcorr_ds_ps.bin -o 20200505_20200809.unw --tile 10 5 200 200 --nproc 20

Corrupted Correct

hfattahi commented 3 years ago

Could you check the size of the unwrapped interferogram from two snaphu runs? Are they the same size?

stoormgeo commented 3 years ago

Could you check the size of the unwrapped interferogram from two snaphu runs? Are they the same size?

Checked. The same size.

hfattahi commented 3 years ago

Could you check the size of the unwrapped interferogram from two snaphu runs? Are they the same size?

Checked. The same size.

May I ask how many bytes are they?

stoormgeo commented 3 years ago

Could you check the size of the unwrapped interferogram from two snaphu runs? Are they the same size?

Checked. The same size.

May I ask how many bytes are they?

Snaphu output tiles mode [insar@osllnx07 unw]$ stat 20200505_20200809.unw File: ‘20200505_20200809.unw’ Size: 252431608 Blocks: 493032 IO Block: 4096 regular file [insar@osllnx07 unw]$ stat 20200505_20200809.unw.conncomp File: ‘20200505_20200809.unw.conncomp’ Size: 31553951 Blocks: 61632 IO Block: 4096 regular file

Built-in snaphu [insar@osllnx07 old]$ stat 20200505_20200809.unw File: ‘20200505_20200809.unw’ Size: 252431608 Blocks: 493032 IO Block: 4096 regular file [insar@osllnx07 old]$ stat 20200505_20200809.unw.conncomp File: ‘20200505_20200809.unw.conncomp’ Size: 31553951 Blocks: 61632 IO Block: 4096 regular file

stoormgeo commented 3 years ago

@hfattahi, As Scott wrote in https://github.com/isce-framework/fringe/issues/21#issuecomment-883757903, this could be a wrong width issue. Is it an issue in my script for make xml and vrt files in this case? However, I successfully checked it on data from the built-in snaphu also. My script code:

import os import argparse from osgeo import gdal import isce import isceobj

def cmdLineParser(): ''' Command line parser. '''

parser = argparse.ArgumentParser(description = 'Make metafiles for external unwrapped data',
            formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-i', '--unwrap_file', type=str, dest='unwrapFile',
        required=True, help='input unwrapped file')
parser.add_argument('-m', '--metadata file', type=str, dest='interferogramFile',
        required=True, help='Input interferogram file for existing metadata')

return parser.parse_args()

def write_xml(fileName,width,length,bands,dataType,scheme):

img = isceobj.createImage()
img.setFilename(fileName)
img.setWidth(width)
img.setLength(length)
img.setAccessMode('READ')
img.bands = bands
img.dataType = dataType
img.scheme = scheme
img.renderHdr()
img.renderVRT()

return None

def getSize(data):

ds = gdal.Open(data, gdal.GA_ReadOnly)
length = ds.RasterYSize
width = ds.RasterXSize
ds = None
return length, width

if name == 'main': ''' Main driver. '''

*****

inps = cmdLineParser()
length, width = getSize(inps.interferogramFile)
print("length, width: ", length , " ", width)

write_xml(inps.unwrapFile, width, length, 2 , "FLOAT", "BIL")                                                                                                                                                                                           
# uncomment if you need to generate xml and vrt for conncomp
# write_xml(inps.unwrapFile+'.conncomp', width, length, 1, "BYTE", "BIP")
hfattahi commented 3 years ago

Could you check the size of the unwrapped interferogram from two snaphu runs? Are they the same size?

Checked. The same size.

May I ask how many bytes are they?

Snaphu output tiles mode [insar@osllnx07 unw]$ stat 20200505_20200809.unw File: ‘20200505_20200809.unw’ Size: 252431608 Blocks: 493032 IO Block: 4096 regular file [insar@osllnx07 unw]$ stat 20200505_20200809.unw.conncomp File: ‘20200505_20200809.unw.conncomp’ Size: 31553951 Blocks: 61632 IO Block: 4096 regular file

Built-in snaphu [insar@osllnx07 old]$ stat 20200505_20200809.unw File: ‘20200505_20200809.unw’ Size: 252431608 Blocks: 493032 IO Block: 4096 regular file [insar@osllnx07 old]$ stat 20200505_20200809.unw.conncomp File: ‘20200505_20200809.unw.conncomp’ Size: 31553951 Blocks: 61632 IO Block: 4096 regular file

Thanks for checking the size. Obviously they are identical.

hfattahi commented 3 years ago

@hfattahi, As Scott wrote in #21 (comment), this could be a wrong width issue. Is it an issue in my script for make xml and vrt files in this case? However, I successfully checked it on data from the built-in snaphu also. My script code:

import os import argparse from osgeo import gdal import isce import isceobj

def cmdLineParser(): ''' Command line parser. '''

parser = argparse.ArgumentParser(description = 'Make metafiles for external unwrapped data',
            formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-i', '--unwrap_file', type=str, dest='unwrapFile',
        required=True, help='input unwrapped file')
parser.add_argument('-m', '--metadata file', type=str, dest='interferogramFile',
        required=True, help='Input interferogram file for existing metadata')

return parser.parse_args()

def write_xml(fileName,width,length,bands,dataType,scheme):

img = isceobj.createImage()
img.setFilename(fileName)
img.setWidth(width)
img.setLength(length)
img.setAccessMode('READ')
img.bands = bands
img.dataType = dataType
img.scheme = scheme
img.renderHdr()
img.renderVRT()

return None

def getSize(data):

ds = gdal.Open(data, gdal.GA_ReadOnly)
length = ds.RasterYSize
width = ds.RasterXSize
ds = None
return length, width

if name == 'main': ''' Main driver. '''

*****

inps = cmdLineParser() length, width = getSize(inps.interferogramFile) print("length, width: ", length , " ", width)

write_xml(inps.unwrapFile, width, length, 2 , "FLOAT", "BIL")                                                                                                                                                                                           
# uncomment if you need to generate xml and vrt for conncomp
# write_xml(inps.unwrapFile+'.conncomp', width, length, 1, "BYTE", "BIP")

Your script looks fine to me. Have you checked what is written differently to your "20200505_20200809.unw.xml" between the two runs?

stoormgeo commented 3 years ago

@hfattahi, As Scott wrote in #21 (comment), this could be a wrong width issue. Is it an issue in my script for make xml and vrt files in this case? However, I successfully checked it on data from the built-in snaphu also. My script code: import os import argparse from osgeo import gdal import isce import isceobj def cmdLineParser(): ''' Command line parser. '''

parser = argparse.ArgumentParser(description = 'Make metafiles for external unwrapped data',
            formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-i', '--unwrap_file', type=str, dest='unwrapFile',
        required=True, help='input unwrapped file')
parser.add_argument('-m', '--metadata file', type=str, dest='interferogramFile',
        required=True, help='Input interferogram file for existing metadata')

return parser.parse_args()

def write_xml(fileName,width,length,bands,dataType,scheme):

img = isceobj.createImage()
img.setFilename(fileName)
img.setWidth(width)
img.setLength(length)
img.setAccessMode('READ')
img.bands = bands
img.dataType = dataType
img.scheme = scheme
img.renderHdr()
img.renderVRT()

return None

def getSize(data):

ds = gdal.Open(data, gdal.GA_ReadOnly)
length = ds.RasterYSize
width = ds.RasterXSize
ds = None
return length, width

if name == 'main': ''' Main driver. '''

*****

inps = cmdLineParser() length, width = getSize(inps.interferogramFile) print("length, width: ", length , " ", width)

write_xml(inps.unwrapFile, width, length, 2 , "FLOAT", "BIL")                                                                                                                                                                                           
# uncomment if you need to generate xml and vrt for conncomp
# write_xml(inps.unwrapFile+'.conncomp', width, length, 1, "BYTE", "BIP")

Your script looks fine to me. Have you checked what is written differently to your "20200505_20200809.unw.xml" between the two runs?

Сhecked, but everything is the same. [insar@osllnx07 old]$ diff -s /data/insar/Proc/merged/fringe/PS_DS/old/20200505_20200809.unw.vrt /data/insar/Proc/merged/fringe/PS_DS/unw/20200505_20200809.unw.vrt Files /data/insar/Proc/merged/fringe/PS_DS/old/20200505_20200809.unw.vrt and /data/insar/Proc/merged/fringe/PS_DS/unw/20200505_20200809.unw.vrt are identical

Here only path differ [insar@osllnx07 unw]$ diff -s /data/insar/Proc/merged/fringe/PS_DS/old/20200505_20200809.unw.xml /data/insar/Proc/merged/fringe/PS_DS/unw/20200505_20200809.unw.xml 80c80 /data/insar/Proc/merged/fringe/PS_DS/old/20200505_20200809.unw

/data/insar/Proc/merged/fringe/PS_DS/unw/20200505_20200809.unw

stoormgeo commented 3 years ago

Solved. Need to specify width instead of length in snaphu string in my case. @hfattahi Do i need include script to the master branch?