ndradex

:zap: Multidimensional RADEX calculator

https://github.com/astropenguin/ndradex

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
    1 of 2 committers (50.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (17.9%) to scientific vocabulary

Keywords

astronomy python radex radio-astronomy xarray
Last synced: 6 months ago · JSON representation ·

Repository

:zap: Multidimensional RADEX calculator

Basic Info
Statistics
  • Stars: 9
  • Watchers: 1
  • Forks: 5
  • Open Issues: 3
  • Releases: 13
Topics
astronomy python radex radio-astronomy xarray
Created about 7 years ago · Last pushed 7 months ago
Metadata Files
Readme License Citation

README.md

ndRADEX

Release Python Downloads DOI Tests

Multidimensional grid RADEX calculator

Overview

ndRADEX is a Python package which can run RADEX, non-LTE molecular radiative transfer code, with multiple grid parameters. The output will be multidimensional arrays provided by xarray, which would be useful for parameter search of physical conditions in comparison with observed values.

Features

  • Grid calculation: ndRADEX has a simple run() function, where all parameters of RADEX can be griddable (i.e., they can be list-like with length of more than one).
  • Builtin RADEX: ndRADEX provides builtin RADEX binaries in the package, which are automatically downloaded and built on the first import. This also enables us to do RADEX calculations in the cloud such as Google Colaboratory.
  • Multiprocessing: ndRADEX supports multiprocessing RADEX run by default. At least twice speedup is expected compared to single processing.
  • Handy I/O: The output of ndRADEX is a xarray's Dataset, a standard multidimensional data structure as well as pandas. You can handle it in the same manner as NumPy and pandas (i.e., element-wise operation, save/load data, plotting, etc).

Requirements

  • Python 3.8-3.11 (tested by the author)
  • gfortran (necessary to build RADEX)

Installation

You can install ndRADEX with pip:

shell $ pip install ndradex

Usages

Within Python, import the package like:

```python

import ndradex ```

Single RADEX calculation

The main function of ndRADEX is ndradex.run(). For example, to get RADEX results of CO(1-0) with kinetic temperature of 100.0 K, CO column density of 1e15 cm^-2, and H2 density of 1e3 cm^-3:

```python

ds = ndradex.run("co.dat", "1-0", 100.0, 1e15, 1e3) ```

where "co.dat" is a name of LAMDA datafile and "1-0" is a name of transition. The available values are listed in List of available LAMDA datafiles and transitions. Note that you do not need to any download datafiles: ndRADEX automatically manage this.

In this case, other parameters like line width, background temperature are default values defined in the function. The geometry of escape probability is uniform ("uni") by default. You can change these values with custom config (see customizations below).

The output is a xarray's Dataset with no dimension:

```python

print(ds) Dimensions: () Coordinates: QNul <U3 '1-0' Tkin int64 100 Nmol float64 1e+15 nH2 float64 1e+03 Tbg float64 2.73 dv float64 1.0 geom <U3 'uni' description <U9 'LAMDA(CO)' Data variables: Eu float64 5.5 freq float64 115.3 wavel float64 2.601e+03 Tex float64 132.5 tau float64 0.009966 Tr float64 1.278 popu float64 0.4934 popl float64 0.1715 I float64 1.36 F float64 2.684e-08 ```

You can access each result value like:

```python

flux = ds["F"].values ```

Grid RADEX calculation

As a natural extension, you can run grid RADEX calculation like:

```python

ds = ndradex.run("co.dat", ["1-0", "2-1"], Tkin=[100.0, 200.0, 300.0], Nmol=1e15, n_H2=[1e3, 1e4, 1e5, 1e6, 1e7]) ```

There are 13 parameters which can be griddable: QN_ul (transition name), T_kin (kinetic temperature), N_mol (column density), n_H2 (H2 density), n_pH2 (para-H2 density), n_oH2 (ortho-H2 density), n_e (electron density), n_H (atomic hydrogen density), n_He (Helium density), n_Hp (ionized hydrogen density), T_bg (background temperature), dv (line width), and geom (photon escape geometry).

The output of this example is a xarray's Dataset with three dimensions of (QN_ul, T_kin, n_H2):

```python

print(ds) Dimensions: (QNul: 2, Tkin: 3, nH2: 5) Coordinates: * QNul (QNul) <U3 '1-0' '2-1' * Tkin (Tkin) int64 100 200 300 Nmol float64 1e+15 * nH2 (nH2) float64 1e+03 1e+04 1e+05 1e+06 1e+07 Tbg float64 2.73 dv float64 1.0 geom <U3 'uni' description <U9 'LAMDA(CO)' Data variables: Eu (QNul, Tkin, nH2) float64 5.5 5.5 5.5 5.5 ... 16.6 16.6 16.6 freq (QNul, Tkin, nH2) float64 115.3 115.3 115.3 ... 230.5 230.5 wavel (QNul, Tkin, nH2) float64 2.601e+03 2.601e+03 ... 1.3e+03 Tex (QNul, Tkin, nH2) float64 132.5 -86.52 127.6 ... 316.6 301.6 tau (QNul, Tkin, nH2) float64 0.009966 -0.005898 ... 0.0009394 Tr (QNul, Tkin, nH2) float64 1.278 0.5333 ... 0.3121 0.2778 popu (QNul, Tkin, nH2) float64 0.4934 0.201 ... 0.04972 0.04426 popl (QNul, Tkin, nH2) float64 0.1715 0.06286 ... 0.03089 0.02755 I (QNul, Tkin, nH2) float64 1.36 0.5677 ... 0.3322 0.2957 F (QNul, Tkin, nH2) float64 2.684e-08 1.12e-08 ... 4.666e-08 ```

For more information, run help(ndradex.run) to see the docstrings.

Save and load results

You can save and load the dataset like:

```python

save results to a netCDF file

ndradex.save_dataset(ds, "results.nc")

load results from a netCDF file

ds = ndradex.load_dataset("results.nc") ```

Customization

For the first time you import ndRADEX, the custom configuration file is created as ~/.config/ndradex/config.toml. By editing this, you can customize the following two settings of ndRADEX. Note that you can change the path of configuration directory by setting an environment variable, NDRADEX_DIR.

Changing default values

As mentioned above, you can change the default values of the run() function like:

```toml

config.toml

[defaults] Tbg = 10.0 # change default background temp to 10.0 K geom = "lvg" # change default geometry to LVG timeout = 60.0 nprocs = 8 ```

You can also change the number of multiprocesses (n_procs) and timeout (timeout) here.

Setting datafile aliases

Sometimes datafile names are not intuitive (for example, name of CS datafile is cs@lique.dat). For convenience, you can define aliases of datafile names like:

```toml

config.toml

[lamda.aliaes] CS = "cs@lique.dat" CO = "~/your/local/co.dat" H13CN = "https://home.strw.leidenuniv.nl/~moldata/datafiles/h13cn@xpol.dat" ```

As shown in the second and third examples, you can also specify a local file path or a URL on the right hand. After the customization, you can use these aliases in the run() function:

```python

ds = ndradex.run("CS", "1-0", ...) # equiv to cs@lique.dat ```

Owner

  • Name: Akio Taniguchi
  • Login: astropenguin
  • Kind: user
  • Location: Nagoya, Japan
  • Company: Nagoya University

Project assistant professor (LMT-FINER)

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."

title: "ndradex"
abstract: "Multidimensional grid RADEX calculator"
version: 0.3.1
date-released: 2023-05-19
license: "MIT"
doi: "10.5281/zenodo.3384031"
url: "https://github.com/astropenguin/ndradex"
authors:
  - given-names: "Akio"
    family-names: "Taniguchi"
    affiliation: "Nagoya University"
    orcid: "https://orcid.org/0000-0002-9695-6183"

GitHub Events

Total
  • Issues event: 9
  • Watch event: 1
  • Delete event: 6
  • Issue comment event: 1
  • Push event: 15
  • Pull request event: 12
  • Fork event: 1
  • Create event: 3
Last Year
  • Issues event: 9
  • Watch event: 1
  • Delete event: 6
  • Issue comment event: 1
  • Push event: 15
  • Pull request event: 12
  • Fork event: 1
  • Create event: 3

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 204
  • Total Committers: 2
  • Avg Commits per committer: 102.0
  • Development Distribution Score (DDS): 0.01
Top Committers
Name Email Commits
Akio Taniguchi t****i@a****p 202
dependabot[bot] 4****]@u****m 2
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 36
  • Total pull requests: 49
  • Average time to close issues: 10 months
  • Average time to close pull requests: 4 months
  • Total issue authors: 5
  • Total pull request authors: 2
  • Average comments per issue: 0.31
  • Average comments per pull request: 0.31
  • Merged pull requests: 29
  • Bot issues: 0
  • Bot pull requests: 21
