Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • wdata wdata
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 4
    • Issues 4
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • wtools
  • wdatawdata
  • Wiki
    • Examples
  • Python examples

Python examples · Changes

Page history
Update Python examples authored Jan 17, 2022 by Gabriel Wlazłowski's avatar Gabriel Wlazłowski
Show whitespace changes
Inline Side-by-side
Examples/Python-examples.md
View page @ 55ec0bde
[[_TOC_]]
# Simple plot of 1D data
The example below demonstrates how to plot 1D data, precisely:
```
......@@ -38,3 +39,46 @@ plt.show()
```
The result of this example:
![rho_a](uploads/e6ca81cfb4602e23d338ddc969af1c42/rho_a.png)
# Simple plot of 2D data
The example below demonstrates how to plot 1D data, precisely:
```
datadim 2 # dimension of block size: 1=nx, 2=nx*ny, 3=nx*ny*nz
```
The simple plotting script may look like:
```python
#!/usr/bin/python3
# Before run:
# Get wata lib:
# pip3 install wdata
# (add -U if you want to update)
# For more info see:
# https://pypi.org/project/wdata/
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from wdata.io import WData, Var
# I read data directly from dwarf,
# Before running the script I mounted file system:
# sshfs gabrielw@dwarf.if.pw.edu.pl:/home2/ /home/gabrielw/home2-dwarf/
fwtxt="/home/gabrielw/home2-dwarf/archive/ntg/repository/atomicjj/CALC-BCS/td-round5-bcs/td1-bcs-z0.02-V0.6.wtxt"
data = WData.load(fwtxt)
ratio=data.Nxyz[0]/data.Nxyz[1]
scale=2.0
fig, ax = plt.subplots(figsize=(scale*ratio,1.2*scale))
im = ax.imshow(np.transpose(data.rho_a[0]), interpolation='bilinear', extent=[0, data.Nxyz[0], 0, data.Nxyz[1]], aspect='auto')
fig.colorbar(im, ax=ax, orientation="horizontal")
plt.tight_layout()
fig.savefig("rho_a.png")
plt.show()
```
The result of this example:
![rho_a](uploads/af555a49c8279e60d1ca1186af98ff9b/rho_a.png)
\ No newline at end of file
Clone repository
  • Data types
  • Examples
    • C examples
    • Python examples
  • Tags
  • VisIt plugin compilation
  • Visit integration
  • Home
  • wdata format concept