# Visualize specific timestep volume vender by python

**URL:** <https://vapor.discourse.group/t/visualize-specific-timestep-volume-vender-by-python/304>\
**Category:** Uncategorized\
**Created:** [May 23, 2023, 7:53pm UTC](https://vapor.discourse.group/t/visualize-specific-timestep-volume-vender-by-python/304 "2023-05-23T19:53:14Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://vapor.discourse.group/u/Ivan)\
**Post date:** [May 23, 2023, 7:53pm UTC](https://vapor.discourse.group/t/visualize-specific-timestep-volume-vender-by-python/304/1 "2023-05-23T19:53:14Z")

</div>

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.

Thanks,  
Ivan

---

<div class="post-metadata">

**Author:** ![pearse](https://yyz2.discourse-cdn.com/free1/user_avatar/vapor.discourse.group/pearse/32/177_2.png) [@pearse](https://vapor.discourse.group/u/pearse)\
**Post date:** [May 24, 2023, 10:18pm UTC](https://vapor.discourse.group/t/visualize-specific-timestep-volume-vender-by-python/304/2 "2023-05-24T22:18:34Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://vapor.discourse.group/u/Ivan)\
**Post date:** [May 25, 2023, 1:31am UTC](https://vapor.discourse.group/t/visualize-specific-timestep-volume-vender-by-python/304/3 "2023-05-25T01:31:40Z")

</div>

Thanks for your reply. Here is the code:

> <https://github.com/zli867/VaporVisualization/blob/main/VolumeRender.ipynb>

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.

 ![Screen Shot 2023-05-24 at 9.30.10 PM](https://global.discourse-cdn.com/free1/uploads/vapor/original/1X/fd7b48e35f9f3b909b4ce953910e8be1ac41e936.jpeg)

Do you have any ideas for it? Thanks!

---

<div class="post-metadata">

**Author:** ![StasJ](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@StasJ](https://vapor.discourse.group/u/StasJ)\
**Post date:** [May 26, 2023, 9:03pm UTC](https://vapor.discourse.group/t/visualize-specific-timestep-volume-vender-by-python/304/4 "2023-05-26T21:03:54Z")

</div>

Hi Ivan,

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

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://vapor.discourse.group/u/Ivan)\
**Post date:** [May 26, 2023, 9:25pm UTC](https://vapor.discourse.group/t/visualize-specific-timestep-volume-vender-by-python/304/5 "2023-05-26T21:25:44Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![StasJ](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@StasJ](https://vapor.discourse.group/u/StasJ)\
**Post date:** [May 26, 2023, 10:21pm UTC](https://vapor.discourse.group/t/visualize-specific-timestep-volume-vender-by-python/304/6 "2023-05-26T22:21:07Z")

</div>

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:

```auto
SetTimestep(...)
    void Session::SetTimestep(int ts)

```

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://vapor.discourse.group/u/Ivan)\
**Post date:** [May 27, 2023, 2:10pm UTC](https://vapor.discourse.group/t/visualize-specific-timestep-volume-vender-by-python/304/7 "2023-05-27T14:10:22Z")

</div>

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:

```auto
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)
ren.SetVariableName(data.GetDataVarNames(3)[smoke_tracer_idx])

```

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!

---

<div class="post-metadata">

**Author:** ![pearse](https://yyz2.discourse-cdn.com/free1/user_avatar/vapor.discourse.group/pearse/32/177_2.png) [@pearse](https://vapor.discourse.group/u/pearse)\
**Post date:** [May 30, 2023, 5:38pm UTC](https://vapor.discourse.group/t/visualize-specific-timestep-volume-vender-by-python/304/8 "2023-05-30T17:38:38Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://vapor.discourse.group/u/Ivan)\
**Post date:** [May 30, 2023, 5:51pm UTC](https://vapor.discourse.group/t/visualize-specific-timestep-volume-vender-by-python/304/9 "2023-05-30T17:51:40Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![pearse](https://yyz2.discourse-cdn.com/free1/user_avatar/vapor.discourse.group/pearse/32/177_2.png) [@pearse](https://vapor.discourse.group/u/pearse)\
**Post date:** [June 1, 2023, 8:46pm UTC](https://vapor.discourse.group/t/visualize-specific-timestep-volume-vender-by-python/304/10 "2023-06-01T20:46:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://vapor.discourse.group/u/Ivan)\
**Post date:** [June 5, 2023, 2:59pm UTC](https://vapor.discourse.group/t/visualize-specific-timestep-volume-vender-by-python/304/11 "2023-06-05T14:59:46Z")

</div>

Thanks for your help. Sure, I am glad to share a dataset:  
[https://drive.google.com/drive/folders/1a879a554CPQzX0NA-5pUWhlz6ltt3AjV?usp=sharing](https://drive.google.com/drive/folders/1a879a554CPQzX0NA-5pUWhlz6ltt3AjV?usp=sharing)

It will include three things in the folder:

1. Combined\_3D\_CCTM\_0323\_FEPS\_SEV\_Vapor.nc: 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!
