36#include "eris_nix_utils.h"
37#include "eris_nix_dfs.h"
38#include "eris_nix_scired.h"
47static const char eris_nix_img_cal_wcs_description[] =
48"This recipe calibrates the astrometry of ERIS/NIX frames.\n"
51" DO CATG Explanation Req. #Frames\n"
52" ------- ----------- --- -------\n"
53" "ERIS_NIX_SKYSUB_OBJECT_JITTER_PRO_CATG
54 " sky-subtracted Y 1-n\n"
57" "ERIS_NIX_SKYSUB_STD_JITTER_PRO_CATG
58 " sky-subtracted Y 1-n\n"
60" "ERIS_NIX_WCS_MATCHED_CATALOGUE_PRO_CATG
61 " manual match of N 0-1\n"
67" DO CATG Explanation Name\n"
68" ------- ----------- ----\n"
69" "ERIS_NIX_CAL_WCS_OBJECT_JITTER_PRO_CATG
70 " The wcs cal_wcs.<in_name>\n"
74" "ERIS_NIX_CAL_WCS_STD_JITTER_PRO_CATG
75 " The wcs cal_wcs.<in_name>\n"
79" There are two stages to the calibration. \n"
81" First, the jitter nearest the centre of the jitter pattern is \n"
82" identified as the 'reference' jitter. The wcs of the 'reference'\n"
83" jitter is calibrated in one of 3 ways as described further below.\n"
84" The aim is to calibrate this jitter against an absolute\n"
85" reference such as Gaia.\n"
87" Second, the wcs calibration is propagated to other jitters in\n"
88" turn, adding them to the calibrated pool as we go. At each step\n"
89" the next jitter to calibrate is the one with the largest overlap\n"
90" with a jitter in the calibrated pool, so the most likely to have\n"
91" sources in common. The calibration is achieved by comparing their\n"
92" source catalogues.\n"
95" Catalogues are matched by trying all possible associations between \n"
96" their objects and calculating a metric of the pattern match for \n"
97" each - that is, the number of object pairs that lie within a \n"
98" small distance of each other. The association with the highest \n"
99" number of matches is selected.\n"
101" The catalogues are sorted in order of decreasing brightness \n"
102" using column 'Aper_flux_3', if it exists. If few sources are \n"
103" present this means that matches between the brightest \n"
104" will be favoured.\n"
106" When a match is found the wcs of the image to be calibrated is \n"
107" recalculated to make the matched sources coincide.\n"
110" The 'reference' jitter can be calibrated in one of 3 ways:\n"
112"1. If an online astrometric catalogue is specified by parameter\n"
113" cdssearch-astrom it will be searched over the area of the\n"
114" jitter image for astrometric standards. \n"
116" In this case, if the calibration succeeds the headers of the \n"
117" output files will have keywords:\n"
118" -- ESO.WCS_METHOD = '"ERIS_NIX_WCS_CATALOGUE_MATCH
"'\n"
119" -- WCS_CAT = <the name of the catalogue used>\n"
121"2. If no reference catalogue is given, cdssearch-astrom is \n"
122" 'none', then the wcs cannot be calibrated absolutely and \n"
123" the recipe can only align the jitters relative to the \n"
126" If the calibration succeeds the output files will have \n"
128" -- ESO.WCS_METHOD = '"ERIS_NIX_WCS_JITTER_RELATIVE
"'\n"
129" -- WCS_CAT = 'none'\n"
131"3. The user can directly specify a position in the 'reference'\n"
132" jitter. This is done by putting the required information \n"
133" in a FITS table and including that file in the SoF with tag\n"
134" "ERIS_NIX_WCS_MATCHED_CATALOGUE_PRO_CATG
".\n"
136" The format of the FITS table should be:\n"
138"Filename RA Dec X_coordinate Y_coordinate Catalogue\n"
139"xyz.fits 99.791... 8.736... 544 599.5 Gaia\n"
140"abc.fits 99.791... 8.736... 561.5 595.2 Gaia\n"
141"pqr.fits 99.791... 8.736... 557.2 496.8 Gaia\n"
145" Filename holds the name of the 'reference' jitter.\n"
146" RA and Dec hold the coords in degrees of the index position.\n"
147" X_coordinate and Y_coordinate hold the x,y coords of the \n"
149" Catalogue has the name of the source catalogue of RA, Dec.\n"
151" If the 'Catalogue' entry is 'Gaia' or '2mass' then the output\n"
152" file will have keywords:\n"
153" -- ESO.WCS_METHOD = '"ERIS_NIX_WCS_CATALOGUE_MATCH
"'\n"
154" -- WCS_CAT = <the name of the catalogue used>\n"
156" -- ESO.WCS_METHOD = '"ERIS_NIX_WCS_JITTER_RELATIVE
"'\n"
157" -- WCS_CAT = 'none'\n"
160" If the calibration fails then the wcs of the file is not modified\n"
161" and the relevant header keywords are set thus:\n"
162" -- ESO.WCS_METHOD = '"ERIS_NIX_WCS_TEL_POINTING
"'\n"
163" -- WCS_CAT = 'none'\n";
165#define RECIPE_NAME "eris_nix_img_cal_wcs"
166#define CONTEXT "eris."RECIPE_NAME
171cpl_recipe_define(eris_nix_img_cal_wcs, ERIS_BINARY_VERSION,
173 PACKAGE_BUGREPORT,
"2017",
174 "Calibrate wcs of ERIS/NIX frames",
175 eris_nix_img_cal_wcs_description);
191static cpl_error_code eris_nix_img_cal_wcs_fill_parameterlist(
192 cpl_parameterlist * self) {
194 if (cpl_error_get_code() != CPL_ERROR_NONE)
return cpl_error_get_code();
196 hdrl_parameter * catalogue_defaults = NULL;
197 cpl_parameterlist * catalogue_parlist = NULL;
198 cpl_parameter * p = NULL;
203 10.0, CPL_TRUE, 128, 5.0, 3.0,
204 ERIS_NIX_SATURATION_DEFAULT, HDRL_CATALOGUE_ALL);
206 "catalogue", catalogue_defaults);
210 for (p = cpl_parameterlist_get_first(catalogue_parlist);
212 p = cpl_parameterlist_get_next(catalogue_parlist)) {
214 const char * pname = cpl_parameter_get_name(p);
215 if (strstr(pname,
"minmax") == NULL) {
216 cpl_parameter * duplicate = cpl_parameter_duplicate(p);
217 cpl_parameterlist_append(self, duplicate);
223 p = cpl_parameter_new_enum(CONTEXT
".catalogue.ao-params",
225 "Default catalogue.core-radius and "
226 "catalogue.mesh-size depending on "
229 "auto", 2,
"auto",
"user");
230 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"catalogue.ao-params");
231 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
232 cpl_parameterlist_append(self, p);
239 p = cpl_parameter_new_enum(CONTEXT
".cdssearch_astrom",
241 "CDS astrometric catalogue",
243 "none", 3,
"none",
"2mass",
"gaiadr3");
244 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"cdssearch-astrom");
245 cpl_parameterlist_append(self, p);
247 p = cpl_parameter_new_value(CONTEXT
".debug-data",
248 CPL_TYPE_BOOL,
"true to save interim results",
250 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"debug-data");
251 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
252 cpl_parameterlist_append(self, p);
254 p = cpl_parameter_new_value(CONTEXT
".edges-trim",
256 "Trim image edges in the source detection: "
257 "[txmin,tymin,txmax,tymax]. t means trim "
258 "the user can trim differently from the min and "
259 "max image edge values along X and Y axes",
260 CONTEXT,
"30,30,30,30");
261 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,
"edges-trim");
262 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
263 cpl_parameterlist_append(self, p);
268 cpl_parameterlist_delete(catalogue_parlist);
283static int eris_nix_img_cal_wcs(cpl_frameset * frameset,
284 const cpl_parameterlist * parlist) {
289 return (
int) cpl_error_get_code();
cpl_error_code eris_nix_scired_cal_wcs(cpl_frameset *frameset, const cpl_parameterlist *parlist, const char *recipe_name, const char *context)
This recipe calibrates the astrometry of ERIS/NIX frames.
hdrl_parameter * hdrl_catalogue_parameter_create(int obj_min_pixels, double obj_threshold, cpl_boolean obj_deblending, double obj_core_radius, cpl_boolean bkg_estimate, int bkg_mesh_size, double bkg_smooth_fwhm, double det_eff_gain, double det_saturation, hdrl_catalogue_options resulttype)
Creates catalogue Parameters object.
cpl_parameterlist * hdrl_catalogue_parameter_create_parlist(const char *base_context, const char *prefix, hdrl_parameter *defaults)
Create parameter list for the catalogue computation.
void hdrl_parameter_delete(hdrl_parameter *obj)
shallow delete of a parameter