Example #1
0
File: s2.cpp Project: dCache/s2
static void
ErrCB(dg_callback cbData)
{
  switch(cbData.level) {
    case ERR_SYSTEM:
      UPDATE_MAX(diagnose_val, ERR_SYSTEM);	/* increase the return value */
      exit(diagnose_val);			/* better than SEGv (e.g.: phreads) */
    break;

    case DG_ERR_ASSERT:				/* don't change to ERR_ASSERT! (see dg.h) */
      UPDATE_MAX(diagnose_val, ERR_ASSERT);	/* increase the return value */
      exit(diagnose_val);			/* better than SEGv */
    break;

    default:
      UPDATE_MAX(diagnose_val, cbData.level);	/* increase the return value */
  }
} /* ErrCB */
Example #2
0
void pstats_log_extremes(SUMMING_CONTEXT *ctx, POWER_SUM_STATS *tmp_pstat, POWER_SUM **ps, int count, EXTREME_INFO *ei, int pi)
{
int i;
POWER_SUM_STATS pstats, pstats_accum;
int highest_ul_idx=0;
int highest_circ_ul_idx=0;
int highest_snr_idx=0;
int skyband;

memset(&pstats_accum, 0, sizeof(pstats_accum));
pstats_accum.max_weight=-1;

thread_mutex_lock(&(ei->mutex));
for(i=0;i<count;i++) {
	memcpy(&pstats, &(tmp_pstat[i]), sizeof(POWER_SUM_STATS));



	skyband=ps[0][i].skyband;

	if(pstats.max_weight_loss_fraction>=1) {
		ei->band_masked_count[skyband]++;
		continue;
		}
	ei->band_valid_count[skyband]++;

	#define FILL_EXTRA_PARAMS(target) {\
		target.ra=ps[0][i].ra; \
		target.dec=ps[0][i].dec; \
		target.spindown=ps[0][i].spindown; \
		target.fdotdot=ps[0][i].fdotdot; \
		target.freq_modulation_freq=ps[0][i].freq_modulation_freq; \
		target.freq_modulation_depth=ps[0][i].freq_modulation_depth; \
		target.freq_modulation_phase=ps[0][i].freq_modulation_phase; \
		target.frequency=(double)ps[0][i].freq_shift+((target).bin+first_bin+side_cut)/args_info.sft_coherence_time_arg; \
		}

	#define FILL_POINT_STATS(target, source)	{\
		memcpy(&(target), &(source), sizeof(target)); \
		FILL_EXTRA_PARAMS(target); \
		}

	#define UPDATE_MAX(target, field) {\
		if(pstats.field>target.field) { \
			target.field=pstats.field;\
			} \
		}

	#define UPDATE_MIN(target, field) {\
		if(pstats.field<target.field) { \
			target.field=pstats.field;\
			} \
		}

	if(ei->band_info[skyband].max_weight<0) {
		memcpy(&(ei->band_info[skyband]), &pstats, sizeof(pstats));
		FILL_EXTRA_PARAMS(ei->band_info[skyband].highest_ul);
		FILL_EXTRA_PARAMS(ei->band_info[skyband].highest_circ_ul);
		FILL_EXTRA_PARAMS(ei->band_info[skyband].highest_snr);
		FILL_EXTRA_PARAMS(ei->band_info[skyband].highest_ks);
		} else {

		ei->band_info[skyband].ntemplates+=pstats.ntemplates;

		if(pstats.highest_ul.ul>ei->band_info[skyband].highest_ul.ul) {
			FILL_POINT_STATS(ei->band_info[skyband].highest_ul, pstats.highest_ul);
			}
	
		if(pstats.highest_circ_ul.ul>ei->band_info[skyband].highest_circ_ul.ul) {
			FILL_POINT_STATS(ei->band_info[skyband].highest_circ_ul, pstats.highest_circ_ul);
			}
	
		if(pstats.highest_snr.snr>ei->band_info[skyband].highest_snr.snr) {
			FILL_POINT_STATS(ei->band_info[skyband].highest_snr, pstats.highest_snr);
			}
	
		if(pstats.highest_ks.ks_value>ei->band_info[skyband].highest_ks.ks_value) {
			FILL_POINT_STATS(ei->band_info[skyband].highest_ks, pstats.highest_ks);
			}
	
		UPDATE_MAX(ei->band_info[skyband], max_weight);
		UPDATE_MIN(ei->band_info[skyband], min_weight);
		UPDATE_MAX(ei->band_info[skyband], max_weight_loss_fraction);

		UPDATE_MAX(ei->band_info[skyband], max_m1_neg);
		UPDATE_MIN(ei->band_info[skyband], min_m1_neg);
		UPDATE_MAX(ei->band_info[skyband], max_m3_neg);
		UPDATE_MIN(ei->band_info[skyband], min_m3_neg);
		UPDATE_MAX(ei->band_info[skyband], max_m4);
		UPDATE_MIN(ei->band_info[skyband], min_m4);

		}


	/* No need to fill extra parameters as results are printed in this function */
	if(pstats_accum.max_weight<0) {
		memcpy(&pstats_accum, &pstats, sizeof(pstats));
		continue;
		}

	pstats_accum.ntemplates+=pstats.ntemplates;

	if(pstats.highest_ul.ul>pstats_accum.highest_ul.ul) {
		memcpy(&pstats_accum.highest_ul, &pstats.highest_ul, sizeof(pstats.highest_ul));
		highest_ul_idx=i;
		}

	if(pstats.highest_circ_ul.ul>pstats_accum.highest_circ_ul.ul) {
		memcpy(&pstats_accum.highest_circ_ul, &pstats.highest_circ_ul, sizeof(pstats.highest_circ_ul));
		highest_circ_ul_idx=i;
		}

	if(pstats.highest_snr.snr>pstats_accum.highest_snr.snr) {
		memcpy(&pstats_accum.highest_snr, &pstats.highest_snr, sizeof(pstats.highest_snr));
		highest_snr_idx=i;
		}

	if(pstats.highest_ks.ks_value>pstats_accum.highest_ks.ks_value) {
		memcpy(&pstats_accum.highest_ks, &pstats.highest_ks, sizeof(pstats.highest_ks));
		}

	UPDATE_MAX(pstats_accum, max_weight);
	UPDATE_MIN(pstats_accum, min_weight);
	UPDATE_MAX(pstats_accum, max_weight_loss_fraction);

	UPDATE_MAX(pstats_accum, max_m1_neg);
	UPDATE_MIN(pstats_accum, min_m1_neg);
	UPDATE_MAX(pstats_accum, max_m3_neg);
	UPDATE_MIN(pstats_accum, min_m3_neg);
	UPDATE_MAX(pstats_accum, max_m4);
	UPDATE_MIN(pstats_accum, min_m4);

	}