Past Year
  • Issues: 2
  • Pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 2
  • Pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 1
Top Authors
Issue Authors
  • astropenguin (36)
  • pirg (2)
  • travisthieme (1)
  • mgsantamaria (1)
  • MIriamastro (1)
Pull Request Authors
  • astropenguin (33)
  • dependabot[bot] (27)
Top Labels
Issue Labels
feature (28) release (5) bug (4) environment (3)
Pull Request Labels
feature (21) dependencies (17) bug (5) release (4) environment (2)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 46 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 14
  • Total maintainers: 1
pypi.org: ndradex

Multidimensional grid RADEX calculator

  • Versions: 14
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 46 Last month
Rankings
Dependent packages count: 10.1%
Forks count: 15.3%
Stargazers count: 19.3%
Average: 20.6%
Dependent repos count: 21.6%
Downloads: 36.9%
Maintainers (1)
Last synced: 6 months ago

Dependencies

poetry.lock pypi
  • appdirs 1.4.4 develop
  • appnope 0.1.0 develop
  • atomicwrites 1.4.0 develop
  • attrs 20.2.0 develop
  • backcall 0.2.0 develop
  • black 20.8b1 develop
  • bleach 3.2.1 develop
  • click 7.1.2 develop
  • colorama 0.4.3 develop
  • dataclasses 0.6 develop
  • decorator 4.4.2 develop
  • docutils 0.16 develop
  • flake8 3.8.3 develop
  • iniconfig 1.0.1 develop
  • ipykernel 5.3.4 develop
  • ipython 7.16.1 develop
  • ipython-genutils 0.2.0 develop
  • jedi 0.17.2 develop
  • jupyter-client 6.1.7 develop
  • jupyter-core 4.6.3 develop
  • mccabe 0.6.1 develop
  • mypy-extensions 0.4.3 develop
  • packaging 20.4 develop
  • parso 0.7.1 develop
  • pathspec 0.8.0 develop
  • pexpect 4.8.0 develop
  • pickleshare 0.7.5 develop
  • pkginfo 1.5.0.1 develop
  • pluggy 0.13.1 develop
  • prompt-toolkit 3.0.3 develop
  • ptyprocess 0.6.0 develop
  • py 1.9.0 develop
  • pycodestyle 2.6.0 develop
  • pyflakes 2.2.0 develop
  • pygments 2.7.1 develop
  • pyparsing 2.4.7 develop
  • pytest 6.1.0 develop
  • pywin32 228 develop
  • pyzmq 19.0.2 develop
  • readme-renderer 26.0 develop
  • regex 2020.9.27 develop
  • requests-toolbelt 0.9.1 develop
  • rfc3986 1.4.0 develop
  • tornado 6.0.4 develop
  • traitlets 4.3.3 develop
  • twine 3.2.0 develop
  • typed-ast 1.4.1 develop
  • typing-extensions 3.7.4.3 develop
  • wcwidth 0.2.5 develop
  • astropy 4.0.1.post1
  • astroquery 0.4.1
  • beautifulsoup4 4.9.2
  • certifi 2020.6.20
  • cffi 1.14.3
  • cftime 1.2.1
  • chardet 3.0.4
  • cryptography 3.1.1
  • html5lib 1.1
  • idna 2.10
  • importlib-metadata 2.0.0
  • jeepney 0.4.3
  • keyring 21.4.0
  • netcdf4 1.5.4
  • numpy 1.19.2
  • pandas 0.25.3
  • pycparser 2.20
  • python-dateutil 2.8.1
  • pytz 2020.1
  • pywin32-ctypes 0.2.0
  • requests 2.24.0
  • secretstorage 3.1.2
  • six 1.15.0
  • soupsieve 2.0.1
  • toml 0.10.1
  • tqdm 4.50.0
  • urllib3 1.25.10
  • webencodings 0.5.1
  • xarray 0.15.1
  • zipp 3.2.0
pyproject.toml pypi
  • black ^20.8b develop
  • flake8 ^3.8 develop
  • ipykernel ^5.3 develop
  • ipython ^7.16 develop
  • pytest ^6.0 develop
  • twine ^3.2 develop
  • astropy ^4.0
  • astroquery ^0.4
  • netcdf4 ^1.5
  • numpy ^1.18
  • pandas >=0.25, <1.2
  • python ^3.6
  • toml ^0.10
  • tqdm ^4.41
  • xarray ^0.15
.github/workflows/pypi.yaml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/tests.yaml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.devcontainer/Dockerfile docker
  • python 3.11-slim build