IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4299


Ignore:
Timestamp:
Jun 17, 2005, 12:14:53 PM (21 years ago)
Author:
eugene
Message:

fixed up 2mass to handle allsky release

Location:
trunk/Ohana/src/addstar
Files:
4 added
11 edited

Legend:

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

    r3904 r4299  
    1818INCS    =       -I$(INC) -I$(LINC) -I$(XINC)
    1919LIBS    =       -L$(LLIB) -lohana -lFITS -lz -lm
    20 CFLAGS  =       $(INCS)
     20CFLAGS  =       $(INCS) -g
    2121LFLAGS  =       $(LIBS)
    2222
     
    3636$(SRC)/gcatalog.$(ARCH).o \
    3737$(SRC)/get2mass.$(ARCH).o \
     38$(SRC)/get2mass_as.$(ARCH).o \
     39$(SRC)/get2mass_dr2.$(ARCH).o \
    3840$(SRC)/getgsc.$(ARCH).o \
    3941$(SRC)/getusno.$(ARCH).o \
     
    6466$(SRC)/rtext.$(ARCH).o
    6567
     68MKACC-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
    6678EXTRA = \
    6779$(SRC)/bracket.$(ARCH).o \
     
    7486
    7587addstar                : $(BIN)/addstar.$(ARCH)
    76 
    7788$(BIN)/addstar.$(ARCH) : $(ADDSTAR)
    78 
    7989# $(ADDSTAR): $(INC)/addstar.h
    80 
    81 INSTALL = addstar
    8290
    8391gztest                : $(BIN)/gztest.$(ARCH)
    8492$(BIN)/gztest.$(ARCH) : $(SRC)/gztest.$(ARCH).o
     93
     94mkacc-2mass                : $(BIN)/mkacc-2mass.$(ARCH)
     95$(BIN)/mkacc-2mass.$(ARCH) : $(MKACC-2MASS)
     96mkacc-2mass.install        : $(DESTBIN)/mkacc-2mass
    8597
    8698INSTALL = addstar
  • trunk/Ohana/src/addstar/include/addstar.h

    r3521 r4299  
    5151} Stars;
    5252
    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 
    6053enum {M_IMAGE, M_REFLIST, M_REFCAT};
    6154
     
    6659char   GSCFILE[256];
    6760char   CATDIR[256];
    68 char   TWO_MASS_DIR[256];
     61char   TWO_MASS_DIR_AS[256];
     62char   TWO_MASS_DIR_DR2[256];
    6963char   GSCDIR[256];
    7064char   CDROM[256];
     
    9993int DUMP_MATCHES;
    10094int ONLY_IMAGES;
     95int EXISTING_REGIONS;
    10196int FORCE_READ;
    10297int SKYPROBE;
     
    172167**/
    173168
    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);
     169Stars *get2mass (GSCRegion *patch, int *NSTARS, int mode);
    177170GSCRegion *gregion_stars (Stars *stars, int Nstars, int *Nregion);
    178171Stars *grefstars (char *file, int *Nstars);
  • trunk/Ohana/src/addstar/src/ConfigInit.c

    r3376 r4299  
    3333  ScanConfig (config, "ADDSTAR_YMAX",           "%d",  0, &YMAX);
    3434
    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);
    3637  ScanConfig (config, "GSCDIR",                 "%s",  0, GSCDIR);
    3738  ScanConfig (config, "USNO_CDROM",             "%s",  0, CDROM);
  • trunk/Ohana/src/addstar/src/RegionOps.c

    r3400 r4299  
    8888    Nregions ++;
    8989  }
     90  if (Nregions > Ny + 2) {
     91    fprintf (stderr, "ERROR: too many regions\n");
     92    exit (2);
     93  }
    9094
    9195  sort_regions (regions, Nregions);
     
    114118  int N, Nlo, Nhi;
    115119  double D0, D1;
     120
     121  if (dec <= 90) return (0);
    116122
    117123  /* D0, D1 are upper lower band boundaries */
     
    147153  double D0, D1;
    148154
     155  if (dec >= 90) return (Nregion - 1);
     156
    149157  /* D0, D1 are upper lower band boundaries */
    150158  /* all regions in this band have DEC[0] < D1 */
  • trunk/Ohana/src/addstar/src/addstar.c

    r3645 r4299  
    4141    break;
    4242  }
    43   if (ONLY_MATCH) {
     43  if (ONLY_MATCH || EXISTING_REGIONS) {
    4444    regions = gregion_match (regions, &Nregions);
    4545  }
     46  if (VERBOSE) fprintf (stderr, "writing to %d regions\n", Nregions);
    4647
    4748  Naverage = Nmeasure = 0;
  • trunk/Ohana/src/addstar/src/args.c

    r3466 r4299  
    44void help () {
    55
    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
    714  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");
    1133  exit (2);
    1234}
     
    99121  /*** modify behavior ***/
    100122  /* 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 */
    101129  ONLY_MATCH = FALSE;
    102130  if ((N = get_argument (argc, argv, "-only-match"))) {
     
    165193    fprintf (stderr, "USAGE: addstar -cat (catalog)\n");
    166194    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"); 
    170195    exit (2);
    171196  }
  • trunk/Ohana/src/addstar/src/get2mass.c

    r3400 r4299  
    11# include "addstar.h"
     2# include "2mass.h"
    23
    3 static short TM_J, TM_H, TM_K;
    4 
    5 Stars *get2mass (GSCRegion *patch, int *NSTARS) {
     4Stars *get2mass (GSCRegion *patch, int *NSTARS, int mode) {
    65 
     6  char accel[64], *path;
    77  int i, Nstars, Nrefcat, Nregions;
    88  Stars     *stars;
    99  Stars     *refcat;
    10   TM_Region *regions;
     10  GSCRegion *regions;
    1111
    1212  NAMED_PHOTCODE (TM_J, "2MASS_J");
     
    2020
    2121good_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");
    2326 
    2427  Nstars = 0;
    2528  ALLOCATE (stars, Stars, 1);
    26  
     29
    2730  for (i = 0; i < Nregions; i++) {
    28     refcat = get2mass_data (&regions[i], patch, &Nrefcat);
     31    switch (mode) {
     32      case 0:
     33        refcat = get2mass_AS_data (&regions[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 (&regions[i], patch, &Nrefcat);
     38        if (VERBOSE) fprintf (stderr, "loaded %d stars from 2MASS (dr2)\n", Nrefcat);
     39        break;
     40    }
    2941
    3042    REALLOCATE (stars, Stars, MAX (1, Nstars + Nrefcat));
     
    3547  }
    3648 
    37   if (VERBOSE) fprintf (stderr, "%d stars from 2MASS\n", Nstars);
     49  if (VERBOSE) fprintf (stderr, "loaded total %d stars from 2MASS\n", Nstars);
    3850  *NSTARS = Nstars;
    3951  return (stars);
     
    4153
    4254/* watch for patch which cross 0,360 boundary */
    43 TM_Region *get2mass_acc (GSCRegion *patch, int *nregions) {
     55GSCRegion *get2mass_acc (GSCRegion *patch, int *nregions, char *path, char *accel) {
    4456
    4557  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;
    5062
    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);
    5466
    5567  Nregions = 0;
    56   NREGIONS = 20;
    57   ALLOCATE (regions, TM_Region, NREGIONS);
     68  NREGIONS = 200;
     69  ALLOCATE (regions, GSCRegion, NREGIONS);
    5870
    5971  /* read in stars line-by-line */
     
    6274    if (line[0] == 0) continue;
    6375    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);
    6577    Rs *= 15.0;
    6678    Re *= 15.0;
    6779    if (Rs > patch[0].RA[1]) continue;
    6880    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);
    7084    regions[Nregions].RA[0] = Rs;
    7185    regions[Nregions].RA[1] = Re;
    72     regions[Nregions].Nrec = Nrec;
     86    regions[Nregions].DEC[0] = Ds;
     87    regions[Nregions].DEC[1] = De;
    7388    Nregions ++;
    74     CHECK_REALLOCATE (regions, TM_Region, NREGIONS, Nregions, 20);
     89    CHECK_REALLOCATE (regions, GSCRegion, NREGIONS, Nregions, 20);
    7590  }   
     91  fclose (f);
    7692
    7793  *nregions = Nregions;
    7894  return (regions);
    7995}
    80 
    81 # define NBYTE 302
    82 # define NLINE 30000
    83 
    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 predictable
    107      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 we
    172        should be skipping large chunks - but we would need to have
    173        the size from the accel file (won't fit in GSCRegion) and need
    174        to use gzseek, if it exists.
    175     */
  • trunk/Ohana/src/addstar/src/greference.c

    r3400 r4299  
    2424  /* get stars from 2MASS for the given region */
    2525  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);
    2737  }
    2838 
  • trunk/Ohana/src/addstar/src/gregion_patch.c

    r3376 r4299  
    2828  }
    2929
     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
    3036  *nregions = Nregions;
    3137  return (regions);
  • trunk/Ohana/src/addstar/src/gstars.c

    r3466 r4299  
    44
    55  FILE *f;
    6   int j, N, extend, Nbytes;
     6  int j, N, Nbytes;
    77  int itmp, hour, min;
    88  char *c, photcode[64], line[80];
  • trunk/Ohana/src/addstar/src/rfits.c

    r3521 r4299  
    33Stars *rfits (FILE *f, int *nstars) {
    44
    5   int i, Nx, Ny, Nstars;
     5  int i, Nstars;
    66  Header theader;
    77  FTable table;
Note: See TracChangeset for help on using the changeset viewer.