Visualize specific timestep volume vender by python

Dear all,

Is there a way to set the time-varying VolumeRender data to a specific time step and visualize it? I tried ses.SetTimestep(time_step_value), but it does not work.


Hmm. That should work, and if it doesn’t it is a bug. Can you provide the script you’re using so we can take a look?

Thanks for your reply. Here is the code:

Although I set the timestep, it shows the volume at the initial time (00:00 UTC).

And I also do it in the vapor software at timestep 60 which is 20:00 UTC in the WRF file.

Do you have any ideas for it? Thanks!

Hi Ivan,

Your script only loads one timestep, 00:00:00.

Thanks for your reply. Can you specify which function I can use to set the timestep of time-varied variables? Also, what is the SetTimestep function usage? I cannot find information for these in the API document and strings returned by the help function. Thanks a lot!

You use Session.SetTimestep

The online documentation for vapor.session is indeed missing so opened a ticket. You can get documentation directly from python by using help. Calling help(Session.SetTimestep) gives you the usage:

    void Session::SetTimestep(int ts)

I am still confused. It seems the SetTimeStep function can tune the session and it seems it must be written exactly just one line before ses.Show() function. But how can I change the timestep of data in this package? Currently, I am doing the following things:

data = ses.OpenDataset(dataset.WRF, filenames)
smoke_tracer_name = "tr17_1"
smoke_tracer_idx = data.GetDataVarNames(3).index(smoke_tracer_name)
# render
ren = data.NewRenderer(renderer.VolumeRenderer)

It seems every time I use these codes to read time-varied data, it will return the first timestep data. The data wrapped in vapor does not like numpy array which can be sliced. And the SetTimeStep does not control the timestep of the data.

I am trying to vary the time step for the render just like what the animation_example did. But the example is only for non-time-varied variables visualization. There are limited resources for time-varied variables visualization. It would be better if you can provide a short example or point me to the function which can change the render’s timestep. Thanks a lot!

@Ivan - In your script you are only loading one timestep. See the following line in your .ipynb file:

filenames = ["/Users/zongrunli/Desktop/WRF_Fire_Visualization/wrfout_d01_2022-04-25_00:00:00"]

This needs to be a list of your entire timeseries, not just a single file.

Thanks for your reply. It is WRF name convention. The NetCDF file should include all time steps (72-time steps in my input file). Do you mean I should slice the NetCDF into 72 parts based on the time step via NCO or other software and then feed it into the list? Thanks a lot!

Could you try that and tell us if it works? I believe this is a bug that we need to consider. Also, if your file is not over a few gigabytes, could you share it with us? This will help us diagnose the difference between what’s happening with Vapor’s GUI and the Python API.

Thank you for bringing this to our attention.

Thanks for your help. Sure, I am glad to share a dataset:

It will include three things in the folder:

  1. a netCDF in WRF format. It can be opened in Vapor software if you import it as WRF-ARW.
  2. VolumeRender_Test.ipynb: a visualization jupyter notebook script for volume render. I set the ses to 15 but it does not work anymore.
  3. Vapor_Software.png: the target visualization which is made by Vapor software. The visualization is for timestep 15.

Please let me know if you have any questions or requirements. Thanks!