Elaboradar 0.1
Caricamento in corso...
Ricerca in corso...
Nessun risultato

◆ eval_classID_beam()

std::vector< unsigned char > radarelab::algo::Cleaner::eval_classID_beam ( const Eigen::VectorXd & beam_z,
const Eigen::VectorXd & beam_w,
const Eigen::VectorXd & beam_v,
const Eigen::VectorXd & beam_sd,
const Eigen::VectorXd & beam_sdray,
const Eigen::VectorXd & beam_sdaz,
int iray,
const string radar,
double v_ny,
const char * fuzzy_path ) const

Funzione che crea l'oggetto cleaner, lo inizializza, pulisce i dati e modifica il PolarScan di DBZH.

Parametri
[in,out]scan_Z- volume di DBZH
[in]scan_W- volume di WRAD
[in]scan_V- volume di V
[in]iel- indice elevazione solo per debug

Definizione alla linea 607 del file cleaner.cpp.

608{
609
610 const unsigned beam_size = beam_z.rows();
611 vector<unsigned char> res(beam_size, 0);
612 int Num_entries=0;
613 int Num_echoes = 5;
614 int Ntraps = 5; // 5 argomenti da passare a Trap : x1,x2,x3,x4,x5
615 //char *cwd = get_current_dir_name();
616 //string f_dir = cwd;
617 string f_dir = fuzzy_path;
618
619 //leggo matrice dei pesi
620 string fin_w = f_dir+"/matrix-"+radar+"-nozdr.txt";
621 vector<string> w_vector;
622 w_vector = read_matrix_from_txt(fin_w);
623 Num_entries = w_vector.size()/Num_echoes;
624
625 Matrix2D<double> Wij(Num_echoes,Num_entries);
626 for(int i=0;i<Num_echoes;i++){ //itero colonna
627 for(int j=0;j<Num_entries;j++){ //itero rriga
628 Wij(i,j) = stod( w_vector[i*Num_entries+j]);
629 }
630 }
631
632 //leggo matrice dei traps
633 string fin_t = f_dir+"/Trap-"+radar+"-nozdr.txt";
634 vector<string> t_vector;
635 t_vector = read_matrix_from_txt(fin_t);
636 double Traps[Num_entries][Num_echoes][Ntraps];
637 for(int i=0;i<Num_entries;i++){
638 for(int j=0;j<Num_echoes;j++){
639 for(int k=0;k<Ntraps;k++){
640 Traps[i][j][k] = stod( t_vector[i*(Num_echoes*Ntraps)+j*Num_echoes+k]);
641 //cout<<" Traps["<<i<<","<<j<<","<<k<<"]="<<Traps[i][j][k];
642 }
643 //cout<<endl;
644 }
645 //cout<<endl;
646 }
647 //------------------------------------------------------------------------
648
649 vector<unsigned> counter (Num_entries,0) ; // non sono sicura di cosa delle dimensioni di questo counter
650 for (unsigned ibin = 0; ibin < beam_size; ++ibin)
651 //for (unsigned ibin = 87*4; ibin < 87*4+12; ++ibin)
652 {
653 //printf(" %4d %4d %6.2f %6.2f %10.6f %10.6f %10.6f %10.6f %10.6f",iray,ibin , beam_z(ibin),beam_v(ibin),beam_w(ibin),beam_zdr(ibin),beam_sd(ibin),beam_sdray(ibin),beam_sdaz(ibin));
654 Matrix2D<double> Pij(Num_echoes,Num_entries);
655 Pij = Pij * 0.;
656 //cout<<Pij<<endl;
657 ArrayXd Class_WP(Num_echoes); // la dimensione di Class_WP deve essere Num_echoes, perchè alla fine ricavo un vettore con 6 valori, uno per ogni echo, passando per prodotto pesi prob
658 Class_WP.setZero();
659 if (beam_z(ibin) == Z_missing) {
660 unsigned ID=0;
661 res[ibin]=ID;
662 counter[ID]++;
663
664 continue;
665 }
666
667//eseguo un test unico per VRAD e WRAD e assegno tutte le prob assieme
668 if (beam_v(ibin) != bin_wind_magic_number ) { // VRAD
669 Pij(0,1)=trap(v_ny*Traps[0][0][0], v_ny*Traps[0][0][1], v_ny*Traps[0][0][2], v_ny*Traps[0][0][3], beam_v(ibin)); // METEO
670 double prob_v = trap (v_ny, v_ny, v_ny, v_ny, beam_v(ibin),v_ny);
671 //cout<<"prob_v computed: "<<prob_v<<endl;
672 //for(int e=1;e<Num_echoes;e++){ Pij(e,1) = prob_v };
673 Pij(1,1)=trap(Traps[0][1][0],Traps[0][1][1],Traps[0][1][2],Traps[0][1][3], beam_v(ibin)); // CLUTTER
674 Pij(2,1)=prob_v; // INTERF. Strong
675 Pij(3,1)=prob_v; // INTERF. Med.
676 Pij(4,1)=prob_v; // INTERF. Weak
677 } else {
678 Pij(0,1)=0.3; // METEO
679 Pij(1,1)=1.; // CLUTTER
680 Pij(2,1)=1.; // INTERF. Strong
681 Pij(3,1)=1.; // INTERF. Med.
682 Pij(4,1)=1.; // INTERF. Weak
683 }
684
685 // WRAD
686 Pij(0,2)= trap(Traps[1][0][0],Traps[1][0][1],Traps[1][0][2],Traps[1][0][3],beam_w(ibin)); // METEO
687 Pij(1,2)= trap(Traps[1][1][0],Traps[1][1][1],Traps[1][1][2],Traps[1][1][3],beam_w(ibin)); // CLUTTER
688 double prob_w = trap(Traps[1][2][0],Traps[1][2][1],Traps[1][2][2],Traps[1][2][3],beam_w(ibin));
689 Pij(2,2) = prob_w; // INTERF MULTIPLE
690 Pij(3,2) = prob_w; // INTERF. Med.
691 Pij(4,2) = prob_w; // INTERF. Weak
692
693// METEO
694 Pij(0,0) = trap(Traps[2][0][0],Traps[2][0][1],Traps[2][0][2],Traps[2][0][3],beam_z(ibin), Traps[2][0][4]); // Z
695 Pij(0,3) = trap (Traps[3][0][0],Traps[3][0][1],Traps[3][0][2],Traps[3][0][3], beam_sd(ibin)); // SD_2D
696 Pij(0,4) = trap (Traps[4][0][0],Traps[4][0][1],Traps[4][0][2],Traps[4][0][3], beam_sdray(ibin)); // SD_RAY
697 Pij(0,5) = trap (Traps[5][0][0],Traps[5][0][1],Traps[5][0][2],Traps[5][0][3], beam_sdaz(ibin)); // SD_AZ
698
699// CLUTTER
700 Pij(1,0) = trap (Traps[2][1][0],Traps[2][1][1],Traps[2][1][2],Traps[2][1][3], beam_z(ibin), Traps[2][1][4]); // Z
701 Pij(1,3) = trap (Traps[3][1][0],Traps[3][1][1],Traps[3][1][2],Traps[3][1][3], beam_sd(ibin)); // SD_2D
702 Pij(1,4) = trap (Traps[4][1][0],Traps[4][1][1],Traps[4][1][2],Traps[4][1][3], beam_sdray(ibin)); // SD_RAY
703 Pij(1,5) = trap (Traps[5][1][0],Traps[5][1][1],Traps[5][1][2],Traps[5][1][3], beam_sdaz(ibin)); // SD_AZ
704// INTERF. Strong
705 Pij(2,0) = trap(Traps[2][2][0],Traps[2][2][1],Traps[2][2][2],Traps[2][2][3],beam_z(ibin), Traps[2][2][4]); // Z
706 Pij(2,3) = trap (Traps[3][2][0],Traps[3][2][1],Traps[3][2][2],Traps[3][2][3], beam_sd(ibin)); // SD_2D
707 Pij(2,4) = trap (Traps[4][2][0],Traps[4][2][1],Traps[4][2][2],Traps[4][2][3], beam_sdray(ibin)); // SD_RAY
708 Pij(2,5) = trap (Traps[5][2][0],Traps[5][2][1],Traps[5][2][2],Traps[5][2][3], beam_sdaz(ibin)); // SD_AZ
709// INTERF. Med.
710 Pij(3,0) = trap(Traps[2][3][0],Traps[2][3][1],Traps[2][3][2],Traps[2][3][3],beam_z(ibin), Traps[2][3][4]); // Z
711 Pij(3,3) = trap (Traps[3][3][0],Traps[3][3][1],Traps[3][3][2],Traps[3][3][3], beam_sd(ibin)); // SD_2D
712 Pij(3,4) = trap (Traps[4][3][0],Traps[4][3][1],Traps[4][3][2],Traps[4][3][3], beam_sdray(ibin)); // SD_RAY
713 Pij(3,5) = trap (Traps[5][3][0],Traps[5][3][1],Traps[5][3][2],Traps[5][3][3], beam_sdaz(ibin)); // SD_AZ
714// INTERF. Weak
715 Pij(4,0) = trap(Traps[2][4][0],Traps[2][4][1],Traps[2][4][2],Traps[2][4][3],beam_z(ibin), Traps[2][4][4]); // Z
716 Pij(4,3) = trap (Traps[3][4][0],Traps[3][4][1],Traps[3][4][2],Traps[3][4][3], beam_sd(ibin)); // SD_2D
717 Pij(4,4) = trap (Traps[4][4][0],Traps[4][4][1],Traps[4][4][2],Traps[4][4][3], beam_sdray(ibin)); // SD_RAY
718 Pij(4,5) = trap (Traps[5][4][0],Traps[5][4][1],Traps[5][4][2],Traps[5][4][3], beam_sdaz(ibin)); // SD_AZ
719
720//---- fine calcolo probabilità
721// Calcolo classe appartenenza
722
723 Class_WP = ((Wij.array()*Pij.array()).matrix()*VectorXd::Ones(Num_entries)).array()/(Wij*VectorXd::Ones(Num_entries)).array();
724 unsigned i,ID;
725 Class_WP.maxCoeff(&i);
726 ID=i;
727 if (Class_WP(i) < 0.1 ) ID=5;
728 res[ibin]=ID;
729 //printf("ID %d \n",ID);
730 counter[ID]++;
731
732 }
733
734 return res;
735
736 }
double trap(double x1, double x2, double x3, double x4, double val, double x5=-9999.) const
Definition cleaner.cpp:1123
const double Z_missing
Valore dato mancante DBZH.
Definition cleaner.h:26
const double bin_wind_magic_number
valore magico per dati in formato SP20
Definition cleaner.h:29

Referenzia bin_wind_magic_number, trap(), e Z_missing.