{ "info": { "author": "Chris Petrich", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Science/Research", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Scientific/Engineering :: Physics" ], "description": "# MCmodel\nA 3D Monte Carlo scattering code to keep track of individual parcels in a plane-parallel homogenous slab\n\nThe theory behind the model, many of its parameters, and model validation have been\ndescribed by Petrich et al. (2012), https://doi.org/10.1016/j.coldregions.2011.12.004\n\nThe Monte Carlo code itself is implemented in C for speed and integrated\nwith a Python interface for convenience.\n\nLicense: Apache 2.0.\n\n## Installation\n\n### Requirements\n\n* Python 2.7, 3.5, 3.6, 3.7. Should work on Linux, MacOS, \n and Windows.\n* Numpy\n* When compiling from source, a C-compiler, and typically\n setuptools and wheel.\n\n### From PyPI\n\nRun `pip install mcmodel`. Done.\nLater, upgrade with `pip install -U mcmodel`, or uninstall with \n`pip uninstall mcmodel`.\n\n### Use without installation\n\nGet the latest source code from https://github.com/cpetrich/MCmodel\nRun `python setup.py build` and copy the contents of the `built/lib.[...]`\ndirectory into the same directory as your own modeling code.\n\n### Installation with pip\n\nGet the latest source code from https://github.com/cpetrich/MCmodel\nA wheel will be built locally and installed with pip. \nBuild the module and create a wheel file\nwith `python setup.py bdist_wheel`, `cd dist`,\n`pip install mcmodel-[...].whl`. To uninstall the package later run\n`pip uninstall mcmodel`.\n\n### Test\n\nTo test the result of the build process, a rather incomplete test suite\ncan be run with `python setup.py test`.\n\n## Limitations\n\nThe code is currently not reentrant since it uses global state for the random\nnumber generator, the phase function, and buffers that hold detailed information\nabout the most recent particle track. I.e., only one instance of the model per\nprocess.\n\nThe special case - in a scattering model - of \"no scattering\" (`w0 == 0`) is\nimplemented only for `k == 0` (i.e. no absorption).\n\n\n## Usage\n\nThe usual mode of operation is:\n\n0. seed the random number generator\n1. define a scattering phase function\n2. call the scattering code with slab optical properties, and position and direction of one parcel of light\n3. store entrance and exit positions and angles of the parcel and information about plane crossings inside the medium\n4. if desired, store complete track of the light parcel\n5. continue with (2) a couple of thousand or million times.\n6. read the simulation results from disk, and determine parcel intensity due to absorption and Fresnel reflection\n7. analyze result as desired\n\nAn example of seeding the random number generator of the Monte Carlo model is\n```\nimport os\nimport mcmodel\nmcmmodel.set_seed(int.from_bytes(os.urandom(4),'little'))\n```\n\nA helper function exists to generate common scattering phase functions, e.g.\n```\nimport mcmodel_util\npf = mcmodel_util.make_phase_function('Henyey-Greenstein', (0.98, 0))\n```\n\nThe phase function is transfered to the model code like\n```\nmcmodel.define_phase_function(pf['lookup_cdf'],pf['lookup_phi'])\n```\n\nA random number generator is usually used to generate an incoming distribution\n(that random number generator is separate from the one used by the Monte Carlo\nmodel and should also be seeded).\n```\nimport random\nrandom.seed()\n```\n\nA sample from the angular distribution of a Lambert emitter\n(i.e., overcast over snow-covered ground) is\n```\nimport math\n\nelevation_angle = math.arcsin(random.uniform(-1., 0))\nazimuth = random.uniform(-math.pi, math.pi)\n```\nNote that the Monte Carlo code works in **elevation** angles. A normally\nincident beam at the upper surface of the slab has an elevation angle\nof -pi/2.\n\nThe domain parameters and incident angle are passed on to the Monte Carlo\ncode in a dictionary, e.g.\n```\nin = {'angle': elevation_angle,\n 'azimuth': azimuth,\n 'thickness': 1, # slab thickness\n 'k': 1} # densiy of microscopic interactions used by the model\n```\nwith additional optional input parameters described below. Many of the output\ndata are obtained through updates to a dictionary that is passed to the scattering\nsimulation. To calculate the track of a single parcel call\n```\nout = {}\nmcmodel.simulate(in, out)\n```\nwhere exit position and angles are\n```\nexit_position = (out['x'], out['y'], out['z'])\nexit_elevation_angle = out['angle']\nexit_azimuth = out['azimuth']\npath_length = out['path_length']\n```\n\nAttenuation of the parcel inside the medium is accounted for by decreasing its\namplitude. The precise method of this depends on the definition and units of\nthickness and microscopic extinction coefficient passed into the model above.\nHowever, the intensity of the emerging parcel will be of a form similar to\n```\nexit_intensity = math.exp(-kappa * path_length)\n```\nwhere kappa is the absorption coefficient.\n\nIntensity reduction due to Fresnel reflection (other than total reflection)\nwould be accounted for based on entrance and exit angles and relative refractive\nindices. To do this in hindsight is not trivial and requires the simulations\nto be run with a relative refractive index of 1 and appropriate scaling of\nthe input angular distribution to account for non-trivial refractive indices.\nThis is outside the scope of this overview.\n*[TODO: in a future version, add an option to have Monte Carlo model take care\nof this by selecting a path stochastically.]*\n\n### API\n\nThe C code exports currently four functions (see Usage above):\n* `mcmodel.set_seed(...)`\n* `mcmodel.define_phase_function(..., ...)`\n* `mcmodel.simulate(..., ...)`\n* `mcmodel.get_last_particle_track()`\n\nIn addion, there is one helper function defined in Python\n* `mcmodel_util.make_phase_function(...)`\n\n### Parameters\n\nThe model domain is a horizontal slab of thickness `thickness`, extending from\n`z=0` at the upper surface to `z=-thickness` at the bottom. Parcles are injected\nat depth `z=z0` (`-thickness <= z0 <= 0`) and `x=0` and `y=0`. Injection at\n`z0 = -thickness` and `z0 = 0` are on the outside of the slab at the lower and\nupper interface, respectively (i.e. still subject to refraction).\n\nIf an anisotropic scattering coefficient is used, i.e. `sigma_anisotropy != 0`,\nthen the vertical and horizontal scattering coefficients are\n`sigma_v = k * w0` and `sigma_h = k * w0 * (sigma_anisotropy+1)`, respectively.\n\n\n#### Input Dictionary of `mcmodel.simulate()`\n\nName | Default | Meaning\n-----|---------|--------\n`angle` | *none* | elevation angle of incident parcel [-pi; pi]\n`azimuth` | *none* | azimuth angle of incident parcel [-pi; pi)\n`z0` | `0` | vertial coordinate of parcel injection\n`thickness`| *none* | slab thickness\n`k` | *none* | microscopic extinction coefficient\n`w0` | `1` | single scattering albedo\n`n_surface` | `1` | refractive index `n_slab / n(z>0)`\n`n_bottom` | `1` | refractive index `n_slab / n(z<-thickness)`\n`sigma_anisotropy` | `0` | anisotropy of scattering coefficient (cf. Trodahl et al.), `sigma_anisotropy = sigma_h/sigma_v - 1`\n`do_record_track` | `False` | log coordinates of scattering the parcel. Retrieve with `mcmodel.get_last_particle_track()`\n`do_record_plane_crossings` | `False` | log position and angle of parcel every time it crosses specified planes\n`record_planes` | `[]` | list of `z` coordinates to record parcel crossings at\n\n#### Output Dictionary of `mcmodel.simulate()`\n\nName | Meaning\n-----|--------\n`angle_in` | copy of `angle` in input dictionary\n`azimuth_in` | copy of `azimuth` in input dictionary\n`angle` | exit eleation angle of parcel\n`azimuth` | exit azimuth of parcel\n`x` | lateral exit coordinate, same unit as `thickness` in input\n`y` | lateral exit coordinate, same unit as `thickness` in input\n`z` | vertical exit coordinate, same unit as `thickness` in input\n`path_length` | total path length of parcel in the medium, same unit as `thickness` in input\n`exit_direction` | `+1`: exit at `z=0`, `-1`: exit at `z=-thickness`\n`min_z` | lowest `z` coordinate along the track\n`max_R` | largest value of `sqrt( x^2 + y^2 )` along the track\n`n_collisions` | number of scattering events along the path (NB: not total reflection)\n`n_missed_collisions` | number of absorption events along the path, all of which have been ignored (count is slightly too high if `w0>0`)\n`n_refractions` | number of refractions experienced along the path\n`n_total_reflections` | number of total reflections along the path\n`n_plane_crossings` | number of plane crossing events along the path\n`plane_crossings` | 2D `numpy` array containing 6 entries (columns) per crossing event (see below)\n\nThe six column entries for each plane crossing are:\n1. elevation angle\n2. azimuth angle\n3. x-coordinate at the point of crossing\n4. y-coordinate at the point of crossing\n5. z-coordinate at the point of crossing\n6. parcel path length so far", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "mcmodel", "package_url": "https://pypi.org/project/mcmodel/", "platform": "", "project_url": "https://pypi.org/project/mcmodel/", "project_urls": null, "release_url": "https://pypi.org/project/mcmodel/3.0/", "requires_dist": null, "requires_python": "", "summary": "Monte Carlo Scattering Model", "version": "3.0" }, "last_serial": 5798228, "releases": { "3.0": [ { "comment_text": "", "digests": { "md5": "60308319073920ae81714f661f001d66", "sha256": "897dd2e8689a5445b2e3981f135533831688e60abc4ea1874f62bcf9e7abc788" }, "downloads": -1, "filename": "mcmodel-3.0-cp35-cp35m-win_amd64.whl", "has_sig": false, "md5_digest": "60308319073920ae81714f661f001d66", "packagetype": "bdist_wheel", "python_version": "cp35", "requires_python": null, "size": 27472, "upload_time": "2019-09-08T03:53:12", "url": "https://files.pythonhosted.org/packages/bb/f2/17386b402642a0ce546f9d24dcd8a06a97c2d6059b4ca94e98d42586151e/mcmodel-3.0-cp35-cp35m-win_amd64.whl" }, { "comment_text": "", "digests": { "md5": "4c2c366764929aaf4a0848ce0251817c", "sha256": "34660d2a039e188047df5158aa28b36fb7c4589daafe89b02ed6e3c09ad1acf8" }, "downloads": -1, "filename": "mcmodel-3.0-cp36-cp36m-macosx_10_13_x86_64.whl", "has_sig": false, "md5_digest": "4c2c366764929aaf4a0848ce0251817c", "packagetype": "bdist_wheel", "python_version": "cp36", "requires_python": null, "size": 30454, "upload_time": "2019-09-08T03:51:32", "url": "https://files.pythonhosted.org/packages/18/0e/8f5d1707e67c34d882db131bf5fdc39318f3b0b8d95f0fc410c6ea79e8ca/mcmodel-3.0-cp36-cp36m-macosx_10_13_x86_64.whl" }, { "comment_text": "", "digests": { "md5": "2d46a2b6ace34fd8289eb5f60860f7ae", "sha256": "a42e5e7be3848003791b1df71dded0fa4ffea3e08967891e0f5bbbae4a248c24" }, "downloads": -1, "filename": "mcmodel-3.0-cp36-cp36m-win_amd64.whl", "has_sig": false, "md5_digest": "2d46a2b6ace34fd8289eb5f60860f7ae", "packagetype": "bdist_wheel", "python_version": "cp36", "requires_python": null, "size": 27121, "upload_time": "2019-09-08T03:53:47", "url": "https://files.pythonhosted.org/packages/71/0b/58c92cdadcc49ccc548602c72f19bed7abdf9dd920c44a2a5aac8ce3ea95/mcmodel-3.0-cp36-cp36m-win_amd64.whl" }, { "comment_text": "", "digests": { "md5": "2672506da2477cb8cc8246c4e5c2af5b", "sha256": "af831486f02d8a121d17fe9552a801b21b9bb1b1c7f29fef6e753461955a694f" }, "downloads": -1, "filename": "mcmodel-3.0-cp37-cp37m-macosx_10_14_x86_64.whl", "has_sig": false, "md5_digest": "2672506da2477cb8cc8246c4e5c2af5b", "packagetype": "bdist_wheel", "python_version": "cp37", "requires_python": null, "size": 29522, "upload_time": "2019-09-08T03:52:17", "url": "https://files.pythonhosted.org/packages/3e/2a/5d99abc0d77959c9cb69df5a3c1e79ec963827b4271ae476e238430ee928/mcmodel-3.0-cp37-cp37m-macosx_10_14_x86_64.whl" }, { "comment_text": "", "digests": { "md5": "b532f6c2d1123069978a026a1d0ade28", "sha256": "3e9f22b93f7b0be4ea7d9e8005cc3cbda2dab88e786eb1df938d3266be7819c0" }, "downloads": -1, "filename": "mcmodel-3.0-cp37-cp37m-win_amd64.whl", "has_sig": false, "md5_digest": "b532f6c2d1123069978a026a1d0ade28", "packagetype": "bdist_wheel", "python_version": "cp37", "requires_python": null, "size": 27121, "upload_time": "2019-09-08T03:54:08", "url": "https://files.pythonhosted.org/packages/9d/04/3e6ed5b6b40c7576908395745596f1ba72555aaa45170458c0c3aebfdcdb/mcmodel-3.0-cp37-cp37m-win_amd64.whl" }, { "comment_text": "", "digests": { "md5": "e332166a2b3170e10381a528559170b9", "sha256": "5b82d5cfa2d7aea714d0459ff7b97a929317ec199f870f65fe9aefdd02aab3b7" }, "downloads": -1, "filename": "mcmodel-3.0.tar.gz", "has_sig": false, "md5_digest": "e332166a2b3170e10381a528559170b9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29844, "upload_time": "2019-09-08T03:49:46", "url": "https://files.pythonhosted.org/packages/e7/7d/d91878caa238e679bd145d9546b9ff4141b0218d2983fdf5ef56aac29be2/mcmodel-3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "60308319073920ae81714f661f001d66", "sha256": "897dd2e8689a5445b2e3981f135533831688e60abc4ea1874f62bcf9e7abc788" }, "downloads": -1, "filename": "mcmodel-3.0-cp35-cp35m-win_amd64.whl", "has_sig": false, "md5_digest": "60308319073920ae81714f661f001d66", "packagetype": "bdist_wheel", "python_version": "cp35", "requires_python": null, "size": 27472, "upload_time": "2019-09-08T03:53:12", "url": "https://files.pythonhosted.org/packages/bb/f2/17386b402642a0ce546f9d24dcd8a06a97c2d6059b4ca94e98d42586151e/mcmodel-3.0-cp35-cp35m-win_amd64.whl" }, { "comment_text": "", "digests": { "md5": "4c2c366764929aaf4a0848ce0251817c", "sha256": "34660d2a039e188047df5158aa28b36fb7c4589daafe89b02ed6e3c09ad1acf8" }, "downloads": -1, "filename": "mcmodel-3.0-cp36-cp36m-macosx_10_13_x86_64.whl", "has_sig": false, "md5_digest": "4c2c366764929aaf4a0848ce0251817c", "packagetype": "bdist_wheel", "python_version": "cp36", "requires_python": null, "size": 30454, "upload_time": "2019-09-08T03:51:32", "url": "https://files.pythonhosted.org/packages/18/0e/8f5d1707e67c34d882db131bf5fdc39318f3b0b8d95f0fc410c6ea79e8ca/mcmodel-3.0-cp36-cp36m-macosx_10_13_x86_64.whl" }, { "comment_text": "", "digests": { "md5": "2d46a2b6ace34fd8289eb5f60860f7ae", "sha256": "a42e5e7be3848003791b1df71dded0fa4ffea3e08967891e0f5bbbae4a248c24" }, "downloads": -1, "filename": "mcmodel-3.0-cp36-cp36m-win_amd64.whl", "has_sig": false, "md5_digest": "2d46a2b6ace34fd8289eb5f60860f7ae", "packagetype": "bdist_wheel", "python_version": "cp36", "requires_python": null, "size": 27121, "upload_time": "2019-09-08T03:53:47", "url": "https://files.pythonhosted.org/packages/71/0b/58c92cdadcc49ccc548602c72f19bed7abdf9dd920c44a2a5aac8ce3ea95/mcmodel-3.0-cp36-cp36m-win_amd64.whl" }, { "comment_text": "", "digests": { "md5": "2672506da2477cb8cc8246c4e5c2af5b", "sha256": "af831486f02d8a121d17fe9552a801b21b9bb1b1c7f29fef6e753461955a694f" }, "downloads": -1, "filename": "mcmodel-3.0-cp37-cp37m-macosx_10_14_x86_64.whl", "has_sig": false, "md5_digest": "2672506da2477cb8cc8246c4e5c2af5b", "packagetype": "bdist_wheel", "python_version": "cp37", "requires_python": null, "size": 29522, "upload_time": "2019-09-08T03:52:17", "url": "https://files.pythonhosted.org/packages/3e/2a/5d99abc0d77959c9cb69df5a3c1e79ec963827b4271ae476e238430ee928/mcmodel-3.0-cp37-cp37m-macosx_10_14_x86_64.whl" }, { "comment_text": "", "digests": { "md5": "b532f6c2d1123069978a026a1d0ade28", "sha256": "3e9f22b93f7b0be4ea7d9e8005cc3cbda2dab88e786eb1df938d3266be7819c0" }, "downloads": -1, "filename": "mcmodel-3.0-cp37-cp37m-win_amd64.whl", "has_sig": false, "md5_digest": "b532f6c2d1123069978a026a1d0ade28", "packagetype": "bdist_wheel", "python_version": "cp37", "requires_python": null, "size": 27121, "upload_time": "2019-09-08T03:54:08", "url": "https://files.pythonhosted.org/packages/9d/04/3e6ed5b6b40c7576908395745596f1ba72555aaa45170458c0c3aebfdcdb/mcmodel-3.0-cp37-cp37m-win_amd64.whl" }, { "comment_text": "", "digests": { "md5": "e332166a2b3170e10381a528559170b9", "sha256": "5b82d5cfa2d7aea714d0459ff7b97a929317ec199f870f65fe9aefdd02aab3b7" }, "downloads": -1, "filename": "mcmodel-3.0.tar.gz", "has_sig": false, "md5_digest": "e332166a2b3170e10381a528559170b9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29844, "upload_time": "2019-09-08T03:49:46", "url": "https://files.pythonhosted.org/packages/e7/7d/d91878caa238e679bd145d9546b9ff4141b0218d2983fdf5ef56aac29be2/mcmodel-3.0.tar.gz" } ] }