Custom Filenamesuffix (from list) in SaveData using pvbatch

I have a time series dataset, I want to save slice data using SaveData method. I was able to do that using below code in pvbatch:

SaveData(File_to_Save,
proxy=slice1,
WriteTimeSteps=1,
Filenamesuffix=‘_%d’,
CellDataArrays=[‘IDREG’, ‘AREA_X-’, ‘AREA_X+’, ‘AREA_Y-’, ‘AREA_Y+’, ‘AREA_Z-’, ‘AREA_Z+’, ‘DENSITY’, ‘PRESSURE’, ‘TEMPERATURE’, ‘TOTAL_PRESSURE’, ‘VOLUME’, ‘TKE’, ‘YPLUS’, ‘XCEN’, ‘VELOCITY’],
Precision=8,
UseScientificNotation=1,
FieldAssociation=‘Cell Data’, # for cell data
AddMetaData=0)

This works fine, However data file is saved as slice1_0.txt , slice1_1.txt … . I want to add time series name as suffix (like slice1_<time_step>.txt , slice1_<time_step>.txt …) , to do so I have created a a list using bleow code:

time_step = sCR_Data.TimestepValues
time_step = list(time_step)

Now I have a list of time series which i want to use as suffix of my filename. What is the best way ?

So far I have tried using typical python tricks %s and {}.format(time_step). None of them are working.

Do you mean time value ? This is not supported, however you could store the time values within your data.

Yes, I want time step value as my filename suffix

not supported afaik.

Thanks @mwestphal.

Do you think it will be a good candidate for future development ?

1 Like

Not as trivial as it may seem, but not a bad idea overall. You may want to open an issue on gitlab
https://gitlab.kitware.com/paraview/paraview/-/issues

Hi Mathieu:
I realized one thing when I execute python script using pvbatch from terminal to add time (as column) to my save data Time is not added to the file. This is the code I am using :

SaveData(File_to_Save,
proxy=slice1,
CellDataArrays=[‘IDREG’, ‘AREA_X-’, ‘AREA_X+’, ‘AREA_Y-’, ‘AREA_Y+’, ‘AREA_Z-’, ‘AREA_Z+’, ‘DENSITY’, ‘PRESSURE’, ‘TEMPERATURE’, ‘TOTAL_PRESSURE’, ‘VOLUME’, ‘TKE’, ‘YPLUS’, ‘XCEN’, ‘VELOCITY’],
Precision=8,
UseScientificNotation=1,
FieldAssociation=‘Cell Data’, # for cell data
AddMetaData=0,
AddTime=1)

However, If I execute this code from Paraview Python Shell, then it adds Time Column at the beginning. I have tried this both in Paraview 5.8.1 and Paraview 5.9.0.

Is this a bug ? or meant to be like this?

Looks like an oversight, you may want to open an issue with steps to reproduce.

Thanks @mwestphal.

I have opened an issue.

https://gitlab.kitware.com/paraview/paraview/-/issues/20331

I came here looking for a way to add timesteps as filename suffixes as well. Your idea to store the time values within my data would help for now. How can i achieve this?

I have a contour filter and need the points over time with time data to calculate dimension of my contour over time and plot these. So far everything works (using python) except time data.

Any help is appreciated!

Juste create a .pvd file similar to this one:

medTime.pvd (675 Bytes)

Thanks for your answer. Sadly it doesn’t help yet.
I will have thousands of timesteps (cfd data, openfoam) and the files will already be loaded accordingly into paraview (using OpenFOAMReader). So I don’t have any vtk files.

I can use AnnotateTime filter to get the current time value. How can I add this information to spreadsheet of the contourfilter and save both?

You can use the python calculator for that. Juste add an array with the “time_value” expression.

Than you! I will try that.

Works perfect! Have a nice day!