JuliaAstro / WCSLIB.jl

Deprecated wcslib wrapper. Use WCS.jl instead.
MIT License
1 stars 6 forks source link

Convenience function: FITSHeader -> wcsprm #2

Open mweastwood opened 9 years ago

mweastwood commented 9 years ago

Something like the following would be a nice convenience function.

function wcsprm(header::FITSHeader)
    naxis   = header["NAXIS"]
    equinox = header["EQUINOX"]
    specsys = header["SPECSYS"]
    ctype = ASCIIString[]
    crpix = Float64[]
    crval = Float64[]
    cdelt = Float64[]
    cunit = ASCIIString[]
    for i = 1:naxis
        push!(ctype,header["CTYPE$i"])
        push!(crpix,header["CRPIX$i"])
        push!(crval,header["CRVAL$i"])
        push!(cdelt,header["CDELT$i"])
        push!(cunit,header["CUNIT$i"])
    end 
    wcsprm(naxis;
           equinox=equinox, specsys=specsys,
           ctype=ctype, crpix=crpix, crval=crval,
           cdelt=cdelt, cunit=cunit)
end
kbarbary commented 9 years ago

Perhaps this sort of thing would belong more in a hypothetical higher-level WCS package. I'm not sure what @nolta's vision here is, but I could imagine WCSLIB.jl being limited to a direct wrapper for the C library. A higher level package could use WCSLIB underneath, but present a more Julian interface and add WCS-related functionality missing in WCSLIB.

I don't have a strong opinion though.

nolta commented 9 years ago

@kbarbary Sounds fine by me.

kbarbary commented 9 years ago

@nolta The higher-level package sounds fine, or adding this method to WCSLIB sounds fine? (or both?)

nolta commented 9 years ago

The former, although both are fine with me. The latter has the minor downside that WCSLIB would then depend on FITSIO.

kbarbary commented 9 years ago

Good point about dependence on FITSIO, which would be a minor annoyance even for a higher-level package. It sounds like Julia may one day have "optional" requirements for some package functionality, which would be nice for this sort of thing.

I would go ahead and create a WCS.jl package, except that I don't currently have any plans to work on it. I'm also worried that it would create confusion for users about which package to use. I'll think about it a bit more.

mweastwood commented 9 years ago

Maybe it makes sense to rename WCSLIB.jl to WCS.jl and include a higher-level interface? FITSIO.jl supplies a reasonable high-level interface despite nominally being a wrapper of cfitsio.

kbarbary commented 9 years ago

That would be my preference. Reducing the potential for package confusion is why I added the high-level interface directly to FITSIO.jl rather than creating a separate package.