{ "info": { "author": "Adam Ginsburg & Julia Kamenetzky", "author_email": "adam.g.ginsburg@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "Python RADEX interface\n======================\n\nA wrapper for RADEX (www.sron.rug.nl/~vdtak/radex/) in python.\n\nAs of v0.2, created October 26, 2013, this package includes both a python\nwrapper of the command-line program and a direct wrapper of the fortran code\ncreated with f2py.\n\nInstallation procedure for the f2py-wrapped version\n---------------------------------------------------\n\nYou need to have `gfortran` and `f2py` on your path. If you've successfully\nbuilt numpy from source, you should have both.\n\nAll you need to do is:\n\n.. code-block:: bash\n\n $ python setup.py install_radex install\n\nThis will call a procedure `install_radex` that downloads the latest version of\nRADEX from the radex homepage, patches the source, and builds a file `radex.so`,\nwhich is a python shared object that can be imported. \n\nSee the install_ page for more details.\n\nIf you want pyradex to look in a specific directory for the molecular data\nfiles, you can specify an environmental variable `RADEX_DATAPATH` prior to\nstarting python. It can also be specified interactively with the `datapath`\nkeyword.\n\n\nUsing the f2py-wrapped version\n------------------------------\n\nThe direct wrapper of the fortran code uses a class `Radex` as its underlying\nstructure. This class is useful for direct manipulation of RADEX inputs and\ndirect access to its outputs.\n\nExample:\n\n.. code-block:: python\n\n import pyradex\n import numpy as np\n R = pyradex.Radex()\n Tlvg = R(collider_densities={'oH2':900,'pH2':100}, column=1e16, species='co',method='lvg')\n Tslab = R(collider_densities={'oH2':900,'pH2':100}, column=1e16, species='co',method='slab')\n Tsphere = R(collider_densities={'oH2':900,'pH2':100}, column=1e16, species='co',method='sphere')\n Tlvg[:3].pprint()\n Tslab[:3].pprint()\n Tsphere[:3].pprint()\n\nResult::\n \n Tex tau frequency upperstateenergy upperlevel lowerlevel upperlevelpop lowerlevelpop flux\n ------------- -------------- ----------- ---------------- ---------- ---------- ---------------- --------------- -----------------\n 15.2747101724 0.937692338925 115.2712018 5.53 2 1 0.273140336953 0.453621905471 2.93964536078e-14\n 10.8673211326 2.74275175782 230.538 16.6 3 2 0.0518618367484 0.273140336953 9.26125039465e-14\n 8.30670325364 2.01021823976 345.7959899 33.19 4 3 0.00379591658449 0.0518618367484 8.16324298598e-14\n Tex tau frequency upperstateenergy upperlevel lowerlevel upperlevelpop lowerlevelpop flux\n ------------- -------------- ----------- ---------------- ---------- ---------- ---------------- -------------- -----------------\n 17.8076937528 0.681341951256 115.2712018 5.53 2 1 0.312979158313 0.394862780876 2.89304678735e-14\n 14.8865118666 1.96024230849 230.538 16.6 3 2 0.102821702575 0.312979158313 1.38012283784e-13\n 11.448407058 2.03949857132 345.7959899 33.19 4 3 0.00920322307626 0.102821702575 1.6139902821e-13\n Tex tau frequency upperstateenergy upperlevel lowerlevel upperlevelpop lowerlevelpop flux\n ------------- ------------- ----------- ---------------- ---------- ---------- ---------------- -------------- -----------------\n 14.38256087 1.06765591906 115.2712018 5.53 2 1 0.243400727834 0.480559204909 2.93394133644e-14\n 9.28920337666 3.1666639484 230.538 16.6 3 2 0.037299201561 0.243400727834 7.24810556601e-14\n 7.50189023571 1.84556901411 345.7959899 33.19 4 3 0.00307839203073 0.037299201561 6.19215196139e-14\n\n \nNote that because of how RADEX was written, i.e. with common blocks, the values\nstored in each of these objects is identical! You cannot have two independent\ncopies of the RADEX class *ever*.\n\nRecommended installation procedure for the command-line version\n---------------------------------------------------------------\n\n1. `make` radex as normal, but create two executables: `radex_sphere`, `radex_lvg`, and `radex_slab` by\n building with one of these three lines commented out each time::\n\n c parameter (method = 1) ! uniform sphere\n parameter (method = 2) ! expanding sphere (LVG)\n c parameter (method = 3) ! plane parallel slab (shock)\n\n2. Copy these to your system path\n3. `python setup.py install` to install pyradex\n\n\nSimple example\n--------------\nUsing some trivial defaults::\n\n In [1]: import pyradex\n\n In [2]: T = pyradex.radex(collider_densities={'H2':1000})\n WARNING: Assumed thermal o/p ratio since only H2 was given but collider file has o- and p- H2 [pyradex.core]\n\n In [3]: T.pprint(show_units=True)\n J_up J_low E_UP FREQ WAVE T_EX TAU T_R POP_UP POP_LOW FLUX_Kkms FLUX_Inu\n K GHz um K K K km / s erg / (cm2 s)\n ---- ----- ---- -------- --------- ----- --------- ------- ------ ------- --------- -------------\n 1 0 5.5 115.2712 2600.7576 5.044 0.0004447 0.00086 0.4709 0.47 0.0009155 1.806e-11\n\n In [4]: T.meta\n Out[4]:\n {'Column density [cm-2]': '1.000E+12',\n 'Density of H2 [cm-3]': '1.000E+03',\n 'Density of oH2 [cm-3]': '3.509E-04',\n 'Density of pH2 [cm-3]': '1.000E+03',\n 'Geometry': 'Uniform sphere',\n 'Line width [km/s]': '1.000',\n 'Molecular data file': '/Users/adam/repos/Radex/data/co.dat',\n 'Radex version': '20nov08',\n 'T(background) [K]': '2.730',\n 'T(kin) [K]': '10.000'}\n\n\n\n\nTiming information\n------------------\ni.e., how fast is it?::\n\n %timeit T = pyradex.radex(collider_densities={'H2':1000})\n 1 loops, best of 3: 149 ms per loop\n\n\n for n in 10**np.arange(6):\n %timeit T = pyradex.radex(collider_densities={'H2':n})\n\n 10 loops, best of 3: 149 ms per loop\n 10 loops, best of 3: 150 ms per loop\n 10 loops, best of 3: 149 ms per loop\n 10 loops, best of 3: 151 ms per loop\n 10 loops, best of 3: 150 ms per loop\n 10 loops, best of 3: 149 ms per loop\n\n for n in 10**np.arange(12,18):\n ....: %timeit T = pyradex.radex(collider_densities={'H2':1000}, column_density=n)\n\n 10 loops, best of 3: 149 ms per loop\n 10 loops, best of 3: 149 ms per loop\n 10 loops, best of 3: 149 ms per loop\n 10 loops, best of 3: 150 ms per loop\n 10 loops, best of 3: 152 ms per loop\n 10 loops, best of 3: 157 ms per loop\n \nThese results indicate that, even in highly optically thick cases where more\niterations are required, the execution time is dominated by the python\noverheads.\n\nIf you redo these tests comparing the fortran wrapper to the \"naive\" version,\nthe difference is enormous. The following tests can be seen in `timing.py\n`__:\n\n::\n\n Python: 0.892609834671\n Fortran: 0.0151958465576\n py/fortran: 58.7403822016\n Python: 0.902825832367\n Fortran: 0.0102920532227\n py/fortran: 87.7206727205\n Python: 0.876524925232\n Fortran: 0.0730140209198\n py/fortran: 12.0048850096\n Python: 0.836034059525\n Fortran: 0.0925290584564\n py/fortran: 9.03536762906\n Python: 0.880390882492\n Fortran: 0.0725519657135\n py/fortran: 12.1346248008\n Python: 0.96048283577\n Fortran: 0.0753719806671\n py/fortran: 12.7432346512\n \n\nMaking Grids\n------------\nIs more efficient with scripts, but you can still do it... ::\n\n for n in 10**np.arange(12,18):\n T = pyradex.radex(collider_densities={'H2':1000}, column_density=n)\n T.pprint()\n \n Row# Line# E_UP FREQ WAVE T_EX TAU T_R POP_UP POP_LOW FLUX_Kkms FLUX_Inu\n ---- ----- ---- -------- --------- ----- --------- ------- ------ ------- --------- ---------\n 1 0 5.5 115.2712 2600.7576 5.044 0.0004447 0.00086 0.4709 0.47 0.0009155 1.806e-11\n Row# Line# E_UP FREQ WAVE T_EX TAU T_R POP_UP POP_LOW FLUX_Kkms FLUX_Inu\n ---- ----- ---- -------- --------- ----- -------- -------- ------ ------- --------- ---------\n 1 0 5.5 115.2712 2600.7576 5.047 0.004444 0.008589 0.471 0.4698 0.009143 1.803e-10\n Row# Line# E_UP FREQ WAVE T_EX TAU T_R POP_UP POP_LOW FLUX_Kkms FLUX_Inu\n ---- ----- ---- -------- --------- ----- ------- ------- ------ ------- --------- ---------\n 1 0 5.5 115.2712 2600.7576 5.075 0.04415 0.08473 0.4721 0.4681 0.0902 1.779e-09\n Row# Line# E_UP FREQ WAVE T_EX TAU T_R POP_UP POP_LOW FLUX_Kkms FLUX_Inu\n ---- ----- ---- -------- --------- ----- ------ ------ ------ ------- --------- ---------\n 1 0 5.5 115.2712 2600.7576 5.336 0.4152 0.7475 0.4817 0.4527 0.7957 1.569e-08\n Row# Line# E_UP FREQ WAVE T_EX TAU T_R POP_UP POP_LOW FLUX_Kkms FLUX_Inu\n ---- ----- ---- -------- --------- ----- ----- ---- ------ ------- --------- ---------\n 1 0 5.5 115.2712 2600.7576 6.929 2.927 3.49 0.5057 0.3745 3.715 7.327e-08\n Row# Line# E_UP FREQ WAVE T_EX TAU T_R POP_UP POP_LOW FLUX_Kkms FLUX_Inu\n ---- ----- ---- -------- --------- ----- ----- ---- ------ ------- --------- ---------\n 1 0 5.5 115.2712 2600.7576 9.294 18.09 5.96 0.4696 0.2839 6.345 1.252e-07\n\nIf you want to create a grid with the directly wrapped version, do loops with\nconstant temperature: every time you load a new temperature, RADEX must read in\nthe molecular data file and interpolate across the collision rate values, which\nmay be a substantial overhead.\n\nIf you want to build a grid, *do not* make an astropy table each time! That\nappears to dominate the overhead at each iteration.\n\nA note on self-consistency in LVG calculations\n----------------------------------------------\n\nLVG computations have weird units. The opacity of a line only depends on the\nvelocity-coherent column along the line of sight, i.e. the column per km/s.\n\nThe key assumption in the LVG Sobolev approximation is that each \"cell\" can be\ntreated independently such that there are no nonlocal radiative effects.\n\nThis independence implies that there is a separation between the local volume\ndensity and the total line-of-sight column density.\n\nHowever, the quantities reported by typical codes - RADEX, DESPOTIC - are\nintegrated line-of-sight values. The column density, abundance, and local\nvolume density are not independent, then.\n\nIn order to have a self-consistent cloud (or line of sight), you must assume\nsome length scale. Usually, one specifies a velocity gradient per length scale\nrather than an absolute length scale, but the length scale is important.\n\nIf a total column density of hydrogen `N(H)` is specified along with a density\n`n(H)`, the length scale is trivial: `N(H)/n(H) = L`. If you increase the\ndensity, this length scale decreases - so far all is fine.\n\nWithin RADEX, the standard free variable is the column of the molecule of\ninterest. \nIf you change the column of the molecule, which is possible to do explicitly,\nand hold everything else fixed in RADEX (`n(H)`, `dV`), the change can be\ninterpreted as a change in the size scale or the column.\n\nOne could consider the alternative possibility of treating the length scale as\na free parameter, but this approach contains a danger of changing the\ninterpretation of the processes involved: if the length scale is decreased for\na fixed delta-V, the velocity gradient `dv/dl` must be larger. This\ninterpretation should be avoided as it bears the risk of breaking the LVG\nassumption. The velocity gradient is also often an imposed constraint via the\nobserved linewidth, while the length scale is only weakly constrained in most\nsituations.\n\nIn DESPOTIC, the free variables are the total column density, the density,\nthe abundance, and the velocity gradient. Length is therefore left as the\ndependent variable, consistent with the above.\n\nThe Classes (`Despotic` & `Radex`) are constructed such that length is a\ndependent variables and all the others can be changed. Since abundance is not\nan explicit input into RADEX, this is done with some property machinery behind\nthe scenes.\n \n\n.. image:: https://d2weczhvl823v0.cloudfront.net/keflavich/pyradex/trend.png\n :alt: Bitdeli badge\n :target: https://bitdeli.com/free\n\n.. _install: install.rst", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/keflavich/pyradex/", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "pyradex", "package_url": "https://pypi.org/project/pyradex/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pyradex/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/keflavich/pyradex/" }, "release_url": "https://pypi.org/project/pyradex/0.2.2/", "requires_dist": null, "requires_python": null, "summary": "Python-RADEX", "version": "0.2.2" }, "last_serial": 2203716, "releases": { "0.2": [ { "comment_text": "built for Darwin-13.0.2", "digests": { "md5": "3b6cc622f641f0800551913774f94e45", "sha256": "de3a05280f76052dbef65e910658fc9fd069a468ebba530e6e148559666a15a5" }, "downloads": -1, "filename": "pyradex-0.2.macosx-10.6-intel.tar.gz", "has_sig": false, "md5_digest": "3b6cc622f641f0800551913774f94e45", "packagetype": "bdist_dumb", "python_version": "any", "requires_python": null, "size": 122675, "upload_time": "2014-02-23T11:57:41", "url": "https://files.pythonhosted.org/packages/48/a7/120ada3a17d33bc3def36261db82be0a351f87a21954507a380f1545f37f/pyradex-0.2.macosx-10.6-intel.tar.gz" }, { "comment_text": "", "digests": { "md5": "6da09b2a19a53b349ef04a09789f48c0", "sha256": "92a511f4f874d896ae31cd99bfd6e6f9e0318b81695b30a3e957e0c9d5baead2" }, "downloads": -1, "filename": "pyradex-0.2.tar.gz", "has_sig": false, "md5_digest": "6da09b2a19a53b349ef04a09789f48c0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18751, "upload_time": "2014-02-23T11:57:48", "url": "https://files.pythonhosted.org/packages/23/f8/30a443f358e219fc22c633d71bcd6ba07ffd9dd45cbeb53a849daa12ff60/pyradex-0.2.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "72b2e4676246ae94b29accc6defbb5d0", "sha256": "2660d63644f2798f145e7b584652481a92c4b5290c044a8c7973b8a403c85dfb" }, "downloads": -1, "filename": "pyradex-0.2.1.tar.gz", "has_sig": false, "md5_digest": "72b2e4676246ae94b29accc6defbb5d0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 109590, "upload_time": "2014-05-29T11:50:15", "url": "https://files.pythonhosted.org/packages/d1/a0/70e28667abce69e7a0e69041c29bb5f298a2436de5d707ed5719f7f7bb95/pyradex-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "92aa5ca8c5d1a305136784591b8aec7a", "sha256": "64369521e6672f6ed9db170040e336db74fa3dc7cb5c871b3efcdddb4f2d2e15" }, "downloads": -1, "filename": "pyradex-0.2.2.tar.gz", "has_sig": false, "md5_digest": "92aa5ca8c5d1a305136784591b8aec7a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 111026, "upload_time": "2014-08-27T12:25:32", "url": "https://files.pythonhosted.org/packages/be/d1/5ec9765ea27f823cecd142af20c99af6501071faf6fbc9bbb15303309e7b/pyradex-0.2.2.tar.gz" } ], "0.4.2dev": [ { "comment_text": "", "digests": { "md5": "44d2168d603ee603e5b2c98159df6b2a", "sha256": "aea2b85681dad8e27a986aeb2554b97423f07030e81a419ddb7bfb9a70c76302" }, "downloads": -1, "filename": "pyradex-0.4.2dev.tar.gz", "has_sig": false, "md5_digest": "44d2168d603ee603e5b2c98159df6b2a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 42675, "upload_time": "2016-07-05T15:44:16", "url": "https://files.pythonhosted.org/packages/c6/9d/846443217422000ac6f4d2e66a78fe15988d48d497d625bc3dcb4cb94851/pyradex-0.4.2dev.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "92aa5ca8c5d1a305136784591b8aec7a", "sha256": "64369521e6672f6ed9db170040e336db74fa3dc7cb5c871b3efcdddb4f2d2e15" }, "downloads": -1, "filename": "pyradex-0.2.2.tar.gz", "has_sig": false, "md5_digest": "92aa5ca8c5d1a305136784591b8aec7a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 111026, "upload_time": "2014-08-27T12:25:32", "url": "https://files.pythonhosted.org/packages/be/d1/5ec9765ea27f823cecd142af20c99af6501071faf6fbc9bbb15303309e7b/pyradex-0.2.2.tar.gz" } ] }