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

doppler_vs_pixel format error in reference.xml #881

Open
SakuraLaurel opened this issue Sep 12, 2024 · 8 comments
Open

doppler_vs_pixel format error in reference.xml #881

SakuraLaurel opened this issue Sep 12, 2024 · 8 comments

Comments

@SakuraLaurel
Copy link

SakuraLaurel commented Sep 12, 2024

Hi, I installed ISCE2 several days ago by building it using CMake on Ubuntu 22.04. I encountered a crash when processing TerraSAR-X data using stripmapApp.py in the runPreprocessor step

2024-09-12 14:50:59,839 - isce.isceobj.scene.frame - ERROR - Error. The attribute corresponding to the key "doppler_vs_pixel" is not present in the object "<class 'isceobj.Scene.Frame.Frame'>".
Possible causes are the definition in the xml file of such attribute that is no longer defined 
in the object "<class 'isceobj.Scene.Frame.Frame'>" or a spelling error

I inspect the reference_slc.xml and the secondary_slc.xml, finding that the doppler_vs_pixel element is wrong:

<property name="doppler_vs_pixel">
    <value>[np.float64(-18.427734185277217), np.float64(-0.00010611554340968327), np.float64(3.057573271351503e-11)]</value>
    <doc>Doppler polynomial coefficients vs pixel number</doc>
</property>

after modifying it into

<property name="doppler_vs_pixel">
    <value>[-18.427734185277217, -0.00010611554340968327, 3.057573271351503e-11]</value>
    <doc>Doppler polynomial coefficients vs pixel number</doc>
</property>

I run the later steps successfully. The temporal method is to edit the code

etObj = ET.ElementTree(root)
edit_doppler_vs_pixel = etObj.getroot().find("component[@name='instance']/property[@name='doppler_vs_pixel']")
if edit_doppler_vs_pixel is not None:
    edit_doppler_vs_pixel[0].text = edit_doppler_vs_pixel[0].text.replace("np.float64(", "").replace(")", "")
fp = open(outfile,'wb')
etObj.write(fp)
fp.close()

in components/iscesys/Dumpers/XmlDumper.py. What is the reason for this problem, and is there a better method?

@shaodongli
Copy link

Hi @SakuraLaurel ,

following your prompts, I found that the problem might arise from

    def addProperty(self,parent,name,value,propMisc):
        child = ET.SubElement(parent,"property",name=name)
        ET.SubElement(child, 'value').text = str(value)
        if not propMisc == None:
            for pkey in self._propertyKeys:
                if pkey in propMisc:
                    ET.SubElement(child, pkey).text = str(propMisc[pkey])

in XmlDumper.py

