Changeset 38525
- Timestamp:
- Jun 24, 2015, 6:38:37 AM (11 years ago)
- Location:
- branches/eam_branches/ipp-20150616/Ohana/src/addstar
- Files:
-
- 9 edited
-
Makefile (modified) (2 diffs)
-
include/addstar.h (modified) (6 diffs)
-
src/FilterStars.c (modified) (6 diffs)
-
src/LoadData.c (modified) (5 diffs)
-
src/LoadStars.c (modified) (5 diffs)
-
src/ReadStarsFITS.c (modified) (12 diffs)
-
src/UpdateImageIDs.c (modified) (2 diffs)
-
src/addstar.c (modified) (10 diffs)
-
src/find_matches_closest.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20150616/Ohana/src/addstar/Makefile
r38522 r38525 76 76 $(SRC)/MatchHeaders.$(ARCH).o \ 77 77 $(SRC)/LoadData.$(ARCH).o \ 78 $(SRC)/LoadDataSDSS.$(ARCH).o \79 $(SRC)/LoadDataUKIRT.$(ARCH).o \80 $(SRC)/LoadDataPMM.$(ARCH).o \81 78 $(SRC)/in_image.$(ARCH).o \ 82 79 $(SRC)/load_subpix.$(ARCH).o \ … … 102 99 $(SRC)/update_coords.$(ARCH).o \ 103 100 $(SRC)/psps_ids.$(ARCH).o 101 102 ## $(SRC)/LoadDataSDSS.$(ARCH).o \ 103 ## $(SRC)/LoadDataUKIRT.$(ARCH).o \ 104 ## $(SRC)/LoadDataPMM.$(ARCH).o \ 105 ## 104 106 105 107 # this is the client for parallel operations -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/include/addstar.h
r38522 r38525 216 216 Image *fakeimage PROTO((char *rootname, off_t *Nimage, int photcode)); 217 217 218 int find_matches_closest PROTO((SkyRegion *region, Catalog *newcat, Catalog *catalog, AddstarClientOptions options)); 219 218 220 int find_matches PROTO((SkyRegion *region, Stars *stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options)); 219 int find_matches_closest PROTO((SkyRegion *region, Stars *stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options));221 // int find_matches_closest PROTO((SkyRegion *region, Stars *stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options)); 220 222 int find_matches_refstars PROTO((SkyRegion *region, Stars **stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options)); 221 223 int find_matches_closest_refstars PROTO((SkyRegion *region, Stars **stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options)); … … 234 236 Stars *grefstars PROTO((char *file, int photcode, unsigned int *Nstars)); 235 237 236 Stars *LoadStars PROTO((char *file, unsigned int *Nstars, Image **images, off_t *Nimages, AddstarClientOptions *options));238 Catalog *LoadStars PROTO((char *file, Image **images, off_t *Nimages, AddstarClientOptions *options)); 237 239 Header **LoadHeaders PROTO((FILE *f, int *mode, int *Nheader)); 238 240 HeaderSet *MatchHeaders PROTO((off_t **extsize, off_t *nimage, int mode, Header **headers, int Nheaders)); 239 241 void HeaderSetFree PROTO((HeaderSet *headerSets, off_t NheaderSets)); 240 int LoadData PROTO((FILE *f, AddstarFile *file, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, int NheaderSets, AddstarClientOptions *options));242 Catalog *LoadData PROTO((FILE *f, AddstarFile *file, Image **images, off_t *nvalid, Header **headers, off_t *extsize, HeaderSet *headerSets, int NheaderSets, AddstarClientOptions *options)); 241 243 int GetZeroPointExposure PROTO((Header **headers, HeaderSet *headerSets, off_t Nimages)); 242 244 … … 257 259 void resort_catalog_old PROTO((Catalog *catalog)); 258 260 259 Stars *ReadStarsFITS PROTO((FILE *f, Header *header, Header *in_theader, unsigned int *nstars));261 Catalog *ReadStarsFITS PROTO((FILE *f, Header *header, Header *in_theader)); 260 262 Stars *ReadStarsTEXT PROTO((FILE *f, unsigned int *nstars)); 261 263 Stars *ReadStarsSDSS PROTO((FILE *f, char *name, Header *header, Header *in_theader, Image *images, off_t *nimages, unsigned int *nstars)); 262 264 int ReadImageHeader PROTO((Header *header, Image *image, int photcode)); 263 Stars *FilterStars PROTO((Stars *instars, Image *image, unsigned int imageID, const AddstarClientOptions *options));264 Stars *MergeStars PROTO((Stars *stars, unsigned int *Nstars, Stars *instars, unsigned int Ninstars));265 266 int ReadXradFITS PROTO((FILE *f, Header *theader, Stars *stars, unsigned int Nstars));265 Catalog *FilterStars PROTO((Catalog *newcat, Image *image, unsigned int imageID, const AddstarClientOptions *options)); 266 // Stars *MergeStars PROTO((Stars *stars, unsigned int *Nstars, Stars *instars, unsigned int Ninstars)); 267 268 // int ReadXradFITS PROTO((FILE *f, Header *theader, Stars *stars, unsigned int Nstars)); 267 269 268 270 double scat_subpix PROTO((double x, double y)); … … 310 312 int args_skycells (int argc, char **argv); 311 313 int ConfigInit_skycells (int *argc, char **argv); 312 int UpdateImageIDs ( Stars *stars, unsigned int Nstars, Image *images, off_t Nimages);314 int UpdateImageIDs (Catalog *catalog, Image *images, off_t Nimages); 313 315 314 316 int CheckDuplicateImageIDs (Image *images, off_t Nimages); … … 338 340 void saveMosaicCoords (Coords *input); 339 341 340 341 342 Stars *ReadStarsUKIRT (FILE *f, char *name, Header *header, Image *images, off_t *nimages, unsigned int *nstars); 342 343 int LoadDataUKIRT (FILE *f, char *file, Image **images, off_t *nimages, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, off_t NheaderSets); … … 344 345 AddstarFile *LoadFilenames (int *nfile, char *filename, AddstarClientOptions *options); 345 346 void AddstarFileFree (AddstarFile *file, int Nfile); 347 348 Catalog *addstar_catalog_init (int Nstars); 346 349 347 350 /** -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/FilterStars.c
r38467 r38525 10 10 // the imageID supplied here is the sequence **within this set** 11 11 // this value is updated based on the image table later (in UpdateImageIDs) 12 Stars *FilterStars (Stars *instars, Image *image, unsigned int imageID, const AddstarClientOptions *options) {12 Catalog *FilterStars (Catalog *newcat, Image *image, unsigned int imageID, const AddstarClientOptions *options) { 13 13 14 14 int j, N; 15 15 float MTIME, dMs, dMx; 16 Stars *stars;17 16 float RMIN, RMAX, DMIN, DMAX; 18 17 … … 26 25 27 26 /* modify resulting star list */ 28 ALLOCATE (stars, Stars, image[0].nstar); 29 for (N = j = 0; j < image[0].nstar; j++) { 27 Catalog *outcat = addstar_catalog_init (newcat->Nmeasure); 28 ALLOCATE (outcat->average, Average, newcat->Nmeasure); 29 30 for (N = j = 0; j < newcat->Nmeasure; j++) { 30 31 31 if ( instars[j].measure.photFlags & options->detectionFilter) continue;32 if (newcat->measure[j].photFlags & options->detectionFilter) continue; 32 33 33 34 /* allow for some dynamic filtering of star list */ 34 if (SNLIMIT && instars[j].measure.dM > SNLIMIT) continue;35 if (XMAX && ( instars[j].measure.Xccd > XMAX)) continue;36 if (XMIN && ( instars[j].measure.Xccd < XMIN)) continue;37 if (YMAX && ( instars[j].measure.Yccd > YMAX)) continue;38 if (YMIN && ( instars[j].measure.Yccd < YMIN)) continue;39 if (PHOTFLAG_EXCLUDE && ( instars[j].measure.photFlags & PHOTFLAG_EXCLUDE)) continue;35 if (SNLIMIT && newcat->measure[j].dM > SNLIMIT) continue; 36 if (XMAX && (newcat->measure[j].Xccd > XMAX)) continue; 37 if (XMIN && (newcat->measure[j].Xccd < XMIN)) continue; 38 if (YMAX && (newcat->measure[j].Yccd > YMAX)) continue; 39 if (YMIN && (newcat->measure[j].Yccd < YMIN)) continue; 40 if (PHOTFLAG_EXCLUDE && (newcat->measure[j].photFlags & PHOTFLAG_EXCLUDE)) continue; 40 41 41 stars[N] = instars[j]; 42 dvo_average_init (&outcat->average[N]); 43 outcat->measure[N] = newcat->measure[j]; 42 44 43 XY_to_RD (&stars[N].average.R, &stars[N].average.D, stars[N].measure.Xccd, stars[N].measure.Yccd, &image[0].coords); 44 stars[N].average.R = ohana_normalize_angle (stars[N].average.R); 45 stars[N].measure.R = stars[N].average.R; 46 stars[N].measure.D = stars[N].average.D; 45 outcat->average[N].Nmeasure = 1; 46 outcat->average[N].measureOffset = N; 47 47 48 stars[N].measure.photcode = image[0].photcode; 48 XY_to_RD (&outcat->average[N].R, &outcat->average[N].D, outcat->measure[N].Xccd, outcat->measure[N].Yccd, &image[0].coords); 49 outcat->average[N].R = ohana_normalize_angle (outcat->average[N].R); 50 outcat->measure[N].R = outcat->average[N].R; 51 outcat->measure[N].D = outcat->average[N].D; 52 53 outcat->measure[N].photcode = image[0].photcode; 49 54 50 55 // determine the full coverage of this set of measurements 51 RMIN = MIN (RMIN, stars[N].average.R);52 RMAX = MAX (RMAX, stars[N].average.R);53 DMIN = MIN (DMIN, stars[N].average.D);54 DMAX = MAX (DMAX, stars[N].average.D);56 RMIN = MIN (RMIN, outcat->average[N].R); 57 RMAX = MAX (RMAX, outcat->average[N].R); 58 DMIN = MIN (DMIN, outcat->average[N].D); 59 DMAX = MAX (DMAX, outcat->average[N].D); 55 60 56 61 /** additional quantities to supply to Stars based on the image data **/ 57 62 58 63 /* calculate accurate per-star airmass and azimuth */ 59 stars[N].measure.airmass = airmass (image[0].secz, stars[N].average.R, stars[N].average.D, image[0].sidtime, image[0].latitude);60 stars[N].measure.az = azimuth (15.0*image[0].sidtime - stars[N].average.R, stars[N].average.D, image[0].latitude);61 stars[N].measure.Mcal = image[0].Mcal;62 stars[N].measure.t = image[0].tzero + 1e-4*stars[N].measure.Yccd*image[0].trate; /* trate is in 0.1 msec / row */63 stars[N].measure.dt = MTIME;64 outcat->measure[N].airmass = airmass (image[0].secz, outcat->average[N].R, outcat->average[N].D, image[0].sidtime, image[0].latitude); 65 outcat->measure[N].az = azimuth (15.0*image[0].sidtime - outcat->average[N].R, outcat->average[N].D, image[0].latitude); 66 outcat->measure[N].Mcal = image[0].Mcal; 67 outcat->measure[N].t = image[0].tzero + 1e-4*outcat->measure[N].Yccd*image[0].trate; /* trate is in 0.1 msec / row */ 68 outcat->measure[N].dt = MTIME; 64 69 65 70 // watch out for any strange values: 66 if (( stars[N].measure.M > 25.0) && (stars[N].measure.M < 32.0)) {71 if ((outcat->measure[N].M > 25.0) && (outcat->measure[N].M < 32.0)) { 67 72 fprintf (stderr, "*"); 68 73 } … … 73 78 dMx = 0.0; 74 79 if (SUBPIX) { 75 dMs = get_subpix ( stars[N].measure.Xccd, stars[N].measure.Yccd);76 dMx = scat_subpix ( stars[N].measure.Xccd, stars[N].measure.Yccd);77 if (!isnan( stars[N].measure.dM)) {78 stars[N].measure.dM = hypot (stars[N].measure.dM, dMx);80 dMs = get_subpix (outcat->measure[N].Xccd, outcat->measure[N].Yccd); 81 dMx = scat_subpix (outcat->measure[N].Xccd, outcat->measure[N].Yccd); 82 if (!isnan(outcat->measure[N].dM)) { 83 outcat->measure[N].dM = hypot (outcat->measure[N].dM, dMx); 79 84 } 80 85 } 81 86 82 if (!isnan( stars[N].measure.M)) {83 stars[N].measure.M += MTIME - dMs;87 if (!isnan(outcat->measure[N].M)) { 88 outcat->measure[N].M += MTIME - dMs; 84 89 } 85 if (!isnan( stars[N].measure.Map)) {86 stars[N].measure.Map += MTIME - dMs;90 if (!isnan(outcat->measure[N].Map)) { 91 outcat->measure[N].Map += MTIME - dMs; 87 92 } 88 if (!isnan( stars[N].measure.Mkron)) {89 stars[N].measure.Mkron += MTIME - dMs;93 if (!isnan(outcat->measure[N].Mkron)) { 94 outcat->measure[N].Mkron += MTIME - dMs; 90 95 } 91 if (!isnan( stars[N].measure.FluxPSF)) {92 stars[N].measure.FluxPSF /= image[0].exptime;96 if (!isnan(outcat->measure[N].FluxPSF)) { 97 outcat->measure[N].FluxPSF /= image[0].exptime; 93 98 } 94 if (!isnan( stars[N].measure.dFluxPSF)) {95 stars[N].measure.dFluxPSF /= image[0].exptime;99 if (!isnan(outcat->measure[N].dFluxPSF)) { 100 outcat->measure[N].dFluxPSF /= image[0].exptime; 96 101 } 97 if (!isnan( stars[N].measure.FluxKron)) {98 stars[N].measure.FluxKron /= image[0].exptime;102 if (!isnan(outcat->measure[N].FluxKron)) { 103 outcat->measure[N].FluxKron /= image[0].exptime; 99 104 } 100 if (!isnan( stars[N].measure.dFluxKron)) {101 stars[N].measure.dFluxKron /= image[0].exptime;105 if (!isnan(outcat->measure[N].dFluxKron)) { 106 outcat->measure[N].dFluxKron /= image[0].exptime; 102 107 } 103 if (!isnan( stars[N].measure.FluxAp)) {104 stars[N].measure.FluxAp /= image[0].exptime;108 if (!isnan(outcat->measure[N].FluxAp)) { 109 outcat->measure[N].FluxAp /= image[0].exptime; 105 110 } 106 if (!isnan( stars[N].measure.dFluxAp)) {107 stars[N].measure.dFluxAp /= image[0].exptime;111 if (!isnan(outcat->measure[N].dFluxAp)) { 112 outcat->measure[N].dFluxAp /= image[0].exptime; 108 113 } 109 if (stars[N].lensing) { 110 if (!isnan(stars[N].lensing-> F_ApR5)) stars[N].lensing-> F_ApR5 /= image[0].exptime; 111 if (!isnan(stars[N].lensing->dF_ApR5)) stars[N].lensing->dF_ApR5 /= image[0].exptime; 112 if (!isnan(stars[N].lensing->sF_ApR5)) stars[N].lensing->sF_ApR5 /= image[0].exptime; 113 if (!isnan(stars[N].lensing->fF_ApR5)) stars[N].lensing->fF_ApR5 /= image[0].exptime; 114 115 if (!isnan(stars[N].lensing-> F_ApR6)) stars[N].lensing-> F_ApR6 /= image[0].exptime; 116 if (!isnan(stars[N].lensing->dF_ApR6)) stars[N].lensing->dF_ApR6 /= image[0].exptime; 117 if (!isnan(stars[N].lensing->sF_ApR6)) stars[N].lensing->sF_ApR6 /= image[0].exptime; 118 if (!isnan(stars[N].lensing->fF_ApR6)) stars[N].lensing->fF_ApR6 /= image[0].exptime; 119 120 if (!isnan(stars[N].lensing-> F_ApR7)) stars[N].lensing-> F_ApR7 /= image[0].exptime; 121 if (!isnan(stars[N].lensing->dF_ApR7)) stars[N].lensing->dF_ApR7 /= image[0].exptime; 122 if (!isnan(stars[N].lensing->sF_ApR7)) stars[N].lensing->sF_ApR7 /= image[0].exptime; 123 if (!isnan(stars[N].lensing->fF_ApR7)) stars[N].lensing->fF_ApR7 /= image[0].exptime; 114 if (outcat->lensing) { 115 if (!isnan(outcat->lensing[N]. F_ApR5)) outcat->lensing[N]. F_ApR5 /= image[0].exptime; 116 if (!isnan(outcat->lensing[N].dF_ApR5)) outcat->lensing[N].dF_ApR5 /= image[0].exptime; 117 if (!isnan(outcat->lensing[N].sF_ApR5)) outcat->lensing[N].sF_ApR5 /= image[0].exptime; 118 if (!isnan(outcat->lensing[N].fF_ApR5)) outcat->lensing[N].fF_ApR5 /= image[0].exptime; 119 if (!isnan(outcat->lensing[N]. F_ApR6)) outcat->lensing[N]. F_ApR6 /= image[0].exptime; 120 if (!isnan(outcat->lensing[N].dF_ApR6)) outcat->lensing[N].dF_ApR6 /= image[0].exptime; 121 if (!isnan(outcat->lensing[N].sF_ApR6)) outcat->lensing[N].sF_ApR6 /= image[0].exptime; 122 if (!isnan(outcat->lensing[N].fF_ApR6)) outcat->lensing[N].fF_ApR6 /= image[0].exptime; 123 if (!isnan(outcat->lensing[N]. F_ApR7)) outcat->lensing[N]. F_ApR7 /= image[0].exptime; 124 if (!isnan(outcat->lensing[N].dF_ApR7)) outcat->lensing[N].dF_ApR7 /= image[0].exptime; 125 if (!isnan(outcat->lensing[N].sF_ApR7)) outcat->lensing[N].sF_ApR7 /= image[0].exptime; 126 if (!isnan(outcat->lensing[N].fF_ApR7)) outcat->lensing[N].fF_ApR7 /= image[0].exptime; 124 127 } 125 128 126 129 // the external ID is supplied, but do we trust it? 127 130 if (!EXTERNAL_ID) { 128 stars[N].measure.detID = N; // sequence number within image131 outcat->measure[N].detID = N; // sequence number within image 129 132 } 130 133 … … 135 138 136 139 if (isStack) { 137 stars[N].measure.extID = CreatePSPSStackDetectionID(image[0].sourceID, image[0].externID, stars[N].measure.detID);140 outcat->measure[N].extID = CreatePSPSStackDetectionID(image[0].sourceID, image[0].externID, outcat->measure[N].detID); 138 141 } else { 139 stars[N].measure.extID = CreatePSPSDetectionID(mjd, image[0].ccdnum, stars[N].measure.detID);142 outcat->measure[N].extID = CreatePSPSDetectionID(mjd, image[0].ccdnum, outcat->measure[N].detID); 140 143 } 141 144 } else { 142 stars[N].measure.extID = 0;145 outcat->measure[N].extID = 0; 143 146 } 144 147 145 stars[N].measure.imageID = imageID; // this value is updated in UpdateImageIDs148 outcat->measure[N].imageID = imageID; // this value is updated in UpdateImageIDs 146 149 147 150 // add imageID to lensing entry, if it exists 148 if ( stars[N].lensing) {149 stars[N].lensing->imageID = imageID;151 if (outcat->lensing) { 152 outcat->lensing[N].imageID = imageID; 150 153 } 151 154 … … 156 159 157 160 image[0].nstar = N; 158 REALLOCATE (stars, Stars, image[0].nstar);159 free (instars);160 161 161 if (VERBOSE) fprintf (stderr, "read %d stars from target file\n", image[0].nstar); 162 REALLOCATE (outcat->measure, Measure, N); 163 REALLOCATE (outcat->average, Average, N); 164 if (outcat->lensing) { 165 REALLOCATE (outcat->average, Average, N); 166 } 167 dvo_catalog_free (newcat); 168 free (newcat); 169 170 outcat->Naverage = N; 171 outcat->Nmeasure = N; 172 outcat->Nlensing = outcat->lensing ? N : 0; 173 174 if (VERBOSE) fprintf (stderr, "read %d stars from target file\n", N); 162 175 if (VERBOSE) fprintf (stderr, "stars cover region %f,%f - %f,%f\n", RMIN, DMIN, RMAX, DMAX); 163 return (stars); 176 177 return (outcat); 164 178 } 165 179 180 # if (0) 166 181 Stars *MergeStars (Stars *stars, unsigned int *Nstars, Stars *instars, unsigned int Ninstars) { 167 182 … … 181 196 return (stars); 182 197 } 198 # endif -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadData.c
r38523 r38525 1 1 # include "addstar.h" 2 2 3 // XXX this function is somewhat specific to the elixir format output files 4 // it is capable of distinguishing several format versions defined for elixir/psphot 5 3 // load photometry data from psphot, sextractor, and a few other formats 6 4 // examine the header sets and set the Image entries for the the valid images 7 Catalog *LoadData (FILE *f, AddstarFile *file, Image **images, off_t *nvalid, unsigned int *Ncatalog,Header **headers, off_t *extsize, HeaderSet *headerSets, int Nimages, AddstarClientOptions *options) {5 Catalog *LoadData (FILE *f, AddstarFile *file, Image **images, off_t *nvalid, Header **headers, off_t *extsize, HeaderSet *headerSets, int Nimages, AddstarClientOptions *options) { 8 6 9 7 off_t Nskip, Nvalid, NVALID; … … 11 9 uint32_t parentID = UINT32_MAX; 12 10 13 int ncatalog = 0;14 int NCATALOG = Nimages;15 11 Catalog *catalog = NULL; 16 ALLOCATE (catalog, Catalog, NCATALOG); 12 // ALLOCATE (catalog, Catalog, 1); 13 // dvo_catalog_init (catalog, TRUE); 17 14 18 15 if (images[0] == NULL) { … … 80 77 fseeko (f, Nskip, SEEK_SET); 81 78 82 status = ReadStarsFITS (f, headers[Nhead], headers[Ndata], &images[0][Nvalid].nstar, &catalog[ncatalog]); 83 if (!status) { 84 // XXX need to free the data here or in ReadStarsFITS on error 79 // ReadStarsFITS populates catalog->measure,Nmeasure 80 Catalog *newcat = ReadStarsFITS (f, headers[Nhead], headers[Ndata]); 81 if (!newcat) { 82 dvo_catalog_free (newcat); 85 83 continue; 86 84 } 85 images[0][Nvalid].nstar = newcat->Nmeasure; 87 86 87 # if (0) 88 88 // XRAD : if we want to read the xrad table, skip to that table here: 89 89 if (headerSets[i].extnum_xrad != -1) { … … 99 99 } 100 100 } 101 # endif 101 102 102 FilterStars (&catalog[ncatalog], &images[0][Nvalid], Nvalid, options); 103 // replace full input catalog newcat with subset version 104 newcat = FilterStars (newcat, &images[0][Nvalid], Nvalid, options); 105 catalog = newcat; 103 106 104 // XXX merge catalogs here : I should only have one output catalog! 105 106 // XXX need to merge here? 107 // *stars = MergeStars (*stars, Nstars, inStars, images[0][Nvalid].nstar); 108 // FREE (inStars); 107 // XXX I need to use find_matches_closest here, but for testing: 108 // find_matches_closest (region, catalog, newcat, options); 109 // dvo_catalog_free (newcat); 110 // free (newcat); 109 111 110 112 Nvalid++; … … 113 115 114 116 if (isfinite(OFFSET_ZPT)) { 115 for (i = 0; i < *Nstars; i++) {116 stars[0][i].measure.M += OFFSET_ZPT;117 stars[0][i].measure.Map += OFFSET_ZPT;117 for (i = 0; i < catalog->Nmeasure; i++) { 118 catalog->measure[i].M += OFFSET_ZPT; 119 catalog->measure[i].Map += OFFSET_ZPT; 118 120 } 119 121 } 120 122 121 123 *nvalid = Nvalid; 122 return (TRUE);124 return catalog; 123 125 } 124 126 -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadStars.c
r38523 r38525 1 1 # include "addstar.h" 2 2 3 Catalog *LoadStars (char *filename, unsigned int *Ncatalog,Image **images, off_t *Nimages, AddstarClientOptions *options) {3 Catalog *LoadStars (char *filename, Image **images, off_t *Nimages, AddstarClientOptions *options) { 4 4 5 5 off_t *extsize; … … 9 9 10 10 *Nimages = 0; 11 *Ncatalog = 0;12 11 *images = NULL; 12 13 13 Catalog *catalog = NULL; 14 // ALLOCATE (catalog, Catalog, 1); 15 // dvo_catalog_init (catalog, TRUE); 14 16 15 17 for (i = 0; i < Nfile; i++) { … … 22 24 // load PMM data if specified (these are not stored as FITS-tables) 23 25 if (PMM_CCD_TABLE != NULL) { 24 *Ncatalog = 1;25 26 // XXX catalog = LoadDataPMM (f, file[i].imagename, images, Nimages); 26 27 continue; … … 58 59 // if these are SDSS data, load with SDSS-specific wrapper 59 60 if (headerSets[0].exttype && !strcmp (headerSets[0].exttype, "SDSS_OBJ")) { 60 *Ncatalog = 1;61 61 // XXX catalog = LoadDataSDSS (f, file[i].imagename, images, Nimages, headers, extsize, headerSets, NheaderSets); 62 62 goto next_file; … … 65 65 // if these are SDSS data, load with SDSS-specific wrapper 66 66 if (headerSets[0].exttype && !strcmp (headerSets[0].exttype, "UKIRT_OBJ")) { 67 *Ncatalog = 1;68 67 // XXX catalog = LoadDataUKIRT (f, file[i].imagename, images, Nimages, headers, extsize, headerSets, NheaderSets); 69 68 goto next_file; 70 69 } 71 70 72 catalog = LoadData (f, &file[i], images, Nimages, Ncatalog, headers, extsize, headerSets, NheaderSets, options); 71 Catalog *newcat = LoadData (f, &file[i], images, Nimages, headers, extsize, headerSets, NheaderSets, options); 72 catalog = newcat; 73 74 // XXX I need to use find_matches_closest here, but for testing: 75 // find_matches_closest (region, catalog, newcat, options); 76 // dvo_catalog_free (newcat); 77 // free (newcat); 73 78 74 79 next_file: -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/ReadStarsFITS.c
r38501 r38525 4 4 // (excluding SDSS data and reference database info, such as 2MASS) 5 5 // NOTE: these must also be listed in MatchHeaders.c (line ~ 62) 6 Stars *Convert_SMPDATA PROTO((FTable *table, unsigned int *nstars)); 7 Stars *Convert_PS1_DEV_0 PROTO((FTable *table, unsigned int *nstars)); 8 Stars *Convert_PS1_DEV_1 PROTO((FTable *table, unsigned int *nstars)); 9 Stars *Convert_PS1_V1 PROTO((FTable *table, unsigned int *nstars)); 10 Stars *Convert_PS1_V1_Alt PROTO((FTable *table, unsigned int *nstars)); 11 Stars *Convert_PS1_V2 PROTO((FTable *table, unsigned int *nstars)); 12 Stars *Convert_PS1_V3 PROTO((FTable *table, unsigned int *nstars)); 13 Stars *Convert_PS1_V4 PROTO((FTable *table, unsigned int *nstars)); 14 Stars *Convert_PS1_V5 PROTO((FTable *table, unsigned int *nstars)); 15 Stars *Convert_PS1_V5_R0_Lensing PROTO((FTable *table, unsigned int *nstars)); 16 Stars *Convert_PS1_V5_R1_Lensing PROTO((FTable *table, unsigned int *nstars)); 17 Stars *Convert_PS1_V5_R2_Lensing PROTO((FTable *table, unsigned int *nstars)); 18 Stars *Convert_PS1_SV1 PROTO((FTable *table, unsigned int *nstars)); 19 Stars *Convert_PS1_SV1_Alt PROTO((FTable *table, unsigned int *nstars)); 20 Stars *Convert_PS1_SV2 PROTO((FTable *table, unsigned int *nstars)); 21 Stars *Convert_PS1_SV3 PROTO((FTable *table, unsigned int *nstars)); 22 Stars *Convert_PS1_SV4 PROTO((FTable *table, unsigned int *nstars)); 23 Stars *Convert_PS1_DV3 PROTO((FTable *table, unsigned int *nstars)); 24 Stars *Convert_PS1_DV4 PROTO((FTable *table, unsigned int *nstars)); 25 Stars *Convert_PS1_DV5 PROTO((FTable *table, unsigned int *nstars)); 6 Catalog *Convert_SMPDATA PROTO((FTable *table)); 7 Catalog *Convert_PS1_DEV_0 PROTO((FTable *table)); 8 Catalog *Convert_PS1_DEV_1 PROTO((FTable *table)); 9 Catalog *Convert_PS1_V1 PROTO((FTable *table)); 10 Catalog *Convert_PS1_V1_Alt PROTO((FTable *table)); 11 Catalog *Convert_PS1_V2 PROTO((FTable *table)); 12 Catalog *Convert_PS1_V3 PROTO((FTable *table)); 13 Catalog *Convert_PS1_V4 PROTO((FTable *table)); 14 Catalog *Convert_PS1_V5 PROTO((FTable *table)); 15 Catalog *Convert_PS1_V5_R0_Lensing PROTO((FTable *table)); 16 Catalog *Convert_PS1_V5_R1_Lensing PROTO((FTable *table)); 17 Catalog *Convert_PS1_V5_R2_Lensing PROTO((FTable *table)); 18 Catalog *Convert_PS1_SV1 PROTO((FTable *table)); 19 Catalog *Convert_PS1_SV1_Alt PROTO((FTable *table)); 20 Catalog *Convert_PS1_SV2 PROTO((FTable *table)); 21 Catalog *Convert_PS1_SV3 PROTO((FTable *table)); 22 Catalog *Convert_PS1_SV4 PROTO((FTable *table)); 23 Catalog *Convert_PS1_DV3 PROTO((FTable *table)); 24 Catalog *Convert_PS1_DV4 PROTO((FTable *table)); 25 Catalog *Convert_PS1_DV5 PROTO((FTable *table)); 26 27 Catalog *addstar_catalog_init (int Nstars) { 28 Catalog *catalog = NULL; 29 ALLOCATE (catalog, Catalog, 1); 30 dvo_catalog_init (catalog, TRUE); 31 32 ALLOCATE (catalog->measure, Measure, Nstars); 33 34 int i; 35 for (i = 0; i < Nstars; i++) { 36 dvo_measure_init (&catalog->measure[i]); 37 } 38 catalog->Nmeasure = Nstars; 39 return catalog; 40 } 26 41 27 42 // given a file with the pointer at the start of the table block and the 28 43 // corresponding image header, load the stars from the table 29 Stars *ReadStarsFITS (FILE *f, Header *header, Header *in_theader, unsigned int *nstars) {44 Catalog *ReadStarsFITS (FILE *f, Header *header, Header *in_theader) { 30 45 31 46 off_t Nskip; 32 unsigned int Nstars;33 47 char type[80]; 34 48 Header theader; 35 49 FTable table; 36 Stars *stars; // Stars contains Average and Measure37 50 38 51 if (in_theader == NULL) { … … 55 68 } 56 69 57 stars = NULL; 70 Catalog *catalog = NULL; 71 # if (0) 58 72 if (!strcmp (type, "SMPDATA")) { 59 73 stars = Convert_SMPDATA (&table, &Nstars); … … 81 95 stars = Convert_PS1_V4 (&table, &Nstars); 82 96 } 97 # endif 83 98 if (!strcmp (type, "PS1_V5")) { 84 99 switch (table.header[0].Naxis[0]) { 85 100 case 232: 86 stars = Convert_PS1_V5 (&table, &Nstars);101 catalog = Convert_PS1_V5 (&table); 87 102 break; 103 # if (0) 88 104 case 312: 89 105 stars = Convert_PS1_V5_R0_Lensing (&table, &Nstars); … … 95 111 stars = Convert_PS1_V5_R2_Lensing (&table, &Nstars); 96 112 break; 113 # endif 97 114 default: 98 115 fprintf (stderr, "invalid PS1_V5 table size %d\n", (int) table.header[0].Naxis[0]); … … 100 117 } 101 118 } 119 # if (0) 102 120 if (!strcmp (type, "PS1_SV1")) { 103 121 stars = Convert_PS1_SV1 (&table, &Nstars); … … 121 139 stars = Convert_PS1_DV5 (&table, &Nstars); 122 140 } 123 if (stars == NULL) { 141 # endif 142 if (catalog == NULL) { 124 143 fprintf (stderr, "invalid table type %s\n", type); 125 144 return (NULL); … … 127 146 128 147 gfits_free_table (&table); 129 130 // Nstars is not necessarily == *nstars (The former is the number of detections, the 131 // latter are the 'good' detections reported by the photometry system. 132 *nstars = Nstars; 133 134 return stars; 148 return catalog; 135 149 } 136 150 … … 151 165 return dFlux; 152 166 } 167 168 # if (0) 153 169 154 170 Stars *Convert_SMPDATA (FTable *table, unsigned int *nstars) { … … 784 800 } 785 801 786 Stars *Convert_PS1_V5 (FTable *table, unsigned int *nstars) { 802 # endif 803 804 Catalog *Convert_PS1_V5 (FTable *table) { 787 805 788 806 off_t Nstars; 789 807 unsigned int i; 790 808 double ZeroPt; 791 Stars *stars;792 809 CMF_PS1_V5 *ps1data; 793 810 … … 799 816 ZeroPt = GetZeroPoint(); 800 817 801 ALLOCATE (stars, Stars,Nstars);802 for (i = 0; i < Nstars; i++) { 803 InitStar (&stars[i]);804 stars[i].measure.Xccd = ps1data[i].X;805 stars[i].measure.Yccd = ps1data[i].Y;806 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX);807 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY);808 809 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle);810 stars[i].measure.pltscale = ps1data[i].pltscale;818 Catalog *catalog = addstar_catalog_init (Nstars); 819 820 for (i = 0; i < Nstars; i++) { 821 catalog->measure[i].Xccd = ps1data[i].X; 822 catalog->measure[i].Yccd = ps1data[i].Y; 823 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 824 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 825 826 catalog->measure[i].posangle = ToShortDegrees(ps1data[i].posangle); 827 catalog->measure[i].pltscale = ps1data[i].pltscale; 811 828 812 829 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 813 stars[i].measure.M = NAN;830 catalog->measure[i].M = NAN; 814 831 } else { 815 stars[i].measure.M = ps1data[i].M + ZeroPt;816 } 817 stars[i].measure.dM = ps1data[i].dM;818 stars[i].measure.dMcal = ps1data[i].dMcal;819 stars[i].measure.Map = ps1data[i].Map + ZeroPt;820 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN;821 822 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN;823 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN;832 catalog->measure[i].M = ps1data[i].M + ZeroPt; 833 } 834 catalog->measure[i].dM = ps1data[i].dM; 835 catalog->measure[i].dMcal = ps1data[i].dMcal; 836 catalog->measure[i].Map = ps1data[i].Map + ZeroPt; 837 catalog->measure[i].dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 838 839 catalog->measure[i].Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 840 catalog->measure[i].dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 824 841 825 842 // these fluxes are converted from counts to counts/sec in FilterStars.c 826 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M);827 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM);828 stars[i].measure.FluxKron = ps1data[i].kronFlux;829 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr;830 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map);831 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap);832 833 stars[i].measure.Sky = ps1data[i].sky;834 stars[i].measure.dSky = ps1data[i].dSky;835 836 stars[i].measure.psfChisq = ps1data[i].psfChisq;837 stars[i].measure.psfQF = ps1data[i].psfQF;838 stars[i].measure.psfQFperf = ps1data[i].psfQFperf;839 840 stars[i].measure.psfNdof = ps1data[i].psfNdof;841 stars[i].measure.psfNpix = ps1data[i].psfNpix;842 stars[i].measure.extNsigma = ps1data[i].extNsigma;843 844 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx);845 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy);846 stars[i].measure.theta = ToShortDegrees(ps1data[i].df);847 848 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx);849 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy);850 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy);851 852 stars[i].measure.photFlags = ps1data[i].flags;853 stars[i].measure.photFlags2 = ps1data[i].flags2;854 855 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 856 stars[i].measure.detID = ps1data[i].detID;843 catalog->measure[i].FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 844 catalog->measure[i].dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, catalog->measure[i].FluxPSF, ps1data[i].dM); 845 catalog->measure[i].FluxKron = ps1data[i].kronFlux; 846 catalog->measure[i].dFluxKron = ps1data[i].kronFluxErr; 847 catalog->measure[i].FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 848 catalog->measure[i].dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, catalog->measure[i].FluxAp, catalog->measure[i].dMap); 849 850 catalog->measure[i].Sky = ps1data[i].sky; 851 catalog->measure[i].dSky = ps1data[i].dSky; 852 853 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 854 catalog->measure[i].psfQF = ps1data[i].psfQF; 855 catalog->measure[i].psfQFperf = ps1data[i].psfQFperf; 856 857 catalog->measure[i].psfNdof = ps1data[i].psfNdof; 858 catalog->measure[i].psfNpix = ps1data[i].psfNpix; 859 catalog->measure[i].extNsigma = ps1data[i].extNsigma; 860 861 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 862 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 863 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 864 865 catalog->measure[i].Mxx = ToShortPixels(ps1data[i].Mxx); 866 catalog->measure[i].Mxy = ToShortPixels(ps1data[i].Mxy); 867 catalog->measure[i].Myy = ToShortPixels(ps1data[i].Myy); 868 869 catalog->measure[i].photFlags = ps1data[i].flags; 870 catalog->measure[i].photFlags2 = ps1data[i].flags2; 871 872 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 873 catalog->measure[i].detID = ps1data[i].detID; 857 874 858 875 // the Average fields and the following Measure fields are set in FilterStars after … … 865 882 // the following fields are currently not being set anywhere: t_msec 866 883 } 867 *nstars = Nstars; 868 return (stars); 869 } 884 return (catalog); 885 } 886 887 # if (0) 870 888 871 889 Stars *Convert_PS1_V5_R0_Lensing (FTable *table, unsigned int *nstars) { … … 1915 1933 return (stars); 1916 1934 } 1917 1918 1919 1935 # endif 1936 1937 -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/UpdateImageIDs.c
r38501 r38525 1 1 # include "addstar.h" 2 2 3 int UpdateImageIDs ( Stars *stars, unsigned int Nstars, Image *images, off_t Nimages) {3 int UpdateImageIDs (Catalog *catalog, Image *images, off_t Nimages) { 4 4 5 5 int i, status, isEmpty; … … 54 54 } 55 55 56 for (i = 0; i < Nstars; i++) { 57 stars[i].measure.imageID += imageID; 58 if (stars[i].lensing) { 59 stars[i].lensing->imageID += imageID; 56 off_t j, m; 57 for (i = 0; i < catalog->Naverage; i++) { 58 m = catalog->average[i].measureOffset; 59 for (j = 0; j < catalog->average[i].Nmeasure; j++, m++) { 60 catalog->measure[m].imageID += imageID; 61 } 62 m = catalog->average[i].lensingOffset; 63 for (j = 0; j < catalog->average[i].Nlensing; j++, m++) { 64 catalog->lensing[m].imageID += imageID; 60 65 } 61 66 } -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/addstar.c
r38501 r38525 6 6 int main (int argc, char **argv) { 7 7 8 unsigned int Nstars, Nsubset;9 8 int Nmatch, status, loadObjects; 10 9 off_t i, Nimages; … … 46 45 MARKTIME ("init and config: %f sec\n", dtime); RESETTIME; 47 46 48 Stars *stars= NULL;47 Catalog *newcat = NULL; 49 48 Image *images = NULL; 50 49 … … 52 51 switch (options.mode) { 53 52 case ADDSTAR_MODE_IMAGE: 54 stars = LoadStars (argv[1], &Nstars, &images, &Nimages, &options);53 newcat = LoadStars (argv[1], &images, &Nimages, &options); 55 54 MARKTIME ("load smf: %f sec\n", dtime); RESETTIME; 56 55 57 56 // set and update the imageID sequence 58 UpdateImageIDs ( stars, Nstars, images, Nimages);59 60 if ((DUMP != NULL) && !strcmp (DUMP, "rawstars")) dump_rawstars (stars, Nstars);57 UpdateImageIDs (newcat, images, Nimages); 58 59 // if ((DUMP != NULL) && !strcmp (DUMP, "rawstars")) dump_rawstars (stars, Nstars); 61 60 for (i = 0; i < Nimages; i++) { 62 61 newlist = SkyListByImage (sky, -1, &images[i]); … … 67 66 ImageOptions (&options, images, Nimages); 68 67 break; 68 # if (0) 69 69 case ADDSTAR_MODE_REFLIST: 70 70 stars = grefstars (argv[1], options.photcode, &Nstars); … … 80 80 skylist[0].ownElements = FALSE; 81 81 break; 82 # endif 82 83 83 84 default: … … 145 146 switch (options.mode) { 146 147 case ADDSTAR_MODE_IMAGE: 147 Nsubset = Nstars;148 // Nsubset = Nstars; 148 149 if (options.closest) { 149 Nmatch += find_matches_closest (skylist[0].regions[i], stars, Nstars, &catalog, options);150 Nmatch += find_matches_closest (skylist[0].regions[i], newcat, &catalog, options); 150 151 } else { 151 Nmatch += find_matches (skylist[0].regions[i], stars, Nstars, &catalog, options);152 // XXX Nmatch += find_matches (skylist[0].regions[i], stars, Nstars, &catalog, options); 152 153 } 153 154 break; 155 # if (0) 154 156 case ADDSTAR_MODE_REFCAT: 155 157 stars = greference (argv[1], skylist[0].regions[i], options.photcode, &Nstars); … … 164 166 break; 165 167 } 168 # endif 169 default: 170 abort(); 166 171 } 167 172 if (VERBOSE) MARKTIME ("match stars: %f sec\n", dtime); RESETTIME; … … 173 178 174 179 // write out catalog, if appropriate 175 if ( Nsubset&& !options.only_images) {180 if (newcat->Naverage && !options.only_images) { 176 181 SetProtect (TRUE); 177 182 if (options.update) { … … 187 192 if (VERBOSE) MARKTIME ("save cpt: %f sec\n", dtime); RESETTIME; 188 193 189 if (options.mode == ADDSTAR_MODE_REFCAT) free (stars);194 if (options.mode == ADDSTAR_MODE_REFCAT) dvo_catalog_free (newcat); 190 195 } 191 196 SkyListFree (skylist); 192 197 193 198 if (options.mode != ADDSTAR_MODE_REFCAT) { 194 FREE (stars); 199 dvo_catalog_free (newcat); 200 free (newcat); 195 201 } 196 202 … … 229 235 gettimeofday (&stopAddstar, (void *) NULL); 230 236 float dtime = DTIME (stopAddstar, startAddstar); 231 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for %5d stars (%5d matches), "OFF_T_FMT" average, "OFF_T_FMT" measure, "OFF_T_FMT" lensing\n", dtime, Nstars, Nmatch, Naverage, Nmeasure, Nlensing);237 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for "OFF_T_FMT" stars (%5d matches), "OFF_T_FMT" average, "OFF_T_FMT" measure, "OFF_T_FMT" lensing\n", dtime, newcat->Naverage, Nmatch, Naverage, Nmeasure, Nlensing); 232 238 233 239 // XXX test -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/find_matches_closest.c
r38467 r38525 1 1 # include "addstar.h" 2 2 3 int find_matches_closest (SkyRegion *region, Stars *stars, unsigned int NstarsIn, Catalog *catalog, AddstarClientOptions options) {3 int find_matches_closest (SkyRegion *region, Catalog *newcat, Catalog *catalog, AddstarClientOptions options) { 4 4 5 5 off_t i, j, n, N, J, Jmin, status, Nstars; … … 13 13 Coords tcoords; 14 14 15 // XXX this probably is no longer needed (absorbed by catalog->average[j].Nmeasure 15 16 if (NSTAR_GROUP <= 0) { 16 17 fprintf (stderr, "ERROR: NSTAR_GROUP NOT SET!\n"); … … 26 27 Nsec = GetPhotcodeNsec (options.photcode); 27 28 28 /** allocate local arrays (stars) **/ 29 ALLOCATE (X1, double, NstarsIn); 30 ALLOCATE (Y1, double, NstarsIn); 31 ALLOCATE (N1, off_t, NstarsIn); 29 /** allocate local arrays (newcat) **/ 30 ALLOCATE (X1, double, newcat->Naverage); 31 ALLOCATE (Y1, double, newcat->Naverage); 32 ALLOCATE (N1, off_t, newcat->Naverage); 33 34 if (!newcat->found_t) { 35 ALLOCATE (newcat->found_t, off_t, newcat->Naverage); 36 for (i = 0; i < newcat->Naverage; i++) { 37 newcat->found_t[i] = -1; 38 } 39 } 32 40 33 41 /** allocate local arrays (catalog) **/ … … 64 72 /* build spatial index (RA sort) referencing input array sequence */ 65 73 Nstars = 0; 66 for (i = 0; i < NstarsIn; i++) {67 status = RD_to_XY (&X1[Nstars], &Y1[Nstars], stars[i].average.R, stars[i].average.D, &tcoords);74 for (i = 0; i < newcat->Naverage; i++) { 75 status = RD_to_XY (&X1[Nstars], &Y1[Nstars], newcat->average[i].R, newcat->average[i].D, &tcoords); 68 76 if (!status) continue; 69 77 N1[Nstars] = i; … … 129 137 } 130 138 131 if (stars[N1[i]].found != -1) { 139 // XXX check that this is allocated 140 if (newcat->found_t[N1[i]] != -1) { 132 141 /* this star has already been assigned to an object in this or another catalog */ 133 142 i++; … … 186 195 187 196 // set the new measurements 188 catalog[0].measure[Nmeas] = stars[N].measure;197 catalog[0].measure[Nmeas] = newcat->measure[N]; 189 198 190 199 // measure now carries R,D (not dR,dD) … … 213 222 fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n", 214 223 catalog[0].average[n].R, catalog[0].average[n].D, 215 stars[N].average.R, stars[N].average.D,224 newcat->average[N].R, newcat->average[N].D, 216 225 X1[i], X2[Jmin], 217 226 Y1[i], Y2[Jmin]); … … 221 230 222 231 // add the lensing values if they exist 223 if ( stars[N].lensing) {232 if (newcat->lensing) { 224 233 add_lens_link (&catalog[0].average[n], next_lens, Nlens, NLENS); // ? 225 catalog[0].lensing[Nlens] = stars[N].lensing[0];234 catalog[0].lensing[Nlens] = newcat->lensing[N]; 226 235 227 236 catalog[0].lensing[Nlens].averef = n; … … 251 260 /* Nm is updated, but not written out in -update mode (for existing entries) 252 261 Nm is recalculated in build_meas_links if loaded table is not sorted */ 253 stars[N].found= Nmeas;262 newcat->found_t[N] = Nmeas; 254 263 catalog[0].found_t[n] = Nmeas; 255 264 catalog[0].average[n].Nmeasure ++; … … 278 287 } 279 288 280 if ( stars[i].found!= -1) continue;281 if (!IN_REGION ( stars[i].average.R, stars[i].average.D)) continue;289 if (newcat->found_t[i] != -1) continue; 290 if (!IN_REGION (newcat->average[i].R, newcat->average[i].D)) continue; 282 291 283 292 dvo_average_init (&catalog[0].average[Nave]); 284 catalog[0].average[Nave].R = stars[i].average.R;285 catalog[0].average[Nave].D = stars[i].average.D;293 catalog[0].average[Nave].R = newcat->average[i].R; 294 catalog[0].average[Nave].D = newcat->average[i].D; 286 295 287 296 catalog[0].average[Nave].Nmeasure = NSTAR_GROUP; … … 303 312 // supply the measurments from this detection 304 313 dvo_measure_init (&catalog[0].measure[Nmeas]); 305 catalog[0].measure[Nmeas] = stars[i + j].measure;314 catalog[0].measure[Nmeas] = newcat->measure[i + j]; 306 315 307 316 // the following measure elements cannot be set until here: … … 319 328 /* next[Nmeas] should always be -1 in this context (it is always the only 320 329 measurement for the star) */ 321 stars[i+j].found= Nmeas;330 newcat->found_t[i+j] = Nmeas; 322 331 next_meas[Nmeas] = -1; // inital value here update below 323 332 Nmeas ++; … … 328 337 329 338 // if we have lensing data, insert that as well 330 if ( stars[i].lensing) {339 if (newcat->lensing) { 331 340 catalog[0].average[Nave].Nlensing = NSTAR_GROUP; 332 341 catalog[0].average[Nave].lensingOffset = Nlens; 333 342 for (j = 0; j < NSTAR_GROUP; j++) { 334 343 // add the lensing values if they exist 335 if ( stars[i + j].lensing) {344 if (newcat->lensing) { 336 345 dvo_lensing_init (&catalog[0].lensing[Nlens]); 337 catalog[0].lensing[Nlens] = stars[i + j].lensing[0];346 catalog[0].lensing[Nlens] = newcat->lensing[i + j]; 338 347 339 348 catalog[0].lensing[Nlens].averef = Nave; … … 365 374 366 375 /* note stars which have been found in this catalog */ 367 for (i = 0; i < NstarsIn; i++) {368 if ( stars[i].found> -1) {369 stars[i].found= -2;376 for (i = 0; i < newcat->Naverage; i++) { 377 if (newcat->found_t[i] > -1) { 378 newcat->found_t[i] = -2; 370 379 } 371 380 }
Note:
See TracChangeset
for help on using the changeset viewer.
