Changeset 3650
- Timestamp:
- Apr 3, 2005, 9:51:44 PM (21 years ago)
- Location:
- trunk/Ohana/src/imregister
- Files:
-
- 6 added
- 6 edited
-
Makefile (modified) (1 diff)
-
detrend/entry.c (modified) (1 diff)
-
imphot (added)
-
imphot/args.c (added)
-
imphot/dumpfits.c (added)
-
imphot/output.c (added)
-
imphot/rtext.c (added)
-
imphot/subset.c (added)
-
imreg/imregclient.c (modified) (3 diffs)
-
spreg/delete.c (modified) (1 diff)
-
src/imphotsearch.c (modified) (3 diffs)
-
src/imstatreg.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/imregister/Makefile
r3649 r3650 57 57 $(IMREG)/FifoOps.$(ARCH).o \ 58 58 $(IMREG)/SockScan.$(ARCH).o \ 59 $(IMREG)/submit.$(ARCH).o 60 61 # $(IMREG)/imregclient.$(ARCH).o \ 59 $(IMREG)/submit.$(ARCH).o \ 60 $(IMREG)/imregclient.$(ARCH).o 62 61 63 62 SPOBJ = \ -
trunk/Ohana/src/imregister/detrend/entry.c
r3649 r3650 107 107 exit (1); 108 108 } 109 fclearlockfile 2(fullname, f, LCK_XCLD, &filestate);109 fclearlockfile (fullname, f, LCK_XCLD, &filestate); 110 110 111 111 return (TRUE); -
trunk/Ohana/src/imregister/imreg/imregclient.c
r2823 r3650 4 4 int imregclient (char *fitsfile, char *statfile, char *datfile) { 5 5 6 int i, Nentry, Nslice, status, tmpint; 6 7 FILE *f; 7 8 RegImage *image; 8 int i, Nentry, Nslice, status, tmpint;9 float *dtime;9 VTable vtable; 10 FITS_DB db; 10 11 11 12 Nentry = 0; … … 45 46 } 46 47 status = 3; 47 Nslice = image[0]. ccd;48 Nslice = image[0].seq; 48 49 Nentry = Nslice + 1; 49 50 REALLOCATE (image, RegImage, Nentry); 50 dtime = (float *)&image[0].junk[0];51 51 for (i = 0; i < Nentry; i++) { 52 52 image[i] = image[0]; 53 53 status = fscanf (f, "%d %f %f", &tmpint, &image[i].sky, &image[i].fwhm); 54 image[i]. ccd= tmpint;55 if (image[i]. ccd== Nslice) continue;56 image[i].obstime += *dtime*image[i].ccd;54 image[i].seq = tmpint; 55 if (image[i].seq == Nslice) continue; 56 image[i].obstime += image[0].seqtime*image[i].seq; 57 57 } 58 58 fclose (f); … … 62 62 if (NoReg) dump_data (image, Nentry); 63 63 64 set_db (TempDB); 64 db.lockstate = LCK_HARD; 65 db.timeout = 300.0; 66 fits_db_init (&db); 65 67 66 status = load_db (); 67 if (!status) { 68 create_db (); 68 if (!fits_db_lock (&db, TempDB)) { 69 fprintf (stderr, "ERROR: failure to lock db\n"); 70 fits_db_close (&db); 71 exit (1); 69 72 } 70 append_db (image, Nentry); 73 if (db.dbstate == LCK_EMPTY) { 74 fits_db_create (&db); 75 fits_table_set_RegImage (&db.ftable, NULL, 0); 76 } else { 77 if (!fits_db_load (&db)) { 78 fprintf (stderr, "ERROR: failure to load db\n"); 79 fits_db_close (&db); 80 exit (1); 81 } 82 } 83 84 fits_convert_RegImage (image, sizeof (RegImage), Nentry); 85 fits_table_to_vtable (&db.ftable, &vtable, 0, 0); 86 fits_vadd_rows (&vtable, (char *) image, Nentry, sizeof(RegImage)); 87 88 fits_db_update (&db, &vtable); 89 fits_db_close (&db); 90 fits_db_free (&db); 91 71 92 fprintf (stderr, "SUCCESS: wrote temp image data\n"); 72 93 exit (0); -
trunk/Ohana/src/imregister/spreg/delete.c
r3593 r3650 22 22 if (Nbad == 0) { 23 23 fprintf (stderr, "SUCCESS\n"); 24 fits_ close_db (&db);24 fits_db_close (db); 25 25 exit (0); 26 26 } -
trunk/Ohana/src/imregister/src/imphotsearch.c
r2803 r3650 2 2 3 3 static char PhotError[] = "unknown"; 4 static char *version = "imphotsearch $Revision: 1. 4$";4 static char *version = "imphotsearch $Revision: 1.5 $"; 5 5 6 6 int DumpFitsTable (char *filename, Image *image, int Nentry, int *index, int Nkeep); … … 26 26 ConfigInit (&argc, argv); 27 27 28 /* load photcode data */ 29 if (!LoadPhotcodes (PhotCodeFile)) { 30 fprintf (stderr, "error loading photcodes from %s\n", PhotCodeFile); 31 exit (1); 32 } 33 34 /* interpret command-line arguments */ 35 if (!get_trange_arguments (&argc, argv, &tstart, &tstop, &Ntimes)) { 36 fprintf (stderr, "ERROR: syntax error\n"); 37 exit (1); 38 } 39 40 /* select by image photcode */ 41 PhotCodeSelect = FALSE; 42 PHOTCODE = 0; 43 if ((N = get_argument (argc, argv, "-photcode"))) { 44 remove_argument (N, &argc, argv); 45 if (!(PHOTCODE = GetPhotcodeCodebyName (argv[N]))) { 46 fprintf (stderr, "ERROR: photcode not found in photcode table\n"); 47 exit (1); 48 } 49 remove_argument (N, &argc, argv); 50 PhotCodeSelect = TRUE; 51 } 52 53 /* string in image name */ 54 NameSelect = (char *) NULL; 55 NameSelectLength = 0; 56 if ((N = get_argument (argc, argv, "-name"))) { 57 remove_argument (N, &argc, argv); 58 NameSelect = strcreate (argv[N]); 59 remove_argument (N, &argc, argv); 60 NameSelectLength = strlen (NameSelect); 61 } 62 63 /* string in image name */ 64 CodeSelect = FALSE; 65 Code = 0; 66 if ((N = get_argument (argc, argv, "-code"))) { 67 CodeSelect = TRUE; 68 remove_argument (N, &argc, argv); 69 Code = atoi (argv[N]); 70 remove_argument (N, &argc, argv); 71 } 72 73 FitsOutput = (char *) NULL; 74 if ((N = get_argument (argc, argv, "-fits"))) { 75 remove_argument (N, &argc, argv); 76 FitsOutput = strcreate (argv[N]); 77 remove_argument (N, &argc, argv); 78 } 79 80 VERBOSE = FALSE; 81 if ((N = get_argument (argc, argv, "-v"))) { 82 remove_argument (N, &argc, argv); 83 VERBOSE = TRUE; 84 } 85 86 FORCE_READ = FALSE; 87 if ((N = get_argument (argc, argv, "-force"))) { 88 remove_argument (N, &argc, argv); 89 FORCE_READ = TRUE; 90 } 91 92 if (argc != 1) { 93 fprintf (stderr, "USAGE: imphotsearch [config ops] [-trange start stop/delta] [-photcode code] [-fits out.fits]\n"); 94 exit (1); 95 } 28 args (&argc, argv); 96 29 97 30 /* load image database - still a non-FITS file */ 98 31 dBFile = ImPhotDB; 99 32 100 f = fsetlockfile (dBFile, 120.0, LCK_SOFT, &dbstate); 101 if (f == (FILE *) NULL) { 102 fprintf (stderr, "ERROR: can't set lock on %s, state is %d\n", dBFile, dbstate); 103 exit (1); 104 } 105 Fseek (f, 0, SEEK_SET); 106 107 /* read header */ 108 if (!fits_fread_header (f, &header)) { 109 if (VERBOSE) fprintf (stderr, "ERROR: can't read image catalog %s\n", dBFile); 110 exit (1); 33 /* how do we decide if it is text or fits? must examine header */ 34 if (FITS) { 35 image = rtext (&Nimage); 36 } else { 37 image = rfits (&Nimage); 111 38 } 112 39 113 /* check that file size makes sense */ 114 Nimage = 0; 115 fits_scan (&header, "NIMAGES", "%d", 1, &Nimage); 116 if (stat (dBFile, &filestatus) == -1) { 117 if (VERBOSE) fprintf (stderr, "ERROR: failed to get status of image catalog\n"); 118 exit (1); 119 } 120 size = Nimage*sizeof(Image) + header.size; 121 if (size != filestatus.st_size) { 122 int Ndata; 40 subset (); 123 41 124 Ndata = (filestatus.st_size - header.size) / sizeof (Image); 125 if (VERBOSE) fprintf (stderr, "ERROR: image catalog has inconsistent size\n"); 126 if (VERBOSE) fprintf (stderr, "header: %d, data: %d\n", Nimage, Ndata); 127 if (!FORCE_READ) exit (1); 128 Nimage = Ndata; 129 } 130 131 /* alloc, read images */ 132 ALLOCATE (image, Image, MAX (Nimage, 1)); 133 nimage = Fread (image, sizeof(Image), Nimage, f, "image"); 134 if (nimage != Nimage) { 135 if (VERBOSE) fprintf (stderr, "ERROR: problem loading image catalog\n"); 136 exit (1); 137 } 138 fclearlockfile (dBFile, f, LCK_SOFT, &dbstate); 139 140 /* allocate space for reference lists */ 141 Nin = 0; 142 ALLOCATE (index, int, Nimage); 143 144 /* note that we are looking for overlap only with tstart */ 145 for (i = 0; i < Nimage; i++) { 146 for (j = 0, status = FALSE; !status && (j < Ntimes); j++) { 147 status = (image[i].tzero >= tstart[j]) && (image[i].tzero <= tstop[j]); 148 } 149 if (!status && Ntimes) continue; 150 if (PhotCodeSelect && (image[i].source != PHOTCODE)) continue; 151 if ((NameSelect != (char *) NULL) && (strncasecmp (image[i].name, NameSelect, NameSelectLength))) continue; 152 if (CodeSelect && (image[i].code != Code)) continue; 153 154 index[Nin] = i; 155 Nin ++; 156 } 157 158 /* output the selected entries */ 159 if (FitsOutput != (char *) NULL) { 160 status = DumpFitsTable (FitsOutput, image, Nimage, index, Nin); 161 } else { 162 for (j = 0; j < Nin; j++) { 163 i = index[j]; 164 165 /* convert UNIX time to Elixir-style date string */ 166 timestr = sec_to_date (image[i].tzero); 167 168 /* convert photcode to filter name */ 169 photstr = GetPhotcodeNamebyCode (image[i].source); 170 if (photstr == (char *) NULL) photstr = PhotError; 171 172 fprintf (stdout, "%s %s %s %7.4f %7.4f %7.4f %5d %02x\n", image[i].name, photstr, timestr, 173 0.001*image[i].Mcal, 0.001*image[i].dMcal, 0.001*image[i].secz, image[i].nstar, image[i].code); 174 free (timestr); 175 } 176 } 42 output (); 177 43 178 44 if (VERBOSE) fprintf (stderr, "SUCCESS\n"); … … 180 46 181 47 } 182 183 int DumpFitsTable (char *filename, Image *image, int Nentry, int *index, int Nkeep) {184 185 Header header, theader;186 Matrix matrix;187 FTable table;188 Image *newdata;189 FILE *f;190 char *startstr, *filtstr, *datestr, *line;191 int i;192 double zp, dzp, ra, dec, airmass, sky;193 unsigned long tsecond;194 195 /* create primary header */196 fits_init_header (&header);197 header.extend = TRUE;198 fits_create_header (&header);199 fits_create_matrix (&header, &matrix);200 fits_print (&header, "NEXTEND", "%d", 1, 1);201 202 /* create table header */203 fits_create_table_header (&theader, "TABLE", "ZPTS");204 205 /* add current date/time to header */206 str_to_time ("now", &tsecond);207 datestr = sec_to_date (tsecond);208 fits_modify (&header, "DATE", "%s", 1, datestr);209 fits_modify (&theader, "DATE", "%s", 1, datestr);210 211 /* define table layout */212 fits_define_table_column (&theader, "A20", "START_TIME", "start time of measurement", "yyyy/mm/dd,hh:mm:ss");213 fits_define_table_column (&theader, "A10", "FILTER", "filter and camera name", "");214 fits_define_table_column (&theader, "F8.4", "ZP_OBS", "measured zero point", "mag");215 fits_define_table_column (&theader, "F7.4", "ZP_ERR", "error on zero point", "mag");216 fits_define_table_column (&theader, "F11.6", "RA", "RA (J2000)", "dec. degrees");217 fits_define_table_column (&theader, "F11.6", "DEC", "DEC (J2000)", "dec. degrees");218 fits_define_table_column (&theader, "F7.3", "C_AIRMASS", "airmass coeff", "mag per airmass");219 fits_define_table_column (&theader, "F7.1", "SKY", "median sky flux", "counts");220 fits_define_table_column (&theader, "I6", "NSTAR", "Number of stars in image", "stars");221 222 /* define TNULL, TNVAL values */223 fits_modify (&theader, "TNULL1", "%s", 1, "NULL"); /* START_TIME */224 fits_modify (&theader, "TNULL2", "%s", 1, "NULL"); /* FILTER */225 fits_modify (&theader, "TNULL3", "%s", 1, "NaN"); /* ZP_OBS */226 fits_modify (&theader, "TNULL4", "%s", 1, "NaN"); /* ZP_ERR */227 fits_modify (&theader, "TNULL5", "%s", 1, "NaN"); /* RA */228 fits_modify (&theader, "TNULL6", "%s", 1, "NaN"); /* DEC */229 fits_modify (&theader, "TNULL7", "%s", 1, "NaN"); /* C_AIRMASS */230 fits_modify (&theader, "TNULL8", "%s", 1, "NaN"); /* SKY */231 fits_modify (&theader, "TNULL9", "%s", 1, "-1"); /* NSTAR */232 233 fits_modify (&theader, "TNVAL1", "%s", 1, "NA"); /* START_TIME */234 fits_modify (&theader, "TNVAL2", "%s", 1, "NA"); /* FILTER */235 fits_modify (&theader, "TNVAL3", "%s", 1, "Inf"); /* ZP_OBS */236 fits_modify (&theader, "TNVAL4", "%s", 1, "Inf"); /* ZP_ERR */237 fits_modify (&theader, "TNVAL5", "%s", 1, "Inf"); /* RA */238 fits_modify (&theader, "TNVAL6", "%s", 1, "Inf"); /* DEC */239 fits_modify (&theader, "TNVAL7", "%s", 1, "Inf"); /* C_AIRMASS */240 fits_modify (&theader, "TNVAL8", "%s", 1, "Inf"); /* SKY */241 fits_modify (&theader, "TNVAL9", "%s", 1, "-2"); /* NSTAR */242 243 /* create table, add data values */244 fits_create_table (&theader, &table);245 246 /* add selected data to table */247 for (i = 0; i < Nkeep; i++) {248 newdata = &image[index[i]];249 startstr = sec_to_date (newdata[0].tzero);250 filtstr = GetPhotcodeNamebyCode (newdata[0].source);251 zp = 0.001*newdata[0].Mcal;252 dzp = 0.001*newdata[0].dMcal;253 254 XY_to_RD (&ra, &dec, 0.0, 0.0, &newdata[0].coords);255 airmass = 0.001*newdata[0].secz;256 sky = newdata[0].Myyyy + 0x8000;257 258 line = fits_table_print (&table, startstr, filtstr, zp, dzp, ra, dec, airmass, sky, newdata[0].nstar);259 fits_add_rows (&table, line, 1, strlen(line));260 261 free (line);262 free (startstr);263 }264 265 /* write data to output file */266 f = fopen (filename, "w");267 if (f == (FILE *) NULL) {268 fprintf (stderr, "Failure writing fits table\n");269 return (FALSE);270 }271 fits_fwrite_header (f, &header);272 fits_fwrite_matrix (f, &matrix);273 fits_fwrite_Theader (f, &theader);274 fits_fwrite_table (f, &table);275 fclose (f);276 return (TRUE);277 }278 279 /*280 281 selection options:282 283 CCDSelect284 TypeSelect285 TimeSelect286 FilterSelect287 ExptimeSelect288 EntrySelect289 LabelSelect290 291 */ -
trunk/Ohana/src/imregister/src/imstatreg.c
r3649 r3650 1 1 # include "imregister.h" 2 2 # include "imreg.h" 3 static char *version = "imstatreg $Revision: 3.1 2$";3 static char *version = "imstatreg $Revision: 3.13 $"; 4 4 5 5 int main (int argc, char **argv) { 6 6 7 RegImage *image;8 int *match, Nmatch, status, Nentry;7 int i, child, status; 8 int *match, Nmatch, Nimage, Nsubset; 9 9 FILE *f; 10 RegImage *image, *subset; 10 11 FITS_DB image_db, temp_db; 12 VTable vtable; 11 13 12 14 get_version (argc, argv, version); … … 68 70 fprintf (stderr, "temporary database read\n"); 69 71 70 /* DELETE and unlock temporarydatabase */71 truncate or delete_db; /****** *****/72 /* delete, unlock existing database */ 73 truncate (TempDB, 0); 72 74 fits_db_close (&temp_db); 73 75 fprintf (stderr, "temporary database closed\n"); … … 115 117 } 116 118 } 117 118 /* basic outline:119 120 - lock temp db121 - if empty, continue122 - load temp db123 - clear temp db124 125 - lock image db126 - if empty, resave temp db127 128 - load image db129 - match temp and main130 131 - update image db132 133 - unlock temp db134 */135
Note:
See TracChangeset
for help on using the changeset viewer.
