Arshpreet Singh,
I highly recommend you take a look at the Python trace feature in the ParaView
GUI. It will automatically create Python code that replicates things you do in
the GUI, which I find much easier than trying to write the Python code from
scratch. The Python trace feature is documented in both the ParaView tutorial
(http://www.paraview.org/Wiki/The_ParaView_Tutorial) and the ParaView User’s
guide (http://www.paraview.org/paraview-guide/), both of which are available
for free.
As an example, I have attached a Python script that loads a netCDF file, shows
a variable, and animates over time. I generated this in the ParaView GUI in
less time than it took me to write the rest of this email.
-Ken
On 5/14/16, 2:26 AM, "ParaView on behalf of Arshpreet Singh"
<[email protected] on behalf of [email protected]> wrote:
>Hi I am accessing netcdf file from Python interface in Paraview, My
>main goal is to access different parameters change in air and
>temperature with respect to time.
>
>
>Can anyone point me towards and example Python code which can show
>demonstration of Paraview and netcdf files from using Python code?
>
>--
>
>Thanks
>Arshpreet Singh
>
>I am Sikh boy, Learning by doing and Learning by teaching is my religion.
>------------------------------------------------------------------------------
>Slashdot TV.
>Video for Nerds. Stuff that matters.
>http://tv.slashdot.org/
>_______________________________________________
>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:
>http://public.kitware.com/mailman/listinfo/paraview
#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
# create a new 'NetCDF Reader'
tos_O1_20012002nc = NetCDFReader(FileName=['/Users/kmorel/data/VTKDataNew/tos_O1_2001-2002.nc'])
# get animation scene
animationScene1 = GetAnimationScene()
# update animation scene based on data timesteps
animationScene1.UpdateAnimationUsingDataTimeSteps()
# Properties modified on tos_O1_20012002nc
tos_O1_20012002nc.ReplaceFillValueWithNan = 1
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# uncomment following to set a specific view size
# renderView1.ViewSize = [792, 667]
# show data in view
tos_O1_20012002ncDisplay = Show(tos_O1_20012002nc, renderView1)
# reset view to fit data
renderView1.ResetCamera()
# set scalar coloring
ColorBy(tos_O1_20012002ncDisplay, ('CELLS', 'tos'))
# rescale color and/or opacity maps used to include current data range
tos_O1_20012002ncDisplay.RescaleTransferFunctionToDataRange(True)
# show color bar/color legend
tos_O1_20012002ncDisplay.SetScalarBarVisibility(renderView1, True)
# get color transfer function/color map for 'tos'
tosLUT = GetColorTransferFunction('tos')
# get opacity transfer function/opacity map for 'tos'
tosPWF = GetOpacityTransferFunction('tos')
# rescale color and/or opacity maps used to exactly fit the current data range
tos_O1_20012002ncDisplay.RescaleTransferFunctionToDataRange(False)
animationScene1.Play()
#### saving camera placements for all active views
# current camera placement for renderView1
renderView1.CameraPosition = [0.0, 0.0, 6.682824817246511]
renderView1.CameraFocalPoint = [0.0, 0.0, 0.00759612349389599]
renderView1.CameraParallelScale = 1.7276763163579985
#### uncomment the following to render all views
# RenderAllViews()
# alternatively, if you want to write images, you can use SaveScreenshot(...)._______________________________________________
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:
http://public.kitware.com/mailman/listinfo/paraview