Issue with extractors in a loop

Hi there,

I merged some scripts that I generated by saving catalyst states.
The idea is to create multiple slices of 3D data at different intervals for each x,y, and z axis.
Even though I feel that the script is too slow due to bad optimization on my part, it is working mostly as I intended.

However, I’m having an issue where the extractor is generating additional 10 images named: RenderView3_00000x.png (with x: 0 to 9). I imagine this is related to the creation of the last extractor “pNG3 = CreateExtractor(‘PNG’, renderView3, registrationName=‘pNG3’)” and the SaveExtractsUsingCatalystOptions(options) command.

I tried just moving all the pNG3 commands to the if loop, it fixed the additional images issue, but that more than doubled the total runtime of the script (from 80s to 180s).

Is there any way I can fix this without slowing too much the script? Tips on better optimizing the script overall are also very appreciated.

Thanks!

Using ParaView 5.11.1 on Windows 10.

1.py (14.4 KB)

Hi,

I think it is due to a combination of things:

  1. SaveExtracts loop over the AnimationScene time list to trigger the extractors
  2. Extractor are always enabled by default
  3. AnimationScene has 10 times by default

I think here you should configure the Extractor to run only once. You can set StartTimeStep and EndTimeStep

1 Like

Hi Nicolas,

Thanks for the response!

I’m fairly new to ParaView. So I’ve been trying to understand the things you mentioned and how could I change the script to include that, but so far I’m still stuck trying to understand how the Animator, Extractor, and the Start/EndTimeSteps interact. I tried changing these values but the result is still the same, regardless of the value I define for those parameters.

That made me think that the issue is with the loop over the extractor in my script. Which runs many times instead of just one, like you suggested. So I’ve been trying, without success, to modify the script to generate the same output without looping over the extractor. Is there a way of saving an animation sequence as a script/catalyst state? If not, could you please give me more details on how can I achieve this?

Cheers

I think about something like that

pNG1.Trigger.UseStartTimeStep = 1
pNG1.Trigger.StartTimeStep = 0
pNG1.Trigger.UseEndTimeStep = 1
pNG1.Trigger.EndTimeStep = 0

(for each extractor)

I changed those parameters for the 3 pNG triggers, but apparently, that doesn’t affect my output. I’m having the same runtime (or very similar ~80s) and the 10 default image files are still extracted.

Ok. Actually this was not the right approach. You better should ask for saving extracts only once instead of looping over the 10 artificial timesteps of the scene.

So, instead of your CatalystOptions version, try

SaveExtracts(ExtractsOutputDirectory='extracts',
    FrameRate=1,
    FrameStride=1,
    FrameWindow=[0, 0])

I modified the loop to have SaveExtracts instead of the CatalystOptions, while also keeping the previous TimeStep parameters you suggested. The loop looks like this:

    # Loop for generating slices and extracting PNGs
    for i in range(-250, 301, 25):
    
        if (i >= -250 & i <= 250):
            # Update slice position for X axis
            sliceX.SliceOffsetValues = [float(i)]
            
            # Update PNG filename for X axis
            pNG1.Writer.FileName = 'Heatmap_X_{position}.png'.format(position=i)
            
            # Update slice position for Y axis
            sliceY.SliceOffsetValues = [float(i)]
            
            # Update PNG filename for Y axis
            pNG2.Writer.FileName = 'Heatmap_Y_{position}.png'.format(position=i)
        
        if (i >= 0 & i <= 300):

            # Update slice position for Z axis
            sliceZ.SliceOffsetValues = [float(i)]
        
            # Update PNG filename for Z axis
            pNG3.Writer.FileName = 'Heatmap_Z_{position}.png'.format(position=i)
        
        # Save extracts
        SaveExtracts(ExtractsOutputDirectory='extracts',
            FrameRate=1,
            FrameStride=1,
            FrameWindow=[0, 0])

I tried it a few times. However, I don’t see any noticeable difference and it also prints the 10 extra images. Do you think it might be worth modifying the whole thing and trying making a new loop over the SliceOffsetValues and having one pNG.writter for each slice offset and calling the SaveExtracts only once?

I believe I fixed the issue. Maybe I overcomplicated stuff by trying to merge everything into one script. Instead of having all in one script, I split each axis into one script, keeping the same structure and using the loop with the SaveExtracts. I created a simple batch script to execute the 3 scripts and now the run time is about 15s total and I don’t get any additional unrequested files.

Each loop looks similar to this:

    for i in range(-250, 251, 25):
    
        # Update slice position for X axis
        sliceX.SliceOffsetValues = [float(i)]
        
        # Update PNG filename for X axis
        pNG1.Writer.FileName = 'Heatmap_X_{position}.png'.format(position=i)
        
        # Save extracts
        SaveExtracts(ExtractsOutputDirectory='extracts',
            FrameRate=1,
            FrameStride=1,
            FrameWindow=[0, 0])

I’m not exactly sure why having the 3 renderViews and looping over all 3 at once increased the run time that much. Maybe this could be something worth investigating. In any case, thanks @nicolas.vuaille for your help!