Changeset 3323
- Timestamp:
- Feb 24, 2005, 4:40:00 PM (21 years ago)
- Location:
- trunk/Ohana/src/mosastro
- Files:
-
- 13 added
- 18 edited
-
Makefile (modified) (7 diffs)
-
include/mosastro.h (modified) (5 diffs)
-
src/ConfigInit.c (modified) (1 diff)
-
src/FitChips.c (added)
-
src/FitGradients.c (added)
-
src/GetGradients.c (added)
-
src/GetScatter.c (added)
-
src/LoadStars.c (modified) (6 diffs)
-
src/args.c (modified) (3 diffs)
-
src/args_obs.c (added)
-
src/chips.c (modified) (2 diffs)
-
src/clip.c (added)
-
src/dump.c (modified) (2 diffs)
-
src/fakefield.c (modified) (5 diffs)
-
src/field.c (modified) (4 diffs)
-
src/fitpoly.c (added)
-
src/gaussj.c (added)
-
src/getstone.c (added)
-
src/getusno.c (modified) (1 diff)
-
src/greference.c (modified) (1 diff)
-
src/match.c (modified) (3 diffs)
-
src/mkheader.c (modified) (2 diffs)
-
src/mkmosaic.c (added)
-
src/mkobs.c (modified) (7 diffs)
-
src/mkpolyterm.c (added)
-
src/mkstandards.c (modified) (3 diffs)
-
src/mosastro.c (modified) (3 diffs)
-
src/output.c (added)
-
src/random.c (added)
-
src/warptest.c (modified) (1 diff)
-
src/wstars.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/mosastro/Makefile
r3294 r3323 1 default: mosastro 2 help: 3 @echo "make options: mosastro (default) mkstandards mkobs warptest" 4 1 5 include ../../Configure 6 2 7 HOME = $(ROOT)/src/mosastro.v3 3 PROGRAM = mosastro4 default: $(PROGRAM)5 6 8 BIN = $(HOME)/bin 7 9 INC = $(HOME)/include … … 32 34 $(SRC)/sort.$(ARCH).o \ 33 35 $(SRC)/ConfigInit.$(ARCH).o \ 36 $(SRC)/getstone.$(ARCH).o \ 34 37 $(SRC)/get2mass.$(ARCH).o \ 35 38 $(SRC)/getgsc.$(ARCH).o \ … … 42 45 $(SRC)/field.$(ARCH).o \ 43 46 $(SRC)/chips.$(ARCH).o \ 47 $(SRC)/GetGradients.$(ARCH).o \ 48 $(SRC)/FitGradients.$(ARCH).o \ 49 $(SRC)/FitChips.$(ARCH).o \ 50 $(SRC)/fitpoly.$(ARCH).o \ 51 $(SRC)/output.$(ARCH).o \ 52 $(SRC)/wstars.$(ARCH).o \ 53 $(SRC)/gaussj.$(ARCH).o \ 54 $(SRC)/mkpolyterm.$(ARCH).o \ 55 $(SRC)/mkmosaic.$(ARCH).o \ 56 $(SRC)/GetScatter.$(ARCH).o \ 57 $(SRC)/clip.$(ARCH).o \ 44 58 $(SRC)/parse_time.$(ARCH).o 45 59 … … 50 64 $(SRC)/mkstandards.$(ARCH).o \ 51 65 $(SRC)/mkheader.$(ARCH).o \ 66 $(SRC)/random.$(ARCH).o \ 52 67 $(SRC)/wstars.$(ARCH).o 53 68 … … 56 71 57 72 OBS = \ 73 $(SRC)/args_obs.$(ARCH).o \ 58 74 $(SRC)/mkobs.$(ARCH).o \ 59 75 $(SRC)/mkheader.$(ARCH).o \ … … 67 83 $(SRC)/getgsc.$(ARCH).o \ 68 84 $(SRC)/getptolemy.$(ARCH).o \ 85 $(SRC)/getstone.$(ARCH).o \ 69 86 $(SRC)/gptolemy.$(ARCH).o \ 70 87 $(SRC)/gregions.$(ARCH).o \ 71 88 $(SRC)/gcatalog.$(ARCH).o \ 72 89 $(SRC)/getusno.$(ARCH).o \ 90 $(SRC)/mkpolyterm.$(ARCH).o \ 91 $(SRC)/random.$(ARCH).o \ 73 92 $(SRC)/wstars.$(ARCH).o 74 93 … … 78 97 warptest: $(BIN)/warptest.(ARCH) 79 98 $(BIN)/warptest.(ARCH) : $(SRC)/warptest.$(ARCH).o 99 100 $(MOS) : $(INC)/mosastro.h 101 $(OBS) : $(INC)/mosastro.h 102 $(STD) : $(INC)/mosastro.h 103 104 INSTALL = mosastro mkstandards mkobs 80 105 81 106 # dependancy rules for binary code ######################### -
trunk/Ohana/src/mosastro/include/mosastro.h
r3294 r3323 8 8 double X, Y; /* Chip Coords - pixels */ 9 9 double Mag, dMag; 10 int type;10 int mask; 11 11 } StarData; 12 12 … … 20 20 char *file; 21 21 int Nstars; 22 int NX, NY; 22 23 StarData *stars; 24 Header header; 25 char *buffer; 26 int Nbuffer; 23 27 24 28 int Nmatch; … … 60 64 } Stars; 61 65 66 int ChipOrder; 62 67 int Nchip; 63 68 Chip *chip; 64 69 Field field; 65 70 double Year; /** carried for precession - probably put this in chip data **/ 66 double RADIUS; /** raw / ref matching radius (units?) **/ 71 double RADIUS; /** raw / ref matching radius (pixels on Focal Plane) **/ 72 double SIGMA; 73 double SIGMA_LIM; 67 74 75 char StoneRegions[256]; 68 76 char CDROM[256]; 69 77 char REFCAT[256]; 70 78 char CATDIR[256]; 79 char ExptimeKeyword[256]; 71 80 char DateKeyword[256]; 72 81 char DateMode[256]; … … 76 85 char TWO_MASS_DIR[256]; 77 86 int VERBOSE; 87 int NO_CHIPS; 78 88 79 89 char GSCFILE[256]; 80 90 char GSC_DIR[256]; 91 92 char *FIELD; 93 char *CHIPS; 94 char *OUTPUT; 95 char *DUMP; 96 char *FOCAL_PLANE; 81 97 82 98 StarData *getusno (CatStats *catstats, int *Nstars); … … 103 119 int fake_field (double RA, double DEC); 104 120 Gradients *GetGradients (); 121 void FitChips (int Norder); 122 void FitChipLinear (StarData *raw, StarData *ref, int Nmatch, Coords *coords); 123 void FitChipResid (StarData *raw, StarData *ref, int Nmatch, Coords *coords); 124 double GetScatter (); 125 Header *mkmosaic (int Nx, int Ny, int Nstars, Coords *coords); -
trunk/Ohana/src/mosastro/src/ConfigInit.c
r3294 r3323 17 17 if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file); 18 18 19 GetConfig (config, "USNO_CDROM", "%s", 0, CDROM);20 GetConfig (config, "DATE-KEYWORD", "%s", 0, DateKeyword);21 GetConfig (config, "DATE-MODE", "%s", 0, DateMode);22 GetConfig (config, "UT-KEYWORD", "%s", 0, UTKeyword);23 GetConfig (config, "MJD-KEYWORD", "%s", 0, MJDKeyword);24 GetConfig (config, "JD-KEYWORD", "%s", 0, JDKeyword);25 ScanConfig (config, "2MASS_DIR", "%s", 0, TWO_MASS_DIR);19 GetConfig (config, "USNO_CDROM", "%s", 0, CDROM); 20 GetConfig (config, "DATE-KEYWORD", "%s", 0, DateKeyword); 21 GetConfig (config, "DATE-MODE", "%s", 0, DateMode); 22 GetConfig (config, "UT-KEYWORD", "%s", 0, UTKeyword); 23 GetConfig (config, "MJD-KEYWORD", "%s", 0, MJDKeyword); 24 GetConfig (config, "JD-KEYWORD", "%s", 0, JDKeyword); 25 ScanConfig (config, "2MASS_DIR", "%s", 0, TWO_MASS_DIR); 26 26 27 27 GetConfig (config, "ASTRO_REFCAT", "%s", 0, REFCAT); 28 ScanConfig (config, "CATDIR", "%s", 0, CATDIR); 29 ScanConfig (config, "GSCFILE", "%s", 0, GSCFILE); 30 ScanConfig (config, "GSCDIR", "%s", 0, GSC_DIR); 28 ScanConfig (config, "CATDIR", "%s", 0, CATDIR); 29 ScanConfig (config, "GSCFILE", "%s", 0, GSCFILE); 30 ScanConfig (config, "GSCDIR", "%s", 0, GSC_DIR); 31 ScanConfig (config, "STONE_DIR", "%s", 0, StoneRegions); 32 33 /* abstracted header keywords */ 34 ScanConfig (config, "DATE-KEYWORD", "%s", 0, DateKeyword); 35 ScanConfig (config, "DATE-MODE", "%s", 0, DateMode); 36 ScanConfig (config, "UT-KEYWORD", "%s", 0, UTKeyword); 37 ScanConfig (config, "MJD-KEYWORD", "%s", 0, MJDKeyword); 38 ScanConfig (config, "JD-KEYWORD", "%s", 0, JDKeyword); 39 ScanConfig (config, "EXPTIME-KEYWORD", "%s", 0, ExptimeKeyword); 31 40 32 41 GetConfig (config, "RADIUS", "%lf", 0, &RADIUS); 42 GetConfig (config, "SIGMA_LIM", "%lf", 0, &SIGMA_LIM); 33 43 34 44 free (config); -
trunk/Ohana/src/mosastro/src/LoadStars.c
r3297 r3323 4 4 int LoadStars (int Nfile, char **file) { 5 5 6 Header header;6 Header *header; 7 7 int i, j, NCHIP, itmp, Nbytes, nbytes; 8 8 FILE *f; 9 char *buffer;10 9 time_t tsval; 11 10 struct tm *tmval; … … 20 19 21 20 /* load header */ 22 if (!fits_read_header (chip[Nchip].file, & header)) {21 if (!fits_read_header (chip[Nchip].file, &chip[Nchip].header)) { 23 22 fprintf (stderr, "ERROR: can't read header for %s\n", file[i]); 24 23 free (chip[Nchip].file); … … 31 30 continue; 32 31 } 33 fseek (f, header.size, SEEK_SET); 32 fseek (f, chip[Nchip].header.size, SEEK_SET); 33 34 /* get image dimensions */ 35 fits_scan (&chip[Nchip].header, "NAXIS1", "%d", 1, &chip[Nchip].NX); 36 fits_scan (&chip[Nchip].header, "NAXIS2", "%d", 1, &chip[Nchip].NY); 34 37 35 38 /* get astrometry information */ 36 if (!GetCoords (&chip[Nchip].coords, & header)) {39 if (!GetCoords (&chip[Nchip].coords, &chip[Nchip].header)) { 37 40 fprintf (stderr, "ERROR: no astrometric solution in header\n"); 38 41 free (chip[Nchip].file); … … 43 46 44 47 itmp = 0; 45 fits_scan (& header, "NASTRO", "%d", 1, &itmp);48 fits_scan (&chip[Nchip].header, "NASTRO", "%d", 1, &itmp); 46 49 if (itmp == 0) { 47 50 fprintf (stderr, "ERROR: bad astrometric solution in header %s\n", file[i]); … … 51 54 52 55 /* get time info */ 53 tsval = parse_time (& header);56 tsval = parse_time (&chip[Nchip].header); 54 57 tmval = gmtime (&tsval); 55 58 Year = tmval[0].tm_year; 56 59 57 60 /* find expected number of stars */ 58 fits_scan (& header, "NSTARS", "%d", 1, &chip[Nchip].Nstars);61 fits_scan (&chip[Nchip].header, "NSTARS", "%d", 1, &chip[Nchip].Nstars); 59 62 if (chip[Nchip].Nstars == 0) { 60 63 fprintf (stderr, "ERROR: can't get NSTARS from header for %s\n", file[i]); … … 65 68 66 69 Nbytes = BYTES_STAR * chip[Nchip].Nstars; 67 ALLOCATE ( buffer, char, Nbytes + 1);68 nbytes = Fread ( buffer, 1, Nbytes, f, "char");70 ALLOCATE (chip[Nchip].buffer, char, Nbytes + 1); 71 nbytes = Fread (chip[Nchip].buffer, 1, Nbytes, f, "char"); 69 72 if (nbytes != Nbytes) { exit (1); } 73 chip[Nchip].Nbuffer = Nbytes; 70 74 71 /** need to save all input lines so we can write on output? (gastro does not) **/72 75 for (j = 0; j < chip[Nchip].Nstars; j++) { 73 76 bzero (&chip[Nchip].stars[j], sizeof(StarData)); 74 dparse (&chip[Nchip].stars[j].X, 1, &buffer[j*BYTES_STAR]); 75 dparse (&chip[Nchip].stars[j].Y, 2, &buffer[j*BYTES_STAR]); 76 dparse (&chip[Nchip].stars[j].Mag, 3, &buffer[j*BYTES_STAR]); 77 dparse (&chip[Nchip].stars[j].X, 1, &chip[Nchip].buffer[j*BYTES_STAR]); 78 dparse (&chip[Nchip].stars[j].Y, 2, &chip[Nchip].buffer[j*BYTES_STAR]); 79 dparse (&chip[Nchip].stars[j].Mag, 3, &chip[Nchip].buffer[j*BYTES_STAR]); 80 dparse (&chip[Nchip].stars[j].dMag, 4, &chip[Nchip].buffer[j*BYTES_STAR]); 81 chip[Nchip].stars[j].dMag *= 0.001; /* millimag errors stored in file */ 77 82 } 78 /** free this or keep with chip data? **/79 free (buffer);80 83 81 84 if (VERBOSE) fprintf (stderr, "loaded %d stars from %s\n", chip[Nchip].Nstars, chip[Nchip].file); -
trunk/Ohana/src/mosastro/src/args.c
r3294 r3323 25 25 } 26 26 27 /* 28 DUMP_REF = FALSE; 29 if ((N = get_argument (*argc, argv, "-dumpref"))) { 30 DUMP_REF = TRUE; 27 DUMP = NULL; 28 if ((N = get_argument (*argc, argv, "-dump"))) { 31 29 remove_argument (N, argc, argv); 32 } 33 34 DUMP_RAW = FALSE; 35 if ((N = get_argument (*argc, argv, "-dumpraw"))) { 36 DUMP_RAW = TRUE; 30 DUMP = strcreate(argv[N]); 37 31 remove_argument (N, argc, argv); 38 32 } … … 51 45 remove_argument (N, argc, argv); 52 46 } 53 */54 47 48 /** currently unused **/ 55 49 field.Norder = 0; 56 50 if ((N = get_argument (*argc, argv, "-order"))) { … … 59 53 remove_argument (N, argc, argv); 60 54 } 55 56 /** currently unused **/ 57 ChipOrder = 1; 58 if ((N = get_argument (*argc, argv, "-chiporder"))) { 59 remove_argument (N, argc, argv); 60 ChipOrder = atoi (argv[N]); 61 remove_argument (N, argc, argv); 62 } 61 63 } -
trunk/Ohana/src/mosastro/src/chips.c
r3294 r3323 5 5 6 6 int i, j; 7 double R, D, P, Q, L, M ;7 double R, D, P, Q, L, M, Scale, Det; 8 8 9 # if (0)10 9 if (CHIPS != (char *) NULL) { 11 10 load_chips (CHIPS); 12 11 return (1); 13 12 } 14 # endif15 13 16 14 for (i = 0; i < Nchip; i++) { 17 15 18 16 /* bore site center guess */ 19 strcpy (chip[i].map.ctype, " RA---WRP");17 strcpy (chip[i].map.ctype, "DEC--WRP"); 20 18 chip[i].map.crpix1 = 0.0; 21 19 chip[i].map.crpix2 = 0.0; … … 30 28 chip[i].map.crval2 = M; 31 29 32 /** allow guess at field rotation?? add correct handling for negative cdelt1,2 **/ 33 chip[i].map.pc1_1 = chip[i].coords.pc1_1; 34 chip[i].map.pc2_2 = chip[i].coords.pc2_2; 35 chip[i].map.pc1_2 = chip[i].coords.pc1_2; 36 chip[i].map.pc2_1 = chip[i].coords.pc2_1; 30 /** we preserve the rotation and parity of coords.pc_ij, but renormalize to unity scale **/ 31 Det = chip[i].coords.pc1_1*chip[i].coords.pc2_2 - chip[i].coords.pc1_2*chip[i].coords.pc2_1; 32 Scale = 1.0 / sqrt(fabs(chip[i].coords.cdelt1*chip[i].coords.cdelt2*Det)); 33 34 /** test for NaN Scale **/ 35 36 chip[i].map.pc1_1 = Scale * chip[i].coords.pc1_1 * chip[i].coords.cdelt1; 37 chip[i].map.pc2_2 = Scale * chip[i].coords.pc2_2 * chip[i].coords.cdelt2; 38 chip[i].map.pc1_2 = Scale * chip[i].coords.pc1_2 * chip[i].coords.cdelt2; 39 chip[i].map.pc2_1 = Scale * chip[i].coords.pc2_1 * chip[i].coords.cdelt1; 37 40 38 41 chip[i].map.Npolyterms = 1; 39 42 for (j = 0; j < 7; j++) { 40 chip[i].map.polyterms[ 0][j] = 0;41 chip[i].map.polyterms[ 1][j] = 0;43 chip[i].map.polyterms[j][0] = 0; 44 chip[i].map.polyterms[j][1] = 0; 42 45 } 43 46 } 44 47 return (1); 45 48 } 49 50 int load_chips (char *filename) { 51 52 fprintf (stderr, "not ready yet\n"); 53 exit (1); 54 } -
trunk/Ohana/src/mosastro/src/dump.c
r3294 r3323 6 6 7 7 for (i = 0; i < Nstars; i++) { 8 fprintf (f, "%4d %10.6f %10.6f %8.2f %8.2f %8.2f %8.2f %7.2f %7.2f \n",8 fprintf (f, "%4d %10.6f %10.6f %8.2f %8.2f %8.2f %8.2f %7.2f %7.2f %7.2f %7.2f\n", 9 9 i, 10 10 stars[i].R, stars[i].D, … … 16 16 return (1); 17 17 } 18 19 int dump_grads (Gradients *grad, char *filename) { 20 21 int i; 22 FILE *f; 23 24 fprintf (stderr, "printing to file %s\n", filename); 25 26 f = fopen (filename, "w"); 27 28 for (i = 0; i < grad[0].Npts; i++) { 29 fprintf (f, "%4d %10.6f %10.6f %10.6f %10.6f %10.6f %10.6f\n", 30 i, 31 grad[0].dPdL[i], grad[0].dPdM[i], 32 grad[0].dQdL[i], grad[0].dQdM[i], 33 grad[0].Lo[i], grad[0].Mo[i]); 34 } 35 fclose (f); 36 return (1); 37 } 38 39 int dump_match () { 40 41 int i; 42 FILE *f, *g; 43 f = fopen ("raw.dat", "w"); 44 g = fopen ("ref.dat", "w"); 45 for (i = 0; i < Nchip; i++) { 46 dump_stars (f, chip[i].raw, chip[i].Nmatch); 47 dump_stars (g, chip[i].ref, chip[i].Nmatch); 48 } 49 fclose (f); 50 fclose (g); 51 exit (1); 52 } 53 54 int dump_rawstars () { 55 56 int i; 57 FILE *f; 58 f = fopen ("stars.dat", "w"); 59 for (i = 0; i < Nchip; i++) { 60 dump_stars (f, chip[i].stars, chip[i].Nstars); 61 } 62 fclose (f); 63 exit (1); 64 } 65 66 int dump_refcat (StarData *refcat, int Nrefcat) { 67 68 int i; 69 FILE *f; 70 f = fopen ("refcat.dat", "w"); 71 dump_stars (f, refcat, Nrefcat); 72 fclose (f); 73 exit (1); 74 } -
trunk/Ohana/src/mosastro/src/fakefield.c
r3297 r3323 2 2 3 3 /* determine an initial guess to field parameters from data */ 4 int fake_field (double RA, double DEC) { 5 6 int i; 4 int fake_field_center (double RA, double DEC) { 7 5 8 6 field.Rmin = RA - 0.5; … … 12 10 13 11 /* bore site center guess */ 14 strcpy (field.project.ctype, "RA---TAN");15 12 field.project.crval1 = 0.5*(field.Rmin + field.Rmax); 16 13 field.project.crval2 = 0.5*(field.Dmin + field.Dmax); 14 15 return (1); 16 } 17 18 /* set default field parameters (overridden in args_obs) */ 19 int fake_field_defaults () { 20 21 int i; 22 23 /* bore site center guess */ 24 strcpy (field.project.ctype, "DEC--TAN"); 17 25 field.project.crpix1 = 0; 18 26 field.project.crpix2 = 0; 19 27 20 /* measure average plate scale - would be better using parabolic min...*/28 /* set TP plate scale */ 21 29 field.project.cdelt1 = 1.0/3600.0; 22 30 field.project.cdelt2 = 1.0/3600.0; … … 29 37 field.project.Npolyterms = 1; 30 38 31 /* bore site center guess*/32 strcpy (field.distort.ctype, " RA---WRP");39 /** distort only has power in polyterms **/ 40 strcpy (field.distort.ctype, "DEC--WRP"); 33 41 field.distort.crval1 = 0.0; 34 42 field.distort.crval2 = 0.0; … … 38 46 field.distort.cdelt2 = 1.0; 39 47 40 /** allow guess at field rotation?? **/41 48 field.distort.pc1_1 = 1; 42 49 field.distort.pc2_2 = 1; … … 44 51 field.distort.pc2_1 = 0; 45 52 46 /* allow 2nd and 3rd order? */47 53 /* how do we handle renormalization? (fixed at 1000 pixels??) */ 48 54 field.distort.Npolyterms = 3; 49 55 for (i = 0; i < 7; i++) { 50 field.distort.polyterms[ 0][i] = 0;51 field.distort.polyterms[ 1][i] = 0;56 field.distort.polyterms[i][0] = 0; 57 field.distort.polyterms[i][1] = 0; 52 58 } 53 54 /* megacam distortion : 50 arcsec @ 1800 arcsec */55 field.distort.polyterms[0][3] = 1e-8;56 field.distort.polyterms[1][6] = 1e-8;57 58 /* tiny distortion : 0.5 arcsec @ 1800 arcsec */59 field.distort.polyterms[0][3] = 1e-10;60 field.distort.polyterms[1][6] = 1e-10;61 62 /* minor distortion : 5 arcsec @ 1800 arcsec */63 field.distort.polyterms[0][3] = 1e-9;64 field.distort.polyterms[1][6] = 1e-9;65 59 66 60 return (1); -
trunk/Ohana/src/mosastro/src/field.c
r3294 r3323 7 7 double PS; 8 8 9 # if (0)10 9 if (FIELD != (char *) NULL) { 11 10 load_field (FIELD); 12 return ( 1);11 return (TRUE); 13 12 } 14 # endif15 13 16 14 /* bore site center guess */ 17 strcpy (field.project.ctype, " RA---TAN");15 strcpy (field.project.ctype, "DEC--TAN"); 18 16 field.project.crval1 = 0.5*(field.Rmin + field.Rmax); 19 17 field.project.crval2 = 0.5*(field.Dmin + field.Dmax); … … 40 38 41 39 /* bore site center guess */ 42 strcpy (field.distort.ctype, " RA---WRP");40 strcpy (field.distort.ctype, "DEC--WRP"); 43 41 field.distort.crval1 = 0.0; 44 42 field.distort.crval2 = 0.0; … … 58 56 field.distort.Npolyterms = 1; 59 57 for (i = 0; i < 7; i++) { 60 field.distort.polyterms[ 0][i] = 0;61 field.distort.polyterms[ 1][i] = 0;58 field.distort.polyterms[i][0] = 0; 59 field.distort.polyterms[i][1] = 0; 62 60 } 63 return ( 1);61 return (TRUE); 64 62 } 65 63 … … 87 85 88 86 } 87 88 void field_combine () { 89 90 int i; 91 92 strcpy (field.project.ctype, "DEC--WRP"); 93 94 field.project.Npolyterms = field.distort.Npolyterms; 95 for (i = 0; i < 7; i++) { 96 field.project.polyterms[i][0] = field.distort.polyterms[i][0]; 97 field.project.polyterms[i][1] = field.distort.polyterms[i][1]; 98 } 99 } 100 101 int load_field (char *filename) { 102 103 int i; 104 Coords coords; 105 Header header; 106 107 /* load header */ 108 if (!fits_read_header (filename, &header)) { 109 fprintf (stderr, "ERROR: can't read header for %s\n", filename); 110 exit (1); 111 } 112 /* get astrometry information */ 113 if (!GetCoords (&coords, &header)) { 114 fprintf (stderr, "ERROR: no astrometric solution in field %s\n", filename); 115 exit (1); 116 } 117 118 /* bore site center guess */ 119 strcpy (field.project.ctype, "DEC--TAN"); 120 field.project.crval1 = 0.5*(field.Rmin + field.Rmax); 121 field.project.crval2 = 0.5*(field.Dmin + field.Dmax); 122 field.project.crpix1 = 0; 123 field.project.crpix2 = 0; 124 125 /* measure average plate scale - would be better using parabolic min... */ 126 field.project.cdelt1 = coords.cdelt1; 127 field.project.cdelt2 = coords.cdelt2; 128 129 /** allow guess at field rotation?? **/ 130 field.project.pc1_1 = coords.pc1_1; 131 field.project.pc2_2 = coords.pc2_2; 132 field.project.pc1_2 = coords.pc1_2; 133 field.project.pc2_1 = coords.pc2_1; 134 field.project.Npolyterms = 1; 135 136 /* bore site center guess */ 137 strcpy (field.distort.ctype, "DEC--WRP"); 138 field.distort.crval1 = 0.0; 139 field.distort.crval2 = 0.0; 140 field.distort.crpix1 = 0.0; 141 field.distort.crpix2 = 0.0; 142 field.distort.cdelt1 = 1.0; 143 field.distort.cdelt2 = 1.0; 144 145 /** allow guess at field rotation?? **/ 146 field.distort.pc1_1 = 1; 147 field.distort.pc2_2 = 1; 148 field.distort.pc1_2 = 0; 149 field.distort.pc2_1 = 0; 150 151 /* allow 2nd and 3rd order? */ 152 /* how do we handle renormalization? (fixed at 1000 pixels??) */ 153 field.distort.Npolyterms = coords.Npolyterms; 154 for (i = 0; i < 7; i++) { 155 field.distort.polyterms[i][0] = coords.polyterms[i][0]; 156 field.distort.polyterms[i][1] = coords.polyterms[i][1]; 157 } 158 return (TRUE); 159 } 160 -
trunk/Ohana/src/mosastro/src/getusno.c
r3297 r3323 24 24 25 25 RA0 = catstats[0].RA[0]; 26 DEC0= catstats[0].RA[1];27 RA1= catstats[0].DEC[0];26 RA1 = catstats[0].RA[1]; 27 DEC0 = catstats[0].DEC[0]; 28 28 DEC1 = catstats[0].DEC[1]; 29 29 -
trunk/Ohana/src/mosastro/src/greference.c
r3294 r3323 16 16 17 17 if (VERBOSE) fprintf (stderr, "full region: %f - %f, %f - %f\n", catstats.RA[0], catstats.RA[1], catstats.DEC[0], catstats.DEC[1]); 18 19 /* get stars from the Stone et al catalog for the given region */ 20 if (!strcmp (REFCAT, "STONE")) { 21 stars = getstone (&catstats, &Nstars); 22 } 18 23 19 24 /* get stars from the USNO catalog for the given region */ -
trunk/Ohana/src/mosastro/src/match.c
r3294 r3323 6 6 int i, j, k, N, K, Ntotal; 7 7 int Nmatch, NMATCH; 8 double dp, dq, radius ;8 double dp, dq, radius, Radius; 9 9 double *p, *q, *P, *Q; 10 10 int *U, *u; 11 12 /* requested radius is in arcsec ; internally radius is in pixels */ 13 Radius = RADIUS / (3600.0 * field.project.cdelt2); 11 14 12 15 /* sort the REFCAT data by P in tangent plane */ … … 42 45 /* find star matches in the tangent plane coord system */ 43 46 for (j = k = 0; (j < chip[i].Nstars) && (k < Nrefcat); ) { 47 /* skip anything with dMag too large */ 48 if (SIGMA_LIM > 0.0) { 49 if (chip[i].stars[u[j]].dMag > SIGMA_LIM) { 50 j++; 51 continue; 52 } 53 } 54 44 55 dp = p[j] - P[k]; 45 56 46 if (dp <= -2*R ADIUS) {57 if (dp <= -2*Radius) { 47 58 j++; 48 59 continue; 49 60 } 50 if (dp >= 2*R ADIUS) {61 if (dp >= 2*Radius) { 51 62 k++; 52 63 continue; … … 54 65 55 66 K = k; 56 for (; (dp > -2*R ADIUS) && (k < Nrefcat); k++) {67 for (; (dp > -2*Radius) && (k < Nrefcat); k++) { 57 68 dp = p[j] - P[k]; 58 69 dq = q[j] - Q[k]; 59 70 radius = hypot (dp, dq); 60 if (radius < R ADIUS) {71 if (radius < Radius) { 61 72 chip[i].raw[Nmatch] = chip[i].stars[u[j]]; 62 73 chip[i].ref[Nmatch] = refcat[U[k]]; -
trunk/Ohana/src/mosastro/src/mkheader.c
r3294 r3323 7 7 ALLOCATE (header, Header, 1); 8 8 9 header[0].simple = TRUE; 9 10 header[0].bitpix = -32; 10 11 header[0].unsign = FALSE; … … 22 23 fits_modify (header, "UTC-OBS", "%s", 1, "14:27:45.30"); 23 24 fits_modify (header, "ZERO_PT", "%lf", 1, 25.0); 25 fits_modify (header, "EXPTIME", "%lf", 1, 2.0); 24 26 25 if (coords[0].Npolyterms > 1) { 26 fits_modify (header, "CTYPE1", "%s", 1, "RA---PLY"); 27 fits_modify (header, "CTYPE2", "%s", 1, "DEC--PLY"); 28 } else { 29 fits_modify (header, "CTYPE1", "%s", 1, "RA---TAN"); 30 fits_modify (header, "CTYPE2", "%s", 1, "DEC--TAN"); 31 } 27 PutCoords (coords, header); 28 32 29 fits_modify (header, "NASTRO", "%d", 1, 1); 33 34 fits_modify (header, "CDELT1", "%le", 1, coords[0].cdelt1);35 fits_modify (header, "CDELT2", "%le", 1, coords[0].cdelt2);36 fits_modify (header, "CRVAL1", "%lf", 1, coords[0].crval1);37 fits_modify (header, "CRVAL2", "%lf", 1, coords[0].crval2);38 fits_modify (header, "CRPIX1", "%lf", 1, coords[0].crpix1);39 fits_modify (header, "CRPIX2", "%lf", 1, coords[0].crpix2);40 fits_modify (header, "PC001001", "%le", 1, coords[0].pc1_1);41 fits_modify (header, "PC001002", "%le", 1, coords[0].pc1_2);42 fits_modify (header, "PC002001", "%le", 1, coords[0].pc2_1);43 fits_modify (header, "PC002002", "%le", 1, coords[0].pc2_2);44 fits_modify (header, "NPLYTERM", "%d", 1, coords[0].Npolyterms);45 if (coords[0].Npolyterms > 1) {46 fits_modify (header, "PCA1X2Y0", "%le", 1, coords[0].polyterms[0][0]);47 fits_modify (header, "PCA1X1Y1", "%le", 1, coords[0].polyterms[1][0]);48 fits_modify (header, "PCA1X0Y2", "%le", 1, coords[0].polyterms[2][0]);49 50 fits_modify (header, "PCA2X2Y0", "%le", 1, coords[0].polyterms[0][1]);51 fits_modify (header, "PCA2X1Y1", "%le", 1, coords[0].polyterms[1][1]);52 fits_modify (header, "PCA2X0Y2", "%le", 1, coords[0].polyterms[2][1]);53 }54 55 if (coords[0].Npolyterms > 2) {56 fits_modify (header, "PCA1X3Y0", "%le", 1, coords[0].polyterms[3][0]);57 fits_modify (header, "PCA1X2Y1", "%le", 1, coords[0].polyterms[4][0]);58 fits_modify (header, "PCA1X1Y2", "%le", 1, coords[0].polyterms[5][0]);59 fits_modify (header, "PCA1X0Y3", "%le", 1, coords[0].polyterms[6][0]);60 61 fits_modify (header, "PCA2X3Y0", "%le", 1, coords[0].polyterms[3][1]);62 fits_modify (header, "PCA2X2Y1", "%le", 1, coords[0].polyterms[4][1]);63 fits_modify (header, "PCA2X1Y2", "%le", 1, coords[0].polyterms[5][1]);64 fits_modify (header, "PCA2X0Y3", "%le", 1, coords[0].polyterms[6][1]);65 }66 30 67 31 return (header); -
trunk/Ohana/src/mosastro/src/mkobs.c
r3297 r3323 4 4 5 5 int i, j, N, Nrefcat, Nchip, Nstars, NSTARS; 6 double Ro, Do, Po, Qo, Lo, Mo; 7 double dX, dY, Dist; 6 8 double RA, DEC; 7 double Ro, Do, Po, Qo, Lo, Mo;8 double dX, dY;9 9 char filename[64]; 10 10 Coords map, coords; … … 14 14 15 15 ConfigInit (&argc, argv); 16 17 if (argc != 4) { 18 fprintf (stderr, "USAGE: mkobs (RA) (DEC) (output)\n"); 19 exit (2); 20 } 16 args (&argc, argv); 17 init_random (); 21 18 22 19 RA = atof(argv[1]); 23 20 DEC = atof(argv[2]); 24 dX = dY = 3600*0.1; 21 OUTPUT = argv[3]; 22 fake_field_center (RA, DEC); 25 23 26 fake_field (RA, DEC); 24 /* chip size in pixels (output is 5x5 grid of chips */ 25 dX = 0.1 / field.project.cdelt1; 26 dY = 0.1 / field.project.cdelt2; 27 27 28 28 refcat = greference (&Nrefcat); 29 29 project_refcat (refcat, Nrefcat); 30 if (FOCAL_PLANE != NULL) { 31 FILE *f; 32 f = fopen (FOCAL_PLANE, "w"); 33 dump_stars (f, refcat, Nrefcat); 34 fclose (f); 35 } 36 if (NO_CHIPS) exit (0); 30 37 31 38 Nchip = 0; … … 34 41 35 42 /* find chip center in TP, FP and Sky */ 36 Po = 0.2*i*3600.0;37 Qo = 0.2*j*3600.0;43 Po = 2*dX*i; 44 Qo = 2*dY*j; 38 45 RD_to_XY (&Lo, &Mo, Po, Qo, &field.distort); 39 46 XY_to_RD (&Ro, &Do, Po, Qo, &field.project); 40 47 41 48 /* FP-Chip terms */ 42 strcpy (map.ctype, " RA---WRP");49 strcpy (map.ctype, "DEC--WRP"); 43 50 map.crval1 = Lo; 44 51 map.crval2 = Mo; … … 53 60 map.pc1_2 = 0; 54 61 map.pc2_1 = 0; 55 map.Npolyterms = 1; 62 63 map.Npolyterms = 2; 64 for (N = 0; N < 7; N++) { 65 map.polyterms[N][0] = 0; 66 map.polyterms[N][1] = 0; 67 } 68 map.polyterms[2][1] = 1e-5; 56 69 57 70 /* project catalog stars to chip */ … … 69 82 if (refcat[N].Y >= 2*dY) continue; 70 83 71 stars[Nstars].X = refcat[N].X; 72 stars[Nstars].Y = refcat[N].Y; 84 /* add random noise - not gaussian noise */ 85 stars[Nstars].X = refcat[N].X + SIGMA*(drand48() - 0.5); 86 stars[Nstars].Y = refcat[N].Y + SIGMA*(drand48() - 0.5); 73 87 stars[Nstars].M = 16.0; 74 88 stars[Nstars].dM = 0.02; … … 88 102 } 89 103 104 90 105 /* Chip-Sky terms */ 91 strcpy (coords.ctype, " RA---WRP");106 strcpy (coords.ctype, "DEC--WRP"); 92 107 coords.crval1 = Ro; 93 108 coords.crval2 = Do; 94 109 coords.crpix1 = dX; 95 coords.crpix2 = d X;110 coords.crpix2 = dY; 96 111 97 coords.cdelt1 = 1/3600.0; 98 coords.cdelt2 = 1/3600.0; 112 { 113 double dP, dQ, dL, dM; 114 double Mx, Lx, scale; 115 116 dP = 10; 117 dQ = 10; 118 RD_to_XY (&Lx, &Mx, Po+dP, Qo+dQ, &field.distort); 119 dL = Lx - Lo; 120 dM = Mx - Mo; 121 scale = hypot (10.0, 10.0) / hypot (dL, dM); 122 coords.cdelt1 = scale/3600.0; 123 coords.cdelt2 = scale/3600.0; 124 } 99 125 100 126 coords.pc1_1 = 1; … … 105 131 106 132 header = mkheader (2*dX, 2*dY, Nstars, &coords); 107 fits_modify (header, "C_L0", "%lf", 1, Lo);108 fits_modify (header, "C_M0", "%lf", 1, Mo);109 133 110 sprintf (filename, "%s.%02d.fits", argv[3], Nchip);134 sprintf (filename, "%s.%02d.fits", OUTPUT, Nchip); 111 135 wstars (filename, stars, Nstars, header); 112 136 fits_free_header (header); -
trunk/Ohana/src/mosastro/src/mkstandards.c
r3297 r3323 1 1 # include "mosastro.h" 2 # define DX 100.0 3 # define DY 100.0 2 # define DX 30.0 3 # define DY 30.0 4 5 extern double drand48(); 4 6 5 7 /* build a grid of reference stars */ 6 8 int main (int argc, char **argv) { 7 9 8 int Nstars, NSTARS;9 double x, y, dX, dY;10 int i, N, Nstars, NSTARS, Random; 11 double x, y, m, dX, dY; 10 12 Header *header; 11 13 Coords coords; 12 14 Stars *stars; 13 15 16 Random = FALSE; 17 if ((N = get_argument (argc, argv, "-random"))) { 18 Random = TRUE; 19 remove_argument (N, &argc, argv); 20 Nstars = atoi (argv[N]); 21 remove_argument (N, &argc, argv); 22 } 23 14 24 if (argc != 5) { 15 fprintf (stderr, "USAGE: mkstandards (RA) (DEC) (half-width) (output) \n");25 fprintf (stderr, "USAGE: mkstandards (RA) (DEC) (half-width) (output) [-random Nstars]\n"); 16 26 exit (2); 17 27 } … … 21 31 22 32 /* bore site center guess */ 23 strcpy (coords.ctype, " RA---TAN");33 strcpy (coords.ctype, "DEC--TAN"); 24 34 coords.crval1 = atof(argv[1]); 25 35 coords.crval2 = atof(argv[2]); … … 36 46 coords.Npolyterms = 1; 37 47 38 Nstars = 0;39 NSTARS = 1000;40 ALLOCATE (stars, Stars, NSTARS);48 if (Random) { 49 50 init_random (); 41 51 42 for (x = 0; x < 2*dX; x += DX) { 43 for (y = 0; y < 2*dY; y += DY) { 44 stars[Nstars].X = x; 45 stars[Nstars].Y = y; 46 stars[Nstars].M = 16.0; 47 stars[Nstars].dM = 0.02; 48 stars[Nstars].dophot = 1; 49 stars[Nstars].sky = 1.0; 50 stars[Nstars].Mgal = 16.0; 51 stars[Nstars].Map = 16.0; 52 stars[Nstars].fx = 1.0; 53 stars[Nstars].fy = 1.0; 54 stars[Nstars].df = 0.0; 52 ALLOCATE (stars, Stars, Nstars); 53 for (i = 0; i < Nstars; i++) { 54 x = 2*dX*drand48(); 55 y = 2*dY*drand48(); 56 m = 14.0 + 4.0*drand48(); 57 stars[i].X = x; 58 stars[i].Y = y; 59 stars[i].M = m; 60 stars[i].dM = 0.02; 61 } 62 } else { 55 63 56 Nstars ++; 57 if (Nstars >= NSTARS) { 58 NSTARS += 1000; 59 REALLOCATE (stars, Stars, NSTARS); 64 Nstars = 0; 65 NSTARS = 1000; 66 ALLOCATE (stars, Stars, NSTARS); 67 68 for (x = 0; x < 2*dX; x += DX) { 69 for (y = 0; y < 2*dY; y += DY) { 70 stars[Nstars].X = x; 71 stars[Nstars].Y = y; 72 stars[Nstars].M = 16.0; 73 74 Nstars ++; 75 if (Nstars >= NSTARS) { 76 NSTARS += 1000; 77 REALLOCATE (stars, Stars, NSTARS); 78 } 60 79 } 61 80 } 81 } 82 83 for (i = 0; i < Nstars; i++) { 84 stars[i].dophot = 1; 85 stars[i].sky = 1.0; 86 stars[i].Mgal = 16.0; 87 stars[i].Map = 16.0; 88 stars[i].fx = 1.0; 89 stars[i].fy = 1.0; 90 stars[i].df = 0.0; 62 91 } 63 92 -
trunk/Ohana/src/mosastro/src/mosastro.c
r3297 r3323 4 4 int main (int argc, char **argv) { 5 5 6 int Nrefcat; 6 int Nrefcat, Nastro; 7 double Cerror; 7 8 glob_t pglob; 8 9 StarData *refcat; … … 12 13 args (&argc, argv); 13 14 14 if (argc != 3) {15 fprintf (stderr, "USAGE: mosastro (inglob) (ext) \n");15 if (argc != 4) { 16 fprintf (stderr, "USAGE: mosastro (inglob) (ext) (mosaic.phu)\n"); 16 17 exit (2); 17 18 } … … 30 31 /* use field model to get TP & FP coords */ 31 32 project_stars (); 33 if ((DUMP != NULL) && !strcmp (DUMP, "rawstars")) dump_rawstars(); 32 34 33 35 refcat = greference (&Nrefcat); 34 36 project_refcat (refcat, Nrefcat); 37 if ((DUMP != NULL) && !strcmp (DUMP, "refcat")) dump_refcat(refcat, Nrefcat); 35 38 36 39 match (refcat, Nrefcat); 37 38 if (1) {39 int i;40 FILE *f, *g;41 f = fopen ("ref.dat", "w");42 g = fopen ("raw.dat", "w");43 for (i = 0; i < Nchip; i++) {44 dump_stars (f, chip[i].raw, chip[i].Nmatch);45 dump_stars (g, chip[i].ref, chip[i].Nmatch);46 }47 fclose (f);48 fclose (g);49 exit (1);50 }51 52 40 deproject_raw (); 53 41 project_ref (); 42 Cerror = GetScatter (&Nastro); 43 fprintf (stderr, "scatter (raw) : %f for %d stars\n", Cerror, Nastro); 44 if ((DUMP != NULL) && !strcmp (DUMP, "rawmatch")) dump_match(); 54 45 55 46 grad = GetGradients (); 56 47 FitGradients (grad); 48 Cerror = GetScatter (&Nastro); 49 fprintf (stderr, "scatter (grad) : %f for %d stars\n", Cerror, Nastro); 50 if ((DUMP != NULL) && !strcmp (DUMP, "fitgrads")) dump_match(); 57 51 58 deproject_raw (); 59 project_ref (); 60 61 FitChips (1); 62 63 deproject_raw (); 64 project_ref (); 52 FitChips (ChipOrder); 53 Cerror = GetScatter (&Nastro); 54 fprintf (stderr, "scatter (chip) : %f for %d stars\n", Cerror, Nastro); 55 if ((DUMP != NULL) && !strcmp (DUMP, "fitchips_unclip")) dump_match(); 65 56 66 57 ClipOnFP (3.0); 58 Cerror = GetScatter (&Nastro); 59 fprintf (stderr, "scatter (clip) : %f for %d stars\n", Cerror, Nastro); 67 60 61 FitChips (ChipOrder); 62 Cerror = GetScatter (&Nastro); 63 fprintf (stderr, "scatter (chip) : %f for %d stars\n", Cerror, Nastro); 64 if ((DUMP != NULL) && !strcmp (DUMP, "fitchips")) dump_match(); 65 66 output (argv[2], argv[3]); 67 exit (0); 68 69 /* 68 70 FitField (3); 71 FitChips (3); 72 */ 69 73 70 deproject_raw ();71 project_ref ();72 73 FitChips (3);74 75 deproject_raw ();76 project_ref ();77 78 wstars ();79 exit (0);80 74 } 81 82 /** bore site terms : field.coords.crval1, field.coords.crval2, field.coords.pcN_M **/83 84 85 /* on the first pass, we only have the rough R,D for each input star */86 /* on the second pass, we have the reference R,D for each input star */87 88 /* pt[0].R,D here are from the chip coords */89 /* pt[0].R,D here are USNO coords */ -
trunk/Ohana/src/mosastro/src/warptest.c
r3295 r3323 38 38 coords.Npolyterms = 3; 39 39 for (i = 0; i < 7; i++) { 40 coords.polyterms[ 0][i] = 0;41 coords.polyterms[ 1][i] = 0;40 coords.polyterms[i][0] = 0; 41 coords.polyterms[i][1] = 0; 42 42 } 43 43 coords.polyterms[3][0] = 1e-10; -
trunk/Ohana/src/mosastro/src/wstars.c
r3294 r3323 1 1 # include "mosastro.h" 2 2 # define NCHAR 66 /* 65 char EXCLUDING return */ 3 4 void wchip (char *filename, Chip *data) { 5 6 FILE *g; 7 8 g = fopen (filename, "w"); 9 if (g == (FILE *) NULL) { 10 fprintf (stderr, "ERROR: can't create output file %s\n", filename); 11 exit (1); 12 } 13 14 fwrite (data[0].header.buffer, 1, data[0].header.size, g); 15 fwrite (data[0].buffer, 1, data[0].Nbuffer, g); 16 fclose (g); 17 18 } 3 19 4 20 void wstars (char *filename, Stars *stars, int Nstars, Header *header) {
Note:
See TracChangeset
for help on using the changeset viewer.
