FORS Pipeline Reference Manual  5.0.9
test_simulate.c
1 /* $Id: test_simulate.c,v 1.34 2009-02-25 15:34:48 hlorch Exp $
2  *
3  * This file is part of the FORS Library
4  * Copyright (C) 2002-2006 European Southern Observatory
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /*
22  * $Author: hlorch $
23  * $Date: 2009-02-25 15:34:48 $
24  * $Revision: 1.34 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 
32 #include <test_simulate.h>
33 
34 #include <fors_instrument.h>
35 #include <fors_image.h>
36 #include <fors_dfs.h>
37 #include <fors_data.h>
38 #include <fors_pfits.h>
39 #include <fors_utils.h>
40 
41 #include <cpl.h>
42 
43 #include <math.h>
44 
45 /* FIXME: - remove FORS_DATA_STD_* !!!
46  * - replace below in create_std_cat()
47  * 1.) by creation of a standard star list, and
48  * 2.) and a new function fors_std_cat_test_create_stetson()
49  * in fors_std_cat.c
50  */
51 const char *const FORS_DATA_STD_MAG[FORS_NUM_FILTER] =
52 {"U",
53  "B",
54  //"G",
55  "V", /* G uses V */
56  "V",
57  "R",
58  "I",
59  "Z"};
60 
61 const char *const FORS_DATA_STD_DMAG[FORS_NUM_FILTER] =
62 {"ERR_U",
63  "ERR_B",
64  //"ERR_G",
65  "ERR_V", /* G uses V */
66  "ERR_V",
67  "ERR_R",
68  "ERR_I",
69  "ERR_Z"};
70 
71 const char *const FORS_DATA_STD_COL[FORS_NUM_FILTER] =
72 {"U_B",
73  "B_V",
74  "B_V",
75  "B_V",
76  "V_R",
77  "V_R",
78  "?Z?"};
79 
80 const char *const FORS_DATA_STD_RA = "RA";
81 const char *const FORS_DATA_STD_DEC = "DEC";
82 const char *const FORS_DATA_STD_NAME = "OBJECT";
83 
94 static const int det_nx = 400; /* Unbinned detector pixels */
95 static const int det_ny = 400;
96 static const int pres_nx = 5;
97 static const int binx = 2;
98 static const int biny = 2;
99 static const double ron = 4.0; /* ADU */
100 static const double conad = 0.78; /* e- / ADU */
101 
102 static const double bias_avg = 200; /* ADU */
103 static const double dark_avg = 50; /* ADU */
104 static const char *const instrume = "fors2";
105 static const char *const chip_id = "Test chip 234";
106 static const char *const read_clock = "200Kps/2ports/low_gain";
107 
115 static cpl_frame *
116 frame_new(const char *filename, const char *tag, cpl_frame_group group)
117 {
118  cpl_frame *f = cpl_frame_new();
119 
120  cpl_frame_set_filename(f, filename);
121  cpl_frame_set_tag (f, tag);
122  cpl_frame_set_group (f, group);
123 
124  return f;
125 }
126 
132 void
133 create_standard_keys(cpl_propertylist *header, double exptime)
134 {
135  int nx = det_nx / binx;
136  int ny = det_ny / biny;
137 
138  cpl_propertylist_update_string(header, "ESO DPR TYPE", "some");
139  cpl_propertylist_update_string(header, "ESO TPL ID", "tpl id.");
140  cpl_propertylist_update_string(header, "ESO INS COLL NAME", "collimator name");
141  cpl_propertylist_update_string(header, "ARCFILE", "archive filename");
142 
143  cpl_propertylist_update_string(header, FORS_PFITS_INSTRUME, instrume);
144  cpl_propertylist_update_string(header, FORS_PFITS_FILTER_NAME, "R_SPECIAL");
145 
146  cpl_propertylist_update_double(header, FORS_PFITS_AIRMASS_START, 1.156);
147  cpl_propertylist_update_double(header, FORS_PFITS_AIRMASS_END , 1.619);
148 
149  cpl_propertylist_update_int (header, "HIERARCH ESO DET CHIP1 NX", nx);
150  cpl_propertylist_update_int (header, "HIERARCH ESO DET CHIP1 NY", ny);
151  cpl_propertylist_update_int (header, "HIERARCH ESO DET OUT1 X", 1);
152  cpl_propertylist_update_int (header, "HIERARCH ESO DET OUT1 Y", 1);
153  cpl_propertylist_update_double(header, "HIERARCH ESO DET CHIP1 PSZX", 15.0);
154  cpl_propertylist_update_double(header, "HIERARCH ESO DET CHIP1 PSZY", 15.0);
155  cpl_propertylist_update_int (header, FORS_PFITS_DET_NY, ny);
156  cpl_propertylist_update_int (header, FORS_PFITS_DET_NX, nx);
157  cpl_propertylist_update_int (header, FORS_PFITS_DET_NY, ny);
158  cpl_propertylist_update_int (header, FORS_PFITS_BINX, binx);
159  cpl_propertylist_update_int (header, FORS_PFITS_BINY, biny);
160  cpl_propertylist_update_int (header, FORS_PFITS_OVERSCANX, 0);
161  cpl_propertylist_update_int (header, FORS_PFITS_OVERSCANY, 0);
162  cpl_propertylist_update_int (header, FORS_PFITS_PRESCANX, pres_nx);
163  cpl_propertylist_update_int (header, FORS_PFITS_PRESCANY, 0);
164 
165  cpl_propertylist_update_double(header, FORS_PFITS_PIXSCALE, 0.126);
166 
167  cpl_propertylist_update_int(header, FORS_PFITS_OUTPUTS, 1);
168  cpl_propertylist_update_double(header, FORS_PFITS_CONAD[0], conad);
169  cpl_propertylist_update_double(header, "HIERARCH ESO DET OUT1 GAIN", 1./conad);
170 
171  /* Convert RON to e- units */
172  cpl_propertylist_update_double(header, FORS_PFITS_RON[0], ron*conad);
173  cpl_propertylist_update_double(header, FORS_PFITS_EXPOSURE_TIME, exptime);
174 
175  cpl_propertylist_update_string(header, FORS_PFITS_CHIP_ID, chip_id);
176  cpl_propertylist_update_string(header, FORS_PFITS_READ_CLOCK, read_clock);
177 
178  /* WCS info, fine tuned to match simulated catalogue */
179  {
180  struct {
181  const char *name;
182  double value;
183  } data[] = {
184  {"CRVAL1", 8.1368333333},
185  {"CRVAL2", -46.9576388889},
186  {"CRPIX1", 1},
187  {"CRPIX2", 1},
188 // {"CD1_1", 5.81347849634012E-21},
189 // {"CD1_2", 9.49444444444444E-05},
190 // {"CD2_1",-9.49444444444444E-05},
191 // {"CD2_2",-5.81347849634012E-21},
192  {"CD1_1", 5.81347849634012E-20},
193  {"CD1_2", 9.49444444444444E-04},
194  {"CD2_1",-9.49444444444444E-04},
195  {"CD2_2",-5.81347849634012E-20},
196  {"PV2_1", 1.0},
197  {"PV2_2", 0.0},
198  {"PV2_3", 42.0},
199  {"PV2_4", 0.0},
200  {"PV2_5", 0.0}
201  };
202 
203  unsigned i;
204  for (i = 0; i < sizeof(data) / sizeof(*data); i++) {
205  cpl_propertylist_append_double(header, data[i].name, data[i].value);
206  }
207  }
208 
209  return;
210 }
211 
212 
213 #undef cleanup
214 #define cleanup \
215 do { \
216  fors_image_delete(&bias); \
217  cpl_propertylist_delete(header); \
218 } while(0)
219 
229 cpl_frame *
230 create_bias(const char *filename, const char *tag, cpl_frame_group group)
231 {
232  int nx = det_nx / binx + pres_nx;
233  int ny = det_ny / biny;
234  double exptime = 0.0;
235 
236  cpl_image *data = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
237  cpl_image *variance = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
238  fors_image *bias = NULL;
239  cpl_propertylist *header = cpl_propertylist_new();
240 
241  create_standard_keys(header, exptime);
242  cpl_propertylist_erase(header, FORS_PFITS_FILTER_NAME); /* No filter */
243 
244  {
245  int x, y;
246  for (y = 1; y <= ny; y++)
247  for (x = 1; x <= nx; x++) {
248  cpl_image_set(data , x, y,
249  (int)(bias_avg + ron*fors_rand_gauss() + 0.5));
250  cpl_image_set(variance, x, y, ron*ron);
251  }
252  }
253 
254  bias = fors_image_new(data, variance);
255  fors_image_save(bias, header, NULL, filename);
256 
257  assure( !cpl_error_get_code(), return NULL,
258  "Saving bias to %s failed", filename );
259 
260  cleanup;
261  return frame_new(filename, tag, group);
262 }
263 
273 cpl_frame *
274 create_master_bias(const char *filename, const char *tag, cpl_frame_group group)
275 {
276  int nx = det_nx / binx;
277  int ny = det_ny / biny;
278  double exptime = 0.0;
279 
280  cpl_image *data = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
281  cpl_image *variance = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
282  fors_image *bias = NULL;
283  cpl_propertylist *header = cpl_propertylist_new();
284 
285  create_standard_keys(header, exptime);
286  cpl_propertylist_erase(header, FORS_PFITS_FILTER_NAME); /* No filter */
287  cpl_propertylist_append_double(header, "ESO QC DET OUT1 RON",4.44); /* No filter */
288 
289  {
290  int x, y;
291  for (y = 1; y <= ny; y++)
292  for (x = 1; x <= nx; x++) {
293  cpl_image_set(data , x, y,
294  (int)(ron*fors_rand_gauss() + 0.5)); //Overscan already removed
295  cpl_image_set(variance, x, y, ron*ron);
296  }
297  }
298 
299  bias = fors_image_new(data, variance);
300  fors_image_save(bias, header, NULL, filename);
301 
302  assure( !cpl_error_get_code(), return NULL,
303  "Saving master bias to %s failed", filename );
304 
305  cleanup;
306  return frame_new(filename, tag, group);
307 }
308 
309 #undef cleanup
310 #define cleanup \
311 do { \
312  fors_image_delete(&dark); \
313  cpl_propertylist_delete(header); \
314 } while(0)
315 
326 cpl_frame *
327 create_dark(const char *filename, const char *tag, cpl_frame_group group)
328 {
329  int nx = det_nx / binx + pres_nx;
330  int ny = det_ny / biny;
331  double exptime = 3.0;
332 
333  cpl_image *data = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
334  cpl_image *variance = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
335  fors_image *dark = NULL;
336  cpl_propertylist *header = cpl_propertylist_new();
337 
338  create_standard_keys(header, exptime);
339 
340  {
341  int x, y;
342  for (y = 1; y <= ny; y++)
343  for (x = 1; x <= nx; x++) {
344  double var = ron*ron + dark_avg/conad;
345 
346  cpl_image_set(data , x, y,
347  (int)(bias_avg + dark_avg +
348  sqrt(var)*fors_rand_gauss()
349  + 0.5));
350  cpl_image_set(variance, x, y, var);
351  }
352  //Fill the prescan region
353  for (y = 1; y <= ny; y++)
354  for (x = 1; x <= pres_nx; x++)
355  {
356  cpl_image_set(data , x, y,
357  (int)(bias_avg + ron*fors_rand_gauss() + 0.5));
358  cpl_image_set(variance, x, y, ron*ron);
359  }
360  }
361 
362  dark = fors_image_new(data, variance);
363  fors_image_save(dark, header, NULL, filename);
364 
365  assure( !cpl_error_get_code(), return NULL,
366  "Saving dark to %s failed", filename );
367 
368  cleanup;
369  return frame_new(filename, tag, group);
370 }
371 
372 
373 #undef cleanup
374 #define cleanup \
375 do { \
376  fors_image_delete(&sflat); \
377  cpl_propertylist_delete(header); \
378 } while(0)
379 
389 cpl_frame *
390 create_screen_flat(const char *filename, const char *tag, cpl_frame_group group)
391 {
392  int nx = det_nx / binx + pres_nx;
393  int ny = det_ny / biny;
394  double exptime = 3.0;
395 
396  cpl_image *data = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
397  cpl_image *variance = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
398  fors_image *sflat = NULL;
399  cpl_propertylist *header = cpl_propertylist_new();
400 
401  create_standard_keys(header, exptime);
402 
403  {
404  int x, y;
405  for (y = 1; y <= ny; y++)
406  for (x = 1; x <= nx; x++) {
407  double medium_scale_structure = 1000*(2 + sin(x*30.0/nx + y*30.0/ny));
408  double large_scale_structure = 1000*(1 + sin(x*4.0/nx));
409  double flat = 5000 + medium_scale_structure + large_scale_structure;
410  double var = ron*ron + flat/conad;
411 
412  cpl_image_set(data , x, y,
413  (int)(bias_avg + flat + sqrt(var)*fors_rand_gauss() + 0.5));
414  cpl_image_set(variance, x, y, var);
415  }
416  //Fill the prescan region
417  for (y = 1; y <= ny; y++)
418  for (x = 1; x <= pres_nx; x++)
419  {
420  cpl_image_set(data , x, y,
421  (int)(bias_avg + ron*fors_rand_gauss() + 0.5));
422  cpl_image_set(variance, x, y, ron*ron);
423  }
424  }
425 
426  sflat = fors_image_new(data, variance);
427  fors_image_save(sflat, header, NULL, filename);
428 
429  assure( !cpl_error_get_code(), return NULL,
430  "Saving screen flat to %s failed", filename );
431 
432  cleanup;
433  return frame_new(filename, tag, group);
434 }
435 
436 #undef cleanup
437 #define cleanup \
438 do { \
439  fors_image_delete(&sflat); \
440  cpl_propertylist_delete(header); \
441 } while(0)
442 
453 cpl_frame *
454 create_sky_flat(const char *filename, const char *tag, cpl_frame_group group,
455  double exptime)
456 {
457  int nx = det_nx / binx + pres_nx;
458  int ny = det_ny / biny;
459 
460  cpl_image *data = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
461  cpl_image *variance = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
462  fors_image *sflat = NULL;
463  cpl_propertylist *header = cpl_propertylist_new();
464 
465  create_standard_keys(header, exptime);
466 
467  {
468  int x, y;
469  for (y = 1; y <= ny; y++)
470  for (x = 1; x <= nx; x++) {
471  double medium_scale_structure = 1000*(2 + sin(x*30.0/nx - y*10.0/ny));
472  double large_scale_structure = 1000*(1 + sin(x*4.0/nx));
473  double flat = exptime*(5000 +
474  medium_scale_structure +
475  large_scale_structure);
476  double var = ron*ron + flat/conad;
477 
478  cpl_image_set(data , x, y,
479  (int)(flat + sqrt(var)*fors_rand_gauss() + 0.5));//Overscan already removed
480  cpl_image_set(variance, x, y, var);
481  }
482  //Fill the prescan region
483  for (y = 1; y <= ny; y++)
484  for (x = 1; x <= pres_nx; x++)
485  {
486  cpl_image_set(data , x, y,
487  (int)(bias_avg + ron*fors_rand_gauss() + 0.5));
488  cpl_image_set(variance, x, y, ron*ron);
489  }
490  }
491 
492  sflat = fors_image_new(data, variance);
493  fors_image_save(sflat, header, NULL, filename);
494 
495  assure( !cpl_error_get_code(), return NULL,
496  "Saving sky flat to %s failed", filename );
497 
498  cleanup;
499  return frame_new(filename, tag, group);
500 }
501 
513 cpl_frame *
514 create_master_sky_flat(const char *filename,
515  const char *tag, cpl_frame_group group,
516  double exptime)
517 {
518  int nx = det_nx / binx;
519  int ny = det_ny / biny;
520 
521  cpl_image *data = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
522  cpl_image *variance = cpl_image_new(nx, ny, FORS_IMAGE_TYPE);
523  fors_image *sflat = NULL;
524  cpl_propertylist *header = cpl_propertylist_new();
525 
526  create_standard_keys(header, exptime);
527 
528  {
529  int x, y;
530  for (y = 1; y <= ny; y++)
531  for (x = 1; x <= nx; x++) {
532  double medium_scale_structure = 1000*(2 + sin(x*30.0/nx - y*10.0/ny));
533  double large_scale_structure = 1000*(1 + sin(x*4.0/nx));
534  double flat = exptime*(5000 +
535  medium_scale_structure +
536  large_scale_structure);
537  double var = ron*ron + flat/conad;
538 
539  cpl_image_set(data , x, y,
540  (int)(flat + sqrt(var)*fors_rand_gauss() + 0.5));//Overscan already removed
541  cpl_image_set(variance, x, y, var);
542  }
543  }
544 
545  sflat = fors_image_new(data, variance);
546  fors_image_save(sflat, header, NULL, filename);
547 
548  assure( !cpl_error_get_code(), return NULL,
549  "Saving sky flat to %s failed", filename );
550 
551  cleanup;
552  return frame_new(filename, tag, group);
553 }
554 
562 cpl_frame *
563 create_standard(const char *filename, const char *tag, cpl_frame_group group)
564 {
565  // fixme: add stars
566  double exptime = 1.0;
567  return create_sky_flat(filename, tag, group, exptime);
568 }
569 
570 
571 #undef cleanup
572 #define cleanup \
573 do { \
574  cpl_table_delete(t); \
575 } while(0)
576 
584 cpl_frame *
585 create_std_cat(const char *filename, const char *tag, cpl_frame_group group)
586 {
587  cpl_table *t;
588  struct {
589  double ra, dec;
590  double magnitude, dmagnitude;
591  double col;
592  const char *name;
593  }
594  data[] = {
595  {8.15958, -47.0347, 15.824000, 0.001, 0.8, "object 1"},
596  {8.14792, -46.9664, 12.895000, 0.002, -0.2, ""},
597  {8.15083, -47.0092, 12.861000, 0.003, -0.3, " dff bject 1"},
598  {8.15583, -47.0222, 16.540001, 0.001, 0.7, "-9"},
599  {8.17167, -47.10 , 11.970000, 0.005, 0.12, NULL},
600  {8.14833, -47.0567, 13.861000, 0.003, -0.2, ""},
601  {8.1475 , -47.0411, 13.903000, 0.001, -0.8, "dddddddobject 1"},
602  {7.92542, 2.62917, 15.446000, 0.002, -0.2, "start 1"},
603  };
604 
605  int N = sizeof(data) / sizeof(*data);
606  int i;
607 
608  t = cpl_table_new(N);
609  cpl_table_new_column(t, FORS_DATA_STD_RA , CPL_TYPE_DOUBLE);
610  cpl_table_new_column(t, FORS_DATA_STD_DEC, CPL_TYPE_DOUBLE);
611  cpl_table_new_column(t, FORS_DATA_STD_NAME, CPL_TYPE_STRING);
612 
613  for (i = 0; i < FORS_NUM_FILTER; i++) {
614  if (!cpl_table_has_column(t, FORS_DATA_STD_MAG[i])) {
615  cpl_table_new_column(t, FORS_DATA_STD_MAG[i], CPL_TYPE_FLOAT);
616  }
617  if (!cpl_table_has_column(t, FORS_DATA_STD_DMAG[i])) {
618  cpl_table_new_column(t, FORS_DATA_STD_DMAG[i], CPL_TYPE_FLOAT);
619  }
620  if (!cpl_table_has_column(t, FORS_DATA_STD_COL[i])) {
621  cpl_table_new_column(t, FORS_DATA_STD_COL[i], CPL_TYPE_FLOAT);
622  }
623  }
624 
625  for (i = 0; i < N; i++) {
626  int j;
627 
628  cpl_table_set_double(t, FORS_DATA_STD_RA , i, data[i].ra);
629  cpl_table_set_double(t, FORS_DATA_STD_DEC , i, data[i].dec);
630  cpl_table_set_string(t, FORS_DATA_STD_NAME, i, data[i].name);
631 
632  for (j = 0; j < FORS_NUM_FILTER; j++) {
633  cpl_table_set_float (t, FORS_DATA_STD_MAG[j], i, data[i].magnitude);
634  cpl_table_set_float (t, FORS_DATA_STD_DMAG[j], i, data[i].dmagnitude);
635  cpl_table_set_float (t, FORS_DATA_STD_COL[j], i, data[i].col);
636  }
637  }
638 
639  cpl_table_save(t, NULL, NULL, filename, CPL_IO_DEFAULT);
640  assure( !cpl_error_get_code(), return NULL,
641  "Failed to save standard catalogue to %s", filename );
642 
643  cleanup;
644  return frame_new(filename, tag, group);
645 }
646 
647 
648 
649 #undef cleanup
650 #define cleanup \
651 do { \
652  cpl_table_delete(t); \
653 } while(0)
654 
662 cpl_frame *
663 create_phot_table(const char *filename, const char *tag, cpl_frame_group group)
664 {
665  cpl_table *t;
666  struct {
667  char band;
668  double ext_coeff, dext_coeff;
669  double color_term, dcolor_term;
670  double expected_zeropoint, dexpected_zeropoint;
671  }
672  data[FORS_NUM_FILTER] = {
673  {'U', 0.4 , 0.01, -0.076, 0.001, 20, 0.2},
674  {'B', 0.05 , 0.01, 0.033, 0.001, 21.123456, 0.2},
675  {'G', 0.1 , 0.01, 0.01 , 0.001, 22, 0.2},
676  {'V', 0.09 , 0.01, -0.02 , 0.001, -18, 0.2},
677  {'R', 0.2 , 0.01, 0.03 , 0.001, 0, 0.2},
678  {'I', 0.000, 0.01, -0.04 , 0.001, 1.0, 0.2},
679  };
680 
681  int N = fors_instrument_known_filters_get_number();
682  int i;
683 
684  t = cpl_table_new(N);
685  cpl_table_new_column(t, FORS_DATA_PHOT_FILTER , CPL_TYPE_STRING);
686  cpl_table_new_column(t, FORS_DATA_PHOT_EXTCOEFF , CPL_TYPE_DOUBLE);
687  cpl_table_new_column(t, FORS_DATA_PHOT_DEXTCOEFF , CPL_TYPE_DOUBLE);
688  cpl_table_new_column(t, FORS_DATA_PHOT_COLORTERM, CPL_TYPE_DOUBLE);
689  cpl_table_new_column(t, FORS_DATA_PHOT_DCOLORTERM, CPL_TYPE_DOUBLE);
690  cpl_table_new_column(t, FORS_DATA_PHOT_ZEROPOINT, CPL_TYPE_DOUBLE);
691  cpl_table_new_column(t, FORS_DATA_PHOT_DZEROPOINT, CPL_TYPE_DOUBLE);
692 
693  /* For each filtername (e.g. "U_BESS") find the matching filter (e.g. FILTER_U) */
694  for (i = 0; i < N; i++) {
695  cpl_table_set_string( t,
696  FORS_DATA_PHOT_FILTER,
697  i,
698  fors_instrument_known_filters_get_name(i));
699 
700  unsigned j;
701  for (j = 0; j < FORS_NUM_FILTER; j++) {
702  if (fors_instrument_known_filters_get_band(i) == data[j].band)
703  {
704  cpl_table_set_double(t, FORS_DATA_PHOT_EXTCOEFF , i, data[j].ext_coeff);
705  cpl_table_set_double(t, FORS_DATA_PHOT_DEXTCOEFF , i, data[j].dext_coeff);
706  cpl_table_set_double(t, FORS_DATA_PHOT_COLORTERM, i, data[j].color_term);
707  cpl_table_set_double(t, FORS_DATA_PHOT_DCOLORTERM, i, data[j].dcolor_term);
708  cpl_table_set_double(t, FORS_DATA_PHOT_ZEROPOINT, i, data[j].expected_zeropoint);
709  cpl_table_set_double(t, FORS_DATA_PHOT_DZEROPOINT, i, data[j].dexpected_zeropoint);
710  }
711  }
712  }
713 
714  cpl_table_save(t, NULL, NULL, filename, CPL_IO_DEFAULT);
715  assure( !cpl_error_get_code(), return NULL,
716  "Failed to save photometry table to %s", filename );
717 
718  cleanup;
719  return frame_new(filename, tag, group);
720 }
double fors_rand_gauss(void)
Pseudo-random gaussian distributed number.
Definition: fors_utils.c:181
cpl_frame * create_bias(const char *filename, const char *tag, cpl_frame_group group)
Simulate bias image.
fors_image * fors_image_new(cpl_image *data, cpl_image *variance)
Create image.
Definition: fors_image.c:102
cpl_frame * create_dark(const char *filename, const char *tag, cpl_frame_group group)
Simulate dark image.
cpl_frame * create_master_sky_flat(const char *filename, const char *tag, cpl_frame_group group, double exptime)
Simulate master sky flat image.
cpl_frame * create_master_bias(const char *filename, const char *tag, cpl_frame_group group)
Simulate master bias image.
#define assure(EXPR)
Definition: list.c:101
void create_standard_keys(cpl_propertylist *header, double exptime)
Write FORS standard keywords to simulated header.
cpl_frame * create_std_cat(const char *filename, const char *tag, cpl_frame_group group)
Create standard star catalogue.
static cpl_frame * frame_new(const char *filename, const char *tag, cpl_frame_group group)
Frame constructor.
cpl_frame * create_sky_flat(const char *filename, const char *tag, cpl_frame_group group, double exptime)
Simulate sky flat image.
cpl_frame * create_screen_flat(const char *filename, const char *tag, cpl_frame_group group)
Simulate screen flat image.
cpl_frame * create_phot_table(const char *filename, const char *tag, cpl_frame_group group)
Create photometry table.
cpl_frame * create_standard(const char *filename, const char *tag, cpl_frame_group group)
Create standard star image.
void fors_image_save(const fors_image *image, const cpl_propertylist *header, const cpl_propertylist *err_header, const char *filename)
Save image.
Definition: fors_image.c:375