Visualization of time series data using Paraview

Hello Everyone,

I am following the documentation available here to understand how time-varying scalar data has to be
read in Paraview.

For instance, I’ve imported the static data of a scalar value with the point coordinates in the following format
Untitled
For a time-varying data of the same scalar value, is it required to save the data corresponding to each time instant in a separate file as described in the above-mentioned documentation?

I would like to know if there are alternate ways of importing the time series data. For example, if I have to do the above for 100 time points, 100 files have to be loaded. If there are examples for
doing this using the Paraview library in Python, I would be happy to have a look.

In the end, I want to use SPH interpolator to interpolate the values of the scalar quantity at all the coordinates of a geometry (e.g. presented here) and animate over time.

Yes and no. There are some file formats that support putting data for many timesteps in a single file. The Exodus II and XDMF file formats both support this feature and are probably a good fit for the type of data you have. But both are far more complex than simple csv/text files and each requires its own support libraries.

There is no way to directly specify multiple time points in a single csv file, and I cannot think of any simple ASCII-based formats that would support this. So you will either have to write out 100 files or use a much more complex format.

For what it’s worth, 100 files does not sound like much. I’ve seen simulations write out 10’s of thousands of files or more. Not that I recommend writing out that many files, but in comparison, 100 files is pretty minor.

Thanks a lot for the details. I actually have all the data in single mat file generated form MATLAB.
different time instances are stored as columns.
I’m looking for Python/ MATLAB libraries to convert mat file to exodus II /xdmf .Would it be a good idea
to do this conversion?

MATLAB supports writing out workspace variables in these formats. Will netCDF be helpful?

netCDF could work. ParaView understands the netCDF CF convention, and you can use that to specify a time dimension.

If I remember correctly, to specify a dimension as a time dimension, you create a 1D variable with the same name as the dimension (e.g. if your time dimension is named time you create a 1D variable with dimension time that is also named time). The variable needs an attribute named units that is some sort of time unit. Some examples of time units that ParaView recognizes are seconds, minutes, hours, and anything in the form X since Y. (Alternately, you can specify an axis attribute with the value T.) The values in this time description variable should be the time value for each time step. They should be monotonically increasing.

ParaView requires the time dimension to be the first dimension on a variable.

1 Like

Hi @Kenneth_Moreland

I tried the following to write the workspace variable in NetCDF file,

header = [‘x’, ‘y’, ‘z’, ‘0.2s’, ‘0.4s’, ‘0.6s’, ‘0.8s’, ‘1.0s’]
time = [0.2 0.4 0.6 0.8 1.0];
mydata = rand(10,8) %first 3 columns (x,y,z) coordinates next 5 time series data at 0.2,0.4,0.6,0.8,1 seconds

% define mode
ncid = netcdf.create(‘myfile.nc’,‘CLOBBER’);
dimid = netcdf.defDim(ncid,‘my_dim’,length(time))
varid = netcdf.defVar(ncid,‘time’,‘NC_BYTE’,dimid)
netcdf.endDef(ncid)

% data mode
netcdf.putVar(ncid,varid,time)
netcdf.close(ncid)

% verify
ncid2 = netcdf.open(‘myfile.nc’,‘NC_NOWRITE’);
x = netcdf.getVar(ncid2,0);
whos x
netcdf.close(ncid2)

I have created a 1D variable time of dimension 1 x nt (nt=5) that’s monotonically increasing. I’m still trying to figure out
how to add the attribute units to time.

Could you please suggest how the coordinates (x,y,z) must be specified ? Should the dimesion be a 3 x np (np= no. of points in the grid) variable? And how the filed data should be specified? Should the dimension be np x nt variable?

It’s been a long time since I’ve done any real programming with netCDF, and never from Matlab, but I think you need to use the putAtt method.

netcdf.putAtt(ncid, varid, 'units', 'seconds')

Also, the name of the dimension has to match the name of the variable. So both the dimension and the variable need to be named time. (Currently you have the dimension named my_dim.)

Also, I think you need to use either NC_FLOAT or NC_DOUBLE instead of NC_BYTE for your call to defVar. The NC_BYTE type of variable can only hold integers, not fractions like 0.2.

Create three additional dimensions named (such as) x, y, and z. Make the variable that stores the actual data be 4 dimensional and, if I remember correctly, the order of the dimensions should be time, z, y, x. ParaView will recognize this as a 3 dimensional, axis-aligned grid that changes over time. You can specify the coordinates along each axis by creating corresponding x, y, and z variables for each dimension and putting the locations there.