DAS  3.1.6 - 18/09/2017
Functions | Variables
Procedures.c File Reference

DAS high level functions. More...

#include <windows.h>
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#include <direct.h>
#include <time.h>
#include <math.h>
#include <errno.h>
#include "mgui.h"
#include "DAS_Spatram.h"
#include "dcl.h"
#include "dil.h"
#include "bil.h"
#include "DOAS.h"
+ Include dependency graph for Procedures.c:

Go to the source code of this file.

Functions

double AutoR_No_Shutt (void)
 
void AutoR_SetND_Filter (void)
 
double AutoR_TestMeas (int mod, double texpmin, double texpar, float level, float levelinf)
 
double AutoR_With_Shutt ()
 
double AutoRange (int mod)
 Calculate the exposure time
The optimum exposure time (TExp) is calculated with an initial TExpAR=0.1 s, and assuming the linearity between the CCD signal and the exposure time.
If TExp calculated is lower than the minimum TExp allowed (0.02s) (meaning a saturation of the CCD), the appropriate filter is positioned and the procedure is repeated.
If with TExpAR the delta(CCD(x,y))=Max(CCD(x,y))-Min(CCD(x,y)) is lower than 2000 counts (meaning very low radiation intensity) TExpAR is increased and the procedure repeated for at least 4 times (Max TExpAR ~ 5 s) More...
 
void D_Average (int mod)
 Performs averaged measurements
. More...
 
void D_AverageTFix (void)
 NOT Used
. More...
 
void D_BuildH (int mod, int s)
 Build Header of the measurements .
. More...
 
int D_Calibra (void)
 Spectral Calibration
Procedure for the spectral calibration with HG lamp. Shift of HG spectral line at 4358.4 on pixel 512. More...
 
void D_Measure (void)
 
void D_Plot (void)
 ViewPlot callback
. More...
 
void D_Saving (void)
 Saving image.
Procedure for saving the CCD Image Used since version 2.1.0. The coiche between binary and ASCII saving mode is obtained with the mode Flag optionini. More...
 
void DB_DefectPixCorr ()
 Apply thew pixel correction.
. More...
 
int DB_GetCCD (int mod)
 Get CCD Image.
. More...
 
void DB_MirrorX (int w)
 
double DB_ScanMaxMin (int w, float *mx, float *mi, int bp)
 Find Max and Min values for the buffer of order w. More...
 
int Lookfor4358 (void)
 function to scan the wl() array in order to identify the position of the 4358 reference wavelength return value: er = -1 –> value 4358 not encountered er >= 0 –> value 4358 found at er position More...
 
int LookforWl_X (int x)
 
void MaskCol (int a, int b, int c, int d, int e)
 
void MaskPix (int a, int b, int c, int d, int e, int f)
 
void MaskRow (int a, int b, int c, int d, int e)
 
void RemoveBlindPixels (void)
 
void SaveCalib (int mod)
 
void ShutterOpening (int mod)
 

Variables

AzimuthSt AST
 
bil BIL
 
config Cfg
 
das DAS
 DAS structure. More...
 
ccd DC_CCD
 
ptf DC_HP
 
d_geo DGEO
 geographical coordinates structure More...
 
int ExeREM
 
int fftprh = 1
 
int fftsavecal = 1
 
flag FLAG
 flags structure More...
 
FilterWheelSt FWS
 Filter Wheel. More...
 
GratingSt GRS
 Grating. More...
 
hdrsp HDRSP
 
float maxar
 
float maxtt
 
float minar
 
float mintt
 
MirrorSt MIS
 Mirror. More...
 
NDFilterWheelSt NDFWS
 ND Filter Wheel. More...
 
paramini PARAM
 Param.ini. More...
 
int SaveCnt = 1
 
int ShuttDelay = 0
 
ZenithSt ZST
 

Detailed Description

DAS high level functions.

Author
Daniele Bortoli

Definition in file Procedures.c.

Function Documentation

§ AutoR_No_Shutt()

double AutoR_No_Shutt ( void  )

Definition at line 468 of file Procedures.c.

References AutoR_SetND_Filter(), BlindPix, DB_GetCCD(), DB_ScanMaxMin(), DI_Regen(), DIL, das::DOption, ccd::dx, ccd::dy, FDOUBLE, optionini::filtertype, GetDateTime(), img::High, img::IHigh, img::ILow, dil::Img, img::Low, image::Mat, maxar, optionini::maxlvlar, paramini::maxtexp, maxtt, minar, mintt, das::Paramini, Server, TExp, and paramini::VBin.

Referenced by AutoRange().

469 {
470 
471  double TExpAutoR = 0.2;
472  double TExpMin=0.05;
473 // double TExpTest;
474  float treshold = 2;
475  float Level = 55000;
476  float LevelInf = 1000;
477  int numrip, maxrep;
478  struct time ACTime;
479  struct date ACDate;
480  struct tm today;
481  double TExpZero;
482  double TExpLast;
483 
484 
485  GetDateTime(&ACDate, &ACTime, &today);
486 
487 
488 /* if (S_zenetr>= 85 & S_zenetr<= 93) // & ACTime.ti_hour <12)
489  Level = 55000;
490  else
491  Level = 55000;
492 */
493 
494  /******************************************************************************************
495  If the Shutter Uniblitz VS25 is present the minimum Exposure time is 0.02 sec
496  otherwise (if the shutter is NOT installed) the minimum exposure time depends on the CCD
497  Reading Time. This last is a function of the binning parameters and it can be calculated
498  according to the formula (for HIRES_IV):
499 
500  RT (in ms)= (vp/vb)*Kv + (vp/vb)*(hp/hb)*Kh
501  where:
502  vp = vertical pixels number
503  vb = vertical binning
504  Kv = 0.024 for hires
505  hp = horizontal pixels number
506  hb = horizontal binning
507  Kh = 0.0125
508 
509  For High values of Vertical Binning the Reading Time (RT) is very short
510  (i.e for VertBin of41-the maximum supported by HiRESIV-RT is less than 0.09 sec)
511  therefore the excess of signal due to the over-exposition of the sensor
512  can be neglected.
513  ******************************************************************************************/
514  //Set Minimum exposure time
515  TExpMin = treshold * ((((float)DC_CCD.dy / (float)DAS.Paramini.VBin) * 0.024 + ((float)DC_CCD.dy /
516  (float)DAS.Paramini.VBin) * DC_CCD.dx * 0.0125) / 1000);
517 
518 
519 
520  if(DAS.DOption.filtertype == FDOUBLE)
521  maxrep = 6;
522  else
523  maxrep = 2;
524 
525  numrip = 1;
526 
527 
528  /*************************************************/
529  Level = (float) DAS.DOption.maxlvlar;
530  /*************************************************/
531  /* zero measurement: with TExp = Tmin (No necessity for Loop over the time
532  since this is the minimum time). The cycle is repeated since when the maximum
533  is at least half of the MAXIMUM set signal (LEVEL=60000)*/
534  TExp = TExpMin;
535 
536  do
537  {
538  //delay(ShuttDelay);
539  DB_GetCCD(1);
540  //delay(ShuttDelay);
541  // Scan Max Min
545  // Regen the histogram
546  DI_Regen(Server);
547 
548  if(DIL.Img.Mat[Server].IHigh >= Level/4)
549  {
551  numrip++;
552  }
553 
554  }
555  while ((DIL.Img.Mat[Server].IHigh >= Level/4) && numrip <= maxrep);
556 
557 // Offset = DIL.Img.Mat[Server].IHigh;// - DIL.Img.Mat[Server].ILow;
559  mintt = DIL.Img.Mat[Server].ILow;
560  TExpZero = TExp;
561 
562 
563 
564  //The Zero point is calculated and the filter positioned
565  //Now the measure (It) for computation of TExp, with TExpAutoR.
566  // decrease the Exposure time (till when the time is the double of the Minimum Exposure time)
567  maxrep = 6;
568  numrip = 1;
569  TExpAutoR = 4*TExpMin;
570  TExp = TExpAutoR;
571 
572  do
573  {
574  //delay(ShuttDelay);
575  DB_GetCCD(1);
576  //delay(ShuttDelay);
577  // Scan Max Min
581  // Regen the histogram
582  DI_Regen(Server);
583 
584  if(DIL.Img.Mat[Server].IHigh >= Level)
585  {
586  TExp = TExp / 1.3;
587  numrip++;
588  }
589  if(DIL.Img.Mat[Server].IHigh - DIL.Img.Mat[Server].ILow <= 100)
590  {
591  TExp = TExp * 3;
592  numrip++;
593  }
594  }
595  while( (DIL.Img.Mat[Server].IHigh >= Level && numrip < maxrep)
596  || ((DIL.Img.Mat[Server].IHigh - DIL.Img.Mat[Server].ILow <= 100) && numrip < maxrep) );
597 
598 // Offset = DIL.Img.Mat[Server].IHigh;// - DIL.Img.Mat[Server].ILow;
600  minar = DIL.Img.Mat[Server].ILow;
601  TExpLast = TExp;
602 
603 
604  TExp = ( Level * ((1000*(TExpLast- TExpZero))/( maxar - maxtt )))/ 1000;
605 
606  if(TExp <= TExpMin)
607  TExp = TExpMin;
608 
609  if( DAS.Paramini.maxtexp == 0.0 )
610  TExp = TExp;
611  else
612  {
613  if (TExp >= DAS.Paramini.maxtexp)
615  else
616  TExp= TExp;
617  }
618 
619 
620  return TExp;
621 
622 
623 
624 
625 }
int Server
Definition: DAS_Spat.c:253
dil DIL
Definition: 2DPlot.c:26
C_DEF void DI_Regen(int s)
ccd DC_CCD
Definition: Procedures.c:29
float minar
Definition: Procedures.c:252
img Mat[MAXIMG]
Definition: Dildef.h:552
image Img
Definition: Dildef.h:675
float maxar
Definition: Procedures.c:252
das DAS
DAS structure.
Definition: Procedures.c:47
double DB_ScanMaxMin(int w, float *mx, float *mi, int bp)
Find Max and Min values for the buffer of order w.
Definition: Procedures.c:1632
#define FDOUBLE
double filter wheel
int VBin
CCD Vertical Binning.
float maxtt
Definition: Procedures.c:252
Definition: Dildef.h:240
float IHigh
Definition: Dildef.h:303
float mintt
Definition: Procedures.c:252
S16 dy
Num. of Y pixels.
Definition: dcldef.h:1023
double TExp
CCD Exposure time.
Definition: DAS_Spat.c:130
float ILow
Definition: Dildef.h:302
int DB_GetCCD(int mod)
Get CCD Image. .
Definition: Procedures.c:1749
void GetDateTime(struct date *dp, struct time *tp, struct tm *when)
Definition: Save.c:43
Definition: Dildef.h:234
double maxtexp
Maximum exposure time (used in Autorange())
void AutoR_SetND_Filter(void)
Definition: Procedures.c:261
int BlindPix
Number of blind pixels (usefull for Dark Current)
Definition: DAS_Spat.c:120
float Low
Definition: Dildef.h:294
float High
Definition: Dildef.h:295
paramini Paramini
structure for the parameters defined in param.ini configuration file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AutoR_SetND_Filter()

void AutoR_SetND_Filter ( void  )

Definition at line 261 of file Procedures.c.

References delay(), das::DOption, paramini::EqType, FDOUBLE, optionini::filtertype, FPLUS, FSIMPLE, GASCODNG3, das::Paramini, FilterWheelSt::Pos, NDFilterWheelSt::Pos, SD_FilterW(), SD_FNTorqueM(), SD_NDFilterW(), SPATRAM2, SPATRAM3, SPATRAMPLUS, wl, and GratingSt::Wl.

Referenced by AutoR_No_Shutt(), and AutoR_With_Shutt().

262 {
263 
265  {
267  {
268  if (NDFWS.Pos == 0)
269  SD_NDFilterW(1); //ND1
270  else if (NDFWS.Pos == 1)
271  SD_NDFilterW(2); //ND2
272  else if (NDFWS.Pos == 2)
273  SD_NDFilterW(3); //ND3
274  else if (NDFWS.Pos == 3)
275  SD_NDFilterW(4); //ND4
276  }
277  }
278  if(DAS.DOption.filtertype == FPLUS)
279  {
280 // if(DAS.Paramini.EqType == GASCODNG1)
281 // {
282  SD_FNTorqueM(1);//ND1
283  delay(700);
284 // }
285  }
287  {
288  if (DAS.Paramini.EqType == GASCODNG3 )
289  {
290  //*Fil_CodeNG[] = {{"NULL"}, {"B12 "}, {"B12F"}, {"B39 "}, {"B39F"}, {"UG5 "}};
291  if ((wl[GRS.Wl] == 3850))
292  {
293  if ( FWS.Pos == 1); //B12
294  SD_FilterW(2); //B12F
295  if ( FWS.Pos == 3); //B39
296  SD_FilterW(4); //B39F
297  }
298  if (wl[GRS.Wl] == 4358)
299  {
300  //The Wl 4358 can be used with 2 different filters:BG12 and BG39, with the ND filters also
301  if (FWS.Pos == 0) //B12
302  SD_FilterW(2); //B12F
303  if (FWS.Pos == 1) //B12
304  SD_FilterW(2); //B12F
305  if (FWS.Pos == 3) //B39
306  SD_FilterW(4); //B39F
307  }
308  if (wl[GRS.Wl] == 4861)
309  {
310  if ((FWS.Pos == 1)) //B12
311  SD_FilterW(2); //B12F
312  if ((FWS.Pos == 3)) //B39
313  SD_FilterW(4); //B39F
314  }
315  if ((wl[GRS.Wl] == 5332) )
316  {
317  if ((FWS.Pos == 1)) //B12
318  SD_FilterW(2); //B12F
319  if ((FWS.Pos == 3)) //B39
320  SD_FilterW(4); //B39F
321  }
322  if ((wl[GRS.Wl] == 4610) )
323  {
324  if ((FWS.Pos == 1)) //B12
325  SD_FilterW(2); //B12F
326  if ((FWS.Pos == 3)) //B39
327  SD_FilterW(4); //B39F
328  }
329  }
330  }
331 }
int Pos
Filter Wheel current Position.
optionini DOption
Options for DAS execution.
void SD_FNTorqueM(int mod)
Positioning NDFilter. .
Definition: Spat_Device.c:3066
int filtertype
type of installed filter module: 0=Simple-SM3, 1=Double-SM3+SM4, 2=simpleplus-SM3+TM) ...
int SD_FilterW(int filter)
Positioning Filter wheel. The filter wheel move on the filter number specified by filter...
Definition: Spat_Device.c:2244
NDFilterWheelSt NDFWS
ND Filter Wheel.
Definition: Procedures.c:35
int Pos
Filter Wheel current Position.
das DAS
DAS structure.
Definition: Procedures.c:47
int Wl
Grating Wavelength.
#define FDOUBLE
double filter wheel
#define FPLUS
Filter Wheel Torque Motor.
#define SPATRAM2
SPATRAM2 (with ATX power supply & HiresV)
#define SPATRAMPLUS
As SPATRAM plus AltAzimuth platform.
void delay(unsigned long d)
Pauses for a specified number of milliseconds. .
Definition: Dxl.c:1113
#define GASCODNG3
GASCODNG 3 (with ATX power supply & HiresIV)
FilterWheelSt FWS
Filter Wheel.
Definition: Procedures.c:34
#define FSIMPLE
simple filter wheel
#define SPATRAM3
SPATRAM3.
int wl[]
WaveLength definition - for SD_Grating.
Definition: DAS_Spat.c:182
int EqType
Spectrometer Type.
int SD_NDFilterW(int filter)
Positioning Filter wheel. The filter wheel move on the filter number specified by filter...
Definition: Spat_Device.c:2354
GratingSt GRS
Grating.
Definition: Procedures.c:36
paramini Paramini
structure for the parameters defined in param.ini configuration file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AutoR_TestMeas()

double AutoR_TestMeas ( int  mod,
double  texpmin,
double  texpar,
float  level,
float  levelinf 
)

Definition at line 334 of file Procedures.c.

References controlpanel::Albl_IE, BlindPix, paramini::ccdWx, gui::ContrPanel, DB_GetCCD(), DB_ScanMaxMin(), DI_Regen(), DIL, ccd::dx, FlagTExp, das::Gui, img::High, img::IHigh, img::ILow, dil::Img, img::Low, image::Mat, MObjectSetText(), das::Paramini, Server, Status(), and TExp.

Referenced by AutoR_With_Shutt().

