{ "info": { "author": "Chris Beaumont", "author_email": "cbeaumont@cfa.harvard.edu", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3" ], "description": "# ModestImage\n\n\n*Friendlier matplotlib interaction with large images*\n\nModestImage extends the matplotlib AxesImage class, and avoids\nunnecessary calculation and memory when rendering large images (where most\nimage pixels aren't visible on the screen). It has the following\nbenefits over AxesImage:\n\n * Draw time is (roughly) independent of image size\n * Large ``numpy.memmap`` arrays can be visualized, without making an\n in-memory copy of the entire array. This enables visualization of\n images too large to fit in memory.\n\n## Installation\n\n```\npip install ModestImage\n```\nor\n```\neasy_install ModestImage\n```\n\n## Using ModestImage\n\n\nThe easiest way is to use the modified ``imshow`` function:\n\n```\nimport matplotlib.pyplot as plt\nfrom modest_image import ModestImage, imshow\n\nax = plt.gca()\nimshow(ax, image_array, vmin=0, vmax=10)\nplt.show()\n```\n\n``imshow`` accepts all the keyword arguments that the matplotlib\nfunction does. The ``vmin`` and ``vmax`` keywords aren't necessary\nbut, if they are not provided, the entire image will be scanned to\ndetermine the min/max values. This can be slow if the array is huge.\n\nTo create a ModestImage artist directly:\n\n```\nartist = ModestImage(data=array)\n```\n\n## Looking at very big FITS images\n\n\n```\nimport matplotlib.pyplot as plt\nimport pyfits\nfrom modest_image import imshow\n\nax = plt.gca()\nhuge_array = pyfits.open('file_name.fits', memmap=True)[0].data\nartist = imshow(ax, huge_array, vmin=0, vmax=10)\nplt.show()\n```\n\nThis opens almost instantly, with a modest memory footprint.\n\n## Why is Matplotlib Image Drawing Slow?\n\n\nFor the first draw request after setting the color mapping or data\narray, AxesImage (the default matplotlib image class) calculates the\nRGBA value for every pixel in the data array. That's a lot of work for\nlarge images, and usually overkill given that the final rendering is\nlimited by screen resolution (usually 100K-1M pixels) and not image\nresolution (often much more).\n\nAxesImage compensates for this by saving the results of this\nscaling. This means that subsequent renderings that only change the\nposition or zoom level are very fast. However, in interactive\nsituations where the data array or intensity scale change often,\nAxesImage wastes lots of time calculating RGBA values for every pixel\nin a (potentially large) data set. It also makes several temporary\narrays with size comparable to the original array, wasting memory.\n\n## How is ModestImage faster?\n\nModestImage resamples the image array at each draw request, extracting\na smaller image whose resolution and extent are matched to the screen\nresolution. Thus, the RGBA scaling step is much faster, since it takes\nplace only for pixels relevant for the current rendering.\n\nThis scheme does not take advantage of AxesImage's caching, and thus\nredraws after move and zoom operations are slightly slower. However,\ndraws after colormap and data changes are substantially faster, and most\nredraws are fast enough for interactive use.\n\n## Performance and Tests\n\n``speed_test.py`` compares the peformance of ModestImage and\nAxesImage. For a 1000x1000 pixel image:\n\n```\n Performace Tests for AxesImage\n\n time_draw: 186 ms per operation\n time_move: 19 ms per operation\n time_move_zoom: 28 ms per operation\n\n Performace Tests for ModestImage\n\n time_draw: 25 ms per operation\n time_move: 20 ms per operation\n time_move_zoom: 28 ms per operation\n```\n\n``time_draw`` is the render time after the cache has been cleared\n(e.g. after ``set_data`` has been called, or the colormap has been\nchanged). ModestImage is slightly slower than, though still\ncompetetive with, AxesImage for move and zoom operations where\nAxesImage uses cached data.\n\nUnit tests can be found in the ``tests`` directory. ModestImage does not\nalways produce results identical to AxesImage at the pixel level, due to\nhow it downsamples images. The discrepancy is minor, however, and disappears\nif no downsampling takes place (i.e. a screen pixel samples <= 1 data pixel)\n", "description_content_type": "", "docs_url": null, "download_url": "http://github.com/ChrisBeaumont/mpl-modest-image", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "ModestImage", "package_url": "https://pypi.org/project/ModestImage/", "platform": "", "project_url": "https://pypi.org/project/ModestImage/", "project_urls": { "Download": "http://github.com/ChrisBeaumont/mpl-modest-image" }, "release_url": "https://pypi.org/project/ModestImage/0.2/", "requires_dist": null, "requires_python": "", "summary": "Friendlier matplotlib interaction with large images", "version": "0.2" }, "last_serial": 4752348, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "58cc9b44472bda358484bb5cb03757af", "sha256": "f1c296d0058abbc633a5c9a6c5c9f9884824615da203600ff493d5c38d0ed359" }, "downloads": -1, "filename": "ModestImage-0.1.tar.gz", "has_sig": false, "md5_digest": "58cc9b44472bda358484bb5cb03757af", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6501, "upload_time": "2014-05-08T19:48:42", "url": "https://files.pythonhosted.org/packages/16/38/68ce9477625d2126e9455897809e08e98d266a0ab438c15ed8f99fc884b7/ModestImage-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "ea18e252831ebfba3e98b84a464ae344", "sha256": "4b71af469f0c4ba73a915c6a96040cc54e81c9ce0c793e6d3e6bb72a99cb53dc" }, "downloads": -1, "filename": "ModestImage-0.2.tar.gz", "has_sig": false, "md5_digest": "ea18e252831ebfba3e98b84a464ae344", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7458, "upload_time": "2019-01-28T23:05:55", "url": "https://files.pythonhosted.org/packages/18/fb/dd00478d57d6e70950831c936f5fa225f65a4241bd920c10b3b4cba5916d/ModestImage-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ea18e252831ebfba3e98b84a464ae344", "sha256": "4b71af469f0c4ba73a915c6a96040cc54e81c9ce0c793e6d3e6bb72a99cb53dc" }, "downloads": -1, "filename": "ModestImage-0.2.tar.gz", "has_sig": false, "md5_digest": "ea18e252831ebfba3e98b84a464ae344", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7458, "upload_time": "2019-01-28T23:05:55", "url": "https://files.pythonhosted.org/packages/18/fb/dd00478d57d6e70950831c936f5fa225f65a4241bd920c10b3b4cba5916d/ModestImage-0.2.tar.gz" } ] }