UnboundLocalError: local variable 'flatten' referenced before assignment

Added by Helen Baldwin 10 months ago

Hi,

I recently posted about an AttributeError: 'NoneType' object has no attribute 'initRecursive' error when running stripmapApp for ALOS PALSAR SLCs (http://earthdef.caltech.edu/boards/4/topics/3136) Successfully resolved, thank you! Now during isce.insar.runResampleSlc it says that misreg/misreg does not exist and then throws the error UnboundLocalError: local variable 'flatten' referenced before assignment. Screenshot attached.

Any assistance would be appreciated.

I'm running ISCE in Colaboratory: https://github.com/MayerT1/FSH_data/blob/master/Exercise2_PreProcess_ISC_Kel.ipynb
ALOS PALSAR SLC IDs: ALPSRP091030890 & ALPSRP077610890

If there's any other information I can provide, please let me know. Best,
Helen


Replies (17)

RE: UnboundLocalError: local variable 'flatten' referenced before assignment - Added by Zhiliang Zhang 10 months ago

Hi
I have met the same problems with you, and I have modified the runResampleSlc.py in line 102 such as attachment, and this can solve problem but I don't know whether I can modify as this?

modified.png (12 kB)

RE: UnboundLocalError: local variable 'flatten' referenced before assignment - Added by Helen Baldwin 10 months ago

Thank you! I will try that. I'm not sure either if it will change anything else to modify that line. Thanks again!

Best,
Helen

RE: UnboundLocalError: local variable 'flatten' referenced before assignment - Added by Piyush Agram 10 months ago

Looks like flatten is not being set for the coarse resampling. You can add

flatten = True

to the code block

    if kind in ['coarse', 'refined']:
        azname = os.path.join(offsetsDir, self.insar.azimuthOffsetFilename)
        rgname = os.path.join(offsetsDir, self.insar.rangeOffsetFilename)

Uncomment the section as shown above will lead to double flattening if you turn on range rubber sheeting (cryo workflows)

Piyush

RE: UnboundLocalError: local variable 'flatten' referenced before assignment/Insar Object has no attribute doRubberSheeting - Added by Helen Baldwin 10 months ago

Thanks, Piyush! That resolved my issue.

I now have a new Attribute Error: Insar Object has no attribute "doRubbersheeting," please see my screenshot for the full output. I took a look at runDenseOffsets.py line 78, but I'm not sure where/how to add this attribute to the insar object.

Thanks!

Best,
Helen

RE: UnboundLocalError: local variable 'flatten' referenced before assignment - Added by Piyush Agram 10 months ago

That single flag has been broken into 2 separate ones - doRubbersheetingAzimuth and doRubbersheetingRange.
For the old behavior, set doRubbersheetingAzimuth. The new range flag is more relevant to cryosphere workflows over ice sheets and glaciers.
We will update the examples folder.

RE: Insar Object has no attribute doRubberSheeting - Added by Helen Baldwin 10 months ago

Hi Piyush,

Thank you so much for the updated example.

I've updated my xml, and keep getting stuck at the denseoffsets step with the same "insar object has no attribute dorRubbersheeting" error. I've tried various versions of the xml, but I think I must not be understanding something. I've uploaded what I think should be the corrected version of my stripmapApp xml based on the updated example here. I've read through the descriptions of the xml in the README and example folders, and I've tried watching parts of the UNAVCO videos that seemed applicable (https://www.unavco.org/education/professional-development/short-courses/course-materials/insar/2014-insar-isce-course-materials/2014-insar-isce-course-materials.html). I'll keep working on it, but if you have any feedback on how I might be off track that would be appreciated.

Best,
Helen

stripmapApp.xml Magnifier (2.1 kB)

RE: UnboundLocalError: local variable 'flatten' referenced before assignment - Added by Piyush Agram 10 months ago

All references to doRubberSheeting must be changed to doRubberSheetingAzimuth. We havent made a new release yet. We are still testing to make sure we catch all these instances.

RE: UnboundLocalError: local variable 'flatten' referenced before assignment - Added by Helen Baldwin 10 months ago

Thank you for getting back to me so quickly! Does this mean I should go in and change the doRubberSheeting to doRubberSheetingAzimuth within the the runDenseOffsets code? I will go ahead and try that. Alternatively, is that something that y'all are working on that I should wait for? Is there an estimated release for that version? Thanks again!

RE: UnboundLocalError: local variable 'flatten' referenced before assignment - Added by Helen Baldwin 10 months ago

And alternatively again, is there a pre-dorubbersheetingAzimuth version of ISCE that I could successfully use in the meantime? I may still have a copy of it installed in a VM from a few months ago, and will try to track that down.

RE: RE: Insar Object has no attribute doRubberSheeting/NameError: name 'ndimage' is not defined - Added by Helen Baldwin 10 months ago

Hi Piyush,

I changed two instances of doRubbersheeting to doRubbersheetingAzimuth, I'm happy to make a pull request but wanted to make sure that everything ran correctly first. I am now producing a new error "NameError: name 'ndimage' is not defined. I've attached a screenshot. Please advise! Thanks!

Best,
Helen

ndimageError.JPG (64.8 kB)

RE: UnboundLocalError: local variable 'flatten' referenced before assignment - Added by Piyush Agram 10 months ago

Any function that uses ndimage must include a "from scipy import ndimage" statement.
We are trying to eliminate import statements at top of scripts. Tracking the error messages and line numbers should help identify the functions that break.

RE: UnboundLocalError: local variable 'flatten' referenced before assignment - Added by Helen Baldwin 10 months ago

Roger that, thanks. Now working on the ValueError: Non-existent file: denseOffsets/filtAzimuth.off.resampled

RE: UnboundLocalError: local variable 'flatten' referenced before assignment - Added by Piyush Agram 10 months ago

Seems like more if/else mismatches. The last stable commit before rubbersheeting - ed8f32e8b810e665d0a7a4f809193f1ef78dde66
If you pull that commit and build, you should be fine. This uses the old "do rubbersheeting" flag.

RE: UnboundLocalError: local variable 'flatten' referenced before assignment - Added by Helen Baldwin 10 months ago

And now working on FileNotFoundError: No such file or directory 'interferogram/topophase.flat.xml'

Would it be correct that this file should actually be called 'full' (rather than 'flat') as opposed to "low" and "high" as found in runFilter.py? Trying that fix now

RE: UnboundLocalError: local variable 'flatten' referenced before assignment - Added by Piyush Agram 10 months ago

I would suspect a missing call to multiLook in another if/else branch in generateInterferogram()

RE: UnboundLocalError: local variable 'flatten' referenced before assignment - Added by Helen Baldwin 10 months ago

Okay, I'll look into that. Is this the same as generateIgram()?

(1-17/17)