335 {
336 
337  char buf[80];
338  int k;
339  int FlgSat = 1;
340 
341  double FlagTExp = 2.0;
342 
343 // double TExpLast;
344  double temp = 0;
345  int Lim_supinf = 0;
346 
347  float treshold = 2;
348 
349  float lowval = 700;
350  float Offset = 0;
351  int numrip = 0;
352 
353 
354  /****************************************************************************************/
355  // To take into account the Blind Pixels
356  //RC = IDY/2;
357  if (DC_CCD.dx - (DAS.Paramini.ccdWx +1) != 0)
358  {
360  }
361  /*****************************************************************************************/
362 
363 
364  if (mod)
365  TExp = texpar;
366  else
367  TExp = texpmin;
368 
369  //delay(ShuttDelay);
370  DB_GetCCD(1);
371  //delay(ShuttDelay);
372  // Scan Max Min
376  // Regen the histogram
377  DI_Regen(Server);
378 
379 //Check the obtained signal
380  // Max value greater than the superior limit
381  if (DIL.Img.Mat[Server].High >= level)
382  {
383  // enter in the first do cicle where the exp. time is iteratively reduced
384  //(until TExpMin * treshold)
385  do
386  {
387  TExp = TExp / FlagTExp;
388 
389  sprintf(buf, "%.3lf", TExp);
391  Status("Autoranging >");
392 
393  //Measure
394  //delay(ShuttDelay);
395  DB_GetCCD(1);
396  //delay(ShuttDelay);
397  // Scan Max Min
401  // Regen the histogram
402  DI_Regen(Server);
403 
404  if(DIL.Img.Mat[Server].High > level && numrip >= 4)
405  {
406  //Exit DO loop and IF condition with TExp = TExpMin
407  //in order to execute the following IF
408  TExp = texpmin;
409  return TExp;
410  }
411  // Increse FlagTExp (in order to reduce the TExp)
412  FlagTExp = FlagTExp * 2.5;
413  numrip++;
414 
415  } while(DIL.Img.Mat[Server].High > level );
416 
417  }
418  // Max value lower than the inferior limit
419  else if (DIL.Img.Mat[Server].High < levelinf)
420  {
421  // enter in the second do cicle where the exp. time is iteratively increased
422  // the cycle is repeted at maximum 5 times
423  k=0;
424  do
425  {
426  TExp = TExp * FlagTExp;
427  k++;
428  sprintf(buf, "%.3lf", TExp);
430  Status("Autoranging >");
431  //Measure
432  DB_GetCCD(1);
433  // Scan Max Min
437  // Regen the histogram
438  DI_Regen(Server);
439  // Increase FlagTExp (in order to increase the TExp)
440  FlagTExp = FlagTExp * 2.5;
441  } while((DIL.Img.Mat[Server].High < levelinf) && k < 5);
442 
443  sprintf(buf, "%.3lf", TExp);
445  }
446  else //No needs for others attempts
447  {
448  if (mod)
449  TExp = TExp;
450  else
451  TExp = TExp;
452  sprintf(buf, "%.3lf", TExp);
454 
455  }
456  return TExp;
457 
458 }
gui Gui
Graphic User Interface Structure.
int Server
Definition: DAS_Spat.c:253
dil DIL
Definition: 2DPlot.c:26
C_DEF void DI_Regen(int s)
ccd DC_CCD
Definition: Procedures.c:29
int ccdWx
CCD X End.
S16 dx
Num. of X pixels.
Definition: dcldef.h:1022
img Mat[MAXIMG]
Definition: Dildef.h:552
void MObjectSetText(MOBJECT obj, const char *text)
image Img
Definition: Dildef.h:675
das DAS
DAS structure.
Definition: Procedures.c:47
double DB_ScanMaxMin(int w, float *mx, float *mi, int bp)
Find Max and Min values for the buffer of order w.
Definition: Procedures.c:1632
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
double FlagTExp
Definition: Exec.c:38
float IHigh
Definition: Dildef.h:303
double TExp
CCD Exposure time.
Definition: DAS_Spat.c:130
float ILow
Definition: Dildef.h:302
int DB_GetCCD(int mod)
Get CCD Image. .
Definition: Procedures.c:1749
controlpanel ContrPanel
Control Panel Structure.
MOBJECT Albl_IE[1]
Active Control Panel Labels for In Execution status.
int BlindPix
Number of blind pixels (usefull for Dark Current)
Definition: DAS_Spat.c:120
float Low
Definition: Dildef.h:294
float High
Definition: Dildef.h:295
paramini Paramini
structure for the parameters defined in param.ini configuration file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AutoR_With_Shutt()

double AutoR_With_Shutt ( )

mha!!!!

Definition at line 627 of file Procedures.c.

References AutoR_SetND_Filter(), AutoR_TestMeas(), BlindPix, paramini::ccdWx, DB_GetCCD(), DB_ScanMaxMin(), DI_Regen(), DIL, das::DOption, ccd::dx, paramini::EqType, FDOUBLE, optionini::filtertype, GASCODNG2, GetDateTime(), img::High, img::IHigh, img::ILow, dil::Img, img::Low, image::Mat, maxar, optionini::maxlvlar, paramini::maxtexp, maxtt, minar, mintt, das::Paramini, ROTSHUT, Server, optionini::shuttertype, TExp, TORQUEM, TROPOGAS, and VS25.

Referenced by AutoRange().

628 {
629 
630  double TExpAutoR = 0.2;
631  double TExpMin;
632  double TExpZero;
633  float Level = 62000;
634  float LevelInf = 1000;
635  int numrip, maxrep;
636  float lowval = 700;
637  float Offset = 0;
638  double TExpLast;
639 // double TExpTest;
640 
641  struct time ACTime;
642  struct date ACDate;
643  struct tm today;
644 
645  GetDateTime(&ACDate, &ACTime, &today);
646 
647 
648 // if ((S_zenetr>= 85 & S_zenetr<= 94) & ACTime.ti_hour <12)
649 // Level = 57000;
650 // else
651  Level = 58000;
652  if (DAS.Paramini.EqType == GASCODNG2 )
653  Level = 54000;
654  if (DAS.Paramini.EqType == TROPOGAS)
655  Level = 50000;
656 
657 
658  if (DAS.DOption.shuttertype == VS25)
659  TExpMin = 0.02;
661  TExpMin = 0.045;
663  TExpMin = 0.08; //per NG2//0.1; //0.08;
664 
665  //depending on the installed filter module set the max number of repetition
667  maxrep = 6;
668  else
669  maxrep = 2;
670 
671  numrip = 1;
672 
673  Level = (float)DAS.DOption.maxlvlar;
674 
675 
676  /****************************************************************************************/
677  // To take into account the Blind Pixels
678  //RC = IDY/2;
679  if (DC_CCD.dx - (DAS.Paramini.ccdWx +1) != 0)
680  {
682  }
683  /*****************************************************************************************/
684 
685 
686  /* zero measurement: with TExp = Tmin (No necessity for Loop over the time
687  since this is the minimum time). The cycle is repeated since when the maximum
688  is at least half of the MAXIMUM set signal (LEVEL=60000)*/
689  TExp = TExpMin;
690 
691  do
692  {
693  //delay(ShuttDelay);
694  DB_GetCCD(1);
695  //delay(ShuttDelay);
696  // Scan Max Min
700  // Regen the histogram
701  DI_Regen(Server);
702 
703  if(DIL.Img.Mat[Server].IHigh >= Level/3)
704  {
706  numrip++;
707  }
708  }
709  while ((DIL.Img.Mat[Server].IHigh >= Level/3) && numrip <= maxrep);
710 
711  Offset = DIL.Img.Mat[Server].IHigh;// - DIL.Img.Mat[Server].ILow;
713  mintt = DIL.Img.Mat[Server].ILow;
714  TExpZero = TExp;
715 
716 
717 
718  //The Zero point is calculated and the filter positioned
719  //Now the measure (It) for computation of TExp, with TExpAutoR.
720  // decrease the Exposure time (till when the time is the double of the Minimum Exposure time)
721  maxrep = 6;
722  numrip = 1;
723 
724  TExpAutoR = 3*TExpMin;
725 
726  if (DAS.Paramini.EqType == GASCODNG2 ) //with the torquemotor shutter
727  TExpAutoR = 2*TExpMin;
728 
729  TExp = TExpAutoR;
730 
731  do
732  {
733  //delay(ShuttDelay);
734  DB_GetCCD(1);
735  //delay(ShuttDelay);
736  // Scan Max Min
740  // Regen the histogram
741  DI_Regen(Server);
742 
743  if(DIL.Img.Mat[Server].IHigh >= Level)
744  {
745  TExp = TExp/1.3;
746  numrip++;
747  }
748 // if(DIL.Img.Mat[Server].ILow <= LevelInf)
749 // TExp = TExp*1.1;
750  else if( (DIL.Img.Mat[Server].IHigh - maxtt) <= 800)
751  {
752  TExp = TExpMin * (4 + numrip);
753  numrip++;
754  }
755  }
756  while( ((DIL.Img.Mat[Server].IHigh >= Level || (DIL.Img.Mat[Server].IHigh - maxtt) <= 800 ) && (numrip < maxrep) ) );
757  //while(DIL.Img.Mat[Server].IHigh >= Level && numrip < maxrep && (DIL.Img.Mat[Server].IHigh - maxtt) <= 800 );
758 // while (TExp >= 2* TExpMin || numrip < maxrep);
759 
760  Offset = DIL.Img.Mat[Server].IHigh;// - DIL.Img.Mat[Server].ILow;
762  minar = DIL.Img.Mat[Server].ILow;
763  TExpLast = TExp;
764 
765  //Test 21/04/2015
766  if ( (maxar - maxtt) > 0)
767  {
768  TExp = (double)( Level * ((10000*(TExpLast- TExpZero))/( fabs(maxar - maxtt) )))/ 10000;
769  if( DAS.Paramini.maxtexp == 0.0 )
770  TExp = TExp;
771  else
772  {
773  if (TExp >= DAS.Paramini.maxtexp)
775  else
776  TExp= TExp;
777  }
778  }
779 // else if ( (maxar - maxtt) <=0)
780 // {
781 // TExp = TExpMin;
782 // }
783 
784  else
785  {
786  if( DAS.Paramini.maxtexp != 0.0 )
788  else
789  TExp = 1;
790 
791  //TExp = ( Level * ((10000*(TExpLast- TExpZero))/( maxar - maxtt+1 )))/ 10000;
792  }
793 
794 
795  if(TExp <= TExpMin )
796  TExp = TExpMin;
797 
798 
799 
800  return TExp;
801 
802 
803 
804 
805  /*****************************************************************************/
806  //do the First test Measurement to fix the zero point (with TExpMin)
807  TExpZero = AutoR_TestMeas(0, TExpMin, TExpAutoR, Level, LevelInf);
808  if (DIL.Img.Mat[Server].High >= Level)
809  {
810  //depending on the installed filter module set the max number of repetition
812  maxrep = 6;
813  else
814  maxrep = 2;
815 
816  numrip = 1;
817  do
818  {
820  TExpZero = AutoR_TestMeas(0, TExpMin, TExpAutoR, Level, LevelInf);
821  numrip++;
822 
823  if(DIL.Img.Mat[Server].High<= Level && TExpZero >= TExpMin)
824  break;
825  }while ((TExpZero <= TExpMin) && (numrip < maxrep));
826  Offset = DIL.Img.Mat[Server].IHigh;// - DIL.Img.Mat[Server].ILow;
828  mintt = DIL.Img.Mat[Server].ILow;
829  }
830  else
831  {
832  Offset = DIL.Img.Mat[Server].IHigh;// - DIL.Img.Mat[Server].ILow;
833  //TExpTest = TExp;
835  mintt = DIL.Img.Mat[Server].ILow;
836 
837  }
838  /*****************************************************************************/
839 
840  /*****************************************************************************/
841 
842 
843  /******************************************************************************/
844  /******************************************************************************/
845  //do the Test Measurement with TExpAutoR
846  //TExpAutoR = 2 * TExpMin;
847  if (TExpZero >=TExpAutoR)
848  TExpAutoR= TExpZero*1.1;
849  TExpLast = AutoR_TestMeas(1, TExpMin, TExpAutoR, Level, LevelInf);
850  if (DIL.Img.Mat[Server].High >= 65535 || TExpLast <= TExpZero)
851  {
852  //depending on the installed filter module set the max number of repetition
854  maxrep = 6;
855  else
856  maxrep = 2;
857 
858  numrip = 1;
859  do
860  {
862  TExpZero = AutoR_TestMeas(0, TExpMin, TExpAutoR, Level, LevelInf);
864  mintt = DIL.Img.Mat[Server].ILow;
865 
866  TExpLast = AutoR_TestMeas(1, TExpMin, TExpAutoR, Level, LevelInf);
867  numrip++;
868 
869  }while ((DIL.Img.Mat[Server].High >= Level || TExpLast <= TExpZero) && numrip < maxrep);
870  Offset = DIL.Img.Mat[Server].IHigh;// - DIL.Img.Mat[Server].ILow;
872  minar = DIL.Img.Mat[Server].ILow;
873  }
874  else
875  {
876  Offset = DIL.Img.Mat[Server].IHigh;// - DIL.Img.Mat[Server].ILow;
878  minar = DIL.Img.Mat[Server].ILow;
879 
880  }
881 
882  LevelInf = lowval + Offset;
883 
884 
885  /******************************************************************************/
886  /******************************************************************************/
887 
888  //Final TExp Computation
889  //TExpLast = TExp;
890 
891  TExp = ( Level * ((1000*(TExpLast- TExpZero))/( maxar - maxtt )))/ 1000;
892 
893  return TExp;
894 
895 }
int Server
Definition: DAS_Spat.c:253
dil DIL
Definition: 2DPlot.c:26
optionini DOption
Options for DAS execution.
#define TORQUEM
Torque Motor.
C_DEF void DI_Regen(int s)
ccd DC_CCD
Definition: Procedures.c:29
int ccdWx
CCD X End.
int filtertype
type of installed filter module: 0=Simple-SM3, 1=Double-SM3+SM4, 2=simpleplus-SM3+TM) ...
float minar
Definition: Procedures.c:252
#define ROTSHUT
Rotating Shutter.
S16 dx
Num. of X pixels.
Definition: dcldef.h:1022
img Mat[MAXIMG]
Definition: Dildef.h:552
image Img
Definition: Dildef.h:675
float maxar
Definition: Procedures.c:252
das DAS
DAS structure.
Definition: Procedures.c:47
double DB_ScanMaxMin(int w, float *mx, float *mi, int bp)
Find Max and Min values for the buffer of order w.
Definition: Procedures.c:1632
#define TROPOGAS
TROPOspheric Gas Analyzer Spectrometer.
#define FDOUBLE
double filter wheel
#define GASCODNG2
GASCODNG 2 (with ATX power supply & HiresIV)
float maxtt
Definition: Procedures.c:252
Definition: Dildef.h:240
float IHigh
Definition: Dildef.h:303
#define VS25
Uniblitz Shutter VS25.
float mintt
Definition: Procedures.c:252
double TExp
CCD Exposure time.
Definition: DAS_Spat.c:130
float ILow
Definition: Dildef.h:302
int DB_GetCCD(int mod)
Get CCD Image. .
Definition: Procedures.c:1749
void GetDateTime(struct date *dp, struct time *tp, struct tm *when)
Definition: Save.c:43
Definition: Dildef.h:234
double maxtexp
Maximum exposure time (used in Autorange())
void AutoR_SetND_Filter(void)
Definition: Procedures.c:261
int EqType
Spectrometer Type.
int BlindPix
Number of blind pixels (usefull for Dark Current)
Definition: DAS_Spat.c:120
float Low
Definition: Dildef.h:294
int shuttertype
type of installed shutter: 0 = VS25, 1 = Rotating Shutter, 2 = TorqueMotor
unsigned int maxlvlar
maximum level of autoranging (max 65000)
float High
Definition: Dildef.h:295
double AutoR_TestMeas(int mod, double texpmin, double texpar, float level, float levelinf)
Definition: Procedures.c:334
paramini Paramini
structure for the parameters defined in param.ini configuration file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ AutoRange()

double AutoRange ( int  mod)

Calculate the exposure time
The optimum exposure time (TExp) is calculated with an initial TExpAR=0.1 s, and assuming the linearity between the CCD signal and the exposure time.
If TExp calculated is lower than the minimum TExp allowed (0.02s) (meaning a saturation of the CCD), the appropriate filter is positioned and the procedure is repeated.
If with TExpAR the delta(CCD(x,y))=Max(CCD(x,y))-Min(CCD(x,y)) is lower than 2000 counts (meaning very low radiation intensity) TExpAR is increased and the procedure repeated for at least 4 times (Max TExpAR ~ 5 s)

