Skip to content

Commit

Permalink
smurf: Allow AST to be skipped on all iterations
Browse files Browse the repository at this point in the history
Setting a negative value for AST.SKIP will result in no more than
-AST.SKIP iterations being performed, and the AST model will be skipped
on all iterations. In this case, AST.SKIP takes the place of NUMITER.
  • Loading branch information
David Berry committed Mar 10, 2014
1 parent 203b320 commit 74d7535
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
6 changes: 6 additions & 0 deletions applications/smurf/defaults/smurf_makemap.def
Expand Up @@ -95,6 +95,12 @@ ast.mapspike = 10
# masking for the FLT and/or COM models, since it allows a
# reasonable mask to be formed before subtracting off the
# first estimate of the astronommical signal.
#
# If ast.skip is set to a negative value, it gives the
# largest number of iterations to perform and indicates
# that the AST model should be skipped on all of them. In
# this case the value supplied for parameter "numiter" is
# ignored.
ast.skip = 0

#-----------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions applications/smurf/libsmf/smf_calcmodel_ast.c
Expand Up @@ -310,6 +310,8 @@ void smf_calcmodel_ast( ThrWorkForce *wf __attribute__((unused)),

/* We only do the rest if we are not skipping this iteration. */
astMapGet0I( kmap, "SKIP", &skip );
if( skip < 0 ) skip = -skip;

if( dat->iter < skip ) {
dat->ast_skipped = 1;
msgOutf( " "," skipping AST model on this iteration (AST.SKIP=%d)\n",
Expand Down
3 changes: 2 additions & 1 deletion applications/smurf/libsmf/smf_get_mask.c
Expand Up @@ -114,7 +114,7 @@
* rather than an error, since a null mask does not prevent a map
* being cerated.
* 10-MAR-2014 (DSB):
* Allow source pixels defined by SNR to be accumulated from iteration
* Allow source pixels defined by SNR to be accumulated from iteration
* to iteration, rather than replaced.
* {enter_further_changes_here}
Expand Down Expand Up @@ -259,6 +259,7 @@ unsigned char *smf_get_mask( ThrWorkForce *wf, smf_modeltype mtype,
astMapGet0A( config, "AST", &akm );
astMapGet0I( akm, "SKIP", &skip );
akm = astAnnul( akm );
if( skip < 0 ) skip = -skip;

/* Get the number of iterations over which the mask is to be applied. Zero
means all. Return with no mask if this number of iterations has
Expand Down
28 changes: 24 additions & 4 deletions applications/smurf/libsmf/smf_iteratemap.c
Expand Up @@ -436,6 +436,10 @@
* performed that included an AST Model. Previously, termination
* could occur as soon as the initial AST-free iterations had been
* completed.
* 2014-03-10 (DSB):
* Provide an option to skip the AST model on all iterations,
* terminating using the normal maptol criterion. This is done by
* setting a negative value for AST.SKIP.
* {enter_further_changes_here}
* Notes:
Expand Down Expand Up @@ -549,6 +553,7 @@ void smf_iteratemap( ThrWorkForce *wf, const Grp *igrp, const Grp *iterrootgrp,
size_t *numcnvg, int *iters, int *status ) {

/* Local Variables */
int ast_skip; /* Number of iterations with no AST model */
int bolomap=0; /* If set, produce single bolo maps */
size_t bstride; /* Bolometer stride */
double *chisquared=NULL; /* chisquared for each chunk each iter */
Expand Down Expand Up @@ -805,8 +810,20 @@ void smf_iteratemap( ThrWorkForce *wf, const Grp *igrp, const Grp *iterrootgrp,
/* Does maptol refer to mean map change or max map change? */
astMapGet0I( keymap, "MAPTOL_MEAN", &maptol_mean );

/* A negative AST.SKIP value over-rides NUMITER. */
ast_skip = 0;
if( astMapGet0A( keymap, "AST", &kmap ) ) {
astMapGet0I( kmap, "SKIP", &ast_skip );
kmap = astAnnul( kmap );
}

/* Number of iterations */
astMapGet0I( keymap, "NUMITER", &numiter );
if( ast_skip < 0 ) {
numiter = ast_skip;
} else {
astMapGet0I( keymap, "NUMITER", &numiter );
}

if( numiter == 0 ) {
*status = SAI__ERROR;
errRep("", FUNC_NAME ": NUMITER cannot be 0", status);
Expand Down Expand Up @@ -2245,9 +2262,12 @@ void smf_iteratemap( ThrWorkForce *wf, const Grp *igrp, const Grp *iterrootgrp,

/* Remember if no AST model was subtracted from the
previous iteration. The dat.ast_skipped flag is updated
within smf_Calcmodel_ast, so we store its current value
now, before it is changed */
last_skipped = dat.ast_skipped;
within smf_calcmodel_ast, so we store its current value
now, before it is changed. It is used to decide on
convergence. But if all iterations are being skipped
we leave it set to zero to prevent it influencing the
termination critirion. */
if( ast_skip > 0 ) last_skipped = dat.ast_skipped;

/* Estimate the AST model and subtract from the residuals. */
smf_calcmodel_ast( wf, &dat, 0, keymap, NULL, dimmflags, status );
Expand Down

0 comments on commit 74d7535

Please sign in to comment.