Changeset 3389
- Timestamp:
- Mar 7, 2005, 6:15:46 PM (21 years ago)
- Location:
- trunk/Ohana/src
- Files:
-
- 1 added
- 12 edited
-
addstar/Makefile (modified) (2 diffs)
-
addstar/include/addstar.h (modified) (1 diff)
-
addstar/src/args.c (modified) (5 diffs)
-
addstar/src/find_matches.c (modified) (5 diffs)
-
addstar/src/gimages.c (modified) (6 diffs)
-
addstar/src/gregion_image.c (modified) (1 diff)
-
addstar/src/gstars.c (modified) (1 diff)
-
libohana/Makefile (modified) (1 diff)
-
libohana/doc/ChangeLog.txt (modified) (1 diff)
-
libohana/doc/coordtrans.txt (modified) (1 diff)
-
libohana/include/loneos.h (modified) (2 diffs)
-
libohana/src/coordops.c (modified) (8 diffs)
-
libohana/src/mosaic_astrom.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/Makefile
r3376 r3389 1 #install: 2 # @echo "addstar under re-construction" 1 3 default: addstar 2 4 help: … … 110 112 # utilities ################################################# 111 113 112 install:114 # install: 113 115 for i in $(INSTALL); do make $$i.install; done 114 116 -
trunk/Ohana/src/addstar/include/addstar.h
r3376 r3389 62 62 PhotCode *thiscode; 63 63 GSCRegion UserPatch; 64 Coords *MOSAIC; 64 65 65 66 char DateKeyword[64]; -
trunk/Ohana/src/addstar/src/args.c
r3376 r3389 14 14 int args (int argc, char **argv) { 15 15 16 int i,N;16 int N; 17 17 18 18 /* check for help request */ … … 61 61 /* provide a time for dataset */ 62 62 TIMEREF = 0; 63 if (( i= get_argument (argc, argv, "-time"))) {64 remove_argument ( i, &argc, argv);65 if (!str_to_time (argv[ i], &TIMEREF)) {63 if ((N = get_argument (argc, argv, "-time"))) { 64 remove_argument (N, &argc, argv); 65 if (!str_to_time (argv[N], &TIMEREF)) { 66 66 fprintf (stderr, "syntax error in time\n"); 67 67 exit (1); 68 68 } 69 remove_argument (i, &argc, argv); 69 remove_argument (N, &argc, argv); 70 } 71 /* provide a mosaic for distortion */ 72 MOSAIC = NULL; 73 if ((N = get_argument (argc, argv, "-mosaic"))) { 74 Header header; 75 ALLOCATE (MOSAIC, Coords, 1); 76 77 remove_argument (N, &argc, argv); 78 if (!fits_read_header (argv[N], &header)) { 79 fprintf (stderr, "ERROR: can't read header for mosaic %s\n", argv[N]); 80 exit (1); 81 } 82 if (!GetCoords (MOSAIC, &header)) { 83 fprintf (stderr, "ERROR: no astrometric solution in header\n"); 84 exit (1); 85 } 86 if (strcmp(&MOSAIC[0].ctype[4], "-DIS")) { 87 fprintf (stderr, "ERROR: not a mosaic distortion header\n"); 88 exit (1); 89 } 90 remove_argument (N, &argc, argv); 91 fits_free_header (&header); 70 92 } 71 93 … … 73 95 /* only add to existing objects */ 74 96 ONLY_MATCH = FALSE; 75 if (( i= get_argument (argc, argv, "-only-match"))) {97 if ((N = get_argument (argc, argv, "-only-match"))) { 76 98 ONLY_MATCH = TRUE; 77 remove_argument ( i, &argc, argv);99 remove_argument (N, &argc, argv); 78 100 } 79 101 /* don't add missed pts to Missed table (image only) */ … … 85 107 /* replace measurement, don't duplicate (ref/cat only) */ 86 108 REPLACE = FALSE; 87 if (( i= get_argument (argc, argv, "-replace"))) {109 if ((N = get_argument (argc, argv, "-replace"))) { 88 110 REPLACE = TRUE; 89 remove_argument ( i, &argc, argv);111 remove_argument (N, &argc, argv); 90 112 } 91 113 /* only add image potion to image table */ … … 133 155 fprintf (stderr, "USAGE: addstar -ref (filename)\n"); 134 156 fprintf (stderr, " cur: %s ", argv[0]); 135 for ( i = 0; i < argc; i++) { fprintf (stderr, "%s ", argv[i]); }157 for (N = 0; N < argc; N++) { fprintf (stderr, "%s ", argv[N]); } 136 158 fprintf (stderr, "\n"); 137 159 exit (2); -
trunk/Ohana/src/addstar/src/find_matches.c
r3376 r3389 49 49 REALLOCATE (catalog[0].missing, Missing, NMISS); 50 50 51 /* project onto rectilinear grid with 1 arcsec pixels, sort by X */ 52 /* reference for coords is this image */ 53 tcoords = image[0].coords; 54 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 55 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 56 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 57 strcpy (tcoords.ctype, "RA---TAN"); 58 51 /* project onto rectilinear grid with 1 arcsec pixels */ 52 /* we keep the original crpix1,2 and crref1,2 */ 53 /* for mosaic astrometry, the grid should be w.r.t. the tangent-plane, not chip coords */ 54 if (!strcmp (&image[0].coords.ctype[4], "-WRP")) { 55 tcoords = MOSAIC[0]; 56 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 57 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 58 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 59 tcoords.Npolyterms = 1; 60 strcpy (tcoords.ctype, "RA---TAN"); 61 } else { 62 tcoords = image[0].coords; 63 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 64 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 65 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 66 strcpy (tcoords.ctype, "RA---TAN"); 67 } 68 59 69 for (i = 0; i < Nstars; i++) { 60 70 fRD_to_XY (&X1[i], &Y1[i], stars[i].R, stars[i].D, &tcoords); … … 134 144 /* calculate accurate per-star airmass */ 135 145 secz = airmass (image[0].secz, stars[N].R, stars[N].D, SiderealTime, Latitude); 136 137 146 138 147 /** add measurements for this star **/ … … 162 171 if (*Mval == NO_MAG) *Mval = Mrel; 163 172 173 /** this is a little tricky: the new measures are not in the measure sequence 174 this call can run into the next star if we have had two measures found at this location. **/ 164 175 if (CALIBRATE) { 165 /** this is a little tricky: the new measures are not in the measure sequence166 this call can run into the next star if we have had two measures found at this location. **/167 176 AddToCalibration (&catalog[0].average[n], &catalog[0].measure[m], &catalog[0].measure[Nmeas], N); 168 177 } … … 202 211 203 212 /* add reference for undetected catalog stars */ 213 if (!strcmp (&image[0].coords.ctype[4], "-WRP")) RegisterMosaic (MOSAIC); 204 214 for (j = 0; (j < Nave) && !SKIP_MISSED; j++) { 205 215 n = N2[j]; … … 287 297 /** now add references from all previous non-detection observations of this spot on the sky */ 288 298 for (j = 0; (j < Noverlap) && !SKIP_MISSED; j++) { 299 if (!FindMosaicForImage (overlap, Noverlap, j)) continue; 289 300 if (!in_image (catalog[0].average[Nave].R, catalog[0].average[Nave].D, &overlap[j])) continue; 290 301 if (catalog[0].average[Nave].Nn < 1) { -
trunk/Ohana/src/addstar/src/gimages.c
r3376 r3389 38 38 /* project onto rectilinear grid with 1 arcsec pixels */ 39 39 /* we keep the original crpix1,2 and crref1,2 */ 40 tcoords = image[0].coords; 41 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 42 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 43 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 44 strcpy (tcoords.ctype, "RA---TAN"); 40 /* for mosaic astrometry, the grid should be w.r.t. the tangent-plane, not chip coords */ 41 if (!strcmp (&image[0].coords.ctype[4], "-WRP")) { 42 tcoords = MOSAIC[0]; 43 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 44 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 45 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 46 tcoords.Npolyterms = 1; 47 strcpy (tcoords.ctype, "RA---TAN"); 48 RegisterMosaic (MOSAIC); 49 /* register so image->sky conversions below have correct mosaic */ 50 } else { 51 tcoords = image[0].coords; 52 tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0; 53 tcoords.pc1_1 = tcoords.pc2_2 = 1.0; 54 tcoords.pc1_2 = tcoords.pc2_1 = 0.0; 55 strcpy (tcoords.ctype, "RA---TAN"); 56 } 45 57 46 58 /* define original corners */ … … 51 63 Xo[4] = 0; Yo[4] = 0; /* so we can make a loop easily */ 52 64 for (j = 0; j < 5; j++) { 65 /* XY-to_RD is two-level if ctype == WRP */ 53 66 XY_to_RD (&r, &d, Xo[j], Yo[j], &image[0].coords); 54 67 RD_to_XY (&Xo[j], &Yo[j], r, d, &tcoords); … … 77 90 } 78 91 79 NTIMAGE = 100; 92 /* kind of dangerous, see note below */ 93 NTIMAGE = MAX (MIN (Nimage, 1000), 1); 80 94 ALLOCATE (timage, Image, NTIMAGE); 81 95 … … 87 101 for (Ntimage = 0; Ntimage < Nimage; Ntimage += ntimage) { 88 102 ntimage = Fread (timage, sizeof(Image), NTIMAGE, f, "image"); 103 if (ntimage == 0) Shutdown ("expected %d images, only found %d", Nimage, Ntimage); 104 BuildChipMatch (timage, ntimage); 105 89 106 for (i = 0; i < ntimage; i++) { 107 108 /* if any of these images are WRP images, need to find matching DIS */ 109 if (!FindMosaicForImage (timage, ntimage, i)) { 110 fprintf (stderr, "!"); 111 continue; 112 } 113 90 114 addtolist = FALSE; 91 115 /* define image corners */ … … 116 140 } 117 141 } 142 } 118 143 119 if (ntimage == 0) { 120 Shutdown ("expected %d images, only found %d", Nimage, Ntimage); 121 } 122 } 144 BuildChipMatch (pimage, npimage); 123 145 124 146 if (VERBOSE) fprintf (stderr, "found %d overlapping images\n", npimage); … … 129 151 } 130 152 153 /* this function tries to find overlapping images with the current image. 154 it loads the image table in blocks (up to 1000 at a time) and looks 155 for overlaps within the set. the search is not very robust. in 156 addition, it needs to look for mosaic DIS images matching any WRP images. 157 if the WRP image is loaded near the beginning of a block, then the corresponding DIS 158 may be in the previous block, and thus missed 159 */ -
trunk/Ohana/src/addstar/src/gregion_image.c
r3376 r3389 12 12 impatch.DEC[0] = +90; 13 13 impatch.DEC[1] = -90; 14 15 if (!strcmp (&image[0].coords.ctype[4], "-WRP")) { 16 if (MOSAIC == NULL) Shutdown ("no mosaic for WRP image (use -mosaic)"); 17 RegisterMosaic (MOSAIC); 18 } 14 19 15 20 for (x = 0; x <= 1; x++) { -
trunk/Ohana/src/addstar/src/gstars.c
r3361 r3389 52 52 exit (1); 53 53 } 54 if (!strcmp (&image[0].coords.ctype[4], "-WRP")) { 55 if (MOSAIC == NULL) { 56 fprintf (stderr, "ERROR: no mosaic for WRP image (use -mosaic)\n"); 57 exit (1); 58 } 59 RegisterMosaic (MOSAIC); 60 } 54 61 55 62 /* get ST (used for airmass calculation) */ -
trunk/Ohana/src/libohana/Makefile
r2833 r3389 28 28 $(SRC)/Fread.$(ARCH).o $(SRC)/glockfile.$(ARCH).o \ 29 29 $(SRC)/LoadPhotcodes.$(ARCH).o $(SRC)/photfits.$(ARCH).o \ 30 $(SRC)/phot_catalog.$(ARCH).o $(SRC)/imreg_datatypes.$(ARCH).o 30 $(SRC)/phot_catalog.$(ARCH).o $(SRC)/imreg_datatypes.$(ARCH).o \ 31 $(SRC)/mosaic_astrom.$(ARCH).o 31 32 32 33 $(DESTLIB)/libohana.a: $(LIB)/libohana.$(ARCH).a -
trunk/Ohana/src/libohana/doc/ChangeLog.txt
r3260 r3389 1 2 changed meaning of PLY / WRP / DIS (see coordtrans.txt) 3 added check on ALLOCATE/REALLOCATE to avoid failures on Nvalues < 1 4 5 libohana-1-2 6 added 'STG' to allowed coordinate transforms (inaccurate & stop-gap) 7 set default Npolyterms to 1 8 initialized filemode in glockfile.c 1 9 2 10 libohana-1-1 -
trunk/Ohana/src/libohana/doc/coordtrans.txt
r2413 r3389 1 2 I have changed the meaning of coord type PLY from the historical 3 meaning. The only previous use that is in a DVO-style database is in 4 the loneos data (all cfht data needed to go to linear terms). these 5 can be easily converted by changing from PLY to DIS. 6 7 There are now three types of higher-order transformation which may be 8 used depending on the circumstance. The new naming scheme is: 9 10 PLY : a cartesian transformation (ie, no projection implied) 11 DIS : equivalent to TAN projection with up-to-3rd order polynomial 12 WRP : a second-level cartesian transformation, implying the presence 13 of a DIS coord frame (must be registered with libohana function) 1 14 2 15 { -
trunk/Ohana/src/libohana/include/loneos.h
r3363 r3389 410 410 int fRD_to_XY (float *x, float *y, double ra, double dec, Coords *coords); 411 411 int GetCoords (Coords *coords, Header *header); 412 int PutCoords (Coords *coords, Header *header); 413 void RegisterMosaic (Coords *coords); 414 void coords_precess (double *ra, double *dec, double in_epoch, double out_epoch); 415 412 416 short int putMi (double value); 413 417 double getMi (short int value); … … 458 462 void ParseColorTerms (char *terms, float *X, int *N); 459 463 460 void coords_precess (double *ra, double *dec, double in_epoch, double out_epoch);461 462 464 int get_image_type (char *name); 463 465 char *get_type_name (int type); -
trunk/Ohana/src/libohana/src/coordops.c
r3371 r3389 2 2 # include <loneos.h> 3 3 4 static Coords *mosaic = NULL; 5 6 void RegisterMosaic (Coords *coords) { 7 mosaic = coords; 8 } 9 4 10 int XY_to_RD (double *ra, double *dec, double x, double y, Coords *coords) { 5 11 6 int Polynomial, Zenithal, Cartesian, PseudoCyl;12 int Zenith1, Zenith2, Zenithal, Polynomial, Cartesian, PseudoCyl; 7 13 char *type; 8 14 double L, M, X, Y, T, Z; … … 15 21 type = &coords[0].ctype[4]; 16 22 17 /* DIS and PLY are identical & apply projection; WRP is cartesian */ 23 /* DIS is equiv to TAN with higher order terms 24 PLY is cartesian with higher order terms 25 WRP is equiv to PLY, with implied mosaic */ 26 18 27 Polynomial = !strcmp(type, "-PLY") || !strcmp(type, "-DIS") || !strcmp(type, "-WRP"); 19 Zenithal = !strcmp(type, "-PLY") || !strcmp(type, "-DIS") || !strcmp(type, "-TAN") || !strcmp(type, "-SIN") || !strcmp(type, "-STG") || !strcmp(type, "-ZEA") || !strcmp(&coords[0].ctype[0], "MM"); 20 Cartesian = !strcmp(type, "-LIN") || !strcmp(type, "-WRP") || !strcmp(&coords[0].ctype[0], "GENE"); 28 Cartesian = !strcmp(type, "-LIN") || !strcmp(type, "-PLY") || !strcmp(type, "-WRP") || !strcmp(&coords[0].ctype[0], "GENE"); 21 29 PseudoCyl = !strcmp(type, "-AIT") || !strcmp(type, "-GLS") || !strcmp(type, "-PAR"); 30 Zenith1 = !strcmp(type, "-DIS") || !strcmp(type, "-TAN") || !strcmp(type, "-STG"); 31 Zenith2 = !strcmp(type, "-SIN") || !strcmp(&coords[0].ctype[0], "MM"); 32 Zenithal = !strcmp(type, "-ZEA") || Zenith1 || Zenith2; 22 33 if (!Zenithal && !Cartesian && !PseudoCyl) return (FALSE); 23 34 … … 45 56 *ra = L + coords[0].crval1; 46 57 *dec = M + coords[0].crval2; 58 59 /* mosaic astrometry : WRP is chip astrometry; apply mosaic (DIS) term */ 60 if (!strcmp(type, "-WRP")) { 61 if (mosaic == NULL) return (FALSE); 62 XY_to_RD (ra, dec, L + coords[0].crval1, M + coords[0].crval2, mosaic); 63 } 47 64 return (TRUE); 48 65 } … … 60 77 61 78 /* this is wrong : STG is not TAN - need to put in correct relationships. but is a close approx */ 62 if ( !strcmp(type, "-PLY") || !strcmp(type, "-DIS") || !strcmp(type, "-TAN") || !strcmp(type, "-STG")) {79 if (Zenith1) { 63 80 if (R == 0) { 64 81 stht = 1.0; … … 70 87 } 71 88 } 72 if ( !strcmp(type, "-SIN") || !strcmp(&coords[0].ctype[0], "MM")) {89 if (Zenith2) { 73 90 ctht = RAD_DEG * R; 74 91 stht = sqrt (1 - ctht*ctht); … … 124 141 125 142 char *type; 126 int i, status, Polynomial, Zenith al, Cartesian, PseudoCyl;143 int i, status, Polynomial, Zenith1, Zenith2, Zenithal, Cartesian, PseudoCyl; 127 144 double phi, theta; 128 145 double determ; … … 139 156 140 157 Polynomial = !strcmp(type, "-PLY") || !strcmp(type, "-DIS") || !strcmp(type, "-WRP"); 141 Zenithal = !strcmp(type, "-PLY") || !strcmp(type, "-DIS") || !strcmp(type, "-TAN") || !strcmp(type, "-SIN") || !strcmp(type, "-STG") || !strcmp(type, "-ZEA") || !strcmp(&coords[0].ctype[0], "MM"); 142 Cartesian = !strcmp(type, "-LIN") || !strcmp(type, "-WRP") || !strcmp(&coords[0].ctype[0], "GENE"); 158 Cartesian = !strcmp(type, "-LIN") || !strcmp(type, "-PLY") || !strcmp(type, "-WRP") || !strcmp(&coords[0].ctype[0], "GENE"); 143 159 PseudoCyl = !strcmp(type, "-AIT") || !strcmp(type, "-GLS") || !strcmp(type, "-PAR"); 160 Zenith1 = !strcmp(type, "-DIS") || !strcmp(type, "-TAN") || !strcmp(type, "-STG"); 161 Zenith2 = !strcmp(type, "-SIN") || !strcmp(&coords[0].ctype[0], "MM"); 162 Zenithal = !strcmp(type, "-ZEA") || Zenith1 || Zenith2; 144 163 if (!Zenithal && !Cartesian && !PseudoCyl) return (FALSE); 145 164 146 165 /**** Locally Cartesian Projections ****/ 147 166 if (Cartesian) { 148 L = (ra - coords[0].crval1); 149 M = (dec - coords[0].crval2); 167 if (!strcmp(type, "-WRP")) { 168 if (mosaic == NULL) return (FALSE); 169 RD_to_XY (&Lo, &Mo, ra, dec, mosaic); 170 L = (Lo - coords[0].crval1); 171 M = (Mo - coords[0].crval2); 172 } else { 173 L = (ra - coords[0].crval1); 174 M = (dec - coords[0].crval2); 175 } 150 176 } 151 177 … … 164 190 if (stht < 0) status = FALSE; 165 191 166 if ( !strcmp(type, "-PLY") || !strcmp(type, "-DIS") || !strcmp(type, "-TAN") || !strcmp(type, "-STG")) {192 if (Zenith1) { 167 193 L = DEG_RAD * sphi / stht; 168 194 M = -DEG_RAD * cphi / stht; 169 195 } 170 if ( !strcmp(type, "-SIN") || !strcmp(&coords[0].ctype[0], "MM")) {196 if (Zenith2) { 171 197 L = DEG_RAD * sphi; 172 198 M = -DEG_RAD * cphi;
Note:
See TracChangeset
for help on using the changeset viewer.
