Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error in loading a fits table as a DataFrame #182

Open
Illuminista opened this issue Feb 9, 2022 · 9 comments
Open

error in loading a fits table as a DataFrame #182

Illuminista opened this issue Feb 9, 2022 · 9 comments

Comments

@Illuminista
Copy link

Illuminista commented Feb 9, 2022

I am a rookie but it seems that something is to working as expected

from the manual:

julia> f[2]
File: file.fits
HDU: 2
Type: Table
Rows: 20
Columns: Name  Size  Type    TFORM  
         .... ....
Table HDUs implement the [Tables.jl] interface, so you can load them into other table types, like [DataFrames].
julia> df = DataFrame(f[2])

my case:

julia> f[2]
File:XXX.fits
HDU: 2
Type: Table
Rows: 24
Columns: Name               Size  Type     TFORM  
                    col1                         Float64  D   
.... ....

julia> df=DataFrame(f[2])
ArgumentError: no default `Tables.columns` implementation for type: TableHDU

Stacktrace:
 [1] columns
   @ ~/.julia/packages/Tables/M26tI/src/fallbacks.jl:264 [inlined]
 [2] DataFrame(x::TableHDU; copycols::Nothing)
   @ DataFrames ~/.julia/packages/DataFrames/BM4OQ/src/other/tables.jl:58
 [3] DataFrame(x::TableHDU)
   @ DataFrames ~/.julia/packages/DataFrames/BM4OQ/src/other/tables.jl:49
 [4] top-level scope
   @ In[17]:1
 [5] eval
   @ ./boot.jl:373 [inlined]
 [6] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base ./loading.jl:1196
@mileslucas
Copy link
Member

Hi, thanks for the report. Can you please list your version of FITSIO.jl in this environment?

julia>] st FITSIO

@mileslucas
Copy link
Member

I just gave this a try and did not run into any issues-

(jl_K0Xnrq) pkg> st
Status `/private/var/folders/q6/j_0w4_mx13jg_7mw9__902f40000gn/T/jl_K0Xnrq/Project.toml`
  [a93c6f00] DataFrames v1.3.2
  [525bcba6] FITSIO v0.16.12

julia> using DataFrames, FITSIO

julia> hdus = FITS("https://fits.gsfc.nasa.gov/samples/WFPC2u5780205r_c0fx.fits")
File: https://fits.gsfc.nasa.gov/samples/WFPC2u5780205r_c0fx.fits
Mode: "r" (read-only)
HDUs: Num  Name                   Type
      1                           Image
      2    u5780205r_cvt.c0h.tab  ASCIITable

julia> df = DataFrame(hdus[2]);

julia> first(df, 3)
3×49 DataFrame
 Row │ CRVAL1   CRVAL2   CRPIX1   CRPIX2   CD1_1        CD1_2        CD2_1        CD2_2        DATAMI 
     │ Float64  Float64  Float64  Float64  Float64      Float64      Float64      Float64      Float6 
─────┼─────────────────────────────────────────────────────────────────────────────────────────────────
   1182.631  39.3963    420.0    424.5  -1.06704e-6  -1.25958e-5  -1.26016e-5   1.06655e-6  -73.19 
   2182.626  39.4121    423.5    414.0  -2.75605e-5   2.08221e-6   2.08021e-6   2.75871e-5  -19.95
   3182.652  39.4109    436.0    424.5   2.23913e-6   2.75426e-5   2.75684e-5  -2.23704e-6  -58.53
                                                                                     41 columns omitted

@Illuminista
Copy link
Author

Illuminista commented Feb 28, 2022 via email

@Illuminista
Copy link
Author

Illuminista commented Feb 28, 2022 via email

@mileslucas
Copy link
Member

Okay, let's start with the version issue.

Can you try updating your whole environment? This should upgrade your registry.

From the REPL-mode:

julia>] up

or

julia> using Pkg
julia> Pkg.update()

Please check if this upgrades your FITSIO version. If it does not, but you see the "updating registry" message, that means some other dependency is manually restricting your FITSIO.jl version. If you do not see a message that the registry is updating, please manually try

julia>] registry up

@Illuminista
Copy link
Author

Illuminista commented Mar 1, 2022 via email

@mileslucas
Copy link
Member

mileslucas commented Mar 2, 2022

Okay, I think something is wrong with your registry, because the latest version of DustExtinction.jl (v0.11) has compatibility for FITSIO.jl v0.16.

The easiest fix is to remove the registry and let Julia fix it itself, can you give this a shot?

$ cd ~/.julia/registries
$ rm -r General*

and then from Julia (in the default, v1.7 environment)

julia>] up

@giordano
Copy link
Member

giordano commented Mar 2, 2022

Or from within julia:

]registry rm General
registry add General

@Illuminista
Copy link
Author

Illuminista commented Mar 2, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants