27 #include "giwavecalib_types.h"
52 GiWcalSolution* tmp = NULL;
54 tmp = (GiWcalSolution*) cx_calloc(1,
sizeof(GiWcalSolution));
56 tmp->subslitfit = FALSE;
57 tmp->opt_mod = LMRQ_UNDEFINED;
58 tmp->opt_mod_params = NULL;
59 tmp->wav_coeffs = NULL;
79 if (ws==NULL) {
return; }
81 if (ws->opt_mod_params!=NULL)
82 cpl_matrix_delete(ws->opt_mod_params);
83 if (ws->wav_coeffs!=NULL)
104 const cxchar *fctid =
"giraffe_wcalsolution_dump";
106 cpl_msg_debug(fctid,
"---- GiWcalSolution --------------------");
110 cpl_msg_debug(fctid,
"Empty GiWcalSolution!");
112 cpl_msg_debug(fctid,
"Subslit fitted : %s",
113 ws->subslitfit ?
"YES" :
"NO" );
115 if (ws->opt_mod==LMRQ_XOPTMOD) {
116 cpl_msg_debug(fctid,
"Opt Model : xoptmod");
117 }
else if (ws->opt_mod==LMRQ_XOPTMOD2) {
118 cpl_msg_debug(fctid,
"Opt Model : xoptmod2");
120 cpl_msg_debug(fctid,
"Opt Model : undefined");
123 cpl_msg_debug(fctid,
"Optical Model Parameters :");
124 if (ws->opt_mod_params!=NULL) {
127 cpl_msg_debug(fctid,
"NONE!");
131 cpl_msg_debug(fctid,
"Slit Geometry :");
132 if (ws->wav_coeffs!=NULL) {
135 cpl_msg_debug(fctid,
"Subslit [%d] : ", i);
142 cpl_msg_debug(fctid,
"NONE!!");
167 GiWcalSolution *wavcoeff = NULL;
169 cpl_plist *_properties = NULL;
170 cpl_table *_table = NULL;
172 cxint poly_x_deg = 0,
178 cpl_matrix *coefficients = NULL;
179 cxdouble *pd_coefficients = NULL;
183 if (wavesolution==NULL) {
return NULL; }
185 wavcoeff = (GiWcalSolution*) cx_calloc(1,
sizeof(GiWcalSolution));
196 if (cpl_plist_contains(_properties, GIALIAS_WSOL_SUBSLITS)) {
197 if (cpl_plist_get_bool(_properties, GIALIAS_WSOL_SUBSLITS) == FALSE)
198 wavcoeff->subslitfit = FALSE;
200 wavcoeff->subslitfit = TRUE;
208 if (cpl_plist_contains(_properties, GIALIAS_WSOL_OMNAME)) {
209 const cxchar *optmod;
210 optmod = cpl_plist_get_string(_properties, GIALIAS_WSOL_OMNAME);
212 if (strcmp(optmod,
"xoptmod2")==0)
213 wavcoeff->opt_mod = LMRQ_XOPTMOD2;
214 else if (strcmp(optmod,
"xoptmod")==0)
215 wavcoeff->opt_mod = LMRQ_XOPTMOD;
217 wavcoeff->opt_mod = LMRQ_UNDEFINED;
220 if (wavcoeff->opt_mod==LMRQ_XOPTMOD2) {
222 wavcoeff->opt_mod_params = cpl_matrix_new(7,1);
224 if (cpl_plist_contains(_properties, GIALIAS_WSOL_OMDIR)) {
226 wavcoeff->opt_mod_params,
229 cpl_plist_get_int(_properties, GIALIAS_WSOL_OMDIR)
236 if (cpl_plist_contains(_properties, GIALIAS_WSOL_OMFCOLL)) {
238 wavcoeff->opt_mod_params,
241 cpl_plist_get_double(_properties, GIALIAS_WSOL_OMFCOLL)
248 if (cpl_plist_contains(_properties, GIALIAS_WSOL_OMGCAM)) {
250 wavcoeff->opt_mod_params,
253 cpl_plist_get_double(_properties, GIALIAS_WSOL_OMGCAM)
260 if (cpl_plist_contains(_properties, GIALIAS_WSOL_OMGTHETA)) {
262 wavcoeff->opt_mod_params,
265 cpl_plist_get_double(_properties, GIALIAS_WSOL_OMGTHETA)
272 if (cpl_plist_contains(_properties, GIALIAS_WSOL_OMSDX)) {
274 wavcoeff->opt_mod_params,
277 cpl_plist_get_double(_properties, GIALIAS_WSOL_OMSDX)
284 if (cpl_plist_contains(_properties, GIALIAS_WSOL_OMSDY)) {
289 wavcoeff->opt_mod_params,
292 cpl_plist_get_double(_properties, GIALIAS_WSOL_OMSDY)
300 if (cpl_plist_contains(_properties, GIALIAS_WSOL_OMSPHI)) {
302 wavcoeff->opt_mod_params,
305 cpl_plist_get_double(_properties, GIALIAS_WSOL_OMSPHI)
313 }
else if (wavcoeff->opt_mod==LMRQ_XOPTMOD) {
315 wavcoeff->opt_mod_params = cpl_matrix_new(4,1);
317 if (cpl_plist_contains(_properties, GIALIAS_WSOL_OMDIR)) {
319 wavcoeff->opt_mod_params,
322 cpl_plist_get_int(_properties, GIALIAS_WSOL_OMDIR)
329 if (cpl_plist_contains(_properties, GIALIAS_WSOL_OMFCOLL)) {
331 wavcoeff->opt_mod_params,
334 cpl_plist_get_double(_properties, GIALIAS_WSOL_OMFCOLL)
341 if (cpl_plist_contains(_properties, GIALIAS_WSOL_OMGCAM)) {
343 wavcoeff->opt_mod_params,
346 cpl_plist_get_double(_properties, GIALIAS_WSOL_OMGCAM)
353 if (cpl_plist_contains(_properties, GIALIAS_WSOL_OMGTHETA)) {
355 wavcoeff->opt_mod_params,
358 cpl_plist_get_double(_properties, GIALIAS_WSOL_OMGTHETA)
376 if (cpl_plist_contains(_properties, GIALIAS_XRES_PDEG)) {
378 cxchar *l, *r, *tmpstr;
380 tmpstr = (cxchar*) cpl_plist_get_string(_properties, GIALIAS_XRES_PDEG);
385 poly_x_deg = atoi(l) + 1;
386 poly_y_deg = atoi(r) + 1;
394 ncoefficients = poly_x_deg * poly_y_deg;
396 coefficients = cpl_matrix_new(poly_x_deg,poly_y_deg);
397 pd_coefficients = cpl_matrix_get_data(coefficients);
399 subslitfit = cpl_table_get_int(_table,
"SSN", 0, NULL);
401 for (i=0; i<ncoefficients; i++) {
403 snprintf(buffer,
sizeof(buffer),
"XC%-d", i);
406 cpl_table_get_double(_table, buffer, 0, NULL);
void giraffe_matrix_dump(const cpl_matrix *matrix, cxint max_rows)
Output a maximum number of rows of the input matrix.
void giraffe_slitgeometry_resize(GiSlitGeometry *self, cxint size)
Destructive resize of a GiSlitGeometry.
cxint giraffe_slitgeometry_size(GiSlitGeometry *self)
Returns current size of a GiSlitGeometry.
cpl_matrix * giraffe_slitgeometry_get(GiSlitGeometry *self, cxint pos)
Gets a reference to the matrix at a specified position.
GiSlitGeometry * giraffe_slitgeometry_new(void)
Create a new GiSlitGeometry.
void giraffe_slitgeometry_set(GiSlitGeometry *self, cxint pos, cpl_matrix *nm)
Sets (copies) a cpl_matrix to a specified position of the GiSlitGeometry.
void giraffe_slitgeometry_delete(GiSlitGeometry *self)
Destroy an GiSlitGeometry.
cpl_propertylist * giraffe_table_get_properties(const GiTable *self)
Gets the table properties.
cpl_table * giraffe_table_get(const GiTable *self)
Get the table data from a Giraffe table.
GiWcalSolution * giraffe_wcalsolution_new(void)
Create a new GiWcalSolution.
void giraffe_wcalsolution_delete(GiWcalSolution *ws)
Destroy an GiWcalSolution.
void giraffe_wcalsolution_dump(GiWcalSolution *ws)
Dump the the information contained in a GiWcalSolution to output.
GiWcalSolution * giraffe_wcalsolution_create(GiTable *wavesolution)
Create a wavecalibration results structure based on a GiTable read from disk.