24#include <cxmessages.h>
28#include "girvcorrection.h"
29#include "giastrometry.h"
75 cxdouble exptime = 0.;
77 cxdouble equinox = 2000.;
78 cxdouble longitude = 0.;
79 cxdouble latitude = 0.;
80 cxdouble elevation = 0.;
82 cxdouble tel_dec = 0.;
84 const cpl_propertylist* properties = NULL;
86 cpl_table* _fibers = NULL;
89 if ((fibers == NULL) || (spectra == NULL)) {
94 cx_assert(properties != NULL);
101 if (cpl_propertylist_has(properties, GIALIAS_EXPTIME) == FALSE) {
105 exptime = cpl_propertylist_get_double(properties, GIALIAS_EXPTIME);
108 if (cpl_propertylist_has(properties, GIALIAS_MJDOBS) == FALSE) {
118 jd = cpl_propertylist_get_double(properties, GIALIAS_MJDOBS);
119 jd += 2400000.5 + 0.5 * exptime / (24. * 3600.);
123 if (cpl_propertylist_has(properties, GIALIAS_EQUINOX) == FALSE) {
127 equinox = cpl_propertylist_get_double(properties, GIALIAS_EQUINOX);
135 if (cpl_propertylist_has(properties, GIALIAS_TEL_LON) == FALSE) {
145 longitude = -cpl_propertylist_get_double(properties, GIALIAS_TEL_LON);
149 if (cpl_propertylist_has(properties, GIALIAS_TEL_LAT) == FALSE) {
153 latitude = cpl_propertylist_get_double(properties, GIALIAS_TEL_LAT);
156 if (cpl_propertylist_has(properties, GIALIAS_TEL_ELEV) == FALSE) {
160 elevation = cpl_propertylist_get_double(properties, GIALIAS_TEL_ELEV);
168 if (cpl_propertylist_has(properties, GIALIAS_RADEG) == FALSE) {
172 tel_ra = cpl_propertylist_get_double(properties, GIALIAS_RADEG);
175 if (cpl_propertylist_has(properties, GIALIAS_DECDEG) == FALSE) {
179 tel_dec = cpl_propertylist_get_double(properties, GIALIAS_DECDEG);
191 if ((cpl_table_has_column(_fibers,
"RA") == FALSE) ||
192 (cpl_table_has_column(_fibers,
"DEC") == FALSE)) {
196 if (cpl_table_has_column(_fibers,
"RP") == FALSE) {
201 giraffe_error_push();
203 if (cpl_table_has_column(_fibers,
"GCORR") == FALSE) {
204 cpl_table_new_column(_fibers,
"GCORR", CPL_TYPE_DOUBLE);
207 if (cpl_table_has_column(_fibers,
"HCORR") == FALSE) {
208 cpl_table_new_column(_fibers,
"HCORR", CPL_TYPE_DOUBLE);
211 if (cpl_table_has_column(_fibers,
"BCORR") == FALSE) {
212 cpl_table_new_column(_fibers,
"BCORR", CPL_TYPE_DOUBLE);
215 if (cpl_error_get_code() != CPL_ERROR_NONE) {
222 nr = cpl_table_get_nrow(_fibers);
224 for (fiber = 0; fiber < nr; ++fiber) {
226 cxint rp = cpl_table_get_int(_fibers,
"RP", fiber, NULL);
228 GiRvCorrection rv = {0., 0., 0.};
233 register cxdouble ra = 0.;
234 register cxdouble dec = 0.;
251 ra = cpl_table_get_double(_fibers,
"RA", fiber, NULL);
252 dec = cpl_table_get_double(_fibers,
"DEC", fiber, NULL);
264 elevation, ra, dec, equinox);
269 cpl_table_set_double(_fibers,
"GCORR", fiber, rv.gc);
270 cpl_table_set_double(_fibers,
"HCORR", fiber, rv.hc);
271 cpl_table_set_double(_fibers,
"BCORR", fiber, rv.bc);
cxint giraffe_add_rvcorrection(GiTable *fibers, const GiImage *spectra)
Add the barycentric and heliocentric corrections to the given fiber setup.
cpl_propertylist * giraffe_image_get_properties(const GiImage *self)
Get the properties of an image.
void giraffe_rvcorrection_compute(GiRvCorrection *rv, cxdouble jdate, cxdouble longitude, cxdouble latitude, cxdouble elevation, cxdouble ra, cxdouble dec, cxdouble equinox)
Compute heliocentric, barycentric and geocentric correction.
cpl_table * giraffe_table_get(const GiTable *self)
Get the table data from a Giraffe table.