{"id":15735699,"url":"https://github.com/simonrw/fitsiochunked","last_synced_at":"2026-07-02T03:31:13.323Z","repository":{"id":57429802,"uuid":"51517154","full_name":"simonrw/fitsiochunked","owner":"simonrw","description":"chunked reading of large fits files, with fitsio","archived":false,"fork":false,"pushed_at":"2017-01-27T18:27:42.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-24T19:55:11.882Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonrw.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-11T13:41:56.000Z","updated_at":"2016-02-11T13:42:06.000Z","dependencies_parsed_at":"2022-08-26T02:41:58.605Z","dependency_job_id":null,"html_url":"https://github.com/simonrw/fitsiochunked","commit_stats":null,"previous_names":["mindriot101/fitsiochunked"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/simonrw/fitsiochunked","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonrw%2Ffitsiochunked","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonrw%2Ffitsiochunked/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonrw%2Ffitsiochunked/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonrw%2Ffitsiochunked/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonrw","download_url":"https://codeload.github.com/simonrw/fitsiochunked/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonrw%2Ffitsiochunked/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35032145,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-02T02:00:06.368Z","response_time":173,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-04T01:14:45.203Z","updated_at":"2026-07-02T03:31:13.297Z","avatar_url":"https://github.com/simonrw.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"===============================\nfitsiochunked\n===============================\n\n.. image:: https://img.shields.io/travis/mindriot101/fitsiochunked.svg\n        :target: https://travis-ci.org/mindriot101/fitsiochunked\n.. image:: https://codecov.io/gh/mindriot101/fitsiochunked/branch/master/graph/badge.svg\n  :target: https://codecov.io/gh/mindriot101/fitsiochunked\n\nPackage to *sequentially* efficiently read large fits arrays in object by object\n\n* Free software: MIT license\n\nFeatures\n--------\n\n* *Sequentially* read in large fits files, within a given fixed memory limit\n\nQuick usage\n-----------\n\nThe following example shows an example of reading in a large fits\nhdu within a memory limit of 2048MB, assuming light curves are\nstored in rows:\n\n.. code:: python\n\n  import numpy as np\n  import fitsio\n  import fitsiochunked as fc\n\n  with fitsio.FITS(filename) as infile:\n      hdu = infile['flux']\n      napertures = hdu.get_info()['ndim'][0]\n      mean_flux = np.zeros(napertures)\n\n      for chunk in fc.chunks(hdu, memory_limit_mb=2048):\n\n          # `chunk` is a namedtuple with `.data` and `.slice` properties\n          chunk_data = chunk.data\n          print('Data shape:', chunk_data.shape)\n          print('Data dtype:', chunk_data.dtype)\n\n\n          chunk_slice = chunk.slice\n          print('Chunk starting from aperture:', chunk_slice.start)\n          print('Chunk up to:', chunk_slice.stop)\n\n          chunk_mean = np.average(chunk_data, axis=1)\n          mean_flux[chunk_slice] = chunk_mean\n\nThe library copes with an aribtrary number of hdus:\n\n.. code:: python\n\n  import numpy as np\n  import fitsio\n  import fitsiochunked as fc\n\n  with fitsio.FITS(filename) as infile:\n      hjd_hdu = infile['hjd']\n      flux_hdu = infile['flux']\n      fluxerr_hdu = infile['fluxerr']\n\n      napertures = flux_hdu.get_info()['ndim'][0]\n      mean_flux = np.zeros(napertures)\n\n      for chunks in fc.chunks(hjd_hdu, flux_hdu, fluxerr_hdu, memory_limit_mb=2048):\n          # chunks is a tuple of chunks\n          hjd_chunk, flux_chunk, fluxerr_chunk = chunks\n\n          # `chunk` is a namedtuple with `.data` and `.slice` properties\n          flux_chunk_data = flux_chunk.data\n          print('Data shape:', flux_chunk_data.shape)\n          print('Data dtype:', flux_chunk_data.dtype)\n\n          # and so on\n\nNote: if multiple hdus are supplied, then the ``memory_limit_mb`` and\n``chunksize`` arguments to ``chunks`` apply to **each** HDU i.e. three HDUs and\na memory limit of 2048MB will lead to 3x2048 = 6144MB of memory used.\n\nInstallation\n------------\n\nInstall with ``pip``:\n\n.. code:: bash\n\n    pip install fitsiochunked\n    # or get the latest development version from github\n    pip install git+https://github.com/mindriot101/fitsiochunked\n\nor download and run the setup file:\n\n.. code:: bash\n\n    git clone https://github.com/mindriot101/fitsiochunked\n    cd fitsiochunked\n    python setup.py install\n\nDetails\n-------\n\nThe high level interface is the ``chunks`` function, which builds a\n``ChunkedAdapter`` object wrapping a ``fitsio.ImageHDU`` object.\n\nThe ``ChunkedAdapter`` wraps a ``fitsio`` HDU object. When constructed,\nit becomes a callable which yields the image data in that hdu in chunks.\n\nThe chunksize can be set either with with the parameter\n``chunksize`` which simply yields ``chunksize`` rows each time,\nor with ``memory_limit_mb`` which *tries* (no promises!) to\nautomatically calculate the number of lightcurves that will fit into\n``memory_limit_mb`` megabytes of memory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonrw%2Ffitsiochunked","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonrw%2Ffitsiochunked","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonrw%2Ffitsiochunked/lists"}