diff --git a/applications/smurf/defaults/smurf_makemap.def b/applications/smurf/defaults/smurf_makemap.def index 44bfa9b9a2c..46a2a42c354 100644 --- a/applications/smurf/defaults/smurf_makemap.def +++ b/applications/smurf/defaults/smurf_makemap.def @@ -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 #----------------------------------------------------------------- diff --git a/applications/smurf/libsmf/smf_calcmodel_ast.c b/applications/smurf/libsmf/smf_calcmodel_ast.c index 11a696a09d8..a4e87a9fffd 100644 --- a/applications/smurf/libsmf/smf_calcmodel_ast.c +++ b/applications/smurf/libsmf/smf_calcmodel_ast.c @@ -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", diff --git a/applications/smurf/libsmf/smf_get_mask.c b/applications/smurf/libsmf/smf_get_mask.c index b54214fa68a..1e0cfb91691 100644 --- a/applications/smurf/libsmf/smf_get_mask.c +++ b/applications/smurf/libsmf/smf_get_mask.c @@ -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} @@ -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 diff --git a/applications/smurf/libsmf/smf_iteratemap.c b/applications/smurf/libsmf/smf_iteratemap.c index a0e0d613d74..8113fa3919c 100644 --- a/applications/smurf/libsmf/smf_iteratemap.c +++ b/applications/smurf/libsmf/smf_iteratemap.c @@ -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: @@ -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 */ @@ -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); @@ -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 );