Skip to content

Commit

Permalink
smurf: Use zero-based numbering for JSA tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
grahambell committed Oct 31, 2013
1 parent 0ebcf80 commit e40540f
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion applications/smurf/libsmf/smf_jsatile.c
Expand Up @@ -19,7 +19,7 @@
* Arguments:
* itile = int (Given)
* The one-based index of the tile. Supplying a tile index of zero
* The zero-based index of the tile. Supplying a tile index of -1
* causes the returned values to cover the whole sky, with a single
* grid pixel corresponding to a single tile.
* skytiling = smfJSATiling * (Given)
Expand Down
20 changes: 10 additions & 10 deletions applications/smurf/libsmf/smf_jsatileheader.c
Expand Up @@ -18,7 +18,7 @@
* Arguments:
* itile = int (Given)
* The one-based tile index, or zero for the whole sky.
* The zero-based tile index, or -1 for the whole sky.
* skytiling = smfJSATiling * (Given)
* Pointer to a structure holding parameters describing the tiling
* scheme used for the required JCMT instrument, as returned by
Expand All @@ -34,7 +34,7 @@
* Description:
* This function returns a FITS header describing a specified sky tile
* holding data from a specified JCMT instrument (or, if "itile" is
* 0, a FITS header describing the whole collection of tiles).
* -1, a FITS header describing the whole collection of tiles).
*
* The whole sky is covered by an HPX (healpix) projection containing
* 12 basic facets,the reference point (native lon.=0, native lat.=0)
Expand Down Expand Up @@ -152,22 +152,22 @@ AstFitsChan *smf_jsatileheader( int itile, smfJSATiling *skytiling,
/* Check inherited status */
if( *status != SAI__OK ) return fc;

/* If the tile index is zero, produce a header for the whole sky (one
/* If the tile index is -1, produce a header for the whole sky (one
pixel per tile). */
if( itile == 0 ) {
if( itile == -1 ) {
ng = 5*skytiling->ntpf;
gx_ref = gy_ref = 0.5*( ng + 1);
ra_ref = dec_ref = 0.0;
fc = smfMakeFC( ng, ng, skytiling->ntpf, 1, gx_ref, gy_ref, ra_ref,
dec_ref, status );

/* Otherwise, check the supplied tile index. */
} else if( itile < 1 || itile > skytiling->ntiles ) {
} else if( itile < 0 || itile >= skytiling->ntiles ) {
*status = SAI__ERROR;
msgSeti( "I", itile );
msgSeti( "M", skytiling->ntiles );
msgSeti( "M", skytiling->ntiles - 1 );
errRep( " ", "smf_jsatileheader: Supplied tile index (^I) is "
"illegal. Should be in the range 1 to ^M.", status );
"illegal. Should be in the range 0 to ^M.", status );

/* If the tile index is good, proceed. */
} else {
Expand All @@ -181,8 +181,8 @@ AstFitsChan *smf_jsatileheader( int itile, smfJSATiling *skytiling,
/* Convert the supplied tile index into a pair of X and Y offsets that
give the gaps along the X and Y axes, in tiles, between the bottom left
tile in the projection plane and the required tile. */
fi = ( itile - 1 )/n2;
tj = itile - 1 - fi*n2;
fi = itile / n2;
tj = itile - fi*n2;
ty = tj/skytiling->ntpf;
tx = tj - ty*skytiling->ntpf;
fy = skytiling->ntpf*( ( fi + 1 )/3 );
Expand Down Expand Up @@ -265,7 +265,7 @@ AstFitsChan *smf_jsatileheader( int itile, smfJSATiling *skytiling,
astPutFits( fc, card, 1 );
}

/* Add the one based tile index into the header. */
/* Add the zero based tile index into the header. */
sprintf( card, "JCMTTILE= %d", itile );
astPutFits( fc, card, 1 );
}
Expand Down
10 changes: 5 additions & 5 deletions applications/smurf/libsmf/smf_jsatilei2xy.c
Expand Up @@ -18,7 +18,7 @@
* Arguments:
* itile = int (Given)
* The one-based index of the tile.
* The zero-based index of the tile.
* skytiling = smfJSATiling * (Given)
* Pointer to a structure holding parameters describing the tiling
* scheme used for the required JCMT instrument, as returned by
Expand All @@ -35,7 +35,7 @@
* Description:
* This function returns offsets along the X (RA) and Y (Dec) axes
* (measured as a number of tiles) from the bottom left tile to the
* tile with the specified one-based tile index.
* tile with the specified zero-based tile index.
* Authors:
* DSB: David S Berry (JAC, UCLan)
Expand Down Expand Up @@ -109,13 +109,13 @@ void smf_jsatilei2xy( int itile, smfJSATiling *skytiling, int *xt, int *yt,
nsq = skytiling->ntpf*skytiling->ntpf;

/* Check the tile index is legal. */
if( itile >= 1 && itile <= 12*nsq ){
if( itile >= 0 && itile < 12*nsq ){

/* Get the zero-based index of the facet contained the tile. */
fi = ( itile - 1 )/nsq;
fi = itile / nsq;

/* Get the offset in tiles into this facet of the required tile. */
tj = ( itile - 1 ) - fi*nsq;
tj = itile - fi*nsq;

/* Within a facet, tiles are stored raster-fashion from bottom left to
top right. Get the row and column indices (zero-based) of the tile within
Expand Down
2 changes: 1 addition & 1 deletion applications/smurf/libsmf/smf_jsatiles_data.c
Expand Up @@ -170,7 +170,7 @@ int *smf_jsatiles_data( Grp *igrp, size_t size, int *ntile, int *status ){
corresponds to a single tile. The current Frame is ICRS (RA,Dec) and
the base Frame is grid coords in which each grid pixel corresponds to
a single tile. */
smf_jsatile( 0, &skytiling, 0, NULL, &fs, NULL, lbnd, ubnd, status );
smf_jsatile( -1, &skytiling, 0, NULL, &fs, NULL, lbnd, ubnd, status );

/* Allocate an image with one pixel for each tile, and fill it with
zeros. */
Expand Down
2 changes: 1 addition & 1 deletion applications/smurf/libsmf/smf_jsatiles_region.c
Expand Up @@ -133,7 +133,7 @@ int *smf_jsatiles_region( AstRegion *region, smf_inst_t instrument,
corresponds to a single tile. The current Frame is ICRS (RA,Dec) and
the base Frame is grid coords in which each grid pixel corresponds to
a single tile. */
smf_jsatile( 0, &skytiling, 0, NULL, &fs, NULL, lbnd, ubnd, status );
smf_jsatile( -1, &skytiling, 0, NULL, &fs, NULL, lbnd, ubnd, status );

/* If the supplied Region is 3-dimensional, remove the third axis, which
is assumed to be a spectral axis. */
Expand Down
6 changes: 3 additions & 3 deletions applications/smurf/libsmf/smf_jsatilexy2i.c
Expand Up @@ -28,7 +28,7 @@
* Pointer to the inherited status variable.
* Returned Value:
* The one-based scalar tile index of the requested tile. VAL__BADI is
* The zero-based scalar tile index of the requested tile. VAL__BADI is
* returned if no tile has the requested X adn Y offsets.
* Description:
Expand Down Expand Up @@ -143,8 +143,8 @@ int smf_jsatilexy2i( int xt, int yt, smfJSATiling *skytiling, int *status ){

/* Get the scalar index of the tile within the facet. Add this index onto
the index of the first tile in the facet, to get the index of the
required tile. Add an extra one to oncert to one-based. */
itile += ty*skytiling->ntpf + tx + 1;
required tile. */
itile += ty*skytiling->ntpf + tx;
}
}

Expand Down
14 changes: 7 additions & 7 deletions applications/smurf/libsmurf/smurf_tileinfo.c
Expand Up @@ -75,7 +75,7 @@
* "rxa", "rxwd" and "rxwb".
* ITILE = _INTEGER (Read)
* The index of the tile about which information is required. The
* first tile has index 1. The largest allowed tile index is
* first tile has index 0. The largest allowed tile index is
* always returned in output parameter MAXTILE. If a null (!)
* value is supplied for ITILE, the MAXTILE parameter is still
* written, but the command will then exit immediately without
Expand Down Expand Up @@ -280,7 +280,7 @@ void smurf_tileinfo( int *status ) {
smf_jsatiling( instrument, &skytiling, status );

/* Return the maximum tile index. */
parPut0i( "MAXTILE", skytiling.ntiles, status );
parPut0i( "MAXTILE", skytiling.ntiles - 1, status );

/* Abort if an error has occurred. */
if( *status != SAI__OK ) goto L999;
Expand All @@ -299,7 +299,7 @@ void smurf_tileinfo( int *status ) {
/* Otherwise, create a FrameSet describing the whole sky in which each
pixel corresponds to a single tile. */
} else {
smf_jsatile( 0, &skytiling, 0, NULL, &fs, NULL, lbnd, ubnd, status );
smf_jsatile( -1, &skytiling, 0, NULL, &fs, NULL, lbnd, ubnd, status );

/* Change the bounds of the output NDF. */
ndfSbnd( 2, lbnd, ubnd, indf3, status );
Expand Down Expand Up @@ -336,9 +336,9 @@ void smurf_tileinfo( int *status ) {
/* Abort if an error has occurred. */
if( *status != SAI__OK ) goto L999;

/* Get the one-based index of the required tile. If a null value is
/* Get the zero-based index of the required tile. If a null value is
supplied, annull the error and skip to the end. */
parGdr0i( "ITILE", 0, 1, skytiling.ntiles, 0, &itile, status );
parGdr0i( "ITILE", 0, 0, skytiling.ntiles - 1, 0, &itile, status );
if( *status == PAR__NULL ) {
errAnnul( status );
goto L999;
Expand All @@ -350,8 +350,8 @@ void smurf_tileinfo( int *status ) {
/* Display the tile number. */
msgBlank( status );
msgSeti( "ITILE", itile );
msgSeti( "MAXTILE", skytiling.ntiles );
msgOut( " ", " Tile ^ITILE (of ^MAXTILE):", status );
msgSeti( "NTILES", skytiling.ntiles );
msgOut( " ", " Tile ^ITILE (of ^NTILES):", status );

/* Get the FITS header, FrameSet and Region defining the tile, and the tile
bounds in pixel indices. */
Expand Down
2 changes: 1 addition & 1 deletion applications/smurf/smurf.ifd.in
Expand Up @@ -5077,7 +5077,7 @@ package @PACKAGE@ {
type _INTEGER
access READ
ppath CURRENT
prompt {One-based tile index}
prompt {Zero-based tile index}
helpkey *
}

Expand Down

0 comments on commit e40540f

Please sign in to comment.