IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7688


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

updates to addstar for better 2mass support

Location:
trunk/Ohana/src
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/Makefile

    r7683 r7688  
    8888$(SRC)/get2mass_as.$(ARCH).o \
    8989$(SRC)/ConfigInit.$(ARCH).o \
     90$(SRC)/Shutdown.$(ARCH).o \
     91$(SRC)/SetSignals.$(ARCH).o
     92
     93LOAD-2MASS = \
     94$(SRC)/load2mass.$(ARCH).o \
     95$(SRC)/load2mass_as_data.$(ARCH).o \
     96$(SRC)/get2mass_ops.$(ARCH).o \
     97$(SRC)/ConfigInit.$(ARCH).o \
     98$(SRC)/args.$(ARCH).o \
    9099$(SRC)/Shutdown.$(ARCH).o \
    91100$(SRC)/SetSignals.$(ARCH).o
  • trunk/Ohana/src/addstar/include/2mass.h

    r7683 r7688  
    1313} TMBands;
    1414
     15typedef struct {
     16  double R, D;
     17  int offset;
     18  int flag;
     19} TMStars;
     20
    1521short TM_J, TM_H, TM_K;
    1622
  • trunk/Ohana/src/addstar/src/get2mass_as.c

    r7683 r7688  
    2929  DEC1 = MIN (patch[0].Dmax, UserPatch.Dmax);
    3030
    31   FilterSkip = TimeSkip = Qentry = 0;
    32   if (photcode == TM_J) {
    33       FilterSkip = 6;
    34       // TimeSkip = 23;
    35       TimeSkip = 28;
    36       Qentry   = 0;
    37   }
    38   if (photcode == TM_H) {
    39       FilterSkip = 10;
    40       // TimeSkip = 19;
    41       TimeSkip = 24;
    42       Qentry   = 1;
    43   }
    44   if (photcode == TM_K) {
    45       FilterSkip = 14;
    46       // looks like this should be 20, not 15...
    47       // TimeSkip = 15;
    48       TimeSkip = 20;
    49       Qentry   = 2;
    50   }
    51   if (!FilterSkip) Shutdown ("invalid photcode %s", GetPhotcodeNamebyCode(photcode));
     31  get2mass_setup (photcode);
    5232
    5333  gf = gzopen (filename, "rb");
     
    7555    while (1) {
    7656
    77       RA = strtod (p, NULL);
    78       ptr = skipNbounds (p, '|', 1, Nbyte - (p - buffer));
    79       DEC = strtod (ptr, NULL);
    80       if (DEC > 90) Shutdown ("weird DEC value: something is wrong");
     57      get2mass_coords (p, &RA, &DEC, Nbyte - (p - buffer));
    8158
    8259      /* skip stars which are outside desired region */
     
    8663      if (RA >  RA1)  goto skip_star;
    8764
    88       ptr = skipNbounds (p, '|', FilterSkip, Nbyte - (p - buffer));
    89       if (ptr == NULL) Shutdown ("format error in 2mass");
    90       M  = strtod (ptr, NULL);
    91       ptr = skipNbounds (ptr, '|', 1, Nbyte - (ptr - buffer));
    92       dM = strtod (ptr, NULL);
    93       time = get2mass_time (ptr, buffer, TimeSkip, Nbyte);
    94 
    95       /* filter on the ph_qual flag for this filter (field 19) */
    96       if (SELECT_2MASS_QUALITY != NULL) {
    97         ptr = skipNbounds (p, '|', 18, Nbyte - (p - buffer));
    98         qc  = ptr[Qentry];
    99         if (strchr (SELECT_2MASS_QUALITY, qc) == NULL) goto skip_star;
    100       }
    101 
    102       stars[Nstars].R     = RA;
    103       stars[Nstars].D     = DEC;
    104       stars[Nstars].M     = M;
    105       stars[Nstars].dM    = dM;
    106       stars[Nstars].code  = photcode;
    107       stars[Nstars].t     = time;
    108       stars[Nstars].found = -1;
     65      get2mass_star (&stars[Nstars], p, Nbyte - (p - buffer));
    10966
    11067      Nstars ++;
     
    149106*/
    150107
    151 /* return a pointer to the first char after Nbound of value bound */
    152 char *skipNbounds (char *line, char bound, int Nbound, int Nbyte) {
    153 
    154   int i;
    155   char *p, *q;
    156 
    157   p = line;
    158   for (i = 0; i < Nbound; i++) {
    159     q = memchr (p, bound, Nbyte - (p - line));
    160     if (q == NULL) return (NULL);
    161     p = q + 1;
    162     if (p - line == Nbyte) return (NULL);
    163   }
    164   return (p);
    165 }
    166  
    167 // this function retrieves the time from the DATE field
    168 e_time get2mass_date (char *ptr, char *buffer, int Nbound, int Nbyte) {
    169 
    170   e_time time;
    171   char *p, *end;
    172 
    173   p = skipNbounds (ptr, '|', Nbound, Nbyte - (ptr - buffer));
    174   if (p == NULL) Shutdown ("format error in 2mass");
    175   end = memchr (p, '|', Nbyte - (p - buffer));
    176   if (end == NULL) Shutdown ("format error in 2mass");
    177   *end = 0;
    178   time = date_to_sec (ptr);
    179   *end = '|';
    180 
    181   return (time);
    182 }
    183 
    184 // this function retrieves the time from the JDATE field (%12.4f)
    185 e_time get2mass_time (char *ptr, char *buffer, int Nbound, int Nbyte) {
    186 
    187   e_time time;
    188   double jd;
    189   char *p, *end;
    190 
    191   p = skipNbounds (ptr, '|', Nbound, Nbyte - (ptr - buffer));
    192   if (p == NULL) Shutdown ("format error in 2mass");
    193   end = memchr (p, '|', Nbyte - (p - buffer));
    194   if (end == NULL) Shutdown ("format error in 2mass");
    195   *end = 0;
    196   jd = strtod (p, NULL);
    197   time = jd_to_sec (jd);
    198   *end = '|';
    199 
    200   return (time);
    201 }
    202 
    203108# if (0)
    204109    /** need to re-think this test **/
  • 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 ++;
  • trunk/Ohana/src/addstar/src/scan2mass_as_data.c

    r7683 r7688  
    5858    while (1) {
    5959
    60       Ro = strtod (p, NULL);
    61       ptr = skipNbounds (p, '|', 1, Nbyte - (p - buffer));
    62       Do = strtod (ptr, NULL);
    63       if (Do > 90) Shutdown ("weird DEC value: something is wrong");
     60      get2mass_coords (p, &Ro, &Do, Nbyte - (p - buffer));
     61
    6462      if (badStar) {
    6563      fprintf (stderr, "next R,D: %10.6f %10.6f\n", Ro, Do);
  • trunk/Ohana/src/opihi/dvo/fitsed.c

    r7681 r7688  
    4444  KapaSection magSection, resSection;
    4545
    46   Catalog catalog;
     46  Catalog catalog, outcat;
    4747  SkyList *skylist;
    4848  SEDtableRow *SEDtableRaw, **SEDtable;
     
    5555  catalog.measure = NULL;
    5656  catalog.secfilt = NULL;
     57
     58  outcat.average = NULL;
     59  outcat.measure = NULL;
     60  outcat.secfilt = NULL;
     61
    5762  SEDtable = NULL;
    5863  SEDtableRaw = NULL;
     
    8186    remove_argument (N, &argc, argv);
    8287    PLOT = TRUE;
     88  }
     89
     90  SAVEDIR = NULL;
     91  if ((N = get_argument (argc, argv, "-save"))) {
     92    remove_argument (N, &argc, argv);
     93    SAVEDIR = strcreate (argv[N]);
     94    remove_argument (N, &argc, argv);
    8395  }
    8496
Note: See TracChangeset for help on using the changeset viewer.