"Loop / Attributes not found"

bherwig
bherwig New Altair Community Member
edited November 5 in Community Q&A
Hello everybody!

I try to access attributes via the Loop Attributes operator.
My dataset consists of only two attributes, but many examples.

Within the loop I want to do a FFT (from the Series extension) on every series I built from the examples.
So in the Data to Series operator (located within the loop), I access every attribute by the macro's name (here: %{loop_attributes}). In the metadata, "att1" and "att2" as attribute-names are visible. But the Data to Series operator complains about not being able to find "att2".

Can someone please have a look at my process (see below) and hint me to a solution?

Thank you a lot for any advice!

Yours
Benjamin
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.2.006">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="5.2.006" expanded="true" name="Process">
    <process expanded="true" height="612" width="1272">
      <operator activated="true" class="retrieve" compatibility="5.2.006" expanded="true" height="60" name="Retrieve (2)" width="90" x="45" y="30">
        <parameter key="repository_entry" value="../daten/zwei_reihen_v"/>
      </operator>
      <operator activated="true" class="loop_attributes" compatibility="5.2.006" expanded="true" height="60" name="Loop Attributes" width="90" x="447" y="120">
        <parameter key="attribute_filter_type" value="subset"/>
        <parameter key="attributes" value="att1|att2|"/>
        <process expanded="true" height="630" width="1284">
          <operator activated="true" class="series:data_to_series" compatibility="5.1.002" expanded="true" height="60" name="Data To Series" width="90" x="179" y="30">
            <parameter key="series_attribute" value="%{loop_attribute}"/>
          </operator>
          <operator activated="true" class="series:fast_fourier_transformation" compatibility="5.1.002" expanded="true" height="60" name="Fast Fourier Transformation" width="90" x="447" y="30"/>
          <operator activated="true" class="series:series_to_data" compatibility="5.1.002" expanded="true" height="60" name="Series To Data" width="90" x="715" y="30"/>
          <connect from_port="example set" to_op="Data To Series" to_port="example set"/>
          <connect from_op="Data To Series" from_port="series" to_op="Fast Fourier Transformation" to_port="series"/>
          <connect from_op="Fast Fourier Transformation" from_port="series" to_op="Series To Data" to_port="series"/>
          <connect from_op="Series To Data" from_port="example set" to_port="example set"/>
          <portSpacing port="source_example set" spacing="0"/>
          <portSpacing port="sink_example set" spacing="0"/>
        </process>
      </operator>
      <connect from_op="Retrieve (2)" from_port="output" to_op="Loop Attributes" to_port="example set"/>
      <connect from_op="Loop Attributes" from_port="example set" to_port="result 1"/>
      <portSpacing port="source_input 1" spacing="0"/>
      <portSpacing port="sink_result 1" spacing="0"/>
      <portSpacing port="sink_result 2" spacing="0"/>
    </process>
  </operator>
</process>

