Changeset 7688 for trunk/Ohana/src/addstar/src/get2mass_as_raw.c
- Timestamp:
- Jun 25, 2006, 12:58:30 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/addstar/src/get2mass_as_raw.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/src/get2mass_as_raw.c
r7683 r7688 31 31 DEC1 = MIN (patch[0].Dmax, UserPatch.Dmax); 32 32 33 FilterSkip = TimeSkip = Qentry = 0; 34 if (photcode == TM_J) { 35 FilterSkip = 6; 36 // TimeSkip = 23; 37 TimeSkip = 28; 38 Qentry = 0; 39 } 40 if (photcode == TM_H) { 41 FilterSkip = 10; 42 // TimeSkip = 19; 43 TimeSkip = 24; 44 Qentry = 1; 45 } 46 if (photcode == TM_K) { 47 FilterSkip = 14; 48 // looks like this should be 20, not 15... 49 // TimeSkip = 15; 50 TimeSkip = 20; 51 Qentry = 2; 52 } 53 if (!FilterSkip) Shutdown ("invalid photcode %s", GetPhotcodeNamebyCode(photcode)); 33 get2mass_setup (photcode); 54 34 55 35 f = fopen (filename, "r"); … … 60 40 NSTARS = 10000; 61 41 ALLOCATE (stars, Stars, NSTARS); 62 63 /* I want to add a seek-ahead test to find a good starting position in the file64 this is very expensive using gzseek / gzread. */65 66 # if 067 if (patch[0].Rmin > 5) {68 // each 2MASS record is a random length of ~ 330 bytes69 // guess at start, then used a binary search to narrow down70 // first guess at start:71 dNoffset = region[0].childE / 360.0;72 Noffset = dNoffset * patch[0].Rmin;73 fseek (f, Noffset * NBREC, SEEK_SET);74 Nbyte = fread (buffer, 1, 10*NBREC, f);75 q = memchr (p, '\n', Nbyte);76 if (q == NULL) Shutdown ("incomplete line at end of file\n");77 q++; // first (or second) complete line78 79 // get coords for this line80 RA = strtod (q, NULL);81 ptr = skipNbounds (q, '|', 1, Nbyte - (q - buffer));82 DEC = strtod (ptr, NULL);83 if (DEC > 90) Shutdown ("weird DEC value: something is wrong");84 85 // if we are beyond, spin back in ~5 deg chunks 'till we are below86 while (RA > patch[0].Rmin) {87 fseek (f, -5 * dNoffset * NBREC, SEEK_CUR);88 Nbyte = fread (buffer, 1, 10*NBREC, f);89 q = memchr (p, '\n', Nbyte);90 if (q == NULL) Shutdown ("incomplete line at end of file\n");91 q++; // first (or second) complete line92 93 // get coords for this line94 RA = strtod (q, NULL);95 ptr = skipNbounds (q, '|', 1, Nbyte - (q - buffer));96 DEC = strtod (ptr, NULL);97 if (DEC > 90) Shutdown ("weird DEC value: something is wrong");98 99 Nextra = Nbyte - (q - buffer);100 memmove (buffer, q, Nextra);101 }102 } else {103 Nextra = 0;104 }105 # endif106 42 107 43 Nextra = 0; … … 119 55 while (1) { 120 56 121 RA = strtod (p, NULL); 122 ptr = skipNbounds (p, '|', 1, Nbyte - (p - buffer)); 123 DEC = strtod (ptr, NULL); 124 if (DEC > 90) Shutdown ("weird DEC value: something is wrong"); 57 get2mass_coords (p, &RA, &DEC, Nbyte - (p - buffer)); 125 58 126 59 /* skip stars which are outside desired region */ … … 130 63 if (RA > RA1) goto skip_star; 131 64 132 ptr = skipNbounds (p, '|', FilterSkip, Nbyte - (p - buffer)); 133 if (ptr == NULL) Shutdown ("format error in 2mass"); 134 M = strtod (ptr, NULL); 135 ptr = skipNbounds (ptr, '|', 1, Nbyte - (ptr - buffer)); 136 dM = strtod (ptr, NULL); 137 time = get2mass_time (ptr, buffer, TimeSkip, Nbyte); 138 139 /* filter on the ph_qual flag for this filter (field 19) */ 140 if (SELECT_2MASS_QUALITY != NULL) { 141 ptr = skipNbounds (p, '|', 18, Nbyte - (p - buffer)); 142 qc = ptr[Qentry]; 143 if (strchr (SELECT_2MASS_QUALITY, qc) == NULL) goto skip_star; 144 } 145 146 stars[Nstars].R = RA; 147 stars[Nstars].D = DEC; 148 stars[Nstars].M = M; 149 stars[Nstars].dM = dM; 150 stars[Nstars].code = photcode; 151 stars[Nstars].t = time; 152 stars[Nstars].found = -1; 65 get2mass_star (&stars[Nstars], p, Nbyte - (p - buffer)); 153 66 154 67 Nstars ++;
Note:
See TracChangeset
for help on using the changeset viewer.
