[Paraview] adjusting vertical level setting via paraview python script

Eatmon Jr., Arnold aeatmon at lanl.gov
Mon Aug 3 15:56:51 EDT 2015


Oh, my mistake I didn’t understand the instructions. I will run it again to get .pvtu output, however in my previous scripts that generate VTK output there was an issue where the currently released 4.3.1 version of Paraview could not open the files due to a back compatability issue. I had a developers head on an old machine that could open them, however I do not any longer and the source code is no longer available on the paraview downloads page. Will v4.3.1 be able to open these .pvtu output files?

From: Andy Bauer <andy.bauer at kitware.com<mailto:andy.bauer at kitware.com>>
Date: Monday, August 3, 2015 at 1:14 PM
To: First name Last name <aeatmon at lanl.gov<mailto:aeatmon at lanl.gov>>, "Patchett, John M" <patchett at lanl.gov<mailto:patchett at lanl.gov>>, Dave DeMarle <dave.demarle at kitware.com<mailto:dave.demarle at kitware.com>>, "paraview at paraview.org<mailto:paraview at paraview.org>" <paraview at paraview.org<mailto:paraview at paraview.org>>
Subject: Re: [Paraview] adjusting vertical level setting via paraview python script

Hi,

Please reply to everyone so that anyone that wants to follow along with the conversation can.

Did you get a chance to look through the Catalyst User's Guide?

For MPAS, the names of the adaptor outputs are:
  'X_Y_NLAYER-primal',
  'X_Y_NLAYER-dual',
  'X_Y_Z_1LAYER-primal',
  'X_Y_Z_1LAYER-dual',
  'X_Y_Z_NLAYER-primal',
  'X_Y_Z_NLAYER-dual',
  'LON_LAT_1LAYER-primal',
  'LON_LAT_1LAYER-dual',
  'LON_LAT_NLAYER-primal',
  'LON_LAT_NLAYER-dual'

The files that you want are the ones provided by Catalyst and not the ones that MPAS natively writes out. The Catalyst files all should be written out with pvtu extensions (e.g. X_Y_NLAYER-primal_1.pvtu). The MPAS native output is the .nc file.

The other error that you're getting is that you have an active Python trace when going through the Catalyst export wizard and that trace needs to be stopped.

Regards,
Andy

On Mon, Aug 3, 2015 at 3:00 PM, Eatmon Jr., Arnold <aeatmon at lanl.gov<mailto:aeatmon at lanl.gov>> wrote:
Alright, in order of what I did just to be clear, I uploaded the attached python to my directory, soft linked it to mpas.py, ran the simulation for a single timestep, and got a file in my output folder labeled output.0015-01-01_00.00.00.nc<http://output.0015-01-01_00.00.00.nc>. I took that file and opened it in the Paraview desktop gui. In paraview with coprocessing enabled (Tools > Plugin Manager > under catalyst option, hit load), I made the adjustment to the vertical level and then exported the state (CoProcessing > Export State). I do not get a python script as an output, I get the error


"Cannot generate Python state when tracing is active."

RuntimeError: Cannot generate Python state when tracing is active.





From: Andy Bauer <andy.bauer at kitware.com<mailto:andy.bauer at kitware.com>>
Date: Monday, August 3, 2015 at 11:33 AM
To: David E DeMarle <dave.demarle at kitware.com<mailto:dave.demarle at kitware.com>>
Cc: First name Last name <aeatmon at lanl.gov<mailto:aeatmon at lanl.gov>>, "Patchett, John M" <patchett at lanl.gov<mailto:patchett at lanl.gov>>, "paraview at paraview.org<mailto:paraview at paraview.org>" <paraview at paraview.org<mailto:paraview at paraview.org>>

Subject: Re: [Paraview] adjusting vertical level setting via paraview python script

Hi,

