DAS  3.1.6 - 18/09/2017
Save.c
Go to the documentation of this file.
1 #include <io.h>
2 #include <fcntl.h>
3 #include <math.h>
4 #include <sys/types.h>
5 #include <sys/stat.h>
6 #include <windows.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <time.h>
11 #include "mgui.h"
12 #include "DAS_Spatram.h"
13 #include "dcl.h"
14 #include "dil.h"
15 #include "bil.h"
16 #include "DOAS.h"
17 
18 
19 // CCD & Camera vars
20 ccd DC_CCD; // CCD settings
21 ptf DC_HP; // Platform settings
22 config Cfg; // Camera controls & Options
24 GratingSt GRS; //Grating
25 flag FLAG; //flags structure
26 bil BIL; //Bortul Library Structure
28 
29 //void D_PrintH(int mod, FILE *fff);
30 
31 
32 void UPS_Status(void)
33 {
34 
35 
36  SYSTEM_POWER_STATUS status;
37 
38 
39  GetSystemPowerStatus( &status );
40 
41 }
42 
43 void GetDateTime(struct date *dp, struct time *tp, struct tm *when)
44 {
45 
46  time_t now;
47  struct tm w;
48 
49  time(&now);
50 
51  //This code retrive the PC clock time as it is
52  //(with or without the daylight saving time setted)
53  w = *localtime(&now);
54 
55  //This code retrive the PC clock and check if the daylight
56  //saving time is setted or not
57  //the time stored in the Header of the measurement is always the LST (Local Solar Time)
58  /**************************************************************/
59  // Check if daylight saving time is in effect
60  // tm_isdst > 0 if daylight saving time is in effect
61  // tm_isdst = 0 if daylight saving time is not in effect
62  // tm_isdst < 0 if status of daylight saving time is unknown.
63  if (w.tm_isdst)
64  {
65  now = now - 3600; // 1 hour less
66  w = *localtime( &now );
67 
68  }
69  //Time for Header of Measurement (Local Solar Time)
70  tp->ti_sec = w.tm_sec;
71  tp->ti_min = w.tm_min;
72  tp->ti_hour = w.tm_hour;
73  tp->ti_hund = 0;
74 
75  //Date for Header of Measurement
76  dp->da_day = w.tm_mday;
77  dp->da_mon = w.tm_mon + 1;
78  dp->da_year = w.tm_year + 1900;
79 
80  when -> tm_sec = w.tm_sec; /* seconds after the minute - [0,59] */
81  when -> tm_min = w.tm_min; /* minutes after the hour - [0,59] */
82  when -> tm_hour = w.tm_hour; /* hours since midnight - [0,23] */
83  when -> tm_mday = w.tm_mday; /* day of the month - [1,31] */
84  when -> tm_mon = w.tm_mon; /* months since January - [0,11] */
85  when -> tm_year = w.tm_year; /* years since 1900 */
86  when -> tm_wday = w.tm_wday; /* days since Sunday - [0,6] */
87  when -> tm_yday = w.tm_yday; /* days since January 1 - [0,365] */
88  when -> tm_isdst = w.tm_isdst; /* daylight savings time flag */
89 
90 }
91 
92 void gettime(struct time *tp)
93 {
94  time_t now;
95  struct tm w;
96 
97  time(&now);
98 
99  //This code retrive the PC clock time as it is
100  //(with or without the daylight saving time setted)
101  w = *localtime(&now);
102  tp->ti_sec = w.tm_sec;
103  tp->ti_min = w.tm_min;
104  tp->ti_hour = w.tm_hour;
105  tp->ti_hund = 0;
106 
107  //This code retrive the PC clock and check if the daylight
108  //saving time is setted or not
109  //the time stored in the Header of the measurement is always the LST (Local Solar Time)
110  /**************************************************************/
111  // Check if daylight saving time is in effect
112  // tm_isdst > 0 if daylight saving time is in effect
113  // tm_isdst = 0 if daylight saving time is not in effect
114  // tm_isdst < 0 if status of daylight saving time is unknown.
115  if (w.tm_isdst)
116  {
117  tp->ti_hour = w.tm_hour - 1;
118  }
119  //NOTE - In Daylight saving period on midnight the hours became -1 so...
120  // if((newtime.tm_hour) == -1)
121  //{
122  // Necessary for measurements performed at high latitude in summer seasons
123  // newtime.tm_hour = 23;
124  // newtime.tm_yday = newtime.tm_yday - 1;
125  //}
126 
127  /**************************************************************/
128 
129 
130 }
131 void getdate(struct date *tp)
132 {
133  time_t now;
134  struct tm w;
135 
136  time(&now);
137  w = *localtime(&now);
138  tp->da_day = w.tm_mday;
139  tp->da_mon = w.tm_mon + 1;
140  tp->da_year = w.tm_year + 1900;
141 }
142 
143 
144 int D_WriteInitLog(char *str)
145 {
146  FILE *fc;
147  char datebuf[9];
148  char timebuf[9];
149 
150  _strdate(datebuf);
151  _strtime(timebuf);
152 
153 
154  fc = fopen("LOG\\Devices.Log", "a");
155  if(fc < 0) return 1;
156 
157  fprintf(fc, " %s %s %s\n",datebuf, timebuf, str);
158 
159  fclose(fc);
160  return 0;
161 
162 }
163 
164 
165 /*
166  *
167  *
168  * Parameters:
169  *
170  * f = file name (include path & extension)
171  * s = Image Number
172  *
173  * Return codes:
174  * 0 = No Error
175  * -1 = Disk i/o error
176  */
177 int D_save_bin(char *f, int s)
178 {
179  U32 info = 0, palet = 0;
180  U16 t, l;
181  int fd, c;
182  char ffile[1024];
183 
184 
185 
186  // Find char \ if present clear it
187  l = strlen(f);
188  while(f[l--] != 0x5C);
189  l += 2;
190  strcpy(ffile, &f[l]);
191 
192  //fd = open(f, O_WRONLY | O_BINARY | O_CREAT, S_IWRITE);
193  fd = open(f, O_WRONLY | O_BINARY | O_CREAT | O_APPEND, S_IWRITE);
194  if(fd < 0) return(-1);
195 
196 // info += write(fd, &info, 4);
197 
198  info += write(fd, &palet, 4);
199 
200  info += write(fd, &DIL.Img.Idx[s], 2);
201  info += write(fd, &DIL.Img.Idy[s], 2);
202 
203  t = 0;
204  // Exp. code
205  info += write(fd, &t, 2);
206  // Image type
207  info += write(fd, &DIL.Img.Mat[s].type, 2);
208 
209  if(DIL.Img.Mat[s].col)
210  for(c = 0; c < DIL.Img.Idy[s]; c++)
211  {
212  info += write(fd, &DIL.Img.Mat[s].Rmat[c * DIL.Img.Idx[s]], DIL.Img.Idx[s] * 2);
213  info += write(fd, &DIL.Img.Mat[s].Gmat[c * DIL.Img.Idx[s]], DIL.Img.Idx[s] * 2);
214  info += write(fd, &DIL.Img.Mat[s].Bmat[c * DIL.Img.Idx[s]], DIL.Img.Idx[s] * 2);
215  }
216  if(DIL.Img.Mat[s].type == INTIMG)
217  for(c = 0; c < DIL.Img.Idy[s]; c++)
218  info += write(fd, &DIL.Img.Mat[s].Imat[c * DIL.Img.Idx[s]], DIL.Img.Idx[s] * 2);
219  if(DIL.Img.Mat[s].type == FLTIMG)
220  for(c = 0; c < DIL.Img.Idy[s]; c++)
221  info += write(fd, &DIL.Img.Mat[s].Fmat[c * DIL.Img.Idx[s]], DIL.Img.Idx[s] * 4);
222  // Image statistics
223  l = DIF_STAT; // Keyword
224  write(fd, &l, sizeof(U16));
225  {
226  write(fd, &DIL.Img.Mat[s].Ctrst, sizeof(char));
227  write(fd, &DIL.Img.Mat[s].Low, sizeof(float));
228  write(fd, &DIL.Img.Mat[s].High, sizeof(float));
229  write(fd, &DIL.Img.Mat[s].ILow, sizeof(float));
230  write(fd, &DIL.Img.Mat[s].IHigh, sizeof(float));
231  write(fd, &DIL.Img.Mat[s].Media, sizeof(float));
232  write(fd, &DIL.Img.Mat[s].Sigma, sizeof(float));
233  write(fd, &DIL.Img.Mat[s].MaxNumbers, sizeof(float));
234  }
235  if(DIL.Img.Mat[s].InfoPar)
236  {
237  // Camera parameter
238  l = DIF_CAMERA; // Keyword
239  write(fd, &l, sizeof(U16));
240  {
241  write(fd, &DIL.Img.Mat[s].CCDName, 20);
242  write(fd, &DIL.Img.Mat[s].CamName, 20);
243  write(fd, &DIL.Img.Mat[s].off, sizeof(S16));
244  write(fd, &DIL.Img.Mat[s].gain, sizeof(double));
245  write(fd, &DIL.Img.Mat[s].range, sizeof(S16));
246  write(fd, &DIL.Img.Mat[s].SExp, sizeof(double));
247  write(fd, &DIL.Img.Mat[s].TAMB, sizeof(S16));
248  write(fd, &DIL.Img.Mat[s].TCCD, sizeof(S16));
249  write(fd, &DIL.Img.Mat[s].HBin, sizeof(U16));
250  write(fd, &DIL.Img.Mat[s].VBin, sizeof(U16));
251  write(fd, &DIL.Img.Mat[s].Sx, sizeof(U16));
252  write(fd, &DIL.Img.Mat[s].Sy, sizeof(U16));
253  write(fd, &DIL.Img.Mat[s].Wx, sizeof(U16));
254  write(fd, &DIL.Img.Mat[s].Wy, sizeof(U16));
255  }
256  // Time date
257  l = DIF_TIME; // Keyword
258  write(fd, &l, sizeof(U16));
259  {
260 
261  write(fd, &DIL.Img.Mat[s].TIME, sizeof(struct time));
262  write(fd, &DIL.Img.Mat[s].DATE, sizeof(struct date));
263  }
264  }
265 
266  close(fd);
267 
268  if(DIL.Img.Mat[s].InfoPar)
269  {
270  // Write info position
271  fd = open(f, O_WRONLY | O_BINARY, S_IWRITE);
272  write(fd, &info, 4);
273  close(fd);
274  }
275  return 0;
276 }
277 
278 
280 {
281 
282 }
283 
284 void D_Print_BIL_H_BIN(int mod, int fd)
285 {
286  unsigned long info = 0;
287 
288 
289  info += write(fd, &BIL.SPH.location, sizeof(BIL.SPH.location));
290  info += write(fd, &BIL.SPH.latitude, sizeof(BIL.SPH.latitude));
291  info += write(fd, &BIL.SPH.longitude, sizeof(BIL.SPH.longitude));
292  info += write(fd, &BIL.SPH.altitude, sizeof(BIL.SPH.altitude));
293  info += write(fd, &BIL.SPH.sza, sizeof(BIL.SPH.sza));
294 
295  info += write(fd, &BIL.SPH.DATE, sizeof(struct ddate));
296  info += write(fd, &BIL.SPH.TIME, sizeof(struct dtime));
297 
298  info += write(fd, &BIL.SPH.mirpos, sizeof(BIL.SPH.mirpos));
299  info += write(fd, &BIL.SPH.wavelen, sizeof(BIL.SPH.wavelen));
300 
301  info += write(fd, &BIL.SPH.filpos, sizeof(BIL.SPH.filpos));
302  info += write(fd, &BIL.SPH.ccdtemp, sizeof(BIL.SPH.ccdtemp));
303  info += write(fd, &BIL.SPH.ccdtexp, sizeof(BIL.SPH.ccdtexp));
304  info += write(fd, &BIL.SPH.ccdmax, sizeof(BIL.SPH.ccdmax));
305 
306  info += write(fd, &BIL.SPH.imgtype, sizeof(BIL.SPH.imgtype));
307  info += write(fd, &BIL.SPH.ccdwx, sizeof(BIL.SPH.ccdwx));
308  info += write(fd, &BIL.SPH.ccdwy, sizeof(BIL.SPH.ccdwy));
309  info += write(fd, &BIL.SPH.ccdsx, sizeof(BIL.SPH.ccdsx));
310  info += write(fd, &BIL.SPH.ccdsy, sizeof(BIL.SPH.ccdsy));
311  info += write(fd, &BIL.SPH.ccdex, sizeof(BIL.SPH.ccdex));
312  info += write(fd, &BIL.SPH.ccdey, sizeof(BIL.SPH.ccdey));
313  info += write(fd, &BIL.SPH.ccdvb, sizeof(BIL.SPH.ccdvb));
314  info += write(fd, &BIL.SPH.ccdnr, sizeof(BIL.SPH.ccdnr));
315  info += write(fd, &BIL.SPH.dummy1, sizeof(BIL.SPH.dummy1));
316  info += write(fd, &BIL.SPH.dummy2, sizeof(BIL.SPH.dummy2));
317  info += write(fd, &BIL.SPH.dummy3, sizeof(BIL.SPH.dummy3));
318  info += write(fd, &BIL.SPH.dummy4, sizeof(BIL.SPH.dummy4));
319  info += write(fd, &BIL.SPH.comment, sizeof(BIL.SPH.comment));
320 
321 }
322 
323 void D_PrintH_BIN(int mod, int fd)
324 {
325  unsigned long info = 0;
326 
327 
328  info += write(fd, &HDRSP.s_name, sizeof(HDRSP.s_name));
329  info += write(fd, &HDRSP.s_latitude, sizeof(HDRSP.s_latitude));
330  info += write(fd, &HDRSP.s_longitude, sizeof(HDRSP.s_longitude));
331  info += write(fd, &HDRSP.s_alt, sizeof(HDRSP.s_alt));
332  info += write(fd, &HDRSP.s_sza, sizeof(HDRSP.s_sza));
333 
334  info += write(fd, &HDRSP.DATE, sizeof(struct date));
335  info += write(fd, &HDRSP.TIME, sizeof(struct time));
336 
337  info += write(fd, &HDRSP.binmirpos, sizeof(HDRSP.binmirpos));
338  info += write(fd, &HDRSP.lambda, sizeof(HDRSP.lambda));
339 
340  info += write(fd, &HDRSP.binfilpos, sizeof(HDRSP.binfilpos));
341  info += write(fd, &HDRSP.ccdtemp, sizeof(HDRSP.ccdtemp));
342  info += write(fd, &HDRSP.ccdtexp, sizeof(HDRSP.ccdtexp));
343  info += write(fd, &HDRSP.imgmax, sizeof(HDRSP.imgmax));
344 
345  info += write(fd, &HDRSP.imgfmt, sizeof(HDRSP.imgfmt));
346  info += write(fd, &HDRSP.ccdwx, sizeof(HDRSP.ccdwx));
347  info += write(fd, &HDRSP.ccdwy, sizeof(HDRSP.ccdwy));
348  info += write(fd, &HDRSP.ccdxs, sizeof(HDRSP.ccdxs));
349  info += write(fd, &HDRSP.ccdys, sizeof(HDRSP.ccdys));
350  info += write(fd, &HDRSP.ccdxe, sizeof(HDRSP.ccdxe));
351  info += write(fd, &HDRSP.ccdye, sizeof(HDRSP.ccdye));
352  info += write(fd, &HDRSP.ccdvbin, sizeof(HDRSP.ccdvbin));
353  info += write(fd, &HDRSP.ccdnr, sizeof(HDRSP.ccdnr));
354  info += write(fd, &HDRSP.dummy1, sizeof(HDRSP.dummy1));
355  info += write(fd, &HDRSP.dummy2, sizeof(HDRSP.dummy2));
356  info += write(fd, &HDRSP.dummy3, sizeof(HDRSP.dummy3));
357  info += write(fd, &HDRSP.dummy4, sizeof(HDRSP.dummy4));
358  info += write(fd, &HDRSP.bincomment, sizeof(HDRSP.bincomment));
359 
360 }
361 
362 void D_PrintH_ASCII(int mod, FILE *fff)
363 {
364 
365  fprintf(fff, "LOC: %s ", HDRSP.s_name); //Name of the station
366  fprintf(fff, "LAT: %.2lf ", HDRSP.s_latitude);//Station latitude
367  fprintf(fff, "LON: %.2lf ", HDRSP.s_longitude);//Station longitude
368  fprintf(fff, "ALT[m/asl]: %u ", HDRSP.s_alt);//Station altitude
369  fprintf(fff, "SZA: %.2lf\n", HDRSP.s_sza);//SZA
370  fprintf(fff, "%d/%02d/%02d ", HDRSP.DATE.da_year, HDRSP.DATE.da_mon, HDRSP.DATE.da_day);
371  fprintf(fff, "%02d:%02d:%02d LT ",HDRSP.TIME.ti_hour, HDRSP.TIME.ti_min,HDRSP.TIME.ti_sec);
372  fprintf(fff, "%s ", HDRSP.mirpos);
373  fprintf(fff, "%d ", HDRSP.lambda);
374  fprintf(fff, "%s ", HDRSP.filpos);
375  fprintf(fff, "%.2lf ", HDRSP.ccdtemp);
376  fprintf(fff, "%.2lf ", HDRSP.ccdtexp);
377  fprintf(fff, "%5u ", HDRSP.imgmax);
378  fprintf(fff, "%5u\n", HDRSP.imgmin);
379 
380  fprintf(fff, "%d ", HDRSP.imgfmt); //Image Format
381  fprintf(fff, "%d ", HDRSP.ccdwx); //X Pixel Tot Number
382  fprintf(fff, "%d ", HDRSP.ccdwy); //Y Pixel Tot Number
383  fprintf(fff, "%d ", HDRSP.ccdxs); //Window X Start
384  fprintf(fff, "%d ", HDRSP.ccdys); //Window Y Start
385  fprintf(fff, "%d ", HDRSP.ccdxe); //Window X End
386  fprintf(fff, "%d ", HDRSP.ccdye); //Window Y End
387  fprintf(fff, "%d ", HDRSP.ccdvbin); // Vertical Binning
388  fprintf(fff, "%d ", HDRSP.ccdnr); // rows number
389 
390  fprintf(fff, "%d ", HDRSP.dummy1);
391  fprintf(fff, "%d ", HDRSP.dummy2);
392  fprintf(fff, "%d ", HDRSP.dummy3);
393  fprintf(fff, "%d\n", HDRSP.dummy4);
394  fprintf(fff, "%s\n", HDRSP.comment);
395 
396 }
397 
398 int D_save_bif(char *f, int s)
399 {
400  unsigned long info = 0;
401  long l;
402  int fd, x, y;
403  char ffile[1024];
404 
405  double pi = 3.1415926535;
406  double raddeg = 57.29747;
407 
408 
409 // char *buf;
410 
411 
412 
413  // Find char "\" if present clear it
414  l = strlen(f);
415  while(f[l--] != 0x5C);
416  l += 2;
417  strcpy(ffile, &f[l]);
418 
419 
420  //fd = open(ffile, O_WRONLY | O_BINARY | O_CREAT, S_IWRITE);
421  fd = open(f, O_WRONLY | O_BINARY | O_CREAT | O_APPEND, S_IWRITE);
422  if(fd < 0) return(-1);
423 
424 
425  // Print on file the header
426  D_PrintH_BIN(0, fd);
427 
428 
429 
430  if(DIL.Img.Mat[s].type == INTIMG)
431 
432  for(x = 0; x < DIL.Img.Idx[s]; x++)
433  {
434  for(y = 0; y < DIL.Img.Idy[s]; y++)
435  {
436  //temp = 10000 * sin((x+10)/raddeg);
437  //if(temp>= 0)
438  // URdMat(s, x, y) = 30000 - temp;
439  //else
440  // URdMat(s, x, y) = -temp + 30000;
441  info += write(fd, &URdMat(s, x, y), 2);
442  }
443  }
444  close(fd);
445 
446  return 0;
447 }
448 
449 
450 
451 int D_save_asc(char *fname, int s)
452 {
453  int x, y;
454  FILE *fd;
455  fd = fopen(fname, "a");
456  if(fd < 0) return 1;
457  VRange("Export as ASCII", 0);
458  // Print on file the header
459  D_PrintH_ASCII(0, fd);
460 
461  for(y = 0; y < DIL.Img.Idy[s]; y++)
462  {
463  for(x = 0; x < DIL.Img.Idx[s]; x++)
464  {
465  if((x % 10) == 0)
466  {
467  if(y == 0 && x == 0)
468  {
469  }
470  else
471  fprintf(fd, "\n", NULL);
472  }
473  if(DIL.Img.Mat[s].type == INTIMG)
474  fprintf(fd, "%5u ", URdMat(s, x, y));
475  if(DIL.Img.Mat[s].type == FLTIMG)
476  fprintf(fd, "%f ", FRdMat(s, x, y));
477  }
478 
479  if((y % 40) == 0 && y > 0)
480  VRange(NULL, (long) y * 100 / DIL.Img.Idy[s]);
481  }
482  fprintf(fd, "\n", NULL);
483  fclose(fd);
484  VRange(NULL, 100);
485  return 0;
486 }
487 
488 
489 
490 
491 
492 
493 int SaveDataOffLine(char *fname, int mod)
494 {
495 
496  unsigned long info = 0;
497  long l;
498  int fd;
499  char ffile[1024];
500  FILE *fn;
501 
502 
503  double pi = 3.1415926535;
504  double raddeg = 57.29747;
505 
506 
507 // char *buf;
508 
509 
510 
511  // Find char "\" if present clear it
512  l = strlen(fname);
513  while(fname[l--] != 0x5C);
514  l += 2;
515  strcpy(ffile, &fname[l]);
516 
517  if(mod) //save in binary mode
518  {
519  fd = open(fname, O_WRONLY | O_BINARY | O_CREAT | O_APPEND, S_IWRITE);
520  if(fd < 0) return(-1);
521 
522  D_Print_BIL_H_BIN(0, fd);
523 
524  WriteIMG_BIN(fd, BIL.DPLOT.ImatOrig, IDX, IDY);
525 
526  close(fd);
527 
528 
529 
530  }
531  else //save in ASCII mode
532  {
533 
534  fn = fopen(fname, "a");
535  if(fn < 0) return 1;
536  // Print on file the header
537  D_Print_BIL_H_ASCII(0, fn);
538 
539  WriteIMG(fn, BIL.DPLOT.ImatOrig, IDX, IDY);
540 
541  fclose(fn);
542 
543 
544 
545  }
546 
547  return 0;
548 
549 }
550 
551 
552 void DB_Save(char *tit, int mod)
553 {
554  int er;
555  struct tm today;
556 
558  {
559  SaveDataOffLine(tit, mod);
560  }
561  else
562  {
564  // gettime( &DIL.Img.Mat[Server].TIME );
565  // getdate( &DIL.Img.Mat[Server].DATE );
566 
567  D_BuildH(mod, Server);
568 
569  if(mod) //save in binary mode
570  er = D_save_bif(tit, Server);
571  else //save in ASCII mode
572  er = D_save_asc(tit, Server);
573  }
574 
575 
576 
577 }
578 
579 
580 void DB_save_img(char *tit, int mod)
581 {
582  int n;
583  FILE *fd;
584  int fh;
585 // struct date d;
586 // struct time t;
587  unsigned int y;
588 
589 
590  char tit1[64];
591  char datebuf[9];
592  char timebuf[9];
593  int Lambda;
594  int riga;
595 // int Idx, Idy, x, k,t,j;
596  int wl[] = {2823, 3337, 3850, 4358, 4861, 5332, 5814, 6282, 6734, 7201, 7677, 8195, 8622, 9023, 9405, 9758, 10066, 10358};
597  // char *filt[] = {{"NULL"},{"UG11"}, {"UG5 "}, {"BG25"}, {"BG39"}, {"GG45"}, {"BG12"}, {"NULL"}};
598 
599 
600  // char *PMirror[] = {{"PHOTOMETRIC"}, {"RADIOM. DX"}, {"DIRECT DX"},
601  // {"DIRECT SX"}, {"RADIOM. SX"}};
602 
603  Lambda = wl[GRS.Wl];
604 // Mirror = MIS.MirPos;
605 
606  //data e ora di memorizzazione dello spettro
607  _strdate(datebuf);
608  _strtime(timebuf);
609 
610  Status("Save Image");
611 
612 
613  if(mod) //binary mode
614  {
615  fh = open(tit, O_WRONLY | O_BINARY | O_CREAT | O_APPEND, S_IWRITE);
616  if ( fh < 0) return;
617 
618  //Salva tutte le righe
619  riga = 1;
620  for(y = 0; y < (unsigned int)IDY; y++)
621  //Salva solo 5 righe centrali
622  //riga = 4;
623  //for(y = 3; y < (DAS.Paramini.ccdWy / DAS.Paramini.VBin) - 3; y++)
624 
625  {
626  write( fh, &datebuf, sizeof(datebuf));
627  write( fh, &timebuf, sizeof(timebuf));
628  write( fh, &MIS.Pos, sizeof(MIS.Pos));
629  write( fh, &Lambda, sizeof(Lambda));
630  write( fh, &FWS.Pos, sizeof(FWS.Pos));
631 
632  write( fh, &TExp, sizeof(TExp));
633  write( fh, &riga, sizeof(riga));
634  // fwrite( Temp, 1, sizeof(Temp), fd );
635  // Commento
636  sprintf(tit1, "%s", "Default comment");
637  write( fh, &tit1, sizeof(tit1));
638 
639 
640  for(n = 0; n < IDX; n++)
641  {
642 // Imat[y * DAS.Paramini.ccdWx + n] = n*2;
643 // write(fh, &Imat[y * DAS.Paramini.ccdWx + n], sizeof(Imat[y * DAS.Paramini.ccdWx + n]));
644  }
645  riga++;
646 
647 
648  }
649 
650  close(fh);
651  }
652  else
653  {
654  fd = fopen(tit, "a");
655  if(fd == NULL)
656  {
657  Status("Error opening file");
658  return;
659  }
660 
661  //Salva tutte le righe
662  riga = 1;
663  for(y = 0; y < (unsigned int)IDY; y++)
664  //Salva solo 5 righe centrali
665  //riga = 4;
666  //for(y = 3; y < (DAS.Paramini.ccdWy / DAS.Paramini.VBin) - 3; y++)
667 
668  {
669  fprintf(fd, "%s %s ", datebuf, timebuf);//data e ora //RTC
670  fprintf(fd, " %d ", MIS.Pos); //Posizione specchio
671  fprintf(fd, " %5d ", Lambda); //lunghezza d'onda
672  fprintf(fd, " %d ", FWS.Pos); //Posizione RUOTA FILTRI
673  fprintf(fd, " %.2lf ", TExp); //tempo di integrazione
674 // fprintf(fd, " %.1lf ", Temp); //Temperatura del CCD
675  fprintf(fd, " Riga:%d ", riga); //Numero riga
676 // fprintf(fd, " %d\n ", VAna[7]); // Pressione esterna
677  // Commento
678  sprintf(tit1, "%s", "Default comment");
679  fprintf(fd, " %s\n ", tit1 ); // Commento
680 
681  for(n = 0; n < IDX; n++)
682 
683  {
684 // Imat[y * DAS.Paramini.ccdWx + n]=n * 2;
685 // fprintf(fd, " %04u", Imat[y * DAS.Paramini.ccdWx + n]);
686  }
687  fprintf(fd,"\n");
688  riga++;
689 
690 
691  }
692  fclose(fd);
693 
694  }
695 
696 
697 
698 
699  return;
700 
701 }
702 
703 
704 int ReadHeaderOnly(FILE *fd)
705 {
706 
707  int er = 0;
708  char str[128], temp[12];
709  int NewnR = 0;
710 
711  if(feof( fd ))
712  {
713  return 1;
714  }
715  else
716  {
717 /*
718  er = fscanf(fd, "%s%s%s%f%s%f%s%u%s%f", temp, BIL.SPH.location, temp, &BIL.SPH.latitude,
719  temp, &BIL.SPH.longitude, temp, &BIL.SPH.altitude, temp, &BIL.SPH.sza);
720 
721  er = fscanf(fd, "%s %s %s %s %d %s %f %f %u %u", BIL.SPH.StrDate, BIL.SPH.StrTime, temp, BIL.SPH.mirpos, &BIL.SPH.wavelen,
722  BIL.SPH.filpos, &BIL.SPH.ccdtemp, &BIL.SPH.ccdtexp, &BIL.SPH.ccdmax,
723  &BIL.SPH.ccdmin);
724 
725  er = fscanf(fd, "%d%d%d%d%d%d%d%d%d%d%d%d%d", &BIL.SPH.imgtype, &BIL.SPH.ccdwx, &BIL.SPH.ccdwy,
726  &BIL.SPH.ccdsx, &BIL.SPH.ccdsy, &BIL.SPH.ccdex, &BIL.SPH.ccdey, &BIL.SPH.ccdvb,
727  &BIL.SPH.ccdnr, &BIL.SPH.dummy1, &BIL.SPH.dummy2, &BIL.SPH.dummy3, &BIL.SPH.dummy4);
728 
729 
730  */
731 
732  er = fscanf(fd, "%s%s%s%lf%s%lf%s%lf%s%lf", temp, BIL.SPH.location, temp, &BIL.SPH.latitude,
733  temp, &BIL.SPH.longitude, temp, &BIL.SPH.altitude, temp, &BIL.SPH.sza);
734 
735  er = fscanf(fd, "%i/%2u/%2u%2u:%2u:%2u%s%s%d%s%lf%lf%lu%lu", &BIL.SPH.DATE.da_year,
736  &BIL.SPH.DATE.da_mon, &BIL.SPH.DATE.da_day, &BIL.SPH.TIME.ti_hour,
737  &BIL.SPH.TIME.ti_min, &BIL.SPH.TIME.ti_sec, temp, BIL.SPH.mirpos, &BIL.SPH.wavelen,
738  BIL.SPH.filpos, &BIL.SPH.ccdtemp, &BIL.SPH.ccdtexp, &BIL.SPH.ccdmax,&BIL.SPH.ccdmin );
739 
740  er = fscanf(fd, "%d%d%d%d%d%d%d%d%d%d%d%d%d", &BIL.SPH.imgtype, &BIL.SPH.ccdwx, &BIL.SPH.ccdwy,
741  &BIL.SPH.ccdsx, &BIL.SPH.ccdsy, &BIL.SPH.ccdex, &BIL.SPH.ccdey, &BIL.SPH.ccdvb,
742  &BIL.SPH.ccdnr, &BIL.SPH.dummy1, &BIL.SPH.dummy2, &BIL.SPH.dummy3, &BIL.SPH.dummy4);
743 
744  er = fscanf(fd, "%s", BIL.SPH.comment);
745  fgets(str, 80, fd);
746  }
747 
748  return 0;
749 }
750 /**********************************/
751 int ReadHeaderOldF(FILE *fd)
752 {
753 
754  int er = 0;
755  char str[128], temp[4];
756 
757 
758 
759  if(feof( fd ))
760  {
761  return 1;
762  }
763  else
764  {
765  er = fscanf(fd, "%s%s%s%lf%s%lf%s%lf%s%lf", temp, BIL.SPH.location, temp, &BIL.SPH.latitude,
766  temp, &BIL.SPH.longitude, temp, &BIL.SPH.altitude, temp, &BIL.SPH.sza);
767 
768  er = fscanf(fd, "%i/%u/%u%u:%u:%u%s%s%d%s%lf%lf%lu%lu", &BIL.SPH.DATE.da_year,&BIL.SPH.DATE.da_mon,
769  &BIL.SPH.DATE.da_day, &BIL.SPH.TIME.ti_hour, &BIL.SPH.TIME.ti_min, &BIL.SPH.TIME.ti_sec, temp,
770  BIL.SPH.mirpos, &BIL.SPH.wavelen, BIL.SPH.filpos, &BIL.SPH.ccdtemp, &BIL.SPH.ccdtexp, &BIL.SPH.ccdmax,
771  &BIL.SPH.ccdmin);
772 
773  er = fscanf(fd, "%d%d%d%d%d%d%d%d%d%d%d", &BIL.SPH.imgtype,
774  &BIL.SPH.ccdsx, &BIL.SPH.ccdsy,
775  &BIL.SPH.ccdex, &BIL.SPH.ccdey,
776  &BIL.SPH.ccdvb, &BIL.SPH.ccdnr,
777  &BIL.SPH.dummy1,
778  &BIL.SPH.dummy2,
779  &BIL.SPH.dummy3,
780  &BIL.SPH.dummy4);
781 
782  er = fscanf(fd, "%s", BIL.SPH.comment);
783  fgets(str, 80, fd);
784 
785  }
786 
787  return 0;
788 }
789 
790 void D_PrintHMod(FILE *fff)
791 {
792 
793 // spectrumheader pe;
794 
795 /*
796  er = fscanf(fd, "%s%s%s%lf%s%lf%s%lf%s%lf", temp, BIL.SPH.location, temp, &BIL.SPH.latitude,
797  temp, &BIL.SPH.longitude, temp, &BIL.SPH.altitude, temp, &BIL.SPH.sza);
798 
799  er = fscanf(fd, "%i/%u/%u%u:%u:%u%s%s%d%s%lf%lf%lu%lu", &BIL.SPH.DATE.da_year,&BIL.SPH.DATE.da_mon,
800  &BIL.SPH.DATE.da_day, &BIL.SPH.TIME.ti_hour, &BIL.SPH.TIME.ti_min, &BIL.SPH.TIME.ti_sec, temp,
801  BIL.SPH.mirpos, &BIL.SPH.wavelen, BIL.SPH.filpos, &BIL.SPH.ccdtemp, &BIL.SPH.ccdtexp, &BIL.SPH.ccdmax,
802  &BIL.SPH.ccdmin);
803 
804  er = fscanf(fd, "%d%d%d%d%d%d%d%d%d%d%d", &BIL.SPH.imgtype, &BIL.SPH.ccdsx, &BIL.SPH.ccdsy, &BIL.SPH.ccdex,
805  &BIL.SPH.ccdey, &BIL.SPH.ccdvb, &BIL.SPH.ccdnr, &BIL.SPH.dummy1, &BIL.SPH.dummy2, &BIL.SPH.dummy3, &BIL.SPH.dummy4);
806 
807  er = fscanf(fd, "%s", BIL.SPH.comment);
808 */
809 
810 
811  fprintf(fff, "LOC: %s ", BIL.SPH.location); //Name of the station
812  fprintf(fff, "LAT: %.2lf ", BIL.SPH.latitude);//Station latitude
813  fprintf(fff, "LON: %.2lf ", BIL.SPH.longitude);//Station latitude
814  fprintf(fff, "ALT[m/asl]: %u ", BIL.SPH.altitude);//Station altitude
815  fprintf(fff, "SZA: %.2lf\n", BIL.SPH.sza);//SZA
816 
817  fprintf(fff, "%d/%02d/%02d ", BIL.SPH.DATE.da_year, BIL.SPH.DATE.da_mon, BIL.SPH.DATE.da_day);
818  fprintf(fff, "%02d:%02d:%02d LT ",BIL.SPH.TIME.ti_hour, BIL.SPH.TIME.ti_min,BIL.SPH.TIME.ti_sec);
819  fprintf(fff, "%s ", BIL.SPH.mirpos);
820  fprintf(fff, "%d ", BIL.SPH.wavelen);
821  fprintf(fff, "%s ", BIL.SPH.filpos);
822  fprintf(fff, "%.2lf ", BIL.SPH.ccdtemp);
823  fprintf(fff, "%.2lf ", BIL.SPH.ccdtexp);
824  fprintf(fff, "%5u ", BIL.SPH.ccdmax);
825  fprintf(fff, "%5u\n", BIL.SPH.ccdmin);
826 
827 
828  // Image format
829  fprintf(fff, "%d ", BIL.SPH.imgtype);
830 // BIL.SPH.imgtype =
831 // BIL.SPH.camtype =
832 // BIL.SPH.ccdtype =
833  fprintf(fff, "%d ", BIL.SPH.ccdsx);
834  fprintf(fff, "%d ", BIL.SPH.ccdsy);
835  fprintf(fff, "%d ", BIL.SPH.ccdex);
836  fprintf(fff, "%d ", BIL.SPH.ccdey);
837  fprintf(fff, "%d ", BIL.SPH.ccdvb);
838  fprintf(fff, "%d ", BIL.SPH.ccdnr);
839  fprintf(fff, "%d ", BIL.SPH.dummy1);
840  fprintf(fff, "%d ", BIL.SPH.dummy2);
841  fprintf(fff, "%d ", BIL.SPH.dummy3);
842  fprintf(fff, "%d\n", BIL.SPH.dummy4);
843  fprintf(fff, "%s\n", BIL.SPH.comment);
844 
845 
846 }
847 
848 
849 
850 void WriteColumn(int mod, FILE *fd)
851 {
852 
853  int x, y;
854 // FILE *fd;
855 // fd = fopen(fname, "a");
856 // if(fd < 0) return 1;
857 // D_VRange("Column FORMAT processing", 0, 128, 254, 128);
858 
859  // Print on file the header
860  D_PrintHMod(fd);
861 
862  if(mod)
863  Pix2Wl(0, BIL.SPH.wavelen, DAS.Paramini.ccdXoff, DAS.Paramini.ccdWx + 1, &DOAS);
864 
865  for(x = 0; x < IDX; x++)
866  {
867 
868  if(mod)
869  fprintf(fd, " %9.4lf", DOAS.lambda[x]);
870  else
871  fprintf(fd, " %04d", x);
872  for(y = 0; y < IDY; y++)
873  {
874  fprintf(fd, " %05u", BIL.DPLOT.ImatGraf[y * IDX + x]);
875  }
876  fprintf(fd, "\n", NULL);
877 // if((x % 40) == 0 && x > 0)
878 // D_VRange(NULL, (long) x * 100 / IDX, 128, 254, 128);
879  }
880  fprintf(fd, "\n", NULL);
881 // fclose(fd);
882 // D_VRange(NULL, 100, 128, 254, 128);
883 // return 0;
884 
885 
886 
887 
888 }
889 
890 int SmoothFloatData(float *source, float *destination, int horpix, int verpix,
891  int filw, int bp)
892 {
893 
894  int x, y, n ;
895  FILE *fd;
896  double *avect;
897  unsigned long eln = (unsigned long)(2 * (horpix - bp + 1 )) ;
898 
899  avect = (double *) calloc( eln, sizeof(double));
900  if( avect == NULL )
901  return 1;
902 
903  for(y = 0; y < verpix; y++)
904  {
905  n=1;
906  for(x = 0; x < horpix; x++)
907  {
908  if ((x <= horpix - bp ) & (x > 1))
909  {
910  avect[n] = (double)source[y * (horpix) + x];
911  n++;
912  }
913  }
914 
915  SmoothingF(avect, n - 1, filw);
916 
917  for(x = 0; x < horpix; x++)
918  {
919  if ((x <= horpix - bp ) & (x > 1))
920  {
921  destination[y * horpix + x] = (float) avect[x-1] ;
922  }
923 
924  }
925  }
926 
927  free(avect);
928 
929  fd = fopen("SmoothFL_In.tmp", "w");
930  if(fd < 0) return 1;
931  for(x = 0; x < horpix + 1; x++)
932  {
933  if ((x <= horpix - bp ) & (x > 1))
934  {
935  fprintf(fd, "%04u ", x);
936 
937  for(y = 0; y < verpix; y++)
938  {
939  fprintf(fd, "%10.5lf ", source[y * IDX + x]);
940  }
941  fprintf(fd, "\n", NULL);
942  }
943  }
944  fprintf(fd, "\n", NULL);
945  fclose(fd);
946 
947 
948  fd = fopen("SmoothFL_Out.tmp", "w");
949  if(fd < 0) return 1;
950 
951  for(x = 0; x < horpix + 1; x++)
952  {
953  if ((x <= horpix - bp ) & (x > 1))
954  {
955  fprintf(fd, "%04u ", x);
956 
957  for(y = 0; y < verpix; y++)
958  {
959  fprintf(fd, "%10.5lf ", destination[y * IDX + x]);
960  }
961  fprintf(fd, "\n", NULL);
962  }
963  }
964  fprintf(fd, "\n", NULL);
965  fclose(fd);
966 
967  return 0;
968 }
969 
970 
971 
972 
973 int SmoothData(unsigned short *source, float *destination, int horpix, int verpix,
974  int filw, int bp)
975 {
976 
977  int x, y, n ;
978  double *avect;
979  unsigned long eln = (unsigned long)(2 * (horpix - bp + 1 )) ;
980  FILE *fd;
981 
982  avect = (double *) calloc( eln, sizeof(double));
983  if( avect == NULL )
984  return 1;
985 
986  for(y = 0; y < verpix; y++)
987  {
988  n=1;
989  for(x = 0; x < horpix; x++)
990  {
991  if ((x <= horpix - bp ) & (x > 1))
992  {
993  avect[n] = (double)source[y * (horpix) + x];
994  n++;
995  }
996  }
997 
998  SmoothingF(avect, n - 1, filw);
999 
1000  for(x = 0; x < horpix; x++)
1001  {
1002  if ((x <= horpix - bp ) & (x > 1))
1003  {
1004  destination[y * horpix + x] = (float) avect[x-1] ;
1005  }
1006 
1007  }
1008  }
1009 
1010  free(avect);
1011 
1012  fd = fopen("SmoothUS_In.tmp", "w");
1013  if(fd < 0) return 1;
1014 // for(x = 0; x < horpix + 1; x++)
1015  for(x = 0; x < horpix ; x++)
1016 
1017  {
1018  if ((x <= horpix - bp ) & (x > 1))
1019  {
1020  fprintf(fd, "%04u ", x);
1021 
1022  for(y = 0; y < verpix; y++)
1023  {
1024  fprintf(fd, "%05u ", source[y * IDX + x]);
1025  }
1026  fprintf(fd, "\n", NULL);
1027  }
1028  }
1029  fprintf(fd, "\n", NULL);
1030  fclose(fd);
1031 
1032 
1033  fd = fopen("SmoothUS_Out.tmp", "w");
1034  if(fd < 0) return 1;
1035 
1036 // for(x = 0; x < horpix + 1; x++)
1037  for(x = 0; x < horpix; x++)
1038 
1039  {
1040  if ((x <= horpix - bp ) & (x > 1))
1041  {
1042  fprintf(fd, "%04u ", x);
1043 
1044  for(y = 0; y < verpix; y++)
1045  {
1046  fprintf(fd, "%10.5lf ", destination[y * IDX + x]);
1047  }
1048  fprintf(fd, "\n", NULL);
1049  }
1050  }
1051  fprintf(fd, "\n", NULL);
1052  fclose(fd);
1053 
1054  return 0;
1055 
1056 }
1057 
1058 
1059 
1060 void WriteSelColandSmoothed(int mod, FILE *fd, int selcol)
1061 {
1062 
1063  int x, BlindPix_1;
1064 // FILE *fd;
1065 // fd = fopen(fname, "a");
1066 // if(fd < 0) return 1;
1067 // D_VRange("Column FORMAT processing", 0, 128, 254, 128);
1068 
1069  BlindPix_1 = 0;
1070  if (BIL.SPH.ccdwx - (BIL.SPH.ccdex +1) != 0) // se i pixel del sensore sono piu' di quelli in param.ini
1071  BlindPix_1 = BIL.SPH.ccdwx - (BIL.SPH.ccdex +1) ;
1072 
1074 
1075 
1076  SmoothData(BIL.DPLOT.ImatOrig, BIL.ANALYSIS.ImatSmooth, IDX, IDY, DOAS.FFTFilter, BlindPix_1);
1077 
1078  // Print on file the header
1079  D_PrintHMod(fd);
1080 
1081  for(x = 0; x < IDX - BlindPix_1 + 1; x++)
1082  {
1083 
1084  if(mod)
1085  fprintf(fd, " %9.4lf", DOAS.lambda[x]);
1086  else
1087  fprintf(fd, " %04u", x);
1088 // for(y = selcol; y < IDY; y++)
1089 // {
1090  fprintf(fd, " %05u %9.4lf", BIL.DPLOT.ImatOrig[selcol * IDX + x],BIL.ANALYSIS.ImatSmooth[selcol * IDX + x]);
1091 // }
1092  fprintf(fd, "\n", NULL);
1093 // if((x % 40) == 0 && x > 0)
1094 // D_VRange(NULL, (long) x * 100 / IDX, 128, 254, 128);
1095  }
1096  fprintf(fd, "\n", NULL);
1097 // fclose(fd);
1098 // D_VRange(NULL, 100, 128, 254, 128);
1099 // return 0;
1100 
1102 
1103 
1104 
1105 
1106 }
1107 
1108 
1109 int DB_Column(char *sourcefilename)
1110 {
1111 
1112 
1113  FILE *fs, *fd;
1114  char buf[256];
1115  int er = 0, k = 0;
1116  char string[4] = ".COL";
1117  int lunstr;
1118  char fext[4];
1119 
1120  int fb;
1121  fext[0] = '\0';
1122 
1123 // MMessageDialog("Full FileName:", nomefile, "ok", NULL);
1124 
1125  lunstr = strlen(sourcefilename);
1126  strcpy(buf,sourcefilename);
1127 
1128  strncpy( buf + (lunstr - 4), string, 4 );
1129 
1130  fd = fopen(buf, "a");
1131  if(fd < 0) return 1;
1132 
1133 
1134  DI_FindExtName(sourcefilename, fext);
1135 
1136  D_VRange("Column FORMAT processing", 0, 128, 254, 128);
1137 
1138 
1139  if( (strcmp(fext,".dat") == 0) |(strcmp(fext,".Dat") == 0) )
1140  {
1141  fs = fopen(sourcefilename, "r");
1142  if(fs < 0) return 1;
1143 
1144 
1145  while( !feof( fs ) )
1146  {
1147  /*
1148  mod = 1 --> Assign Header to plot labels
1149  mod = 0 --> Read header only
1150  */
1151  ReadHeader_ASCII(0, fs);
1152  if(BIL.DPLOT.ImatGraf == 0)
1153  BIL.DPLOT.ImatGraf = AllocUSMat(IDX, IDY);
1154 
1155  ReadIMG(fs, BIL.DPLOT.ImatGraf, IDX, IDY);
1156 
1157  if(TOOLS.FlagFilter)
1158  FilterData(BIL.DPLOT.ImatGraf, IDX, IDY, DOAS.FFTFilter, 30);
1159 
1160  WriteColumn( FLAG.Wl, fd);
1161  k++;
1162  if((k % 5) == 0 && k > 0)
1163  D_VRange(NULL, (long) k * 100 / SAVECNT , 128, 254, 128);
1164  }
1165 
1166 // D_VRange(NULL, 100, 128, 254, 128);
1167  fclose(fs);
1168  }
1169  else if( (strcmp(fext,".bif") == 0) | (strcmp(fext,".Bif") == 0) )
1170  {
1171  fb = open(sourcefilename, O_RDONLY | O_BINARY, S_IREAD );
1172 
1173  while( !eof( fb ) )
1174  {
1175 
1176  er = ReadHeader_BIN(fb);
1177 
1178  if(BIL.DPLOT.ImatGraf == 0)
1179  BIL.DPLOT.ImatGraf = AllocUSMat(IDX, IDY);
1180 
1181  ReadIMG_BIN(fb, BIL.DPLOT.ImatGraf, IDX, IDY);
1182 
1183  if(TOOLS.FlagFilter)
1184  FilterData(BIL.DPLOT.ImatGraf, IDX, IDY, DOAS.FFTFilter, 30);
1185 
1186  WriteColumn( FLAG.Wl, fd);
1187  k++;
1188  if((k % 5) == 0 && k > 0)
1189  D_VRange(NULL, (long) k * 100 / SAVECNT , 128, 254, 128);
1190 
1191  }
1192 // D_VRange(NULL, 100, 128, 254, 128);
1193  close (fb);
1194 
1195  }
1196  D_VRange(NULL, 100, 128, 254, 128);
1197  fclose(fd);
1198 
1199  return 0;
1200 }
struct ddate DATE
Definition: bildef.h:134
U16 VBin
Definition: Dildef.h:337
char comment[255]
Definition: bildef.h:157
unsigned int ccdmax
Definition: bildef.h:142
int IDX
Number of sensible horizontal pixels.
Definition: DAS_Spat.c:118
void WriteColumn(int mod, FILE *fd)
Definition: Save.c:850
float Sigma
Definition: Dildef.h:306
void D_Print_BIL_H_BIN(int mod, int fd)
Definition: Save.c:284
U16 Idx[MAXIMG]
Definition: Dildef.h:570
int Server
Definition: DAS_Spat.c:253
Definition: DOASdef.h:16
dil DIL
Definition: 2DPlot.c:26
void WriteSelColandSmoothed(int mod, FILE *fd, int selcol)
write selected Column
Definition: Save.c:1060
char Ctrst
Definition: Dildef.h:304
void D_VRange(char *str, int val, int, int g, int b)
Create and display the status bar.
Definition: Utils.c:206
unsigned int imgmin
Image minimum value.
Definition: Dildef.h:710
#define O_BINARY
Definition: Dildef.h:201
int D_save_asc(char *fname, int s)
Definition: Save.c:451
#define DIF_STAT
Definition: Dildef.h:171
float MaxNumbers
Definition: Dildef.h:309
config Cfg
Definition: Save.c:22
int SmoothData(unsigned short *source, float *destination, int horpix, int verpix, int filw, int bp)
Calc. the smoothed matrix of an unsigned short one. .
Definition: Save.c:973
int Wl
Flag for the units on the X scale plot.
int ccdwy
Total Number of Y Pixels.
Definition: Dildef.h:693
void AssignNewH()
Definition: Save.c:279
U8 da_mon
Definition: Dildef.h:243
char CCDName[20]
Definition: Dildef.h:328
U8 ti_sec
Definition: Dildef.h:238
char InfoPar
Definition: Dildef.h:327
double gain
Definition: Dildef.h:331
#define DIF_TIME
Definition: Dildef.h:173
void D_BuildH(int mod, int s)
Build Header of the measurements . .
Definition: Procedures.c:63
int ccdWx
CCD X End.
Definition: bildef.h:83
int ccdwx
Total Number of X Pixels.
Definition: Dildef.h:692
S16 off
Definition: Dildef.h:330
int dummy4
Definition: Dildef.h:716
#define DOASMODE
execution for DOAS Processing
int dummy3
Definition: Dildef.h:715
int FilterData(unsigned short *mat, int horpix, int verpix, int filw, int bp)
Definition: FFT.c:250
int Pos
Mirror Current Position.
flag Flag
Structure for different flags.
int D_WriteInitLog(char *str)
writes devices errors(AMS, CCD...) on the Devices.log file.
Definition: Save.c:144
#define FLTIMG
Definition: Dildef.h:12
void getdate(struct date *tp)
get current date
Definition: Save.c:131
struct date DATE
Registration date.
Definition: Dildef.h:701
U16 * Imat
Definition: Dildef.h:286
doas DOAS
Definition: Save.c:27
int ccdys
Y Start.
Definition: Dildef.h:695
U16 HBin
Definition: Dildef.h:336
int SmoothFloatData(float *source, float *destination, int horpix, int verpix, int filw, int bp)
Calc. the smoothed matrix of a float one. .
Definition: Save.c:890
das DAS
Definition: Chktemp.c:26
S16 type
Definition: Dildef.h:280
analize ANALYSIS
Definition: bildef.h:258
int ccdXoff
CCD X Start.
void DB_save_img(char *tit, int mod)
Saving image. Procedure for saving the CCD Image Used until version 2.0.9, Since 2.1.0 D_Saving(void) is used.
Definition: Save.c:580
U16 * Gmat
Definition: Dildef.h:289
unsigned int altitude
Altitude of the Station.
Definition: bildef.h:131
float ccdtemp
CCD Temperature.
Definition: Dildef.h:707
Definition: Dildef.h:423
float * DeallocFloatMat(float *mat)
Definition: Spat_Plot.c:153
spectrumheader SPH
Spectrum Header Structure.
Definition: bildef.h:256
Definition: Dildef.h:687
img Mat[MAXIMG]
Definition: Dildef.h:552
void ReadIMG(FILE *file, unsigned short *mat, int hp, int vp)
Read ASCII Image (Spectral Data only) .
Definition: Spat_Plot.c:1206
float * ImatSmooth
Definition: bildef.h:165
unsigned char ti_hour
Definition: bildef.h:79
struct date DATE
Definition: Dildef.h:348
int ccdxe
X End.
Definition: Dildef.h:696
U16 * Rmat
Definition: Dildef.h:288
S16 range
Definition: Dildef.h:332
image Img
Definition: Dildef.h:675
int Pos
Filter Wheel current Position.
S16 da_year
Definition: Dildef.h:241
void D_PrintHMod(FILE *fff)
Print the header in Column format.
Definition: Save.c:790
U16 Wy
Definition: Dildef.h:343
U8 da_day
Definition: Dildef.h:242
short unsigned U16
2 byte without sign, range 0-65535
Definition: dcldef.h:375
void D_PrintH_BIN(int mod, int fd)
Definition: Save.c:323
S16 TAMB
Definition: Dildef.h:334
#define INTIMG
Definition: Dildef.h:10
Control Flags.
U16 Idy[MAXIMG]
Definition: Dildef.h:571
U8 ti_hour
Definition: Dildef.h:236
int Wl
Grating Wavelength.
ccd DC_CCD
Definition: Save.c:20
U8 ti_hund
Definition: Dildef.h:237
unsigned int s_alt
station altitude
Definition: Dildef.h:722
float s_longitude
station longitude
Definition: Dildef.h:720
struct time TIME
Registration time.
Definition: Dildef.h:700
int ReadHeader_ASCII(int mod, FILE *fd)
Read ASCII Header of the measurement. .
Definition: Spat_Plot.c:1877
char binmirpos[8]
Mirror position.
Definition: Dildef.h:703
#define OFFLINEPLOT
execution for archived data visualisation
#define FRdMat(s, x, y)
Definition: Dildef.h:196
int SaveDataOffLine(char *fname, int mod)
Definition: Save.c:493
unsigned long U32
4 byte without sign, range 0-4294967295
Definition: dcldef.h:376
#define SAVECNT
maximum number of spectra in one file
char * comment
comment
Definition: Dildef.h:717
unsigned short * ImatOrig
Definition: bildef.h:180
GratingSt GRS
Grating.
Definition: Save.c:24
void WriteIMG_BIN(int fd, unsigned short *mat, int hp, int vp)
Definition: Spat_Plot.c:1153
unsigned char ti_sec
Definition: bildef.h:81
d_view DPLOT
Definition: bildef.h:254
char filpos[5]
Definition: bildef.h:139
int ReadHeaderOldF(FILE *fd)
read the ASCII header of the stored spectrum (OLD FORMAT - replaced by ReadHeaderOnly(FILE *fd) ...
Definition: Save.c:751
int imgfmt
Image format: 0 = ASCII, 1 = BIN.
Definition: Dildef.h:688
U16 Sy
Definition: Dildef.h:341
double lambda[1055]
Wavelength series.
Definition: DOASdef.h:18
void Status(char *tit)
Writes information&#39;s on the Status label .
Definition: Load.c:1556
bil BIL
Definition: Save.c:26
int dummy2
Definition: Dildef.h:714
int ccdnr
Row number (ccdyoff-ccdwx)/ccdvbin.
Definition: Dildef.h:699
int D_save_bin(char *f, int s)
Definition: Save.c:177
Definition: Dildef.h:240
ptf DC_HP
Definition: Save.c:21
int ReadHeader_BIN(int fd)
read the BINARY header of the stored spectrum
Definition: Spat_Plot.c:1798
char mirpos[8]
Definition: bildef.h:137
struct dtime TIME
Definition: bildef.h:133
float IHigh
Definition: Dildef.h:303
float s_sza
sun solar zenith angles
Definition: Dildef.h:724
char bincomment[255]
comment
Definition: Dildef.h:718
U16 Sx
Definition: Dildef.h:340
void ReadIMG_BIN(int fd, unsigned short *mat, int hp, int vp)
read the BINARY stored spectrum
Definition: Spat_Plot.c:1166
int IDY
Number of sensible vertical pixels.
Definition: DAS_Spat.c:119
int Pix2Wl(int mod, int pos, int spix, int epix, struct doas *pd)
Definition: DOAS.c:26
hdrsp HDRSP
Definition: Save.c:23
Function prototypes.
Definition: bildef.h:77
S16 col
Definition: Dildef.h:284
#define URdMat(s, x, y)
Definition: Dildef.h:192
float s_latitude
station latitude
Definition: Dildef.h:719
int FFTFilter
Fast Fourier Trasform Filter windows.
Definition: DOASdef.h:25
int FlagFilter
flag for filterinf
int ReadHeaderOnly(FILE *fd)
read the ASCII header of the stored spectrum
Definition: Save.c:704
unsigned short * ImatGraf
Definition: bildef.h:176
double TExp
CCD Exposure time.
Definition: DAS_Spat.c:130
MirrorSt MIS
Mirror.
Definition: DAS_Spat.c:61
Function prototypes.
float ILow
Definition: Dildef.h:302
double SExp
Definition: Dildef.h:333
short int S16
2 byte with sign, -32768+32767
Definition: dcldef.h:374
float ccdtexp
Definition: bildef.h:140
char binfilpos[5]
Filter position.
Definition: Dildef.h:706
const char * filpos
Filter position.
Definition: Dildef.h:705
void D_PrintH_ASCII(int mod, FILE *fff)
Definition: Save.c:362
void GetDateTime(struct date *dp, struct time *tp, struct tm *when)
Definition: Save.c:43
int D_save_bif(char *f, int s)
Definition: Save.c:398
char s_name[4]
station localization
Definition: Dildef.h:721
C_DEF void VRange(char *str, int val)
float * Fmat
Definition: Dildef.h:287
int wl[]
WaveLength definition - for SD_Grating.
Definition: DAS_Spat.c:182
U8 ti_min
Definition: Dildef.h:235
int SmoothingF(double *tmp, int npix, int pts)
Smoothing of 1D array.
Definition: FFT.c:151
unsigned char ti_min
Definition: bildef.h:78
void gettime(struct time *tp)
get current time
Definition: Save.c:92
char mirpos[8]
Mirror position.
Definition: Dildef.h:702
Bortul Image Library Structure .
Definition: bildef.h:250
float longitude
Longitude of the Station.
Definition: bildef.h:130
unsigned char da_mon
Definition: bildef.h:86
int ccdye
Y End.
Definition: Dildef.h:697
void DB_Save(char *tit, int mod)
Save the acquired spectrum. Procedure that Save the acquired spectrum.
Definition: Save.c:552
U16 Wx
Definition: Dildef.h:342
int dummy1
Definition: Dildef.h:713
int ccdxs
X Start.
Definition: Dildef.h:694
flag FLAG
flags structure
Definition: Save.c:25
float latitude
Latitude of the Station.
Definition: bildef.h:129
#define DIF_CAMERA
Definition: Dildef.h:172
unsigned char da_day
Definition: bildef.h:85
Definition: Dildef.h:234
char location[4]
Name of the Station (BLQ, LPA, EVR, TNB, DMC.....)
Definition: bildef.h:128
Definition: dcldef.h:1020
float * AllocFloatMat(int hp, int vp)
Definition: Spat_Plot.c:2009
short int da_year
Definition: bildef.h:84
C_DEF void DI_FindExtName(char *fullname, char *fext)
Definition: dcldef.h:1043
void UPS_Status(void)
Definition: Save.c:32
S16 TCCD
Definition: Dildef.h:335
struct time TIME
Definition: Dildef.h:347
float ccdtemp
Definition: bildef.h:141
unsigned short * AllocUSMat(int hp, int vp)
Definition: Spat_Plot.c:1994
int lambda
wavelength value
Definition: Dildef.h:704
char CamName[20]
Definition: Dildef.h:329
float Low
Definition: Dildef.h:294
float ccdtexp
ccd Exposure time
Definition: Dildef.h:708
unsigned int ccdmin
Definition: bildef.h:143
U16 * Bmat
Definition: Dildef.h:290
tools TOOLS
Definition: CreateForms.c:81
unsigned int imgmax
Image maximum value.
Definition: Dildef.h:709
void WriteIMG(FILE *file, unsigned short *mat, int hp, int vp)
Definition: Spat_Plot.c:1178
float High
Definition: Dildef.h:295
Status of the Grating .
static double raddeg
Definition: SOLPOS.C:133
int exemode
Set the Execution MODE (Execution modes)
FilterWheelSt FWS
Filter Wheel.
Definition: DAS_Spat.c:57
int ccdvbin
Vertical binning value.
Definition: Dildef.h:698
float Media
Definition: Dildef.h:305
float sza
Solar Zenith Angle.
Definition: bildef.h:132
void D_Print_BIL_H_ASCII(int mod, FILE *fff)
Definition: Utils.c:621
paramini Paramini
structure for the parameters defined in param.ini configuration file
int DB_Column(char *sourcefilename)
Column format.
Definition: Save.c:1109
______________________________________________________________________________________
Generated on Mon Sep 18 2017 11:44:09 for DAS - Rel. 3.1.6 - 18/09/2017.