{"id":16519866,"url":"https://github.com/zonca/cfitsio_checkpoint_write","last_synced_at":"2025-08-25T02:17:32.703Z","repository":{"id":138270572,"uuid":"317323690","full_name":"zonca/cfitsio_checkpoint_write","owner":"zonca","description":null,"archived":false,"fork":false,"pushed_at":"2020-12-01T07:33:51.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-02T23:41:31.443Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zonca.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-30T19:23:51.000Z","updated_at":"2020-12-01T07:33:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"4441e0a8-a230-4ce0-8391-b54f0927174c","html_url":"https://github.com/zonca/cfitsio_checkpoint_write","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zonca/cfitsio_checkpoint_write","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonca%2Fcfitsio_checkpoint_write","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonca%2Fcfitsio_checkpoint_write/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonca%2Fcfitsio_checkpoint_write/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonca%2Fcfitsio_checkpoint_write/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zonca","download_url":"https://codeload.github.com/zonca/cfitsio_checkpoint_write/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonca%2Fcfitsio_checkpoint_write/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271998576,"owners_count":24856063,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-25T02:00:12.092Z","response_time":1107,"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-11T16:48:45.288Z","updated_at":"2025-08-25T02:17:32.634Z","avatar_url":"https://github.com/zonca.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"CFITSIO file writing with checkpoints\n=====================================\n\n![C/C++ CI](https://github.com/zonca/cfitsio_checkpoint_write/workflows/C/C++%20CI/badge.svg)\n\nPrototype implementation and test of writing a FITS\nfile to disk and checkpointing it by flushing the contents\nto disk in order to avoid having a corrupt file in case of segfault.\n\n`fits_flush_file` allows to write a file to disk and then reopen it,\nso that in case of segmentation fault the file is not corrupt.\nHowever it can be slower, so we can just use it after writing the first\ntime, then we can switch to `fits_flush_buffer` which is quicker.\n\nIn this test case the software needs to write a datacube, it writes\na 2D slice (readout) at a time, therefore it only needs to explicitely allocate\nmemory for one 2D slice.\nHowever, `cfitsio` keeps internal buffers, therefore, calling regularly\n`fits_flush_buffer` both empties those buffers and also checkpoints the file to\ndisk.\nWe can configure independently how often we checkpoint the file but still\nhaving a single output datacube.\n\nIn this specific example, executed via Github Actions under Ubuntu, we execute:\n\n* we target a datacube (500x30x20)\n* we allocate memory for one (30x20) readout\n* we write the first readout\n* we call `fits_flush_file` to create the HDU and write the first readout\n* we write other 9 readouts for a total of 10 readouts\n* we call `fits_flush_buffer` to checkpoint the file on disk\n* we trigger a segmentation fault\n* open the output file with `astropy` and check the contents are as expected\n\nSee:\n\n* [implementation in C](src/main.c)\n* [testing program in Python](read_fits.py)\n* [output log of the execution on Github actions](https://github.com/zonca/cfitsio_checkpoint_write/actions?query=workflow%3A%22C%2FC%2B%2B+CI%22)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzonca%2Fcfitsio_checkpoint_write","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzonca%2Fcfitsio_checkpoint_write","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzonca%2Fcfitsio_checkpoint_write/lists"}