IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Opened 20 years ago

Closed 17 years ago

#733 closed defect (fixed)

psFitsHeaderValidate defined too restrictive.

Reported by: robert.desonia@… Owned by: Paul Price
Priority: high Milestone:
Component: PSLib SDRS Version: unspecified
Severity: normal Keywords:
Cc:

Description

The function psFitsHeaderValidate is defined and implemented too restrictively.

First, limiting keywords to 8 characters and to be only uppercase, 0-9, or underscore is not required if
the HIERARCH keyword extension is used.

Furthermore, requiring that the 'missing' keywords be added is just not very useful as nothing in the
psLib library requires them to exist in the psMetadata header. it is truly best for the particular write
routines to add the keywords as required given the size of the image, table elements, or whatever the
case may be. Even the 'SIMPLE' keyword is of no use as that is automatically inserted as well in the
write/insert routines and all it does in the psMetadata structure is consume memory.

The function's only real added value is to scan the items of the psMetadata for datatypes not able to be
represented in the header.

-rdd

Change History (6)

comment:1 by Paul Price, 20 years ago

Resolution: fixed
Status: newclosed

Agreed, so long as we keep psFitsHeaderFromImage.

comment:2 by Paul Price, 20 years ago

Cc: eugene@… added

Updated definition of psFitsHeaderValidate and psFitsWriteImage, added
psFitsHeaderFromImage. psFitsHeaderFromImage can be put together from code in
the rel10_ifa branch version of psFitsWriteImage.

\begin{prototype}
bool psFitsHeaderValidate(psMetadata *header);
\end{prototype}

\code{psFitsHeaderValidate} shall validate the supplied \code{header}
so that it is in compliance to the FITS standard for header keyword
names and types. This involves scanning for types that cannot be
represented in FITS, and changing the keywords to conform to the FITS
standard where possible by using the \code{HIERARCH} keyword. If the
resulting \code{header} conforms to the FITS standard, the function
shall return \code{true}; otherwise the function shall return
\code{false}.

\begin{prototype}
psMetadata *psFitsHeaderFromImage(psMetadata *header, const psImage *image);
psMetadata *psFitsHeaderFromTable(psMetadata *header, const psArray *table);
\end{prototype}

\code{psFitsHeaderFromImage} shall format the \code{header} to be
appropriate for writing the \code{image}. The function shall update
the following keywords in the \code{header} on the basis of the
\code{image}: \code{SIMPLE}, \code{NAXIS}, \code{NAXIS1},
\code{NAXIS2}, \code{NAXIS3}, \code{BSCALE}, \code{BZERO},
\code{EXTNAME}. If the \code{header} is \code{NULL}, a new header
shall be allocated and returned. \code{psFitsHeaderFromTable} shall
do similarly for \code{table}s, setting the appropriate keywords for
FITS tables.

\begin{prototype}
bool psFitsWriteImage(psFits *fits, psMetadata *header, const psImage *input,
int depth,

const char *extname);

\end{prototype}
Create a new image based on the dimensions specified for the image and
the requested depth. The header and image data segments are written
at the end of the file. This function will only write images of the
native FITS image types (\code{psU8}, \code{psS16}, \code{psS32},
\code{psF32}, \code{psF64}). The user is expected to convert the data
type as needed with \code{psImageCopy}. The function shall call
\code{psFitsHeaderForImage} to obtain the correct FITS headers. The
return value must be 0 for a successful operation and 1 for an error.

comment:3 by robert.desonia@…, 20 years ago

Resolution: fixed
Status: closedreopened

The concept of using something like psFitsHeaderFromImage is just more work than really necessary.
CFITSIO handles setting these header values for me, so I never need to put things like SIMPLE, NAXISx,
BSCALE, BZERO, et cetera in the psMetadata. It would just be much easier if keywords like that be ignored
altogether in the psMetadata, as I have no choice but to ignore that entry anyway when I write the HDU.
Those keywords are derived wholely from the psImage and also forcing it into the psMetadata can be
confusing.

-rdd

comment:4 by robert.desonia@…, 20 years ago

The concept of using something like psFitsHeaderFromImage is just more work than really necessary.
CFITSIO handles setting these header values for me, so I never need to put things like SIMPLE, NAXISx,
BSCALE, BZERO, et cetera in the psMetadata. It would just be much easier if keywords like that be
ignored altogether in the psMetadata, as I have no choice but to ignore that entry anyway when I write
the HDU. Those keywords are derived wholely from the psImage and also forcing it into the psMetadata
can be confusing.

Also, the use of HIERARCH is better to be applied at the time of the write (as it is automatically done by
CFITSIO) and before removed at read (also done automatically by CFITSIO). There is no need for
HIERARCH to appear anywhere in the psMetadata; that just requires the user to parse it out as needed.

Lastly, shall psFitsValidateHeader still make all keywords UPPERCASE?

-rdd

comment:5 by Paul Price, 20 years ago

Status: reopenedassigned

We would like to have NAXIS, NAXIS[1-3], BSCALE, BZERO and EXTNAME in the
metadata, since they describe the image (and we want to be able to write the
metadata out in other formats). Therefore we need a way of using an image to
write these into the metadata. I don't think it really matters whether
psFitsWriteImage writes these headers from the metadata or not, but it should
update them in the psMetadata, and we need psFitsHeaderFromImage.

comment:6 by eugene, 17 years ago

Resolution: fixed
Status: assignedclosed

this function seems to be ok, but is not actually used in practice. I think the issues causing the bug have been resolved.

Note: See TracTickets for help on using tickets.