Elaboradar  0.1
 Tutto Classi Namespace File Funzioni Variabili Tipi enumerati (enum) Gruppi
func_SP20toMDB.cpp
1 /*=================================================================
2  omstart func_SP20toMDB
3 
4  Questo file contiene le funzioni che leggono l'header del DBP
5  nel nuovo formato SP20.Inoltre contiene la funzione che converte
6  l'header.Queste funzioni sono chiamate dal programma cum_bac_SP20_[]
7 
8  omend
9  ================================================================== */
10 #include <string.h>
11 #include <math.h>
12 #include "func_SP20read.h"
13 
14 /*=============================================================
15  HEADER DI VOLUME: acquisizione e decodifica dei dati
16  relativi al DBP e conversione nel vecchio formato.
17  =============================================================*/
18 
19 /* ==================== */
20 char get_DBP_scan_mode(unsigned char hd[8][4])
21 /* ==================== */
22 {
23  return (hd [0][1]>>1 & 0x03);
24 }
25 
26 
27 /* ==================== */
28 float get_DBP_rot_vel(unsigned char hd[8][4])
29 /* ==================== */
30 {
31  // printf("%x %x\n", hd[0][1], hd[2][2]);
32 
33  return ( ( ((hd[0][1]>>3)&0x1f) + ((hd[2][2]>>6)&0x03)*0.1 ));
34 
35 }
36 
37 
38 /* ==================== */
39 char get_DBP_pulse_lenght(unsigned char hd[8][4])
40 /* ==================== */
41 {
42  return (hd [0][3]>>6 & 0x03);
43 }
44 
45 
46 /* ==================== */
47 float get_DBP_el_min(unsigned char hd[8][4])
48 /* ==================== */
49 {
50  // printf("el_min: %x %x \n", hd[1][1], hd[1][2]);
51 
52  return ( ( hd[1][1] | ((hd[1][2] &0x0f) <<8) ) *(360./4096.) );
53 }
54 
55 
56 /* ==================== */
57 float get_DBP_el_max(unsigned char hd[8][4])
58 /* ==================== */
59 {
60  // printf("el_max: %x %x \n", hd[2][1], hd[2][2]);
61 
62  return ( ( hd[2][1] | ((hd[2][2] &0x0f) <<8) ) *(360./4096.) );
63 }
64 
65 
66 /* ==================== */
67 float get_DBP_az_min(unsigned char hd[8][4])
68 /* ==================== */
69 {
70  // printf("az_min: %x %x \n", hd[4][1], hd[4][2]);
71 
72  return ( ( hd[4][1] | ((hd[4][2] &0x0f) <<8) ) *(360./4096.) );
73 }
74 
75 
76 /* ==================== */
77 float get_DBP_az_max(unsigned char hd[8][4])
78 /* ==================== */
79 {
80  // printf("az_max: %x %x \n", hd[5][1], hd[5][2]);
81 
82  return ( (hd[5][1] | ( (hd[5][2] &0x0f) <<8)) *(360./4096.) );
83 }
84 
85 
86 /* ==================== */
87 short get_DBP_pulse_number(unsigned char hd[8][4])
88 /* ==================== */
89 {
90  return ( (short)( ((hd[4][2]>>4) & 0x0f) | ((hd[4][3] &0x1f) <<4) ));
91 }
92 
93 
94 /* ============================================ */
95 void get_DBP_flag_quantities (unsigned char hd[8][4], char *flag_quantities)
96 /* ============================================ */
97 {
98  //misura di Z
99  flag_quantities[0] = hd[1][3] & 0x01;
100  //misura di Zdr
101  flag_quantities[1] = hd[1][3]>>1 & 0x01;
102  //misura di V
103  flag_quantities[2] = hd[1][3]>>2 & 0x01;
104  //misura di sV
105  flag_quantities[3] = hd[1][3]>>3 & 0x01;
106 
107  return;
108 
109 }
110 
111 
112 
113 /* ==================== */
114 char get_DBP_cell_size (unsigned char hd[8][4])
115 /* ==================== */
116 {
117  return ( (hd[1][3]>>4) & 0x07);
118 }
119 
120 
121 
122 /* ==================== */
123 char get_DBP_Dual_PRF (unsigned char hd[8][4])
124 /* ==================== */
125 {
126  return ( (hd[1][3]>>7) & 0x01);
127 }
128 
129 
130 //da verificare
131 /* ========================= */
132 char get_DBP_tipo_filtro(unsigned char hd[8][4])
133 /* ========================= */
134 {
135  return ( (char) ((hd[2][3]>>4)&0x0f) );
136 }
137 
138 /* =========================== */
139 char get_DBP_corr_clutter (unsigned char hd[8][4])
140 /* =========================== */
141 {
142  return ( (char) ((hd[2][3]>>2)&0x01) );
143 }
144 
145 /* ============================= */
146 char get_DBP_filtro_clutter (unsigned char hd[8][4])
147 /* ============================= */
148 {
149  return ( (char) ((hd[2][3]>>3)&0x01) );
150 }
151 
152 /* ================================== */
153 char get_DBP_anticlutter_mappato (unsigned char hd[8][4])
154 /* ================================== */
155 {
156  return ( (char) ((hd[2][3])>>1 &0x01) );
157 }
158 
159 //da verificare
160 /* ==================== */
161 char get_DBP_Z_range (unsigned char hd[8][4])
162 /* ==================== */
163 {
164  return ( (char) (hd[3][2]>>6)&0x03 );
165 }
166 
167 
168 /* ================================= */
169 char get_DBP_calibration_factor (unsigned char hd[8][4])
170 /* ================================= */
171 {
172  return( (char) (hd[3][3]&0x0f) + (((hd[3][3]>>4)&0x0f)*10) );
173 }
174 
175 
176 
177 /* ========================= */
178 char get_DBP_stalo_code (unsigned char hd[8][4])
179 /* ========================= */
180 {
181  // printf("stalo_code esadecimale: %x\n",hd[7][3]);
182 
183  return ( hd[7][3] & 0x07 );
184 }
185 
186 
187 
188 
189 
190 //per richiamare le singole routine
191 /*===========================================*/
192 void decode_header_DBP_SP20 (HD_DBP_SP20_RAW *hd_raw, HD_DBP_SP20_DECOD *hd_decod)
193 /*===========================================*/
194 {
195  int i;
196 
197 
198  hd_decod->scan_mode = get_DBP_scan_mode(hd_raw->frame);
199  hd_decod->rot_vel = get_DBP_rot_vel(hd_raw->frame);
200  hd_decod->pulse_lenght = get_DBP_pulse_lenght(hd_raw->frame);
201  hd_decod->el_min = get_DBP_el_min(hd_raw->frame);
202  hd_decod->el_max = get_DBP_el_max(hd_raw->frame);
203  hd_decod->az_min = get_DBP_az_min(hd_raw->frame);
204  hd_decod->az_max = get_DBP_az_max(hd_raw->frame);
205 
206  get_DBP_flag_quantities (hd_raw->frame, hd_decod->flag_quantities);
207 
208  hd_decod->cell_size = get_DBP_cell_size(hd_raw->frame);
209  hd_decod->Dual_PRF = get_DBP_Dual_PRF(hd_raw->frame);
210  hd_decod->filtro_clutter = get_DBP_filtro_clutter(hd_raw->frame);
211  hd_decod->tipo_filtro = get_DBP_tipo_filtro(hd_raw->frame);
212  hd_decod->anticlutter_mappato = get_DBP_anticlutter_mappato(hd_raw->frame);
213  hd_decod->corr_clutter = get_DBP_corr_clutter(hd_raw->frame);
214  hd_decod->Z_range = get_DBP_Z_range(hd_raw->frame);
215  hd_decod->calibration_factor = get_DBP_calibration_factor(hd_raw->frame);
216  hd_decod->pulse_number = get_DBP_pulse_number(hd_raw->frame);
217  hd_decod->stalo_code = get_DBP_stalo_code(hd_raw->frame);
218  if (hd_raw->num_ele >= 41 )
219  hd_decod->num_ele=hd_raw->num_ele-41;
220  else
221  hd_decod->num_ele=hd_raw->num_ele;
222 
223  hd_decod->corr_pot=hd_raw->corr_pot;
224 
225  for(i=0; i<hd_decod->num_ele; i++) //ciclo sul numero elementi significativi
226  hd_decod->ele[i]=hd_raw->ele[i]*0.0879;
227 
228  return ;
229 }
230 
231 
232 
233 
234 /*converte nelle variabili del vecchio formato*/
235 /*==============================================*/
236 void convert_format(HD_DBP_SP20_DECOD *hd_decod, BEAM_HD_SP20_INFO *beam_info, T_MDB_data_header *old_header) //raggio= beam_info
237 /*==============================================*/
238 {
239  int i, k;
240 
241  old_header->norm.maq.acq_date=beam_info->time;
242  old_header->norm.maq.scans_type=hd_decod->scan_mode;
243  old_header->norm.maq.rot_vel=hd_decod->rot_vel;
244  old_header->norm.maq.imp_duration=hd_decod->pulse_lenght;
245 
246  old_header->norm.maq.grand=0;
247  for(k=0; k<4; k++)
248  {
249  old_header->norm.maq.grand=old_header->norm.maq.grand +
250  (int)( pow((double)2,(double)k) * (int)hd_decod->flag_quantities[k]);
251  // printf("\nflag_quantities[k]=%d grand=%d\n ",hd_decod->flag_quantities[k], old_header->norm.maq.grand);
252  }
253  old_header->norm.maq.resolution=hd_decod->cell_size;
254  old_header->norm.maq.vel_range=hd_decod->Dual_PRF;
255  old_header->norm.maq.declutter_rsp=hd_decod->filtro_clutter;
256 
257  // printf("%1d 1d\n", old_header->norm.maq.declutter_rsp,hd_decod->filtro_clutter);
258 
259  old_header->norm.maq.filter_value=hd_decod->tipo_filtro;
260  old_header->norm.maq.type_declutter=hd_decod->anticlutter_mappato;
261  old_header->norm.maq.corr_Z=hd_decod->corr_clutter;
262  old_header->norm.maq.spare[1]=hd_decod->Z_range;
263  if(hd_decod->Z_range ==0)
264  old_header->norm.maq.spare[0]=2;
265  if(hd_decod->Z_range ==1)
266  old_header->norm.maq.spare[0]=1;
267  if(hd_decod->Z_range ==2)
268  old_header->norm.maq.spare[0]=3;
269 
270  old_header->norm.maq.num_imp=hd_decod->pulse_number;
271  old_header->norm.maq.num_el=hd_decod->num_ele;
272  //ciclo sul num di elementi significativi
273  for(i=0; i<old_header->norm.maq.num_el ;i++)
274  old_header->norm.maq.value[i]=hd_decod->ele[i]/FATT_MOLT_EL;
275  return ;
276 }
277 
278 
279 /* ========================================= */
280 void PrintHeaderDBP(HD_DBP_SP20_DECOD *hd_decod)
281 /* ========================================= */
282 {
283  int i;
284 
285  printf("HEADER DBP:\n");
286  printf("%2d ",hd_decod->scan_mode);
287  printf("%2d ",hd_decod->flag_quantities[0]);
288  printf("%1d ",hd_decod->flag_quantities[1]);
289  printf("%1d ",hd_decod->flag_quantities[2]);
290  printf("%1d ",hd_decod->flag_quantities[3]);
291  printf("%2d ",hd_decod->Z_range);
292  printf("%2d ",hd_decod->Dual_PRF);
293  printf("%2d ",hd_decod->pulse_lenght);
294  printf("%2d ",hd_decod->pulse_number);
295  printf("%2d\n ",hd_decod->cell_size);
296  printf("%9.5f ",hd_decod->az_min);
297  printf("%9.5f ",hd_decod->az_max);
298  printf("%8.5f ",hd_decod->el_min);
299  printf("%8.5f\n ",hd_decod->el_max);
300  printf("%5.2f ",hd_decod->rot_vel);
301  printf("%2d ",hd_decod->filtro_clutter);
302  printf("%2d ",hd_decod->tipo_filtro);
303  printf("%2d ",hd_decod->anticlutter_mappato);
304  printf("%2d ",hd_decod->corr_clutter);
305  printf("%2d ",hd_decod->calibration_factor);
306  printf("%3d ",hd_decod->stalo_code);
307  printf("%3d ",hd_decod->num_ele);
308  printf("%3d\n ",hd_decod->corr_pot);
309  // ciclo sul numero di elementi significativi
310  for(i=0;i<hd_decod->num_ele;i++)
311  printf("%9.5f ",hd_decod->ele[i]);
312 
313  printf("\n");
314  return;
315 }
316 
317 
318 
319 /*===============================================*/
320 void PrintOldHeader (T_MDB_data_header *old_header)
321 /*===============================================*/
322 {
323  int i;
324 
325  printf("OLD HEADER :\n");
326  printf("%2d ", old_header->norm.maq.scans_type);
327  printf("%2d ", old_header->norm.maq.grand );
328  printf("%2d ", old_header->norm.maq.spare[0]);
329  printf("%2d ", old_header->norm.maq.vel_range);
330  printf("%2d ", old_header->norm.maq.imp_duration);
331  printf("%2d ", old_header->norm.maq.num_imp);
332  printf("%2d\n ", old_header->norm.maq.resolution);
333  printf("%5.2f ", old_header->norm.maq.rot_vel);
334  printf("%2d ", old_header->norm.maq.declutter_rsp);
335  printf("%2d ", old_header->norm.maq.filter_value);
336  printf("%2d ", old_header->norm.maq.type_declutter);
337  printf("%2d ", old_header->norm.maq.corr_Z);
338  printf("%2d ", old_header->norm.maq.num_el);
339 
340  printf("\n");
341 
342  for(i=0; i<old_header->norm.maq.num_el; i++)
343  {
344  printf("%9.5f ", old_header->norm.maq.value[i] * FATT_MOLT_EL);
345  }
346  printf("\n");
347 
348 }
349 
350 /*=============================================================
351  FINE HEADER DI VOLUME
352  =============================================================*/
353 
354 
355 
356 /*=============================================================
357  FORMATO BEAM
358  =============================================================*/
359 
360 /* ==================== */
361 short check_flag(unsigned char hd[])
362 /* ==================== */
363 {
364  if (hd[0]|hd[1]|hd[2])
365  return(-1);
366  return(0);
367 }
368 
369 /* ======================== */
370 short BCD_decoding(char byte)
371 /* ======================== */
372 {
373  unsigned char units,tenths;
374  units=byte&0x0f;
375  tenths=(byte>>4)&0x0f;
376  return ((short)(tenths*10+units));
377 }
378 
379 /* ====================== */
380 time_t get_date(unsigned char hd[], struct tm *tm_date)
381 /* ====================== */
382 {
383  time_t differenza = 10000;
384  time_t UTC_time;
385  // printf(" %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x \n", hd[24], hd[23], hd[22], hd[20], hd[19], hd[18]);
386 
387  tm_date->tm_year=BCD_decoding(hd[24]); /* Year */
388  if (tm_date->tm_year < 50)
389  tm_date->tm_year=tm_date->tm_year+100;
390 
391  tm_date->tm_mon=BCD_decoding(hd[23])-1; /* Month */
392  tm_date->tm_mday=BCD_decoding(hd[22]); /* Day */
393 
394  /*------
395  NON estraggo il dato ma lo ricalcolo con la funzione mktime
396  date->tm_wday=BCD_decoding(hd->week_day);
397  --------*/
398  tm_date->tm_hour=BCD_decoding(hd[20]); /* Hour */
399  tm_date->tm_min=BCD_decoding(hd[19]); /* Minute */
400  tm_date->tm_sec=BCD_decoding(hd[18]); /* Second */
401 
402  /*------------
403  A questo punto riempio tutto la struttuta tm_date
404  ------------*/
405  tm_date->tm_isdst=0;
406  tm_date->tm_gmtoff=0;
407 
408  /*------------
409  chiamo la mktime
410  ------------*/
411  /* printf("--- %s\n",asctime(tm_date));*/
412 
413 
414  /*-----------------------------------------
415  calcolo la differenza tra l'ora locala della macchina su cui gira l'applicativo
416  e il fuso GMT perche' mktime() restituisce i secondi lavorando sul fuso orario locale
417  -----------------------------------------------*/
418  differenza = differenza-mktime(gmtime(&differenza));
419  UTC_time= mktime(tm_date)-differenza;
420  tm_date=gmtime(&UTC_time);
421 
422  return (UTC_time);
423 }
424 
425 
426 
427 
428 /* ====================== */
429 void get_asc_date(struct tm *tm_date, char *asc_date)
430 /* ====================== */
431 {
432  char *mese[12]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
433  //char *weekday[7]={"Mon","Tue","Wed","Thu","Fri","Sat","Sun"};
434  char *weekday[7]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
435 
436  sprintf(asc_date,"%s %s %2d %2.2d:%2.2d:%2.2d %4d",weekday[tm_date->tm_wday],
437  mese[tm_date->tm_mon],tm_date->tm_mday,tm_date->tm_hour,
438  tm_date->tm_min,tm_date->tm_sec,tm_date->tm_year+1900);
439  /* sprintf(asc_date,"%s %s %2d %2.2d:%2.2d:%2.2d %4d",weekday[tm_date->tm_wday-1],
440  mese[tm_date->tm_mon],tm_date->tm_mday,tm_date->tm_hour,
441  tm_date->tm_min,tm_date->tm_sec,tm_date->tm_year+1900);
442 */
443  return;
444 }
445 
446 
447 /* ============================ */
448 char check_data_validity(unsigned char hd[])
449 /* ============================ */
450 {
451  if ((hd[12]>>1)&0x01)
452  return('V');
453  return('N');
454 }
455 
456 /* ======================== */
457 short get_real_power(unsigned char hd[])
458 /* ======================== */
459 {
460  return((short)(hd[15]*4));
461 }
462 
463 /* ======================== */
464 short get_eval_power(unsigned char hd[])
465 /* ======================== */
466 {
467  return((short)(hd[16]*4));
468 }
469 
470 /* ====================== */
471 char get_scan_mode(unsigned char hd[])
472 /* ====================== */
473 {
474  switch ((hd[8]>>2)&0x03)
475  {
476  case 0:
477  return('V');
478 
479  case 1:
480  return('V');
481 
482  case 2:
483  return('A');
484 
485  case 3:
486  return('E');
487 
488  default:
489  return('?');
490  }
491 }
492 
493 
494 /* ======================= */
495 float get_elevation(unsigned char hd[])
496 /* ======================= */
497 {
498  return((float)((hd[5] |(hd[6] &0x1f)<<8 )*ACF));
499 // return((float)((hd[5] |(hd[6] &0x1f)<<8 )*ACF)/8.);
500 
501 }
502 
503 /* ===================== */
504 float get_azimuth(unsigned char hd[])
505 /* ===================== */
506 {
507  return((float)((hd[3] |(hd[4] &0x1f)<<8 )*ACF));
508 // return((float)((hd[3] |(hd[4] &0x1f)<<8 )*ACF)/8.);
509 }
510 
511 /* ================================== */
512 void get_quantities(unsigned char hd[], char quantities[5])
513 /* ================================== */
514 {
515  strcpy(quantities,"");
516  if (hd[9]&0x01)
517  strcat(quantities,"Z");
518  if ((hd[9]>>1)&0x01)
519  strcat(quantities,"D");
520  if ((hd[9]>>2)&0x01)
521  strcat(quantities,"V");
522  if ((hd[9]>>7)&0x01)
523  strcat(quantities,"S");
524  return;
525 }
526 
527 /* ================================== */
528 void get_flag_quantities(unsigned char hd[], char flag_quantities[])
529 /* ================================== */
530 {
531  /* Z */
532  flag_quantities[0]=hd[9]&0x01;
533 
534  /* ZDR */
535  flag_quantities[1]=(hd[9]>>1)&0x01;
536 
537  /* V */
538  flag_quantities[2]=(hd[9]>>2)&0x01;
539 
540  /* sigma V */
541  flag_quantities[3]=(hd[9]>>7)&0x01;
542 
543  return;
544 }
545 
546 /* ===================== */
547 int check_dualPRF(unsigned char hd[])
548 /* ===================== */
549 {
550  return ((hd[9]>>3)&0x01);
551 }
552 
553 /* ==================== */
554 char get_Z_range(unsigned char hd[])
555 /* ==================== */
556 {
557  switch (hd[14]&0x03)
558  {
559  case 0:
560  return('M');
561 
562  case 1:
563  return('H');
564 
565  case 2:
566  return('L');
567 
568  default:
569  return('?');
570  }
571 }
572 
573 /* ====================== */
574 char get_pulse_len(unsigned char hd[])
575 /* ====================== */
576 {
577  switch (hd[8]&0x03)
578  {
579  case 0:
580  return('L');
581 
582  case 1:
583  return('M');
584 
585  case 2:
586  return('S');
587 
588  default:
589  return('?');
590  }
591 }
592 
593 /* ========================== */
594  short get_pulse_num(unsigned char hd[])
595 /* ========================== */
596 {
597  return((short)(hd[13] |(hd[14]>>6 &0x03)<<8 ));
598 }
599 
600 /* ====================== */
601  char get_cell_size(unsigned char hd[])
602 /* ====================== */
603 {
604  return((hd[9]>>4)&0x07);
605 }
606 
607 /* ====================== */
608  short get_cell_num(unsigned char hd[])
609 /* ====================== */
610 {
611  return((short)(hd[10] |(hd[11]>>6 &0x03)<<8 ));
612 }
613 
614 /* ====================== */
615  char get_channel(unsigned char hd[])
616 /* ====================== */
617 {
618  return((hd[11]>>3)&0x07);
619 }
620 
621 /* =========================================== */
622  void get_controller_identity(unsigned char hd[], char controller[4])
623 /* =========================================== */
624 {
625  switch ((hd[8]>>5)&0x03)
626  {
627  case 0:
628  strcpy(controller,"LOC");
629  break;
630  case 1:
631  strcpy(controller,"RM1");
632  break;
633  case 2:
634  strcpy(controller,"RM2");
635  break;
636  default:
637  strcpy(controller,"ERR");
638  }
639  return;
640 }
641 
642 /* =========================================== */
643 char get_filtro_clutter(unsigned char *hd)
644 /* =========================================== */
645 {
646  return((hd[12]>>7)&0x01);
647 }
648 
649 /* =========================================== */
650 char get_tipo_filtro(unsigned char *hd)
651 /* =========================================== */
652 {
653  return((hd[12]>>2)&0x0f);
654 }
655 
656 /* =========================================== */
657 char get_anticlutter_mappato(unsigned char *hd)
658 /* =========================================== */
659 {
660  return(hd[12]&0x01);
661 }
662 
663 /* =========================================== */
664 char get_corr_clutter(unsigned char *hd)
665 /* =========================================== */
666 {
667  return((hd[12]>>6)&0x01);
668 }
669 
670 
671 /* ================================= */
672 BEAM_HD_SP20_INFO * decode_header_sp20(unsigned char* hd_char, BEAM_HD_SP20_INFO *beam_info) //info=beam_info
673 /* ================================= */
674 {
675  char quantities[5];
676  char controller[4];
677 
678  beam_info->time=get_date(hd_char,&(beam_info->tm_date));
679  /*-----------------------------
680  Nota - PPA - 29/09/2009
681 non sappiamo perchè ma la get_date_from_name mi restituisce la struttura tm_date errata.
682 La ricalcoliamo dal tempo in secondi
683 ----------------------------------------*/
684  memcpy(&(beam_info->tm_date),gmtime(&beam_info->time),sizeof(beam_info->tm_date));
685  get_asc_date(&(beam_info->tm_date),&(beam_info->date[0]));
686 
687  beam_info->valid_data=check_data_validity(hd_char);
688 
689  beam_info->real_power=get_real_power(hd_char);
690 
691  beam_info->eval_power=get_eval_power(hd_char);
692 
693  beam_info->scan_mode=get_scan_mode(hd_char);
694 
695 
696  beam_info->azimuth=get_azimuth(hd_char);
697 
698  beam_info->elevation=get_elevation(hd_char);
699 
700  get_quantities(hd_char,quantities);
701 
702  strcpy(beam_info->quantities,quantities);
703 
704  get_flag_quantities(hd_char, beam_info->flag_quantities);
705 
706 
707  beam_info->Z_range=get_Z_range(hd_char);
708 
709  beam_info->pulse_lenght=get_pulse_len(hd_char);
710 
711  beam_info->pulse_number=get_pulse_num(hd_char);
712 
713  beam_info->cell_size=get_cell_size(hd_char);
714 
715  beam_info->cell_num=get_cell_num(hd_char);
716 
717  beam_info->channel=get_channel(hd_char);
718 
719 
720  get_controller_identity(hd_char,controller);
721 
722  strcpy(beam_info->controller,controller);
723 
724  if (check_dualPRF(hd_char))
725  beam_info->PRF='D';
726  else
727  beam_info->PRF='S';
728 
729 
730  beam_info->filtro_clutter=get_filtro_clutter(hd_char);
731  beam_info->tipo_filtro=get_tipo_filtro(hd_char);
732  beam_info->anticlutter_mappato=get_anticlutter_mappato(hd_char);
733 
734  beam_info->corr_clutter=get_corr_clutter(hd_char);
735 
736 
737  return(beam_info);
738 }
739 
740 
741 /* ================================= */
742 BEAM_HD_SP20_INFO * decode_header_sp20_date_real_eo_name(unsigned char *hd_char, BEAM_HD_SP20_INFO *beam_info, char *nome_file)
743 /* ================================= */
744 {
745 
746  char quantities[5];
747  char controller[4];
748 
749 
750  beam_info->time=get_date(hd_char,&(beam_info->tm_date));
751  if (beam_info->time == -1)
752  beam_info->time=get_date_from_name((T_MDB_data_header*)hd_char,&(beam_info->tm_date),nome_file);
753  /*-----------------------------
754  Nota - PPA - 29/09/2009
755 non sappiamo perchè ma la get_date_from_name mi restituisce la struttura tm_date errata.
756 La ricalcoliamo dal tempo in secondi
757 ----------------------------------------*/
758  memcpy(&(beam_info->tm_date),gmtime(&beam_info->time),sizeof(beam_info->tm_date));
759 
760  get_asc_date(&(beam_info->tm_date),&(beam_info->date[0]));
761  beam_info->valid_data=check_data_validity(hd_char);
762  beam_info->real_power=get_real_power(hd_char);
763  beam_info->eval_power=get_eval_power(hd_char);
764  beam_info->scan_mode=get_scan_mode(hd_char);
765 
766  beam_info->azimuth=get_azimuth(hd_char);
767  beam_info->elevation=get_elevation(hd_char);
768 
769  get_quantities(hd_char,quantities);
770  strcpy(beam_info->quantities,quantities);
771  get_flag_quantities(hd_char, beam_info->flag_quantities);
772 
773  beam_info->Z_range=get_Z_range(hd_char);
774  beam_info->pulse_lenght=get_pulse_len(hd_char);
775  beam_info->pulse_number=get_pulse_num(hd_char);
776  beam_info->cell_size=get_cell_size(hd_char);
777  beam_info->cell_num=get_cell_num(hd_char);
778  beam_info->channel=get_channel(hd_char);
779 
780  get_controller_identity(hd_char,controller);
781  strcpy(beam_info->controller,controller);
782  if (check_dualPRF(hd_char))
783  beam_info->PRF='D';
784  else
785  beam_info->PRF='S';
786 
787  beam_info->filtro_clutter=get_filtro_clutter(hd_char);
788  beam_info->tipo_filtro=get_tipo_filtro(hd_char);
789  beam_info->anticlutter_mappato=get_anticlutter_mappato(hd_char);
790  beam_info->corr_clutter=get_corr_clutter(hd_char);
791 
792  return(beam_info);
793 }
794 
795 /* ================================= */
796 BEAM_HD_SP20_INFO * decode_header_sp20_date_from_name(unsigned char *hd_char, BEAM_HD_SP20_INFO *beam_info, char *nome_file)
797 /* ================================= */
798 {
799 
800  char quantities[5];
801  char controller[4];
802 
803  /*
804  printf(" prima get_date_from_name --- ") ;
805  printf("%2d %2d %4d %2d %2d\n",
806  beam_info->tm_date.tm_mday,beam_info->tm_date.tm_mon,beam_info->tm_date.tm_year,
807  beam_info->tm_date.tm_hour,beam_info->tm_date.tm_min);
808  */
809 
810  beam_info->time=get_date_from_name((T_MDB_data_header*)hd_char,&(beam_info->tm_date),nome_file);
811 
812 /* printf(" dopo get_date_from_name --- ") ;
813  printf("%2d %2d %4d %2d %2d\n",
814  beam_info->tm_date.tm_mday,beam_info->tm_date.tm_mon,beam_info->tm_date.tm_year,
815  beam_info->tm_date.tm_hour,beam_info->tm_date.tm_min);
816 */
817  /*-----------------------------
818  Nota - PPA - 29/09/2009
819 non sappiamo perchè ma la get_date_from_name mi restituisce la struttura tm_date errata.
820 La ricalcoliamo dal tempo in secondi
821 ----------------------------------------*/
822  memcpy(&(beam_info->tm_date),gmtime(&beam_info->time),sizeof(beam_info->tm_date));
823  /* printf(" dopo get_date_from_name --- ") ;
824  printf("%2d %2d %4d %2d %2d - %2d\n",
825  beam_info->tm_date.tm_mday,beam_info->tm_date.tm_mon,beam_info->tm_date.tm_year,
826  beam_info->tm_date.tm_hour,beam_info->tm_date.tm_min, beam_info->tm_date.tm_wday);
827 */
828  get_asc_date(&(beam_info->tm_date),&(beam_info->date[0]));
829 //printf(" data in chiaro -- %s\n", beam_info->date);
830  beam_info->valid_data=check_data_validity(hd_char);
831  beam_info->real_power=get_real_power(hd_char);
832  beam_info->eval_power=get_eval_power(hd_char);
833  beam_info->scan_mode=get_scan_mode(hd_char);
834 
835  beam_info->azimuth=get_azimuth(hd_char);
836  beam_info->elevation=get_elevation(hd_char);
837 
838  get_quantities(hd_char,quantities);
839  strcpy(beam_info->quantities,quantities);
840  get_flag_quantities(hd_char, beam_info->flag_quantities);
841 
842  beam_info->Z_range=get_Z_range(hd_char);
843  beam_info->pulse_lenght=get_pulse_len(hd_char);
844  beam_info->pulse_number=get_pulse_num(hd_char);
845  beam_info->cell_size=get_cell_size(hd_char);
846  beam_info->cell_num=get_cell_num(hd_char);
847  beam_info->channel=get_channel(hd_char);
848 
849  get_controller_identity(hd_char,controller);
850  strcpy(beam_info->controller,controller);
851  if (check_dualPRF(hd_char))
852  beam_info->PRF='D';
853  else
854  beam_info->PRF='S';
855 
856  beam_info->filtro_clutter=get_filtro_clutter(hd_char);
857  beam_info->tipo_filtro=get_tipo_filtro(hd_char);
858  beam_info->anticlutter_mappato=get_anticlutter_mappato(hd_char);
859  beam_info->corr_clutter=get_corr_clutter(hd_char);
860 
861  return(beam_info);
862 }
863 
864 /* ========================================= */
865 void PrintHeader(BEAM_HD_SP20_INFO *beam_info)
866 /* ========================================= */
867 {
868  printf("HEADER BEAM:\n");
869  printf("%s ",beam_info->date);
870  printf("%i ",beam_info->time);
871  printf("%c ",beam_info->scan_mode);
872  printf("%s ",beam_info->quantities);
873  printf("%c ",beam_info->Z_range);
874  printf("%c ",beam_info->PRF);
875  printf("%c ",beam_info->pulse_lenght);
876  printf("%i ",beam_info->pulse_number);
877  printf("%i ",beam_info->cell_size);
878  printf("%i ",beam_info->cell_num);
879  printf("%c ",beam_info->valid_data);
880  printf("%i ",beam_info->real_power);
881  printf("%i ",beam_info->eval_power);
882  printf("%9.5f ",beam_info->azimuth);
883  printf("%8.5f ",beam_info->elevation);
884  printf("%1d ",beam_info->channel);
885  printf("%2d ",beam_info->filtro_clutter);
886  printf("%2d ",beam_info->tipo_filtro);
887  printf("%2d ",beam_info->anticlutter_mappato);
888  printf("%2d ",beam_info->corr_clutter);
889 
890  printf("\n");
891  return;
892 }
893 
894 
895 /*=============================================================
896  FINE FORMATO BEAM
897  =============================================================*/
898 
899 
900 
901 
902