跳转到主要内容

用于分析idefix/pluto模拟结果(特别是用于原行星盘)的工具

项目描述

nonos

PyPI Documentation Status pre-commit.ci status Ruff

nonos是一个用于行星-盘数值模拟的二维可视化命令行应用程序,也是一个Python库。它使用来自普鲁托和Idefix的vtk格式数据,以及Fargo-adsg和Fargo3D的dat格式数据。

更多信息,请参阅文档!

数据格式

我们在此列出接受的数据格式:Pluto和Idefix:data.****.vtk Fargo-adsg:gasdens.dat,gasvy*.dat,gasvx*.dat Fargo3D:与Fargo-adsg相同 + gasvz*.dat

:construction: 此项目和文档处于建设中 :construction

正在进行的工作

  • 球坐标
  • nonos的api

安装

:warning: Nonos需要Python 3.8或更高版本。最简单的安装方法是

$ pip install nonos

使用方法

在命令行中

nonos CLI从以下三个来源获取其参数

  • 命令行参数
  • 配置文件
  • 默认值

命令行参数优先于配置文件,配置文件本身优先于默认值。

要获取帮助,请运行

$ nonos --help
usage: nonos [-h] [-dir DATADIR] [-field FIELD]
             [-geometry {polar,cylindrical,spherical,cartesian}]
             [-operation {vm,vp,vz,lt,lp,aa,ap,apl,rr} [{vm,vp,vz,lt,lp,aa,ap,apl,rr} ...]]
             [-plane PLANE [PLANE ...]] [-corotate COROTATE] [-range RANGE [RANGE ...]]
             [-vmin VMIN] [-vmax VMAX] [-theta THETA] [-z Z] [-phi PHI]
             [-distance DISTANCE] [-cpu NCPU] [-on ON [ON ...] | -all] [-diff] [-log]
             [-pbar] [-scaling SCALING] [-cmap CMAP] [-title TITLE]
             [-uc UNIT_CONVERSION] [-fmt FORMAT] [-dpi DPI] [-input INPUT | -isolated]
             [-d | -version | -logo | -config] [-v]

Analysis tool for idefix/pluto/fargo3d simulations (in polar coordinates).

options:
  -h, --help            show this help message and exit
  -dir DATADIR          location of output files and param files (default: '.').
  -field FIELD          name of field to plot (default: 'RHO').
  -geometry {polar,cylindrical,spherical,cartesian}
                        if the geometry of idefix outputs is not recognized (default:
                        'unset').
  -operation {vm,vp,vz,lt,lp,aa,ap,apl,rr} [{vm,vp,vz,lt,lp,aa,ap,apl,rr} ...]
                        operation to apply to the fild (default: 'unset').
  -plane PLANE [PLANE ...]
                        abscissa and ordinate of the plane of projection (default:
                        'unset'), example: r phi
  -corotate COROTATE    planet number that defines with which planet the grid corotates.
  -range RANGE [RANGE ...]
                        range of matplotlib window (default: unset), example: x x -2 2
  -vmin VMIN            min value (default: unset)
  -vmax VMAX            max value (default: unset)
  -theta THETA          if latitudinal operation (default: unset)
  -z Z                  if vertical operation (default: unset)
  -phi PHI              if azimuthal operation (default: unset)
  -distance DISTANCE    if radial operation (default: unset)
  -cpu NCPU, -ncpu NCPU
                        number of parallel processes (default: 1).
  -on ON [ON ...]       output number(s) (on) to plot. This can be a single value or a
                        range (start, end, [step]) where both ends are inclusive.
                        (default: last output available).
  -all                  save an image for every available snapshot (this will force
                        show=False).
  -scaling SCALING      scale the overall sizes of features in the graph (fonts,
                        linewidth...) (default: 1).
  -cmap CMAP            choice of colormap for the 2D maps (default: 'RdYlBu_r').
  -title TITLE          name of the field in the colorbar for the 2D maps (default:
                        'unset').
  -uc UNIT_CONVERSION, -unit_conversion UNIT_CONVERSION
                        conversion factor for the considered quantity (default: '1').
  -fmt FORMAT, -format FORMAT
                        select output image file format (default: unset)
  -dpi DPI              image file resolution (default: 200)

boolean flags:
  -diff                 plot the relative perturbation of the field f, i.e. (f-f0)/f0.
  -log                  plot the log10 of the field f, i.e. log(f).
  -pbar                 display a progress bar

