Changeset 3593
- Timestamp:
- Mar 31, 2005, 7:38:37 AM (21 years ago)
- Location:
- trunk/Ohana/src
- Files:
-
- 2 added
- 13 edited
-
imregister/Makefile (modified) (1 diff)
-
imregister/detrend/altpath.c (modified) (4 diffs)
-
imregister/detrend/criteria.c (modified) (2 diffs)
-
imregister/detrend/db_names.c (added)
-
imregister/detrend/delete.c (modified) (3 diffs)
-
imregister/detrend/match.c (modified) (1 diff)
-
imregister/detrend/modify.c (modified) (2 diffs)
-
imregister/detrend/output.c (modified) (4 diffs)
-
imregister/detrend/unique.c (modified) (1 diff)
-
imregister/include/detrend.h (modified) (1 diff)
-
imregister/spreg/delete.c (modified) (2 diffs)
-
imregister/src/detsearch.c (modified) (2 diffs)
-
libautocode/Makefile (modified) (2 diffs)
-
libautocode/def/detreg.d (added)
-
libohana/Makefile (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/imregister/Makefile
r3536 r3593 81 81 82 82 DETOBJ = \ 83 $(DETREND)/db.$(ARCH).o \84 $(DETREND)/define.$(ARCH).o \85 83 $(DETREND)/criteria.$(ARCH).o \ 86 84 $(DETREND)/define.$(ARCH).o \ -
trunk/Ohana/src/imregister/detrend/altpath.c
r2803 r3593 2 2 # include "detrend.h" 3 3 4 int SetAltpath ( Match *match, int Nmatch) {4 int SetAltpath (FITS_DB *db, DetReg *image, int Nimage, Match *match, int Nmatch) { 5 5 6 int i, j, n, found, status; 7 int Nimage, Nlist; 6 int i, j, n, found, status, Nlist; 8 7 int *list, *current; 9 8 char *dBPath, infile[256], outfile[256], line[1024]; 10 DetReg *image;11 9 struct stat statbuf; 12 10 13 image = get_images (&Nimage);14 11 ALLOCATE (current, int, Nimage); 15 16 12 ALLOCATE (list, int, Nimage); 17 13 Nlist = 0; … … 49 45 image[i].altpath = TRUE; 50 46 } 51 update_db (list, Nlist); 52 close_db (); 47 48 /** we may later want to pull this out and put it elsewhere **/ 49 fits_vtable_from_ftable (&db[0].ftable, &vtable, list, Nlist); 50 for (i = 0; i < Nmatch; i++) { 51 fits_convert_DetReg ((DetReg *) vtable.buffer[i], sizeof (DetReg), 1); 52 } 53 fits_db_update (db, &vtable); 54 fits_db_close (db); 55 fits_db_free (db); 56 53 57 fprintf (stderr, "SUCCESS\n"); 54 58 exit (0); … … 78 82 } 79 83 } 80 update_db (list, Nlist); 81 close_db (); 84 85 /** we may later want to pull this out and put it elsewhere **/ 86 fits_vtable_from_ftable (&db[0].ftable, &vtable, list, Nlist); 87 for (i = 0; i < Nmatch; i++) { 88 fits_convert_DetReg ((DetReg *) vtable.buffer[i], sizeof (DetReg), 1); 89 } 90 fits_db_update (db, &vtable); 91 fits_db_close (db); 92 fits_db_free (db); 93 82 94 fprintf (stderr, "SUCCESS\n"); 83 95 exit (0); … … 99 111 image[i].altpath = found; 100 112 } 101 update_db (list, Nlist); 102 close_db (); 113 114 /** we may later want to pull this out and put it elsewhere **/ 115 fits_vtable_from_ftable (&db[0].ftable, &vtable, list, Nlist); 116 for (i = 0; i < Nmatch; i++) { 117 fits_convert_DetReg ((DetReg *) vtable.buffer[i], sizeof (DetReg), 1); 118 } 119 fits_db_update (db, &vtable); 120 fits_db_close (db); 121 fits_db_free (db); 122 103 123 fprintf (stderr, "SUCCESS\n"); 104 124 exit (0); -
trunk/Ohana/src/imregister/detrend/criteria.c
r2803 r3593 60 60 */ 61 61 62 Match *ExptimeCriteria ( Match *match, int *nmatch) {63 64 int i, j, N image, Nmatch, Nnew, NNEW, entry;62 Match *ExptimeCriteria (DetReg *image, int Nimage, Match *match, int *nmatch) { 63 64 int i, j, Nmatch, Nnew, NNEW, entry; 65 65 unsigned long dtime; 66 66 float Chi, ChiMin; 67 DetReg *image;68 67 Match *new; 69 68 70 69 Nmatch = *nmatch; 71 image = get_images (&Nimage);72 70 73 71 Nnew = 0; … … 134 132 } 135 133 136 Match *CloseCriteria ( Match *match, int *nmatch) {137 138 int i, j, N image, Nmatch, Nnew, NNEW, Ngood, entry;134 Match *CloseCriteria (DetReg *image, int Nimage, Match *match, int *nmatch) { 135 136 int i, j, Nmatch, Nnew, NNEW, Ngood, entry; 139 137 unsigned long dmin, dtime; 140 138 Match *new; 141 DetReg *image;142 143 image = get_images (&Nimage);144 139 145 140 Nmatch = *nmatch; -
trunk/Ohana/src/imregister/detrend/delete.c
r2823 r3593 2 2 # include "detrend.h" 3 3 4 void DeleteSubset ( Match *match, int Nmatch) {4 void DeleteSubset (FITS_DB *db, DetReg *image, int Nimage, Match *match, int Nmatch) { 5 5 6 6 int i, j; 7 int *keep, Ndel, Nimage, Nsubset; 8 DetReg *image, *subset; 9 10 image = get_images (&Nimage); 7 int *keep, Ndel, Nsubset; 8 DetReg *subset; 11 9 12 10 ALLOCATE (keep, int, MAX (Nimage, 1)); … … 23 21 } 24 22 fprintf (stderr, "delete %d images\n", Ndel); 25 26 23 if (Ndel == 0) { 27 24 fprintf (stderr, "SUCCESS\n"); 28 close_db ();25 fits_close_db (&db); 29 26 exit (0); 30 27 } … … 39 36 j ++; 40 37 } 41 42 38 free (keep); 43 39 free (image); 44 set_images (subset, Nsubset);45 40 46 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_DetReg (&db[0].ftable, subset, Nsubset); 44 fits_db_save (db); 45 fits_db_close (db); 46 fits_db_free (db); 47 47 48 fprintf (stderr, "SUCCESS\n"); 48 49 exit (0); -
trunk/Ohana/src/imregister/detrend/match.c
r3 r3593 2 2 # include "detrend.h" 3 3 4 Match *MatchCriteria ( int *nmatch) {4 Match *MatchCriteria (DetReg *image, int Nimage, int *nmatch) { 5 5 6 6 int i; 7 int Nmatch, NMATCH , Nimage;7 int Nmatch, NMATCH; 8 8 Match result, *match; 9 DetReg *image;10 11 image = get_images (&Nimage);12 9 13 10 /* find entries that matches criteria */ -
trunk/Ohana/src/imregister/detrend/modify.c
r2803 r3593 2 2 # include "detrend.h" 3 3 4 int ModifySubset ( Match *match, int Nmatch) {4 int ModifySubset (FITS_DB *db, DetReg *image, int Nimage, Match *match, int Nmatch) { 5 5 6 int i, j, Nimage,value;6 int i, j, value; 7 7 int *list; 8 DetReg *image;9 8 10 9 value = M_UNDEF; 11 image = get_images (&Nimage);12 10 13 11 ALLOCATE (list, int, Nimage); … … 45 43 } 46 44 47 update_db (list, Nmatch); 48 close_db (); 45 /** we may later want to pull this out and put it elsewhere **/ 46 fits_vtable_from_ftable (&db[0].ftable, &vtable, match, Nmatch); 47 for (i = 0; i < Nmatch; i++) { 48 fits_convert_DetReg ((DetReg *) vtable.buffer[i], sizeof (DetReg), 1); 49 } 50 fits_db_update (db, &vtable); 51 fits_db_close (db); 52 fits_db_free (db); 53 49 54 fprintf (stderr, "SUCCESS\n"); 50 55 exit (0); -
trunk/Ohana/src/imregister/detrend/output.c
r2803 r3593 5 5 extern double drand48(); 6 6 7 int OutputSubset (Match *match, int Nmatch) { 8 9 int Nimage; 10 DetReg *image; 7 int OutputSubset (DetReg *image, int Nimage, Match *match, int Nmatch) { 11 8 12 9 image = get_images (&Nimage); … … 32 29 FTable table; 33 30 DetReg *subset; 34 35 /* define table layout */ 36 define_table (&header, &matrix, &theader, &table); 31 FILE *f; 37 32 38 33 ALLOCATE (subset, DetReg, MAX (1, Nmatch)); … … 41 36 memcpy (&subset[i], &image[j], sizeof (DetReg)); 42 37 } 43 ConvertStruct ((char *) subset, sizeof (DetReg), Nmatch, "detreg"); 44 fits_add_rows (&table, (char *) subset, Nmatch, sizeof (DetReg)); 45 46 fits_write_header (filename, &header); 47 fits_write_matrix (filename, &matrix); 48 fits_write_Theader (filename, &theader); 49 fits_write_table (filename, &table); 38 39 /* open file for output */ 40 f = fopen (filename, "w"); 41 if (f == NULL) { 42 fprintf (stderr, "ERROR: can't open output file %s\n", filename); 43 exit (1); 44 } 45 46 /* create primary header */ 47 fits_init_header (&header); 48 header.extend = TRUE; 49 fits_create_header (&header); 50 fits_create_matrix (&header, &matrix); 51 fits_print (&header, "NEXTEND", "%d", 1, 1); 52 53 ftable.header = &theader; 54 fits_table_set_DetReg (&ftable, subset, Nmatch); 55 56 fits_write_header (f, &header); 57 fits_write_matrix (f, &matrix); 58 fits_write_Theader (f, &theader); 59 fits_write_table (f, &table); 50 60 exit (0); 51 61 } … … 78 88 fits_modify (&header, "DATE", "%s", 1, datestr); 79 89 fits_modify (&theader, "DATE", "%s", 1, datestr); 90 free (datestr); 80 91 81 92 /* define table layout */ -
trunk/Ohana/src/imregister/detrend/unique.c
r2450 r3593 3 3 4 4 /* define a list of best images which have unique properties */ 5 Match *UniqueSubset ( Match *match, int *nmatch) {5 Match *UniqueSubset (DetReg *image, int Nimage, Match *match, int *nmatch) { 6 6 7 7 int Nsubset, Nunique, Ncrit, NCRIT; 8 int i, j, N, Nmatch, Nimage,found;8 int i, j, N, Nmatch, found; 9 9 Criteria *crit; 10 10 Match *subset, *unique, *local; 11 DetReg *image;12 11 13 12 Nmatch = *nmatch; 14 13 ALLOCATE (local, Match, Nmatch); 15 16 image = get_images (&Nimage);17 14 18 15 /* create a set of complete criteria derived from the images */ -
trunk/Ohana/src/imregister/include/detrend.h
r3466 r3593 72 72 int args (int argc, char **argv); 73 73 int DefineImage (char *filename, Descriptor *descriptor); 74 int define_table (Header *header, Matrix *matrix, Header *theader, FTable *table); 74 DetReg DefineEntry (Descriptor descriptor); 75 75 76 char *get_dBPath (); 76 DetReg DefineEntry (Descriptor descriptor);77 77 int SaveEntry (char *input, DetReg *newdata, char *ID); 78 79 void init_db ();80 int load_db ();81 int save_db ();82 int update_db (int *match, int Nmatch);83 int append_db (DetReg *new, int Nnew);84 int create_db ();85 int close_db ();86 78 87 79 char **LoadRecipe (char *filter, int *nrecipe); 88 80 89 Match *MatchCriteria ( int *nmatch);90 Match *UniqueSubset ( Match *match, int *nmatch);91 Match * CloseCriteria (Match *match, int *nmatch);92 Match * ExptimeCriteria (Match *match, int *nmatch);81 Match *MatchCriteria (DetReg *image, int Nimage, int *nmatch); 82 Match *UniqueSubset (DetReg *image, int Nimage, Match *match, int *nmatch); 83 Match *ExptimeCriteria (DetReg *image, int Nimage, Match *match, int *nmatch); 84 Match *CloseCriteria (DetReg *image, int Nimage, Match *match, int *nmatch); 93 85 94 86 Match CheckCriteria (DetReg *image); 95 DetReg *get_images (int *N);96 int set_images (DetReg *new, int Nnew);97 87 98 88 int delete_image (DetReg *image); 99 int OutputSubset ( Match *match, int Nmatch);89 int OutputSubset (DetReg *image, int Nimage, Match *match, int Nmatch); 100 90 int DumpFitsTable (char *filename, DetReg *detdata, Match *match, int Nmatch); 101 91 int PrintSubset (DetReg *detdata, Match *match, int Nmatch); 102 92 Match SelectEntry (Match *list, int Nlist, Criteria *crit); 103 93 104 int ModifySubset (Match *match, int Nmatch); 105 void DeleteSubset (Match *match, int Nmatch); 94 int ModifySubset (DetReg *image, int Nimage, Match *match, int Nmatch); 95 void DeleteSubset (DetReg *image, int Nimage, Match *match, int Nmatch); 96 106 97 int usage (); 107 98 Criteria *MosaicCriteria (Criteria base, char *filename, int *ncrit); -
trunk/Ohana/src/imregister/spreg/delete.c
r3509 r3593 20 20 } 21 21 fprintf (stderr, "delete %d spectra\n", Nbad); 22 if (Nbad == 0) { 23 fprintf (stderr, "SUCCESS\n"); 24 fits_close_db (&db); 25 exit (0); 26 } 22 27 23 28 Nsubset = Nspectrum - Nbad; … … 29 34 j++; 30 35 } 31 32 36 free (keep); 37 free (spectrum); 33 38 34 39 /** we may later want to pull this out and put it elsewhere **/ -
trunk/Ohana/src/imregister/src/detsearch.c
r2823 r3593 1 1 # include "imregister.h" 2 2 # include "detrend.h" 3 static char *version = "detsearch $Revision: 3. 3$";3 static char *version = "detsearch $Revision: 3.4 $"; 4 4 5 5 int main (int argc, char **argv) { … … 15 15 if (output.Criteria) PrintCriteria (); 16 16 17 init_db (); 18 status = load_db (); 19 if (!status) { 20 close_db (); 21 fprintf (stderr, "database missing or empty\n"); 22 exit (0); 17 db.lockstate = (output.modify || output.delete) ? LCK_HARD : LCK_SOFT; 18 db.timeout = 300.0; 19 fits_db_init (&db); 20 21 dBFile = set_db_name (); 22 if (!fits_db_lock (&db, dBFile)) { 23 fits_db_close (&db); 24 exit (1); 23 25 } 24 if (!output.Modify && !output.Delete && !output.Altpath) close_db ();25 26 26 match = MatchCriteria (&Nmatch); /* match basic criteria */ 27 match = ExptimeCriteria (match, &Nmatch); /* reduce matches based on Exptime */ 28 match = CloseCriteria (match, &Nmatch); /* reduce matches based on closeness */ 27 if (!fits_db_load (&db)) { 28 fits_db_close (&db); 29 exit (1); 30 } 31 32 if (!output.Modify && !output.Delete && !output.Altpath) fits_close_db (&db); 33 detrend = fits_table_get_DetReg (&db.ftable, &Ndetrend); 34 35 match = MatchCriteria (detrend, Ndetrend, &Nmatch); /* match basic criteria */ 36 match = ExptimeCriteria (detrend, Ndetrend, match, &Nmatch); /* reduce matches based on Exptime */ 37 match = CloseCriteria (detrend, Ndetrend, match, &Nmatch); /* reduce matches based on closeness */ 29 38 30 39 if (output.Select) { 31 match = UniqueSubset ( match, &Nmatch);40 match = UniqueSubset (detrend, Ndetrend, match, &Nmatch); 32 41 if (Nmatch == 0) { 33 42 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); 34 close_db ();43 fits_close_db (&db); 35 44 exit (1); 36 45 } 37 46 } 38 47 39 if (output.Altpath) SetAltpath ( match, Nmatch);40 if (output.Modify) ModifySubset ( match, Nmatch);41 if (output.Delete) DeleteSubset ( match, Nmatch);48 if (output.Altpath) SetAltpath (&db, detrend, Ndetrend, match, Nmatch); 49 if (output.Modify) ModifySubset (&db, detrend, Ndetrend, match, Nmatch); 50 if (output.Delete) DeleteSubset (&db, detrend, Ndetrend, match, Nmatch); 42 51 43 OutputSubset ( match, Nmatch);52 OutputSubset (detrend, Ndetrend, match, Nmatch); 44 53 exit (0); 45 54 } -
trunk/Ohana/src/libautocode/Makefile
r3536 r3593 29 29 # remember to add entries here to libohana/Makefile:AOBJ as well 30 30 LIBOBJ = \ 31 $(SRC)/detreg.$(ARCH).o \ 31 32 $(SRC)/photreg.$(ARCH).o \ 32 33 $(SRC)/photreg-old.$(ARCH).o \ … … 36 37 37 38 LIBINC = \ 39 $(INC)/detreg.h \ 38 40 $(INC)/photreg.h \ 39 41 $(INC)/photreg-old.h \ -
trunk/Ohana/src/libohana/Makefile
r3536 r3593 48 48 49 49 AOBJ = \ 50 $(ASRC)/detreg.$(ARCH).o \ 50 51 $(ASRC)/photreg.$(ARCH).o \ 51 52 $(ASRC)/photreg-old.$(ARCH).o \
Note:
See TracChangeset
for help on using the changeset viewer.