Parameters
mod
  • 0 = first attempt (with no filter)
  • 1 = second attempt (with the filter positioned
Returns
double = exposure time (x.xx sec)

Definition at line 899 of file Procedures.c.

References controlpanel::Albl_IE, AutoR_No_Shutt(), AutoR_With_Shutt(), gui::ContrPanel, DB_GetCCD(), DBDEMO, delay(), das::DOption, optionini::emshutter, paramini::EqType, flag::exemode, das::Flag, FlagTExp, GASCODNG1, das::Gui, MObjectSetText(), das::Paramini, MirrorSt::Pos, S_zenetr, ShuttDelay, Status(), TESTSZAMODE, and TExp.

Referenced by D_Average(), D_AverageTFix(), D_Calibra(), D_Measure(), DB_HorComm_CB(), DB_KeyB_CB(), E_AutoRange(), E_ChkExLamp(), E_HgScan(), E_QjScan(), GetDefPix(), and PerformMeas().

900 {
901  char buf[80];
902  int i;
903  int FlgSat = 1;
904  double FlagTExp = 2.0;
905  double TExpAutoR = 0.2;
906  //double TExpMin=0;
907 // double TExpLast;
908  double temp = 0;
909  int Lim_supinf = 0;
910 
911  float Level = 55000;
912 // float LevelInf;
913  float lowval = 700;
914  float Offset = 0;
915  static int numrip = 0;
916 
917  /*****************************************************************************************/
918  // For DEMO Mode
920  {
921  for(i=0;i<3; i++)
922  {
923  delay(ShuttDelay);
924  TExp =(float) (3 - i);
925  DB_GetCCD(1);
926 
927  }
928  TExp = 1.2;
929  return TExp;
930  }
931  /*****************************************************************************************/
932 
933 
934 
935  /******************************************************************************************
936  If the Shutter Uniblitz VS25 is present the minimum Exposure time is 0.02 sec
937  otherwise (if the shutter is NOT installed) the minimum exposure time depends on the CCD
938  Reading Time. This last is a function of the binning parameters and it can be calculated
939  according to the formula (for HIRES_IV):
940 
941  RT (in ms)= (vp/vb)*Kv + (vp/vb)*(hp/hb)*Kh
942  where:
943  vp = vertical pixels number
944  vb = vertical binning
945  Kv = 0.024 for hires
946  hp = horizontal pixels number
947  hb = horizontal binning
948  Kh = 0.0125
949 
950  For High values of Vertical Binning the Reading Time (RT) is very short
951  (i.e for VertBin of41-the maximum supported by HiRESIV-RT is less than 0.09 sec)
952  therefore the excess of signal due to the over-exposition of the sensor
953  can be neglected.
954  ******************************************************************************************/
955  Status("Autoranging");
956 if (S_zenetr>= 100 & DAS.Paramini.EqType == GASCODNG1 & MIS.Pos != 2)
957 {
958  TExp = 300.0;
959 }
960 else
961 {
962  if (DAS.DOption.emshutter)
963  {
965  }
966  else
967  {
968  TExp = AutoR_No_Shutt();
969  }
970 }
971  /*****************************************************************************************/
972 
973 
974  sprintf(buf, "%.3lf", TExp);
976 
977  Status("Autoranging DONE");
978  return TExp;
979 
980 
981 }
gui Gui
Graphic User Interface Structure.
double S_zenetr
Definition: SOLPOS.C:92
optionini DOption
Options for DAS execution.
#define TESTSZAMODE
execution driven by SZAPRG file
int Pos
Mirror Current Position.
flag Flag
Structure for different flags.
#define DBDEMO
execution in demo mode
double AutoR_No_Shutt(void)
Definition: Procedures.c:468
void MObjectSetText(MOBJECT obj, const char *text)
das DAS
DAS structure.
Definition: Procedures.c:47
int ShuttDelay
Definition: Procedures.c:255
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
double FlagTExp
Definition: Exec.c:38
int emshutter
Presence of the CCD Shutter, emshutter = 1 –> Shutter IS Installed, = 0 –> Shutter NOT Installed...
void delay(unsigned long d)
Pauses for a specified number of milliseconds. .
Definition: Dxl.c:1113
#define GASCODNG1
GASCODNG 1 (with ATX power supply & HiresIV)
double TExp
CCD Exposure time.
Definition: DAS_Spat.c:130
int DB_GetCCD(int mod)
Get CCD Image. .
Definition: Procedures.c:1749
controlpanel ContrPanel
Control Panel Structure.
MOBJECT Albl_IE[1]
Active Control Panel Labels for In Execution status.
int EqType
Spectrometer Type.
MirrorSt MIS
Mirror.
Definition: Procedures.c:33
int exemode
Set the Execution MODE (Execution modes)
double AutoR_With_Shutt()
Definition: Procedures.c:627
paramini Paramini
structure for the parameters defined in param.ini configuration file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ D_Average()

void D_Average ( int  mod)

Performs averaged measurements
.

Parameters
mod= 1 –> perform AutoRanging, = 0 –> DO NOT PERFORM AutoRange

Definition at line 2655 of file Procedures.c.

References AutoRange(), optionini::avgautor, marconi::AVGmat, optionini::avgmode, BlindPix, DB_GetCCD(), DB_ScanMaxMin(), delay(), DI_Regen(), DIL, das::DOption, HGFlg, img::High, IDX, IDY, img::IHigh, img::ILow, img::Imat, dil::Img, img::Low, das::Marconi, image::Mat, MLoopWhileEvents(), MMessageDialog(), N_AVG, N_RM, QJFlg, Server, ShuttDelay, st, Status(), TExp, and TOTTEXP.

Referenced by DB_HorComm_CB(), DB_KeyB_CB(), and PerformMeas().

2657 {
2658  char buf[64];
2659  int c;
2660 // int fd;
2661  long n, np;
2662  double TT, DeadTime,availabletime;
2663  int NM; //Number of calculated/setted measurements
2664  //int NRM; // Number of measurements effectively obtained (without the saturated measurements that can occur
2665  int tmpnavg = 0;
2666 
2667  MOBJECT sh;
2668  int t, j;
2669  unsigned long st, et, x;
2670  struct tm today;
2671 
2672 
2673 
2674  if(mod) // perform autoranging
2675  {
2676  if(DAS.DOption.avgautor)
2677  AutoRange(0);
2678  else
2679  {
2680  if (TExp==0)
2681  MMessageDialog("DAS information", "TExp = 0\nThe Average procedure can NOT be executed\nPlease provide a valid TExp\n(Executing a GetCCD or Autoranging)!!", " Ok ", NULL);
2682  return ;
2683  }
2684  }
2685 
2686  //DAS.Marconi.AVGmat = AllocFloatMat(IDX, IDY);
2687  np = IDX * IDY;// * 2;
2688  //memset(DAS.Marconi.AVGmat, 0, np);
2689  for(n = 0; n < np; n++)
2690  DAS.Marconi.AVGmat[n] = 0;
2691 
2692  // Fix Number of Measurements
2693  if(DAS.DOption.avgmode == 0)
2694  {
2695 
2696  tmpnavg = N_AVG;
2697  if(TExp > 0.5 && TExp <= 1.0) tmpnavg = 10;
2698  else
2699  if(TExp > 1.0) tmpnavg = 2;
2700 
2701  for(c = 0; c < tmpnavg; c++)
2702  {
2703  DB_GetCCD(1);
2704  MLoopWhileEvents(0);
2705  sprintf(buf,"Averaging #: %d", c+1);
2706  Status(buf);
2707 
2708 
2709  for(n = 0; n < np; n++)
2710  DAS.Marconi.AVGmat[n] += DIL.Img.Mat[Server].Imat[n];
2711  //AVGmat[n] += (long) DIL.Img.Mat[Server].Imat[n];
2712  delay(50);
2713  }
2714 
2715  for(n = 0; n < np; n++)
2716  DIL.Img.Mat[Server].Imat[n] = (DAS.Marconi.AVGmat[n] / tmpnavg);
2717  //DIL.Img.Mat[Server].Imat[n] = AVGmat[n] / tmpnavg;
2718 
2719 
2720 
2721 // if(DAS.DOption.measmode == 0) //Single
2722 // {
2726  DI_Regen(Server);
2727 // }
2728  Status("Ready");
2729 
2730  }
2731  //Fix TOT Exposure Time
2732  else if(DAS.DOption.avgmode == 1)
2733  {
2734  NM = 0;
2735  if(QJFlg)
2736  TT = 1;
2737  if(HGFlg)
2738  TT = 2;
2739  if(!HGFlg & !QJFlg)
2740  TT = TOTTEXP;
2741 
2742  //If there is a delay in the shutter opening, this is accounted for
2743  //in the computation of the number of measurements
2744  if(ShuttDelay > 0)
2745  DeadTime = (TT * (double) ShuttDelay/1000 );
2746  else
2747  DeadTime = 0;
2748 
2749 
2750  availabletime = TT - DeadTime;
2751 
2752  if (availabletime > 0)
2753  TT = availabletime;
2754  else
2755  TT = TT;
2756 
2757  //First computation of number of measurement
2758  NM = (int)(TT / (TExp + 0.5)); //0.5 is the average download time for each measurement
2759  // This is tested for SPATRAM2 instrument
2760 
2761 
2762 /*
2763  Computation of CCD reading time
2764  DTA Formula: RT (in ms)= (vp/vb)*Kv + (vp/vb)*(hp/hb)*Kh
2765  where:
2766  vp = vertical pixels number
2767  vb = vertical binning
2768  Kv = 0.024 for hires
2769  hp = horizontal pixels number
2770  hb = horizontal binning
2771  Kh = 0.0125
2772 
2773 */
2774 /* RT = (((float)DC_CCD.dy / (float)DAS.Paramini.VBin) * 0.024 + ((float)DC_CCD.dy / (float)DAS.Paramini.VBin) * DC_CCD.dx * 0.0125)/1000;
2775 
2776 
2777  if(TExp > RT)
2778  {
2779  RTot = NM * RT;
2780  TT = TT - RTot;
2781  //Second computation of number of measurement (after the correction due to the reading time
2782  NM = (int)(TT / TExp);
2783  }
2784 
2785 
2786 /*
2787  Computation of CCD downloading time ( in ms)
2788  DT = ((vp/vb)*(hp/hb))/KCCD
2789  where:
2790  vp = vertical pixels number
2791  vb = vertical binning
2792  hp = horizontal pixels number
2793  hb = horizontal binning
2794  KCCD = frequency of the CCD (Front = 40Khz; Back = 60Khz)
2795 */
2796 /* DT = (((float)DC_CCD.dy / (float)DAS.Paramini.VBin) * DC_CCD.dx) / 60000;
2797 
2798 // if(TExp > DT)
2799 // {
2800  DTot = NM * DT;
2801  TT = TT - DTot;
2802 // }
2803 
2804  //Third computation of number of measurement (after the correction due to the Downloading time
2805  NM = (int)(TT / TExp);
2806 
2807 */
2808  N_RM = NM;
2809  if(NM > 1)
2810  {
2811  for(c = 0; c < NM; c++)
2812  {
2813 
2814  //st = GetTickCount();
2815 
2816  DB_GetCCD(1);
2817  MLoopWhileEvents(0);
2818 
2819  //et = GetTickCount();
2820 
2821  //x = labs(et - st);
2822 
2823  //sprintf(buf, "%6.3lf", x - (TExp * 1000.0) );
2824  sprintf(buf,"Avg #: %d on %d. TotTExp: %d s", c+1, NM, TOTTEXP);
2825 
2826  Status(buf);
2827  // If the spectrum is saturated
2828  if ((DIL.Img.Mat[Server].IHigh > 65000) & (c != 0))
2829  {
2830  N_RM = N_RM - 1;
2831  }
2832  else
2833  {
2834 
2835  for(n = 0; n < np; n++)
2836  DAS.Marconi.AVGmat[n] += DIL.Img.Mat[Server].Imat[n];
2837  }
2838  }
2839 
2840  for(n = 0; n < np; n++)
2841  DIL.Img.Mat[Server].Imat[n] = ( DAS.Marconi.AVGmat[n] / N_RM);
2842 
2843 
2844 
2845 // if(DAS.DOption.measmode == 0) //Single
2846 // {
2850  DI_Regen(Server);
2851 // }
2852 
2853  }
2854  else //if(NM == 0 or NM ==1)
2855  {
2856 /* if(TExp > .5)
2857  {
2858  sh = MDCreateExpo("EXPOSURE");
2859  sprintf(buf, "%6.1lf", TExp);
2860  DI_WriteDigit(DAS.Marconi.LblExpP, buf);
2861  DI_WriteDigit(DAS.Marconi.LblExpD, buf);
2862  }
2863 */
2864  sprintf(buf,"Measuring with TExp = %3.1lf" , TExp);
2865  Status(buf);
2866 
2867  DB_GetCCD(1);
2868 
2869 /* GetDateTime(&DIL.Img.Mat[Server].DATE, &DIL.Img.Mat[Server].TIME, &today);
2870 
2871  st = GetTickCount();
2872  do
2873  {
2874  et = GetTickCount();
2875  x = labs(et - st);
2876  MLoopWhileEvents(1);
2877  //if((x % 10) == 0 && x > 0)
2878  if(x > 0)
2879  {
2880  sprintf(buf, "%6.1lf", TExp - x / 1000.0 );
2881  //sprintf(TTot, "%6.1lf", TExp );
2882  //ShowDown(buf, TTot);
2883 
2884  ShowDown(buf, 0);
2885 
2886 
2887  }
2888  }while(labs(et - st) < (TExp * 1000));
2889 */
2890 /* if(TExp > .5)
2891  {
2892  MShellUnrealize(sh);
2893  MShellDestroy(sh);
2894  }
2895 */
2896  N_RM = 1;
2897  }
2898  }
2899 
2900  Status("Ready");
2901 // D_Plot();
2902  //free(DAS.Marconi.AVGmat);
2903 
2904 }
int IDX
Number of sensible horizontal pixels.
Definition: DAS_Spat.c:118
int Server
Definition: DAS_Spat.c:253
dil DIL
Definition: 2DPlot.c:26
void MLoopWhileEvents(int discard)
optionini DOption
Options for DAS execution.
C_DEF void DI_Regen(int s)
int QJFlg
Definition: DAS_Spatram.h:2969
U16 * Imat
Definition: Dildef.h:286
int avgautor
autoranging for averaged measurement, 0 = NO AutoR before average; 1 = AutoR before average; ...
img Mat[MAXIMG]
Definition: Dildef.h:552
image Img
Definition: Dildef.h:675
das DAS
DAS structure.
Definition: Procedures.c:47
double DB_ScanMaxMin(int w, float *mx, float *mi, int bp)
Find Max and Min values for the buffer of order w.
Definition: Procedures.c:1632
int avgmode
Flag to set Averaging mode: 0 = Repeat measurements for fixed number, 1 = Repeat measurements for fix...
int ShuttDelay
Definition: Procedures.c:255
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
void delay(unsigned long d)
Pauses for a specified number of milliseconds. .
Definition: Dxl.c:1113
float IHigh
Definition: Dildef.h:303
int IDY
Number of sensible vertical pixels.
Definition: DAS_Spat.c:119
double AutoRange(int mod)
Calculate the exposure time The optimum exposure time (TExp) is calculated with an initial TExpAR=0...
Definition: Procedures.c:899
int TOTTEXP
Total Exposure time in Averaging mode.
Definition: DAS_Spat.c:115
int MMessageDialog(const char *t, const char *msg, const char *btn1, const char *btn2,...)
double TExp
CCD Exposure time.
Definition: DAS_Spat.c:130
float ILow
Definition: Dildef.h:302
int DB_GetCCD(int mod)
Get CCD Image. .
Definition: Procedures.c:1749
long * AVGmat
buffer for averaging measurements
static double st
Definition: SOLPOS.C:142
void * MOBJECT
Definition: Mguidefs.h:192
int N_RM
Number of measurements for Averaging mode in fixed exposure time mode.
Definition: DAS_Spat.c:114
int HGFlg
Definition: DAS_Spatram.h:2968
int BlindPix
Number of blind pixels (usefull for Dark Current)
Definition: DAS_Spat.c:120
int N_AVG
Number of measurements for Averaging mode in fixed number of meas. mode.
Definition: DAS_Spat.c:113
float Low
Definition: Dildef.h:294
float High
Definition: Dildef.h:295
marconi Marconi
CCD Sensor struct.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ D_AverageTFix()

void D_AverageTFix ( void  )

NOT Used
.

Definition at line 2597 of file Procedures.c.

References AutoRange(), marconi::AVGmat, D_Plot(), DB_GetCCD(), DIL, HGFlg, IDX, IDY, img::Imat, dil::Img, das::Marconi, image::Mat, QJFlg, Server, Status(), and TExp.

2598 {
2599 
2600  char buf[64];
2601  int c;
2602 // int fd;
2603  long n, np;
2604  double TT;
2605  int NM;
2606 
2607  NM = 0;
2608 
2609  if(QJFlg)
2610  TT = 1;
2611  if(HGFlg)
2612  TT = 2;
2613  if(!HGFlg & !QJFlg)
2614  TT = 15;
2615 
2616 
2617  AutoRange(0);
2618 
2619 
2620  NM = (int)(TT / TExp);
2621 
2622  np = (long) IDX * IDY * 2;
2623 
2624  DAS.Marconi.AVGmat = malloc(np * 4);
2625  memset(DAS.Marconi.AVGmat, 0, np * 4);
2626 
2627 
2628  if(NM > 0)
2629  {
2630  for(c = 0; c < NM; c++)
2631  {
2632  DB_GetCCD(1);
2633  sprintf(buf,"Averaging #: %d on %d", c, NM);
2634  Status(buf);
2635  for(n = 0; n < np; n++)
2636  DAS.Marconi.AVGmat[n] += (long) DIL.Img.Mat[Server].Imat[n];
2637  }
2638 
2639  for(n = 0; n < np; n++)
2640  DIL.Img.Mat[Server].Imat[n] = (unsigned short) DAS.Marconi.AVGmat[n] / NM;
2641 
2642  }
2643  if(NM == 0)
2644  {
2645  DB_GetCCD(1);
2646  }
2647 
2648  D_Plot();
2649 
2650  free(DAS.Marconi.AVGmat);
2651 
2652 }
int IDX
Number of sensible horizontal pixels.
Definition: DAS_Spat.c:118
int Server
Definition: DAS_Spat.c:253
dil DIL
Definition: 2DPlot.c:26
int QJFlg
Definition: DAS_Spatram.h:2969
U16 * Imat
Definition: Dildef.h:286
void D_Plot(void)
ViewPlot callback .
Definition: Procedures.c:192
img Mat[MAXIMG]
Definition: Dildef.h:552
image Img
Definition: Dildef.h:675
das DAS
DAS structure.
Definition: Procedures.c:47
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
int IDY
Number of sensible vertical pixels.
Definition: DAS_Spat.c:119
double AutoRange(int mod)
Calculate the exposure time The optimum exposure time (TExp) is calculated with an initial TExpAR=0...
Definition: Procedures.c:899
double TExp
CCD Exposure time.
Definition: DAS_Spat.c:130
int DB_GetCCD(int mod)
Get CCD Image. .
Definition: Procedures.c:1749
long * AVGmat
buffer for averaging measurements
int HGFlg
Definition: DAS_Spatram.h:2968
marconi Marconi
CCD Sensor struct.
+ Here is the call graph for this function:

§ D_BuildH()

void D_BuildH ( int  mod,
int  s 
)

Build Header of the measurements .
.

Parameters
mod
  • 0 = ASCII Header
  • 1 = BINARY Header
s
  • 0, 1 = Buffer ccd identifier

Definition at line 63 of file Procedures.c.

References d_geo::alititude, optionini::avgmode, hdrsp::bincomment, hdrsp::binfilpos, hdrsp::binmirpos, hdrsp::ccdnr, marconi::CCDTemp, hdrsp::ccdtemp, hdrsp::ccdtexp, hdrsp::ccdvbin, paramini::ccdWx, hdrsp::ccdwx, paramini::ccdWy, hdrsp::ccdwy, hdrsp::ccdxe, paramini::ccdXoff, hdrsp::ccdxs, hdrsp::ccdye, paramini::ccdYoff, hdrsp::ccdys, hdrsp::comment, img::DATE, hdrsp::DATE, das::DGeo, DIL, das::DOption, hdrsp::dummy1, hdrsp::dummy2, hdrsp::dummy3, hdrsp::dummy4, ccd::dx, ccd::dy, paramini::EqType, FDOUBLE, Fil_Code, Fil_Code8H, Fil_CodeNG, Fil_CodeNG1, Fil_CodeTropo, hdrsp::filpos, optionini::filtertype, FPLUS, GASCODNG1, GASCODNG2, GASCODNG3, GASCODNG4, img::High, dil::Img, hdrsp::imgfmt, hdrsp::imgmax, hdrsp::imgmin, hdrsp::lambda, d_geo::latitude, LIS_, d_geo::longitude, img::Low, das::Marconi, image::Mat, optionini::measmode, Mir_Code, Mir_CodeTropo, hdrsp::mirpos, N_AVG, N_RM, das::Paramini, FilterWheelSt::Pos, NDFilterWheelSt::Pos, MirrorSt::Pos, AzimuthSt::realazpos, ZenithSt::realzenpos, hdrsp::s_alt, hdrsp::s_latitude, hdrsp::s_longitude, d_geo::s_name, hdrsp::s_name, hdrsp::s_sza, S_zenetr, optionini::savingmode, Server, SPATRAM3, TExp, img::TIME, hdrsp::TIME, TMFlg, TROPOGAS, paramini::VBin, wl, and GratingSt::Wl.

Referenced by DB_GetCCD(), and DB_Save().

64 {
65 
66  char buf[16];
67  // Image format
69  HDRSP.imgfmt=1;
70  else
71  HDRSP.imgfmt=0;
72 
73  HDRSP.ccdwx = DC_CCD.dx; //X Pixel Number
74  HDRSP.ccdwy = DC_CCD.dy; //Y Pixel Number
75 
76 
77  HDRSP.ccdxs = DAS.Paramini.ccdXoff; // window X Start
78  HDRSP.ccdys = DAS.Paramini.ccdYoff; // windowY Start
79  HDRSP.ccdxe = DAS.Paramini.ccdWx; // windowX End
80  HDRSP.ccdye = DAS.Paramini.ccdWy; // windowY End
81 
82  HDRSP.ccdvbin = DAS.Paramini.VBin; //Vertical Binning
86 
87 
88  if(mod) //binary
89  {
91  sprintf(buf, "%s",Mir_CodeTropo[MIS.Pos]);
92  else
93  sprintf(buf, "%s",Mir_Code[MIS.Pos]);
94 
95 
96  sprintf(HDRSP.binmirpos, buf);
97  }
98  else
99  {
101  sprintf(buf, "%s",Mir_CodeTropo[MIS.Pos]);
102  else
103  sprintf(buf, "%s",Mir_Code[MIS.Pos]);
104 
105 
106  sprintf(HDRSP.mirpos, buf);
107  }
108  HDRSP.lambda = wl[GRS.Wl];
109 
110  if(mod)
111  {
112  if(DAS.Paramini.EqType == LIS_)
113  sprintf(HDRSP.binfilpos, Fil_Code8H[FWS.Pos]);
114  else
115  {
116  if(DAS.Paramini.EqType == TROPOGAS)
117  sprintf(HDRSP.binfilpos, Fil_CodeTropo[FWS.Pos]);
119  sprintf(HDRSP.binfilpos, Fil_CodeNG[FWS.Pos]);
120  else if (DAS.Paramini.EqType == GASCODNG1)
121  sprintf(HDRSP.binfilpos, Fil_CodeNG1[FWS.Pos]);
122  else
123  sprintf(HDRSP.binfilpos, Fil_Code[FWS.Pos]);
124  }
125  }
126  else
127  {
128  if(DAS.Paramini.EqType == LIS_)
130  else
131  {
132  if(DAS.Paramini.EqType == TROPOGAS)
136  else if (DAS.Paramini.EqType == GASCODNG1)
137  sprintf(HDRSP.binfilpos, Fil_CodeNG1[FWS.Pos]);
138  else
140  }
141  }
142 
144 
145  HDRSP.ccdtexp = (float) TExp;
146  HDRSP.imgmax = (unsigned int) DIL.Img.Mat[s].High;
147  HDRSP.imgmin = (unsigned int) DIL.Img.Mat[s].Low;
148 /* HDRSP.imgavg =
149  HDRSP.imgsig =
150 */
151  HDRSP.dummy1 = (int)(ZST.realzenpos * 100); //elevation angle
152  HDRSP.dummy2 = (int)(AST.realazpos * 100); //azimuth angle
153 
154 
156  HDRSP.dummy3 = NDFWS.Pos;
157  else if(DAS.DOption.filtertype == FPLUS)
158  HDRSP.dummy3 = TMFlg;
159  else
160  HDRSP.dummy3 = 0;
161 
162  if(DAS.DOption.measmode == 1) //measuring with average
163  {
164  if(DAS.DOption.avgmode == 0)
165  HDRSP.dummy4 = N_AVG; // number of measurements in fixed number of measurements
166  else
167  HDRSP.dummy4 = N_RM; // number of measurements in fixed exposure time
168  }
169  else
170  HDRSP.dummy4 = 0;
171 
172  if(mod) //binary
173  sprintf(HDRSP.bincomment, "Default Comment");
174  else
175  HDRSP.comment = "Default Comment ";
176 
177  sprintf(HDRSP.s_name, "%s", DAS.DGeo.s_name);
178  HDRSP.s_latitude = (float)DAS.DGeo.latitude;
180  HDRSP.s_alt = (unsigned int) DAS.DGeo.alititude;
181  HDRSP.s_sza = (float)S_zenetr;
182 
183 
184  //Image Type, Camera Type, CCD Type, CCDWx, CCDWy, CCDXoff, CCDYoff, VBin
185  //Date, Time, MirrorPos, Lambda, Filter, TempCCD, T_Exp,
186  //Max, Min, Media, Deviazione, Dummy1, Dummy2, Dummy3, Dummy4
187  //Riga di commento
188 
189 }
int Pos
Filter Wheel current Position.
double S_zenetr
Definition: SOLPOS.C:92
int Server
Definition: DAS_Spat.c:253
dil DIL
Definition: 2DPlot.c:26
optionini DOption
Options for DAS execution.
int savingmode
Flag to set saving mode: 0=ASCII, 1=Binary.
double alititude
Station altitude.
const char * Mir_Code[]
const char array for the realisation of the Mirrors buttons in the Mirror shell
Definition: DAS_Spat.c:231
hdrsp HDRSP
Definition: Procedures.c:32
unsigned int imgmin
Image minimum value.
Definition: Dildef.h:710
double realazpos
ccd DC_CCD
Definition: Procedures.c:29
int ccdwy
Total Number of Y Pixels.
Definition: Dildef.h:693
int ccdWx
CCD X End.
double latitude
Station latitude.
int ccdwx
Total Number of X Pixels.
Definition: Dildef.h:692
int dummy4
Definition: Dildef.h:716
int dummy3
Definition: Dildef.h:715
int Pos
Mirror Current Position.
struct date DATE
Registration date.
Definition: Dildef.h:701
int filtertype
type of installed filter module: 0=Simple-SM3, 1=Double-SM3+SM4, 2=simpleplus-SM3+TM) ...
int ccdys
Y Start.
Definition: Dildef.h:695
int ccdXoff
CCD X Start.
float ccdtemp
CCD Temperature.
Definition: Dildef.h:707
NDFilterWheelSt NDFWS
ND Filter Wheel.
Definition: Procedures.c:35
S16 dx
Num. of X pixels.
Definition: dcldef.h:1022
img Mat[MAXIMG]
Definition: Dildef.h:552
char * Fil_Code8H[]
const char array for the realisation of the Filters buttons in the Filter shell
Definition: DAS_Spat.c:204
struct date DATE
Definition: Dildef.h:348
int ccdxe
X End.
Definition: Dildef.h:696
int TMFlg
Definition: DAS_Spatram.h:2972
image Img
Definition: Dildef.h:675
int Pos
Filter Wheel current Position.
das DAS
DAS structure.
Definition: Procedures.c:47
d_geo DGeo
struct for Station location
#define LIS_
Lampedusa Island Spectrometer - ENEA.
int ccdWy
CCD Y End.
int Wl
Grating Wavelength.
#define TROPOGAS
TROPOspheric Gas Analyzer Spectrometer.
unsigned int s_alt
station altitude
Definition: Dildef.h:722
float s_longitude
station longitude
Definition: Dildef.h:720
char * Fil_CodeNG[]
const char array for the realisation of the Filters buttons in the Filter shell for GASCODNG2 and NG3...
Definition: DAS_Spat.c:216
char s_name[4]
Station name.
float CCDTemp
Actual CCD Temperature.
struct time TIME
Registration time.
Definition: Dildef.h:700
#define FDOUBLE
double filter wheel
#define FPLUS
Filter Wheel Torque Motor.
char binmirpos[8]
Mirror position.
Definition: Dildef.h:703
int avgmode
Flag to set Averaging mode: 0 = Repeat measurements for fixed number, 1 = Repeat measurements for fix...
#define GASCODNG2
GASCODNG 2 (with ATX power supply & HiresIV)
char * comment
comment
Definition: Dildef.h:717
int VBin
CCD Vertical Binning.
int imgfmt
Image format: 0 = ASCII, 1 = BIN.
Definition: Dildef.h:688
int dummy2
Definition: Dildef.h:714
int ccdnr
Row number (ccdyoff-ccdwx)/ccdvbin.
Definition: Dildef.h:699
#define GASCODNG3
GASCODNG 3 (with ATX power supply & HiresIV)
float s_sza
sun solar zenith angles
Definition: Dildef.h:724
char bincomment[255]
comment
Definition: Dildef.h:718
#define GASCODNG1
GASCODNG 1 (with ATX power supply & HiresIV)
FilterWheelSt FWS
Filter Wheel.
Definition: Procedures.c:34
#define GASCODNG4
GASCODNG 4.
char * Fil_CodeNG1[]
const char array for the realisation of the Filters buttons in the Filter shell for GASCODNG1 instrum...
Definition: DAS_Spat.c:213
float s_latitude
station latitude
Definition: Dildef.h:719
S16 dy
Num. of Y pixels.
Definition: dcldef.h:1023
#define SPATRAM3
SPATRAM3.
double TExp
CCD Exposure time.
Definition: DAS_Spat.c:130
char binfilpos[5]
Filter position.
Definition: Dildef.h:706
const char * filpos
Filter position.
Definition: Dildef.h:705
ZenithSt ZST
Definition: Procedures.c:44
char s_name[4]
station localization
Definition: Dildef.h:721
char * Fil_Code[]
const char array for the realisation of the Filters buttons in the Filter shell
Definition: DAS_Spat.c:207
int wl[]
WaveLength definition - for SD_Grating.
Definition: DAS_Spat.c:182
AzimuthSt AST
Definition: Procedures.c:45
char mirpos[8]
Mirror position.
Definition: Dildef.h:702
double longitude
Station longitude.
int ccdye
Y End.
Definition: Dildef.h:697
int measmode
measuring mode: 0 = Single; 1 = Averaged
int dummy1
Definition: Dildef.h:713
int ccdxs
X Start.
Definition: Dildef.h:694
char * Fil_CodeTropo[]
const char array for the realisation of the Filters buttons in the Filter shell for TROPOGAS instrume...
Definition: DAS_Spat.c:210
struct time TIME
Definition: Dildef.h:347
double realzenpos
int EqType
Spectrometer Type.
int N_RM
Number of measurements for Averaging mode in fixed exposure time mode.
Definition: DAS_Spat.c:114
int lambda
wavelength value
Definition: Dildef.h:704
int N_AVG
Number of measurements for Averaging mode in fixed number of meas. mode.
Definition: DAS_Spat.c:113
float Low
Definition: Dildef.h:294
float ccdtexp
ccd Exposure time
Definition: Dildef.h:708
int ccdYoff
CCD Y Start.
GratingSt GRS
Grating.
Definition: Procedures.c:36
unsigned int imgmax
Image maximum value.
Definition: Dildef.h:709
float High
Definition: Dildef.h:295
MirrorSt MIS
Mirror.
Definition: Procedures.c:33
int ccdvbin
Vertical binning value.
Definition: Dildef.h:698
marconi Marconi
CCD Sensor struct.
const char * Mir_CodeTropo[]
const char array for the realisation of the Mirrors buttons in the Mirror shell for TROPOGAS ...
Definition: DAS_Spat.c:234
paramini Paramini
structure for the parameters defined in param.ini configuration file
+ Here is the caller graph for this function:

