Changeset 37037
- Timestamp:
- Jul 17, 2014, 10:12:36 AM (12 years ago)
- Location:
- trunk/Ohana/src/relphot
- Files:
-
- 27 edited
- 2 copied
-
Makefile (modified) (2 diffs)
-
doc/mosaic.txt (modified) (1 diff)
-
doc/pv2.txt (copied) (copied from branches/eam_branches/ipp-20140610/Ohana/src/relphot/doc/pv2.txt )
-
include/relphot.h (modified) (6 diffs)
-
src/BrightCatalog.c (modified) (13 diffs)
-
src/GridOps.c (modified) (3 diffs)
-
src/ImageMagIO.c (modified) (2 diffs)
-
src/ImageOps.c (modified) (17 diffs)
-
src/ImageSubset.c (modified) (2 diffs)
-
src/MeanMagIO.c (modified) (6 diffs)
-
src/MosaicOps.c (modified) (39 diffs)
-
src/Shutdown.c (modified) (1 diff)
-
src/StarOps.c (modified) (14 diffs)
-
src/args.c (modified) (1 diff)
-
src/assign_images.c (modified) (1 diff)
-
src/bcatalog.c (modified) (10 diffs)
-
src/extra.c (copied) (copied from branches/eam_branches/ipp-20140610/Ohana/src/relphot/src/extra.c )
-
src/initialize.c (modified) (4 diffs)
-
src/launch_region_hosts.c (modified) (1 diff)
-
src/load_catalogs.c (modified) (5 diffs)
-
src/plot_scatter.c (modified) (1 diff)
-
src/relphot_client.c (modified) (1 diff)
-
src/relphot_images.c (modified) (1 diff)
-
src/relphot_parallel_images.c (modified) (2 diffs)
-
src/relphot_parallel_regions.c (modified) (3 diffs)
-
src/setExclusions.c (modified) (1 diff)
-
src/setMrelCatalog.c (modified) (19 diffs)
-
src/setMrelFinal.c (modified) (3 diffs)
-
src/share_mean_mags.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/relphot/Makefile
r36630 r37037 34 34 $(SRC)/args.$(ARCH).o \ 35 35 $(SRC)/help.$(ARCH).o \ 36 $(SRC)/extra.$(ARCH).o \ 36 37 $(SRC)/bcatalog.$(ARCH).o \ 37 38 $(SRC)/global_stats.$(ARCH).o \ … … 82 83 $(SRC)/args.$(ARCH).o \ 83 84 $(SRC)/help.$(ARCH).o \ 85 $(SRC)/extra.$(ARCH).o \ 84 86 $(SRC)/synthetic_mags.$(ARCH).o \ 85 87 $(SRC)/plotstuff.$(ARCH).o \ 86 88 $(SRC)/liststats.$(ARCH).o \ 87 89 $(SRC)/initialize.$(ARCH).o \ 90 $(SRC)/syncfile.$(ARCH).o \ 88 91 $(SRC)/load_catalogs.$(ARCH).o \ 89 92 $(SRC)/reload_catalogs.$(ARCH).o \ -
trunk/Ohana/src/relphot/doc/mosaic.txt
r33963 r37037 1 2 3 2014.07.09 4 5 * trying to make sense of mosaic.Mcal vs image.Mcal in the context of UBERCAL: 6 7 * relphot_images: 8 * load_images (convert raw FITS table to Image structure, select subset matching selection) 9 * initMosaics (associate mosaics to images (gpc1 photcodes only)) 10 * initMosaicGrid (define spatial range of mosaics [only used by grid analysis]; set Mcal to <image.Mcal> and image.Mcal to 0.0) 11 --- calculate image or mosaic Mcal values 12 * setMcalFinal (set image.Mcal = mosaicMcal) 13 14 * relphot_parallel_regions: 15 * assign_images 16 * makeMosaics (equivalent to initMosaics, but works on full image table, not subset) 17 * setMosaicCenters (set Mcal to <image.Mcal> and image.Mcal to 0.0) <--- this is wrong! 18 (sends images ONLY, not mosaics, to remote machines) 19 (slurps back new image values, applies to db) 20 21 * relphot_parallel_images: 22 * makeMosaics (associate mosaics to images, gpc1 photcodes only) 23 * initMosaicGrid (needed in this one) 24 --- 1 25 2 26 For 'mosaic' zero points, I define the mosaics by grouping the images -
trunk/Ohana/src/relphot/include/relphot.h
r36632 r37037 4 4 # include <signal.h> 5 5 # include <pthread.h> 6 7 # define MARKTIME(MSG,...) { \8 gettimeofday (&stopTimer, (void *) NULL); \9 float dtime = DTIME (stopTimer, startTimer); \10 fprintf (stderr, MSG, __VA_ARGS__); }11 12 # define INITTIME \13 struct timeval startTimer, stopTimer; \14 gettimeofday (&startTimer, (void *) NULL);15 6 16 7 /* # define GRID_V1 */ … … 119 110 float M; 120 111 float dM; 121 float Xm;112 float Mchisq; 122 113 int Nsec; 123 114 unsigned int objID; … … 130 121 float dMcal; 131 122 float dMagSys; 132 float Xm;123 short Xm; 133 124 int nFitPhotom; 134 125 int flags; … … 317 308 int findMosaics PROTO((Catalog *catalog, int Ncatalog, int doMosaicList)); 318 309 319 void makeMosaics (Image *image, off_t Nimage );310 void makeMosaics (Image *image, off_t Nimage, int mergeMcal); 320 311 Mosaic *getMosaicForImage (off_t im); 321 312 void setMosaicCenters (Image *image, off_t Nimage); … … 360 351 void liststats_setmode PROTO((StatType *stats, char *strmode)); 361 352 int liststats PROTO((double *value, double *dvalue, double *wvalue, int N, StatType *stats)); 362 Catalog *load_catalogs PROTO((SkyList *skylist, int *Ncatalog, int hostID, char *hostpath ));363 Catalog *load_catalogs_parallel PROTO((SkyList *sky, int *Ncatalog ));353 Catalog *load_catalogs PROTO((SkyList *skylist, int *Ncatalog, int hostID, char *hostpath, char *syncfile)); 354 Catalog *load_catalogs_parallel PROTO((SkyList *sky, int *Ncatalog, char *syncfile)); 364 355 365 356 SkyList *load_images PROTO((FITS_DB *db, char *regionName, SkyRegion *region)); … … 509 500 int relphot_parallel_images (); 510 501 int relphot_parallel_regions (); 502 503 // in extra.c 504 int isGPC1chip (int photcode); 505 int isGPC1stack (int photcode); 506 int isGPC1warp (int photcode); 507 508 -
trunk/Ohana/src/relphot/src/BrightCatalog.c
r36630 r37037 63 63 64 64 // need to create and assign to flat-field correction 65 GET_COLUMN( dR, "RA_OFF", float);66 GET_COLUMN( dD, "DEC_OFF", float);65 GET_COLUMN(R, "RA", double); 66 GET_COLUMN(D, "DEC", double); 67 67 GET_COLUMN(M, "MAG_SYS", float); 68 68 GET_COLUMN(Mcal, "MAG_CAL", float); … … 85 85 ALLOCATE (measure, MeasureTiny, Nrow); 86 86 for (i = 0; i < Nrow; i++) { 87 measure[i]. dR = dR[i];88 measure[i]. dD = dD[i];87 measure[i].R = R[i]; 88 measure[i].D = D[i]; 89 89 measure[i].M = M[i]; 90 90 measure[i].Mcal = Mcal[i]; … … 105 105 fprintf (stderr, "loaded data for %lld measure\n", (long long) Nrow); 106 106 107 free ( dR);108 free ( dD);107 free (R ); 108 free (D ); 109 109 free (M ); 110 110 free (Mcal ); … … 136 136 137 137 // need to create and assign to flat-field correction 138 GET_COLUMN(R, "RA", double);139 GET_COLUMN(D, "DEC", double);138 GET_COLUMN(R, "RA", double); 139 GET_COLUMN(D, "DEC", double); 140 140 GET_COLUMN(Nmeasure, "NMEAS", int); 141 141 GET_COLUMN(measureOffset, "MEASURE_OFF", int); … … 182 182 183 183 // need to create and assign to flat-field correction 184 GET_COLUMN(M, "MAG", float);185 GET_COLUMN(dM, "MAG_ERR", float);186 GET_COLUMN( Xm,"MAG_CHI", float);187 GET_COLUMN(flags, "FLAGS", int);188 GET_COLUMN(Ncode, "NCODE", short);189 GET_COLUMN(Nused, "NUSED", short);190 GET_COLUMN(M _20, "MAG_20", short);191 GET_COLUMN(M _80, "MAG_80", short);184 GET_COLUMN(M, "MAG", float); 185 GET_COLUMN(dM, "MAG_ERR", float); 186 GET_COLUMN(Mchisq, "MAG_CHI", float); 187 GET_COLUMN(flags, "FLAGS", int); 188 GET_COLUMN(Ncode, "NCODE", short); 189 GET_COLUMN(Nused, "NUSED", short); 190 GET_COLUMN(Mmin, "MAG_MIN", float); 191 GET_COLUMN(Mmax, "MAG_MAX", float); 192 192 gfits_free_header (&theader); 193 193 gfits_free_table (&ftable); … … 196 196 ALLOCATE (secfilt, SecFilt, Nrow); 197 197 for (i = 0; i < Nrow; i++) { 198 secfilt[i].M = M[i];199 secfilt[i].dM = dM[i];200 secfilt[i]. Xm = Xm[i];201 secfilt[i].flags = flags[i];202 secfilt[i].Ncode = Ncode[i];203 secfilt[i].Nused = Nused[i];204 secfilt[i].M _20 = M_20[i];205 secfilt[i].M _80 = M_80[i];198 secfilt[i].M = M[i]; 199 secfilt[i].dM = dM[i]; 200 secfilt[i].Mchisq = Mchisq[i]; 201 secfilt[i].flags = flags[i]; 202 secfilt[i].Ncode = Ncode[i]; 203 secfilt[i].Nused = Nused[i]; 204 secfilt[i].Mmin = Mmin[i]; 205 secfilt[i].Mmax = Mmax[i]; 206 206 } 207 207 fprintf (stderr, "loaded data for %lld secfilt\n", (long long) Nrow); 208 208 209 free (M );210 free (dM );211 free ( Xm);212 free (flags );213 free (Ncode );214 free (Nused );215 free (M _20);216 free (M _80);209 free (M ); 210 free (dM ); 211 free (Mchisq); 212 free (flags ); 213 free (Ncode ); 214 free (Nused ); 215 free (Mmin ); 216 free (Mmax ); 217 217 catalog->secfilt = secfilt; 218 218 // assert Nsecfilt * Naverage = Nrow? … … 265 265 gfits_create_table_header (&theader, "BINTABLE", "MEASURE_TINY"); 266 266 267 gfits_define_bintable_column (&theader, " E", "RA_OFF", "ra offset", "arcsec", 1.0, 0.0);268 gfits_define_bintable_column (&theader, " E", "DEC_OFF", "dec offset", "arcsec", 1.0, 0.0);267 gfits_define_bintable_column (&theader, "D", "RA", "ra", "degree", 1.0, 0.0); 268 gfits_define_bintable_column (&theader, "D", "DEC", "dec", "degree", 1.0, 0.0); 269 269 gfits_define_bintable_column (&theader, "E", "MAG_SYS", "magnitude (sys)", NULL, 1.0, 0.0); 270 270 gfits_define_bintable_column (&theader, "E", "MAG_CAL", "magnitude (cal)", NULL, 1.0, 0.0); … … 274 274 gfits_define_bintable_column (&theader, "E", "Y_CCD", "ccd y coord", "pix", 1.0, 0.0); 275 275 gfits_define_bintable_column (&theader, "E", "EXPTIME", "-2.5 * log (exposure time)", "sec", 1.0, 0.0); 276 gfits_define_bintable_column (&theader, "J", "TIME", "time of exp", "sec", 1.0, 1.0*0x8000);277 gfits_define_bintable_column (&theader, "J", "AVE_REF", "pointer to average table", NULL, 1.0, 1.0*0x8000);278 gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image", NULL, 1.0, 1.0*0x8000);279 gfits_define_bintable_column (&theader, "J", "DB_FLAGS", "flags", NULL, 1.0, 1.0*0x8000);280 gfits_define_bintable_column (&theader, "J", "PHOT_FLAGS", "photflags", NULL, 1.0, 1.0*0x8000);281 gfits_define_bintable_column (&theader, "J", "CAT_ID", "catalog", NULL, 1.0, 1.0*0x8000);282 gfits_define_bintable_column (&theader, "I", "PHOTCODE", "photcode", NULL, 1.0, 1.0*0x80);276 gfits_define_bintable_column (&theader, "J", "TIME", "time of exp", "sec", 1.0, FT_BZERO_INT32); 277 gfits_define_bintable_column (&theader, "J", "AVE_REF", "pointer to average table", NULL, 1.0, FT_BZERO_INT32); 278 gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image", NULL, 1.0, FT_BZERO_INT32); 279 gfits_define_bintable_column (&theader, "J", "DB_FLAGS", "flags", NULL, 1.0, FT_BZERO_INT32); 280 gfits_define_bintable_column (&theader, "J", "PHOT_FLAGS", "photflags", NULL, 1.0, FT_BZERO_INT32); 281 gfits_define_bintable_column (&theader, "J", "CAT_ID", "catalog", NULL, 1.0, FT_BZERO_INT32); 282 gfits_define_bintable_column (&theader, "I", "PHOTCODE", "photcode", NULL, 1.0, FT_BZERO_INT16); 283 283 284 284 // generate the output array that carries the data … … 286 286 287 287 // create intermediate storage arrays 288 float *dR ; ALLOCATE (dR , float, catalog->Nmeasure);289 float *dD ; ALLOCATE (dD , float, catalog->Nmeasure);290 float *M ; ALLOCATE (M , float,catalog->Nmeasure);291 float *Mcal ; ALLOCATE (Mcal , float,catalog->Nmeasure);292 float *dM ; ALLOCATE (dM , float,catalog->Nmeasure);293 float *airmass ; ALLOCATE (airmass , float,catalog->Nmeasure);294 float *Xccd ; ALLOCATE (Xccd , float,catalog->Nmeasure);295 float *Yccd ; ALLOCATE (Yccd , float,catalog->Nmeasure);296 float *dt ; ALLOCATE (dt , float,catalog->Nmeasure);297 int *t ; ALLOCATE (t , int ,catalog->Nmeasure);298 int *averef ; ALLOCATE (averef , int ,catalog->Nmeasure);299 int *imageID ; ALLOCATE (imageID , int ,catalog->Nmeasure);300 int *dbFlags ; ALLOCATE (dbFlags , int ,catalog->Nmeasure);301 int *photFlags ; ALLOCATE (photFlags, int ,catalog->Nmeasure);302 int *catID ; ALLOCATE (catID , int ,catalog->Nmeasure);303 short *photcode ; ALLOCATE (photcode , short,catalog->Nmeasure);288 double *R ; ALLOCATE (R , double, catalog->Nmeasure); 289 double *D ; ALLOCATE (D , double, catalog->Nmeasure); 290 float *M ; ALLOCATE (M , float, catalog->Nmeasure); 291 float *Mcal ; ALLOCATE (Mcal , float, catalog->Nmeasure); 292 float *dM ; ALLOCATE (dM , float, catalog->Nmeasure); 293 float *airmass ; ALLOCATE (airmass , float, catalog->Nmeasure); 294 float *Xccd ; ALLOCATE (Xccd , float, catalog->Nmeasure); 295 float *Yccd ; ALLOCATE (Yccd , float, catalog->Nmeasure); 296 float *dt ; ALLOCATE (dt , float, catalog->Nmeasure); 297 int *t ; ALLOCATE (t , int , catalog->Nmeasure); 298 int *averef ; ALLOCATE (averef , int , catalog->Nmeasure); 299 int *imageID ; ALLOCATE (imageID , int , catalog->Nmeasure); 300 int *dbFlags ; ALLOCATE (dbFlags , int , catalog->Nmeasure); 301 int *photFlags ; ALLOCATE (photFlags, int , catalog->Nmeasure); 302 int *catID ; ALLOCATE (catID , int , catalog->Nmeasure); 303 short *photcode ; ALLOCATE (photcode , short, catalog->Nmeasure); 304 304 305 305 // assign the storage arrays 306 306 MeasureTiny *measure = catalog->measure; 307 307 for (i = 0; i < catalog->Nmeasure; i++) { 308 dR[i] = measure[i].dR ;309 dD[i] = measure[i].dD ;308 R[i] = measure[i].R ; 309 D[i] = measure[i].D ; 310 310 M[i] = measure[i].M ; 311 311 Mcal[i] = measure[i].Mcal ; … … 325 325 326 326 // add the columns to the output array 327 gfits_set_bintable_column (&theader, &ftable, "RA _OFF", dR,catalog->Nmeasure);328 gfits_set_bintable_column (&theader, &ftable, "DEC _OFF", dD,catalog->Nmeasure);327 gfits_set_bintable_column (&theader, &ftable, "RA", R, catalog->Nmeasure); 328 gfits_set_bintable_column (&theader, &ftable, "DEC", D, catalog->Nmeasure); 329 329 gfits_set_bintable_column (&theader, &ftable, "MAG_SYS", M, catalog->Nmeasure); 330 330 gfits_set_bintable_column (&theader, &ftable, "MAG_CAL", Mcal, catalog->Nmeasure); … … 342 342 gfits_set_bintable_column (&theader, &ftable, "PHOTCODE", photcode, catalog->Nmeasure); 343 343 344 free ( dR);345 free ( dD);344 free (R ); 345 free (D ); 346 346 free (M ); 347 347 free (Mcal ); … … 428 428 gfits_create_table_header (&theader, "BINTABLE", "SECFILT"); 429 429 430 gfits_define_bintable_column (&theader, "E", "MAG", " ra offset","arcsec", 1.0, 0.0);431 gfits_define_bintable_column (&theader, "E", "MAG_ERR", " dec offset","arcsec", 1.0, 0.0);432 gfits_define_bintable_column (&theader, "E", "MAG_CHI", " magnitude (sys)",NULL, 1.0, 0.0);433 gfits_define_bintable_column (&theader, "J", "FLAGS", " magnitude (cal)",NULL, 1.0, 0.0);434 gfits_define_bintable_column (&theader, "I", "NCODE", " magnitude (err)",NULL, 1.0, 0.0);435 gfits_define_bintable_column (&theader, "I", "NUSED", " airmass",NULL, 1.0, 0.0);436 gfits_define_bintable_column (&theader, " I", "MAG_20", "ccd x coord", "pix",1.0, 0.0);437 gfits_define_bintable_column (&theader, " I", "MAG_80", "ccd y coord", "pix",1.0, 0.0);430 gfits_define_bintable_column (&theader, "E", "MAG", "", "arcsec", 1.0, 0.0); 431 gfits_define_bintable_column (&theader, "E", "MAG_ERR", "", "arcsec", 1.0, 0.0); 432 gfits_define_bintable_column (&theader, "E", "MAG_CHI", "", NULL, 1.0, 0.0); 433 gfits_define_bintable_column (&theader, "J", "FLAGS", "", NULL, 1.0, 0.0); 434 gfits_define_bintable_column (&theader, "I", "NCODE", "", NULL, 1.0, 0.0); 435 gfits_define_bintable_column (&theader, "I", "NUSED", "", NULL, 1.0, 0.0); 436 gfits_define_bintable_column (&theader, "E", "MAG_MIN", "min valid mag", "mag", 1.0, 0.0); 437 gfits_define_bintable_column (&theader, "E", "MAG_MAX", "max valid mag", "mag", 1.0, 0.0); 438 438 439 439 // generate the output array that carries the data … … 447 447 float *M ; ALLOCATE (M , float, Nsec); 448 448 float *dM ; ALLOCATE (dM , float, Nsec); 449 float * Xm ; ALLOCATE (Xm, float, Nsec);449 float *Mchisq ; ALLOCATE (Mchisq , float, Nsec); 450 450 int *flags ; ALLOCATE (flags , int, Nsec); 451 451 short *Ncode ; ALLOCATE (Ncode , short, Nsec); 452 452 short *Nused ; ALLOCATE (Nused , short, Nsec); 453 short *M_20 ; ALLOCATE (M_20 , short, Nsec);454 short *M_80 ; ALLOCATE (M_80 , short, Nsec);453 float *Mmin ; ALLOCATE (Mmin , float, Nsec); 454 float *Mmax ; ALLOCATE (Mmax , float, Nsec); 455 455 456 456 // assign the storage arrays 457 457 SecFilt *secfilt = catalog->secfilt; 458 458 for (i = 0; i < Nsec; i++) { 459 M [i] = secfilt[i]. M ;460 dM [i] = secfilt[i]. dM ;461 Xm [i] = secfilt[i]. Xm;462 flags [i] = secfilt[i]. flags ;463 Ncode [i] = secfilt[i]. Ncode ;464 Nused [i] = secfilt[i]. Nused ;465 M _20 [i] = secfilt[i]. M_20;466 M _80 [i] = secfilt[i]. M_80;459 M [i] = secfilt[i].M ; 460 dM [i] = secfilt[i].dM ; 461 Mchisq[i] = secfilt[i].Mchisq ; 462 flags [i] = secfilt[i].flags ; 463 Ncode [i] = secfilt[i].Ncode ; 464 Nused [i] = secfilt[i].Nused ; 465 Mmin [i] = secfilt[i].Mmin ; 466 Mmax [i] = secfilt[i].Mmax ; 467 467 } 468 468 469 469 // add the columns to the output array 470 gfits_set_bintable_column (&theader, &ftable, "MAG", M , Nsec);471 gfits_set_bintable_column (&theader, &ftable, "MAG_ERR", dM , Nsec);472 gfits_set_bintable_column (&theader, &ftable, "MAG_CHI", Xm, Nsec);473 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags , Nsec);474 gfits_set_bintable_column (&theader, &ftable, "NCODE", Ncode , Nsec);475 gfits_set_bintable_column (&theader, &ftable, "NUSED", Nused , Nsec);476 gfits_set_bintable_column (&theader, &ftable, "MAG_ 20", M_20, Nsec);477 gfits_set_bintable_column (&theader, &ftable, "MAG_ 80", M_80, Nsec);470 gfits_set_bintable_column (&theader, &ftable, "MAG", M , Nsec); 471 gfits_set_bintable_column (&theader, &ftable, "MAG_ERR", dM , Nsec); 472 gfits_set_bintable_column (&theader, &ftable, "MAG_CHI", Mchisq, Nsec); 473 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags , Nsec); 474 gfits_set_bintable_column (&theader, &ftable, "NCODE", Ncode , Nsec); 475 gfits_set_bintable_column (&theader, &ftable, "NUSED", Nused , Nsec); 476 gfits_set_bintable_column (&theader, &ftable, "MAG_MIN", Mmin , Nsec); 477 gfits_set_bintable_column (&theader, &ftable, "MAG_MAX", Mmax , Nsec); 478 478 479 479 free (M ); 480 480 free (dM ); 481 free ( Xm);481 free (Mchisq ); 482 482 free (flags ); 483 483 free (Ncode ); 484 484 free (Nused ); 485 free (M _20);486 free (M _80);485 free (Mmin ); 486 free (Mmax ); 487 487 488 488 gfits_fwrite_Theader (f, &theader); -
trunk/Ohana/src/relphot/src/GridOps.c
r34088 r37037 414 414 // select the color- and airmass-corrected observed magnitude for this star 415 415 // XXX need to be able to turn off the color-correction until initial average mags are found 416 Msys = PhotCatTiny (&catalog[c].measureT[m] );416 Msys = PhotCatTiny (&catalog[c].measureT[m], MAG_CLASS_PSF); 417 417 if (isnan(Msys)) { 418 418 Nsys++; … … 573 573 574 574 n = catalog[c].measureT[m].averef; 575 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt] );575 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt], MAG_CLASS_PSF); 576 576 if (isnan(Msys)) { 577 577 Nsys++; … … 651 651 652 652 n = catalog[c].measureT[m].averef; 653 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt] );653 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt], MAG_CLASS_PSF); 654 654 655 655 xlist[N] = Xmeas[c][m]; -
trunk/Ohana/src/relphot/src/ImageMagIO.c
r36630 r37037 61 61 GET_COLUMN (dMcal, "MCAL_ERR", float); 62 62 GET_COLUMN (dMagSys, "MCAL_SYSERR", float); 63 GET_COLUMN (Xm, "CHISQ", float);64 63 GET_COLUMN (nFitPhotom, "NFIT", int); 65 64 GET_COLUMN (flags, "FLAGS", int); 66 65 GET_COLUMN (ubercalDist, "UDIST", int); 67 66 GET_COLUMN (imageID, "ID", int); 67 GET_COLUMN (Xm, "CHISQ", short); 68 68 69 69 // free the memory associated with the FITS files … … 121 121 gfits_create_table_header (&theader, "BINTABLE", "IMAGE_MAGS"); 122 122 123 gfits_define_bintable_column (&theader, "E", "MCAL", "cal offset", "magnitudes", 1.0, 0.0);124 gfits_define_bintable_column (&theader, "E", "MCAL_ERR", "cal error", "magnitudes", 1.0, 0.0);125 gfits_define_bintable_column (&theader, "E", "MCAL_SYSERR", "systematic error", "magnitudes", 1.0, 0.0);126 gfits_define_bintable_column (&theader, " E", "CHISQ", "cal chisq", "unitless",1.0, 0.0);127 gfits_define_bintable_column (&theader, "J", " NFIT", "number of fitted stars", "unitless",1.0, 0.0);128 gfits_define_bintable_column (&theader, "J", " FLAGS", "analysis flags", "unitless",1.0, 0.0);129 gfits_define_bintable_column (&theader, "J", " UDIST", "distance to ubercal images", "images",1.0, 0.0);130 gfits_define_bintable_column (&theader, " J", "ID", "image ID", "unitless", 1.0, 0.0);123 gfits_define_bintable_column (&theader, "E", "MCAL", "cal offset", "magnitudes", 1.0, 0.0); 124 gfits_define_bintable_column (&theader, "E", "MCAL_ERR", "cal error", "magnitudes", 1.0, 0.0); 125 gfits_define_bintable_column (&theader, "E", "MCAL_SYSERR", "systematic error", "magnitudes", 1.0, 0.0); 126 gfits_define_bintable_column (&theader, "J", "NFIT", "number of fitted stars", "unitless", 1.0, 0.0); 127 gfits_define_bintable_column (&theader, "J", "FLAGS", "analysis flags", "unitless", 1.0, 0.0); 128 gfits_define_bintable_column (&theader, "J", "UDIST", "distance to ubercal images", "images", 1.0, 0.0); 129 gfits_define_bintable_column (&theader, "J", "ID", "image ID", "unitless", 1.0, 0.0); 130 gfits_define_bintable_column (&theader, "I", "CHISQ", "cal chisq", "unitless", 1.0, FT_BZERO_INT16); 131 131 132 132 // generate the output array that carries the data -
trunk/Ohana/src/relphot/src/ImageOps.c
r36630 r37037 531 531 liststats_setmode (&stats, STATMODE); 532 532 533 if (FREEZE_IMAGES) return;533 // FREEZE_IMAGES only applies to mosaic data (eg, gpc1) 534 534 535 535 fprintf (stderr, "limiting negative clouds to %f\n", CLOUD_TOLERANCE); … … 561 561 if (!bad) continue; 562 562 } 563 564 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 563 565 564 566 // UBERCAL image: if this is an ubercal image, set minUbercalDist to 0: … … 608 610 609 611 n = catalog[c].measureT[m].averef; 610 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt] );612 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt], MAG_CLASS_PSF); 611 613 if (isnan(Msys)) { 612 614 Nsys++; … … 695 697 double MaxOffset, MaxScatter, MedOffset; 696 698 697 if (FREEZE_IMAGES) return;699 // if (FREEZE_IMAGES) return; 698 700 699 701 if (VERBOSE) fprintf (stderr, "marking poor images\n"); … … 706 708 for (i = N = 0; i < Nimage; i++) { 707 709 if (image[i].flags & IMAGE_BAD) continue; 710 711 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 712 708 713 mlist[N] = image[i].Mcal; 709 714 slist[N] = image[i].dMcal; … … 797 802 Graphdata graphdata; 798 803 799 if (FREEZE_IMAGES) return;804 // if (FREEZE_IMAGES) return; 800 805 801 806 ALLOCATE (xlist, double, Nimage); … … 810 815 float mindMcal = +100.0; 811 816 float maxdMcal = -100.0; 812 for (i = 0; i < Nimage; i++) { 813 Mlist[i] = image[i].Mcal; 814 dlist[i] = image[i].dMcal; 815 xlist[i] = image[i].secz; 817 818 int Nplot = 0; 819 820 for (i = 0; i < Nimage; i++) { 821 822 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 823 824 Mlist[Nplot] = image[i].Mcal; 825 dlist[Nplot] = image[i].dMcal; 826 xlist[Nplot] = image[i].secz; 816 827 minAirmass = MIN (image[i].secz, minAirmass); 817 828 maxAirmass = MAX (image[i].secz, maxAirmass); … … 820 831 mindMcal = MIN (image[i].dMcal, mindMcal); 821 832 maxdMcal = MAX (image[i].dMcal, maxdMcal); 833 834 Nplot ++; 822 835 } 823 836 … … 852 865 for (i = 0; i < NBIN; i++) xlist[i] = 0.00025*i; 853 866 bzero (Mlist, NBIN*sizeof(double)); 854 for (i = 0; i < Nimage; i++) { 867 868 for (i = 0; i < Nimage; i++) { 869 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 870 855 871 bin = image[i].dMcal / 0.00025; 856 872 bin = MAX (0, MIN (NBIN - 1, bin)); … … 877 893 StatType stats; 878 894 bzero (&stats, sizeof (StatType)); 879 if (FREEZE_IMAGES) return (stats); 895 896 // we no longer blindly apply FREEZE_IMAGES to all images, only to mosaics 897 // if (FREEZE_IMAGES) return (stats); 880 898 881 899 ALLOCATE (list, double, Nimage); … … 885 903 for (i = 0; i < Nimage; i++) { 886 904 if (image[i].flags & IMAGE_BAD) continue; 905 906 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 887 907 888 908 N = 0; … … 920 940 921 941 bzero (&stats, sizeof (StatType)); 922 if (FREEZE_IMAGES) return (stats);942 // if (FREEZE_IMAGES) return (stats); 923 943 924 944 ALLOCATE (list, double, Nimage); … … 929 949 930 950 if (image[i].flags & IMAGE_BAD) continue; 951 952 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 931 953 932 954 list[n] = pow (10.0, 0.01*image[i].Xm); … … 950 972 951 973 bzero (&stats, sizeof (StatType)); 952 if (FREEZE_IMAGES) return (stats);974 // if (FREEZE_IMAGES) return (stats); 953 975 954 976 ALLOCATE (list, double, Nimage); … … 959 981 960 982 if (image[i].flags & IMAGE_BAD) continue; 983 984 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 961 985 962 986 list[n] = image[i].Mcal; … … 980 1004 981 1005 bzero (&stats, sizeof (StatType)); 982 if (FREEZE_IMAGES) return (stats);1006 // if (FREEZE_IMAGES) return (stats); 983 1007 984 1008 ALLOCATE (list, double, Nimage); … … 989 1013 990 1014 if (image[i].flags & IMAGE_BAD) continue; 1015 1016 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 991 1017 992 1018 list[n] = image[i].dMcal; -
trunk/Ohana/src/relphot/src/ImageSubset.c
r36491 r37037 126 126 gfits_create_table_header (&theader, "BINTABLE", "IMAGE_SUBSET"); 127 127 128 gfits_define_bintable_column (&theader, "E", "MCAL", "zero point offset", "magnitudes", 1.0, 0.0); 129 gfits_define_bintable_column (&theader, "E", "MCAL_ERR", "zero point error", "magnitudes", 1.0, 0.0); 130 131 gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image ID", NULL, 1.0, 1.0*0x8000); 132 gfits_define_bintable_column (&theader, "J", "PHOTOM_MAP", "map", NULL, 1.0, 1.0*0x8000); 133 gfits_define_bintable_column (&theader, "J", "FLAGS", "flags", NULL, 1.0, 1.0*0x8000); 134 135 gfits_define_bintable_column (&theader, "J", "TESS_ID", "ID", NULL, 1.0, 0.0); 136 gfits_define_bintable_column (&theader, "J", "PROJ_ID", "ID", NULL, 1.0, 0.0); 137 gfits_define_bintable_column (&theader, "J", "SKYCELL_ID", "ID", NULL, 1.0, 0.0); 138 139 gfits_define_bintable_column (&theader, "J", "TZERO", "exposure start", NULL, 1.0, 1.0*0x8000); 140 gfits_define_bintable_column (&theader, "I", "TRATE", "tti rate", NULL, 1.0, 0.0); 141 142 gfits_define_bintable_column (&theader, "I", "UBERCAL_DIST", "ubercal distance", NULL, 1.0, 1.0*0x80); 128 gfits_define_bintable_column (&theader, "E", "MCAL", "zero point offset", "magnitudes", 1.0, 0.0); 129 gfits_define_bintable_column (&theader, "E", "MCAL_ERR", "zero point error", "magnitudes", 1.0, 0.0); 130 gfits_define_bintable_column (&theader, "J", "IMAGE_ID", "image ID", NULL, 1.0, FT_BZERO_INT32); 131 gfits_define_bintable_column (&theader, "J", "PHOTOM_MAP", "map", NULL, 1.0, FT_BZERO_INT32); 132 gfits_define_bintable_column (&theader, "J", "FLAGS", "flags", NULL, 1.0, FT_BZERO_INT32); 133 gfits_define_bintable_column (&theader, "J", "TESS_ID", "ID", NULL, 1.0, 0.0); 134 gfits_define_bintable_column (&theader, "J", "PROJ_ID", "ID", NULL, 1.0, 0.0); 135 gfits_define_bintable_column (&theader, "J", "SKYCELL_ID", "ID", NULL, 1.0, 0.0); 136 gfits_define_bintable_column (&theader, "J", "TZERO", "exposure start", NULL, 1.0, FT_BZERO_INT32); 137 gfits_define_bintable_column (&theader, "I", "TRATE", "tti rate", NULL, 1.0, FT_BZERO_INT16); 138 gfits_define_bintable_column (&theader, "I", "UBERCAL_DIST", "ubercal distance", NULL, 1.0, 0.0); 143 139 144 140 // generate the output array that carries the data … … 152 148 153 149 // create intermediate storage arrays 154 ALLOCATE (Mcal, float, Nimage);155 ALLOCATE (dMcal, float, Nimage);150 ALLOCATE (Mcal, float, Nimage); 151 ALLOCATE (dMcal, float, Nimage); 156 152 ALLOCATE (imageID, unsigned int, Nimage); 157 153 ALLOCATE (map, unsigned int, Nimage); -
trunk/Ohana/src/relphot/src/MeanMagIO.c
r36630 r37037 60 60 GET_COLUMN (M, "MAG", float); 61 61 GET_COLUMN (dM, "MAG_ERR", float); 62 GET_COLUMN ( Xm,"MAG_CHISQ", float);62 GET_COLUMN (Mchisq, "MAG_CHISQ", float); 63 63 GET_COLUMN (Nsec, "NSEC", int); 64 64 GET_COLUMN (objID, "OBJ_ID", int); … … 73 73 ALLOCATE (meanmags, MeanMag, Nrow); 74 74 for (i = 0; i < Nrow; i++) { 75 meanmags[i].M = M [i];76 meanmags[i].dM = dM [i];77 meanmags[i]. Xm = Xm[i];78 meanmags[i].Nsec = Nsec [i];79 meanmags[i].objID = objID [i];80 meanmags[i].catID = catID [i];75 meanmags[i].M = M [i]; 76 meanmags[i].dM = dM [i]; 77 meanmags[i].Mchisq = Mchisq [i]; 78 meanmags[i].Nsec = Nsec [i]; 79 meanmags[i].objID = objID [i]; 80 meanmags[i].catID = catID [i]; 81 81 } 82 82 fprintf (stderr, "loaded data for %lld objects (* filters)\n", (long long) Nrow); 83 83 84 free (M );85 free (dM );86 free ( Xm);87 free (Nsec );88 free (objID );89 free (catID );84 free (M ); 85 free (dM ); 86 free (Mchisq); 87 free (Nsec ); 88 free (objID ); 89 free (catID ); 90 90 91 91 *nmeanmags = Nrow; … … 118 118 gfits_define_bintable_column (&theader, "E", "MAG_ERR", "mean magnitude error", "magnitudes", 1.0, 0.0); 119 119 gfits_define_bintable_column (&theader, "E", "MAG_CHISQ", "mean magnitude chisq", "unitless", 1.0, 0.0); 120 gfits_define_bintable_column (&theader, "J", "NSEC", "secfilt sequence", NULL, 1.0, 1.0*0x8000);121 gfits_define_bintable_column (&theader, "J", "OBJ_ID", "object ID", NULL, 1.0, 1.0*0x8000);122 gfits_define_bintable_column (&theader, "J", "CAT_ID", "catalog ID", NULL, 1.0, 1.0*0x8000);120 gfits_define_bintable_column (&theader, "J", "NSEC", "secfilt sequence", NULL, 1.0, FT_BZERO_INT32); 121 gfits_define_bintable_column (&theader, "J", "OBJ_ID", "object ID", NULL, 1.0, FT_BZERO_INT32); 122 gfits_define_bintable_column (&theader, "J", "CAT_ID", "catalog ID", NULL, 1.0, FT_BZERO_INT32); 123 123 124 124 // generate the output array that carries the data 125 125 gfits_create_table (&theader, &ftable); 126 126 127 float *M, *dM, * Xm;127 float *M, *dM, *Mchisq; 128 128 int *Nsec; 129 129 unsigned int *objID, *catID; … … 132 132 ALLOCATE (M, float, Nmeanmags); 133 133 ALLOCATE (dM, float, Nmeanmags); 134 ALLOCATE ( Xm,float, Nmeanmags);134 ALLOCATE (Mchisq, float, Nmeanmags); 135 135 ALLOCATE (Nsec, int, Nmeanmags); 136 136 ALLOCATE (objID, unsigned int, Nmeanmags); … … 139 139 // assign the storage arrays 140 140 for (i = 0; i < Nmeanmags; i++) { 141 M [i] = meanmags[i].M;142 dM [i] = meanmags[i].dM;143 Xm [i] = meanmags[i].Xm;144 Nsec [i] = meanmags[i].Nsec;145 objID [i] = meanmags[i].objID;146 catID [i] = meanmags[i].catID;141 M [i] = meanmags[i].M ; 142 dM [i] = meanmags[i].dM ; 143 Mchisq[i] = meanmags[i].Mchisq; 144 Nsec [i] = meanmags[i].Nsec ; 145 objID [i] = meanmags[i].objID ; 146 catID [i] = meanmags[i].catID ; 147 147 } 148 148 … … 150 150 gfits_set_bintable_column (&theader, &ftable, "MAG", M, Nmeanmags); 151 151 gfits_set_bintable_column (&theader, &ftable, "MAG_ERR", dM, Nmeanmags); 152 gfits_set_bintable_column (&theader, &ftable, "MAG_CHISQ", Xm,Nmeanmags);152 gfits_set_bintable_column (&theader, &ftable, "MAG_CHISQ", Mchisq, Nmeanmags); 153 153 gfits_set_bintable_column (&theader, &ftable, "NSEC", Nsec, Nmeanmags); 154 154 gfits_set_bintable_column (&theader, &ftable, "OBJ_ID", objID, Nmeanmags); 155 155 gfits_set_bintable_column (&theader, &ftable, "CAT_ID", catID, Nmeanmags); 156 156 157 free (M );158 free (dM );159 free ( Xm);160 free (Nsec );161 free (objID );162 free (catID );157 free (M ); 158 free (dM ); 159 free (Mchisq); 160 free (Nsec ); 161 free (objID ); 162 free (catID ); 163 163 164 164 FILE *f = fopen (filename, "w"); -
trunk/Ohana/src/relphot/src/MosaicOps.c
r36630 r37037 1 1 # include "relphot.h" 2 2 void plot_setMcal (double *list, int Npts, StatType *stats, float clouds); 3 off_t findMosaic (unsigned int *startTimes, off_t Nmosaic, unsigned int start); 3 4 4 5 // see discussion in ImagesOps.c re: IDX_T … … 36 37 // MosaicN_image was 'Nimlist' 37 38 // MosaicToImage was 'imlist' 39 40 void sort_times (unsigned int *T, int N) { 41 42 # define SWAPFUNC(A,B){ unsigned int tmp; \ 43 tmp = T[A]; T[A] = T[B]; T[B] = tmp; \ 44 } 45 # define COMPARE(A,B)(T[A] < T[B]) 46 47 OHANA_SORT (N, COMPARE, SWAPFUNC); 48 49 # undef SWAPFUNC 50 # undef COMPARE 51 52 } 38 53 39 54 /* find mosaic frames (unique time periods & photcode name matches mosaic) */ … … 96 111 97 112 /* a new mosaic, define ranges -- preserve the original values incase this image is not used */ 98 mosaic[Nmosaic].start = start;99 mosaic[Nmosaic].stop = stop;100 mosaic[Nmosaic].Mcal = 0.0; // note : mosaic stores only offsets relative to the original image values101 mosaic[Nmosaic].dMcal = 0.0; // note : at the end, mosaic.Mcal is added back to the input images102 mosaic[Nmosaic].dMsys = 0.0;103 mosaic[Nmosaic].Xm = 0.0;113 mosaic[Nmosaic].start = start; 114 mosaic[Nmosaic].stop = stop; 115 mosaic[Nmosaic].Mcal = 0.0; // note : mosaic stores only offsets relative to the original image values 116 mosaic[Nmosaic].dMcal = 0.0; // note : at the end, mosaic.Mcal is added back to the input images 117 mosaic[Nmosaic].dMsys = 0.0; 118 mosaic[Nmosaic].Xm = 0.0; 104 119 mosaic[Nmosaic].flags = image[i].flags; 105 mosaic[Nmosaic].secz = image[i].secz;120 mosaic[Nmosaic].secz = image[i].secz; 106 121 mosaic[Nmosaic].photcode = GetPhotcodeEquivCodebyCode (image[i].photcode); 107 122 … … 136 151 } 137 152 138 off_t findMosaic (unsigned int *startTimes, off_t Nmosaic, unsigned int start);139 140 void sort_times (unsigned int *T, int N) {141 142 # define SWAPFUNC(A,B){ unsigned int tmp; \143 tmp = T[A]; T[A] = T[B]; T[B] = tmp; \144 }145 # define COMPARE(A,B)(T[A] < T[B])146 147 OHANA_SORT (N, COMPARE, SWAPFUNC);148 149 # undef SWAPFUNC150 # undef COMPARE151 152 }153 154 153 /* find mosaic frames (unique time periods) (NOTE : we do NOT require matching photcodes...) 155 154 this function will also identify the images NOT in the subset which belong to a selected mosaic … … 157 156 void initMosaics (Image *subset, off_t Nsubset, Image *image, char *inSubset, off_t Nimage) { 158 157 159 off_t i, j, status,found, NMOSAIC, *MosaicN_IMAGE;158 off_t i, j, found, NMOSAIC, *MosaicN_IMAGE; 160 159 unsigned int start, stop, *startTimes, *startTimesMosaic; 161 char *pname;162 160 163 161 if (!MOSAIC_ZEROPT) return; … … 172 170 // generate a list of all subset image start times 173 171 ALLOCATE (startTimes, unsigned int, Nsubset); 172 int Nmoschip = 0; 174 173 for (i = 0; i < Nsubset; i++) { 175 startTimes[i] = subset[i].tzero; 176 } 177 sort_times (startTimes, Nsubset); 174 if (!isGPC1chip(subset[i].photcode)) continue; 175 startTimes[Nmoschip] = subset[i].tzero; 176 Nmoschip ++; 177 } 178 sort_times (startTimes, Nmoschip); 178 179 MARKTIME("create array of all image obstimes: %f sec\n", dtime); 179 180 … … 184 185 185 186 // generate a list of the unique start times (these define the mosaics) 186 for (i = 0; i < Nsubset; i++) { 187 if (startTimes[i] < startTimesMosaic[Nmosaic]) { 188 fprintf (stderr, "error?\n"); 189 abort(); 190 } 187 for (i = 0; i < Nmoschip; i++) { 188 myAssert (startTimes[i] >= startTimesMosaic[Nmosaic], "times out of order?"); 191 189 if (startTimes[i] == startTimesMosaic[Nmosaic]) continue; 192 190 Nmosaic ++; … … 210 208 for (i = 0; i < Nmosaic; i++) { 211 209 /* a new mosaic, define ranges */ 212 mosaic[i].start = startTimesMosaic[i];213 mosaic[i].stop = 0;214 mosaic[i].Mcal = 0.0;215 mosaic[i].dMcal = 0.0;216 mosaic[i].dMsys = 0.0;217 mosaic[i].Xm = 0.0;218 mosaic[i].flags = 0;219 mosaic[i].secz = NAN;210 mosaic[i].start = startTimesMosaic[i]; 211 mosaic[i].stop = 0; 212 mosaic[i].Mcal = 0.0; 213 mosaic[i].dMcal = 0.0; 214 mosaic[i].dMsys = 0.0; 215 mosaic[i].Xm = 0.0; 216 mosaic[i].flags = 0; 217 mosaic[i].secz = NAN; 220 218 mosaic[i].photcode = 0; 221 mosaic[i].skipCal = FALSE;219 mosaic[i].skipCal = FALSE; 222 220 223 221 memset (&mosaic[i].coords, 0, sizeof(Coords)); … … 238 236 } 239 237 240 /* select valid mosaic images by photcode */ 241 pname = GetPhotcodeNamebyCode (image[i].photcode); 242 if (!pname) continue; 243 status = strncmp (pname, MOSAICNAME, strlen (MOSAICNAME)); 244 if (status) continue; 238 if (!isGPC1chip(image[i].photcode)) continue; 245 239 246 240 /* set image time range */ … … 262 256 263 257 // assign each image to a mosaic 258 int Nsimple = 0; 264 259 for (i = 0; i < Nsubset; i++) { 265 260 ImageToMosaic[i] = -1; 266 261 267 /* select valid mosaic images by photcode */268 pname = GetPhotcodeNamebyCode (subset[i].photcode);269 status = strncmp (pname, MOSAICNAME, strlen (MOSAICNAME));270 if (status) continue;262 if (!isGPC1chip(subset[i].photcode)) { 263 Nsimple ++; 264 continue; 265 } 271 266 272 267 start = subset[i].tzero; … … 299 294 abort(); 300 295 } 301 mosaic[j].stop = stop;302 mosaic[j].Mcal = 0.0;303 mosaic[j].dMcal = 0.0;304 mosaic[j].Xm = 0.0;305 mosaic[j].dMsys = subset[i].flags;306 mosaic[j].flags = subset[i].flags;307 mosaic[j].secz = subset[i].secz;296 mosaic[j].stop = stop; 297 mosaic[j].Mcal = 0.0; 298 mosaic[j].dMcal = 0.0; 299 mosaic[j].Xm = 0.0; 300 mosaic[j].dMsys = subset[i].flags; 301 mosaic[j].flags = subset[i].flags; 302 mosaic[j].secz = subset[i].secz; 308 303 mosaic[j].photcode = GetPhotcodeEquivCodebyCode (subset[i].photcode); 309 304 } … … 316 311 initMosaicGrid (subset, Nsubset); 317 312 318 fprintf (stderr, "matched %d images to %d mosaics \n", (int) Nsubset, (int) Nmosaic);313 fprintf (stderr, "matched %d images to %d mosaics, %d simple chips not matched to mosaics\n", (int) (Nsubset - Nsimple), (int) Nmosaic, (int) Nsimple); 319 314 return; 320 315 } 321 316 322 /* find mosaic frames (unique time periods) (NOTE : we do NOT require matching photcodes but we 323 match images by MOSAICNAME. this last point is weak: it forces a single camera at a time. 324 we can extend the logic to multiple cameras if we make list of MOSAICNAMES (better to assign a camera ID) 317 /* find mosaic frames (unique time periods) (NOTE : require gpc1 chips, which is pretty limiting) 318 if mergeMcal is TRUE, <image.Mcal> values will be saved on Mosaic.Mcal 325 319 */ 326 void makeMosaics (Image *image, off_t Nimage ) {327 328 off_t i, j, status,found, NMOSAIC, *MosaicN_IMAGE;320 void makeMosaics (Image *image, off_t Nimage, int mergeMcal) { 321 322 off_t i, j, found, NMOSAIC, *MosaicN_IMAGE; 329 323 unsigned int start, stop, *startTimes, *startTimesMosaic; 330 char *pname;331 324 332 325 if (!MOSAIC_ZEROPT) return; … … 341 334 // generate a list of all image start times 342 335 ALLOCATE (startTimes, unsigned int, Nimage); 336 int Nmoschip = 0; 343 337 for (i = 0; i < Nimage; i++) { 344 startTimes[i] = image[i].tzero; 345 } 346 sort_times (startTimes, Nimage); 338 if (!isGPC1chip(image[i].photcode)) continue; 339 startTimes[Nmoschip] = image[i].tzero; 340 Nmoschip ++; 341 } 342 sort_times (startTimes, Nmoschip); 347 343 MARKTIME("create array of all image obstimes: %f sec\n", dtime); 348 344 … … 353 349 354 350 // generate a list of the unique start times (these define the mosaics) 355 for (i = 0; i < Nimage; i++) { 356 if (startTimes[i] < startTimesMosaic[Nmosaic]) { 357 fprintf (stderr, "error?\n"); 358 abort(); 359 } 351 for (i = 0; i < Nmoschip; i++) { 352 myAssert (startTimes[i] >= startTimesMosaic[Nmosaic], "times out of order?"); 360 353 if (startTimes[i] == startTimesMosaic[Nmosaic]) continue; 361 354 Nmosaic ++; … … 379 372 // init the mosaic array values 380 373 for (i = 0; i < Nmosaic; i++) { 381 mosaic[i].start = startTimesMosaic[i];382 mosaic[i].stop = 0;383 mosaic[i].Mcal = 0.0;384 mosaic[i].dMcal = 0.0;385 mosaic[i].dMsys = 0.0;386 mosaic[i].Xm = 0.0;387 mosaic[i].flags = 0;388 mosaic[i].secz = NAN;374 mosaic[i].start = startTimesMosaic[i]; 375 mosaic[i].stop = 0; 376 mosaic[i].Mcal = 0.0; 377 mosaic[i].dMcal = 0.0; 378 mosaic[i].dMsys = 0.0; 379 mosaic[i].Xm = 0.0; 380 mosaic[i].flags = 0; 381 mosaic[i].secz = NAN; 389 382 mosaic[i].photcode = 0; 390 mosaic[i].skipCal = FALSE;383 mosaic[i].skipCal = FALSE; 391 384 392 385 memset (&mosaic[i].coords, 0, sizeof(Coords)); … … 401 394 402 395 // assign each image to a mosaic 396 int Nsimple = 0; 403 397 for (i = 0; i < Nimage; i++) { 404 398 ImageToMosaic[i] = -1; 405 399 406 /* select valid mosaic images by photcode */ 407 pname = GetPhotcodeNamebyCode (image[i].photcode); 408 if (!pname) continue; 409 410 status = strncmp (pname, MOSAICNAME, strlen (MOSAICNAME)); 411 if (status) continue; 400 if (!isGPC1chip(image[i].photcode)) { 401 Nsimple ++; 402 continue; 403 } 412 404 413 405 start = image[i].tzero; … … 440 432 abort(); 441 433 } 442 mosaic[j].stop = stop;443 mosaic[j].Mcal = 0.0;444 mosaic[j].dMcal = 0.0;445 mosaic[j].Xm = 0.0;446 mosaic[j].dMsys = image[i].flags;447 mosaic[j].flags = image[i].flags;448 mosaic[j].secz = image[i].secz;434 mosaic[j].stop = stop; 435 mosaic[j].Mcal = 0.0; 436 mosaic[j].dMcal = 0.0; 437 mosaic[j].Xm = 0.0; 438 mosaic[j].dMsys = image[i].flags; 439 mosaic[j].flags = image[i].flags; 440 mosaic[j].secz = image[i].secz; 449 441 mosaic[j].photcode = GetPhotcodeEquivCodebyCode (image[i].photcode); 450 442 } … … 456 448 free (startTimesMosaic); 457 449 450 if (mergeMcal) { 451 initMosaicGrid (image, Nimage); 452 } 453 458 454 fprintf (stderr, "matched %d images to %d mosaics\n", (int) Nimage, (int) Nmosaic); 459 460 455 return; 461 456 } … … 513 508 off_t i, j, m, NX, NY, NC, Nc; 514 509 double R, D, Rmid, Dmid; 515 double Mcal, dMcal, Xm;516 510 double *Rc, *Dc; 517 511 … … 523 517 Nc = 0; 524 518 Rmid = Dmid = NAN; 525 Mcal = dMcal = Xm = 0;526 519 for (j = 0; j < MosaicN_Image[i]; j++) { 527 520 m = MosaicToImage[i][j]; … … 563 556 REALLOCATE (Dc, double, NC); 564 557 } 565 566 Mcal += image[m].Mcal;567 dMcal += image[m].dMcal;568 Xm += image[m].Xm;569 570 // for ubercal images, we (elsewhere) keep Mcal frozen571 572 /* we are using mosaic.Mcal, not image.Mcal. reset image.Mcal */573 image[m].Mcal = 0.0;574 image[m].dMcal = NAN;575 image[m].Xm = NAN_S_SHORT;576 558 } 577 559 … … 617 599 mosaic[i].coords.pc2_1 = 0.0; 618 600 619 mosaic[i].Mcal = Mcal / MosaicN_Image[i];620 mosaic[i].dMcal = dMcal / MosaicN_Image[i];621 mosaic[i].Xm = Xm / MosaicN_Image[i];601 mosaic[i].Mcal = 0.0; 602 mosaic[i].dMcal = 0.0; 603 mosaic[i].Xm = 0.0; 622 604 } 623 605 return; … … 635 617 double R, D, Rmin, Rmax, Dmin, Dmax; 636 618 double Mcal, dMcal, Xm; 619 620 fprintf (stderr, "*** moving Mcal from image.Mcal to mosaic.Mcal ***\n"); 637 621 638 622 dXmax = dYmax = 0.0; … … 667 651 Dmin = MIN (Dmin, D); 668 652 Dmax = MAX (Dmax, D); 653 654 /* we are using mosaic.Mcal, not image.Mcal. reset image.Mcal */ 655 656 // XXX: how does this work with UBERCAL? We want to keep the Mcal values supplied by ubercal, but 657 // solve for a single offset for each exposure (Mosaic.Mcal). 658 // we also want to keep the flat-field terms for each exposure (regardless of ubercal or not) 659 // if it helps, note that ubercal uses a single zp per exposure, so the mean of those values is the same as the value 660 669 661 Mcal += image[m].Mcal; 670 662 dMcal += image[m].dMcal; 671 663 Xm += image[m].Xm; 672 664 673 // XXX: how does this work with UBERCAL? We want to keep the Mcal values supplied by ubercal, but 674 // solve for a single offset for each exposure (Mosaic.Mcal). 675 676 // we also want to keep the flat-field terms for each exposure (regardless of ubercal or not) 677 678 // if it helps, note that ubercal uses a single zp per exposure, so the mean of those values is the same as the value 679 680 /* we are using mosaic.Mcal, not image.Mcal. reset image.Mcal */ 681 image[m].Mcal = 0.0; 682 image[m].dMcal = NAN; 683 image[m].Xm = NAN_S_SHORT; 665 image[m].Mcal = 0.0; 666 image[m].dMcal = NAN; 667 image[m].Xm = NAN_S_SHORT; 684 668 } 685 669 dS /= MosaicN_Image[i]; … … 697 681 RD_to_XY (&dX, &dY, Rmax, Dmax, &mosaic[i].coords); 698 682 699 mosaic[i].Mcal = Mcal / MosaicN_Image[i];700 mosaic[i].dMcal = dMcal / MosaicN_Image[i];701 mosaic[i].Xm = Xm / MosaicN_Image[i];683 mosaic[i].Mcal = Mcal / MosaicN_Image[i]; 684 mosaic[i].dMcal = dMcal / MosaicN_Image[i]; 685 mosaic[i].Xm = Xm / MosaicN_Image[i]; 702 686 } 703 687 if (!USE_GRID) return; … … 709 693 } 710 694 711 // XXX : what about mosaics with skipCal == TRUE?712 695 void setMcalFinal () { 713 696 … … 719 702 image = getimages (&Nimage, NULL); 720 703 721 // XXX I think this is OK in the ubercal context, but probably need to skip UBERCAL 722 // images? (no need to update them) 704 fprintf (stderr, "*** return Mcal from mosaic.Mcal to image.Mcal ***\n"); 723 705 724 706 // copy the mosaic results to the images. set the mosaic Mcal to 0.0 since we have moved its … … 840 822 mosID = ImageToMosaic[idx]; 841 823 if (mosID < 0) { 842 Image *image = getimage(idx); 843 fprintf (stderr, "unmatched image %s\n", image[0].name); 824 // Image *image = getimage(idx); 825 // fprintf (stderr, "unmatched image %s\n", image[0].name); 826 // skip measurements from simple chips (not matched to a mosaic by definition) 844 827 return; 845 828 } … … 882 865 if (!MOSAIC_ZEROPT) return (0); 883 866 867 // unassigned measurements belong to simple chips 884 868 i = MeasureToMosaic[cat][meas]; 885 if (i == -1) return ( NAN);869 if (i == -1) return (0.0); 886 870 887 871 if (mosaic[i].flags & IMAGE_BAD) return (NAN); … … 1127 1111 1128 1112 off_t n = catalog[c].measureT[m].averef; 1129 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt] );1113 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt], MAG_CLASS_PSF); 1130 1114 1131 1115 float delta = Msys - Mrel - Mcal - Mgrid + Mflat; … … 1164 1148 1165 1149 off_t n = catalog[c].measureT[m].averef; 1166 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt] );1150 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt], MAG_CLASS_PSF); 1167 1151 if (isnan(Msys)) { 1168 1152 info->Nsys++; … … 1239 1223 1240 1224 if (testImage) { 1241 fprintf (stderr, "%f %f : % d %f\n", myMosaic[0].Mcal, myMosaic[0].dMsys, myMosaic[0].Xm, pow(10.0, 0.01*myMosaic[0].Xm));1225 fprintf (stderr, "%f %f : %f\n", myMosaic[0].Mcal, myMosaic[0].dMsys, pow (10.0, 0.01*myMosaic[0].Xm)); 1242 1226 } 1243 1227 … … 1592 1576 if (mosaic[i].flags & IMAGE_BAD) continue; 1593 1577 if (mosaic[i].skipCal) continue; 1578 if (KEEP_UBERCAL && (mosaic[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue; 1579 1594 1580 list[n] = mosaic[i].Mcal; 1595 1581 dlist[n] = 1; … … 1622 1608 if (mosaic[i].flags & IMAGE_BAD) continue; 1623 1609 if (mosaic[i].skipCal) continue; 1610 if (KEEP_UBERCAL && (mosaic[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue; 1611 1624 1612 list[n] = mosaic[i].dMcal; 1625 1613 dlist[n] = 1; … … 1653 1641 if (mosaic[i].flags & IMAGE_BAD) continue; 1654 1642 if (mosaic[i].skipCal) continue; 1643 if (KEEP_UBERCAL && (mosaic[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue; 1655 1644 1656 1645 N = 0; … … 1699 1688 if (mosaic[i].flags & IMAGE_BAD) continue; 1700 1689 if (mosaic[i].skipCal) continue; 1701 list[n] = pow(10.0, 0.01*mosaic[i].Xm); 1690 if (KEEP_UBERCAL && (mosaic[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue; 1691 1692 list[n] = pow (10.0, 0.01*mosaic[i].Xm); 1702 1693 dlist[n] = 1; 1703 1694 n++; … … 1782 1773 void plot_mosaic_fields (Catalog *catalog) { 1783 1774 1784 off_t i, j, m, c, N, ave,Nimage;1775 off_t i, j, m, c, N, Nimage; 1785 1776 double *xlist, *ylist; 1786 // double Xmin, Xmax, Ymin, Ymax;1787 1777 char string[64]; 1788 1778 Graphdata graphdata; … … 1803 1793 for (i = 0; i < Nmosaic; i++) { 1804 1794 N = 0; 1805 // Xmin = Ymin = +360.0;1806 // Xmax = Ymax = -360.0;1807 1795 for (j = 0; j < N_onMosaic[i]; j++) { 1808 1796 … … 1812 1800 if (catalog[c].measureT[m].dbFlags & (ID_MEAS_AREA | ID_MEAS_NOCAL)) continue; 1813 1801 1814 ave = catalog[c].measureT[m].averef;1815 xlist[N] = catalog[c]. averageT[ave].R - catalog[c].measureT[m].dR / 3600.0;1816 ylist[N] = catalog[c]. averageT[ave].D - catalog[c].measureT[m].dD / 3600.0;1802 // ave = catalog[c].measureT[m].averef; 1803 xlist[N] = catalog[c].measureT[m].R; 1804 ylist[N] = catalog[c].measureT[m].D; 1817 1805 N++; 1818 1806 } -
trunk/Ohana/src/relphot/src/Shutdown.c
r33651 r37037 23 23 SetProtect (TRUE); 24 24 if (db) gfits_db_close (db); 25 fprintf (stderr, "ERROR: addstarhalted\n");25 fprintf (stderr, "ERROR: relphot halted\n"); 26 26 exit (1); 27 27 } -
trunk/Ohana/src/relphot/src/StarOps.c
r36630 r37037 153 153 int i; 154 154 155 // fprintf (stderr, "this version of setMrel is invalid for now\n"); 156 // exit (1); 157 155 158 int Nsecfilt = GetPhotcodeNsecfilt (); 156 159 … … 407 410 408 411 /* star/photcodes already calibrated */ 409 if ( isSetMrelFinal && catalog[Nc].found [Nsecfilt*j+Nsec]) continue;412 if ( isSetMrelFinal && catalog[Nc].found_t[Nsecfilt*j+Nsec]) continue; 410 413 411 414 // skip bad stars … … 467 470 468 471 // skip some absurd values NAN, < 0.0, > 30.0 469 Msys = PhotSysTiny (&catalog[Nc].measureT[m], &catalog[Nc].averageT[j], &catalog[Nc].secfilt[j*Nsecfilt] );472 Msys = PhotSysTiny (&catalog[Nc].measureT[m], &catalog[Nc].averageT[j], &catalog[Nc].secfilt[j*Nsecfilt], MAG_CLASS_PSF); 470 473 if (isnan(Msys)) SKIP_THIS_MEAS(Nsys); 471 474 if (Msys < 0.0) SKIP_THIS_MEAS(Nsys); … … 670 673 liststats (list, dlist, wlist, N, &stats); 671 674 672 catalog[Nc].secfilt[Nsecfilt*j+Nsec].M = stats.mean;673 catalog[Nc].secfilt[Nsecfilt*j+Nsec].dM = stats.error;674 catalog[Nc].secfilt[Nsecfilt*j+Nsec]. Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq + 1e-4) : NAN_S_SHORT;675 catalog[Nc].secfilt[Nsecfilt*j+Nsec].M = stats.mean; 676 catalog[Nc].secfilt[Nsecfilt*j+Nsec].dM = stats.error; 677 catalog[Nc].secfilt[Nsecfilt*j+Nsec].Mchisq = (stats.Nmeas > 1) ? stats.chisq : NAN; 675 678 676 679 // when running -averages, we have no information about the images, so we cannot set this … … 680 683 681 684 if (isSetMrelFinal) { 682 catalog[Nc].found [Nsecfilt*j+Nsec] = TRUE;685 catalog[Nc].found_t[Nsecfilt*j+Nsec] = TRUE; 683 686 684 687 catalog[Nc].secfilt[Nsecfilt*j+Nsec].Mstdev = 1000.0*stats.sigma; // Mstdev is in millimags (not enough space for more precision) … … 950 953 951 954 int i, j, Ndel, Nave, Ntot, mark, Ns, Nscat, Nchi, Nnan; 952 float dM , Xm;953 double Chisq,MaxScatter, MaxChisq;955 float dM; 956 double MaxScatter, MaxChisq; 954 957 double *xlist, *slist, *dlist; 955 958 … … 978 981 for (j = 0; j < catalog[i].Naverage; j++) { 979 982 if ( catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD ) continue; 980 Xm = catalog[i].secfilt[Nsecfilt*j+Nsec].Xm; 981 if (Xm == -1) continue; 982 Chisq = pow (10.0, 0.01*Xm); 983 xlist[Ntot] = Chisq; 983 float Mchisq = catalog[i].secfilt[Nsecfilt*j+Nsec].Mchisq; 984 if (isnan(Mchisq)) continue; 985 xlist[Ntot] = Mchisq; 984 986 slist[Ntot] = catalog[i].secfilt[Nsecfilt*j+Nsec].dM; 985 987 dlist[Ntot] = 1; … … 999 1001 for (j = 0; j < catalog[i].Naverage; j++) { 1000 1002 dM = catalog[i].secfilt[Nsecfilt*j+Nsec].dM; 1001 Xm = catalog[i].secfilt[Nsecfilt*j+Nsec].Xm; 1002 Chisq = pow (10.0, 0.01*Xm); 1003 mark = (dM > MaxScatter) || (Xm == NAN_S_SHORT) || (Chisq > MaxChisq); 1003 float Mchisq = catalog[i].secfilt[Nsecfilt*j+Nsec].Mchisq; 1004 mark = (dM > MaxScatter) || (isnan(Mchisq)) || (Mchisq > MaxChisq); 1004 1005 if (mark) { 1005 1006 catalog[i].secfilt[Nsecfilt*j+Nsec].flags |= ID_STAR_POOR; 1006 1007 Ndel ++; 1007 if (dM > MaxScatter) { Nscat ++; }1008 if ( Xm == NAN_S_SHORT){ Nnan ++; }1009 if ( Chisq > MaxChisq) { Nchi ++; }1008 if (dM > MaxScatter) { Nscat ++; } 1009 if (isnan(Mchisq)) { Nnan ++; } 1010 if (Mchisq > MaxChisq) { Nchi ++; } 1010 1011 } else { 1011 1012 catalog[i].secfilt[Nsecfilt*j+Nsec].flags &= ~ID_STAR_POOR; … … 1072 1073 1073 1074 /* on final processing, skip stars already measured */ 1074 if (final && catalog[i].found [Nsecfilt*j + Nsec]) continue;1075 if (final && catalog[i].found_t[Nsecfilt*j + Nsec]) continue; 1075 1076 1076 1077 /* skip bad stars to prevent them from becoming good (on inner sample) */ … … 1093 1094 if (isnan(Mgrid)) { Ngrid ++; continue; } 1094 1095 1095 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt] );1096 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt], MAG_CLASS_PSF); 1096 1097 list[N] = Msys - Mcal - Mmos - Mgrid; 1097 1098 dlist[N] = MAX (catalog[i].measureT[m].dM, MIN_ERROR); … … 1138 1139 if (isnan(Mgrid)) continue; 1139 1140 1140 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt] );1141 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt], MAG_CLASS_PSF); 1141 1142 list[N] = Msys - Mcal - Mmos - Mgrid; 1142 1143 dlist[N] = MAX (catalog[i].measureT[m].dM, MIN_ERROR); … … 1233 1234 1234 1235 off_t j, Ntot; 1235 int i, n , Xm;1236 int i, n; 1236 1237 double *list, *dlist; 1237 1238 StatType stats; … … 1254 1255 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue; 1255 1256 1256 Xm = catalog[i].secfilt[Nsecfilt*j+Nsec].Xm;1257 if ( Xm == NAN_S_SHORT) continue;1258 list[n] = pow (10.0, 0.01*Xm);1257 float Mchisq = catalog[i].secfilt[Nsecfilt*j+Nsec].Mchisq; 1258 if (isnan(Mchisq)) continue; 1259 list[n] = Mchisq; 1259 1260 dlist[n] = 1; 1260 1261 n++; … … 1377 1378 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue; 1378 1379 xlist[N] = catalog[i].secfilt[Nsecfilt*j+Nsec].M; 1379 value = catalog[i].secfilt[Nsecfilt*j+Nsec]. Xm;1380 if ( value == NAN_S_SHORT) continue;1381 ylist[N] = 0.01*value;1380 value = catalog[i].secfilt[Nsecfilt*j+Nsec].Mchisq; 1381 if (isnan(value)) continue; 1382 ylist[N] = value; 1382 1383 N++; 1383 1384 } -
trunk/Ohana/src/relphot/src/args.c
r36630 r37037 227 227 } 228 228 229 SHOW_PARAMS = FALSE;229 SHOW_PARAMS = TRUE; 230 230 if ((N = get_argument (argc, argv, "-params"))) { 231 231 remove_argument (N, &argc, argv); 232 SHOW_PARAMS = TRUE;232 SHOW_PARAMS = FALSE; 233 233 } 234 234 -
trunk/Ohana/src/relphot/src/assign_images.c
r36630 r37037 25 25 26 26 if (MOSAIC_ZEROPT) { 27 makeMosaics (image, Nimage );28 29 // center coords and Mcal, dMcal, Xmfor the mosaics27 makeMosaics (image, Nimage, FALSE); 28 29 // center coords and Mcal, dMcal, Mchisq for the mosaics 30 30 setMosaicCenters (image, Nimage); 31 31 MARKTIME("set mosaic coordinates and Mcal values: %f sec\n", dtime); -
trunk/Ohana/src/relphot/src/bcatalog.c
r35416 r37037 23 23 Nmeasure = Naverage = 0; 24 24 25 int NmMax = 0; 26 int NmMin = catalog[0].Nmeasure; 27 25 28 Ncode = Ntime = Ndophot = Nmag = Nsigma = Nimag = Nfew = Npsfqf = Ngalaxy = Nnan = Nbad = Npoor = 0; 26 29 … … 55 58 if (RESET) { 56 59 int Ns; 60 61 # if (0) 57 62 DVOSecfiltFlags secfiltBits = 58 63 ID_SECF_STAR_FEW | … … 66 71 ID_SECF_USE_UBERCAL | 67 72 ID_SECF_OBJ_EXT; 73 # endif 74 68 75 for (Ns = 0; Ns < Nphotcodes; Ns++) { 69 76 … … 71 78 int Nsec = GetPhotcodeNsec(thisCode); 72 79 73 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].M = NAN; 74 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Map = NAN; 75 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].dM = NAN; 76 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Mstdev = NAN_S_SHORT; 77 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Xm = NAN; 78 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].M_20 = NAN_S_SHORT; 79 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].M_80 = NAN_S_SHORT; 80 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Ncode = 0; 81 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Nused = 0; 82 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].flags &= ~secfiltBits; 83 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].ubercalDist = 1000; 80 fprintf (stderr, "really use dvo_secfilt_init?"); 81 dvo_secfilt_init (&subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec]); 82 83 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].M = NAN; 84 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Map = NAN; 85 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].dM = NAN; 86 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Mstdev = NAN_S_SHORT; 87 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Mchisq = NAN; 88 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].M_20 = NAN_S_SHORT; 89 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].M_80 = NAN_S_SHORT; 90 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Ncode = 0; 91 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].Nused = 0; 92 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].flags &= ~secfiltBits; 93 // subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].ubercalDist = 1000; 84 94 } 85 95 } … … 136 146 137 147 /* select measurements by mag limit */ 138 mag = PhotCat (&catalog[0].measure[offset] );148 mag = PhotCat (&catalog[0].measure[offset], MAG_CLASS_PSF); 139 149 if (mag > MAG_LIM) { Nmag ++; continue; } 140 150 … … 144 154 /* select measurements by mag limit */ 145 155 if (ImagSelect) { 146 mag = PhotInst (&catalog[0].measure[offset] );156 mag = PhotInst (&catalog[0].measure[offset], MAG_CLASS_PSF); 147 157 if (mag < ImagMin) { Nimag ++; continue; } 148 158 if (mag > ImagMax) { Nimag ++; continue; } … … 180 190 } 181 191 myAssert (Nmeasure < NMEASURE, "realloc failure"); 182 } 192 } // end of catalog.average.Nmeasure loop 183 193 184 194 // skip object if it is likely to be a galaxy … … 205 215 continue; 206 216 } 217 NmMin = MIN (Nm, NmMin); 218 NmMax = MAX (Nm, NmMax); 207 219 208 220 // for w-band photometry (& other cases?) convert gri photometry … … 235 247 subcatalog[0].Nsecf_mem = Naverage * catalog[0].Nsecfilt; 236 248 249 if (VERBOSE) { 250 fprintf (stderr, "using "OFF_T_FMT" stars ("OFF_T_FMT" measures) of "OFF_T_FMT" ("OFF_T_FMT" measures) for catalog %s, %d < Nm < %d\n", 251 subcatalog[0].Naverage, subcatalog[0].Nmeasure, catalog[0].Naverage, catalog[0].Nmeasure, catalog[0].filename, NmMin, NmMax); 252 fprintf (stderr, "rejections: %d stars have too few measures:\n %d code, %d time, %d dophot, %d mag, %d sigma, %d imag, %d psfqf, %d Nnan, %d galaxies, %d bad, %d poor\n", 253 Nfew, Ncode, Ntime, Ndophot, Nmag, Nsigma, Nimag, Npsfqf, Nnan, Ngalaxy, Nbad, Npoor); 254 } 255 237 256 // limit the total number of stars in the catalog 238 257 if (MaxDensityUse) { … … 240 259 } 241 260 242 if (VERBOSE) {243 fprintf (stderr, "using "OFF_T_FMT" stars ("OFF_T_FMT" measures) of "OFF_T_FMT" for catalog %s\n",244 subcatalog[0].Naverage, subcatalog[0].Nmeasure, i, catalog[0].filename);245 fprintf (stderr, "rejections: %d code, %d time, %d dophot, %d mag, %d sigma, %d imag, %d few, %d psfqf, %d Nnan, %d galaxies, %d bad, %d poor\n",246 Ncode, Ntime, Ndophot, Nmag, Nsigma, Nimag, Nfew, Npsfqf, Nnan, Ngalaxy, Nbad, Npoor);247 }248 261 return (TRUE); 249 262 } -
trunk/Ohana/src/relphot/src/initialize.c
r36630 r37037 36 36 37 37 if (SHOW_PARAMS) { 38 fprintf (stderr, "current parameter settings:\n"); 38 int Ns; 39 fprintf (stderr, "subset selection criteria:\n"); 40 fprintf (stderr, " photcodes "); 41 for (Ns = 0; Ns < Nphotcodes; Ns++) { 42 if (Ns == Nphotcodes - 1) { 43 fprintf (stderr, "%s\n", photcodes[Ns][0].name); 44 } else { 45 fprintf (stderr, "%s, ", photcodes[Ns][0].name); 46 } 47 } 39 48 if (TimeSelect) { 40 49 fprintf (stderr, "TimeSelect: TRUE (%s - %s)\n", ohana_sec_to_date (TSTART), ohana_sec_to_date (TSTOP)); … … 42 51 fprintf (stderr, "TimeSelect: FALSE\n"); 43 52 } 53 if (DophotSelect) { 54 fprintf (stderr, "DophotSelect: TRUE (%d)\n", DophotValue); 55 } else { 56 fprintf (stderr, "DophotSelect: FALSE\n"); 57 } 58 fprintf (stderr, "PSF_QF limit: 0.85 (hardwired)\n"); 59 60 // fprintf (stderr, "Photom Bad Mask: 0x%08x, Photom Poor Mask: 0x%08x\n"); 61 62 fprintf (stderr, "MAG_LIM: %f, SIGMA_LIM: %f\n", MAG_LIM, SIGMA_LIM); 63 fprintf (stderr, "INST_MAG_MIN: %f, INST_MAG_MAX: %f\n", ImagMin, ImagMax); 64 65 fprintf (stderr, "STAR_TOOFEW: %d\n", STAR_TOOFEW); 66 44 67 fprintf (stderr, "VERBOSE: %d, PLOTSTUFF: %d\n", VERBOSE, PLOTSTUFF); 45 68 fprintf (stderr, "GRID_X: %d, GRID_Y: %d, BINNING: %d == Nmx: %d, Nmy: %d\n", … … 49 72 (int)(RELPHOT_GRID_X/RELPHOT_GRID_BINNING), (int)(RELPHOT_GRID_Y/RELPHOT_GRID_BINNING)); 50 73 51 fprintf (stderr, "MAG_LIM %lf\n", MAG_LIM);52 74 fprintf (stderr, "STAR_SCATTER %lf\n", STAR_SCATTER); 53 75 fprintf (stderr, "IMAGE_SCATTER %lf\n", IMAGE_SCATTER); … … 56 78 fprintf (stderr, "GSCFILE %s\n", GSCFILE); 57 79 fprintf (stderr, "CATDIR %s\n", CATDIR); 58 exit (0);59 80 } 60 81 -
trunk/Ohana/src/relphot/src/launch_region_hosts.c
r36871 r37037 55 55 56 56 char command[1024]; 57 snprintf (command, 1024, "relphot %s -parallel-images %s -region-hosts %s -region-hostID %d -D CATDIR %s -region %f %f %f %f -statmode %s -D CAMERA %s -D STAR_TOOFEW %d -minerror %f", 58 PhotcodeList, filename, REGION_FILE, host->hostID, CATDIR, host->RminCat, host->RmaxCat, host->DminCat, host->DmaxCat, STATMODE, CAMERA, STAR_TOOFEW, MIN_ERROR); 57 snprintf (command, 1024, "relphot %s", PhotcodeList); 58 strextend (command, "-parallel-images %s", filename); 59 strextend (command, "-region-hosts %s", REGION_FILE); 60 strextend (command, "-region-hostID %d", host->hostID); 61 strextend (command, "-D CATDIR %s", CATDIR); 62 strextend (command, "-region %f %f %f %f", host->RminCat, host->RmaxCat, host->DminCat, host->DmaxCat); 63 strextend (command, "-statmode %s", STATMODE); 64 strextend (command, "-D CAMERA %s", CAMERA); 65 strextend (command, "-D STAR_TOOFEW %d", STAR_TOOFEW); 66 strextend (command, "-minerror %f", MIN_ERROR); 67 strextend (command, "-cloud-limit %f", CLOUD_TOLERANCE); 59 68 60 69 if (VERBOSE) strextend (command, "-v"); -
trunk/Ohana/src/relphot/src/load_catalogs.c
r36630 r37037 12 12 // if this function is called with a specified hostID, then only the fraction of the 13 13 // database hosted by that hostID is loaded 14 Catalog *load_catalogs (SkyList *skylist, int *Ncatalog, int hostID, char *hostpath ) {14 Catalog *load_catalogs (SkyList *skylist, int *Ncatalog, int hostID, char *hostpath, char *syncfile) { 15 15 16 16 off_t i, Nmeas, Nstar, Nmeas_total, Nstar_total; … … 19 19 // XXX need to decide how to determine PARALLEL mode... 20 20 if (PARALLEL && !hostID) { 21 catalog = load_catalogs_parallel (skylist, Ncatalog );21 catalog = load_catalogs_parallel (skylist, Ncatalog, syncfile); 22 22 return catalog; 23 23 } … … 92 92 // in regular relphot, we shutdown here; in relphot_client, we generate and return an empty table (for consistency) 93 93 94 // if we are running with parallel_images but not a parallel database, we need to 95 // release the lock so the next image host can proceed 96 if (!hostID && syncfile) { 97 update_sync_file (syncfile, 1); 98 } 99 94 100 // XXX consider only returning the populated catalogs 95 101 *Ncatalog = skylist[0].Nregions; … … 105 111 // CATDIR is supplied globally 106 112 # define DEBUG 1 107 Catalog *load_catalogs_parallel (SkyList *sky, int *Ncatalog ) {113 Catalog *load_catalogs_parallel (SkyList *sky, int *Ncatalog, char *syncfile) { 108 114 109 115 char uniquer[12]; … … 206 212 } 207 213 214 // update syncfile here (save lots of I/O time): 215 216 // at this point, the remote relastro_client jobs are done loading their data. in a 217 // parallel_images mode, the next image host can be launched while this image host now 218 // reads that 219 220 // NOTE: if I let all hosts load blindly, I saturate the data clients with too many 221 // relphot_client requests. I need to have the master mediate this. the master 222 // will not launch the next remote job until this one says it is done 223 if (syncfile) { 224 update_sync_file (syncfile, 1); 225 } 226 208 227 // each host generates a BrightCatalog structure, with the measure, average, etc value 209 228 // loaded into a single set of arrays (of MeasureTiny, AverageTiny, Secfilt). I need to -
trunk/Ohana/src/relphot/src/plot_scatter.c
r35759 r37037 51 51 52 52 xlist[N] = Mrel; 53 ylist[N] = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt] ) - Mcal - Mmos - Mgrid - Mrel;54 ilist[N] = PhotInstTiny (&catalog[i].measureT[m] );53 ylist[N] = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt], MAG_CLASS_PSF) - Mcal - Mmos - Mgrid - Mrel; 54 ilist[N] = PhotInstTiny (&catalog[i].measureT[m], MAG_CLASS_PSF); 55 55 N++; 56 56 } -
trunk/Ohana/src/relphot/src/relphot_client.c
r36630 r37037 39 39 case MODE_LOAD: { 40 40 int Ncatalog; 41 Catalog *catalog = load_catalogs (skylist, &Ncatalog, HOST_ID, HOSTDIR );41 Catalog *catalog = load_catalogs (skylist, &Ncatalog, HOST_ID, HOSTDIR, NULL); 42 42 if (!catalog) { 43 43 fprintf (stderr, "ERROR loading catalogs from %s\n", CATDIR); -
trunk/Ohana/src/relphot/src/relphot_images.c
r36630 r37037 52 52 if (NLOOP > 0) { 53 53 /* load catalog data from region files (hostID is 0 since we are not a client */ 54 catalog = load_catalogs (skylist, &Ncatalog, 0, NULL );54 catalog = load_catalogs (skylist, &Ncatalog, 0, NULL, NULL); 55 55 MARKTIME("-- load catalog data: %f sec\n", dtime); 56 56 -
trunk/Ohana/src/relphot/src/relphot_parallel_images.c
r36630 r37037 38 38 // unlink (IMAGE_TABLE); // XXX a bit risky, add some protection? 39 39 40 // XXX need to deal with mosaic vs image... 41 makeMosaics (image, Nimage); 40 makeMosaics (image, Nimage, TRUE); 42 41 43 42 initImages (image, NULL, Nimage); … … 56 55 57 56 /* load catalog data from region files (hostID is 0 since we are not a client */ 58 catalog = load_catalogs (skylist, &Ncatalog, 0, NULL); 57 char *syncfile = make_filename (CATDIR, regionHosts->hosts[myHost].hostname, REGION_HOST_ID, "loadcat.sync"); 58 catalog = load_catalogs (skylist, &Ncatalog, 0, NULL, syncfile); 59 59 MARKTIME("-- load catalog data: %f sec\n", dtime); 60 free (syncfile); 61 60 62 client_logger_message ("loaded catalog data\n"); 61 63 62 // NOTE: if I let all hosts load blindly, I saturate the data clients with too many63 // relphot_client requests. I need to have the master mediate this. the master64 // will not launch the next remote job until this one says it is done65 char *syncfile = make_filename (CATDIR, regionHosts->hosts[myHost].hostname, REGION_HOST_ID, "loadcat.sync");66 update_sync_file (syncfile, 1);67 68 64 // generate tables go from catID,objID -> catSeq,objSeq 69 65 indexCatalogs (catalog, Ncatalog); -
trunk/Ohana/src/relphot/src/relphot_parallel_regions.c
r36630 r37037 1 1 # include "relphot.h" 2 int save_images_backup (FITS_DB *db); 2 3 3 4 int relphot_parallel_regions () { … … 63 64 SkyList *skylist = SkyListByBounds (sky, -1, regionHosts->Rmin, regionHosts->Rmax, regionHosts->Dmin, regionHosts->Dmax); 64 65 66 // I have to save a copy because dvo_image_save and _unlock swap and free the data 67 save_images_backup (&db); 68 65 69 /* update catalogs (in parallel) */ 66 70 reload_catalogs (skylist, flatcorr, 0, NULL); … … 74 78 } 75 79 80 int save_images_backup (FITS_DB *db) { 81 82 FITS_DB dbX; 83 char filename[1024]; 84 85 INITTIME; 86 87 gfits_db_init (&dbX); 88 dbX.lockstate = LCK_XCLD; 89 dbX.timeout = 60.0; 90 dbX.mode = db->mode; 91 dbX.format = db->format; 92 93 snprintf (filename, 1024, "%s.bck", ImageCat); 94 if (!gfits_db_lock (&dbX, filename)) { 95 fprintf (stderr, "can't lock backup image image catalog\n"); 96 return (FALSE); 97 } 98 99 // copy Images.dat data (all or only the subset / vtable elements?) I think I need to dump 100 // the entire Image table, but with the updates in place I think this says: re-work the 101 // ftable/vtable usage in this program to be more sensible... 102 gfits_copy_header (&db->header, &dbX.header); 103 gfits_copy_matrix (&db->matrix, &dbX.matrix); 104 gfits_copy_header (&db->theader, &dbX.theader); 105 gfits_copy_ftable (&db->ftable, &dbX.ftable); 106 107 dbX.ftable.header = &dbX.theader; 108 109 dvo_image_save (&dbX, VERBOSE); 110 dvo_image_unlock (&dbX); 111 MARKTIME("-- save Image.dat.bck: %f sec\n", dtime); 112 113 return TRUE; 114 } -
trunk/Ohana/src/relphot/src/setExclusions.c
r33651 r37037 35 35 /* select measurements by mag limit */ 36 36 if (AreaSelect) { 37 r = catalog[i]. averageT[j].R + catalog[i].measureT[m].dR / 3600.0;38 d = catalog[i]. averageT[j].D + catalog[i].measureT[m].dD / 3600.0;37 r = catalog[i].measureT[m].R; 38 d = catalog[i].measureT[m].D; 39 39 if ((coords = getCoords (m, i)) == NULL) goto markbad; 40 40 RD_to_XY (&x, &y, r, d, coords); -
trunk/Ohana/src/relphot/src/setMrelCatalog.c
r36630 r37037 1 1 # include "relphot.h" 2 # define UBERCAL_WEIGHT 100.0 2 3 3 4 # define SKIP_THIS_MEAS(REASON) { \ … … 13 14 continue; } 14 15 16 static float MagToFlux (float Mag) { 17 float Flux = pow(10.0, -0.4*(Mag)); 18 return (Flux); 19 } 20 15 21 int print_measure_set_alt (Average *average, SecFilt *secfilt, Measure *measure) { 16 22 … … 29 35 return (TRUE); 30 36 } 37 38 int setMrelAverageForcedWarp (off_t measureOffset, int cat, int pass, SetMrelInfo *results, Average *average, SecFilt *secfilt, Measure *measure, off_t *found); 31 39 32 40 int setMrel_catalog_alt (Catalog *catalog, int Nc, int pass, FlatCorrectionTable *flatcorr, SetMrelInfo *results, int Nsecfilt) { … … 52 60 Average *average = catalog[Nc].average ? &catalog[Nc].average[j] : NULL; 53 61 Measure *measure = catalog[Nc].measure ? &catalog[Nc].measure[m] : NULL; 54 setMrelAverageExposure (m, Nc, pass, flatcorr, results, average, &catalog[Nc].averageT[j], &catalog[Nc].secfilt[j*Nsecfilt], measure, &catalog[Nc].measureT[m], &catalog[Nc].found [Nsecfilt*j]);62 setMrelAverageExposure (m, Nc, pass, flatcorr, results, average, &catalog[Nc].averageT[j], &catalog[Nc].secfilt[j*Nsecfilt], measure, &catalog[Nc].measureT[m], &catalog[Nc].found_t[Nsecfilt*j]); 55 63 56 64 // only apply Stack operation on setMrelFinal in first pass … … 59 67 setGlobalObjStats (&catalog[Nc].average[j], &catalog[Nc].measure[m]); 60 68 } 69 70 // only measure force-warp mean values if issetMrelFinal (make it optional?) 71 if (isSetMrelFinal) { 72 setMrelAverageForcedWarp (m, Nc, pass, results, &catalog[Nc].average[j], &catalog[Nc].secfilt[j*Nsecfilt], &catalog[Nc].measure[m], &catalog[Nc].foundWarp_t[Nsecfilt*j]); 73 setGlobalObjStats (&catalog[Nc].average[j], &catalog[Nc].measure[m]); 74 } 61 75 } 62 76 if (primaryCell) free (primaryCell); … … 64 78 } 65 79 80 // set mean of chip measurements (selected by photcode range for now): 66 81 int setMrelAverageExposure (off_t measureOffset, int cat, int pass, FlatCorrectionTable *flatcorr, SetMrelInfo *results, Average *average, AverageTiny *averageT, SecFilt *secfilt, Measure *measure, MeasureTiny *measureT, off_t *found) { 67 82 … … 144 159 145 160 // are we a PS1 exposure photcode? 146 if ((measureT[k].photcode >= 10000) && (measureT[k].photcode <= 10500)) { 147 NexpPS1 ++; 148 } 161 if (isGPC1chip(measureT[k].photcode)) NexpPS1 ++; 162 163 // SKIP gpc1 stack data 164 if (isGPC1stack(measureT[k].photcode)) continue; 165 166 // SKIP gpc1 forced-warp data 167 if (isGPC1warp(measureT[k].photcode)) continue; 149 168 150 169 if (measureT[k].dbFlags & MEAS_BAD) SKIP_THIS_MEAS(Nbad); … … 166 185 167 186 // skip some absurd values NAN, < 0.0, > 30.0 168 Msys = PhotSysTiny (&measureT[k], &averageT[0], &secfilt[0] );187 Msys = PhotSysTiny (&measureT[k], &averageT[0], &secfilt[0], MAG_CLASS_PSF); 169 188 if (isnan(Msys)) SKIP_THIS_MEAS(Nsys); 170 189 if (Msys < 0.0) SKIP_THIS_MEAS(Nsys); … … 197 216 } 198 217 havePS1 = TRUE; 199 }200 201 // gpc1 stack data202 if ((measure[k].photcode >= 11000) && (measure[k].photcode <= 11400)) {203 continue;204 218 } 205 219 … … 255 269 256 270 // Map (Maplist) and Mkron (Mkronlist,dkronlist) are used to calculate mean mags per filter 257 float Map = Phot AperCat (&measure[k]);271 float Map = PhotCat (&measure[k], MAG_CLASS_APER); 258 272 if (!isnan(Map)) { 259 273 Maplist[Nap] = Map - Mcal - Mmos - Mgrid; 260 daplist[Nap] = dMpsf; 261 waplist[Nap] = isUbercal ? 10.0: 1.0;274 daplist[Nap] = dMpsf;// XXX check on this... 275 waplist[Nap] = isUbercal ? UBERCAL_WEIGHT : 1.0; 262 276 Nap ++; 263 277 } 264 278 265 float Mkron = Phot KronCat (&measure[k]);279 float Mkron = PhotCat (&measure[k], MAG_CLASS_KRON); 266 280 if (!isnan(Mkron)) { 267 281 Mkronlist[Nkron] = Mkron - Mcal - Mmos - Mgrid; 268 282 dkronlist[Nkron] = measure[k].dMkron; 269 wkronlist[Nkron] = isUbercal ? 10.0: 1.0;283 wkronlist[Nkron] = isUbercal ? UBERCAL_WEIGHT : 1.0; 270 284 Nkron ++; 271 285 } … … 280 294 Mpsflist[Npsf] = Msys - Mcal - Mmos - Mgrid; 281 295 dpsflist[Npsf] = dMpsf; 282 wpsflist[Npsf] = isUbercal ? 10.0: 1.0;296 wpsflist[Npsf] = isUbercal ? UBERCAL_WEIGHT : 1.0; 283 297 284 298 // NOTE: … … 293 307 if (refPhotcode) { 294 308 if (code->code == refPhotcode->code) { 295 wpsflist[Npsf] = 100.0;309 wpsflist[Npsf] = UBERCAL_WEIGHT; 296 310 } 297 311 } … … 304 318 if (isSetMrelFinal && (pass == 0)) { 305 319 if ((thisCode < 6) || (thisCode == 9)) { 306 secfilt[Nsec].Ncode = NexpPS1; 320 secfilt[Nsec].Ncode = NexpPS1; 307 321 } else { 308 322 secfilt[Nsec].Ncode = Ncode; // 2MASS data if it exists … … 334 348 liststats (Mpsflist, dpsflist, wpsflist, Npsf, psfstats); 335 349 336 secfilt[Nsec].M = psfstats->mean;337 secfilt[Nsec].dM = psfstats->error;338 secfilt[Nsec]. Xm = (psfstats->Nmeas > 1) ? 100.0*log10(psfstats->chisq + 1e-4) : NAN_S_SHORT;350 secfilt[Nsec].M = psfstats->mean; 351 secfilt[Nsec].dM = psfstats->error; 352 secfilt[Nsec].Mchisq = (psfstats->Nmeas > 1) ? psfstats->chisq : NAN; 339 353 340 354 // when running -averages, we have no information about the images, so we cannot set this … … 346 360 found[Nsec] = TRUE; 347 361 348 secfilt[Nsec].Mstdev = 1000.0*psfstats->sigma; // Mstdev is in millimags (not enough space for more precision)362 secfilt[Nsec].Mstdev = psfstats->sigma; // Mstdev is in millimags (not enough space for more precision) 349 363 // secfilt[Nsec].Ncode = Ncode; 350 364 secfilt[Nsec].Nused = psfstats->Nmeas; 351 365 352 secfilt[Nsec].M _80 = 1000 * psfstats->Upper80;353 secfilt[Nsec].M _20 = 1000 * psfstats->Lower20;366 secfilt[Nsec].Mmax = psfstats->max; 367 secfilt[Nsec].Mmin = psfstats->min; 354 368 355 369 // NOTE : use the modified weight for apmags as well as psf mags 356 370 liststats (Maplist, daplist, waplist, Nap, apstats); 357 371 secfilt[Nsec].Map = Nap > 0 ? apstats->mean : NAN; 372 secfilt[Nsec].dMap = Nap > 0 ? apstats->error : NAN; 373 secfilt[Nsec].sMap = Nap > 0 ? apstats->sigma : NAN; 374 secfilt[Nsec].NusedAp = Nap; 358 375 359 376 liststats (Mkronlist, dkronlist, wkronlist, Nkron, kronstats); 360 377 secfilt[Nsec].Mkron = Nkron > 0 ? kronstats->mean : NAN; 361 378 secfilt[Nsec].dMkron = Nkron > 0 ? kronstats->error : NAN; 379 secfilt[Nsec].sMkron = Nkron > 0 ? kronstats->sigma : NAN; 380 secfilt[Nsec].NusedKron = Nkron; 362 381 363 382 // NOTE: for 2MASS measurements, Next should be 1, as should N … … 472 491 473 492 // only examine gpc1 stack data 474 // XXX this is absurdly hardwired (along with several photcode tests) 475 if (measure[k].photcode < 11000) continue; 476 if (measure[k].photcode > 11400) continue; 493 if (!isGPC1stack(measure[k].photcode)) continue; 477 494 478 495 haveStack = TRUE; … … 493 510 if (isnan(Mgrid)) SKIP_THIS_MEAS_STACK(Ngrid); 494 511 495 Msys = PhotSys (&measure[k], &average[0], &secfilt[0] );512 Msys = PhotSys (&measure[k], &average[0], &secfilt[0], MAG_CLASS_PSF); 496 513 if (isnan(Msys)) SKIP_THIS_MEAS_STACK(Nsys); 497 514 … … 581 598 582 599 // need to put in AB mag factor to get to Janskies (or uJy?) 583 secfilt[Nsec].FluxPSF = zpFactor * measure[k].FluxPSF; 584 secfilt[Nsec].dFluxPSF = zpFactor * measure[k].dFluxPSF; 585 secfilt[Nsec].FluxKron = zpFactor * measure[k].FluxKron; 586 secfilt[Nsec].dFluxKron = zpFactor * measure[k].dFluxKron; 600 secfilt[Nsec].FpsfStk = zpFactor * measure[k].FluxPSF; 601 secfilt[Nsec].dFpsfStk = zpFactor * measure[k].dFluxPSF; 602 secfilt[Nsec].FkronStk = zpFactor * measure[k].FluxKron; 603 secfilt[Nsec].dFkronStk = zpFactor * measure[k].dFluxKron; 604 secfilt[Nsec].FapStk = zpFactor * measure[k].FluxAp; 605 secfilt[Nsec].dFapStk = zpFactor * measure[k].dFluxAp; 606 607 secfilt[Nsec].MpsfStk = (measure[k].FluxPSF > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FpsfStk) : NAN; 608 secfilt[Nsec].MkronStk = (measure[k].FluxKron > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FkronStk) : NAN; 609 secfilt[Nsec].MapStk = (measure[k].FluxAp > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FapStk) : NAN; 587 610 588 611 secfilt[Nsec].stackDetectID = ID; … … 607 630 } 608 631 632 # undef SKIP_THIS_MEAS 633 # define SKIP_THIS_MEAS(REASON) { \ 634 measure[k].dbFlags |= ID_MEAS_SKIP_PHOTOM; \ 635 results->REASON ++; \ 636 continue; } 637 638 // set mean of forced-warp measurements (selected by photcode range for now): 639 // somewhat simplified relative to chip-photometry: 640 // * no grid, no mosaic, no 2MASS, no SYNTH, no Ubercal, no flatcorr 641 int setMrelAverageForcedWarp (off_t measureOffset, int cat, int pass, SetMrelInfo *results, Average *average, SecFilt *secfilt, Measure *measure, off_t *found) { 642 643 off_t k; 644 float Fsys = 0, Mcal= 0; 645 646 // we are measuring means for 3 types of FLUXes: psf, ap, kron. I am using the psf mag 647 // error for the ap mags, but krons have their own errors. it is an open question if I 648 // should be doing weighted or unweighted fits (this is a user option) 649 double *Fpsflist = results->Mpsflist; 650 double *dpsflist = results->dpsflist; 651 double *wpsflist = results->wpsflist; 652 653 double *Faplist = results->Maplist; 654 double *daplist = results->daplist; 655 double *waplist = results->waplist; 656 657 double *Fkronlist = results->Mkronlist; 658 double *dkronlist = results->dkronlist; 659 double *wkronlist = results->wkronlist; 660 661 StatType *psfstats = &results->psfstats; 662 StatType *apstats = &results->apstats; 663 StatType *kronstats = &results->kronstats; 664 665 // option for a test print 666 if (FALSE && (average[0].objID == 0x7146) && (average[0].catID == 0x49d8)) { 667 fprintf (stderr, "test obj\n"); 668 print_measure_set_alt (average, secfilt, measure); 669 } 670 671 int Ns; 672 for (Ns = 0; Ns < Nphotcodes; Ns++) { 673 674 int thisCode = photcodes[Ns][0].code; 675 int Nsec = GetPhotcodeNsec(thisCode); 676 677 /* calculate the average mag in this SEC photcode for a single star */ 678 679 /* star/photcodes already calibrated */ 680 if (found[Nsec]) continue; 681 682 off_t meas = measureOffset; 683 684 int Nap = 0; 685 int Npsf = 0; 686 int Nkron = 0; 687 for (k = 0; k < average[0].Nmeasure; k++, meas++) { 688 689 // only examine gpc1 forced-warp data 690 if (!isGPC1warp(measure[k].photcode)) continue; 691 692 // skip measurements that do not match the current photcode 693 PhotCode *code = GetPhotcodebyCode (measure[k].photcode); 694 if (!code) continue; 695 if (code->equiv != thisCode) { continue; } 696 697 if (measure[k].dbFlags & MEAS_BAD) SKIP_THIS_MEAS(Nbad); 698 699 if (getImageEntry (meas, cat) < 0) { 700 // measurements without an image are either external reference photometry or 701 // data for which the associated image has not been loaded (probably because of 702 // overlaps). Msys + measure.Mcal is our best guess of the true magnitude 703 Mcal = measure[k].Mcal; // check that this is zero for loaded REF value 704 } else { 705 // use getMcal not getMcal_alt? 706 Mcal = getMcal_alt (meas, cat, NULL, measure[k].Xccd, measure[k].Yccd); 707 // Mcal = getMcal (meas, cat); 708 if (isnan(Mcal)) SKIP_THIS_MEAS(Ncal); 709 } 710 float Fcal = MagToFlux(-Mcal); 711 712 // in the calculations below, 713 // ...list gives the error per measurement, wlist gives the weight 714 // we can modify the error and weight in a few ways: 715 // 1) MIN_ERROR guarantees a floor 716 // 2) photomErrSys is added in quadrature as a sytematic error, set per photcode 717 718 // skip some absurd values NAN 719 // NOTE : I am using PhotCat not PhotSys for now since GPC1 chip-to-chip color terms 720 // are small (and not measured) 721 float Fpsf = PhotFluxCat (&measure[k], MAG_CLASS_PSF); 722 if (isnan(Fsys)) SKIP_THIS_MEAS(Nsys); 723 // if (Msys < 0.0) SKIP_THIS_MEAS(Nsys); 724 // if (Msys > 30.0) SKIP_THIS_MEAS(Nsys); 725 726 float dFpsf = PhotFluxCatErr (&measure[k], MAG_CLASS_PSF); 727 dFpsf = MAX (dFpsf, MIN_ERROR*Fpsf); // MIN_ERROR is a fractional error 728 Fpsflist[Npsf] = Fpsf * Fcal; 729 dpsflist[Npsf] = dFpsf * Fcal; 730 wpsflist[Npsf] = 1.0; 731 Npsf ++; 732 733 float Fap = PhotFluxCat (&measure[k], MAG_CLASS_APER); 734 float dFap = PhotFluxCatErr (&measure[k], MAG_CLASS_APER); 735 if (!isnan(Fap)) { 736 Faplist[Nap] = Fap * Fcal; 737 daplist[Nap] = dFap * Fcal; 738 waplist[Nap] = 1.0; // drop weight lists? 739 Nap ++; 740 } 741 742 float Fkron = PhotFluxCat (&measure[k], MAG_CLASS_KRON); 743 float dFkron = PhotFluxCatErr (&measure[k], MAG_CLASS_KRON); 744 if (!isnan(Fkron)) { 745 Fkronlist[Nkron] = Fkron * Fcal; 746 dkronlist[Nkron] = dFkron * Fcal; 747 wkronlist[Nkron] = 1.0; 748 Nkron ++; 749 } 750 } 751 if (Npsf < 1) continue; 752 753 found[Nsec] = TRUE; 754 755 liststats (Fpsflist, dpsflist, wpsflist, Npsf, psfstats); 756 757 secfilt[Nsec].FpsfWrp = psfstats->mean; 758 secfilt[Nsec].dFpsfWrp = psfstats->error; 759 secfilt[Nsec].sFpsfWrp = psfstats->sigma; // Mstdev is in millimags (not enough space for more precision) 760 secfilt[Nsec].NusedWrp = psfstats->Nmeas; 761 secfilt[Nsec].MpsfWrp = isnan(secfilt[Nsec].FpsfWrp) ? NAN : 8.9 - 2.5*log10(secfilt[Nsec].FpsfWrp); // 8.9 since flux is in Jy 762 763 // NOTE : use the modified weight for apmags as well as psf mags 764 liststats (Faplist, daplist, waplist, Nap, apstats); 765 secfilt[Nsec].FapWrp = Nap > 0 ? apstats->mean : NAN; 766 secfilt[Nsec].dFapWrp = Nap > 0 ? apstats->error : NAN; 767 secfilt[Nsec].sFapWrp = Nap > 0 ? apstats->sigma : NAN; 768 secfilt[Nsec].NusedApWrp = Nap; 769 secfilt[Nsec].MapWrp = isnan(secfilt[Nsec].FapWrp) ? NAN : 8.9 - 2.5*log10(secfilt[Nsec].FapWrp); // 8.9 since flux is in Jy 770 771 liststats (Fkronlist, dkronlist, wkronlist, Nkron, kronstats); 772 secfilt[Nsec].FkronWrp = Nkron > 0 ? kronstats->mean : NAN; 773 secfilt[Nsec].dFkronWrp = Nkron > 0 ? kronstats->error : NAN; 774 secfilt[Nsec].sFkronWrp = Nkron > 0 ? kronstats->sigma : NAN; 775 secfilt[Nsec].NusedKronWrp = Nkron; 776 secfilt[Nsec].MkronWrp = isnan(secfilt[Nsec].FkronWrp) ? NAN : 8.9 - 2.5*log10(secfilt[Nsec].FkronWrp); // 8.9 since flux is in Jy 777 } 778 return (TRUE); 779 } 780 609 781 int setGlobalObjStats (Average *average, Measure *measure) { 610 782 -
trunk/Ohana/src/relphot/src/setMrelFinal.c
r35759 r37037 85 85 86 86 /* set catalog[0].found[i] = FALSE */ 87 ALLOCATE (catalog[0].found, off_t, MAX (1, Nsecfilt*catalog[0].Naverage)); 87 ALLOCATE (catalog[0].found_t, off_t, MAX (1, Nsecfilt*catalog[0].Naverage)); 88 ALLOCATE (catalog[0].foundWarp_t, off_t, MAX (1, Nsecfilt*catalog[0].Naverage)); 88 89 for (i = 0; i < Nsecfilt*catalog[0].Naverage; i++) { 89 catalog[0].found[i] = FALSE; 90 catalog[0].found_t[i] = FALSE; 91 catalog[0].foundWarp_t[i] = FALSE; 90 92 } 91 93 … … 194 196 195 197 /* star/photcodes already calibrated */ 196 if (catalog[0].found [Nsecfilt*i+Nsec]) continue;198 if (catalog[0].found_t[Nsecfilt*i+Nsec]) continue; 197 199 198 200 m = catalog[0].average[i].measureOffset; … … 229 231 if ((pass < 4) && ImagSelect) { 230 232 if (Nim > -1) { 231 mag = PhotInst (&catalog[0].measure[m] );233 mag = PhotInst (&catalog[0].measure[m], MAG_CLASS_PSF); 232 234 if (mag < ImagMin) goto skip; 233 235 if (mag > ImagMax) goto skip; -
trunk/Ohana/src/relphot/src/share_mean_mags.c
r36630 r37037 123 123 meanmags->M = secfilt->M; 124 124 meanmags->dM = secfilt->dM; 125 meanmags-> Xm = secfilt->Xm;125 meanmags->Mchisq = secfilt->Mchisq; 126 126 meanmags->Nsec = Nsec; // key to secfilt entry 127 127
Note:
See TracChangeset
for help on using the changeset viewer.
