Using user-defined variable in calculator/python calculator

Hi,

I’m trying to obtain a new array defined as absPres which can be defined as “p-hydroPres”. Here p is pressure (a scalar Point Data) and hydroPres is the p at y=max(y) over a line. I can’t figure out how to get hydroPres on a line and then absPres at each point using the calculator or Python calculator. Could anyone help me?

Here is an example:

Sounds like the solution is a Programmable Filter.

Think the Calculator as an operator that is repeated on each point. You do not have access to anything else than the current point attributes. So max(y) has no sense in this context, nor has p(y). So you have to write some python script.

2 Likes

Hi Nicolas,

Many thanks for your answer. I’m new to ParaView and have been trying to understand the Programmable Filter, but I still need help. Please let me explain what I have been trying.

As can be seen in Figure, I have data “p”. I need to get a value, so-called hydroPres, at maximum y (e.g, here is y=0.115 and z=0.058) and then calculate “p-hydroPres” (let’s call it absPres) as a new variable. Final thing that I want to do is visualize this new variable (absPres) in ParaView.

I obtained and exported absPres as a csv file by using a Python script but I couldn’t figure out how to use it in Programmable Filter.

Many thanks in advance for your time and consideration.

There is another method that does not use the Programmable filter.

In that way, the use of nearest neighbor extrapolation, using the Voroni kernel of the Point Interpolation filter, extends the value at ymax to the entire region.

The steps are as follows:

  1. Use the Plot Over Line filter to plot the data on a line parallel to the horizontal axis at ymax.

  2. Using the Voronoi Kernel of the Point Dataset Interpolator filter, the ymax data is extrapolated to the nearest neighbor over the region. Here, specify the following:

  1. Select both Slice1 and PointDataSetInterPolator1 on the Pipepline Browser while holding down the Ctrl key, and merge the data with the Append Attributes filter.

  2. Finally, the p - hydroPres could be calculated using the Calculator filter.

2 Likes

Hi Kyoshimi,

Apologies for the late reply; I’ve been busy building ParaView on my personal computer.

Thank you for your answer. I think this is the solution in my case. However, some things are still unclear to me. For example, there are some new data named “p_input_1”, “u_input_1”, etc. Here, the value of p_input_1 at maximum y is what I’m looking for, isn’t it?

Let me share the outputs I obtained with respect to the steps you suggested

  1. This figure shows what the final result should be:
  2. After using the Voronoi Kernel
  3. After merging data with the Append Attributes filter
  4. Then, using the Calculator by defining Result Array Name as absPresNew (p-max(p_input_1)) gives

This result is different from the output I mentioned in 1st step. I could not take the maximum value which is, e.g., around 2.3e-01 in this case.

I appreciate your help.

Hi,

Is PlotOverLine1 parallel to the z-axis and passing through ymax? It appears to be a line parallel to the y-axis.

If you don’t mind, would it be possible to share your data?

Is PlotOverLine1 parallel to the z-axis and passing through ymax?

Oh, as I always do, I plotted “line” parallel to the y-axis. Now, the solution you suggested works! Thank you very much for your time and support!