[Paraview] generic NetCDFreader support for CellData

Cory Quammen cory.quammen at kitware.com
Wed May 2 13:19:17 EDT 2018


On Wed, May 2, 2018 at 11:37 AM Engelen, J. van (Joeri) <j.vanengelen1 at uu.nl>
wrote:

> Thank you Cory,
>
>
>
> I sense this solution might work. However, the type of my data is
> “Rectilinear Grid”, not sure if that increases the complexity (dx = 1000,
> dy = 1000, dz = 1).
>

Ah. From the documentation: "To define a vtkRectilinearGrid
<https://www.vtk.org/doc/nightly/html/classvtkRectilinearGrid.html>, you
must specify the dimensions of the data and provide three arrays of values
specifying the coordinates along the x-y-z axes". It should be a similar
script, but you'd have to add an additional X, Y, and Z position at the end
of those coordinate arrays. So your script would look more like:

dims = inputs[0].GetDimensions()

ext = inputs[0].GetExtent()

output.SetDimensions(dims[0]+1, dims[1]+1, dims[2]+1)

output.SetExtent(ext[0], ext[1]+1, ext[2], ext[3]+1, ext[4], ext[5]+1)

inputPd = inputs[0].GetPointData()

outputCd = output.GetCellData()

outputCd.SetScalars(inputPd.GetScalars())


# Set coordinates

xCoords = inputs[0].GetXCoordinates().NewInstance()

xCoords.DeepCopy(inputs[0].GetXCoordinates())

xCoords.InsertNextValue(1.0) # Should a reasonable x value for your
dataset larger than previous max x

output.SetXCoordinates(xCoords)


yCoords = inputs[0].GetYCoordinates().NewInstance()

yCoords.DeepCopy(inputs[0].GetYCoordinates())

yCoords.InsertNextValue(1.5) # Should be a reasonable like the x coordinate

output.SetYCoordinates(yCoords)


zCoords = inputs[0].GetZCoordinates().NewInstance()

zCoords.DeepCopy(inputs[0].GetZCoordinates())

zCoords.InsertNextValue(1.0) # Should be a reasonable like the z coordinate

output.SetZCoordinates(zCoords)


Some extent information also needs to be supplied, but I'm not entirely
clear on how to do that correctly.

A better solution would be to add an option to the reader to take care of
this for you if that is reasonable for your data.

Best,
Cory

Regardless, the script you provided does not give me output and it also
> does not throw an error, so I’m left a bit in the dark here.
>

>
> *From:* Cory Quammen [mailto:cory.quammen at kitware.com]
> *Sent:* Wednesday, May 02, 2018 5:01 PM
> *To:* Engelen, J. van (Joeri)
> *Cc:* paraview at public.kitware.com
> *Subject:* Re: [Paraview] generic NetCDFreader support for CellData
>
>
>
> Joeri,
>
>
>
> You can try the "Point Data to Cell Data" filter, but that averages the
> point data and places the results in the cell data. You may wind up with
> some incorrect values using that approach.
>
>
>
> Better would be to use a "Progammable Filter" to resize the cartesian grid
> read by the NetCDF reader and treat the point data as cell data. That is a
> bit involved, but not terrible. Set the Script to
>
>
>
> dims = inputs[0].GetDimensions()
>
> ext = inputs[0].GetExtent()
>
> output.SetDimensions(dims[0]+1, dims[1]+1, dims[2]+1)
>
> output.SetExtent(ext[0], ext[1]+1, ext[2], ext[3]+1, ext[4], ext[5]+1)
>
> inputPd = inputs[0].GetPointData()
>
> outputCd = output.GetCellData()
>
> outputCd.SetScalars(inputPd.GetScalars())
>
>
>
> This assumes that the NetCDF reader is producing a vtkImageData (you can
> check under the Information panel) which would report the Type: of the data
> set as "Image (Uniform Rectilinear Grid).
>
>
>
> HTH,
>
> Cory
>
>
>
> On Wed, May 2, 2018 at 10:17 AM Engelen, J. van (Joeri) <
> j.vanengelen1 at uu.nl> wrote:
>
> Hi,
>
>
>
> I was wondering whether it is possible to read NetCDF files as CellData.
>
>
>
> I have categorial data on Cartesian coordinates that I want to visualize.
> To be more specific, the data represents lithologies of the subsurface. So
> 1 = sand, 3 = clay, 5 = rock.
>
> The problem is that my file is automatically interpreted as PointData. To
> render this PointData, Paraview than consequently interpolates to achieve
> cell values.
>
> With most variables that is not such a problem, but here it is. If I have
> sand (1) overlying rock (5), Paraview shows me clay (3).
>
>
>
> Also, the information available to me was ambiguous,
>
> -this source says it is probably not possible:
>
> https://public.kitware.com/pipermail/paraview/2017-September/040984.html
>
> -this states it is possible return Cell Data information:
>
>
> https://www.paraview.org/ParaView/Doc/Nightly/www/py-doc/paraview.simple.NetCDFReader.html
>
>
>
> I tried converting my data from NetCDF to a .vtr file in Python, but this
> resulted in more problems than solutions. (Just gave me very glitched
> rendering).
>
>
>
> So I have two questions:
>
> -Is this possible?
>
> -Are there any workarounds you can think of to get my data as CellData in
> Paraview?
>
>
>
> I’m using Paraview v5.4.1 on Windows 7.
>
>
>
> Kind regards,
> Joeri
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/paraview
>
>
>
>
> --
>
> Cory Quammen
> Staff R&D Engineer
> Kitware, Inc.
>


-- 
Cory Quammen
Staff R&D Engineer
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/paraview/attachments/20180502/1e74ebaa/attachment.html>


More information about the ParaView mailing list