§ D_Calibra()

int D_Calibra ( void  )

Spectral Calibration
Procedure for the spectral calibration with HG lamp. Shift of HG spectral line at 4358.4 on pixel 512.

Definition at line 2313 of file Procedures.c.

References controlpanel::Albl_LS, AMS1, AutoRange(), BlindPix, gui::ContrPanel, D_Plot(), DB_GetCCD(), DB_StepMotor(), DBDEMO, delay(), DIL, GratingSt::dp, paramini::EqType, flag::exec, flag::exemode, ExeREM, das::Flag, GASCODNG1, GASCODNG2, GASCODNG3, GASCODNG4, das::Gui, HgLamp(), IDX, IDY, img::Imat, dil::Img, controlpanel::LedSM, LookforWl_X(), MANUAL, image::Mat, MMessageDialog(), MObjectSetText(), MPixmapSetImageFile(), das::Paramini, flag::plotW, PRGFILE, SaveCalib(), SD_FilterW(), SD_Grating(), SD_Mirror(), Server, stepm::SM_B, SM_stepr(), SPATRAM2, SPATRAM3, SPATRAMPLUS, Status(), stepm::step, das::StepM, SZAMODE, TESTSZAMODE, TROPOGAS, wl, and GratingSt::Wl.

Referenced by DB_HorComm_CB(), DB_KeyB_CB(), E_Calibra(), and E_HGratCal().

