PyPLUTO: Difference between revisions

From Arbeitsgruppe Kuiper
Jump to navigation Jump to search
m (- header)
(→‎Usage: warning, +members)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
... exists in different versions from different sources:
... exists in different versions from different sources:


* https://github.com/bellatrics/pyPLUTO is from 2011, don't use
* https://github.com/bellatrics/pyPLUTO, alpha state from 2011, don't use
* https://github.com/coolastro/pyPLUTO is from 2012, don't use
* https://github.com/coolastro/pyPLUTO, version 1.0 from 2012, don't use
* https://gitlab.mpcdf.mpg.de/sdoetsch/pypluto was maintained until 2022
* https://gitlab.mpcdf.mpg.de/sdoetsch/pypluto, modified version 4.4, maintained until 2022 ← use ''this''
* ... use ''this''
 
= Installation =
 
(... as non-administrator)
 
* Grab the files off of gitlab e.g. in [https://gitlab.mpcdf.mpg.de/sdoetsch/pypluto/-/archive/main/pypluto-main.zip ZIP format] and unzip them into a local folder.
* Inside the extracted folder, enter your python environment (e.g. conda) and run <code>python3 setup.py install</code>.
 
= Usage =
 
  import pyPLUTO.pload as pp
  wdir="/path/to/data/files/"  # trailing slash!
  data=pp.pload(timestep, w_dir=wdir)  #  timestep = int, e.g. 1
 
(Unfortunately, <code>pload()</code>'s verbosity cannot be turned off, but in JupyterLab you can put <code>%%capture --no-display</code> as the first line of the cell.)
 
Now, <code>data</code> contains all the information of the given timestep. To obtain a specific variable, e.g. <code>vx1</code>, you can use <code>data.vx1</code> to get a numpy array with all the values in that timestep. Moreover, <code>x1</code>, <code>x2</code> and <code>x3</code>, as well as <code>dx1</code>, <code>dx2</code> and <code>dx3</code>, contain the grid and its spacings, respectively. For a list of all members see below.
 
Notes:
* Upon import, there may be a warning about ''invalid escape sequence '\h''', which can be ignored. (It stems from a <code>$\hat{y}$</code> in the docstring of the function <code>myfieldlines()</code>).
* Up to version 4.1 it used to be <code>import pyPLUTO as pp</code> rather than <code>import pyPLUTO'''.pload''' as pp</code>. You may encounter the old way in documentations.
 
Members of an object of type <code>pyPLUTO.pload.pload</code> (besides the physical fields listed in <code>vars</code>) are: <code>DataScan()</code>, <code>DataScanHDF5()</code>, <code>DataScanVTK()</code>, <code>Dt</code>, <code>NStep</code>, <code>NStepStr</code>, <code>ReadDataFile()</code>, <code>ReadGridFile()</code>, <code>ReadMultipleFiles()</code>, <code>ReadSingleFile()</code>, <code>ReadTimeInfo()</code>, <code>ReadVarFile()</code>, <code>'''SimTime'''</code>, <code>Slice</code>, <code>datatype</code>, <code>dx1</code>, <code>dx2</code>, <code>dx3</code>, <code>endianess</code>, <code>filetype</code>, <code>geometry</code>, <code>irange</code>, <code>jrange</code>, <code>krange</code>, <code>level</code>, <code>n1</code>, <code>n1_tot</code>, <code>n2</code>, <code>n2_tot</code>, <code>n3</code>, <code>n3_tot</code>, <code>nshp</code>, <code>vars</code>, <code>wdir</code>, <code>x1</code>, <code>x1r</code>, <code>x1range</code>, <code>x2</code>, <code>x2r</code>, <code>x2range</code>, <code>x3</code>, <code>x3r</code>, <code>x3range</code>

Latest revision as of 07:50, 27 May 2025

... exists in different versions from different sources:

Installation

(... as non-administrator)

  • Grab the files off of gitlab e.g. in ZIP format and unzip them into a local folder.
  • Inside the extracted folder, enter your python environment (e.g. conda) and run python3 setup.py install.

Usage

 import pyPLUTO.pload as pp
 wdir="/path/to/data/files/"  # trailing slash!
 data=pp.pload(timestep, w_dir=wdir)  #  timestep = int, e.g. 1

(Unfortunately, pload()'s verbosity cannot be turned off, but in JupyterLab you can put %%capture --no-display as the first line of the cell.)

Now, data contains all the information of the given timestep. To obtain a specific variable, e.g. vx1, you can use data.vx1 to get a numpy array with all the values in that timestep. Moreover, x1, x2 and x3, as well as dx1, dx2 and dx3, contain the grid and its spacings, respectively. For a list of all members see below.

Notes:

  • Upon import, there may be a warning about invalid escape sequence '\h', which can be ignored. (It stems from a $\hat{y}$ in the docstring of the function myfieldlines()).
  • Up to version 4.1 it used to be import pyPLUTO as pp rather than import pyPLUTO.pload as pp. You may encounter the old way in documentations.

Members of an object of type pyPLUTO.pload.pload (besides the physical fields listed in vars) are: DataScan(), DataScanHDF5(), DataScanVTK(), Dt, NStep, NStepStr, ReadDataFile(), ReadGridFile(), ReadMultipleFiles(), ReadSingleFile(), ReadTimeInfo(), ReadVarFile(), SimTime, Slice, datatype, dx1, dx2, dx3, endianess, filetype, geometry, irange, jrange, krange, level, n1, n1_tot, n2, n2_tot, n3, n3_tot, nshp, vars, wdir, x1, x1r, x1range, x2, x2r, x2range, x3, x3r, x3range