A Space & astronomy forum. SpaceBanter.com

Go Back   Home » SpaceBanter.com forum » Astronomy and Astrophysics » FITS
Site Map Home Authors List Search Today's Posts Mark Forums Read Web Partners

[fitsbits] Clarification of EXTEND, please



 
 
Thread Tools Display Modes
  #1  
Old May 14th 04, 05:31 PM
Stephen Walton
external usenet poster
 
Posts: n/a
Default [fitsbits] Clarification of EXTEND, please

Without naming names, I just today hit a conflict between two pieces of
software. One created a FITS file with only a single HDU whose header
contained the line 'EXTEND = F'. A second piece of software interpreted
the presence of the EXTEND keyword in the primary HDU as meaning it
should check for extensions, tried to fseek() beyond the end of the
primary HDU and data array, and died.

Who did what right and wrong in this scenario? I'll send bug reports
with the correct answers to the software authors.

--
Stephen Walton
Dept. of Physics & Astronomy, Cal State Northridge

  #2  
Old May 14th 04, 05:57 PM
Jonathan McDowell
external usenet poster
 
Posts: n/a
Default [fitsbits] Clarification of EXTEND, please


Stephen, the standard is pretty clear on this
e.g.
http://archive.stsci.edu/fits/fits_standard/node39.html

Even if EXTEND = T, it only means that there *may* be
further extensions, so doing something that will die if
extensions are not present is always incorrect.
You should be prepared to handle the possibility of EOF
when checking for extensions; it's not that hard to do.

EXTEND=F is in fact a guarantee that further extensions
are NOT present and by my reading of the standard is
a perfectly legal thing to do.
- Jonathan McDowell


  #3  
Old May 14th 04, 05:57 PM
Jonathan McDowell
external usenet poster
 
Posts: n/a
Default [fitsbits] Clarification of EXTEND, please


Stephen, the standard is pretty clear on this
e.g.
http://archive.stsci.edu/fits/fits_standard/node39.html

Even if EXTEND = T, it only means that there *may* be
further extensions, so doing something that will die if
extensions are not present is always incorrect.
You should be prepared to handle the possibility of EOF
when checking for extensions; it's not that hard to do.

EXTEND=F is in fact a guarantee that further extensions
are NOT present and by my reading of the standard is
a perfectly legal thing to do.
- Jonathan McDowell


  #4  
Old May 14th 04, 06:59 PM
Stephen Walton
external usenet poster
 
Posts: n/a
Default [fitsbits] Clarification of EXTEND, please

On Fri, 2004-05-14 at 10:31, Thierry Forveille wrote:
the presence of the EXTEND keyword in the primary HDU as meaning it
should check for extensions, tried to fseek() beyond the end of the
primary HDU and data array, and died.

The second piece did wrong, twice :-) EXTEND indicates only that the file
may contain an extension, not that it does, and then only when set to T.
It looks like they took two unwarranted shortcuts...


Time to name names. The offending piece of software is the fitsread.m
which The Mathworks distributes with MATLAB. In addition to above
problem, Mathworks's FITS software contains another bug, this one in
fitsinfo.m: it seeks 2880 bytes past an HDU which is exactly n*2880
bytes in length before trying to read data, and thus skips the first
2880 bytes of actual data. I have a patch for the second problem which
I'd be happy to share; I haven't tried to fix the first one yet, but it
is probably a simple matter of checking for EXTEND = T rather than the
mere existence of EXTEND.

Thanks to all.

--
Stephen Walton
Dept. of Physics & Astronomy, Cal State Northridge

  #5  
Old May 14th 04, 06:59 PM
Stephen Walton
external usenet poster
 
Posts: n/a
Default [fitsbits] Clarification of EXTEND, please

On Fri, 2004-05-14 at 10:31, Thierry Forveille wrote:
the presence of the EXTEND keyword in the primary HDU as meaning it
should check for extensions, tried to fseek() beyond the end of the
primary HDU and data array, and died.

The second piece did wrong, twice :-) EXTEND indicates only that the file
may contain an extension, not that it does, and then only when set to T.
It looks like they took two unwarranted shortcuts...


Time to name names. The offending piece of software is the fitsread.m
which The Mathworks distributes with MATLAB. In addition to above
problem, Mathworks's FITS software contains another bug, this one in
fitsinfo.m: it seeks 2880 bytes past an HDU which is exactly n*2880
bytes in length before trying to read data, and thus skips the first
2880 bytes of actual data. I have a patch for the second problem which
I'd be happy to share; I haven't tried to fix the first one yet, but it
is probably a simple matter of checking for EXTEND = T rather than the
mere existence of EXTEND.

