Changeset 30976
- Timestamp:
- Mar 18, 2011, 2:11:14 PM (15 years ago)
- Location:
- branches/eam_branches/ipp-20110213/Ohana/src
- Files:
-
- 10 edited
-
relphot/src/load_images.c (modified) (3 diffs)
-
uniphot/Makefile (modified) (1 diff)
-
uniphot/include/uniphot.h (modified) (2 diffs)
-
uniphot/src/dumpresult.c (modified) (1 diff)
-
uniphot/src/find_image_sgroups.c (modified) (4 diffs)
-
uniphot/src/find_image_tgroups.c (modified) (6 diffs)
-
uniphot/src/fit_groups.c (modified) (2 diffs)
-
uniphot/src/subset_images.c (modified) (3 diffs)
-
uniphot/src/uniphot.c (modified) (5 diffs)
-
uniphot/src/update.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110213/Ohana/src/relphot/src/load_images.c
r30616 r30976 7 7 fprintf (stderr, MSG, __VA_ARGS__); } 8 8 9 // This function generates a subset of the images based on selections. Input db has already 10 // been loaded with the raw fits table data 9 11 SkyList *load_images (FITS_DB *db, char *regionName, SkyRegion *region, int RegionSelect) { 10 12 … … 32 34 } 33 35 34 // convert database table to internal structure 36 // convert database table to internal structure (binary to Image) 35 37 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped); 36 38 if (!image) { … … 44 46 MARKTIME("selected images: %f sec\n", dtime); 45 47 48 // generate db->vtable from db->ftable based on the selection 49 // XXX does this simply duplicate the memory needlessly? we recreate these lines 50 // in reload_images. If we had saved the line numbers, we could avoid this 46 51 gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, LineNumber, Nsubset); 47 52 MARKTIME("converted ftable to vtable: %f sec\n", dtime); 48 53 54 // save the subset of images in the static reference in ImageOps, set up indexes 49 55 initImages (subset, Nsubset); 50 56 MARKTIME("init images: %f sec\n", dtime); 51 57 58 // match chips to mosaics (if applicable) 52 59 initMosaics (subset, Nsubset); 53 60 MARKTIME("init mosaics: %f sec\n", dtime); -
branches/eam_branches/ipp-20110213/Ohana/src/uniphot/Makefile
r27790 r30976 34 34 $(SRC)/update.$(ARCH).o \ 35 35 $(SRC)/update_catalog.$(ARCH).o \ 36 $(SRC)/convert.$(ARCH).o \ 36 37 $(SRC)/SetSignals.$(ARCH).o \ 37 38 $(SRC)/Shutdown.$(ARCH).o \ -
branches/eam_branches/ipp-20110213/Ohana/src/uniphot/include/uniphot.h
r28717 r30976 29 29 30 30 typedef struct { 31 char tstart[64]; 32 char tstop[64]; 31 33 char label[64]; 32 34 float M; … … 124 126 int update_setphot PROTO((Image *image, off_t Nimage)); 125 127 void update_catalog_setphot PROTO((Catalog *catalog, Image *image, off_t *index, off_t Nimage)); 128 129 /*** time/coord conversion functions not supplied by libohana ***/ 130 time_t TimeRef PROTO((double time, time_t TimeReference, int TimeFormat)); 131 double TimeValue PROTO((time_t time, time_t TimeReference, int TimeFormat)); 132 133 int hh_hms PROTO((double hh, int *hr, int *mn, double *sc)); 134 int dd_dms PROTO((double dd, int *dg, int *mn, double *sc)); 135 int hms_format PROTO((char *line, double value)); 136 int dms_format PROTO((char *line, double value)); 137 int hh_hm PROTO((double hh, int *hr, double *mn)); 138 int day_to_sec PROTO((char *string, time_t *second)); 139 int hms_to_sec PROTO((char *string, time_t *second)); 140 char *ohana_sec_to_hms PROTO((time_t second)); 141 char *ohana_sec_to_day PROTO((time_t second)); 142 143 char *meade_deg_to_str PROTO((double deg)); 144 char *meade_ra_to_str PROTO((double deg)); 145 char *meade_dec_to_str PROTO((double deg)); 146 char *strptime PROTO((const char *s, const char *format, struct tm *tm)); 147 time_t GetTimeReference PROTO((char *reference)); 148 int GetTimeUnits PROTO((char *name)); -
branches/eam_branches/ipp-20110213/Ohana/src/uniphot/src/dumpresult.c
r4797 r30976 17 17 Mgrp = tgrp[0].M; 18 18 fprintf (f, "%7.4f %7.4f %7.4f %7.4f %10.6f %10.6f %f %s\n", 19 0.001*Mcal, 0.001*Mgrp, 0.001*Mset, 0.001*sgroup[i].image[j][0].dMcal,19 Mcal, Mgrp, Mset, sgroup[i].image[j][0].dMcal, 20 20 sgroup[i].image[j][0].coords.crval1, sgroup[i].image[j][0].coords.crval2, (sgroup[i].image[j][0].tzero-915148800)/86400.0, tgrp[0].label); 21 21 } -
branches/eam_branches/ipp-20110213/Ohana/src/uniphot/src/find_image_sgroups.c
r29001 r30976 3 3 Group *find_image_sgroups (FITS_DB *db, ImageLink **Imlink, int *Nsgroup) { 4 4 5 off_t i, Nimage;6 int j,Ngroup, Nentry, NENTRY;5 off_t i, j, Nimage; 6 int Ngroup, Nentry, NENTRY; 7 7 double r, d, x, y, radius; 8 8 Group *group; … … 27 27 ALLOCATE (group, Group, Nimage); 28 28 29 if (VERBOSE) fprintf (stderr, "finding images\n"); 30 BuildChipMatch (image, Nimage); 31 // MARKTIME("build chip match: %f sec\n", dtime); 32 29 33 /* set imlink.sgroups = NULL as a marker */ 30 34 for (i = 0; i < Nimage; i++) imlink[i].sgroup = NULL; … … 34 38 if (image[i].flags & ID_IMAGE_PHOTOM_NOCAL) continue; 35 39 40 // XXX optionally, we should be able to use ONLY the DIS or NOT the DIS images 41 // NOCAL above is used to mark images which do not match the photcode (including the DIS) 42 // if (!strcmp(&image[i].coords.ctype[4], "-DIS")) continue; 43 44 // this adds 1.3 sec for 3M images 45 if (!FindMosaicForImage (image, Nimage, i)) { 46 fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i); 47 continue; 48 } 49 50 /* define image center - note the DIS images (mosaic phu) are special */ 51 if (!strcmp(&image[i].coords.ctype[4], "-DIS")) { 52 XY_to_RD (&r, &d, 0.0, 0.0, &image[i].coords); 53 } else { 54 XY_to_RD (&r, &d, 0.5*image[i].NX, 0.5*image[i].NX, &image[i].coords); 55 } 56 36 57 /* new sgroup, set ref coords */ 37 XY_to_RD (&r, &d, 0.5*image[i].NX, 0.5*image[i].NX, &image[i].coords);38 58 coords.crval1 = r; 39 59 coords.crval2 = d; … … 59 79 if (image[j].flags & ID_IMAGE_PHOTOM_NOCAL) continue; 60 80 if (imlink[j].sgroup != NULL) continue; 81 // XXX optionally, we should be able to use ONLY the DIS or NOT the DIS images 82 // NOCAL above is used to mark images which do not match the photcode (including the DIS) 83 // if (!strcmp(&image[j].coords.ctype[4], "-DIS")) continue; 84 85 // this adds 1.3 sec for 3M images 86 if (!FindMosaicForImage (image, Nimage, j)) { 87 fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", j); 88 continue; 89 } 61 90 62 91 /* project image center to local coords, check radius */ 63 XY_to_RD (&r, &d, 0.5*image[j].NX, 0.5*image[j].NX, &image[j].coords); 92 if (!strcmp(&image[j].coords.ctype[4], "-DIS")) { 93 XY_to_RD (&r, &d, 0.0, 0.0, &image[j].coords); 94 } else { 95 XY_to_RD (&r, &d, 0.5*image[j].NX, 0.5*image[j].NX, &image[j].coords); 96 } 64 97 if (!RD_to_XY (&x, &y, r, d, &coords)) continue; 98 65 99 /* RD_to_XY returns FALSE if opposite hemispheres */ 66 100 radius = hypot (x, y); -
branches/eam_branches/ipp-20110213/Ohana/src/uniphot/src/find_image_tgroups.c
r29001 r30976 5 5 char *start, *stop; 6 6 int j, Ngroup, NGROUP, Nentry, NENTRY; 7 off_t i, Nimage ;7 off_t i, Nimage, Ntime; 8 8 unsigned int *time, *tmin, *tmax; 9 9 Group *group; … … 21 21 /* sort time list (use only valid images?) */ 22 22 ALLOCATE (time, unsigned int, Nimage); 23 Ntime = 0; 23 24 for (i = 0; i < Nimage; i++) { 24 time[i] = image[i].tzero; 25 if (image[i].flags & ID_IMAGE_PHOTOM_NOCAL) continue; 26 if (!strcmp(&image[i].coords.ctype[4], "-DIS")) continue; 27 time[Ntime] = image[i].tzero; 28 Ntime ++; 25 29 } 26 sort_time (time, N image);30 sort_time (time, Ntime); 27 31 28 32 /* find groups with dt < TRANGE */ … … 34 38 35 39 /* generate tgroups */ 36 for (i = 0; i < N image - 1; i++) {40 for (i = 0; i < Ntime - 1; i++) { 37 41 if (time[i+1] - time[i] < TRANGE) continue; 38 42 … … 47 51 tmin[Ngroup] = time[i + 1]; 48 52 } 49 tmax[Ngroup] = time[N image - 1];53 tmax[Ngroup] = time[Ntime - 1]; 50 54 Ngroup ++; 51 55 ALLOCATE (group, Group, Ngroup); … … 63 67 stop = ohana_sec_to_date (tmax[i]); 64 68 snprintf (group[i].label, 64, "%s - %s", start, stop); 69 strcpy(group[i].tstart, start); 70 strcpy(group[i].tstop, stop); 65 71 free (start); 66 72 free (stop); … … 70 76 if (image[j].tzero > tmax[i]) continue; 71 77 if (image[j].flags & ID_IMAGE_PHOTOM_NOCAL) continue; 78 if (!strcmp(&image[j].coords.ctype[4], "-DIS")) continue; 72 79 73 80 group[i].image[Nentry] = &image[j]; -
branches/eam_branches/ipp-20110213/Ohana/src/uniphot/src/fit_groups.c
r21508 r30976 29 29 tgroup[i].Ngood = stats.Nmeas; 30 30 31 // fprintf (stderr, "tgroup %d : %f +/- %f : %d stars\n", i, stats.mean, stats.sigma, stats.Nmeas); 32 31 33 initstats ("MEAN"); 32 34 liststats (mlist, dlist, Nlist, &stats); … … 67 69 sgroup[i].Ngood = stats.Nmeas; 68 70 71 // fprintf (stderr, "sgroup %d : %f +/- %f : %d stars\n", i, stats.mean, stats.sigma, stats.Nmeas); 72 69 73 initstats ("MEAN"); 70 74 liststats (mlist, dlist, Nlist, &stats); -
branches/eam_branches/ipp-20110213/Ohana/src/uniphot/src/subset_images.c
r29001 r30976 3 3 int subset_images (FITS_DB *db) { 4 4 5 off_t i, Nimage , Nkeep, *keep;5 off_t i, Nimage; 6 6 int equiv; 7 7 Image *image; 8 8 9 / * use a vtable to keep the images to be calibrated */9 // convert from the binary I/O format to the internal structure (Image) 10 10 image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped); 11 11 if (!image) { … … 13 13 exit (2); 14 14 } 15 16 Nkeep = 0;17 ALLOCATE (keep, off_t, Nimage);18 15 19 16 /* mark images to be calibrated */ … … 32 29 } 33 30 image[i].flags &= ~ID_IMAGE_PHOTOM_NOCAL; 34 keep[Nkeep] = i;35 Nkeep ++;36 31 } 37 38 gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, keep, Nkeep);39 32 return (TRUE); 40 33 } -
branches/eam_branches/ipp-20110213/Ohana/src/uniphot/src/uniphot.c
r27790 r30976 1 1 # include "uniphot.h" 2 3 static char *timeref = "2000/01/01,00:00:00"; 4 static char *timeunit = "days"; 2 5 3 6 int main (int argc, char **argv) { … … 8 11 FITS_DB db; 9 12 13 // set up time format stuff 14 time_t TimeReference = GetTimeReference (timeref); 15 int TimeUnits = GetTimeUnits (timeunit); 16 10 17 /* get configuration info, args, lockfile */ 11 18 initialize_uniphot (argc, argv); … … 15 22 if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename); 16 23 if (db.dbstate == LCK_EMPTY) Shutdown ("ERROR: No images in catalog %s (1)", db.filename); 17 if (!UPDATE) dvo_image_unlock (&db);18 24 19 25 /* load images */ 20 26 load_images_uniphot (&db); 27 if (!UPDATE) dvo_image_unlock (&db); 21 28 22 29 /* filter image list by selection */ … … 38 45 fprintf (stdout, "# NLOOP: %d\n", NLOOP); 39 46 fprintf (stdout, "# time groups : %d\n", Ntgroup); 47 fprintf (stdout, "# TIMEREF : %s\n", timeref); 48 fprintf (stdout, "# TIMEFORMAT : %s\n", timeunit); 40 49 for (i = 0; i < Ntgroup; i++) { 41 fprintf (stdout, "%s %5d %5d %7.4f %7.4f %7.4f\n", tgroup[i].label, 42 tgroup[i].Nimage, tgroup[i].Ngood, 0.001*tgroup[i].M, 0.001*tgroup[i].dM, 0.001*tgroup[i].dMsub); 50 51 double tstart = NAN; 52 double tstop = NAN; 53 54 time_t time; 55 if (ohana_str_to_time (tgroup[i].tstart, &time)) { 56 tstart = TimeValue (time, TimeReference, TimeUnits); 57 } 58 if (ohana_str_to_time (tgroup[i].tstop, &time)) { 59 tstop = TimeValue (time, TimeReference, TimeUnits); 60 } 61 62 fprintf (stdout, "%s : %12.6f %12.6f : %5d %5d %7.4f %7.4f %7.4f\n", 63 tgroup[i].label, tstart, tstop, 64 tgroup[i].Nimage, tgroup[i].Ngood, 65 tgroup[i].M, tgroup[i].dM, tgroup[i].dMsub); 43 66 } 44 67 fprintf (stdout, "\n"); … … 47 70 for (i = 0; i < Nsgroup; i++) { 48 71 fprintf (stdout, "%s %5d %5d %7.4f %7.4f %7.4f\n", sgroup[i].label, 49 sgroup[i].Nimage, sgroup[i].Ngood, 0.001*sgroup[i].M, 0.001*sgroup[i].dM, 0.001*sgroup[i].dMsub);72 sgroup[i].Nimage, sgroup[i].Ngood, sgroup[i].M, sgroup[i].dM, sgroup[i].dMsub); 50 73 } 51 74 if (!UPDATE) exit (0); -
branches/eam_branches/ipp-20110213/Ohana/src/uniphot/src/update.c
r29001 r30976 4 4 void update (FITS_DB *db, Group *sgroup, int Nsgroup) { 5 5 6 off_t i, Nimage ;6 off_t i, Nimage, Nkeep, *keep; 7 7 int j, status, Nmin; 8 8 char line[256]; … … 19 19 } 20 20 21 /* clear the NOCAL flags */ 21 // create a subset list so we can make a vtable 22 Nkeep = 0; 23 ALLOCATE (keep, off_t, Nimage); 24 25 // identify the images used and clear the NOCAL flags on the rest 22 26 for (i = 0; i < Nimage; i++) { 23 image[i].flags &= ~ID_IMAGE_PHOTOM_NOCAL; 27 if (image[i].flags & ID_IMAGE_PHOTOM_NOCAL) { 28 image[i].flags &= ~ID_IMAGE_PHOTOM_NOCAL; 29 continue; 30 } 31 keep[Nkeep] = i; 32 Nkeep ++; 24 33 } 25 34 … … 31 40 } 32 41 33 /** write image table **/ 42 // save the rows in the image table which were used in this analysis 43 gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, keep, Nkeep); 44 45 // write image table 34 46 dvo_image_update (db, VERBOSE); 47 48 // XXX need to fix the update for the catalog (or make it optional) 49 return; 35 50 36 51 // XXX this process uses the existence of the file to perform the update
Note:
See TracChangeset
for help on using the changeset viewer.
