IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38594


Ignore:
Timestamp:
Jul 16, 2015, 8:21:43 AM (11 years ago)
Author:
eugene
Message:

update the loadXXX programs to replace Stars with Catalogs (some tests would be good!)

Location:
branches/eam_branches/ipp-20150625/Ohana/src/addstar
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150625/Ohana/src/addstar/Makefile

    r38593 r38594  
    3737mkcmf        : $(BIN)/mkcmf.$(ARCH)
    3838
    39 # programs in 'OTHERS' have not been updated since moving from Stars to Catalog as an internal carrier
    4039# programs in 'SERVER' use the client-server concept and are out of date
    4140
    42 INSTALL = addstar sedstar loadstarpar loadstarpar_client loadICRF loadICRF_client load2mass skycells mkcmf dumpskycells findskycell
    43 OTHERS  = loadwise loadtycho loadsupercos
     41INSTALL = addstar sedstar loadstarpar loadstarpar_client loadICRF loadICRF_client load2mass loadwise loadtycho loadsupercos skycells mkcmf dumpskycells findskycell
    4442SERVER  = addstar_client addstarc addstard addstart
    4543
    46 old: $(OTHERS)
    4744all: $(INSTALL)
    4845
     
    355352$(SRC)/ConfigInit.$(ARCH).o \
    356353$(SRC)/Shutdown.$(ARCH).o \
    357 $(SRC)/StarOps.$(ARCH).o \
    358354$(SRC)/find_matches_refstars.$(ARCH).o \
    359355$(SRC)/build_links.$(ARCH).o \
     
    372368$(SRC)/Shutdown.$(ARCH).o \
    373369$(SRC)/find_matches_closest_refstars.$(ARCH).o \
     370$(SRC)/replace_match.$(ARCH).o \
    374371$(SRC)/build_links.$(ARCH).o \
    375372$(SRC)/SetSignals.$(ARCH).o \
     
    387384$(SRC)/ConfigInit.$(ARCH).o \
    388385$(SRC)/Shutdown.$(ARCH).o \
    389 $(SRC)/StarOps.$(ARCH).o \
     386$(SRC)/SkyListForStars.$(ARCH).o \
    390387$(SRC)/find_matches_refstars.$(ARCH).o \
    391388$(SRC)/build_links.$(ARCH).o \
  • branches/eam_branches/ipp-20150625/Ohana/src/addstar/include/WISE.h

    r38062 r38594  
    3535int getWISE_sortStars (WISE_Stars *tstars, int Ntstars);
    3636
    37 int loadwise_star_prelim (Stars **star, char *line, int Nmax);
    38 int loadwise_star_allsky (Stars **star, char *line, int Nmax);
    39 int loadwise_star_allwise (Stars **star, char *line, int Nmax);
     37int loadwise_star_prelim  (Measure *measure, char *line, int Nmax);
     38int loadwise_star_allsky  (Measure *measure, char *line, int Nmax);
     39int loadwise_star_allwise (Measure *measure, char *line, int Nmax);
    4040
    4141
    4242char *nextWISEfield (char *line);
    43 int setWISE_cc_flag (Stars *star, char qual);
    44 int setWISE_ph_qual (Stars *star, char qual);
    45 int setWISE_rd_flag (Stars *star, char qual);
    46 int setWISE_bl_flag (Stars *star, char qual);
    47 int setWISE_gal_flag (Stars *star, char qual);
    48 int setWISE_mp_flag (Stars *star, char qual);
    49 int setWISE_dup_flag (Stars *star, char qual);
    50 int setWISE_use_flag (Stars *star, char qual);
     43int setWISE_cc_flag  (Measure *measure, char qual);
     44int setWISE_ph_qual  (Measure *measure, char qual);
     45int setWISE_rd_flag  (Measure *measure, char qual);
     46int setWISE_bl_flag  (Measure *measure, char qual);
     47int setWISE_gal_flag (Measure *measure, char qual);
     48int setWISE_mp_flag  (Measure *measure, char qual);
     49int setWISE_dup_flag (Measure *measure, char qual);
     50int setWISE_use_flag (Measure *measure, char qual);
    5151
    5252char *skipNbounds (char *line, char bound, int Nbound, int Nbyte);
  • branches/eam_branches/ipp-20150625/Ohana/src/addstar/include/supercos.h

    r33653 r38594  
    8080Image *loadsupercos_plates (Survey *survey, int Nsurvey, char *filename, int *nimage);
    8181int loadsupercos_getFilterInfo (char *line, char *emulsion, char *filterID);
    82 int loadsupercos_rawdata (Image *image, int *imlist, int Nimage, SkyList *skytable, char *filename, AddstarClientOptions options);
    83 int loadsupercos_sortStars (Stars *tstars, int Ntstars);
     82int loadsupercos_rawdata (Image *image, int *imlist, int Nimage, SkyTable *skytable, char *filename, AddstarClientOptions options);
    8483int *loadsupercos_image_index (Image *image, int Nimage);
    8584int loadsupercos_getST (char *line, double *st);
  • branches/eam_branches/ipp-20150625/Ohana/src/addstar/src/load2mass_as_rawdata.c

    r38593 r38594  
    1212int load2mass_as_rawdata (SkyList *skytable, char *filename, AddstarClientOptions options) {
    1313 
    14   int i, j, verbose;
     14  int i, j, k, verbose;
    1515  int Ntstars, NTSTARS;
    1616  int Nbyte, Nextra, offset;
     
    146146
    147147        dvo_average_init (&newcat->average[Nave]);
    148         dvo_measure_init (&newcat->measure[Nmeas+0]);
    149         dvo_measure_init (&newcat->measure[Nmeas+1]);
    150         dvo_measure_init (&newcat->measure[Nmeas+2]);
     148        for (k = 0; k < 4; k++) {
     149          dvo_measure_init (&newcat->measure[Nmeas+k]);
     150        }
    151151
    152152        newcat->average[Nave].R = tstars[j].R;
     
    174174      }
    175175
    176       if (DEBUG) fprintf (stderr, "selected %d stars (%10.6f - %10.6f, %10.6f - %10.6f)\n", (int) newcat->Naverage,
     176      if (DEBUG) fprintf (stderr, "selected %d stars (%10.6f - %10.6f, %10.6f - %10.6f)\n",
     177                          (int) newcat->Naverage,
    177178                          region[0].Rmin, region[0].Rmax, region[0].Dmin, region[0].Dmax);
    178179
  • branches/eam_branches/ipp-20150625/Ohana/src/addstar/src/loadsupercos.c

    r38441 r38594  
    1515  int i, status;
    1616  SkyTable *sky;
    17   SkyList *skylist = NULL;
    1817  AddstarClientOptions options;
    1918  FITS_DB db;
     
    2726  SkyTableSetFilenames (sky, CATDIR, "cpt");
    2827 
    29   // generate the subset matching the user-selected region
    30   skylist = SkyListByPatch (sky, -1, &UserPatch);
    31 
    32   // if we only match to existing (already populated) regions, limit the select to those regions:
    33   if (options.existing_regions) {
    34     SkyList *tmp;
    35     tmp = SkyListExistingSubset (skylist, CATDIR);
    36     SkyListFree (skylist);
    37     skylist = tmp;
    38   }
    39 
    4028  // load the images table (needed regardless)
    4129  int Nsurvey = 0;
     
    6856  for (i = 3; i < argc; i++) {
    6957      fprintf (stderr, "loading %s\n", argv[i]);
    70       loadsupercos_rawdata (image, imlist, Nimage, skylist, argv[i], options);
     58      loadsupercos_rawdata (image, imlist, Nimage, sky, argv[i], options);
    7159  }
    7260  exit (0);
  • branches/eam_branches/ipp-20150625/Ohana/src/addstar/src/loadsupercos_ops.c

    r37036 r38594  
    7979}
    8080
    81 int loadsupercos_sortStars (Stars *tstars, int Ntstars) {
    82 
    83 # define SWAPFUNC(A,B){ Stars temp = tstars[A]; tstars[A] = tstars[B]; tstars[B] = temp; }
    84 # define COMPARE(A,B)(tstars[A].average.R < tstars[B].average.R)
    85 
    86   OHANA_SORT (Ntstars, COMPARE, SWAPFUNC);
    87 
    88 # undef SWAPFUNC
    89 # undef COMPARE
    90  
    91   return TRUE;
    92 }
    93 
    9481int *loadsupercos_image_index (Image *image, int Nimage) {
    9582
  • branches/eam_branches/ipp-20150625/Ohana/src/addstar/src/loadsupercos_rawdata.c

    r38471 r38594  
    66# define DEBUG 0
    77
    8 int loadsupercos_rawdata (Image *image, int *imlist, int Nimage, SkyList *skytable, char *filename, AddstarClientOptions options) {
     8int loadsupercos_rawdata (Image *image, int *imlist, int Nimage, SkyTable *skytable, char *filename, AddstarClientOptions options) {
    99 
    10   int i, j, verbose;
    11   int Nstars, NSTARS, Nrecords;
     10  int i;
     11  int Nrecords;
    1212 
    1313  FILE *f;
     
    1515
    1616  Detection *sstars;
    17   Stars **stars, *tstars;
    18   SkyList *skylist;
    19   SkyRegion *region;
    2017  Catalog catalog;
    2118
     
    2623  if (f == NULL) Shutdown ("can't read the Supercosmos data file: %s", filename);
    2724
    28   ALLOCATE (tstars, Stars, NRECORDS);
    2925  ALLOCATE (sstars, Detection, NRECORDS);
    3026
     
    3329  double Dmin = +90.0;
    3430  double Dmax = -90.0;
     31
     32  Catalog *newcat = NULL;
     33  ALLOCATE (newcat, Catalog, 1);
     34  dvo_catalog_init (newcat, TRUE);
     35  ALLOCATE (newcat->average, Average, NRECORDS);
     36  ALLOCATE (newcat->measure, Measure, NRECORDS);
    3537
    3638  while ((Nrecords = fread (buffer, NBYTE, NRECORDS, f)) != 0) {
     
    6264    // convert to the Stars format
    6365    for (i = 0; i < Nrecords; i++) {
    64         InitStar (&tstars[i]);
    65         tstars[i].measure.Xccd = sstars[i].xCen;
    66         tstars[i].measure.Yccd = sstars[i].yCen;
    6766
    68         tstars[i].measure.M = sstars[i].sMag;
    69         tstars[i].measure.Map = sstars[i].gMag;
    70         tstars[i].measure.photFlags = sstars[i].class;
     67        dvo_average_init (&newcat->average[i]);
     68        dvo_measure_init (&newcat->measure[i]);
    7169
    72         tstars[i].average.R = sstars[i].ra;
    73         tstars[i].average.D = sstars[i].dec;
     70        newcat->measure[i].Xccd = sstars[i].xCen;
     71        newcat->measure[i].Yccd = sstars[i].yCen;
    7472
    75         tstars[i].measure.R = sstars[i].ra;
    76         tstars[i].measure.D = sstars[i].dec;
     73        newcat->measure[i].M = sstars[i].sMag;
     74        newcat->measure[i].Map = sstars[i].gMag;
     75        newcat->measure[i].photFlags = sstars[i].class;
     76
     77        newcat->average[i].R = sstars[i].ra;
     78        newcat->average[i].D = sstars[i].dec;
     79
     80        newcat->measure[i].R = sstars[i].ra;
     81        newcat->measure[i].D = sstars[i].dec;
    7782
    7883        int Ni = imlist[sstars[i].plateID];
     
    8085
    8186        // XXX fix these
    82         tstars[i].measure.Mcal = 0.0;
    83         tstars[i].measure.dt = image[Ni].exptime;
     87        newcat->measure[i].Mcal = 0.0;
     88        newcat->measure[i].dt = image[Ni].exptime;
    8489
    8590        double sidtime = image[Ni].sidtime;
     
    8792       
    8893        double alt, az;
    89         altaz (&alt, &az, 15.0*sidtime - tstars[i].average.R, tstars[i].average.D, latitude);
     94        altaz (&alt, &az, 15.0*sidtime - newcat->average[i].R, newcat->average[i].D, latitude);
    9095
    91         tstars[i].measure.airmass = 1.0 / cos(RAD_DEG*alt);
    92         tstars[i].measure.az = az;
    93         tstars[i].measure.t = image[Ni].tzero;
    94         tstars[i].measure.imageID = image[Ni].imageID;
    95         tstars[i].measure.photcode = image[Ni].photcode;
     96        newcat->measure[i].airmass = 1.0 / cos(RAD_DEG*alt);
     97        newcat->measure[i].az = az;
     98        newcat->measure[i].t = image[Ni].tzero;
     99        newcat->measure[i].imageID = image[Ni].imageID;
     100        newcat->measure[i].photcode = image[Ni].photcode;
    96101
    97         tstars[i].measure.FWx = ToShortPixels(sstars[i].aU);
    98         tstars[i].measure.FWy = ToShortPixels(sstars[i].bU);
    99         tstars[i].measure.theta = ToShortDegrees(sstars[i].thetaU);
     102        newcat->measure[i].FWx = ToShortPixels(sstars[i].aU);
     103        newcat->measure[i].FWy = ToShortPixels(sstars[i].bU);
     104        newcat->measure[i].theta = ToShortDegrees(sstars[i].thetaU);
    100105
    101         Rmin = MIN (Rmin, tstars[i].average.R);
    102         Rmax = MAX (Rmax, tstars[i].average.R);
    103         Dmin = MIN (Dmin, tstars[i].average.D);
    104         Dmax = MAX (Dmax, tstars[i].average.D);
     106        Rmin = MIN (Rmin, newcat->average[i].R);
     107        Rmax = MAX (Rmax, newcat->average[i].R);
     108        Dmin = MIN (Dmin, newcat->average[i].D);
     109        Dmax = MAX (Dmax, newcat->average[i].D);
    105110    }
    106111
    107112    if (VERBOSE) fprintf (stderr, "scan %d stars (%10.6f - %10.6f, %10.6f - %10.6f) .. ", Nrecords, Rmin, Rmax, Dmin, Dmax);
    108113
    109     // sort the tstars by RA
    110     loadsupercos_sortStars (tstars, Nrecords);
     114    SkyList *skylist = SkyListForStars (skytable, -1, newcat);
    111115
    112     // scan through the stars, loading the containing catalogs
    113     // skip through table for unsaved stars
    114     for (i = 0; i < Nrecords; i++) {
    115       if (tstars[i].found != -1) continue;
     116    for (i = 0; i < skylist[0].Nregions; i++) {
     117      // now we have all of the loaded stars in this catalog
     118      dvo_catalog_init (&catalog, TRUE);
     119      catalog.filename = skylist[0].filename[0];
     120      catalog.catformat = dvo_catalog_catformat (CATFORMAT);  // set the default catformat from config data
     121      catalog.catmode   = dvo_catalog_catmode (CATMODE);      // set the default catmode from config data
     122      catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT;
     123      catalog.Nsecfilt  = GetPhotcodeNsecfilt ();
    116124
    117       // scan forward until we reach the UserPatch (stars sorted by RA)
    118       if (tstars[i].average.R < UserPatch.Rmin) continue;
    119       if (tstars[i].average.R > UserPatch.Rmax) break;
    120       if (tstars[i].average.D < UserPatch.Dmin) continue;
    121       if (tstars[i].average.D > UserPatch.Dmax) continue;
    122 
    123       // identify the relevant catalog
    124       skylist = SkyRegionByPoint_List (skytable, -1, tstars[i].average.R, tstars[i].average.D);
    125       if (skylist[0].Nregions == 0) {
    126           SkyListFree (skylist);
    127           continue;
    128       }
    129       region = skylist[0].regions[0];
    130       if (DEBUG) fprintf (stderr, "writing to %s\n", skylist[0].filename[0]);
    131 
    132       int this_image_id = tstars[i].measure.imageID;
    133 
    134       // loop over stars in this WISE region that are also in this output region
    135       Nstars = 0;
    136       NSTARS = 1000;
    137       ALLOCATE (stars, Stars *, NSTARS);
    138 
    139       for (j = i; j < Nrecords; j++) {
    140         if (tstars[j].found != -1) continue;
    141 
    142         if (tstars[j].measure.imageID != this_image_id) continue;
    143 
    144         // check if in skyregion
    145         if (tstars[j].average.R < region[0].Rmin) continue;
    146         if (tstars[j].average.R > region[0].Rmax) break;
    147         if (tstars[j].average.D < region[0].Dmin) continue;
    148         if (tstars[j].average.D > region[0].Dmax) continue;
    149          
    150         // check if in UserPatch
    151         if (tstars[j].average.R < UserPatch.Rmin) continue;
    152         if (tstars[j].average.R > UserPatch.Rmax) break;
    153         if (tstars[j].average.D < UserPatch.Dmin) continue;
    154         if (tstars[j].average.D > UserPatch.Dmax) continue;
    155 
    156         stars[Nstars] = &tstars[j];
    157         Nstars ++;
    158 
    159         CHECK_REALLOCATE (stars, Stars *, NSTARS, Nstars, 1000);
    160       }
    161          
    162       if (DEBUG) fprintf (stderr, "selected %d stars (%10.6f - %10.6f, %10.6f - %10.6f)\n", Nstars,
    163                           region[0].Rmin, region[0].Rmax, region[0].Dmin, region[0].Dmax);
    164 
    165       if (1) {
    166         verbose = VERBOSE;
    167         VERBOSE = FALSE;
    168 
    169         // now we have all of the loaded stars in this catalog
    170         dvo_catalog_init (&catalog, TRUE);
    171         catalog.filename = skylist[0].filename[0];
    172         catalog.catformat = dvo_catalog_catformat (CATFORMAT);  // set the default catformat from config data
    173         catalog.catmode   = dvo_catalog_catmode (CATMODE);      // set the default catmode from config data
    174         catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT;
    175         catalog.Nsecfilt  = GetPhotcodeNsecfilt ();
    176 
    177         // an error exit status here is a significant error
    178         if (!dvo_catalog_open (&catalog, skylist[0].regions[0], VERBOSE, "w")) {
    179           fprintf (stderr, "ERROR: failure to open/create catalog file %s\n", catalog.filename);
    180           exit (2);
    181         }
    182 
    183         // assume no input star matches an existing star
    184         // simply add to the existing table
    185         // loadWISE_catalog (&catalog, stars, Nstars);
    186         find_matches_refstars (skylist[0].regions[0], stars, Nstars, &catalog, options);
    187         // loadWISE_catalog (&catalog, stars, Nstars);
    188 
    189         dvo_catalog_save (&catalog, VERBOSE);
    190         dvo_catalog_unlock (&catalog);
    191         dvo_catalog_free (&catalog);
    192         // free (catalog.filename);
    193         // XXX don't free this! it points to an element of the skytable
     125      // an error exit status here is a significant error
     126      if (!dvo_catalog_open (&catalog, skylist[0].regions[0], VERBOSE, "w")) {
     127        fprintf (stderr, "ERROR: failure to open/create catalog file %s\n", catalog.filename);
     128        exit (2);
    194129      }
    195130
    196       SkyListFree (skylist);
     131      // assume no input star matches an existing star
     132      // simply add to the existing table
     133      find_matches_refstars (skylist[0].regions[0], newcat, &catalog, options);
    197134
    198       free (stars);
    199       VERBOSE = verbose;
     135      dvo_catalog_save (&catalog, VERBOSE);
     136      dvo_catalog_unlock (&catalog);
     137      dvo_catalog_free (&catalog);
    200138    }
     139
     140    SkyListFree (skylist);
     141    dvo_catalog_free (newcat);
     142    free (newcat);
     143   
    201144    if (VERBOSE) fprintf (stderr, "done\n");
    202145  }
     
    204147  if (VERBOSE) fprintf (stderr, "\n");
    205148 
    206   free (tstars);
    207149  free (sstars);
    208150
     
    225167*/
    226168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
  • branches/eam_branches/ipp-20150625/Ohana/src/addstar/src/loadtycho_rawdata.c

    r38471 r38594  
    2222
    2323  Tycho_Stars *tstars;
    24   Stars *stars, **starrefs; // this is an array of pointers to be consistent with input to find_match_refstars
    2524  SkyList *skylist;
    2625  SkyRegion *region;
     
    8786      if (DEBUG) fprintf (stderr, "writing to %s\n", skylist[0].filename[0]);
    8887
    89       // collect array of (Stars *) stars in a new output catalog
    90       int Nstars = 0;
    91       int NSTARS = (NGROUP*1000);
    92       ALLOCATE (stars, Stars, NSTARS);
     88      int Nave = 0;
     89      int Nmeas = 0;
     90      int NAVE = 1000;
     91      int NMEAS = 4000;
     92
     93      Catalog *newcat = NULL;
     94      ALLOCATE (newcat, Catalog, 1);
     95      dvo_catalog_init (newcat, TRUE);
     96      ALLOCATE (newcat->average, Average, NAVE);
     97      ALLOCATE (newcat->measure, Measure, NMEAS);
    9398
    9499      // loop over stars in this WISE region that are also in this output region
     
    108113        if (tstars[j].average.D > UserPatch.Dmax) continue;
    109114         
    110         for (k = 0; k < NGROUP; k++) {
    111           stars[Nstars+k].average = tstars[j].average;
    112           stars[Nstars+k].measure = tstars[j].measure[k];
    113           stars[Nstars+k].found = -1;
    114         }         
     115        dvo_average_init (&newcat->average[Nave]);
     116        newcat->average[Nave] = tstars[j].average;
     117        for (k = 0; k < NGROUP; k++) {
     118          dvo_measure_init (&newcat->measure[Nmeas + k]);
     119          newcat->measure[Nmeas + k] = tstars[j].measure[k];
     120        }
    115121        tstars[j].flag = TRUE;
    116122
    117         Nstars += NGROUP;
    118         if (Nstars >= NSTARS - NGROUP) {
    119           NSTARS += (NGROUP*1000);
    120           REALLOCATE (stars, Stars, NSTARS);
    121         }
     123        newcat->average[Nave].Nmeasure = NGROUP;
     124        newcat->average[Nave].measureOffset = Nmeas;
     125
     126        Nave ++;
     127        Nmeas += NGROUP;
     128
     129        CHECK_REALLOCATE (newcat->average, Average, NAVE,  Nave,  1000);
     130        CHECK_REALLOCATE (newcat->measure, Measure, NMEAS, Nmeas + NGROUP, 4000);
    122131      }
     132      newcat->Naverage = Nave;
     133      newcat->Nmeasure = Nmeas;
    123134
    124       ALLOCATE (starrefs, Stars *, NSTARS);
    125       for (j = 0; j < Nstars; j++) {
    126         starrefs[j] = &stars[j];
     135      if (!newcat->Naverage) {
     136        dvo_catalog_free (newcat);
     137        free (newcat);
     138        continue;
    127139      }
    128140
     
    145157      // assume no input star matches an existing star
    146158      // simply add to the existing table
    147       find_matches_closest_refstars(region, starrefs, Nstars, &catalog, options);
     159      find_matches_closest_refstars(region, newcat, &catalog, options);
    148160
    149161      dvo_catalog_save (&catalog, verbose);
     
    152164
    153165      SkyListFree (skylist);
    154       free (stars);
    155       free (starrefs);
     166      dvo_catalog_free (newcat);
     167      free (newcat);
    156168    }
    157169    free (tstars);
  • branches/eam_branches/ipp-20150625/Ohana/src/addstar/src/loadwise_rawdata.c

    r38471 r38594  
    1313 
    1414  int i, j, k, verbose;
    15   int Nstars, NSTARS, Ntstars, NTSTARS;
     15  int Ntstars, NTSTARS;
    1616  int Nbyte, Nextra, offset;
    1717
     
    2121  char *buffer, *p, *q;
    2222
    23   Stars **stars; // this is an array of pointers to be consistent with input to find_match_refstars
    2423  WISE_Stars *tstars;
    2524  SkyList *skylist;
     
    117116      if (DEBUG) fprintf (stderr, "writing to %s\n", skylist[0].filename[0]);
    118117
    119       // collect array of (Stars *) stars in a new output catalog
    120       Nstars = 0;
    121       NSTARS = 3000;
    122       ALLOCATE (stars, Stars *, NSTARS);
     118      int Nave = 0;
     119      int Nmeas = 0;
     120      int NAVE = 1000;
     121      int NMEAS = 4000;
     122
     123      Catalog *newcat = NULL;
     124      ALLOCATE (newcat, Catalog, 1);
     125      dvo_catalog_init (newcat, TRUE);
     126      ALLOCATE (newcat->average, Average, NAVE);
     127      ALLOCATE (newcat->measure, Measure, NMEAS);
    123128
    124129      // loop over stars in this WISE region that are also in this output region
     
    140145        offset = tstars[j].offset;
    141146
     147        dvo_average_init (&newcat->average[Nave]);
    142148        for (k = 0; k < 4; k++) {
    143           ALLOCATE (stars[Nstars + k], Stars, 1);
    144           InitStar (stars[Nstars + k]);
    145           stars[Nstars+k][0].average.R = tstars[j].R;
    146           stars[Nstars+k][0].average.D = tstars[j].D;
    147           stars[Nstars+k][0].measure.R = tstars[j].R;
    148           stars[Nstars+k][0].measure.D = tstars[j].D;
    149         }         
     149          dvo_measure_init (&newcat->measure[Nmeas+k]);
     150        }
    150151       
     152        newcat->average[Nave].R = tstars[j].R;
     153        newcat->average[Nave].D = tstars[j].D;
     154
    151155        switch (MODE) {
    152156          case MODE_PRELIM:
    153             loadwise_star_prelim (&stars[Nstars], &buffer[offset], Nbyte - offset);
     157            loadwise_star_prelim (&newcat->measure[Nmeas], &buffer[offset], Nbyte - offset);
    154158            break;
    155159          case MODE_ALLSKY:
    156             loadwise_star_allsky (&stars[Nstars], &buffer[offset], Nbyte - offset);
     160            loadwise_star_allsky (&newcat->measure[Nmeas], &buffer[offset], Nbyte - offset);
    157161            break;
    158162          case MODE_ALLWISE:
    159             loadwise_star_allwise (&stars[Nstars], &buffer[offset], Nbyte - offset);
     163            loadwise_star_allwise (&newcat->measure[Nmeas], &buffer[offset], Nbyte - offset);
    160164            break;
    161165          default:
     
    165169        tstars[j].flag = TRUE;
    166170
    167         Nstars += 4;
    168         if (Nstars >= NSTARS - 4) {
    169           NSTARS += 4000;
    170           REALLOCATE (stars, Stars *, NSTARS);
    171         }
    172       }
    173 
    174       if (!Nstars) {
    175         free (stars);
     171        newcat->average[Nave].Nmeasure = 4;
     172        newcat->average[Nave].measureOffset = Nmeas;
     173
     174        Nave ++;
     175        Nmeas += 4;
     176
     177        CHECK_REALLOCATE (newcat->average, Average, NAVE,  Nave,  1000);
     178        CHECK_REALLOCATE (newcat->measure, Measure, NMEAS, Nmeas, 4000);
     179      }
     180      newcat->Naverage = Nave;
     181      newcat->Nmeasure = Nmeas;
     182
     183      if (!newcat->Naverage) {
     184        dvo_catalog_free (newcat);
     185        free (newcat);
    176186        continue;
    177187      }
    178188
    179       if (DEBUG) fprintf (stderr, "selected %d stars (%10.6f - %10.6f, %10.6f - %10.6f)\n", Nstars,
     189      if (DEBUG) fprintf (stderr, "selected %d stars (%10.6f - %10.6f, %10.6f - %10.6f)\n",
     190                          (int) newcat->Naverage,
    180191                          region[0].Rmin, region[0].Rmax, region[0].Dmin, region[0].Dmax);
    181192
     
    200211        // assume no input star matches an existing star
    201212        // simply add to the existing table
    202         // loadWISE_catalog (&catalog, stars, Nstars);
    203         find_matches_refstars (skylist[0].regions[0], stars, Nstars, &catalog, options);
    204         // loadWISE_catalog (&catalog, stars, Nstars);
     213        find_matches_refstars (skylist[0].regions[0], newcat, &catalog, options);
    205214
    206215        dvo_catalog_save (&catalog, VERBOSE);
    207216        dvo_catalog_unlock (&catalog);
    208217        dvo_catalog_free (&catalog);
    209         // free (catalog.filename);
    210         // XXX don't free this! it points to an element of the skytable
    211218      }
    212219
    213220      SkyListFree (skylist);
    214       for (j = 0; j < Nstars; j++) free (stars[j]);
    215       free (stars);
     221      dvo_catalog_free (newcat);
     222      free (newcat);
    216223      VERBOSE = verbose;
    217224    }
  • branches/eam_branches/ipp-20150625/Ohana/src/addstar/src/loadwise_star_full.c

    r38593 r38594  
    242242
    243243  for (i = 0; i < 4; i++) {
    244       setWISE_ph_qual (star[i], ptr[i]); // ph_qual
     244      setWISE_ph_qual (&measure[i], ptr[i]); // ph_qual
    245245  }
    246246
     
    343343
    344344  // set blend flags for all 4 measures
    345   setWISE_blend_flag (star, ptr); // nb & na both used here
     345  setWISE_blend_flag (measure, ptr); // nb & na both used here
    346346  ptr = skipNbounds (ptr, '|', 2, Nmax); // skip: nb, na
    347347
    348348  for (i = 0; i < 4; i++) {
    349       setWISE_sat_flag (star[i], ptr); // w1sat
     349      setWISE_sat_flag (&measure[i], ptr); // w1sat
    350350      ptr = nextWISEfield (ptr);
    351351  }
     
    353353
    354354  for (i = 0; i < 4; i++) {
    355       setWISE_cc_flag (star[i], ptr[i]); // cc_flg
     355      setWISE_cc_flag (&measure[i], ptr[i]); // cc_flg
    356356  }
    357357  ptr = nextWISEfield (ptr); // skip cc_flags
    358358
    359359  // set ext flags for all 4 measures
    360   setWISE_ext_flag_prelim (star, *ptr); // ext_flg
     360  setWISE_ext_flag_prelim (measure, *ptr); // ext_flg
    361361  ptr = nextWISEfield (ptr); // skip ext_flags
    362362
    363363  for (i = 0; i < 4; i++) {
    364       setWISE_var_flag_prelim (star[i], ptr[i]); // var_flg
     364      setWISE_var_flag_prelim (&measure[i], ptr[i]); // var_flg
    365365  }
    366366  ptr = nextWISEfield (ptr); // skip var_flags
    367367
    368368  for (i = 0; i < 4; i++) {
    369       setWISE_ph_qual (star[i], ptr[i]); // ph_qual
     369      setWISE_ph_qual (&measure[i], ptr[i]); // ph_qual
    370370  }
    371371
Note: See TracChangeset for help on using the changeset viewer.