Changeset 38522
- Timestamp:
- Jun 23, 2015, 4:11:40 PM (11 years ago)
- Location:
- branches/eam_branches/ipp-20150616/Ohana/src/addstar
- Files:
-
- 1 added
- 9 edited
-
Makefile (modified) (1 diff)
-
include/addstar.h (modified) (3 diffs)
-
src/ImageIndex.c (modified) (2 diffs)
-
src/LoadData.c (modified) (4 diffs)
-
src/LoadDataPMM.c (modified) (3 diffs)
-
src/LoadDataSDSS.c (modified) (3 diffs)
-
src/LoadDataUKIRT.c (modified) (3 diffs)
-
src/LoadFilenames.c (added)
-
src/LoadStars.c (modified) (7 diffs)
-
src/ReadStarsUKIRT.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20150616/Ohana/src/addstar/Makefile
r38521 r38522 71 71 $(SRC)/grefstars.$(ARCH).o \ 72 72 $(SRC)/GetZeroPointExposure.$(ARCH).o \ 73 $(SRC)/LoadFilenames.$(ARCH).o \ 73 74 $(SRC)/LoadStars.$(ARCH).o \ 74 75 $(SRC)/LoadHeaders.$(ARCH).o \ -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/include/addstar.h
r38501 r38522 33 33 34 34 # define myAbortF(FORMAT,...) { fprintf (stderr, FORMAT, __VA_ARGS__); abort(); } 35 36 // things that are needed for a single file 37 typedef struct { 38 char *filename; // name of the file on disk (full path) 39 char *imagename; // name of the image for user reference (eg, base of neb path, full path, etc) 40 } AddstarFile; 35 41 36 42 typedef struct { … … 232 238 HeaderSet *MatchHeaders PROTO((off_t **extsize, off_t *nimage, int mode, Header **headers, int Nheaders)); 233 239 void HeaderSetFree PROTO((HeaderSet *headerSets, off_t NheaderSets)); 234 int LoadData PROTO((FILE *f, char*file, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, int NheaderSets, AddstarClientOptions *options));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)); 235 241 int GetZeroPointExposure PROTO((Header **headers, HeaderSet *headerSets, off_t Nimages)); 236 242 … … 336 342 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); 337 343 344 AddstarFile *LoadFilenames (int *nfile, char *filename, AddstarClientOptions *options); 345 void AddstarFileFree (AddstarFile *file, int Nfile); 346 338 347 /** 339 348 there is an inconsistency to be resolved: fixed structures (like Image) -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/ImageIndex.c
r38501 r38522 199 199 200 200 // extend the storage arrays 201 // no reason to extend 'found' 201 202 REALLOCATE (index->imageID, IDTYPE, index->Nimage + Nimages); 202 203 REALLOCATE (index->externID, IDTYPE, index->Nimage + Nimages); … … 226 227 ALLOCATE (index->imageID, IDTYPE, 1); 227 228 ALLOCATE (index->externID, IDTYPE, 1); 229 ALLOCATE (index->found, char, 1); 228 230 index->Nimage = 0; 229 231 -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadData.c
r38501 r38522 5 5 6 6 // examine the header sets and set the Image entries for the the valid images 7 int LoadData (FILE *f, char*file, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, int Nimages, AddstarClientOptions *options) {7 int LoadData (FILE *f, AddstarFile *file, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, int Nimages, AddstarClientOptions *options) { 8 8 9 char *name;10 9 off_t Nskip, Nvalid, NVALID; 11 10 int i, j, Nhead, Ndata; … … 22 21 REALLOCATE (images[0], Image, NVALID); 23 22 } 24 25 // find image rootname26 if (USE_NAME) {27 name = filebasename (USE_NAME);28 } else {29 name = filebasename (file);30 }31 23 32 24 // if zero points are calculated for the full exposure using more than just the matched chip header, … … 58 50 // XXX use something to set the chip name? EXTNAME? 59 51 if (!strcmp(headerSets[i].exthead, "PHU") && (Nimages == 1)) { 60 snprintf (images[0][Nvalid].name, DVO_IMAGE_NAME_LEN, "%s", name);52 snprintf (images[0][Nvalid].name, DVO_IMAGE_NAME_LEN, "%s", file->imagename); 61 53 } else { 62 snprintf (images[0][Nvalid].name, DVO_IMAGE_NAME_LEN, "%s[%s]", name, headerSets[i].exthead);54 snprintf (images[0][Nvalid].name, DVO_IMAGE_NAME_LEN, "%s[%s]", file->imagename, headerSets[i].exthead); 63 55 } 64 56 … … 117 109 stars[0][i].measure.Map += OFFSET_ZPT; 118 110 } 119 120 111 } 121 112 122 free (name);123 113 *nvalid = Nvalid; 124 114 return (TRUE); -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadDataPMM.c
r37807 r38522 15 15 # define MAG_INDEX_ASC 22 16 16 17 int LoadDataPMM (FILE *f, char * file, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars) {17 int LoadDataPMM (FILE *f, char *imagename, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars) { 18 18 19 19 off_t Nvalid, NVALID; 20 char * name, *buffer;20 char *buffer; 21 21 int i, fd, Nbyte, Nline, code; 22 22 double ra, dec, mag, airmass, az, ZeroPoint, ZeroPt; … … 38 38 } 39 39 40 // find image rootname41 name = filebasename (file);42 43 40 // there is only one PMM image per file 44 if (VERBOSE) fprintf (stderr, "reading data for %s\n", file);41 if (VERBOSE) fprintf (stderr, "reading data for %s\n", imagename); 45 42 46 43 ZeroPt = GetZeroPoint(); 47 44 48 45 // need to get the metadata from the PMM_CCD_TABLE 49 photcode = LoadMetadataPMM ( name, &images[0][Nvalid]);46 photcode = LoadMetadataPMM (imagename, &images[0][Nvalid]); 50 47 code = photcode[0].code; 51 48 ZeroPoint = 0.001*photcode[0].C; … … 121 118 122 119 free (inStars); 123 free (name);124 120 *nvalid = Nvalid + 1; 125 121 -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadDataSDSS.c
r27435 r38522 4 4 // there should only be a single data set (phu + table) in this file 5 5 // each SDSS data set corresponds to 5 images (ugriz) 6 int LoadDataSDSS (FILE *f, char * file, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, off_t Nimages) {6 int LoadDataSDSS (FILE *f, char *imagename, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, off_t Nimages) { 7 7 8 8 off_t Nskip, Nvalid, NVALID; 9 char *name;10 9 int j, Nhead, Ndata; 11 10 unsigned int Ninstars; … … 21 20 REALLOCATE (images[0], Image, NVALID); 22 21 } 23 24 // find image rootname25 name = filebasename (file);26 22 27 23 // there is only one SDSS image per file (TRUE?) … … 40 36 41 37 // XXX I think this is an error? should this be &images[0][Nvalid] ?? 42 inStars = ReadStarsSDSS (f, name, headers[Nhead], headers[Ndata], images[0], &Nvalid, &Ninstars);38 inStars = ReadStarsSDSS (f, imagename, headers[Nhead], headers[Ndata], images[0], &Nvalid, &Ninstars); 43 39 *stars = MergeStars (*stars, Nstars, inStars, Ninstars); 44 40 45 free (name);46 41 *nvalid = Nvalid; 47 42 return (TRUE); -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadDataUKIRT.c
r38467 r38522 3 3 // examine the header sets and set the Image entries for the the valid images 4 4 // UKIRT data has the WCS/image metadata header intermixed with the bintable header 5 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) { 5 6 int LoadDataUKIRT (FILE *f, char *imagename, Image **images, off_t *nimages, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, off_t NheaderSets) { 6 7 7 8 off_t Nskip, Nvalid, NVALID; 8 char *name;9 9 int i, j, Nhead, Ndata; 10 10 unsigned int Ninstars; … … 22 22 } 23 23 24 // find image rootname25 name = filebasename (file);26 27 24 // validate the number of headers sets == 4 28 25 for (i = 0; i < NheaderSets; i++) { … … 38 35 fseeko (f, Nskip, SEEK_SET); 39 36 40 inStars = ReadStarsUKIRT (f, name, headers[Nhead], images[0], &Nvalid, &Ninstars);37 inStars = ReadStarsUKIRT (f, imagename, headers[Nhead], images[0], &Nvalid, &Ninstars); 41 38 *stars = MergeStars (*stars, Nstars, inStars, Ninstars); 42 39 -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadStars.c
r38521 r38522 4 4 5 5 off_t *extsize; 6 int i, Nfile, NFILE, mode; 7 char **file, line[4096]; 8 FILE *f; 9 glob_t globList; 6 int i, Nfile, mode; 10 7 Stars *stars; 11 8 12 if (options[0].filelist) { 13 // read the list of input files from the supplied file 14 f = fopen (filename, "r"); 15 if (f == NULL) { 16 fprintf (stderr, "can't read input list %s, giving up\n", filename); 17 exit (1); 18 } 19 20 NFILE = 10; 21 ALLOCATE (file, char *, NFILE); 22 for (i = 0; (scan_line (f, line) != EOF); i++) { 23 // find first non-whitespace char & skip commented lines 24 for (i = 0; OHANA_WHITESPACE (line[i]); i++); 25 if (line[i] == '#') continue; 26 if (line[i] == 0) continue; 27 28 // file lines may have: 29 // filename 30 // filename = nebname 31 // filename limited to 4096 chars 32 Nfield = sscanf (line, "%s %s %s", word1, sep, word2); 33 if ((Nfield != 1) && (Nfield != 3)) { 34 fprintf (stderr, "invalid *line: %s 35 } 36 37 fprintf (stderr, "file: %s\n", line); 38 file[i] = strcreate (line); 39 if (i == NFILE - 1) { 40 NFILE += 10; 41 REALLOCATE (file, char *, NFILE); 42 } 43 } 44 Nfile = i; 45 } else { 46 // parse the filename as a glob 47 globList.gl_offs = 0; 48 glob (filename, 0, NULL, &globList); 49 50 // if the glob does not match, save the literal word: 51 // otherwise save all glob matches 52 if (globList.gl_pathc == 0) { 53 Nfile = 1; 54 ALLOCATE (file, char *, Nfile); 55 file[0] = strcreate (filename); 56 } else { 57 Nfile = globList.gl_pathc; 58 ALLOCATE (file, char *, Nfile); 59 for (i = 0; i < Nfile; i++) { 60 file[i] = strcreate (globList.gl_pathv[i]); 61 } 62 } 63 } 9 AddstarFile *file = LoadFilenames (&Nfile, filename, options); 64 10 65 11 *Nimages = 0; … … 69 15 70 16 for (i = 0; i < Nfile; i++) { 71 f = fopen (file[i], "r");17 FILE *f = fopen (file[i].filename, "r"); 72 18 if (f == NULL) { 73 fprintf (stderr, "can't read file %s, skipping\n", file[i] );19 fprintf (stderr, "can't read file %s, skipping\n", file[i].filename); 74 20 continue; 75 21 } … … 77 23 // load PMM data if specified (these are not stored as FITS-tables) 78 24 if (PMM_CCD_TABLE != NULL) { 79 LoadDataPMM (f, file[i] , images, Nimages, &stars, Nstars);25 LoadDataPMM (f, file[i].imagename, images, Nimages, &stars, Nstars); 80 26 continue; 81 27 } … … 90 36 headerSets = MatchHeaders (&extsize, &NheaderSets, mode, headers, Nheaders); 91 37 if (headerSets == NULL) { 92 fprintf (stderr, "ERROR: can't read headers for %s\n", file[i] );38 fprintf (stderr, "ERROR: can't read headers for %s\n", file[i].filename); 93 39 goto next_file; 94 40 } 95 41 if (NheaderSets == 0) { 96 fprintf (stderr, "no object data in file %s, skipping\n", file[i] );42 fprintf (stderr, "no object data in file %s, skipping\n", file[i].filename); 97 43 goto next_file; 98 44 } 99 if (VERBOSE) fprintf (stderr, "file %s has %d headers, including "OFF_T_FMT" images\n", file[i] , Nheaders, NheaderSets);45 if (VERBOSE) fprintf (stderr, "file %s has %d headers, including "OFF_T_FMT" images\n", file[i].filename, Nheaders, NheaderSets); 100 46 101 47 /* supplied photcode is incompatible with multi-chip images */ … … 112 58 // if these are SDSS data, load with SDSS-specific wrapper 113 59 if (headerSets[0].exttype && !strcmp (headerSets[0].exttype, "SDSS_OBJ")) { 114 LoadDataSDSS (f, file[i] , images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets);60 LoadDataSDSS (f, file[i].imagename, images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets); 115 61 goto next_file; 116 62 } … … 118 64 // if these are SDSS data, load with SDSS-specific wrapper 119 65 if (headerSets[0].exttype && !strcmp (headerSets[0].exttype, "UKIRT_OBJ")) { 120 LoadDataUKIRT (f, file[i] , images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets);66 LoadDataUKIRT (f, file[i].imagename, images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets); 121 67 goto next_file; 122 68 } 123 69 124 LoadData (f, file[i], images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets, options); 125 126 // XXX add a function to (optionally) load the extended source measurements 127 # if (0) 128 if (extSources) { 129 // not sure how to link the measurements here to the psf measurements above (though there is an ID in the det list) 130 LoadDataXSRC (f, file[i], images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets); 131 } 132 if (extFits) { 133 LoadDataXFIT (f, file[i], images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets); 134 } 135 # endif 70 LoadData (f, &file[i], images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets, options); 136 71 137 72 next_file: … … 153 88 exit (0); 154 89 } 90 ohana_memcheck (TRUE); 155 91 156 for (i = 0; i < Nfile; i++) { 157 FREE (file[i]); 158 } 159 FREE (file); 160 92 AddstarFileFree (file, Nfile); 161 93 return stars; 162 94 } -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/ReadStarsUKIRT.c
r38496 r38522 8 8 // given a file with the pointer at the start of the table block and the 9 9 // corresponding image header, load the stars from the table 10 Stars *ReadStarsUKIRT (FILE *f, char * name, Header *header, Image *images, off_t *nimages, unsigned int *nstars) {10 Stars *ReadStarsUKIRT (FILE *f, char *imagename, Header *header, Image *images, off_t *nimages, unsigned int *nstars) { 11 11 12 12 off_t Nrow; … … 250 250 251 251 // save the filename 252 snprintf (images[N].name, DVO_IMAGE_NAME_LEN, "%s[%02d]", name, detID);252 snprintf (images[N].name, DVO_IMAGE_NAME_LEN, "%s[%02d]", imagename, detID); 253 253 *nimages = N + 1; 254 254 }
Note:
See TracChangeset
for help on using the changeset viewer.
