Skip to main content

A tool to analyze results from idefix/pluto simulations (for protoplanetary disks more specifically)

Project description

nonos

PyPI

nonos is a 2D visualization command line application for planet-disk hydro simulations, as well as a Python library. It works seamlessly with vtu-formatted data from Pluto, Fargo3D and Idefix.

:construction: This project and documentation are under construction :construction:

Ongoing progress

  • spherical coordinates
  • error: streamlines & midplane=False -> not yet implemented
  • warning: isPlanet=False & corotate=True -> we don't rotate the grid if there is no planet for now. omegagrid = 0.
  • warning: cartesian=False & midplane=False -> plot not optimized for now in the (R,z) plane in polar.

Installation

:warning: Nonos requires Python 3.8 or newer. The easiest installation method is

pip install nonos

Usage

There are three ways to use nonos:

  1. use the command line tool
  2. use the local mode with the config.toml file
  3. write a Python script using the nonos library

1. On the command line

To get help, run

$ nonos --help

nonos -mod d/f [options]
-info: give the default parameters in the config.toml file.
-dir: where .vtk files and the inifile are stored ("." by default).
-mod [d/f]: display/film ("" home page by default).
-f [str]: field (for now RHO, VX1 and VX2 in 2D, + VX3 in 3D, RHO by default).
-on [int]: if -mod d -> we plot the field of the data.on.vtk file (1 by default).
-onend [int]: if -mod f and -partial (15 by default).
-partial: if -mod f -> partial movie between -on and -onend (false by default).
-vmin [float]: minimum value for the data (-0.5 by default).
-vmax [float]: maximum value for the data (0.5 by default).
-diff: plot the relative perturbation of the field f, i.e. (f-f0)/f0 (false by default).
-log: plot the log of the field f, i.e. log(f) (false by default).
-cor: does the grid corotate? For now, works in pair with -isp (false by default).
-isp: is there a planet in the grid ? (false by default)
-p [1d/2d]: 1D axisymmetric radial profile or 2D field (2d by default).
-mid/-rz: 2D plot in the (R-phi) plane or in the (R-z) plane (-mid by default).
-cart/-pol: 2D plot in cartesian or polar coordinates (-cart by default).
-avr/-noavr: do we average is the 3rd dimension, i.e. vertically when -mid and azimuthally when -rz (-avr by default).
-s: do we compute streamlines? (false by default)
-stype [random/fixed/lic]: do we compute random, fixed streams, or do we use line integral convolution? (random by default)
-srmin [float]: minimum radius for streamlines computation (0.7 by default).
-srmax [float]: maximum radius for streamlines computation (1.3 by default).
-sn [int]: number of streamlines (50 by default).
-ft [float]: fontsize in the graph (11 by default).
-cmap [str]: choice of colormap for the -p 2d maps (RdYlBu_r by default).
-pbar: do we display the progress bar when -mod f? (false by default)
-multi: load and save figures in parallel when -mod f (false by default).
-cpu [int]: number of cpus if -multi (4 by default).
-l: local mode.

2. Use of the local mode

Run the following command to copy the default config.toml file to the current working directory.

$ nonos -l

You can then edit it directly, and change the parameters. Then run again:

$ nonos -l

3. Programmatic usage

Here are some example Python scripts using nonos' api.

Example of field

from nonos import InitParamNonos, FieldNonos

init = InitParamNonos(info=True) #info=True gives the default parameters in the param file config.toml
fieldon = FieldNonos(init, field='RHO', on=25, diff=True)

Example of plot without streamlines

import matplotlib.pyplot as plt
from nonos import InitParamNonos, PlotNonos

init = InitParamNonos()
ploton = PlotNonos(init, field='RHO', on=25, diff=True)

fig, ax = plt.subplots()
ploton.plot(ax, cartesian=True)
plt.show()

Example of (R,z) plot with quiver

import matplotlib.pyplot as plt
import numpy as np
from nonos import InitParamNonos, FieldNonos, PlotNonos, StreamNonos


init = InitParamNonos(isPlanet=True, corotate=True)

ploton = PlotNonos(init, field='RHO', on=25, diff=True)
streamon = StreamNonos(init, on=25)
vx1on = FieldNonos(init, field='VX1', on=25)
vr = vx1on.data
vx2on = FieldNonos(init, field='VX3', on=25)
vz = vx2on.data

fig, ax = plt.subplots()
ploton.plot(ax, vmin=-0.15, vmax=0.15, midplane=False, cartesian=True, fontsize=8)
Z,R = np.meshgrid(ploton.zmed, ploton.xmed)
ax.quiver(R[:,::2], Z[:,::2], vr[:,ploton.ny//2,::2], vz[:,ploton.ny//2,::2])
plt.show()

Example of plot with streamlines with a planet

import matplotlib.pyplot as plt
from nonos import InitParamNonos, FieldNonos, PlotNonos, StreamNonos

init = InitParamNonos(isPlanet=True, corotate=True)

ploton = PlotNonos(init, field='RHO', on=25, diff=True)
streamon = StreamNonos(init, on=25)
vx1on = FieldNonos(init, field='VX1', on=25, diff=False, log=False)
vr = vx1on.data
vx2on = FieldNonos(init, field='VX2', on=25, diff=False, log=False)
vphi = vx2on.data
vphi -= vx2on.omegaplanet[25]*vx2on.xmed[:,None,None]
streams = streamon.get_random_streams(vr,vphi,xmin=0.7,xmax=1.3, n=30)

fig, ax = plt.subplots()
ploton.plot(ax, cartesian=True, fontsize=8)
streamon.plot_streams(ax,streams, cartesian=True, color='k', linewidth=2, alpha=0.5)
plt.show()

Example of plot with a comparison between several simulations

import matplotlib.pyplot as plt
from nonos import InitParamNonos, PlotNonos

dirpath = ['path_to_dir1', 'path_to_dir2', 'path_to_dir3']

fig, axes = plt.subplots(figsize=(9,2.5), ncols=len(dirpath))
plt.subplots_adjust(left=0.05, right=0.94, top=0.95, bottom=0.1, wspace=0.4)

for dirp, ax in zip(dirpath, axes):
    init = InitParamNonos(directory=dirp)
    ploton = PlotNonos(init, field='RHO', on=10, diff=True, directory=dirp)
    ploton.plot(ax, cartesian=True, fontsize=6)

plt.show()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonos-0.1.1.tar.gz (34.3 kB view details)

Uploaded Source

Built Distribution

nonos-0.1.1-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

Details for the file nonos-0.1.1.tar.gz.

File metadata

  • Download URL: nonos-0.1.1.tar.gz
  • Upload date:
  • Size: 34.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for nonos-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a101de3893b8d392690542cdf7b4e9070c0ecf65d8b677d0deb4d622caf45f17
MD5 ac36131ac9df81d0b2f183b0329350e3
BLAKE2b-256 1cf5ea0875e8fe936217a8b5b6482355c01a5b0314ba5368791ed6c88c5d5aa6

See more details on using hashes here.

File details

Details for the file nonos-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: nonos-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for nonos-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f732d2709743dcdd2442a871cad06477d2cd1266a25a73824a83f17ff5d05625
MD5 e297769a1947f968e547e57fe46619f9
BLAKE2b-256 31c506b8ae7b49cc8e9cbd50a8664d6c104438aa9e22fbfce166bc4b7da3ca8f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page