CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ParaView (https://www.cfd-online.com/Forums/paraview/)
-   -   [General] NaN color for TecPlot data (https://www.cfd-online.com/Forums/paraview/128838-nan-color-tecplot-data.html)

Eloise January 22, 2014 10:45

NaN color for TecPlot data
 
Hello,

I import some 2D data from a TecPlot format into ParaView through a Python script. The TecPlot data file has the following structure:
Code:

TITLE = "B00001"
VARIABLES = "x", "y", "U"
ZONE T="Frame 0", I=74, J=55
1.271574e+02 -8.534172e+00 NaN
[...]
1.263715e+02 -1.875147e+01 9.161986e-01
[...]

In order to highlight the region where the variable U is defined, I'd like to use a colorbar for U and a white color for the NaN region.

I'm using the following command to define my LookUpTable. The colorbar is properly created, but the instruction regarding NaN seems to be ignored. It looks like ParaView automatically converts the NaN to 0.0 because the NaN region get the color assigned to 0.0 (gray) instead of a white color.
Code:

a1_Ux_PVLookupTable = GetLookupTableForArray( "U", 1, RGBPoints=[UMin, 0.23, 0.299, 0.754, 0.0, 0.865, 0.865, 0.865, UMax, 0.706, 0.016, 0.15], NanColor=[1.0, 1.0, 1.0], ColorSpace='Diverging', ScalarRangeInitialized=1.0)
I've also tried to import manually the TecPlot file through the GUI and set NaN color to white in the colorbar menu, but it does not have any effect on the image.

Does someone know more about handling of NaN values during TecPlot import in ParaView 4.1.0-RC1 and can help me?

Many thanks,
Eloïse

wyldckat January 24, 2014 20:26

Greetings Eloïse,

Without an example file to test this myself, I can only guess that the TecPlot reader in ParaView is actually the one to blame here ;)

Did you confirm in the Spreadsheet view in ParaView, if the values were correctly loaded?

Best regards,
Bruno

Eloise January 27, 2014 07:19

2 Attachment(s)
Hello Bruno,

Yes, let's blame the loader :) I uploaded a TecPlot file where you can see that the original data contain NaN. The spreadsheet view confirms that the NaN values are converted to 0.0 at import.

It annoys me because it is then difficult to identify the boundary of the region which actually contains the data, as I also have a region close to 0.0 in my data.

Having NaNs would make it easy to define the color of the NaNs to white and create the contrast to highlight the region containing data. Another way to do is maybe to filter all the 0.0 values in Paraview and set another color for them. But I didn't manage to do so. Any help or suggestions are welcome!

Thanks,
Eloïse

wyldckat February 2, 2014 11:54

1 Attachment(s)
Hi Eloïse,

Mmm... strange. Perhaps this was already fixed in ParaView 4.1.0, since RC1 was released?
I've used the 4.1.0 version for Linux 64 bit and attached is the image that tells almost all of the details:
  • The spreadsheet view demonstrates that the NaN values were read properly.
  • The colour for NaN values was respected.
The missing detail is that I used the "Tecplot Files" option when ParaView asked me which reader to use to load the data.

Best regards,
Bruno

Eloise February 4, 2014 11:04

1 Attachment(s)
Hello Bruno,

I'm post-processing those data on a Windows 64bits machine. I've downloaded Paraview 4.1 for Windows 64bits and the NaN values are still converted to zeros here. I'm also using the TecPlot file option when loading the data.

Thanks for trying,
Eloïse

wyldckat February 15, 2014 15:56

Hi Eloïse,

I went into the VTK source code and found out that the limitation is in atof, a function that converts a number in text format to a double value: https://github.com/Kitware/VTK/blob/...eader.cxx#L824

Unfortunately, if we Google:
Code:

microsoft atof nan
We can easily find that Microsoft's implementation of atof cannot handle NaN values, which returns simply "0.0".

Therefore, the only solution (aside from using a Linux Distribution :)) is to use a text editor to search and replace all NaN values for something... I've done some tests and 1e40 is enough to get all ex-NaN values to be interpreted as "inf" (infinite)... problem is that I can't do anything worth while with it :(

Now I'm understanding a lot better why some people say Windows isn't very science friendly... :(

Best regards,
Bruno


All times are GMT -4. The time now is 06:46.