Giter Site home page Giter Site logo

Comments (12)

esheldon avatar esheldon commented on August 20, 2024

Thanks for the pointer; I should probably at least give a better error message. I'll try to give this a look later in the week.

from fitsio.

esheldon avatar esheldon commented on August 20, 2024

I added a check for tdim None. tdim None happens when a call to
fits_read_tdimll
fails.

I'm tentatively going to continue and read these as a 1-d array, although that
will be surprising for high dimension columns that were simply declared wrong.

I am printing a warning message
'Warning:',name,'has malformed TDIM, reading as 1-d array'

from fitsio.

esheldon avatar esheldon commented on August 20, 2024

Actually that would not work; I'm raising an error

from fitsio.

esheldon avatar esheldon commented on August 20, 2024

Dustin, Can you please post one of these bad files somewhere?

from fitsio.

dstndstn avatar dstndstn commented on August 20, 2024

Sure -- sorry for not including one in my original report

http://skyservice.pha.jhu.edu/CasJobsOutput/FITS/MyTable_dstn.fit

from fitsio.

esheldon avatar esheldon commented on August 20, 2024

Thanks; checking that file also prompted me to update the repr so it shows the column has a bad TDIM.

Can you check if the current behavior in master makes sense to you?

from fitsio.

dstndstn avatar dstndstn commented on August 20, 2024

uh, I get,

python -c "import fitsio; F=fitsio.FITS('MyTable_dstn.fit'); print F[1]['survey']"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/fitsio/lib/python/fitsio/fitslib.py", line 2857, in __repr__
    if len(tdim) > 1:
TypeError: object of type 'NoneType' has no len()

from fitsio.

esheldon avatar esheldon commented on August 20, 2024

Ah, yes, I had not fixed the repr in the column subset. I factored out this stuff to a function so I only need to fix this in one place now.

Can you try again when you get time?

from fitsio.

esheldon avatar esheldon commented on August 20, 2024

by "try again" I mean git pull and try the new version

from fitsio.

dstndstn avatar dstndstn commented on August 20, 2024

I get:

python -c "import fitsio; F=fitsio.FITS('MyTable_dstn.fit.1'); print 'Survey is:'; print F[1]['survey']; print F[1].read()['survey']")
Survey is:
  file: MyTable_dstn.fit.1
  extension: 1
  type: BINARY_TBL
  rows: 10
  column subset:
    survey              S1  array[bad TDIM]
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/fitsio/lib/python/fitsio/fitslib.py", line 1624, in read
    data = self.read_all(**keys)
  File "/usr/local/fitsio/lib/python/fitsio/fitslib.py", line 1756, in read_all
    dtype, offsets, isvar = self.get_rec_dtype(**keys)
  File "/usr/local/fitsio/lib/python/fitsio/fitslib.py", line 2454, in get_rec_dtype
    dt,isvar = self.get_rec_column_descr(colnum, vstorage)
  File "/usr/local/fitsio/lib/python/fitsio/fitslib.py", line 2506, in get_rec_column_descr
    shape = tdim2shape(tdim, name, is_string=(npy_type[0] == 'S'))
  File "/usr/local/fitsio/lib/python/fitsio/fitslib.py", line 2916, in tdim2shape
    raise ValueError("field '%s' has malformed TDIM" % name)
ValueError: field 'survey' has malformed TDIM

from fitsio.

esheldon avatar esheldon commented on August 20, 2024

Yes, that is the intended error. Do you think the behavior should be different? One possibility is to fall back to reading it into a 1-d array column.

from fitsio.

dstndstn avatar dstndstn commented on August 20, 2024

Ok, that's totally reasonable. The fallback would be handy in this case, but since the work-around is so easy (just remove the TDIM from the input to make it valid FITS), I wouldn't spend any time on it if I were you.

Thanks again!

from fitsio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.