Changeset 3606
- Timestamp:
- Mar 31, 2005, 4:42:29 PM (21 years ago)
- Location:
- trunk/Ohana/src/imregister
- Files:
-
- 3 added
- 2 deleted
- 32 edited
-
Makefile (modified) (5 diffs)
-
detrend/altpath.c (modified) (1 diff)
-
detrend/db_names.c (modified) (2 diffs)
-
detrend/delete.c (modified) (1 diff)
-
detrend/modify.c (modified) (2 diffs)
-
detrend/output.c (modified) (3 diffs)
-
detrend/select.c (modified) (2 diffs)
-
detrend/unique.c (modified) (1 diff)
-
doc/autocode.txt (added)
-
doc/spdb2.txt (added)
-
imreg/delete.c (modified) (3 diffs)
-
imreg/iminfo.c (modified) (4 diffs)
-
imreg/match.c (modified) (3 diffs)
-
imreg/modify.c (modified) (2 diffs)
-
imreg/newimages.c (added)
-
imreg/output.c (modified) (4 diffs)
-
imreg/submit.c (modified) (1 diff)
-
imreg/unique.c (modified) (3 diffs)
-
include/detrend.h (modified) (3 diffs)
-
include/imreg.h (modified) (2 diffs)
-
include/photreg.h (modified) (1 diff)
-
photreg/args.photreg.c (modified) (1 diff)
-
photreg/args.photsearch.c (modified) (1 diff)
-
photreg/output.c (modified) (2 diffs)
-
src/detregister.c (modified) (2 diffs)
-
src/detsearch.c (modified) (4 diffs)
-
src/imregister.c (modified) (1 diff)
-
src/imregtable.c (modified) (2 diffs)
-
src/imsearch.c (modified) (1 diff)
-
src/imstatreg.c (modified) (5 diffs)
-
src/notes.txt (deleted)
-
src/photreg.c (modified) (3 diffs)
-
src/photsearch.c (modified) (1 diff)
-
src/select.c (deleted)
-
src/showiminfo.c (modified) (2 diffs)
-
src/spregister.c (modified) (4 diffs)
-
src/spsearch.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/imregister/Makefile
r3593 r3606 43 43 44 44 IMOBJ = \ 45 $(IMREG)/db.$(ARCH).o \46 45 $(IMREG)/delete.$(ARCH).o \ 47 $(IMREG)/define.$(ARCH).o \48 46 $(IMREG)/iminfo.$(ARCH).o \ 49 47 $(IMREG)/load_probes.$(ARCH).o \ 50 48 $(IMREG)/match.$(ARCH).o \ 51 49 $(IMREG)/modify.$(ARCH).o \ 50 $(IMREG)/newimages.$(ARCH).o \ 52 51 $(IMREG)/output.$(ARCH).o \ 53 52 $(IMREG)/unique.$(ARCH).o \ … … 56 55 $(IMREG)/ConfigPID.$(ARCH).o \ 57 56 $(IMREG)/SetSignals.$(ARCH).o \ 58 $(IMREG)/imregclient.$(ARCH).o \59 57 $(IMREG)/rconnect.$(ARCH).o \ 60 58 $(IMREG)/FifoOps.$(ARCH).o \ 61 59 $(IMREG)/SockScan.$(ARCH).o \ 62 60 $(IMREG)/submit.$(ARCH).o 61 62 # $(IMREG)/imregclient.$(ARCH).o \ 63 63 64 64 SPOBJ = \ … … 75 75 $(PHOTREG)/delete.$(ARCH).o \ 76 76 $(PHOTREG)/match.$(ARCH).o \ 77 $(PHOTREG)/define.$(ARCH).o \78 77 $(PHOTREG)/convert.$(ARCH).o \ 79 78 $(PHOTREG)/output.$(ARCH).o \ … … 82 81 DETOBJ = \ 83 82 $(DETREND)/criteria.$(ARCH).o \ 84 $(DETREND)/define.$(ARCH).o \85 83 $(DETREND)/delete.$(ARCH).o \ 86 84 $(DETREND)/entry.$(ARCH).o \ … … 95 93 $(DETREND)/unique.$(ARCH).o \ 96 94 $(DETREND)/altpath.$(ARCH).o \ 95 $(DETREND)/db_names.$(ARCH).o \ 97 96 $(DETREND)/usage.$(ARCH).o 98 97 -
trunk/Ohana/src/imregister/detrend/altpath.c
r3593 r3606 8 8 char *dBPath, infile[256], outfile[256], line[1024]; 9 9 struct stat statbuf; 10 VTable vtable; 10 11 11 12 ALLOCATE (current, int, Nimage); -
trunk/Ohana/src/imregister/detrend/db_names.c
r3593 r3606 3 3 4 4 static char *dBFile = NULL; 5 static char *dBPath = NULL; 5 6 static char *dBTrash = NULL; 6 7 7 8 /*** these are functions to handle the special detrend.db file/trash names ****/ 8 9 9 int delete_image (DetReg *item) { 10 11 int status; 12 char line[256]; 13 14 if (output.verbose) fprintf (stderr, "deleting %s\n", item[0].filename); 15 sprintf (line, "mv -f %s/%s %s", DetrendDB, item[0].filename, dBTrash); 16 status = system (line); 17 if (status) fprintf (stderr, "trouble moving %s to trash (%s)\n", item[0].filename, dBTrash); 18 19 if (status) 20 return (FALSE); 21 else 22 return (TRUE); 23 } 24 25 char *set_db_name () { 10 char *set_dBFile () { 26 11 27 12 struct stat statbuf; 28 13 int status; 29 14 15 dBPath = DetrendDB; 16 30 17 /* define dBFile based on config data */ 31 ALLOCATE (dBFile, char, strlen ( DetrendDB) + 15);32 sprintf (dBFile, "%s/detrend.db", DetrendDB);;33 ALLOCATE (dBTrash, char, strlen ( DetrendDB) + 15);34 sprintf (dBTrash, "%s/trash", DetrendDB);18 ALLOCATE (dBFile, char, strlen (dBPath) + 15); 19 sprintf (dBFile, "%s/detrend.db", dBPath);; 20 ALLOCATE (dBTrash, char, strlen (dBPath) + 15); 21 sprintf (dBTrash, "%s/trash", dBPath); 35 22 36 23 /* check on directories */ 37 status = stat ( DetrendDB, &statbuf);24 status = stat (dBPath, &statbuf); 38 25 if (output.Modify) { 39 26 if (status == -1) { 40 if (mkdirhier ( DetrendDB) == -1) {41 fprintf (stderr, "ERROR: can't find or create path %s\n", DetrendDB);27 if (mkdirhier (dBPath) == -1) { 28 fprintf (stderr, "ERROR: can't find or create path %s\n", dBPath); 42 29 exit (1); 43 30 } … … 55 42 return (dBFile); 56 43 } 44 45 char *get_dBPath () { 46 47 return (dBPath); 48 49 } 50 51 int delete_image (DetReg *item) { 52 53 int status; 54 char line[256]; 55 56 if (output.verbose) fprintf (stderr, "deleting %s\n", item[0].filename); 57 sprintf (line, "mv -f %s/%s %s", dBPath, item[0].filename, dBTrash); 58 status = system (line); 59 if (status) fprintf (stderr, "trouble moving %s to trash (%s)\n", item[0].filename, dBTrash); 60 61 if (status) 62 return (FALSE); 63 else 64 return (TRUE); 65 } 66 -
trunk/Ohana/src/imregister/detrend/delete.c
r3593 r3606 23 23 if (Ndel == 0) { 24 24 fprintf (stderr, "SUCCESS\n"); 25 fits_ close_db (&db);25 fits_db_close (db); 26 26 exit (0); 27 27 } -
trunk/Ohana/src/imregister/detrend/modify.c
r3593 r3606 6 6 int i, j, value; 7 7 int *list; 8 VTable vtable; 8 9 9 10 value = M_UNDEF; … … 44 45 45 46 /** we may later want to pull this out and put it elsewhere **/ 46 fits_vtable_from_ftable (&db[0].ftable, &vtable, match, Nmatch);47 fits_vtable_from_ftable (&db[0].ftable, &vtable, list, Nmatch); 47 48 for (i = 0; i < Nmatch; i++) { 48 49 fits_convert_DetReg ((DetReg *) vtable.buffer[i], sizeof (DetReg), 1); -
trunk/Ohana/src/imregister/detrend/output.c
r3593 r3606 6 6 7 7 int OutputSubset (DetReg *image, int Nimage, Match *match, int Nmatch) { 8 9 image = get_images (&Nimage);10 8 11 9 if (output.table != (char *) NULL) { … … 25 23 26 24 int i, j; 27 Header header, theader; 25 FILE *f; 26 Header header; 28 27 Matrix matrix; 29 FTable table; 28 Header theader; 29 FTable ftable; 30 30 DetReg *subset; 31 FILE *f;32 31 33 32 ALLOCATE (subset, DetReg, MAX (1, Nmatch)); … … 54 53 fits_table_set_DetReg (&ftable, subset, Nmatch); 55 54 56 fits_write_header (f, &header); 57 fits_write_matrix (f, &matrix); 58 fits_write_Theader (f, &theader); 59 fits_write_table (f, &table); 55 fits_fwrite_header (f, &header); 56 fits_fwrite_matrix (f, &matrix); 57 fits_fwrite_Theader (f, &theader); 58 fits_fwrite_table (f, &ftable); 59 fclose (f); 60 60 exit (0); 61 61 } -
trunk/Ohana/src/imregister/detrend/select.c
r3 r3606 2 2 # include "detrend.h" 3 3 4 Match SelectEntry ( Match *list, int Nlist, Criteria *crit) {4 Match SelectEntry (DetReg *image, int Nimage, Match *list, int Nlist, Criteria *crit) { 5 5 6 6 /* force a single selection */ … … 16 16 17 17 int i, j, entry, order, matchnum; 18 int nmatch, Nmatch , Nimage;18 int nmatch, Nmatch; 19 19 unsigned int tstart; 20 20 Match *match, *tmatch, answer; 21 DetReg *image;22 23 image = get_images (&Nimage);24 21 25 22 Nmatch = Nlist; -
trunk/Ohana/src/imregister/detrend/unique.c
r3593 r3606 61 61 62 62 /* subset, Nsubset has a unique list of matched images */ 63 unique[Nunique] = SelectEntry ( subset, Nsubset, crit);63 unique[Nunique] = SelectEntry (image, Nimage, subset, Nsubset, crit); 64 64 Nunique ++; 65 65 } -
trunk/Ohana/src/imregister/imreg/delete.c
r2823 r3606 2 2 # include "imreg.h" 3 3 4 void DeleteSubset ( int *match, int Nmatch) {4 void DeleteSubset (FITS_DB *db, RegImage *image, int Nimage, int *match, int Nmatch) { 5 5 6 6 int i, j; 7 int *keep, Ndel, Nimage, Nsubset; 8 RegImage *image, *subset; 9 10 image = get_images (&Nimage); 7 int *keep, Ndel, Nsubset; 8 RegImage *subset; 11 9 12 10 ALLOCATE (keep, int, MAX (Nimage, 1)); … … 22 20 } 23 21 fprintf (stderr, "delete %d images\n", Ndel); 24 25 22 if (Ndel == 0) { 26 23 fprintf (stderr, "SUCCESS\n"); 27 close_db ();24 fits_db_close (db); 28 25 exit (0); 29 26 } … … 41 38 free (keep); 42 39 free (image); 43 set_images (subset, Nsubset);44 40 45 save_db (); 41 /** we may later want to pull this out and put it elsewhere **/ 42 /** free db[0].theader, db[0].table.buffer? **/ 43 fits_table_set_RegImage (&db[0].ftable, subset, Nsubset); 44 fits_db_save (db); 45 fits_db_close (db); 46 fits_db_free (db); 47 46 48 fprintf (stderr, "SUCCESS\n"); 47 49 exit (0); -
trunk/Ohana/src/imregister/imreg/iminfo.c
r2803 r3606 9 9 Header header; 10 10 int extend; 11 int Naxes, Nextend ;11 int Naxes, Nextend, Nseq; 12 12 char Imagetype[80], line[80]; 13 13 struct timeval now; 14 14 char *name, *cwd, *tempname; 15 15 double tmp; 16 float *dtime;17 16 18 17 ALLOCATE (image, RegImage, 1); … … 36 35 Naxes = 2; 37 36 extend = FALSE; 38 image[0].mode = M_SINGLE; 39 image[0].flag = 0; 40 image[0].ccd = 0; 37 image[0].mode = M_SINGLE; 38 image[0].flag = 0; 39 image[0].ccd = 0; 40 image[0].seq = 0; 41 image[0].seqtime = 0; 41 42 42 43 /* determine data layout (SINGLE, SPLIT, MEF, CUBE, SLICE) */ … … 48 49 image[0].ccd = Nextend; 49 50 } 51 /* need to distinguish MEF, CUBE, and MEF-CUBE */ 50 52 if (Naxes == 3) { /* data cube */ 51 fits_scan (&header, "NAXIS3", "%d", 1, &Nextend); 53 fits_scan (&header, "NAXIS3", "%d", 1, &Nseq); 54 if (image[0].mode == M_MEF) { 55 fprintf (stderr, "MEF-CUBE not ready\n"); 56 exit (1); 57 } 52 58 image[0].mode = M_CUBE; 53 image[0]. ccd = Nextend;54 dtime = (float *)&image[0].junk[0];55 fits_scan (&header, "SEQTIME", "%f", 1, dtime);59 image[0].seq = Nseq; 60 /* abstract this name somewhere ? */ 61 fits_scan (&header, "SEQTIME", "%f", 1, &image[0].seqtime); 56 62 } 57 63 if (SingleIsSplit && (image[0].mode == M_SINGLE)) { … … 119 125 /* the probes have to agree with the entries in the program 'gettemps' */ 120 126 { 121 int i;122 127 double pvalues[4]; 123 128 static int probes[] = {2, 36, 43, 45}; 124 129 if (load_probes (TempLogFile, image[0].obstime, probes, pvalues, 4)) { 125 for (i = 0; i < 4; i++) { 126 image[0].teltemp[i] = pvalues[i]; 127 } 130 image[0].teltemp_0 = pvalues[0]; 131 image[0].teltemp_1 = pvalues[1]; 132 image[0].teltemp_2 = pvalues[2]; 133 image[0].teltemp_3 = pvalues[3]; 128 134 } else { 129 135 fprintf (stderr, "failure to get probe data\n"); 130 image[0].teltemp [0]= 200.0;131 image[0].teltemp [1]= 200.0;132 image[0].teltemp [2]= 200.0;133 image[0].teltemp [3]= 200.0;136 image[0].teltemp_0 = 200.0; 137 image[0].teltemp_1 = 200.0; 138 image[0].teltemp_2 = 200.0; 139 image[0].teltemp_3 = 200.0; 134 140 } 135 141 } -
trunk/Ohana/src/imregister/imreg/match.c
r2803 r3606 2 2 # include "imreg.h" 3 3 4 int *match_criteria ( int *Nmatch) {4 int *match_criteria (RegImage *image, int Nimage, int *Nmatch) { 5 5 6 int i, j, Nname , Nimage;6 int i, j, Nname; 7 7 int N, NMATCH; 8 8 int *match; 9 9 int reject; 10 RegImage *image;11 10 12 11 /* create selection index */ … … 18 17 if (criteria.NameSelect) Nname = strlen (criteria.Name); 19 18 20 image = get_images (&Nimage);21 22 19 /* find entries that matches criteria */ 23 20 for (i = 0; i < Nimage; i++) { … … 46 43 } 47 44 48 int *match_images (RegImage * subset, int Nsubset, int *Nmatch) {45 int *match_images (RegImage *image, int Nimage, RegImage *subset, int Nsubset, int *Nmatch) { 49 46 50 int i, j, N, N image, Nfound;47 int i, j, N, Nfound; 51 48 int *match; 52 RegImage *image;53 54 image = get_images (&Nimage);55 49 56 50 /* find matching images - very inefficient : sort by obstime, find those first? */ -
trunk/Ohana/src/imregister/imreg/modify.c
r2803 r3606 2 2 # include "imreg.h" 3 3 4 void ModifySubset ( int *match, int Nmatch) {4 void ModifySubset (FITS_DB *db, RegImage *image, int Nimage, int *match, int Nmatch) { 5 5 6 6 int i, j, Nold; 7 7 char *tmppath; 8 8 char *ext, *root, *path, dist; 9 int Nimage; 10 RegImage *image; 9 VTable vtable; 11 10 12 11 Nold = 0; 13 12 tmppath = NULL; 14 15 image = get_images (&Nimage);16 13 17 14 /* create some necessary variables */ … … 81 78 } 82 79 83 update_db (match, Nmatch); 80 /** we may later want to pull this out and put it elsewhere **/ 81 fits_vtable_from_ftable (&db[0].ftable, &vtable, match, Nmatch); 82 for (i = 0; i < Nmatch; i++) { 83 fits_convert_RegImage ((RegImage *) vtable.buffer[i], sizeof (RegImage), 1); 84 } 85 fits_db_update (db, &vtable); 86 fits_db_close (db); 87 fits_db_free (db); 88 84 89 fprintf (stderr, "SUCCESS\n"); 85 90 exit (0); -
trunk/Ohana/src/imregister/imreg/output.c
r2803 r3606 24 24 25 25 /* given a subset list, write out the selected images, if desired */ 26 void OutputSubset (int *match, int Nmatch) { 27 28 int Nimage; 29 RegImage *image; 30 31 image = get_images (&Nimage); 26 void OutputSubset (RegImage *image, int Nimage, int *match, int Nmatch) { 32 27 33 28 if (output.table != (char *) NULL) { … … 53 48 54 49 int i, j; 55 Header header, theader; 50 FILE *f; 51 Header header; 56 52 Matrix matrix; 57 FTable table; 53 Header theader; 54 FTable ftable; 58 55 RegImage *subset; 59 56 60 /* define table layout */ 61 define_table (&header, &matrix, &theader, &table); 62 57 /* extract subset list to single array */ 63 58 ALLOCATE (subset, RegImage, MAX (1, Nmatch)); 64 59 for (i = 0; i < Nmatch; i++){ … … 66 61 memcpy (&subset[i], &image[j], sizeof (RegImage)); 67 62 } 68 ConvertStruct ((char *) subset, sizeof (RegImage), Nmatch, "regimage"); 69 fits_add_rows (&table, (char *) subset, Nmatch, sizeof (RegImage)); 70 71 fits_write_header (filename, &header); 72 fits_write_matrix (filename, &matrix); 73 fits_write_Theader (filename, &theader); 74 fits_write_table (filename, &table); 63 64 /* open file for output */ 65 f = fopen (filename, "w"); 66 if (f == NULL) { 67 fprintf (stderr, "ERROR: can't open output file %s\n", filename); 68 exit (1); 69 } 70 71 /* create primary header */ 72 fits_init_header (&header); 73 header.extend = TRUE; 74 fits_create_header (&header); 75 fits_create_matrix (&header, &matrix); 76 fits_print (&header, "NEXTEND", "%d", 1, 1); 77 78 ftable.header = &theader; 79 fits_table_set_RegImage (&ftable, subset, Nmatch); 80 81 fits_fwrite_header (f, &header); 82 fits_fwrite_matrix (f, &matrix); 83 fits_fwrite_Theader (f, &theader); 84 fits_fwrite_table (f, &ftable); 85 fclose (f); 75 86 exit (0); 76 87 } … … 154 165 subset[0].telfocus, subset[0].xprobe, subset[0].yprobe, subset[0].zprobe, 155 166 subset[0].dettemp, 156 subset[0].teltemp[0], subset[0].teltemp[1], 157 subset[0].teltemp[2], subset[0].teltemp[3], 167 subset[0].teltemp_0, subset[0].teltemp_1, subset[0].teltemp_2, subset[0].teltemp_3, 158 168 subset[0].rotangle, 159 169 subset[0].ra, subset[0].dec, -
trunk/Ohana/src/imregister/imreg/submit.c
r85 r3606 8 8 9 9 /* send these images to FIFOs for imstat and ptolemy */ 10 11 /* image[0].ccd contains:12 MEF : Nccd13 SPLIT : ccd number14 CUBE : Nslice15 SLICE : slice number16 SINGLE : 017 */18 10 19 11 if (image[0].mode == M_MEF) { -
trunk/Ohana/src/imregister/imreg/unique.c
r2803 r3606 3 3 4 4 /* input is a subset index of image list, output is a new subset */ 5 int *unique_entries ( int *subset, int *Nmatch) {5 int *unique_entries (RegImage *image, int Nimage, int *subset, int *Nmatch) { 6 6 7 int i, j, k, m, N image, Nsubset;7 int i, j, k, m, Nsubset; 8 8 int N, NMATCH; 9 9 int *match, *entry; 10 RegImage *image;11 10 char idxline[128]; 12 11 char **index; … … 20 19 21 20 Nsubset = *Nmatch; 22 image = get_images (&Nimage);23 21 24 22 /* index = filename.ccd */ … … 65 63 return (match); 66 64 } 67 -
trunk/Ohana/src/imregister/include/detrend.h
r3593 r3606 74 74 DetReg DefineEntry (Descriptor descriptor); 75 75 76 char *set_dBFile (); 76 77 char *get_dBPath (); 78 int delete_image (DetReg *image); 79 77 80 int SaveEntry (char *input, DetReg *newdata, char *ID); 78 81 … … 86 89 Match CheckCriteria (DetReg *image); 87 90 88 int delete_image (DetReg *image);89 91 int OutputSubset (DetReg *image, int Nimage, Match *match, int Nmatch); 90 92 int DumpFitsTable (char *filename, DetReg *detdata, Match *match, int Nmatch); 91 93 int PrintSubset (DetReg *detdata, Match *match, int Nmatch); 92 Match SelectEntry (Match *list, int Nlist, Criteria *crit); 93 94 int ModifySubset (DetReg *image, int Nimage, Match *match, int Nmatch); 95 void DeleteSubset (DetReg *image, int Nimage, Match *match, int Nmatch); 94 Match SelectEntry (DetReg *image, int Nimage, Match *list, int Nlist, Criteria *crit); 96 95 97 96 int usage (); … … 107 106 int ckpathname (char *newpath); 108 107 int PrintCriteria (); 109 int SetAltpath (Match *match, int Nmatch);110 108 109 int SetAltpath (FITS_DB *db, DetReg *image, int Nimage, Match *match, int Nmatch); 110 int ModifySubset (FITS_DB *db, DetReg *image, int Nimage, Match *match, int Nmatch); 111 void DeleteSubset (FITS_DB *db, DetReg *image, int Nimage, Match *match, int Nmatch); -
trunk/Ohana/src/imregister/include/imreg.h
r3466 r3606 73 73 74 74 int args (int argc, char **argv); 75 RegImage *get_images (int *N); 76 int set_images (RegImage *new, int Nnew); 77 void init_db (); 78 int load_db (); 79 int save_db (); 80 int update_db (int *match, int Nmatch); 81 int append_db (RegImage *new, int Nnew); 82 int create_db (); 83 int close_db (); 84 void DeleteSubset (int *match, int Nmatch); 75 76 void DeleteSubset (FITS_DB *db, RegImage *image, int Nimage, int *match, int Nmatch); 85 77 RegImage *iminfo (char *filename); 86 int *match_criteria (int *Nmatch); 87 int *match_images (RegImage *subset, int Nsubset, int *Nmatch); 88 void ModifySubset (int *match, int Nmatch); 78 79 int *match_criteria (RegImage *image, int Nimage, int *Nmatch); 80 int *match_images (RegImage *image, int Nimage, RegImage *subset, int Nsubset, int *Nmatch); 81 82 RegImage *newimages (RegImage *image, int *Nimage); 83 84 void ModifySubset (FITS_DB *db, RegImage *image, int Nimage, int *match, int Nmatch); 89 85 void SetOutputMode (char *mode); 90 void OutputSubset ( int *match, int Nmatch);86 void OutputSubset (RegImage *image, int Nimage, int *match, int Nmatch); 91 87 void DumpFitsBintable (char *filename, RegImage *image, int *match, int Nmatch); 92 88 void DumpFitsTable (char *filename, RegImage *image, int *match, int Nmatch); … … 132 128 int memstr (char *m1, char *m2, int n); 133 129 134 int *unique_entries ( int *subset, int *Nmatch);130 int *unique_entries (RegImage *image, int Nimage, int *subset, int *Nmatch); -
trunk/Ohana/src/imregister/include/photreg.h
r3536 r3606 21 21 int offset; 22 22 char *db; 23 int photcodenames; 23 24 } output; 24 25 -
trunk/Ohana/src/imregister/photreg/args.photreg.c
r3538 r3606 119 119 fprintf (stderr, "missing required fields\n"); 120 120 usage (); 121 return (FALSE); 121 122 } 122 123 -
trunk/Ohana/src/imregister/photreg/args.photsearch.c
r3536 r3606 79 79 } 80 80 81 output.photcodenames = TRUE; 82 if ((N = get_argument (argc, argv, "-photcodes"))) { 83 remove_argument (N, &argc, argv); 84 output.photcodenames = FALSE; 85 } 86 81 87 output.convert = FALSE; 82 88 if ((N = get_argument (argc, argv, "-convert"))) { -
trunk/Ohana/src/imregister/photreg/output.c
r3536 r3606 4 4 static char PhotError[] = "unknown"; 5 5 static char PhotNA[] = "unknown"; 6 static char *ASCIIName = (char *) NULL;7 6 8 7 /* given a subset list, write out the selected images, if desired */ … … 210 209 timestr = sec_to_date (photdata[i].tstart); 211 210 212 /* convert photcode to filter name */ 213 photstr = GetPhotcodeNamebyCode (photdata[i].photcode); 214 refcode = GetPhotcodeNamebyCode (photdata[i].refcode); 215 c1 = GetPhotcodeNamebyCode (photdata[i].c1); 216 c2 = GetPhotcodeNamebyCode (photdata[i].c2); 217 if (photstr == (char *) NULL) photstr = PhotError; 218 if (refcode == (char *) NULL) refcode = PhotError; 219 if (c1 == (char *) NULL) c1 = PhotError; 220 if (c2 == (char *) NULL) c2 = PhotError; 211 if (output.photcodenames) { 212 /* convert photcode to filter name */ 213 photstr = GetPhotcodeNamebyCode (photdata[i].photcode); 214 refcode = GetPhotcodeNamebyCode (photdata[i].refcode); 215 c1 = GetPhotcodeNamebyCode (photdata[i].c1); 216 c2 = GetPhotcodeNamebyCode (photdata[i].c2); 217 218 if (photstr == NULL) photstr = PhotError; 219 if (refcode == NULL) refcode = PhotError; 220 if (c1 == NULL) c1 = PhotError; 221 if (c2 == NULL) c2 = PhotError; 221 222 222 fprintf (stdout, "%s %s %7.4f %7.4f %7.4f %3d %3d %7.4f %7.4f %s %s %s %s\n", 223 photstr, timestr, photdata[i].ZP, photdata[i].ZPo, photdata[i].dZP, photdata[i].Nmeas, photdata[i].Ntime, 224 photdata[i].X, photdata[i].K, refcode, c1, c2, photdata[i].label); 223 fprintf (stdout, "%s %s %7.4f %7.4f %7.4f %3d %3d %7.4f %7.4f %s %s %s %s\n", 224 photstr, timestr, photdata[i].ZP, photdata[i].ZPo, photdata[i].dZP, photdata[i].Nmeas, photdata[i].Ntime, 225 photdata[i].X, photdata[i].K, refcode, c1, c2, photdata[i].label); 226 } else { 227 fprintf (stdout, "%4d %s %7.4f %7.4f %7.4f %3d %3d %7.4f %7.4f %4d %4d %4d %s\n", 228 photdata[i].photcode, timestr, photdata[i].ZP, photdata[i].ZPo, photdata[i].dZP, photdata[i].Nmeas, 229 photdata[i].Ntime, photdata[i].X, photdata[i].K, 230 photdata[i].refcode, photdata[i].c1, photdata[i].c2, photdata[i].label); 231 } 232 225 233 free (timestr); 226 234 } 227 235 return (TRUE); 228 236 } 237 238 /**** the pre-autocode implementation of this program failed to byte-swap refcode! 239 any tables from before the new implementation have to be treated carefully 240 ****/ -
trunk/Ohana/src/imregister/src/detregister.c
r2823 r3606 1 1 # include "imregister.h" 2 2 # include "detrend.h" 3 static char *version = "detregister $Revision: 3. 1$";3 static char *version = "detregister $Revision: 3.2 $"; 4 4 5 5 int main (int argc, char **argv) { 6 6 7 int status;7 char *dBFile; 8 8 DetReg newdata; 9 9 Descriptor descriptor; 10 VTable vtable; 11 FITS_DB db; 10 12 11 13 get_version (argc, argv, version); … … 16 18 SaveEntry (argv[1], &newdata, descriptor.imageID); 17 19 18 init_db (); 19 status = load_db (); 20 if (!status) { 21 create_db (); 20 db.lockstate = LCK_HARD; 21 db.timeout = 300.0; 22 fits_db_init (&db); 23 24 dBFile = set_dBFile (); 25 if (!fits_db_lock (&db, dBFile)) { 26 fits_db_close (&db); 27 exit (1); 22 28 } 23 append_db (&newdata, 1); 29 if (db.dbstate == LCK_EMPTY) { 30 fits_db_create (&db); 31 fits_table_set_DetReg (&db.ftable, NULL, 0); 32 } else { 33 if (!fits_db_load (&db)) { 34 fits_db_close (&db); 35 exit (1); 36 } 37 } 38 39 /** we may later want to pull this out and put it elsewhere **/ 40 fits_convert_DetReg (&newdata, sizeof (DetReg), 1); 41 fits_table_to_vtable (&db.ftable, &vtable, 0, 0); 42 fits_vadd_rows (&vtable, (char *) &newdata, 1, sizeof(DetReg)); 43 44 fits_db_update (&db, &vtable); 45 fits_db_close (&db); 46 fits_db_free (&db); 24 47 25 48 fprintf (stderr, "SUCCESS\n"); 26 49 exit (0); 27 28 50 } 29 51 -
trunk/Ohana/src/imregister/src/detsearch.c
r3593 r3606 1 1 # include "imregister.h" 2 2 # include "detrend.h" 3 static char *version = "detsearch $Revision: 3. 4$";3 static char *version = "detsearch $Revision: 3.5 $"; 4 4 5 5 int main (int argc, char **argv) { 6 6 7 int status; 7 int Nmatch, Ndetrend; 8 char *dBFile; 9 FITS_DB db; 8 10 Match *match; 9 int Nmatch;11 DetReg *detrend; 10 12 11 13 /* args searches the argument list and generates an array of criteria */ … … 15 17 if (output.Criteria) PrintCriteria (); 16 18 17 db.lockstate = (output. modify || output.delete) ? LCK_HARD : LCK_SOFT;19 db.lockstate = (output.Modify || output.Delete) ? LCK_HARD : LCK_SOFT; 18 20 db.timeout = 300.0; 19 21 fits_db_init (&db); 20 22 21 dBFile = set_d b_name ();23 dBFile = set_dBFile (); 22 24 if (!fits_db_lock (&db, dBFile)) { 23 25 fits_db_close (&db); … … 30 32 } 31 33 32 if (!output.Modify && !output.Delete && !output.Altpath) fits_ close_db(&db);34 if (!output.Modify && !output.Delete && !output.Altpath) fits_db_close (&db); 33 35 detrend = fits_table_get_DetReg (&db.ftable, &Ndetrend); 34 36 … … 41 43 if (Nmatch == 0) { 42 44 if (output.verbose) fprintf (stderr, "ERROR: can't find any valid detrend files (%s %s %d)\n", get_type_name(criteria[0].Type), filtername[criteria[0].Filter], criteria[0].CCD); 43 fits_ close_db(&db);45 fits_db_close (&db); 44 46 exit (1); 45 47 } -
trunk/Ohana/src/imregister/src/imregister.c
r2823 r3606 1 1 # include "imregister.h" 2 2 # include "imreg.h" 3 static char *version = "imregister $Revision: 3. 4$";3 static char *version = "imregister $Revision: 3.5 $"; 4 4 5 5 int main (int argc, char **argv) { 6 6 7 RegImage *image, *pimage; 8 int i, status, Nnew; 9 float *dtime; 7 int Nregimage; 8 RegImage *image, *regimage; 9 VTable vtable; 10 FITS_DB db; 10 11 11 12 get_version (argc, argv, version); 12 13 args (argc, argv); 14 13 15 image = iminfo (argv[1]); 14 init_db ();16 regimage = newimages (image, &Nregimage); 15 17 16 Nnew = 0; 17 pimage = NULL; 18 if (NoReg) goto skip_reg; 18 19 19 /* define new entries (pimage, Nnew) */ 20 switch (image[0].mode) { 21 case M_CUBE: 22 Nnew = image[0].ccd + 1; 23 ALLOCATE (pimage, RegImage, Nnew); 24 pimage[0] = image[0]; 25 dtime = (float *)&image[0].junk[0]; 26 for (i = 1; i < Nnew; i++) { 27 pimage[i] = image[0]; 28 pimage[i].ccd = i - 1; 29 pimage[i].mode = M_SLICE; 30 pimage[i].obstime += *dtime*pimage[i].ccd; 20 db.lockstate = LCK_HARD; 21 db.timeout = 300.0; 22 fits_db_init (&db); 23 24 if (!fits_db_lock (&db, ImageDB)) { 25 fits_db_close (&db); 26 exit (1); 27 } 28 if (db.dbstate == LCK_EMPTY) { 29 fits_db_create (&db); 30 fits_table_set_RegImage (&db.ftable, NULL, 0); 31 } else { 32 if (!fits_db_load (&db)) { 33 fits_db_close (&db); 34 exit (1); 31 35 } 32 break;33 case M_MEF:34 Nnew = image[0].ccd;35 ALLOCATE (pimage, RegImage, Nnew);36 for (i = 0; i < Nnew; i++) {37 pimage[i] = image[0];38 pimage[i].ccd = i;39 }40 break;41 case M_SPLIT:42 case M_SINGLE:43 Nnew = 1;44 pimage = &image[0];45 break;46 36 } 47 37 48 set_db (ImageDB); 38 fits_convert_RegImage (regimage, sizeof (RegImage), Nregimage); 39 fits_table_to_vtable (&db.ftable, &vtable, 0, 0); 40 fits_vadd_rows (&vtable, (char *) regimage, Nregimage, sizeof(RegImage)); 49 41 50 if (!NoReg) { 51 status = load_db (); 52 if (!status) { 53 create_db (); 54 } 55 append_db (pimage, Nnew); 56 } 42 fits_db_update (&db, &vtable); 43 fits_db_close (&db); 44 fits_db_free (&db); 57 45 46 skip_reg: 58 47 if (IMSORT) SubmitImages (image); 59 48 fprintf (stderr, "SUCCESS: registered %s\n", argv[1]); -
trunk/Ohana/src/imregister/src/imregtable.c
r2823 r3606 1 1 # include "imregister.h" 2 2 # include "imreg.h" 3 static char *version = "imregtable $Revision: 3. 4$";3 static char *version = "imregtable $Revision: 3.5 $"; 4 4 5 5 int main (int argc, char **argv) { 6 6 7 int status, Nimage, Nx, Ny;7 int Nimage; 8 8 char *infile; 9 9 RegImage *image; 10 Header header, theader; 10 Header header; 11 Header theader; 11 12 Matrix matrix; 12 FTable table; 13 FTable ftable; 14 VTable vtable; 15 FITS_DB db; 13 16 14 17 get_version (argc, argv, version); … … 16 19 ConfigCamera (); 17 20 ConfigFilter (); 18 init_db (); 19 21 20 22 if (argc != 2) { 21 23 fprintf (stderr, "USAGE: imregtable (table)\n"); 22 24 exit (1); 23 25 } 24 infile = argv[1];25 output.modify = TRUE;26 26 27 27 /* load in table data */ 28 table.header = &theader; 29 if (!fits_read_header (infile, &header)) escape (UNLOCK, "can't open file header"); 30 if (!fits_read_matrix (infile, &matrix)) escape (UNLOCK, "can't open file matrix"); 31 if (!fits_read_ftable (infile, &table, "IMAGE_DATABASE")) escape (UNLOCK, "can't open file table"); 28 infile = argv[1]; 32 29 33 /* convert to internal format*/34 image = (RegImage *) table.buffer;35 fits_ scan (table.header, "NAXIS1", "%d", 1, &Nx);36 fits_ scan (table.header, "NAXIS2", "%d", 1, &Ny);37 Nimage = Ny;30 /* need to error check these */ 31 ftable.header = &theader; 32 fits_read_header (infile, &header); 33 fits_read_matrix (infile, &matrix); 34 fits_read_ftable (infile, &ftable, "IMAGE_DATABASE"); 38 35 39 ConvertStruct ((char *) image, sizeof (RegImage), Nimage, "regimage");36 image = fits_table_get_RegImage (&ftable, &Nimage); 40 37 41 set_db (ImageDB); 38 /* load database table */ 39 db.lockstate = LCK_HARD; 40 db.timeout = 300.0; 41 fits_db_init (&db); 42 42 43 status = load_db ();44 if (!status) {45 create_db ();43 if (!fits_db_lock (&db, ImageDB)) { 44 fits_db_close (&db); 45 exit (1); 46 46 } 47 append_db (image, Nimage); 47 if (db.dbstate == LCK_EMPTY) { 48 fits_db_create (&db); 49 fits_table_set_RegImage (&db.ftable, NULL, 0); 50 } else { 51 if (!fits_db_load (&db)) { 52 fits_db_close (&db); 53 exit (1); 54 } 55 } 56 57 fits_convert_RegImage (image, sizeof (RegImage), Nimage); 58 fits_table_to_vtable (&db.ftable, &vtable, 0, 0); 59 fits_vadd_rows (&vtable, (char *) image, Nimage, sizeof(RegImage)); 60 61 fits_db_update (&db, &vtable); 62 fits_db_close (&db); 63 fits_db_free (&db); 48 64 49 65 fprintf (stderr, "SUCCESS: registered %s\n", argv[1]); -
trunk/Ohana/src/imregister/src/imsearch.c
r2823 r3606 1 1 # include "imregister.h" 2 2 # include "imreg.h" 3 static char *version = "imsearch $Revision: 3. 3$";3 static char *version = "imsearch $Revision: 3.4 $"; 4 4 5 5 int main (int argc, char **argv) { 6 6 7 int status, Nmatch; 8 int *match; 7 int Nmatch, Nimage, *match; 8 RegImage *image; 9 FITS_DB db; 9 10 10 11 get_version (argc, argv, version); 11 12 args (argc, argv); 12 init_db ();13 13 14 set_db (ImageDB); 14 db.lockstate = (output.modify || output.delete) ? LCK_HARD : LCK_SOFT; 15 db.timeout = 300.0; 16 fits_db_init (&db); 15 17 16 status = load_db (); 17 if (!status) { 18 close_db (); 19 fprintf (stderr, "database missing or empty\n"); 20 exit (0); 18 if (!fits_db_lock (&db, ImageDB)) { 19 fits_db_close (&db); 20 exit (1); 21 21 } 22 if (!output.modify && !output.delete) close_db (); 22 if (!fits_db_load (&db)) { 23 fits_db_close (&db); 24 exit (1); 25 } 26 27 if (!output.modify && !output.delete) fits_db_close (&db); 28 29 image = fits_table_get_RegImage (&db.ftable, &Nimage); 23 30 24 match = match_criteria ( &Nmatch);25 match = unique_entries ( match, &Nmatch);31 match = match_criteria (image, Nimage, &Nmatch); 32 match = unique_entries (image, Nimage, match, &Nmatch); 26 33 27 if (output.modify) ModifySubset ( match, Nmatch);28 if (output.delete) DeleteSubset ( match, Nmatch);34 if (output.modify) ModifySubset (&db, image, Nimage, match, Nmatch); 35 if (output.delete) DeleteSubset (&db, image, Nimage, match, Nmatch); 29 36 30 OutputSubset ( match, Nmatch);37 OutputSubset (image, Nimage, match, Nmatch); 31 38 32 39 exit (0); -
trunk/Ohana/src/imregister/src/imstatreg.c
r2823 r3606 1 1 # include "imregister.h" 2 2 # include "imreg.h" 3 static char *version = "imstatreg $Revision: 3.8 $"; 4 # define DEBUG 0 3 static char *version = "imstatreg $Revision: 3.9 $"; 5 4 6 5 int main (int argc, char **argv) { 7 6 8 7 RegImage *image; 9 int *match, Nmatch, status, child,Nentry;8 int *match, Nmatch, status, Nentry; 10 9 FILE *f; 10 FITS_DB db; 11 11 12 12 get_version (argc, argv, version); … … 18 18 SetSignals (); 19 19 20 # if (!DEBUG)21 20 /* fork in background */ 22 if ((child = fork ())) { 23 if (child == -1) { 21 if (fork () == -1) { 24 22 fprintf (stderr, "error forking imstatreg -daemon \n"); 25 23 exit (1); … … 28 26 exit (0); 29 27 } 30 # endif31 28 32 29 /* child process, check for process */ 33 30 ConfigPID (PIDFILE); 34 31 35 # if (!DEBUG)36 32 /* redirect stderr, stdout to logfile */ 37 33 f = freopen (LogFile, "a", stdout); … … 42 38 f = freopen (LogFile, "a", stderr); 43 39 } 44 # else 45 f = stderr; 46 # endif 40 41 db.lockstate = LCK_HARD; 42 db.timeout = 300.0; 43 fits_db_init (&db); 47 44 48 45 /* start loop */ … … 50 47 51 48 /* check / load / delete temporary database */ 52 set_db (TempDB); 53 status = load_db (); 54 if (!status) { 55 print_db_status ("temporary database empty"); 56 close_db (); 49 if (!fits_db_lock (&db, TempDB)) { 50 fits_db_close (&db); 51 fprintf (stderr, "error locking db (path missing? access permission?)\n"); 52 exit (1); 53 } 54 if (db.dbstate == LCK_EMPTY) { 55 fprintf (stderr, "temporary database empty\n"); 56 goto next; 57 } 58 if (!fits_db_load (&db)) { 59 fprintf (stderr, "error reading temp db\n"); 57 60 goto next; 58 61 } 59 image = get_images (&Nentry);60 print_db_status ("temporary database read");61 status = set_images (NULL, 0); 62 close_db ();63 print_db_status ("temporary database closed");62 image = fits_table_get_RegImage (&db.ftable, &Nimage); 63 fprintf (stderr, "temporary database read\n"); 64 65 /* need to zero out this file */ 66 fprintf (stderr, "temporary database closed\n"); 64 67 68 /******* need to finish this section up *****/ 65 69 /* check / load main database */ 66 70 set_db (ImageDB); -
trunk/Ohana/src/imregister/src/photreg.c
r3538 r3606 1 1 # include "imregister.h" 2 2 # include "photreg.h" 3 static char *version = "photreg $Revision: 1. 5$";3 static char *version = "photreg $Revision: 1.6 $"; 4 4 5 5 int main (int argc, char **argv) { 6 6 7 7 char *filename; 8 PhotPars newdata , *photdata;8 PhotPars newdata; 9 9 VTable vtable; 10 10 FITS_DB db; … … 23 23 24 24 if (db.dbstate == LCK_EMPTY) { 25 fits_init_header (&db.header); 26 db.header.extend = TRUE; 27 fits_create_header (&db.header); 28 fits_create_matrix (&db.header, &db.matrix); 29 fits_print (&db.header, "NEXTEND", "%d", 1, 1); 30 db.ftable.header = &db.theader; 25 fits_db_create (&db); 31 26 fits_table_set_PhotPars (&db.ftable, NULL, 0); 32 27 /* EXTNAME is set to ZERO_POINTS_3.0 by default */ … … 43 38 /** we may later want to pull this out and put it elsewhere **/ 44 39 fits_convert_PhotPars (&newdata, sizeof (PhotPars), 1); 45 fits_table_to_vtable (&db.ftable, &vtable, 0, 1); 40 fits_table_to_vtable (&db.ftable, &vtable, 0, 0); 41 fits_vadd_rows (&vtable, (char *) &newdata, 1, sizeof(PhotPars)); 42 46 43 fits_db_update (&db, &vtable); 47 44 fits_db_close (&db); -
trunk/Ohana/src/imregister/src/photsearch.c
r3538 r3606 1 1 # include "imregister.h" 2 2 # include "photreg.h" 3 static char *version = "photsearch $Revision: 1. 5$";3 static char *version = "photsearch $Revision: 1.6 $"; 4 4 5 5 int main (int argc, char **argv) { 6 6 7 7 char *filename; 8 int status,Nmatch, Nphotpars;8 int Nmatch, Nphotpars; 9 9 int *match; 10 10 FITS_DB db; -
trunk/Ohana/src/imregister/src/showiminfo.c
r3 r3606 1 1 # include "imregister.h" 2 2 # include "imreg.h" 3 static char *version = "showiminfo $Revision: 3. 0$";3 static char *version = "showiminfo $Revision: 3.1 $"; 4 4 5 5 int main (int argc, char **argv) { … … 24 24 fprintf (stderr, "xprobe: %f, yprobe: %f, zprobe: %f\n", im.xprobe, im.yprobe, im.zprobe); 25 25 fprintf (stderr, "dettemp: %f, temp0: %f temp1: %f, temp2: %f, temp3: %f\n\n", 26 im.dettemp, im.teltemp [0], im.teltemp[1], im.teltemp[2], im.teltemp[3]);26 im.dettemp, im.teltemp_0, im.teltemp_1, im.teltemp_2, im.teltemp_3); 27 27 28 28 fprintf (stderr, "ra: %f, dec: %f, rotangle: %f\n", im.ra, im.dec, im.rotangle); -
trunk/Ohana/src/imregister/src/spregister.c
r3536 r3606 1 1 # include "imregister.h" 2 2 # include "spreg.h" 3 static char *version = "spregister $Revision: 1. 5$";3 static char *version = "spregister $Revision: 1.6 $"; 4 4 5 5 int main (int argc, char **argv) { … … 20 20 db.lockstate = LCK_HARD; 21 21 db.timeout = 300.0; 22 23 22 fits_db_init (&db); 24 23 … … 28 27 } 29 28 if (db.dbstate == LCK_EMPTY) { 30 fits_init_header (&db.header); 31 db.header.extend = TRUE; 32 fits_create_header (&db.header); 33 fits_create_matrix (&db.header, &db.matrix); 34 fits_print (&db.header, "NEXTEND", "%d", 1, 1); 35 db.ftable.header = &db.theader; 29 fits_db_create (&db); 36 30 fits_table_set_Spectrum (&db.ftable, NULL, 0); 37 31 } else { … … 42 36 } 43 37 44 /** we may later want to pull this out and put it elsewhere **/45 38 fits_convert_Spectrum (spectrum, sizeof (Spectrum), 1); 46 fits_table_to_vtable (&db.ftable, &vtable, 0, 1); 39 fits_table_to_vtable (&db.ftable, &vtable, 0, 0); 40 fits_vadd_rows (&vtable, (char *) spectrum, 1, sizeof(Spectrum)); 41 47 42 fits_db_update (&db, &vtable); 48 43 fits_db_close (&db); -
trunk/Ohana/src/imregister/src/spsearch.c
r3536 r3606 1 1 # include "imregister.h" 2 2 # include "spreg.h" 3 static char *version = "spsearch $Revision: 1. 4$";3 static char *version = "spsearch $Revision: 1.5 $"; 4 4 5 5 int main (int argc, char **argv) { … … 20 20 exit (1); 21 21 } 22 23 22 if (!fits_db_load (&db)) { 24 23 fits_db_close (&db);
Note:
See TracChangeset
for help on using the changeset viewer.
