Changeset 4299
- Timestamp:
- Jun 17, 2005, 12:14:53 PM (21 years ago)
- Location:
- trunk/Ohana/src/addstar
- Files:
-
- 4 added
- 11 edited
-
Makefile (modified) (4 diffs)
-
include/2mass.h (added)
-
include/addstar.h (modified) (4 diffs)
-
src/ConfigInit.c (modified) (1 diff)
-
src/RegionOps.c (modified) (3 diffs)
-
src/addstar.c (modified) (1 diff)
-
src/args.c (modified) (3 diffs)
-
src/get2mass.c (modified) (5 diffs)
-
src/get2mass_as.c (added)
-
src/get2mass_dr2.c (added)
-
src/greference.c (modified) (1 diff)
-
src/gregion_patch.c (modified) (1 diff)
-
src/gstars.c (modified) (1 diff)
-
src/mkacc-2mass.c (added)
-
src/rfits.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/Makefile
r3904 r4299 18 18 INCS = -I$(INC) -I$(LINC) -I$(XINC) 19 19 LIBS = -L$(LLIB) -lohana -lFITS -lz -lm 20 CFLAGS = $(INCS) 20 CFLAGS = $(INCS) -g 21 21 LFLAGS = $(LIBS) 22 22 … … 36 36 $(SRC)/gcatalog.$(ARCH).o \ 37 37 $(SRC)/get2mass.$(ARCH).o \ 38 $(SRC)/get2mass_as.$(ARCH).o \ 39 $(SRC)/get2mass_dr2.$(ARCH).o \ 38 40 $(SRC)/getgsc.$(ARCH).o \ 39 41 $(SRC)/getusno.$(ARCH).o \ … … 64 66 $(SRC)/rtext.$(ARCH).o 65 67 68 MKACC-2MASS = \ 69 $(SRC)/mkacc-2mass.$(ARCH).o \ 70 $(SRC)/image-db.$(ARCH).o \ 71 $(SRC)/check_permissions.$(ARCH).o \ 72 $(SRC)/ConfigInit.$(ARCH).o \ 73 $(SRC)/SetSignals.$(ARCH).o \ 74 $(SRC)/conversions.$(ARCH).o \ 75 $(SRC)/wimage.$(ARCH).o \ 76 $(SRC)/get2mass_as.$(ARCH).o 77 66 78 EXTRA = \ 67 79 $(SRC)/bracket.$(ARCH).o \ … … 74 86 75 87 addstar : $(BIN)/addstar.$(ARCH) 76 77 88 $(BIN)/addstar.$(ARCH) : $(ADDSTAR) 78 79 89 # $(ADDSTAR): $(INC)/addstar.h 80 81 INSTALL = addstar82 90 83 91 gztest : $(BIN)/gztest.$(ARCH) 84 92 $(BIN)/gztest.$(ARCH) : $(SRC)/gztest.$(ARCH).o 93 94 mkacc-2mass : $(BIN)/mkacc-2mass.$(ARCH) 95 $(BIN)/mkacc-2mass.$(ARCH) : $(MKACC-2MASS) 96 mkacc-2mass.install : $(DESTBIN)/mkacc-2mass 85 97 86 98 INSTALL = addstar -
trunk/Ohana/src/addstar/include/addstar.h
r3521 r4299 51 51 } Stars; 52 52 53 /* structure for data on a catalog region */54 typedef struct {55 char filename[256];56 double RA[2];57 int Nrec;58 } TM_Region;59 60 53 enum {M_IMAGE, M_REFLIST, M_REFCAT}; 61 54 … … 66 59 char GSCFILE[256]; 67 60 char CATDIR[256]; 68 char TWO_MASS_DIR[256]; 61 char TWO_MASS_DIR_AS[256]; 62 char TWO_MASS_DIR_DR2[256]; 69 63 char GSCDIR[256]; 70 64 char CDROM[256]; … … 99 93 int DUMP_MATCHES; 100 94 int ONLY_IMAGES; 95 int EXISTING_REGIONS; 101 96 int FORCE_READ; 102 97 int SKYPROBE; … … 172 167 **/ 173 168 174 Stars *get2mass (GSCRegion *patch, int *NSTARS); 175 TM_Region *get2mass_acc (GSCRegion *patch, int *nfiles); 176 Stars *get2mass_data (TM_Region *region, GSCRegion *patch, int *nstars); 169 Stars *get2mass (GSCRegion *patch, int *NSTARS, int mode); 177 170 GSCRegion *gregion_stars (Stars *stars, int Nstars, int *Nregion); 178 171 Stars *grefstars (char *file, int *Nstars); -
trunk/Ohana/src/addstar/src/ConfigInit.c
r3376 r4299 33 33 ScanConfig (config, "ADDSTAR_YMAX", "%d", 0, &YMAX); 34 34 35 ScanConfig (config, "2MASS_DIR", "%s", 0, TWO_MASS_DIR); 35 ScanConfig (config, "2MASS_DIR_AS", "%s", 0, TWO_MASS_DIR_AS); 36 ScanConfig (config, "2MASS_DIR_DR2", "%s", 0, TWO_MASS_DIR_DR2); 36 37 ScanConfig (config, "GSCDIR", "%s", 0, GSCDIR); 37 38 ScanConfig (config, "USNO_CDROM", "%s", 0, CDROM); -
trunk/Ohana/src/addstar/src/RegionOps.c
r3400 r4299 88 88 Nregions ++; 89 89 } 90 if (Nregions > Ny + 2) { 91 fprintf (stderr, "ERROR: too many regions\n"); 92 exit (2); 93 } 90 94 91 95 sort_regions (regions, Nregions); … … 114 118 int N, Nlo, Nhi; 115 119 double D0, D1; 120 121 if (dec <= 90) return (0); 116 122 117 123 /* D0, D1 are upper lower band boundaries */ … … 147 153 double D0, D1; 148 154 155 if (dec >= 90) return (Nregion - 1); 156 149 157 /* D0, D1 are upper lower band boundaries */ 150 158 /* all regions in this band have DEC[0] < D1 */ -
trunk/Ohana/src/addstar/src/addstar.c
r3645 r4299 41 41 break; 42 42 } 43 if (ONLY_MATCH ) {43 if (ONLY_MATCH || EXISTING_REGIONS) { 44 44 regions = gregion_match (regions, &Nregions); 45 45 } 46 if (VERBOSE) fprintf (stderr, "writing to %d regions\n", Nregions); 46 47 47 48 Naverage = Nmeasure = 0; -
trunk/Ohana/src/addstar/src/args.c
r3466 r4299 4 4 void help () { 5 5 6 fprintf (stderr, "USAGE: addstar (filename)\n"); 6 fprintf (stderr, "USAGE\n"); 7 fprintf (stderr, " addstar (filename)\n"); 8 fprintf (stderr, " add specified image (cmp format) to database\n\n"); 9 fprintf (stderr, " addstar -ref (filename)"); 10 fprintf (stderr, " add ASCII data (ra dec mag dmag) to database\n\n"); 11 fprintf (stderr, " addstar -cat (catalog)"); 12 fprintf (stderr, " add data from catalog (USNO/2MASS/GSC) to database\n\n"); 13 7 14 fprintf (stderr, " optional flags:\n"); 8 fprintf (stderr, " -v (verbose mode)\n"); 9 fprintf (stderr, " -p (photcode) - define the photcode\n"); 10 fprintf (stderr, "\n"); 15 fprintf (stderr, " -region ra ra dec dec : only add data in specified region (-ref mode only)\n"); 16 fprintf (stderr, " -p (photcode) : specify photcode (override header)\n"); 17 fprintf (stderr, " -time (YYYY/MM/DD,HH:MM:SS) : specify date/time (override header)\n"); 18 fprintf (stderr, " -mosaic (filename) : identify associated mosaic frame for chip image\n"); 19 fprintf (stderr, " -fits : input file is FITS table, not TEXT table\n"); 20 fprintf (stderr, " -existing-regions : only add measurements to existing catalog files\n"); 21 fprintf (stderr, " -only-match : only add measurements to existing objects\n"); 22 fprintf (stderr, " -missed : skipped 'missed' entries\n"); 23 fprintf (stderr, " -replace : replace time/photcode measurements (no duplication)\n"); 24 fprintf (stderr, " -image : only insert image data\n"); 25 fprintf (stderr, " -cal : perform zero-point calibration\n"); 26 fprintf (stderr, " -skyprobe : specify skyprobe mode\n"); 27 fprintf (stderr, " -accept : accept bad astrometry from header\n"); 28 fprintf (stderr, " -force : force read of database with inconsistent info\n"); 29 fprintf (stderr, " -v : verbose mode\n"); 30 fprintf (stderr, " -dump (mode) : output test data\n"); 31 fprintf (stderr, " -help : this list\n"); 32 fprintf (stderr, " -h : this list\n\n"); 11 33 exit (2); 12 34 } … … 99 121 /*** modify behavior ***/ 100 122 /* only add to existing objects */ 123 EXISTING_REGIONS = FALSE; 124 if ((N = get_argument (argc, argv, "-existing-regions"))) { 125 EXISTING_REGIONS = TRUE; 126 remove_argument (N, &argc, argv); 127 } 128 /* only add to existing objects */ 101 129 ONLY_MATCH = FALSE; 102 130 if ((N = get_argument (argc, argv, "-only-match"))) { … … 165 193 fprintf (stderr, "USAGE: addstar -cat (catalog)\n"); 166 194 fprintf (stderr, "USAGE: addstar -ref (filename)\n"); 167 fprintf (stderr, " cur: %s ", argv[0]);168 for (N = 0; N < argc; N++) { fprintf (stderr, "%s ", argv[N]); }169 fprintf (stderr, "\n");170 195 exit (2); 171 196 } -
trunk/Ohana/src/addstar/src/get2mass.c
r3400 r4299 1 1 # include "addstar.h" 2 # include "2mass.h" 2 3 3 static short TM_J, TM_H, TM_K; 4 5 Stars *get2mass (GSCRegion *patch, int *NSTARS) { 4 Stars *get2mass (GSCRegion *patch, int *NSTARS, int mode) { 6 5 6 char accel[64], *path; 7 7 int i, Nstars, Nrefcat, Nregions; 8 8 Stars *stars; 9 9 Stars *refcat; 10 TM_Region *regions;10 GSCRegion *regions; 11 11 12 12 NAMED_PHOTCODE (TM_J, "2MASS_J"); … … 20 20 21 21 good_code: 22 regions = get2mass_acc (patch, &Nregions); 22 path = TWO_MASS_DIR_AS; 23 if (mode == 1) path = TWO_MASS_DIR_DR2; 24 25 regions = get2mass_acc (patch, &Nregions, path, "accel.dat"); 23 26 24 27 Nstars = 0; 25 28 ALLOCATE (stars, Stars, 1); 26 29 27 30 for (i = 0; i < Nregions; i++) { 28 refcat = get2mass_data (®ions[i], patch, &Nrefcat); 31 switch (mode) { 32 case 0: 33 refcat = get2mass_AS_data (®ions[i], patch, &Nrefcat); 34 if (VERBOSE) fprintf (stderr, "loaded %d stars from 2MASS (allsky)\n", Nrefcat); 35 break; 36 case 1: 37 refcat = get2mass_2DR_data (®ions[i], patch, &Nrefcat); 38 if (VERBOSE) fprintf (stderr, "loaded %d stars from 2MASS (dr2)\n", Nrefcat); 39 break; 40 } 29 41 30 42 REALLOCATE (stars, Stars, MAX (1, Nstars + Nrefcat)); … … 35 47 } 36 48 37 if (VERBOSE) fprintf (stderr, " %d stars from 2MASS\n", Nstars);49 if (VERBOSE) fprintf (stderr, "loaded total %d stars from 2MASS\n", Nstars); 38 50 *NSTARS = Nstars; 39 51 return (stars); … … 41 53 42 54 /* watch for patch which cross 0,360 boundary */ 43 TM_Region *get2mass_acc (GSCRegion *patch, int *nregions) {55 GSCRegion *get2mass_acc (GSCRegion *patch, int *nregions, char *path, char *accel) { 44 56 45 57 int Nregions, NREGIONS, Nrec; 46 TM_Region *regions;47 char accel [1024], line[128], filename[128];48 FILE *f;49 double Rs, Re ;58 GSCRegion *regions; 59 char accelfile[1024], line[256], filename[128]; 60 FILE *f; 61 double Rs, Re, Ds, De; 50 62 51 sprintf (accel , "%s/idr2.acc", TWO_MASS_DIR);52 f = fopen (accel , "r");53 if (f == NULL) Shutdown ("can't read data from accelerator %s", accel );63 sprintf (accelfile, "%s/%s", path, accel); 64 f = fopen (accelfile, "r"); 65 if (f == NULL) Shutdown ("can't read data from accelerator %s", accelfile); 54 66 55 67 Nregions = 0; 56 NREGIONS = 20 ;57 ALLOCATE (regions, TM_Region, NREGIONS);68 NREGIONS = 200; 69 ALLOCATE (regions, GSCRegion, NREGIONS); 58 70 59 71 /* read in stars line-by-line */ … … 62 74 if (line[0] == 0) continue; 63 75 if (line[0] == '#') continue; 64 sscanf (line, "%s %lf %lf % d", filename, &Rs, &Re, &Nrec);76 sscanf (line, "%s %lf %lf %lf %lf", filename, &Rs, &Re, &Ds, &De); 65 77 Rs *= 15.0; 66 78 Re *= 15.0; 67 79 if (Rs > patch[0].RA[1]) continue; 68 80 if (Re < patch[0].RA[0]) continue; 69 sprintf (regions[Nregions].filename, "%s/%s", TWO_MASS_DIR, filename); 81 if (Ds > patch[0].DEC[1]) continue; 82 if (De < patch[0].DEC[0]) continue; 83 sprintf (regions[Nregions].filename, "%s/%s", path, filename); 70 84 regions[Nregions].RA[0] = Rs; 71 85 regions[Nregions].RA[1] = Re; 72 regions[Nregions].Nrec = Nrec; 86 regions[Nregions].DEC[0] = Ds; 87 regions[Nregions].DEC[1] = De; 73 88 Nregions ++; 74 CHECK_REALLOCATE (regions, TM_Region, NREGIONS, Nregions, 20);89 CHECK_REALLOCATE (regions, GSCRegion, NREGIONS, Nregions, 20); 75 90 } 91 fclose (f); 76 92 77 93 *nregions = Nregions; 78 94 return (regions); 79 95 } 80 81 # define NBYTE 30282 # define NLINE 3000083 84 Stars *get2mass_data (TM_Region *region, GSCRegion *patch, int *nstars) {85 86 int i, Nstars, NSTARS, Nbyte, Nline;87 Stars *stars;88 gzFile gf;89 char *filename, buffer[NLINE*NBYTE];90 double RA, DEC, J, H, K, dJ, dH, dK;91 double RA0, RA1, DEC0, DEC1;92 93 RA0 = MAX (patch[0].RA[0], UserPatch.RA[0]);94 RA1 = MIN (patch[0].RA[1], UserPatch.RA[1]);95 DEC0 = MAX (patch[0].DEC[0], UserPatch.DEC[0]);96 DEC1 = MIN (patch[0].DEC[1], UserPatch.DEC[1]);97 98 filename = region[0].filename;99 gf = gzopen (filename, "rb");100 if (gf == NULL) Shutdown ("can't read 2mass data file: %s", filename);101 102 Nstars = 0;103 NSTARS = 10000;104 ALLOCATE (stars, Stars, NSTARS);105 106 /* don't bother to seek ahead : position is not sufficiently predictable107 and gzseek is as expensive as gzread */108 /*109 Noffset = region[0].Nrec * (patch[0].DEC[0] + 90) / 180.0;110 gzseek (gf, Noffset * NBYTE, SEEK_SET);111 Nbyte = gzread (gf, buffer, NLINE*NBYTE);112 */113 114 while ((Nbyte = gzread (gf, buffer, NLINE*NBYTE)) != 0) {115 if (Nbyte == 0) Shutdown ("error reading from gzipped file %s", filename);116 if (Nbyte == -1) Shutdown ("error reading from gzipped file %s", filename);117 if (Nbyte % NBYTE) Shutdown ("error reading complete line from gzipped file %s", filename);118 Nline = Nbyte / NBYTE;119 120 /* skip past block not yet in range */121 sscanf (&buffer[NBYTE*(Nline - 1)], "%lf %lf", &RA, &DEC);122 if (DEC < DEC0) continue;123 124 for (i = 0; i < Nline; i++) {125 126 dparse (&RA, 1, &buffer[NBYTE*i+ 0]);127 dparse (&DEC, 2, &buffer[NBYTE*i+ 0]);128 129 if (DEC > DEC1) goto finished;130 if (DEC < DEC0) continue;131 if (RA < RA0) continue;132 if (RA > RA1) continue;133 134 stars[Nstars].R = RA;135 stars[Nstars].D = DEC;136 stars[Nstars].t = short_date_to_sec (&buffer[NBYTE*i + 164]);137 stars[Nstars].found = -1;138 139 if (thiscode[0].code == TM_J) {140 dparse (&J, 1, &buffer[NBYTE*i + 53]);141 dparse (&dJ, 2, &buffer[NBYTE*i + 53]);142 stars[Nstars].M = J;143 stars[Nstars].dM = dJ;144 stars[Nstars].code = TM_J;145 }146 if (thiscode[0].code == TM_H) {147 dparse (&H, 1, &buffer[NBYTE*i + 72]);148 dparse (&dH, 2, &buffer[NBYTE*i + 72]);149 stars[Nstars].M = H;150 stars[Nstars].dM = dH;151 stars[Nstars].code = TM_H;152 }153 if (thiscode[0].code == TM_K) {154 dparse (&K, 1, &buffer[NBYTE*i + 91]);155 dparse (&dK, 2, &buffer[NBYTE*i + 91]);156 stars[Nstars].M = K;157 stars[Nstars].dM = dK;158 stars[Nstars].code = TM_K;159 }160 Nstars ++;161 CHECK_REALLOCATE (stars, Stars, NSTARS, Nstars, 300);162 }163 }164 finished:165 gzclose (gf);166 167 *nstars = Nstars;168 return (stars);169 }170 171 /* this just scans along in the file. file is sorted by dec, so we172 should be skipping large chunks - but we would need to have173 the size from the accel file (won't fit in GSCRegion) and need174 to use gzseek, if it exists.175 */ -
trunk/Ohana/src/addstar/src/greference.c
r3400 r4299 24 24 /* get stars from 2MASS for the given region */ 25 25 if (!strcasecmp (Refcat, "2MASS")) { 26 stars = get2mass (catstats, &Nstars); 26 stars = get2mass (catstats, &Nstars, 0); 27 } 28 29 /* get stars from 2MASS for the given region */ 30 if (!strcasecmp (Refcat, "2MASS-ALLSKY")) { 31 stars = get2mass (catstats, &Nstars, 0); 32 } 33 34 /* get stars from 2MASS for the given region */ 35 if (!strcasecmp (Refcat, "2MASS-DR2")) { 36 stars = get2mass (catstats, &Nstars, 1); 27 37 } 28 38 -
trunk/Ohana/src/addstar/src/gregion_patch.c
r3376 r4299 28 28 } 29 29 30 if (VERBOSE) fprintf (stderr, "Nregions in patch: %d, Ne: %d, Ns: %d\n", Nregions, Ne, Ns); 31 if (Nregions > (Ne - Ns)) { 32 fprintf (stderr, "ERROR: too many regions found\n"); 33 exit (1); 34 } 35 30 36 *nregions = Nregions; 31 37 return (regions); -
trunk/Ohana/src/addstar/src/gstars.c
r3466 r4299 4 4 5 5 FILE *f; 6 int j, N, extend,Nbytes;6 int j, N, Nbytes; 7 7 int itmp, hour, min; 8 8 char *c, photcode[64], line[80]; -
trunk/Ohana/src/addstar/src/rfits.c
r3521 r4299 3 3 Stars *rfits (FILE *f, int *nstars) { 4 4 5 int i, N x, Ny, Nstars;5 int i, Nstars; 6 6 Header theader; 7 7 FTable table;
Note:
See TracChangeset
for help on using the changeset viewer.