Dave is correct in that the reader's output needs to match what the adaptor is producing and in this case the MPAS NetCDF reader does not match what the adaptor provides to Catalyst. The way to get around this is to run Catalyst with a sample Python script that outputs the full data set that the adaptor provides. For MPAS this is slightly more complex because it provides several outputs, 10 in fact, depending on how the scientists want the data (e.g. spherical vs. projected, primal vs. dual grid, single level vs. multiple levels) for what they're trying to do. The attached script can be used to write out all 10 of these outputs which is done every 5th output (this can be changed by changing the outputfrequency value).

The general workflow would be to run MPAS with this script for a small amount of time steps (maybe also with a smaller input data set). Then use those outputs to generate the Catalyst script that you want from the GUI.

If this is a bit unclear, I'd recommend going through the Catalyst User's Guide (http://www.paraview.org/files/catalyst/docs/ParaViewCatalystUsersGuide_v2.pdf) for more details.

Regards,
Andy

On Mon, Aug 3, 2015 at 12:20 PM, David E DeMarle <dave.demarle at kitware.com<mailto:dave.demarle at kitware.com>> wrote:
Andy Bauer just explained it to me. He'll get back to you soon with a detailed explanation and hints about how to get what you want done.

Meanwhile, what is tripping us up is that MPAS's catalyst adaptor is not the same thing as ParaViews MPAS reader. The reader has the SetVerticalLevel(int) method, but the adaptor probably has an entirely different method for doing that.

I don't know firsthand what that method is so we'll have to wait for his response.





David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909<tel:518-881-4909>

On Thu, Jul 30, 2015 at 4:20 PM, Eatmon Jr., Arnold <aeatmon at lanl.gov<mailto:aeatmon at lanl.gov>> wrote:

      # Level2 = paraview.simple.FindSource('X_Y_Z_1LAYER-primal')

      # Level2.VerticalLevel = 32


      Layer2 = output00240101_000000nc

      Layer2.VerticalLevel = 32


Also,

I tried both of the above both individually with the other commented out and running at the same time, they both return that the attribute VerticalLevel does not exist in that class. It seems to solely exist in paraview.simple.NetCDFreader.


From: David E DeMarle <dave.demarle at kitware.com<mailto:dave.demarle at kitware.com>>
Date: Thursday, July 30, 2015 at 1:45 PM
To: First name Last name <aeatmon at lanl.gov<mailto:aeatmon at lanl.gov>>
Subject: Re: [Paraview] adjusting vertical level setting via paraview python script

I verified in the GUI that I can change the level and see it take effect, so it should work in principle. You might want to open that file in the paraView GUI and do the same exercise.

In your script a couple of bits looks fishy to me and might cause the problem.

paraview.simple.NetCDFMPASreader.PointArrayStatus = ['temperature']
paraview.simple.NetCDFMPASreader.ShowMultilayerView = 0
paraview.simple.NetCDFMPASreader.VerticalLevel = '1' #use = 1 not = '1'

later

paraview.simple.NetCDFMPASreader.VerticalLevel = 1

just do it one time


I think the above all do something like set propeties of the global netcdmfmpasreader class, not the one specific instance of that class that you care about.

# get active source.
# Level2 = paraview.simple.GetActiveSource()
# Level2.VerticalLevel = 1

this is closer, try
level2=paraview.simple.FindSource('X_Y_Z_1LAYER-primal')

or better yet, since it is defined early on just

Layer2 = output00240101_000000nc

Either should give you the specific instance and then you can call Layer2.VerticalLevel = 1 on it.



David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909<tel:518-881-4909>

On Thu, Jul 30, 2015 at 3:12 PM, Eatmon Jr., Arnold <aeatmon at lanl.gov<mailto:aeatmon at lanl.gov>> wrote:
As a followup to my last reply, I’m pasting the script below for reference because there may be a problem within of which I am not aware. The script is not too clean, though.

Also attached is an image of the output where I see the vertical level still needs to be turned down.

——————————————————————————————————————————————————

from paraview import coprocessing



#--------------------------------------------------------------

# Code generated from cpstate.py to create the CoProcessor.

# ParaView 4.3.1 64 bits



# ----------------------- CoProcessor definition -----------------------


def CreateCoProcessor():

  def _CreatePipeline(coprocessor, datadescription):

    class Pipeline:

      # state file generated using paraview version 4.3.1


      # ----------------------------------------------------------------

      # setup views used in the visualization

      # ----------------------------------------------------------------


      #### disable automatic camera reset on 'Show'

      paraview.simple._DisableFirstRenderCameraReset()


      # Create a new 'Render View'

      renderView1 = CreateView('RenderView')

      renderView1.ViewSize = [1811, 837]

      renderView1.CenterOfRotation = [0.0, 0.0, 69503.75]

      renderView1.StereoType = 0

      renderView1.CameraPosition = [-41129254.56226203, -8828710.007515563, 6001602.840730475]

      renderView1.CameraFocalPoint = [0.0, 0.0, 69503.75]

      renderView1.CameraViewUp = [0.06821863148547692, 0.3176561586160046, 0.9457487949828816]

      renderView1.CameraParallelScale = 10995245.645232411

      renderView1.Background = [0.37254901960784315, 0.36470588235294116, 0.3411764705882353]


      # register the view with coprocessor

      # and provide it with information such as the filename to use,

      # how frequently to write the images, etc.

      coprocessor.RegisterView(renderView1,

          filename='image_%t.png', freq=1, fittoscreen=0, magnification=1, width=1811, height=837, cinema={"camera":"Spherical", "phi":[-180,-162,-144,-126,-108,-90,-72,-54,-36,-18,0,18,36,54,72,90,108,126,144,162], "theta":[-180,-162,-144,-126,-108,-90,-72,-54,-36,-18,0,18,36,54,72,90,108,126,144,162] })


      # ----------------------------------------------------------------

      # setup the data processing pipelines

      # ---------------------------------------------------------------


      # create a new 'NetCDF MPAS reader'

      # create a producer from a simulation input

      output00240101_000000nc = coprocessor.CreateProducer(datadescription, 'X_Y_Z_1LAYER-primal')


      # ----------------------------------------------------------------

      # setup color maps and opacity mapes used in the visualization

      # note: the Get..() functions create a new object, if needed

      # ----------------------------------------------------------------



      # reset view to fit data

      renderView1.ResetCamera()


      # show data in view

      output00240101_000000ncDisplay = Show(output00240101_000000nc, renderView1)


      # Properties modified on output00240101_000000nc

      paraview.simple.NetCDFMPASreader.PointArrayStatus = ['temperature']

      paraview.simple.NetCDFMPASreader.ShowMultilayerView = 0

      paraview.simple.NetCDFMPASreader.VerticalLevel = '1'


      # Level1 = paraview.simple.ColorByArray()

      # Level1.ColorBy(mpas_data_1pvtuDisplay, ('CELLS', 'temperature'))


      # set scalar coloring

      ColorBy(output00240101_000000ncDisplay, ('CELLS', 'temperature'))


      # rescale color and/or opacity maps used to include current data range

      output00240101_000000ncDisplay.RescaleTransferFunctionToDataRange(True)



      # get color transfer function/color map for 'temperature'

      temperatureLUT = GetColorTransferFunction('temperature')

      temperatureLUT.InterpretValuesAsCategories = 0

      temperatureLUT.Discretize = 0

      temperatureLUT.MapControlPointsToLinearSpace()

      temperatureLUT.UseLogScale = 0

      temperatureLUT.RGBPoints = [-2.0, 0.105882, 0.2, 0.14902, -1.25, 0.141176, 0.25098, 0.180392, -0.5, 0.172549, 0.301961, 0.211765, 0.25, 0.211765, 0.34902, 0.243137, 1.0, 0.227451, 0.388235, 0.254902, 1.75, 0.239216, 0.431373, 0.258824, 2.5, 0.25098, 0.470588, 0.262745, 3.25, 0.258824, 0.509804, 0.258824, 4.0, 0.294118, 0.54902, 0.27451, 4.75, 0.333333, 0.580392, 0.294118, 5.5, 0.380392, 0.619608, 0.321569, 6.250000000000002, 0.431373, 0.658824, 0.34902, 7.0, 0.482353, 0.690196, 0.380392, 7.750000000000002, 0.52549, 0.729412, 0.388235, 8.5, 0.564706, 0.760784, 0.380392, 9.250000000000002, 0.631373, 0.788235, 0.411765, 10.0, 0.694118, 0.819608, 0.443137, 10.75, 0.745098, 0.85098, 0.458824, 11.5, 0.803922, 0.878431, 0.494118, 12.25, 0.843137, 0.901961, 0.521569, 13.0, 0.894118, 0.929412, 0.556863, 14.500000000000004, 0.94902, 0.94902, 0.647059, 16.0, 0.968627, 0.968627, 0.796078, 17.05, 1.0, 0.996078, 0.901961, 17.2, 0.968627, 1.0, 0.996078, 17.35, 0.901961, 1.0, 0.984314, 18.1, 0.831373, 0.988235, 0.972549, 19.0, 0.721569, 0.94902, 0.945098, 19.75, 0.639216, 0.882353, 0.901961, 20.500000000000004, 0.568627, 0.807843, 0.85098, 21.25, 0.513725, 0.717647, 0.788235, 22.0, 0.447059, 0.627451, 0.721569, 22.75, 0.388235, 0.541176, 0.65098, 23.5, 0.337255, 0.462745, 0.580392, 24.25, 0.286275, 0.388235, 0.521569, 25.0, 0.25098, 0.333333, 0.478431, 25.750000000000004, 0.219608, 0.290196, 0.45098, 26.5, 0.196078, 0.247059, 0.419608, 27.25, 0.152941, 0.188235, 0.34902, 28.0, 0.113725, 0.113725, 0.278431]

      temperatureLUT.ColorSpace = 'Lab'

      temperatureLUT.LockScalarRange = 0

      temperatureLUT.NanColor = [0.250004, 0.0, 0.0]

      temperatureLUT.ScalarRangeInitialized = 1.0



      # get opacity transfer function/opacity map for 'temperature'

      temperaturePWF = GetOpacityTransferFunction('temperature')

      temperaturePWF.Points = [-2.0, 0.0, 0.5, 0.0, 28.0, 1.0, 0.5, 0.0]

      temperaturePWF.ScalarRangeInitialized = 1


      # Properties modified on temperatureLUT

      # temperatureLUT.InterpretValuesAsCategories = 0



      # paraview.simple.NetCDFMPASreader.ShowMultilayerView = 0

      paraview.simple.NetCDFMPASreader.VerticalLevel = 1


      # renderView1.ResetCamera()


      # get active source.

      # Level2 = paraview.simple.GetActiveSource()

      # Level2.VerticalLevel = 1



      # ----------------------------------------------------------------

      # setup the visualization in view 'renderView1'

      # ----------------------------------------------------------------


      # show data from output00240101_000000nc

      output00240101_000000ncDisplay = Show(output00240101_000000nc, renderView1)

      # trace defaults for the display properties. 356617.92693278694

      output00240101_000000ncDisplay.ColorArrayName = ['CELLS', 'temperature']

      output00240101_000000ncDisplay.LookupTable = temperatureLUT

      output00240101_000000ncDisplay.ScalarOpacityUnitDistance = 1469170.6394257464<tel:6394257464>


      # show color legend

      output00240101_000000ncDisplay.SetScalarBarVisibility(renderView1, True)


      # setup the color legend parameters for each legend in this view



      # get color legend/bar for temperatureLUT in view renderView1

      temperatureLUTColorBar = GetScalarBar(temperatureLUT, renderView1)

      temperatureLUTColorBar.Title = 'temperature'

      temperatureLUTColorBar.ComponentTitle = ''

    return Pipeline()


  class CoProcessor(coprocessing.CoProcessor):

    def CreatePipeline(self, datadescription):

      self.Pipeline = _CreatePipeline(self, datadescription)


  coprocessor = CoProcessor()

  # these are the frequencies at which the coprocessor updates.

  freqs = {'X_Y_Z_1LAYER-primal': [1]}

  coprocessor.SetUpdateFrequencies(freqs)

  return coprocessor


#--------------------------------------------------------------

# Global variables that will hold the pipeline for each timestep

# Creating the CoProcessor object, doesn't actually create the ParaView pipeline.

# It will be automatically setup when coprocessor.UpdateProducers() is called the

# first time.

coprocessor = CreateCoProcessor()


#--------------------------------------------------------------

# Enable Live-Visualizaton with ParaView

coprocessor.EnableLiveVisualization(False, 1)



# ---------------------- Data Selection method ----------------------


def RequestDataDescription(datadescription):

    "Callback to populate the request for current timestep"

    global coprocessor

    if datadescription.GetForceOutput() == True:

        # We are just going to request all fields and meshes from the simulation

        # code/adaptor.

        for i in range(datadescription.GetNumberOfInputDescriptions()):

            datadescription.GetInputDescription(i).AllFieldsOn()

            datadescription.GetInputDescription(i).GenerateMeshOn()

        return


    # setup requests for all inputs based on the requirements of the

    # pipeline.

    coprocessor.LoadRequestedData(datadescription)


# ------------------------ Processing method ------------------------


def DoCoProcessing(datadescription):

    "Callback to do co-processing for current timestep"

    global coprocessor


    # Update the coprocessor by providing it the newly generated simulation data.

    # If the pipeline hasn't been setup yet, this will setup the pipeline.

    coprocessor.UpdateProducers(datadescription)


    # Write output data, if appropriate.

    coprocessor.WriteData(datadescription);




    # Write image capture (Last arg: rescale lookup table), if appropriate.

    coprocessor.WriteImages(datadescription, rescale_lookuptable=False)


    # Live Visualization, if enabled.

    coprocessor.DoLiveVisualization(datadescription, "localhost", 22222)



From: David E DeMarle <dave.demarle at kitware.com<mailto:dave.demarle at kitware.com>>
Date: Thursday, July 30, 2015 at 12:32 PM
To: First name Last name <aeatmon at lanl.gov<mailto:aeatmon at lanl.gov>>
Cc: "paraview at paraview.org<mailto:paraview at paraview.org>" <paraview at paraview.org<mailto:paraview at paraview.org>>
Subject: Re: [Paraview] adjusting vertical level setting via paraview python script

Regarding the adding attributes error message, it is likely that the ActiveSource is not an MPAS reader at that point in time.
…GetActiveSource().__class__ should tell your what it is.

Regarding the level setting - what is yourReader.ShowMultilayerView?
The docs indicated a value of 1 makes VerticalLayer immaterial.



David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909<tel:518-881-4909>

On Thu, Jul 30, 2015 at 9:52 AM, Eatmon Jr., Arnold <aeatmon at lanl.gov<mailto:aeatmon at lanl.gov>> wrote:
I’m one of the DSS interns working under Jim Ahrens for the summer. I am using paraviews python script in the HPC and I’m having an issue adjusting an attribute of paraview.simple.netcdfmpasreader “VerticalLevel”.

I want to adjust it from the default to one and attempted:

paraview.simple.NetCDFMPASreader.VerticalLevel = 1
paraview.simple.NetCDFMPASreader.VerticalLevel = ‘1'
And
paraview.simple.GetActiveSource().VerticalLevel = 1

The first two operate with no errors doing nothing in the program and the last returns an error that the class bars adding attributes to prevent errors due to spelling.

How do I adjust the vertical level setting?

Thank you in advance for your assistance.

_______________________________________________
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:
http://public.kitware.com/mailman/listinfo/paraview





_______________________________________________
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:
http://public.kitware.com/mailman/listinfo/paraview



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20150803/5284f479/attachment-0001.html>


More information about the ParaView mailing list