Changeset 10937
- Timestamp:
- Jan 5, 2007, 10:51:17 AM (19 years ago)
- Location:
- trunk/Ohana/src/addstar
- Files:
-
- 4 added
- 11 edited
-
Makefile (modified) (3 diffs)
-
doc/notes.txt (modified) (1 diff)
-
include/addstar.h (modified) (8 diffs)
-
src/FilterStars.c (modified) (4 diffs)
-
src/GetFileMode.c (added)
-
src/ImageOptions.c (added)
-
src/ReadImageHeader.c (added)
-
src/ReadStarsFITS.c (modified) (8 diffs)
-
src/Shutdown.c (modified) (2 diffs)
-
src/addstar.c (modified) (9 diffs)
-
src/args.c (modified) (1 diff)
-
src/find_matches.c (modified) (15 diffs)
-
src/find_missing.c (added)
-
src/gstars.c (modified) (7 diffs)
-
src/parse_time.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/Makefile
r10342 r10937 41 41 $(SRC)/fakeimage.$(ARCH).o \ 42 42 $(SRC)/find_matches.$(ARCH).o \ 43 $(SRC)/find_matches_closest.$(ARCH).o \44 43 $(SRC)/find_matches_refstars.$(ARCH).o \ 45 44 $(SRC)/find_subset.$(ARCH).o \ … … 53 52 $(SRC)/getusno.$(ARCH).o \ 54 53 $(SRC)/getusnob.$(ARCH).o \ 55 $(SRC)/gimages.$(ARCH).o \56 54 $(SRC)/greference.$(ARCH).o \ 57 55 $(SRC)/grefstars.$(ARCH).o \ … … 63 61 $(SRC)/replace_match.$(ARCH).o \ 64 62 $(SRC)/resort_catalog.$(ARCH).o \ 65 $(SRC)/rfits.$(ARCH).o \ 66 $(SRC)/rtext.$(ARCH).o \ 67 $(SRC)/sort_lists.$(ARCH).o \ 63 $(SRC)/ReadStarsFITS.$(ARCH).o \ 64 $(SRC)/ReadStarsTEXT.$(ARCH).o \ 65 $(SRC)/FilterStars.$(ARCH).o \ 66 $(SRC)/sort_lists.$(ARCH).o \ 67 $(SRC)/ImageOptions.$(ARCH).o \ 68 $(SRC)/GetFileMode.$(ARCH).o \ 69 $(SRC)/ReadImageHeader.$(ARCH).o \ 68 70 $(SRC)/update_coords.$(ARCH).o 71 72 # $(SRC)/gimages.$(ARCH).o \ 73 # $(SRC)/find_matches_closest.$(ARCH).o \ 69 74 70 75 ADDSTARD = \ -
trunk/Ohana/src/addstar/doc/notes.txt
r6763 r10937 1 2 2007.01.04 3 4 Use of options.photcode: 5 - M_REFLIST: used to assign a photcode value to the loaded data 6 - M_REFCAT: used to select data from the reference of the given photcode 7 - M_FAKEIMAGE: used to assign a photcode value to the generated data 8 - M_RESORT: unused 9 - M_IMAGE: is used to override or supply the image header photcode 10 * only valid for single chip runs 11 12 Re: MOSAIC_PHU 13 - the mosaic phu needs to have the time to enable the image/mosaic match 14 15 - NX,NY are used for plotting the mosaic outline. the center of 16 the mosaic is 0,0, and the mosaic outline is drawn from 17 -NX/2,-NY/2 to NX/2,NY/2. A problem: NX,NY in Image is using 18 a short int. If the units of the FPA/TPA coords are microns, this overflows. 19 * change NX,NY to int? 20 * require the use of mm not microns? 21 * for GPC, NX,NY ~ 384000 um excluding gaps 22 23 - only the astrometry, time, and NX,NY are loaded for MOSAIC_PHU headers. 24 25 2007.01.03 26 27 I am working on adding the ability to read MEF files containing 28 multiple tables and multiple image headers. Here are the details: 29 30 SIMPLE CMP: 31 PHU: 32 NAXIS = 2 or 33 SIMPLE = FALSE or 34 TEXTMODE = TRUE (use option; global variable) 35 36 SIMPLE CMF: 37 PHU: 38 NAXIS = 0 39 NAXIS1 exists, > 0 40 NAXIS2 exists, > 0 41 EXT: 42 EXTNAME = SMPDATA, PS1DATA, etc (defines layout) 43 44 SIMPLE MEF: 45 PHU: 46 NAXIS = 0 47 NAXIS1 does not exist 48 NAXIS2 does not exist 49 &CTYPE[4] is not "-DIS" 50 EXTEND is true 51 EXT HEAD: 52 EXTTYPE = IMAGE 53 EXTNAME = image.name 54 EXTDATA = table.name 55 EXT DATA: 56 EXTTYPE = SMPDATA, PS1DATA, etc (defines layout) 57 EXTNAME = table.name 58 EXTHEAD = image.name 59 60 MOSAIC MEF: 61 PHU: 62 NAXIS = 0 63 NAXIS1 does not exist 64 NAXIS2 does not exist 65 &CTYPE[4] is "-DIS" 66 EXTEND is true 67 EXT HEAD: 68 EXTTYPE = IMAGE 69 EXTNAME = image.name 70 EXTDATA = table.name 71 EXT DATA: 72 EXTTYPE = SMPDATA, PS1DATA, etc (defines layout) 73 EXTNAME = table.name 74 EXTHEAD = image.name 75 76 MOSAIC PHU: 77 PHU: 78 NAXIS = 0 79 NAXIS1 does not exist 80 NAXIS2 does not exist 81 &CTYPE[4] is "-DIS" 82 NEXTEND = 0 or 83 EXTEND is false 84 85 1 86 2 87 2006.04.02 -
trunk/Ohana/src/addstar/include/addstar.h
r10889 r10937 11 11 12 12 /* used in find_matches, find_matches_refstars */ 13 # define IN_ CATALOG(R,D) ( \13 # define IN_REGION(R,D) ( \ 14 14 ((D) >= region[0].Dmin) && ((D) < region[0].Dmax) && \ 15 15 ((R) >= region[0].Rmin) && ((R) < region[0].Rmax)) … … 35 35 36 36 enum {M_IMAGE, M_REFLIST, M_REFCAT, M_FAKEIMAGE, M_RESORT}; 37 38 /* global which define database info / data sources (KEEP) */ 37 enum {NONE, SIMPLE_CMP, SIMPLE_CMF, SIMPLE_MEF, MOSAIC_CMP, MOSAIC_CMF, MOSAIC_MEF, MOSAIC_PHU}; 38 /* note: MEF implies CMF */ 39 40 /* globals which define database info / data sources (KEEP) */ 39 41 char ImageCat[256]; 40 42 char GSCFILE[256]; … … 108 110 109 111 /*** addstar prototypes ***/ 112 110 113 void AddToCalibration PROTO((Average *average, Measure *measure, Measure *new, int *next, int Nstar)); 111 114 AddstarClientOptions ConfigInit PROTO((int *argc, char **argv)); … … 126 129 int edge_check PROTO((double *x1, double *y1, double *x2, double *y2)); 127 130 Image *fakeimage PROTO((char *rootname, int *Nimage, int photcode)); 128 int find_matches PROTO((SkyRegion *region, Stars *stars, int Nstars, Catalog *catalog, Image *image, Image *overlap, int Noverlap, Coords *mosaic,AddstarClientOptions options));129 int find_matches_closest PROTO((SkyRegion *region, Stars *stars, int Nstars, Catalog *catalog, Image *image, Image *overlap, int Noverlap, Coords *mosaic,AddstarClientOptions options));131 int find_matches PROTO((SkyRegion *region, Stars *stars, int Nstars, Catalog *catalog, AddstarClientOptions options)); 132 int find_matches_closest PROTO((SkyRegion *region, Stars *stars, int Nstars, Catalog *catalog, AddstarClientOptions options)); 130 133 int find_matches_refstars PROTO((SkyRegion *region, Stars **stars, int Nstars, Catalog *catalog, AddstarClientOptions options)); 131 134 Stars **find_subset PROTO((SkyRegion *region, Stars *stars, int Nstars, int *NSTARS)); … … 140 143 Stars *grefcat PROTO((char *Refcat, SkyRegion *catstats, int photcode, int *nstars)); 141 144 Stars *grefstars PROTO((char *file, int photcode, int *Nstars)); 142 Stars *gstars PROTO((char *file, int *N STARS, int photcode, Image *image));145 Stars *gstars PROTO((char *file, int *Nstars, Image **images, int *Nimages, int photcode)); 143 146 int in_image PROTO((double r, double d, Image *image)); 144 147 int load_pt_catalog PROTO((Catalog *catalog, SkyRegion *region)); /*** choose new name ***/ … … 156 159 Stars *rfits PROTO((FILE *f, unsigned int *nstars)); 157 160 Stars *rtext PROTO((FILE *f, unsigned int *nstars)); 161 Stars *ReadStarsFITS PROTO((FILE *f, Header *header, Header *in_theader, unsigned int *nstars)); 162 Stars *ReadStarsTEXT PROTO((FILE *f, unsigned int *nstars)); 163 int ReadImageHeader PROTO((Header *header, Image *image, int photcode)); 164 Stars *FilterStars PROTO((Stars *instars, Image *image)); 165 Stars *MergeStars PROTO((Stars *stars, int *Nstars, Stars *instars, int Ninstars)); 158 166 void save_pt_catalog PROTO((Catalog *catalog)); /*** choose new name ***/ 159 167 double scat_subpix PROTO((double x, double y)); … … 169 177 void create_image_db PROTO((FITS_DB *db)); 170 178 void set_db PROTO((FITS_DB *in)); 171 172 179 void uppercase PROTO((char *string)); 173 180 void fsort PROTO((float *X, int N)); 174 181 void fsort2 PROTO((float *X, float *Y, int N)); 175 176 int *init_measure_links (Average *average, int Naverage, Measure *measure, int Nmeasure); 177 int *init_missing_links (Average *average, int Naverage, Missing *missing, int Nmissing); 178 int add_meas_link (Average *average, int *next, int Nmeasure, int NMEASURE); 179 int add_miss_link (Average *average, int *next, int Nmissing); 180 int *build_measure_links (Average *average, int Naverage, Measure *measure, int Nmeasure); 181 Measure *sort_measure (Average *average, int Naverage, Measure *measure, int Nmeasure, int *next); 182 Missing *sort_missing (Average *average, int Naverage, Missing *missing, int Nmissing, int *next_miss); 182 int *init_measure_links PROTO((Average *average, int Naverage, Measure *measure, int Nmeasure)); 183 int *init_missing_links PROTO((Average *average, int Naverage, Missing *missing, int Nmissing)); 184 int add_meas_link PROTO((Average *average, int *next, int Nmeasure, int NMEASURE)); 185 int add_miss_link PROTO((Average *average, int *next, int Nmissing)); 186 int *build_measure_links PROTO((Average *average, int Naverage, Measure *measure, int Nmeasure)); 187 Measure *sort_measure PROTO((Average *average, int Naverage, Measure *measure, int Nmeasure, int *next)); 188 Missing *sort_missing PROTO((Average *average, int Naverage, Missing *missing, int Nmissing, int *next_miss)); 189 Stars *ConvertSMPDATA PROTO((FTable *table, int *nstars)); 190 // Stars *ConvertPS1DATA PROTO((FTable *table, int *nstars)); 191 int ImageOptions PROTO((AddstarClientOptions *options, Image *images, int Nimages)); 192 int GetFileMode PROTO((Header *header)); 193 AddstarClientOptions args_client PROTO((int argc, char **argv, AddstarClientOptions options)); 194 AddstarClientOptions args_load2mass PROTO((int argc, char **argv, AddstarClientOptions options)); 195 AddstarClientOptions args_sedstar PROTO((int argc, char **argv, AddstarClientOptions options)); 196 void args_server PROTO((int argc, char **argv)); 197 int CheckPassword PROTO((int BindSocket)); 198 int NewImage PROTO((int BindSocket)); 199 int NewReflist PROTO((int BindSocket)); 200 int NewRefcat PROTO((int BindSocket)); 201 int InitServerSocket PROTO((SockAddress *Address)); 202 int WaitServerSocket PROTO((int InitSocket, SockAddress *Address, int *validIP, int Nvalid)); 203 int GetClientSocket PROTO((char *hostname)); 204 int UpdateDatabase_Image PROTO((AddstarClientOptions *options, Image *image, Coords *mosaic, Stars *stars, int Nstars)); 205 int UpdateDatabase_Reflist PROTO((AddstarClientOptions *options, Stars *stars, int Nstars)); 206 int UpdateDatabase_Refcat PROTO((AddstarClientOptions *options, SkyRegion *UserPatch, char *refcat)); 207 SkyList *SkyListForStars PROTO((SkyTable *table, int depth, Stars *stars, int Nstars)); 208 SkyList *SkyListExistingSubset PROTO((SkyList *input, char *path)); 209 int SkyListSetPath PROTO((SkyList *list, char *path)); 210 SkyTable *SkyTableLoadOptimal PROTO(()); 211 int InitDataset PROTO(()); 212 int PushDataset PROTO((DVO_DATA *data)); 213 DVO_DATA *PopDataset PROTO((void)); 214 void *ListenClients_Thread PROTO((void *data)); 215 int NewImage_Thread PROTO((int BindSocket)); 216 int NewRefcat_Thread PROTO((int BindSocket)); 217 int NewReflist_Thread PROTO((int BindSocket)); 218 219 // this is a gnu extension?? caution! 220 void *memrchr(const void *s, int c, size_t n); 183 221 184 222 /** … … 191 229 **/ 192 230 231 193 232 /** function for client / server **/ 194 233 195 AddstarClientOptions args_client (int argc, char **argv, AddstarClientOptions options);196 AddstarClientOptions args_load2mass (int argc, char **argv, AddstarClientOptions options);197 AddstarClientOptions args_sedstar (int argc, char **argv, AddstarClientOptions options);198 199 void args_server (int argc, char **argv);200 201 int CheckPassword (int BindSocket);202 int NewImage (int BindSocket);203 int NewReflist (int BindSocket);204 int NewRefcat (int BindSocket);205 206 int InitServerSocket (SockAddress *Address);207 int WaitServerSocket (int InitSocket, SockAddress *Address, int *validIP, int Nvalid);208 int GetClientSocket (char *hostname);209 210 int UpdateDatabase_Image (AddstarClientOptions *options, Image *image, Coords *mosaic, Stars *stars, int Nstars);211 int UpdateDatabase_Reflist (AddstarClientOptions *options, Stars *stars, int Nstars);212 int UpdateDatabase_Refcat (AddstarClientOptions *options, SkyRegion *UserPatch, char *refcat);213 214 SkyList *SkyListForStars (SkyTable *table, int depth, Stars *stars, int Nstars);215 SkyList *SkyListExistingSubset (SkyList *input, char *path);216 int SkyListSetPath (SkyList *list, char *path);217 SkyTable *SkyTableLoadOptimal ();218 219 int InitDataset ();220 int PushDataset (DVO_DATA *data);221 DVO_DATA *PopDataset (void);222 void *ListenClients_Thread (void *data);223 int NewImage_Thread (int BindSocket);224 int NewRefcat_Thread (int BindSocket);225 int NewReflist_Thread (int BindSocket);226 227 // this is a gnu extension?? caution!228 void *memrchr(const void *s, int c, size_t n); -
trunk/Ohana/src/addstar/src/FilterStars.c
r10897 r10937 4 4 5 5 int j, N; 6 float MTIME, dMs; 7 Stars *stars; 8 9 /* correct instrumental mags for exposure time */ 10 MTIME = (image[0].exptime > 0) ? 2.500*log10(image[0].exptime) : 0.0; 6 11 7 12 /* modify resulting star list */ 8 ALLOCATE (stars, Stars, image[0].nstar s);9 for (N = j = 0; j < image[0].nstar s; j++) {13 ALLOCATE (stars, Stars, image[0].nstar); 14 for (N = j = 0; j < image[0].nstar; j++) { 10 15 /* allow for some dynamic filtering of star list */ 11 16 if (SNLIMIT && instars[j].dM > SNLIMIT) continue; … … 20 25 while (stars[N].R >= 360.0) stars[N].R -= 360.0; 21 26 stars[N].found = -1; 22 stars[N].code = photcode;27 stars[N].code = image[0].source; 23 28 29 /** additional quantities to supply to Stars based on the image data **/ 30 31 /* calculate accurate per-star airmass */ 32 stars[N].airmass = airmass (image[0].secz_PS, stars[N].R, stars[N].D, image[0].sidtime, image[0].latitude); 33 stars[N].Mcal = image[0].Mcal_PS; 34 stars[N].t = image[0].tzero + 1e-4*stars[N].Y*image[0].trate; /* trate is in 0.1 msec / row */ 35 36 stars[N].M = MIN (stars[N].M + MTIME, NO_MAG); 37 stars[N].dM = MIN (stars[N].dM, NO_ERR); 38 39 stars[N].Mgal = MIN (stars[N].Mgal + MTIME, NO_MAG); 40 24 41 if (SUBPIX) { 25 42 dMs = get_subpix (stars[N].X, stars[N].Y); … … 40 57 } 41 58 42 Stars *MergeStars (Stars *instars, int Ninstars, Stars *stars, int *Nstars) { 59 Stars *MergeStars (Stars *stars, int *Nstars, Stars *instars, int Ninstars) { 60 61 int i, j; 43 62 44 63 if (stars == NULL) { … … 48 67 } 49 68 50 for (j = 0, i = *Nstars; i < *Nstars + Ninstars; i++ ) {69 for (j = 0, i = *Nstars; i < *Nstars + Ninstars; i++, j++) { 51 70 stars[i] = instars[j]; 52 71 } -
trunk/Ohana/src/addstar/src/ReadStarsFITS.c
r10897 r10937 5 5 Stars *ReadStarsFITS (FILE *f, Header *header, Header *in_theader, unsigned int *nstars) { 6 6 7 int i, Nstars; 7 int i, Nskip, Nstars; 8 char type[80]; 8 9 Header theader; 9 10 FTable table; … … 33 34 } 34 35 35 if (!gfits_scan ( header, "EXTTYPE", "%s", 1, type)) {36 if (!gfits_scan (&theader, "EXTTYPE", "%s", 1, type)) { 36 37 strcpy (type, "SMPDATA"); 37 38 } … … 41 42 stars = ConvertSMPDATA (&table, &Nstars); 42 43 } 44 # if (0) 43 45 if (!strcmp (type, "PS1DATA")) { 44 46 stars = ConvertPS1DATA (&table, &Nstars); 45 47 } 48 # endif 46 49 if (stars == NULL) { 47 50 fprintf (stderr, "ERROR: invalid table type %s\n", type); … … 49 52 } 50 53 if (*nstars != Nstars) { 51 fprintf (stderr, "ERROR: inconsistent number of stars? %d vs %d\n", *nstars, Nstars); 52 exit (1); 54 fprintf (stderr, "WARNING: inconsistent number of stars? %d vs %d\n", *nstars, Nstars); 53 55 } 56 *nstars = Nstars; 54 57 return stars; 55 58 } … … 57 60 Stars *ConvertSMPDATA (FTable *table, int *nstars) { 58 61 59 int i, Nstars ;60 Stars *stars ;61 SMPData *smpdata ;62 int i, Nstars, swapped; 63 Stars *stars = NULL; 64 SMPData *smpdata = NULL; 62 65 63 smpdata = gfits_table_get_SMPData (table, &Nstars, NULL); 66 swapped = FALSE; 67 smpdata = gfits_table_get_SMPData (table, &Nstars, &swapped); 68 /* XXX we need to check at least the size of the loaded table */ 64 69 65 70 ALLOCATE (stars, Stars, Nstars); … … 68 73 stars[i].Y = smpdata[i].Y; 69 74 stars[i].M = smpdata[i].M; 70 stars[i].dM = smpdata[i].dM ;75 stars[i].dM = smpdata[i].dM*0.001; 71 76 stars[i].dophot = smpdata[i].dophot; 72 77 … … 81 86 } 82 87 88 # if (0) 83 89 Stars *ConvertPS1DATA (FTable *table, int *nstars) { 84 90 … … 106 112 return (stars); 107 113 } 114 # endif -
trunk/Ohana/src/addstar/src/Shutdown.c
r8458 r10937 1 1 # include "addstar.h" 2 3 static FITS_DB *db;4 5 void set_db (FITS_DB *in) {6 db = in;7 }8 2 9 3 /* clean up open / locked ImageCat before shutting down */ … … 21 15 va_end (argp); 22 16 23 SetProtect (TRUE);24 if (db != NULL) gfits_db_close (db);25 17 fprintf (stderr, "ERROR: addstar halted\n"); 26 18 exit (1); -
trunk/Ohana/src/addstar/src/addstar.c
r10889 r10937 4 4 5 5 int Nmatch, status; 6 int i, Nstars, Nimages, N overlap, Nsubset;6 int i, Nstars, Nimages, Nsubset; 7 7 unsigned long long Naverage, Nmeasure; 8 8 Stars *stars, **subset; 9 Image *images , *overlap;9 Image *images; 10 10 Catalog catalog; 11 11 FITS_DB db; … … 29 29 30 30 stars = NULL; 31 overlap = NULL;32 set_db (&db);33 31 34 /* we use the image table to lock db access -- perhaps this is not necessary? */ 35 db.mode = dvo_catalog_catmode (CATMODE); 36 db.format = dvo_catalog_catformat (CATFORMAT); 37 status = dvo_image_lock (&db, ImageCat, 3600.0, LCK_XCLD); 38 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename); 39 32 /*** load in the new data (images, stars) ***/ 40 33 switch (options.mode) { 41 34 case M_IMAGE: 42 stars = gstars (argv[1], &Nstars, options.photcode, &images, &Nimages);35 stars = gstars (argv[1], &Nstars, &images, &Nimages, options.photcode); 43 36 if ((DUMP != NULL) && !strcmp (DUMP, "rawstars")) dump_rawstars (stars, Nstars); 44 37 RegisterMosaic (MOSAIC); 45 38 for (i = 0; i < Nimages; i++) { 46 newlist = SkyListByImage (sky, -1, &image); 47 SkyListMergeLists (&skylist, &newlist); 39 newlist = SkyListByImage (sky, -1, &images[i]); 40 SkyListMerge (&skylist, newlist); 41 SkyListFree (newlist, FALSE); 48 42 } 49 overlap = gimages (&db, &image, MOSAIC, &Noverlap);43 ImageOptions (&options, images, Nimages); 50 44 break; 51 45 case M_REFLIST: … … 60 54 images = fakeimage (argv[1], &Nimages, options.photcode); 61 55 RegisterMosaic (MOSAIC); 56 ALLOCATE (skylist, SkyList, 1); 57 skylist[0].Nregions = 0; 58 break; 62 59 63 if (db.dbstate == LCK_EMPTY) { 64 dvo_image_create (&db, ZeroPt); 65 } else { 66 if (!dvo_image_load (&db, VERBOSE, FORCE_READ)) { 67 Shutdown ("can't read image catalog %s", db.filename); 68 } 69 } 60 default: 61 fprintf (stderr, "ERROR: invalid mode\n"); 62 exit (2); 63 } 70 64 71 dvo_image_addrows (&db, imageSet, Nimages); 72 SetProtect (TRUE); 73 dvo_image_update (&db, VERBOSE); 74 SetProtect (FALSE); 75 76 ohana_memcheck (FALSE); 77 dvo_image_unlock (&db); /* unlock? */ 78 79 gettimeofday (&stop, NULL); 80 dtime = DTIME (stop, start); 81 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for fake image\n", dtime); 82 exit (0); 83 } 65 // in these cases, limit the sky catalogs to an existing subset 84 66 if (options.only_match || options.existing_regions) { 85 67 SkyList *tmp; … … 92 74 /* XXX clean this up a bit : for only_image, I don't need to do this loop 93 75 unless we are getting the calibration. */ 76 /*** match stars to existing catalog data (or otherwise manipulate catalog data) ***/ 94 77 Nmatch = Naverage = Nmeasure = 0; 95 78 for (i = 0; i < skylist[0].Nregions; i++) { … … 116 99 } 117 100 118 Naverage += catalog.Naverage;119 Nmeasure += catalog.Nmeasure;120 121 101 switch (options.mode) { 122 102 case M_IMAGE: 123 103 Nsubset = Nstars; 124 104 if (options.closest) { 125 Nmatch += find_matches_closest (skylist[0].regions[i], stars, Nstars, &catalog, &image, overlap, Noverlap, MOSAIC, options);105 // Nmatch += find_matches_closest (skylist[0].regions[i], stars, Nstars, &catalog, options); 126 106 } else { 127 Nmatch += find_matches (skylist[0].regions[i], stars, Nstars, &catalog, &image, overlap, Noverlap, MOSAIC,options);107 Nmatch += find_matches (skylist[0].regions[i], stars, Nstars, &catalog, options); 128 108 } 129 109 break; … … 141 121 break; 142 122 } 123 /* report total updated values */ 124 Naverage += catalog.Naverage; 125 Nmeasure += catalog.Nmeasure; 143 126 144 127 // write out catalog, if appropriate … … 154 137 } 155 138 156 // XXX is it necessary to lock the image catalog during this entire process?157 if (options.calibrate) { FindCalibration (&image ); }139 // We only measure a single value for the entire mosaic (add all images to this function) 140 if (options.calibrate) { FindCalibration (&images[0]); } 158 141 142 /*** update the image table ***/ 143 /* setup image table format and lock */ 144 db.mode = dvo_catalog_catmode (CATMODE); 145 db.format = dvo_catalog_catformat (CATFORMAT); 146 status = dvo_image_lock (&db, ImageCat, 3600.0, LCK_XCLD); // shorter timeout? 147 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename); 148 149 /* load or create the image table */ 159 150 if (db.dbstate == LCK_EMPTY) { 160 151 if (VERBOSE) fprintf (stderr, "can't find %s, creating a new one\n", ImageCat); 161 152 dvo_image_create (&db, ZeroPt); 153 } else { 154 if (!dvo_image_load (&db, VERBOSE, FORCE_READ)) { 155 Shutdown ("can't read image catalog %s", db.filename); 156 } 162 157 } 163 164 ohana_memcheck (FALSE);165 158 166 /* write out new image */159 /* add the new images and save */ 167 160 if (options.mode == M_IMAGE) { 168 dvo_image_addrows (&db, &image, 1);161 dvo_image_addrows (&db, images, Nimages); 169 162 SetProtect (TRUE); 170 163 dvo_image_update (&db, VERBOSE); 171 164 SetProtect (FALSE); 172 165 } 173 ohana_memcheck (FALSE);174 166 dvo_image_unlock (&db); /* unlock? */ 175 167 … … 177 169 dtime = DTIME (stop, start); 178 170 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for %5d stars (%5d matches), %6lld average, %7lld measure\n", dtime, Nstars, Nmatch, Naverage, Nmeasure); 171 179 172 exit (0); 180 173 } … … 185 178 patch - RA,DEC bounded portion of sky 186 179 */ 180 181 // add in case of failures: 182 // ohana_memcheck (FALSE); -
trunk/Ohana/src/addstar/src/args.c
r7691 r10937 137 137 } 138 138 /* don't add missed pts to Missed table (image only) */ 139 options.skip_missed = FALSE;139 options.skip_missed = TRUE; 140 140 if ((N = get_argument (argc, argv, "-missed"))) { 141 141 options.skip_missed = TRUE; 142 142 remove_argument (N, &argc, argv); 143 fprintf (stderr, "ERROR: addstar no longer supports -missed\n"); 144 exit (2); 143 145 } 144 146 /* replace measurement, don't duplicate (ref/cat only) */ -
trunk/Ohana/src/addstar/src/find_matches.c
r10889 r10937 1 1 # include "addstar.h" 2 2 3 int find_matches (SkyRegion *region, Stars *stars, int NstarsIn, Catalog *catalog, Image *image, Image *overlap, int Noverlap, Coords *mosaic,AddstarClientOptions options) {3 int find_matches (SkyRegion *region, Stars *stars, int NstarsIn, Catalog *catalog, AddstarClientOptions options) { 4 4 5 5 int i, j, n, N, J, status, Nstars; 6 double X, Y, RADIUS, RADIUS2 , secz;6 double X, Y, RADIUS, RADIUS2; 7 7 float *X1, *Y1, *X2, *Y2; 8 8 float dX, dY, dR; 9 int *N1, *N2, *next_meas , *next_miss;10 int Nave, NAVE, Nmeas, NMEAS, Nm iss, NMISS, Nmatch;9 int *N1, *N2, *next_meas; 10 int Nave, NAVE, Nmeas, NMEAS, Nmatch; 11 11 int Nsecfilt, Nsec; 12 12 float Mcat, *Mval, MTIME; … … 14 14 Coords tcoords; 15 15 16 /* changes needed to handle mosaic MEF images: 17 - options should not carry photcode: this is set per star in gstars 18 - validate that all images have the same equiv code value (same Nsec) 19 - add dt to Stars.d and set in gstars, not here 20 - add airmass to Stars.d and set in gstars, not here 21 - set stars.t in gstars 22 - disallow mosaic and missed? otherwise, need to loop over all images 23 for each missed source to see if it should have been found 24 - Mcal_PS is supplied by image, but is not correctly set: it is 25 calculated *after* find_matches in addstar 26 */ 27 28 /* XXX EAM : options.photcode overridden by image.source.... */ 29 /* XXX this function could be modified to handle multiple photcodes as long 30 as they match the same equiv code value, resulting in the same value of Nsec */ 31 code = GetPhotcodebyCode (image[0].source); 32 33 /* photcode data - must by of type DEP, (PRI, SEC) - probably should restrict to DEP */ 34 // XXX : rely on catalog[0].Nsecfilt or GetPhotcodeNsecfilt?? 16 /* photcode data - must by of type DEP; options.photcode is equiv PRI/SEC photcode */ 17 /* this function requires incoming stars to have the same photcode.equiv value */ 35 18 Nsecfilt = GetPhotcodeNsecfilt (); 36 Nsec = (code[0].type == PHOT_DEP) ? GetPhotcodeNsec (code[0].equiv) : GetPhotcodeNsec (code[0].code); 37 /* this function requires incoming stars to have the same photcode */ 19 Nsec = GetPhotcodeNsec (options.photcode); 38 20 39 21 /** allocate local arrays (stars) **/ … … 53 35 Nmatch = 0; 54 36 NMEAS = Nmeas = catalog[0].Nmeasure; 55 NMISS = Nmiss = catalog[0].Nmissing;56 37 57 38 /* project onto rectilinear grid with 1 arcsec pixels. the choice of ZEA projection has the 58 advantage that every point in R,D has a mapping to a unique X,Y. However, note that not all 59 possible X,Y points map back to R,D and the local plate scale changes substantially far from 60 the projection pole. a better mapping might be ARC, not yet implemented (see 61 coordops.update.c). We keep the original crpix1,2 and crref1,2. For mosaic astrometry, the 62 grid should be w.r.t. the tangent-plane, not chip coords */ 63 64 if (!strcmp (&image[0].coords.ctype[4], "-WRP")) { 65 tcoords = mosaic[0]; 66 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 67 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 68 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 69 tcoords.Npolyterms = 1; 70 strcpy (tcoords.ctype, "RA---ZEA"); 39 * advantage that every point in R,D has a mapping to a unique X,Y. However, note that not all 40 * possible X,Y points map back to R,D and the local plate scale changes substantially far from 41 * the projection pole. a better mapping might be ARC, not yet implemented (see 42 * coordops.update.c). We use the center of the region (catalog) for crval1,2. 43 */ 44 tcoords.crval1 = 0.5*(region[0].Rmin + region[0].Rmax); 45 if (region[0].Rmax < 90) { 46 tcoords.crval2 = 0.5*(region[0].Dmin + region[0].Dmax); 71 47 } else { 72 tcoords = image[0].coords; 73 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 74 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 75 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 76 tcoords.Npolyterms = 1; 77 strcpy (tcoords.ctype, "RA---ZEA"); 78 } 48 tcoords.crval2 = 90.0; 49 } 50 tcoords.crpix1 = 0; 51 tcoords.crpix2 = 0; 52 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 53 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 54 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 55 tcoords.Npolyterms = 1; 56 strcpy (tcoords.ctype, "RA---ZEA"); 79 57 80 58 /* build spatial index (RA sort) */ … … 95 73 free (Y2); 96 74 free (N2); 97 return ;75 return (0); 98 76 } 99 77 if (Nstars > 1) sort_lists (X1, Y1, N1, Nstars); … … 107 85 if (Nave > 1) sort_lists (X2, Y2, N2, Nave); 108 86 109 /* set up pointers for linked list of measure , missing*/87 /* set up pointers for linked list of measure */ 110 88 if (catalog[0].sorted) { 111 89 next_meas = init_measure_links (catalog[0].average, Nave, catalog[0].measure, Nmeas); … … 113 91 next_meas = build_measure_links (catalog[0].average, Nave, catalog[0].measure, Nmeas); 114 92 } 115 next_miss = init_missing_links (catalog[0].average, Nave, catalog[0].missing, Nmiss); 116 /* missing MUST be written 'sorted', or not at all */ 117 118 /* choose a radius for matches */ 119 if (options.radius == 0) { 120 RADIUS = options.Nsigma * 0.02 * image[0].cerror; /* 0.02 corrects cerror to arcsec from storage units */ 121 } else { 122 RADIUS = options.radius; /* provided by config */ 123 } 93 94 /* choose a radius for matches (defined in args.c or ImageOptions.c) */ 95 RADIUS = options.radius; 124 96 RADIUS2 = RADIUS*RADIUS; 125 126 /* correct instrumental mags for exposure time */127 MTIME = (image[0].exptime > 0) ? 2.500*log10(image[0].exptime) : 0.0;128 97 129 98 /** find matched stars **/ … … 163 132 add_meas_link (&catalog[0].average[n], next_meas, Nmeas, NMEAS); 164 133 165 /* calculate accurate per-star airmass */166 secz = airmass (image[0].secz_PS, stars[N].R, stars[N].D, image[0].sidtime, image[0].latitude);167 168 134 /** add measurements for this star **/ 169 135 /** dR,dD now represent arcsec **/ … … 187 153 } 188 154 catalog[0].measure[Nmeas].dD_PS = 3600.0*(catalog[0].average[n].D - stars[N].D); 189 catalog[0].measure[Nmeas].M_PS = MIN (stars[N].M + MTIME, NO_MAG);190 catalog[0].measure[Nmeas].dM_PS = MIN (stars[N].dM, NO_ERR); /* error in input files stored in thousandths of mag */191 catalog[0].measure[Nmeas].Mcal_PS = image[0].Mcal_PS;192 catalog[0].measure[Nmeas].t = image[0].tzero + 1e-4*stars[N].Y*image[0].trate; /* trate is in 0.1 msec / row */155 catalog[0].measure[Nmeas].M_PS = stars[N].M; 156 catalog[0].measure[Nmeas].dM_PS = stars[N].dM; /* error in input files stored in thousandths of mag */ 157 catalog[0].measure[Nmeas].Mcal_PS = stars[N].Mcal; 158 catalog[0].measure[Nmeas].t = stars[N].t; 193 159 catalog[0].measure[Nmeas].averef = n; /* this must be an absolute sequence number, if partial average is loaded */ 194 160 catalog[0].measure[Nmeas].source = stars[N].code; /* photcode */ 195 161 catalog[0].measure[Nmeas].dophot = stars[N].dophot; 196 162 catalog[0].measure[Nmeas].flags = 0; 197 catalog[0].measure[Nmeas].dt_PS = MTIME;198 catalog[0].measure[Nmeas].airmass_PS = s ecz;199 200 catalog[0].measure[Nmeas].Mgal_PS = MIN (stars[N].Mgal + MTIME, NO_MAG);163 catalog[0].measure[Nmeas].dt_PS = stars[N].dt; 164 catalog[0].measure[Nmeas].airmass_PS = stars[N].airmass; 165 166 catalog[0].measure[Nmeas].Mgal_PS = stars[N].Mgal; 201 167 catalog[0].measure[Nmeas].FWx = MIN (100*stars[N].fx, NO_MAG); 202 168 catalog[0].measure[Nmeas].FWy = MIN (100*stars[N].fy, NO_MAG); … … 247 213 } 248 214 249 /* add reference for undetected catalog stars */250 if (!strcmp (&image[0].coords.ctype[4], "-WRP")) RegisterMosaic (mosaic);251 for (j = 0; (j < Nave) && !options.skip_missed; j++) {252 n = N2[j];253 if (catalog[0].found[n] < 0) {254 /* make sure there is space for next entry */255 if (Nmiss >= NMISS) {256 NMISS = Nmiss + 1000;257 REALLOCATE (next_miss, int, NMISS);258 REALLOCATE (catalog[0].missing, Missing, NMISS);259 }260 261 /* should the catalog star be on this image? project into image coords */262 if (!in_image (catalog[0].average[n].R, catalog[0].average[n].D, image)) continue;263 add_miss_link (&catalog[0].average[n], next_miss, Nmiss);264 265 /* calculate time of exposure for this coordinate in the image */266 RD_to_XY (&X, &Y, catalog[0].average[n].R, catalog[0].average[n].D, &image[0].coords);267 catalog[0].missing[Nmiss].t = image[0].tzero + 1e-4*Y*image[0].trate; /* trate is in 0.1 msec / row */268 catalog[0].average[n].Nn ++;269 Nmiss ++;270 }271 }272 273 215 /* incorporate unmatched image stars, if this star is in field of this catalog */ 274 216 /* these new entries are all written out in UPDATE mode */ … … 288 230 N = N1[i]; 289 231 if (stars[N].found >= 0) continue; 290 if (!IN_CATALOG (stars[N].R, stars[N].D)) continue; 291 292 secz = airmass (image[0].secz_PS, stars[N].R, stars[N].D, image[0].sidtime, image[0].latitude); 232 if (!IN_REGION (stars[N].R, stars[N].D)) continue; 293 233 294 234 catalog[0].average[Nave].R = stars[N].R; … … 322 262 catalog[0].measure[Nmeas].dR_PS = 0.0; 323 263 catalog[0].measure[Nmeas].dD_PS = 0.0; 324 catalog[0].measure[Nmeas].M_PS = MIN (stars[N].M + MTIME, NO_MAG);325 catalog[0].measure[Nmeas].dM_PS = MIN (stars[N].dM, NO_ERR);326 catalog[0].measure[Nmeas].Mcal_PS = image[0].Mcal_PS;327 catalog[0].measure[Nmeas].t = image[0].tzero + 1e-4*stars[N].Y*image[0].trate; /* trate is in 0.1 msec / row */264 catalog[0].measure[Nmeas].M_PS = stars[N].M; 265 catalog[0].measure[Nmeas].dM_PS = stars[N].dM; 266 catalog[0].measure[Nmeas].Mcal_PS = stars[N].Mcal; 267 catalog[0].measure[Nmeas].t = stars[N].t; 328 268 catalog[0].measure[Nmeas].averef = Nave; /* XXX EAM : must be absolute Nave if partial read */ 329 269 catalog[0].measure[Nmeas].source = stars[N].code; /* photcode */ 330 270 catalog[0].measure[Nmeas].dophot = stars[N].dophot; 331 271 catalog[0].measure[Nmeas].flags = 0; 332 catalog[0].measure[Nmeas].dt_PS = MTIME;333 catalog[0].measure[Nmeas].airmass_PS = s ecz;272 catalog[0].measure[Nmeas].dt_PS = stars[N].dt; 273 catalog[0].measure[Nmeas].airmass_PS = stars[N].airmass; 334 274 335 275 catalog[0].measure[Nmeas].Mgal_PS = MIN (stars[N].Mgal + MTIME, NO_MAG); … … 341 281 Mval = (Nsec == -1) ? &catalog[0].average[Nave].M : &catalog[0].secfilt[Nave*Nsecfilt+Nsec].M_PS; 342 282 if (*Mval == NO_MAG) *Mval = Mcat; 343 344 /** now add references from all previous non-detection observations of this spot on the sky */345 for (j = 0; (j < Noverlap) && !options.skip_missed; j++) {346 /* make sure there is space for next entry */347 if (Nmiss >= NMISS) {348 NMISS = Nmiss + 1000;349 REALLOCATE (next_miss, int, NMISS);350 REALLOCATE (catalog[0].missing, Missing, NMISS);351 }352 if (!FindMosaicForImage (overlap, Noverlap, j)) continue;353 if (!in_image (catalog[0].average[Nave].R, catalog[0].average[Nave].D, &overlap[j])) continue;354 add_miss_link (&catalog[0].average[Nave], next_miss, Nmiss);355 356 /* get time of exposure of this portion of the image */357 RD_to_XY (&X, &Y, catalog[0].average[Nave].R, catalog[0].average[Nave].D, &overlap[j].coords);358 catalog[0].missing[Nmiss].t = overlap[j].tzero + 1e-4*Y*overlap[j].trate; /* rough guess at time */359 catalog[0].average[Nave].Nn ++;360 Nmiss ++;361 }362 283 363 284 /* next[Nmeas] should always be -1 in this context (it is always the only … … 371 292 REALLOCATE (catalog[0].average, Average, Nave); 372 293 REALLOCATE (catalog[0].measure, Measure, Nmeas); 373 REALLOCATE (catalog[0].missing, Missing, Nmiss);374 294 375 295 if (options.nosort) { … … 379 299 catalog[0].measure = sort_measure (catalog[0].average, Nave, catalog[0].measure, Nmeas, next_meas); 380 300 } 381 catalog[0].missing = sort_missing (catalog[0].average, Nave, catalog[0].missing, Nmiss, next_miss);382 /* missing is REQUIRED to be sorted */383 301 384 302 /* note stars which have been found in this catalog */ … … 394 312 catalog[0].Naverage = Nave; 395 313 catalog[0].Nmeasure = Nmeas; 396 catalog[0].Nmissing = Nmiss; 397 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas, Nmiss: %d %d %d %d, (%d matches)\n", Nstars, Nave, Nmeas, Nmiss, Nmatch); 314 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %d %d %d, (%d matches)\n", Nstars, Nave, Nmeas, Nmatch); 398 315 399 316 free (catalog[0].found); -
trunk/Ohana/src/addstar/src/gstars.c
r10897 r10937 1 1 # include "addstar.h" 2 2 3 enum {NONE, SIMPLE_CMP, SIMPLE_CMF, SIMPLE_MEF, MOSAIC_CMP, MOSAIC_CMF, MOSAIC_MEF, MOSAIC_PHU}; 4 /* note: MEF implies CMF */ 5 6 Stars *gstars (char *filename, int *NSTARS, int photcode, Image **imageList, int Nimages) { 7 8 int i, Nfile, Nimage;3 // XXX where and when should I call RegisterMosaic?? 4 5 Stars *gstars (char *filename, int *Nstars, Image **images, int *Nimages, int photcode) { 6 7 int i, j, Nfile, Nheader, NHEADER, Nimage, NIMAGE; 8 int Nskip, Nhead, Ndata, done, status, mode, NinStars; 9 9 char **file; 10 10 FILE *f; 11 11 glob_t globList; 12 char **exthead, **extdata ;12 char **exthead, **extdata, **exttype, tmpword[80]; 13 13 int *extnum_head, *extnum_data, *extsize; 14 14 Header *header, **headers; … … 18 18 // parse the filename as a glob 19 19 globList.gl_offs = 0; 20 glob (file , 0, NULL, &globList);20 glob (filename, 0, NULL, &globList); 21 21 22 22 // if the glob does not match, save the literal word: … … 46 46 47 47 stars = NULL; 48 Nstars = 0;49 50 / / valid for all but MEF files48 *Nstars = 0; 49 50 /*** load data from a single PHU or a collection of PHU files ***/ 51 51 if ((mode != SIMPLE_MEF) && (mode != MOSAIC_MEF)) { 52 52 Nimage = Nfile; … … 62 62 } 63 63 64 ReadImageHeader (header, &image[i] );64 ReadImageHeader (header, &image[i], photcode); 65 65 66 66 switch (mode) { 67 67 case SIMPLE_CMP: 68 68 case MOSAIC_CMP: 69 inStars = ReadStarsTEXT (f, header, NULL, &image[i].nstars);69 inStars = ReadStarsTEXT (f, &image[i].nstar); 70 70 inStars = FilterStars (inStars, &image[i]); 71 stars = MergeStars ( inStars, NinStars, stars, &Nstars);71 stars = MergeStars (stars, Nstars, inStars, image[i].nstar); 72 72 break; 73 73 74 74 case SIMPLE_CMF: 75 75 case MOSAIC_CMF: 76 inStars = ReadStarsFITS (f, header, NULL, &image[i].nstar s);76 inStars = ReadStarsFITS (f, header, NULL, &image[i].nstar); 77 77 inStars = FilterStars (inStars, &image[i]); 78 stars = MergeStars ( inStars, NinStars, stars, &Nstars);78 stars = MergeStars (stars, Nstars, inStars, image[i].nstar); 79 79 break; 80 80 … … 87 87 gfits_free_header (header); 88 88 } 89 } else { 90 91 /* we need to examine the extensions to determine the headers and the data */ 92 NHEADER = 10; 93 ALLOCATE (headers, Header *, NHEADER); 94 95 // the first header is already loaded 96 headers[0] = header; 97 Nskip = gfits_matrix_size (header); 98 fseek (f, Nskip, SEEK_CUR); 99 100 // load all headers into memory 101 done = FALSE; 102 for (i = 1; !done; i++) { 89 *Nimages = Nimage; 90 *images = image; 91 92 return stars; 93 } 94 95 /* we have a multi-chip image */ 96 97 /* supplied photcode is incompatible with multi-chip images */ 98 if (photcode) { 99 fprintf (stderr, "ERROR: photcode cannot be supplied to multi-chip images -- manually adjust the headers\n"); 100 exit (1); 101 } 102 103 /* we need to examine the extensions to determine the headers and the data */ 104 NHEADER = 10; 105 ALLOCATE (headers, Header *, NHEADER); 106 107 // the first header is already loaded 108 headers[0] = header; 109 Nskip = gfits_matrix_size (header); 110 fseek (f, Nskip, SEEK_CUR); 111 112 // load all headers into memory 113 done = FALSE; 114 for (i = 1; !done; i++) { 103 115 ALLOCATE (header, Header, 1); 104 116 105 117 status = gfits_fread_header (f, header); 106 118 if (!status) { 107 done = TRUE;119 done = TRUE; 108 120 } else { 109 headers[i] = header;110 Nskip = gfits_matrix_size (header);111 fseek (f, Nskip, SEEK_CUR);121 headers[i] = header; 122 Nskip = gfits_matrix_size (header); 123 fseek (f, Nskip, SEEK_CUR); 112 124 } 113 125 if (i == NHEADER - 1) { 114 NHEADER += 10;115 REALLOCATE (headers, Header *, NHEADER);116 } 117 }118 Nheader = i;119 120 // space to store the images, indexes to the matching headers121 Nimage = 0;122 NIMAGE = Nheader;123 ALLOCATE (image, Image, NIMAGE);124 ALLOCATE (exthead, char **, NIMAGE);125 ALLOCATE (extdata, char **, NIMAGE);126 ALLOCATE (extnum_head, int, NIMAGE);127 ALLOCATE (extnum_data, int, NIMAGE);128 ALLOCATE (extsize, int, Nheader);129 130 if (mode == MOSAIC_MEF) {126 NHEADER += 10; 127 REALLOCATE (headers, Header *, NHEADER); 128 } 129 } 130 Nheader = i - 1; /* we failed on the last loop */ 131 132 // space to store the images, indexes to the matching headers 133 Nimage = 0; 134 NIMAGE = Nheader; 135 ALLOCATE (image, Image, NIMAGE); 136 ALLOCATE (exthead, char *, NIMAGE); 137 ALLOCATE (extdata, char *, NIMAGE); 138 ALLOCATE (extnum_head, int, NIMAGE); 139 ALLOCATE (extnum_data, int, NIMAGE); 140 ALLOCATE (extsize, int, Nheader); 141 142 if (mode == MOSAIC_MEF) { 131 143 exthead[Nimage] = strcreate ("PHU"); 132 144 extdata[Nimage] = strcreate ("NONE"); … … 134 146 extnum_head[Nimage] = 0; 135 147 Nimage ++; 136 }137 138 // now examine the headers, count the table entries, find corresponding headers139 for (i = 0; i < Nheader; i++) {148 } 149 150 // now examine the headers, count the table entries, find corresponding headers 151 for (i = 0; i < Nheader; i++) { 140 152 extsize[i] = headers[i][0].size + gfits_matrix_size (headers[i]); 141 153 gfits_scan (headers[i], "EXTTYPE", "%s", 1, tmpword); 142 154 if (!strcmp (tmpword, "SMPDATA") || 143 155 !strcmp (tmpword, "PS1DATA")) { 144 exttype[Nimage] = strcreate (tmpword); 145 gfits_scan (headers[i], "EXTNAME", "%s", 1, tmpword); 146 extdata[Nimage] = strcreate (tmpword); 147 gfits_scan (header[i], "EXTHEAD", "%s", 1, tmpword); 148 exthead[Nimage] = strcreate (tmpword); 149 extnum_data[Nimage] = i; 150 extnum_head[Nimage] = -1; 151 // find the matching exthead entry 152 for (j = 0; j < Nheader; j++) { 153 gfits_scan (header[j], "EXTNAME", "%s", 1, tmpword); 154 if (!strcmp (tmpword, exthead[Nimage])) { 155 extnum_head[Nimage] = j; 156 exttype[Nimage] = strcreate (tmpword); 157 gfits_scan (headers[i], "EXTNAME", "%s", 1, tmpword); 158 extdata[Nimage] = strcreate (tmpword); 159 gfits_scan (headers[i], "EXTHEAD", "%s", 1, tmpword); 160 exthead[Nimage] = strcreate (tmpword); 161 extnum_data[Nimage] = i; 162 extnum_head[Nimage] = -1; 163 // find the matching exthead entry 164 for (j = 0; j < Nheader; j++) { 165 if (gfits_scan (headers[j], "EXTNAME", "%s", 1, tmpword)) { 166 if (!strcmp (tmpword, exthead[Nimage])) { 167 extnum_head[Nimage] = j; 168 } 169 } 156 170 } 157 }158 // skip or crash on table with missing matching header?159 if (extnum_head[Nimage] == -1) {160 fprintf (stderr, "ERROR: can't read header for %s\n", file[0]);161 exit (1);162 }163 Nimage ++; 164 }165 }166 167 // now run through the images, interpret the headers and read the stars168 for (i = 0; i < Nimage; i++) {171 // skip or crash on table with missing matching header? 172 if (extnum_head[Nimage] == -1) { 173 fprintf (stderr, "ERROR: can't read header for %s\n", file[0]); 174 exit (1); 175 } 176 Nimage ++; 177 } 178 } 179 if (VERBOSE) fprintf (stderr, "file %s has %d headers, including %d images\n", file[0], Nheader, Nimage); 180 181 // now run through the images, interpret the headers and read the stars 182 for (i = 0; i < Nimage; i++) { 169 183 Nhead = extnum_head[i]; 170 ReadImageHeader (header[Nhead], &image[i]); 184 185 if (VERBOSE) fprintf (stderr, "reading header for %s (%s)\n", exthead[i], extdata[i]); 186 ReadImageHeader (headers[Nhead], &image[i], 0); 171 187 172 188 if (!strcmp(exthead[i], "PHU")) continue; … … 176 192 Nskip = 0; 177 193 for (j = 0; j < Ndata; j++) { 178 Nskip += extsize[j];194 Nskip += extsize[j]; 179 195 } 180 196 fseek (f, Nskip, SEEK_SET); 181 197 182 inStars = ReadStarsFITS (f, header[Nhead], header[Ndata], &NinStars); 183 inStars = FilterStars (inStars, &NinStars, &image[i]); 184 stars = MergeStars (inStars, NinStars, stars, &Nstars); 185 } 198 inStars = ReadStarsFITS (f, headers[Nhead], headers[Ndata], &image[i].nstar); 199 inStars = FilterStars (inStars, &image[i]); 200 stars = MergeStars (stars, Nstars, inStars, image[i].nstar); 201 } 202 *Nimages = Nimage; 203 *images = image; 204 205 return stars; 206 } -
trunk/Ohana/src/addstar/src/parse_time.c
r8428 r10937 14 14 if (strcasecmp (JDKeyword, "NONE")) { 15 15 uppercase (JDKeyword); 16 gfits_scan (header, JDKeyword, "%lf", 1, &jd); 16 if (!gfits_scan (header, JDKeyword, "%lf", 1, &jd)) { 17 fprintf (stderr, "ERROR: missing JD Keyword %s\n", JDKeyword); 18 exit (1); 19 } 17 20 Nsec = (jd - 2440587.5)*86400; 18 21 return (Nsec); … … 22 25 if (strcasecmp (MJDKeyword, "NONE")) { 23 26 uppercase (MJDKeyword); 24 gfits_scan (header, MJDKeyword, "%lf", 1, &jd); 27 if (!gfits_scan (header, MJDKeyword, "%lf", 1, &jd)) { 28 fprintf (stderr, "ERROR: missing MJD Keyword %s\n", MJDKeyword); 29 exit (1); 30 } 25 31 Nsec = (jd - 40587.0)*86400; 26 32 return (Nsec); … … 42 48 /* get UT and DATE */ 43 49 uppercase (UTKeyword); 44 gfits_scan (header, UTKeyword, "%s", 1, line); 50 if (!gfits_scan (header, UTKeyword, "%s", 1, line)) { 51 fprintf (stderr, "ERROR: missing UT Keyword %s\n", UTKeyword); 52 exit (1); 53 } 45 54 /* remove ':' characters */ 46 55 for (c = strchr (line, 0x3a); c != (char *) NULL; c = strchr (line, 0x3a)) { *c = ' '; } … … 81 90 /* parse date entry */ 82 91 uppercase (DateKeyword); 83 gfits_scan (header, DateKeyword, "%s", 1, line); 92 if (!gfits_scan (header, DateKeyword, "%s", 1, line)) { 93 fprintf (stderr, "ERROR: missing DATE Keyword %s\n", DateKeyword); 94 exit (1); 95 } 84 96 /* remove possible separators: ':', '/' '.', '-' */ 85 97 for (c = strchr (line, 0x3a); c != (char *) NULL; c = strchr (line, 0x3a)) { *c = ' '; }
Note:
See TracChangeset
for help on using the changeset viewer.