CLI-only options:
  -input INPUT, -i INPUT
                        specify a configuration file.
  -isolated             ignore any existing 'nonos.ini' file.
  -d, -display          open a graphic window with the plot (only works with a single
                        image)
  -version, --version   show raw version number and exit
  -logo                 show Nonos logo with version number, and exit.
  -config               show configuration and exit.
  -v, -verbose, --verbose
                        increase output verbosity (-v: info, -vv: debug).

-operation 命令允许您选择对数据应用的操作,可以根据操作与 -z-theta-phi-distance 配对。

  • vm:垂直于中平面
  • vz:垂直于z,可以与-z配合使用以给出垂直切片的纬度。
  • vp:垂直投影,可以与-z配合使用以给出垂直积分的间隔。
  • lt:纬度在θ,可以与-theta配合使用以给出进行纬度切片的纬度。
  • lp:纬度投影,可以与-theta配合使用以给出纬度积分的间隔。
  • ap:方位在φ,可以与-phi配合使用以给出进行方位切片的方位。
  • apl:方位在行星,必须与-corotate配合使用以在行星方位进行切片。
  • aa:方位平均
  • rr:径向在r,可以与-distance配合使用以给出进行径向切片的距离。您可以累积一些操作,例如lpaa,例如对于-field=RHO给出气体表面密度。

注意,对于旧的idefix输出,您需要添加-geometry命令来处理数据。

使用配置文件

如果存在,CLI将读取本地文件nonos.ini中的参数,或者使用-i/-input参数指定的任何其他名称。要忽略任何现有的nonos.ini文件,请使用-isolated标志。

配置nonos的一种方法是通过

$ nonos -config

打印当前配置到stdout。然后您可以将其重定向以获取一个可工作的配置文件,如下所示:

$ nonos -config > nonos.ini

此方法也可以用于从命令行参数存储完整的配置文件。

$ nonos -ncpu 8 -cmap viridis -operation vm -diff -vmin=-10 -vmax=+100 -config

从nonos 0.7.0版本开始,这将打印

# Generated with nonos 0.7.0
datadir            .
field              RHO
operation          vm
theta              unset
z                  unset
phi                unset
distance           unset
geometry           unset
on                 unset
diff               True
log                False
range              unset
vmin               -1e1
vmax               1e2
plane              unset
progressBar        False
corotate           unset
ncpu               8
scaling            1
cmap               viridis
title              unset
unit_conversion    1
format             unset
dpi                200

程序性使用

from nonos.api import GasDataSet
import matplotlib.pyplot as plt

plt.close("all")
# We use GasDataSet which takes as argument the output number of the output file given by idefix/pluto/fargo
# contains in particular a dictionary with the different fields.
ds = GasDataSet(43, geometry="polar", directory="nonos/tests/data/idefix_planet3d")
# We select the GasField "RHO", then
# we perform a vertical slice in the midplane,
# and make the result plotable in the xy plane,
# rotating the grid given the planet number 0
# (which orbit is described in the planet0.dat file).
dsop = ds["RHO"].vertical_at_midplane().map("x", "y", planet_corotation=0)
fig, ax = plt.subplots()
# dsop is now a Plotable object.
# We represent its log10, with a given colormap,
# and we display the colorbar by adding the argument title.
dsop.plot(fig, ax, log=True, cmap="inferno", title=r"$\rho_{\rm mid}$")
ax.set_aspect("equal")

# This time, we perform a latitudinal projection,
# i.e. the integral of "RHO" between -theta and theta,
# and then an azimuthal average,
# before mapping it in the radial ("R") direction.
dsop = ds["RHO"].latitudinal_projection(theta=3*0.05).azimuthal_average().map("R")
fig, ax = plt.subplots()
# We display the y-axis by adding the argument title.
dsop.plot(fig, ax, c="k", title=r"$\Sigma$")
plt.show()

重新使用nonos样式

需要matplotlib >= 3.7

nonos CLI使用一个自定义样式,可以通过matplotlib API重新使用,而无需导入包

import matplotlib.pyplot as plt
plt.style.use("nonos.default")

有关更多信息,请参阅matplotlib.style文档

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

nonos-0.17.tar.gz (70.5 kB 查看散列值)

上传时间

构建分布

nonos-0.17-py3-none-any.whl (63.8 kB 查看散列值)

上传时间 Python 3

由以下支持