Starlink-AST
view release on metacpan or search on metacpan
ast/src/dssmap.c view on Meta::CPAN
if ( !astOK ) result = 0;
/* Return the result, */
return result;
}
static struct WorldCoor *BuildWcs( AstFitsChan *fits, const char *method,
const char *class, int *status ) {
/*
* Name:
* BuildWcs
* Purpose:
* Copy DSS plate fit information from a FitsChan to a SAOimage
* WorldCoor structure.
* Type:
* Private function.
* Synopsis:
* #include "dssmap.h"
* struct WorldCoor *BuildWcs( AstFitsChan *fits, const char *method,
* const char *class )
* Class Membership:
* DssMap member function.
* Description:
* This creates a WorldCoor structure and copies the required data
* from the supplied FitsChan into the new WorldCoor structure. Note,
* only those components of the WorldCoor structure which are needed to
* transform between pixel and sky coordinates are initialised in the
* returned structure.
* Parameters:
* fits
* Pointer to the FitsChan containing the FITS header describing
* the DSS plate fit.
* method
* The calling method (for error messages).
* class
* The object class (for error messages).
* Returned Value:
* A pointer to the new WorldCoor structure. This should be freed
* using astFree when no longer needed.
* Notes:
* - A NULL pointer is returned if an error has already occurred, or
* if this function should fail for any reason.
*/
/* Local Variables: */
char name_buff[ 10 ]; /* Buffer for keyword name */
char *name; /* Pointer to jeyword name string */
char *ckeyval; /* Pointer to string keyword value */
struct WorldCoor *ret; /* Pointer to the returned structure */
double rah,ram,ras; /* Centre RA hours, minutes and seconds */
double dsign; /* Sign of centre dec */
double decd,decm,decs; /* Centre Dec degrees, minutes, seconds */
double dec_deg; /* Centre Dec in degrees */
double ra_hours; /* Centre RA in hours */
int i; /* Coefficient index */
/* Check the local error status. */
if ( !astOK ) return NULL;
/* Get memory to hold the returned structure. */
ret = (struct WorldCoor *) astMalloc( sizeof( struct WorldCoor ) );
/* Check the memory can be used. */
if( astOK ){
/* The following code is based on the "wcsinit" function in SAOimage file
wcs.c. Note, only the values needed in the platepos and platepix
functions are set up. The FITS keywords are accessed in the order in
which they are usually stored in a FITS file. This will cut down the
time spent searching for keywords. Report an error if any required
keyword is not found. */
/* Plate center RA */
rah = 0.0;
ram = 0.0;
ras = 0.0;
name = "PLTRAH";
if( !astGetFitsF( fits, name, &rah ) && astOK ){
astError( AST__BDFTS, "%s(%s): No value has been supplied for the "
"FITS keyword '%s'.", status, method, class, name );
}
name = "PLTRAM";
if( !astGetFitsF( fits, name, &ram ) && astOK ){
astError( AST__BDFTS, "%s(%s): No value has been supplied for the "
"FITS keyword '%s'.", status, method, class, name );
}
name = "PLTRAS";
if( !astGetFitsF( fits, name, &ras ) && astOK ){
astError( AST__BDFTS, "%s(%s): No value has been supplied for the "
"FITS keyword '%s'.", status, method, class, name );
}
ra_hours = rah + (ram / (double)60.0) + (ras / (double)3600.0);
ret->plate_ra = AST__DD2R*15.0*ra_hours;
/* Plate center Dec */
name = "PLTDECSN";
if( !astGetFitsS( fits, name, &ckeyval ) && astOK ){
dsign = 1.0;
} else {
if( *ckeyval == '-' ){
dsign = -1.0;
} else {
dsign = 1.0;
}
}
decd = 0.0;
decm = 0.0;
decs = 0.0;
name = "PLTDECD";
if( !astGetFitsF( fits, name, &decd ) && astOK ){
astError( AST__BDFTS, "%s(%s): No value has been supplied for the "
"FITS keyword '%s'.", status, method, class, name );
}
name = "PLTDECM";
if( !astGetFitsF( fits, name, &decm ) && astOK ){
astError( AST__BDFTS, "%s(%s): No value has been supplied for the "
"FITS keyword '%s'.", status, method, class, name );
}
name = "PLTDECS";
if( !astGetFitsF( fits, name, &decs ) && astOK ){
astError( AST__BDFTS, "%s(%s): No value has been supplied for the "
"FITS keyword '%s'.", status, method, class, name );
}
dec_deg = dsign * (decd+(decm/(double)60.0)+(decs/(double)3600.0));
ret->plate_dec = AST__DD2R*dec_deg;
/* Plate Scale arcsec per mm */
name = "PLTSCALE";
if( !astGetFitsF( fits, name, &ret->plate_scale ) && astOK ){
astError( AST__BDFTS, "%s(%s): No value has been supplied for the "
"FITS keyword '%s'.", status, method, class, name );
}
/* X and Y corners (in pixels) */
name = "CNPIX1";
if( !astGetFitsF( fits, name, &ret->x_pixel_offset ) && astOK ){
astError( AST__BDFTS, "%s(%s): No value has been supplied for the "
"FITS keyword '%s'.", status, method, class, name );
}
name = "CNPIX2";
if( !astGetFitsF( fits, name, &ret->y_pixel_offset ) && astOK ){
astError( AST__BDFTS, "%s(%s): No value has been supplied for the "
"FITS keyword '%s'.", status, method, class, name );
}
/* X and Y pixel sizes (microns). */
name = "XPIXELSZ";
if( !astGetFitsF( fits, name, &ret->x_pixel_size ) && astOK ){
astError( AST__BDFTS, "%s(%s): No value has been supplied for the "
"FITS keyword '%s'.", status, method, class, name );
}
name = "YPIXELSZ";
if( !astGetFitsF( fits, name, &ret->y_pixel_size ) && astOK ){
astError( AST__BDFTS, "%s(%s): No value has been supplied for the "
"FITS keyword '%s'.", status, method, class, name );
}
/* Orientation Coefficients. Only report an error if PPO3 or PPO6 are
missing (these are the only two which are actually used). Assume a
value of zero for any of the others which are missing. */
name = name_buff;
for ( i = 0; i < 6; i++ ) {
sprintf( name_buff, "PPO%d", i + 1 );
if( !astGetFitsF( fits, name, &ret->ppo_coeff[i] ) ) {
ret->ppo_coeff[i] = 0.0;
if( ( i == 2 || i == 5 ) && astOK ) {
astError( AST__BDFTS, "%s(%s): No value has been supplied "
"for the FITS keyword '%s'.", status, method, class,
name );
break;
}
}
}
/* Plate solution x and y coefficients. Report an error if any of
coefficients 1 to 14 are missing. Assume a value of zero for any
others which are missing. */
name = name_buff;
for( i = 0; i < 19; i++ ){
sprintf( name_buff, "AMDX%d", i + 1 );
if( !astGetFitsF( fits, name, &ret->amd_x_coeff[i] ) ) {
ret->amd_x_coeff[i] = 0.0;
( run in 2.105 seconds using v1.01-cache-2.11-cpan-71847e10f99 )