IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 25, 2006, 12:58:30 PM (20 years ago)
Author:
eugene
Message:

updates to addstar for better 2mass support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/src/get2mass_as_raw.c

    r7683 r7688  
    3131  DEC1 = MIN (patch[0].Dmax, UserPatch.Dmax);
    3232
    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);
    5434
    5535  f = fopen (filename, "r");
     
    6040  NSTARS = 10000;
    6141  ALLOCATE (stars, Stars, NSTARS);
    62 
    63   /* I want to add a seek-ahead test to find a good starting position in the file
    64      this is very expensive using gzseek / gzread.  */
    65 
    66   # if 0
    67   if (patch[0].Rmin > 5) {
    68     // each 2MASS record is a random length of ~ 330 bytes
    69     // guess at start, then used a binary search to narrow down
    70     // 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 line
    78  
    79     // get coords for this line
    80     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 below
    86     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 line
    92  
    93       // get coords for this line
    94       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   # endif
    10642
    10743  Nextra = 0;
     
    11955    while (1) {
    12056
    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));
    12558
    12659      /* skip stars which are outside desired region */
     
    13063      if (RA >  RA1)  goto skip_star;
    13164
    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));
    15366
    15467      Nstars ++;
Note: See TracChangeset for help on using the changeset viewer.