{ "info": { "author": "Canadian Astronomy Data Centre", "author_email": "cadc@nrc-cnrc.gc.ca", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: GNU Affero General Public License v3", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "cadccutout\n===============\n.. image:: https://img.shields.io/pypi/v/cadccutout.svg\n :target: https://pypi.python.org/pypi/cadcecutout\n\nCutout library written in Python that uses Astropy APIs.\n\nInstallation\n------------\n\nCan be installed using ``pip install cadccutout`` in Python 2.7 or 3.X.\n\n\nAPI\n---\n\nCutouts are performed unidirectionally, meaning the library assumes an\ninput stream that can only be read once, rather than seeking. If more\nthan one HDU was requested, then each HDU is iterated over and compared\nfrom top to bottom. Single HDU requests are shortcircuited using the\nAstropy ``astropy.io.fits.getdata()`` function\n\nPython 3.x has a potential issue when appending to an output stream\nwhere Astropy incorrectly sets a mode to prevent appending (See `Astropy\nGitHub 7856`_).\n\nExample 1\n~~~~~~~~~\n\nPerform a cutout of a file using the ``cfitsio`` cutout string format.\n\n.. code:: python\n\n import tempfile\n from cadccutout import OpenCADCCutout\n\n test_subject = OpenCADCCutout()\n output_file = tempfile.mkstemp(suffix='.fits')\n input_file = '/path/to/file.fits'\n\n # Cutouts are in cfitsio format.\n cutout_region_string = '[300:800,810:1000]' # HDU 0 along two axes.\n\n # Needs to have 'append' flag set. The cutout() method will write out the data.\n with open(output_file, 'ab+') as output_writer, open(input_file, 'rb') as input_reader:\n test_subject.cutout(input_reader, output_writer, cutout_region_string, 'FITS')\n\nExample 2 (CADC)\n~~~~~~~~~~~~~~~~\n\nPerform a cutout from an input stream from an HTTP request.\n\n.. code:: python\n\n import tempfile\n from cadccutout import OpenCADCCutout\n from cadcdata import CadcDataClient\n\n test_subject = OpenCADCCutout()\n anonSubject = net.Subject()\n data_client = CadcDataClient(anonSubject)\n output_file = tempfile.mkstemp(suffix='.fits')\n archive = 'HST'\n file_name = 'n8i311hiq_raw.fits'\n input_stream = data_client.get_file(archive, file_name)\n\n # Cutouts are in cfitsio format.\n cutout_region_string = '[SCI,10][80:220,100:150]' # SCI version 10, along two axes.\n\n # Needs to have 'append' flag set. The cutout() method will write out the data.\n with open(output_file, 'ab+') as output_writer:\n test_subject.cutout(input_stream, output_writer, cutout_region_string, 'FITS')\n\n\nCommand Line Access\n-------------------\n\nThe executable ``cadccutout`` is installed by default, or the module can be run using ``python -m cadccutout``.\n\nRunning\n~~~~~~~\n\n``cadccutout -d --infile path/to/source.fits --outfile path/to/output.fits [100:400]``\n\n``cadccutout -d --infile path/to/source.fits --outfile path/to/output.fits \"CIRCLE=10 60 0.5\"``\n\n\nRunning in Docker\n~~~~~~~~~~~~~~~~~\n\nThe provided `Dockerfile`_ can be used to build an image based on the desired\nPython version.\n\nBuild an image for Python 2.7:\n\n``docker build --build-arg PYTHON_VERSION=2.7 -t opencadc/cadccutout:2.7-alpine .``\n\nThen execute it (``/usr/src/data`` is the location of the source files). This will send the output to standard out:\n\n``docker run --rm -v $(pwd):/usr/src/data opencadc/cadccutout:2.7-alpine cadccutout --infile /usr/src/data/myfile.fits [100:400]``\n\nor\n\n``docker run --rm --mount type=bind,source=$(pwd),target=/usr/src/data opencadc/cadccutout:2.7-alpine cadccutout --infile /usr/src/data/myfile.fits [100:400]``\n\n\nBuild an image for Python 3.6:\n\n``docker build --build-arg PYTHON_VERSION=3.6 -t opencadc/cadccutout:3.6-alpine .``\n\nThen execute it (``/usr/src/data`` is the location of the source files). This will send the output to a FITS file:\n\n``docker run --rm -v $(pwd):/usr/src/data opencadc/cadccutout:3.6-alpine cadccutout --infile /usr/src/data/myfile.fits --outfile /usr/src/data/mycutout_0_100_400.fits [100:400]``\n\nor\n\n``docker run --rm --mount type=bind,source=$(pwd,target=/usr/src/data opencadc/cadccutout:3.6-alpine cadccutout --infile /usr/src/data/myfile.fits --outfile /usr/src/data/mycutout_0_100_400.fits [100:400]``\n\n\nTesting\n-------\n\nDocker\n~~~~~~\n\nThe easiest thing to do is to run it with docker. OpenCADC has an\n`AstroQuery docker image`_ available for runtime available in Python\n2.7, 3.5, 3.6, and 3.7.\n\nRun tests in Docker\n^^^^^^^^^^^^^^^^^^^\n\nYou can mount the local dev directory to the image and run the python\ntest that way. From inside the dev (working) directory:\n\nPython 3.7:\n\n``docker run --rm -v $(pwd):/usr/src/app opencadc/astroquery:3.7-alpine python setup.py test``\n\nor\n\n``docker run --rm --mount type=bind,source=$(pwd),target=/usr/src/app opencadc/astroquery:3.7-alpine python setup.py test``\n\nPython 2.7:\n\n``docker run --rm -v $(pwd):/usr/src/app opencadc/astroquery:2.7-alpine python setup.py test``\n\nor\n\n``docker run --rm --mount type=bind,source=$(pwd),target=/usr/src/app opencadc/astroquery:2.7-alpine python setup.py test``\n\n.. _Astropy GitHub 7856: https://github.com/astropy/astropy/pull/7856\n.. _AstroQuery docker image: https://hub.docker.com/r/opencadc/astroquery/\n.. _Dockerfile: ./Dockerfile", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/", "keywords": "", "license": "AGPLv3", "maintainer": "", "maintainer_email": "", "name": "cadccutout", "package_url": "https://pypi.org/project/cadccutout/", "platform": "", "project_url": "https://pypi.org/project/cadccutout/", "project_urls": { "Homepage": "http://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/" }, "release_url": "https://pypi.org/project/cadccutout/0.4.1/", "requires_dist": null, "requires_python": "", "summary": "Cutout library in Python", "version": "0.4.1" }, "last_serial": 5204410, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "284db5eb29db73690e4587b4a6374b99", "sha256": "12b413056e4deb2e3e1e6e5e95af4123315cc2ce6d1b9494a753f3351b1db576" }, "downloads": -1, "filename": "cadccutout-0.1.0.tar.gz", "has_sig": false, "md5_digest": "284db5eb29db73690e4587b4a6374b99", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3796663, "upload_time": "2018-11-16T19:48:31", "url": "https://files.pythonhosted.org/packages/77/14/756256a8042d6e344111d601b8d735661d29cc9dfb3c1476371e05403ec4/cadccutout-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "188fdea02c2c6d24e857fb067894c9cc", "sha256": "3b6b171bd2b123b863584d804fca0e74f2852fe11bc988d227dbf3118d31c29a" }, "downloads": -1, "filename": "cadccutout-0.2.0.tar.gz", "has_sig": false, "md5_digest": "188fdea02c2c6d24e857fb067894c9cc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23213, "upload_time": "2018-11-28T19:43:12", "url": "https://files.pythonhosted.org/packages/27/e3/bfb3085f1e8b17c94e8444d874492650cc865909aa9e0b4a20bc289e119e/cadccutout-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "33ddd54f39f9d2fd7d6a5e983517af1c", "sha256": "7d20ea984c82c4ff0bf3794e17c22a5cfb59ba23a1ccbbd401df29deedfa6d1d" }, "downloads": -1, "filename": "cadccutout-0.3.0.tar.gz", "has_sig": false, "md5_digest": "33ddd54f39f9d2fd7d6a5e983517af1c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23680, "upload_time": "2018-12-13T23:19:38", "url": "https://files.pythonhosted.org/packages/65/4b/213826e80b5c1ddc9882c6f1c26f1c5976138f5c1cf64e1f43d39e386fa8/cadccutout-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "e0669f4526c2e8f39d63bdf94c8db816", "sha256": "ef12aa4a722144b69124b6e762d425a00b3460cc3836e0c813fbe3a4acfbe8f5" }, "downloads": -1, "filename": "cadccutout-0.3.1.tar.gz", "has_sig": false, "md5_digest": "e0669f4526c2e8f39d63bdf94c8db816", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23763, "upload_time": "2018-12-14T21:10:52", "url": "https://files.pythonhosted.org/packages/6e/c4/b9b9ea446adc32778738c3fd1f1b117767e20bd8e8935465bc99451a6a43/cadccutout-0.3.1.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "8e98a812a339accfc0aa0d8f887dafc2", "sha256": "4f5c77a18da8a79c0ab951ef7ec43ef5154c87dcf0e46bda0583b0e71aaab67e" }, "downloads": -1, "filename": "cadccutout-0.3.3.tar.gz", "has_sig": false, "md5_digest": "8e98a812a339accfc0aa0d8f887dafc2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22914, "upload_time": "2019-03-07T18:31:20", "url": "https://files.pythonhosted.org/packages/a3/5a/5eeb1a3800636f5afeeecb4a842b9ff4bc9dfca589e131fefe2a4ad3ea8d/cadccutout-0.3.3.tar.gz" } ], "0.3.4": [ { "comment_text": "", "digests": { "md5": "b23a94bf23d14d21da6afd2b3e3b7719", "sha256": "e8944eeee5400b35b0dad0deb90ed948ff0cf66f4616bffba38c0a9f011cff43" }, "downloads": -1, "filename": "cadccutout-0.3.4.tar.gz", "has_sig": false, "md5_digest": "b23a94bf23d14d21da6afd2b3e3b7719", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22963, "upload_time": "2019-03-13T23:00:23", "url": "https://files.pythonhosted.org/packages/34/76/dff8f8da197f76111356cc55719002ab4bf766b624a390bb57fc3cdfb308/cadccutout-0.3.4.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "42e472ab7987046efbcf7c42d2276369", "sha256": "2386b4fff86c167914a1a64570033925f30384e1c3742568ce33351ccf9a56a4" }, "downloads": -1, "filename": "cadccutout-0.4.0.tar.gz", "has_sig": false, "md5_digest": "42e472ab7987046efbcf7c42d2276369", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23424, "upload_time": "2019-04-16T15:53:37", "url": "https://files.pythonhosted.org/packages/fd/6c/d8b4c61d8e0eb49bf92eb5d02395ebb02f22d4c47c5873e4df6dc25f8e74/cadccutout-0.4.0.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "2b0ac8f78690a36802bc833bc8b91a16", "sha256": "707ad1314bb5f286a54c58c27369b6a9da66741f339e3e8ceb5659849e827883" }, "downloads": -1, "filename": "cadccutout-0.4.1.tar.gz", "has_sig": false, "md5_digest": "2b0ac8f78690a36802bc833bc8b91a16", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23747, "upload_time": "2019-04-29T18:23:31", "url": "https://files.pythonhosted.org/packages/cb/6f/43d9fe14fbf10a586e0ece630eb8d10d409460d6ca6234b07222bfcecbc2/cadccutout-0.4.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2b0ac8f78690a36802bc833bc8b91a16", "sha256": "707ad1314bb5f286a54c58c27369b6a9da66741f339e3e8ceb5659849e827883" }, "downloads": -1, "filename": "cadccutout-0.4.1.tar.gz", "has_sig": false, "md5_digest": "2b0ac8f78690a36802bc833bc8b91a16", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23747, "upload_time": "2019-04-29T18:23:31", "url": "https://files.pythonhosted.org/packages/cb/6f/43d9fe14fbf10a586e0ece630eb8d10d409460d6ca6234b07222bfcecbc2/cadccutout-0.4.1.tar.gz" } ] }