Elaboradar  0.1
 Tutto Classi Namespace File Funzioni Variabili Tipi enumerati (enum) Gruppi
int elaboradar::CalcoloVPR::analyse_VPR ( float *  vpr_liq,
int *  snow,
float *  hliq 
)

funzione che analizza il profilo

analizza il profilo usando : la temperatura al suolo, la quota del massimo, e una funzione di interpolazione

Parametri
[out]vpr_liqvalore del profilo al livello liquido
[out]snowmatrice che indica se è presente neve o no secondo l'analisi fatta
[out]hliqquota del livello liquido
Restituisce
ier_ana valore che indica se tutto è andato a buon fine (0) o no (1)

Definizione alla linea 1099 del file cum_bac.cpp.

Referenzia elaboradar::CUM_BAC::date, elaboradar::CUM_BAC::logging_category, e radarelab::File::open().

1101 {
1102  int ier=1,ier_ana=0,liv0;
1103  char date[]="000000000000";
1104  struct tm *tempo;
1105  time_t Time;
1106 
1107  // ------------inizializzazione delle variabili ----------
1108 
1109  //strcpy(date,"000000000000");
1110 
1111  int tipo_profilo=-1;
1112  float v600sottobb=NODATAVPR;
1113  float v1000=NODATAVPR;
1114  float v1500=NODATAVPR;
1115  float vliq=NODATAVPR;
1116  float vhliquid=NODATAVPR;
1117  float vprmax=NODATAVPR;
1118  //*togliere gli ultimi tre*/;
1119 
1120  //ier_max=trovo_hvprmax(&hvprmax);
1121 
1122 
1123  if (t_ground == NODATAVPR) //1 se non ho nè T nè il massimo esco altrimenti tipo_profilo=0
1124  {
1125  LOG_WARN("non ho T,...");
1126 
1127  if ( ! ier_max ) {
1128  LOG_ERROR(" non ho trovato hvprmax, nè T, esco");
1129  return 1;
1130  }
1131  tipo_profilo=0;
1132  }
1133  else
1134  {
1135 
1136  if (t_ground >= T_MAX_ML+0.65*(float)(livmin+TCK_VPR/2)/100.){ //1 se T > T_MAX_ML e non ho il massimo esco
1137  if ( ! ier_max ) {
1138  LOG_ERROR(" temperatura alta e non ho trovato hvprmax, esco");
1139  return 1;
1140  }
1141  tipo_profilo=0;
1142  }
1143 
1144 
1145  // if (t_ground >= T_MAX_SN+0.65*(float)(livmin+TCK_VPR/2)/100 && t_ground < T_MAX_ML+0.65*(float)(livmin+TCK_VPR/2)/100. )
1146  if (t_ground >= T_MAX_SN && t_ground < T_MAX_ML+0.65*(float)(livmin+TCK_VPR/2)/100. )
1147  {
1148 
1149  if ( ier_max ) {
1150  LOG_INFO(" temperatura da scioglimento e massimo in quota");
1151  tipo_profilo=2;
1152  }
1153  else{
1154  LOG_ERROR(" temperatura da scioglimento ma superiore a temperatura max neve e non ho trovato hvprmax, esco");
1155  return 1;
1156  }
1157  // solo una scritta per descrivere cos'è accaduto
1158  liv0=livmin+HALF_BB;
1159  if (hvprmax > liv0) LOG_INFO(" il livello %i è sotto la Bright band, ma T bassa interpolo",livmin);
1160  else LOG_INFO(" il livello %i potrebbe essere dentro la Bright Band, interpolo",livmin);
1161 
1162  }
1163 
1164  //if (t_ground >= T_MIN_ML && t_ground < T_MAX_SN+0.65*(float)(livmin+TCK_VPR/2)/100.)
1165  if (t_ground < T_MAX_SN)
1166  {
1167  if ( ier_max ){
1168  LOG_INFO(" temperatura da neve o scioglimento e massimo in quota");
1169  tipo_profilo=2;
1170  }
1171  else {
1172  LOG_INFO(" temperatura da neve o scioglimento e massimo non trovato,neve , non interpolo");
1173  tipo_profilo=3;
1174  hvprmax=0;
1175  }
1176  }
1177 
1178  }
1179 
1180  // InterpolaVPR_NR iv;
1181  InterpolaVPR_GSL iv;
1182 
1183  switch
1184  (tipo_profilo)
1185  {
1186  case 0:
1187  case 1:
1188  case 2:
1189  ier=iv.interpola_VPR(vpr.val.data(), hvprmax, livmin);
1190  if (ier){
1191  LOG_INFO(" interpolazione fallita");
1192  switch (tipo_profilo)
1193  {
1194 
1195  /*Questo fallisce se la bright band non è al suolo (per evitare correzioni dannose in casi poco omogenei)*/
1196  case 0:
1197  case 1:
1198  ier_ana=1;
1199  *vpr_liq=NODATAVPR;
1200  *hliq=NODATAVPR;
1201  break;
1202  case 2:
1203  *vpr_liq=vpr.val[(hvprmax+1000)/TCK_VPR]*2.15;/*21 aprile 2008*/
1204  *hliq=0;
1205  break;
1206  }
1207  }
1208  else{
1209  LOG_INFO(" interpolazione eseguita con successo");
1210  //
1211  // stampa del profilo interpolato
1212  const char* vpr_arch = getenv("VPR_ARCH");
1213  if (!vpr_arch) throw runtime_error("VPR_ARCH is not defined");
1214  string fname(vpr_arch);
1215  fname += "_int";
1216  File file(logging_category);
1217  file.open(fname, "wt", "vpr interpolato");
1218  for (unsigned i = 0; i < NMAXLAYER; ++i)
1219  fprintf(file," %f \n", cum_bac.dbz.RtoDBZ(iv.vpr_int[i]));
1220 
1221  /*calcolo valore di riferimento di vpr_liq per l'acqua liquida nell'ipotesi che a[2]=quota_bright_band e a[2]-1.5*a[3]=quota acqua liquida*/
1222  if (tipo_profilo == 2 ) {
1223  *hliq=(iv.E-2.1*iv.G)*1000.;
1224  //lineargauss(a[2]-2.1*a[3], a, vpr_liq, dyda, ndata);
1225  if (*hliq<0)
1226  *hliq=0; /*con casi di bright band bassa.. cerco di correggere il più possibile*/
1227  *vpr_liq=vpr.val[(hvprmax+1000)/TCK_VPR]*2.15;
1228  }
1229  else {
1230  *hliq=(iv.E-2.1*iv.G)*1000.;
1231  //lineargauss(a[2]-2.1*a[3], a, vpr_liq, dyda, ndata);
1232  if ( *hliq > livmin) {
1233  *vpr_liq=vpr.val[(int)(*hliq/TCK_VPR)]; // ... SE HO IL VALORE VPR USO QUELLO.
1234  }
1235  else // altrimenti tengo il valore vpr neve + 6 dB* e metto tipo_profilo=2
1236  {
1237  if (*hliq<0) *hliq=0;
1238  tipo_profilo=2;
1239  //*vpr_liq=vpr.val[(hvprmax+1000)/TCK_VPR]*2.15;
1240  *vpr_liq=iv.C;
1241  }
1242  }
1243  }
1244  break;
1245  case 3:
1246  *snow=1;
1247  *vpr_liq=NODATAVPR;
1248  *hliq=NODATAVPR;
1249  break;
1250  }
1251  LOG_INFO("TIPO_PROFILO= %i vpr_liq %f hliq %f", tipo_profilo, *vpr_liq,*hliq );
1252 
1253 
1254  /* parte di stampa test vpr*/
1255 
1256  /* nome data */
1257  //definisco stringa data in modo predefinito
1258  Time = cum_bac.volume.load_info->acq_date;
1259  tempo = gmtime(&Time);
1260  sprintf(date,"%04d%02d%02d%02d%02d",tempo->tm_year+1900, tempo->tm_mon+1,
1261  tempo->tm_mday,tempo->tm_hour, tempo->tm_min);
1262  if (! ier ) {
1263  if(*hliq > livmin +200 )
1264  vhliquid=cum_bac.dbz.RtoDBZ(vpr.val[(int)(*hliq)/TCK_VPR]);
1265  vliq=cum_bac.dbz.RtoDBZ(*vpr_liq);
1266  }
1267  if (ier_max) {
1268  if ( hvprmax-600 >= livmin )
1269  v600sottobb=cum_bac.dbz.RtoDBZ(vpr.val[(hvprmax-600)/TCK_VPR]);
1270  if ((hvprmax+1000)/TCK_VPR < NMAXLAYER )
1271  v1000=cum_bac.dbz.RtoDBZ(vpr.val[(hvprmax+1000)/TCK_VPR]);
1272  if ((hvprmax+1500)/TCK_VPR < NMAXLAYER )
1273  v1500=cum_bac.dbz.RtoDBZ(vpr.val[(hvprmax+1500)/TCK_VPR]);
1274  vprmax=cum_bac.dbz.RtoDBZ(vpr.val[(hvprmax/TCK_VPR)]);
1275  }
1276 
1277  if (FILE* test_vpr=fopen(getenv("TEST_VPR"),"a+"))
1278  {
1279  fprintf(test_vpr,"%s %i %i -1 %f %f %f %f %f %f %f %f %f %f %f %f %f %f \n",date,hvprmax,tipo_profilo,iv.chisqfin,*hliq,vliq,vhliquid,v600sottobb,v1000+6,v1500+6,vprmax,iv.rmsefin,iv.B,iv.E,iv.G,iv.C,iv.F);
1280  fclose(test_vpr);
1281  }
1282 
1283  // fine parte di stampa test vpr
1284 
1285  //---SCRIVO ALTEZZA MASSIMO PER CLASSIFICAZIONE AL RUN SUCCESSIVO
1286 
1288  LOG_INFO("fatta scrittura hmax vpr = %d",hvprmax);
1289 
1290  return (ier_ana);
1291 }
Assets assets
others
Definition: cum_bac.h:88
radarelab::algo::DBZ dbz
????
Definition: cum_bac.h:107
void write_vpr_hmax(int hvprmax)
write in $VPR_HMAX the vpr peak&#39;s height.
Definition: assets.cpp:320
CUM_BAC & cum_bac
oggeto CUM_BAC di riferimento
Definition: cum_bac.h:227
std::shared_ptr< LoadInfo > load_info
Polar volume information.
Definition: volume.h:270
float t_ground
2m temperature
Definition: cum_bac.h:230
radarelab::Volume< double > & volume
Polar volume of Reflectivity.
Definition: cum_bac.h:103
int hvprmax
quota picco vpr
Definition: cum_bac.h:234
radarelab::algo::VPR vpr
Informa se il pixel è convettivo.
Definition: cum_bac.h:233
int ier_max
flag d&#39;errore su calcolo quota max
Definition: cum_bac.h:245
int livmin
quota livello minimo calcolato
Definition: cum_bac.h:240
Open a file taking its name from a given env variable.
Definition: utils.h:21