2314 {
2315 
2316 
2317  long n;
2318 // unsigned v;
2319  int x, y, px, DirCal, er = 0, c;
2320  int k;
2321  int PxHg;
2322  int exm;
2323 // int count, i;
2324  int PosRefWl;
2325 
2326  char buf[256];
2327  unsigned int mx;
2328 
2329  Status("Hg Calibration");
2330 
2332  SD_FilterW(0); //Hole
2334  SD_FilterW(1); //BG12
2335  if(DAS.Paramini.EqType == GASCODNG1)
2336  SD_FilterW(0); //Hole
2337  if(DAS.Paramini.EqType == GASCODNG4)
2338  SD_FilterW(2); //BG12F
2339 
2340 
2341 
2342  BlindPix = 0;
2343 // SaveCalib();
2344  if (IDX>=1024)
2345  BlindPix = IDX - 1024;
2346 
2347  PxHg = (IDX - BlindPix) / 2;
2348 
2349  exm = DAS.Flag.exemode;
2350 
2351 
2352  //PosRefWl = Lookfor4358();
2353  PosRefWl = LookforWl_X(4358);
2354  /************************************************************/
2355  if ((exm == DBDEMO) ||
2356  (exm == MANUAL) ||
2357  (FLAG.exec == 0 && exm == PRGFILE))
2358  {
2359 
2360  if (GRS.Wl != PosRefWl)
2361  {
2362  //If is not the 4358 spectral window
2363  sprintf(buf, "You are performing HG calibration in the %.1lf nm spectral window!!!\nUsually this operation is performed in the 435.8 nm window \nDo you want to continue ?", (double)wl[GRS.Wl]/10);
2364  er = MMessageDialog("DAS information", buf, "Yes, in this window", "Yes, but go to 435.8!", "Cancel Calibration", NULL);
2365  //if it was chosen to calibrate in the actual spectral window the filter is removed
2366  if (er==0)
2367  {
2368  SD_FilterW(0); //Hole
2369  }
2370 
2371  if (er == 1)
2372  {
2373 
2374  SD_Grating(PosRefWl); //Positioning at 4358 A
2375 
2376  }
2377  else if (er == 2)
2378  return 1;
2379  }
2380  }
2381  else if ((exm == DBDEMO) ||
2382  (exm == MANUAL) ||
2383  (FLAG.exec == 1 && exm == PRGFILE) ||
2384  (FLAG.exec == 1 && exm == TESTSZAMODE) ||
2385  (FLAG.exec == 1 && exm == SZAMODE))
2386 
2387  {
2388  ExeREM = 0;
2389  SD_Grating(PosRefWl); //Positioning at 4358 A
2390  ExeREM = 1;
2391 
2392 
2393  }
2394  /************************************************************/
2395 
2396  HgLamp(1);
2398  SD_Mirror(0);
2399  else
2400  SD_Mirror(2);
2401 
2402  sprintf(buf, "Wait 5 sec. for HG lamp Heating");
2403  Status(buf);
2404  delay(5000);
2405 // FlagCalibra = 1;
2406 
2407 
2408 
2409 
2410  for(c = 0; c < 10; c++)
2411  {
2412  sprintf(buf, "Guess %d", c+1);
2413  Status(buf);
2414 
2415 
2416  AutoRange(0);
2417 
2418  DB_GetCCD(1);
2419 
2420  //Save Calibration
2421  if (c==0)
2422  SaveCalib(0);
2423 
2424  y = IDY / 2 ;
2425 
2426 
2427  px = (IDX - BlindPix) / 2;
2428  mx = 5000;
2429  for(x = PxHg - 200; x < PxHg + 200; x++)
2430  {
2431  if(DIL.Img.Mat[Server].Imat[x + y * IDX] > mx)
2432  {
2433  px = x;
2434  mx = DIL.Img.Mat[Server].Imat[x + y * IDX];
2435  }
2436  }
2437  sprintf(buf, "Hg: %u, found at: %d", mx, px);
2438  Status(buf);
2439  delay(1000);
2440  if((px > (PxHg + 1)) || (px < (PxHg - 1))) //grosso
2441  {
2442 
2444  n = (PxHg - px) * (k/200-5) * 4; //4 e' il rapporto di riduzione
2445  // il 60
2446 
2447  if(n < 0)
2448  DirCal = 1;
2449  else
2450  DirCal = 0;
2451 
2452  n = labs(n);
2453  if(n & DirCal == 0) //si va verso l'UV
2454  n += GRS.dp; // add fixed step number for backlash recovery
2455  // Eseguo NStep
2456  if(n)
2457  {
2458  er = DB_StepMotor(AMS1, 1, n, DirCal);
2459  if (er)
2460  {
2461  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS1][1], "SYS\\ledGreen.bmp");
2462  }
2463  }
2464 
2465  //Se ci si e' mossi verso l'UV si fa il recupero del gioco
2466 
2467  if(n & DirCal == 0) // faccio recupero gioco
2468  {
2469  er=DB_StepMotor(AMS1, 1, GRS.dp, 1);
2470  if (er)
2471  {
2472  MPixmapSetImageFile(DAS.Gui.ContrPanel.LedSM[AMS1][1], "SYS\\ledGreen.bmp");
2473  }
2474  }
2475 
2476  }
2477 
2478  else break;
2479  }
2480 
2481 
2482  HgLamp(0);
2483  MObjectSetText(DAS.Gui.ContrPanel.Albl_LS[1], "4358");
2484 
2485  SaveCalib(0);
2486 
2487 // er = AMS_AzzeraCoord(AMS1, 1);
2488 // if(er) { Message("No Zero Coord Grating", er); }
2489 
2490 
2491  if(DAS.Flag.plotW)
2492  D_Plot();
2493 
2494 
2495 
2496  sprintf(buf, "Hg: %u, found at: %d", mx, px);
2497  Status(buf);
2498  delay(500);
2499 
2500  return 0;
2501 
2502 }
stepm StepM
Stepper motors parameters structure.
gui Gui
Graphic User Interface Structure.
MOBJECT LedSM[AMSMAX][2]
Leds for stepper motors status.
int SD_Grating(int ang)
Positioning Grating. The Grating move to the position specified by ang (Wavelength) ...
Definition: Spat_Device.c:2108
int SD_Mirror(int where)
Positioning Input Mirror. The Input Mirror reaches the position specified by where.
Definition: Spat_Device.c:1898
int IDX
Number of sensible horizontal pixels.
Definition: DAS_Spat.c:118
MOBJECT Albl_LS[8]
Active Control Panel Labels for LIS status.
void HgLamp(int mod)
HG Lamp ON/OFF .
Definition: Spat_Device.c:2673
int Server
Definition: DAS_Spat.c:253
dil DIL
Definition: 2DPlot.c:26
int LookforWl_X(int x)
Definition: Procedures.c:2295
int ExeREM
Definition: DAS_Spat.c:143
int plotW
Flag for the plot display.
void MPixmapSetImageFile(MOBJECT pixmap, const char *fname)
#define TESTSZAMODE
execution driven by SZAPRG file
flag Flag
Structure for different flags.
U16 * Imat
Definition: Dildef.h:286
#define DBDEMO
execution in demo mode
int SD_FilterW(int filter)
Positioning Filter wheel. The filter wheel move on the filter number specified by filter...
Definition: Spat_Device.c:2244
void D_Plot(void)
ViewPlot callback .
Definition: Procedures.c:192
img Mat[MAXIMG]
Definition: Dildef.h:552
void MObjectSetText(MOBJECT obj, const char *text)
image Img
Definition: Dildef.h:675
das DAS
DAS structure.
Definition: Procedures.c:47
int exec
= 0 -> PRG Execution Paused; = 1 -> PRG Execution Resumed
int Wl
Grating Wavelength.
#define TROPOGAS
TROPOspheric Gas Analyzer Spectrometer.
long dp
Grating backslash recovery steps.
#define GASCODNG2
GASCODNG 2 (with ATX power supply & HiresIV)
#define SPATRAM2
SPATRAM2 (with ATX power supply & HiresV)
#define SPATRAMPLUS
As SPATRAM plus AltAzimuth platform.
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
void SaveCalib(int mod)
Definition: Procedures.c:2130
void delay(unsigned long d)
Pauses for a specified number of milliseconds. .
Definition: Dxl.c:1113
#define GASCODNG3
GASCODNG 3 (with ATX power supply & HiresIV)
#define PRGFILE
execution driven by *.prg file
flag FLAG
flags structure
Definition: Procedures.c:37
int IDY
Number of sensible vertical pixels.
Definition: DAS_Spat.c:119
#define GASCODNG1
GASCODNG 1 (with ATX power supply & HiresIV)
double AutoRange(int mod)
Calculate the exposure time The optimum exposure time (TExp) is calculated with an initial TExpAR=0...
Definition: Procedures.c:899
#define GASCODNG4
GASCODNG 4.
int MMessageDialog(const char *t, const char *msg, const char *btn1, const char *btn2,...)
#define SPATRAM3
SPATRAM3.
#define SZAMODE
execution driven by SZAPRG file
int SM_B
Motor B (su Y12) respectively: ID=0->Grating,ID=1->Not Connected,ID=2->Azimuth.
int DB_GetCCD(int mod)
Get CCD Image. .
Definition: Procedures.c:1749
int wl[]
WaveLength definition - for SD_Grating.
Definition: DAS_Spat.c:182
controlpanel ContrPanel
Control Panel Structure.
#define AMS1
AMS1 address.
int step[AMSMAX][2]
Stepper Motors Step.
int EqType
Spectrometer Type.
int BlindPix
Number of blind pixels (usefull for Dark Current)
Definition: DAS_Spat.c:120
GratingSt GRS
Grating.
Definition: Procedures.c:36
int SM_stepr(int t)
AMS &#39;steps/round&#39; value return the AMS &#39;steps/round&#39; value (microstepping) depending on the setted st...
Definition: Spat_Device.c:209
int exemode
Set the Execution MODE (Execution modes)
int DB_StepMotor(int id, int motor, long step, int dir)
Send steps to the selected stepper motor. .
Definition: Dxl.c:816
#define MANUAL
execution in manual mode (for lab use)
paramini Paramini
structure for the parameters defined in param.ini configuration file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ D_Measure()

void D_Measure ( void  )

Definition at line 2504 of file Procedures.c.

References AutoRange(), D_Plot(), D_Saving(), DB_GetCCD(), E_REM(), PrgCnt, Program, SD_FilterW(), SD_Grating(), SD_Mirror(), and TExp.

2505 {
2506  int er=0;
2507  int l, f, m, a, d, s, g, ss;
2508  double t;
2509  extern struct date dok;
2510 
2511 // char buf[80];
2512 // PrgCnt += 7;
2513 
2514 
2515  sscanf(&Program[PrgCnt], "%d%d%d%d%lf%d%d%d", &m, &l, &f, &a, &t, &d, &s, &g);
2516 
2517 
2518 
2519  //Posiziona specchio
2520  SD_Mirror(m);
2521  //Posiziona reticolo
2522  SD_Grating(l);
2523  //Posiziona Ruota dei filtri
2524  SD_FilterW(f);
2525 
2526 
2527 // ExeREM = 0;
2528  if(a)
2529  {
2530 
2531  AutoRange(0);
2532 
2533  // Ciclo ottimale per Autoranging;
2534  //Controlla che il valore ottenuto sia compreso tra 1000 e 50000,
2535  //inoltre esegue l'autoranging fino a che il min-max e' maggiore
2536  //di 1000
2537  //oppure il contatore ss sia maggiore di 8
2538  ss=0;
2539 
2540 /* while ((Low < 1000) || (High > 50000) || (((High-Low) < 400) && (ss < 8) ))
2541  {
2542  E_AutoRange();
2543  if(((TExp && 0.01) == 1) && (High > 50000) && (Low > 1000)) goto Salta;
2544  while ((High-Low) < 400 && ss < 8)
2545  {
2546  FlagTExp = FlagTExp * 3;
2547  E_AutoRange();
2548  if((Low < 1000) || (High > 50000) && ss > 0)
2549  {
2550  ss--;
2551  }
2552  else
2553  {
2554  ss++;
2555  }
2556  }
2557  FlagTExp = 1.0;
2558  }
2559 
2560  FlagTExp = 1.0;
2561 */
2562 
2563 
2564  }
2565  else
2566  {
2567  TExp = t;
2568  }
2569 
2570  //Measure (d=1) or dark (d=0)
2571  if(d)
2572  {
2573  DB_GetCCD(1);
2574  }
2575  else
2576  {
2577  DB_GetCCD(0);
2578  }
2579 
2580 
2581  if(s)
2582  {
2583  D_Saving();
2584  }
2585  if(g)
2586  {
2587  D_Plot();
2588  }
2589 // ExeREM = 1;
2590  E_REM();
2591 
2592 
2593 }
int SD_Grating(int ang)
Positioning Grating. The Grating move to the position specified by ang (Wavelength) ...
Definition: Spat_Device.c:2108
int SD_Mirror(int where)
Positioning Input Mirror. The Input Mirror reaches the position specified by where.
Definition: Spat_Device.c:1898
int SD_FilterW(int filter)
Positioning Filter wheel. The filter wheel move on the filter number specified by filter...
Definition: Spat_Device.c:2244
void D_Plot(void)
ViewPlot callback .
Definition: Procedures.c:192
char * Program
buffer for the PRG file
Definition: DAS_Spat.c:90
long PrgCnt
Counter for the position in the PRG file.
Definition: DAS_Spat.c:93
Definition: Dildef.h:240
double AutoRange(int mod)
Calculate the exposure time The optimum exposure time (TExp) is calculated with an initial TExpAR=0...
Definition: Procedures.c:899
void D_Saving(void)
Saving image. Procedure for saving the CCD Image Used since version 2.1.0. The coiche between binary ...
Definition: Procedures.c:1369
double TExp
CCD Exposure time.
Definition: DAS_Spat.c:130
void E_REM(void)
Flush string since the Carriege Return. Procedure for flushing the readed string since the Carriege R...
Definition: Exec.c:47
int DB_GetCCD(int mod)
Get CCD Image. .
Definition: Procedures.c:1749
+ Here is the call graph for this function:

§ D_Plot()

void D_Plot ( void  )

ViewPlot callback
.

Definition at line 192 of file Procedures.c.

References ViewPlot().

Referenced by D_AverageTFix(), D_Calibra(), D_Measure(), E_HgScan(), E_Meashor(), E_Meashor2(), E_QjScan(), and PerformMeas().

193 {
194 
195 
196  ViewPlot(1);
197  //MDCreateSh_Plot();
198 
199 }
int ViewPlot(int mod)
Create the plot shell. Procedure that build the plot shell for the data visualization.
Definition: Spat_Plot.c:3775
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ D_Saving()

void D_Saving ( void  )

Saving image.
Procedure for saving the CCD Image Used since version 2.1.0. The coiche between binary and ASCII saving mode is obtained with the mode Flag optionini.

Returns
void

Definition at line 1369 of file Procedures.c.

References _MAX_PATH, controlpanel::Albl_CS, gui::ContrPanel, d_fileman::DAILYDATADIRECTORY, d_fileman::DATADIRECTORY, DB_Save(), bil::DFILEM, das::DGeo, das::DOption, fftprh, das::Gui, MObjectSetText(), spectrumheader::newdate, spectrumheader::olddate, d_geo::s_name, SaveCnt, SAVECNT, optionini::savingmode, bil::SPH, and Total.

Referenced by D_Measure(), DB_HorComm_CB(), DB_KeyB_CB(), E_Meashor(), E_Meashor2(), E_Save(), GetDefPix(), and PerformMeas().

1370 {
1371 
1372  char tmpbuf[128] ;
1373  static char tit[_MAX_PATH];
1374  char tit1[80];
1375  time_t ltime;
1376  struct tm *today;
1377  int fd, er = 0;
1378 
1379 
1380 
1381 
1382  if(fftprh) //flag first time program run here
1383  {
1384  /* Get UNIX-style time */
1385  time( &ltime );
1386  /* Use time structure to build a customized time string. */
1387  today = localtime( &ltime );
1388  /* Use strftime to build a customized time string. */
1389  strftime( tmpbuf, 7,"%y%m%d", today );
1390 
1391  sprintf(BIL.DFILEM.DAILYDATADIRECTORY,"%s\\%s",BIL.DFILEM.DATADIRECTORY,tmpbuf);
1392 
1393  //_chdir( BIL.DFILEM.DATADIRECTORY );
1394 
1395  er = _mkdir( BIL.DFILEM.DAILYDATADIRECTORY );
1396 /*
1397  if ( er ) //error in creating dir
1398  {
1399  if(EEXIST)
1400  _chdir( BIL.DFILEM.DAILYDATADIRECTORY );
1401  else if (ENOENT)
1402 
1403 
1404  }
1405  else
1406  {
1407  _chdir( BIL.DFILEM.DAILYDATADIRECTORY );
1408  }
1409 */
1410  fftprh=0;
1411  if(DAS.DOption.savingmode) // Binary saving
1412  {
1413  do
1414  {
1415  Total++;
1416  //sprintf(tit, "DATA\\%s%s%03d.bif", DGEO.s_name, tmpbuf, Total);
1417  sprintf(tit, "%s\\%s%s%03d.bif",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf, Total);
1418  fd = access(tit, 0);
1419  }while(!fd);
1420  DB_Save(tit, 1);
1421  }
1422  else //ASCII saving
1423  {
1424  do
1425  {
1426  Total++;
1427  //sprintf(tit, "DATA\\%s%s%03d.dat", DGEO.s_name, tmpbuf, Total);
1428  sprintf(tit, "%s\\%s%s%03d.dat",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf, Total);
1429  sprintf(tit1, "%s", tit+5);
1430  fd = access(tit, 0);
1431  }while(!fd);
1432  DB_Save(tit, 0);
1433  }
1434  sprintf(BIL.SPH.olddate, "%s",tmpbuf);
1435 
1436  }
1437  else
1438  {
1439 
1440 
1441  /* Get UNIX-style time */
1442  time( &ltime );
1443  /* Use time structure to build a customized time string. */
1444  today = localtime( &ltime );
1445  /* Use strftime to build a customized time string. */
1446  strftime( BIL.SPH.newdate, 7,"%y%m%d", today );
1447  /* Use strftime to build a customized time string. */
1448  strftime( tmpbuf, 7,"%y%m%d", today );
1449 
1450 
1451 
1452 
1453  // Se e' cambiata la data rimette a 1 il contatore del numero dei files
1454  if(strcmp(BIL.SPH.newdate, BIL.SPH.olddate) != 0)
1455  {
1456  sprintf(BIL.SPH.olddate, "%s",BIL.SPH.newdate);
1457  Total = 0;
1458 
1459  sprintf(BIL.DFILEM.DAILYDATADIRECTORY,"%s\\%s",BIL.DFILEM.DATADIRECTORY,tmpbuf);
1460  er = _mkdir( BIL.DFILEM.DAILYDATADIRECTORY );
1461 
1462  /*****************************/
1463  if(DAS.DOption.savingmode) // Binary saving
1464  {
1465  do
1466  {
1467  Total++;
1468 // sprintf(tit, "DATA\\%s%s%03d.bif", DGEO.s_name, tmpbuf, Total);
1469  sprintf(tit, "%s\\%s%s%03d.bif",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf, Total);
1470  fd = access(tit, 0);
1471  }while(!fd);
1472  DB_Save(tit, 1);
1473  }
1474  else //ASCII saving
1475  {
1476  do
1477  {
1478  Total++;
1479 // sprintf(tit, "DATA\\%s%s%03d.dat", DGEO.s_name, tmpbuf, Total);
1480  sprintf(tit, "%s\\%s%s%03d.dat",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf, Total);
1481  sprintf(tit1, "%s", tit+5);
1482  fd = access(tit, 0);
1483  }while(!fd);
1484  DB_Save(tit, 0);
1485  }
1486 /*****************************/
1487  }
1488  //Se ha raggiunto il numero di acquisizioni SAVECNT=50
1489  if((SaveCnt % SAVECNT) == 0)
1490  {
1491  if(DAS.DOption.savingmode)
1492  {
1493 // sprintf(tit, "DATA\\%s%s%03d.bif", DGEO.s_name, tmpbuf, Total);
1494  sprintf(tit, "%s\\%s%s%03d.bif",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf, Total);
1495  Total++;
1496  DB_Save(tit, 1);
1497  }
1498  else
1499  {
1500  //sprintf(tit, "DATA\\%s%s%03d.dat", DGEO.s_name, tmpbuf, Total);
1501  sprintf(tit, "%s\\%s%s%03d.dat",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf, Total);
1502  Total++;
1503  DB_Save(tit, 0);
1504  }
1505  }
1506  else
1507  {
1508  if(DAS.DOption.savingmode)
1509  {
1510  //sprintf(tit, "DATA\\%s%s%03d.bif", DGEO.s_name, tmpbuf, Total);
1511  sprintf(tit, "%s\\%s%s%03d.bif",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf, Total);
1512  DB_Save(tit, 1);
1513  }
1514  else
1515  {
1516  //sprintf(tit, "DATA\\%s%s%03d.dat", DGEO.s_name, tmpbuf, Total);
1517  sprintf(tit, "%s\\%s%s%03d.dat",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf, Total);
1518  DB_Save(tit, 0);
1519  }
1520  }
1521  }
1522 
1523 
1524 
1525  sprintf(tit1, "%s%s%03d.bif",DAS.DGeo.s_name, tmpbuf, Total);
1527  sprintf(tit1, "%05d", SaveCnt);
1529 
1530  SaveCnt++;
1531 
1532 
1533 
1534 }
bil BIL
Definition: Procedures.c:42
gui Gui
Graphic User Interface Structure.
optionini DOption
Options for DAS execution.
int savingmode
Flag to set saving mode: 0=ASCII, 1=Binary.
int Total
Progressive acquisition number for file (MAX defined = 50)
Definition: Exec.c:34
char DAILYDATADIRECTORY[_MAX_PATH]
Definition: bildef.h:203
char DATADIRECTORY[_MAX_PATH]
Definition: bildef.h:201
spectrumheader SPH
Spectrum Header Structure.
Definition: bildef.h:256
MOBJECT Albl_CS[4]
Active Control Panel Labels for Camera Status 4.
void DB_Save(char *tit, int mod)
Save the acquired spectrum. Procedure that Save the acquired spectrum.
Definition: Save.c:552
char olddate[8]
Definition: bildef.h:158
void MObjectSetText(MOBJECT obj, const char *text)
das DAS
DAS structure.
Definition: Procedures.c:47
d_geo DGeo
struct for Station location
char s_name[4]
Station name.
d_fileman DFILEM
Definition: bildef.h:257
#define SAVECNT
maximum number of spectra in one file
#define _MAX_PATH
Definition: Dildef.h:202
controlpanel ContrPanel
Control Panel Structure.
char newdate[8]
Definition: bildef.h:159
Definition: Dildef.h:234
int fftprh
Definition: Procedures.c:50
int SaveCnt
Definition: Procedures.c:49
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ DB_DefectPixCorr()

