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
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00111
00114 #ifdef HAVE_CONFIG_H
00115 # include <config.h>
00116 #endif
00117
00118
00119
00120 #include <uves_physmod_create_table.h>
00121
00122 #include <uves_physmod_utils.h>
00123 #include <uves_utils_wrappers.h>
00124 #include <uves_pfits.h>
00125 #include <uves_msg.h>
00126 #include <uves_error.h>
00127
00128
00129
00130
00131
00132
00133
00134
00135 static int
00136 flames_get_trans(const int plt_no,
00137 enum uves_chip chip,
00138 const double wlen,
00139 double * TX,
00140 double * TY);
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00173
00174
00175
00176
00177
00178 int
00179 uves_physmod_create_table(const uves_propertylist *raw_header,
00180 enum uves_chip chip,
00181 const char *recipe_id,
00182 const cpl_parameterlist* parameters,
00183 cpl_table* line_refer,
00184 const double physmod_shift_x,
00185 const double physmod_shift_y,
00186 cpl_table** mod_tbl,
00187 cpl_table** fsr_tbl)
00188
00189 {
00190
00191
00192 int MBOX_X=0;
00193 int MBOX_Y=0;
00194 double TRANS_X=0;
00195 double TRANS_Y=0;
00196
00197 double ECH_ANG_OFF=0;
00198 double CD_ANG_OFF=0;
00199 double CCD_ANG_OFF=0;
00200
00201
00202
00203 int CMP_REG_SW=0;
00204
00205 double binx=0;
00206 double biny=0;
00207
00208 double pressure=0;
00209 double temp_cam=0;
00210 double slit_width=0;
00211 double slit_length=0;
00212 double humidity=0;
00213
00214
00215 double wcent=0;
00216 double xtrans=0;
00217 double ytrans=0;
00218 double echoff=0;
00219 double CDoff=0;
00220 double ccdrotoff=0;
00221 double ccd_rot[2];
00222 double offset_x[6];
00223 double offset_y[6];
00224
00225 const char* cd_id;
00226 int CDID=0;
00227 int status=0;
00228
00229
00230 int aRowNumber=0;
00231 int xpix=0;
00232 int ypix=0;
00233 int i=0;
00234 int mm=0;
00235 double xmod=0;
00236 double ymod=0;
00237 double blaze=0;
00238 double binsize=0;
00239 double pixscale=0;
00240 double pixscalCD=0;
00241 double linelenpx=0;
00242 double linewidth=0;
00243 double linewidpx=0;
00244 double resol=0;
00245 double xreg=0;
00246 double yreg=0;
00247 double fsr_min=0;
00248 double fsr_max=0;
00249 double xfsr_min=0;
00250 double xfsr_max=0;
00251 double yfsr_min=0;
00252 double yfsr_max=0;
00253 int m_min=0;
00254 int m_max=0;
00255 double lmin=0;
00256 double lmax=0;
00257 double dxpix=0;
00258 double dypix=0;
00259 double dblwav=0;
00260 int imod=0;
00261 double dl=0;
00262 int mmin=0;
00263 int mmax=0;
00264 int ncol=0;
00265 int order=0;
00266 double xr=0;
00267 double yr=0;
00268 double lcent=0;
00269
00270 double mbox_x=0;
00271 double mbox_y=0;
00272
00273
00274 double uves_beta_ech=0;
00275 double uves_beta_cd=0 ;
00276 double uves_physmod_rcd=0;
00277 double uves_physmod_rech=0;
00278 double uves_physmod_x_off=0;
00279 double uves_physmod_y_off=0;
00280 double x=0;
00281 double y=0;
00282 double fc=0;
00283 double l=0;
00284 int m=0;
00285 int plate_no=0;
00286
00287
00288
00289
00290 enum uves_arm_ident {UVES_ARM_UNDEF,UVES_ARM_BLUE,UVES_ARM_RED};
00291 enum uves_arm_ident uves_arm_ident = UVES_ARM_UNDEF;
00292 int upper;
00293
00294 const char* ccd_id="";
00295 const char* dpr_tech="";
00296
00297
00298
00299
00300 {
00301 check( uves_get_parameter(parameters, NULL, recipe_id,
00302 "mbox_x", CPL_TYPE_INT, &MBOX_X ) ,
00303 "Could not read parameter");
00304
00305 check( uves_get_parameter(parameters, NULL, recipe_id,
00306 "mbox_y", CPL_TYPE_INT, &MBOX_Y ) ,
00307 "Could not read parameter");
00308
00309 check( uves_get_parameter(parameters, NULL, recipe_id,
00310 "trans_x", CPL_TYPE_DOUBLE, &TRANS_X ) ,
00311 "Could not read parameter");
00312
00313 check( uves_get_parameter(parameters, NULL, recipe_id,
00314 "trans_y", CPL_TYPE_DOUBLE, &TRANS_Y ) ,
00315 "Could not read parameter");
00316 xtrans=TRANS_X;
00317 ytrans=TRANS_Y;
00318
00319
00320
00321
00322
00323
00324 if ((xtrans == 0.) && (ytrans == 0.)) {
00325
00326
00327
00328
00329 if (chip == UVES_CHIP_REDU) {
00330 ytrans = 6.7;
00331 }
00332 }
00333
00334 uves_msg_debug("xtrans=%f ytrans=%f",xtrans,ytrans);
00335 check( uves_get_parameter(parameters, NULL, recipe_id,
00336 "ech_angle_off", CPL_TYPE_DOUBLE, &ECH_ANG_OFF ) ,
00337 "Could not read parameter");
00338
00339 check( uves_get_parameter(parameters, NULL, recipe_id,
00340 "cd_angle_off", CPL_TYPE_DOUBLE, &CD_ANG_OFF ) ,
00341 "Could not read parameter");
00342
00343 check( uves_get_parameter(parameters, NULL, recipe_id,
00344 "ccd_rot_angle_off", CPL_TYPE_DOUBLE, &CCD_ANG_OFF ) ,
00345 "Could not read parameter");
00346
00347 check( uves_get_parameter(parameters, NULL, recipe_id,
00348 "compute_regression_sw", CPL_TYPE_BOOL, &CMP_REG_SW ) ,
00349 "Could not read parameter");
00350
00351
00352
00353
00354 }
00355
00356
00357
00358
00359 check (ccd_id = uves_pfits_get_chipid(raw_header,chip),
00360 "Could not read CCD ID from input header");
00361 check (dpr_tech = uves_pfits_get_dpr_tech(raw_header),
00362 "Could not read DPR TECH from input header");
00363 uves_msg("DPR TECH=%s<",dpr_tech);
00364 if(strstr(dpr_tech,"MOS")!=NULL) {
00365 check_nomsg( plate_no = uves_flames_pfits_get_plateid(raw_header) );
00366 uves_msg("PLATE NO=%d",plate_no);
00367 }
00368
00369 if(strcmp(ccd_id,"CCD-44b") == 0) {
00370 uves_msg("New Spectral Format");
00371 offset_x[0]=1355.0;
00372 offset_x[1]=1350.0;
00373 offset_x[2]=1852.0;
00374 offset_x[3]=1835.0;
00375 offset_x[4]=1852.0;
00376 offset_x[5]=1834.0;
00377
00378 offset_y[0]=1030.0;
00379 offset_y[1]=1023.0;
00380 offset_y[2]=2098.0;
00381 offset_y[3]=2104.0;
00382 offset_y[4]=-52.0;
00383 offset_y[5]=-49.0;
00384 ccd_rot[0]=0.3;
00385 ccd_rot[1]=-0.10;
00386
00387 } else {
00388 uves_msg("Old Spectral Format");
00389
00390 offset_x[0]=1391.0;
00391 offset_x[1]=1385.0;
00392 offset_x[2]=1852.0;
00393 offset_x[3]=1835.0;
00394 offset_x[4]=1852.0;
00395 offset_x[5]=1834.0;
00396
00397 offset_y[0]=1030.0;
00398 offset_y[1]=1025.0;
00399 offset_y[2]=2098.0;
00400 offset_y[3]=2104.0;
00401 offset_y[4]=-52.0;
00402 offset_y[5]=-49.0;
00403
00404 ccd_rot[0]=0.3;
00405 ccd_rot[1]=-0.55;
00406 }
00407
00408
00409 check (biny = uves_pfits_get_binx(raw_header),
00410 "Could not read x binning factor from input header");
00411
00412 check (binx = uves_pfits_get_biny(raw_header),
00413 "Could not read x binning factor from input header");
00414
00415 check (pressure = uves_pfits_get_pressure(raw_header),
00416 "Could not read pressure from input header");
00417
00418
00419
00420
00421
00422 humidity=3.;
00423
00424
00425
00426 check (slit_width = uves_pfits_get_slitwidth(raw_header, chip),
00427 "Could not read slit width input header");
00428
00429 check (slit_length = uves_pfits_get_slitlength(raw_header, chip),
00430 "Could not read slit length input header");
00431
00432 check (wcent = uves_pfits_get_gratwlen(raw_header, chip),
00433 "Could not read central wavelength setting from input header");
00434
00435 check (cd_id = uves_pfits_get_gratid(raw_header, chip),
00436 "Could not read central CD ID setting from input header");
00437
00438 check (temp_cam = uves_pfits_get_tempcam(raw_header,chip),
00439 "Could not read camera's temperature from input header");
00440
00441 if (chip == UVES_CHIP_BLUE)
00442 {
00443 uves_arm_id='b';
00444 uves_arm_ident=UVES_ARM_BLUE;
00445
00446 }
00447 else
00448 {
00449 uves_arm_id='r';
00450 uves_arm_ident=UVES_ARM_RED;
00451 }
00452 upper = (chip == UVES_CHIP_REDU);
00453
00454
00455
00456
00457 if(strstr(cd_id,"CD#1") != NULL) {
00458 CDID=1;
00459 } else if(strstr(cd_id,"CD#2") != NULL) {
00460 CDID=2;
00461 } else if(strstr(cd_id,"CD#3") != NULL) {
00462 CDID=3;
00463 } else if(strstr(cd_id,"CD#4") != NULL) {
00464 CDID=4;
00465 } else {
00466 CDID=0;
00467 }
00468
00469 mbox_x=MBOX_X/binx;
00470 mbox_y=MBOX_Y/biny;
00471 uves_msg("UVES configuration:");
00472 uves_msg("Optical path: %s (%s)",
00473 UVES_ARM(chip),UVES_ARMID(chip));
00474
00475 uves_msg("Detector: %s Binning: %1.1f, %1.1f pix/bin",
00476 UVES_DETECTOR(chip),binx,biny);
00477 uves_msg("Cross disperser ID, number: %s %d",cd_id,CDID);
00478 uves_msg("Central wavelength: %4.1f nm",wcent);
00479 uves_msg("Slit width: %3.1f (arcsecs)",slit_width);
00480 uves_msg("Slit length: %3.1f (arcsecs)",slit_length);
00481 uves_msg("Temperature: %3.1f C",temp_cam);
00482 uves_msg("Air pressure: %4.1f mmHg/cm^2",pressure);
00483 uves_msg("Humidity: %2.1f %%",humidity);
00484
00485 uves_msg_debug("chip =%s", uves_chip_tostring_upper(chip));
00486
00487
00488
00489 ncol=cpl_table_get_ncol(line_refer);
00490
00491 aRowNumber = cpl_table_get_nrow(line_refer);
00492
00493 uves_msg_debug("Opened table %s ncol=%d nrow=%d","line_ref_table" ,ncol,aRowNumber);
00494
00495 uves_air_config(pressure/1.33322, temp_cam, humidity);
00496 uves_msg("Air Index = %g",uves_air_index(wcent));
00497 if(strstr(dpr_tech,"MOS")!=NULL) {
00498 uves_msg("uves chip=%s ",uves_chip_tostring_upper(chip));
00499 flames_get_trans(plate_no,chip,wcent,&TRANS_X,&TRANS_Y);
00500
00501
00502
00503 xtrans=physmod_shift_x;
00504 ytrans=physmod_shift_y;
00505 }
00506 uves_msg("Shift in x = %6.3f pix, shift in y = %6.3f pix",TRANS_X,TRANS_Y);
00507 uves_msg("External Shift in x = %6.3f pix, shift in y = %6.3f pix",
00508 physmod_shift_x,physmod_shift_y);
00509 uves_msg("Offset angle of echelle, CD, CCD rotation (deg): "
00510 "%4.3f, %4.3f, %4.3f",ECH_ANG_OFF,CD_ANG_OFF,CCD_ANG_OFF);
00511
00512 uves_set_ccd_rot(ccd_rot,ccdrotoff, ccdrotoff);
00513 uves_physmod_set_incidence(echoff, echoff, CDoff, CDoff);
00514 uves_msg_debug("ccdbin=%f,%f",binx,biny);
00515 uves_msg_debug("offset x=%f %f %f %f %f %f",
00516 offset_x[0],offset_x[1],offset_x[2],offset_x[3],offset_x[4],offset_x[5]);
00517
00518 uves_msg_debug("offset y=%f %f %f %f %f %f",
00519 offset_y[0],offset_y[1],offset_y[2],offset_y[3],offset_y[4],offset_y[5]);
00520
00521 uves_msg("Central wavelength: %4.2f nm",wcent);
00522 uves_msg_debug("chip =%s", uves_chip_tostring_upper(chip));
00523
00524 uves_msg_debug("uves_arm_ident=%d",uves_arm_ident);
00525
00526
00527
00528
00529 uves_cfg_indx = uves_config_cpl_new(uves_arm_ident,upper,CDID,wcent,binx,biny);
00530 uves_msg_debug("uves_cfg_indx=%d",uves_cfg_indx);
00531
00532 uves_physmod_set_offset(offset_x[uves_cfg_indx-1],offset_y[uves_cfg_indx-1],
00533 uves_physmod_x_off,uves_physmod_y_off);
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545 *mod_tbl= cpl_table_new(3*aRowNumber);
00546
00547 uves_msg("table created: %s ncol=%d, nrow=%d","mod_tbl",10,3*aRowNumber);
00548 cpl_table_new_column(*mod_tbl,"WAVE",CPL_TYPE_DOUBLE);
00549 cpl_table_new_column(*mod_tbl,"ORDER",CPL_TYPE_INT);
00550 cpl_table_new_column(*mod_tbl,"XMOD",CPL_TYPE_DOUBLE);
00551 cpl_table_new_column(*mod_tbl,"YMOD",CPL_TYPE_DOUBLE);
00552 cpl_table_new_column(*mod_tbl,"BIN_SIZE",CPL_TYPE_DOUBLE);
00553 cpl_table_new_column(*mod_tbl,"LINEWIDPX",CPL_TYPE_DOUBLE);
00554 cpl_table_new_column(*mod_tbl,"LINEWIDTH",CPL_TYPE_DOUBLE);
00555 cpl_table_new_column(*mod_tbl,"RESOL",CPL_TYPE_DOUBLE);
00556 cpl_table_new_column(*mod_tbl,"LINELENPX",CPL_TYPE_DOUBLE);
00557 cpl_table_new_column(*mod_tbl,"BLAZE",CPL_TYPE_DOUBLE);
00558
00559 uves_ccd_size(&xpix,&ypix);
00560 uves_msg_debug("CCDsize: %d %d",xpix,ypix);
00561
00562
00563 for (i=0; i<aRowNumber; i++) {
00564
00565
00566
00567
00568
00569
00570
00571 dblwav=cpl_table_get_double(line_refer, "Wave",i,&status);
00572 uves_msg_debug(" i: %d Line: %f",i,dblwav);
00573
00574 dblwav /= 10.0;
00575 order = uves_physmod_find_order(dblwav);
00576 uves_msg_debug("order=%d",order);
00577
00578 order++;
00579
00580
00581
00582
00583 for (mm=0; mm<3; mm++){
00584
00585
00586
00587 uves_physmod_lambda_order2beta(dblwav, order, &uves_beta_ech, &uves_beta_cd, &fc);
00588
00589 uves_msg_debug("uves_beta_ech %f, uves_beta_cd %f, fc %f",
00590 uves_beta_ech, uves_beta_cd, fc);
00591
00592 uves_beta2xy(uves_beta_cd, uves_beta_ech, fc, &xmod, &ymod);
00593 uves_msg_debug("xmod=%f ymod=%f",xmod,ymod);
00594
00595 uves_physmod_photo_beta(dblwav, uves_beta_ech, uves_beta_cd,
00596 &uves_physmod_rech, &uves_physmod_rcd, &blaze);
00597
00598 uves_msg_debug("uves_physmod_rech %f, uves_physmod_rcd %f, blaze %f",
00599 uves_physmod_rech, uves_physmod_rcd, blaze);
00600
00601
00602
00603 uves_msg_debug("Before translation: xmod %f, ymod %f",xmod, ymod);
00604
00605 xmod += xtrans;
00606 ymod += ytrans;
00607 uves_msg_debug("xtrans=%f ytrans=%f xmod=%f ymod=%f",
00608 xtrans, ytrans, xmod, ymod);
00609
00610 uves_msg_debug("After translation: xmod %f, ymod %f",xmod, ymod);
00611 uves_msg_debug("xpix=%d ypix=%d",xpix,ypix);
00612
00613 uves_msg_debug("binx=%f biny=%f",binx,biny);
00614
00615 if (xmod > 0 && xmod < xpix && ymod > 0 && ymod < ypix) {
00616
00617
00618 uves_physmod_pixscl(dblwav, order, uves_physmod_rech, uves_physmod_rcd,
00619 binx, biny, fc, slit_width, slit_length,
00620 &binsize, &pixscale, &pixscalCD, &linewidpx,
00621 &linelenpx, &linewidth, &resol);
00622
00623 uves_msg_debug("binsize %f, pixscale %f, pixscalCD %f",
00624 binsize,pixscale,pixscalCD);
00625 uves_msg_debug("linewidpx %f, linelenpx %f, linewidth %f, resol %f",
00626 linewidpx,linelenpx,linewidth,resol);
00627
00628
00629 if (CMP_REG_SW) {
00630 uves_physmod_xy_regres(xmod,ymod,&xreg,&yreg);
00631 } else {
00632 xreg = xmod;
00633 yreg = ymod;
00634 }
00635
00636
00637 uves_msg_debug("Fill tab: i=%d wave=%f order=%d xmod=%f ymod=%f",
00638 i,dblwav,order,xmod,ymod);
00639
00640 uves_msg_debug("Fill tab: bin_sixe=%f xreg=%f yreg=%f ",
00641 binsize,xreg,yreg);
00642
00643 uves_msg_debug("Fill tab: linewidpx=%f linewidth=%f resol=%f linelenpx=%f blaze=%f",
00644 linewidpx,linewidth,resol,linelenpx,blaze);
00645
00646
00647 cpl_table_set_double(*mod_tbl, "WAVE" ,imod, dblwav);
00648 cpl_table_set_int (*mod_tbl, "ORDER" ,imod, order);
00649 cpl_table_set_double(*mod_tbl, "XMOD" ,imod, xreg);
00650 cpl_table_set_double(*mod_tbl, "YMOD" ,imod, yreg);
00651 cpl_table_set_double(*mod_tbl, "BIN_SIZE" ,imod, binsize);
00652 cpl_table_set_double(*mod_tbl, "LINEWIDPX",imod, linewidpx);
00653 cpl_table_set_double(*mod_tbl, "LINEWIDTH",imod, linewidth);
00654 cpl_table_set_double(*mod_tbl, "RESOL" ,imod, resol);
00655 cpl_table_set_double(*mod_tbl, "LINELENPX",imod, linelenpx);
00656 cpl_table_set_double(*mod_tbl, "BLAZE" ,imod, blaze);
00657 ++imod;
00658
00659 }
00660 order--;
00661 }
00662 }
00663
00664 cpl_table_duplicate_column(*mod_tbl,"IDENT",*mod_tbl,"WAVE");
00665 cpl_table_multiply_scalar(*mod_tbl,"IDENT",10.);
00666 cpl_table_duplicate_column(*mod_tbl,"XSTART",*mod_tbl,"XMOD");
00667 cpl_table_add_scalar(*mod_tbl,"XSTART",-mbox_x/2.);
00668 cpl_table_duplicate_column(*mod_tbl,"YSTART",*mod_tbl,"YMOD");
00669 cpl_table_add_scalar(*mod_tbl,"YSTART",-mbox_y/2.);
00670 cpl_table_duplicate_column(*mod_tbl,"XEND",*mod_tbl,"XMOD");
00671 cpl_table_add_scalar(*mod_tbl,"XEND",mbox_x/2.);
00672 cpl_table_duplicate_column(*mod_tbl,"YEND",*mod_tbl,"YMOD");
00673 cpl_table_add_scalar(*mod_tbl,"YEND",mbox_y/2.);
00674
00675
00676
00677
00678
00679
00680 uves_msg("Predicted number of lines: %d",imod);
00681
00682
00683
00684 uves_msg("Determine the Free Spectral Range");
00685
00686 dxpix = (double) xpix;
00687 dypix = (double) ypix;
00688
00689 m_min = -1;
00690 m_max = -1;
00691
00692
00693
00694
00695 uves_physmod_lambda_order_model(&lmax,&m_min,1.0,dypix);
00696 uves_physmod_lambda_order_model(&lmin,&m_max,dxpix,1.0);
00697
00698 uves_physmod_lambda_order_model(&lmax,&m_min,dxpix,dypix);
00699 uves_physmod_lambda_order_model(&lmin,&m_max,1.0,1.0);
00700
00701
00702 uves_msg_debug("m_min= %d,m_max= %d",m_min,m_max);
00703
00704
00705
00706
00707 *fsr_tbl=cpl_table_new(m_max-m_min+1);
00708
00709 uves_msg("FSR tbl created: %s. No of columns: %d, No of rows: %d","free_spectral_range",
00710 20,m_max-m_min+1);
00711 cpl_table_new_column(*fsr_tbl,"ORDER",CPL_TYPE_INT);
00712 cpl_table_new_column(*fsr_tbl,"WVCENTCOL",CPL_TYPE_DOUBLE);
00713 cpl_table_new_column(*fsr_tbl,"YCENTCOL",CPL_TYPE_DOUBLE);
00714 cpl_table_new_column(*fsr_tbl,"START",CPL_TYPE_DOUBLE);
00715 cpl_table_new_column(*fsr_tbl,"END",CPL_TYPE_DOUBLE);
00716 cpl_table_new_column(*fsr_tbl,"WAVECENT",CPL_TYPE_DOUBLE);
00717 cpl_table_new_column(*fsr_tbl,"YCENT",CPL_TYPE_DOUBLE);
00718 cpl_table_new_column(*fsr_tbl,"FSRMIN",CPL_TYPE_DOUBLE);
00719 cpl_table_new_column(*fsr_tbl,"FSRMAX",CPL_TYPE_DOUBLE);
00720 cpl_table_new_column(*fsr_tbl,"XFSR_MIN",CPL_TYPE_DOUBLE);
00721 cpl_table_new_column(*fsr_tbl,"XFSR_MAX",CPL_TYPE_DOUBLE);
00722 cpl_table_new_column(*fsr_tbl,"YFSR_MIN",CPL_TYPE_DOUBLE);
00723 cpl_table_new_column(*fsr_tbl,"YFSR_MAX",CPL_TYPE_DOUBLE);
00724 cpl_table_new_column(*fsr_tbl,"PIXSCALE",CPL_TYPE_DOUBLE);
00725 cpl_table_new_column(*fsr_tbl,"PIXSCALCD",CPL_TYPE_DOUBLE);
00726 cpl_table_new_column(*fsr_tbl,"BIN_SIZE",CPL_TYPE_DOUBLE);
00727 cpl_table_new_column(*fsr_tbl,"LINEWIDPX",CPL_TYPE_DOUBLE);
00728 cpl_table_new_column(*fsr_tbl,"LINEWIDTH",CPL_TYPE_DOUBLE);
00729 cpl_table_new_column(*fsr_tbl,"RESOL",CPL_TYPE_DOUBLE);
00730 cpl_table_new_column(*fsr_tbl,"LINELENPX",CPL_TYPE_DOUBLE);
00731
00732
00733 imod = 0;
00734 uves_msg_debug("m, waveCentcol, Start, End, yCent, FSRmin, FSRmax, bin (mA)");
00735
00736 for (m=m_max; m>=m_min; m--) {
00737 uves_msg_debug("%d ",m);
00738 uves_physmod_find_FSR(m,&l, &fsr_min, &fsr_max);
00739
00740 uves_physmod_xy_model(l,m,&x,&y);
00741
00742
00743 x += xtrans;
00744 y += ytrans;
00745
00746 uves_physmod_xy_model(fsr_min,m,&xfsr_min,&yfsr_min);
00747
00748
00749 xfsr_min += xtrans;
00750 yfsr_min += ytrans;
00751
00752 uves_physmod_xy_model(fsr_max,m,&xfsr_max,&yfsr_max);
00753
00754
00755 xfsr_max += xtrans;
00756 yfsr_max += ytrans;
00757
00758
00759 uves_physmod_lambda_order2beta(l,m, &uves_beta_ech, &uves_beta_cd, &fc);
00760 uves_physmod_photo_beta(l, uves_beta_ech, uves_beta_cd,
00761 &uves_physmod_rech, &uves_physmod_rcd, &blaze);
00762
00763
00764
00765
00766 uves_physmod_pixscl(l, m, uves_physmod_rech, uves_physmod_rcd,
00767 binx, biny, fc, slit_width, slit_length,
00768 &dl, &pixscale, &pixscalCD,
00769 &linewidpx, &linelenpx, &linewidth, &resol);
00770
00771 mmin = m;
00772 mmax = m;
00773
00774
00775
00776
00777 uves_physmod_lambda_order_model(&lcent,&m,dxpix/2,y);
00778 uves_physmod_xy_model(lcent,m,&xr,&yr);
00779
00780 uves_physmod_lambda_order_model(&lmax,&mmax,dxpix,y);
00781 uves_physmod_lambda_order_model(&lmin,&mmin,1.0,y);
00782
00783
00784
00785 uves_msg_debug("m=%d, waveCent (nm)=%f, Start=%f, End=%f",m,l,lmin,lmax);
00786 uves_msg_debug("yCent=%f,FSRmin=%f,FSRmax=%f,bin (mA)=%f",y,fsr_min,fsr_max,dl);
00787
00788
00789 uves_msg_debug("%d %f %f %f %f %f %f %f",m,lcent,lmin,lmax,yr,fsr_min,fsr_max,dl);
00790
00791
00792 uves_msg_debug("pixel-scale = %f, anamorphic corrections = %f, %f",
00793 pixscale, uves_physmod_rech, uves_physmod_rcd);
00794
00795
00796 cpl_table_set_int(*fsr_tbl, "ORDER",imod,m);
00797 cpl_table_set_double(*fsr_tbl, "WVCENTCOL",imod,lcent);
00798 cpl_table_set_double(*fsr_tbl, "YCENTCOL",imod,yr);
00799 cpl_table_set_double(*fsr_tbl, "START",imod,lmin);
00800 cpl_table_set_double(*fsr_tbl, "END",imod,lmax);
00801 cpl_table_set_double(*fsr_tbl, "WAVECENT",imod,l);
00802 cpl_table_set_double(*fsr_tbl, "YCENT",imod,y);
00803 cpl_table_set_double(*fsr_tbl, "FSRMIN",imod,fsr_min);
00804 cpl_table_set_double(*fsr_tbl, "FSRMAX",imod,fsr_max);
00805 cpl_table_set_double(*fsr_tbl, "XFSR_MIN",imod,xfsr_min);
00806 cpl_table_set_double(*fsr_tbl, "XFSR_MAX",imod,xfsr_max);
00807 cpl_table_set_double(*fsr_tbl, "YFSR_MIN",imod,yfsr_min);
00808 cpl_table_set_double(*fsr_tbl, "YFSR_MAX",imod,yfsr_max);
00809 cpl_table_set_double(*fsr_tbl, "PIXSCALE",imod,pixscale);
00810 cpl_table_set_double(*fsr_tbl, "PIXSCALCD",imod,pixscalCD);
00811 cpl_table_set_double(*fsr_tbl, "BIN_SIZE",imod,dl);
00812 cpl_table_set_double(*fsr_tbl, "LINEWIDPX",imod,linewidpx);
00813 cpl_table_set_double(*fsr_tbl, "LINEWIDTH",imod,linewidth);
00814 cpl_table_set_double(*fsr_tbl, "RESOL",imod,resol);
00815 cpl_table_set_double(*fsr_tbl, "LINELENPX",imod,linelenpx);
00816 ++imod;
00817
00818
00819 }
00820
00821
00822 cpl_table_erase_invalid_rows(*mod_tbl);
00823
00824
00825 uves_msg_debug("End determination fsr range");
00826
00827
00828 cleanup:
00829
00830 return 0;
00831 }
00832
00833
00834 static int
00835 flames_get_trans(const int plt_no,
00836 enum uves_chip chip,
00837 const double wlen,
00838 double * TX,
00839 double * TY)
00840 {
00841
00842
00843 if(plt_no==1) {
00844 if( chip==UVES_CHIP_REDL) {
00845 if(wlen==520) {
00846 *TX = -15.330;
00847 *TY = -40.461;
00848 } else if (wlen == 580) {
00849 *TX = -17.972;
00850 *TY = -39.200;
00851 } else if (wlen == 860) {
00852 *TX= -12.212;
00853 *TY= -49.370;
00854 }
00855 } else {
00856 if(wlen==520) {
00857 *TX = -14.237;
00858 *TY = -40.337;
00859 } else if (wlen == 580) {
00860 *TX= -14.738;
00861 *TY= -38.831;
00862 } else if (wlen == 860) {
00863
00864 *TX = -08.253;
00865 *TY = -45.385;
00866 }
00867 }
00868 } else if (plt_no==2) {
00869 if( chip==UVES_CHIP_REDL) {
00870 if(wlen==520) {
00871 *TX = +10.136;
00872 *TY = -41.420;
00873 } else if (wlen == 580) {
00874 *TX = +09.000;
00875 *TY = -38.289;
00876 } else if (wlen == 860) {
00877 *TX = +16.386;
00878 *TY = -47.519;
00879 }
00880 } else {
00881 if(wlen==520) {
00882 *TX = +12.244;
00883 *TY = -41.970;
00884 } else if (wlen == 580) {
00885 *TX = +12.023;
00886 *TY = -38.165;
00887 } else if (wlen == 860) {
00888 *TX = +18.241;
00889 *TY = -43.889;
00890 }
00891 }
00892
00893 } else {
00894 uves_msg_warning("plt_no=%d chip=%d Wlen %g is not standard setting setting defaults",plt_no,chip,wlen);
00895 *TX = 0;
00896 *TY = 0;
00897 }
00898 return 0;
00899
00900 }
00901