question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

refid KeyError when adding SNAP "Collocate" node to workflow

See original GitHub issue

Hello, I get an error when trying to create an XML file with the SNAP “Collocate” operator. I haven’t encountered this before and the code should be right.

  • which operating system are you using?
    Windows 8
  • which environment is pyroSAR running in?
    Anaconda virtual environment
  • which version of pyroSAR are you using?
    Via conda
  • which function of pyroSAR did you call with which parameters?

# Code that I'm using

workflow = parse_recipe('blank')

read1 = parse_node('Read')
read1.parameters['file'] = dim
workflow.insert_node(read1)

read2 = parse_node('Read')
read2.parameters['file'] = clip_water_mask
read2.parameters['formatName'] = 'GeoTIFF'
workflow.insert_node(read2)

collocate = parse_node('Collocate')
collocate.parameters['masterProductName'] = os.path.basename(dim).rstrip('.dim')
collocate.parameters['renameMasterComponents'] = False
collocate.parameters['renameSlaveComponents'] = False

# This line below raises the error
workflow.insert_node(collocate, before=[read1.id, read2.id])
  • if applicable, which version of SNAP or GAMMA are you using in pyroSAR? SNAP
  • the full error message
  File "workflows.py", line 186, in add_water_mask
    workflow.insert_node(collocate, before=[read1.id, read2.id])
  File "C:\Users\Angelo\Miniconda3\envs\pyrosar\lib\site-packages\pyroSAR\snap\auxil.py", line 892, in insert_node
    self.__reset_successor_source(newnode.id)
  File "C:\Users\Angelo\Miniconda3\envs\pyrosar\lib\site-packages\pyroSAR\snap\auxil.py", line 788, in __reset_successor_source
    reset(id, self[id].source)
  File "C:\Users\Angelo\Miniconda3\envs\pyrosar\lib\site-packages\pyroSAR\snap\auxil.py", line 1124, in source
    sources.append(element.attrib['refid'])
KeyError: 'refid'

I’ve confirmed that this graph should work in SNAP. I tested it in the GUI. Here is an XML that I created using the graph tool in SNAP GUI.

Open XML from SNAP GUI
<graph id="Graph">
  <version>1.0</version>
  <node id="Read">
    <operator>Read</operator>
    <sources/>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <file>C:\Users\Angelo\Documents\PANJI\Projects\sar_disaster_assessment\flood\seasonality_120E_20Nv1_3_2020.tif</file>
    </parameters>
  </node>
  <node id="Collocate">
    <operator>Collocate</operator>
    <sources>
      <sourceProduct refid="Read"/>
      <sourceProduct.1 refid="Read(2)"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <sourceProductPaths/>
      <masterProductName>stack</masterProductName>
      <targetProductName>_collocated</targetProductName>
      <targetProductType>COLLOCATED</targetProductType>
      <renameMasterComponents>false</renameMasterComponents>
      <renameSlaveComponents>false</renameSlaveComponents>
      <masterComponentPattern>${ORIGINAL_NAME}_M</masterComponentPattern>
      <slaveComponentPattern>${ORIGINAL_NAME}</slaveComponentPattern>
      <resamplingType>NEAREST_NEIGHBOUR</resamplingType>
    </parameters>
  </node>
  <node id="Read(2)">
    <operator>Read</operator>
    <sources/>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <file>C:\Users\Angelo\Documents\PANJI\Projects\sar_disaster_assessment\flood\output\stack.dim</file>
    </parameters>
  </node>
  <node id="Write">
    <operator>Write</operator>
    <sources>
      <sourceProduct refid="Collocate"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
      <file>C:\Users\Angelo\Documents\PANJI\Projects\sar_disaster_assessment\flood\output\_collocated.dim</file>
      <formatName>BEAM-DIMAP</formatName>
    </parameters>
  </node>
  <applicationData id="Presentation">
    <Description/>
    <node id="Read">
            <displayPosition x="37.0" y="134.0"/>
    </node>
    <node id="Collocate">
      <displayPosition x="246.0" y="133.0"/>
    </node>
    <node id="Read(2)">
      <displayPosition x="27.0" y="186.0"/>
    </node>
    <node id="Write">
            <displayPosition x="453.0" y="136.0"/>
    </node>
  </applicationData>
</graph>

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
johntruckenbrodtcommented, Feb 3, 2022

This is all done in function pyroSAR.snap.auxil.parse_node. It executes gpt Collocate -h, reads the XML representation, and stores it in the .pyrosar/snap/nodes folder.

Setting the node’s source(s) is done here. Node.source has a get method (property) and a set method (@source.setter).

So the first question is whether parse_node has to be modified so that the XML representation is better or whether this looks alright and just the source.setter has to be adjusted to properly fill in the values of the list of node IDs you want to set as source.

1reaction
pbrotoisworocommented, Feb 2, 2022

Hmm, I found the relevant XML file in the .pyrosar folder. But I’m not sure where is the code that creates the data in .pyrosar\snap\nodes. Can you point me to where it is @johntruckenbrodt ? I think I can try and sort this out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · johntruckenbrodt/pyroSAR - GitHub
refid KeyError when adding SNAP "Collocate" node to workflow bug ... Add option to choose EGM for external DEM in pyroSAR.snap.util.geocode enhancement.
Read more >
the of and to a in for is on s that by this with i you it not
... porn similar garden schools million added reference companies listed baby ... enhance switzerland bound exact parameter node adapter processor formal ...
Read more >
gps tracking system: Topics by Science.gov
Additional tasks can be added to the software to support GPS science experiments or ... Active UHF RFID systems are often used for...
Read more >
Click here to download - Computer Science
... schools million added reference companies listed baby learning energy run ... exact bound parameter adapter processor node formal dimensions contribute ...
Read more >
topAbbWordPair.txt - GitHub
... 263250 sb stringbuffer 252955 i iterator 244864 n node 233029 db database ... wp watchpoint 63 a added 63 snaps snapshot 63...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found