IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 30, 2012, 1:46:12 PM (14 years ago)
Author:
eugene
Message:

merge changes from eam_branches/ipp-20120405

Location:
trunk
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/Ohana/src/libdvo/include/dvo.h

    r33779 r33963  
    6969  NAN_U_INT   = (signed int) 0xffffffff,
    7070} DVO_INT_NAN;
     71
     72// max path length
     73# define DVO_MAX_PATH 1024
    7174
    7275/* RegImage.flag values */
     
    453456float PhotdM (PhotCode *code, Average *average, SecFilt *secfilt);
    454457
     458float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt);
     459float PhotM20 (PhotCode *code, Average *average, SecFilt *secfilt);
     460float PhotM80 (PhotCode *code, Average *average, SecFilt *secfilt);
     461float PhotUCdist (PhotCode *code, Average *average, SecFilt *secfilt);
     462
    455463float PhotColorForCode (Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code);
    456464int PhotColor (Average *average, SecFilt *secfilt, Measure *measure, int c1, int c2, double *color);
     
    516524void dvo_catalog_test (Catalog *catalog, int halt);
    517525
     526int dvo_catalog_backup (Catalog *catalog, int primary);
     527int dvo_catalog_unlink_backup (Catalog *catalog, int primary);
     528
    518529/* catmode-specific APIs */
    519530int dvo_catalog_load_raw (Catalog *catalog, int VERBOSE);
  • trunk/Ohana/src/libdvo/include/dvodb.h

    r33649 r33963  
    3232      MAG_REF,
    3333      MAG_ERR,
     34      MAG_STDEV,
    3435      MAG_AVE_ERR,
    3536      MAG_PHOT_FLAGS,
     
    3738      MAG_NCODE,
    3839      MAG_NPHOT,
     40      MAG_20,
     41      MAG_80,
     42      MAG_UC_DIST,
    3943};
    4044
     
    327331
    328332int dbExtractAveragesInitTransform (CoordTransformSystem target);
     333int dbExtractAveragesInitAve (void);
    329334int dbExtractAveragesInit (void);
    330335
  • trunk/Ohana/src/libdvo/src/HostTable.c

    r33779 r33963  
    125125
    126126  for (i = 0; i < table->Nhosts; i++) {
    127     if (table->index[table->hosts[i].hostID] == -1) {
     127    if (table->index[table->hosts[i].hostID] != -1) {
    128128      fprintf (stderr, "error: duplicate hostID %d\n", table->hosts[i].hostID);
    129129      exit (1);
     
    168168
    169169    // find the host which has finished
    170     int j;
     170    int Nout, j;
    171171    int found = FALSE;
    172172    for (j = 0; j < table->Nhosts; j++) {
     
    180180      EmptyIOBuffer (&buffer, 100, table->hosts[j].stdio[HOST_STDOUT]);
    181181      fprintf (stderr, "--- stdout from %s ---\n", table->hosts[j].hostname);
    182       write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer);
     182      Nout = write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer);
     183      if (Nout != buffer.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); }
    183184      fprintf (stderr, "\n");
    184185         
     
    186187      EmptyIOBuffer (&buffer, 100, table->hosts[j].stdio[HOST_STDERR]);
    187188      fprintf (stderr, "--- stderr from %s ---\n", table->hosts[j].hostname);
    188       write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer);
     189      Nout = write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer);
     190      if (Nout != buffer.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); }
    189191      fprintf (stderr, "\n");
    190192      if (WIFEXITED(status)) {
     
    271273        // if (table->hosts[i].stdout.Nbuffer > 0x10000) {
    272274        if (table->hosts[i].stdout.Nbuffer > 0x1000) {
    273           int printHead = VERBOSE || table->hosts[i].stdout.Nbuffer;
    274           if (printHead) fprintf (stdout, "--- stdout from %s ---\n", table->hosts[i].hostname);
    275           write (STDOUT_FILENO, table->hosts[i].stdout.buffer, table->hosts[i].stdout.Nbuffer);
     275          int printHead = VERBOSE || (table->hosts[i].stdout.Nbuffer > 0);
     276          if (printHead) fprintf (stdout, "--- stdout from %s --- (%d bytes, v1)\n", table->hosts[i].hostname, table->hosts[i].stdout.Nbuffer);
     277          int Nout = write (STDOUT_FILENO, table->hosts[i].stdout.buffer, table->hosts[i].stdout.Nbuffer);
     278          if (Nout != table->hosts[i].stdout.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); }
    276279          FlushIOBuffer (&table->hosts[i].stdout);
    277280          if (printHead) fprintf (stdout, "\n");
     
    284287        // if (table->hosts[i].stderr.Nbuffer > 0x10000) {
    285288        if (table->hosts[i].stderr.Nbuffer > 0x1000) {
    286           int printHead = VERBOSE || table->hosts[i].stderr.Nbuffer;
    287           if (printHead) fprintf (stdout, "--- stderr from %s ---\n", table->hosts[i].hostname);
    288           write (STDOUT_FILENO, table->hosts[i].stderr.buffer, table->hosts[i].stderr.Nbuffer);
     289          int printHead = VERBOSE || (table->hosts[i].stderr.Nbuffer > 0);
     290          if (printHead) fprintf (stdout, "--- stderr from %s --- (%d bytes, v1)\n", table->hosts[i].hostname, table->hosts[i].stderr.Nbuffer);
     291          int Nout = write (STDOUT_FILENO, table->hosts[i].stderr.buffer, table->hosts[i].stderr.Nbuffer);
     292          if (Nout != table->hosts[i].stderr.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); }
    289293          FlushIOBuffer (&table->hosts[i].stderr);
    290294          if (printHead) fprintf (stdout, "\n");
     
    321325        // read stdout
    322326        int printHead;
    323         printHead = VERBOSE || host->stdout.Nbuffer;
     327        printHead = VERBOSE || (host->stdout.Nbuffer > 0);
    324328        EmptyIOBuffer (&host->stdout, 100, host->stdio[HOST_STDOUT]);
    325         if (printHead) fprintf (stdout, "--- stdout from %s ---\n", host->hostname);
    326         write (STDOUT_FILENO, host->stdout.buffer, host->stdout.Nbuffer);
     329        if (printHead) fprintf (stdout, "--- stdout from %s --- (%d bytes, v2)\n", host->hostname, host->stdout.Nbuffer);
     330        int Nout = write (STDOUT_FILENO, host->stdout.buffer, host->stdout.Nbuffer);
     331        if (Nout != host->stdout.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); }
    327332        FlushIOBuffer (&host->stdout);
    328333        if (printHead) fprintf (stdout, "\n");
    329334           
    330335        // read stderr
    331         printHead = VERBOSE || host->stderr.Nbuffer;
     336        printHead = VERBOSE || (host->stderr.Nbuffer > 0);
    332337        EmptyIOBuffer (&host->stderr, 100, host->stdio[HOST_STDERR]);
    333         if (printHead) fprintf (stdout, "--- stderr from %s ---\n", host->hostname);
    334         write (STDOUT_FILENO, host->stderr.buffer, host->stderr.Nbuffer);
     338        if (printHead) fprintf (stdout, "--- stderr from %s --- (%d bytes, v2)\n", host->hostname, host->stderr.Nbuffer);
     339        Nout = write (STDOUT_FILENO, host->stderr.buffer, host->stderr.Nbuffer);
     340        if (Nout != host->stderr.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); }
    335341        FlushIOBuffer (&host->stderr);
    336342        if (printHead) fprintf (stdout, "\n");
  • trunk/Ohana/src/libdvo/src/dbExtractAverages.c

    r33649 r33963  
    4040int dbExtractAveragesInit () {
    4141  GetTimeFormat (&TimeReference, &TimeFormat);
     42  return (TRUE);
     43}
     44
     45int dbExtractAveragesInitAve () {
    4246  haveGalactic = FALSE;
    4347  haveEcliptic = FALSE;
     
    200204          }
    201205          break;
     206        case MAG_STDEV:
     207          value.Flt = PhotMstdev (field->photcode, average, secfilt);
     208          break;
    202209        case MAG_PHOT_FLAGS:
    203210          if ((field->photcode->type == PHOT_REF) || (field->photcode->type == PHOT_DEP)) {
     
    226233          break;
    227234
     235        case MAG_20:
     236          value.Flt = PhotM20 (field->photcode, average, secfilt);
     237          break;
     238        case MAG_80:
     239          value.Flt = PhotM80 (field->photcode, average, secfilt);
     240          break;
     241        case MAG_UC_DIST:
     242          value.Flt = PhotUCdist (field->photcode, average, secfilt);
     243          break;
    228244      }
    229245      break;
  • trunk/Ohana/src/libdvo/src/dbFields.c

    r33649 r33963  
    4646  if (!strcasecmp (string, "ncode"))     return (MAG_NCODE);
    4747  if (!strcasecmp (string, "nphot"))     return (MAG_NPHOT);
     48  if (!strcasecmp (string, "stdev"))     return (MAG_STDEV);
     49  if (!strcasecmp (string, "20"))        return (MAG_20);
     50  if (!strcasecmp (string, "80"))        return (MAG_80);
     51  if (!strcasecmp (string, "ucdist"))    return (MAG_UC_DIST);
    4852  return (MAG_NONE);
    4953}
  • trunk/Ohana/src/libdvo/src/dvo_catalog.c

    r33649 r33963  
    211211 
    212212  if (!check_file_access (catalog[0].filename, BACKUP, READWRITE, VERBOSE)) {
    213     if (VERBOSE) fprintf (stderr, "no permission to access %s\n", catalog[0].filename);
     213    fprintf (stderr, "no permission to access %s\n", catalog[0].filename);
    214214    return (FALSE);
    215215  }
     
    219219  switch (dvo_catalog_lock (catalog, catalog[0].lockmode)) {
    220220  case DVO_CAT_OPEN_FAIL:
    221     if (VERBOSE) fprintf (stderr, "can't lock file %s\n", catalog[0].filename);
     221    fprintf (stderr, "can't lock file %s\n", catalog[0].filename);
    222222    return (FALSE);
    223223  case DVO_CAT_OPEN_OK:
    224224    if (!dvo_catalog_load (catalog, VERBOSE)) {
    225       if (VERBOSE) fprintf (stderr, "failure loading catalog\n");
     225      fprintf (stderr, "failure loading catalog\n");
    226226      return (FALSE);
    227227    }
    228228    if (!dvo_catalog_check (catalog, Nsecfilt, TRUE)) {
    229       if (VERBOSE) fprintf (stderr, "can't reduce number of secondary filters\n");
     229      fprintf (stderr, "can't reduce number of secondary filters\n");
    230230      return (FALSE);
    231231    }
     
    499499}
    500500
     501// make a backup of this catalog (including the measure, secfilt, and missing tables as needed)
     502int dvo_catalog_backup (Catalog *catalog, int primary) {
     503
     504  // skip empty cpt files
     505  if (primary && !catalog->Naves_disk) {
     506    return TRUE;
     507  }
     508
     509  char tmpfilename[DVO_MAX_PATH];
     510  int status = snprintf (tmpfilename, DVO_MAX_PATH, "%s~", catalog->filename);
     511  if (status >= DVO_MAX_PATH) {
     512    fprintf (stderr, "path name too long: %s\n", catalog->filename);
     513    return FALSE;
     514  }
     515     
     516  // unlock the catalog here (closes file as well) (also closes subcat files Measure, Secfilt, Missing)
     517  if (primary) {
     518    status = dvo_catalog_unlock (catalog);
     519    if (!status) {
     520      fprintf (stderr, "failed to unlock catalog %s\n", catalog->filename);
     521      return FALSE;
     522    }
     523  }
     524
     525  status = rename (catalog->filename, tmpfilename);
     526  if (status) {
     527    fprintf (stderr, "failed to rename catalog %s\n", catalog->filename);
     528    return FALSE;
     529  }
     530     
     531  // keep the same lockmode
     532  int lockmode = catalog->lockmode;
     533
     534  // lock the new catalog file here (re-opens file as well) (does NOT open/lock the subcat files)
     535  status = dvo_catalog_lock (catalog, lockmode);
     536  if (!status) {
     537    fprintf (stderr, "failed to lock new catalog file %s\n", catalog->filename);
     538    return FALSE;
     539  }
     540
     541  if (catalog[0].catmode == DVO_MODE_SPLIT) {
     542    if (catalog[0].measure_catalog != NULL) {
     543      if (!dvo_catalog_backup (catalog[0].measure_catalog, FALSE)) {
     544        return FALSE;
     545      }
     546    }
     547    if (catalog[0].missing_catalog != NULL) {
     548      if (!dvo_catalog_backup (catalog[0].missing_catalog, FALSE)) {
     549        return FALSE;
     550      }
     551    }
     552    if (catalog[0].secfilt_catalog != NULL) {
     553      if (!dvo_catalog_backup (catalog[0].secfilt_catalog, FALSE)) {
     554        return FALSE;
     555      }
     556    }
     557  }
     558  return TRUE;
     559}
     560
     561// make a backup of this catalog (including the measure, secfilt, and missing tables as needed)
     562int dvo_catalog_unlink_backup (Catalog *catalog, int primary) {
     563
     564  if (primary && !catalog->Naves_disk) {
     565    // skip empty files (empty when read, but output may not be empty)
     566    return TRUE;
     567  }
     568
     569  char tmpfilename[DVO_MAX_PATH];
     570  int status = snprintf (tmpfilename, DVO_MAX_PATH, "%s~", catalog->filename);
     571  if (status >= DVO_MAX_PATH) {
     572    fprintf (stderr, "path name too long: %s\n", catalog->filename);
     573    return FALSE;
     574  }
     575     
     576  status = unlink (tmpfilename);
     577  if (status) {
     578    fprintf (stderr, "failed to unlink catalog %s\n", catalog->filename);
     579    return FALSE;
     580  }
     581     
     582  if (catalog[0].catmode == DVO_MODE_SPLIT) {
     583    if (catalog[0].measure_catalog != NULL) {
     584      if (!dvo_catalog_unlink_backup (catalog[0].measure_catalog, FALSE)) {
     585        return FALSE;
     586      }
     587    }
     588    if (catalog[0].missing_catalog != NULL) {
     589      if (!dvo_catalog_unlink_backup (catalog[0].missing_catalog, FALSE)) {
     590        return FALSE;
     591      }
     592    }
     593    if (catalog[0].secfilt_catalog != NULL) {
     594      if (!dvo_catalog_unlink_backup (catalog[0].secfilt_catalog, FALSE)) {
     595        return FALSE;
     596      }
     597    }
     598  }
     599  return TRUE;
     600}
     601
  • trunk/Ohana/src/libdvo/src/dvo_catalog_split.c

    r33649 r33963  
    8080  // write PHU header
    8181  if (!gfits_fwrite_header  (catalog->f, &catalog->header)) {
    82     fprintf (stderr, "can't write primary header");
     82    fprintf (stderr, "can't write primary header\n");
    8383    return (FALSE);
    8484  }
     
    8787  gfits_create_matrix (&catalog->header, &matrix);
    8888  if (!gfits_fwrite_matrix  (catalog->f, &matrix)) {
    89     fprintf (stderr, "can't write primary matrix");
     89    fprintf (stderr, "can't write primary matrix\n");
    9090    gfits_free_matrix (&matrix);
    9191    return (FALSE);
     
    9595  // write the table data
    9696  if (!gfits_fwrite_ftable_range (catalog->f, ftable, start, Nrows, Ndisk, Ntotal)) {
    97     fprintf (stderr, "can't write table data");
     97    fprintf (stderr, "can't write table data\n");
    9898    return (FALSE);
    9999  }
  • trunk/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_1.c

    r33649 r33963  
    213213    // added in PS1_V3
    214214    out[i].Map         = 0;
     215    out[i].Mstdev      = 0;
    215216    out[i].ubercalDist = 0;
    216217 }
  • trunk/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c

    r33649 r33963  
    207207    // added in PS1_V3
    208208    out[i].Map         = 0;
     209    out[i].Mstdev      = 0;
    209210    out[i].ubercalDist = 0;
    210211 }
  • trunk/Ohana/src/libdvo/src/dvo_convert_PS1_REF.c

    r33649 r33963  
    167167    // added in PS1_V3
    168168    out[i].Map         = 0;
     169    out[i].Mstdev      = 0;
    169170    out[i].ubercalDist = 0;
    170171 }
  • trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V1.c

    r33649 r33963  
    211211    // added in PS1_V3
    212212    out[i].Map         = 0;
     213    out[i].Mstdev      = 0;
    213214    out[i].ubercalDist = 0;
    214215 }
  • trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V2.c

    r33649 r33963  
    214214    // added in PS1_V3
    215215    out[i].Map         = 0;
     216    out[i].Mstdev      = 0;
    216217    out[i].ubercalDist = 0;
    217218 }
  • trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V3.c

    r33649 r33963  
    212212    out[i].M_20        = in[i].M_20;     
    213213    out[i].M_80        = in[i].M_80;     
     214    out[i].Mstdev      = in[i].Mstdev;     
    214215    out[i].ubercalDist = in[i].ubercalDist;     
    215216 }
     
    234235    out[i].M_20        = in[i].M_20;     
    235236    out[i].M_80        = in[i].M_80;     
     237    out[i].Mstdev      = in[i].Mstdev;     
    236238    out[i].ubercalDist = in[i].ubercalDist;     
    237239  }
  • trunk/Ohana/src/libdvo/src/dvo_convert_elixir.c

    r33649 r33963  
    222222    // added in PS1_V3
    223223    out[i].Map         = 0;
     224    out[i].Mstdev      = 0;
    224225    out[i].ubercalDist = 0;
    225226  }
  • trunk/Ohana/src/libdvo/src/dvo_convert_loneos.c

    r33649 r33963  
    215215    // added in PS1_V3
    216216    out[i].Map         = 0;
     217    out[i].Mstdev      = 0;
    217218    out[i].ubercalDist = 0;
    218219  }
  • trunk/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c

    r33649 r33963  
    222222    // added in PS1_V3
    223223    out[i].Map         = 0;
     224    out[i].Mstdev      = 0;
    224225    out[i].ubercalDist = 0;
    225226 }
  • trunk/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c

    r33649 r33963  
    222222    // added in PS1_V3
    223223    out[i].Map         = 0;
     224    out[i].Mstdev      = 0;
    224225    out[i].ubercalDist = 0;
    225226 }
  • trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c

    r33649 r33963  
    476476}
    477477
     478float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt) {
     479
     480  int Ns;
     481  float Mstdev;
     482
     483  if (code == NULL) return NAN;
     484
     485  Ns = photcodes[0].hashNsec[code[0].code];
     486  Mstdev  = (Ns == -1) ? NAN : 0.001*secfilt[Ns].Mstdev;
     487  return (Mstdev);
     488}
     489
     490float PhotM20 (PhotCode *code, Average *average, SecFilt *secfilt) {
     491
     492  int Ns;
     493  float M20;
     494
     495  if (code == NULL) return NAN;
     496
     497  Ns = photcodes[0].hashNsec[code[0].code];
     498  M20  = (Ns == -1) ? NAN : 0.001*secfilt[Ns].M_20;
     499  return (M20);
     500}
     501
     502float PhotM80 (PhotCode *code, Average *average, SecFilt *secfilt) {
     503
     504  int Ns;
     505  float M80;
     506
     507  if (code == NULL) return NAN;
     508
     509  Ns = photcodes[0].hashNsec[code[0].code];
     510  M80  = (Ns == -1) ? NAN : 0.001*secfilt[Ns].M_80;
     511  return (M80);
     512}
     513
     514float PhotUCdist (PhotCode *code, Average *average, SecFilt *secfilt) {
     515
     516  int Ns;
     517  float Muc;
     518
     519  if (code == NULL) return NAN;
     520
     521  Ns = photcodes[0].hashNsec[code[0].code];
     522  Muc  = (Ns == -1) ? NAN : secfilt[Ns].ubercalDist;
     523  return (Muc);
     524}
     525
    478526// XXX return NAN or NAN_S_SHORT? (secfilt->Xm is short)
    479527float PhotXm (PhotCode *code, Average *average, SecFilt *secfilt) {
  • trunk/Ohana/src/libdvo/src/flatcorr_io.c

    r33649 r33963  
    185185float FlatCorrectionOffset (FlatCorrectionTable *flatcorr, int ID, int X, int Y) {
    186186
     187  if (!flatcorr) return 0.0;
     188
    187189  // validate the flat_id (not out of range?)
    188190  int seq = flatcorr->IDtoSeq[ID];
Note: See TracChangeset for help on using the changeset viewer.