Changeset 37176
- Timestamp:
- Aug 2, 2014, 6:17:20 AM (12 years ago)
- Location:
- branches/eam_branches/ipp-20140717/Ohana/src/dvopsps
- Files:
-
- 5 edited
-
include/dvopsps.h (modified) (2 diffs)
-
src/DetectionOps.c (modified) (5 diffs)
-
src/insert_detections_dvopsps.c (modified) (1 diff)
-
src/insert_detections_dvopsps_catalog.c (modified) (4 diffs)
-
src/insert_objects_dvopsps_catalog.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140717/Ohana/src/dvopsps/include/dvopsps.h
r36188 r37176 9 9 10 10 typedef struct { 11 int imageID; 12 unsigned int ippDetectID; 11 uint64_t objID; 13 12 uint64_t detectID; 14 13 uint64_t ippObjID; 15 uint64_t objID; 16 int photcode; 17 unsigned int flags; 18 float zp; 19 float zpErr; 20 float airMass; 21 float expTime; 14 unsigned int ippDetectID; 15 int imageID; 22 16 double ra; 23 17 double dec; 24 18 float raErr; 25 19 float decErr; 20 float zp; 21 float telluricExt; 22 float airmass; 23 float expTime; 24 25 float Mpsf; 26 float dMpsf; 27 float Mkron; 28 float dMkron; 29 float Map; 30 float dMap; 31 32 unsigned int flags; 26 33 } Detections; 27 34 … … 78 85 79 86 int insert_detections_mysql_commit PROTO((IOBuffer *buffer, MYSQL *mysql)); 80 int insert_detections_mysql_value PROTO((IOBuffer *buffer, Average *average, Measure *measure));87 // int insert_detections_mysql_value PROTO((IOBuffer *buffer, Average *average, Measure *measure)); 81 88 int insert_detections_mysql_init PROTO((IOBuffer *buffer)); 82 89 83 90 int insert_detections_mysql_array PROTO((MYSQL *mysql, Detections *detections, int Ndetections)); 84 91 int insert_detections_mysql_detvalue PROTO((IOBuffer *buffer, Detections *detection)); 92 int assign_detection_values PROTO((Detections *detection, Measure *measure, Average *average)); 85 93 86 94 int init_detections PROTO(()); -
branches/eam_branches/ipp-20140717/Ohana/src/dvopsps/src/DetectionOps.c
r35578 r37176 1 1 # include "dvopsps.h" 2 # define BZERO_INT16 1.0*0x80003 # define BZERO_INT32 1.0*0x800000004 # define BZERO_INT64 1.0*0x80000000000000005 2 6 3 # define GET_COLUMN(OUT,NAME,TYPE) \ … … 49 46 50 47 // need to create and assign to flat-field correction 51 GET_COLUMN(imageID , "imageID", int); 52 GET_COLUMN(ippDetectID , "ippDetectID", int); 48 GET_COLUMN(objID , "objID", int64_t); 53 49 GET_COLUMN(detectID , "detectID", int64_t); 54 50 GET_COLUMN(ippObjID , "ippObjID", int64_t); 55 GET_COLUMN(objID , "objID", int64_t); 56 GET_COLUMN(photcode , "photcode", int); 57 GET_COLUMN(flags , "flags", int); 58 GET_COLUMN(zp , "zp", float); 59 GET_COLUMN(zpErr , "zpErr", float); 60 GET_COLUMN(airMass , "airMass", float); 61 GET_COLUMN(expTime , "expTime", float); 51 GET_COLUMN(ippDetectID , "ippDetectID", int); 52 GET_COLUMN(imageID , "imageID", int); 62 53 GET_COLUMN(ra , "ra", double); // XXX signed vs unsigned? 63 54 GET_COLUMN(dec , "dec", double); 64 55 GET_COLUMN(raErr , "raErr", float); 65 56 GET_COLUMN(decErr , "decErr", float); 57 GET_COLUMN(zp , "zp", float); 58 GET_COLUMN(telluricExt , "telluricExt", float); 59 GET_COLUMN(airmass , "airmass", float); 60 GET_COLUMN(expTime , "expTime", float); 61 GET_COLUMN(Mpsf , "Mpsf", float); 62 GET_COLUMN(dMpsf , "dMpsf", float); 63 GET_COLUMN(Mkron , "Mkron", float); 64 GET_COLUMN(dMkron , "dMkron", float); 65 GET_COLUMN(Map , "Map", float); 66 GET_COLUMN(dMap , "dMap", float); 67 GET_COLUMN(flags , "flags", int); 66 68 gfits_free_header (&theader); 67 69 gfits_free_table (&ftable); … … 69 71 ALLOCATE (detections, Detections, Nrow); 70 72 for (i = 0; i < Nrow; i++) { 71 detections[i].imageID = imageID[i]; 72 detections[i].ippDetectID = ippDetectID[i]; 73 detections[i].objID = objID[i]; 73 74 detections[i].detectID = detectID[i]; 74 75 detections[i].ippObjID = ippObjID[i]; 75 detections[i].objID = objID[i]; 76 detections[i].photcode = photcode[i]; 77 detections[i].flags = flags[i]; 78 detections[i].zp = zp[i]; 79 detections[i].zpErr = zpErr[i]; 80 detections[i].airMass = airMass[i]; 81 detections[i].expTime = expTime[i]; 76 detections[i].ippDetectID = ippDetectID[i]; 77 detections[i].imageID = imageID[i]; 82 78 detections[i].ra = ra[i]; 83 79 detections[i].dec = dec[i]; 84 80 detections[i].raErr = raErr[i]; 85 81 detections[i].decErr = decErr[i]; 82 detections[i].zp = zp[i]; 83 detections[i].telluricExt = telluricExt[i]; 84 detections[i].airmass = airmass[i]; 85 detections[i].expTime = expTime[i]; 86 detections[i].Mpsf = Mpsf[i]; 87 detections[i].dMpsf = dMpsf[i]; 88 detections[i].Mkron = Mkron[i]; 89 detections[i].dMkron = dMkron[i]; 90 detections[i].Map = Map[i]; 91 detections[i].dMap = dMap[i]; 92 detections[i].flags = flags[i]; 86 93 } 87 94 fprintf (stderr, "loaded data for %lld detections\n", (long long) Nrow); 88 95 89 free (imageID ); 90 free (ippDetectID); 96 free (objID ); 91 97 free (detectID ); 92 98 free (ippObjID ); 93 free (objID ); 94 free (photcode ); 95 free (flags ); 96 free (zp ); 97 free (zpErr ); 98 free (airMass ); 99 free (expTime ); 99 free (ippDetectID); 100 free (imageID ); 100 101 free (ra ); 101 102 free (dec ); 102 103 free (raErr ); 103 104 free (decErr ); 105 free (zp ); 106 free (telluricExt); 107 free (airmass ); 108 free (expTime ); 109 free (Mpsf ); 110 free (dMpsf ); 111 free (Mkron ); 112 free (dMkron ); 113 free (Map ); 114 free (dMap ); 115 free (flags ); 104 116 105 117 gfits_free_header (&header); … … 149 161 150 162 // XXX need to get the bzero values right 151 gfits_define_bintable_column (&theader, "J", "imageID", NULL, NULL, 1.0, BZERO_INT32); 152 gfits_define_bintable_column (&theader, "J", "ippDetectID", NULL, NULL, 1.0, BZERO_INT32); 163 gfits_define_bintable_column (&theader, "K", "objID", NULL, NULL, 1.0, 0); 153 164 gfits_define_bintable_column (&theader, "K", "detectID", NULL, NULL, 1.0, 0); 154 165 gfits_define_bintable_column (&theader, "K", "ippObjID", NULL, NULL, 1.0, 0); 155 gfits_define_bintable_column (&theader, "K", "objID", NULL, NULL, 1.0, 0); 156 // gfits_define_bintable_column (&theader, "K", "detectID", NULL, NULL, 1.0, BZERO_INT64); 157 // gfits_define_bintable_column (&theader, "K", "ippObjID", NULL, NULL, 1.0, BZERO_INT64); 158 // gfits_define_bintable_column (&theader, "K", "objID", NULL, NULL, 1.0, BZERO_INT64); 159 gfits_define_bintable_column (&theader, "J", "photcode", NULL, NULL, 1.0, 0.0); 160 gfits_define_bintable_column (&theader, "J", "flags", NULL, NULL, 1.0, BZERO_INT32); 161 gfits_define_bintable_column (&theader, "E", "zp", NULL, NULL, 1.0, 0.0); 162 gfits_define_bintable_column (&theader, "E", "zpErr", NULL, NULL, 1.0, 0.0); 163 gfits_define_bintable_column (&theader, "E", "airMass", NULL, NULL, 1.0, 0.0); 164 gfits_define_bintable_column (&theader, "E", "expTime", NULL, NULL, 1.0, 0.0); 166 gfits_define_bintable_column (&theader, "J", "ippDetectID", NULL, NULL, 1.0, FT_BZERO_INT32); 167 gfits_define_bintable_column (&theader, "J", "imageID", NULL, NULL, 1.0, FT_BZERO_INT32); 165 168 gfits_define_bintable_column (&theader, "D", "ra", NULL, NULL, 1.0, 0.0); 166 169 gfits_define_bintable_column (&theader, "D", "dec", NULL, NULL, 1.0, 0.0); 167 170 gfits_define_bintable_column (&theader, "E", "raErr", NULL, NULL, 1.0, 0.0); 168 171 gfits_define_bintable_column (&theader, "E", "decErr", NULL, NULL, 1.0, 0.0); 172 gfits_define_bintable_column (&theader, "E", "zp", NULL, NULL, 1.0, 0.0); 173 gfits_define_bintable_column (&theader, "E", "telluricExt", NULL, NULL, 1.0, 0.0); 174 gfits_define_bintable_column (&theader, "E", "airmass", NULL, NULL, 1.0, 0.0); 175 gfits_define_bintable_column (&theader, "E", "expTime", NULL, NULL, 1.0, 0.0); 176 gfits_define_bintable_column (&theader, "E", "Mpsf", NULL, NULL, 1.0, 0.0); 177 gfits_define_bintable_column (&theader, "E", "dMpsf", NULL, NULL, 1.0, 0.0); 178 gfits_define_bintable_column (&theader, "E", "Mkron", NULL, NULL, 1.0, 0.0); 179 gfits_define_bintable_column (&theader, "E", "dMkron", NULL, NULL, 1.0, 0.0); 180 gfits_define_bintable_column (&theader, "E", "Map", NULL, NULL, 1.0, 0.0); 181 gfits_define_bintable_column (&theader, "E", "dMap", NULL, NULL, 1.0, 0.0); 182 gfits_define_bintable_column (&theader, "J", "flags", NULL, NULL, 1.0, FT_BZERO_INT32); 169 183 170 184 // generate the output array that carries the data … … 172 186 173 187 // create intermediate storage arrays 174 int32_t *imageID ; ALLOCATE (imageID , int32_t, Ndetections); 175 uint32_t *ippDetectID ; ALLOCATE (ippDetectID , uint32_t, Ndetections); 188 uint64_t *objID ; ALLOCATE (objID , uint64_t, Ndetections); 176 189 uint64_t *detectID ; ALLOCATE (detectID , uint64_t, Ndetections); 177 190 uint64_t *ippObjID ; ALLOCATE (ippObjID , uint64_t, Ndetections); 178 uint64_t *objID ; ALLOCATE (objID , uint64_t, Ndetections); 179 int *photcode ; ALLOCATE (photcode , int, Ndetections); 180 uint32_t *flags ; ALLOCATE (flags , uint32_t, Ndetections); 181 float *zp ; ALLOCATE (zp , float, Ndetections); 182 float *zpErr ; ALLOCATE (zpErr , float, Ndetections); 183 float *airMass ; ALLOCATE (airMass , float, Ndetections); 184 float *expTime ; ALLOCATE (expTime , float, Ndetections); 191 uint32_t *ippDetectID ; ALLOCATE (ippDetectID , uint32_t, Ndetections); 192 int32_t *imageID ; ALLOCATE (imageID , int32_t, Ndetections); 185 193 double *ra ; ALLOCATE (ra , double, Ndetections); 186 194 double *dec ; ALLOCATE (dec , double, Ndetections); 187 195 float *raErr ; ALLOCATE (raErr , float, Ndetections); 188 196 float *decErr ; ALLOCATE (decErr , float, Ndetections); 197 float *zp ; ALLOCATE (zp , float, Ndetections); 198 float *telluricExt ; ALLOCATE (telluricExt , float, Ndetections); 199 float *airmass ; ALLOCATE (airmass , float, Ndetections); 200 float *expTime ; ALLOCATE (expTime , float, Ndetections); 201 float *Mpsf ; ALLOCATE (Mpsf , float, Ndetections); 202 float *dMpsf ; ALLOCATE (dMpsf , float, Ndetections); 203 float *Mkron ; ALLOCATE (Mkron , float, Ndetections); 204 float *dMkron ; ALLOCATE (dMkron , float, Ndetections); 205 float *Map ; ALLOCATE (Map , float, Ndetections); 206 float *dMap ; ALLOCATE (dMap , float, Ndetections); 207 uint32_t *flags ; ALLOCATE (flags , uint32_t, Ndetections); 189 208 190 209 // assign the storage arrays 191 210 for (i = 0; i < Ndetections; i++) { 192 imageID[i] = detections[i].imageID ; 193 ippDetectID[i] = detections[i].ippDetectID ; 211 objID[i] = detections[i].objID ; 194 212 detectID[i] = detections[i].detectID ; 195 213 ippObjID[i] = detections[i].ippObjID ; 196 objID[i] = detections[i].objID ; 197 photcode[i] = detections[i].photcode ; 198 flags[i] = detections[i].flags ; 199 zp[i] = detections[i].zp ; 200 zpErr[i] = detections[i].zpErr ; 201 airMass[i] = detections[i].airMass ; 202 expTime[i] = detections[i].expTime ; 214 ippDetectID[i] = detections[i].ippDetectID ; 215 imageID[i] = detections[i].imageID ; 203 216 ra[i] = detections[i].ra ; 204 217 dec[i] = detections[i].dec ; 205 218 raErr[i] = detections[i].raErr ; 206 219 decErr[i] = detections[i].decErr ; 220 zp[i] = detections[i].zp ; 221 telluricExt[i] = detections[i].telluricExt ; 222 airmass[i] = detections[i].airmass ; 223 expTime[i] = detections[i].expTime ; 224 Mpsf[i] = detections[i].Mpsf ; 225 dMpsf[i] = detections[i].dMpsf ; 226 Mkron[i] = detections[i].Mkron ; 227 dMkron[i] = detections[i].dMkron ; 228 Map[i] = detections[i].Map ; 229 dMap[i] = detections[i].dMap ; 230 flags[i] = detections[i].flags ; 207 231 } 208 232 209 233 // add the columns to the output array 210 gfits_set_bintable_column (&theader, &ftable, "imageID", imageID , Ndetections); 211 gfits_set_bintable_column (&theader, &ftable, "ippDetectID", ippDetectID , Ndetections); 234 gfits_set_bintable_column (&theader, &ftable, "objID", objID , Ndetections); 212 235 gfits_set_bintable_column (&theader, &ftable, "detectID", detectID , Ndetections); 213 236 gfits_set_bintable_column (&theader, &ftable, "ippObjID", ippObjID , Ndetections); 214 gfits_set_bintable_column (&theader, &ftable, "objID", objID , Ndetections); 215 gfits_set_bintable_column (&theader, &ftable, "photcode", photcode , Ndetections); 216 gfits_set_bintable_column (&theader, &ftable, "flags", flags , Ndetections); 217 gfits_set_bintable_column (&theader, &ftable, "zp", zp , Ndetections); 218 gfits_set_bintable_column (&theader, &ftable, "zpErr", zpErr , Ndetections); 219 gfits_set_bintable_column (&theader, &ftable, "airMass", airMass , Ndetections); 220 gfits_set_bintable_column (&theader, &ftable, "expTime", expTime , Ndetections); 237 gfits_set_bintable_column (&theader, &ftable, "ippDetectID", ippDetectID , Ndetections); 238 gfits_set_bintable_column (&theader, &ftable, "imageID", imageID , Ndetections); 221 239 gfits_set_bintable_column (&theader, &ftable, "ra", ra , Ndetections); 222 240 gfits_set_bintable_column (&theader, &ftable, "dec", dec , Ndetections); 223 241 gfits_set_bintable_column (&theader, &ftable, "raErr", raErr , Ndetections); 224 242 gfits_set_bintable_column (&theader, &ftable, "decErr", decErr , Ndetections); 225 226 free (imageID ); 227 free (ippDetectID ); 243 gfits_set_bintable_column (&theader, &ftable, "zp", zp , Ndetections); 244 gfits_set_bintable_column (&theader, &ftable, "telluricExt", telluricExt , Ndetections); 245 gfits_set_bintable_column (&theader, &ftable, "airmass", airmass , Ndetections); 246 gfits_set_bintable_column (&theader, &ftable, "expTime", expTime , Ndetections); 247 gfits_set_bintable_column (&theader, &ftable, "Mpsf", Mpsf , Ndetections); 248 gfits_set_bintable_column (&theader, &ftable, "dMpsf", dMpsf , Ndetections); 249 gfits_set_bintable_column (&theader, &ftable, "Mkron", Mkron , Ndetections); 250 gfits_set_bintable_column (&theader, &ftable, "dMkron", dMkron , Ndetections); 251 gfits_set_bintable_column (&theader, &ftable, "Map", Map , Ndetections); 252 gfits_set_bintable_column (&theader, &ftable, "dMap", dMap , Ndetections); 253 gfits_set_bintable_column (&theader, &ftable, "flags", flags , Ndetections); 254 255 free (objID ); 228 256 free (detectID ); 229 257 free (ippObjID ); 230 free (objID ); 231 free (photcode ); 232 free (flags ); 233 free (zp ); 234 free (zpErr ); 235 free (airMass ); 236 free (expTime ); 258 free (ippDetectID ); 259 free (imageID ); 237 260 free (ra ); 238 261 free (dec ); 239 262 free (raErr ); 240 263 free (decErr ); 264 free (zp ); 265 free (telluricExt ); 266 free (airmass ); 267 free (expTime ); 268 free (Mpsf ); 269 free (dMpsf ); 270 free (Mkron ); 271 free (dMkron ); 272 free (Map ); 273 free (dMap ); 274 free (flags ); 241 275 242 276 gfits_fwrite_Theader (f, &theader); -
branches/eam_branches/ipp-20140717/Ohana/src/dvopsps/src/insert_detections_dvopsps.c
r37048 r37176 281 281 } 282 282 283 # define PRINT_FLOAT(BUFFER,FIELD,FORMAT) \284 if (!isfinite(FIELD)) PrintIOBuffer (BUFFER, "NULL, "); \285 else PrintIOBuffer (BUFFER, FORMAT, FIELD);286 287 int insert_detections_mysql_detvalue (IOBuffer *buffer, Detections *detection) {288 289 PrintIOBuffer (buffer, "(%d, ", detection->imageID); // imageID290 PrintIOBuffer (buffer, "%u, ", detection->ippDetectID); // ippDetectID291 PrintIOBuffer (buffer, "%lu, ", detection->detectID); // detectID292 PrintIOBuffer (buffer, "%lu, ", detection->ippObjID); // ippObjID293 PrintIOBuffer (buffer, "%lu, ", detection->objID); // objID294 PrintIOBuffer (buffer, "%u, ", detection->flags); // flags295 PRINT_FLOAT(buffer, detection->zp, "%.6f, ");296 PRINT_FLOAT(buffer, detection->zpErr, "%.6f, ");297 PRINT_FLOAT(buffer, detection->airMass, "%.6f, ");298 PRINT_FLOAT(buffer, detection->expTime, "%.6f, ");299 PRINT_FLOAT(buffer, detection->ra, "%.8f, ");300 PRINT_FLOAT(buffer, detection->dec, "%.8f, ");301 PRINT_FLOAT(buffer, detection->raErr, "%.6f, ");302 PRINT_FLOAT(buffer, detection->decErr, "%.6f),\n");303 return TRUE;304 } -
branches/eam_branches/ipp-20140717/Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c
r37048 r37176 47 47 if (measure->photcode >= PHOTCODE_END) continue; 48 48 49 PhotCode *code = GetPhotcodebyCode(measure->photcode); 50 51 detections[Ndetections].imageID = measure->imageID; // imageID 52 detections[Ndetections].ippDetectID = measure->detID; // ippDetectID 53 detections[Ndetections].detectID = measure->extID; // detectID 54 detections[Ndetections].ippObjID = ((uint64_t)average->catID * 1000000000) + (uint64_t)average->objID; // ippObjID 55 // NOTE: this is better, but the above is the current ippToPsps value 56 // detections[Ndetections]. ((uint64_t)average->catID << 32) + (uint64_t)average->objID; // ippObjID 57 detections[Ndetections].objID = average->extID; // objID 58 detections[Ndetections].photcode = measure->photcode; // photcode 59 detections[Ndetections].flags = measure->dbFlags; // flags 60 detections[Ndetections].zp = code->C * 0.001 + code->K * (measure->airmass - 1) - measure->Mcal; // zp 61 detections[Ndetections].zpErr = measure->dMcal; // zpErr 62 detections[Ndetections].airMass = measure->airmass; 63 detections[Ndetections].expTime = pow(10.0, 0.4 * measure->dt); // expTime 64 detections[Ndetections].ra = measure->R; // ra 65 detections[Ndetections].dec = measure->D; // dec 66 detections[Ndetections].raErr = measure->dXccd * 0.01 * fabs(measure->pltscale); // estimate of raErr 67 detections[Ndetections].decErr = measure->dYccd * 0.01 * fabs(measure->pltscale); // estimate of decErr 68 49 assign_detection_values (&detections[Ndetections], measure, average); 69 50 Ndetections ++; 51 70 52 myAssert (Ndetections <= NDETECTIONS, "programming error"); 71 53 } … … 143 125 144 126 // XXX check return status 145 if (!insert_detections_mysql_value (&buffer, &average[i], &measure[Nmeas])) { 127 Detections detection; 128 assign_detection_values (&detection, &measure[Nmeas], &average[i]); 129 130 if (!insert_detections_mysql_detvalue (&buffer, &detection)) { 146 131 fprintf (stderr, "failure to insert detections in mysql\n"); 147 132 status = FALSE; … … 194 179 } 195 180 196 // PrintIOBuffer (buffer, "INSERT INTO dvoDetectionFull (imageID, ippDetectID, detectID, ippObjID, objID, photcode, flags, zp, zpErr, airMass, expTime, ra, dec_, raErr, decErr) VALUES \n"); 197 PrintIOBuffer (buffer, "INSERT INTO dvoDetectionFull (imageID, ippDetectID, detectID, ippObjID, objID, flags, zp, zpErr, airMass, expTime, ra, dec_, raErr, decErr) VALUES \n"); 198 199 return TRUE; 200 } 201 202 # define PRINT_FLOAT(BUFFER,FIELD,FORMAT) \ 203 if (isinf(FIELD) || isnan(FIELD)) PrintIOBuffer (BUFFER, "NULL, "); \ 204 else PrintIOBuffer (BUFFER, FORMAT, FIELD); 205 206 int insert_detections_mysql_value (IOBuffer *buffer, Average *average, Measure *measure) { 207 208 PhotCode *code = GetPhotcodebyCode(measure->photcode); 209 PrintIOBuffer (buffer, "(%d, ", measure->imageID); // imageID 210 PrintIOBuffer (buffer, "%u, ", measure->detID); // ippDetectID 211 PrintIOBuffer (buffer, "%lu, ", measure->extID); // detectID 212 PrintIOBuffer (buffer, "%lu, ", ((uint64_t)average->catID * 1000000000) + (uint64_t)average->objID); // ippObjID 213 // NOTE: the following is better, but the above is the current ippToPsps value 214 // ((uint64_t)average->catID << 32) + (uint64_t)average->objID, // ippObjID 215 PrintIOBuffer (buffer, "%lu, ", average->extID); // objID 216 // XXX PrintIOBuffer (buffer, "%d, ", measure->photcode); // photcode 217 PrintIOBuffer (buffer, "%u, ", measure->dbFlags); // flags 218 219 float zp = code->C * 0.001 + code->K * (measure->airmass - 1) - measure->Mcal; 220 float exptime = pow(10.0, 0.4 * measure->dt); 221 double ra = measure->R; 222 double dec = measure->D; 223 double dR = measure->dXccd * 0.01 * fabs(measure->pltscale); 224 double dD = measure->dYccd * 0.01 * fabs(measure->pltscale); 225 226 PRINT_FLOAT(buffer, zp, "%.6f, "); 227 PRINT_FLOAT(buffer, measure->dMcal, "%.6f, "); 228 PRINT_FLOAT(buffer, measure->airmass, "%.6f, "); 229 PRINT_FLOAT(buffer, exptime, "%.6f, "); 230 PRINT_FLOAT(buffer, ra, "%.8f, "); 231 PRINT_FLOAT(buffer, dec, "%.8f, "); 232 PRINT_FLOAT(buffer, dR, "%.6f, "); 233 PRINT_FLOAT(buffer, dD, "%.6f),\n"); 234 235 return TRUE; 236 } 237 181 PrintIOBuffer (buffer, "INSERT INTO dvoDetectionFull (objID, detectID, ippObjID, ippDetectID, imageID, "); 182 PrintIOBuffer (buffer, "ra, dec_, raErr, decErr, zp, telluricExt, airmass, expTime, Mpsf, dMpsf, Mkron, dMkron, Map, dMap, flags) VALUES \n"); 183 184 return TRUE; 185 } 186 238 187 int insert_detections_mysql_commit (IOBuffer *buffer, MYSQL *mysql) { 239 188 … … 270 219 return status; 271 220 } 221 222 # define PRINT_FLOAT(BUFFER,FIELD,FORMAT) \ 223 if (!isfinite(FIELD)) PrintIOBuffer (BUFFER, "NULL, "); \ 224 else PrintIOBuffer (BUFFER, FORMAT, FIELD); 225 226 int insert_detections_mysql_detvalue (IOBuffer *buffer, Detections *detection) { 227 228 PrintIOBuffer (buffer, "(%lu, ", detection->objID); // objID 229 PrintIOBuffer (buffer, "%lu, ", detection->detectID); // detectID 230 PrintIOBuffer (buffer, "%lu, ", detection->ippObjID); // ippObjID 231 PrintIOBuffer (buffer, "%u, ", detection->ippDetectID); // ippDetectID 232 PrintIOBuffer (buffer, "%d, ", detection->imageID); // imageID 233 234 PRINT_FLOAT(buffer, detection->ra, "%.8f, "); 235 PRINT_FLOAT(buffer, detection->dec, "%.8f, "); 236 PRINT_FLOAT(buffer, detection->raErr, "%.6f, "); 237 PRINT_FLOAT(buffer, detection->decErr, "%.6f, "); 238 PRINT_FLOAT(buffer, detection->zp, "%.6f, "); 239 PRINT_FLOAT(buffer, detection->telluricExt, "%.6f, "); 240 PRINT_FLOAT(buffer, detection->airmass, "%.6f, "); 241 PRINT_FLOAT(buffer, detection->expTime, "%.6f, "); 242 243 PRINT_FLOAT(buffer, detection->Mpsf, "%.6f, "); 244 PRINT_FLOAT(buffer, detection->dMpsf, "%.6f, "); 245 PRINT_FLOAT(buffer, detection->Mkron, "%.6f, "); 246 PRINT_FLOAT(buffer, detection->dMkron, "%.6f, "); 247 PRINT_FLOAT(buffer, detection->Map, "%.6f, "); 248 PRINT_FLOAT(buffer, detection->dMap, "%.6f, "); 249 250 PrintIOBuffer (buffer, "%u),\n", detection->flags); // flags 251 return TRUE; 252 } 253 254 int assign_detection_values (Detections *detection, Measure *measure, Average *average) { 255 256 PhotCode *code = GetPhotcodebyCode(measure->photcode); 257 258 uint64_t ippObjID = ((uint64_t)average->catID << 32) + (uint64_t)average->objID; // ippObjID 259 260 float nominalZP = code->C * 0.001 + code->K * (measure->airmass - 1); 261 float zp = nominalZP - measure->Mcal; 262 float telluricExt = - measure->Mcal; 263 float expTime = pow(10.0, 0.4 * measure->dt); 264 float airmass = measure->airmass; 265 266 detection->objID = average->extID; // objID 267 detection->detectID = measure->extID; // detectID 268 detection->ippObjID = ippObjID; // ippObID 269 detection->ippDetectID = measure->detID; // ippDetectID 270 detection->imageID = measure->imageID; // imageID 271 272 detection->ra = measure->R; // ra 273 detection->dec = measure->D; // dec 274 detection->raErr = measure->dXccd * 0.01 * fabs(measure->pltscale); // estimate of raErr 275 detection->decErr = measure->dYccd * 0.01 * fabs(measure->pltscale); // estimate of decErr 276 277 detection->zp = zp; 278 detection->telluricExt = telluricExt; 279 detection->airmass = airmass; 280 detection->expTime = expTime; 281 282 // XXX clean this up with dvo_photcode_ops calls: 283 detection->Mpsf = (measure->FluxPSF > 0.0) ? zp - 2.5*log10(measure->FluxPSF) : NAN; 284 detection->Mkron = (measure->FluxKron > 0.0) ? zp - 2.5*log10(measure->FluxKron) : NAN; 285 detection->Map = (measure->FluxAp > 0.0) ? zp - 2.5*log10(measure->FluxAp) : NAN; 286 287 detection->dMpsf = (measure->FluxPSF > 0.0) ? measure->dFluxPSF / measure->FluxPSF : NAN; 288 detection->dMkron = (measure->FluxKron > 0.0) ? measure->dFluxKron/ measure->FluxKron: NAN; 289 detection->dMap = (measure->FluxAp > 0.0) ? measure->dFluxAp / measure->FluxAp : NAN; 290 291 detection->flags = measure->dbFlags; // flags 292 293 return TRUE; 294 } 295 -
branches/eam_branches/ipp-20140717/Ohana/src/dvopsps/src/insert_objects_dvopsps_catalog.c
r37115 r37176 90 90 // Only send the necessary fields (eg, do not sent parallax and pm) 91 91 PrintIOBuffer (&buffer, "CREATE TABLE %s_cpt (" 92 "EXT_ID BIGINT" 93 "OBJ_ID INT, " 94 "CAT_ID INT, " 95 "DVO_REGION INT" 96 "FLAGS INT, " 97 "RA_STK DOUBLE, " 98 "DEC_STK DOUBLE, " 92 "EXT_ID BIGINT, " 93 "OBJ_ID INT, " 94 "CAT_ID INT, " 95 "DVO_REGION INT, " 96 "RA_STK DOUBLE, " 97 "DEC_STK DOUBLE, " 99 98 "RA_STK_ERR FLOAT, " 100 99 "DEC_STK_ERR FLOAT, " 101 "RA_MEAN DOUBLE, "102 "DEC_MEAN DOUBLE, "100 "RA_MEAN DOUBLE, " 101 "DEC_MEAN DOUBLE, " 103 102 "RA_ERR FLOAT, " 104 103 "DEC_ERR FLOAT, " 105 104 "CHISQ_POS FLOAT, " 106 105 "CHISQ_PM FLOAT, " 107 "CHISQ_PAP FLOAT, " 106 "CHISQ_PAR FLOAT, " 107 "FLAGS INT " 108 108 ")\n", basename); 109 109 … … 153 153 154 154 PrintIOBuffer (&buffer, "CREATE TABLE %s_cps (" 155 "MAG FLOAT, " 156 "MAG_ERR FLOAT, " 157 "MAG_STDEV FLOAT, " 158 "MAG_MIN FLOAT, " 159 "MAG_MAX FLOAT, " 160 "NUSED SMALLINT, " 161 155 "MAG FLOAT, " 156 "MAG_ERR FLOAT, " 157 "MAG_STDEV FLOAT, " 158 "MAG_MIN FLOAT, " 159 "MAG_MAX FLOAT, " 160 "NUSED SMALLINT, " 162 161 "MAG_KRON FLOAT, " 163 162 "MAG_KRON_ERR FLOAT, " 164 163 "MAG_KRON_STDEV FLOAT, " 165 164 "NUSED_KRON SMALLINT, " 166 167 165 "MAG_AP FLOAT, " 168 166 "MAG_AP_ERR FLOAT, " 169 167 "MAG_AP_STDEV FLOAT, " 170 168 "NUSED_AP SMALLINT, " 171 172 "FLAGS INT,"169 "NCODE SMALLINT, " 170 "FLAGS INT " 173 171 ")\n", basename); 174 172 … … 194 192 195 193 PrintIOBuffer (ave_buffer, "INSERT INTO %s_cpt (" 196 "EXT_ID" 197 "OBJ_ID, " 198 "CAT_ID, " 199 "DVO_REGION, " 200 "FLAGS, " 201 "RA_STK, " 202 "DEC_STK, " 203 "RA_STK_ERR, " 194 "EXT_ID, " 195 "OBJ_ID, " 196 "CAT_ID, " 197 "DVO_REGION, " 198 "RA_STK, " 199 "DEC_STK, " 200 "RA_STK_ERR, " 204 201 "DEC_STK_ERR, " 205 "RA_MEAN, " 206 "DEC_MEAN, " 207 "RA_ERR, " 208 "DEC_ERR, " 209 "CHISQ_POS, " 210 "CHISQ_PM, " 211 "CHISQ_PAP, " 202 "RA_MEAN, " 203 "DEC_MEAN, " 204 "RA_ERR, " 205 "DEC_ERR, " 206 "CHISQ_POS, " 207 "CHISQ_PM, " 208 "CHISQ_PAR, " 209 "FLAGS " 212 210 ") VALUES \n", basename); 213 211 … … 234 232 "NUSED_AP, " 235 233 236 "FLAGS, " 234 "NCODE, " 235 "FLAGS " 237 236 ") VALUES \n", basename); 238 237 return TRUE; … … 249 248 // XXX this bit could/should be autocoded... 250 249 PrintIOBuffer (ave_buffer, " ("); 251 PrintIOBuffer (ave_buffer, "%lu ",average->extID);252 PrintIOBuffer (ave_buffer, "%u, ",average->objID);253 PrintIOBuffer (ave_buffer, "%u, ",average->catID);250 PrintIOBuffer (ave_buffer, "%lu, ", average->extID); 251 PrintIOBuffer (ave_buffer, "%u, ", average->objID); 252 PrintIOBuffer (ave_buffer, "%u, ", average->catID); 254 253 255 254 int dvoRegion = 1; 256 255 PrintIOBuffer (ave_buffer, "%u, ", dvoRegion); 257 PrintIOBuffer (ave_buffer, "%u, ", average->flags);258 256 259 257 PRINT_FLOAT(ave_buffer, average->Rstk, "%.8f, "); // 0.036 mas precision … … 270 268 PRINT_FLOAT(ave_buffer, average->ChiSqPM, "%.4f, "); 271 269 PRINT_FLOAT(ave_buffer, average->ChiSqPar, "%.4f, "); 270 271 PrintIOBuffer (ave_buffer, "%u ", average->flags); 272 272 273 273 PrintIOBuffer (ave_buffer, "),\n"); … … 323 323 PRINT_FLOAT(sec_buffer, meanApMagStd, "%.6f, "); // umag precision 324 324 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->NusedAp); 325 326 PrintIOBuffer (sec_buffer, "%u, ", secfilt->flags); 325 PrintIOBuffer (sec_buffer, "%hd, ", secfilt->Ncode); 326 PrintIOBuffer (sec_buffer, "%u ", secfilt->flags); 327 327 328 PrintIOBuffer (sec_buffer, "),\n"); 328 329 secfilt ++;
Note:
See TracChangeset
for help on using the changeset viewer.