After some trial and error, I found str([np.float64()] behaves differently with different versions of numpy.

>>> import numpy as np
>>> np.__version__
'1.26.4'
>>> str([np.float64(5.0)])
'[5.0]'

and

>>> import numpy as np
>>> np.__version__
'2.0.1'
>>> str([np.float64(5.0)])
'[np.float64(5.0)]'

Downgrading numpy to numpy=1.26.4 solved my problem.

FYI, I am using ISCE2 on M1 Mac Sequoia 15.2. I installed ISCE2 following a slightly modified version of the installation guide by lijun99.

@Hassan2211345
Copy link

Hi guys, I tried both ways, downgrading numpy and also trying modified code but still get the error that @SakuraLaurel got.
Any updates on this issue ???

@SakuraLaurel
Copy link
Author

Hi guys, I tried both ways, downgrading numpy and also trying modified code but still get the error that @SakuraLaurel got. Any updates on this issue ???

After that I never tried this function again, but I think the cause of this problem is clear thanks to @shaodongli .If you still get the error, I think it is because that the XmlDumper.py or the numpy version you modified was wrong. There may be multiple environments in your computer, so be sure you have found the correct one. You may add a line of code like

import numpy as np
print(np.__version__)

in the addProperty function, to test it.

@Hassan2211345
Copy link

Thanks for your response. I checked my Numpy version which is '1.26.4'.
The issue persists.
I used ISCE for quite some time on other device and never had this issue
Reecently, i installed isce on my new laptop where i face this issue.
The only difference is that I am using python 3.11 and on my older device, I used latest version of python

@SakuraLaurel
Copy link
Author

Thanks for your response. I checked my Numpy version which is '1.26.4'. The issue persists. I used ISCE for quite some time on other device and never had this issue Reecently, i installed isce on my new laptop where i face this issue. The only difference is that I am using python 3.11 and on my older device, I used latest version of python

The logic is that python will execute the code in components/iscesys/Dumpers/XmlDumper.py.

etObj = ET.ElementTree(root)
fp = open(outfile,'wb')
etObj.write(fp)
fp.close()

So If you have modified the code successfully, I can't think of another reason. Try to print the content of etObj here, for example, print(etObj.getroot().find("component[@name='instance']/property[@name='doppler_vs_pixel']")[0].text), to find out what happened.

@shaodongli
Copy link

shaodongli commented Feb 11, 2025 via email

@Hassan2211345
Copy link

Hassan2211345 commented Feb 11, 2025

Hi, thank you for the message @SakuraLaurel and @shaodongli

The problem persists. I am using Linux mint by the way, and before also, I always used linux. The code is modified and i am pasting that part of my XmlDumper for your reference.

`

def addProperty(self, parent, name, value, propMisc):
print(f"Using NumPy version: {np.version}")
child = ET.SubElement(parent, "property", name=name)
ET.SubElement(child, 'value').text = str(value)
if not propMisc ==None:
for pkey in self._propertyKeys:
if pkey in propMisc:
ET.SubElement(child, pkey).text = str(propMisc[pkey])
def addComponent(self,parent,dictIn,factDict = None,miscDict = None):
keys = sorted(dictIn.keys())
for key in keys:
val = dictIn[key]
if (not factDict is None) and key in factDict:#check in the key is in the factory dictionary. that means that is a component
comp = factDict[key]
child = ET.SubElement(parent,"component",name=key)
for ckey in self._componentKeys:
if ckey in comp:
ET.SubElement(child,ckey).text = str(comp[ckey])
valMisc = None
if (not miscDict == None) and key in miscDict:
valMisc = miscDict[key]
self.addComponent(child,val,comp,valMisc)

        else:#is a property
            propMisc = None
            if not miscDict == None:
                if key in miscDict:
                    propMisc = miscDict[key]
            self.addProperty(parent,key,val,propMisc)
            
def indent(self,elem, depth = None,last = None):
    if depth == None:
        depth = [0]
    if last == None:
        last = False
    tab = ' '*4
    if(len(elem)):
        depth[0] += 1
        elem.text = '\n' + (depth[0])*tab
        lenEl = len(elem)
        lastCp = False
        for i in range(lenEl):
            if(i == lenEl - 1):
                lastCp = True
            self.indent(elem[i],depth,lastCp)
        if(not last):
            elem.tail = '\n' + (depth[0])*tab
        else:
            depth[0] -= 1
            elem.tail = '\n' + (depth[0])*tab
    else:
        if(not last):
            elem.tail = '\n' + (depth[0])*tab
        else:
            depth[0] -= 1
            elem.tail = '\n' + (depth[0])*tab

def dump(self,outfile,propDict,factDict = None, miscDict = None,firstTag = None):
    if firstTag == None:
        firstTag = "input"
    root = ET.Element(firstTag)
    self.addComponent(root,propDict,factDict,miscDict)
    self.indent(root)
    etObj = ET.ElementTree(root)
    fp = open(outfile,'wb')
    etObj.write(fp)
    fp.close()

`

@Hassan2211345
Copy link

Hassan2211345 commented Feb 11, 2025

@SakuraLaurel

Image

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants