Changeset 29938
- Timestamp:
- Dec 5, 2010, 10:04:42 PM (15 years ago)
- Location:
- trunk/Ohana/src
- Files:
-
- 74 edited
- 26 copied
-
addstar/Makefile (modified) (1 diff)
-
addstar/doc/resort_catalog.alloc.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/addstar/doc/resort_catalog.alloc.c )
-
addstar/include/addstar.h (modified) (3 diffs)
-
addstar/src/ReadStarsFITS.c (modified) (1 diff)
-
addstar/src/ReadStarsSDSS.c (modified) (1 diff)
-
addstar/src/addstar.c (modified) (2 diffs)
-
addstar/src/args.c (modified) (2 diffs)
-
addstar/src/resort_catalog.c (modified) (2 diffs)
-
addstar/src/resort_threaded.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/addstar/src/resort_threaded.c )
-
addstar/src/resort_unthreaded.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/addstar/src/resort_unthreaded.c )
-
addstar/test/dvomerge.dvo (modified) (3 diffs)
-
dvomerge/Makefile (modified) (2 diffs)
-
dvomerge/doc (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/doc )
-
dvomerge/doc/notes.txt (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/doc/notes.txt )
-
dvomerge/include/dvomerge.h (modified) (4 diffs)
-
dvomerge/src/ImageOps.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/ImageOps.c )
-
dvomerge/src/LoadCatalog.c (modified) (1 diff)
-
dvomerge/src/LoadImages.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/LoadImages.c )
-
dvomerge/src/ReadDeleteList.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/ReadDeleteList.c )
-
dvomerge/src/args.c (modified) (2 diffs)
-
dvomerge/src/dvo_image_merge_dbs.c (modified) (1 diff)
-
dvomerge/src/dvoconvert.c (modified) (4 diffs)
-
dvomerge/src/dvomerge.c (modified) (2 diffs)
-
dvomerge/src/dvomergeContinue.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/dvomergeContinue.c )
-
dvomerge/src/dvomergeContinue_threaded.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/dvomergeContinue_threaded.c )
-
dvomerge/src/dvomergeCreate.c (modified) (10 diffs)
-
dvomerge/src/dvomergeFromList.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/dvomergeFromList.c )
-
dvomerge/src/dvomergeImageIDs.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/dvomergeImageIDs.c )
-
dvomerge/src/dvomergeUpdate.c (modified) (11 diffs)
-
dvomerge/src/dvomergeUpdate_threaded.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/dvomergeUpdate_threaded.c )
-
dvomerge/src/dvorepair.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/dvorepair.c )
-
dvomerge/src/dvorepairCPT.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/dvorepairCPT.c )
-
dvomerge/src/dvorepairDeleteImageList.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/dvorepairDeleteImageList.c )
-
dvomerge/src/dvorepairFixCPT.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/dvorepairFixCPT.c )
-
dvomerge/src/dvorepairFixImages.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/dvorepairFixImages.c )
-
dvomerge/src/dvorepairFixTables.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/dvorepairFixTables.c )
-
dvomerge/src/dvorepairImageVsMeasure.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/dvorepairImageVsMeasure.c )
-
dvomerge/src/dvorepairImagesVsMeasures.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/dvorepairImagesVsMeasures.c )
-
dvomerge/src/dvoverify.c (modified) (1 diff)
-
dvomerge/src/help.c (modified) (6 diffs)
-
dvomerge/src/match_image.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/match_image.c )
-
dvomerge/src/merge_catalogs_old.c (modified) (3 diffs)
-
imregister/imphot/rfits.c (modified) (1 diff)
-
kapa2/Makefile (modified) (1 diff)
-
kapa2/include/prototypes.h (modified) (8 diffs)
-
kapa2/include/structures.h (modified) (1 diff)
-
kapa2/src/ButtonFunctions.c (modified) (1 diff)
-
kapa2/src/CheckPipe.c (modified) (4 diffs)
-
kapa2/src/DefineSection.c (modified) (1 diff)
-
kapa2/src/DrawFrame.c (modified) (15 diffs)
-
kapa2/src/Image.c (modified) (1 diff)
-
kapa2/src/JPEGit24.c (modified) (3 diffs)
-
kapa2/src/PNGit.c (modified) (4 diffs)
-
kapa2/src/PPMit.c (modified) (2 diffs)
-
kapa2/src/PSFrame.c (modified) (3 diffs)
-
kapa2/src/PSimage.c (modified) (1 diff)
-
kapa2/src/PSit.c (modified) (2 diffs)
-
kapa2/src/Resize.c (modified) (1 diff)
-
kapa2/src/SetGraphSize.c (modified) (10 diffs)
-
kapa2/src/bDrawFrame.c (modified) (6 diffs)
-
kapa2/src/bDrawImage.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/kapa2/src/bDrawImage.c )
-
kapa2/src/bDrawIt.c (modified) (4 diffs)
-
kapa2/src/bDrawLabels.c (modified) (4 diffs)
-
kapa2/src/bDrawObjects.c (modified) (35 diffs)
-
kapa2/src/bDrawOverlay.c (modified) (6 diffs)
-
libdvo/include/dvo.h (modified) (5 diffs)
-
libdvo/src/dvo_catalog.c (modified) (3 diffs)
-
libdvo/src/dvo_catalog_mef.c (modified) (4 diffs)
-
libdvo/src/dvo_catalog_split.c (modified) (4 diffs)
-
libdvo/src/dvo_photcode_ops.c (modified) (1 diff)
-
libdvo/src/fits_db.c (modified) (1 diff)
-
libdvo/src/mosaic_astrom.c (modified) (7 diffs)
-
libfits/include/gfitsio.h (modified) (2 diffs)
-
libfits/table/F_read_T.c (modified) (3 diffs)
-
libkapa/include/kapa.h (modified) (4 diffs)
-
libkapa/src/KapaWindow.c (modified) (2 diffs)
-
libkapa/src/bDrawFuncs.c (modified) (16 diffs)
-
libkapa/src/bDrawRotFont.c (modified) (10 diffs)
-
opihi/cmd.astro/region.c (modified) (1 diff)
-
opihi/cmd.data/Makefile (modified) (1 diff)
-
opihi/cmd.data/densify.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/opihi/cmd.data/densify.c )
-
opihi/cmd.data/init.c (modified) (2 diffs)
-
opihi/cmd.data/rd.c (modified) (1 diff)
-
opihi/cmd.data/read_vectors.c (modified) (4 diffs)
-
opihi/cmd.data/resize.c (modified) (1 diff)
-
opihi/cmd.data/section.c (modified) (4 diffs)
-
opihi/cmd.data/vgauss.c (modified) (1 diff)
-
opihi/dvo/images.c (modified) (8 diffs)
-
opihi/dvo/imlist.c (modified) (1 diff)
-
opihi/lib.data/starfuncs.c (modified) (5 diffs)
-
photdbc/include/photdbc.h (modified) (1 diff)
-
photdbc/src/args.c (modified) (2 diffs)
-
photdbc/src/initialize.c (modified) (1 diff)
-
photdbc/src/join_stars.c (modified) (1 diff)
-
relastro/src/GetAstromError.c (modified) (4 diffs)
-
relastro/src/UpdateObjects.c (modified) (8 diffs)
-
relastro/src/high_speed_objects.c (modified) (13 diffs)
-
relphot/doc/config.txt (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/relphot/doc/config.txt )
-
tools/Makefile (modified) (1 diff)
-
tools/src/roc.c (copied) (copied from branches/eam_branches/ipp-20101103/Ohana/src/tools/src/roc.c )
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/Makefile
r27582 r29938 72 72 $(SRC)/replace_match.$(ARCH).o \ 73 73 $(SRC)/resort_catalog.$(ARCH).o \ 74 $(SRC)/resort_threaded.$(ARCH).o \ 75 $(SRC)/resort_unthreaded.$(ARCH).o \ 74 76 $(SRC)/StarOps.$(ARCH).o \ 75 77 $(SRC)/ReadStarsFITS.$(ARCH).o \ -
trunk/Ohana/src/addstar/include/addstar.h
r29541 r29938 125 125 float ZPT_ERR_PHU; 126 126 127 int OLD_RESORT; 128 127 129 // carries the mosaic into gstars 128 130 … … 135 137 double MIN_FWHM_X; 136 138 double MIN_FWHM_Y; 139 int NTHREADS; 137 140 138 141 /* modify server behavior (make this an addstar cleanup mode?) */ … … 207 210 Stars *rd_gsc PROTO((char *filename, unsigned int *nstars)); 208 211 int replace_match PROTO((Average *average, Measure *measure, Stars *star)); 212 int resort_threaded PROTO((AddstarClientOptions *options, SkyTable *sky)); 213 int resort_unthreaded PROTO((AddstarClientOptions *options, SkyTable *sky)); 209 214 void resort_catalog PROTO((Catalog *catalog)); 215 void resort_catalog_old PROTO((Catalog *catalog)); 210 216 Stars *ReadStarsFITS PROTO((FILE *f, Header *header, Header *in_theader, unsigned int *nstars)); 211 217 Stars *ReadStarsTEXT PROTO((FILE *f, unsigned int *nstars)); -
trunk/Ohana/src/addstar/src/ReadStarsFITS.c
r29541 r29938 22 22 23 23 /* load the table data */ 24 if (!gfits_fread_ftable_data (f, &table )) {24 if (!gfits_fread_ftable_data (f, &table, FALSE)) { 25 25 fprintf (stderr, "ERROR: can't read table header\n"); 26 26 exit (1); -
trunk/Ohana/src/addstar/src/ReadStarsSDSS.c
r28939 r29938 60 60 61 61 /* load the table data */ 62 if (!gfits_fread_ftable_data (f, &table )) {62 if (!gfits_fread_ftable_data (f, &table, FALSE)) { 63 63 fprintf (stderr, "ERROR: can't read table header\n"); 64 64 exit (1); -
trunk/Ohana/src/addstar/src/addstar.c
r28241 r29938 34 34 SkyTableSetFilenames (sky, CATDIR, "cpt"); 35 35 36 if (options.mode == M_RESORT) { 37 if (NTHREADS == 0) { 38 resort_unthreaded (&options, sky); 39 } else { 40 resort_threaded (&options, sky); 41 } 42 exit (0); 43 } 44 36 45 stars = NULL; 37 46 … … 157 166 } 158 167 159 resort_catalog (&catalog); 168 if (OLD_RESORT) { 169 resort_catalog_old (&catalog); 170 } else { 171 resort_catalog (&catalog); 172 } 160 173 Nsubset = 1; 161 174 break; -
trunk/Ohana/src/addstar/src/args.c
r27392 r29938 34 34 remove_argument (N, &argc, argv); 35 35 } 36 OLD_RESORT = FALSE; 37 if ((N = get_argument (argc, argv, "-old-resort"))) { 38 remove_argument (N, &argc, argv); 39 OLD_RESORT = TRUE; 40 } 36 41 if ((N = get_argument (argc, argv, "-fakeimage"))) { 37 42 options.mode = M_FAKEIMAGE; … … 62 67 remove_argument (N, &argc, argv); 63 68 PMM_CCD_TABLE = strcreate (argv[N]); 69 remove_argument (N, &argc, argv); 70 } 71 72 // number of worker threads for resort (must have at least one worker thread) 73 NTHREADS = 0; 74 if ((N = get_argument (argc, argv, "-threads"))) { 75 remove_argument (N, &argc, argv); 76 NTHREADS = MAX(0, atoi (argv[N])); 64 77 remove_argument (N, &argc, argv); 65 78 } -
trunk/Ohana/src/addstar/src/resort_catalog.c
r27435 r29938 1 1 # include "addstar.h" 2 2 3 void resort_catalog (Catalog *catalog) {3 void resort_catalog_old (Catalog *catalog) { 4 4 5 5 off_t *next_meas; … … 28 28 return; 29 29 } 30 31 # define myAbort(MSG) { fprintf (stderr, "%s\n", MSG); abort(); } 32 # define myAssert(LOGIC,MSG) { if (!(LOGIC)) { fprintf (stderr, "%s\n", MSG); abort(); } } 33 34 // sort the measure Sequence based on the average Sequence entries 35 void SortAveMeasMatch (off_t *MEAS, off_t *AVE, off_t N) { 36 37 # define SWAPFUNC(A,B){ off_t tmp_meas; off_t tmp_ave; \ 38 tmp_meas = MEAS[A]; MEAS[A] = MEAS[B]; MEAS[B] = tmp_meas; \ 39 tmp_ave = AVE[A]; AVE[A] = AVE[B]; AVE[B] = tmp_ave; \ 40 } 41 # define COMPARE(A,B)(MEAS[A] < MEAS[B]) 42 OHANA_SORT (N, COMPARE, SWAPFUNC); 43 # undef SWAPFUNC 44 # undef COMPARE 45 } 46 47 # define MARKTIME(MSG,...) { \ 48 float dtime; \ 49 gettimeofday (&stop, (void *) NULL); \ 50 dtime = DTIME (stop, start); start = stop; \ 51 fprintf (stderr, MSG, __VA_ARGS__); } 52 53 // XXX : where is the time going? perhaps the ALLOCATE? 54 // XXX : I don't thnk his is getting the right answer yet. 55 56 void resort_catalog (Catalog *catalog) { 57 58 off_t Naverage, Nmeasure; 59 Measure *measure; 60 Average *average; 61 off_t i, j, N, currentAve; 62 63 off_t *measureSeq = NULL; 64 off_t *averageSeq = NULL; 65 Measure *measureTMP = NULL; 66 67 if (catalog[0].sorted == TRUE) return; 68 69 // struct timeval start, stop; 70 // gettimeofday (&start, NULL); 71 72 /* internal counters */ 73 Nmeasure = catalog[0].Nmeasure; 74 Naverage = catalog[0].Naverage; 75 76 measure = catalog[0].measure; 77 average = catalog[0].average; 78 79 // we have a table of average objects and an unsorted table of measurements. each measurement 80 // has a reference to the average object sequence (as well as an ID) 81 // measure[i].averef -> average[averef] 82 // measure[i].objID = average[averef].objID 83 // measure[i].catID = average[averef].catID 84 85 // we want a sorted measure array with all averef entries in sequence 86 87 ALLOCATE (measureSeq, off_t, Nmeasure); 88 ALLOCATE (averageSeq, off_t, Nmeasure); 89 90 for (i = 0; i < Nmeasure; i++) { 91 measureSeq[i] = i; 92 averageSeq[i] = measure[i].averef; 93 94 myAssert(average[averageSeq[i]].objID == measure[measureSeq[i]].objID, "object / detection mismatch"); 95 myAssert(average[averageSeq[i]].catID == measure[measureSeq[i]].catID, "object / detection mismatch"); 96 } 97 98 SortAveMeasMatch(measureSeq, averageSeq, Nmeasure); 99 // MARKTIME("sort : %f sec\n", dtime); 100 101 // copy the measurements in the sorted order 102 ALLOCATE (measureTMP, Measure, Nmeasure); 103 for (i = 0; i < Nmeasure; i++) { 104 j = measureSeq[i]; 105 measureTMP[i] = measure[j]; 106 } 107 // MARKTIME("assign measure : %f sec\n", dtime); 108 109 // update the values of average.measureOffset and average.Nmeasure 110 FREE(measure); 111 catalog[0].measure = measureTMP; 112 113 N = 0; 114 currentAve = averageSeq[0]; 115 average[currentAve].measureOffset = 0; 116 for (i = 0; i < Nmeasure; i++) { 117 if (averageSeq[i] != currentAve) { 118 average[currentAve].Nmeasure = N; 119 N = 0; 120 currentAve = averageSeq[i]; 121 average[currentAve].measureOffset = i; 122 } 123 N++; 124 } 125 N++; 126 average[currentAve].Nmeasure = N; 127 // MARKTIME("update Nmeasure : %f sec\n", dtime); 128 129 // MARKTIME(" match time %9.4f sec for %7lld measures, %6lld average\n", dtime, (long long) Nmeasure, (long long) Naverage); 130 131 FREE (measureSeq); 132 FREE (averageSeq); 133 134 return; 135 } 136 -
trunk/Ohana/src/addstar/test/dvomerge.dvo
r29001 r29938 4 4 5 5 # create 2 populated catdirs, each with a couple of cmf files 6 macro test.dvomerge. update6 macro test.dvomerge.continue 7 7 8 8 tapPLAN 51 … … 16 16 17 17 mkinput 18 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec 10.0 20.0 19 exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf 20 21 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec 10.0 20.0 22 exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf 23 24 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 03:00:00 -radec 9.9 20.0 25 exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf 26 27 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 04:00:00 -radec 9.9 20.0 28 exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf 29 30 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 05:00:00 -radec 10.0 19.9 31 exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf 32 33 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 06:00:00 -radec 10.0 19.9 34 exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf 35 36 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 07:00:00 -radec 9.9 19.9 37 exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf 38 39 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 08:00:00 -radec 9.9 19.9 40 exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf 41 42 break 43 44 exec rsync -auc catdir.test2/ catdir.test3/ 45 46 date -var t1 -seconds -reftime 1276000000 47 exec dvomerge catdir.test1 into catdir.test3 48 date -var t2 -seconds -reftime 1276000000 49 echo "merge time: {$t2 - $t1}" 50 51 catdir catdir.test3 52 skyregion {$RA-1} {$RA+1} {$DEC-1} {$DEC+1} 53 mextract ra dec mag 54 create n 0 ra[] 55 subset r0 = ra if (n % 4 == 0) 56 subset r1 = ra if (n % 4 == 1) 57 subset r2 = ra if (n % 4 == 2) 58 subset r3 = ra if (n % 4 == 3) 59 60 catdir catdir.test1/ 61 mextract RA DEC MAG 62 create N 0 RA[] 63 subset R0 = RA if (N % 2 == 0) 64 subset R1 = RA if (N % 2 == 1) 65 66 set dr0 = r0 - R0 67 vstat -q dr0 68 tapOK {abs($MEAN) < 0.001} "ra (in - 0) vs ra (out - 0) (MEAN)" 69 tapOK {abs($SIGMA) < 0.001} "ra (in - 0) vs ra (out - 0) (SIGMA)" 70 71 set dr1 = r1 - R1 72 vstat -q dr1 73 tapOK {abs($MEAN) < 0.001} "ra (in - 0) vs ra (out - 0) (MEAN)" 74 tapOK {abs($SIGMA) < 0.001} "ra (in - 0) vs ra (out - 0) (SIGMA)" 75 76 catdir catdir.test2/ 77 mextract RA DEC MAG 78 create N 0 RA[] 79 subset R2 = RA if (N % 2 == 0) 80 subset R3 = RA if (N % 2 == 1) 81 82 set dr2 = r2 - R2 83 vstat -q dr2 84 tapOK {abs($MEAN) < 0.001} "ra (in - 0) vs ra (out - 0) (MEAN)" 85 tapOK {abs($SIGMA) < 0.001} "ra (in - 0) vs ra (out - 0) (SIGMA)" 86 87 set dr3 = r3 - R3 88 vstat -q dr3 89 tapOK {abs($MEAN) < 0.001} "ra (in - 0) vs ra (out - 0) (MEAN)" 90 tapOK {abs($SIGMA) < 0.001} "ra (in - 0) vs ra (out - 0) (SIGMA)" 91 92 # check on updates to imageID 93 catdir catdir.test3 94 imextract imageID 95 sort imageID 96 tapOK {imageID[] == 4} "image IDs exist" 97 tapOK {imageID[0] == 1} "updated image IDs" 98 tapOK {imageID[1] == 2} "updated image IDs" 99 tapOK {imageID[2] == 3} "updated image IDs" 100 tapOK {imageID[3] == 4} "updated image IDs" 101 102 catdir catdir.test3 103 mextract imageID, time 104 set id = imageID 105 set t = time 106 imextract imageID, time 107 108 for i 0 time[] 109 subset T = t if (id == imageID[$i]) 110 set dT = T - time[$i] 111 vstat dT 112 tapOK {abs($MEAN) < 0.00001} "time for measure ID $i (MEAN)" 113 tapOK {abs($SIGMA) < 0.00001} "time for measure ID $i (SIGMA)" 114 end 115 116 # exec rm test.in.txt test.cmf 117 # exec rm -rf catdir.test1 118 # exec rm -rf catdir.test2 119 # exec rm -rf catdir.test3 120 121 tapDONE 122 end 123 124 # create 2 populated catdirs, each with a couple of cmf files 125 macro test.dvomerge.update 126 127 tapPLAN 51 128 129 exec rm -rf catdir.test1 130 exec rm -rf catdir.test2 131 exec rm -rf catdir.test3 132 133 $RA = 10.0 134 $DEC = 20.0 135 136 mkinput 18 137 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC 19 138 exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf … … 27 146 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 04:00:00 -radec $RA $DEC 28 147 exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf 148 149 break 29 150 30 151 exec rsync -auc catdir.test2/ catdir.test3/ -
trunk/Ohana/src/dvomerge/Makefile
r29001 r29938 22 22 all: dvomerge dvoconvert dvosecfilt 23 23 24 # $(SRC)/dvomergeContinue.$(ARCH).o 25 24 26 DVOMERGE = \ 25 27 $(SRC)/dvomerge.$(ARCH).o \ 26 28 $(SRC)/dvomergeUpdate.$(ARCH).o \ 27 29 $(SRC)/dvomergeCreate.$(ARCH).o \ 30 $(SRC)/dvomergeUpdate_threaded.$(ARCH).o \ 31 $(SRC)/dvomergeFromList.$(ARCH).o \ 32 $(SRC)/dvomergeImageIDs.$(ARCH).o \ 28 33 $(SRC)/dvo_image_merge_dbs.$(ARCH).o \ 29 34 $(SRC)/SetSignals.$(ARCH).o \ … … 70 75 $(BIN)/dvosecfilt.$(ARCH) : $(DVOSECFILT) 71 76 72 INSTALL = dvomerge dvoconvert dvosecfilt 77 DVOREPAIR = \ 78 $(SRC)/dvorepair.$(ARCH).o \ 79 $(SRC)/dvorepairFixCPT.$(ARCH).o \ 80 $(SRC)/dvorepairImagesVsMeasures.$(ARCH).o \ 81 $(SRC)/dvorepairDeleteImageList.$(ARCH).o \ 82 $(SRC)/dvorepairFixImages.$(ARCH).o \ 83 $(SRC)/psps_ids.$(ARCH).o \ 84 $(SRC)/LoadImages.$(ARCH).o \ 85 $(SRC)/ReadDeleteList.$(ARCH).o \ 86 $(SRC)/match_image.$(ARCH).o \ 87 $(SRC)/help.$(ARCH).o \ 88 $(SRC)/ImageOps.$(ARCH).o 89 90 $(DVOREPAIR) : $(INC)/dvomerge.h 91 92 $(BIN)/dvorepair.$(ARCH) : $(DVOREPAIR) 93 94 DVOVERIFY = \ 95 $(SRC)/dvoverify.$(ARCH).o 96 97 $(DVOVERIFY) : $(INC)/dvomerge.h 98 99 $(BIN)/dvoverify.$(ARCH) : $(DVOVERIFY) 100 101 INSTALL = dvomerge dvoconvert dvosecfilt dvorepair dvoverify 73 102 74 103 # dependancy rules for binary code ######################### -
trunk/Ohana/src/dvomerge/include/dvomerge.h
r29001 r29938 17 17 # include <glob.h> 18 18 19 # define myAbort(MSG) { fprintf (stderr, "%s\n", MSG); abort(); } 20 # define myAssert(LOGIC,MSG) { if (!(LOGIC)) { fprintf (stderr, "%s\n", MSG); abort(); } } 21 19 22 int VERBOSE; 20 23 char CATDIR[256]; … … 25 28 float RADIUS; 26 29 int SKY_DEPTH; 30 int NTHREADS; 27 31 char *ALTERNATE_PHOTCODE_FILE; 28 32 … … 65 69 SkyList *SkyTablePopulatedList_old PROTO((SkyTable *sky, off_t Ns, off_t Ne)); 66 70 67 int LoadCatalog PROTO((Catalog *catalog, SkyRegion *region, char *filename, char *mode ));71 int LoadCatalog PROTO((Catalog *catalog, SkyRegion *region, char *filename, char *mode, int Nsecfilt)); 68 72 69 73 int merge_catalogs_new PROTO((SkyRegion *region, Catalog *output, Catalog *input, int *secflitMap)); … … 86 90 off_t dvo_map_image_ID PROTO((IDmapType *IDmap, off_t oldID)); 87 91 int dvo_update_image_IDs PROTO((IDmapType *IDmap, Catalog *catalog)); 92 93 // dvorepair prototypes 94 Image *LoadImages PROTO((FITS_DB *db, char *filename, off_t *Nimage)); 95 Image *MatchImage PROTO((Image *image, off_t Nimage, unsigned int time, short int source, unsigned int imageID)); 96 off_t match_image PROTO((Image *image, off_t Nimage, unsigned int T, short int S)); 97 98 int SaveImages PROTO((FITS_DB *oldDB, char *filename, Image *imagesOut, off_t Nout)); 99 100 int dvorepairFixCPT PROTO((int argc, char **argv)); 101 int dvorepairImagesVsMeasures PROTO((int argc, char **argv)); 102 int dvorepairDeleteImageList PROTO((int argc, char **argv)); 103 int dvorepairFixImages PROTO((int argc, char **argv)); 104 105 int *ReadDeleteList PROTO((char *filename, int *nindex)); 106 int RepairTableCPT PROTO((char *cptFilenameSrc, char *cptFilenameTgt, char *cpsFilenameSrc, char *cpsFilenameTgt, Measure *measure, off_t Nmeasure, Image *image, off_t Nimage, char catformat)); 107 void dvorepair_help PROTO((int argc, char **argv)); 108 109 off_t getTgtIndex PROTO((e_time start, e_time stop, short photcode, off_t *TgtIndex, e_time *TgtTimes, short *TgtCodes, off_t NimagesTgt)); 110 void SortTgtByTimes PROTO((e_time *S, off_t *I, short *C, off_t N)); 111 int dvo_image_match_dbs PROTO((IDmapType *IDmap, FITS_DB *tgt, FITS_DB *src)); 112 int dvomergeImagesGetMap PROTO((IDmapType *IDmap, char *input, char *output)); 113 int dvomergeFromList PROTO((int argc, char **argv)); 114 int dvomergeUpdate_threaded PROTO((int argc, char **argv)); -
trunk/Ohana/src/dvomerge/src/LoadCatalog.c
r28329 r29938 1 1 # include "dvomerge.h" 2 2 3 int LoadCatalog (Catalog *catalog, SkyRegion *region, char *filename, char *mode ) {3 int LoadCatalog (Catalog *catalog, SkyRegion *region, char *filename, char *mode, int Nsecfilt) { 4 4 5 5 // set the parameters which guide catalog open/load/create 6 6 catalog[0].filename = filename; 7 catalog[0].Nsecfilt = GetPhotcodeNsecfilt ();7 catalog[0].Nsecfilt = Nsecfilt; 8 8 9 9 // always load all of the data (if any exists) -
trunk/Ohana/src/dvomerge/src/args.c
r29001 r29938 15 15 remove_argument (N, argc, argv); 16 16 ALTERNATE_PHOTCODE_FILE = strdup(argv[N]); 17 remove_argument (N, argc, argv); 18 } 19 20 NTHREADS = 0; 21 if ((N = get_argument (*argc, argv, "-threads"))) { 22 remove_argument (N, argc, argv); 23 NTHREADS = MAX(0, atoi(argv[N])); 17 24 remove_argument (N, argc, argv); 18 25 } … … 36 43 } 37 44 38 if ((*argc != 6) && (*argc != 4)) dvomerge_usage();45 if ((*argc < 4) || (*argc > 6)) dvomerge_usage(); 39 46 return TRUE; 40 47 } -
trunk/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c
r29001 r29938 2 2 3 3 void sort_IDmap (IDmapType *IDmap); 4 5 off_t getTgtIndex (e_time start, e_time stop, short photcode, off_t *TgtIndex, e_time *TgtTimes, short *TgtCodes, off_t NimagesTgt) { 6 7 // use bisection to find the starting entry by time 8 9 off_t Nlo, Nhi, N; 10 11 // find the last TGT before start 12 Nlo = 0; Nhi = NimagesTgt; 13 while (Nhi - Nlo > 10) { 14 N = 0.5*(Nlo + Nhi); 15 if (TgtTimes[N] < start) { 16 Nlo = MAX(N, 0); 17 } else { 18 Nhi = MIN(N + 1, NimagesTgt); 19 } 20 } 21 22 // check for the matched mosaic starting from Nlo 23 // we may have to go much beyond Nlo since stop is not sorted 24 // can we use a sorted version of stop to check when we are beyond the valid range?? 25 for (N = Nlo; N < NimagesTgt; N++) { 26 if (TgtTimes[N] < start) continue; 27 if (TgtTimes[N] > stop) return (-1); 28 if (TgtCodes[N] != photcode) continue; 29 return (TgtIndex[N]); 30 } 31 return (-1); 32 } 33 34 // sort two times vectors and an index by first time vector 35 void SortTgtByTimes (e_time *S, off_t *I, short *C, off_t N) { 36 37 # define SWAPFUNC(A,B){ e_time tmp_t; off_t tmp_i; short tmp_c; \ 38 tmp_t = S[A]; S[A] = S[B]; S[B] = tmp_t; \ 39 tmp_i = I[A]; I[A] = I[B]; I[B] = tmp_i; \ 40 tmp_c = C[A]; C[A] = C[B]; C[B] = tmp_c; \ 41 } 42 # define COMPARE(A,B)(S[A] < S[B]) 43 44 OHANA_SORT (N, COMPARE, SWAPFUNC); 45 46 # undef SWAPFUNC 47 # undef COMPARE 48 49 } 50 51 // we have two tables; 'tgt' contains some exposures from 'src' : find them and match a map 52 int dvo_image_match_dbs (IDmapType *IDmap, FITS_DB *tgt, FITS_DB *src) { 53 54 Image *imagesSrc, *imagesTgt; 55 off_t NimagesSrc, NimagesTgt; 56 off_t iSrc, iTgt; 57 off_t *TgtIndex; 58 e_time *TgtTimes; 59 short *TgtCodes; 60 61 imagesSrc = gfits_table_get_Image (&src[0].ftable, &NimagesSrc, &src[0].swapped); 62 if (!imagesSrc) { 63 fprintf (stderr, "ERROR: failed to read images from src\n"); 64 exit (2); 65 } 66 67 imagesTgt = gfits_table_get_Image (&tgt[0].ftable, &NimagesTgt, &tgt[0].swapped); 68 if (!imagesTgt) { 69 fprintf (stderr, "ERROR: failed to read images from tgt\n"); 70 exit (2); 71 } 72 73 ALLOCATE (IDmap->old, off_t, NimagesSrc); 74 ALLOCATE (IDmap->new, off_t, NimagesSrc); 75 IDmap->Nmap = NimagesSrc; 76 77 // match by time and photcode 78 ALLOCATE (TgtIndex, off_t, NimagesTgt); 79 ALLOCATE (TgtTimes, e_time, NimagesTgt); 80 ALLOCATE (TgtCodes, short, NimagesTgt); 81 82 // save the Index, Times, Codes for all TGT images 83 for (iTgt = 0; iTgt < NimagesTgt; iTgt++) { 84 TgtIndex[iTgt] = iTgt; 85 TgtTimes[iTgt] = imagesTgt[iTgt].tzero; 86 TgtCodes[iTgt] = imagesTgt[iTgt].photcode; 87 } 88 89 // sort the index, start, and stop by the start times: 90 SortTgtByTimes (TgtTimes, TgtIndex, TgtCodes, NimagesTgt); 91 92 for (iSrc = 0; iSrc < NimagesSrc; iSrc++) { 93 iTgt = getTgtIndex (imagesSrc[iSrc].tzero, imagesSrc[iSrc].tzero + (int) imagesSrc[iSrc].exptime, imagesSrc[iSrc].photcode, TgtIndex, TgtTimes, TgtCodes, NimagesTgt); 94 if (iTgt < 0) Shutdown ("failure to match images: %s\n", imagesSrc[iSrc].name); 95 IDmap[0].old[iSrc] = imagesSrc[iSrc].imageID; 96 IDmap[0].new[iSrc] = imagesTgt[iTgt].imageID; 97 } 98 99 FREE(TgtIndex); 100 FREE(TgtTimes); 101 FREE(TgtCodes); 102 103 // sort IDmap->old,new on the basis of IDmap->old: 104 sort_IDmap (IDmap); 105 106 return TRUE; 107 } 4 108 5 109 // merge db2 into db1 -
trunk/Ohana/src/dvomerge/src/dvoconvert.c
r29001 r29938 6 6 char filename[256], *input, *output; 7 7 8 int depth ;8 int depth, Nsecfilt; 9 9 off_t i, j, Ns, Ne; 10 10 SkyTable *outsky, *insky; … … 32 32 exit (1); 33 33 } 34 Nsecfilt = GetPhotcodeNsecfilt(); 35 34 36 // save the photcodes in the output catdir 35 37 sprintf (filename, "%s/Photcodes.dat", output); … … 67 69 68 70 // load / create output catalog 69 LoadCatalog (&outcatalog, &outsky[0].regions[i], outsky[0].filename[i], "w" );71 LoadCatalog (&outcatalog, &outsky[0].regions[i], outsky[0].filename[i], "w", Nsecfilt); 70 72 71 73 // combine only tables at equal or larger depth … … 77 79 78 80 // load input catalog 79 LoadCatalog (&incatalog, inlist[0].regions[j], inlist[0].filename[j], "r" );81 LoadCatalog (&incatalog, inlist[0].regions[j], inlist[0].filename[j], "r", Nsecfilt); 80 82 81 83 // skip empty input catalogs -
trunk/Ohana/src/dvomerge/src/dvomerge.c
r28327 r29938 8 8 dvomerge_args (&argc, argv); 9 9 10 // XXX require both inputs to be sorted? 11 12 if (argc == 6) dvomergeCreate (argc, argv); 13 if (argc == 4) dvomergeUpdate (argc, argv); 10 if (argc == 6) { 11 if (!strcasecmp (argv[2], "and")) { 12 dvomergeCreate (argc, argv); 13 } else { 14 dvomergeFromList (argc, argv); 15 } 16 } 17 if ((argc == 4) || (argc == 5)) { 18 if (NTHREADS) { 19 dvomergeUpdate_threaded (argc, argv); 20 } else { 21 dvomergeUpdate (argc, argv); 22 } 23 } 14 24 dvomerge_usage(); 15 25 exit (2); // cannot reach here. … … 18 28 /* we have two possible modes of operation: 19 29 20 Create : dvomerge (in1) and (in2) to (out) -- create a new db from two input dbs 21 Update : dvomerge (in) into (out) -- merge a new db into an existing db 30 Create : dvomerge (in1) and (in2) to (out) -- create a new db from two input dbs 31 Update : dvomerge (in) into (out) -- merge a new db into an existing db 32 Continue : dvomerge (in) into (out) continue -- merge a new db into an existing db 22 33 23 34 */ -
trunk/Ohana/src/dvomerge/src/dvomergeCreate.c
r28855 r29938 15 15 char *input1, *input2, *output; 16 16 IDmapType IDmap1, IDmap2; 17 int NsecfiltInput1, NsecfiltInput2, NsecfiltOutput; 17 18 18 19 if (strcasecmp (argv[2], "and")) dvomerge_usage(); … … 39 40 } 40 41 input1Photcodes = GetPhotcodeTable(); 42 NsecfiltInput1 = GetPhotcodeNsecfilt(); 41 43 42 44 // Read the input2 photcodes … … 48 50 } 49 51 input2Photcodes = GetPhotcodeTable(); 52 NsecfiltInput2 = GetPhotcodeNsecfilt(); 50 53 51 54 if (ALTERNATE_PHOTCODE_FILE) { … … 60 63 } 61 64 outputPhotcodes = GetPhotcodeTable(); 65 NsecfiltOutput = GetPhotcodeNsecfilt(); 62 66 63 67 secfiltMap1 = GetSecFiltMap(outputPhotcodes, input1Photcodes); … … 74 78 outputPhotcodes = input1Photcodes; 75 79 codesFilename = filename1; 80 NsecfiltOutput = NsecfiltInput1; 76 81 // secfitMap1 can remain NULL since input1 defines the set of codes 77 82 } … … 84 89 } 85 90 91 // trigger any dependencies, if any 92 SetPhotcodeTable(NULL); 93 86 94 // save the output photcodes in the output catdir 87 SetPhotcodeTable(outputPhotcodes);95 // SetPhotcodeTable(outputPhotcodes); 88 96 sprintf (filename, "%s/Photcodes.dat", output); 89 97 if (!check_file_access (filename, TRUE, TRUE, VERBOSE)) { … … 121 129 if (VERBOSE) fprintf (stderr, "output: %s\n", outsky[0].regions[i].name); 122 130 123 if (outputPhotcodes) {124 SetPhotcodeTable(outputPhotcodes);125 }131 // if (outputPhotcodes) { 132 // SetPhotcodeTable(outputPhotcodes); 133 // } 126 134 // load / create output catalog 127 LoadCatalog (&outcatalog, &outsky[0].regions[i], outsky[0].filename[i], "w" );128 129 if (input1Photcodes) {130 SetPhotcodeTable(input1Photcodes);131 }135 LoadCatalog (&outcatalog, &outsky[0].regions[i], outsky[0].filename[i], "w", NsecfiltOutput); 136 137 // if (input1Photcodes) { 138 // SetPhotcodeTable(input1Photcodes); 139 // } 132 140 // combine only tables at equal or larger depth 133 141 … … 138 146 139 147 // load input catalog (1) 140 LoadCatalog (&incatalog, inlist[0].regions[j], inlist[0].filename[j], "r" );148 LoadCatalog (&incatalog, inlist[0].regions[j], inlist[0].filename[j], "r", NsecfiltInput1); 141 149 142 150 // skip empty input catalogs … … 153 161 SkyListFree (inlist); 154 162 155 if (input2Photcodes) {156 SetPhotcodeTable(input2Photcodes);157 }163 // if (input2Photcodes) { 164 // SetPhotcodeTable(input2Photcodes); 165 // } 158 166 159 167 // load in all of the tables from input2 for this region … … 163 171 164 172 // load input catalog (2) 165 LoadCatalog (&incatalog, inlist[0].regions[j], inlist[0].filename[j], "r" );173 LoadCatalog (&incatalog, inlist[0].regions[j], inlist[0].filename[j], "r", NsecfiltInput2); 166 174 167 175 // skip empty input catalogs -
trunk/Ohana/src/dvomerge/src/dvomergeUpdate.c
r29001 r29938 3 3 int dvomergeUpdate (int argc, char **argv) { 4 4 5 int depth ;5 int depth, CONTINUE; 6 6 off_t i, j, Ns, Ne; 7 7 SkyTable *outsky, *insky; … … 13 13 PhotCodeData *outputPhotcodes; 14 14 int *secfiltMap = NULL; 15 int NsecfiltInput, NsecfiltOutput; 15 16 17 double dtime; 18 struct timeval start, stop; 19 gettimeofday (&start, NULL); 20 21 CONTINUE = FALSE; 16 22 if (strcasecmp (argv[2], "into")) dvomerge_usage(); 23 if (argc == 5) { 24 if (strcasecmp (argv[4], "continue")) dvomerge_usage(); 25 CONTINUE = TRUE; 26 } 17 27 18 28 input = argv[1]; … … 31 41 } 32 42 inputPhotcodes = GetPhotcodeTable(); 43 NsecfiltInput = GetPhotcodeNsecfilt(); 33 44 34 45 // since we are merging the input db into the output db, the output defines the photcode … … 41 52 42 53 outputPhotcodes = GetPhotcodeTable(); 54 NsecfiltOutput = GetPhotcodeNsecfilt(); 43 55 44 56 secfiltMap = GetSecFiltMap(outputPhotcodes, inputPhotcodes); … … 50 62 fprintf(stderr, "%s not found using photcodes from %s/Photcodes.dat\n", filename, input); 51 63 outputPhotcodes = inputPhotcodes; 64 NsecfiltOutput = NsecfiltInput; 65 52 66 if (!check_dir_access (output, VERBOSE)) { 53 67 fprintf (stderr, "error creating output database directory %s\n", output); … … 61 75 } 62 76 63 dvomergeImagesUpdate (&IDmap, input, output); 77 if (CONTINUE) { 78 // need to determine the mapping from the input to the output images 79 dvomergeImagesGetMap (&IDmap, input, output); 80 } else { 81 dvomergeImagesUpdate (&IDmap, input, output); 82 } 64 83 65 84 // load the sky table for the existing database … … 85 104 depth = inlist[0].regions[Ns][0].depth; 86 105 106 SetPhotcodeTable(NULL); 107 87 108 // loop over the populated input regions 88 109 for (i = 0; i < inlist[0].Nregions; i++) { … … 90 111 if (VERBOSE) fprintf (stderr, "input: %s\n", inlist[0].regions[i][0].name); 91 112 92 SetPhotcodeTable(inputPhotcodes);93 113 // load / create output catalog (if catalog does not exist, it will be created) 94 LoadCatalog (&incatalog, &inlist[0].regions[i][0], inlist[0].filename[i], "r" );114 LoadCatalog (&incatalog, &inlist[0].regions[i][0], inlist[0].filename[i], "r", NsecfiltInput); 95 115 // skip empty input catalogs 96 116 if (!incatalog.Naves_disk) { … … 111 131 112 132 // load input catalog 113 SetPhotcodeTable(outputPhotcodes); 114 LoadCatalog (&outcatalog, outlist[0].regions[j], outlist[0].filename[j], "w"); 133 LoadCatalog (&outcatalog, outlist[0].regions[j], outlist[0].filename[j], "w", NsecfiltOutput); 115 134 116 135 dvo_update_image_IDs (&IDmap, &incatalog); … … 121 140 // if we receive a signal which would cause us to exit, wait until the full catalog is written 122 141 SetProtect (TRUE); 123 dvo_catalog_save (&outcatalog, VERBOSE); 142 if (!dvo_catalog_save (&outcatalog, VERBOSE)) { 143 fprintf (stderr, "ERROR: failed to save catalog %s\n", outlist[0].filename[j]); 144 exit (1); 145 } 124 146 SetProtect (FALSE); 125 147 … … 143 165 } 144 166 167 gettimeofday (&stop, NULL); 168 dtime = DTIME (stop, start); 169 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec\n", dtime); 170 145 171 exit (0); 146 172 } 147 148 /*** update the image table ***/149 int dvomergeImagesUpdate (IDmapType *IDmap, char *input, char *output) {150 151 FITS_DB inDB;152 FITS_DB outDB;153 int status;154 155 /*** load input1/Images.dat ***/156 sprintf (ImageCat, "%s/Images.dat", input);157 inDB.mode = dvo_catalog_catmode (CATMODE);158 inDB.format = dvo_catalog_catformat (CATFORMAT);159 status = dvo_image_lock (&inDB, ImageCat, 3600.0, LCK_XCLD); // shorter timeout?160 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", inDB.filename);161 162 // load the image table163 if (inDB.dbstate == LCK_EMPTY) {164 // Shutdown ("can't find input image catalog %s", inDB.filename);165 IDmap->Nmap = 0;166 return TRUE;167 }168 if (!dvo_image_load (&inDB, VERBOSE, TRUE)) {169 Shutdown ("can't read input image catalog %s", inDB.filename);170 }171 172 /*** load output/Images.dat ***/173 sprintf (ImageCat, "%s/Images.dat", output);174 outDB.mode = dvo_catalog_catmode (CATMODE);175 outDB.format = dvo_catalog_catformat (CATFORMAT);176 status = dvo_image_lock (&outDB, ImageCat, 3600.0, LCK_XCLD); // shorter timeout?177 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", outDB.filename);178 179 /* load the image table */180 if (outDB.dbstate == LCK_EMPTY) {181 dvo_image_create (&outDB, GetZeroPoint());182 } else {183 if (!dvo_image_load (&outDB, VERBOSE, TRUE)) {184 Shutdown ("can't read output image catalog %s", outDB.filename);185 }186 }187 188 // convert database table to internal structure & add to output image db189 dvo_image_merge_dbs(IDmap, &outDB, &inDB);190 dvo_image_unlock (&inDB); // unlock input191 192 SetProtect (TRUE);193 dvo_image_save (&outDB, VERBOSE);194 SetProtect (FALSE);195 dvo_image_unlock (&outDB); // unlock output196 197 return TRUE;198 } -
trunk/Ohana/src/dvomerge/src/dvoverify.c
r29001 r29938 8 8 */ 9 9 10 int VerifyTableFile (char *filename); 11 12 # define DEBUG 0 13 10 14 int main (int argc, char **argv) { 11 15 12 char filename[ 256], *input, *output;13 14 int depth;15 off_t i , j, Ns, Ne;16 SkyTable * outsky, *insky;16 char filename[1024]; 17 18 int N, Nbad; 19 off_t i; 20 SkyTable *insky; 17 21 SkyList *inlist; 18 Catalog incatalog, outcatalog; 19 20 SetSignals (); 21 dvoconvert_help (argc, argv); 22 ConfigInit (&argc, argv); 23 dvoconvert_args (&argc, argv); 24 25 if (strcasecmp (argv[2], "to")) dvoconvert_usage(); 26 input = argv[1]; 27 output = argv[3]; 28 29 // load input images, save to output images 30 dvoConvert_copy_images (input, output); 31 32 // copy photcode table 33 { 34 // the first input defines the photcode table & db layout 35 sprintf (filename, "%s/Photcodes.dat", input); 36 if (!LoadPhotcodes (filename, NULL, FALSE)) { 37 fprintf (stderr, "error loading photcode table %s\n", filename); 38 exit (1); 39 } 40 // save the photcodes in the output catdir 41 sprintf (filename, "%s/Photcodes.dat", output); 42 if (!check_file_access (filename, TRUE, TRUE, VERBOSE)) { 43 fprintf (stderr, "error creating output catdir %s\n", output); 44 exit (1); 45 } 46 if (!SavePhotcodesFITS (filename)) { 47 fprintf (stderr, "error saving photcode table %s\n", filename); 48 exit (1); 49 } 50 } 51 52 // copy skytable 53 { 54 // load the sky table for the existing database 55 insky = SkyTableLoadOptimal (input, NULL, NULL, FALSE, SKY_DEPTH_HST, VERBOSE); 56 SkyTableSetFilenames (insky, input, "cpt"); 57 58 // generate an output table populated at the desired depth 59 // XXX force this to match the input? 60 outsky = SkyTableLoadOptimal (output, NULL, GSCFILE, TRUE, SKY_DEPTH, VERBOSE); 61 SkyTableSetFilenames (outsky, output, "cpt"); 62 63 SkyTablePopulatedRange (&Ns, &Ne, insky, 0); 64 depth = insky[0].regions[Ns].depth; 65 // XXX this seems to imply that insky is a uniform depth... 66 } 67 68 // loop over all input catalogs, save to output catalogs 69 // loop over the populatable output regions 70 for (i = 0; i < outsky[0].Nregions; i++) { 71 if (!outsky[0].regions[i].table) continue; 72 if (VERBOSE) fprintf (stderr, "output: %s\n", outsky[0].regions[i].name); 73 74 // load / create output catalog 75 LoadCatalog (&outcatalog, &outsky[0].regions[i], outsky[0].filename[i], "w"); 76 77 // combine only tables at equal or larger depth 78 79 // load in all of the tables from input for this region 80 inlist = SkyListByBounds (insky, depth, outsky[0].regions[i].Rmin, outsky[0].regions[i].Rmax, outsky[0].regions[i].Dmin, outsky[0].regions[i].Dmax); 81 for (j = 0; j < inlist[0].Nregions; j++) { 82 if (VERBOSE) fprintf (stderr, "input : %s\n", inlist[0].regions[j][0].name); 83 84 // load input catalog 85 LoadCatalog (&incatalog, inlist[0].regions[j], inlist[0].filename[j], "r"); 86 87 // skip empty input catalogs 88 if (!incatalog.Naves_disk) { 89 dvo_catalog_unlock (&incatalog); 90 dvo_catalog_free (&incatalog); 91 continue; 92 } 93 merge_catalogs_new (&outsky[0].regions[i], &outcatalog, &incatalog); 94 dvo_catalog_unlock (&incatalog); 95 dvo_catalog_free (&incatalog); 96 } 97 SkyListFree (inlist); 98 99 outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; 100 dvo_catalog_save (&outcatalog, VERBOSE); 101 dvo_catalog_unlock (&outcatalog); 102 dvo_catalog_free (&outcatalog); 103 } 104 105 // save the output sky table copy 106 sprintf (filename, "%s/SkyTable.fits", output); 107 check_file_access (filename, TRUE, TRUE, VERBOSE); 108 if (!SkyTableSave (outsky, filename)) { 109 fprintf (stderr, "ERROR: failed to save sky table for %s\n", output); 22 SkyRegion UserPatch; 23 // Catalog catalog; 24 25 // restrict to a portion of the sky 26 UserPatch.Rmin = 0; 27 UserPatch.Rmax = 360; 28 UserPatch.Dmin = -90; 29 UserPatch.Dmax = +90; 30 if ((N = get_argument (argc, argv, "-region"))) { 31 remove_argument (N, &argc, argv); 32 UserPatch.Rmin = atof (argv[N]); 33 remove_argument (N, &argc, argv); 34 UserPatch.Rmax = atof (argv[N]); 35 remove_argument (N, &argc, argv); 36 UserPatch.Dmin = atof (argv[N]); 37 remove_argument (N, &argc, argv); 38 UserPatch.Dmax = atof (argv[N]); 39 remove_argument (N, &argc, argv); 40 } 41 42 if (argc != 2) { 43 fprintf (stderr, "USAGE: dvoverify (catdir) [-region Rmin Rmax Dmin Dmax]\n"); 44 fprintf (stderr, " catdir : database of interest\n"); 45 exit (2); 46 } 47 48 char *catdir = argv[1]; 49 50 Nbad = 0; 51 52 // XXX make this step optional 53 if (1) { 54 // check the photcode table 55 sprintf (filename, "%s/Photcodes.dat", catdir); 56 if (!VerifyTableFile (filename)) { 57 Nbad ++; 58 } 59 60 // check the skytable 61 sprintf (filename, "%s/SkyTable.fits", catdir); 62 if (!VerifyTableFile (filename)) { 63 Nbad ++; 64 } 65 66 // check the image table 67 sprintf (filename, "%s/Images.dat", catdir); 68 if (!VerifyTableFile (filename)) { 69 Nbad ++; 70 } 71 } 72 73 // load the sky table for the existing database 74 insky = SkyTableLoadOptimal (catdir, NULL, NULL, FALSE, SKY_DEPTH_HST, VERBOSE); 75 myAssert(insky, "can't read SkyTable"); 76 SkyTableSetFilenames (insky, catdir, "cpt"); 77 inlist = SkyListByPatch (insky, -1, &UserPatch); 78 79 // loop over all catalogs, save to output catalogs 80 for (i = 0; i < inlist[0].Nregions; i++) { 81 if (!inlist[0].regions[i][0].table) continue; 82 83 if (i % 1000 == 0) fprintf (stderr, "."); 84 85 sprintf (filename, "%s/%s.cpt", catdir, inlist[0].regions[i][0].name); 86 if (!VerifyTableFile (filename)) { 87 Nbad ++; 88 } 89 90 sprintf (filename, "%s/%s.cps", catdir, inlist[0].regions[i][0].name); 91 if (!VerifyTableFile (filename)) { 92 Nbad ++; 93 } 94 95 sprintf (filename, "%s/%s.cpm", catdir, inlist[0].regions[i][0].name); 96 if (!VerifyTableFile (filename)) { 97 Nbad ++; 98 } 99 } 100 101 if (Nbad > 0) { 102 fprintf (stderr, "ERROR: %d files are bad\n", Nbad); 110 103 exit (1); 111 104 } 112 105 106 fprintf (stderr, "SUCCESS: no files are bad\n"); 113 107 exit (0); 114 108 } 115 109 116 int dvoConvert_copy_images (char *input, char *output) { 117 118 FITS_DB inDB; 119 FITS_DB outDB; 120 int status; 121 122 Image *images; 123 off_t Nimages; 124 off_t ID; 125 126 /*** load output/Images.dat ***/ 127 sprintf (ImageCat, "%s/Images.dat", output); 128 outDB.mode = dvo_catalog_catmode (CATMODE); 129 outDB.format = dvo_catalog_catformat (CATFORMAT); 130 status = dvo_image_lock (&outDB, ImageCat, 3600.0, LCK_XCLD); // shorter timeout? 131 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", outDB.filename); 132 133 // output image table should not already exist 134 if (outDB.dbstate != LCK_EMPTY) { 135 Shutdown ("ERROR: image table %s already exists", outDB.filename); 136 } 137 dvo_image_create (&outDB, GetZeroPoint()); 138 139 /*** load input/Images.dat ***/ 140 sprintf (ImageCat, "%s/Images.dat", input); 141 // inDB.mode = dvo_catalog_catmode (CATMODE); 142 // inDB.format = dvo_catalog_catformat (CATFORMAT); 143 status = dvo_image_lock (&inDB, ImageCat, 3600.0, LCK_XCLD); // shorter timeout? 144 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", inDB.filename); 145 146 // load the image table 147 if (inDB.dbstate == LCK_EMPTY) { 148 Shutdown ("can't find input image catalog %s", inDB.filename); 149 } 150 if (!dvo_image_load (&inDB, VERBOSE, TRUE)) { 151 Shutdown ("can't read input image catalog %s", inDB.filename); 152 } 153 154 // convert the raw image table to Image type (byteswap if needed) 155 images = gfits_table_get_Image (&inDB.ftable, &Nimages, &inDB.swapped); 156 if (!images) { 157 fprintf (stderr, "ERROR: failed to read images\n"); 158 exit (2); 159 } 160 161 // update additional metadata 162 gfits_scan (&inDB.header, "IMAGEID", OFF_T_FMT, 1, &ID); 163 gfits_modify (&outDB.header, "NIMAGES", OFF_T_FMT, 1, Nimages); 164 gfits_modify (&outDB.header, "IMAGEID", OFF_T_FMT, 1, ID); 165 166 // copy input rows to output table 167 gfits_add_rows (&outDB.ftable, (char *) images, Nimages, sizeof(Image)); 168 169 // write out the image table to disk 170 SetProtect (TRUE); 171 dvo_image_save (&outDB, VERBOSE); 172 SetProtect (FALSE); 173 dvo_image_unlock (&outDB); // unlock output 174 dvo_image_unlock (&inDB); // unlock input1 175 110 // is this file a consistent FITS file? 111 int VerifyTableFile (char *filename) { 112 113 int status; 114 off_t Nbytes; 115 Header header; 116 117 struct stat fileStats; 118 FILE *file; 119 120 // does the file exist? 121 status = stat (filename, &fileStats); 122 if (status) { 123 // some error accessing the file. there is only one acceptable error: file not found 124 switch (errno) { 125 case ENOENT: 126 if (DEBUG) fprintf (stderr, "file does not exist, skipping %s\n", filename); 127 return TRUE; 128 case ENOMEM: 129 fprintf (stderr, "Out of memory: %s\n", filename); 130 return TRUE; 131 case EACCES: 132 fprintf (stderr, "Permission error on %s\n", filename); 133 return FALSE; 134 case EFAULT: 135 fprintf (stderr, "Bad address: %s\n", filename); 136 return FALSE; 137 case ELOOP: 138 fprintf (stderr, "Too many symbolic links encountered while traversing the path: %s\n", filename); 139 return FALSE; 140 case ENAMETOOLONG: 141 fprintf (stderr, "File name too long: %s\n", filename); 142 return FALSE; 143 case ENOTDIR: 144 fprintf (stderr, "A component of the path is not a directory: %s\n", filename); 145 return FALSE; 146 case EOVERFLOW: 147 fprintf (stderr, "file too large for program version: %s\n", filename); 148 return FALSE; 149 default: 150 fprintf (stderr, "unknown error: %s\n", filename); 151 return FALSE; 152 } 153 } 154 155 // does it have any data? 156 if (fileStats.st_size == 0) { 157 fprintf (stderr, "file is empty: %s\n", filename); 158 return FALSE; 159 } 160 161 // can we open it? 162 file = fopen(filename, "r"); 163 if (!file) { 164 fprintf (stderr, "unable to open valid file: %s\n", filename); 165 return FALSE; 166 } 167 168 // scan all extentions 169 Nbytes = 0; 170 if (DEBUG) fprintf (stderr, "sizes: ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nbytes, fileStats.st_size); 171 while (Nbytes < fileStats.st_size) { 172 173 // Check on the PHU 174 if (!gfits_fread_header (file, &header)) { 175 fprintf (stderr, "unable to read PHU header for %s\n", filename); 176 fclose(file); 177 return (FALSE); 178 } 179 180 // move to TBL header 181 Nbytes += header.datasize + gfits_data_size (&header); 182 if (DEBUG) fprintf (stderr, "sizes: ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nbytes, fileStats.st_size); 183 if (Nbytes > fileStats.st_size) { 184 fprintf (stderr, "file is short ("OFF_T_FMT" vs "OFF_T_FMT"): %s\n", Nbytes, fileStats.st_size, filename); 185 gfits_free_header(&header); 186 fclose (file); 187 return FALSE; 188 } 189 gfits_free_header(&header); 190 191 status = fseeko (file, Nbytes, SEEK_SET); 192 if (status) { 193 switch (errno) { 194 case EBADF: 195 fprintf (stderr, "something wrong with file handle: %s\n", filename); 196 fclose (file); 197 return FALSE; 198 case EINVAL: 199 fprintf (stderr, "invalid offset: %s\n", filename); 200 fclose (file); 201 return FALSE; 202 default: 203 fprintf (stderr, "other error in fseeko: %s\n", filename); 204 fclose (file); 205 return FALSE; 206 } 207 } 208 } 209 if (DEBUG) fprintf (stderr, "file is good: %s\n", filename); 210 fclose (file); 176 211 return TRUE; 177 212 } 213 214 // gfits_scan(&cpmHeaderTBL, "NAXIS1", "%d", 1, &NbytesPerRow); 215 // gfits_scan(&cpmHeaderTBL, "NAXIS2", "%d", 1, &Nrows); 216 217 -
trunk/Ohana/src/dvomerge/src/help.c
r29001 r29938 4 4 fprintf (stderr, "USAGE: dvomerge (input1) and (input2) to (output)\n"); 5 5 fprintf (stderr, " OR: dvomerge (input) into (output)\n"); 6 fprintf (stderr, " OR: dvomerge (input) into (output) continue\n"); 7 fprintf (stderr, " OR: dvomerge (input) into (output) from (list)\n"); 6 8 fprintf (stderr, " [-region Rmin Rmax Dmin Dmax]\n"); 7 9 exit (2); … … 17 19 void dvosecfilt_usage(void) { 18 20 19 fprintf (stderr, "USAGE: dvosecfilt ( input) -photcodes (photcodes.txt)\n");21 fprintf (stderr, "USAGE: dvosecfilt (catdir) (Nsecfilt)\n"); 20 22 21 23 exit (2); … … 33 35 fprintf (stderr, "USAGE\n"); 34 36 fprintf (stderr, " dvomerge (input1) and (input2) to (output)\n"); 35 fprintf (stderr, " dvomerge (input) into (output)\n\n"); 37 fprintf (stderr, " dvomerge (input) into (output)\n"); 38 fprintf (stderr, " dvomerge (input) into (output) continue\n\n"); 39 fprintf (stderr, " dvomerge (input) into (output) from (list)\n\n"); 36 40 fprintf (stderr, " merge DVO databases\n"); 37 41 fprintf (stderr, " optional flags:\n"); … … 39 43 fprintf (stderr, " -help : this list\n"); 40 44 fprintf (stderr, " -h : this list\n\n"); 45 fprintf (stderr, " -region Rmin Rmax Dmin Dmax : region to merge\n\n"); 41 46 exit (2); 42 47 } … … 75 80 76 81 fprintf (stderr, "USAGE\n"); 77 fprintf (stderr, " dvosecfilt ( input) (Nsecfilt)\n\n");82 fprintf (stderr, " dvosecfilt (catdir) (Nsecfilt)\n\n"); 78 83 79 fprintf (stderr, " change number of secfilt entries in photcode table (updates secfilt tables only)\n"); 84 fprintf (stderr, " change number of secfilt entries in photcode table (updates secfilt tables (cps), NSECFILT in cpt files)\n"); 85 fprintf (stderr, " NOTE: the user must change the photcode table to reflect the change (use photcode-table -export / -import)\n"); 80 86 81 87 fprintf (stderr, " optional flags:\n"); … … 86 92 } 87 93 94 void dvorepair_help (int argc, char **argv) { 95 96 /* check for help request */ 97 if (!argv) goto show_help; 98 if (get_argument (argc, argv, "-help")) goto show_help; 99 if (get_argument (argc, argv, "-h")) goto show_help; 100 if (argc < 2) goto show_help; 101 return; 102 103 show_help: 104 105 fprintf (stderr, "USAGE\n"); 106 fprintf (stderr, " dvorepair -fix-cpt (images) (rootlist) - regenerate cpt & cps files from the cpm files\n"); 107 fprintf (stderr, " dvorepair -images-vs-measures (catdir) (Ntol) - find images with too many missing detections\n"); 108 fprintf (stderr, " dvorepair -delete-image-list (catdir) (deleteList) - delete a set of images based on image IDs (output from -images-vs-measures)\n"); 109 fprintf (stderr, " dvorepair -fix-images (catdir) (deleteList) - delete a set of images based on image IDs (output from -images-vs-measures)\n"); 110 fprintf (stderr, "\n"); 111 112 fprintf (stderr, " optional flags:\n"); 113 fprintf (stderr, " -help : this list\n"); 114 fprintf (stderr, " -h : this list\n\n"); 115 exit (2); 116 } 117 -
trunk/Ohana/src/dvomerge/src/merge_catalogs_old.c
r29181 r29938 28 28 unsigned int objID, catID; 29 29 Coords tcoords; 30 30 31 31 // struct timeval start, stop; 32 32 // gettimeofday (&start, (void *) NULL); … … 240 240 } else { 241 241 for (k = 0; k < NsecfiltIn; k++) { 242 if (secfiltMap[k] < 0) continue; // skip secfilt entries from input that are not in the output 243 242 244 // index for this entry in output's secfilt list 243 245 int outputIndex = n * NsecfiltOut + secfiltMap[k]; … … 254 256 i++; 255 257 } 256 // MARKTIME("find matched stars: %f sec for "OFF_T_FMT","OFF_T_FMT" stars \n", dtime, Nstars, Nave);258 // MARKTIME("find matched stars: %f sec for "OFF_T_FMT","OFF_T_FMT" stars ("OFF_T_FMT" meas)\n", dtime, Nstars, Nave, Nmeas); 257 259 258 260 /** incorporate unmatched image stars, if this star is in field of this catalog **/ -
trunk/Ohana/src/imregister/imphot/rfits.c
r7080 r29938 17 17 return (FALSE); 18 18 } 19 if (!gfits_fread_ftable_data (db[0].f, &db[0].ftable )) {19 if (!gfits_fread_ftable_data (db[0].f, &db[0].ftable, FALSE)) { 20 20 fprintf (stderr, "can't read table data"); 21 21 return (FALSE); -
trunk/Ohana/src/kapa2/Makefile
r25757 r29938 42 42 $(SRC)/bDrawObjects.$(ARCH).o $(SRC)/bDrawFrame.$(ARCH).o \ 43 43 $(SRC)/bDrawLabels.$(ARCH).o $(SRC)/bDrawIt.$(ARCH).o \ 44 $(SRC)/bDrawImage.$(ARCH).o \ 44 45 $(SRC)/PNGit.$(ARCH).o $(SRC)/PPMit.$(ARCH).o \ 45 46 $(SRC)/PSit.$(ARCH).o $(SRC)/CrossHairs.$(ARCH).o \ -
trunk/Ohana/src/kapa2/include/prototypes.h
r29539 r29938 40 40 void DrawYErrors PROTO((KapaGraphWidget *graph, Gobjects *objects)); 41 41 void DrawTick PROTO((Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis)); 42 void AxisTickScale PROTO((Axis *axis, double *major, double *minor ));42 void AxisTickScale PROTO((Axis *axis, double *major, double *minor, int *nsignif)); 43 43 TickMarkData *CreateAxisTicks PROTO((Axis *axis, int *nticks)); 44 int PrintTick PROTO((char *string, double value, double min, double max ));44 int PrintTick PROTO((char *string, double value, double min, double max, int nsignif)); 45 45 46 46 /* EventLoop */ 47 47 int PScommand PROTO((int sock)); 48 int PNGcommand PROTO((int sock)); 48 49 int CheckPipe PROTO((void)); 49 50 int Reconfig PROTO((XEvent *event)); … … 52 53 53 54 /* CheckPipe */ 54 int PNGit PROTO(( int sock));55 int PNGit PROTO((char *filename)); 55 56 int PPMit PROTO((int sock)); 56 57 int LoadFrame PROTO((int sock)); … … 67 68 int MoveSection PROTO((int sock)); 68 69 int DefineSection PROTO((int sock)); 70 int DefineSectionByImage PROTO((int sock)); 69 71 int SetFont PROTO((int sock)); 70 72 int EraseCurrentPlot PROTO((void)); … … 126 128 127 129 /* kapa bDraw Functions */ 128 int bDrawFrame PROTO((KapaGraphWidget *graph)); 129 int bDrawObjects PROTO((KapaGraphWidget *graph)); 130 void bDrawLabels PROTO((KapaGraphWidget *graph)); 131 void bDrawTextlines PROTO((KapaGraphWidget *graph)); 132 void bDrawConnect PROTO((KapaGraphWidget *graph, Gobjects *object)); 133 void bDrawHistogram PROTO((KapaGraphWidget *graph, Gobjects *object)); 134 void bDrawPoints PROTO((KapaGraphWidget *graph, Gobjects *object)); 135 void bDrawXErrors PROTO((KapaGraphWidget *graph, Gobjects *object)); 136 void bDrawYErrors PROTO((KapaGraphWidget *graph, Gobjects *object)); 137 void bDrawTick PROTO((Axis *axis, int P, TickMarkData *tick, int naxis)); 138 void bDrawClipLine PROTO((double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0)); 139 bDrawBuffer *bDrawIt PROTO((void)); 140 void bDrawGraph PROTO((KapaGraphWidget *graph)); 130 int bDrawFrame PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph)); 131 int bDrawObjects PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph)); 132 void bDrawLabels PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph)); 133 void bDrawTextlines PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph)); 134 void bDrawConnect PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object)); 135 void bDrawHistogram PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object)); 136 void bDrawPoints PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object)); 137 void bDrawXErrors PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object)); 138 void bDrawYErrors PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object)); 139 void bDrawTick PROTO((bDrawBuffer *buffer, Axis *axis, int P, TickMarkData *tick, int naxis)); 140 void bDrawClipLine PROTO((bDrawBuffer *buffer, double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0)); 141 void bDrawGraph PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph)); 142 int bDrawImage PROTO((bDrawBuffer *buffer, KapaImageWidget *image, Graphic *graphic)); 143 bDrawBuffer *bDrawIt PROTO((png_color *palette, int Npalette, int Nbyte)); 141 144 142 145 /* misc support */ … … 212 215 int Overlay3 PROTO((Graphic *graphic, KapaImageWidget *image)); 213 216 int PSfunction PROTO((Graphic *graphic, KapaImageWidget *image)); 217 int PNGfunction PROTO((Graphic *graphic, KapaImageWidget *image)); 218 int JPEGfunction PROTO((Graphic *graphic, KapaImageWidget *image)); 214 219 215 220 /* misc functions */ … … 219 224 int SaveOverlay (int sock); 220 225 int CSaveOverlay (int sock); 221 int JPEGit24 (int sock); 226 int JPEGit24 (char *filename); 227 int JPEGcommand (int sock); 222 228 223 229 int UpdatePointer (Graphic *graphic, XMotionEvent *event); … … 241 247 int GetActiveSocket (void); 242 248 void InvertButton (Graphic *graphic, Button *button); 243 void bDrawOverlay ( KapaImageWidget *image, int N);249 void bDrawOverlay (bDrawBuffer *buffer, KapaImageWidget *image, int N); 244 250 245 251 /* color cube tools */ … … 261 267 int SetColorScale3D_CC (Graphic *graphic, KapaImageWidget *image); 262 268 int SetColorCubeHistogram (void); 269 int GetGraphBoundary (Section *section, double *x0, double *y0, double *x1, double *y1, int *dXm, int *dXp, int *dYm, int *dYp); 270 int ResizeByImage (int sock); 271 -
trunk/Ohana/src/kapa2/include/structures.h
r29539 r29938 148 148 int IsMajor; 149 149 int IsLabel; 150 int nsignif; 150 151 } TickMarkData; 151 152 -
trunk/Ohana/src/kapa2/src/ButtonFunctions.c
r29539 r29938 7 7 8 8 status = PSit ("kapa.ps", "default", TRUE, KAPA_PS_NEWPLOT); 9 return (status); 10 } 11 12 int PNGfunction (Graphic *graphic, KapaImageWidget *image) { 13 14 int status; 15 16 status = PNGit ("kapa.png"); 17 return (status); 18 } 19 20 int JPEGfunction (Graphic *graphic, KapaImageWidget *image) { 21 22 int status; 23 24 status = JPEGit24 ("kapa.jpg"); 9 25 return (status); 10 26 } -
trunk/Ohana/src/kapa2/src/CheckPipe.c
r27790 r29938 89 89 90 90 if (!strcmp (word, "PNGF")) { 91 status = PNGit (sock); 92 KiiSendCommand (sock, 4, "DONE"); 93 FINISHED (status); 94 } 95 91 status = PNGcommand (sock); 92 KiiSendCommand (sock, 4, "DONE"); 93 FINISHED (status); 94 } 95 96 if (!strcmp (word, "JPEG")) { 97 status = JPEGcommand (sock); 98 KiiSendCommand (sock, 4, "DONE"); 99 FINISHED (status); 100 } 101 96 102 if (!strcmp (word, "PPMF")) { 97 103 status = PPMit (sock); … … 131 137 } 132 138 139 if (!strcmp (word, "ISIZ")) { 140 status = ResizeByImage (sock); 141 KiiSendCommand (sock, 4, "DONE"); 142 FINISHED (TRUE); 143 } 144 133 145 if (!strcmp (word, "MOVE")) { 134 146 status = Relocate (sock); … … 211 223 if (!strcmp (word, "DSEC")) { 212 224 status = DefineSection (sock); 225 KiiSendCommand (sock, 4, "DONE"); 226 FINISHED (TRUE); 227 } 228 229 if (!strcmp (word, "ISEC")) { 230 status = DefineSectionByImage (sock); 213 231 KiiSendCommand (sock, 4, "DONE"); 214 232 FINISHED (TRUE); … … 300 318 if (!strcmp (word, "CSVE")) { 301 319 status = CSaveOverlay (sock); 302 KiiSendCommand (sock, 4, "DONE");303 FINISHED (status);304 }305 306 if (!strcmp (word, "JPEG")) {307 status = JPEGit24 (sock);308 320 KiiSendCommand (sock, 4, "DONE"); 309 321 FINISHED (status); -
trunk/Ohana/src/kapa2/src/DefineSection.c
r27790 r29938 40 40 return (TRUE); 41 41 } 42 43 // define the section, but do not create a graph or image 44 int DefineSectionByImage (int sock) { 45 46 int N, bg; 47 char name[128]; 48 double x, y, dx, dy; 49 int dXm, dXp, dYm, dYp; 50 double x0, y0, x1, y1, expand; 51 Section *section; 52 Graphic *graphic; 53 KapaImageWidget *image; 54 55 KiiScanMessage (sock, "%s %lf %lf %d", name, &x, &y, &bg); 56 57 N = GetSectionByName (name); 58 section = GetSectionByNumber (N); 59 image = section->image; 60 if (!image) { 61 fprintf (stderr, "no image to define section\n"); 62 return (TRUE); 63 } 64 SetActiveSectionByNumber (N); 65 66 graphic = GetGraphic (); 67 68 GetGraphBoundary (section, &x0, &y0, &x1, &y1, &dXm, &dXp, &dYm, &dYp); 69 70 expand = 1.0; 71 if (image[0].picture.expand > 0) { 72 expand = image[0].picture.expand; 73 } 74 if (image[0].picture.expand < 0) { 75 expand = 1.0 / fabs((double)image[0].picture.expand); 76 } 77 78 // pixel dimensions of the imaging region + boundary 79 dx = image[0].image[0].matrix.Naxis[0]*expand + x1; 80 dy = image[0].image[0].matrix.Naxis[1]*expand + y1; 81 82 section[0].x = x; 83 section[0].y = y; 84 section[0].bg = bg; 85 section[0].dx = dx / graphic[0].dx; 86 section[0].dy = dy / graphic[0].dy; 87 88 // if (section[0].x != x) MoveSection = TRUE; 89 // if (section[0].y != y) MoveSection = TRUE; 90 // if (section[0].dx != dx) MoveSection = TRUE; 91 // if (section[0].dy != dy) MoveSection = TRUE; 92 93 SetSectionSizes (section); 94 Refresh (); 95 96 return (TRUE); 97 } -
trunk/Ohana/src/kapa2/src/DrawFrame.c
r29539 r29938 5 5 int DrawFrame (KapaGraphWidget *graph) { 6 6 7 int i, j, Nticks, P ;8 double fx, fy, dfx, dfy, lweight;7 int i, j, Nticks, P, doffset; 8 double fx, fy, dfx, dfy, dx, dy, lweight; 9 9 Graphic *graphic; 10 10 TickMarkData *ticks; … … 15 15 /* each axis is drawn independently, but ticks and labels are placed according to perpendicular distance. */ 16 16 for (i = 0; i < 4; i++) { 17 fx = graph[0].axis[i].fx;18 fy = graph[0].axis[i].fy;19 dfx = graph[0].axis[i].dfx;20 dfy = graph[0].axis[i].dfy;21 P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy);22 23 17 lweight = MAX (0, MIN (10, graph[0].axis[i].lweight)); 24 18 color = MAX (0, MIN (15, graph[0].axis[i].color)); 19 20 /* temporarily assume rectilinear axes */ 21 doffset = ((int)(lweight) % 2) ? 0.5*(lweight - 1) : 0.5*lweight; 22 if (i == 0) { dx = doffset; dy = 0.0; } 23 if (i == 2) { dx = doffset; dy = 0.0; } 24 if (i == 1) { dx = 0.0; dy = doffset; } 25 if (i == 3) { dx = 0.0; dy = doffset; } 26 27 fx = graph[0].axis[i].fx - dx; 28 fy = graph[0].axis[i].fy - dy; 29 dfx = graph[0].axis[i].dfx + 2*dx; 30 dfy = graph[0].axis[i].dfy + 2*dy; 31 32 P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy); 33 P *= (1 + 0.25*lweight); 25 34 26 35 XSetLineAttributes (graphic->display, graphic->gc, lweight, LineSolid, CapNotLast, JoinMiter); … … 43 52 } 44 53 45 int PrintTick (char *string, double value, double min, double max ) {54 int PrintTick (char *string, double value, double min, double max, int nsignif) { 46 55 47 56 int Nexp = 0; … … 54 63 } 55 64 56 double lvalue = log10(fabs(value)); 57 58 if (isfinite(lvalue)) { 59 Nexp = fabs(lvalue); 60 } else { 61 Nexp = 0; 62 } 63 65 // double lvalue = log10(fabs(value)); 66 // if (isfinite(lvalue)) { 67 // Nexp = fabs(lvalue); 68 // } else { 69 // Nexp = 0; 70 // } 71 72 Nexp = abs(nsignif); 73 64 74 if (Nexp > 3) { 65 75 Nchar = sprintf (string, "%.1e", value); 66 76 } else { 67 Nchar = sprintf (string, "%.1f", value); 77 if (nsignif < 0) { 78 char format[16]; 79 snprintf (format, 16, "%%.%df", -1 * nsignif); 80 Nchar = sprintf (string, format, value); 81 } else { 82 Nchar = sprintf (string, "%.1f", value); 83 } 68 84 } 69 85 return Nchar; … … 129 145 yt = fy + (value-min)*dfy/(max - min) + dy; 130 146 131 PrintTick (string, value, min, max );147 PrintTick (string, value, min, max, tick->nsignif); 132 148 DrawRotText (xt, yt, string, pos, 0.0); 133 149 } … … 136 152 # define MIN_RANGE 1e-10 137 153 138 void AxisTickScale (Axis *axis, double *major, double *minor ) {154 void AxisTickScale (Axis *axis, double *major, double *minor, int *nsignif) { 139 155 140 156 double range, lrange, factor, mantis, fmantis, power; … … 152 168 } 153 169 170 // how many significant digits are needed? 171 154 172 power = MAX(pow(10.0, factor), MIN_RANGE); 155 173 fmantis = pow(10.0, mantis); … … 160 178 *major = 0.5 * power; 161 179 *minor = 0.1 * power; 180 *nsignif = factor - 1; 162 181 if (axis[0].areticks == 1) { 163 182 *major = 0.25 * power; 164 183 *minor = 0.05 * power; 184 *nsignif = factor - 2; 165 185 } 166 186 } … … 168 188 *major = 1.0 * power; 169 189 *minor = 0.2 * power; 190 *nsignif = factor; 170 191 if (axis[0].areticks == 1) { 171 192 *major = 0.5 * power; 172 193 *minor = 0.1 * power; 194 *nsignif = factor - 1; 173 195 } 174 196 } … … 176 198 *major = 1.0 * power; 177 199 *minor = 0.5 * power; 200 *nsignif = factor; 178 201 if (axis[0].areticks == 1) { 179 202 *major = 1.0 * power; 180 203 *minor = 0.2 * power; 204 *nsignif = factor; 181 205 } 182 206 } … … 184 208 *major = 2.0 * power; 185 209 *minor = 0.5 * power; 210 *nsignif = factor; 186 211 if (axis[0].areticks == 1) { 187 212 *major = 1.0 * power; 188 213 *minor = 0.5 * power; 214 *nsignif = factor; 189 215 } 190 216 } … … 192 218 *major = 2.5 * power; 193 219 *minor = 0.5 * power; 220 *nsignif = factor - 1; 194 221 if (axis[0].areticks == 1) { 195 222 *major = 2.0 * power; 196 223 *minor = 0.5 * power; 224 *nsignif = factor; 197 225 } 198 226 } … … 203 231 TickMarkData *ticks; 204 232 double range, major, minor, first, value, dPixels, overshoot; 205 int i, NTICKS, nPixels, done, ifirst ;233 int i, NTICKS, nPixels, done, ifirst, nsignif; 206 234 207 235 *nticks = 0; … … 223 251 dPixels = nPixels / range; // axis pixel-scale 224 252 225 AxisTickScale (axis, &major, &minor );253 AxisTickScale (axis, &major, &minor, &nsignif); 226 254 227 255 // be a little generous … … 256 284 ticks[i].IsLabel = (ticks[i].IsMajor && axis->islabel); 257 285 ticks[i].value = value; 286 ticks[i].nsignif = nsignif; 258 287 if (range > 0) 259 288 value += minor; -
trunk/Ohana/src/kapa2/src/Image.c
r29539 r29938 88 88 89 89 InitButtonSize (&image[0].PS_button, PS_width, PS_height, PS_bits); 90 InitButtonFunc (&image[0].PS_button, PSfunction); 90 // InitButtonFunc (&image[0].PS_button, PSfunction); 91 image->PS_button.function_1 = PSfunction; 92 image->PS_button.function_2 = PNGfunction; 93 image->PS_button.function_3 = JPEGfunction; 91 94 92 95 InitButtonSize (&image[0].grey_button, grey_width, grey_height, grey_bits); -
trunk/Ohana/src/kapa2/src/JPEGit24.c
r27601 r29938 8 8 # define WHITE_B 255 9 9 10 int JPEGcommand (int sock) { 11 12 int status; 13 char filename[1024]; 14 15 KiiScanMessage (sock, "%s", filename); 16 status = JPEGit24 (filename); 17 return (status); 18 } 19 10 20 // XXX this currently writes out the jpeg for just the active image 11 int JPEGit24 ( int sock) {21 int JPEGit24 (char *filename) { 12 22 13 23 struct jpeg_compress_struct cinfo; … … 31 41 unsigned short *in_pix, *in_pix_ref; 32 42 unsigned char *pixel1, *pixel2, *pixel3; 33 char filename[1024];34 43 FILE *f; 35 36 /* expect a line telling the number of bytes and a filename */37 KiiScanMessage (sock, "%s", filename);38 44 39 45 graphic = GetGraphic(); … … 196 202 palette = KapaPNGPalette (&Npalette); 197 203 198 buffer = bDrawBufferCreate (dx, dy); 199 bDrawSetBuffer (buffer); 204 buffer = bDrawBufferCreate (dx, dy, 1, palette, Npalette); 200 205 for (i = 0; i < NOVERLAYS; i++) { 201 if (image[ i].overlay[i].active) bDrawOverlay (image, i);206 if (image[0].overlay[i].active) bDrawOverlay (buffer, image, i); 202 207 } 203 208 -
trunk/Ohana/src/kapa2/src/PNGit.c
r29408 r29938 7 7 */ 8 8 9 bDrawBuffer *bDrawBufferCreate8bitRGB (int Nx, int Ny); 10 int bDrawImage (bDrawBuffer *buffer, Graphic *graphic); 9 int PNGcommand (int sock) { 11 10 12 int PNGit (int sock) { 11 int status; 12 char filename[1024]; 13 14 KiiScanMessage (sock, "%s", filename); 15 status = PNGit (filename); 16 return (status); 17 } 18 19 int PNGit (char *filename) { 13 20 14 21 FILE *f; 15 22 png_structp png_ptr; 16 23 png_infop info_ptr; 17 int status, Npalette; 18 char filename[1024]; 24 int i, status, Npalette, Nsection; 19 25 bDrawBuffer *buffer = NULL; 20 26 Graphic *graphic = NULL; 21 27 png_color *palette = NULL; 28 Section *section; 22 29 23 30 graphic = GetGraphic(); 24 25 /* expect a line telling the number of bytes and a filename */26 KiiScanMessage (sock, "%s", filename);27 31 28 32 f = fopen (filename, "w"); … … 62 66 png_init_io (png_ptr, f); 63 67 68 palette = KapaPNGPalette (&Npalette); 69 70 // do we have an image in any of the sections? 71 Nsection = GetNumberOfSections (); 72 int haveImage = FALSE; 73 for (i = 0; !haveImage && (i < Nsection); i++) { 74 section = GetSectionByNumber (i); 75 haveImage = (section->image != NULL); 76 } 77 64 78 /* see docs for write-row-callback to provide progress info */ 65 # define PALETTE 1 66 if (PALETTE) { 67 png_set_IHDR (png_ptr, info_ptr, graphic->dx, graphic->dy, 8, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); 68 palette = KapaPNGPalette (&Npalette); 69 png_set_PLTE (png_ptr, info_ptr, palette, Npalette); 70 } else { 79 if (haveImage) { 71 80 // png_set_IHDR (png_ptr, info_ptr, graphic->dx, graphic->dy, 16, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); 72 81 png_set_IHDR (png_ptr, info_ptr, graphic->dx, graphic->dy, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); 73 82 png_set_sRGB (png_ptr, info_ptr, PNG_sRGB_INTENT_ABSOLUTE); 83 } else { 84 png_set_IHDR (png_ptr, info_ptr, graphic->dx, graphic->dy, 8, PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); 85 png_set_PLTE (png_ptr, info_ptr, palette, Npalette); 74 86 } 75 87 … … 81 93 png_write_info (png_ptr, info_ptr); 82 94 83 if (PALETTE) { 84 buffer = bDrawIt (); 95 if (haveImage) { 96 buffer = bDrawIt (palette, Npalette, 3); 97 // bDrawImage (buffer, graphic); 85 98 } else { 86 buffer = bDrawBufferCreate8bitRGB(graphic->dx, graphic->dy); 87 bDrawImage (buffer, graphic); 99 buffer = bDrawIt (palette, Npalette, 1); 88 100 } 89 101 … … 93 105 94 106 bDrawBufferFree (buffer); 95 free (palette);96 107 fclose (f); 97 108 return (TRUE); 98 109 99 110 } 100 101 /* For color images, I need to define the relationship between the drawing colors and the RGB values? */102 103 104 bDrawBuffer *bDrawBufferCreate8bitRGB (int Nx, int Ny) {105 106 int i, j;107 bDrawBuffer *buffer;108 109 ALLOCATE (buffer, bDrawBuffer, 1);110 buffer[0].Nx = Nx;111 buffer[0].Ny = Ny;112 113 ALLOCATE (buffer[0].pixels, bDrawColor *, Ny);114 for (i = 0; i < Ny; i++) {115 ALLOCATE (buffer[0].pixels[i], bDrawColor, 3*Nx);116 for (j = 0; j < 3*Nx; j+=3) {117 buffer[0].pixels[i][j+0] = 0xff;118 buffer[0].pixels[i][j+1] = 0xff;119 buffer[0].pixels[i][j+2] = 0xff;120 }121 }122 return (buffer);123 }124 125 # define WHITE_R 255126 # define WHITE_G 255127 # define WHITE_B 255128 # define MY_SWAP_INT(A,B) { int tmp; tmp = A; A = B; B = tmp; }129 130 int bDrawImage (bDrawBuffer *buffer, Graphic *graphic) {131 132 Section *section;133 KapaImageWidget *image;134 135 int ii, i, j;136 int i_start, i_end, j_start, j_end;137 int I_start, J_start;138 int dropback; /* this is a bit of a kludge... */139 int dx, dy, DX, DY, inDX, inDY;140 int expand_in, expand_out;141 double expand, Ix, Iy;142 unsigned char *out_pix;143 unsigned short *in_pix, *in_pix_ref;144 unsigned char *pixel1, *pixel2, *pixel3;145 146 bDrawColor *line_buffer;147 148 section = GetActiveSection();149 image = section->image;150 if (image == NULL) return (TRUE);151 152 ALLOCATE (pixel1, unsigned char, graphic[0].Npixels);153 ALLOCATE (pixel2, unsigned char, graphic[0].Npixels);154 ALLOCATE (pixel3, unsigned char, graphic[0].Npixels);155 156 /** cmap[i].pixel must be defined even if X is not used **/157 for (i = 0; i < graphic[0].Npixels; i++) { /* set up pixel array */158 pixel1[i] = graphic[0].cmap[i].red >> 8;159 pixel2[i] = graphic[0].cmap[i].green >> 8;160 pixel3[i] = graphic[0].cmap[i].blue >> 8;161 }162 163 assert ((image[0].picture.expand >= 1) || (image[0].picture.expand <= -2));164 expand = expand_in = expand_out = 1.0;165 if (image[0].picture.expand > 0) {166 expand = 1 / (1.0*image[0].picture.expand);167 expand_out = image[0].picture.expand;168 expand_in = 1;169 }170 if (image[0].picture.expand < 0) {171 expand = fabs((double)image[0].picture.expand);172 expand_out = 1;173 expand_in = -image[0].picture.expand;174 }175 176 dx = image[0].picture.dx;177 dy = image[0].picture.dy;178 DX = image[0].image[0].matrix.Naxis[0];179 DY = image[0].image[0].matrix.Naxis[1];180 181 // i_start, j_start are the closest lit screen pixel to 0,0182 // I_start, J_start are the image pixel corresponding to i_start, j_start183 Picture_Lower (&i_start, &j_start, &I_start, &J_start, &image[0].image[0].matrix, &image[0].picture);184 185 // i_end, j_end are the closest lit screen pixel to dx, dy186 // I_end, J_end are the image pixel corresponding to i_end, j_end187 Picture_Upper (&i_end, &j_end, i_start, j_start, &image[0].image[0].matrix, &image[0].picture);188 189 assert (i_start <= i_end);190 assert (j_start <= j_end);191 192 Ix = image[0].picture.flipx ? I_start - 1 : I_start;193 Iy = image[0].picture.flipy ? J_start - 1 : J_start;194 195 inDX = image[0].picture.flipx ? -1 : +1;196 inDY = image[0].picture.flipy ? -1 : +1;197 198 dropback = expand_out - (i_end - i_start) % expand_out;199 if ((i_end - i_start) % expand_out == 0) dropback = 0;200 201 ALLOCATE (line_buffer, bDrawColor, 3*dx);202 203 in_pix_ref = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)];204 205 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/206 207 /**** fill in bottom area ****/208 out_pix = line_buffer;209 for (i = 0; i < dx; i++, out_pix+=3) {210 out_pix[0] = WHITE_R;211 out_pix[1] = WHITE_G;212 out_pix[2] = WHITE_B;213 }214 for (j = 0; j < j_start; j++) {215 memcpy (buffer[0].pixels[j], line_buffer, 3*dx);216 }217 218 /*** fill in the image data region ***/219 for (j = j_start; j < j_end; j+= expand_out, in_pix_ref += inDY*expand_in*DX) {220 221 /* create one output image line */222 in_pix = in_pix_ref;223 out_pix = line_buffer;224 225 /**** fill in area to the left of the picture ****/226 for (i = 0; i < i_start; i++, out_pix+=3) {227 out_pix[0] = WHITE_R;228 out_pix[1] = WHITE_G;229 out_pix[2] = WHITE_B;230 }231 232 /*** fill in the picture region ***/233 for (i = i_start; i < i_end; i+=expand_out, in_pix += inDX*expand_in) {234 for (ii = 0; ii < expand_out; ii++, out_pix+=3) {235 out_pix[0] = pixel1[*in_pix];236 out_pix[1] = pixel2[*in_pix];237 out_pix[2] = pixel3[*in_pix];238 }239 }240 241 /**** fill in area to the right of the picture ****/242 for (i = i_end; i < dx; i++, out_pix+=3) {243 out_pix[0] = WHITE_R;244 out_pix[1] = WHITE_G;245 out_pix[2] = WHITE_B;246 }247 248 /* write out the image line expand_out times */249 for (i = 0; i < expand_out; i++) {250 memcpy (buffer[0].pixels[j + i], line_buffer, 3*dx);251 }252 }253 254 /**** fill in top area ****/255 out_pix = line_buffer;256 for (i = 0; i < dx; i++, out_pix+=3) {257 out_pix[0] = WHITE_R;258 out_pix[1] = WHITE_G;259 out_pix[2] = WHITE_B;260 }261 for (j = j_end; j < dy; j++) {262 memcpy (buffer[0].pixels[j], line_buffer, 3*dx);263 }264 265 free (pixel1);266 free (pixel2);267 free (pixel3);268 free (line_buffer);269 270 return (TRUE);271 }272 273 # if (0)274 275 /* I need to write the overlay objects on the jpeg image.276 if i can write / overwrite data in jpeg buffer, then do it here,277 otherwise i need to create a temporary image buffer, then write the278 scanlines to that buffer */279 280 {281 int Npalette;282 png_color *palette;283 bDrawColor white, color;284 bDrawBuffer *buffer;285 286 palette = KapaPNGPalette (&Npalette);287 288 buffer = bDrawBufferCreate (dx, dy);289 bDrawSetBuffer (buffer);290 for (i = 0; i < NOVERLAYS; i++) {291 if (image[i].overlay[i].active) bDrawOverlay (image, i);292 }293 294 white = KapaColorByName ("white");295 for (j = 0; j < dy; j++) {296 for (i = 0; i < dx; i++) {297 color = buffer[0].pixels[j][i];298 if (color == white) continue;299 image_buffer[j*3*dx + 3*i + 0] = palette[color].red;300 image_buffer[j*3*dx + 3*i + 1] = palette[color].green;301 image_buffer[j*3*dx + 3*i + 2] = palette[color].blue;302 }303 }304 bDrawBufferFree (buffer);305 }306 307 # endif -
trunk/Ohana/src/kapa2/src/PPMit.c
r27435 r29938 30 30 fprintf (f, "255\n"); 31 31 32 buffer = bDrawIt ( );32 buffer = bDrawIt (palette, Npalette, 1); 33 33 34 34 ALLOCATE (line, char, 3*dx); … … 47 47 bDrawBufferFree (buffer); 48 48 return (TRUE); 49 50 49 } -
trunk/Ohana/src/kapa2/src/PSFrame.c
r29539 r29938 4 4 int PSFrame (KapaGraphWidget *graph, FILE *f) { 5 5 6 int i, j, Nticks, P ;7 double fx, fy, dfx, dfy, lweight;6 int i, j, Nticks, P, doffset; 7 double fx, fy, dfx, dfy, dx, dy, lweight; 8 8 Graphic *graphic; 9 9 TickMarkData *ticks; … … 15 15 fprintf (f, "1 setlinewidth\n"); 16 16 for (i = 0; i < 4; i++) { 17 fx = graph[0].axis[i].fx;18 fy = graphic->dy - graph[0].axis[i].fy;19 dfx = graph[0].axis[i].dfx;20 dfy = -graph[0].axis[i].dfy;21 P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy);22 23 17 lweight = MAX (0, MIN (10, graph[0].axis[i].lweight)); 24 18 color = MAX (0, MIN (15, graph[0].axis[i].color)); 19 20 /* temporarily assume rectilinear axes */ 21 doffset = ((int)(lweight) % 2) ? 0.5*(lweight - 1) : 0.5*lweight; 22 if (i == 0) { dx = doffset; dy = 0.0; } 23 if (i == 2) { dx = doffset; dy = 0.0; } 24 if (i == 1) { dx = 0.0; dy = doffset; } 25 if (i == 3) { dx = 0.0; dy = doffset; } 26 27 fx = graph[0].axis[i].fx - dx; 28 fy = graphic->dy - graph[0].axis[i].fy - dy; 29 dfx = graph[0].axis[i].dfx + 2*dx; 30 dfy = -graph[0].axis[i].dfy + 2*dy; 31 32 P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy); 33 P *= (1 + 0.25*lweight); 25 34 26 35 fprintf (f, "%.1f setlinewidth\n", lweight); … … 95 104 yt = fy + (value-min)*dfy/(max - min) + dy; 96 105 97 PrintTick (string, value, min, max );106 PrintTick (string, value, min, max, tick->nsignif); 98 107 PSRotText (f, xt, yt, string, pos, 0.0); 99 108 } -
trunk/Ohana/src/kapa2/src/PSimage.c
r14913 r29938 13 13 graphic = GetGraphic(); 14 14 15 fprintf (f, " newpath 0 0 moveto %d 0 lineto %d %d lineto 0 %d lineto closepath clip\n\n", 16 image[0].picture.dx, image[0].picture.dx, image[0].picture.dy, image[0].picture.dy); 15 fprintf (f, " newpath %d %d moveto %d %d lineto %d %d lineto %d %d lineto closepath\n\n", 16 (int) image[0].picture.x, graphic->dy - (int) image[0].picture.y, 17 (int) image[0].picture.x + image[0].picture.dx, graphic->dy - (int) image[0].picture.y, 18 (int) image[0].picture.x + image[0].picture.dx, graphic->dy - (int) image[0].picture.y - image[0].picture.dy, 19 (int) image[0].picture.x, graphic->dy - (int) image[0].picture.y - image[0].picture.dy); 17 20 fprintf (f, "gsave %% encloses image\n"); 21 fprintf (f, "%d %d translate\n", (int) image[0].picture.x, graphic->dy - (int) image[0].picture.y - image[0].picture.dy); 18 22 fprintf (f, "%d %d 8\n", image[0].picture.dx, image[0].picture.dy); 19 23 fprintf (f, "[1 0 0 1 0 0]\n"); -
trunk/Ohana/src/kapa2/src/PSit.c
r13479 r29938 87 87 for (i = 0; i < Nsection; i++) { 88 88 section = GetSectionByNumber (i); 89 if (section->image) { 90 PSimage (section->image, f); 91 } 89 92 if (section->graph) { 90 93 PSFrame (section->graph, f); … … 92 95 PSLabels (section->graph, f); 93 96 PSTextlines (section->graph, f); 94 }95 if (section->image) {96 PSimage (section->image, f);97 97 } 98 98 } -
trunk/Ohana/src/kapa2/src/Resize.c
r26891 r29938 39 39 return (TRUE); 40 40 } 41 42 // resise the window so the image in the currently active window fills its section 43 int ResizeByImage (int sock) { 44 45 int i, Nsection; 46 unsigned int NX, NY; 47 double dx, dy; 48 int dXm, dXp, dYm, dYp; 49 double x0, y0, x1, y1, expand; 50 Section *section; 51 Graphic *graphic; 52 KapaImageWidget *image; 53 54 graphic = GetGraphic(); 55 56 section = GetActiveSection(); 57 58 image = section->image; 59 if (!image) { 60 fprintf (stderr, "no image to define size\n"); 61 return (TRUE); 62 } 63 64 GetGraphBoundary (section, &x0, &y0, &x1, &y1, &dXm, &dXp, &dYm, &dYp); 65 66 expand = 1.0; 67 if (image[0].picture.expand > 0) { 68 expand = image[0].picture.expand; 69 } 70 if (image[0].picture.expand < 0) { 71 expand = 1.0 / fabs((double)image[0].picture.expand); 72 } 73 74 // pixel dimensions of the imaging region + boundary 75 dx = image[0].image[0].matrix.Naxis[0]*expand + x1; 76 dy = image[0].image[0].matrix.Naxis[1]*expand + y1; 77 78 NX = dx / section[0].dx; 79 NY = dy / section[0].dy; 80 81 NX = MAX(NX, MIN_WIDTH); 82 NY = MAX(NY, MIN_HEIGHT); 83 84 // if the new size is the same as the old size, do nothing. 85 if ((graphic->dx == NX) && (graphic->dy == NY)) return (TRUE); 86 87 // set the new window size 88 graphic->dx = NX; 89 graphic->dy = NY; 90 91 if (USE_XWINDOW) XResizeWindow (graphic->display, graphic->window, NX, NY); 92 93 // reset the sizes for all sections 94 Nsection = GetNumberOfSections (); 95 for (i = 0; i < Nsection; i++) { 96 section = GetSectionByNumber (i); 97 SetSectionSizes (section); 98 } 99 100 if (USE_XWINDOW) XClearWindow (graphic->display, graphic->window); 101 Refresh (); 102 103 return (TRUE); 104 } -
trunk/Ohana/src/kapa2/src/SetGraphSize.c
r29539 r29938 5 5 6 6 void SetGraphSize (Section *section) { 7 8 int dXm, dXp, dYm, dYp; 9 double x0, y0, x1, y1; 10 KapaGraphWidget *graph; 11 Graphic *graphic; 12 13 GetGraphBoundary(section, &x0, &y0, &x1, &y1, &dXm, &dXp, &dYm, &dYp); 14 15 if (section == NULL) return; 16 graph = section->graph; 17 if (graph == NULL) return; 18 19 graphic = GetGraphic (); 20 21 double X0 = graphic[0].dx * section[0].x + x0; 22 double Y0 = graphic[0].dy * section[0].y + y0; 23 double dX = graphic[0].dx * section[0].dx - x1; 24 double dY = graphic[0].dy * section[0].dy - y1; 25 26 /* define locations of coordinate axes */ 27 graph[0].axis[0].fx = X0; 28 graph[0].axis[0].fy = graphic->dy - Y0; 29 graph[0].axis[0].dfx = dX; 30 graph[0].axis[0].dfy = 0; 31 32 graph[0].axis[1].fx = X0; 33 graph[0].axis[1].fy = graphic->dy - Y0; 34 graph[0].axis[1].dfx = 0; 35 graph[0].axis[1].dfy = -dY; 36 37 graph[0].axis[2].fx = X0; 38 graph[0].axis[2].fy = graphic->dy - Y0 - dY; 39 graph[0].axis[2].dfx = dX; 40 graph[0].axis[2].dfy = 0; 41 42 graph[0].axis[3].fx = X0 + dX; 43 graph[0].axis[3].fy = graphic->dy - Y0; 44 graph[0].axis[3].dfx = 0; 45 graph[0].axis[3].dfy = -dY; 46 47 /* define locations of axis labels */ 48 graph[0].label[LABELLL].x = graph[0].axis[0].fx; 49 graph[0].label[LABELLL].y = graph[0].axis[0].fy + dXm; 50 graph[0].label[LABELX0].x = graph[0].axis[0].fx + 0.5*graph[0].axis[0].dfx; 51 graph[0].label[LABELX0].y = graph[0].axis[0].fy + dXm; 52 graph[0].label[LABELLR].x = graph[0].axis[0].fx + graph[0].axis[0].dfx; 53 graph[0].label[LABELLR].y = graph[0].axis[0].fy + dXm; 54 55 graph[0].label[LABELUL].x = graph[0].axis[2].fx; 56 graph[0].label[LABELUL].y = graph[0].axis[2].fy - dXp; 57 graph[0].label[LABELX1].x = graph[0].axis[2].fx + 0.5*graph[0].axis[2].dfx; 58 graph[0].label[LABELX1].y = graph[0].axis[2].fy - dXp; 59 graph[0].label[LABELUR].x = graph[0].axis[2].fx + graph[0].axis[2].dfx; 60 graph[0].label[LABELUR].y = graph[0].axis[2].fy - dXp; 61 62 graph[0].label[LABELY0].y = graph[0].axis[1].fy + 0.5*graph[0].axis[1].dfy; 63 graph[0].label[LABELY0].x = graph[0].axis[1].fx - dYm; 64 65 graph[0].label[LABELY1].y = graph[0].axis[3].fy + 0.5*graph[0].axis[3].dfy; 66 graph[0].label[LABELY1].x = graph[0].axis[3].fx + dYp; 67 68 return; 69 } 70 71 int GetGraphBoundary (Section *section, double *x0, double *y0, double *x1, double *y1, int *dXm, int *dXp, int *dYm, int *dYp) { 7 72 8 73 int i, Nticks; 9 74 int fontsize, Nc = 0; 10 75 int textpad, textdY, WdY; 11 int dXm, dXp, dYm, dYp;12 76 double padXm, padXp, padYm, padYp; 13 77 double minPADx, maxPADx, minPADy; 14 78 double minPAD, maxPAD; 15 double X0, Y0, dX, dY;16 79 char string[64], *fontname; 17 80 KapaGraphWidget *graph; … … 19 82 TickMarkData *ticks; 20 83 21 if (section == NULL) return; 84 *x0 = 0.0; 85 *y0 = 0.0; 86 *x1 = 0.0; 87 *y1 = 0.0; 88 89 *dXm = 0; 90 *dXp = 0; 91 *dYm = 0; 92 *dYp = 0; 93 94 if (section == NULL) return FALSE; 22 95 graph = section->graph; 23 if (graph == NULL) return ;96 if (graph == NULL) return FALSE; 24 97 25 98 graphic = GetGraphic (); … … 40 113 // these depend on (a) existence of tick labels and (b) auto-offset or not 41 114 if (isnan(graph[0].axis[0].labelPad)) { 42 dXm = (graph[0].axis[0].islabel) ? maxPAD : minPAD;43 } else { 44 dXm = graph[0].axis[0].labelPad * fontsize;115 *dXm = (graph[0].axis[0].islabel) ? maxPAD : minPAD; 116 } else { 117 *dXm = graph[0].axis[0].labelPad * fontsize; 45 118 } 46 119 if (isnan(graph[0].axis[0].pad)) { … … 53 126 // these depend on (a) existence of tick labels and (b) auto-offset or not 54 127 if (isnan(graph[0].axis[2].labelPad)) { 55 dXp = (graph[0].axis[2].islabel) ? maxPAD : minPAD;56 } else { 57 dXp = graph[0].axis[2].labelPad * fontsize;128 *dXp = (graph[0].axis[2].islabel) ? maxPAD : minPAD; 129 } else { 130 *dXp = graph[0].axis[2].labelPad * fontsize; 58 131 } 59 132 if (isnan(graph[0].axis[2].pad)) { … … 73 146 if (!ticks[i].IsMajor) continue; 74 147 75 int Nchar = PrintTick (string, ticks[i].value, graph[0].axis[1].min, graph[0].axis[1].max );148 int Nchar = PrintTick (string, ticks[i].value, graph[0].axis[1].min, graph[0].axis[1].max, ticks[i].nsignif); 76 149 77 150 Nc = MAX (Nc, Nchar); … … 80 153 } 81 154 if (isnan(graph[0].axis[1].labelPad)) { 82 dYm = (graph[0].axis[1].islabel) ? (0.7*(Nc + 1.5)*fontsize) : minPAD;83 } else { 84 dYm = graph[0].axis[1].labelPad * fontsize;155 *dYm = (graph[0].axis[1].islabel) ? (0.7*(Nc + 1.5)*fontsize) : minPAD; 156 } else { 157 *dYm = graph[0].axis[1].labelPad * fontsize; 85 158 } 86 159 if (isnan(graph[0].axis[1].pad)) { … … 98 171 for (i = 0; i < Nticks; i++) { 99 172 if (!ticks[i].IsMajor) continue; 100 int Nchar = PrintTick (string, ticks[i].value, graph[0].axis[3].min, graph[0].axis[3].max );173 int Nchar = PrintTick (string, ticks[i].value, graph[0].axis[3].min, graph[0].axis[3].max, ticks[i].nsignif); 101 174 Nc = MAX (Nc, Nchar); 102 175 } … … 104 177 } 105 178 if (isnan(graph[0].axis[3].labelPad)) { 106 dYp = (graph[0].axis[3].islabel) ? (0.7*(Nc + 1.5)*fontsize) : minPAD;107 } else { 108 dYp = graph[0].axis[3].labelPad * fontsize;179 *dYp = (graph[0].axis[3].islabel) ? (0.7*(Nc + 1.5)*fontsize) : minPAD; 180 } else { 181 *dYp = graph[0].axis[3].labelPad * fontsize; 109 182 } 110 183 if (isnan(graph[0].axis[3].pad)) { … … 115 188 116 189 /* basic size of the graph in Xwindow coordinates, but measured from lower-left corner */ 117 X0 = graphic[0].dx * section[0].x +padYm;118 Y0 = graphic[0].dy * section[0].y +padXm;119 dX = graphic[0].dx * section[0].dx - padYm -padYp;120 dY = graphic[0].dy * section[0].dy - padXm -padXp;190 *x0 = padYm; 191 *y0 = padXm; 192 *x1 = padYm + padYp; 193 *y1 = padXm + padXp; 121 194 122 195 // if we are tied to an image, make mods as needed … … 128 201 switch (section->image->location) { 129 202 case 0: 130 // no changes?131 203 break; 132 204 case 1: 133 Y0 = graphic[0].dy * section[0].y + padXm+ 2*PAD1 + WdY + 2;134 dY = graphic[0].dy * section[0].dy - padXm - padXp - 4*PAD1 - 1 - WdY -COLORPAD;205 *y0 = padXm + 2*PAD1 + WdY + 2; 206 *y1 = padXm + padXp + 4*PAD1 + 1 + WdY + COLORPAD; 135 207 break; 136 208 case 3: 137 dY = graphic[0].dy * section[0].dy - padXm - padXp - 4*PAD1 - 1 - WdY -COLORPAD;209 *y1 = padXm + padXp + 4*PAD1 + 1 + WdY + COLORPAD; 138 210 break; 139 211 case 2: 140 X0 = graphic[0].dx * section[0].x + padYm+ 2*PAD1 + ZOOM_X;141 dX = graphic[0].dx * section[0].dx - padYm - padYp - 3*PAD1 -ZOOM_X;142 dY = graphic[0].dy * section[0].dy - padXm - padXp - 2*PAD1 -COLORPAD;212 *x0 = padYm + 2*PAD1 + ZOOM_X; 213 *x1 = padYm + padYp + 3*PAD1 + ZOOM_X; 214 *y1 = padXm + padXp + 2*PAD1 + COLORPAD; 143 215 break; 144 216 case 4: 145 dX = graphic[0].dx * section[0].dx - padYm - padYp - 3*PAD1 -ZOOM_X;146 dY = graphic[0].dy * section[0].dy - padXm - padXp - 2*PAD1 -COLORPAD;217 *x1 = padYm + padYp + 3*PAD1 + ZOOM_X; 218 *y1 = padXm + padXp + 2*PAD1 + COLORPAD; 147 219 break; 148 220 } 149 221 } 150 222 151 /* define locations of coordinate axes */ 152 graph[0].axis[0].fx = X0; 153 graph[0].axis[0].fy = graphic->dy - Y0; 154 graph[0].axis[0].dfx = dX; 155 graph[0].axis[0].dfy = 0; 156 157 graph[0].axis[1].fx = X0; 158 graph[0].axis[1].fy = graphic->dy - Y0; 159 graph[0].axis[1].dfx = 0; 160 graph[0].axis[1].dfy = -dY; 161 162 graph[0].axis[2].fx = X0; 163 graph[0].axis[2].fy = graphic->dy - Y0 - dY; 164 graph[0].axis[2].dfx = dX; 165 graph[0].axis[2].dfy = 0; 166 167 graph[0].axis[3].fx = X0 + dX; 168 graph[0].axis[3].fy = graphic->dy - Y0; 169 graph[0].axis[3].dfx = 0; 170 graph[0].axis[3].dfy = -dY; 171 172 /* define locations of axis labels */ 173 graph[0].label[LABELLL].x = graph[0].axis[0].fx; 174 graph[0].label[LABELLL].y = graph[0].axis[0].fy + dXm; 175 graph[0].label[LABELX0].x = graph[0].axis[0].fx + 0.5*graph[0].axis[0].dfx; 176 graph[0].label[LABELX0].y = graph[0].axis[0].fy + dXm; 177 graph[0].label[LABELLR].x = graph[0].axis[0].fx + graph[0].axis[0].dfx; 178 graph[0].label[LABELLR].y = graph[0].axis[0].fy + dXm; 179 180 graph[0].label[LABELUL].x = graph[0].axis[2].fx; 181 graph[0].label[LABELUL].y = graph[0].axis[2].fy - dXp; 182 graph[0].label[LABELX1].x = graph[0].axis[2].fx + 0.5*graph[0].axis[2].dfx; 183 graph[0].label[LABELX1].y = graph[0].axis[2].fy - dXp; 184 graph[0].label[LABELUR].x = graph[0].axis[2].fx + graph[0].axis[2].dfx; 185 graph[0].label[LABELUR].y = graph[0].axis[2].fy - dXp; 186 187 graph[0].label[LABELY0].y = graph[0].axis[1].fy + 0.5*graph[0].axis[1].dfy; 188 graph[0].label[LABELY0].x = graph[0].axis[1].fx - dYm; 189 190 graph[0].label[LABELY1].y = graph[0].axis[3].fy + 0.5*graph[0].axis[3].dfy; 191 graph[0].label[LABELY1].x = graph[0].axis[3].fx + dYp; 192 193 // fprintf (stderr, "section %s, %f,%f : %f,%f\n", section->name, X0, Y0, dX, dY); 194 195 /* these are wrong and have to be adjusted to sit in the corners */ 196 223 return (TRUE); 197 224 } -
trunk/Ohana/src/kapa2/src/bDrawFrame.c
r29539 r29938 2 2 // bDrawLine is a function, not a macro like DrawLine 3 3 4 int bDrawFrame ( KapaGraphWidget *graph) {4 int bDrawFrame (bDrawBuffer *buffer, KapaGraphWidget *graph) { 5 5 6 int i, j, Nticks, P ;7 double fx, fy, dfx, dfy, lweight ;6 int i, j, Nticks, P, doffset; 7 double fx, fy, dfx, dfy, lweight, dx, dy; 8 8 // Graphic graphic; is not needed 9 9 TickMarkData *ticks; … … 14 14 /* each axis is drawn independently */ 15 15 for (i = 0; i < 4; i++) { 16 fx = graph[0].axis[i].fx;17 fy = graph[0].axis[i].fy;18 dfx = graph[0].axis[i].dfx;19 dfy = graph[0].axis[i].dfy;20 P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy);21 22 16 lweight = MAX (0, MIN (10, graph[0].axis[i].lweight)); 23 17 color = MAX (0, MIN (15, graph[0].axis[i].color)); 24 18 25 bDrawSetStyle (color, lweight, 0); 26 // function about sets solor and weight 19 /* temporarily assume rectilinear axes */ 20 doffset = ((int)(lweight) % 2) ? 0.5*(lweight - 1) : 0.5*lweight; 21 if (i == 0) { dx = doffset; dy = 0.0; } 22 if (i == 2) { dx = doffset; dy = 0.0; } 23 if (i == 1) { dx = 0.0; dy = doffset; } 24 if (i == 3) { dx = 0.0; dy = doffset; } 25 26 fx = graph[0].axis[i].fx - dx; 27 fy = graph[0].axis[i].fy - dy; 28 dfx = graph[0].axis[i].dfx + 2*dx; 29 dfy = graph[0].axis[i].dfy + 2*dy; 30 P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy); 31 P *= (1 + 0.25*lweight); 32 33 bDrawSetStyle (buffer, color, lweight, 0); 34 // function about sets color and weight 27 35 // bDrawRotTextInit does not exist 28 36 29 37 if (graph[0].axis[i].isaxis) { 30 bDrawLine ( fx, fy, fx+dfx, fy+dfy);38 bDrawLine (buffer, fx, fy, fx+dfx, fy+dfy); 31 39 } 32 40 … … 34 42 ticks = CreateAxisTicks (&graph[0].axis[i], &Nticks); 35 43 for (j = 0; j < Nticks; j++) { 36 bDrawTick (&graph[0].axis[i], P, &ticks[j], i); 44 bDrawTick (buffer, &graph[0].axis[i], P, &ticks[j], i); 45 46 // XXX DrawTick sets the style to (color, 0, 0) for the font 47 // should the font weight stay the same? 48 // XXX probably not needed now: 49 // bDrawSetStyle (buffer, color, lweight, 0); 37 50 } 38 51 FREE (ticks); … … 42 55 } 43 56 44 void bDrawTick ( Axis *axis, int P, TickMarkData *tick, int naxis) {57 void bDrawTick (bDrawBuffer *buffer, Axis *axis, int P, TickMarkData *tick, int naxis) { 45 58 46 59 double x, y, dx, dy; … … 75 88 dy = dir*size*dfx*n; 76 89 77 bDrawLine ( x, y, x+dx, y+dy);90 bDrawLine (buffer, x, y, x+dx, y+dy); 78 91 79 92 if (tick->IsLabel) { … … 94 107 yt = fy + (value-min)*dfy/(max - min) + dy; 95 108 96 PrintTick (string, value, min, max );97 bDrawRotText ( xt, yt, string, pos, 0.0);109 PrintTick (string, value, min, max, tick->nsignif); 110 bDrawRotText (buffer, xt, yt, string, pos, 0.0); 98 111 } 99 112 } -
trunk/Ohana/src/kapa2/src/bDrawIt.c
r13479 r29938 1 1 # include "Ximage.h" 2 2 3 bDrawBuffer *bDrawIt ( ) {3 bDrawBuffer *bDrawIt (png_color *palette, int Npalette, int Nbyte) { 4 4 5 5 int i, Nsection; … … 13 13 black = KapaColorByName ("black"); 14 14 15 buffer = bDrawBufferCreate (graphic->dx, graphic->dy); 16 bDrawSetBuffer (buffer); 17 bDrawSetStyle (black, 0, 0); 15 buffer = bDrawBufferCreate (graphic->dx, graphic->dy, Nbyte, palette, Npalette); 16 bDrawSetStyle (buffer, black, 0, 0); 18 17 19 18 // reset the sizes for all sections … … 21 20 for (i = 0; i < Nsection; i++) { 22 21 section = GetSectionByNumber (i); 23 bDraw Graph (section->graph);24 // bDrawImage (section->image);22 bDrawImage (buffer, section->image, graphic); 23 bDrawGraph (buffer, section->graph); 25 24 } 26 25 … … 28 27 } 29 28 30 void bDrawGraph ( KapaGraphWidget *graph) {29 void bDrawGraph (bDrawBuffer *buffer, KapaGraphWidget *graph) { 31 30 if (graph == NULL) return; 32 bDrawFrame ( graph);33 bDrawObjects ( graph);34 bDrawLabels ( graph);35 bDrawTextlines ( graph);31 bDrawFrame (buffer, graph); 32 bDrawObjects (buffer, graph); 33 bDrawLabels (buffer, graph); 34 bDrawTextlines (buffer, graph); 36 35 } -
trunk/Ohana/src/kapa2/src/bDrawLabels.c
r13320 r29938 1 1 # include "Ximage.h" 2 2 3 void bDrawLabels ( KapaGraphWidget *graph) {3 void bDrawLabels (bDrawBuffer *buffer, KapaGraphWidget *graph) { 4 4 5 5 int i, pos, x, y, size; … … 25 25 y = graph[0].label[i].y; 26 26 SetRotFont (graph[0].label[i].font, graph[0].label[i].size); 27 bDrawRotText ( x, y, graph[0].label[i].text, pos, angle);27 bDrawRotText (buffer, x, y, graph[0].label[i].text, pos, angle); 28 28 } 29 29 } … … 31 31 } 32 32 33 void bDrawTextlines ( KapaGraphWidget *graph) {33 void bDrawTextlines (bDrawBuffer *buffer, KapaGraphWidget *graph) { 34 34 35 35 int i, x, y, size; … … 44 44 y = graph[0].textline[i].y; 45 45 SetRotFont (graph[0].textline[i].font, graph[0].textline[i].size); 46 bDrawRotText ( x, y, graph[0].textline[i].text, 5, angle);46 bDrawRotText (buffer, x, y, graph[0].textline[i].text, 5, angle); 47 47 } 48 48 } -
trunk/Ohana/src/kapa2/src/bDrawObjects.c
r27530 r29938 1 1 # include "Ximage.h" 2 2 3 # define DrawLine( X1,Y1,X2,Y2) (bDrawLine ((X1), (Y1), (X2), (Y2)))4 # define DrawCircle( X1,Y1,R) (bDrawCircle ((X1), (Y1), (R)))5 # define DrawRectangle( X,Y,dX,dY) (bDrawRectOpen ((X-0.5*dX), (Y-0.5*dY), (X+0.5*dX), (Y+0.5*dY)))6 # define FillRectangle( X,Y,dX,dY) (bDrawRectFill ((X-0.5*dX), (Y-0.5*dY), (X+0.5*dX), (Y+0.5*dY)))7 # define FillTriangle( X1,Y1,X2,Y2,X3,Y3) (bDrawTriFill ((X1), (Y1), (X2), (Y2), (X3), (Y3)))8 # define OpenTriangle( X1,Y1,X2,Y2,X3,Y3) (bDrawTriOpen ((X1), (Y1), (X2), (Y2), (X3), (Y3)))3 # define DrawLine(BUF,X1,Y1,X2,Y2) (bDrawLine (BUF, (X1), (Y1), (X2), (Y2))) 4 # define DrawCircle(BUF,X1,Y1,R) (bDrawCircle (BUF, (X1), (Y1), (R))) 5 # define DrawRectangle(BUF,X,Y,dX,dY) (bDrawRectOpen (BUF, (X-0.5*dX), (Y-0.5*dY), (X+0.5*dX), (Y+0.5*dY))) 6 # define FillRectangle(BUF,X,Y,dX,dY) (bDrawRectFill (BUF, (X-0.5*dX), (Y-0.5*dY), (X+0.5*dX), (Y+0.5*dY))) 7 # define FillTriangle(BUF,X1,Y1,X2,Y2,X3,Y3) (bDrawTriFill (BUF, (X1), (Y1), (X2), (Y2), (X3), (Y3))) 8 # define OpenTriangle(BUF,X1,Y1,X2,Y2,X3,Y3) (bDrawTriOpen (BUF, (X1), (Y1), (X2), (Y2), (X3), (Y3))) 9 9 10 10 # define CONNECT 0 … … 14 14 static Graphic *graphic; 15 15 16 int bDrawObjects ( KapaGraphWidget *graph) {16 int bDrawObjects (bDrawBuffer *buffer, KapaGraphWidget *graph) { 17 17 18 18 int i; … … 30 30 type = graph[0].objects[i].ltype; 31 31 color = graph[0].objects[i].color; 32 bDrawSetStyle ( color, weight, type);32 bDrawSetStyle (buffer, color, weight, type); 33 33 34 34 switch (graph[0].objects[i].style) { 35 35 case CONNECT: 36 bDrawConnect ( graph, &graph[0].objects[i]);36 bDrawConnect (buffer, graph, &graph[0].objects[i]); 37 37 break; 38 38 case HISTOGRAM: 39 bDrawHistogram ( graph, &graph[0].objects[i]);39 bDrawHistogram (buffer, graph, &graph[0].objects[i]); 40 40 break; 41 41 case POINTS: 42 bDrawPoints ( graph, &graph[0].objects[i]);42 bDrawPoints (buffer, graph, &graph[0].objects[i]); 43 43 break; 44 44 } 45 45 46 46 if (graph[0].objects[i].etype & 0x01) { 47 bDrawYErrors ( graph, &graph[0].objects[i]);47 bDrawYErrors (buffer, graph, &graph[0].objects[i]); 48 48 } 49 49 if (graph[0].objects[i].etype & 0x02) { 50 bDrawXErrors ( graph, &graph[0].objects[i]);51 } 52 } 53 bDrawSetStyle (b lack, 0, 0);50 bDrawXErrors (buffer, graph, &graph[0].objects[i]); 51 } 52 } 53 bDrawSetStyle (buffer, black, 0, 0); 54 54 return (TRUE); 55 55 } 56 56 57 void bDrawConnect ( KapaGraphWidget *graph, Gobjects *object) {57 void bDrawConnect (bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object) { 58 58 59 59 int i; … … 91 91 sx1 = x[i]*mxi + y[i]*mxj + bx; 92 92 sy1 = x[i]*myi + y[i]*myj + by; 93 bDrawClipLine ( sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);93 bDrawClipLine (buffer, sx0, sy0, sx1, sy1, X0, Y0, X1, Y1); 94 94 sx0 = sx1; sy0 = sy1; 95 95 } 96 96 } 97 97 98 void bDrawClipLine ( double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0) {98 void bDrawClipLine (bDrawBuffer *buffer, double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0) { 99 99 100 100 /* skip line segement if both points are beyond box */ … … 145 145 y1 = Y1; 146 146 } 147 DrawLine ( x0, y0, x1, y1);147 DrawLine (buffer, x0, y0, x1, y1); 148 148 } 149 149 150 150 /*******/ 151 void bDrawHistogram ( KapaGraphWidget *graph, Gobjects *object) {151 void bDrawHistogram (bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object) { 152 152 153 153 int i; … … 192 192 sy1 = MAX (MIN (sy1, Y0), Y1); 193 193 sxa = 0.5*(sx0 + sx1); 194 DrawLine ( sx0, sy0, sxa, sy0);195 DrawLine ( sxa, sy0, sxa, sy1);196 DrawLine ( sxa, sy1, sx1, sy1);194 DrawLine (buffer, sx0, sy0, sxa, sy0); 195 DrawLine (buffer, sxa, sy0, sxa, sy1); 196 DrawLine (buffer, sxa, sy1, sx1, sy1); 197 197 sx0 = sx1; sy0 = sy1; 198 198 } … … 200 200 201 201 /*******/ 202 void bDrawPoints ( KapaGraphWidget *graph, Gobjects *object) {202 void bDrawPoints (bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object) { 203 203 204 204 int i; … … 233 233 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 234 234 { 235 FillRectangle ( sx, sy, 2*d*z[i], 2*d*z[i]);235 FillRectangle (buffer, sx, sy, 2*d*z[i], 2*d*z[i]); 236 236 } 237 237 } … … 245 245 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 246 246 { 247 DrawRectangle ( sx, sy, 2*d*z[i], 2*d*z[i]);247 DrawRectangle (buffer, sx, sy, 2*d*z[i], 2*d*z[i]); 248 248 } 249 249 } … … 257 257 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 258 258 { 259 DrawLine ( sx - d*z[i], sy, sx + d*z[i], sy);260 DrawLine ( sx, sy - d*z[i], sx, sy + d*z[i]);259 DrawLine (buffer, sx - d*z[i], sy, sx + d*z[i], sy); 260 DrawLine (buffer, sx, sy - d*z[i], sx, sy + d*z[i]); 261 261 } 262 262 } … … 270 270 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 271 271 { 272 DrawLine ( sx + d*z[i], sy - d*z[i], sx - d*z[i], sy + d*z[i]);273 DrawLine ( sx - d*z[i], sy - d*z[i], sx + d*z[i], sy + d*z[i]);272 DrawLine (buffer, sx + d*z[i], sy - d*z[i], sx - d*z[i], sy + d*z[i]); 273 DrawLine (buffer, sx - d*z[i], sy - d*z[i], sx + d*z[i], sy + d*z[i]); 274 274 } 275 275 } … … 283 283 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 284 284 { 285 FillTriangle ( sx - d*z[i], sy - 0.58*d*z[i], sx + d*z[i], sy - 0.58*d*z[i], sx, sy + 1.15*d*z[i]);285 FillTriangle (buffer, sx - d*z[i], sy - 0.58*d*z[i], sx + d*z[i], sy - 0.58*d*z[i], sx, sy + 1.15*d*z[i]); 286 286 } 287 287 } … … 295 295 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 296 296 { 297 OpenTriangle ( sx - d*z[i], sy + 0.58*d*z[i], sx, sy - 1.15*d*z[i], sx + d*z[i], sy + 0.58*d*z[i]);297 OpenTriangle (buffer, sx - d*z[i], sy + 0.58*d*z[i], sx, sy - 1.15*d*z[i], sx + d*z[i], sy + 0.58*d*z[i]); 298 298 } 299 299 } … … 307 307 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 308 308 { 309 DrawLine ( sx, sy, sx - d*z[i], sy + 0.58*d*z[i]);310 DrawLine ( sx, sy, sx + d*z[i], sy + 0.58*d*z[i]);311 DrawLine ( sx, sy, sx, sy - 1.15*d*z[i]);309 DrawLine (buffer, sx, sy, sx - d*z[i], sy + 0.58*d*z[i]); 310 DrawLine (buffer, sx, sy, sx + d*z[i], sy + 0.58*d*z[i]); 311 DrawLine (buffer, sx, sy, sx, sy - 1.15*d*z[i]); 312 312 } 313 313 } … … 321 321 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 322 322 { 323 DrawCircle ( sx, sy, d*z[i]);323 DrawCircle (buffer, sx, sy, d*z[i]); 324 324 } 325 325 } … … 333 333 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 334 334 { 335 DrawLine ( sx + 0.00*d*z[i], sy - 1.00*d*z[i], sx + 0.95*d*z[i], sy - 0.31*d*z[i]);336 DrawLine ( sx + 0.95*d*z[i], sy - 0.31*d*z[i], sx + 0.58*d*z[i], sy + 0.81*d*z[i]);337 DrawLine ( sx + 0.58*d*z[i], sy + 0.81*d*z[i], sx - 0.58*d*z[i], sy + 0.81*d*z[i]);338 DrawLine ( sx - 0.58*d*z[i], sy + 0.81*d*z[i], sx - 0.95*d*z[i], sy - 0.31*d*z[i]);339 DrawLine ( sx - 0.95*d*z[i], sy - 0.31*d*z[i], sx + 0.00*d*z[i], sy - 1.00*d*z[i]);335 DrawLine (buffer, sx + 0.00*d*z[i], sy - 1.00*d*z[i], sx + 0.95*d*z[i], sy - 0.31*d*z[i]); 336 DrawLine (buffer, sx + 0.95*d*z[i], sy - 0.31*d*z[i], sx + 0.58*d*z[i], sy + 0.81*d*z[i]); 337 DrawLine (buffer, sx + 0.58*d*z[i], sy + 0.81*d*z[i], sx - 0.58*d*z[i], sy + 0.81*d*z[i]); 338 DrawLine (buffer, sx - 0.58*d*z[i], sy + 0.81*d*z[i], sx - 0.95*d*z[i], sy - 0.31*d*z[i]); 339 DrawLine (buffer, sx - 0.95*d*z[i], sy - 0.31*d*z[i], sx + 0.00*d*z[i], sy - 1.00*d*z[i]); 340 340 } 341 341 } … … 349 349 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 350 350 { 351 DrawLine ( sx - d*z[i], sy, sx - 0.50*d*z[i], sy + 0.87*d*z[i]);352 DrawLine ( sx - 0.50*d*z[i], sy + 0.87*d*z[i], sx + 0.50*d*z[i], sy + 0.87*d*z[i]);353 DrawLine ( sx + 0.50*d*z[i], sy + 0.87*d*z[i], sx + d*z[i], sy);354 355 DrawLine ( sx + d*z[i], sy, sx + 0.50*d*z[i], sy - 0.87*d*z[i]);356 DrawLine ( sx + 0.50*d*z[i], sy - 0.87*d*z[i], sx - 0.50*d*z[i], sy - 0.87*d*z[i]);357 DrawLine ( sx - 0.50*d*z[i], sy - 0.87*d*z[i], sx - d*z[i], sy);351 DrawLine (buffer, sx - d*z[i], sy, sx - 0.50*d*z[i], sy + 0.87*d*z[i]); 352 DrawLine (buffer, sx - 0.50*d*z[i], sy + 0.87*d*z[i], sx + 0.50*d*z[i], sy + 0.87*d*z[i]); 353 DrawLine (buffer, sx + 0.50*d*z[i], sy + 0.87*d*z[i], sx + d*z[i], sy); 354 355 DrawLine (buffer, sx + d*z[i], sy, sx + 0.50*d*z[i], sy - 0.87*d*z[i]); 356 DrawLine (buffer, sx + 0.50*d*z[i], sy - 0.87*d*z[i], sx - 0.50*d*z[i], sy - 0.87*d*z[i]); 357 DrawLine (buffer, sx - 0.50*d*z[i], sy - 0.87*d*z[i], sx - d*z[i], sy); 358 358 } 359 359 } … … 366 366 sx2 = x[i+1]*mxi + y[i+1]*mxj + bx; 367 367 sy2 = x[i+1]*myi + y[i+1]*myj + by; 368 DrawLine ( sx1, sy1, sx2, sy2);368 DrawLine (buffer, sx1, sy1, sx2, sy2); 369 369 } 370 370 } … … 380 380 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 381 381 { 382 FillRectangle ( sx, sy, 2*d, 2*d);382 FillRectangle (buffer, sx, sy, 2*d, 2*d); 383 383 } 384 384 } … … 392 392 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 393 393 { 394 DrawRectangle ( sx, sy, 2*d, 2*d);394 DrawRectangle (buffer, sx, sy, 2*d, 2*d); 395 395 } 396 396 } … … 404 404 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 405 405 { 406 DrawLine ( sx - d, sy, sx + d, sy);407 DrawLine ( sx, sy - d, sx, sy + d);406 DrawLine (buffer, sx - d, sy, sx + d, sy); 407 DrawLine (buffer, sx, sy - d, sx, sy + d); 408 408 } 409 409 } … … 417 417 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 418 418 { 419 DrawLine ( sx + d, sy - d, sx - d, sy + d);420 DrawLine ( sx - d, sy - d, sx + d, sy + d);419 DrawLine (buffer, sx + d, sy - d, sx - d, sy + d); 420 DrawLine (buffer, sx - d, sy - d, sx + d, sy + d); 421 421 } 422 422 } … … 430 430 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 431 431 { 432 FillTriangle ( sx - d, sy - 0.58*d, sx + d, sy - 0.58*d, sx, sy + 1.15*d);432 FillTriangle (buffer, sx - d, sy - 0.58*d, sx + d, sy - 0.58*d, sx, sy + 1.15*d); 433 433 } 434 434 } … … 442 442 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 443 443 { 444 OpenTriangle ( sx - d, sy + 0.58*d, sx + d, sy + 0.58*d, sx, sy - 1.15*d);444 OpenTriangle (buffer, sx - d, sy + 0.58*d, sx + d, sy + 0.58*d, sx, sy - 1.15*d); 445 445 } 446 446 } … … 454 454 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 455 455 { 456 DrawLine ( sx, sy, sx - d, sy - 0.58*d);457 DrawLine ( sx, sy, sx + d, sy - 0.58*d);458 DrawLine ( sx, sy, sx, sy + 1.15*d);456 DrawLine (buffer, sx, sy, sx - d, sy - 0.58*d); 457 DrawLine (buffer, sx, sy, sx + d, sy - 0.58*d); 458 DrawLine (buffer, sx, sy, sx, sy + 1.15*d); 459 459 } 460 460 } … … 468 468 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 469 469 { 470 DrawCircle ( sx, sy, d);470 DrawCircle (buffer, sx, sy, d); 471 471 } 472 472 } … … 480 480 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 481 481 { 482 DrawLine ( sx + 0.00*d, sy - 1.00*d, sx + 0.95*d, sy - 0.31*d);483 DrawLine ( sx + 0.95*d, sy - 0.31*d, sx + 0.58*d, sy + 0.81*d);484 DrawLine ( sx + 0.58*d, sy + 0.81*d, sx - 0.58*d, sy + 0.81*d);485 DrawLine ( sx - 0.58*d, sy + 0.81*d, sx - 0.95*d, sy - 0.31*d);486 DrawLine ( sx - 0.95*d, sy - 0.31*d, sx + 0.00*d, sy - 1.00*d);482 DrawLine (buffer, sx + 0.00*d, sy - 1.00*d, sx + 0.95*d, sy - 0.31*d); 483 DrawLine (buffer, sx + 0.95*d, sy - 0.31*d, sx + 0.58*d, sy + 0.81*d); 484 DrawLine (buffer, sx + 0.58*d, sy + 0.81*d, sx - 0.58*d, sy + 0.81*d); 485 DrawLine (buffer, sx - 0.58*d, sy + 0.81*d, sx - 0.95*d, sy - 0.31*d); 486 DrawLine (buffer, sx - 0.95*d, sy - 0.31*d, sx + 0.00*d, sy - 1.00*d); 487 487 } 488 488 } … … 496 496 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 497 497 { 498 DrawLine ( sx - 1.00*d, sy + 0.00*d, sx - 0.50*d, sy + 0.87*d);499 DrawLine ( sx - 0.50*d, sy + 0.87*d, sx + 0.50*d, sy + 0.87*d);500 DrawLine ( sx + 0.50*d, sy + 0.87*d, sx + 1.00*d, sy + 0.00*d);501 DrawLine ( sx + 1.00*d, sy + 0.00*d, sx + 0.50*d, sy - 0.87*d);502 DrawLine ( sx + 0.50*d, sy - 0.87*d, sx - 0.50*d, sy - 0.87*d);503 DrawLine ( sx - 0.50*d, sy - 0.87*d, sx - 1.00*d, sy + 0.00*d);498 DrawLine (buffer, sx - 1.00*d, sy + 0.00*d, sx - 0.50*d, sy + 0.87*d); 499 DrawLine (buffer, sx - 0.50*d, sy + 0.87*d, sx + 0.50*d, sy + 0.87*d); 500 DrawLine (buffer, sx + 0.50*d, sy + 0.87*d, sx + 1.00*d, sy + 0.00*d); 501 DrawLine (buffer, sx + 1.00*d, sy + 0.00*d, sx + 0.50*d, sy - 0.87*d); 502 DrawLine (buffer, sx + 0.50*d, sy - 0.87*d, sx - 0.50*d, sy - 0.87*d); 503 DrawLine (buffer, sx - 0.50*d, sy - 0.87*d, sx - 1.00*d, sy + 0.00*d); 504 504 } 505 505 } … … 512 512 sx2 = x[i+1]*mxi + y[i+1]*mxj + bx; 513 513 sy2 = x[i+1]*myi + y[i+1]*myj + by; 514 DrawLine ( sx1, sy1, sx2, sy2);514 DrawLine (buffer, sx1, sy1, sx2, sy2); 515 515 } 516 516 } … … 519 519 520 520 /*******/ 521 void bDrawXErrors ( KapaGraphWidget *graph, Gobjects *object) {521 void bDrawXErrors (bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object) { 522 522 523 523 int i, bar; … … 553 553 (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy))) 554 554 { 555 DrawLine ( sx0, sy0, sx1, sy1);555 DrawLine (buffer, sx0, sy0, sx1, sy1); 556 556 if (bar) { 557 557 sx10 = sy1 - sz; 558 558 sx11 = sy1 + sz; 559 DrawLine ( sx1, sx10, sx1, sx11);559 DrawLine (buffer, sx1, sx10, sx1, sx11); 560 560 } 561 561 } … … 570 570 (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy))) 571 571 { 572 DrawLine ( sx0, sy0, sx1, sy1);572 DrawLine (buffer, sx0, sy0, sx1, sy1); 573 573 if (bar) { 574 574 sx10 = sy1 - sz; 575 575 sx11 = sy1 + sz; 576 DrawLine ( sx1, sx10, sx1, sx11);576 DrawLine (buffer, sx1, sx10, sx1, sx11); 577 577 } 578 578 } … … 581 581 582 582 /*******/ 583 void bDrawYErrors ( KapaGraphWidget *graph, Gobjects *object) {583 void bDrawYErrors (bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object) { 584 584 585 585 int i, bar; … … 615 615 (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy))) 616 616 { 617 DrawLine ( sx0, sy0, sx1, sy1);617 DrawLine (buffer, sx0, sy0, sx1, sy1); 618 618 if (bar) { 619 619 sx10 = sx1 - sz; 620 620 sx11 = sx1 + sz; 621 DrawLine ( sx10, sy1, sx11, sy1);621 DrawLine (buffer, sx10, sy1, sx11, sy1); 622 622 } 623 623 } … … 632 632 (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy))) 633 633 { 634 DrawLine ( sx0, sy0, sx1, sy1);634 DrawLine (buffer, sx0, sy0, sx1, sy1); 635 635 if (bar) { 636 636 sx10 = sx1 - sz; 637 637 sx11 = sx1 + sz; 638 DrawLine ( sx10, sy1, sx11, sy1);638 DrawLine (buffer, sx10, sy1, sx11, sy1); 639 639 } 640 640 } -
trunk/Ohana/src/kapa2/src/bDrawOverlay.c
r25757 r29938 4 4 static char name[4][16] = {"red", "green", "blue", "yellow"}; 5 5 6 void bDrawOverlay ( KapaImageWidget *image, int N) {6 void bDrawOverlay (bDrawBuffer *buffer, KapaImageWidget *image, int N) { 7 7 8 8 int i; … … 14 14 /* translate color to bDrawColors : image[0].overlay[N].color */ 15 15 color = KapaColorByName (name[N]); 16 bDrawSetStyle ( color, 0, 0);16 bDrawSetStyle (buffer, color, 0, 0); 17 17 18 18 expand = 1.0; … … 57 57 switch (image[0].overlay[N].objects[i].type) { 58 58 case KII_OVERLAY_LINE: 59 bDrawLine ( X, Y, (X+dX), (Y+dY));59 bDrawLine (buffer, X, Y, (X+dX), (Y+dY)); 60 60 break; 61 61 case KII_OVERLAY_TEXT: 62 bDrawRotText ( X, Y, image[0].overlay[N].objects[i].text, 8, 0.0);62 bDrawRotText (buffer, X, Y, image[0].overlay[N].objects[i].text, 8, 0.0); 63 63 break; 64 64 case KII_OVERLAY_BOX: 65 65 dx = MAX (abs(dX),2) / 2; 66 66 dy = MAX (abs(dY),2) / 2; 67 bDrawRectOpen ( (X-dx), (Y-dy), (X+dx), (Y+dy));68 // bDrawRectOpen ( (X-dx), (Y-dy), (X), (Y));67 bDrawRectOpen (buffer, (X-dx), (Y-dy), (X+dx), (Y+dy)); 68 // bDrawRectOpen (buffer, (X-dx), (Y-dy), (X), (Y)); 69 69 break; 70 70 case KII_OVERLAY_CIRCLE: … … 72 72 dy = MAX (abs(dY),2); 73 73 if (image[0].overlay[N].objects[i].angle == 0.0) { 74 bDrawArc ( X, Y, dx, dy, 0, 360);74 bDrawArc (buffer, X, Y, dx, dy, 0, 360); 75 75 } else { 76 76 // moderately-stupid rotated ellipse drawing: … … 88 88 x1 = X + pX*dx*cos(t)*cs - pX*dy*sin(t)*sn; 89 89 y1 = Y + pY*dx*cos(t)*sn + pY*dy*sin(t)*cs; 90 bDrawLine ( x0, y0, x1, y1);90 bDrawLine (buffer, x0, y0, x1, y1); 91 91 x0 = x1; 92 92 y0 = y1; … … 101 101 102 102 /* translate color to bDrawColors : image[0].overlay[N].color */ 103 bDrawSetStyle ( color, 0, 0);103 bDrawSetStyle (buffer, color, 0, 0); 104 104 } 105 105 -
trunk/Ohana/src/libdvo/include/dvo.h
r29001 r29938 58 58 // these are used as NAN for types of int values 59 59 typedef enum { 60 NAN_S_CHAR = 0x7f,61 NAN_U_CHAR = 0xff, // was NO_ERR62 NAN_S_SHORT = 0x7fff, // was NO_MAG63 NAN_U_SHORT = 0xffff,64 NAN_S_INT = 0x7fffffff,65 NAN_U_INT =0xffffffff,60 NAN_S_CHAR = 0x7f, 61 NAN_U_CHAR = 0xff, // was NO_ERR 62 NAN_S_SHORT = 0x7fff, // was NO_MAG 63 NAN_U_SHORT = 0xffff, 64 NAN_S_INT = 0x7fffffff, 65 NAN_U_INT = (signed int) 0xffffffff, 66 66 } DVO_INT_NAN; 67 67 … … 135 135 /* Average.code values -- these values are 32 bit (as of PS1_V1) */ 136 136 typedef enum { 137 ID_STAR_FEW = 0x00000001, // used within relphot: skip star 138 ID_STAR_POOR = 0x00000002, // used within relphot: skip star 139 ID_PROPER = 0x00000400, // star with large proper motion 140 ID_TRANSIENT = 0x00001000, // is this mutually exclusive with USNO? 141 ID_VARIABLE = 0x00002000, // not currently set? 142 ID_ASTEROID = 0x00002000, // identified with an asteroid 143 ID_BAD_OBJECT = 0x00004000, // if all measurements are bad, set this bit 137 ID_STAR_FEW = 0x00000001, // used within relphot: skip star 138 ID_STAR_POOR = 0x00000002, // used within relphot: skip star 139 ID_PROPER = 0x00000400, // star with large proper motion 140 ID_TRANSIENT = 0x00001000, // is this mutually exclusive with USNO? 141 ID_VARIABLE = 0x00002000, // not currently set? 142 ID_ASTEROID = 0x00002000, // identified with an asteroid 143 ID_BAD_OBJECT = 0x00004000, // if all measurements are bad, set this bit 144 144 ID_MOVING = 0x00008000, // is a moving object 145 ID_ROCK = 0x0000a000, // 0x8000 + 0x2000 146 ID_GHOST = 0x0000c001, // 0x8000 + 0x4000 + 0x0001 147 ID_TRAIL = 0x0000c002, // 0x8000 + 0x4000 + 0x0002 148 ID_BLEED = 0x0000c003, // 0x8000 + 0x4000 + 0x0003 149 ID_COSMIC = 0x0000c004, // 0x8000 + 0x4000 + 0x0004 145 ID_ROCK = 0x0000a000, // 0x8000 + 0x2000 146 ID_GHOST = 0x0000c001, // 0x8000 + 0x4000 + 0x0001 147 ID_TRAIL = 0x0000c002, // 0x8000 + 0x4000 + 0x0002 148 ID_BLEED = 0x0000c003, // 0x8000 + 0x4000 + 0x0003 149 ID_COSMIC = 0x0000c004, // 0x8000 + 0x4000 + 0x0004 150 150 ID_STAR_FIT_AVE = 0x00010000, // average position fitted 151 151 ID_STAR_FIT_PM = 0x00020000, // proper motion fitted … … 156 156 ID_OBJ_EXT = 0x01000000, // extended in our data (eg, PS) 157 157 ID_OBJ_EXT_ALT = 0x02000000, // extended in external data (eg, 2MASS) 158 ID_OBJ_GOOD = 0x04000000, // good-quality measurement in our data (eg, PS)159 ID_OBJ_GOOD_ALT = 0x08000000, // good-quality measurement in external data (eg, 2MASS)158 ID_OBJ_GOOD = 0x04000000, // good-quality measurement in our data (eg,PS) 159 ID_OBJ_GOOD_ALT = 0x08000000, // good-quality measurement in external data (eg, 2MASS) 160 160 } DVOAverageFlags; 161 161 … … 233 233 *** that is just silly, and bad: convert to using Nsec_mem, Nsec_disk, Nsec_off. 234 234 *** unless we always require the secfilt and average entries to be loaded sychronously. 235 */235 */ 236 236 237 237 /* pointers to split data files */ … … 293 293 int isRegisteredMosaic (void); 294 294 off_t GetRegisteredMosaic (void); 295 off_t *GetChipMatch (void); 295 296 int GetMosaicCoords (Coords *coords); 296 297 int FindMosaicForImage (Image *images, off_t Nimages, off_t entry); -
trunk/Ohana/src/libdvo/src/dvo_catalog.c
r27580 r29938 302 302 int dvo_catalog_save (Catalog *catalog, char VERBOSE) { 303 303 304 int status = FALSE; 305 304 306 // set the 'sorted' header keyword 305 307 gfits_modify_alt (&catalog[0].header, "SORTED", "%t", 1, catalog[0].sorted); … … 308 310 switch (catalog[0].catmode) { 309 311 case DVO_MODE_RAW: 310 dvo_catalog_save_raw (catalog, VERBOSE);312 status = dvo_catalog_save_raw (catalog, VERBOSE); 311 313 break; 312 314 case DVO_MODE_MEF: 313 dvo_catalog_save_mef (catalog, VERBOSE);315 status = dvo_catalog_save_mef (catalog, VERBOSE); 314 316 break; 315 317 case DVO_MODE_SPLIT: 316 dvo_catalog_save_split (catalog, VERBOSE);318 status = dvo_catalog_save_split (catalog, VERBOSE); 317 319 break; 318 320 default: … … 320 322 exit (2); 321 323 } 322 return ( TRUE);324 return (status); 323 325 } 324 326 -
trunk/Ohana/src/libdvo/src/dvo_catalog_mef.c
r29001 r29938 66 66 /* read Average table data (or skip) */ 67 67 if (catalog[0].catflags & LOAD_AVES) { 68 if (!gfits_fread_ftable_data (f, &ftable )) {68 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) { 69 69 if (VERBOSE) fprintf (stderr, "can't read table average data"); 70 70 return (FALSE); … … 94 94 /* read Measure table data */ 95 95 if (catalog[0].catflags & LOAD_MEAS) { 96 if (!gfits_fread_ftable_data (f, &ftable )) {96 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) { 97 97 if (VERBOSE) fprintf (stderr, "can't read table measure data"); 98 98 return (FALSE); … … 119 119 /* read Missing table data */ 120 120 if (catalog[0].catflags & LOAD_MISS) { 121 if (!gfits_fread_ftable_data (f, &ftable )) {121 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) { 122 122 if (VERBOSE) fprintf (stderr, "can't read table missing data"); 123 123 return (FALSE); … … 149 149 /* read secfilt table data */ 150 150 if (catalog[0].catflags & LOAD_SECF) { 151 if (!gfits_fread_ftable_data (f, &ftable )) {151 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) { 152 152 if (VERBOSE) fprintf (stderr, "can't read table secfilt data"); 153 153 return (FALSE); -
trunk/Ohana/src/libdvo/src/dvo_catalog_split.c
r29001 r29938 218 218 } 219 219 /* read Average table data : format is irrelevant here */ 220 if (!gfits_fread_ftable_data (catalog[0].f, &ftable )) {220 if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) { 221 221 if (VERBOSE) fprintf (stderr, "can't read table average data"); 222 222 return (FALSE); … … 249 249 // XXX this allows an empty Measure catalog with non-empty Average catalog : is that OK? 250 250 /* read Measure table data */ 251 if (!gfits_fread_ftable_data (catalog[0].measure_catalog[0].f, &ftable )) {251 if (!gfits_fread_ftable_data (catalog[0].measure_catalog[0].f, &ftable, FALSE)) { 252 252 if (VERBOSE) fprintf (stderr, "can't read table measure data\n"); 253 253 return (FALSE); … … 279 279 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_MISS)) { 280 280 /* read Missing table data */ 281 if (!gfits_fread_ftable_data (catalog[0].missing_catalog[0].f, &ftable )) {281 if (!gfits_fread_ftable_data (catalog[0].missing_catalog[0].f, &ftable, FALSE)) { 282 282 if (VERBOSE) fprintf (stderr, "can't read table missing data\n"); 283 283 return (FALSE); … … 313 313 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_SECF)) { 314 314 /* read secfilt table data */ 315 if (!gfits_fread_ftable_data (catalog[0].secfilt_catalog[0].f, &ftable )) {315 if (!gfits_fread_ftable_data (catalog[0].secfilt_catalog[0].f, &ftable, FALSE)) { 316 316 if (VERBOSE) fprintf (stderr, "can't read table secfilt data\n"); 317 317 return (FALSE); -
trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c
r29182 r29938 557 557 } 558 558 } 559 if (entry == -1) { 560 // entry is missing fail (no printfs in this file) 561 free(map); 562 return(FALSE); 563 } 559 // if (entry == -1) { 560 // // entry is missing fail (no printfs in this file) 561 // free(map); 562 // return(FALSE); 563 // } 564 565 // if entry is still -1, we will skip this one (not map into the output db) 564 566 map[i] = entry; 565 567 } -
trunk/Ohana/src/libdvo/src/fits_db.c
r28246 r29938 83 83 return (FALSE); 84 84 } 85 if (!gfits_fread_ftable_data (db[0].f, &db[0].ftable )) {85 if (!gfits_fread_ftable_data (db[0].f, &db[0].ftable, FALSE)) { 86 86 fprintf (stderr, "can't read table data"); 87 87 gfits_db_free (db); -
trunk/Ohana/src/libdvo/src/mosaic_astrom.c
r27435 r29938 17 17 } 18 18 19 /* what is the currently registered mosaic image? */ 20 off_t *GetChipMatch () { 21 return (ChipMatch); 22 } 23 19 24 /* given an image array and a current entry of type WRP, find matching DIS & Register it */ 20 25 int FindMosaicForImage (Image *images, off_t Nimages, off_t entry) { … … 40 45 if (strcmp(&images[entry].coords.ctype[4], "-WRP")) { 41 46 /* not a wrp image, do nothing */ 42 return ( TRUE); /* error or not */47 return (entry + 1); /* error or not */ 43 48 } 44 49 … … 52 57 RegisterMosaic (&images[i].coords); 53 58 iDIS = i; 54 return ( TRUE);59 return (i + 1); 55 60 } 56 61 … … 62 67 RegisterMosaic (&images[i].coords); 63 68 iDIS = i; 64 return ( TRUE);69 return (i + 1); 65 70 } 66 71 return (FALSE); … … 74 79 if (strcmp(&images[entry].coords.ctype[4], "-WRP")) { 75 80 /* not a wrp image, do nothing */ 76 return ( TRUE); /* error or not? */81 return (entry + 1); /* error or not? */ 77 82 } 78 83 … … 85 90 RegisterMosaic (&images[N].coords); 86 91 iDIS = N; 87 return ( TRUE);92 return (N + 1); 88 93 } 89 94 … … 165 170 SortDISindex (DIStzero, DISentry, Ndis); 166 171 172 // ChipMatch has a few possible values: 173 // -3 : image is a mosaic (DIS) 174 // -2 : image is an unassigned WRP image 175 // -1 : image is not a WRP or DIS images 176 // >= 0 : value is the mosaic seq number for this WRP image 177 167 178 /* find all matched WRP images */ 168 179 ALLOCATE (ChipMatch, off_t, Nimages); 169 180 for (i = 0; i < Nimages; i++) { 170 181 ChipMatch[i] = -1; 182 if (!strcmp(&images[i].coords.ctype[4], "-DIS")) { 183 ChipMatch[i] = -3; 184 continue; 185 } 171 186 if (strcmp(&images[i].coords.ctype[4], "-WRP")) continue; 172 187 -
trunk/Ohana/src/libfits/include/gfitsio.h
r29537 r29938 64 64 char *buffer; 65 65 off_t datasize; 66 off_t validsize; 66 67 } FTable; 67 68 … … 172 173 int gfits_define_table_column PROTO((Header *header, char *format, char *label, char *comment, char *unit)); 173 174 int gfits_fread_ftable PROTO((FILE *f, FTable *ftable, char *extname)); 174 int gfits_fread_ftable_data PROTO((FILE *f, FTable *ftable ));175 int gfits_fread_ftable_data PROTO((FILE *f, FTable *ftable, int padIfShort)); 175 176 int gfits_fread_ftable_range PROTO((FILE *f, FTable *ftable, off_t start, off_t Nrows)); 176 177 int gfits_fread_vtable PROTO((FILE *f, VTable *vtable, char *extname, off_t Nrow, off_t *row)); -
trunk/Ohana/src/libfits/table/F_read_T.c
r28241 r29938 36 36 gfits_scan (header, "EXTNAME", "%s", 1, tname); 37 37 if (!strcmp (tname, extname)) { 38 if (gfits_fread_ftable_data (f, table )) return (TRUE);38 if (gfits_fread_ftable_data (f, table, FALSE)) return (TRUE); 39 39 gfits_free_header (header); 40 40 return (FALSE); … … 50 50 51 51 /*********************** fits read ftable data ***********************************/ 52 int gfits_fread_ftable_data (FILE *f, FTable *table ) {52 int gfits_fread_ftable_data (FILE *f, FTable *table, int padIfShort) { 53 53 54 54 off_t Nbytes, Nread; … … 65 65 if (Nread < gfits_data_min_size (table[0].header)) { 66 66 fprintf (stderr, "error: fits read error in %s, read "OFF_T_FMT", need "OFF_T_FMT"\n", __func__, Nread, gfits_data_min_size (table[0].header)); 67 gfits_free_table (table); 68 return (FALSE); 67 if (padIfShort) { 68 memset (&table[0].buffer[Nread], 0, Nbytes - Nread); 69 fprintf (stderr, "warning: file missing data, padding with zeros: USE AT YOUR OWN RISK!\n"); 70 table[0].validsize = Nread; 71 table[0].datasize = Nbytes; 72 return (TRUE); 73 } else { 74 gfits_free_table (table); 75 return (FALSE); 76 } 69 77 } 70 78 fprintf (stderr, "warning: file missing pad\n"); 71 79 } 80 table[0].validsize = Nread; 72 81 table[0].datasize = Nbytes; 73 82 return (TRUE); -
trunk/Ohana/src/libkapa/include/kapa.h
r29537 r29938 115 115 116 116 typedef struct { 117 int Nx, Ny ;117 int Nx, Ny, Nbyte; 118 118 bDrawColor **pixels; 119 png_color *palette; 120 int Npalette; 121 // current drawing values: 122 int bWeight; 123 int bType; 124 bDrawColor bColor; 125 bDrawColor bColor_R; 126 bDrawColor bColor_G; 127 bDrawColor bColor_B; 119 128 } bDrawBuffer; 120 129 … … 165 174 /* KapaWindow.c */ 166 175 int KiiResize (int fd, int Nx, int Ny); 176 int KiiResizeByImage (int fd); 167 177 int KiiRelocate (int fd, int x, int y); 168 178 int KiiCenter (int fd, double x, double y, int zoom); … … 182 192 int KapaGetLimits (int fd, float *dx, float *dy); 183 193 int KapaSetSection (int fd, KapaSection *section); 194 int KapaSetSectionByImage (int fd, KapaSection *section); 184 195 int KapaSelectSection (int fd, char *name); 185 196 int KapaGetSection (int fd, char *name); … … 221 232 222 233 /* bDrawFuncs.c */ 223 bDrawBuffer *bDrawBufferCreate (int Nx, int Ny );234 bDrawBuffer *bDrawBufferCreate (int Nx, int Ny, int Nbyte, png_color *palette, int Npalette); 224 235 void bDrawBufferFree (bDrawBuffer *buffer); 225 236 void bDrawSetBuffer (bDrawBuffer *buffer); 226 void bDrawSetStyle (bDraw Color color, int lw, int lt);227 void bDrawPoint ( int x, int y);228 void bDrawPointf ( float x, float y);229 230 void bDrawArc ( double Xc, double Yc, double Xr, double Yr, double Ts, double Te);231 void bDrawCircle ( double Xc, double Yc, double radius);232 void bDrawCircleFill ( double xc, double yc, double radius);233 234 void bDrawLine ( double x1, double y1, double x2, double y2);235 void bDrawLineWeight ( int X1, int Y1, int X2, int Y2, int swapcoords);236 void bDrawLineBresen ( int X1, int Y1, int X2, int Y2, int swapcoords);237 void bDrawLineHorizontal ( int X1, int X2, int Y);238 void bDrawLineVertical ( int X, int Y1, int Y2);239 240 void bDrawRectOpen ( double x1, double y1, double x2, double y2);241 void bDrawRectFill ( double x1, double y1, double x2, double y2);242 void bDrawTriOpen (double x1, double y1, double x2, double y2, double x3, double y3);243 void bDrawTriFill (double x1, double y1, double x2, double y2, double x3, double y3);237 void bDrawSetStyle (bDrawBuffer *buffer, bDrawColor color, int lw, int lt); 238 void bDrawPoint (bDrawBuffer *buffer, int x, int y); 239 void bDrawPointf (bDrawBuffer *buffer, float x, float y); 240 241 void bDrawArc (bDrawBuffer *buffer, double Xc, double Yc, double Xr, double Yr, double Ts, double Te); 242 void bDrawCircle (bDrawBuffer *buffer, double Xc, double Yc, double radius); 243 void bDrawCircleFill (bDrawBuffer *buffer, double xc, double yc, double radius); 244 245 void bDrawLine (bDrawBuffer *buffer, double x1, double y1, double x2, double y2); 246 void bDrawLineWeight (bDrawBuffer *buffer, int X1, int Y1, int X2, int Y2, int swapcoords); 247 void bDrawLineBresen (bDrawBuffer *buffer, int X1, int Y1, int X2, int Y2, int swapcoords); 248 void bDrawLineHorizontal (bDrawBuffer *buffer, int X1, int X2, int Y); 249 void bDrawLineVertical (bDrawBuffer *buffer, int X, int Y1, int Y2); 250 251 void bDrawRectOpen (bDrawBuffer *buffer, double x1, double y1, double x2, double y2); 252 void bDrawRectFill (bDrawBuffer *buffer, double x1, double y1, double x2, double y2); 253 void bDrawTriOpen (bDrawBuffer *buffer, double x1, double y1, double x2, double y2, double x3, double y3); 254 void bDrawTriFill (bDrawBuffer *buffer, double x1, double y1, double x2, double y2, double x3, double y3); 244 255 245 256 /* bDrawRotFont.c */ 246 int bDrawRotText ( int x, int y, char *string, int pos, double angle);247 int bDrawRotBitmap ( int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale);257 int bDrawRotText (bDrawBuffer *buffer, int x, int y, char *string, int pos, double angle); 258 int bDrawRotBitmap (bDrawBuffer *buffer, int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale); 248 259 249 260 /* Kapa Socket functions */ -
trunk/Ohana/src/libkapa/src/KapaWindow.c
r27790 r29938 23 23 KiiSendCommand (fd, 4, "RSIZ"); 24 24 KiiSendMessage (fd, "%d %d", Nx, Ny); 25 KiiWaitAnswer (fd, "DONE"); 26 return (TRUE); 27 } 28 29 int KiiResizeByImage (int fd) { 30 31 KiiSendCommand (fd, 4, "ISIZ"); 25 32 KiiWaitAnswer (fd, "DONE"); 26 33 return (TRUE); … … 370 377 } 371 378 379 int KapaSetSectionByImage (int fd, KapaSection *section) { 380 381 KiiSendCommand (fd, 4, "ISEC"); 382 KiiSendMessage (fd, "%s %6.3f %6.3f %3d", 383 section[0].name, 384 section[0].x, 385 section[0].y, 386 section[0].bg); 387 KiiWaitAnswer (fd, "DONE"); 388 return (TRUE); 389 } 390 372 391 int KapaSectionBG (int fd, char *name, int bg) { 373 392 -
trunk/Ohana/src/libkapa/src/bDrawFuncs.c
r29537 r29938 1 1 # include <kapa_internal.h> 2 3 // XXX we can get rid of these static vars by making them elements of the bDrawBuffer 4 // 5 6 7 static int bWeight; 8 static int bType; 9 static bDrawColor bColor; 10 static bDrawBuffer *bBuffer; 11 void bDrawCircleSingle (double xc, double yc, double radius); 12 13 bDrawBuffer *bDrawBufferCreate (int Nx, int Ny) { 2 # define myAssert(LOGIC,MSG) { if (!(LOGIC)) { fprintf (stderr, "%s\n", MSG); abort (); } } 3 4 // move these to the bDrawBuffer type 5 // static int bWeight; 6 // static int bType; 7 // static bDrawColor bColor; 8 // static bDrawColor bColor_R; 9 // static bDrawColor bColor_G; 10 // static bDrawColor bColor_B; 11 // static bDrawBuffer *bBuffer; 12 13 void bDrawCircleSingle (bDrawBuffer *buffer, double xc, double yc, double radius); 14 15 // create a drawing buffer with either 1 or 3 byte colors 16 bDrawBuffer *bDrawBufferCreate (int Nx, int Ny, int Nbyte, png_color *palette, int Npalette) { 14 17 15 18 int i, j; 16 bDrawColor white ;19 bDrawColor white, white_R, white_G, white_B; 17 20 bDrawBuffer *buffer; 18 21 22 myAssert((Nbyte == 1) || (Nbyte == 3), "invalid depth"); 23 myAssert(palette, "missing palette"); 24 19 25 white = KapaColorByName ("white"); 26 white_R = palette[white].red; 27 white_G = palette[white].green; 28 white_B = palette[white].blue; 20 29 21 30 ALLOCATE (buffer, bDrawBuffer, 1); 22 31 buffer[0].Nx = Nx; 23 32 buffer[0].Ny = Ny; 33 buffer[0].Nbyte = Nbyte; 34 buffer[0].palette = palette; 35 buffer[0].Npalette = Npalette; 24 36 25 37 ALLOCATE (buffer[0].pixels, bDrawColor *, Ny); 26 38 for (i = 0; i < Ny; i++) { 27 ALLOCATE (buffer[0].pixels[i], bDrawColor, N x);39 ALLOCATE (buffer[0].pixels[i], bDrawColor, Nbyte*Nx); 28 40 for (j = 0; j < Nx; j++) { 29 buffer[0].pixels[i][j] = white; 30 } 31 } 41 if (Nbyte == 1) { 42 buffer[0].pixels[i][j] = white; 43 } else { 44 buffer[0].pixels[i][3*j+0] = white_R; 45 buffer[0].pixels[i][3*j+1] = white_G; 46 buffer[0].pixels[i][3*j+2] = white_B; 47 } 48 } 49 } 50 51 buffer[0].bWeight = 0; 52 buffer[0].bType = 0; 53 buffer[0].bColor = white; 54 buffer[0].bColor_R = white_R; 55 buffer[0].bColor_G = white_G; 56 buffer[0].bColor_B = white_B; 32 57 return (buffer); 33 58 } … … 41 66 } 42 67 free (buffer[0].pixels); 68 free (buffer[0].palette); 43 69 free (buffer); 44 70 return; 45 71 } 46 72 47 void bDrawSetBuffer (bDrawBuffer *buffer) { 48 bBuffer = buffer; 49 return; 50 } 51 52 void bDrawSetStyle (bDrawColor color, int lw, int lt) { 53 bColor = color; 54 bWeight = lw; 55 bType = lt; 73 // void bDrawSetBuffer (bDrawBuffer *buffer) { 74 // myAssert(buffer[0].Nbyte == 1, "invalid depth"); 75 // bBuffer = buffer; 76 // return; 77 // } 78 79 void bDrawSetStyle (bDrawBuffer *buffer, bDrawColor color, int lw, int lt) { 80 buffer->bColor = color; 81 buffer->bColor_R = buffer->palette[color].red; 82 buffer->bColor_G = buffer->palette[color].green; 83 buffer->bColor_B = buffer->palette[color].blue; 84 buffer->bWeight = lw; 85 buffer->bType = lt; 56 86 return; 57 87 } 58 88 59 89 // draw a point in the current color 60 void bDrawPoint (int x, int y) { 61 90 void bDrawPoint (bDrawBuffer *buffer, int x, int y) { 91 92 // myAssert(buffer[0].Nbyte == 1, "invalid depth"); 62 93 if (x < 0) return; 63 94 if (y < 0) return; 64 if (x >= bBuffer[0].Nx) return; 65 if (y >= bBuffer[0].Ny) return; 66 bBuffer[0].pixels[y][x] = bColor; 95 if (x >= buffer[0].Nx) return; 96 if (y >= buffer[0].Ny) return; 97 if (buffer[0].Nbyte == 1) { 98 buffer[0].pixels[y][x] = buffer->bColor; 99 } else { 100 buffer[0].pixels[y][3*x+0] = buffer->bColor_R; 101 buffer[0].pixels[y][3*x+1] = buffer->bColor_G; 102 buffer[0].pixels[y][3*x+2] = buffer->bColor_B; 103 } 67 104 return; 68 105 } 69 106 70 107 // draw a point in the current color 71 void bDrawPointf ( float x, float y) {72 73 bDrawPoint ( ROUND(x), ROUND(y));74 return; 75 } 76 77 void bDrawTriOpen ( double x1, double y1, double x2, double y2, double x3, double y3) {78 79 bDrawLine ( x1, y1, x2, y2);80 bDrawLine ( x2, y2, x3, y3);81 bDrawLine ( x3, y3, x1, y1);82 83 return; 84 } 85 86 void bDrawRectOpen ( double x1, double y1, double x2, double y2) {108 void bDrawPointf (bDrawBuffer *buffer, float x, float y) { 109 110 bDrawPoint (buffer, ROUND(x), ROUND(y)); 111 return; 112 } 113 114 void bDrawTriOpen (bDrawBuffer *buffer, double x1, double y1, double x2, double y2, double x3, double y3) { 115 116 bDrawLine (buffer, x1, y1, x2, y2); 117 bDrawLine (buffer, x2, y2, x3, y3); 118 bDrawLine (buffer, x3, y3, x1, y1); 119 120 return; 121 } 122 123 void bDrawRectOpen (bDrawBuffer *buffer, double x1, double y1, double x2, double y2) { 87 124 88 125 int X1, Y1, X2, Y2; … … 91 128 if (y1 > y2) SWAP (y1, y2); 92 129 93 X1 = MIN (MAX (ROUND (x1), 0), b Buffer[0].Nx - 1);94 X2 = MIN (MAX (ROUND (x2), 1), b Buffer[0].Nx);95 96 Y1 = MIN (MAX (ROUND (y1), 0), b Buffer[0].Ny - 1);97 Y2 = MIN (MAX (ROUND (y2), 1), b Buffer[0].Ny);98 99 bDrawLineHorizontal ( X1, X2, Y1);100 bDrawLineHorizontal ( X1, X2, Y2);101 bDrawLineVertical (X1, Y1, Y2);102 bDrawLineVertical (X2, Y1, Y2);103 return; 104 } 105 106 void bDrawRectFill ( double x1, double y1, double x2, double y2) {130 X1 = MIN (MAX (ROUND (x1), 0), buffer[0].Nx - 1); 131 X2 = MIN (MAX (ROUND (x2), 1), buffer[0].Nx - 1); 132 133 Y1 = MIN (MAX (ROUND (y1), 0), buffer[0].Ny - 1); 134 Y2 = MIN (MAX (ROUND (y2), 1), buffer[0].Ny - 1); 135 136 bDrawLineHorizontal (buffer, X1, X2, Y1); 137 bDrawLineHorizontal (buffer, X1, X2, Y2); 138 bDrawLineVertical (buffer, X1, Y1, Y2); 139 bDrawLineVertical (buffer, X2, Y1, Y2); 140 return; 141 } 142 143 void bDrawRectFill (bDrawBuffer *buffer, double x1, double y1, double x2, double y2) { 107 144 108 145 int i; … … 112 149 if (y1 > y2) SWAP (y1, y2); 113 150 114 X1 = MIN (MAX (ROUND (x1), 0), b Buffer[0].Nx - 1);115 X2 = MIN (MAX (ROUND (x2), 1), b Buffer[0].Nx);116 117 Y1 = MIN (MAX (ROUND (y1), 0), b Buffer[0].Ny - 1);118 Y2 = MIN (MAX (ROUND (y2), 0), b Buffer[0].Ny);151 X1 = MIN (MAX (ROUND (x1), 0), buffer[0].Nx - 1); 152 X2 = MIN (MAX (ROUND (x2), 1), buffer[0].Nx - 1); 153 154 Y1 = MIN (MAX (ROUND (y1), 0), buffer[0].Ny - 1); 155 Y2 = MIN (MAX (ROUND (y2), 0), buffer[0].Ny - 1); 119 156 120 157 for (i = Y1; i < Y2; i++) { 121 bDrawLineHorizontal ( X1, X2, i);158 bDrawLineHorizontal (buffer, X1, X2, i); 122 159 } 123 160 return; … … 125 162 126 163 // identify the quadrant and draw the correct line 127 void bDrawLine ( double x1, double y1, double x2, double y2) {164 void bDrawLine (bDrawBuffer *buffer, double x1, double y1, double x2, double y2) { 128 165 129 166 int FlipDirect, FlipCoords; … … 144 181 FlipDirect = FlipCoords ? (y1 > y2) : (x1 > x2); 145 182 146 if (!FlipDirect && !FlipCoords) bDrawLineWeight ( X1, Y1, X2, Y2, FALSE);147 if ( FlipDirect && !FlipCoords) bDrawLineWeight ( X2, Y2, X1, Y1, FALSE);148 if (!FlipDirect && FlipCoords) bDrawLineWeight ( Y1, X1, Y2, X2, TRUE);149 if ( FlipDirect && FlipCoords) bDrawLineWeight ( Y2, X2, Y1, X1, TRUE);183 if (!FlipDirect && !FlipCoords) bDrawLineWeight (buffer, X1, Y1, X2, Y2, FALSE); 184 if ( FlipDirect && !FlipCoords) bDrawLineWeight (buffer, X2, Y2, X1, Y1, FALSE); 185 if (!FlipDirect && FlipCoords) bDrawLineWeight (buffer, Y1, X1, Y2, X2, TRUE); 186 if ( FlipDirect && FlipCoords) bDrawLineWeight (buffer, Y2, X2, Y1, X1, TRUE); 150 187 151 188 return; … … 153 190 154 191 // draw a series of lines to give the line weight 155 void bDrawLineWeight ( int X1, int Y1, int X2, int Y2, int swapcoords) {192 void bDrawLineWeight (bDrawBuffer *buffer, int X1, int Y1, int X2, int Y2, int swapcoords) { 156 193 157 194 int dN, dNs, dNe; 158 195 159 dNs = -0.5*(b Weight - 1);196 dNs = -0.5*(buffer->bWeight - 1); 160 197 /* 0, 0, 0, -1, -1, -2, -2 */ 161 198 162 dNe = +0.5*b Weight + 1;199 dNe = +0.5*buffer->bWeight + 1; 163 200 /* 1, 1, 2, 2, 2, 3, 3 */ 164 201 165 202 for (dN = dNs; dN < dNe; dN++) { 166 bDrawLineBresen ( X1, Y1 + dN, X2, Y2 + dN, swapcoords);203 bDrawLineBresen (buffer, X1, Y1 + dN, X2, Y2 + dN, swapcoords); 167 204 } 168 205 return; … … 171 208 // use the Bresenham line drawing technique 172 209 // integer-only Bresenham line-draw version which is fast 173 void bDrawLineBresen ( int X1, int Y1, int X2, int Y2, int swapcoords) {210 void bDrawLineBresen (bDrawBuffer *buffer, int X1, int Y1, int X2, int Y2, int swapcoords) { 174 211 175 212 int X, Y, dX, dY; … … 185 222 e = 0; 186 223 for (X = X1, N = 0; X <= X2; X++, N++) { 187 if (b Type == 1) { DashOn = (N % 10) < 5; }188 if (b Type == 2) { DashOn = (N % 6) < 3; }224 if (buffer->bType == 1) { DashOn = (N % 10) < 5; } 225 if (buffer->bType == 2) { DashOn = (N % 6) < 3; } 189 226 if (swapcoords) { 190 if (DashOn) bDrawPoint ( Y,X);227 if (DashOn) bDrawPoint (buffer, Y,X); 191 228 } else { 192 if (DashOn) bDrawPoint ( X,Y);229 if (DashOn) bDrawPoint (buffer, X,Y); 193 230 } 194 231 e += dY; … … 206 243 } 207 244 208 void bDrawLineHorizontal ( int X1, int X2, int Y) {245 void bDrawLineHorizontal (bDrawBuffer *buffer, int X1, int X2, int Y) { 209 246 210 247 int i; 211 248 212 249 for (i = X1; i < X2; i++) { 213 bBuffer[0].pixels[Y][i] = bColor; 214 } 215 return; 216 } 217 218 void bDrawLineVertical (int X, int Y1, int Y2) { 250 if (buffer[0].Nbyte == 1) { 251 buffer[0].pixels[Y][i] = buffer->bColor; 252 } else { 253 buffer[0].pixels[Y][3*i+0] = buffer->bColor_R; 254 buffer[0].pixels[Y][3*i+1] = buffer->bColor_G; 255 buffer[0].pixels[Y][3*i+2] = buffer->bColor_B; 256 } 257 } 258 return; 259 } 260 261 void bDrawLineVertical (bDrawBuffer *buffer, int X, int Y1, int Y2) { 219 262 220 263 int i; 221 264 222 265 for (i = Y1; i < Y2; i++) { 223 bBuffer[0].pixels[i][X] = bColor; 224 } 225 return; 226 } 227 228 void bDrawTriFill (double x1, double y1, double x2, double y2, double x3, double y3) { 229 230 bDrawTriOpen (x1, y1, x2, y2, x3, y3); 231 return; 232 } 233 234 void bDrawArc (double Xc, double Yc, double Xr, double Yr, double Ts, double Te) { 266 if (buffer[0].Nbyte == 1) { 267 buffer[0].pixels[i][X] = buffer->bColor; 268 } else { 269 buffer[0].pixels[i][3*X+0] = buffer->bColor_R; 270 buffer[0].pixels[i][3*X+1] = buffer->bColor_G; 271 buffer[0].pixels[i][3*X+2] = buffer->bColor_B; 272 } 273 } 274 return; 275 } 276 277 void bDrawTriFill (bDrawBuffer *buffer, double x1, double y1, double x2, double y2, double x3, double y3) { 278 279 bDrawTriOpen (buffer, x1, y1, x2, y2, x3, y3); 280 return; 281 } 282 283 void bDrawArc (bDrawBuffer *buffer, double Xc, double Yc, double Xr, double Yr, double Ts, double Te) { 235 284 236 285 float t, dt; … … 258 307 259 308 /* we could use the value of MAX(dy/dt,dx/dt) to set dt */ 260 bDrawPoint ( x,y);309 bDrawPoint (buffer, x,y); 261 310 262 311 dt = MAX (fabs(Xr * sin(t)), fabs(Yr * cos(t))); … … 267 316 268 317 // draw a series of circles to give line weight 269 void bDrawCircle ( double xc, double yc, double radius) {318 void bDrawCircle (bDrawBuffer *buffer, double xc, double yc, double radius) { 270 319 271 320 int dN, dNs, dNe; 272 321 273 dNs = -0.5*(b Weight - 1);322 dNs = -0.5*(buffer->bWeight - 1); 274 323 /* 0, 0, 0, -1, -1, -2, -2 */ 275 324 276 dNe = +0.5*b Weight + 1;325 dNe = +0.5*buffer->bWeight + 1; 277 326 /* 1, 1, 2, 2, 2, 3, 3 */ 278 327 279 328 for (dN = dNs; dN < dNe; dN++) { 280 bDrawCircleSingle ( xc, yc, radius + dN);329 bDrawCircleSingle (buffer, xc, yc, radius + dN); 281 330 } 282 331 return; … … 284 333 285 334 // draw a pure circle 286 void bDrawCircleSingle ( double xc, double yc, double radius) {335 void bDrawCircleSingle (bDrawBuffer *buffer, double xc, double yc, double radius) { 287 336 288 337 int Xc, Yc, Radius; … … 300 349 301 350 while (x <= y) { 302 bDrawPoint ( Xc+x, Yc+y);303 bDrawPoint ( Xc+x, Yc-y);304 bDrawPoint ( Xc-x, Yc+y);305 bDrawPoint ( Xc-x, Yc-y);306 bDrawPoint ( Xc+y, Yc+x);307 bDrawPoint ( Xc+y, Yc-x);308 bDrawPoint ( Xc-y, Yc+x);309 bDrawPoint ( Xc-y, Yc-x);351 bDrawPoint (buffer, Xc+x, Yc+y); 352 bDrawPoint (buffer, Xc+x, Yc-y); 353 bDrawPoint (buffer, Xc-x, Yc+y); 354 bDrawPoint (buffer, Xc-x, Yc-y); 355 bDrawPoint (buffer, Xc+y, Yc+x); 356 bDrawPoint (buffer, Xc+y, Yc-x); 357 bDrawPoint (buffer, Xc-y, Yc+x); 358 bDrawPoint (buffer, Xc-y, Yc-x); 310 359 311 360 if (d < 0) { … … 322 371 323 372 // draw a pure circle 324 void bDrawCircleFill ( double xc, double yc, double radius) {373 void bDrawCircleFill (bDrawBuffer *buffer, double xc, double yc, double radius) { 325 374 326 375 int Xc, Yc, Radius; … … 338 387 339 388 while (x <= y) { 340 bDrawLineHorizontal ( Xc-x, Xc+x, Yc+y);341 bDrawLineHorizontal ( Xc-x, Xc+x, Yc-y);342 bDrawLineHorizontal ( Xc-y, Xc+y, Yc+x);343 bDrawLineHorizontal ( Xc-y, Xc+y, Yc-x);389 bDrawLineHorizontal (buffer, Xc-x, Xc+x, Yc+y); 390 bDrawLineHorizontal (buffer, Xc-x, Xc+x, Yc-y); 391 bDrawLineHorizontal (buffer, Xc-y, Xc+y, Yc+x); 392 bDrawLineHorizontal (buffer, Xc-y, Xc+y, Yc-x); 344 393 345 394 if (d < 0) { -
trunk/Ohana/src/libkapa/src/bDrawRotFont.c
r12332 r29938 6 6 # define NEARINT(x) ((x < 0) ? ((int)(x - 0.5)) : ((int)(x + 0.5))) 7 7 8 static bDrawColor black; 9 static bDrawColor white; 10 11 int bDrawRotText (int x, int y, char *string, int pos, double angle) { 8 // XXX need to pass the rot text color here 9 // static bDrawColor black; 10 // static bDrawColor white; 11 12 int bDrawRotText (bDrawBuffer *buffer, int x, int y, char *string, int pos, double angle) { 12 13 13 14 unsigned char *bitmap; … … 19 20 RotFont *currentfont; 20 21 21 white = KapaColorByName ("white");22 black = KapaColorByName ("black");22 // white = KapaColorByName ("white"); 23 // black = KapaColorByName ("black"); 23 24 24 25 currentname = GetRotFont (¤tsize); … … 111 112 X = x + (int)(Xoff*cs - Yoff*sn) + (int)(currentscale*currentfont[N].ascent*sn); 112 113 Y = y + (int)(Xoff*sn + Yoff*cs) - (int)(currentscale*currentfont[N].ascent*cs); 113 bDrawRotBitmap ( X, Y, dx, dy, bitmap, TRUE, angle, currentscale);114 bDrawRotBitmap (buffer, X, Y, dx, dy, bitmap, TRUE, angle, currentscale); 114 115 Xoff += 1 + (int)(currentscale*dx + 0.5); 115 116 } … … 118 119 } 119 120 120 int bDrawRotBitmap ( int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale) {121 int bDrawRotBitmap (bDrawBuffer *buffer, int x, int y, int dx, int dy, unsigned char *bitmap, int mode, double angle, double scale) { 121 122 122 123 int ii, jj, byte_line, byte, bit, flag; 123 bDrawColor color;124 124 double i, j, cs, sn, rscale, tmp; 125 125 int X, Y, X0, X1, X2, Y0, Y1, Y2, x0, y0; 126 126 127 127 /* this mode option is nort actually used... */ 128 if (mode) {129 color = black;130 } else {131 color = white;132 }128 // if (mode) { 129 // color = black; 130 // } else { 131 // color = white; 132 // } 133 133 134 134 byte_line = (int) ((dx + 7) / 8); … … 148 148 Y = YPROC (dx,0); 149 149 # ifdef DRAWBOXES 150 bDrawLine ( x+X, y+Y, x+X1, y+Y1);150 bDrawLine (buffer, x+X, y+Y, x+X1, y+Y1); 151 151 Xt = X; 152 152 Yt = Y; … … 160 160 Y = YPROC (dx,dy); 161 161 # ifdef DRAWBOXES 162 bDrawLine ( x+X, y+Y, x+Xt, y+Yt);162 bDrawLine (buffer, x+X, y+Y, x+Xt, y+Yt); 163 163 Xt = X; 164 164 Yt = Y; … … 172 172 Y = YPROC (0,dy); 173 173 # ifdef DRAWBOXES 174 bDrawLine ( x+X, y+Y, x+Xt, y+Yt);174 bDrawLine (buffer, x+X, y+Y, x+Xt, y+Yt); 175 175 Xt = X; 176 176 Yt = Y; … … 181 181 X2 = MAX (X, X2); 182 182 183 bDrawSetStyle (color, 0, 0);183 // bDrawSetStyle (color, 0, 0); 184 184 if (scale > 1) { 185 185 for (i = X1; i <= X2; i+=1) { … … 191 191 bit = ii % 8; 192 192 flag = 0x01 & (bitmap[byte] >> bit); 193 if (flag) bDrawPointf ( x + i, y + j);193 if (flag) bDrawPointf (buffer, x + i, y + j); 194 194 } 195 195 } … … 203 203 bit = ii % 8; 204 204 flag = 0x01 & (bitmap[byte] >> bit); 205 if (flag) bDrawPointf ( x + i, y + j);205 if (flag) bDrawPointf (buffer, x + i, y + j); 206 206 } 207 207 } 208 208 } 209 bDrawSetStyle (black, 0, 0);209 // bDrawSetStyle (black, 0, 0); 210 210 return (TRUE); 211 211 } -
trunk/Ohana/src/opihi/cmd.astro/region.c
r27435 r29938 55 55 if ((argc != 4) && (argc != 5)) { 56 56 gprint (GP_ERR, "USAGE: region Ra Dec Radius [projection] [orientation]\n"); 57 gprint (GP_ERR, " [-image] [-ew] [+ew] [-ns] [+ns] [-no-clear]\n"); 57 58 gprint (GP_ERR, " current: %f %f (%f x %f) (%s)\n", 58 59 graphmode.coords.crval1, graphmode.coords.crval2, -
trunk/Ohana/src/opihi/cmd.data/Makefile
r29540 r29938 36 36 $(SRC)/cut.$(ARCH).o \ 37 37 $(SRC)/delete.$(ARCH).o \ 38 $(SRC)/densify.$(ARCH).o \ 38 39 $(SRC)/device.$(ARCH).o \ 39 40 $(SRC)/dimendown.$(ARCH).o \ -
trunk/Ohana/src/opihi/cmd.data/init.c
r29540 r29938 25 25 int dbselect PROTO((int, char **)); 26 26 int delete PROTO((int, char **)); 27 int densify PROTO((int, char **)); 27 28 int device PROTO((int, char **)); 28 29 int dimendown PROTO((int, char **)); … … 161 162 {1, "dbselect", dbselect, "extract vectors from mysql database table"}, 162 163 {1, "delete", delete, "delete vectors or images"}, 164 {1, "densify", densify, "create an image histogram from a set of vectors"}, 163 165 {1, "device", device, "set / get current graphics device"}, 164 166 {1, "dimendown", dimendown, "convert image to vector"}, -
trunk/Ohana/src/opihi/cmd.data/rd.c
r28241 r29938 184 184 ftable.header[0].buffer = NULL; 185 185 gfits_copy_header (&buf[0].header, ftable.header); 186 status = gfits_fread_ftable_data (f, &ftable ); // this just reads the bytes (not even a SWAP)186 status = gfits_fread_ftable_data (f, &ftable, FALSE); // this just reads the bytes (not even a SWAP) 187 187 status = gfits_uncompress_image (&buf[0].header, &buf[0].matrix, &ftable); 188 188 // uncompressing the image leaves the format as an extension -
trunk/Ohana/src/opihi/cmd.data/read_vectors.c
r29540 r29938 160 160 161 161 off_t Nbytes; 162 int i, j, k, N, Nextend, Ny, Binary, vecType ;162 int i, j, k, N, Nextend, Ny, Binary, vecType, padIfShort; 163 163 char type[16], ID[80], *CCDKeyword; 164 164 FTable table; … … 174 174 CCDKeyword = strcreate (argv[N]); 175 175 remove_argument (N, &argc, argv); 176 } 177 178 padIfShort = FALSE; 179 if ((N = get_argument (argc, argv, "-pad-if-short"))) { 180 remove_argument (N, &argc, argv); 181 padIfShort = TRUE; 176 182 } 177 183 … … 205 211 } 206 212 if (!gfits_load_header (f, &header)) ESCAPE ("error reading header for extension"); 207 if (!gfits_fread_ftable_data (f, &table )) ESCAPE ("error reading table for extension");213 if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension"); 208 214 209 215 } else { … … 236 242 continue; 237 243 } 238 if (!gfits_fread_ftable_data (f, &table )) ESCAPE ("error reading table for extension");244 if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension"); 239 245 break; 240 246 } -
trunk/Ohana/src/opihi/cmd.data/resize.c
r13479 r29938 17 17 if (!GetImage (NULL, &kapa, name)) return (FALSE); 18 18 FREE (name); 19 20 if ((N = get_argument (argc, argv, "-by-image"))) { 21 remove_argument (N, &argc, argv); 22 KiiResizeByImage (kapa); 23 return (TRUE); 24 } 19 25 20 26 if (argc != 3) { -
trunk/Ohana/src/opihi/cmd.data/section.c
r27790 r29938 1 1 # include "data.h" 2 2 3 enum {NONE, LIST, UP, DOWN, TOP, BOTTOM, TOOL, BG };3 enum {NONE, LIST, UP, DOWN, TOP, BOTTOM, TOOL, BG, IMAGE}; 4 4 5 5 int section (int argc, char **argv) { … … 49 49 remove_argument (N, &argc, argv); 50 50 action = BG; 51 } 52 53 if ((N = get_argument (argc, argv, "-image"))) { 54 remove_argument (N, &argc, argv); 55 action = IMAGE; 51 56 } 52 57 … … 130 135 } 131 136 137 if (argc == 4) { 138 /* set section */ 139 section.name = argv[1]; 140 section.x = atof (argv[2]); 141 section.y = atof (argv[3]); 142 section.bg = background; 143 KapaSetSectionByImage (kapa, §ion); 144 return (TRUE); 145 } 146 132 147 if (argc == 6) { 133 148 /* set section */ … … 142 157 } 143 158 gprint (GP_ERR, "USAGE: section name [x y dx dy]\n"); 159 gprint (GP_ERR, "USAGE: section name [-image x y] : width based on current image\n"); 144 160 gprint (GP_ERR, "USAGE: section name [-list] [-up] [-down] [-top] [-bottom]\n"); 145 161 return (FALSE); -
trunk/Ohana/src/opihi/cmd.data/vgauss.c
r29001 r29938 45 45 CastVector (yvec, OPIHI_FLT); 46 46 CastVector (svec, OPIHI_FLT); 47 // XXX Cast is failing. 48 47 49 48 50 Npts = xvec[0].Nelements; -
trunk/Ohana/src/opihi/dvo/images.c
r28958 r29938 11 11 int images (int argc, char **argv) { 12 12 13 off_t i, Nimage ;13 off_t i, Nimage, Nmosaic; 14 14 int j, status, InPic, leftside, *plist, TimeSelect, ByName; 15 15 int WITH_MOSAIC, SOLO_MOSAIC, HIDDEN; 16 16 time_t tzero, tend; 17 int N, NPTS, n, npts, Npts, kapa ;17 int N, NPTS, n, npts, Npts, kapa, *foundMosaic; 18 18 Vector Xvec, Yvec; 19 19 double r[8], d[8], x[8], y[8], Rmin, Rmax, Rmid, trange, Radius; … … 35 35 36 36 SOLO_MOSAIC = FALSE; 37 foundMosaic = NULL; 37 38 if ((N = get_argument (argc, argv, "-mosaic"))) { 38 39 remove_argument (N, &argc, argv); … … 132 133 BuildChipMatch (image, Nimage); 133 134 135 if (SOLO_MOSAIC && photcode) { 136 ALLOCATE(foundMosaic, int, Nimage); 137 memset(foundMosaic, 0, Nimage*sizeof(int)); 138 } 139 134 140 Rmin = graphmode.coords.crval1 - 180.0; 135 141 Rmax = graphmode.coords.crval1 + 180.0; … … 137 143 138 144 int DistortImage = wordhash ("-DIS"); 145 int ChipImage = wordhash ("-WRP"); 139 146 int TriangleUp = wordhash ("TRP-"); 140 147 int TriangleDn = wordhash ("TRM-"); … … 150 157 if (ByName && strncmp (image[i].name, name, strlen(name))) continue; 151 158 if (TimeSelect && ((image[i].tzero < tzero) || (image[i].tzero+image[i].trate*image[i].NY > tzero + trange))) continue; 152 if (!FindMosaicForImage (image, Nimage, i)) continue; 159 if (!(Nmosaic = FindMosaicForImage (image, Nimage, i))) continue; 160 Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1 153 161 if (photcode) { 154 162 if ( photcodeEquiv && (photcode[0].code != GetPhotcodeEquivCodebyCode(image[i].photcode))) continue; … … 161 169 162 170 typehash = wordhash (&image[i].coords.ctype[4]); 171 172 if (photcode && SOLO_MOSAIC) { 173 // mosaic (DIS) images are not currently given a photcode : plot these via the WRP entries 174 /* DIS images represent a field, not a chip */ 175 if (typehash != ChipImage) continue; 176 if (foundMosaic[Nmosaic]) continue; 177 x[0] = -0.5*image[Nmosaic].NX; y[0] = -0.5*image[Nmosaic].NY; 178 x[1] = +0.5*image[Nmosaic].NX; y[1] = -0.5*image[Nmosaic].NY; 179 x[2] = +0.5*image[Nmosaic].NX; y[2] = +0.5*image[Nmosaic].NY; 180 x[3] = -0.5*image[Nmosaic].NX; y[3] = +0.5*image[Nmosaic].NY; 181 for (j = 0; j < Npts; j++) { 182 status = XY_to_RD (&r[j], &d[j], x[j], y[j], &image[Nmosaic].coords); 183 if (!status) break; 184 r[j] = ohana_normalize_angle (r[j]); 185 while (r[j] < Rmin) { r[j] += 360.0; } 186 while (r[j] > Rmax) { r[j] -= 360.0; } 187 if (j == 0) { 188 leftside = (r[j] < Rmid); 189 } 190 if (j > 0) { 191 if ( leftside && (r[j] > Rmid + 90)) { r[j] -= 360.0; } 192 if (!leftside && (r[j] < Rmid - 90)) { r[j] += 360.0; } 193 } 194 } 195 foundMosaic[Nmosaic] = TRUE; 196 goto plot_points; 197 } 163 198 164 199 /* DIS images represent a field, not a chip */ … … 270 305 if (Npts == 0) continue; 271 306 307 plot_points: 308 272 309 status = FALSE; 273 310 for (j = 0; j < Npts; j++) { … … 320 357 free (Yvec.elements.Flt); 321 358 FreeImages (image); 359 FREE (foundMosaic); 322 360 return (TRUE); 323 361 -
trunk/Ohana/src/opihi/dvo/imlist.c
r29540 r29938 104 104 XY_to_RD (&r, &d, 0.5*image[i].NX, 0.5*image[i].NY, &image[i].coords); 105 105 } 106 gprint (GP_LOG, "%3lld %s %8 .4f %8.4f %f %5d %2d %4.2f %5.3f %5.3f\n",107 (long long) i, image[i].name, r, d, t, image[i].nstar, image[i].photcode, image[i].secz, image[i].Mcal, image[i].dMcal);106 gprint (GP_LOG, "%3lld %s %8lld %8.4f %8.4f %f %5d %2d %4.2f %5.3f %5.3f\n", 107 (long long) i, image[i].name, (long long) image[i].imageID, r, d, t, image[i].nstar, image[i].photcode, image[i].secz, image[i].Mcal, image[i].dMcal); 108 108 } 109 109 -
trunk/Ohana/src/opihi/lib.data/starfuncs.c
r20936 r29938 5 5 double *ring; 6 6 double x, y, x2, y2, xy, I, sky, FWHMx, FWHMy, value, mag, Sxy; 7 int i, j, n, Npix2, Nring, Nmax;7 int i, j, n, Radius, Nring, Nmax; 8 8 double Npts, gain, dsky2, dmag, peak, offset; 9 9 char *string; … … 19 19 Nborder = MIN (1000, Nborder); 20 20 21 Npix2= (int)(0.5*Npix);22 Npix = 2 * Npix2+ 1;21 Radius = (int)(0.5*Npix); 22 Npix = 2 * Radius + 1; 23 23 Nring = 4*Nborder*(Nborder + Npix); 24 24 ALLOCATE (ring, double, Nring); … … 27 27 n = 0; 28 28 for (j = 0; j < Nborder; j++) { 29 for (i = X - Npix2 - Nborder; i < X + Npix2+ Nborder + 1; i++, n+=2) {30 ring[n] = gfits_get_matrix_value (matrix, i, (int)(Y - Npix2- j));31 ring[n+1] = gfits_get_matrix_value (matrix, i, (int)(Y + Npix2+ j));32 } 33 for (i = Y - Npix2; i < Y + Npix2+ 1; i++, n+=2) {34 ring[n] = gfits_get_matrix_value (matrix, (int)(X - Npix2- j), i);35 ring[n+1] = gfits_get_matrix_value (matrix, (int)(X + Npix2+ j), i);29 for (i = X - Radius - Nborder; i < X + Radius + Nborder + 1; i++, n+=2) { 30 ring[n] = gfits_get_matrix_value (matrix, i, (int)(Y - Radius - j)); 31 ring[n+1] = gfits_get_matrix_value (matrix, i, (int)(Y + Radius + j)); 32 } 33 for (i = Y - Radius; i < Y + Radius + 1; i++, n+=2) { 34 ring[n] = gfits_get_matrix_value (matrix, (int)(X - Radius - j), i); 35 ring[n+1] = gfits_get_matrix_value (matrix, (int)(X + Radius + j), i); 36 36 } 37 37 } … … 50 50 Npts = Nmax = 0; 51 51 x = y = x2 = y2 = xy = I = 0; 52 for (i = X - Npix2; i < X + Npix2 + 1; i++) { 53 for (j = Y - Npix2; j < Y + Npix2 + 1; j++) { 52 for (i = X - Radius; i < X + Radius + 1; i++) { 53 for (j = Y - Radius; j < Y + Radius + 1; j++) { 54 if (hypot((i-X), (j-Y)) > Radius) continue; 54 55 value = gfits_get_matrix_value (matrix, i, j); 55 56 offset = value - sky; … … 92 93 set_variable ("Zpk", peak); 93 94 set_int_variable ("Nsat", Nmax); 95 set_int_variable ("Npts", Npts); 94 96 95 97 gprint (GP_LOG, "%f %f %f %f %f %f %f %f\n", x, y, FWHMx, FWHMy, sky, I, mag, dmag); -
trunk/Ohana/src/photdbc/include/photdbc.h
r28331 r29938 114 114 int SetSignals (void); 115 115 int copy_images (char *outdir); 116 void usage(); -
trunk/Ohana/src/photdbc/src/args.c
r8630 r29938 61 61 } 62 62 63 if (argc != 2) { 64 fprintf (stderr, "USAGE: photdbc (output)\n"); 65 exit (2); 66 } 63 if (argc != 2) usage(); 67 64 68 65 if ((REGION.Rmin == 0) && (REGION.Rmax == 360) && (REGION.Dmin == -90) && (REGION.Dmax == +90)) { … … 80 77 } 81 78 82 /** 79 void usage() { 83 80 84 this program takes an existing DVO database and makes a copy, applying a number of optional 85 filters in the process. 86 87 photdbc (output) 88 89 allowed filters / restrictions include: 90 91 -region ra dec ra dec : limit operation to the specified region 92 -join : join measurements between stars using JOIN_RADIUS 93 -ccdregion X Y X Y : only keep detections within the specified detector region 94 (can this be limited to specific photcodes? cameras? detectors?) 95 -photcode_limits code Mmin Mmax : allow multiples of these 96 97 SIGMA_MAX 98 NMEAS_MIN 99 INST_MAG_MAX 100 INST_MAG_MIN 101 102 **/ 81 fprintf (stderr, "USAGE: photdbc (output)\n\n"); 82 fprintf (stderr, " this program takes an existing DVO database and makes a copy, applying a number of optional\n"); 83 fprintf (stderr, " filters in the process. \n"); 84 fprintf (stderr, "\n"); 85 fprintf (stderr, " photdbc (output)\n"); 86 fprintf (stderr, "\n"); 87 fprintf (stderr, " allowed filters / restrictions include:\n"); 88 fprintf (stderr, "\n"); 89 fprintf (stderr, " -region Rmin Rmax Dmin Dmax : limit operation to the specified region \n"); 90 fprintf (stderr, " -join : join measurements between stars using JOIN_RADIUS\n"); 91 fprintf (stderr, " -ccdregion X Y X Y : only keep detections within the specified detector region\n"); 92 fprintf (stderr, " (can this be limited to specific photcodes? cameras? detectors?)\n"); 93 fprintf (stderr, " -photcode_limits code Mmin Mmax : allow multiples of these\n"); 94 fprintf (stderr, "\n"); 95 fprintf (stderr, " SIGMA_MAX\n"); 96 fprintf (stderr, " NMEAS_MIN\n"); 97 fprintf (stderr, " INST_MAG_MAX\n"); 98 fprintf (stderr, " INST_MAG_MIN\n"); 99 exit (2); 100 } -
trunk/Ohana/src/photdbc/src/initialize.c
r4808 r29938 4 4 5 5 /* are these set correctly? */ 6 if (get_argument (argc, argv, "-h")) usage(); 7 if (get_argument (argc, argv, "--h")) usage(); 8 if (get_argument (argc, argv, "-help")) usage(); 9 if (get_argument (argc, argv, "--help")) usage(); 10 6 11 ConfigInit (&argc, argv); 7 12 args (argc, argv); -
trunk/Ohana/src/photdbc/src/join_stars.c
r28306 r29938 32 32 33 33 /* reference for coords is this region */ 34 Ncurr = 0; 34 35 Naves = 0; 35 36 Rmid = Dmid = 0; -
trunk/Ohana/src/relastro/src/GetAstromError.c
r27581 r29938 2 2 3 3 float GetAstromError (Measure *measure, int mode) { 4 4 //BIG HACKXXXXXXXX 5 return 0.1; 5 6 PhotCode *code; 6 7 float dPobs, dPsys, dPtotal, dM, AS, MS; 7 8 8 switch (mode) { 9 9 case ERROR_MODE_RA: … … 19 19 abort(); 20 20 } 21 22 21 /* the astrometric errors are not being carried yet (but should be!) */ 23 22 /* we use the photometric mag error as a weighting term */ … … 28 27 dPsys = code[0].astromErrSys; 29 28 dM = measure[0].dM; 30 31 29 dPtotal = sqrt(SQ(dPsys) + AS*SQ(dPobs) + MS*SQ(dM)); 32 30 … … 35 33 36 34 dPtotal = MAX (dPtotal, MIN_ERROR); 37 38 35 return (dPtotal); 39 36 } -
trunk/Ohana/src/relastro/src/UpdateObjects.c
r28241 r29938 54 54 memset (&fitPM, 0, sizeof(fitPM)); 55 55 memset (&fitPAR, 0, sizeof(fitPAR)); 56 57 56 initObjectData (catalog, Ncatalog); 58 57 … … 72 71 // use J2000 as a reference time 73 72 T2000 = ohana_date_to_sec ("2000/01/01"); 74 75 73 // XXX in the future, use catalog[0].Nsecfilt only? allow catalogs to have variable Nsecfilt? 76 74 Nsecfilt = GetPhotcodeNsecfilt (); … … 97 95 N = 0; 98 96 m = catalog[i].average[j].measureOffset; 99 100 97 Tmin = Tmax = (catalog[i].measure[m].t - T2000) / (86400*365.25); 101 98 mode = FIT_MODE; … … 137 134 138 135 // dX, dY : error in arcsec -- 139 dX[N] = GetAstromError (&catalog[i].measure[m], ERROR_MODE_RA); 140 dY[N] = GetAstromError (&catalog[i].measure[m], ERROR_MODE_DEC); 136 // dX[N] = GetAstromError (&catalog[i].measure[m], ERROR_MODE_RA); 137 // dY[N] = GetAstromError (&catalog[i].measure[m], ERROR_MODE_DEC); 138 139 dX[N] = 0.1; 140 dY[N] = 0.1; 141 141 dT[N] = catalog[i].measure[m].dt; 142 142 … … 145 145 // non-circular errors (different values for X and Y), then dR and dD will be 146 146 // incorrect: they would need to be rotated to take out the position angle 147 dR[ k] = dX[k] / 3600.0;148 dD[ k] = dY[k] / 3600.0;147 dR[N] = dX[N] / 3600.0; 148 dD[N] = dY[N] / 3600.0; 149 149 150 150 N++; … … 194 194 195 195 FitPM (&fitPM, X, dX, Y, dY, T, N); 196 196 197 if (XVERB) fprintf (stderr, "fitted: %f - %f : %f %f : %f %f : %f vs %f\n", Tmin, Tmax, fitPM.Ro, fitPM.Do, fitPM.uR, fitPM.uD, fitPM.chisq, fitAve.chisq); 197 198 … … 244 245 245 246 switch (result) { 246 case FIT_AVERAGE: 247 catalog[i].average[j].flags |= ID_STAR_USE_AVE; 248 fit = fitAve; 249 break; 250 case FIT_PM_ONLY: 251 catalog[i].average[j].flags |= ID_STAR_USE_PM; 252 fit = fitPM; 253 break; 254 case FIT_PM_AND_PAR: 255 catalog[i].average[j].flags |= ID_STAR_USE_PAR; 256 fit = fitPAR; 257 break; 258 } 259 260 if (XVERB) fprintf (stderr, "%f %f -> %f %f (%f,%f)\n", 247 case FIT_AVERAGE: 248 catalog[i].average[j].flags |= ID_STAR_USE_AVE; 249 fit = fitAve; 250 break; 251 case FIT_PM_ONLY: 252 catalog[i].average[j].flags |= ID_STAR_USE_PM; 253 fit = fitPM; 254 break; 255 case FIT_PM_AND_PAR: 256 catalog[i].average[j].flags |= ID_STAR_USE_PAR; 257 fit = fitPAR; 258 break; 259 } 260 if (XVERB) fprintf (stderr, "A%f %f -> %f %f (%f,%f) pm=(%f %f)\n", 261 261 catalog[i].average[j].R, 262 262 catalog[i].average[j].D, 263 263 fit.Ro, fit.Do, 264 264 3600*(catalog[i].average[j].R - fit.Ro), 265 3600*(catalog[i].average[j].D - fit.Do)); 265 3600*(catalog[i].average[j].D - fit.Do), 266 fit.uR, 267 fit.uD); 266 268 267 269 //make sure that the fit succeeded 268 status = finite(fit.Ro); 270 status = TRUE; 271 status &= finite(fit.Ro); 269 272 status &= finite(fit.Do); 270 273 status &= finite(fit.dRo); … … 310 313 catalog[i].average[j].Trange = (Trange * 86400 * 365.26); 311 314 catalog[i].average[j].Npos = fit.Nfit; 315 if (XVERB) fprintf (stderr, "%f %f -> %f %f (%f,%f) pm=(%f %f)\n", 316 catalog[i].average[j].R, 317 catalog[i].average[j].D, 318 fit.Ro, fit.Do, 319 3600*(catalog[i].average[j].R - fit.Ro), 320 3600*(catalog[i].average[j].D - fit.Do), 321 catalog[i].average[j].uR, 322 catalog[i].average[j].uD); 323 312 324 } 313 325 -
trunk/Ohana/src/relastro/src/high_speed_objects.c
r28811 r29938 13 13 // XXX seems silly to require region here just to find the catalog bounds / center 14 14 15 off_t i, j, m, J, ni, nj, *N1, Nslow, Ninvalid, NgroupA, NgroupB, NgroupAbad, NgroupBbad ;16 int *slowMoving, *groupA, *groupB, status, foundA, foundB, Nmatch, valid ;15 off_t i, j, m, J, ni, nj, *N1, Nslow, Ninvalid, NgroupA, NgroupB, NgroupAbad, NgroupBbad,l,i1,Noff,Nmeasure,Naverage, NAVERAGE, NMEASURE; 16 int *slowMoving, *groupA, *groupB, status, foundA, foundB, Nmatch, valid,Nmatchmeas,Nepoch,nv[2],Nmatchmeasobj; 17 17 double *X1, *Y1; 18 double dX, dY, dR, RADIUS2 , yJ;18 double dX, dY, dR, RADIUS2; 19 19 Coords tcoords; 20 Catalog catalog1; 20 21 21 22 int zcode, zNsec, ycode, yNsec, jcode, jNsec, hcode, hNsec, kcode, kNsec, USNO_R, USNO_N, Nsecfilt; 23 char filename[1024]; 24 char outdir[]="/data/ipp022.0/ndeacon/hispeedzy"; 25 Noff = strlen(CATDIR); 26 sprintf (filename, "%s/%s", outdir, &catalog[0].filename[Noff]); 27 dvo_catalog_init(&catalog1, TRUE); /*initialise new catalogue*/ 28 catalog1.filename = strcreate(filename); 29 30 SIGMA_LIM = 0.0; 22 31 23 32 Nsecfilt = GetPhotcodeNsecfilt(); 33 Naverage=catalog[0].Naverage; 34 Nmeasure=catalog[0].Nmeasure; 35 // ALLOCATE (catalog1.average, Average,Naverage); 36 // ALLOCATE (catalog1.measure, Measure,Nmeasure); 37 // ALLOCATE(catalog1.secfilt, SecFilt,catalog[0].Naverage*Nsecfilt); 38 catalog1.filename = filename; // based on the input name, need to keep everything below the catdir portion 39 catalog1.Nsecfilt = Nsecfilt; 40 // always load all of the data (if any exists) 41 catalog1.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF; 42 43 catalog1.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 44 catalog1.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 45 46 if (!dvo_catalog_open (&catalog1, region, VERBOSE,"w")) { 47 fprintf (stderr, "ERROR: failure to open catalog file %s\n", 48 filename); 49 exit (2); 50 } 51 52 NAVERAGE = 1000; 53 NMEASURE = 10000; 54 REALLOCATE (catalog1.average, Average, NAVERAGE); 55 REALLOCATE (catalog1.measure, Measure, NMEASURE); 56 REALLOCATE(catalog1.secfilt, SecFilt, NAVERAGE*Nsecfilt); 24 57 25 58 ycode = GetPhotcodeCodebyName("y"); … … 67 100 NgroupBbad = 0; 68 101 69 fprintf (stdout, "# RA_A DEC_A RA_B DEC_B : pmx pmy dR : z dz y dy J dJ H dH K dK\n");102 fprintf (stdout, "# RA_A DEC_A RA_B DEC_B : pmx pmy dR dt: z dz y dy J dJ H dH K dK\n"); 70 103 //................270.2346670 20.2471540 270.2170434 20.2717396 : -59.11 88.78 106.66 : 0.000 0.000 19.582 0.112 16.041 0.110 15.388 0.098 14.858 0.001 71 104 … … 88 121 foundA = FALSE; 89 122 for (j = 0; !foundA && (j < catalog[0].average[i].Nmeasure); j++, m++) { 123 if((catalog[0].average[i].R>204.1923)&&(catalog[0].average[i].R<204.1924)&&(catalog[0].average[i].D>11.376)&&(catalog[0].average[i].D<11.377)) 124 { 125 printf("Hello"); 126 } 127 90 128 if (MeasMatchesPhotcode(&catalog[0].measure[m], photcodesGroupA, NphotcodesGroupA)) { 91 129 foundA = TRUE; … … 97 135 foundB = FALSE; 98 136 for (j = 0; !foundB && (j < catalog[0].average[i].Nmeasure); j++, m++) { 137 138 if((catalog[0].average[i].R>204.192)&&(catalog[0].average[i].R<204.1925)&&(catalog[0].average[i].D>11.376)&&(catalog[0].average[i].D<11.377)) 139 { 140 printf("Hello"); 141 } 142 99 143 if (MeasMatchesPhotcode(&catalog[0].measure[m], photcodesGroupB, NphotcodesGroupB)) { 100 144 foundB = TRUE; … … 114 158 if (foundA && !foundB) { 115 159 // average-based tests: 160 161 if((catalog[0].average[i].R>204.1923)&&(catalog[0].average[i].R<204.1924)&&(catalog[0].average[i].D>11.376)&&(catalog[0].average[i].D<11.377)) 162 { 163 printf("Hello"); 164 } 165 116 166 valid = TRUE; 117 valid &= ((catalog[0].average[i].flags & 0x 40000) == 0);118 valid &= ((catalog[0].average[i].flags & 0x 80000) > 0);119 valid &= ( catalog[0].secfilt[i*Nsecfilt + yNsec].M < 1.0);120 valid &= ( catalog[0].secfilt[i*Nsecfilt + zNsec].M < 1.0);167 valid &= ((catalog[0].average[i].flags & 0x02000000) == 0); 168 valid &= ((catalog[0].average[i].flags & 0x08000000) > 0); 169 valid &= ((catalog[0].secfilt[i*Nsecfilt + yNsec].M < 1.0)||(isnan(catalog[0].secfilt[i*Nsecfilt + yNsec].M))); 170 valid &= (((catalog[0].secfilt[i*Nsecfilt + zNsec].M < 1.0))||(isnan(catalog[0].secfilt[i*Nsecfilt + zNsec].M))); 121 171 // XXX color restrictions are applied in the pair-wise matching below 122 172 123 173 // measure-based tests: 124 m = catalog[0].average[i].measureOffset;174 /* m = catalog[0].average[i].measureOffset; 125 175 for (j = 0; valid && (j < catalog[0].average[i].Nmeasure); j++, m++) { 126 176 if (catalog[0].measure[m].photcode == USNO_R) { … … 130 180 valid &= ((catalog[0].measure[m].M > 18.0) || isnan(catalog[0].measure[m].M)); 131 181 } 132 } 182 }*/ 133 183 134 184 // ((objflags & 524288) == 524288) && … … 154 204 155 205 // average-based tests: 206 if((catalog[0].average[i].R>204.192)&&(catalog[0].average[i].R<204.193)&&(catalog[0].average[i].D>11.372)&&(catalog[0].average[i].D<11.373)) 207 { 208 printf("Hello"); 209 } 156 210 valid = TRUE; 157 valid &= ((catalog[0].average[i].flags & 0x10000) == 0); 158 valid &= ((catalog[0].average[i].flags & 0x20000) > 0); 159 valid &= (catalog[0].secfilt[i*Nsecfilt + jNsec].M < 1.0); 211 valid &= ((catalog[0].average[i].flags & 0x01000000) == 0); 212 213 valid &= ((catalog[0].average[i].flags & 0x04000000) > 0); 214 215 valid &= ((catalog[0].secfilt[i*Nsecfilt + jNsec].M < 1.0)||(isnan(catalog[0].secfilt[i*Nsecfilt + jNsec].M))); 160 216 valid &= (catalog[0].secfilt[i*Nsecfilt + yNsec].Nused > 1); 161 217 valid &= (catalog[0].secfilt[i*Nsecfilt + yNsec].dM < 0.2); 162 218 163 if ((catalog[0].secfilt[i*Nsecfilt + zNsec].M < 1.0) || (catalog[0].secfilt[i*Nsecfilt + zNsec].Nused == 1)) {219 /*if ((catalog[0].secfilt[i*Nsecfilt + zNsec].M < 1.0) || (catalog[0].secfilt[i*Nsecfilt + zNsec].Nused == 1)) { 164 220 valid &= TRUE; 165 221 } else { 166 222 valid &= ((catalog[0].secfilt[i*Nsecfilt + zNsec].M - catalog[0].secfilt[i*Nsecfilt + yNsec].M) > 0.2); 167 } 223 }*/ 168 224 169 225 // measure-based tests: 170 m = catalog[0].average[i].measureOffset;226 /*m = catalog[0].average[i].measureOffset; 171 227 for (j = 0; valid && (j < catalog[0].average[i].Nmeasure); j++, m++) { 172 228 if (catalog[0].measure[m].photcode == USNO_R) { … … 176 232 valid &= ((catalog[0].measure[m].M > 18.5) || isnan(catalog[0].measure[m].M)); 177 233 } 178 } 234 }*/ 179 235 180 236 // (abs(glat)>15.0) && … … 236 292 237 293 Nmatch = 0; 294 Nmatchmeas = 0; 238 295 RADIUS2 = SQ(RADIUS); 239 296 … … 243 300 ni = N1[i]; 244 301 nj = N1[j]; 245 246 302 // if (ni == 131030) { 247 303 // fprintf (stderr, "got 2mass\n"); … … 268 324 269 325 // within match range; look for valid matches 270 for (J = j; (dX > -1.02*RADIUS) && (J < catalog[0].Naverage); J++) { 326 for (J = j; (dX > -1.02*RADIUS) && (J < catalog[0].Naverage); J++) { 271 327 if (J == i) continue; // avoid auto-matches 272 328 … … 281 337 282 338 // y_groupA - J_groupB 283 yJ = catalog[0].secfilt[nj*Nsecfilt + yNsec].M - catalog[0].secfilt[ni*Nsecfilt + jNsec].M; 339 340 /* yJ = catalog[0].secfilt[nj*Nsecfilt + yNsec].M - catalog[0].secfilt[ni*Nsecfilt + jNsec].M; 284 341 if (yJ < 1.25) continue; 285 if (yJ > 5.0) continue; 342 if (yJ > 5.0) continue;*/ 286 343 287 344 /*** a match is found (just print it for the moment) ***/ 345 /*Define a vector of matched indices and set averages in new catalogue*/ 346 Nepoch=2; 347 FIT_MODE = FIT_PM_ONLY; 348 /*nv=(int *)malloc(Nepoch*sizeof(int));*/ 349 nv[0]=ni; /*THESE SHOULD BE CHANGED FOR MULTIPLE EPOCHS AS SHOULD nv*/ 350 nv[1]=nj; 351 352 catalog1.average[Nmatch]=catalog[0].average[nv[0]]; 353 /*Loop over index values and set measurements in new catalogue*/ 354 Nmatchmeasobj=0; 355 catalog1.average[Nmatch].measureOffset=Nmatchmeas; 356 for(l=0;l<Nepoch;l++) { 357 m = catalog[0].average[nv[l]].measureOffset; 358 for(i1=0;i1<catalog[0].average[nv[l]].Nmeasure;i1++) { 359 catalog1.measure[Nmatchmeas]=catalog[0].measure[m+i1]; 360 /*Set offset RA and Dec wrt correct average value*/ 361 catalog1.measure[Nmatchmeas].dR=catalog[0].measure[m+i1].dR+3600.0*(catalog[0].average[nv[0]].R-catalog[0].average[nv[l]].R); 362 catalog1.measure[Nmatchmeas].dD=catalog[0].measure[m+i1].dD+3600.0*(catalog[0].average[nv[0]].D-catalog[0].average[nv[l]].D); 363 catalog1.measure[Nmatchmeas].averef = Nmatch; 364 Nmatchmeasobj++; 365 Nmatchmeas++; 366 367 if (Nmatchmeas == NMEASURE - 1) { 368 NMEASURE += 10000; 369 REALLOCATE (catalog1.measure, Measure, NMEASURE); 370 } 371 } 372 } 373 catalog1.average[Nmatch].Nmeasure=Nmatchmeasobj; 288 374 Nmatch ++; 289 375 376 if (Nmatch == NAVERAGE - 1) { 377 NAVERAGE += 1000; 378 REALLOCATE (catalog1.average, Average, NAVERAGE); 379 REALLOCATE(catalog1.secfilt, SecFilt, NAVERAGE*Nsecfilt); 380 } 290 381 // for the moment, just write the matches to stdout: 291 float pmx = -dX; // proper-motion displacement in ra direction (B - A) [arcsec]292 float pmy = -dY; // proper-motion displacement in dec direction (B - A) [arcsec]293 fprintf (stdout, "%11.7f %11.7f %11.7f %11.7f : %7.2f %7.2f %7.2f: %7.3f %6.3f %7.3f %6.3f %7.3f %6.3f %7.3f %6.3f %7.3f %6.3f\n",382 //float pmx = -dX; // proper-motion displacement in ra direction (B - A) [arcsec] 383 //float pmy = -dY; // proper-motion displacement in dec direction (B - A) [arcsec] 384 /* fprintf (stdout, "%11.7f %11.7f %11.7f %11.7f : %7.2f %7.2f %7.2f: %7.3f %6.3f %7.3f %6.3f %7.3f %6.3f %7.3f %6.3f %7.3f %6.3f\n", 294 385 catalog[0].average[ni].R, catalog[0].average[ni].D, 295 386 catalog[0].average[nj].R, catalog[0].average[nj].D, 296 pmx, pmy, sqrt(dR),387 dX, dY, sqrt(dR), 297 388 catalog[0].secfilt[nj*Nsecfilt + zNsec].M, 298 389 catalog[0].secfilt[nj*Nsecfilt + zNsec].dM, … … 304 395 catalog[0].secfilt[ni*Nsecfilt + hNsec].dM, 305 396 catalog[0].secfilt[ni*Nsecfilt + kNsec].M, 306 catalog[0].secfilt[ni*Nsecfilt + kNsec].dM); 397 catalog[0].secfilt[ni*Nsecfilt + kNsec].dM);*/ 307 398 } 308 399 i++; 309 400 } 401 catalog1.Naverage=Nmatch; 402 catalog1.Nmeasure=Nmatchmeas; 403 catalog1.Nsecfilt=Nsecfilt; 404 catalog1.Nsecf_mem=Nmatch*Nsecfilt; 405 406 UpdateObjects(&catalog1, 1); 407 310 408 fprintf (stderr, "found %d matches\n", Nmatch); 311 409 dvo_catalog_save (&catalog1, VERBOSE); 410 dvo_catalog_unlock (&catalog1); 411 dvo_catalog_free (&catalog1); 312 412 free (slowMoving); 313 413 free (groupA); -
trunk/Ohana/src/tools/Makefile
r20983 r29938 17 17 PROGRAMS = gconfig fhead ftable fields list_astro glockfile \ 18 18 radec mktemp precess csystem fits_insert \ 19 medianfilter mefhead ckfits 19 medianfilter mefhead ckfits roc 20 20 21 21 all tools: $(PROGRAMS)
Note:
See TracChangeset
for help on using the changeset viewer.
