{"id":17113010,"url":"https://github.com/emmt/easyfits.jl","last_synced_at":"2025-04-09T20:33:44.915Z","repository":{"id":71510216,"uuid":"217003177","full_name":"emmt/EasyFITS.jl","owner":"emmt","description":"Using FITS files made easier for Julia","archived":false,"fork":false,"pushed_at":"2024-11-06T11:17:47.000Z","size":1126,"stargazers_count":9,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-23T22:34:39.262Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emmt.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2019-10-23T08:09:30.000Z","updated_at":"2024-11-06T11:17:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"61ac8f66-c09d-4891-b7db-a2ff19bdd952","html_url":"https://github.com/emmt/EasyFITS.jl","commit_stats":{"total_commits":284,"total_committers":2,"mean_commits":142.0,"dds":"0.035211267605633756","last_synced_commit":"5bfa5e2797fbf7a18c38ce49189a390d2e213e0d"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emmt%2FEasyFITS.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emmt%2FEasyFITS.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emmt%2FEasyFITS.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emmt%2FEasyFITS.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emmt","download_url":"https://codeload.github.com/emmt/EasyFITS.jl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248107859,"owners_count":21049022,"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","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-14T17:02:18.471Z","updated_at":"2025-04-09T20:33:44.883Z","avatar_url":"https://github.com/emmt.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Easy reading/writing of FITS files in Julia\n\n[![Doc][doc-dev-img]][doc-dev-url]\n[![License][license-img]][license-url]\n[![Build Status](https://github.com/emmt/EasyFITS.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/emmt/EasyFITS.jl/actions/workflows/CI.yml?query=branch%3Amain)\n[![Build Status](https://ci.appveyor.com/api/projects/status/github/emmt/EasyFITS.jl?svg=true)](https://ci.appveyor.com/project/emmt/EasyFITS-jl)\n[![Coverage](https://codecov.io/gh/emmt/EasyFITS.jl/graph/badge.svg?token=7QTvjQqn5O)](https://codecov.io/gh/emmt/EasyFITS.jl)\n\n`EasyFITS` is a [Julia](https://julialang.org/) package designed to make it easier to read\nand write data in [FITS](https://fits.gsfc.nasa.gov/fits_standard.html) format without\nsacrificing performances, flexibility, or readability.\n\n\n## A few examples\n\nThe full documentation is available [on-line][doc-dev-url].\n\nThe *Flexible Image Transport System* (or\n[FITS](https://fits.gsfc.nasa.gov/fits_standard.html) for short) is a file\nformat widely used in Astronomy to store many kinds of data (images, tables,\netc.) and metadata. FITS files consist in a concatenation of Header Data Units\n(HDUs) which each have a header part followed by a data part.\n\nThe following example demonstrates how to write a FITS file with 3 HDUs, an\n*Image Extension* and two *Table Extensions*:\n\n```julia\nusing Dates, EasyFITS\nfilename = \"/tmp/test.fits\";\narr = rand(Float32, (3,4,5));\nnrows = 20;\ninds = 1:nrows;\nspeed = rand(Float64, nrows);\nmass = rand(Float32, nrows);\nposition = rand(Float32, 3, nrows);\nphase = (1:7) .// 3;\namplitude = exp.(-1:-1:-7);\nx = amplitude.*cos.(phase);\ny = amplitude.*sin.(phase);\nwritefits(filename,\n          #-----------------------------------------------------------------\n          # First HDU must be a FITS \"image\", but data may be empty.\n          #\n          # Header part as a vector of `key=\u003eval` or `key=\u003e(val,com)` pairs:\n          [\"DATE\"    =\u003e (now(), \"date of creation\"),\n           \"HISTORY\" =\u003e \"This file has been produced by EasyFITS\",\n           \"USER\"    =\u003e ENV[\"USER\"]],\n          # Data part as an array:\n          arr,\n          #-----------------------------------------------------------------\n          # Second HDU, here a FITS \"table\".\n          #\n          # Header part of 2nd HDU as a tuple of pairs:\n          (\"EXTNAME\" =\u003e (\"MY-EXTENSION\", \"Name of this extension\"),\n           \"EXTVER\"  =\u003e (1, \"Version of this extension\")),\n          # Data part is a table in the form of a named tuple:\n          (Speed    = (speed, \"km/s\"),  # this column has units\n           Indices  = inds,             # not this one\n           Mass     = (mass, \"kg\"),\n           Position = (position, \"cm\")),\n          #-----------------------------------------------------------------\n          # Third HDU, another FITS \"table\".\n          #\n          # Header part of 3rd HDU as a named tuple (note that keywords must\n          # be in uppercase letters):\n          (EXTNAME = (\"MY-OTHER-EXTENSION\", \"Name of this other extension\"),\n           EXTVER  = (1, \"Version of this other extension\"),\n           COMMENT = \"This is an interesting comment\"),\n          # Data part is a table in the form of a vector of pairs (column names\n          # can be strings or symbols but not a mixture):\n          [:phase =\u003e ((180/π).*phase, \"deg\"),\n           :amplitude =\u003e (amplitude, \"V\"),\n           :xy =\u003e (hcat(x,y)', \"V\")])\n```\n\nEach HDU has a header part (the metadata) and a data part which is reflected by the pairs\nof arguments after`filename`, the name of the file, in the above call to `writefits`. The\nheaders are provided by collections (a vector for the 1st one, a tuple for the 2nd one) of\npairs or by a named tuples (3rd one) associating a keyword with a value and a comment\n(both optional). In a FITS *Image Extension*, the data can be any real-valued Julia array.\nIn a FITS *Table Extension* , the data part is provided by a collection of column names\nassociated with columns values and optional units. The columns in a FITS table must have\nthe same trailing dimension (interpreted as the rows of the table) but may have different\nleading dimensions corresponding to the sizes of the column cells. In the above example,\nthe `\"Position\"` column has 3 values per cell (presumably the 3D coordinates), while other\ncolumns have a single value per cell. Note that the 1st HDU, so-called *Primary HDU*, of a\nFITS file must be a *Fits Image* (possibly empty), not a *FITS Table*.\n\nTo read the headers of the 1st and 2nd HDU of the file:\n\n```julia\nhdr1 = read(FitsHeader, filename)\nhdr2 = read(FitsHeader, filename, ext=2)\n```\n\nyield two instance of `FitsHeader`. Reading the data parts is very easy:\n\n```julia\ndat1 = readfits(filename)\ndat2 = readfits(filename, ext=2)\n```\n\nwill yield an array `dat1` equal to `arr` and a dictionary `dat2` indexed by the column\nnames (in uppercase letters by default). For example:\n\n``` julia\ndat2[\"SPEED\"] == speed\n```\n\nshould hold.\n\n\n## Installation\n\nThe easiest way to install `EasyFITS` is via Julia registry\n[`EmmtRegistry`](https://github.com/emmt/EmmtRegistry):\n\n```julia\nusing Pkg\npkg\"registry add General\"\npkg\"registry add https://github.com/emmt/EmmtRegistry\"\npkg\"add EasyFITS\"\n```\n\nAdding the `General` registry (2nd line of the above example) is mandatory to have access\nto the official Julia packages if you never have used the package manager before.\n\n\n## Related projects\n\nThe [FITSIO](https://github.com/JuliaAstro/FITSIO.jl) package is another alternative to\nread/write FITS files. `EasyFITS` is no longer based on `FITSIO` and now exploits\n[Clang.jl](https://github.com/JuliaInterop/Clang.jl) to directly call the functions of the [CFITSIO](https://github.com/JuliaAstro/CFITSIO.jl) library\nand [`FITSHeaders`](https://github.com/emmt/FITSHeaders.jl) to parse metadata (FITS header\ncards).\n\n\n[doc-stable-img]: https://img.shields.io/badge/docs-stable-blue.svg\n[doc-stable-url]: https://emmt.github.io/EasyFITS.jl/stable\n\n[doc-dev-img]: https://img.shields.io/badge/docs-dev-blue.svg\n[doc-dev-url]: https://emmt.github.io/EasyFITS.jl/dev\n\n[license-url]: ./LICENSE.md\n[license-img]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femmt%2Feasyfits.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femmt%2Feasyfits.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femmt%2Feasyfits.jl/lists"}