Answers

  • Hello

    The output from one iteration of the series to data operator is used as the input to the next iteration of the data to series operator. This does not contain the attribute att2 so the process fails.

    Disconnect the link from the output to the exit point of the loop operator.

    Of course the problem is then to save the results. One approach is to store them in memory or the repository inside the loop and recall outside.

    Hope that helps

    regards

    Andrew
  • MariusHelf
    MariusHelf New Altair Community Member
    Andrew is right about the behaviour of the loop. To store the result you can do something as in the process below. The idea is to store the result in memory with the Remember operator, and join the new result with the Join operator. In the first operator there is nothing stored yet in memory, so the Recall operator fails. In that case the exception is caught by Handle Exception, which then just passes the input example set to its output.
    For the join to work, we need an ID, which is generated by Generate ID.

    After the execution of Loop Attributes, the result is Recalled from memory and pased to the process output.

    Note that  I replaced your retrieve operator with generate data since I obviously can't access any data from your repository :)

    Best, Marius

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.2.006">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.2.006" expanded="true" name="Process">
        <process expanded="true" height="607" width="681">
          <operator activated="false" class="retrieve" compatibility="5.2.006" expanded="true" height="60" name="Retrieve (2)" width="90" x="45" y="255">
            <parameter key="repository_entry" value="../daten/zwei_reihen_v"/>
          </operator>
          <operator activated="true" class="generate_data" compatibility="5.2.006" expanded="true" height="60" name="Generate Data" width="90" x="112" y="30">
            <parameter key="number_of_attributes" value="2"/>
          </operator>
          <operator activated="true" class="loop_attributes" compatibility="5.2.006" expanded="true" height="60" name="Loop Attributes" width="90" x="246" y="30">
            <parameter key="attribute_filter_type" value="subset"/>
            <parameter key="attributes" value="att1|att2|"/>
            <process expanded="true" height="607" width="882">
              <operator activated="true" class="series:data_to_series" compatibility="5.1.002" expanded="true" height="60" name="Data To Series" width="90" x="45" y="30">
                <parameter key="series_attribute" value="%{loop_attribute}"/>
              </operator>
              <operator activated="true" class="series:fast_fourier_transformation" compatibility="5.1.002" expanded="true" height="60" name="Fast Fourier Transformation" width="90" x="179" y="30"/>
              <operator activated="true" class="series:series_to_data" compatibility="5.1.002" expanded="true" height="60" name="Series To Data" width="90" x="313" y="30"/>
              <operator activated="true" class="generate_id" compatibility="5.2.006" expanded="true" height="76" name="Generate ID" width="90" x="45" y="165"/>
              <operator activated="true" class="handle_exception" compatibility="5.2.006" expanded="true" height="76" name="Handle Exception" width="90" x="179" y="165">
                <process expanded="true" height="625" width="421">
                  <operator activated="true" class="recall" compatibility="5.2.006" expanded="true" height="60" name="Recall" width="90" x="45" y="120">
                    <parameter key="name" value="result"/>
                    <parameter key="io_object" value="ExampleSet"/>
                  </operator>
                  <operator activated="true" class="join" compatibility="5.2.006" expanded="true" height="76" name="Join" width="90" x="179" y="30">
                    <list key="key_attributes"/>
                  </operator>
                  <connect from_port="in 1" to_op="Join" to_port="left"/>
                  <connect from_op="Recall" from_port="result" to_op="Join" to_port="right"/>
                  <connect from_op="Join" from_port="join" to_port="out 1"/>
                  <portSpacing port="source_in 1" spacing="0"/>
                  <portSpacing port="source_in 2" spacing="0"/>
                  <portSpacing port="sink_out 1" spacing="0"/>
                  <portSpacing port="sink_out 2" spacing="0"/>
                </process>
                <process expanded="true" height="625" width="421">
                  <connect from_port="in 1" to_port="out 1"/>
                  <portSpacing port="source_in 1" spacing="0"/>
                  <portSpacing port="source_in 2" spacing="0"/>
                  <portSpacing port="sink_out 1" spacing="0"/>
                  <portSpacing port="sink_out 2" spacing="0"/>
                </process>
              </operator>
              <operator activated="true" class="remember" compatibility="5.2.006" expanded="true" height="60" name="Remember" width="90" x="313" y="165">
                <parameter key="name" value="result"/>
                <parameter key="io_object" value="ExampleSet"/>
              </operator>
              <connect from_port="example set" to_op="Data To Series" to_port="example set"/>
              <connect from_op="Data To Series" from_port="series" to_op="Fast Fourier Transformation" to_port="series"/>
              <connect from_op="Fast Fourier Transformation" from_port="series" to_op="Series To Data" to_port="series"/>
              <connect from_op="Series To Data" from_port="example set" to_op="Generate ID" to_port="example set input"/>
              <connect from_op="Generate ID" from_port="example set output" to_op="Handle Exception" to_port="in 1"/>
              <connect from_op="Handle Exception" from_port="out 1" to_op="Remember" to_port="store"/>
              <portSpacing port="source_example set" spacing="0"/>
              <portSpacing port="sink_example set" spacing="0"/>
            </process>
          </operator>
          <operator activated="true" class="recall" compatibility="5.2.006" expanded="true" height="60" name="Recall (2)" width="90" x="581" y="30">
            <parameter key="name" value="result"/>
            <parameter key="io_object" value="ExampleSet"/>
          </operator>
          <connect from_op="Generate Data" from_port="output" to_op="Loop Attributes" to_port="example set"/>
          <connect from_op="Recall (2)" from_port="result" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
        </process>
      </operator>
    </process>