# Plotting of variables through f2grid file

**URL:** <https://forum.itascainternational.com/t/plotting-of-variables-through-f2grid-file/2102>\
**Category:** FLAC2D\
**Created:** [May 25, 2025, 12:10am UTC](https://forum.itascainternational.com/t/plotting-of-variables-through-f2grid-file/2102 "2025-05-25T00:10:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![katerinaziot](https://avatars.discourse-cdn.com/v4/letter/k/e0b2c6/32.png) [@katerinaziot](https://forum.itascainternational.com/u/katerinaziot)\
**Post date:** [May 25, 2025, 12:10am UTC](https://forum.itascainternational.com/t/plotting-of-variables-through-f2grid-file/2102/1 "2025-05-25T00:10:44Z")

</div>

Hello peeps. I’m probably missing something simple here, but I could use a hand figuring this out.

I want to export grid properties and contents for post-processing and overall “beautification” of plots with python later.

The zone export command (zone export s ) simply gives me all the geometry properties in an f2grid file. If I want to export contour contents (stresses, say vertical effective ones, or field quantities stored in extra variables), can I use this command or is there another one that would work? I tried doing zone export ‘filepath’ extra 1 range x-position 0 66.0 or zone export ‘filepath’ stress-effective quantity yy range group ‘soil’ but I don’t think it the keyword slot is meant for what I am trying to do.

In FLAC 8.1 I used to create a 2D array with information per column and then write it into a .txt file. Totally fine to write a fish function to do something similar in FLAC9 but wondering if it could be easier!

---

<div class="post-metadata">

**Author:** ![Theophile](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.itascainternational.com/theophile/32/299_2.png) [@Theophile](https://forum.itascainternational.com/u/Theophile)\
**Post date:** [May 26, 2025, 8:26am UTC](https://forum.itascainternational.com/t/plotting-of-variables-through-f2grid-file/2102/2 "2025-05-26T08:26:15Z")

</div>

Hi there!

I am not familiar with Flac, but since that you are planning on post-processing with Python, maybe you could dump your data directly into a NumPy `.npz` file?

An example of script to execute in Flac iPython console could be:

```python
import itasca as it
import numpy as np

my_extras = [1, 10, 12]
to_dump = dict(
    stresses = it.zonearray.stress(),
    gp_pos = it.gridpointarray.pos(),
    zone_gps = it.zonearray.gridpoints()
)
for index in my_extras:
    to_dump[f'zone_extra_{index}']=it.zonearray.extra(index)

np.savez_compressed('demo.npz', **to_dump)

```

Now, in an external Python session:

```python
>>> import numpy as np
>>> data_flac = np.load('demo.npz')
>>> tuple(data_flac.keys())
('stresses', 'zone_extra_12', 'zone_extra_1', 'zone_extra_10', 'zone_gps', 'gp_pos')
>>> data_flac['gp_pos']
array([[0., 0., 0.],
       [1., 0., 0.],
       [0., 1., 0.],
       ...,
       [98., 100., 100.],
       [99., 100., 100.],
       [100., 100., 100.]])
>>>

```

By the way, you could do the plotting directly from Flac’s Python!

Cheers

Theophile

---

<div class="post-metadata">

**Author:** ![cheng](https://avatars.discourse-cdn.com/v4/letter/c/ecccb3/32.png) [@cheng](https://forum.itascainternational.com/u/cheng)\
**Post date:** [May 27, 2025, 10:15pm UTC](https://forum.itascainternational.com/t/plotting-of-variables-through-f2grid-file/2102/3 "2025-05-27T22:15:29Z")

</div>

Below is a small example to export zone ID, zone coordinates, and zone effective vertical stress in FLAC2D:

```auto
fish define export
   local zonedata = list.sequence(::zone.id(::zone.list), ::zone.pos(::zone.list)->x, ...
   ::zone.pos(::zone.list)->y, ::zone.stress.eff(::zone.list)->yy)
   file.all('zone.csv', 'text') = string.csv.to(::zonedata)
end
[export]

```

---

<div class="post-metadata">

**Author:** ![katerinaziot](https://avatars.discourse-cdn.com/v4/letter/k/e0b2c6/32.png) [@katerinaziot](https://forum.itascainternational.com/u/katerinaziot)\
**Post date:** [May 28, 2025, 4:44am UTC](https://forum.itascainternational.com/t/plotting-of-variables-through-f2grid-file/2102/4 "2025-05-28T04:44:32Z")

</div>

Thank you Zhao!! Will give this a try.

---

<div class="post-metadata">

**Author:** ![katerinaziot](https://avatars.discourse-cdn.com/v4/letter/k/e0b2c6/32.png) [@katerinaziot](https://forum.itascainternational.com/u/katerinaziot)\
**Post date:** [May 28, 2025, 4:48am UTC](https://forum.itascainternational.com/t/plotting-of-variables-through-f2grid-file/2102/5 "2025-05-28T04:48:32Z")

</div>

Thank you!  
I haven’t played with Python within the software but I guess this will get me there.
