Skip to content

Commit a2d5656

Browse files
committed
fits: add nasty hack around LDAC FITS format idiosyncracies
This is about the LDAC FITS variant: http://marvinweb.astro.uni-bonn.de/data_products/THELIWWW/LDAC/LDAC_concepts.html The first (LDAC_IMHEAD) table extension contains a single-cell table where the cell's content is an array of FITS headers. In auto-format-detection mode this confuses STIL into thinking that the file is in colfits format, which in turn means that the StarTableFactory.makeStarTables method ignores the second (LDAC_OBJECTS) table extension, since colfits is not multi-table-capable. Add a hack to spot LDAC_IMHEAD HDUs in colfits and reject them as colfits.
1 parent 5bd7b32 commit a2d5656

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

fits/src/main/uk/ac/starlink/fits/ColFitsStarTable.java

+20-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ public class ColFitsStarTable extends AbstractStarTable {
4343
* @param hdr header of the HDU containing the table
4444
* @param dataPos offset into <code>file</code> of the start of the
4545
* data part of the HDU
46+
* @param force true to make a table if we possibly can,
47+
* false to reject if it doesn't look very much like one
4648
*/
47-
public ColFitsStarTable( DataSource datsrc, Header hdr, long dataPos )
49+
public ColFitsStarTable( DataSource datsrc, Header hdr, long dataPos,
50+
boolean force )
4851
throws IOException {
4952
HeaderCards cards = new HeaderCards( hdr );
5053

@@ -61,6 +64,21 @@ public ColFitsStarTable( DataSource datsrc, Header hdr, long dataPos )
6164
/* Find the number of columns. */
6265
ncol_ = cards.getIntValue( "TFIELDS" ).intValue();
6366

67+
/* Nasty hack.
68+
* LDAC is a somewhat eccentric FITS variant that has a single-cell
69+
* BINTABLE as HDU1 containing an array of FITS header cards.
70+
* That looks like colfits, and causes the later HDU to be
71+
* ignored in format auto-detection mode, since colfits is not
72+
* a multi-table-capable format. So reject this HDU explicitly here,
73+
* in auto-detection format it will get passed on to some other
74+
* format handler (basic FITS).
75+
* See http://marvinweb.astro.uni-bonn.de/
76+
* data_products/THELIWWW/LDAC/LDAC_concepts.html */
77+
if ( ! force &&
78+
"LDAC_IMHEAD".equals( cards.getStringValue( "EXTNAME" ) ) ) {
79+
throw new TableFormatException( "Reject LDAC_IMHEAD table" );
80+
}
81+
6482
/* Read metadata for each column from the FITS header cards. */
6583
long nrow = 0;
6684
valReaders_ = new ValueReader[ ncol_ ];
@@ -192,7 +210,7 @@ public BasicInput createInput( boolean isSeq )
192210
}
193211
}
194212

195-
/* Otherwise use a different stream for each collumn. */
213+
/* Otherwise use a different stream for each column. */
196214
else {
197215
if ( isFile && datsrc.getCompression() != Compression.NONE ) {
198216
logger_.warning( "Can't map compressed file " + datsrc.getName()

fits/src/main/uk/ac/starlink/fits/ColFitsTableBuilder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ public StarTable makeStarTable( DataSource datsrc, boolean wantRandom,
7272
in.close();
7373
}
7474

75-
return new ColFitsStarTable( datsrc, hdr, pos );
75+
return new ColFitsStarTable( datsrc, hdr, pos, false );
7676
}
7777
}

topcat/src/docs/sun253.xml

+2
Original file line numberDiff line numberDiff line change
@@ -20797,6 +20797,8 @@ introduced since the last version:
2079720797
in the <ref id="SsaMultiWindow">Multiple SSA Query</ref> window.
2079820798
This long-standing bug would have stopped this window working at all
2079920799
with well-behaved SSA services.</li>
20800+
<li>Add a hack that allows LDAC FITS tables to be treated sensibly
20801+
in auto-format-detection mode.</li>
2080020802
</ul>
2080120803
</p></dd>
2080220804

ttools/src/docs/sun256.xml

+2
Original file line numberDiff line numberDiff line change
@@ -10108,6 +10108,8 @@ eds. C. Gabriel et al., ASP Conf. Ser. 351, p. 666 (2006)
1010810108
<code>coneskymatch</code>.
1010910109
This long-standing bug would have stopped this command working at all
1011010110
with well-behaved SSA services.</li>
10111+
<li>Add a hack that allows LDAC FITS tables to be treated sensibly
10112+
in auto-format-detection mode.</li>
1011110113
</ul>
1011210114
</p></dd>
1011310115

votable/src/main/uk/ac/starlink/votable/ColFitsPlusTableBuilder.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ public StarTable makeStarTable( DataSource datsrc, boolean wantRandom,
9898
}
9999

100100
/* Get the table itself from the next HDU. */
101-
StarTable tableData = new ColFitsStarTable( datsrc, hdr, dataPos );
101+
StarTable tableData =
102+
new ColFitsStarTable( datsrc, hdr, dataPos, false );
102103

103104
/* If we got a TABLE element, combine the metadata from that and
104105
* the data from the FITS table to provide the output table. */

0 commit comments

Comments
 (0)