void DB_DefectPixCorr ( void  )

Apply thew pixel correction.
.

Choose the buttons to enable/disable. Repaced with DB_KB_ButtonActive();
.

Definition at line 1568 of file Procedures.c.

References CItem, MaskCol(), MaskedCol, MaskedPix, MaskedRow, MaskPix(), MaskRow(), PItem, and RItem.

Referenced by DB_GetCCD(), and E_Dark().

1569 {
1570  int i;
1571 
1572 
1573  for(i=0;i<PItem;i++)
1574  {
1575 
1576  MaskPix(MaskedPix[i][0], MaskedPix[i][1], MaskedPix[i][2], MaskedPix[i][3], MaskedPix[i][4], MaskedPix[i][5]);
1577 
1578  }
1579 
1580 
1581  for(i=0;i<CItem;i++)
1582  {
1583 
1584  MaskCol(MaskedCol[i][0], MaskedCol[i][1], MaskedCol[i][2], MaskedCol[i][3], MaskedCol[i][4]);
1585 
1586  }
1587 
1588 
1589  for(i=0;i<RItem;i++)
1590  {
1591 
1592  MaskRow(MaskedRow[i][0], MaskedRow[i][1], MaskedRow[i][2], MaskedRow[i][3], MaskedRow[i][4]);
1593 
1594 
1595  }
1596 
1597 }
void MaskPix(int a, int b, int c, int d, int e, int f)
Definition: Procedures.c:1538
void MaskRow(int a, int b, int c, int d, int e)
Definition: Procedures.c:1557
int MaskedPix[100][6]
Masked pixel&#39;s array.
Definition: Load.c:37
int RItem
number of Pixel, Column, Row Item
Definition: Load.c:40
int CItem
Definition: Load.c:40
int PItem
Definition: Load.c:40
void MaskCol(int a, int b, int c, int d, int e)
Definition: Procedures.c:1548
int MaskedRow[100][6]
Masked rows array.
Definition: Load.c:39
int MaskedCol[100][6]
Masked column array.
Definition: Load.c:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ DB_GetCCD()

int DB_GetCCD ( int  mod)

Get CCD Image.
.

Parameters
mod
  • 0 –> Dark measurement
  • 1 –> Light measurement
Returns
er = 0

Definition at line 1749 of file Procedures.c.

References img::BHigh, BlindPix, img::BLow, countsopsh, D_BuildH(), optionini::darkremove, optionini::darksource, img::DATE, DB_DefectPixCorr(), DB_MirrorX(), DB_ScanMaxMin(), DBDEMO, DC_GetCCD(), delay(), DI_Regen(), DI_ScanMaxMin(), DI_WriteDigit(), DIL, das::DOption, flag::exemode, das::Flag, GetDateTime(), img::GHigh, img::GLow, img::High, IDX, IDY, img::IHigh, img::ILow, img::Imat, ImatDark, dil::Img, optionini::imgtype, INTIMG, marconi::LblExpD, marconi::LblExpP, img::Low, das::Marconi, image::Mat, MDCreateExpo(), optionini::measmode, optionini::mirrorimg, MLoopWhileEvents(), MShellDestroy(), MShellUnrealize(), optionini::pixcorr, RemoveBlindPixels(), RGBIMG, img::RHigh, img::RLow, optionini::savingmode, Server, ShowDown(), ShuttDelay, st, TESTSZAMODE, TExp, img::TIME, img::type, and XAX.

Referenced by AutoR_No_Shutt(), AutoR_TestMeas(), AutoR_With_Shutt(), AutoRange(), D_Average(), D_AverageTFix(), D_Calibra(), D_Measure(), DB_AskCB(), DB_HorComm_CB(), DB_KeyB_CB(), E_GetCCD(), E_HgScan(), E_Meashor(), E_Meashor2(), E_QjScan(), GetDefPix(), and PerformMeas().

