32 #include <fors_star.h>
34 #include <fors_utils.h>
78 if (colname != NULL && colname[0] !=
'\0')
81 d = cpl_table_get( tab, colname, row, &null);
82 assure( !cpl_error_get_code(),
116 double smajor,
double sminor,
121 assure( smajor >= sminor && sminor >= 0,
return NULL,
122 "Illegal semi major/minor axes: %g, %g",
125 assure( 0 <= si && si <= 1,
return NULL,
126 "Stellarity index must be between 0 and 1, is %f",
129 assure( fwhm >= 0,
return NULL,
130 "Star FWHM must be non-negative, is %f",
137 s->semi_major = smajor;
138 s->semi_minor = sminor;
139 s->stellarity_index = si;
140 s->orientation = orientation;
143 s->magnitude_corr = 0;
144 s->dmagnitude_corr = 0;
153 #define cleanup fors_star_delete(&s)
174 const char *fwhm_col,
175 const char *smaj_col,
176 const char *smin_col,
177 const char *theta_col,
179 const char *dmag_col,
180 const char *stlndx_col)
187 assure(!cpl_error_get_code(),
return s, NULL);
190 assure(!cpl_error_get_code(),
return s, NULL);
193 assure(!cpl_error_get_code(),
return s, NULL);
196 assure(!cpl_error_get_code(),
return s, NULL);
199 assure(!cpl_error_get_code(),
return s, NULL);
202 assure(!cpl_error_get_code(),
return s, NULL);
205 assure(!cpl_error_get_code(),
return s, NULL);
208 assure(!cpl_error_get_code(),
return s, NULL);
210 s->magnitude_corr = 0;
211 s->dmagnitude_corr = 0;
231 success &= (star != NULL);
232 success &= (star->semi_major >= star->semi_minor);
233 success &= (0.0 <= star->stellarity_index && star->stellarity_index <= 1.0);
234 success &= (star->fwhm > 0.0);
252 assure( star != NULL,
return NULL, NULL );
254 d = cpl_malloc(
sizeof(*d));
260 if (star->id != NULL) {
261 d->id = fors_std_star_duplicate(star->id);
277 if ((*star)->id != NULL) {
278 fors_std_star_delete_const(&((*star)->id));
280 cpl_free(*star); *star = NULL;
295 cpl_free(*star); *star = NULL;
312 assure( s != NULL && t != NULL,
return true, NULL );
334 return (s1->magnitude < s2->magnitude);
349 assure( s != NULL,
return 0, NULL );
350 assure( t != NULL,
return 0, NULL );
367 assure( s != NULL,
return -1, NULL );
371 return s->fwhm / TWOSQRT2LN2;
386 assure( s != NULL,
return -1, NULL );
389 return s->stellarity_index;
404 assure( s != NULL,
return -1, NULL );
407 if (s->semi_major <= 0)
return 1;
408 else return 1 - (s->semi_minor / s->semi_major);
421 fors_msg(level,
"[NULL]");
424 fors_msg(level,
"at (%7.2f, %7.2f): m = %g +- %g (mc = %g +- %g), "
425 "shape: (%g, %g, %g)",
426 s->pixel->x, s->pixel->y,
427 s->magnitude, s->dmagnitude,
428 s->magnitude_corr, s->dmagnitude_corr,
429 s->orientation, s->semi_major, s->semi_minor);
445 if (sl == NULL) fors_msg(level,
"Null list");
449 for (s = fors_star_list_first_const(sl);
451 s = fors_star_list_next_const(sl)) {
469 assure( s != NULL,
return -1, NULL );
487 assure( s != NULL,
return -1, NULL );
506 assure( s != NULL,
return 0, NULL );
507 assure( s->id != NULL,
return 0, NULL );
510 return (s->id->magnitude - s->magnitude_corr);
524 assure( s != NULL,
return 0, NULL );
525 assure( s->id != NULL,
return 0, NULL );
528 return sqrt(s->dmagnitude_corr * s->dmagnitude_corr +
529 s->id->dmagnitude * s->id->dmagnitude);
544 assure( s != NULL,
return 0, NULL );
545 return (s->id != NULL && s->id->trusted);
550 #define LIST_ELEM fors_star
fors_point * fors_point_new(double x, double y)
Constructor.
double fors_star_get_x(const fors_star *s, void *data)
Get position.
void fors_star_print_list(cpl_msg_severity level, const fors_star_list *sl)
Print list of stars.
double fors_star_stellarity(const fors_star *s, void *data)
Get star stellarity.
double fors_star_ellipticity(const fors_star *s, void *data)
Get star ellipticity.
bool fors_star_equal(const fors_star *s, const fors_star *t)
Test for equality.
void fors_star_delete(fors_star **star)
Delete object and set pointer to NULL.
double fors_star_distsq(const fors_star *s, const fors_star *t)
Get distance between stars.
void fors_star_print(cpl_msg_severity level, const fors_star *s)
Print object.
static double _get_optional_table_value(const cpl_table *tab, unsigned int row, const char *colname)
Get a double value from a table.
void fors_point_delete(fors_point **p)
Destructor.
fors_star * fors_star_new(double x, double y, double fwhm, double smajor, double sminor, double orientation, double m, double dm, double si)
Constructor.
bool fors_star_is_identified(const fors_star *s, void *data)
Determine if star was identified.
fors_star * fors_star_duplicate(const fors_star *star)
Copy constructor.
double fors_star_get_y(const fors_star *s, void *data)
Get position.
double fors_star_get_zeropoint_err(const fors_star *s, void *data)
Get zeropoint error.
double fors_star_extension(const fors_star *s, void *data)
Get star size.
bool fors_star_brighter_than(const fors_star *s1, const fors_star *s2, void *data)
Compare star brightness.
fors_point * fors_point_duplicate(const fors_point *p)
Copy constructor.
bool fors_point_equal(const fors_point *p, const fors_point *q)
Equality.
bool fors_star_check_values(const fors_star *star)
Copy constructor.
void fors_star_delete_but_standard(fors_star **star)
Delete object and set pointer to NULL - but ignore the standard star.
double fors_point_distsq(const fors_point *p, const fors_point *q)
Metric.
double fors_star_get_zeropoint(const fors_star *s, void *data)
Get zeropoint.
fors_star * fors_star_new_from_table(const cpl_table *tab, unsigned int row, const char *x_col, const char *y_col, const char *fwhm_col, const char *smaj_col, const char *smin_col, const char *theta_col, const char *mag_col, const char *dmag_col, const char *stlndx_col)
Create a star from a table WITHOUT checking.