Changeset 3416
- Timestamp:
- Mar 14, 2005, 12:46:02 PM (21 years ago)
- Location:
- trunk/Ohana/src
- Files:
-
- 7 added
- 12 edited
-
addstar/Makefile (modified) (1 diff)
-
addstar/include/addstar.h (modified) (2 diffs)
-
addstar/src/ConvertStars.c (added)
-
addstar/src/gimages.c (modified) (3 diffs)
-
addstar/src/gstars.c (modified) (5 diffs)
-
addstar/src/rfits.c (added)
-
addstar/src/rtext.c (added)
-
mosastro/Makefile (modified) (1 diff)
-
mosastro/include/mosastro.h (modified) (3 diffs)
-
mosastro/src/ConvertStars.c (added)
-
mosastro/src/LoadStars.c (modified) (5 diffs)
-
mosastro/src/clip.c (modified) (1 diff)
-
mosastro/src/dump.c (modified) (2 diffs)
-
mosastro/src/mosastro.c (modified) (2 diffs)
-
mosastro/src/output.c (modified) (2 diffs)
-
mosastro/src/rfits.c (added)
-
mosastro/src/rtext.c (added)
-
mosastro/src/wfits.c (added)
-
mosastro/src/wstars.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/Makefile
r3402 r3416 61 61 $(SRC)/update_coords.$(ARCH).o \ 62 62 $(SRC)/wcatalog.$(ARCH).o \ 63 $(SRC)/wimage.$(ARCH).o 63 $(SRC)/wimage.$(ARCH).o \ 64 $(SRC)/rfits.$(ARCH).o \ 65 $(SRC)/rtext.$(ARCH).o \ 66 $(SRC)/ConvertStars.$(ARCH).o 64 67 65 68 EXTRA = \ -
trunk/Ohana/src/addstar/include/addstar.h
r3402 r3416 17 17 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", NAME); \ 18 18 exit (0); } 19 20 /* this structure is used for loading the data from the FITS smp file */ 21 typedef struct { 22 float X; 23 float Y; 24 float M; 25 float dM; 26 float Mgal; 27 float Map; 28 float sky; 29 float fx; 30 float fy; 31 float df; 32 char dophot; 33 char dummy[3]; 34 } StarData; 19 35 20 36 typedef struct { … … 198 214 GSCRegion *gregion_match (GSCRegion *regions, int *nregions); 199 215 GSCRegion *gregion_patch (GSCRegion *patch, int *nregions); 216 int ConvertStars (StarData *data, int size, int nitems); -
trunk/Ohana/src/addstar/src/gimages.c
r3389 r3416 98 98 ALLOCATE (pimage, Image, NPIMAGE); 99 99 100 fprintf (stderr, "find overlapping images\n"); 100 101 /* run through image table, reading images in blocks */ 101 102 for (Ntimage = 0; Ntimage < Nimage; Ntimage += ntimage) { … … 141 142 } 142 143 } 144 fprintf (stderr, "done\n"); 143 145 144 146 BuildChipMatch (pimage, npimage); … … 157 159 if the WRP image is loaded near the beginning of a block, then the corresponding DIS 158 160 may be in the previous block, and thus missed 161 162 we are not adding the matching DIS image to the table. 159 163 */ -
trunk/Ohana/src/addstar/src/gstars.c
r3402 r3416 1 1 # include "addstar.h" 2 # define D_NSTARS 10003 # define BYTES_STAR 664 # define BLOCK 10005 2 6 3 Stars *gstars (char *file, int *NSTARS, Image *image) { … … 8 5 FILE *f; 9 6 Header header; 10 int j, N, Ninstar ;7 int j, N, Ninstar, extend; 11 8 int nbytes, Nbytes; 12 Stars *stars ;9 Stars *stars, *rdstars; 13 10 char *buffer, *c, *c2, photcode[64]; 14 11 double tmp; … … 22 19 exit (1); 23 20 } 24 25 /* open file */26 f = fopen (file, "r");27 if (f == NULL) {28 fprintf (stderr, "ERROR: can't read data from %s\n", file);29 exit (1);30 }31 fseek (f, header.size, SEEK_SET);32 21 33 22 /* find image rootname */ … … 147 136 exit (1); 148 137 } 149 ALLOCATE (stars, Stars, image[0].nstar);150 138 151 139 /* this is really lame. get sky background from Flips data */ … … 170 158 } 171 159 172 /* load in stars by blocks of 1000 */ 173 N = 0; 174 ALLOCATE (buffer, char, (BLOCK*BYTES_STAR) + 1); 175 buffer[BLOCK*BYTES_STAR] = 0; 176 Nextra = 0; 177 doneread = FALSE; 178 while (!doneread) { 179 Nbytes = BYTES_STAR * BLOCK - Nextra; 180 nbytes = Fread (&buffer[Nextra], 1, Nbytes, f, "char"); 181 if (nbytes == 0) { 182 doneread = TRUE; 183 continue; 160 /* read in data section */ 161 f = fopen (file, "r"); 162 if (f == NULL) { 163 fprintf (stderr, "ERROR: can't read data from %s\n", file); 164 exit (1); 165 } 166 fseek (f, header.size, SEEK_SET); 167 168 extend = FALSE; 169 fits_scan (&header, "EXTEND", "%t", 1, &extend); 170 if (extend) { 171 Nbytes = fits_matrix_size (&header); 172 fseek (f, Nbytes, SEEK_CUR); 173 rdstars = rfits (f, &image[0].nstar); 174 } else { 175 rdstars = rtext (f, &image[0].nstar); 176 } 177 fclose (f); 178 179 /* modify resulting star list */ 180 ALLOCATE (stars, Stars, image[0].nstar); 181 for (N = j = 0; j < image[0].nstar; j++) { 182 /* allow for some dynamic filtering of star list */ 183 if (rdstars[j].dM > 1000.0 / SNLIMIT) continue; 184 if (XMAX && (rdstars[j].X > XMAX)) continue; 185 if (XMIN && (rdstars[j].X < XMIN)) continue; 186 if (YMAX && (rdstars[j].Y > YMAX)) continue; 187 if (YMIN && (rdstars[j].Y < YMIN)) continue; 188 stars[N] = rdstars[j]; 189 190 XY_to_RD (&stars[N].R, &stars[N].D, stars[N].X, stars[N].Y, &image[0].coords); 191 while (stars[N].R < 0.0) stars[N].R += 360.0; 192 while (stars[N].R >= 360.0) stars[N].R -= 360.0; 193 stars[N].found = -1; 194 stars[N].code = thiscode[0].code; 195 196 if (SKYPROBE) { 197 dMs = get_subpix (stars[N].X, stars[N].Y); 198 stars[N].M -= dMs; 199 stars[N].Mgal -= dMs; 200 stars[N].Map -= dMs; 201 dMs = 1000.0*scat_subpix (stars[N].X, stars[N].Y); 202 stars[N].dM = hypot (stars[N].dM, dMs); 184 203 } 185 nbytes += Nextra; 186 /* check line-by-line integrity */ 187 c = buffer; 188 done = FALSE; 189 while ((c < buffer + nbytes) && (!done)) { 190 for (c2 = c; *c2 == '\n'; c2++); 191 if (c2 > c) { /* extra return chars */ 192 memmove (c, c2, (int)(buffer + nbytes - c2)); 193 Nskip = c2 - c; 194 nbytes -= Nskip; 195 bzero (buffer + nbytes, Nskip); 196 if (VERBOSE) fprintf (stderr, "deleted %d extra return chars\n", Nskip); 197 } 198 c2 = strchr (c, '\n'); 199 if (c2 == (char *) NULL) { 200 done = TRUE; 201 continue; 202 } 203 c2++; 204 if ((c2 - c) != BYTES_STAR) { /* bad line, delete it */ 205 memmove (c, c2, (int)(buffer + nbytes - c2)); 206 Nskip = c2 - c; 207 nbytes -= Nskip; 208 bzero (buffer + nbytes, Nskip); 209 if (VERBOSE) fprintf (stderr, "deleted line, %d extra chars\n", Nskip); 210 } else { 211 c = c2; 212 } 213 } 214 Ninstar = nbytes / BYTES_STAR; 215 Nextra = nbytes % BYTES_STAR; 216 for (j = 0; j < Ninstar; j++, N++) { 217 dparse (&stars[N].X, 1, &buffer[j*BYTES_STAR]); 218 dparse (&stars[N].Y, 2, &buffer[j*BYTES_STAR]); 219 dparse (&stars[N].M, 3, &buffer[j*BYTES_STAR]); 220 221 /* cmp files carry dM in millimags */ 222 dparse (&tmp, 4, &buffer[j*BYTES_STAR]); 223 stars[N].dM = 0.001*tmp; 224 225 /* allow for some dynamic filtering of star list */ 226 if (stars[N].dM > 1000.0 / SNLIMIT) { N--; continue; } 227 if (XMAX && (stars[N].X > XMAX)) { N--; continue; } 228 if (XMIN && (stars[N].X < XMIN)) { N--; continue; } 229 if (YMAX && (stars[N].Y > YMAX)) { N--; continue; } 230 if (YMIN && (stars[N].Y < YMIN)) { N--; continue; } 231 232 dparse (&tmp, 5, &buffer[j*BYTES_STAR]); 233 stars[N].dophot = tmp; 234 235 dparse (&stars[N].Mgal, 7, &buffer[j*BYTES_STAR]); 236 dparse (&stars[N].Map, 8, &buffer[j*BYTES_STAR]); 237 dparse (&stars[N].fx, 9, &buffer[j*BYTES_STAR]); 238 dparse (&stars[N].fy, 10, &buffer[j*BYTES_STAR]); 239 dparse (&stars[N].df, 11, &buffer[j*BYTES_STAR]); 240 241 XY_to_RD (&stars[N].R, &stars[N].D, stars[N].X, stars[N].Y, &image[0].coords); 242 while (stars[N].R < 0.0) stars[N].R += 360.0; 243 while (stars[N].R >= 360.0) stars[N].R -= 360.0; 244 stars[N].found = -1; 245 stars[N].code = thiscode[0].code; 246 247 if (SKYPROBE) { 248 dMs = get_subpix (stars[N].X, stars[N].Y); 249 stars[N].M -= dMs; 250 stars[N].Mgal -= dMs; 251 stars[N].Map -= dMs; 252 dMs = 1000.0*scat_subpix (stars[N].X, stars[N].Y); 253 stars[N].dM = hypot (stars[N].dM, dMs); 254 } 255 } 256 } 257 204 N ++; 205 } 258 206 image[0].nstar = N; 259 207 REALLOCATE (stars, Stars, image[0].nstar); 208 free (rdstars); 209 260 210 if (VERBOSE) fprintf (stderr, "read %d stars from target file\n", image[0].nstar); 261 211 *NSTARS = image[0].nstar; -
trunk/Ohana/src/mosastro/Makefile
r3401 r3416 57 57 $(SRC)/clip.$(ARCH).o \ 58 58 $(SRC)/parse_time.$(ARCH).o \ 59 $(SRC)/testcoords.$(ARCH).o 59 $(SRC)/testcoords.$(ARCH).o \ 60 $(SRC)/rfits.$(ARCH).o \ 61 $(SRC)/wfits.$(ARCH).o \ 62 $(SRC)/rtext.$(ARCH).o \ 63 $(SRC)/ConvertStars.$(ARCH).o 60 64 61 65 mosastro: $(BIN)/mosastro.$(ARCH) -
trunk/Ohana/src/mosastro/include/mosastro.h
r3401 r3416 23 23 StarData *stars; 24 24 Header header; 25 Header theader; 26 Matrix matrix; 27 25 28 char *buffer; 26 29 int Nbuffer; 30 int FITS; 27 31 28 32 int Nmatch; … … 55 59 56 60 typedef struct { 57 double X; 58 double Y; 59 double M, dM; 60 char dophot; 61 double sky; 62 double fx, fy, df; 63 double Mgal, Map; 61 float X; 62 float Y; 63 float M; 64 float dM; 65 float Mgal; 66 float Map; 67 float sky; 68 float fx; 69 float fy; 70 float df; 71 char dophot; 72 char dummy[3]; 64 73 } Stars; 65 74 … … 168 177 void wchip (char *filename, Chip *data); 169 178 void wstars (char *filename, Stars *stars, int Nstars, Header *header); 179 int ConvertStars (Stars *data, int size, int nitems); -
trunk/Ohana/src/mosastro/src/LoadStars.c
r3401 r3416 1 1 # include "mosastro.h" 2 # define BYTES_STAR 663 2 4 3 int LoadStars (int Nfile, char **file) { 5 4 6 int i, j, itmp, Nbytes, nbytes ;5 int i, j, itmp, Nbytes, nbytes, status, extend; 7 6 FILE *f; 8 7 time_t tsval; … … 23 22 continue; 24 23 } 25 f = fopen (chip[Nchip].file, "r");26 if (f == NULL) {27 fprintf (stderr, "ERROR: can't read data from %s\n", file[i]);28 free (chip[Nchip].file);29 continue;30 }31 fseek (f, chip[Nchip].header.size, SEEK_SET);32 24 33 25 /* get image dimensions */ … … 39 31 fprintf (stderr, "ERROR: no astrometric solution in header\n"); 40 32 free (chip[Nchip].file); 33 fits_free_header (&chip[Nchip].header); 41 34 continue; 42 35 } … … 49 42 fprintf (stderr, "ERROR: bad astrometric solution in header %s\n", file[i]); 50 43 free (chip[Nchip].file); 44 fits_free_header (&chip[Nchip].header); 51 45 continue; 52 46 } … … 57 51 Year = tmval[0].tm_year; 58 52 59 /* find expected number of stars */ 60 fits_scan (&chip[Nchip].header, "NSTARS", "%d", 1, &chip[Nchip].Nstars); 61 if (chip[Nchip].Nstars == 0) { 62 fprintf (stderr, "ERROR: can't get NSTARS from header for %s\n", file[i]); 53 extend = FALSE; 54 fits_scan (&chip[Nchip].header, "EXTEND", "%t", 1, &extend); 55 if (extend) { 56 status = rfits (&chip[Nchip]); 57 } else { 58 status = rtext (&chip[Nchip]); 59 } 60 if (!status) { 61 /* skip on failure */ 63 62 free (chip[Nchip].file); 63 fits_free_header (&chip[Nchip].header); 64 64 continue; 65 }66 ALLOCATE (chip[Nchip].stars, StarData, chip[Nchip].Nstars);67 68 Nbytes = BYTES_STAR * chip[Nchip].Nstars;69 ALLOCATE (chip[Nchip].buffer, char, Nbytes + 1);70 nbytes = Fread (chip[Nchip].buffer, 1, Nbytes, f, "char");71 if (nbytes != Nbytes) { exit (1); }72 chip[Nchip].Nbuffer = Nbytes;73 74 for (j = 0; j < chip[Nchip].Nstars; j++) {75 bzero (&chip[Nchip].stars[j], sizeof(StarData));76 dparse (&chip[Nchip].stars[j].X, 1, &chip[Nchip].buffer[j*BYTES_STAR]);77 dparse (&chip[Nchip].stars[j].Y, 2, &chip[Nchip].buffer[j*BYTES_STAR]);78 dparse (&chip[Nchip].stars[j].Mag, 3, &chip[Nchip].buffer[j*BYTES_STAR]);79 dparse (&chip[Nchip].stars[j].dMag, 4, &chip[Nchip].buffer[j*BYTES_STAR]);80 chip[Nchip].stars[j].dMag *= 0.001; /* millimag errors stored in file */81 65 } 82 66 -
trunk/Ohana/src/mosastro/src/clip.c
r3401 r3416 8 8 StarData *raw, *ref; 9 9 10 sigma = GetScatter (&Nscatter);11 fprintf (stderr, "scatter (chip) : %f for %d stars\n", sigma, Nscatter);12 13 10 Nmask = Nkeep = 0; 11 sigma = GetScatter (&Nscatter) / (3600.0 * field.project.cdelt1); 14 12 15 13 for (i = 0; i < Nchip; i++) { -
trunk/Ohana/src/mosastro/src/dump.c
r3401 r3416 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 %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 %d\n", 9 9 i, 10 10 stars[i].R, stars[i].D, … … 12 12 stars[i].L, stars[i].M, 13 13 stars[i].X, stars[i].Y, 14 stars[i].Mag, stars[i].dMag );14 stars[i].Mag, stars[i].dMag, stars[i].mask); 15 15 } 16 16 return (1); -
trunk/Ohana/src/mosastro/src/mosastro.c
r3404 r3416 56 56 if ((DUMP != NULL) && !strcmp (DUMP, "fitchips_unclip")) dump_match(); 57 57 58 ClipOnFP ( 3.0);58 ClipOnFP (2.0); 59 59 Cerror = GetScatter (&Nastro); 60 60 fprintf (stderr, "scatter (clip) : %f for %d stars\n", Cerror, Nastro); … … 64 64 fprintf (stderr, "scatter (chip) : %f for %d stars\n", Cerror, Nastro); 65 65 66 ClipOnFP (3.0); 66 ClipOnFP (2.0); 67 Cerror = GetScatter (&Nastro); 68 fprintf (stderr, "scatter (clip) : %f for %d stars\n", Cerror, Nastro); 69 70 FitChips (ChipOrder); 71 Cerror = GetScatter (&Nastro); 72 fprintf (stderr, "scatter (chip) : %f for %d stars\n", Cerror, Nastro); 73 74 ClipOnFP (2.0); 67 75 Cerror = GetScatter (&Nastro); 68 76 fprintf (stderr, "scatter (clip) : %f for %d stars\n", Cerror, Nastro); -
trunk/Ohana/src/mosastro/src/output.c
r3401 r3416 4 4 5 5 int i, N; 6 char *p; 7 char outname[256]; 6 char *p, outname[256]; 7 FILE *f; 8 Header *header; 8 9 9 10 for (i = 0; i < Nchip; i++) { … … 26 27 } 27 28 28 {29 field_combine (); 29 30 30 Header *header; 31 FILE *f; 32 33 field_combine (); 34 35 f = fopen (phu, "w"); 36 if (f == (FILE *) NULL) { 37 fprintf (stderr, "ERROR: can't create output file %s\n", phu); 38 exit (1); 39 } 40 41 header = mkmosaic (1, 1, 0, &field.project); 42 fwrite (header[0].buffer, 1, header[0].size, f); 43 fclose (f); 31 f = fopen (phu, "w"); 32 if (f == (FILE *) NULL) { 33 fprintf (stderr, "ERROR: can't create output file %s\n", phu); 34 exit (1); 44 35 } 45 36 46 { 47 48 FILE *f; 49 double R, D; 50 51 fprintf (stderr, "starting test.dat\n"); 52 f = fopen ("test.dat", "w"); 53 if (f == (FILE *) NULL) { 54 fprintf (stderr, "ERROR: can't create output file \n"); 55 exit (1); 56 } 57 58 RegisterMosaic (&field.project); 59 for (i = 0; i < chip[0].Nmatch; i++) { 60 XY_to_RD (&R, &D, chip[0].raw[i].X, chip[0].raw[i].Y, &chip[0].map); 61 fprintf (f, "%4d %10.6f %10.6f %8.2f %8.2f\n", 62 i, R, D, chip[0].raw[i].X, chip[0].raw[i].Y); 63 } 64 fclose (f); 65 } 66 37 header = mkmosaic (1, 1, 0, &field.project); 38 fwrite (header[0].buffer, 1, header[0].size, f); 39 fclose (f); 67 40 } -
trunk/Ohana/src/mosastro/src/wstars.c
r3323 r3416 6 6 FILE *g; 7 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 } 8 if (data[0].FITS) { 9 wfits (filename, (Stars *) data[0].buffer, data[0].Nstars, &data[0].header); 10 } else { 13 11 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); 12 g = fopen (filename, "w"); 13 if (g == (FILE *) NULL) { 14 fprintf (stderr, "ERROR: can't create output file %s\n", filename); 15 exit (1); 16 } 17 17 18 fwrite (data[0].header.buffer, 1, data[0].header.size, g); 19 fwrite (data[0].buffer, 1, data[0].Nbuffer, g); 20 fclose (g); 21 } 18 22 } 19 23
Note:
See TracChangeset
for help on using the changeset viewer.
