Thanks everybody for the support, I followed Ken’s suggestion, which will simplify things, however when I put Cory’s original script in the programmable filter no Data Array can be found in the output. So I sense there is a (small) bug in the script? I tried changing the last three lines to the oneliner output.GetCellData().SetScalars(inputs[0].GetPointData().GetScalars()) But that did not help.
I have uploaded a small subset of my data here for you to toy around with https://coeri.stackstorage.com/s/0vUfQkVyv2MD3Ml. (Note: It helps for visualization to stretch the z-axis by a factor 3000). This perhaps helps you with helping me. From: Moreland, Kenneth [mailto:kmo...@sandia.gov] Sent: Wednesday, May 02, 2018 7:27 PM To: Quammen, Cory (External Contacts); Engelen, J. van (Joeri) Cc: paraview@public.kitware.com Subject: Re: [Paraview] generic NetCDFreader support for CellData The NetCDF Generic/CF reader has an option named “Output Type” that you can use to force the output to a vtkImageData. Then Cory’s original programmable filter will work, and you won’t have to deal with the coordinates. -Ken From: ParaView <paraview-boun...@public.kitware.com> on behalf of Cory Quammen <cory.quam...@kitware.com> Date: Wednesday, May 2, 2018 at 11:19 AM To: "j.vanengel...@uu.nl" <j.vanengel...@uu.nl> Cc: "paraview@public.kitware.com" <paraview@public.kitware.com> Subject: [EXTERNAL] Re: [Paraview] generic NetCDFreader support for CellData On Wed, May 2, 2018 at 11:37 AM Engelen, J. van (Joeri) <j.vanengel...@uu.nl<mailto:j.vanengel...@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.quam...@kitware.com<mailto:cory.quam...@kitware.com>] Sent: Wednesday, May 02, 2018 5:01 PM To: Engelen, J. van (Joeri) Cc: paraview@public.kitware.com<mailto:paraview@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.vanengel...@uu.nl<mailto:j.vanengel...@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<http://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.
_______________________________________________ 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