Skip to content

Commit 4e293da

Browse files
authored
Merge pull request #233 from JuliaAstro/fixup
add WCS dep
2 parents eb12cee + 6038146 commit 4e293da

File tree

5 files changed

+56
-33
lines changed

5 files changed

+56
-33
lines changed

.github/workflows/CI.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ jobs:
2626
os:
2727
- ubuntu-latest
2828
- macOS-latest
29-
- macOS-13
3029
- windows-latest
3130
arch:
3231
- default

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ WCSExt = "WCS"
2121
CFITSIO = "1.7.0"
2222
Printf = "<0.0.1, 1"
2323
Tables = "1"
24+
WCS = "0.6.3"
2425
julia = "1.10"

src/header.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@
66
# Used here and in other files. Functions that operate on FITSFile
77
# start with `fits_`.
88

9+
"""
10+
FITSHeader(cards::AbstractVector{<:NamedTuple})
11+
12+
Construct a [`FITSHeader`](@ref) from a vector of `NamedTuples` with the following fields: `key`, `value`, and `comment`.
13+
14+
# Examples
15+
16+
```jldoctest
17+
julia> using FITSIO
18+
19+
julia> FITSHeader([
20+
(key = "Key1", value = 1.0, comment = "Comment1"),
21+
(key = "Key2", value = "one", comment = "Comment2"),
22+
])
23+
Key1 = 1.0 / Comment1
24+
Key2 = 'one ' / Comment2
25+
```
26+
"""
927
FITSHeader(cards::AbstractVector{<:NamedTuple}) = FITSHeader(
1028
map(x -> x.key, cards),
1129
map(x -> x.value, cards),

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ParallelTestRunner = "d3525ed8-44d0-4b2c-a655-542cee43accc"
77
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
88
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
99
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
10+
WCS = "15f3aee2-9e10-537f-b834-a6fb8bdb944d"
1011

1112
[sources]
1213
FITSIO = {path = ".."}

test/test_wcs.jl

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using WCS: WCSTransform
2+
using FITSIO: fitswrite, read_header
23

34
@testset "WCS handling" begin
45
# Create sample fits data
@@ -10,41 +11,44 @@ using WCS: WCSTransform
1011
crval = [0., -90],
1112
pv = [(2, 1, 45.0)],
1213
)
14+
1315
header_wcs = FITSHeader(wcs)
1416

15-
# Check output
16-
header_default_str = """SIMPLE = T / file does conform to FITS standard
17-
BITPIX = 64 / number of bits per data pixel
18-
NAXIS = 2 / number of data axes
19-
NAXIS1 = 2 / length of data axis 1
20-
NAXIS2 = 2 / length of data axis 2
21-
EXTEND = T / FITS dataset may contain extensions
22-
COMMENT FITS (Flexible Image Transport System) format is defined in 'Astronom
23-
COMMENT and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H
24-
"""
17+
@test header_wcs isa FITSHeader
18+
19+
# TODO: Too brittle between *nix and Windows. Tracking in https://github.com/JuliaAstro/FITSIO.jl/issues/234
20+
#header_default_str = """SIMPLE = T / file does conform to FITS standard
21+
# BITPIX = 64 / number of bits per data pixel
22+
# NAXIS = 2 / number of data axes
23+
# NAXIS1 = 2 / length of data axis 1
24+
# NAXIS2 = 2 / length of data axis 2
25+
# EXTEND = T / FITS dataset may contain extensions
26+
# COMMENT FITS (Flexible Image Transport System) format is defined in 'Astronom
27+
# COMMENT and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H
28+
# """
2529

26-
header_wcs_str = """WCSAXES = '2 ' / Number of coordinate axes
27-
CRPIX1 = '-234.7500' / Pixel coordinate of reference point
28-
CRPIX2 = '8.3393 ' / Pixel coordinate of reference point
29-
CDELT1 = '-0.066667' / [deg] Coordinate increment at reference point
30-
CDELT2 = '0.066667' / [deg] Coordinate increment at reference point
31-
CUNIT1 = 'deg ' / Units of coordinate increment and value
32-
CUNIT2 = 'deg ' / Units of coordinate increment and value
33-
CTYPE1 = 'RA---AIR' / Right ascension, Airys zenithal projection
34-
CTYPE2 = 'DEC--AIR' / Declination, Airys zenithal projection
35-
CRVAL1 = '0.0 ' / [deg] Coordinate value at reference point
36-
CRVAL2 = '-90.0 ' / [deg] Coordinate value at reference point
37-
PV2_1 = '45.0 ' / AIR projection parameter
38-
LONPOLE = '180.0 ' / [deg] Native longitude of celestial pole
39-
LATPOLE = '-90.0 ' / [deg] Native latitude of celestial pole
40-
MJDREF = '0.0 ' / [d] MJD of fiducial time
41-
RADESYS = 'ICRS ' / Equatorial coordinate system
42-
COMMENT WCS header keyrecords produced by WCSLIB 7.7"""
30+
#header_wcs_str = """WCSAXES = '2 ' / Number of coordinate axes
31+
# CRPIX1 = '-234.7500' / Pixel coordinate of reference point
32+
# CRPIX2 = '8.3393 ' / Pixel coordinate of reference point
33+
# CDELT1 = '-0.066667' / [deg] Coordinate increment at reference point
34+
# CDELT2 = '0.066667' / [deg] Coordinate increment at reference point
35+
# CUNIT1 = 'deg ' / Units of coordinate increment and value
36+
# CUNIT2 = 'deg ' / Units of coordinate increment and value
37+
# CTYPE1 = 'RA---AIR' / Right ascension, Airys zenithal projection
38+
# CTYPE2 = 'DEC--AIR' / Declination, Airys zenithal projection
39+
# CRVAL1 = '0.0 ' / [deg] Coordinate value at reference point
40+
# CRVAL2 = '-90.0 ' / [deg] Coordinate value at reference point
41+
# PV2_1 = '45.0 ' / AIR projection parameter
42+
# LONPOLE = '180.0 ' / [deg] Native longitude of celestial pole
43+
# LATPOLE = '-90.0 ' / [deg] Native latitude of celestial pole
44+
# MJDREF = '0.0 ' / [d] MJD of fiducial time
45+
# RADESYS = 'ICRS ' / Equatorial coordinate system
46+
# COMMENT WCS header keyrecords produced by WCSLIB 7.7"""
4347

44-
@test string(header_wcs) == header_wcs_str
48+
#@test string(header_wcs) == header_wcs_str
4549

46-
tempnamefits() do fname
47-
FITSIO.fitswrite(fname, img; header = header_wcs)
48-
@test string(FITSIO.read_header(fname)) == header_default_str * header_wcs_str
49-
end
50+
#tempnamefits() do fname
51+
# fitswrite(fname, img; header = header_wcs)
52+
# @test (string ∘ read_header)(fname) == header_default_str * header_wcs_str
53+
#end
5054
end

0 commit comments

Comments
 (0)