int scamp_write_field(const qfits_header* imageheader, const sip_t* wcs, const starxy_t* xy, const char* filename) { scamp_cat_t* scamp; qfits_header* hdr; int i; if (!imageheader) hdr = qfits_table_prim_header_default(); else hdr = qfits_header_copy(imageheader); sip_add_to_header(hdr, wcs); scamp = scamp_catalog_open_for_writing(filename, FALSE); if (!scamp) { return -1; } if (scamp_catalog_write_field_header(scamp, hdr)) { return -1; } qfits_header_destroy(hdr); for (i=0; i<starxy_n(xy); i++) { scamp_obj_t obj; obj.x = starxy_getx(xy, i); obj.y = starxy_gety(xy, i); obj.err_a = 1.0; obj.err_b = 1.0; obj.err_theta = 0.0; if (xy->flux) obj.flux = xy->flux[i]; else obj.flux = 1000.0; obj.err_flux = 1.0; obj.flags = 0; if (scamp_catalog_write_object(scamp, &obj)) { return -1; } } if (scamp_catalog_close(scamp)) { return -1; } return 0; }
static int ansip_add_to_header(const sip_t* sip, qfits_header* hdr) { sip_add_to_header(hdr, sip); return 0; }
qfits_header* sip_create_header(const sip_t* sip) { qfits_header* hdr = qfits_table_prim_header_default(); sip_add_to_header(hdr, sip); return hdr; }