00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031
00032
00033
00034
00035 #include <cpl.h>
00036 #include "xsh_detmon.h"
00037 #include "xsh_detmon_lg.h"
00038
00039
00040
00041 #include "xsh_dfs.h"
00042 #include "xsh_drl.h"
00043 #include "xsh_msg.h"
00044 #include "xsh_error.h"
00045 #include "xsh_utils.h"
00046 #include <xsh_data_instrument.h>
00047 #include "xsh_parameters.h"
00048 #include "xsh_badpixelmap.h"
00049
00050
00051
00052 #define XSH_LINGAIN_ON_RAW(it) ((it) == 0 ? XSH_LINEARITY_UVB_ON : \
00053 (it) == 1 ? XSH_LINEARITY_VIS_ON : \
00054 (it) == 2 ? XSH_LINEARITY_NIR_ON : \
00055 "???")
00056
00057 #define XSH_LINGAIN_OFF_RAW(it) ((it) == 0 ? XSH_LINEARITY_UVB_OFF : \
00058 (it) == 1 ? XSH_LINEARITY_VIS_OFF : \
00059 (it) == 2 ? XSH_LINEARITY_NIR_OFF : \
00060 "???")
00061
00062 #define XSH_LINGAIN_DET_LIN_INFO(it) ((it) == 0 ? XSH_DET_LIN_INFO_UVB : \
00063 (it) == 1 ? XSH_DET_LIN_INFO_VIS : \
00064 (it) == 2 ? XSH_DET_LIN_INFO_NIR : \
00065 "???")
00066
00067 #define XSH_LINGAIN_GAIN_INFO(it) ((it) == 0 ? XSH_GAIN_INFO_UVB : \
00068 (it) == 1 ? XSH_GAIN_INFO_VIS : \
00069 (it) == 2 ? XSH_GAIN_INFO_NIR : \
00070 "???")
00071
00072 #define XSH_LINGAIN_COEFFS_CUBE(it) ((it) == 0 ? XSH_COEFFS_CUBE_UVB : \
00073 (it) == 1 ? XSH_COEFFS_CUBE_VIS : \
00074 (it) == 2 ? XSH_COEFFS_CUBE_NIR : \
00075 "???")
00076
00077 #define XSH_LINGAIN_BP_MAP_NL(it) ((it) == 0 ? XSH_BP_MAP_NL_UVB : \
00078 (it) == 1 ? XSH_BP_MAP_NL_VIS : \
00079 (it) == 2 ? XSH_BP_MAP_NL_NIR : \
00080 "???")
00081
00082 #define XSH_LINGAIN_RAW_BP_MAP_NL(it) ((it) == 0 ? XSH_RAW_BP_MAP_NL_UVB : \
00083 (it) == 1 ? XSH_RAW_BP_MAP_NL_VIS : \
00084 (it) == 2 ? XSH_RAW_BP_MAP_NL_NIR : \
00085 "???")
00086
00087 #define XSH_LINGAIN_AUTOCORR(it) ((it) == 0 ? XSH_AUTOCORR_UVB : \
00088 (it) == 1 ? XSH_AUTOCORR_VIS : \
00089 (it) == 2 ? XSH_AUTOCORR_NIR : \
00090 "???")
00091
00092 #define XSH_LINGAIN_DIFF_FLAT(it) ((it) == 0 ? XSH_DIFF_FLAT_UVB : \
00093 (it) == 1 ? XSH_DIFF_FLAT_VIS : \
00094 (it) == 2 ? XSH_DIFF_FLAT_NIR : \
00095 "???")
00096
00097 #define RECIPE_ID "xsh_lingain"
00098 #define RECIPE_AUTHOR "Lander de Bilbao,A.Modigliani"
00099 #define RECIPE_CONTACT "amodigli@eso.org"
00100
00101
00102 #define INSTREGEXP "ESO INS SETUP ID"
00103
00104 #define PAFREGEXP "^(" REGEXP "|" INSTREGEXP ")$"
00105 #define NIR TRUE
00106 #define OPT FALSE
00107 #define XSH_PIX2PIX CPL_TRUE
00108 #define XSH_EXTS_RED -1
00109 #define XSH_BPMBIN 1
00110 #define XSH_TOL 0.1
00111
00112
00113
00114 static int xsh_lingain_create(cpl_plugin *);
00115 static int xsh_lingain_exec(cpl_plugin *);
00116 static int xsh_lingain_destroy(cpl_plugin *);
00117 static int
00118 xsh_lingain(cpl_frameset * frameset,
00119 cpl_parameterlist * parlist);
00120
00121 cpl_error_code
00122 xsh_lingain_fill_parlist_default_opt(cpl_parameterlist * parlist);
00123 cpl_error_code
00124 xsh_lingain_fill_parlist_default_nir(cpl_parameterlist * parlist);
00125 static cpl_error_code
00126 xsh_lingain_set_saturation_limit(cpl_parameterlist * parlist,
00127 xsh_instrument* instrument );
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 static char xsh_lingain_description_short[] = "Computes detector's gain/linearity-map";
00141
00142 static char xsh_lingain_description[] =
00143 "This recipe computes detector linearity coefficients and gain\n\
00144 Input Frames : \n\
00145 arm = UVB-VIS: \n\
00146 - A set of n RAW linearity frames (Format=RAW, n >=8, Tag = LINEARITY_arm_ON)\n\
00147 - A set of n RAW bias frames (Format=RAW, n >=1, Tag = LINEARITY_arm_OFF)\n\
00148 arm = NIR:\n\
00149 - A set of n RAW linearity on frames (Format=RAW, n >=8, Tag = LINEARITY_arm_ON)\n\
00150 - A set of n RAW linearity off frames (Format=RAW, n >=8, Tag = LINEARITY_arm_OFF)\n\
00151 - [OPTIONAL] a static bad pixel map (PRO.CATG=BP_MAP_RP_arm) \n\
00152 Note: on and off frames are taken in pairs sequence: OFF-ON-ON-OFF, \n\
00153 at least 16 frames.\n\
00154 Products : \n\
00155 - A linearity map table, PRO.CATG = BP_MAP_LIN_NIR\n\
00156 - A gain table, PRO.CATG = GAIN_INFO\n\
00157 - A cube cointaining the linearity coefficients, PRO.CATG = COEFFS_CUBE_arm\n\
00158 - A linearity map image (RAW format), PRO.CATG = RAW_BP_MAP_NL_arm\n\
00159 - A linearity map image (PRE format), PRO.CATG = BP_MAP_NL_arm\n";
00160
00161
00162
00163
00164
00173
00174
00175 int cpl_plugin_get_info(cpl_pluginlist * list)
00176 {
00177 cpl_recipe *recipe = NULL;
00178 cpl_plugin *plugin = NULL;
00179
00180 recipe = cpl_calloc(1, sizeof(*recipe));
00181 if (recipe == NULL) {
00182 return -1;
00183 }
00184
00185 plugin = &recipe->interface;
00186
00187 cpl_plugin_init(plugin, CPL_PLUGIN_API,
00188 XSH_BINARY_VERSION,
00189 CPL_PLUGIN_TYPE_RECIPE,
00190 RECIPE_ID,
00191 xsh_lingain_description_short,
00192 xsh_lingain_description,
00193 RECIPE_AUTHOR,
00194 RECIPE_CONTACT,
00195 xsh_get_license(),
00196 xsh_lingain_create,
00197 xsh_lingain_exec,
00198 xsh_lingain_destroy);
00199
00200 cpl_pluginlist_append(list, plugin);
00201
00202 return (cpl_error_get_code() != CPL_ERROR_NONE);
00203 }
00204
00205
00215
00216
00217 static int xsh_lingain_create(cpl_plugin * plugin)
00218 {
00219 cpl_recipe *recipe = NULL;
00220
00221 xsh_init();
00222
00223
00224 assure(plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin");
00225
00226
00227 assure(cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00228 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
00229
00230 recipe = (cpl_recipe *) plugin;
00231
00232
00233 recipe->parameters = cpl_parameterlist_new();
00234 assure(recipe->parameters != NULL,
00235 CPL_ERROR_ILLEGAL_OUTPUT, "Memory allocation failed!");
00236
00237
00238 check( xsh_parameters_generic( RECIPE_ID, recipe->parameters ) ) ;
00239 xsh_parameters_decode_bp(RECIPE_ID,recipe->parameters,-1);
00240 check(xsh_lingain_fill_parlist_default_opt(recipe->parameters));
00241
00242 cleanup:
00243 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00244 xsh_error_dump(CPL_MSG_ERROR);
00245 return 1;
00246 } else {
00247 return 0;
00248 }
00249 }
00250
00251
00252
00258
00259
00260 static int xsh_lingain_exec(cpl_plugin * plugin)
00261 {
00262 cpl_recipe *recipe = NULL;
00263
00264
00265 assure(plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin");
00266
00267
00268 assure(cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00269 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
00270
00271 recipe = (cpl_recipe *) plugin;
00272
00273
00274 xsh_lingain(recipe->frames,recipe->parameters);
00275
00276 cleanup:
00277 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00278 xsh_error_dump(CPL_MSG_ERROR);
00279 cpl_error_reset();
00280 return 1;
00281 } else {
00282 return 0;
00283 }
00284 }
00285
00286
00292
00293 static int xsh_lingain_destroy(cpl_plugin * plugin)
00294 {
00295 cpl_recipe *recipe = NULL;
00296
00297 xsh_error_reset();
00298
00299 assure(plugin != NULL, CPL_ERROR_NULL_INPUT, "Null plugin");
00300
00301
00302 assure(cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE,
00303 CPL_ERROR_TYPE_MISMATCH, "Plugin is not a recipe");
00304
00305 recipe = (cpl_recipe *) plugin;
00306
00307 xsh_free_parameterlist(&recipe->parameters);
00308
00309 cleanup:
00310 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00311 return 1;
00312 } else {
00313 return 0;
00314 }
00315 }
00316
00317 static cpl_error_code
00318 xsh_params_set_defaults(cpl_parameterlist* pars,
00319 xsh_instrument* inst)
00320 {
00321 cpl_parameter* p=NULL;
00322
00323 if (xsh_instrument_get_arm(inst) == XSH_ARM_UVB){
00324 check(p=xsh_parameters_find(pars,RECIPE_ID,"kappa"));
00325 if(xsh_parameter_get_default_flag(p) == 0) {
00326
00327 cpl_parameter_set_double(p,5.);
00328 }
00329 }
00330
00331
00332 cleanup:
00333
00334 return cpl_error_get_code();
00335
00336 }
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347 static int
00348 xsh_lingain(cpl_frameset * frameset,
00349 cpl_parameterlist * parlist)
00350 {
00351
00352 const char* recipe_tags[6] = {XSH_LINEARITY_UVB_ON,XSH_LINEARITY_UVB_OFF,
00353 XSH_LINEARITY_VIS_ON,XSH_LINEARITY_VIS_OFF,
00354 XSH_LINEARITY_NIR_ON,XSH_LINEARITY_NIR_OFF};
00355 int recipe_tags_size = 6;
00356
00357 cpl_error_code error=0;
00358 int processed=0;
00359 cpl_parameterlist* plist=NULL;
00360 xsh_instrument* instrument=NULL;
00361 cpl_frameset* raws=NULL;
00362 cpl_frameset* calib=NULL;
00363 cpl_frameset* pros=NULL;
00364
00365 cpl_propertylist * lintbl = NULL;
00366 cpl_propertylist * gaintbl = NULL;
00367 cpl_propertylist * coeffscube = NULL;
00368 cpl_propertylist * bpm = NULL;
00369 cpl_propertylist * corr = NULL;
00370 cpl_propertylist * diff_flat =NULL;
00371 cpl_frame* bpmap_nl=NULL;
00372 cpl_image* ima=NULL;
00373 char name[256];
00374 cpl_propertylist* head=NULL;
00375 cpl_frame *bpmap = NULL;
00376 cpl_frame* coadd_bp_map=NULL;
00377 cpl_image* crox=NULL;
00378
00379
00380 char* bp_nl_tag=NULL;
00381 char* bp_nl_name=NULL;
00382 xsh_pre* pre_bp_nl = NULL;
00383 cpl_frame* bp_nl_frame = NULL;
00384
00385
00386
00387
00388
00389 check( xsh_begin( frameset, parlist, &instrument, &raws, &calib,
00390 recipe_tags, recipe_tags_size,
00391 RECIPE_ID, XSH_BINARY_VERSION,
00392 xsh_lingain_description_short ) ) ;
00393 if((bpmap=xsh_find_frame_with_tag(calib,XSH_BP_MAP_RP,instrument))==NULL) {
00394 xsh_msg("%s not provided",XSH_BP_MAP_RP);
00395 }
00396 check(plist=xsh_parameterlist_duplicate(parlist));
00397
00398 if ( xsh_instrument_get_arm(instrument) == XSH_ARM_NIR){
00399
00400
00401
00402 xsh_lingain_fill_parlist_default_nir(plist);
00403 xsh_lingain_set_saturation_limit(plist,instrument);
00404
00405 processed++;
00406
00407 lintbl=xsh_detmon_fill_prolist("DET_LIN_INFO_NIR","TYPE","TECH",CPL_FALSE);
00408
00409 gaintbl=xsh_detmon_fill_prolist("GAIN_INFO_NIR","TYPE","TECH",CPL_FALSE);
00410
00411 coeffscube=xsh_detmon_fill_prolist("COEFFS_CUBE_NIR","TYPE","TECH",CPL_FALSE);
00412
00413 bpm=xsh_detmon_fill_prolist("RAW_BP_MAP_NL_NIR","TYPE","TECH",CPL_FALSE);
00414
00415 corr=xsh_detmon_fill_prolist("AUTOCORR_NIR","TYPE","TECH",CPL_FALSE);
00416
00417 diff_flat=xsh_detmon_fill_prolist("DIFF_FLAT_NIR","TYPE","TECH",CPL_FALSE);
00418
00419 check(error = xsh_detmon_lg(raws,
00420 plist,
00421 XSH_LINEARITY_NIR_ON,
00422 XSH_LINEARITY_NIR_OFF,
00423 RECIPE_ID,
00424 "xsh",
00425 PAFREGEXP,
00426 lintbl,
00427 gaintbl,
00428 coeffscube,
00429 bpm,
00430 corr,
00431 diff_flat,
00432 PACKAGE "/" PACKAGE_VERSION,
00433 NULL, NULL, NIR));
00434
00435 } else if ( xsh_instrument_get_arm(instrument) == XSH_ARM_UVB){
00436
00437
00438
00439 xsh_lingain_fill_parlist_default_opt(plist);
00440 check(xsh_params_set_defaults(parlist,instrument));
00441 xsh_lingain_set_saturation_limit(plist,instrument);
00442
00443 processed++;
00444
00445 lintbl=xsh_detmon_fill_prolist("DET_LIN_INFO_UVB","TYPE","TECH",CPL_FALSE);
00446
00447 gaintbl=xsh_detmon_fill_prolist("GAIN_INFO_UVB","TYPE","TECH",CPL_FALSE);
00448
00449 coeffscube=xsh_detmon_fill_prolist("COEFFS_CUBE_UVB","TYPE","TECH",CPL_FALSE);
00450
00451 bpm=xsh_detmon_fill_prolist("RAW_BP_MAP_NL_UVB","TYPE","TECH",CPL_FALSE);
00452
00453 corr=xsh_detmon_fill_prolist("AUTOCORR_UVB","TYPE","TECH",CPL_FALSE);
00454
00455 diff_flat=xsh_detmon_fill_prolist("DIFF_FLAT_UVB","TYPE","TECH",CPL_FALSE);
00456 check(error = xsh_detmon_lg(raws,
00457 plist,
00458 XSH_LINEARITY_UVB_ON,
00459 XSH_LINEARITY_UVB_OFF,
00460 RECIPE_ID,
00461 "xsh",
00462 PAFREGEXP,
00463 lintbl,
00464 gaintbl,
00465 coeffscube,
00466 bpm,
00467 corr,
00468 diff_flat,
00469 PACKAGE "/" PACKAGE_VERSION,
00470 NULL, NULL, OPT));
00471
00472
00473
00474 } else if ( xsh_instrument_get_arm(instrument) == XSH_ARM_VIS) {
00475
00476
00477
00478 xsh_lingain_fill_parlist_default_opt(plist);
00479 xsh_lingain_set_saturation_limit(plist,instrument);
00480
00481 processed++;
00482
00483 lintbl=xsh_detmon_fill_prolist("DET_LIN_INFO_VIS","TYPE","TECH",CPL_FALSE);
00484
00485 gaintbl=xsh_detmon_fill_prolist("GAIN_INFO_VIS","TYPE","TECH",CPL_FALSE);
00486
00487 coeffscube=xsh_detmon_fill_prolist("COEFFS_CUBE_VIS","TYPE","TECH",CPL_FALSE);
00488
00489 bpm=xsh_detmon_fill_prolist("RAW_BP_MAP_NL_VIS","TYPE","TECH",CPL_FALSE);
00490
00491 corr=xsh_detmon_fill_prolist("AUTOCORR_VIS","TYPE","TECH",CPL_FALSE);
00492
00493 diff_flat=xsh_detmon_fill_prolist("DIFF_FLAT_VIS","TYPE","TECH",CPL_FALSE);
00494 check(error = xsh_detmon_lg(raws,
00495 plist,
00496 XSH_LINEARITY_VIS_ON,
00497 XSH_LINEARITY_VIS_OFF,
00498 RECIPE_ID,
00499 "xsh",
00500 PAFREGEXP,
00501 lintbl,
00502 gaintbl,
00503 coeffscube,
00504 bpm,
00505 corr,
00506 diff_flat,
00507 PACKAGE "/" PACKAGE_VERSION,
00508 NULL, NULL, OPT));
00509
00510
00511
00512 }
00513
00514 pros=cpl_frameset_new();
00515 check(xsh_dfs_extract_pro_frames(raws,pros));
00516 check(xsh_frameset_merge(frameset,pros));
00517 xsh_free_frameset(&pros);
00518 check(bpmap_nl=xsh_find_frame_with_tag(frameset,XSH_RAW_BP_MAP_NL,instrument));
00519
00520
00521 check( pre_bp_nl = xsh_pre_create(bpmap_nl , NULL, NULL, instrument,0,CPL_FALSE));
00522 bp_nl_tag=cpl_sprintf("%s_%s",XSH_BP_MAP_NL,
00523 xsh_instrument_arm_tostring( instrument ));
00524 bp_nl_name=cpl_sprintf("%s.fits",bp_nl_tag);
00525 check( bp_nl_frame = xsh_pre_save( pre_bp_nl, bp_nl_name,bp_nl_tag,1 ));
00526 cpl_frameset_insert(frameset, bp_nl_frame);
00527
00528
00529 check(sprintf(name,cpl_frame_get_filename(bp_nl_frame)));
00530 check(ima=cpl_image_load(name,CPL_TYPE_FLOAT,0,0));
00531 check(head=cpl_propertylist_load(name,0));
00532 cpl_propertylist_erase_regexp(head, "NPIXSAT",0);
00533 cpl_propertylist_erase_regexp(head, "FPIXSAT",0);
00534 check(xsh_bpmap_bitwise_to_flag(ima,QFLAG_NON_LINEAR_PIXEL));
00535
00536 if ( xsh_instrument_get_arm(instrument) == XSH_ARM_NIR) {
00537 check(crox=xsh_image_flag_bptype_with_crox(ima));
00538 check(cpl_image_save(crox,name,CPL_BPP_IEEE_FLOAT,head,CPL_IO_DEFAULT));
00539 xsh_free_image(&crox);
00540 } else {
00541 check(cpl_image_save(ima,name,CPL_BPP_IEEE_FLOAT,head,CPL_IO_DEFAULT));
00542 }
00543 xsh_free_image(&ima);
00544 xsh_free_propertylist(&head);
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576 if(processed>0) {
00577
00578 cpl_ensure_code(!error, error);
00579 } else {
00580 xsh_msg("No data has been processed.");
00581 xsh_msg("Pls check if input frame set contains valid tags");
00582 }
00583
00584
00585 cleanup:
00586
00587 xsh_free_frame(&coadd_bp_map);
00588 xsh_free_frameset(&pros);
00589 xsh_free_image(&ima);
00590 xsh_free_propertylist(&head);
00591 xsh_free_propertylist(&lintbl);
00592 xsh_free_propertylist(&gaintbl);
00593 xsh_free_propertylist(&coeffscube);
00594 xsh_free_propertylist(&bpm);
00595 xsh_free_propertylist(&corr);
00596 xsh_free_propertylist(&diff_flat);
00597 xsh_pre_free(&pre_bp_nl);
00598 return CPL_ERROR_NONE;
00599 }
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661 cpl_error_code
00662 xsh_lingain_fill_parlist_default_opt(cpl_parameterlist * parlist)
00663 {
00664
00665 cpl_error_code error =
00666 xsh_detmon_lg_fill_parlist_opt_default(parlist, RECIPE_ID, PACKAGE);
00667 cpl_parameter * p;
00668
00669 cpl_ensure_code(!error, error);
00670
00671
00672
00673 p = cpl_parameterlist_find(parlist, PACKAGE "." RECIPE_ID ".pix2pix");
00674
00675 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00676
00677 error = cpl_parameter_set_default_bool(p, XSH_PIX2PIX);
00678
00679 p = cpl_parameterlist_find(parlist, PACKAGE "." RECIPE_ID ".tolerance");
00680
00681 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00682
00683 error = cpl_parameter_set_default_double(p, XSH_TOL);
00684
00685 cpl_ensure_code(!error, error);
00686
00687 return CPL_ERROR_NONE;
00688 }
00689
00690
00691 cpl_error_code
00692 xsh_lingain_fill_parlist_default_nir(cpl_parameterlist * parlist)
00693 {
00694
00695
00696
00697 cpl_error_code error =
00698 xsh_detmon_lg_fill_parlist_nir_default(parlist,RECIPE_ID,
00699 PACKAGE_TARNAME);
00700 cpl_parameter * p;
00701
00702 cpl_ensure_code(!error, error);
00703
00704
00705 p = cpl_parameterlist_find(parlist, PACKAGE_TARNAME "." RECIPE_ID ".bpmbin");
00706
00707 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00708
00709 error = cpl_parameter_set_default_bool(p, XSH_BPMBIN);
00710
00711 cpl_ensure_code(!error, error);
00712
00713
00714 return CPL_ERROR_NONE;
00715
00716 }
00717
00718
00719
00720 static cpl_error_code
00721 xsh_lingain_set_saturation_limit(cpl_parameterlist * parlist,
00722 xsh_instrument* instrument )
00723 {
00724
00725 cpl_error_code error =0;
00726 cpl_parameter * p;
00727 double val=0;
00728 double thresh_max=65000;
00729
00730 if ( xsh_instrument_get_arm(instrument) == XSH_ARM_NIR) {
00731 thresh_max=42000;
00732 }
00733
00734 cpl_ensure_code(!error, error);
00735
00736 p = cpl_parameterlist_find(parlist, PACKAGE "." RECIPE_ID ".saturation_limit");
00737
00738 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00739 val=cpl_parameter_get_double(p);
00740
00741 if( fabs(val+1.) < 0.00001) {
00742 error = cpl_parameter_set_default_double(p, thresh_max);
00743 }
00744 cpl_ensure_code(!error, error);
00745
00746 return CPL_ERROR_NONE;
00747
00748 }
00749