Elaboradar  0.1
 Tutto Classi Namespace File Funzioni Variabili Tipi enumerati (enum) Gruppi
bool elaboradar::Assets::read_archived_vpr ( const radarelab::algo::DBZ dbz,
time_t  time,
radarelab::algo::VPR &  vpr 
)

Try to read the archived VPR at time time.

Return false if the file was not found.

Definizione alla linea 345 del file assets.cpp.

Referenzia elaboradar::Site::name, e radarelab::File::open().

Referenziato da find_vpr0().

346 {
347  const char* dir = getenv("DIR_STORE_VPR"); //--questa non sarebbe una dir_arch più che store?... contesto il nome...
348  if (!dir) return false;
349 
350  struct tm t;
351  gmtime_r(&time, &t);
352 
353  char fname[64];
354  snprintf(fname, 64, "%04d%02d%02d%02d%02d_vpr_%s",
355  t.tm_year + 1900, t.tm_mon + 1, t.tm_mday,
356  t.tm_hour, t.tm_min, conf_site->name.c_str());
357 
358  string pathname = dir;
359  pathname += "/";
360  pathname += fname;
361 
362  File in(logging_category);
363  if (!in.open(pathname, "r", "archived VPR file"))
364  return false;
365 
366  // TODO: check the actual format of the file and make the parsing safe:
367  // currently if one of these strings is longer than 99, we crash or worse.
368  char stringa[100];
369  fscanf(in, " %s %s %s %s" ,stringa ,stringa,stringa,stringa);
370  for (unsigned ilay=0; ilay < vpr.size(); ++ilay){
371  float vpr_dbz;
372  long int ar;
373  int il;
374  fscanf(in, " %i %f %li", &il, &vpr_dbz, &ar); //---NB il file in archivio è in dBZ e contiene anche la quota----
375 
376  //---- converto in R il profilo vecchio--
377  if (vpr_dbz > 0)
378  {
379  vpr.val[ilay] = dbz.DBZtoR(vpr_dbz);
380  vpr.area[ilay] = ar;
381  }
382  else
383  vpr.val[ilay] = NODATAVPR;
384  }
385 
386  return true;
387 }
Open a file taking its name from a given env variable.
Definition: utils.h:21
std::string name
Nome sito radar.
Definition: site.h:29