IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15735


Ignore:
Timestamp:
Dec 5, 2007, 11:27:37 AM (18 years ago)
Author:
eugene
Message:

finish basic coding for dvosplit

Location:
branches/eam_branch_20071130/Ohana/src/dvosplit
Files:
5 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20071130/Ohana/src/dvosplit/src/dvosplit.c

    r15729 r15735  
    11# include "dvosplit.h"
    22
     3// dvosplit (outlevel) [-region Rmin Rmax Dmin Dmax]
    34int main (int argc, char **argv) {
    45
    5   // 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];
    612
    7   // the output catalog needs to inherit the SKY_DEPTH of the input catalog.
    8   // if the CATDIR/SkyTable.fits is not found, assume the HST layout (old default)
     13  SetSignals ();
     14  ConfigInit (&argc, argv);
     15  args (argc, argv);
    916
    10   // force the output to have SPLIT mode?
     17  OUT_DEPTH = atoi (argv[1]);
    1118
    1219  // load the sky table for the existing database
     
    1421  SkyTableSetFilenames (sky, CATDIR, "cpt");
    1522
    16   // XXX I should just be copying the input sky and setting the output names on that
    17   // load the sky table for the existing database, generate output names
    18   outsky = SkyTableLoadOptimal (CATDIR, NULL, NULL, SKY_DEPTH_HST, VERBOSE);
    19   SkyTableSetFilenames (outsky, OUTDIR, "cpt");
    20 
    2123  // get the list of populated regions
    22   skylist  = SkyListByPatch (sky, -1, &REGION);
     24  skylist  = SkyListByPatch (sky, -1, &UserPatch);
    2325 
    2426  for (i = 0; i < skylist[0].Nregions; i++) {
     
    2830    // if (current level == out level) skip: no action is needed
    2931    if (skylist[0].regions[i][0].depth >= OUT_DEPTH) continue;
    30     // XXX : we need to copy these files to their new names
    3132
    3233    // set the parameters which guide catalog open/load/create
     
    4849    }
    4950
    50     // change outsky.regions[i].depth for these regions
    51     outlist = SkyListByPatch (outsky, OUT_DEPTH, skylist[0].regions[i]);
     51    // change sky.regions[i].depth for these regions
     52    outlist = SkyListByPatch (sky, OUT_DEPTH, skylist[0].regions[i]);
    5253
    5354    outcatalogs = open_output_catalogs (outlist);
     
    6061    // split_missings (&incatalog, outlist, outcatalogs, avelinks);
    6162
    62     dvo_catalog_close (&incatalog);
     63    dvo_catalog_unlock (&incatalog);
    6364
    6465    for (j = 0; j < outlist[0].Nregions; j++) {
    65       dvo_catalog_close (&outcatalogs[j]);
     66      dvo_catalog_unlock (&outcatalogs[j]);
    6667    }
     68
     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;
     73    }
     74
    6775  }
     76
     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  }
     84
    6885  exit (0);
    6986}
  • branches/eam_branch_20071130/Ohana/src/dvosplit/src/open_output_catalogs.c

    r15729 r15735  
    33Catalog *open_output_catalogs (SkyList *outlist) {
    44
     5  int i;
    56  Catalog *outcatalogs;
    67
     
    1112   
    1213    // set the parameters which guide catalog open/load/create
    13     outcatalogs[i].filename = skylist[0].filename[i];
    14     outcatalogs[i].Nsecfilt = GetPhotcodeNsecfilt ();
    15     outcatalogs[i].catflags = LOAD_NONE;
     14    outcatalogs[i].filename  = outlist[0].filename[i];
     15    outcatalogs[i].Nsecfilt  = GetPhotcodeNsecfilt ();
     16    outcatalogs[i].catflags  = LOAD_NONE;
     17    outcatalogs[i].catformat = dvo_catalog_catformat (CATFORMAT);  // set the default catformat from config data
     18    outcatalogs[i].catmode   = dvo_catalog_catmode (CATMODE);      // set the default catmode from config data
    1619
    1720    if (!dvo_catalog_open (&outcatalogs[i], outlist[0].regions[i], VERBOSE, "w")) {
  • branches/eam_branch_20071130/Ohana/src/dvosplit/src/split_averages.c

    r15732 r15735  
    55
    66  double inR, inD;
    7   int block, ave, cat, Nblocks, Ncat, Nout;
     7  int n, block, ave, cat, averef, Nblocks, Ncat, Nout, Nsecfilt;
    88  int *outref, *outcat;
    99  AveLinks *avelinks;
     
    1717  // contains primary photcodes, which will increase Nsecfilt by one.
    1818  for (cat = 0; cat < outlist[0].Nregions; cat++) {
    19     REALLOCATE (outcatalog[cat].average, Average, NROWS);
    20     REALLOCATE (outcatalog[cat].secfilt, SecFilt, NROWS*(Nsecfilt + 1));
     19    REALLOCATE (outcatalogs[cat].average, Average, NROWS);
     20    REALLOCATE (outcatalogs[cat].secfilt, SecFilt, NROWS*(Nsecfilt + 1));
    2121  }
    2222
     
    2727
    2828    // read up to NROWS at a time
    29     dvo_catalog_load_segment (&incatalog, VERBOSE, block*NROWS, NROWS);
    30     assert (block*NROWS == incatalogs[0].Naves_off);
     29    dvo_catalog_load_segment (incatalog, VERBOSE, block*NROWS, NROWS);
     30    assert (block*NROWS == incatalog[0].Naves_off);
    3131
    3232    for (ave = 0; ave < incatalog[0].Naverage; ave++) {
     
    5353      }
    5454
    55       Nout = outcatalog[Ncat].Naverage;
    56       outref[averef] = Nout + outcatalog[Ncat].Naves_off;
     55      Nout = outcatalogs[Ncat].Naverage;
     56      outref[averef] = Nout + outcatalogs[Ncat].Naves_off;
    5757      outcat[averef] = Ncat;
    5858
    5959      // assign the value to the next element of the output catalog
    60       outcatalog[Ncat].average[Nout] = incatalog[0].average[k];
    61       outcatalog[Ncat].Naverage++;
     60      outcatalogs[Ncat].average[Nout] = incatalog[0].average[ave];
     61      outcatalogs[Ncat].Naverage ++;
    6262
    6363      // update secfilt at the same time
    6464      for (n = 0; n < Nsecfilt; n++) {
    65         outcatalog[Ncat].secfilt[Nout*Nsecfilt + n] = incatalog[0].secfilt[ave*Nsecfilt + n];
    66         outcatalog[Ncat].Nsecf_mem++;
     65        outcatalogs[Ncat].secfilt[Nout*Nsecfilt + n] = incatalog[0].secfilt[ave*Nsecfilt + n];
     66        outcatalogs[Ncat].Nsecf_mem++;
    6767      }
    6868    }
     
    7272    // write out the new values
    7373    for (cat = 0; cat < outlist[0].Nregions; cat++) {
    74       outcatalog[cat].catflags = LOAD_AVES | LOAD_SECF;
    75       dvo_catalog_save_segment (&outcatalog[cat], VERBOSE);
     74      outcatalogs[cat].catflags = LOAD_AVES | LOAD_SECF;
     75      dvo_catalog_save (&outcatalogs[cat], VERBOSE);
    7676
    7777      // XXX I need to advance the pointers and free the current data
    7878      // XXX these should be done within save segment:
    79       outcatalog[cat].Naves_disk += outcatalog[cat].Naverage;
    80       outcatalog[cat].Naves_off  += outcatalog[cat].Naverage;
    81       outcatalog[cat].Naverage    = 0;
     79      outcatalogs[cat].Naves_disk += outcatalogs[cat].Naverage;
     80      outcatalogs[cat].Naves_off  += outcatalogs[cat].Naverage;
     81      outcatalogs[cat].Naverage    = 0;
    8282
    83       outcatalog[cat].Nsecf_disk += Nsecfilt * outcatalog[cat].Naverage;
    84       outcatalog[cat].Nsecf_off  += Nsecfilt * outcatalog[cat].Naverage;
    85       outcatalog[cat].Nsecf_mem   = 0;
     83      outcatalogs[cat].Nsecf_disk += Nsecfilt * outcatalogs[cat].Naverage;
     84      outcatalogs[cat].Nsecf_off  += Nsecfilt * outcatalogs[cat].Naverage;
     85      outcatalogs[cat].Nsecf_mem   = 0;
    8686    }
    8787  }
  • branches/eam_branch_20071130/Ohana/src/dvosplit/src/split_measures.c

    r15729 r15735  
    44int split_measures (Catalog *incatalog, SkyList *outlist, Catalog *outcatalogs, AveLinks *avelinks) {
    55
     6  int block, meas, cat, Nblocks, Ncat, Nout, averef;
    67  int *outref, *outcat;
    78
     
    1112  // allocate enough space for the output buffer
    1213  for (cat = 0; cat < outlist[0].Nregions; cat++) {
    13     REALLOCATE (outcatalog[cat].measure, Measure, NROWS);
     14    REALLOCATE (outcatalogs[cat].measure, Measure, NROWS);
    1415  }
    1516
     
    2728      Ncat = outcat[averef];
    2829
    29       Nout = outcatalog[Ncat].Nmeasure;
    30       outcatalog[Ncat].measure[Nout] = incatalog[0].measure[meas];
    31       outcatalog[Ncat].measure[Nout].averef = outref[averef];
    32       outcatalog[Ncat].Nmeasure++;
     30      Nout = outcatalogs[Ncat].Nmeasure;
     31      outcatalogs[Ncat].measure[Nout] = incatalog[0].measure[meas];
     32      outcatalogs[Ncat].measure[Nout].averef = outref[averef];
     33      outcatalogs[Ncat].Nmeasure++;
    3334    }
    3435
    3536    for (cat = 0; cat < outlist[0].Nregions; cat++) {
    3637      outcatalogs[cat].catflags = LOAD_AVES | LOAD_SECF;
    37       dvo_catalog_save_segment (&outcatalog[cat], VERBOSE);
     38      dvo_catalog_save (&outcatalogs[cat], VERBOSE);
    3839
    39       outcatalog[cat].Nmeas_disk += outcatalog[cat].Nmeasure;
    40       outcatalog[cat].Nmeas_off  += outcatalog[cat].Nmeasure;
    41       outcatalog[cat].Nmeasure    = 0;
     40      outcatalogs[cat].Nmeas_disk += outcatalogs[cat].Nmeasure;
     41      outcatalogs[cat].Nmeas_off  += outcatalogs[cat].Nmeasure;
     42      outcatalogs[cat].Nmeasure    = 0;
    4243
    4344    }
Note: See TracChangeset for help on using the changeset viewer.