Comments (12)
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.
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.
Actually that would not work; I'm raising an error
from fitsio.
Dustin, Can you please post one of these bad files somewhere?
from fitsio.
Sure -- sorry for not including one in my original report
http://skyservice.pha.jhu.edu/CasJobsOutput/FITS/MyTable_dstn.fit
from fitsio.
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.
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.
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.
by "try again" I mean git pull and try the new version
from fitsio.
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.
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.
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)
- pkg_resources is deprecated HOT 2
- Efficient "where" when iterating or slicing HOT 5
- HDU.write_keys() appends new cards instead of replacing existing string cards
- Return requested row order rather than sorted
- Bug when installing fitsio in one of the new Apple M2 Max HOT 18
- 1.1.9 segfaults in test_table_read_write() on i586 HOT 3
- Image return None value HOT 13
- cfitsio build failure HOT 8
- GZIP_2 does not appear to do lossless compression HOT 4
- lossless gzip not finalizing wile FITS object is open
- Please consider forwarding cfitsio adjustments to upstream HOT 2
- Consider support for `numpy` 2 variable length string `StringDType`
- move to ruff for linter in order to help flag numpy2 issues HOT 1
- Build failures against NumPy 2.0 with GCC 14 HOT 8
- 1.2.2 on pypi? HOT 4
- fitsio error while pip installing HOT 5
- bzip and curl checks don't seem to be working
- CFITSIO changed license: incompatible with GPL HOT 14
- Error when using pip install for fitsio HOT 5
- Error when install fitsio on linux, both 'pip install fitsio' and 'python setup.py install' failed. HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fitsio.