//free_partial_power_sum_F(pps);
thread_mutex_unlock(&(ei->mutex));

thread_mutex_lock(&data_logging_mutex);

if(write_data_log_header) {
	write_data_log_header=0;
	/* we write this into the main log file so that data.log files can simply be concatenated together */
	fprintf(LOG, "data_log: kind label index set pi pps_count template_count first_bin min_gps max_gps skyband frequency spindown fdotdot freq_modulation_freq freq_modulation_depth freq_modulation_phase ra dec iota psi snr ul ll M S ks_value ks_count m1_neg m3_neg m4 frequency_bin max_weight weight_loss_fraction max_ks_value max_m1_neg min_m1_neg max_m3_neg min_m3_neg max_m4 min_m4 max_weight_loss_fraction\n");
	}

/* now that we know extreme points go and characterize them */
#define WRITE_POINT(psum, pstat, kind)	{\
	fprintf(DATA_LOG, "%s \"%s\" %d %s %d %d %d %d %lf %lf %d %lf %lg %lg %lg %lg %lg %lf %lf %lf %lf %lf %lg %lg %lg %lg %lf %d %lf %lf %lf %d %lg %lf %lf %lf %lf %lf %lf %lf %lf %lf\n", \
		kind, \
		args_info.label_arg, \
		data_log_index, \
		ei->name, \
		pi, \
		count, \
		pstats_accum.ntemplates, \
		first_bin+side_cut, \
		psum.min_gps, \
		psum.max_gps, \
		psum.skyband, \
		(pstat.bin+first_bin+side_cut)/args_info.sft_coherence_time_arg+psum.freq_shift, \
		psum.spindown, \
		psum.fdotdot, \
		psum.freq_modulation_freq, \
		psum.freq_modulation_depth, \
		psum.freq_modulation_phase, \
		psum.ra, \
		psum.dec, \
		pstat.iota, \
		pstat.psi, \
		pstat.snr, \
		pstat.ul, \
		pstat.ll, \
		pstat.M, \
		pstat.S, \
		pstat.ks_value, \
		pstat.ks_count, \
		pstat.m1_neg, \
		pstat.m3_neg, \
		pstat.m4, \
		pstat.bin, \
		pstat.max_weight, \
		pstat.weight_loss_fraction, \
		pstats_accum.highest_ks.ks_value, \
		pstats_accum.max_m1_neg, \
		pstats_accum.min_m1_neg, \
		pstats_accum.max_m3_neg, \
		pstats_accum.min_m3_neg, \
		pstats_accum.max_m4, \
		pstats_accum.min_m4, \
		pstats_accum.max_weight_loss_fraction \
		); data_log_index++; }

if(args_info.output_cache_arg) {
	WRITE_POINT(ps[0][highest_ul_idx], pstats_accum.highest_ul, "ul");
	WRITE_POINT(ps[0][highest_circ_ul_idx], pstats_accum.highest_circ_ul, "circ");
	}