1750 {
1751 
1752  char buf[80];
1753  MOBJECT sh;
1754  int t, j;
1755  unsigned long st, et, x;
1756  struct tm today;
1757 
1758 
1759 
1760 if(DAS.DOption.measmode == 0) //Single
1761 {
1762  if(TExp > .5)
1763  {
1764  sh = MDCreateExpo("EXPOSURE");
1765  sprintf(buf, "%6.1lf", TExp);
1766 
1769 
1770 
1771  }
1772 
1773 }
1774 /*************************************************************************/
1775  // DEMO mode
1776  if((DAS.Flag.exemode == DBDEMO) | (DAS.Flag.exemode == TESTSZAMODE))
1777  {
1778 
1779 
1780  GetDateTime(&DIL.Img.Mat[Server].DATE, &DIL.Img.Mat[Server].TIME, &today);
1781  //gettime( &DIL.Img.Mat[Server].TIME );
1782 
1783  st = GetTickCount();
1784  do
1785  {
1786  et = GetTickCount();
1787  x = labs(et - st);
1788  MLoopWhileEvents(1);
1789  //if((x % 10) == 0 && x > 0)
1790  if(x > 0)
1791  {
1792  sprintf(buf, "%6.1lf", TExp - x / 1000.0 );
1793  //sprintf(TTot, "%6.1lf", TExp );
1794  //ShowDown(buf, TTot);
1795 
1796  ShowDown(buf, 0);
1797 
1798 
1799  }
1800  }while(labs(et - st) < (TExp * 1000));
1801 
1802  if(DAS.DOption.measmode == 0) //Single Measurement
1803  {
1804  if(TExp > .5)
1805  {
1806  MShellUnrealize(sh);
1807  MShellDestroy(sh);
1808  }
1809  }
1810 
1811  return 0;
1812  }
1813 
1814  /*************************************************************************/
1815 
1816 /*
1817 void DC_GetWinCCD(int mode, double expos, int sx, int sy, int, dx, int dy, Unsigned *mat, int camera);
1818 Descrizione:
1819 Procedura che permette di leggere un’immagine selezionando un’area definita del ccd.
1820 I parametri che devono essere specificati sono:
1821 1. mode, Impostandolo a 0 si effettua una dark, con 1 si riprende l’immagine.
1822 2. expos, Tempo di esposizione espresso in secondi.
1823 3. sx, sy, Coordinate di origine della finestra.
1824 4. dx, dy Dimensione in pixel della finestra.
1825 5. mat, Array lineare dove viene memorizzata l’immagine. L’array mat deve essere dimensionato secondo:
1826 dimx x dimy x 2.
1827 6. camera, specifica quale camera dell’array viene utilizzata (se questa modalita’ e’ attiva).
1828 */
1829 
1830 
1831 
1832  if(!DAS.DOption.imgtype) //Mono image
1833  /******* MONO IMAGE ***************/
1834  {
1835  DIL.Img.Mat[Server].type = INTIMG;
1836  if(mod) // Light Measurement
1837  {
1838 /*
1839  sx = DAS.Paramini.ccdXoff;
1840  sy = DAS.Paramini.ccdYoff;
1841  dx = DAS.Paramini.ccdWx - DAS.Paramini.ccdXoff;
1842  dy = DAS.Paramini.ccdWy - DAS.Paramini.ccdYoff;
1843  DC_StopNow;
1844  DC_FGetWinCCD(1, TExp, sx, sy, dx, dy, Mat[Server].Imat, 0);
1845 */
1846  if(DAS.DOption.darkremove) // Remove Dark from Measurements
1847  {
1848  if(DAS.DOption.darksource) // Dark Source = Full Frame
1849  {
1850  /*******************************/
1851  //Dark Measurement
1852  DC_GetCCD(0, TExp, DIL.Img.Mat[Server].Imat, 0);
1853  if (DAS.DOption.mirrorimg[XAX] == 1)
1854  DB_MirrorX(Server); //Mirror X axis
1855  if (DAS.DOption.pixcorr)
1856  DB_DefectPixCorr();
1857  for(t = 0; t < IDY; t++)
1858  {
1859  for(j = 0; j < IDX ; j++)
1860  {
1861  ImatDark[t * IDX + j] = (unsigned short) DIL.Img.Mat[Server].Imat[t * IDX + j];
1862  }
1863  }
1864  /********************************/
1865  // Light Measurement
1866  // count opening shutter
1867  countsopsh++;
1868  delay(ShuttDelay);
1869  DC_GetCCD(1, TExp, DIL.Img.Mat[Server].Imat, 0);
1870  //Image Rotation
1871  /* if (DAS.Paramini.EqType == SPATRAM2)
1872  {
1873  U16 sav[3];
1874  U32 len = (unsigned long) IDX * (unsigned long) IDY; //DC_CCD.dx * DC_CCD.dy; // dimX e dimY = dimensione immagine
1875 
1876  sav[0] = DIL.Img.Mat[Server].Imat[0];
1877  sav[1] = DIL.Img.Mat[Server].Imat[1];
1878  memcpy(&DIL.Img.Mat[Server].Imat[0], &DIL.Img.Mat[Server].Imat[2], (IDX << 1) );
1879 
1880  DIL.Img.Mat[Server].Imat[len - 1] = sav[1];
1881  DIL.Img.Mat[Server].Imat[len ] = sav[0];
1882 
1883  sav[0] = DIL.Img.Mat[Server].Imat[IDX-3];
1884  sav[1] = DIL.Img.Mat[Server].Imat[IDX-2];
1885 
1886  DIL.Img.Mat[Server].Imat[IDX-1] = sav[0];
1887  DIL.Img.Mat[Server].Imat[IDX-3] = sav[1];
1888  }
1889 
1890  */
1891 
1892  delay(ShuttDelay);
1893  if (DAS.DOption.mirrorimg[XAX] == 1)
1894  DB_MirrorX(Server); //Mirror X axis
1895  if (DAS.DOption.pixcorr)
1896  DB_DefectPixCorr();
1897  //sottrae la dark alla misura
1898  //ATTENZIONE quando la dark e' maggiore della misura
1899  //la sottrazione non funziona RIVEDERE
1900  //RIVISTO - si aggiunge 100 alla misura!!!! (Manuele Dixit)
1901  for(t = 0; t < IDY; t++)
1902  {
1903  for(j = 0; j < IDX ; j++)
1904  {
1905  DIL.Img.Mat[Server].Imat[t * IDX + j] = (unsigned short) (DIL.Img.Mat[Server].Imat[t * IDX + j] + 100) - ImatDark[t * IDX + j];
1906  }
1907  }
1908  }
1909  else // Dark Source = Blind Pixels
1910  {
1911  // Light Measurement
1912  // count opening shutter
1913  countsopsh++;
1914  delay(ShuttDelay);
1915  DC_GetCCD(1, TExp, DIL.Img.Mat[Server].Imat, 0);
1916  //Image Rotation
1917  /* if (DAS.Paramini.EqType == SPATRAM2)
1918  {
1919  U16 sav[3];
1920  U32 len = (unsigned long) IDX * (unsigned long) IDY; //DC_CCD.dx * DC_CCD.dy; // dimX e dimY = dimensione immagine
1921 
1922  sav[0] = DIL.Img.Mat[Server].Imat[0];
1923  sav[1] = DIL.Img.Mat[Server].Imat[1];
1924  memcpy(&DIL.Img.Mat[Server].Imat[0], &DIL.Img.Mat[Server].Imat[2], (IDX << 1) );
1925 
1926  DIL.Img.Mat[Server].Imat[len - 1] = sav[1];
1927  DIL.Img.Mat[Server].Imat[len ] = sav[0];
1928 
1929  sav[0] = DIL.Img.Mat[Server].Imat[IDX-3];
1930  sav[1] = DIL.Img.Mat[Server].Imat[IDX-2];
1931 
1932  DIL.Img.Mat[Server].Imat[IDX-1] = sav[0];
1933  DIL.Img.Mat[Server].Imat[IDX-3] = sav[1];
1934  }
1935 
1936  */
1937  delay(ShuttDelay);
1938  if (DAS.DOption.mirrorimg[XAX] == 1)
1939  DB_MirrorX(Server); //Mirror X axis
1940  if (DAS.DOption.pixcorr)
1941  DB_DefectPixCorr();
1943  }
1944  }
1945  else // NOT Remove Dark from Measurements
1946  {
1947  // count opening shutter
1948  countsopsh++;
1949  delay(ShuttDelay);
1950  DC_GetCCD(1, TExp, DIL.Img.Mat[Server].Imat, 0);
1951  //Image Rotation
1952  /*if (DAS.Paramini.EqType == SPATRAM2)
1953  {
1954  U16 sav[3];
1955  U32 len = (unsigned long) IDX * (unsigned long) IDY; //DC_CCD.dx * DC_CCD.dy; // dimX e dimY = dimensione immagine
1956 
1957  sav[0] = DIL.Img.Mat[Server].Imat[0];
1958  sav[1] = DIL.Img.Mat[Server].Imat[1];
1959  memcpy(&DIL.Img.Mat[Server].Imat[0], &DIL.Img.Mat[Server].Imat[2], (IDX << 1) );
1960 
1961  DIL.Img.Mat[Server].Imat[len - 1] = sav[1];
1962  DIL.Img.Mat[Server].Imat[len ] = sav[0];
1963 
1964  sav[0] = DIL.Img.Mat[Server].Imat[IDX-3];
1965  sav[1] = DIL.Img.Mat[Server].Imat[IDX-2];
1966 
1967  DIL.Img.Mat[Server].Imat[IDX-1] = sav[0];
1968  DIL.Img.Mat[Server].Imat[IDX-3] = sav[1];
1969  }
1970 
1971  */
1972  delay(ShuttDelay);
1973  if (DAS.DOption.mirrorimg[XAX] == 1)
1974  DB_MirrorX(Server); //Mirror X axis
1975  if (DAS.DOption.pixcorr)
1976  DB_DefectPixCorr();
1977  }
1978 
1979  }
1980  else // Make Dark Measurement
1981  {
1982 /*
1983  sx = DAS.Paramini.ccdXoff;
1984  sy = DAS.Paramini.ccdYoff;
1985  dx = DAS.Paramini.ccdWx - DAS.Paramini.ccdXoff;
1986  dy = DAS.Paramini.ccdWy - DAS.Paramini.ccdYoff;
1987  DC_StopNow;
1988  DC_FGetWinCCD(0, TExp, sx, sy, dx, dy, Mat[Server].Imat, 0);
1989 */
1990  DC_GetCCD(0, TExp, DIL.Img.Mat[Server].Imat, 0);
1991  //Image Rotation
1992  /*if (DAS.Paramini.EqType == SPATRAM2)
1993  {
1994  U16 sav[3];
1995  U32 len = (unsigned long) IDX * (unsigned long) IDY; //DC_CCD.dx * DC_CCD.dy; // dimX e dimY = dimensione immagine
1996 
1997  sav[0] = DIL.Img.Mat[Server].Imat[0];
1998  sav[1] = DIL.Img.Mat[Server].Imat[1];
1999  memcpy(&DIL.Img.Mat[Server].Imat[0], &DIL.Img.Mat[Server].Imat[2], (IDX << 1) );
2000  DIL.Img.Mat[Server].Imat[len - 1] = sav[1];
2001  DIL.Img.Mat[Server].Imat[len ] = sav[0];
2002 
2003  sav[0] = DIL.Img.Mat[Server].Imat[IDX-3];
2004  sav[1] = DIL.Img.Mat[Server].Imat[IDX-2];
2005 
2006  DIL.Img.Mat[Server].Imat[IDX-1] = sav[0];
2007  DIL.Img.Mat[Server].Imat[IDX-3] = sav[1];
2008  }
2009  */
2010  if (DAS.DOption.mirrorimg[XAX] == 1)
2011  DB_MirrorX(Server); //Mirror X axis
2012  if (DAS.DOption.pixcorr)
2013  DB_DefectPixCorr();
2014 
2015  }
2016 
2020  DI_Regen(Server);
2021 
2022  GetDateTime(&DIL.Img.Mat[Server].DATE, &DIL.Img.Mat[Server].TIME, &today);
2023  // gettime( &DIL.Img.Mat[Server].TIME );
2024  // getdate( &DIL.Img.Mat[Server].DATE );
2025 
2026  if(DAS.DOption.savingmode)
2027  D_BuildH(1, Server);
2028  else
2029  D_BuildH(0, Server);
2030  /******* END MONO IMAGE ***************/
2031  }
2032  if(DAS.DOption.imgtype) //RGB image
2033  {
2034  DIL.Img.Mat[Server].type = RGBIMG;
2035  if(mod)
2036  {
2037  if(DAS.DOption.darkremove)
2038  {
2039  /*******************************/
2040  //Dark Measurement
2041  DC_GetCCD(0, TExp, DIL.Img.Mat[Server].Imat, 0);
2042  if (DAS.DOption.mirrorimg[XAX] == 1)
2043  DB_MirrorX(Server); //Mirror X axis
2044  if (DAS.DOption.pixcorr)
2045  DB_DefectPixCorr();
2046 
2047  for(t = 0; t < IDY; t++)
2048  {
2049  for(j = 0; j < IDX ; j++)
2050  {
2051  ImatDark[t * IDX + j] = (unsigned short) DIL.Img.Mat[Server].Imat[t * IDX + j];
2052  }
2053  }
2054  /********************************/
2055  // Light Measurement
2056  // count opening shutter
2057  countsopsh++;
2058  delay(ShuttDelay);
2059  DC_GetCCD(1, TExp, DIL.Img.Mat[Server].Imat, 0);
2060  delay(ShuttDelay);
2061  if (DAS.DOption.mirrorimg[XAX] == 1)
2062  DB_MirrorX(Server); //Mirror X axis
2063  if (DAS.DOption.pixcorr)
2064  DB_DefectPixCorr();
2065  //sottrae la dark alla misura
2066  //ATTENZIONE quando la dark e' maggiore della misura
2067  //la sottrazione non funziona RIVEDERE
2068  //RIVISTO - si aggiunge 100 alla misura!!!! (Manuele Dixit)
2069  for(t = 0; t < IDY; t++)
2070  {
2071  for(j = 0; j < IDX ; j++)
2072  {
2073  DIL.Img.Mat[Server].Imat[t * IDX + j] = (unsigned short) (DIL.Img.Mat[Server].Imat[t * IDX + j] + 50) - ImatDark[t * IDX + j];
2074  }
2075  }
2076  }
2077  else
2078  {
2079  // count opening shutter
2080  countsopsh++;
2081  delay(ShuttDelay);
2082  DC_GetCCD(1, TExp, DIL.Img.Mat[Server].Imat, 0);
2083  delay(ShuttDelay);
2084  if (DAS.DOption.mirrorimg[XAX] == 1)
2085  DB_MirrorX(Server); //Mirror X axis
2086  if (DAS.DOption.pixcorr)
2087  DB_DefectPixCorr();
2088  }
2089  }
2090  else
2091  {
2092  DC_GetCCD(0, TExp,DIL.Img.Mat[Server].Imat, 0);
2093  if (DAS.DOption.mirrorimg[XAX] == 1)
2094  DB_MirrorX(Server); //Mirror X axis
2095  if (DAS.DOption.pixcorr)
2096  DB_DefectPixCorr();
2097  }
2098 
2099 
2100 
2104 
2105 
2106 
2107 // Mat[Server].ILow = Mat[Server].Low ;
2108 // Mat[Server].IHigh = Mat[Server].High ;
2109 
2110  DI_Regen(Server);
2111 
2112  }
2113 
2114 if(DAS.DOption.measmode == 0) //Single
2115 {
2116  if(TExp > .5)
2117  {
2118  MShellUnrealize(sh);
2119  MShellDestroy(sh);
2120  }
2121 }
2122  return 0;
2123 
2124 
2125 
2126 }
int IDX
Number of sensible horizontal pixels.
Definition: DAS_Spat.c:118
int Server
Definition: DAS_Spat.c:253
dil DIL
Definition: 2DPlot.c:26
void MLoopWhileEvents(int discard)
optionini DOption
Options for DAS execution.
int savingmode
Flag to set saving mode: 0=ASCII, 1=Binary.
float GHigh
Definition: Dildef.h:299
C_DEF void DI_Regen(int s)
C_DEF double DI_ScanMaxMin(int w, float *mx, float *mi)
#define TESTSZAMODE
execution driven by SZAPRG file
flag Flag
Structure for different flags.
int darkremove
Flag to set Dark Removal from measurements; motors0 = No Dark Removal, 1 = Dark Removal.
U16 * Imat
Definition: Dildef.h:286
#define DBDEMO
execution in demo mode
#define XAX
X Axis.
S16 type
Definition: Dildef.h:280
img Mat[MAXIMG]
Definition: Dildef.h:552
void MShellUnrealize(MOBJECT obj)
struct date DATE
Definition: Dildef.h:348
void D_BuildH(int mod, int s)
Build Header of the measurements . .
Definition: Procedures.c:63
image Img
Definition: Dildef.h:675
das DAS
DAS structure.
Definition: Procedures.c:47
void MShellDestroy(MOBJECT obj)
float BHigh
Definition: Dildef.h:301
double DB_ScanMaxMin(int w, float *mx, float *mi, int bp)
Find Max and Min values for the buffer of order w.
Definition: Procedures.c:1632
#define INTIMG
Definition: Dildef.h:10
MOBJECT LblExpP[7]
Label for presetted time exposure.
unsigned long countsopsh
counting the number of opening shutter
Definition: DAS_Spat.c:133
float RHigh
Definition: Dildef.h:297
void DB_DefectPixCorr()
Apply thew pixel correction. .
Definition: Procedures.c:1568
unsigned short * ImatDark
buffer for the dark image
Definition: DAS_Spatram.h:3045
#define RGBIMG
Definition: Dildef.h:11
void __stdcall ShowDown(const char *str, int port)
Shows the countdown. Procedure for the visualisation of the countdown.
Definition: Init.c:98
int ShuttDelay
Definition: Procedures.c:255
MOBJECT MDCreateExpo(char *tit)
Create Exposure/countdown shell. Procedure that build the Exposure/countdown shell during the calcula...
Definition: Init.c:55
float RLow
Definition: Dildef.h:296
void delay(unsigned long d)
Pauses for a specified number of milliseconds. .
Definition: Dxl.c:1113
float IHigh
Definition: Dildef.h:303
int IDY
Number of sensible vertical pixels.
Definition: DAS_Spat.c:119
double TExp
CCD Exposure time.
Definition: DAS_Spat.c:130
CTYPE void DLL DC_GetCCD(int Mode, double Exposure, U16 *mat, int Camera)
Get an image at full resolution. Procedure that allows you to read an image, given an exposure time e...
float ILow
Definition: Dildef.h:302
int mirrorimg[2]
Flag to set the mirroring of the CCD image: 0 = NO Mirroring, 1= YES Mirroring (element 0 for X axis;...
void GetDateTime(struct date *dp, struct time *tp, struct tm *when)
Definition: Save.c:43
int pixcorr
Flag to set defective pixel correction: 0=NOT Corrected, 1=Corrected.
int imgtype
Flag to set Image type: 0=MONOINT, 1=RGB.
int measmode
measuring mode: 0 = Single; 1 = Averaged
void RemoveBlindPixels(void)
Definition: Procedures.c:1600
static double st
Definition: SOLPOS.C:142
void * MOBJECT
Definition: Mguidefs.h:192
C_DEF void DI_WriteDigit(MOBJECT *pix, char *fmt)
struct time TIME
Definition: Dildef.h:347
float GLow
Definition: Dildef.h:298
int BlindPix
Number of blind pixels (usefull for Dark Current)
Definition: DAS_Spat.c:120
int darksource
Flag to set Dark source: 0 = Blind Pixels, 1 = Full Frame.
float Low
Definition: Dildef.h:294
float High
Definition: Dildef.h:295
MOBJECT LblExpD[7]
Label for time exposure countdown.
int exemode
Set the Execution MODE (Execution modes)
void DB_MirrorX(int w)
Definition: Procedures.c:201
float BLow
Definition: Dildef.h:300
marconi Marconi
CCD Sensor struct.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ DB_MirrorX()

void DB_MirrorX ( int  w)

Definition at line 201 of file Procedures.c.

References D_VRange(), DIL, das::DOption, FLTIMG, img::Fmat, image::Idx, image::Idy, img::Imat, dil::Img, image::Mat, optionini::measmode, and img::type.

Referenced by DB_GetCCD().

202 {
203  int x, y, mx = DIL.Img.Idx[w] - 30;
204  U16 *m, t;
205  float *M, T;
206 
207  if(DAS.DOption.measmode == 0) //Single
208  D_VRange("Mirroring X axis..", 0, 0, 222, 235);
209 
210  if(DIL.Img.Mat[w].type == FLTIMG)
211  for(y = 0; y < DIL.Img.Idy[w]; y++)
212  {
213  M = &DIL.Img.Mat[w].Fmat[(long) y * (mx + 30)];
214  for(x = 0; x <= mx / 2; x++)
215  {
216  T = M[x];
217  M[x] = M[mx - x];
218  M[mx - x] = T;
219  }
220  if(DAS.DOption.measmode == 0) //Single
221  {
222  if((y % 20) == 0 && y > 0)
223  D_VRange(NULL, (long) y * 100 / DIL.Img.Idy[w],0, 222, 235);
224  }
225 
226  }
227  else
228  for(y = 0; y < DIL.Img.Idy[w]; y++)
229  {
230  m = &DIL.Img.Mat[w].Imat[(long) y * (mx + 30)];
231  for(x = 0; x <= mx / 2; x++)
232  {
233  t = m[x];
234  m[x] = m[mx - x];
235  m[mx - x] = t;
236  }
237  if(DAS.DOption.measmode == 0) //Single
238  {
239  if((y % 20) == 0 && y > 0)
240  D_VRange(NULL, (long) y * 100 / DIL.Img.Idy[w],0, 222, 235);
241  }
242  }
243  if(DAS.DOption.measmode == 0) //Single
244  D_VRange(NULL, 100, 0,0,0);
245 }
U16 Idx[MAXIMG]
Definition: Dildef.h:570
dil DIL
Definition: 2DPlot.c:26
optionini DOption
Options for DAS execution.
void D_VRange(char *str, int val, int, int g, int b)
Create and display the status bar.
Definition: Utils.c:206
#define FLTIMG
Definition: Dildef.h:12
U16 * Imat
Definition: Dildef.h:286
S16 type
Definition: Dildef.h:280
img Mat[MAXIMG]
Definition: Dildef.h:552
image Img
Definition: Dildef.h:675
das DAS
DAS structure.
Definition: Procedures.c:47
short unsigned U16
2 byte without sign, range 0-65535
Definition: dcldef.h:375
U16 Idy[MAXIMG]
Definition: Dildef.h:571
float * Fmat
Definition: Dildef.h:287
int measmode
measuring mode: 0 = Single; 1 = Averaged
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ DB_ScanMaxMin()

double DB_ScanMaxMin ( int  w,
float *  mx,
float *  mi,
int  bp 
)

Find Max and Min values for the buffer of order w.

Parameters
w= index of the image (0 or 1) .
bp= number of the CCD blind pixels .
Returns
l = sum of the image values

Definition at line 1632 of file Procedures.c.

References D_VRange(), DIL, das::DOption, FLTIMG, img::Fmat, image::Idx, image::Idy, img::Imat, dil::Img, INTIMG, image::Mat, img::MaxNumbers, optionini::measmode, RGBIMG, and img::type.

Referenced by AutoR_No_Shutt(), AutoR_TestMeas(), AutoR_With_Shutt(), D_Average(), and DB_GetCCD().

1633 {
1634  double l = 0;
1635  int x, y, xi = DIL.Img.Idx[w] - bp , yi = DIL.Img.Idy[w];
1636  U16 *m = DIL.Img.Mat[w].Imat;
1637  float *f = DIL.Img.Mat[w].Fmat;
1638 
1639 
1640  *mx = 0; *mi = DIL.Img.Mat[w].MaxNumbers;
1641  if(DAS.DOption.measmode == 0) //Single Measurement
1642  D_VRange("Find Max/Min..", 0, 192, 195, 192);
1643  //VRange("Find Max/Min", 0);
1644 
1645  if(DIL.Img.Mat[w].type == INTIMG || DIL.Img.Mat[w].type == RGBIMG)
1646  for(y = 0; y < yi-1; y++)
1647  {
1648  for(x = 2; x < xi; x++)
1649  {
1650  //l += (double) *m;
1651  *mi = min(*mi, m[y * DIL.Img.Idx[w] + x]);
1652  *mx = max(*mx, m[y * DIL.Img.Idx[w] + x]);
1653  //m++;
1654  }
1655  if(DAS.DOption.measmode == 0) //Single Measurement
1656  if((y % 32) == 0 && y > 0)
1657  D_VRange(NULL, (long) y * 100 / DIL.Img.Idy[w], 192, 195, 192);
1658  //VRange(NULL, (long) y * 100 / DIL.Img.Idy[w]);
1659  }
1660  if(DIL.Img.Mat[w].type == FLTIMG)
1661  for(y = 0; y < yi; y++)
1662  {
1663  for(x = 2; x < xi; x++)
1664  {
1665  l += (double) *f;
1666  *mi = min(*mi, *m);
1667  *mx = max(*mx, *m);
1668  f++;
1669  }
1670  if(DAS.DOption.measmode == 0) //Single Measurement
1671  if((y % 32) == 0 && y > 0)
1672  D_VRange(NULL, (long) y * 100 / DIL.Img.Idy[w], 192, 195, 192);
1673 
1674 // VRange(NULL, (long) y * 100 / DIL.Img.Idy[w]);
1675  }
1676  //VRange(NULL, 100);
1677  if(DAS.DOption.measmode == 0) //Single Measurement
1678  D_VRange(NULL, 100 , 192, 195, 192);
1679 
1680  return l;
1681 }
U16 Idx[MAXIMG]
Definition: Dildef.h:570
dil DIL
Definition: 2DPlot.c:26
optionini DOption
Options for DAS execution.
void D_VRange(char *str, int val, int, int g, int b)
Create and display the status bar.
Definition: Utils.c:206
float MaxNumbers
Definition: Dildef.h:309
#define FLTIMG
Definition: Dildef.h:12
U16 * Imat
Definition: Dildef.h:286
S16 type
Definition: Dildef.h:280
img Mat[MAXIMG]
Definition: Dildef.h:552
image Img
Definition: Dildef.h:675
das DAS
DAS structure.
Definition: Procedures.c:47
short unsigned U16
2 byte without sign, range 0-65535
Definition: dcldef.h:375
#define INTIMG
Definition: Dildef.h:10
U16 Idy[MAXIMG]
Definition: Dildef.h:571
#define RGBIMG
Definition: Dildef.h:11
float * Fmat
Definition: Dildef.h:287
int measmode
measuring mode: 0 = Single; 1 = Averaged
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ Lookfor4358()

int Lookfor4358 ( void  )

function to scan the wl() array in order to identify the position of the 4358 reference wavelength return value: er = -1 –> value 4358 not encountered er >= 0 –> value 4358 found at er position

Definition at line 2270 of file Procedures.c.

References wl.

2271 {
2272 
2273  int i, er = 0;
2274 
2275  for (i=0; i<17; i++)
2276  {
2277  if (wl[i] == 4358)
2278  {
2279  er = i;
2280  return er;
2281  }
2282  }
2283 
2284  return -1;
2285 }
int wl[]
WaveLength definition - for SD_Grating.
Definition: DAS_Spat.c:182

§ LookforWl_X()

int LookforWl_X ( int  x)

Definition at line 2295 of file Procedures.c.

References wl.

Referenced by D_Calibra(), DemoInitMotor(), E_AAMeasure(), E_Almucantar(), E_Average(), E_AvgCCDHor(), E_DFMeasure(), E_DirectSun(), E_IRefSun(), E_Lambda(), E_Meashor(), E_Meashor2(), E_Measure(), HomeGratingFast(), PRG_ChkGrating(), and WinRes().

2296 {
2297 
2298  int i, er = 0;
2299 
2300  for (i=0; i<18; i++)
2301  {
2302  if (wl[i] == x)
2303  {
2304  er = i;
2305  return er;
2306  }
2307  }
2308 
2309  return -10;
2310 }
int wl[]
WaveLength definition - for SD_Grating.
Definition: DAS_Spat.c:182
+ Here is the caller graph for this function:

§ MaskCol()

void MaskCol ( int  a,
int  b,
int  c,
int  d,
int  e 
)

Definition at line 1548 of file Procedures.c.

References DIL, IDX, img::Imat, dil::Img, image::Mat, and Server.

Referenced by DB_DefectPixCorr().

1549 {
1550  int k;
1551 
1552  for(k=b;k<c;k++)
1553  DIL.Img.Mat[Server].Imat[a + k * IDX] = (DIL.Img.Mat[Server].Imat[a + k * IDX - d] / 2) + (DIL.Img.Mat[Server].Imat[a + k * IDX + e] / 2);
1554 
1555 }
int IDX
Number of sensible horizontal pixels.
Definition: DAS_Spat.c:118
int Server
Definition: DAS_Spat.c:253
dil DIL
Definition: 2DPlot.c:26
U16 * Imat
Definition: Dildef.h:286
img Mat[MAXIMG]
Definition: Dildef.h:552
image Img
Definition: Dildef.h:675
+ Here is the caller graph for this function:

§ MaskPix()

void MaskPix ( int  a,
int  b,
int  c,
int  d,
int  e,
int  f 
)

Definition at line 1538 of file Procedures.c.

References DIL, IDX, img::Imat, dil::Img, image::Mat, and Server.

Referenced by DB_DefectPixCorr().

1539 {
1540 
1541  if (c!=0 && d!=0)
1542  DIL.Img.Mat[Server].Imat[a + b * IDX] = (int)(DIL.Img.Mat[Server].Imat[a + b * IDX - c] + DIL.Img.Mat[Server].Imat[a + b * IDX + d])/2;
1543  if (e!=0 && f!=0)
1544  DIL.Img.Mat[Server].Imat[a + b * IDX] = (int)(DIL.Img.Mat[Server].Imat[a + (b-e) * IDX ] + DIL.Img.Mat[Server].Imat[a + (b+f) * IDX ])/2;
1545 
1546 }
int IDX
Number of sensible horizontal pixels.
Definition: DAS_Spat.c:118
int Server
Definition: DAS_Spat.c:253
dil DIL
Definition: 2DPlot.c:26
U16 * Imat
Definition: Dildef.h:286
img Mat[MAXIMG]
Definition: Dildef.h:552
image Img
Definition: Dildef.h:675
+ Here is the caller graph for this function:

§ MaskRow()

void MaskRow ( int  a,
int  b,
int  c,
int  d,
int  e 
)

Definition at line 1557 of file Procedures.c.

References DIL, IDX, img::Imat, dil::Img, image::Mat, and Server.

Referenced by DB_DefectPixCorr().

1558 {
1559 
1560  int k;
1561 
1562  for(k=a;k<b;k++)
1563  DIL.Img.Mat[Server].Imat[k + c * IDX] = (DIL.Img.Mat[Server].Imat[k + c * IDX - (IDX * d)] / 2) + (DIL.Img.Mat[Server].Imat[k + c * IDX + (IDX * e)] / 2);
1564 
1565 }
int IDX
Number of sensible horizontal pixels.
Definition: DAS_Spat.c:118
int Server
Definition: DAS_Spat.c:253
dil DIL
Definition: 2DPlot.c:26
U16 * Imat
Definition: Dildef.h:286
img Mat[MAXIMG]
Definition: Dildef.h:552
image Img
Definition: Dildef.h:675
+ Here is the caller graph for this function:

§ RemoveBlindPixels()

void RemoveBlindPixels ( void  )

Definition at line 1600 of file Procedures.c.

References BlindPix, DIL, IDX, IDY, img::Imat, dil::Img, image::Mat, and Server.

Referenced by DB_GetCCD().

1601 {
1602 
1603  double l = 0;
1604  int t, j;
1605 
1606  BlindPix = 0;
1607  if(IDX > 1024)
1608  BlindPix = IDX - 1024;
1609 
1610 
1611  for(t = 0; t < IDY; t++)
1612  {
1613  for(j = IDX - BlindPix + 1 ; j < IDX; j++)
1614  {
1615  l = l + (double) DIL.Img.Mat[Server].Imat[t * IDX + j];
1616  }
1617  }
1618  l = l / (IDY * (BlindPix));
1619 
1620  for(t = 0; t < IDY; t++)
1621  {
1622  for(j = 0; j < IDX ; j++)
1623  {
1624  DIL.Img.Mat[Server].Imat[t * IDX + j] = (unsigned short) (DIL.Img.Mat[Server].Imat[t * IDX + j] ) - (unsigned short) l;
1625  }
1626  }
1627 
1628 
1629 
1630 }
int IDX
Number of sensible horizontal pixels.
Definition: DAS_Spat.c:118
int Server
Definition: DAS_Spat.c:253
dil DIL
Definition: 2DPlot.c:26
U16 * Imat
Definition: Dildef.h:286
img Mat[MAXIMG]
Definition: Dildef.h:552
image Img
Definition: Dildef.h:675
int IDY
Number of sensible vertical pixels.
Definition: DAS_Spat.c:119
int BlindPix
Number of blind pixels (usefull for Dark Current)
Definition: DAS_Spat.c:120
+ Here is the caller graph for this function:

§ SaveCalib()

void SaveCalib ( int  mod)

Definition at line 2130 of file Procedures.c.

References _MAX_PATH, d_fileman::DAILYDATADIRECTORY, d_fileman::DATADIRECTORY, DB_Save(), bil::DFILEM, das::DGeo, das::DOption, fftsavecal, spectrumheader::newdate, spectrumheader::olddate, d_geo::s_name, optionini::savingmode, bil::SPH, and Total.

Referenced by D_Calibra(), E_HgScan(), and E_QjScan().

2131 {
2132 
2133 
2134  char tmpbuf[128] ;
2135  static char tit[_MAX_PATH];
2136  char tit1[80];
2137  time_t ltime;
2138  struct tm *today;
2139  int er = 0;
2140 
2141 
2142 
2143 
2144  if(fftsavecal) //flag first time program run here
2145  {
2146  /* Get UNIX-style time */
2147  time( &ltime );
2148  /* Use time structure to build a customized time string. */
2149  today = localtime( &ltime );
2150  /* Use strftime to build a customized time string. */
2151  strftime( tmpbuf, 7,"%y%m%d", today );
2152 
2153  //Build name of Daily data directory
2154  sprintf(BIL.DFILEM.DAILYDATADIRECTORY,"%s\\%s",BIL.DFILEM.DATADIRECTORY,tmpbuf);
2155  //Create Daily data dir
2156  er = _mkdir( BIL.DFILEM.DAILYDATADIRECTORY );
2157 
2158  fftsavecal=0;
2159  if(DAS.DOption.savingmode) // Binary saving
2160  {
2161 
2162  if (mod)
2163  sprintf(tit, "%s\\%s%s.bqj",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf);
2164  else
2165  sprintf(tit, "%s\\%s%s.bhg",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf);
2166  DB_Save(tit, 1);
2167  }
2168  else //ASCII saving
2169  {
2170  if (mod)
2171  sprintf(tit, "%s\\%s%s.aqj",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf);
2172  else
2173  {
2174  sprintf(tit, "%s\\%s%s.ahg",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf);
2175  sprintf(tit1, "%s", tit+5);
2176  }
2177  DB_Save(tit, 0);
2178  }
2179  sprintf(BIL.SPH.olddate, "%s",tmpbuf);
2180  }
2181  else
2182  {
2183 
2184  /* Get UNIX-style time */
2185  time( &ltime );
2186  /* Use time structure to build a customized time string. */
2187  today = localtime( &ltime );
2188  /* Use strftime to build a customized time string. */
2189  strftime( BIL.SPH.newdate, 7,"%y%m%d", today );
2190  /* Use strftime to build a customized time string. */
2191  strftime( tmpbuf, 7,"%y%m%d", today );
2192 
2193 
2194  // Se e' cambiata la data rimette a 1 il contatore del numero dei files
2195  if(strcmp(BIL.SPH.newdate, BIL.SPH.olddate) != 0)
2196  {
2197  sprintf(BIL.SPH.olddate, "%s",BIL.SPH.newdate);
2198  Total = 0;
2199 
2200  sprintf(BIL.DFILEM.DAILYDATADIRECTORY,"%s\\%s",BIL.DFILEM.DATADIRECTORY,tmpbuf);
2201  er = _mkdir( BIL.DFILEM.DAILYDATADIRECTORY );
2202 
2203  /*****************************/
2204  if(DAS.DOption.savingmode) // Binary saving
2205  {
2206  if (mod)
2207  sprintf(tit, "%s\\%s%s.bqj",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf);
2208  else
2209  sprintf(tit, "%s\\%s%s.bhg",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf);
2210  DB_Save(tit, 1);
2211  }
2212  else //ASCII saving
2213  {
2214  if (mod)
2215  sprintf(tit, "%s\\%s%s.aqj",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf);
2216  else
2217  {
2218  sprintf(tit, "%s\\%s%s.ahg",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf);
2219  sprintf(tit1, "%s", tit+5);
2220  }
2221 
2222  DB_Save(tit, 0);
2223  }
2224  }
2225 /*****************************/
2226 
2227 
2228  if(DAS.DOption.savingmode)
2229  {
2230  if (mod)
2231  sprintf(tit, "%s\\%s%s.bqj",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf);
2232  else
2233  sprintf(tit, "%s\\%s%s.bhg",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf);
2234 
2235  DB_Save(tit, 1);
2236  }
2237  else
2238  {
2239  if (mod)
2240  sprintf(tit, "%s\\%s%s.aqj",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf);
2241  else
2242  {
2243  sprintf(tit, "%s\\%s%s.ahg",BIL.DFILEM.DAILYDATADIRECTORY, DAS.DGeo.s_name, tmpbuf);
2244  sprintf(tit1, "%s", tit+5);
2245  }
2246  DB_Save(tit, 0);
2247  }
2248 
2249  }
2250 
2251 
2252  //sprintf(tit1, "%s", tit+5);
2253  //MObjectSetText(DAS.Gui.ContrPanel.Albl_CS[3], tit1);
2254  //sprintf(tit1, "%05d", SaveCnt);
2255  //MObjectSetText(DAS.Gui.ContrPanel.Albl_CS[2], tit1);
2256 
2257  //SaveCnt++;
2258 
2259 
2260 }
bil BIL
Definition: Procedures.c:42
optionini DOption
Options for DAS execution.
int savingmode
Flag to set saving mode: 0=ASCII, 1=Binary.
int Total
Progressive acquisition number for file (MAX defined = 50)
Definition: Exec.c:34
char DAILYDATADIRECTORY[_MAX_PATH]
Definition: bildef.h:203
char DATADIRECTORY[_MAX_PATH]
Definition: bildef.h:201
spectrumheader SPH
Spectrum Header Structure.
Definition: bildef.h:256
void DB_Save(char *tit, int mod)
Save the acquired spectrum. Procedure that Save the acquired spectrum.
Definition: Save.c:552
char olddate[8]
Definition: bildef.h:158
das DAS
DAS structure.
Definition: Procedures.c:47
d_geo DGeo
struct for Station location
char s_name[4]
Station name.
d_fileman DFILEM
Definition: bildef.h:257
#define _MAX_PATH
Definition: Dildef.h:202
char newdate[8]
Definition: bildef.h:159
Definition: Dildef.h:234
int fftsavecal
Definition: Procedures.c:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ ShutterOpening()

void ShutterOpening ( int  mod)

Definition at line 1685 of file Procedures.c.

References _MAX_PATH, d_fileman::CONFIGDIREQUIPMENT, countsopsh, bil::DFILEM, and MMessageDialog().

Referenced by InitCCD_AMS(), ShutCB(), Task_LOG(), and WinRes().

1686 {
1687 
1688  int fd, er;
1689  char buff[_MAX_PATH];
1690  FILE *fs;
1691 
1692 
1693  sprintf(buff,"%s\\Shutter.ini", BIL.DFILEM.CONFIGDIREQUIPMENT);
1694 
1695  if(mod == 0) //read or create file
1696  {
1697  fd = access(buff, 0);
1698  if (fd == 0) //file exist
1699  {
1700  fs = fopen(buff, "r");
1701  if(fs == NULL)
1702  {
1703  MMessageDialog("DAS information", "Problems in opening file", " Ok ", NULL);
1704  return ;
1705  }
1706  er = fscanf(fs, "%ul", &countsopsh);
1707 
1708  fclose(fs);
1709  }
1710  else
1711  {
1712  fs = fopen(buff, "w");
1713  if(fs == NULL)
1714  {
1715  MMessageDialog("DAS information", "Problems in opening file", " Ok ", NULL);
1716  return ;
1717  }
1718  fprintf(fs, "%u\n", 1);
1719  fclose(fs);
1720  }
1721 
1722  }
1723  else //mod == 1 write file
1724  {
1725  fs = fopen(buff, "w");
1726  if(fs == NULL)
1727  {
1728  MMessageDialog("DAS information", "Problems in opening file", " Ok ", NULL);
1729  return ;
1730  }
1731  fprintf(fs, "%u\n", countsopsh);
1732  fclose(fs);
1733  }
1734 
1735 
1736 
1737 
1738 
1739 }
bil BIL
Definition: Procedures.c:42
unsigned long countsopsh
counting the number of opening shutter
Definition: DAS_Spat.c:133
d_fileman DFILEM
Definition: bildef.h:257
char CONFIGDIREQUIPMENT[_MAX_PATH]
Definition: bildef.h:208
#define _MAX_PATH
Definition: Dildef.h:202
int MMessageDialog(const char *t, const char *msg, const char *btn1, const char *btn2,...)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

§ AST

AzimuthSt AST

Definition at line 45 of file Procedures.c.

§ BIL

bil BIL

Definition at line 42 of file Procedures.c.

§ Cfg

config Cfg

Definition at line 31 of file Procedures.c.

§ DAS

das DAS

DAS structure.

Definition at line 47 of file Procedures.c.

§ DC_CCD

ccd DC_CCD

Definition at line 29 of file Procedures.c.

§ DC_HP

ptf DC_HP

Definition at line 30 of file Procedures.c.

§ DGEO

d_geo DGEO

geographical coordinates structure

Definition at line 41 of file Procedures.c.

§ ExeREM

int ExeREM

Definition at line 143 of file DAS_Spat.c.

Referenced by D_Calibra().

§ fftprh

int fftprh = 1

Definition at line 50 of file Procedures.c.

Referenced by D_Saving().

§ fftsavecal

int fftsavecal = 1

Definition at line 51 of file Procedures.c.

Referenced by SaveCalib().

§ FLAG

flag FLAG

flags structure

Definition at line 37 of file Procedures.c.

§ FWS

Filter Wheel.

Definition at line 34 of file Procedures.c.

§ GRS

GratingSt GRS

Grating.

Definition at line 36 of file Procedures.c.

§ HDRSP

hdrsp HDRSP

Definition at line 32 of file Procedures.c.

§ maxar

float maxar

Definition at line 252 of file Procedures.c.

Referenced by AutoR_No_Shutt(), and AutoR_With_Shutt().

§ maxtt

float maxtt

Definition at line 252 of file Procedures.c.

Referenced by AutoR_No_Shutt(), and AutoR_With_Shutt().

§ minar

float minar

Definition at line 252 of file Procedures.c.

Referenced by AutoR_No_Shutt(), and AutoR_With_Shutt().

§ mintt

float mintt

Definition at line 252 of file Procedures.c.

Referenced by AutoR_No_Shutt(), and AutoR_With_Shutt().

§ MIS

MirrorSt MIS

Mirror.

Definition at line 33 of file Procedures.c.

§ NDFWS

ND Filter Wheel.

Definition at line 35 of file Procedures.c.

§ PARAM

paramini PARAM

Param.ini.

Definition at line 39 of file Procedures.c.

§ SaveCnt

int SaveCnt = 1

Definition at line 49 of file Procedures.c.

Referenced by D_Saving(), DB_HorComm_CB(), DB_KeyB_CB(), E_QjScan(), and ExMaster().

§ ShuttDelay

int ShuttDelay = 0

Definition at line 255 of file Procedures.c.

Referenced by AutoRange(), D_Average(), and DB_GetCCD().

§ ZST

ZenithSt ZST

Definition at line 44 of file Procedures.c.

______________________________________________________________________________________
Generated on Mon Sep 18 2017 11:46:39 for DAS - Rel. 3.1.6 - 18/09/2017.