On Thu, 18 Jan 2007, Peter W. Draper wrote:
> On Thu, 18 Jan 2007, John Barrow wrote:
>
> > Two of our users are trying to reduce some HARP-ACSIS data, using the
> > version of GAIA included in the "keoe" release of the Starlink Software
> > Collection. They are receiving errors of the following form:
> >
> > !! Error while reading AST_ data from the HDS object
> > ! /lochy/wfdt/jcmt_bd/20070101/ac20070101_00031_01_01.WCS.DATA.
> > ! NDF_STATE: Error determining the state of an NDF component.
> >
> > Can you tell me if a more recent version of GAIA is needed to reduce this
> > data, or if there is some other problem.
>
> Hi John,
>
> there is a problem with the format of the WCS stored in this data which is
> unfortunately causing this error. There will be a new release, maybe next
> month, which will fix this, but in the meanwhile there are some work
> arounds.
>
> I think the best was some script that David had for editing the WCS
> component? So I've CC'd this message to him (since I seem to have lost
> that message).
The issue is that harp-acsis NDFs are being created with a more recent
version of the AST library than the keoe release was built against. This
is because harp-acsis data benefits from a value for DUT1 (the difference
between UTC and UT1) stored with it, but the version of AST used by keoe
doesn't know anything about DUT1. So keoe moans when it finds this DUT1
value in the WCS information.
The work around is to modify the WCS info in the NDF to remove the DUT1
value. The only thing that may be affected by this is the smurf:makecube
command, but I presume you wont have this anyway since it wasn't included
in keoe.
The attached script should do the necessary editing. Let me know if you
have any problems.
David
#!/usr/bin/perl
# Name:
# dedut.pl
# Purpose:
# Remove the "dut1" attribute from the WCS FrameSet in an NDF.
# Usage:
# % dedut.pl in out
# Command Line Parameters:
# in
# The input NDF from which the "dut1" attribute is to be removed.
# out
# The output NDF. A copy of "in" without the "dut1" attribute.
# Requirements:
# A starlink distribution must be available, containing at least
# KAPPA, ATOOLS and HDSTRACE. The environment variable KAPPA_DIR
# should point to the directory containing the kappa binaries (it
# is assumed that the hdstrace binary is in $KAPPA_DIR/..). The
# environment variable ATOOLS_DIR should point to the directory
# containing the atools binaries.
# Check that both input and output NDFs were given on the command line
if( $#ARGV < 0 ) {
die "No input or output NDF specified.\nUsage: dedut.pl in out\n";
} elsif( $#ARGV < 1 ) {
die "No output NDF specified.\nUsage: dedut.pl in out\n";
}
# Get the input NDF name without any ".sdf" suffix
$in = $ARGV[0];
$in =~ s/\.sdf$//;
# Run hdstrace to get a text version of the WCS FrameSet, ensuring that
# any previous log file is deleted first.
unlink "dedut.log";
system "\$KAPPA_DIR/../hdstrace object=$in.wcs eachline nline=all logfile=dedut.log newline > /dev/null ";
# Open the log file created by hdstrace, and also create a new file to receive
# the modified WCS FrameSet.
open INFILE, "<dedut.log";
open OUTFILE, ">dedut2.log";
# Read through the entire log file
$state = 1;
while( <INFILE> ) {
chomp;
$outline = "";
# First watch for the "Begin FrameSet" line, marking the start of the
# FrameSet
if( $state == 1 ){
if( /Begin +FrameSet/ ) {
$outline = 'Begin FrameSet';
$state = 2;
}
# Now watch for the end of the WCS FrameSet (a line containg a string
# enclosed in single quotes that is not terminated by a comma). Either way
# extract the string between the single quotes.
} elsif( $state == 2 ){
if( /^ +\'(.*)\' *$/ ) {
$outline = $1;
$state = 3;
} elsif( /^ +\'(.*)\', *$/ ) {
$outline = $1;
}
}
# Write out the line of the AST FrameSet to the output file so long as
# it is not a "Dut1" line.
if( $outline ) {
if( !( $outline =~ /Dut1/ ) ) {
print OUTFILE "$outline\n";
}
}
}
# Close the files.
close INFILE;
close OUTFILE;
# Create a copy of the input NDF.
$out = $ARGV[1];
$out =~ s/\.sdf$//;
system "cp $in.sdf $out.sdf";
# Erase the WCS component in the output NDF.
system "\$KAPPA_DIR/erase $out.wcs ok";
# Copy the new WCS FrameSet to the output NDF.
system "\$ATOOLS_DIR/astcopy dedut2.log $out";
# Erase the log files
unlink "dedut.log";
unlink "dedut2.log";
|