if((pstats_accum.highest_snr.snr>args_info.min_candidate_snr_arg) &
   (pstats_accum.highest_snr.bin>=args_info.tail_veto_arg) &
   (pstats_accum.highest_snr.bin<(useful_bins-args_info.tail_veto_arg)))WRITE_POINT(ps[0][highest_snr_idx], pstats_accum.highest_snr, "snr");

thread_mutex_unlock(&data_logging_mutex);

#define FILL_SKYMAP(skymap, value)	if(ei->skymap!=NULL)ei->skymap[pi]=value;

FILL_SKYMAP(ul_skymap, pstats_accum.highest_ul.ul);
FILL_SKYMAP(ul_freq_skymap, (pstats_accum.highest_ul.bin)/args_info.sft_coherence_time_arg+ps[0][highest_ul_idx].freq_shift);

FILL_SKYMAP(circ_ul_skymap, pstats_accum.highest_circ_ul.ul);
FILL_SKYMAP(circ_ul_freq_skymap, (pstats_accum.highest_circ_ul.bin)/args_info.sft_coherence_time_arg+ps[0][highest_circ_ul_idx].freq_shift);

FILL_SKYMAP(snr_skymap, pstats_accum.highest_snr.snr);
FILL_SKYMAP(snr_ul_skymap, pstats_accum.highest_snr.ul);
FILL_SKYMAP(snr_freq_skymap, (pstats_accum.highest_snr.bin)/args_info.sft_coherence_time_arg+ps[0][highest_snr_idx].freq_shift);

FILL_SKYMAP(max_weight_skymap, pstats_accum.max_weight);
FILL_SKYMAP(min_weight_skymap, pstats_accum.min_weight);
FILL_SKYMAP(weight_loss_fraction_skymap, pstats_accum.max_weight_loss_fraction);

FILL_SKYMAP(ks_skymap, pstats_accum.highest_ks.ks_value);
}
Example #3
0
File: s2.cpp Project: dCache/s2
/********************************************************************
 * Parse command-line arguments (non -+ options)
 *
 * Returns:
 *   ERR_OK: if success
 *   >= ERR_OK: otherwise
 ********************************************************************/
static int
s2_run(int argc, char **argv, int i)
{
  int rval = ERR_OK, lval;
  int i_1 = i;
  Node *root = NULL;
  Process *proc = NULL;
  BOOL tp_created = FALSE;

  /* init progress bar */
  Process::progress(-1,proc);

#if defined(HAVE_SRM21) || defined(HAVE_SRM22)
  srm_init();
#endif

  lval = parse(opts.scr_fname, &root);
  DM_DBG(DM_N(1), "parser return value=%d\n", lval);
  UPDATE_MAX(rval, lval);
  if(rval > opts.s2_eval) {
    /* stop evaluation */
    UPDATE_MAX(rval, ERR_NEXEC);
    goto cleanup;
  }

  /* create thread pool */
  if(!tp_created) tp_init(opts.tp_size);
  tp_created = TRUE;

  /* pretty-print S2 tree ($ENV{VAR} are evaluated) */
  if(opts.pp_fname) lval = pp_print(root);
  DM_DBG(DM_N(1), "pretty-printer return value=%d\n", lval);
  UPDATE_MAX(rval, lval);

  if(root) {
    Process::threads_init();
    proc = new Process(root, NULL, NULL);

    if(!proc) {
      DM_ERR(ERR_SYSTEM, _("failed to create a Process: %s\n"), _(strerror(errno)));
      UPDATE_MAX(rval, ERR_SYSTEM);
      goto cleanup;
    }

    /* write ${0}..${n} variables */
    const char *name = cmd_label();
    proc->WriteVariable("0", name, TRUE);
    for(; i < argc; i++) {
      proc->WriteVariable(i2str(i - i_1 + 1).c_str(), argv[i], TRUE);
    }

    setenv("CLIENT_INFO", build_client_info(name), 1);

    lval = proc->eval();
    Process::threads_destroy();
    DM_DBG(DM_N(1), "evaluation return value=%d\n", lval);
    UPDATE_MAX(rval, lval);
  }

  /* after-evaluation print of the tree */
  if(opts.e2_fname) lval = e2_print(root);
  DM_DBG(DM_N(2), "after-evaluation print return value=%d\n", lval);
  UPDATE_MAX(rval, lval);

cleanup:
  /* cleanup */
  DELETE(proc);	/* free proc *first*, then root */
  DELETE(root);

  /* destroy thread pool */
  if(tp_created) tp_cleanup();

  /* hide progress bar */
  Process::progress(0,proc);

  DM_DBG(DM_N(1), "s2_run return value=%d\n", rval);
  return rval;
}
Example #4
0
File: s2.cpp Project: dCache/s2
static void
WarnCB(dg_callback cbData)
{
  UPDATE_MAX(diagnose_val, cbData.level);	/* increase the return value */
} /* WarnCB */