IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 5, 2007, 3:29:29 PM (19 years ago)
Author:
eugene
Message:

importing updates from eam_branch_20071130

Location:
trunk/Ohana/src/dvosplit
Files:
11 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/dvosplit/src/dvosplit.c

    r15722 r15743  
    11# include "dvosplit.h"
    2 # define NROWS 100000 /* ~10MB per row for measures */
    32
     3// dvosplit (outlevel) [-region Rmin Rmax Dmin Dmax]
    44int main (int argc, char **argv) {
    55
    6   // USAGE: dvosplit (outlevel) [-region RA RA DEC DEC]
     6  int i, j, OUT_DEPTH;
     7  SkyTable *sky;
     8  SkyList *skylist, *outlist;
     9  Catalog incatalog, *outcatalogs;
     10  AveLinks *avelinks;
     11  char filename[256];
    712
    8   // the output catalog needs to inherit the SKY_DEPTH of the input catalog.
    9   // if the CATDIR/SkyTable.fits is not found, assume the HST layout (old default)
     13  SetSignals ();
     14  ConfigInit (&argc, argv);
     15  args (argc, argv);
     16
     17  OUT_DEPTH = atoi (argv[1]);
    1018
    1119  // load the sky table for the existing database
     
    1321  SkyTableSetFilenames (sky, CATDIR, "cpt");
    1422
    15   // XXX I should just be copying the input sky and setting the output names on that
    16   // load the sky table for the existing database, generate output names
    17   outsky = SkyTableLoadOptimal (CATDIR, NULL, NULL, SKY_DEPTH_HST, VERBOSE);
    18   SkyTableSetFilenames (outsky, OUTDIR, "cpt");
    19 
    2023  // get the list of populated regions
    21   skylist  = SkyListByPatch (sky, -1, &REGION);
     24  skylist  = SkyListByPatch (sky, -1, &UserPatch);
    2225 
    2326  for (i = 0; i < skylist[0].Nregions; i++) {
     
    2730    // if (current level == out level) skip: no action is needed
    2831    if (skylist[0].regions[i][0].depth >= OUT_DEPTH) continue;
    29 
    30     outlist = SkyListByPatch (outsky, OUT_DEPTH, skylist[0].regions[i]);
    3132
    3233    // set the parameters which guide catalog open/load/create
     
    4243
    4344    // skip empty input catalogs
    44     if (!incatalog.Nave_disk) {
     45    if (!incatalog.Naves_disk) {
    4546      dvo_catalog_unlock (&incatalog);
    4647      dvo_catalog_free (&incatalog);
     
    4849    }
    4950
    50     outcatalog = SkyTableSubdivide (&incatalog, &Noutcatalog);
     51    // change sky.regions[i].depth for these regions
     52    outlist = SkyListByPatch (sky, OUT_DEPTH, skylist[0].regions[i]);
    5153
    52     // split out the average entries:
    53     incatalog.catflags = LOAD_AVES;
    54     Nblocks = incatalog.Nave_disk / NROWS;
    55     for (j = 0; j < Nblocks; j++) {
     54    outcatalogs = open_output_catalogs (outlist);
    5655
    57       // read up to NROWS at a time
    58       dvo_catalog_load_segment (&incatalog, VERBOSE, j*NROWS, NROWS);
     56    avelinks = split_averages (&incatalog, outlist, outcatalogs);
    5957
    60       for (k = 0; k < incatalog.Naverage; k++) {
    61         averef = j*NROWS + k;
    62        
    63         inR  = incatalog.average[k].R;
    64         inD = incatalog.average[k].D;
     58    split_measures (&incatalog, outlist, outcatalogs, avelinks);
    6559
    66         // which of the outcatalogs contains this coordinate?
     60    // XXX missing entries have to be reconstructed if they are desired
     61    // split_missings (&incatalog, outlist, outcatalogs, avelinks);
    6762
    68         N = -1;
    69         for (n = 0; n < Noutcatalog; n++) {
    70           if (inR < outregions[n].Rmin) continue;
    71           if (inR > outregions[n].Rmax) continue;
    72           if (inD < outregions[n].Dmin) continue;
    73           if (inD > outregions[n].Dmax) continue;
    74           Ncat = n;
    75           break;
    76         }
    77         if (Ncat == -1) continue;
     63    dvo_catalog_unlock (&incatalog);
    7864
    79         // XXX this probably needs to be Nave_disk so we can have partial saves
    80         Nout = outcatalog[Ncat].Naverage;
    81         outref[averef] = Nout;
    82         outcat[averef] = Ncat;
    83 
    84         outcatalog[Ncat].average[Nout] = incatalog.average[k];
    85         outcatalog[Ncat].Naverage++;
    86       }
    87 
    88       for (n = 0; n < Noutcatalog; n++) {
    89         dvo_catalog_save_segment (&outcatalog[Ncat], VERBOSE, outcatalog[Ncat].Nave_disk, outcatalog[Ncat].Naverage);
    90       }
     65    for (j = 0; j < outlist[0].Nregions; j++) {
     66      dvo_catalog_unlock (&outcatalogs[j]);
    9167    }
    9268
    93     // split out the measure entries:
    94     incatalog.catflags = LOAD_MEAS;
    95     Nblocks = incatalog.Nmeas_disk / NROWS;
    96     for (j = 0; j < Nblocks; j++) {
    97 
    98       // read up to NROWS at a time
    99       dvo_catalog_load_segment (&incatalog, VERBOSE, j*NROWS, NROWS);
    100 
    101       for (k = 0; k < incatalog.Nmeasure; k++) {
    102 
    103         averef = incatalog.measure[k].averef;
    104         Ncat = outcat[averef];
    105 
    106         Nout = outcatalog[Ncat].Nmeasure;
    107         outcatalog[Ncat].measure[Nout] = incatalog.measure[k];
    108         outcatalog[Ncat].measure[Nout].averef = outref[averef];
    109         outcatalog[Ncat].Nmeasure++;
    110       }
    111 
    112       for (n = 0; n < Noutcatalog; n++) {
    113         dvo_catalog_save_segment (&outcatalog[N], VERBOSE, outcatalog[N].Nmeas_disk, outcatalog[N].Nmeasure);
    114       }
     69    // adjust depth
     70    skylist[0].regions[i][0].table = FALSE;
     71    for (j = 0; j < outlist[0].Nregions; j++) {
     72      outlist[0].regions[j][0].table = TRUE;
    11573    }
    11674
    117     // split out the secfilt entries:
    118     incatalog.catflags = LOAD_SECF;
    119     Nblocks = incatalog.Nsecfilt_disk / NROWS;
    120     for (j = 0; j < Nblocks; j++) {
     75  }
    12176
    122       // read up to NROWS at a time
    123       dvo_catalog_load_segment (&incatalog, VERBOSE, j*NROWS, NROWS);
     77  // save sky table copy
     78  sprintf (filename, "%s/SkyTable.fits", CATDIR);
     79  check_file_access (filename, FALSE, VERBOSE);
     80  if (!SkyTableSave (sky, filename)) {
     81    fprintf (stderr, "ERROR: failed to save sky table for %s\n", CATDIR);
     82    exit (1);
     83  }
    12484
    125       for (k = 0; k < incatalog.Naverage; k++) {
    126 
    127         averef = j*NROWS + k;
    128         Ncat = outcat[averef];
    129         Nout = outref[averef] * Nsecfilt;
    130 
    131         for (n = 0; n < Nsecfilt; n++) {
    132           outcatalog[Ncat].secfilt[Nout + n] = incatalog.measure[k*Nsecfilt + n];
    133         }
    134       }
    135 
    136       for (n = 0; n < Noutcatalog; n++) {
    137         dvo_catalog_save_segment (&outcatalog[N], VERBOSE, outcatalog[N].Nmeas_disk, outcatalog[N].Nmeasure);
    138       }
    139     }
    140 
     85  exit (0);
     86}
Note: See TracChangeset for help on using the changeset viewer.