IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6675


Ignore:
Timestamp:
Mar 24, 2006, 3:19:05 PM (20 years ago)
Author:
eugene
Message:

added tycho and USNO-B to addstar

Location:
trunk/Ohana/src/addstar
Files:
3 added
5 edited

Legend:

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

    r6674 r6675  
    4040$(SRC)/get2mass_dr2.$(ARCH).o \
    4141$(SRC)/getgsc.$(ARCH).o \
     42$(SRC)/gettycho.$(ARCH).o \
    4243$(SRC)/getusno.$(ARCH).o \
     44$(SRC)/getusnob.$(ARCH).o \
    4345$(SRC)/gimages.$(ARCH).o \
    4446$(SRC)/greference.$(ARCH).o \
     
    5860$(SRC)/wcatalog.$(ARCH).o \
    5961$(SRC)/Shutdown.$(ARCH).o \
     62$(SRC)/SkyTableFromTychoIndex.$(ARCH).o \
    6063$(SRC)/SkyRegionUtils.$(ARCH).o \
    6164$(SRC)/SkyListForStars.$(ARCH).o \
  • trunk/Ohana/src/addstar/include/addstar.h

    r6674 r6675  
    4444char   TWO_MASS_DIR_DR2[256];
    4545char   GSCDIR[256];
    46 char   CDROM[256];
     46char   USNO_A_DIR[256];
     47char   USNO_B_DIR[256];
     48char   TYCHO_DIR[256];
    4749char   SubpixDatafile[256];
    4850char   PASSWORD[80];
     
    110112float      airmass                PROTO((float secz_image, double ra, double dec, double st, double latitude));
    111113void       SetAirmassQuality      PROTO((int quality));
     114SkyTable  *SkyTableFromTychoIndex PROTO((char *filename, int VERBOSE));
    112115AddstarClientOptions args         PROTO((int argc, char **argv, AddstarClientOptions options));
    113116void       check_permissions      PROTO((char *basefile));
     
    122125double     get_subpix             PROTO((double x, double y));
    123126Stars     *getgsc                 PROTO((SkyRegion *patch, int *NSTARS));
     127Stars     *gettycho               PROTO((SkyRegion *catstats, int photcode, double epoch, int *Nstars));
    124128Stars     *getusno                PROTO((SkyRegion *catstats, int photcode, int *Nstars));
     129Stars     *getusnob               PROTO((SkyRegion *catstats, int photcode, double epoch, int *Nstars));
    125130Image     *gimages                PROTO((FITS_DB *db, Image *image, Coords *mosaic, int *Npimage));
    126131Stars     *grefcat                PROTO((char *Refcat, SkyRegion *catstats, int photcode, int *nstars));
  • trunk/Ohana/src/addstar/src/ConfigInit.c

    r5585 r6675  
    5252  ScanConfig (config, "2MASS_DIR_DR2",          "%s",  0, TWO_MASS_DIR_DR2);
    5353  ScanConfig (config, "GSCDIR",                 "%s",  0, GSCDIR);
    54   ScanConfig (config, "USNO_CDROM",             "%s",  0, CDROM);
     54
     55  if (!ScanConfig (config, "USNO_A_DIR",             "%s",  0, USNO_A_DIR)) {
     56    ScanConfig (config, "USNO_CDROM",             "%s",  0, USNO_A_DIR);
     57  }
     58  ScanConfig (config, "USNO_B_DIR",             "%s",  0, USNO_B_DIR);
     59
     60  ScanConfig (config, "TYCHO_DIR",             "%s",  0, TYCHO_DIR);
    5561
    5662  ScanConfig (config, "IMAGE_CATALOG",          "%s",  0, ImageCat);
  • trunk/Ohana/src/addstar/src/getusno.c

    r5443 r6675  
    11# include "addstar.h"
    22# define NZONE 24
     3# define NBYTE  4
     4# define NELEM  3
    35
    4 int SPDzone[] = {
    5   0, 75, 450, 375, 1500, 1650, 300, 1425, 1725, 525, 1275, 225,
    6   675, 150, 600, 1575, 750, 975, 900, 1050, 1125, 1200, 825, 1350};
    7 
    8 int USNOdisk[] = {
    9   1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10};
    10 
    11 Stars *getusno (SkyRegion *catstats, int photcode, int *Nstars) {
     6Stars *getusno (SkyRegion *catstats, int photcode, int *nstars) {
    127
    138  long int offset;
    14   int i, bin, first, last, nitems, Nitems, Nbins;
     9  int i, bin, first, last, nitems, Nitems, Nbins, Nstars;
    1510  float hours[100];
    1611  int start[100], number[100], *buffer, *buf;
    17   char filename[128], c;
     12  char filename[128];
    1813  FILE *f;
    1914  int iRA0, iRA1, iDEC0, iDEC1;
    2015  double dec;
    21   int spd, spd_start, spd_end, disk;
     16  int spd, spd_start, spd_end;
    2217  int NUSNO, Nusno;
    2318  Stars *stars;
     
    5348
    5449  for (spd = spd_start; spd < spd_end; spd += 75) {
    55     disk = -1;
    56     for (i = 0; i < NZONE; i++) {
    57       if (spd == SPDzone[i])
    58         disk = USNOdisk[i];
    59     }
    60     if (disk < 0) {
    61       fprintf (stderr, "ERROR: can't find cdrom for spd %d\n",  spd);
    62       exit (1);
    63     }
    6450   
    6551    /* load accelerator file */
    66     sprintf (filename, "%s/zone%04d.acc", CDROM, spd);
     52    sprintf (filename, "%s/zone%04d.acc", USNO_A_DIR, spd);
    6753    if (VERBOSE) fprintf (stderr, "reading from %s\n", filename);
    6854    f = fopen (filename, "r");
    6955    if (f == (FILE *) NULL) {
    70       fprintf (stderr, "can't open file %s, is cdrom %d in drive?\n", filename, disk);
    71       fprintf (stderr, "press return when ready to continue: ");
    72       fscanf (stdin, "%c", &c);
    73       fprintf (stderr, "trying again...\n");
    74       f = fopen (filename, "r");
    75       if (f == (FILE *) NULL) {
    76         fprintf (stderr, "ERROR: can't open file %s, is cdrom %d in drive?\n", filename, disk);
    77         exit (1); 
    78       }
     56      fprintf (stderr, "ERROR: can't open accelerator file %s\n", filename);
     57      exit (1); 
    7958    }
    8059    for (i = 0; fscanf (f, "%f %d %d", &hours[i], &start[i], &number[i]) != EOF; i++);
     
    9473   
    9574    /* open data file */
    96     sprintf (filename, "%s/zone%04d.cat", CDROM, spd);
     75    sprintf (filename, "%s/zone%04d.cat", USNO_A_DIR, spd);
    9776    if (VERBOSE) fprintf (stderr, "reading from %s\n", filename);
    9877    f = fopen (filename, "r");
     
    10180      exit (1);
    10281    }
     82
     83    /** USNO-A consists of 3 x 4byte (int) records **/
    10384    /* advance file pointer to first slice */
    104     offset = 3*sizeof(int)*(start[first] - 1);
     85    offset = NELEM*NBYTE*(start[first] - 1);
    10586    fseek (f, offset, SEEK_SET);
    106     /* on each loop, load data from an RA slice of the catalog */
     87
     88    /* sum the number of stars in data segment of interest */
     89    Nstars = 0;
    10790    for (bin = first; bin < last; bin++) {
    108       Nitems = 3*number[bin];
    109       ALLOCATE (buffer, int, Nitems);
    110       nitems = Fread (buffer, sizeof(int), Nitems, f, "int");
    111       if (nitems != Nitems) {
    112         fprintf (stderr, "ERROR: failure reading data from file %s\n", filename);
    113         exit (1);
     91      Nstars += number[bin];
     92    }
     93    Nitems = NELEM*Nstars; 
     94    /* number of blocks to read -- we need to use Fread for byte-swapping read */
     95
     96    /* read stars from catalog */
     97    ALLOCATE (buffer, int, Nitems);
     98    nitems = Fread (buffer, NBYTE, Nitems, f, "int");
     99    if (nitems != Nitems) {
     100      fprintf (stderr, "ERROR: failure reading data from file %s\n", filename);
     101      exit (1);
     102    }
     103
     104    /* extract the data of interest from segment (in RA and DEC range) */
     105    buf = buffer;
     106    for (i = 0; i < Nstars; i++, buf += NELEM) {
     107      if (buf[0] < iRA0) continue;
     108      if (buf[0] > iRA1) continue;
     109      if (buf[1] < iDEC0) continue;
     110      if (buf[1] > iDEC1) continue;
     111
     112      bzero (&stars[Nusno], sizeof(Stars));
     113      stars[Nusno].R     = buf[0]/360000.0;
     114      stars[Nusno].D     = buf[1]/360000.0 - 90.0;
     115      stars[Nusno].dM    = NO_ERR;
     116      stars[Nusno].t     = 0;
     117      stars[Nusno].found = -1;
     118
     119      /* one pass of addstar does either r or b */
     120      if (photcode == USNO_RED) {
     121        stars[Nusno].code  = USNO_RED;
     122        stars[Nusno].M     = fabs (0.1*(buf[2] - 1000*((int)(buf[2]/1000))));
     123      }
     124      if (photcode == USNO_BLUE) {     
     125        stars[Nusno].code  = USNO_BLUE;
     126        stars[Nusno].M     = fabs (0.1*((int)(buf[2] - 1000000*((int)(buf[2]/1000000))) / 1000));
    114127      }
    115       buf = buffer;
    116       /* print out data from slice within RA and DEC range */
    117       for (i = 0; i < number[bin]; i++, buf+=3) {
    118         if (buf[0] < iRA0) continue;
    119         if (buf[0] > iRA1) continue;
    120         if (buf[1] < iDEC0) continue;
    121         if (buf[1] > iDEC1) continue;
    122 
    123         bzero (&stars[Nusno], sizeof(Stars));
    124         stars[Nusno].R     = buf[0]/360000.0;
    125         stars[Nusno].D     = buf[1]/360000.0 - 90.0;
    126         stars[Nusno].dM    = NO_ERR;
    127         stars[Nusno].t     = 0;
    128         stars[Nusno].found = -1;
    129 
    130         /* one pass of addstar does either r or b */
    131         if (photcode == USNO_RED) {
    132           stars[Nusno].code  = USNO_RED;
    133           stars[Nusno].M     = fabs (0.1*(buf[2] - 1000*((int)(buf[2]/1000))));
    134         }
    135         if (photcode == USNO_BLUE) {   
    136           stars[Nusno].code  = USNO_BLUE;
    137           stars[Nusno].M     = fabs (0.1*((int)(buf[2] - 1000000*((int)(buf[2]/1000000))) / 1000));
    138         }
    139         Nusno ++;
    140         CHECK_REALLOCATE (stars, Stars, NUSNO, Nusno, 5000);
    141       }
    142       free (buffer);
     128      Nusno ++;
     129      CHECK_REALLOCATE (stars, Stars, NUSNO, Nusno, 5000);
    143130    }
     131    free (buffer);
    144132    fclose (f);
    145133  }
     134  REALLOCATE (stars, Stars, Nusno);
    146135
    147   *Nstars = Nusno;
     136  *nstars = Nusno;
    148137  if (VERBOSE) fprintf (stderr, "%d stars from USNO 1.0\n", Nusno);
    149138  return (stars);
     
    151140
    152141
     142
     143
     144/* these entries are legacy code incase you want to read from one of the USNO CDRoms
     145int SPDzone[]  = {0, 75, 450, 375, 1500, 1650, 300, 1425, 1725, 525, 1275, 225, 675, 150, 600, 1575, 750, 975, 900, 1050, 1125, 1200, 825, 1350};
     146int USNOdisk[] = {1,  1,   1,   2,    2,    2,   3,    3,    3,   4,    4,   5,   5,   6,   6,    6,   7,   7,   8,    8,    9,    9,  10,   10};
     147
     148    disk = -1;
     149    for (i = 0; i < NZONE; i++) {
     150      if (spd == SPDzone[i])
     151        disk = USNOdisk[i];
     152    }
     153    if (disk < 0) {
     154      fprintf (stderr, "ERROR: can't find cdrom for spd %d\n",  spd);
     155      exit (1);
     156    }
     157
     158*/
     159
  • trunk/Ohana/src/addstar/src/greference.c

    r5443 r6675  
    1717  if (!strcasecmp (Refcat, "USNO")) {
    1818    stars = getusno (region, photcode, &Nstars);
     19  }
     20
     21  /* get stars from the USNO B catalog for the given region */
     22  if (!strcasecmp (Refcat, "USNOB")) {
     23    stars = getusnob (region, photcode, 2000.0, &Nstars);
     24  }
     25
     26  /* get stars from the USNO B catalog for the given region */
     27  if (!strcasecmp (Refcat, "TYCHO")) {
     28    stars = gettycho (region, photcode, 2000.0, &Nstars);
    1929  }
    2030
Note: See TracChangeset for help on using the changeset viewer.