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
Create Examples/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 0 → 100644
View page @ 46f46db6
# Simple plot of 1D data
The example below demonstrates how to plot 1D data, precisely:
```
datadim 1 # 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
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/scratch/barrus-gw/h1d/lambda006.wtxt"
data = WData.load(fwtxt)
fig, ax = plt.subplots()
ax.plot(data.xyz[0], data.rho_a[-1]) # plot last frame [-1]
ax.set(xlabel='x', ylabel=r'$n_{\uparrow}(x)$')
ax.grid()
fig.savefig("rho_a.png")
plt.show()
```
The result of this example:
![rho_a](uploads/e6ca81cfb4602e23d338ddc969af1c42/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