- Timestamp:
- Dec 17, 2015, 8:53:56 PM (11 years ago)
- Location:
- trunk/Ohana/src/uniphot
- Files:
-
- 16 edited
-
Makefile (modified) (4 diffs)
-
include/setastrom.h (modified) (3 diffs)
-
include/setphot.h (modified) (4 diffs)
-
src/cam_correction.c (modified) (3 diffs)
-
src/cam_zpt_correction.c (modified) (8 diffs)
-
src/dcr_correction.c (modified) (3 diffs)
-
src/initialize_setastrom.c (modified) (4 diffs)
-
src/initialize_setphot.c (modified) (2 diffs)
-
src/initialize_setphot_client.c (modified) (2 diffs)
-
src/match_camcorr_to_images.c (modified) (1 diff)
-
src/setphot.c (modified) (3 diffs)
-
src/setphot_client.c (modified) (1 diff)
-
src/update_catalog_setastrom.c (modified) (8 diffs)
-
src/update_catalog_setphot.c (modified) (2 diffs)
-
src/update_dvo_setastrom.c (modified) (3 diffs)
-
src/update_dvo_setphot.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/uniphot/Makefile
r39272 r39288 1 # default: uniphot setphot setphot_client setfwhm setposangle setposangle_client setastrom setastrom_client setgalmodel setgalmodel_client fiximids fiximids_client fixstkids fixstkids_client ckids ckids_client 2 default: uniphot setfwhm setposangle setposangle_client setastrom setastrom_client setgalmodel setgalmodel_client fiximids fiximids_client fixstkids fixstkids_client ckids ckids_client 1 default: uniphot setphot setphot_client setfwhm setposangle setposangle_client setastrom setastrom_client setgalmodel setgalmodel_client fiximids fiximids_client fixstkids fixstkids_client ckids ckids_client 3 2 4 3 help: … … 36 35 ckids_client: $(BIN)/ckids_client.$(ARCH) 37 36 38 # install: $(DESTBIN)/uniphot $(DESTBIN)/setfwhm $(DESTBIN)/setphot $(DESTBIN)/setphot_client $(DESTBIN)/setposangle $(DESTBIN)/setposangle_client $(DESTBIN)/setastrom $(DESTBIN)/setastrom_client $(DESTBIN)/setgalmodel $(DESTBIN)/setgalmodel_client $(DESTBIN)/fiximids $(DESTBIN)/fiximids_client $(DESTBIN)/fixstkids $(DESTBIN)/fixstkids_client $(DESTBIN)/ckids $(DESTBIN)/ckids_client 39 install: $(DESTBIN)/uniphot $(DESTBIN)/setfwhm $(DESTBIN)/setphot $(DESTBIN)/setposangle $(DESTBIN)/setposangle_client $(DESTBIN)/setastrom $(DESTBIN)/setastrom_client $(DESTBIN)/setgalmodel $(DESTBIN)/setgalmodel_client $(DESTBIN)/fiximids $(DESTBIN)/fiximids_client $(DESTBIN)/fixstkids $(DESTBIN)/fixstkids_client $(DESTBIN)/ckids $(DESTBIN)/ckids_client 37 install: $(DESTBIN)/uniphot $(DESTBIN)/setfwhm $(DESTBIN)/setphot $(DESTBIN)/setphot_client $(DESTBIN)/setposangle $(DESTBIN)/setposangle_client $(DESTBIN)/setastrom $(DESTBIN)/setastrom_client $(DESTBIN)/setgalmodel $(DESTBIN)/setgalmodel_client $(DESTBIN)/fiximids $(DESTBIN)/fiximids_client $(DESTBIN)/fixstkids $(DESTBIN)/fixstkids_client $(DESTBIN)/ckids $(DESTBIN)/ckids_client 40 38 41 39 UNIPHOT = \ … … 70 68 $(SRC)/match_camcorr_to_images.$(ARCH).o \ 71 69 $(SRC)/cam_zpt_correction.$(ARCH).o \ 70 $(SRC)/cam_correction.$(ARCH).o \ 71 $(SRC)/dcr_correction.$(ARCH).o \ 72 $(SRC)/kh_correction.$(ARCH).o \ 73 $(SRC)/astrom_correction.$(ARCH).o \ 72 74 $(SRC)/update_dvo_setphot.$(ARCH).o \ 73 75 $(SRC)/update_catalog_setphot.$(ARCH).o \ 76 $(SRC)/update_catalog_setastrom.$(ARCH).o \ 74 77 $(SRC)/repair_catalog_by_objID.$(ARCH).o \ 75 78 $(SRC)/SetSignals.$(ARCH).o \ … … 83 86 $(SRC)/update_dvo_setphot.$(ARCH).o \ 84 87 $(SRC)/update_catalog_setphot.$(ARCH).o \ 88 $(SRC)/update_catalog_setastrom.$(ARCH).o \ 85 89 $(SRC)/repair_catalog_by_objID.$(ARCH).o \ 86 90 $(SRC)/initialize_setphot_client.$(ARCH).o \ 91 $(SRC)/cam_zpt_correction.$(ARCH).o \ 92 $(SRC)/cam_correction.$(ARCH).o \ 93 $(SRC)/dcr_correction.$(ARCH).o \ 94 $(SRC)/kh_correction.$(ARCH).o \ 95 $(SRC)/astrom_correction.$(ARCH).o \ 87 96 $(SRC)/SetSignals.$(ARCH).o \ 88 97 $(SRC)/Shutdown.$(ARCH).o \ -
trunk/Ohana/src/uniphot/include/setastrom.h
r38986 r39288 30 30 Matrix **matrix; // allocate an array of pointers 31 31 // index = ix + iy*Nx + filter*Nchips + dir*Ngroup 32 } Cam Correction;32 } CamAstromCorrection; 33 33 34 34 /* global variables set in parameter file */ … … 48 48 char *KH_FILE; 49 49 char *DCR_FILE; 50 char *CAM_FILE;51 50 char *TYC_FILE; 51 52 char *CAM_ASTROM_FILE; 52 53 53 54 int KH_RESET; … … 91 92 int get_dcr_correction (int filter, double *dX, double *dY, float Color); 92 93 93 int load_cam_correction(char *filename);94 int get_cam_correction(int chipID, int filter, float Xccd, float Yccd, double *dX, double *dY);94 int CamAstromCorrectionLoad (char *filename); 95 int CamAstromCorrectionValue (int chipID, int filter, float Xccd, float Yccd, double *dX, double *dY); 95 96 96 97 int load_tyc_correction (char *filename); -
trunk/Ohana/src/uniphot/include/setphot.h
r39272 r39288 43 43 44 44 // index = ix + iy*Nx + filter*Nchips + dir*Ngroup 45 } Cam Correction;45 } CamPhotomCorrection; 46 46 47 47 /* global variables set in parameter file */ … … 53 53 char *IMAGES; 54 54 char *SINGLE_CPT; 55 char *CAM_FILE; 55 56 char *KH_FILE; 57 char *DCR_FILE; 58 char *CAM_PHOTOM_FILE; 59 char *CAM_ASTROM_FILE; 60 61 int KH_RESET; 62 int DCR_RESET; 63 int CAM_RESET; 64 56 65 int VERBOSE; 57 66 int RESET; … … 96 105 Image *load_images_setphot PROTO((FITS_DB *db, off_t *Nimage)); 97 106 int match_zpts_to_images PROTO((Image *image, off_t Nimage, ZptTable *zpts, int Nzpts)); 98 int update_dvo_setphot PROTO((Image *image, off_t Nimage, Cam Correction *camcorr));99 void update_catalog_setphot PROTO((Catalog *catalog, Image *image, off_t *index, off_t Nimage, Cam Correction *camcorr));107 int update_dvo_setphot PROTO((Image *image, off_t Nimage, CamPhotomCorrection *camcorr)); 108 void update_catalog_setphot PROTO((Catalog *catalog, Image *image, off_t *index, off_t Nimage, CamPhotomCorrection *camcorr)); 100 109 void update_catalog_setphot_client PROTO((Catalog *catalog, ImageSubset *image, off_t *index, off_t Nimage, FlatCorrectionTable *flatcorr)); 101 110 … … 109 118 int repair_catalog_by_objID PROTO((Catalog *catalog)); 110 119 111 void free_cam_correction PROTO((CamCorrection *cam)); 112 CamCorrection *alloc_cam_correction PROTO((int Nx, int Ny, int Nfilter, int Nseason)); 113 CamCorrection *load_cam_correction PROTO((char *filename)); 114 int save_cam_correction PROTO((CamCorrection *cam, char *filename)); 115 // int get_cam_correction PROTO((int chipID, int filter, float Xccd, float Yccd, double *dX, double *dY)); 116 float get_cam_correction PROTO((CamCorrection *cam, int flat_id, float Xccd, float Yccd)); 117 CamCorrection *merge_flatcorr_and_camcorr PROTO((FlatCorrectionTable *flatcorr, CamCorrection *camcorr)); 120 void CamPhotomCorrectionFree PROTO((CamPhotomCorrection *cam)); 121 CamPhotomCorrection *CamPhotomCorrectionAlloc PROTO((int Nx, int Ny, int Nfilter, int Nseason)); 122 CamPhotomCorrection *CamPhotomCorrectionLoad PROTO((char *filename)); 123 int CamPhotomCorrectionSave PROTO((CamPhotomCorrection *cam, char *filename)); 124 float CamPhotomCorrectionValue PROTO((CamPhotomCorrection *cam, int flat_id, float Xccd, float Yccd)); 118 125 119 int match_camcorr_to_images PROTO((Image *image, off_t Nimage, CamCorrection *camcorr)); 126 int match_camcorr_to_images PROTO((Image *image, off_t Nimage, CamPhotomCorrection *camcorr)); 127 CamPhotomCorrection *merge_flatcorr_and_camcorr PROTO((FlatCorrectionTable *flatcorr, CamPhotomCorrection *camcorr)); 128 129 // spline correction functions 130 double spline_apply_dbl (double *x, double *y, double *y2, int N, double X); 131 132 int load_kh_correction (char *filename); 133 int get_kh_correction (int sub, int chip, double *dX, double *dY, float Minst); 134 135 int load_dcr_correction (char *filename); 136 int get_dcr_correction (int filter, double *dX, double *dY, float Color); 137 138 int CamAstromCorrectionLoad (char *filename); 139 int CamAstromCorrectionValue (int chipID, int filter, float Xccd, float Yccd, double *dX, double *dY); 140 141 142 int update_catalog_setastrom PROTO((Catalog *catalog)); -
trunk/Ohana/src/uniphot/src/cam_correction.c
r39262 r39288 6 6 // note that we are allocating pointers for XY00 - XY77, but only the octal elements are set (and not the 00,07,70,77 ones) 7 7 8 static Cam Correction *cam = NULL;8 static CamAstromCorrection *cam = NULL; 9 9 10 int load_cam_correction(char *filename) {10 int CamAstromCorrectionLoad (char *filename) { 11 11 12 12 int i, ix, iy, dir, filter; … … 20 20 } 21 21 22 ALLOCATE (cam, Cam Correction, 1);22 ALLOCATE (cam, CamAstromCorrection, 1); 23 23 24 24 // read the PHU header … … 96 96 // chipID == octal chip ID (eg 40 for XY40) 97 97 // filter == (01234 = grizy) 98 int get_cam_correction(int chipID, int filter, float Xccd, float Yccd, double *dX, double *dY) {98 int CamAstromCorrectionValue (int chipID, int filter, float Xccd, float Yccd, double *dX, double *dY) { 99 99 100 100 *dX = 0.0; -
trunk/Ohana/src/uniphot/src/cam_zpt_correction.c
r39278 r39288 9 9 // note that we are allocating pointers for XY00 - XY77, but only the octal elements are set (and not the 00,07,70,77 ones) 10 10 11 void free_cam_correction (CamCorrection *cam) {11 void CamPhotomCorrectionFree (CamPhotomCorrection *cam) { 12 12 13 13 if (!cam) return; … … 28 28 } 29 29 30 Cam Correction *alloc_cam_correction(int Nx, int Ny, int Nfilter, int Nseason) {31 32 Cam Correction *cam;33 34 ALLOCATE (cam, Cam Correction, 1);30 CamPhotomCorrection *CamPhotomCorrectionAlloc (int Nx, int Ny, int Nfilter, int Nseason) { 31 32 CamPhotomCorrection *cam; 33 34 ALLOCATE (cam, CamPhotomCorrection, 1); 35 35 36 36 cam->phu = NULL; … … 59 59 } 60 60 61 Cam Correction *load_cam_correction(char *filename) {61 CamPhotomCorrection *CamPhotomCorrectionLoad (char *filename) { 62 62 63 63 int i, ix, iy, season, filter; … … 88 88 if (!gfits_scan (phu, "NY_CHIP", "%d", 1, &NyCCD)) return FALSE; 89 89 90 Cam Correction *cam = alloc_cam_correction(Nx, Ny, Nfilter, Nseason);90 CamPhotomCorrection *cam = CamPhotomCorrectionAlloc (Nx, Ny, Nfilter, Nseason); 91 91 cam->phu = phu; 92 92 … … 140 140 } 141 141 142 int save_cam_correction (CamCorrection *cam, char *filename) {142 int CamPhotomCorrectionSave (CamPhotomCorrection *cam, char *filename) { 143 143 144 144 int i; … … 170 170 } 171 171 172 # if (0) 173 // input is: 174 // chipID == octal chip ID (eg 40 for XY40) 175 // filter == (01234 = grizy) 176 int get_cam_correction (CamCorrection *cam, int chipID, int filter, float Xccd, float Yccd, double *dX, double *dY) { 177 178 *dX = 0.0; 179 *dY = 0.0; 180 181 int index, jx, jy, NxModel; 182 Matrix *matrix; 183 float *buffer, value; 184 185 // split out the chipID number (eg 43 for XY43) into X and Y elements 186 int ix = (int) (chipID / 10); 187 int iy = (int) (chipID % 10); 188 189 // dX (dir == 0) 190 index = ix + iy*cam->Nx + filter*cam->Nchips; 191 192 matrix = cam->matrix[index]; 193 NxModel = cam->matrix[index]->Naxis[0]; 194 195 buffer = (float *) matrix->buffer; 196 197 jx = MAX(MIN(cam->NxCCD, Xccd / cam->dX), 0); 198 jy = MAX(MIN(cam->NyCCD, Yccd / cam->dY), 0); 199 200 value = buffer[jx + jy*NxModel]; 201 202 *dX = isnan(value) ? 0.0 : value; 203 204 // dY (dir == 1) uses the next block 205 index += cam->Ngroup; 206 207 matrix = cam->matrix[index]; 208 NxModel = cam->matrix[index]->Naxis[0]; 209 210 buffer = (float *) matrix->buffer; 211 212 jx = MAX(MIN(cam->NxCCD, Xccd / cam->dX), 0); 213 jy = MAX(MIN(cam->NyCCD, Yccd / cam->dY), 0); 214 215 value = buffer[jx + jy*NxModel]; 216 217 *dY = isnan(value) ? 0.0 : value; 218 219 return TRUE; 220 } 221 # endif 222 223 float get_cam_correction (CamCorrection *cam, int flat_id, float Xccd, float Yccd) { 172 float CamPhotomCorrectionValue (CamPhotomCorrection *cam, int flat_id, float Xccd, float Yccd) { 224 173 225 174 if (!flat_id) return 0.0; … … 249 198 } 250 199 251 Cam Correction *merge_flatcorr_and_camcorr (FlatCorrectionTable *flatcorr, CamCorrection *camcorr) {200 CamPhotomCorrection *merge_flatcorr_and_camcorr (FlatCorrectionTable *flatcorr, CamPhotomCorrection *camcorr) { 252 201 253 202 int i, j, ix, iy, Nf, Ns; … … 260 209 myAssert (camcorr->Nseason == 1, "no code to merge seasons flats to seasonal flats"); 261 210 262 // we need to create a new Cam Correction with Nx,Ny,Nfilter from camcorr and Nseason from flatcorr:263 Cam Correction *newcorr = alloc_cam_correction(camcorr->Nx, camcorr->Ny, camcorr->Nfilter, flatcorr->Nseason);211 // we need to create a new CamPhotomCorrection with Nx,Ny,Nfilter from camcorr and Nseason from flatcorr: 212 CamPhotomCorrection *newcorr = CamPhotomCorrectionAlloc (camcorr->Nx, camcorr->Ny, camcorr->Nfilter, flatcorr->Nseason); 264 213 newcorr->phu = gfits_alloc_header(); 265 214 gfits_create_header(newcorr->phu); -
trunk/Ohana/src/uniphot/src/dcr_correction.c
r37807 r39288 26 26 27 27 char type[16]; 28 char extname[80];29 28 30 29 Header header; … … 67 66 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) return (FALSE); 68 67 69 if (!gfits_scan (&theader, "EXTNAME", "%s", 1, extname)) return (FALSE); 68 char word[80]; 69 if (!gfits_scan (&theader, "EXTNAME", "%s", 1, word)) return (FALSE); 70 char *extname = strcreate(word); 70 71 71 72 // figure out the filter and direction from the EXTNAME 73 // EXTNAME is of the form DCR.[grizy].dP[xy] 72 74 73 // EXTNAME is of the form [grizy].[xy].v0 where 74 char filtname = extname[0]; 75 char *ptr = NULL; 76 char *w0 = strtok_r (extname, ".", &ptr); myAssert (w0, "invalid dcr file"); 77 char *w1 = strtok_r (NULL, ".", &ptr); myAssert (w1, "invalid dcr file"); 78 char *w2 = strtok_r (NULL, ".", &ptr); myAssert (w2, "invalid dcr file"); 79 80 myAssert (!strcmp(w0, "DCR"), "invalid dcr file"); 81 82 char filtname = w1[0]; 75 83 int filtnum = -1; 76 84 switch (filtname) { … … 86 94 87 95 int dir = -1; 88 if ( extname[2] == 'x') {96 if (w2[2] == 'x') { 89 97 dir = 0; 90 98 } 91 if ( extname[2] == 'y') {99 if (w2[2] == 'y') { 92 100 dir = 1; 93 101 } -
trunk/Ohana/src/uniphot/src/initialize_setastrom.c
r38464 r39288 79 79 } 80 80 81 CAM_ FILE = NULL;81 CAM_ASTROM_FILE = NULL; 82 82 if ((N = get_argument (argc, argv, "-CAM"))) { 83 83 remove_argument (N, &argc, argv); 84 84 char *tmpfile = strcreate (argv[N]); 85 CAM_ FILE = abspath (tmpfile, DVO_MAX_PATH);85 CAM_ASTROM_FILE = abspath (tmpfile, DVO_MAX_PATH); 86 86 remove_argument (N, &argc, argv); 87 87 } … … 174 174 } 175 175 176 if (!KH_FILE && !DCR_FILE && !CAM_ FILE && !TYC_FILE) {176 if (!KH_FILE && !DCR_FILE && !CAM_ASTROM_FILE && !TYC_FILE) { 177 177 fprintf (stderr, "WARNING: none of -CAM, -KH, -DCR, -TYC supplied\n"); 178 178 } … … 252 252 } 253 253 254 CAM_ FILE = NULL;254 CAM_ASTROM_FILE = NULL; 255 255 if ((N = get_argument (argc, argv, "-CAM"))) { 256 256 remove_argument (N, &argc, argv); 257 CAM_ FILE = strcreate (argv[N]);257 CAM_ASTROM_FILE = strcreate (argv[N]); 258 258 remove_argument (N, &argc, argv); 259 259 } … … 336 336 if (!CATDIR) usage_setastrom_client(); 337 337 338 if (!KH_FILE && !DCR_FILE && !CAM_ FILE && !TYC_FILE) {338 if (!KH_FILE && !DCR_FILE && !CAM_ASTROM_FILE && !TYC_FILE) { 339 339 fprintf (stderr, "WARNING: none of -CAM, -KH, -DCR, -TYC supplied\n"); 340 340 } -
trunk/Ohana/src/uniphot/src/initialize_setphot.c
r39272 r39288 34 34 int N; 35 35 36 CAM_FILE = NULL; 36 KH_FILE = NULL; 37 if ((N = get_argument (argc, argv, "-KH"))) { 38 remove_argument (N, &argc, argv); 39 char *tmpfile = strcreate (argv[N]); 40 KH_FILE = abspath (tmpfile, DVO_MAX_PATH); 41 remove_argument (N, &argc, argv); 42 } 43 KH_RESET = FALSE; 44 if ((N = get_argument (argc, argv, "-KH-reset"))) { 45 remove_argument (N, &argc, argv); 46 KH_RESET = TRUE; 47 } 48 49 DCR_FILE = NULL; 50 if ((N = get_argument (argc, argv, "-DCR"))) { 51 remove_argument (N, &argc, argv); 52 char *tmpfile = strcreate (argv[N]); 53 DCR_FILE = abspath (tmpfile, DVO_MAX_PATH); 54 remove_argument (N, &argc, argv); 55 } 56 DCR_RESET = FALSE; 57 if ((N = get_argument (argc, argv, "-DCR-reset"))) { 58 remove_argument (N, &argc, argv); 59 DCR_RESET = TRUE; 60 } 61 62 CAM_ASTROM_FILE = NULL; 63 if ((N = get_argument (argc, argv, "-CAM"))) { 64 remove_argument (N, &argc, argv); 65 char *tmpfile = strcreate (argv[N]); 66 CAM_ASTROM_FILE = abspath (tmpfile, DVO_MAX_PATH); 67 remove_argument (N, &argc, argv); 68 } 69 CAM_RESET = FALSE; 70 if ((N = get_argument (argc, argv, "-CAM-reset"))) { 71 remove_argument (N, &argc, argv); 72 CAM_RESET = TRUE; 73 } 74 75 CAM_PHOTOM_FILE = NULL; 37 76 if ((N = get_argument (argc, argv, "-cam-flat"))) { 38 77 remove_argument (N, &argc, argv); 39 78 char *tmpfile = strcreate (argv[N]); 40 CAM_ FILE = abspath (tmpfile, DVO_MAX_PATH);79 CAM_PHOTOM_FILE = abspath (tmpfile, DVO_MAX_PATH); 41 80 remove_argument (N, &argc, argv); 42 81 } … … 126 165 remove_argument (N, &argc, argv); 127 166 UBERCAL = TRUE; 128 if (!CAM_ FILE) {167 if (!CAM_PHOTOM_FILE) { 129 168 fprintf (stderr, "ubercal now requires a high-res static flat-file: -cam-flat filename\n"); 130 169 exit (2); -
trunk/Ohana/src/uniphot/src/initialize_setphot_client.c
r39262 r39288 27 27 int N; 28 28 29 CAM_FILE = NULL; 29 KH_FILE = NULL; 30 if ((N = get_argument (argc, argv, "-KH"))) { 31 remove_argument (N, &argc, argv); 32 char *tmpfile = strcreate (argv[N]); 33 KH_FILE = abspath (tmpfile, DVO_MAX_PATH); 34 remove_argument (N, &argc, argv); 35 } 36 KH_RESET = FALSE; 37 if ((N = get_argument (argc, argv, "-KH-reset"))) { 38 remove_argument (N, &argc, argv); 39 KH_RESET = TRUE; 40 } 41 42 DCR_FILE = NULL; 43 if ((N = get_argument (argc, argv, "-DCR"))) { 44 remove_argument (N, &argc, argv); 45 char *tmpfile = strcreate (argv[N]); 46 DCR_FILE = abspath (tmpfile, DVO_MAX_PATH); 47 remove_argument (N, &argc, argv); 48 } 49 DCR_RESET = FALSE; 50 if ((N = get_argument (argc, argv, "-DCR-reset"))) { 51 remove_argument (N, &argc, argv); 52 DCR_RESET = TRUE; 53 } 54 55 CAM_ASTROM_FILE = NULL; 30 56 if ((N = get_argument (argc, argv, "-CAM"))) { 31 57 remove_argument (N, &argc, argv); 32 58 char *tmpfile = strcreate (argv[N]); 33 CAM_ FILE = abspath (tmpfile, DVO_MAX_PATH);59 CAM_ASTROM_FILE = abspath (tmpfile, DVO_MAX_PATH); 34 60 remove_argument (N, &argc, argv); 35 61 } … … 39 65 CAM_RESET = TRUE; 40 66 } 67 68 CAM_PHOTOM_FILE = NULL; 69 /* 70 if ((N = get_argument (argc, argv, "-cam-flat"))) { 71 remove_argument (N, &argc, argv); 72 char *tmpfile = strcreate (argv[N]); 73 CAM_PHOTOM_FILE = abspath (tmpfile, DVO_MAX_PATH); 74 remove_argument (N, &argc, argv); 75 } 76 */ 41 77 42 78 VERBOSE = FALSE; -
trunk/Ohana/src/uniphot/src/match_camcorr_to_images.c
r39272 r39288 4 4 // the photcode is used to find the actual flat correction 5 5 6 int match_camcorr_to_images (Image *image, off_t Nimage, Cam Correction *camcorr) {6 int match_camcorr_to_images (Image *image, off_t Nimage, CamPhotomCorrection *camcorr) { 7 7 8 8 int i, j; 9 9 10 // we have an array of Cam Correction->matrix values, where each matrix is a flat-field image10 // we have an array of CamPhotomCorrection->matrix values, where each matrix is a flat-field image 11 11 // the sequence is seq = ix + Nx_chip*iy + filter*Nchips + season*(Nchips*Nfilter) 12 12 -
trunk/Ohana/src/uniphot/src/setphot.c
r39272 r39288 8 8 ZptTable *zpts; 9 9 10 Cam Correction *camcorr = NULL;10 CamPhotomCorrection *camcorr = NULL; 11 11 FlatCorrectionTable flatcorrTable; 12 12 … … 31 31 // XXX should this program save any old copy of this file? 32 32 33 Cam Correction *rawcorr = load_cam_correction (CAM_FILE);33 CamPhotomCorrection *rawcorr = CamPhotomCorrectionLoad (CAM_PHOTOM_FILE); 34 34 if (!rawcorr) { 35 35 fprintf (stderr, "failed to load camera-static flat-field correction\n"); … … 41 41 size = snprintf (newflatfile, DVO_MAX_PATH, "%s/flatfield.fits", CATDIR); 42 42 assert (size < DVO_MAX_PATH); 43 save_cam_correction(camcorr, newflatfile);43 CamPhotomCorrectionSave (camcorr, newflatfile); 44 44 } else { 45 45 zpts = load_zpt_table (argv[1], &Nzpts); -
trunk/Ohana/src/uniphot/src/setphot_client.c
r38986 r39288 22 22 23 23 // load the flat-field correction table from CATDIR 24 char flatcorrFile[1024]; 25 snprintf (flatcorrFile, 1024, "%s/flatcorr.fits", CATDIR); 26 FlatCorrectionTable *flatcorrTable = FlatCorrectionLoad (flatcorrFile, VERBOSE); 24 char flatfieldFile[1024]; 25 snprintf (flatfieldFile, 1024, "%s/flatfield.fits", CATDIR); 27 26 28 update_dvo_setphot (image, Nimage, flatcorrTable); 27 CamPhotomCorrection *camcorr = CamPhotomCorrectionLoad (flatfieldFile); 28 if (!camcorr) { 29 fprintf (stderr, "failed to load camera-static flat-field correction\n"); 30 exit (2); 31 } 32 33 update_dvo_setphot (image, Nimage, camcorr); 29 34 30 35 exit (0); -
trunk/Ohana/src/uniphot/src/update_catalog_setastrom.c
r38986 r39288 11 11 off_t i; 12 12 13 // this is the special date when KH corrections stopped being needed 13 14 time_t timeRef = ohana_date_to_sec("2011/05/11,00:00:00"); 14 15 … … 121 122 double dX_CAM = 0.0; 122 123 double dY_CAM = 0.0; 123 if (CAM_ FILE) {124 if (CAM_ASTROM_FILE) { 124 125 125 126 // camera systematic correction ("astroflat") depends on only the X,Y coordinate, … … 130 131 131 132 // correction is in arcseconds 132 get_cam_correction(chipID, filtCode, measure->Xccd, measure->Yccd, &dX_CAM, &dY_CAM);133 CamAstromCorrectionValue (chipID, filtCode, measure->Xccd, measure->Yccd, &dX_CAM, &dY_CAM); 133 134 } 134 135 … … 166 167 } 167 168 int filtSeq = filtCode % 100; 168 if (!isfinite(dColor)) goto skip_DCR; 169 if (!isfinite(dColor)) { 170 goto skip_DCR; 171 } 169 172 170 173 // I need to get the parallactic angle, but I only have alt & az, s:o … … 195 198 // WARNING: these are NOT sin(ha),cos(ha) but are scaled 196 199 // double ha = DEG_RAD * atan2 (sinh, cosh); 197 double sinh = -cs_alt * sn_az; 198 double cosh = sn_alt * cs_lat - cs_alt * cs_az * sn_lat; 199 double r_ha = hypot(sinh, cosh); 200 double sn_ha = sinh / r_ha; 201 double cs_ha = cosh / r_ha; 202 203 sinh = -cs_az * sn_alt * sn_ha * sn_lat + sn_az * sn_alt * cs_ha - sn_ha * cs_alt * cs_lat; 204 cosh = -sn_az * sn_ha * sn_lat - cs_az * cs_ha; 205 double r_rot = hypot(sinh, cosh); 206 207 double sn_rot = -sinh / r_rot; 208 double cs_rot = +cosh / r_rot; 200 201 // EAM 20151217: this is the old version of the code. it is mathematically identical but does some extra work: 202 // double sinh = -cs_alt * sn_az; 203 // double cosh = sn_alt * cs_lat - cs_alt * cs_az * sn_lat; 204 // double r_ha = hypot(sinh, cosh); 205 // double sn_ha = sinh / r_ha; 206 // double cs_ha = cosh / r_ha; 207 208 // sinh = -cs_az * sn_alt * sn_ha * sn_lat + sn_az * sn_alt * cs_ha - sn_ha * cs_alt * cs_lat; 209 // cosh = -sn_az * sn_ha * sn_lat - cs_az * cs_ha; 210 // double r_rot = hypot(sinh, cosh); 211 // double sn_rot = -sinh / r_rot; 212 // double cs_rot = +cosh / r_rot; 213 214 // EAM 20151217: this is the new version: 215 double sn_ha = -cs_alt * sn_az; 216 double cs_ha = sn_alt * cs_lat - cs_alt * cs_az * sn_lat; 217 218 double sn_rot_r = -cs_az * sn_alt * sn_ha * sn_lat + sn_az * sn_alt * cs_ha - sn_ha * cs_alt * cs_lat; 219 double cs_rot_r = -sn_az * sn_ha * sn_lat - cs_az * cs_ha; 220 double r_rot = hypot(sn_rot_r, cs_rot_r); 221 222 double sn_rot = -sn_rot_r / r_rot; 223 double cs_rot = cs_rot_r / r_rot; 209 224 210 225 double dPx = 0.0; … … 248 263 249 264 // do not modify the original Xccd,Yccd values 265 // dR,dD are measured as measure.D - average.D 266 // thus we correct back to the truth (average) with 267 // average.D = measure.D - dD 250 268 if (KH_FILE) { 251 269 measure[0].XoffKH = -dX_KH / pltScale; … … 264 282 measure[0].YoffDCR = 0.0; 265 283 } 266 if (CAM_ FILE) {284 if (CAM_ASTROM_FILE) { 267 285 measure[0].XoffCAM = -dX_CAM / pltScale; 268 286 measure[0].YoffCAM = -dY_CAM / pltScale; … … 291 309 292 310 if (found) { 293 fprintf (stderr, "found "OFF_T_FMT" matches \n", found);311 fprintf (stderr, "found "OFF_T_FMT" matches for setastrom\n", found); 294 312 } 295 313 -
trunk/Ohana/src/uniphot/src/update_catalog_setphot.c
r39279 r39288 1 1 # include "setphot.h" 2 2 3 void update_catalog_setphot (Catalog *catalog, Image *image, off_t *index, off_t Nimage, Cam Correction *camcorr) {3 void update_catalog_setphot (Catalog *catalog, Image *image, off_t *index, off_t Nimage, CamPhotomCorrection *camcorr) { 4 4 5 off_t i, j,found;5 off_t i, found; 6 6 7 7 // if we are resetting, reset all flags … … 9 9 10 10 found = 0; 11 for (i = 0; i < catalog[0].N average; i++) {11 for (i = 0; i < catalog[0].Nmeasure; i++) { 12 12 13 off_t m = catalog[0].average[i].measureOffset; 14 for (j = 0; j < catalog[0].average[i].Nmeasure; j++, m++) { 15 off_t idx = catalog[0].measure[m].imageID; 16 if (idx <= 0) continue; // detections with imageID == 0 do not have a valid image (eg, ref photcode) 13 Measure *measure = &catalog[0].measure[i]; 17 14 18 off_t id = index[idx]; 19 if (id < 0) continue; 15 // only do GPC1 data for now 16 if (measure[0].photcode < 10000) continue; 17 if (measure[0].photcode > 10600) continue; 18 19 off_t idx = measure[0].imageID; 20 if (idx <= 0) continue; // detections with imageID == 0 do not have a valid image (eg, ref photcode) 20 21 21 float Mcal = image[id].Mcal; 22 float dMcal = image[id].dMcal; 23 float Mflat = 0.0; 22 off_t id = index[idx]; 23 if (id < 0) continue; 24 24 25 // if we know about a flat-field correction, then we need to apply the sub-chip correction 26 int flat_id = image[id].photom_map_id; 27 if (flat_id > 0) { 28 Mflat = get_cam_correction (camcorr, flat_id, catalog[0].measure[m].Xccd, catalog[0].measure[m].Yccd); 29 } 25 float Mcal = image[id].Mcal; 26 float dMcal = image[id].dMcal; 27 float Mflat = 0.0; 30 28 31 catalog[0].measure[m].Mcal = Mcal; 32 catalog[0].measure[m].Mflat = Mflat; // in the previous version, Mcal_offset (which is added to Mflat) had a negative sign here 33 catalog[0].measure[m].dMcal = dMcal; 34 myAssert(isfinite(catalog[0].measure[m].Mcal), "oops: ubercal made a nan"); 29 // if we know about a flat-field correction, then we need to apply the sub-chip correction 30 int flat_id = image[id].photom_map_id; 31 if (flat_id > 0) { 32 Mflat = CamPhotomCorrectionValue (camcorr, flat_id, measure[0].Xccd, measure[0].Yccd); 33 } 35 34 36 if (RESET) { 37 catalog[0].measure[m].dbFlags &= ~photomFlags; 38 } 35 measure[0].Mcal = Mcal; 36 measure[0].Mflat = Mflat; // in the previous version, Mcal_offset (which is added to Mflat) had a negative sign here 37 measure[0].dMcal = dMcal; 38 myAssert(isfinite(measure[0].Mcal), "oops: ubercal made a nan"); 39 39 40 // if we are setting the zero points from an UBERCAL database, and this detection is from one of those images, 41 // then tag the measurement as well 42 if (UBERCAL && (image[id].flags & ID_IMAGE_PHOTOM_UBERCAL)) { 43 catalog[0].measure[m].dbFlags |= ID_MEAS_PHOTOM_UBERCAL; 44 } 40 if (RESET) { 41 measure[0].dbFlags &= ~photomFlags; 42 } 45 43 46 found ++; 44 // if we are setting the zero points from an UBERCAL database, and this detection is from one of those images, 45 // then tag the measurement as well 46 if (UBERCAL && (image[id].flags & ID_IMAGE_PHOTOM_UBERCAL)) { 47 measure[0].dbFlags |= ID_MEAS_PHOTOM_UBERCAL; 47 48 } 49 50 found ++; 48 51 } 49 52 50 53 if (found) { 51 fprintf (stderr, "found "OFF_T_FMT" matches \n", found);54 fprintf (stderr, "found "OFF_T_FMT" matches for setphot\n", found); 52 55 } 53 56 } -
trunk/Ohana/src/uniphot/src/update_dvo_setastrom.c
r38986 r39288 19 19 if (KH_FILE) if (!load_kh_correction (KH_FILE)) { fprintf (stderr, "failed to load KH correction %s\n", KH_FILE ); exit (1); } 20 20 if (DCR_FILE) if (!load_dcr_correction (DCR_FILE)) { fprintf (stderr, "failed to load DCR correction %s\n", DCR_FILE); exit (1); } 21 if (CAM_FILE) if (!load_cam_correction (CAM_FILE)) { fprintf (stderr, "failed to load CAM correction %s\n", CAM_FILE); exit (1); }22 21 if (TYC_FILE) if (!load_tyc_correction (TYC_FILE)) { fprintf (stderr, "failed to load TYC correction %s\n", TYC_FILE); exit (1); } 22 23 if (CAM_ASTROM_FILE) if (!CamAstromCorrectionLoad (CAM_ASTROM_FILE)) { fprintf (stderr, "failed to load CAM correction %s\n", CAM_ASTROM_FILE); exit (1); } 23 24 24 25 // determine the populated SkyRegions overlapping the requested area (default depth) … … 83 84 gfits_modify_alt (&catalog.header, "HISTORY", "%S", 0, history); // adds a new entry 84 85 85 snprintf (history, 128, "setastrom options: KH: %1d, DCR: %1d, CAM: %1d", (KH_FILE != NULL), (DCR_FILE != NULL), (CAM_ FILE != NULL));86 snprintf (history, 128, "setastrom options: KH: %1d, DCR: %1d, CAM: %1d", (KH_FILE != NULL), (DCR_FILE != NULL), (CAM_ASTROM_FILE != NULL)); 86 87 gfits_modify_alt (&catalog.header, "HISTORY", "%S", 0, history); // adds a new entry 87 88 … … 121 122 if (KH_FILE) { strextend (&command, "-KH %s", KH_FILE); } 122 123 if (DCR_FILE) { strextend (&command, "-DCR %s", DCR_FILE); } 123 if (CAM_ FILE) { strextend (&command, "-CAM %s", CAM_FILE); }124 if (CAM_ASTROM_FILE) { strextend (&command, "-CAM %s", CAM_ASTROM_FILE); } 124 125 if (UPDATE_CATFORMAT) { strextend (&command, "-update-catformat %s", UPDATE_CATFORMAT); } 125 126 if (KH_RESET) { strextend (&command, "-KH-reset"); } -
trunk/Ohana/src/uniphot/src/update_dvo_setphot.c
r39272 r39288 3 3 4 4 // XXX convert this to use the ImageSubset to save space 5 int update_dvo_setphot (Image *image, off_t Nimage, Cam Correction *camcorr) {5 int update_dvo_setphot (Image *image, off_t Nimage, CamPhotomCorrection *camcorr) { 6 6 7 7 SkyTable *sky = NULL; … … 19 19 } 20 20 21 if (KH_FILE) if (!load_kh_correction (KH_FILE)) { fprintf (stderr, "failed to load KH correction %s\n", KH_FILE ); exit (1); } 22 if (DCR_FILE) if (!load_dcr_correction (DCR_FILE)) { fprintf (stderr, "failed to load DCR correction %s\n", DCR_FILE); exit (1); } 23 24 if (CAM_ASTROM_FILE) if (!CamAstromCorrectionLoad (CAM_ASTROM_FILE)) { fprintf (stderr, "failed to load CAM correction %s\n", CAM_ASTROM_FILE); exit (1); } 25 21 26 // create an index for the image IDs 22 27 maxID = 0; … … 54 59 catalog.filename = HOST_ID ? localFilename : skylist[0].filename[i]; 55 60 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE; 61 if (KH_FILE || DCR_FILE || CAM_ASTROM_FILE) { 62 catalog.catflags |= DVO_LOAD_SECFILT; 63 } 56 64 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 57 65 … … 74 82 75 83 update_catalog_setphot (&catalog, image, index, Nimage, camcorr); 84 85 if (KH_FILE || DCR_FILE || CAM_ASTROM_FILE) { 86 update_catalog_setastrom (&catalog); 87 } 76 88 77 89 if (!UPDATE) { … … 92 104 gfits_modify_alt (&catalog.header, "HISTORY", "%S", 0, history); // adds a new entry 93 105 94 snprintf (history, 128, "setphot options: reset: %1d, ubercal: %1d ", RESET, UBERCAL);106 snprintf (history, 128, "setphot options: reset: %1d, ubercal: %1d, camflat: %1d", RESET, UBERCAL, (CAM_PHOTOM_FILE != NULL)); 95 107 gfits_modify_alt (&catalog.header, "HISTORY", "%S", 0, history); // adds a new entry 108 109 if (KH_FILE || DCR_FILE || CAM_ASTROM_FILE) { 110 gfits_modify (&catalog.header, "SETASTR", "%s", 1, moddate); // replaces the single entry 111 112 snprintf (history, 128, "setphot (setastrom) options: KH: %1d, DCR: %1d, CAM: %1d", (KH_FILE != NULL), (DCR_FILE != NULL), (CAM_ASTROM_FILE != NULL)); 113 gfits_modify_alt (&catalog.header, "HISTORY", "%S", 0, history); // adds a new entry 114 } 96 115 97 116 free (moddate); … … 139 158 if (RESET) { strextend (&command, "-reset"); } 140 159 if (UPDATE) { strextend (&command, "-update"); } 141 if (UBERCAL) { strextend (&command, "-ubercal"); }142 160 if (REPAIR_BY_OBJID) { strextend (&command, "-repair-by-objid"); } 161 162 if (UBERCAL) { strextend (&command, "-ubercal"); } 163 // if (CAM_PHOTOM_FILE) { strextend (&command, "-cam-flat %s", CAM_PHOTOM_FILE); } 164 165 if (KH_FILE) { strextend (&command, "-KH %s", KH_FILE); } 166 if (DCR_FILE) { strextend (&command, "-DCR %s", DCR_FILE); } 167 if (CAM_ASTROM_FILE) { strextend (&command, "-CAM %s", CAM_ASTROM_FILE); } 168 169 if (KH_RESET) { strextend (&command, "-KH-reset"); } 170 if (DCR_RESET) { strextend (&command, "-DCR-reset"); } 171 if (CAM_RESET) { strextend (&command, "-CAM-reset"); } 143 172 144 173 fprintf (stderr, "command: %s\n", command);
Note:
See TracChangeset
for help on using the changeset viewer.
