Example #1
0
/**
  fitscopy ~/DATA/tycho2-cut.fits"[RA<10 && DEC > 0 && DEC < 10]" t.fits
  build-index -i t.fits -o t10.index -P 10 -E -M -v -S mag
  build-index -1 t10.index -o t11.index -P 11 -E -M -v -S mag
  build-index -1 t10.index -o t12.index -P 12 -E -M -v -S mag
  fitsgetext -i t10.index -o t10.skdt -e 0 -e 7 -e 8 -e 9 -e 10 -e 11 -e 12 -e 13
  fitsgetext -i t10.index -o t10.ind -e 0 -e 1 -e 2 -e 3 -e 4 -e 5 -e 6
  fitsgetext -i t11.index -o t11.ind -e 0 -e 1 -e 2 -e 3 -e 4 -e 5 -e 6
  fitsgetext -i t12.index -o t12.ind -e 0 -e 1 -e 2 -e 3 -e 4 -e 5 -e 6
 */
void test_multiindex(CuTest* ct) {
	sl* fns;
	multiindex_t* mi;
	int i;

	fns = sl_new(4);
	sl_append(fns, "t10.ind");
	sl_append(fns, "t11.ind");
	sl_append(fns, "t12.ind");
	mi = multiindex_open("t10.skdt", fns);

	printf("Got %i indices\n", multiindex_n(mi));
	for (i=0; i<multiindex_n(mi); i++) {
		index_t* ind = multiindex_get(mi, i);
		printf("  %i: %s, %i stars, %i quads (%g to %g arcmin)\n",
			   i, ind->indexname, index_nquads(ind), index_nstars(ind),
			   ind->index_scale_lower/60., ind->index_scale_upper/60.);
	}

	multiindex_free(mi);
	sl_free2(fns);
}
void test_solve_multiindex(CuTest* ct) {
    sl* fns;
    multiindex_t* mi;
    int i;
    solver_t* s = NULL;
    starxy_t* field = NULL;
    MatchObj* mo = NULL;
    xylist_t* xy = NULL;

    log_init(LOG_VERB);

    fns = sl_new(4);
    sl_append(fns, "../util/t10.ind");
    sl_append(fns, "../util/t11.ind");
    sl_append(fns, "../util/t12.ind");
    mi = multiindex_open("../util/t10.skdt", fns, 0);

    printf("Got %i indices\n", multiindex_n(mi));
    for (i=0; i<multiindex_n(mi); i++) {
        index_t* ind = multiindex_get(mi, i);
        printf("  %i: %s, %i stars, %i quads (%g to %g arcmin)\n",
               i, ind->indexname, index_nquads(ind), index_nstars(ind),
               ind->index_scale_lower/60., ind->index_scale_upper/60.);
    }

    s = solver_new();

    // 10.8
    s->funits_lower = 5.0;
    s->funits_upper = 15.0;

    xy = xylist_open("../util/t1.xy");
    if (!xy) {
        ERROR("Failed to open xylist\n");
        CuFail(ct, "xylist");
    }
    field = xylist_read_field(xy, NULL);

    solver_set_field(s, field);
    solver_set_field_bounds(s, 0, 1000, 0, 1000);

    for (i=0; i<multiindex_n(mi); i++) {
        index_t* ind = multiindex_get(mi, i);
        solver_add_index(s, ind);
    }

    solver_run(s);

    if (solver_did_solve(s)) {
        mo = solver_get_best_match(s);
        matchobj_print(mo, LOG_MSG);

        // HACK -- ugly!!
        verify_free_matchobj(mo);
    }

    xylist_close(xy);

    solver_cleanup_field(s);
    solver_free(s);

    multiindex_free(mi);
    sl_free2(fns);
}