Changeset 33114
- Timestamp:
- Jan 17, 2012, 4:36:22 PM (15 years ago)
- Location:
- branches/eam_branches/ipp-20111122/Ohana/src
- Files:
-
- 8 edited
-
libdvo/src/flatcorr_io.c (modified) (4 diffs)
-
uniphot/include/uniphot.h (modified) (1 diff)
-
uniphot/src/ConfigInit.c (modified) (3 diffs)
-
uniphot/src/args.c (modified) (1 diff)
-
uniphot/src/initialize.c (modified) (1 diff)
-
uniphot/src/load_zpt_table.c (modified) (7 diffs)
-
uniphot/src/match_flatcorr_to_images.c (modified) (2 diffs)
-
uniphot/src/match_zpts_to_images.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/Ohana/src/libdvo/src/flatcorr_io.c
r33104 r33114 104 104 MaxID = MAX(flatcorrTable->image[i].ID, MaxID); 105 105 } 106 MaxID ++; // we want the outer bound, not the last value 106 107 107 108 // generate the index and init values to -1 … … 126 127 assert (seq != -1); 127 128 128 flatcorrTable->offset[ i][x][y] = flatcorrTable->corr[i].offset;129 flatcorrTable->offset[seq][x][y] = flatcorrTable->corr[i].offset; 129 130 } 130 131 … … 142 143 FTable ftableCorr; 143 144 FILE *f; 145 146 FlatCorrectionImage *image; 147 FlatCorrection *corr; 148 149 // these output functions byteswap their buffers. make a copy for output 150 ALLOCATE (image, FlatCorrectionImage, flatcorrTable->Nimage); 151 memcpy (image, flatcorrTable->image, flatcorrTable->Nimage*sizeof(FlatCorrectionImage)); 152 153 ALLOCATE (corr, FlatCorrection, flatcorrTable->Ncorr); 154 memcpy (corr, flatcorrTable->corr, flatcorrTable->Ncorr*sizeof(FlatCorrection)); 144 155 145 156 /* make phu header (no matrix needed) */ … … 150 161 151 162 ftableImage.header = &theaderImage; 152 gfits_table_set_FlatCorrectionImage (&ftableImage, flatcorrTable->image, flatcorrTable->Nimage);163 gfits_table_set_FlatCorrectionImage (&ftableImage, image, flatcorrTable->Nimage); 153 164 154 165 ftableCorr.header = &theaderCorr; 155 gfits_table_set_FlatCorrection (&ftableCorr, flatcorrTable->corr, flatcorrTable->Ncorr);166 gfits_table_set_FlatCorrection (&ftableCorr, corr, flatcorrTable->Ncorr); 156 167 157 168 f = fopen (filename, "w"); -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/include/uniphot.h
r33104 r33114 77 77 time_t TSTOP; 78 78 PhotCode *photcode; 79 80 // hard-wired values which describe the ubercal analysis 81 # define NFILTER 5 82 # define NSEASON 4 83 # define NCHIP_X 8 84 # define NCHIP_Y 8 85 # define NCELL_X 2 86 # define NCELL_Y 2 87 88 // these are initialized by initialize_setphot (in initialize.c) 89 e_time tstart [NSEASON]; 90 e_time tstop [NSEASON]; 91 char filter [NFILTER]; 79 92 80 93 enum {black, white, red, orange, yellow, green, blue, indigo, violet}; -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/ConfigInit.c
r27790 r33114 7 7 double ZERO_POINT; 8 8 char *config, *file; 9 char CatdirPhotcodeFile[256];10 char MasterPhotcodeFile[256];11 9 12 10 /*** load configuration info ***/ … … 23 21 ScanConfig (config, "CATMODE", "%s", 0, CATMODE); 24 22 ScanConfig (config, "CATFORMAT", "%s", 0, CATFORMAT); 25 ScanConfig (config, "PHOTCODE_FILE", "%s", 0, MasterPhotcodeFile);26 23 27 24 sprintf (ImageCat, "%s/Images.dat", CATDIR); … … 43 40 if (*CATMODE == 0) strcpy (CATMODE, "RAW"); 44 41 if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR"); 45 46 /* XXX this does not yet write out the master photcode table */47 sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);48 if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {49 fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);50 exit (1);51 }52 53 42 } 54 43 -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/args.c
r33103 r33114 95 95 96 96 if (argc != 2) { 97 fprintf (stderr, "ERROR: USAGE: setphot (zptfile) [options]\n"); 97 fprintf (stderr, "USAGE: setphot (zptfile) [options]\n"); 98 fprintf (stderr, " options:\n"); 99 fprintf (stderr, " -v : verbose mode\n"); 100 fprintf (stderr, " -ubercal : interpret zpt file as a GPC1 ubercal FITS table\n"); 101 fprintf (stderr, " -update : actually write results to detections tables\n"); 102 fprintf (stderr, " Note that the dvo db can be specified by -D CATDIR (directory)\n"); 98 103 exit (2); 99 104 } -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/initialize.c
r31160 r33114 23 23 void initialize_setphot (int argc, char **argv) { 24 24 25 struct stat statbuffer; 26 27 char CatdirPhotcodeFile[256]; 28 25 29 /* are these set correctly? */ 26 30 ConfigInit (&argc, argv); 27 31 args_setphot (argc, argv); 32 33 if (stat (CATDIR, &statbuffer)) { 34 fprintf (stderr, "error accessing dvo database directory '%s'\n", CATDIR); 35 exit (1); 36 } 37 38 /* XXX this does not yet write out the master photcode table */ 39 sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR); 40 if (!LoadPhotcodes (CatdirPhotcodeFile, NULL, TRUE)) { 41 fprintf (stderr, "error loading photcode table %s\n", CatdirPhotcodeFile); 42 exit (1); 43 } 44 45 // we have hard-coded the MJD season ranges from Eddie in uniphot.h 46 47 double tstart_mjd[] = {55000.0, 55296.0, 55327.0, 55662.0}; 48 double tstop_mjd[] = {55296.0, 55327.0, 55662.0, 60000.0}; 49 filter[0] = 'g'; 50 filter[1] = 'r'; 51 filter[2] = 'i'; 52 filter[3] = 'z'; 53 filter[4] = 'y'; 54 55 int i; 56 for (i = 0; i < NSEASON; i++) { 57 tstart[i] = ohana_mjd_to_sec(tstart_mjd[i]); 58 tstop[i] = ohana_mjd_to_sec(tstop_mjd[i]); 59 } 28 60 } 29 61 -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/load_zpt_table.c
r33104 r33114 41 41 return zpts; 42 42 } 43 44 # define NFILTER 545 # define NSEASON 446 47 char filter[NFILTER] = {'g', 'r', 'i', 'z', 'y'};48 double tstart[NSEASON] = {55000.0, 55296.0, 55327.0, 55662.0};49 double tstop[NSEASON] = {55296.0, 55327.0, 55662.0, 60000.0};50 51 # define NCHIP_X 852 # define NCHIP_Y 853 # define NCELL_X 254 # define NCELL_Y 255 43 56 44 ZptTable *load_zpt_ubercal (char *filename, int *nzpts, FlatCorrectionTable *flatcorrTable) { … … 97 85 ALLOCATE (flatcorrTable->corr, FlatCorrection, flatcorrTable->Ncorr); 98 86 ALLOCATE (flatcorrTable->image, FlatCorrectionImage, flatcorrTable->Nimage); 87 memset (flatcorrTable->corr, 0, flatcorrTable->Ncorr*sizeof(FlatCorrection)); 99 88 100 89 int corrID = 1; … … 106 95 107 96 // read the fits table bytes 108 if ( gfits_fread_ftable_data (f, &ftable, FALSE)) return (NULL);97 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) return (NULL); 109 98 110 99 // skip over remaining bytes in data segment … … 118 107 assert (!strcmp(type, "double")); 119 108 120 double*zperr = gfits_get_bintable_column_data (&theader, &ftable, "resid", type, &Nrow, &Ncol);121 assert (!strcmp(type, " double"));109 float *zperr = gfits_get_bintable_column_data (&theader, &ftable, "resid", type, &Nrow, &Ncol); 110 assert (!strcmp(type, "float")); 122 111 123 112 NZPTS += Nrow; … … 136 125 137 126 // read the fits table bytes 138 if ( gfits_fread_matrix (f, &matrix, FALSE)) return (NULL);127 if (!gfits_fread_matrix (f, &matrix, &header)) return (NULL); 139 128 140 129 for (nseason = 0; nseason < NSEASON; nseason++) { // seasons 141 130 for (iy = 0; iy < NCHIP_Y; iy++) { // y-chip 142 131 for (ix = 0; ix < NCHIP_X; ix++) { // x-chip 132 133 // photcode name 134 char photname[64]; 135 snprintf (photname, 64, "GPC1.%c.XY%d%d", filter[nfilter], ix, iy); 136 // note that the XY00, XY07, etc, chips will have photcode values of 0 137 138 flatcorrTable->image[Nimage].photcode = GetPhotcodeCodebyName(photname); 143 139 flatcorrTable->image[Nimage].Nx = NCELL_X; 144 140 flatcorrTable->image[Nimage].Ny = NCELL_Y; … … 146 142 flatcorrTable->image[Nimage].DX = 4880; 147 143 flatcorrTable->image[Nimage].DY = 4864; 148 flatcorrTable->image[Nimage].tstart = ohana_mjd_to_sec(tstart[nseason]);149 flatcorrTable->image[Nimage].tstop = ohana_mjd_to_sec(tstop[nseason]);150 151 // photcode name152 char photname[64];153 snprintf (photname, 64, "GPC1.%c.XY%d%d", filter[nfilter], ix, iy);154 // note that the XY00, XY07, etc, chips will have photcode values of 0155 flatcorrTable->image[Nimage].photcode = GetPhotcodeCodebyName(photname);156 144 flatcorrTable->image[Nimage].tstart = tstart[nseason]; 157 145 flatcorrTable->image[Nimage].tstop = tstop[nseason]; … … 160 148 for (ixc = 0; ixc < NCELL_X; ixc++) { 161 149 if (ix > 3) { 162 seq = nfilter*NSEASON*NCHIP_X*NCHIP_Y*NCELL_X*NCELL_Y + nseason*NCHIP_X*NCHIP_Y*NCELL_X*NCELL_Y + (iy*NCELL_Y + NCELL_Y - 1 - iyc)*NCHIP_X + (ix*NCELL_X + NCELL_X - 1 - ixc);150 seq = nfilter*NSEASON*NCHIP_X*NCHIP_Y*NCELL_X*NCELL_Y + nseason*NCHIP_X*NCHIP_Y*NCELL_X*NCELL_Y + (iy*NCELL_Y + NCELL_Y - 1 - iyc)*NCHIP_X*NCELL_X + (ix*NCELL_X + NCELL_X - 1 - ixc); 163 151 } else { 164 seq = nfilter*NSEASON*NCHIP_X*NCHIP_Y*NCELL_X*NCELL_Y + nseason*NCHIP_X*NCHIP_Y*NCELL_X*NCELL_Y + (iy*NCELL_Y + iyc)*NCHIP_X + (ix*NCELL_X + ixc);152 seq = nfilter*NSEASON*NCHIP_X*NCHIP_Y*NCELL_X*NCELL_Y + nseason*NCHIP_X*NCHIP_Y*NCELL_X*NCELL_Y + (iy*NCELL_Y + iyc)*NCHIP_X*NCELL_X + (ix*NCELL_X + ixc); 165 153 } 154 assert (!flatcorrTable->corr[seq].ID); 166 155 flatcorrTable->corr[seq].x = ixc; 167 156 flatcorrTable->corr[seq].y = iyc; -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/match_flatcorr_to_images.c
r33104 r33114 1 1 # include "uniphot.h" 2 3 // the date/time of the image is used to find the 'season' 4 // the photcode is used to find the actual flat correction 2 5 3 6 int match_flatcorr_to_images (Image *image, off_t Nimage, FlatCorrectionTable *flatcorrTable) { … … 5 8 int i, j; 6 9 10 // make 4 lookup tables for the photcodes (one for each season) 11 12 short **index; 13 14 short maxCode = 0; 15 for (i = 0; i < flatcorrTable->Nimage; i++) { 16 maxCode = MAX (maxCode, flatcorrTable->image[i].photcode); 17 } 18 maxCode ++; // we want the outer bound, not the last value 19 20 ALLOCATE (index, short *, NSEASON); 21 for (i = 0; i < NSEASON; i++) { 22 ALLOCATE (index[i], short, maxCode); 23 for (j = 0; j < maxCode; j++) { 24 index[i][j] = -1; 25 } 26 } 27 28 for (j = 0; j < NSEASON; j++) { 29 assert (tstart[j]); 30 assert (tstop[j]); 31 } 32 33 for (i = 0; i < flatcorrTable->Nimage; i++) { 34 // the flat-field correction is defined for non-existent images (eg, XY00) 35 // these have photcode == 0, so skip them 36 if (!flatcorrTable->image[i].photcode) continue; 37 38 // which season? 39 for (j = 0; j < NSEASON; j++) { 40 if (flatcorrTable->image[i].tstart == tstart[j]) { 41 assert (index[j][flatcorrTable->image[i].photcode] == -1); 42 index[j][flatcorrTable->image[i].photcode] = i; 43 break; 44 } 45 } 46 } 47 7 48 for (i = 0; i < Nimage; i++) { 49 if (!image[i].photcode) continue; // skip PHU images 8 50 9 51 int found = FALSE; 10 for (j = 0; !found && (j < flatcorrTable->Nimage); j++) { 52 for (j = 0; !found && (j < NSEASON); j++) { 53 if (image[i].tzero < tstart[j]) continue; 54 if (image[i].tzero > tstop[j]) continue; 11 55 12 i f (image[i].tzero < flatcorrTable->image[j].tstart) continue;13 if ( image[i].tzero > flatcorrTable->image[j].tstop) continue;14 if (image[i].photcode != flatcorrTable->image[j].photcode) continue; 15 image[i].photom_map_id = flatcorrTable->image[ j].ID;56 int seq = index[j][image[i].photcode]; 57 if (seq == -1) break; 58 59 image[i].photom_map_id = flatcorrTable->image[seq].ID; 16 60 found = TRUE; 17 61 } -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/match_zpts_to_images.c
r29001 r33114 42 42 for (i = Nz = 0; (i < Nimage) && (Nz < Nzpts); ) { 43 43 44 if (i % 1000 == 0) fprintf (stderr, ".");45 if (Nz % 100 == 0) fprintf (stderr, "!");44 // if (i % 1000 == 0) fprintf (stderr, "."); 45 // if (Nz % 100 == 0) fprintf (stderr, "!"); 46 46 47 47 Ni = index[i];
Note:
See TracChangeset
for help on using the changeset viewer.
