IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3347


Ignore:
Timestamp:
Mar 1, 2005, 7:15:45 AM (21 years ago)
Author:
eugene
Message:

continuing towards addstar-2-0

Location:
trunk/Ohana/src/addstar
Files:
1 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/include/addstar.h

    r3339 r3347  
    1515  int found;
    1616} Stars;
     17
     18enum {M_IMAGE, M_REFLIST, M_REFCAT};
    1719
    1820/* global variables set in parameter file */
  • trunk/Ohana/src/addstar/src/RegionOps.c

    r3339 r3347  
    100100}
    101101
    102 FindRegionByPoint (double ra, double dec, GSCRegion *gsc, int Ngsc) {
     102int FindRegionByPoint (GSCRegion *regions, double ra, double dec, GSCRegion *gsc, int Ngsc) {
    103103
    104104  Ns = FindRegionDecBandStart (gsc, Ngsc, dec);
     
    109109    if (gsc[i].DEC[0] >= dec) continue;
    110110    if (gsc[i].DEC[1] <  dec) continue;
    111     return (value);
    112   }
    113 
    114  error:
    115   return (-1);
     111    region[0] = gsc[i];
     112    return (TRUE);
     113  }
     114  return (FALSE);
    116115}
    117116
  • trunk/Ohana/src/addstar/src/addstar.c

    r3339 r3347  
    1414  args (argc, argv);
    1515
     16  if (SKYPROBE) load_subpix ();
     17
    1618  lock_image_db ();
    1719
    1820  switch (mode) {
    19   case IMAGE:
     21  case M_IMAGE:
    2022    stars = gstars (argv[1], &Nstars, &image);
    2123    region = gregion_image (&image, &Nregions);
    22     image_db = gimages (&image, &Nimage_db);
     24    overlap = gimages (&image, &Noverlap);
    2325    break;
    24   case REFLIST:
     26  case M_REFLIST:
    2527    stars = grefstars (argv[1], &Nstars);
    2628    region = gregion_stars (stars, &Nregion);
    2729    break;
    28   case PATCH :
     30  case M_REFCAT:
    2931    regions = gregion_patch (patch, &Nregions);
    30     break;
    31   case MATCH:
    32     regions = gregion_match (&Nregions);
     32    if (ONLY_MATCH) {
     33      regions = gregion_match (regions, &Nregions);
     34    }
    3335    break;
    3436  }
     
    3840
    3941    switch (mode) {
    40     case IMAGE:
    41       find_matches (&region[i], stars, Nstars, &catalog, &image, pimage, Nimage);
     42    case M_IMAGE:
     43      find_matches (&region[i], stars, Nstars, &catalog, &image, overlap, Noverlap);
    4244      break;
    43     case PATCH:
    44     case MATCH:
    45       stars = grefcat (region, &Nstars);
    46     case REFLIST:
     45    case M_REFCAT:
     46      stars = grefcat (argv[1], region, &Nstars);
     47    case M_REFLIST:
    4748      subset = find_subset (&region, stars, Nstars, &subref, &Nsubset);
    4849      find_matches_refstars (&region, subset, Nsubset, &catalog);
  • trunk/Ohana/src/addstar/src/args.c

    r3339 r3347  
    2323  }
    2424
    25   /* check for command line options */
    26   VERBOSE = FALSE;
    27   if ((N = get_argument (argc, argv, "-v"))) {
    28     VERBOSE = TRUE;
     25  /*** check for command line options ***/
     26
     27  /* basic mode: image, list, refcat */
     28  mode = M_IMAGE;
     29  if ((N = get_argument (argc, argv, "-ref"))) {
     30    mode = M_REFLIST;
    2931    remove_argument (N, &argc, argv);
    3032  }
    31   ACCEPT_ASTROM = FALSE;
    32   if ((N = get_argument (argc, argv, "-accept"))) {
    33     ACCEPT_ASTROM = TRUE;
     33  if ((N = get_argument (argc, argv, "-cat"))) {
     34    mode = M_REFCAT;
    3435    remove_argument (N, &argc, argv);
    3536  }
    36   thiscode = NULL;
    37   if ((N = get_argument (argc, argv, "-p"))) {
     37
     38  /* restrict to a portion of the sky? (REFCAT only) */
     39  patch.RA[0] = 0;
     40  patch.RA[1] = 360;
     41  patch.DEC[0] = -90;
     42  patch.DEC[1] = +90;
     43  if ((N = get_argument (argc, argv, "-region"))) {
    3844    remove_argument (N, &argc, argv);
    39     thiscode = GetPhotcodebyName (argv[N]);
     45    patch.RA[0] = atof (argv[N]);
     46    patch.RA[1] = atof (argv[N]);
     47    patch.DEC[0] = atof (argv[N]);
     48    patch.DEC[1] = atof (argv[N]);
     49  }
     50 
     51  /* only add to existing objects (REFCAT only) */
     52  ONLY_MATCH = FALSE;
     53  if ((i = get_argument (argc, argv, "-only-match"))) {
     54    ONLY_MATCH = TRUE;
     55    remove_argument (i, &argc, argv);
     56  }
     57  /* don't add missed pts to Missed table */
     58  SKIP_MISSED = FALSE;
     59  if ((N = get_argument (argc, argv, "-missed"))) {
     60    SKIP_MISSED = TRUE;
    4061    remove_argument (N, &argc, argv);
    4162  }
     63  /* replace measurement, don't duplicate */
     64  REPLACE = FALSE;
     65  if ((i = get_argument (argc, argv, "-replace"))) {
     66    REPLACE = TRUE;
     67    remove_argument (i, &argc, argv);
     68  }
     69  /* only add image potion to image table */
    4270  ONLY_IMAGES = FALSE;
    4371  if ((N = get_argument (argc, argv, "-image"))) {
     
    4573    remove_argument (N, &argc, argv);
    4674  }
    47   DUMP_MATCHES = FALSE;
    48   if ((N = get_argument (argc, argv, "-dump"))) {
    49     DUMP_MATCHES = TRUE;
    50     remove_argument (N, &argc, argv);
    51   }
    52   FORCE_READ = FALSE;
    53   if ((N = get_argument (argc, argv, "-force"))) {
    54     FORCE_READ = TRUE;
    55     remove_argument (N, &argc, argv);
    56   }
    57   SKIP_MISSED = FALSE;
    58   if ((N = get_argument (argc, argv, "-missed"))) {
    59     SKIP_MISSED = TRUE;
    60     remove_argument (N, &argc, argv);
    61   }
    62   SKYPROBE = FALSE;
    63   if ((N = get_argument (argc, argv, "-skyprobe"))) {
    64     SKYPROBE = TRUE;
    65     remove_argument (N, &argc, argv);
    66   }
    67   ADDREFS = FALSE;
    68   if ((N = get_argument (argc, argv, "-addrefs"))) {
    69     ADDREFS = TRUE;
    70     remove_argument (N, &argc, argv);
    71   }
    72   REPLACE = FALSE;
    73   if ((i = get_argument (argc, argv, "-replace"))) {
    74     REPLACE = TRUE;
    75     remove_argument (i, &argc, argv);
    76   }
    77   TIMEREF = 0;
    78   if ((i = get_argument (argc, argv, "-time"))) {
    79     remove_argument (i, &argc, argv);
    80     if (!str_to_time (argv[i], &TIMEREF)) {
    81       fprintf (stderr, "syntax error in time\n");
    82       exit (1);
    83     }
    84     remove_argument (i, &argc, argv);
    85   }
    86   ONLY_MATCH = FALSE;
    87   if ((i = get_argument (argc, argv, "-only-match"))) {
    88     ONLY_MATCH = TRUE;
    89     remove_argument (i, &argc, argv);
    90   }
     75  /* apply average zpt offset calibration */
    9176  CALIBRATE = FALSE;
    9277  if ((N = get_argument (argc, argv, "-cal"))) {
     
    10691    remove_argument (N, &argc, argv);
    10792  }
     93
     94  /* treat data specially for skyprobe (calibration, subpix) */
     95  SKYPROBE = FALSE;
     96  if ((N = get_argument (argc, argv, "-skyprobe"))) {
     97    SKYPROBE = TRUE;
     98    remove_argument (N, &argc, argv);
     99  }
     100  ACCEPT_ASTROM = FALSE;
     101  if ((N = get_argument (argc, argv, "-accept"))) {
     102    ACCEPT_ASTROM = TRUE;
     103    remove_argument (N, &argc, argv);
     104  }
     105  DUMP_MATCHES = FALSE;
     106  if ((N = get_argument (argc, argv, "-dump"))) {
     107    DUMP_MATCHES = TRUE;
     108    remove_argument (N, &argc, argv);
     109  }
     110  FORCE_READ = FALSE;
     111  if ((N = get_argument (argc, argv, "-force"))) {
     112    FORCE_READ = TRUE;
     113    remove_argument (N, &argc, argv);
     114  }
     115
     116  VERBOSE = FALSE;
     117  if ((N = get_argument (argc, argv, "-v"))) {
     118    VERBOSE = TRUE;
     119    remove_argument (N, &argc, argv);
     120  }
     121  thiscode = NULL;
     122  if ((N = get_argument (argc, argv, "-p"))) {
     123    remove_argument (N, &argc, argv);
     124    thiscode = GetPhotcodebyName (argv[N]);
     125    remove_argument (N, &argc, argv);
     126  }
     127  TIMEREF = 0;
     128  if ((i = get_argument (argc, argv, "-time"))) {
     129    remove_argument (i, &argc, argv);
     130    if (!str_to_time (argv[i], &TIMEREF)) {
     131      fprintf (stderr, "syntax error in time\n");
     132      exit (1);
     133    }
     134    remove_argument (i, &argc, argv);
     135  }
    108136  if (DUMP_MATCHES && !CALIBRATE) {
    109137    fprintf (stderr, "-dump only valid -with -cal\n");
    110138    exit (1);
    111139  }
    112 
    113   if (SKYPROBE) load_subpix ();
    114140
    115141  if (argc != 2) {
     
    132158    ASCII - RA,DEC,M,dM in a table
    133159
     160    addstar
     161
    134162**/
    135163
  • trunk/Ohana/src/addstar/src/calibrate.c

    r3339 r3347  
    7575  }
    7676  /* create a hash array from Nstar[] entries */
    77   ALLOCATE (Nlist, int, MAX (1, MaxN + 1));
     77  ALLOCATE (Nlist, int, MaxN + 1);
    7878  bzero (Nlist, MAX (0, MaxN*sizeof(int)));
    7979  for (i = 0; i < Ncal; i++) {
  • trunk/Ohana/src/addstar/src/find_matches.c

    r3339 r3347  
    55((R) >= region[0].RA[0])  && ((R) < region[0].RA[1]))
    66
    7 void find_matches (GSCRegion *region, Stars *stars, int Nstars, Catalog *catalog, Image *image, Image *pimage, int Nimage) {
     7void find_matches (GSCRegion *region, Stars *stars, int Nstars, Catalog *catalog, Image *image, Image *overlap, int Noverlap) {
    88
    99  double secz;
     
    360360
    361361      /** now add references from all previous non-detection observations of this spot on the sky */
    362       for (j = 0; (j < Nimage) && !SKIP_MISSED; j++) {
    363         if (in_image (catalog[0].average[Nave].R, catalog[0].average[Nave].D, &pimage[j])) {
     362      for (j = 0; (j < Noverlap) && !SKIP_MISSED; j++) {
     363        if (in_image (catalog[0].average[Nave].R, catalog[0].average[Nave].D, &overlap[j])) {
    364364          if (catalog[0].average[Nave].Nn < 1) {
    365365            catalog[0].average[Nave].missing = Nmiss;
     
    369369          last_miss = Nmiss;
    370370          /* this can now be done exactly */
    371           RD_to_XY (&X, &Y, catalog[0].average[Nave].R, catalog[0].average[Nave].D, &pimage[j].coords);   
    372           catalog[0].missing[Nmiss].t  = pimage[j].tzero + 1e-4*Y*pimage[j].trate;  /* rough guess at time */
     371          RD_to_XY (&X, &Y, catalog[0].average[Nave].R, catalog[0].average[Nave].D, &overlap[j].coords);         
     372          catalog[0].missing[Nmiss].t  = overlap[j].tzero + 1e-4*Y*overlap[j].trate;  /* rough guess at time */
    373373          catalog[0].average[Nave].Nn ++;
    374374          Nmiss ++;
  • trunk/Ohana/src/addstar/src/find_matches_refstars.c

    r3339 r3347  
    1818  int Nsecfilt, Nsec;
    1919
    20   /* photcode data */
     20  /* photcode data -- should not have to modify secfilt / average */
    2121  Nsecfilt = GetPhotcodeNsecfilt ();
    2222  Nsec     = GetPhotcodeNsec (thiscode[0].code);
  • trunk/Ohana/src/addstar/src/get2mass.c

    r3339 r3347  
    2121    Nstars += Ngsc;
    2222
    23     REALLOCATE (stars, StarData, MAX (1, Nstars));
     23    REALLOCATE (stars, StarData, Nstars);
    2424    for (k = Ns, j = 0; j < Ngsc; k++, j++) {
    2525      stars[k].R = gsc[j].R;
  • trunk/Ohana/src/addstar/src/getgsc.c

    r3339 r3347  
    2121    Nstars += Ngsc;
    2222
    23     REALLOCATE (stars, StarData, MAX (1, Nstars));
     23    REALLOCATE (stars, StarData, Nstars);
    2424    for (k = Ns, j = 0; j < Ngsc; k++, j++) {
    2525      stars[k].R   = gsc[j].R;
  • trunk/Ohana/src/addstar/src/getusno.c

    r3339 r3347  
    99  1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10};
    1010
    11 StarData *getusno (CatStats *catstats, int *Nstars) {
     11Stars *getusno (CatStats *catstats, int *Nstars) {
    1212
    1313  long int offset;
     
    2121  int spd, spd_start, spd_end, disk;
    2222  int NUSNO, Nusno;
    23   StarData *stars;
     23  Stars *stars;
    2424
    2525  /** USNO-specific things **/
     
    5757  Nusno = 0;
    5858  NUSNO = 5000;
    59   ALLOCATE (stars, StarData, NUSNO);
     59  ALLOCATE (stars, Stars, NUSNO);
    6060
    6161  for (spd = spd_start; spd < spd_end; spd += 75) {
     
    125125        if ((buf[0] > iRA0) && (buf[0] < iRA1) &&
    126126            (buf[1] > iDEC0) && (buf[1] < iDEC1)) {
    127           bzero (&stars[Nusno], sizeof(StarData));
     127          bzero (&stars[Nusno], sizeof(Stars));
    128128          stars[Nusno].R = buf[0]/360000.0;
    129129          stars[Nusno].D = buf[1]/360000.0 - 90.0;
    130130          stars[Nusno].Mag = fabs (0.1*(buf[2] - 1000*((int)(buf[2]/1000))));
    131           /* b = 0.1*((int)(buf[2] - 1000000*((int)(buf[2]/1000000))) / 1000); */
     131          stars[Nusno].code = USNO_RED;
     132          /* r data */
    132133          Nusno ++;
    133           if (Nusno == NUSNO) {
    134             NUSNO += 5000;
    135             REALLOCATE (stars, StarData, NUSNO);
    136           }       
     134          stars[Nusno].R = buf[0]/360000.0;
     135          stars[Nusno].D = buf[1]/360000.0 - 90.0;
     136          stars[Nusno].Mag = fabs (0.1*((int)(buf[2] - 1000000*((int)(buf[2]/1000000))) / 1000));
     137          stars[Nusno].code = USNO_BLUE;
     138          /* b data */
     139          Nusno ++;
     140          CHECK_REALLOCATE (stars, Stars, NUSNO, Nusno-1, 5000);
    137141        }
    138142      }
  • trunk/Ohana/src/addstar/src/greference.c

    r3339 r3347  
    11# include "addstar.h"
    22
    3 Stars *grefcat (CatStats *catstats, int *Nrefcat) {
     3Stars *grefcat (char *Refcat, CatStats *catstats, int *Nrefcat) {
    44
    55  int Nstars;
    66  Stars *stars;
    77
    8   if (VERBOSE) fprintf (stderr, "loading astrometric reference data from %s\n", REFCAT);
     8  if (VERBOSE) fprintf (stderr, "loading reference catalog data from %s\n", Refcat);
    99
    1010  Nstars = 0;
     
    1212
    1313  /* get stars from USNO for the given region */
    14   if (!strcmp (REFCAT, "USNO")) {
     14  if (!strcmp (Refcat, "USNO")) {
    1515    stars = getusno (catstats, &Nstars);
    1616  }
    1717
    1818  /* get stars from HST GSC for the given region */
    19   if (!strcmp (REFCAT, "GSC")) {
     19  if (!strcmp (Refcat, "GSC")) {
    2020    stars = getgsc (catstats, &Nstars);
    2121  }
    2222 
    2323  /* get stars from 2MASS for the given region */
    24   if (!strcmp (REFCAT, "2MASS")) {
     24  if (!strcmp (Refcat, "2MASS")) {
    2525    stars = get2mass (catstats, &Nstars);
    2626  }
    2727 
    2828  if (Nstars == 0) {
    29     fprintf (stderr, "no ref objs: %s\n", REFCAT);
     29    fprintf (stderr, "no ref objs: %s\n", Refcat);
    3030    exit (1);
    3131  }
  • trunk/Ohana/src/addstar/src/grefstars.c

    r3339 r3347  
    2121  ALLOCATE (stars, Stars, NSTARS);
    2222
     23  /* require photcode */
     24  if (thiscode == NULL) {
     25    fprintf (stderr, "error: photcode not specified\n");
     26    exit (2);
     27  }
     28
    2329  /* read in stars line-by-line */
    2430  for (N = 0; scan_line (f, line) != EOF; N++) {
     
    3440    stars[N].dophot = 0;
    3541    stars[N].found = -1;
    36     if (N == NSTARS - 1) {
    37       NSTARS += 100;
    38       REALLOCATE (stars, Stars, NSTARS);
    39     }
     42    stars[N].code = thiscode[0].code;;
     43    CHECK_REALLOCATE (stars, Stars, NSTARS, N+1, 100);
    4044  }
    4145  *Nstars = N;
     
    4347}
    4448
     49/* add the photcode here */
  • trunk/Ohana/src/addstar/src/gregion_image.c

    r3339 r3347  
    1717 
    1818  /* find regions at image corners */
    19   NREGION = 10;
     19  NREGION = 100;
    2020  ALLOCATE (region, GSCRegion, NREGION);
    2121  nregion = 0;
     
    3535      }
    3636      nregion ++;
    37       if (nregion == NREGION) {
    38         NREGION += 10;
    39         REALLOCATE (region, GSCRegion, NREGION);
    40       }
     37      CHECK_REALLOCATE (region, GSCRegion, NREGION, nregion, 100);
    4138    }
    4239  }
  • trunk/Ohana/src/addstar/src/gregion_match.c

    r3339 r3347  
    11# include "addstar.h"
    2 # include <glob.h>
    32
    4 GSCRegion *gregion_match (int *nregions) {
     3GSCRegion *gregion_match (GSCRegion *regions, int *nregions) {
    54 
    65  int i;
    7   int    Ngsc, Nregions;
    8   glob_t pglob;
     6  int       Nsubset;
     7  GSCRegion *subset;
     8  struct stat filestats;
     9 
     10  Nregions = *nregions;
    911
    10   GSCRegion *gsc, *regions;
    11  
    12   gsc = LoadRegions (&Ngsc);
    13 
    14   sprintf (globline, "%s/[nsNS]????/*.cpt", CATDIR);
    15   pglob.gl_offs = 0;
    16   glob (globline, 0, NULL, &pglob);
    17 
    18   Nregions = 0;
    19   ALLOCATE (regions, GSCRegions, MAX (1, pglob.gl_pathc));
     12  Nsubset = 0;
     13  NSUBSET = 100;
     14  ALLOCATE (subset, GSCRegions, NSUBSET);
    2015
    2116  /* match the basename against the GSCRegion file names */
    22   for (i = 0; i < pglob.gl_pathc; i++) {
    23     found = FALSE;
    24     for (j = 0; !found && (j < Ngsc); j++) {
    25       if (strcasecmp (pglob.gl_pathv, gsc[j].filename)) continue;
    26       regions[Nregions] = gsc[j];
    27       found = TRUE;
    28     }
     17  for (i = 0; i < Nregions; i++) {
     18    status = stat (regions[i].filename, &filestats);
     19    if ((status == -1) && (errno == ENOENT)) continue;
     20    /* give an error for other conditions? */
     21
     22    subset[Nsubset] = regions[i];
     23    Nsubset ++;
     24    CHECK_ALLOCATE (subset, GSCRegion, NSUBSET, Nsubset, 100);
    2925  }
    30   *nregions = Nregions;
    31   return (regions);
    32  
    33   /* should free things up here */
     26  free (regions);
     27
     28  *nregions = Nsubset;
     29  return (subset);
    3430}
    35 
    36 /* given a ra,dec bounded region, find all region files which overlap it
    37 
    38    - split region into two if overlapping 0,360 boundary
    39 
    40 */
    41 
    42 /* the goal here is to return a list of the existing region files
    43    this means either:
    44 
    45       grabbing all files that are on disk and converting
    46       them to GSCRegion files
    47 
    48       trying all GSCRegion files to see if they exist
    49       (and are populated?)
    50      
    51 */
  • trunk/Ohana/src/addstar/src/gregion_patch.c

    r3339 r3347  
    1414 
    1515  Nregions = 0;
    16   ALLOCATE (regions, GSCRegions, MAX (1, (Ne - Ns)));
     16  ALLOCATE (regions, GSCRegions, (Ne - Ns));
    1717
    1818  /* find all regions in range within ra range */
  • trunk/Ohana/src/addstar/src/gregion_star.c

    r3339 r3347  
    44 
    55  int i;
    6   int       Ngsc;
    7   GSCRegion *gsc;
     6  int       Ngsc, Nregions, NREGIONS;
     7  GSCRegion *gsc, regions;
    88 
    99  gsc = LoadRegions (&Ngsc);
     10
     11  Nregions = 0;
     12  NREGIONS = 100;
     13  ALLOCATE (region, GSCRegion, NREGIONS);
    1014
    1115  sort_stars (stars, Nstars);
    1216  for (i = 0; i < Nstars; i++) {
    1317    if (stars[0].found) continue;
    14     region = FindRegionByPoint (star[0].R, star[0].D, gsc, Ngsc);
     18    FindRegionByPoint (&regions[Nregions], star[0].R, star[0].D, gsc, Ngsc);
    1519    stars[0].found = TRUE;
    1620    /* search forward for all contained stars */
    1721    for (j = i; j < Nstars; j++) {
    18       if (stars[j].R >= region.RA[1]) break;
    19       if (stars[j].D <  region.DEC[0]) continue;
    20       if (stars[j].D >= region.DEC[1]) continue;
     22      if (stars[j].R >= regions.RA[1]) break;
     23      if (stars[j].D <  regions.DEC[0]) continue;
     24      if (stars[j].D >= regions.DEC[1]) continue;
    2125      stars[j].found = TRUE;
    2226    }
     27    Nregions ++;
     28    CHECK_REALLOCATE (regions, GSCRegion, Nregions, NREGIONS, 100);
    2329  }
    2430
    2531}
    26 
    2732
    2833/* given a list of stars, find all region files which contain them
     
    4045
    4146*/
    42 
    43    
  • trunk/Ohana/src/addstar/src/gstars.c

    r3339 r3347  
    244244  return (stars);
    245245}
    246 
    247 # if (0)
    248   /* left over fraction of a block */
    249   nbytes = Fread (buffer, 1, (Nbytes % (BLOCK*BYTES_STAR)), f, "char");
    250   if (nbytes != (Nbytes % (BLOCK*BYTES_STAR))) {
    251     fprintf (stderr, "ERROR: failed to read in stars (2)\n");
    252     exit (1);
    253   }
    254   /* check line-by-line integrity */
    255   Nnew = 0;
    256   c = buffer;
    257   done = FALSE;
    258   while ((c < buffer + nbytes) && (!done)) {
    259     for (c2 = c; *c2 == '\n'; c2++);
    260     if (c2 > c) { /* extra return chars */
    261       memmove (c, c2, (int)(buffer + nbytes - c2));
    262       Nnew += c2 - c;
    263       fprintf (stderr, "deleting %d extra return chars\n", (int)(c2-c));
    264     }
    265     c2 = strchr (c, '\n');
    266     if (c2 == (char *) NULL) {
    267       if (Nnew > 0) {
    268         nnew = Fread (&buffer[nbytes-Nnew], 1, Nnew, f, "char");
    269         if (nnew != Nnew) {
    270           fprintf (stderr, "ERROR: failed to read in stars (1)\n");
    271           exit (1);
    272         }
    273       } else {
    274         done = TRUE;   
    275       }
    276       continue;
    277     }
    278     c2++;
    279     if ((c2 - c) != BYTES_STAR) {
    280       /* this is a bad line, delete it, adjust data in buffer,
    281          and be ready to read the rest of the last line */
    282       memmove (c, c2, (int)(buffer + nbytes - c2));
    283       Nnew += c2 - c;
    284       fprintf (stderr, "deleting bad line with %d chars\n", (int)(c2-c));
    285     } else {
    286       c = c2;
    287     }
    288   }
    289   for (j = 0; j < nbytes / BYTES_STAR; j++, nstar++, N++) {
    290     dparse (&stars[N].X, 1, &buffer[j*BYTES_STAR]);
    291     dparse (&stars[N].Y, 2, &buffer[j*BYTES_STAR]);
    292     dparse (&stars[N].M, 3, &buffer[j*BYTES_STAR]);
    293     dparse (&stars[N].dM, 4, &buffer[j*BYTES_STAR]);
    294     XY_to_RD (&stars[N].R, &stars[N].D, stars[N].X, stars[N].Y, &image[0].coords);
    295     while (stars[N].R < 0.0) stars[N].R += 360.0;
    296     while (stars[N].R >= 360.0) stars[N].R -= 360.0;
    297     dparse (&tmp, 5, &buffer[j*BYTES_STAR]);
    298     stars[N].dophot = tmp;
    299     stars[N].found = -1;
    300   }
    301 
    302 # endif
Note: See TracChangeset for help on using the changeset viewer.