- Timestamp:
- Dec 1, 2008, 4:25:00 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20081124/Ohana/src/opihi/dvo/dbExtractImages.c
r20861 r20862 1 1 # include "dvoshell.h" 2 3 /* time concepts */ 4 static time_t TimeReference; 5 static int TimeFormat; 2 6 3 7 static CoordTransform *celestial_to_galactic = NULL; … … 11 15 static double ELON = 0.0; 12 16 static double ELAT = 0.0; 17 18 static int haveCelestial = FALSE; 19 static double RAo = 0.0; 20 static double DECo = 0.0; 13 21 14 22 // define a locally-static transform … … 34 42 35 43 int dbExtractImagesInit () { 36 haveGalactic = FALSE; 37 haveEcliptic = FALSE; 44 GetTimeFormat (&TimeReference, &TimeFormat); 38 45 return (TRUE); 39 46 } 40 47 48 int dbExtractImagesReset () { 49 haveGalactic = FALSE; 50 haveEcliptic = FALSE; 51 haveCelestial = FALSE; 52 return (TRUE); 53 } 54 41 55 /* return image.field based on the selection */ 42 dbValue dbExtractImages (Image *image, dbField *field) { 43 56 dbValue dbExtractImages (Image *image, int Nimage, int N, dbField *field) { 57 58 double x, y; 59 time_t t; 44 60 int i, Nsec; 45 61 dbValue value; … … 51 67 switch (field->ID) { 52 68 case IMAGE_RA: 53 XXX : need a better implementation of this... 54 if (!FindMosaicForImage (image, Nimage, j)) continue; 55 x = 0.5*image[0].NX; 56 y = 0.5*image[0].NY; 57 XY_to_RD (&ra, &dec, x, y, &image[0].coords); 58 value.Flt = ra; 69 if (!haveCelestial) { 70 if (!FindMosaicForImage (image, Nimage, N)) return value; 71 x = 0.5*image[N].NX; 72 y = 0.5*image[N].NY; 73 XY_to_RD (&RAo, &DECo, x, y, &image[N].coords); 74 haveCelestial = TRUE; 75 } 76 value.Flt = RAo; 59 77 break; 60 78 case IMAGE_DEC: 61 if (!FindMosaicForImage (image, Nimage, j)) continue; 62 x = 0.5*image[0].NX; 63 y = 0.5*image[0].NY; 64 XY_to_RD (&ra, &dec, x, y, &image[0].coords); 65 value.Flt = dec; 79 if (!haveCelestial) { 80 if (!FindMosaicForImage (image, Nimage, N)) return value; 81 x = 0.5*image[N].NX; 82 y = 0.5*image[N].NY; 83 XY_to_RD (&RAo, &DECo, x, y, &image[N].coords); 84 haveCelestial = TRUE; 85 } 86 value.Flt = DECo; 66 87 break; 67 88 case IMAGE_GLON: 68 89 if (!haveGalactic) { 90 if (!haveCelestial) { 91 if (!FindMosaicForImage (image, Nimage, N)) return value; 92 x = 0.5*image[N].NX; 93 y = 0.5*image[N].NY; 94 XY_to_RD (&RAo, &DECo, x, y, &image[N].coords); 95 haveCelestial = TRUE; 96 } 69 97 ApplyTransform (&GLON, &GLAT, RAo, DECo, celestial_to_galactic); 70 98 haveGalactic = TRUE; … … 74 102 case IMAGE_GLAT: 75 103 if (!haveGalactic) { 104 if (!haveCelestial) { 105 if (!FindMosaicForImage (image, Nimage, N)) return value; 106 x = 0.5*image[N].NX; 107 y = 0.5*image[N].NY; 108 XY_to_RD (&RAo, &DECo, x, y, &image[N].coords); 109 haveCelestial = TRUE; 110 } 76 111 ApplyTransform (&GLON, &GLAT, RAo, DECo, celestial_to_galactic); 77 112 haveGalactic = TRUE; … … 81 116 case IMAGE_ELON: 82 117 if (!haveEcliptic) { 118 if (!haveCelestial) { 119 if (!FindMosaicForImage (image, Nimage, N)) return value; 120 x = 0.5*image[N].NX; 121 y = 0.5*image[N].NY; 122 XY_to_RD (&RAo, &DECo, x, y, &image[N].coords); 123 haveCelestial = TRUE; 124 } 83 125 ApplyTransform (&ELON, &ELAT, RAo, DECo, celestial_to_ecliptic); 84 126 haveEcliptic = TRUE; … … 88 130 case IMAGE_ELAT: 89 131 if (!haveEcliptic) { 132 if (!haveCelestial) { 133 if (!FindMosaicForImage (image, Nimage, N)) return value; 134 x = 0.5*image[N].NX; 135 y = 0.5*image[N].NY; 136 XY_to_RD (&RAo, &DECo, x, y, &image[N].coords); 137 haveCelestial = TRUE; 138 } 90 139 ApplyTransform (&ELON, &ELAT, RAo, DECo, celestial_to_ecliptic); 91 140 haveEcliptic = TRUE; … … 93 142 value.Flt = ELAT; 94 143 break; 95 case IMAGE_X m:96 value.Flt = pow(10.0, 0.01*image[ 0].Xm);144 case IMAGE_XM: 145 value.Flt = pow(10.0, 0.01*image[N].Xm); 97 146 break; 98 147 case IMAGE_AIRMASS: 99 value.Flt = image[ 0].secz;148 value.Flt = image[N].secz; 100 149 break; 101 150 case IMAGE_MCAL: 102 value.Flt = image[ 0].Mcal;151 value.Flt = image[N].Mcal; 103 152 break; 104 153 case IMAGE_dMCAL: 105 value.Flt = image[ 0].dMcal;154 value.Flt = image[N].dMcal; 106 155 break; 107 156 case IMAGE_PHOTCODE: 108 value.Flt = image[ 0].photcode;157 value.Flt = image[N].photcode; 109 158 break; 110 159 case IMAGE_TIME: 111 t = image[ 0].tzero + 0.5*image[0].NY * image[0].trate / 10000;160 t = image[N].tzero + 0.5*image[N].NY * image[N].trate / 10000; 112 161 value.Flt = TimeValue (t, TimeReference, TimeFormat); 113 162 break; 114 163 case IMAGE_FWHM: 115 value.Flt = image[ 0].fwhm_x / 25.0;164 value.Flt = image[N].fwhm_x / 25.0; 116 165 break; 117 166 case IMAGE_EXPTIME: 118 value.Flt = image[ 0].exptime;167 value.Flt = image[N].exptime; 119 168 break; 120 169 case IMAGE_NSTAR: 121 value.Flt = image[ 0].nstar;170 value.Flt = image[N].nstar; 122 171 break; 123 172 case IMAGE_NCAL: 124 value.Flt = image[ 0].Mxxxx;173 value.Flt = image[N].Mxxxx; 125 174 break; 126 175 case IMAGE_SKY: 127 value.Flt = image[ 0].Myyyy + 0x8000;176 value.Flt = image[N].Myyyy + 0x8000; 128 177 break; 129 178 case IMAGE_FLAG: 130 value.Flt = image[ 0].code;179 value.Flt = image[N].code; 131 180 break; 132 181 case IMAGE_NX_PIX: 133 value.Flt = image[ 0].NX;182 value.Flt = image[N].NX; 134 183 break; 135 184 case IMAGE_NY_PIX: 136 value.Flt = image[ 0].NY;185 value.Flt = image[N].NY; 137 186 break; 138 187 case IMAGE_IMAGE_ID: 139 value.Flt = image[ 0].imageID;188 value.Flt = image[N].imageID; 140 189 break; 141 190 case IMAGE_THETA: { 142 191 double theta1, theta2, s1, s2; 143 s1 = SIGN(image[ 0].coords.pc1_1);144 s2 = SIGN(image[ 0].coords.pc2_2);145 theta1 = DEG_RAD*atan2 (+s1*image[ 0].coords.pc1_2, s1*image[0].coords.pc1_1);146 theta2 = DEG_RAD*atan2 (-s2*image[ 0].coords.pc2_1, s2*image[0].coords.pc2_2);192 s1 = SIGN(image[N].coords.pc1_1); 193 s2 = SIGN(image[N].coords.pc2_2); 194 theta1 = DEG_RAD*atan2 (+s1*image[N].coords.pc1_2, s1*image[N].coords.pc1_1); 195 theta2 = DEG_RAD*atan2 (-s2*image[N].coords.pc2_1, s2*image[N].coords.pc2_2); 147 196 value.Flt = 0.5*(theta1+theta2); 148 197 break; } 149 198 case IMAGE_SKEW: { 150 199 double theta1, theta2, s1, s2; 151 s1 = SIGN(image[ 0].coords.pc1_1);152 s2 = SIGN(image[ 0].coords.pc2_2);153 theta1 = DEG_RAD*atan2 (+s1*image[ 0].coords.pc1_2, s1*image[0].coords.pc1_1);154 theta2 = DEG_RAD*atan2 (-s2*image[ 0].coords.pc2_1, s2*image[0].coords.pc2_2);200 s1 = SIGN(image[N].coords.pc1_1); 201 s2 = SIGN(image[N].coords.pc2_2); 202 theta1 = DEG_RAD*atan2 (+s1*image[N].coords.pc1_2, s1*image[N].coords.pc1_1); 203 theta2 = DEG_RAD*atan2 (-s2*image[N].coords.pc2_1, s2*image[N].coords.pc2_2); 155 204 value.Flt = (theta1-theta2); 156 205 break; } 157 206 case IMAGE_SCALE: { 158 207 double scale1, scale2; 159 scale1 = fabs(image[ 0].coords.cdelt1);160 scale2 = fabs(image[ 0].coords.cdelt2);208 scale1 = fabs(image[N].coords.cdelt1); 209 scale2 = fabs(image[N].coords.cdelt2); 161 210 value.Flt = 0.5*(scale1+scale2); 162 211 break; } 163 212 case IMAGE_DSCALE: { 164 213 double scale1, scale2; 165 scale1 = fabs(image[ 0].coords.cdelt1);166 scale2 = fabs(image[ 0].coords.cdelt2);214 scale1 = fabs(image[N].coords.cdelt1); 215 scale2 = fabs(image[N].coords.cdelt2); 167 216 value.Flt = (scale1-scale2); 168 217 break; } … … 177 226 case IMAGE_X_LR_CHIP: 178 227 case IMAGE_X_UR_CHIP: 179 value.Flt = image[ 0].NX;228 value.Flt = image[N].NX; 180 229 break; 181 230 case IMAGE_Y_UL_CHIP: 182 231 case IMAGE_Y_UR_CHIP: 183 value.Flt = image[ 0].NX;232 value.Flt = image[N].NX; 184 233 break; 185 234 186 235 case IMAGE_X_LL_FP: 187 236 case IMAGE_Y_LL_FP: 188 XY_to_LM (&x, &y, 0.0, 0.0, &image[ 0].coords);189 value.Flt = ( mode ==X_LL_FP) ? x : y;237 XY_to_LM (&x, &y, 0.0, 0.0, &image[N].coords); 238 value.Flt = (field->ID == IMAGE_X_LL_FP) ? x : y; 190 239 break; 191 240 case IMAGE_X_LR_FP: 192 241 case IMAGE_Y_LR_FP: 193 XY_to_LM (&x, &y, image[ 0].NX, 0.0, &image[0].coords);194 value.Flt = ( mode ==X_LR_FP) ? x : y;242 XY_to_LM (&x, &y, image[N].NX, 0.0, &image[N].coords); 243 value.Flt = (field->ID == IMAGE_X_LR_FP) ? x : y; 195 244 break; 196 245 case IMAGE_X_UL_FP: 197 246 case IMAGE_Y_UL_FP: 198 XY_to_LM (&x, &y, 0.0, image[ 0].NY, &image[0].coords);199 value.Flt = ( mode ==X_UL_FP) ? x : y;247 XY_to_LM (&x, &y, 0.0, image[N].NY, &image[N].coords); 248 value.Flt = (field->ID == IMAGE_X_UL_FP) ? x : y; 200 249 break; 201 250 case IMAGE_X_UR_FP: 202 251 case IMAGE_Y_UR_FP: 203 XY_to_LM (&x, &y, image[ 0].NX, image[0].NY, &image[0].coords);204 value.Flt = ( mode ==X_UR_FP) ? x : y;252 XY_to_LM (&x, &y, image[N].NX, image[N].NY, &image[N].coords); 253 value.Flt = (field->ID == IMAGE_X_UR_FP) ? x : y; 205 254 break; 206 255 }
Note:
See TracChangeset
for help on using the changeset viewer.