Thanks to all.

--
Stephen Walton
Dept. of Physics & Astronomy, Cal State Northridge

  #6  
Old May 14th 04, 08:59 PM
Thierry Forveille
external usenet poster
 
Posts: n/a
Default [fitsbits] Clarification of EXTEND, please

Stephen Walton writes:
Time to name names. The offending piece of software is the fitsread.m
which The Mathworks distributes with MATLAB. In addition to above
problem, Mathworks's FITS software contains another bug, this one in
fitsinfo.m: it seeks 2880 bytes past an HDU which is exactly n*2880
bytes in length before trying to read data, and thus skips the first
2880 bytes of actual data. I have a patch for the second problem which
I'd be happy to share; I haven't tried to fix the first one yet, but it
is probably a simple matter of checking for EXTEND = T rather than the
mere existence of EXTEND.

That's a first step, but even if EXTEND is present and set to T it remains
legal to not have any extension, and there could also be multiple extensions.
FITS reading software should really be prepared to recover if it does not
find an extension.

  #7  
Old May 14th 04, 08:59 PM
Thierry Forveille
external usenet poster
 
Posts: n/a
Default [fitsbits] Clarification of EXTEND, please

Stephen Walton writes:
Time to name names. The offending piece of software is the fitsread.m
which The Mathworks distributes with MATLAB. In addition to above
problem, Mathworks's FITS software contains another bug, this one in
fitsinfo.m: it seeks 2880 bytes past an HDU which is exactly n*2880
bytes in length before trying to read data, and thus skips the first
2880 bytes of actual data. I have a patch for the second problem which
I'd be happy to share; I haven't tried to fix the first one yet, but it
is probably a simple matter of checking for EXTEND = T rather than the
mere existence of EXTEND.

That's a first step, but even if EXTEND is present and set to T it remains
legal to not have any extension, and there could also be multiple extensions.
FITS reading software should really be prepared to recover if it does not
find an extension.

  #8  
Old May 19th 04, 12:53 AM
Stephen Walton
external usenet poster
 
Posts: n/a
Default [fitsbits] Clarification of EXTEND, please

On Fri, 2004-05-14 at 09:57, Jonathan McDowell wrote:
Stephen, the standard is pretty clear on this
e.g.
http://archive.stsci.edu/fits/fits_standard/node39.html


I have sent a bug report to the Mathworks about fitsinfo.m, specifically
that it should not treat the absence of an extension on an otherwise
legal FITS file as a fatal error even if EXTEND=T is stated in the
primary HDU. I'll see what response I get.

Thanks to everyone who responded.

--
Stephen Walton
Dept. of Physics & Astronomy, Cal State Northridge

  #9  
Old May 19th 04, 12:53 AM
Stephen Walton
external usenet poster
 
Posts: n/a
Default [fitsbits] Clarification of EXTEND, please

On Fri, 2004-05-14 at 09:57, Jonathan McDowell wrote:
Stephen, the standard is pretty clear on this
e.g.
http://archive.stsci.edu/fits/fits_standard/node39.html


I have sent a bug report to the Mathworks about fitsinfo.m, specifically
that it should not treat the absence of an extension on an otherwise
legal FITS file as a fatal error even if EXTEND=T is stated in the
primary HDU. I'll see what response I get.

Thanks to everyone who responded.

--
Stephen Walton
Dept. of Physics & Astronomy, Cal State Northridge

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[fitsbits] Dataset identifications. Thierry Forveille FITS 12 March 12th 04 02:33 PM
[fitsbits] Dataset identifications. Thomas McGlynn FITS 0 March 10th 04 07:20 PM
Rings Around The Planets: Recycling Of Material May Extend Ring Lifetimes(Forwarded) Andrew Yee Astronomy Misc 0 December 10th 03 03:59 PM
Telescope Game Kevin Rehberg Amateur Astronomy 8 November 15th 03 11:02 PM
To C8 Orange Tube Owners: Fork Clarification Roy Dionne Amateur Astronomy 0 September 16th 03 04:43 AM


All times are GMT +1. The time now is 03:33 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 SpaceBanter.com.
The comments are property of their posters.