IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5443


Ignore:
Timestamp:
Oct 24, 2005, 10:36:17 AM (21 years ago)
Author:
eugene
Message:

adding SkyRegion support to addstar (removing GSCRegion)

Location:
trunk/Ohana/src/addstar
Files:
2 added
19 edited

Legend:

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

    r5347 r5443  
    4444$(SRC)/greference.$(ARCH).o \
    4545$(SRC)/grefstars.$(ARCH).o \
    46 $(SRC)/gregion_image.$(ARCH).o \
    47 $(SRC)/gregion_match.$(ARCH).o \
    48 $(SRC)/gregion_patch.$(ARCH).o \
    49 $(SRC)/gregion_star.$(ARCH).o \
    5046$(SRC)/gstars.$(ARCH).o \
    5147$(SRC)/image-db.$(ARCH).o \
     
    5652$(SRC)/opening_angle.$(ARCH).o \
    5753$(SRC)/parse_time.$(ARCH).o \
    58 $(SRC)/RegionOps.$(ARCH).o \
    5954$(SRC)/replace_match.$(ARCH).o \
    6055$(SRC)/SetSignals.$(ARCH).o \
     
    6358$(SRC)/wcatalog.$(ARCH).o \
    6459$(SRC)/Shutdown.$(ARCH).o \
     60$(SRC)/SkyRegionUtils.$(ARCH).o \
     61$(SRC)/SkyListForStars.$(ARCH).o \
    6562$(SRC)/rfits.$(ARCH).o \
    6663$(SRC)/rtext.$(ARCH).o
     64
     65GSC-OPS = \
     66$(SRC)/RegionOps.$(ARCH).o \
     67$(SRC)/gregion_image.$(ARCH).o \
     68$(SRC)/gregion_match.$(ARCH).o \
     69$(SRC)/gregion_patch.$(ARCH).o \
     70$(SRC)/gregion_star.$(ARCH).o
    6771
    6872MKACC-2MASS = \
  • trunk/Ohana/src/addstar/include/2mass.h

    r5328 r5443  
    99short TM_J, TM_H, TM_K;
    1010
    11 GSCRegion *get2mass_acc (GSCRegion *patch, int *nfiles, char *path, char *accel);
    12 Stars *get2mass_2DR_data (GSCRegion *region, GSCRegion *patch, int photcode, int *nstars);
    13 Stars *get2mass_AS_data (GSCRegion *region, GSCRegion *patch, int phocode, int *nstars);
     11SkyTable *get2mass_acc (SkyRegion *patch, char *path, char *accel);
     12Stars *get2mass_2DR_data (SkyRegion *region, SkyRegion *patch, int photcode, int *nstars);
     13Stars *get2mass_AS_data (SkyRegion *region, SkyRegion *patch, int phocode, int *nstars);
  • trunk/Ohana/src/addstar/include/addstar.h

    r5347 r5443  
    1111/* used in find_matches, find_matches_refstars */
    1212# define IN_CATALOG(R,D) ( \
    13 ((D) >= region[0].DEC[0]) && ((D) < region[0].DEC[1]) && \
    14 ((R) >= region[0].RA[0])  && ((R) < region[0].RA[1]))
     13((D) >= region[0].Dmin) && ((D) < region[0].Dmax) && \
     14((R) >= region[0].Rmin)  && ((R) < region[0].Rmax))
    1515
    1616/* grab named photcode */
     
    3939char   HOSTNAME[80];
    4040int    NVALID, *VALID_IP;
     41int    SKY_DEPTH;  /** XXX EAM : depth of catalog tables, fix usage */
    4142
    4243/* used to select entries from header (gstars or parse_time) (KEEP) */
     
    7980/* these depend on HOW we implement the client/server interaction for CAT/REF modes */
    8081time_t    TIMEREF;    // used by MODE REF
    81 GSCRegion UserPatch;  // used by MODE CAT
     82SkyRegion UserPatch;  // used by MODE CAT
    8283char     *SELECT_2MASS_QUALITY;  // used only by get2mass_as
    8384
     
    8687AddstarClientOptions ConfigInit   PROTO((int *argc, char **argv));
    8788void       FindCalibration        PROTO((Image *image));
    88 int        FindDecBand            PROTO((double dec, double *DEC0, double *DEC1));
    89 int        FindRegionByPoint      PROTO((GSCRegion *regions, double ra, double dec, GSCRegion *gsc, int Ngsc));
    90 int        FindRegionDecBandStart PROTO((GSCRegion *region, int Nregion, double dec));
    91 int        FindRegionDecBandStop  PROTO((GSCRegion *region, int Nregion, double dec));
    9289FILE      *GetDB                  PROTO((int *state));
    9390void       InitCalibration        PROTO(());
    94 GSCRegion *LoadRegions            PROTO((int *nregions));
    9591void       SaveCalibration        PROTO((float M, float dM, float Mr, float dMr, float Mc, float A, int N));
    9692void       SetProtect             PROTO((int mode));
     
    10096float      airmass                PROTO((float secz_image, double ra, double dec, double st, double latitude));
    10197void       SetAirmassQuality      PROTO((int quality));
    102 void       aregion                PROTO((GSCRegion *region, FILE *f, double ra, double dec));
    10398AddstarClientOptions args         PROTO((int argc, char **argv, AddstarClientOptions options));
    10499void       check_permissions      PROTO((char *basefile));
    105100int        dump_rawstars          PROTO((Stars *stars, int Nstars));
    106101int        edge_check             PROTO((double *x1, double *y1, double *x2, double *y2));
    107 void       find_matches           PROTO((GSCRegion *region, Stars *stars, int Nstars, Catalog *catalog, Image *image, Image *overlap, int Noverlap, Coords *mosaic, AddstarClientOptions options));
    108 void       find_matches_closest   PROTO((GSCRegion *region, Stars *stars, int Nstars, Catalog *catalog, Image *image, Image *overlap, int Noverlap, Coords *mosaic, AddstarClientOptions options));
    109 void       find_matches_refstars  PROTO((GSCRegion *region, Stars **stars, int Nstars, Catalog *catalog, AddstarClientOptions options));
    110 Stars    **find_subset            PROTO((GSCRegion *region, Stars *stars, int Nstars, int *NSTARS));
     102void       find_matches           PROTO((SkyRegion *region, Stars *stars, int Nstars, Catalog *catalog, Image *image, Image *overlap, int Noverlap, Coords *mosaic, AddstarClientOptions options));
     103void       find_matches_closest   PROTO((SkyRegion *region, Stars *stars, int Nstars, Catalog *catalog, Image *image, Image *overlap, int Noverlap, Coords *mosaic, AddstarClientOptions options));
     104void       find_matches_refstars  PROTO((SkyRegion *region, Stars **stars, int Nstars, Catalog *catalog, AddstarClientOptions options));
     105Stars    **find_subset            PROTO((SkyRegion *region, Stars *stars, int Nstars, int *NSTARS));
    111106int        gcatalog               PROTO((Catalog *catalog));
    112 Stars     *get2mass               PROTO((GSCRegion *patch, int photcode, int mode, int *NSTARS));
     107Stars     *get2mass               PROTO((SkyRegion *patch, int photcode, int mode, int *NSTARS));
    113108double     get_subpix             PROTO((double x, double y));
    114 Stars     *getgsc                 PROTO((GSCRegion *patch, int *NSTARS));
    115 Stars     *getusno                PROTO((GSCRegion *catstats, int photcode, int *Nstars));
     109Stars     *getgsc                 PROTO((SkyRegion *patch, int *NSTARS));
     110Stars     *getusno                PROTO((SkyRegion *catstats, int photcode, int *Nstars));
    116111Image     *gimages                PROTO((FITS_DB *db, Image *image, Coords *mosaic, int *Npimage));
    117 Stars     *grefcat                PROTO((char *Refcat, GSCRegion *catstats, int photcode, int *nstars));
     112Stars     *grefcat                PROTO((char *Refcat, SkyRegion *catstats, int photcode, int *nstars));
    118113Stars     *grefstars              PROTO((char *file, int photcode, int *Nstars));
    119 GSCRegion *gregion_image          PROTO((Image *image, Coords *mosaic, int *Nregions));
    120 GSCRegion *gregion_match          PROTO((GSCRegion *regions, int *nregions));
    121 GSCRegion *gregion_patch          PROTO((GSCRegion *patch, int *nregions));
    122 void       gregion_star           PROTO((Stars *star, GSCRegion *region));
    123 GSCRegion *gregion_stars          PROTO((Stars *stars, int Nstars, int *Nregion));
    124 GSCRegion *gregions               PROTO((Image *image, int *Nregions));
    125114Stars     *gstars                 PROTO((char *file, int *NSTARS, int photcode, Image *image));
    126115void       help                   PROTO(());
    127116int        in_image               PROTO((double r, double d, Image *image));
    128 int        load_pt_catalog        PROTO((Catalog *catalog, GSCRegion *region));  /*** choose new name ***/
     117int        load_pt_catalog        PROTO((Catalog *catalog, SkyRegion *region));  /*** choose new name ***/
    129118void       load_subpix            PROTO(());
    130119void       lock_image_db          PROTO((FITS_DB *db, char *filename));
     
    132121void       make_backup            PROTO((char *filename));
    133122int        match_refstars         PROTO((Stars *stars, int Nstars));
    134 void       mkcatalog              PROTO((GSCRegion *region, Catalog *catalog));
     123void       mkcatalog              PROTO((SkyRegion *region, Catalog *catalog));
    135124double     opening_angle          PROTO((double x1, double y1, double x2, double y2, double x3, double y3));
    136125int        parse_time             PROTO((Header *header));
     
    165154Missing *sort_missing (Average *average, int Naverage, Missing *missing, int Nmissing, int *next_miss);
    166155
     156GSCRegion *LoadRegions            PROTO((int *nregions));
     157int        FindDecBand            PROTO((double dec, double *DEC0, double *DEC1));
     158int        FindRegionByPoint      PROTO((GSCRegion *regions, double ra, double dec, GSCRegion *gsc, int Ngsc));
     159int        FindRegionDecBandStart PROTO((GSCRegion *region, int Nregion, double dec));
     160int        FindRegionDecBandStop  PROTO((GSCRegion *region, int Nregion, double dec));
     161void       aregion                PROTO((GSCRegion *region, FILE *f, double ra, double dec));
     162GSCRegion *gregion_image          PROTO((Image *image, Coords *mosaic, int *Nregions));
     163GSCRegion *gregion_match          PROTO((GSCRegion *regions, int *nregions));
     164GSCRegion *gregion_patch          PROTO((GSCRegion *patch, int *nregions));
     165void       gregion_star           PROTO((Stars *star, GSCRegion *region));
     166GSCRegion *gregion_stars          PROTO((Stars *stars, int Nstars, int *Nregion));
     167GSCRegion *gregions               PROTO((Image *image, int *Nregions));
     168
    167169/**
    168170  there is an inconsistency to be resolved: fixed structures (like Image)
     
    192194int UpdateDatabase_Reflist (AddstarClientOptions *options, Stars *stars, int Nstars);
    193195int UpdateDatabase_Refcat (AddstarClientOptions *options, GSCRegion *UserPatch, char *refcat);
     196
     197SkyList *SkyListForStars (SkyTable *table, int depth, Stars *stars, int Nstars);
     198SkyList *SkyListExistingSubset (SkyList *input);
     199int SkyListSetPath (SkyList *list, char *path);
  • trunk/Ohana/src/addstar/src/ConfigInit.c

    r5347 r5443  
    5656  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
    5757  ScanConfig (config, "PHOTCODE_FILE",          "%s",  0, PhotCodeFile);
     58  if (!ScanConfig (config, "SKY_DEPTH",         "%d",  0, &SKY_DEPTH)) {
     59    SKY_DEPTH = 2;
     60  }
    5861
    5962  /* used by client/server setup */
  • trunk/Ohana/src/addstar/src/addstar.c

    r5328 r5443  
    77  Stars *stars, **subset;
    88  Image image, *overlap;
    9   GSCRegion *regions;
    109  Catalog catalog;
    1110  FITS_DB db;
    1211  AddstarClientOptions options;
     12
     13  SkyTable *sky;
     14  SkyList *skylist;
     15  SkyRegion *regions;
    1316
    1417  double dtime;
     
    2023  options = ConfigInit (&argc, argv);
    2124  options = args (argc, argv, options);
     25
     26  sky = SkyTableFromGSC (GSCFILE, SKY_DEPTH, VERBOSE);
    2227
    2328  stars = NULL;
     
    4146    stars = gstars (argv[1], &Nstars, options.photcode, &image);
    4247    if ((DUMP != NULL) && !strcmp (DUMP, "rawstars")) dump_rawstars (stars, Nstars);
    43     regions = gregion_image (&image, MOSAIC, &Nregions);
    44     /* lock_image_db (&db, ImageCat); */
     48    skylist = SkyListByImage (sky, -1, &image, MOSAIC);
    4549    overlap = gimages (&db, &image, MOSAIC, &Noverlap);
    46     /* unlock_image_db (&db); */
    4750    break;
    4851  case M_REFLIST:
    4952    stars = grefstars (argv[1], options.photcode, &Nstars);
    50     regions = gregion_stars (stars, Nstars, &Nregions);
     53    skylist = SkyListForStars (sky, -1, stars, Nstars);
    5154    break;
    5255  case M_REFCAT:
    53     regions = gregion_patch (&UserPatch, &Nregions);
     56    skylist = SkyListByPatch (sky, -1, &UserPatch);
    5457    break;
    5558  }
     59  SkyListSetPath (skylist, CATDIR);
    5660  if (options.only_match || options.existing_regions) {
    57     regions = gregion_match (regions, &Nregions);
     61    SkyList *tmp;
     62    tmp = SkyListExistingSubset (skylist);
     63    SkyListFree (skylist);
     64    skylist = tmp;
    5865  }
    59   if (VERBOSE) fprintf (stderr, "writing to %d regions\n", Nregions);
     66  if (VERBOSE) fprintf (stderr, "writing to %d regions\n", skylist[0].Nregions);
    6067
    6168  gettimeofday (&stop, NULL);
     
    6471
    6572  Naverage = Nmeasure = 0;
    66   for (i = 0; i < Nregions; i++) {
     73  for (i = 0; i < skylist[0].Nregions; i++) {
    6774
    6875    gettimeofday (&t1, NULL);
    6976
    70     load_pt_catalog (&catalog, &regions[i]);
     77    load_pt_catalog (&catalog, skylist[0].regions[i]);
    7178
    7279    /* for only_match, skip empty catalogs XXX EAM : this leaves behind empty files */
     
    93100      Nsubset = Nstars;
    94101      if (options.closest) {
    95         find_matches_closest (&regions[i], stars, Nstars, &catalog, &image, overlap, Noverlap, MOSAIC, options);
     102        find_matches_closest (skylist[0].regions[i], stars, Nstars, &catalog, &image, overlap, Noverlap, MOSAIC, options);
    96103      } else {
    97         find_matches (&regions[i], stars, Nstars, &catalog, &image, overlap, Noverlap, MOSAIC, options);
     104        find_matches (skylist[0].regions[i], stars, Nstars, &catalog, &image, overlap, Noverlap, MOSAIC, options);
    98105      }
    99106      break;
    100107    case M_REFCAT:
    101       stars = grefcat (argv[1], &regions[i], options.photcode, &Nstars);
     108      stars = grefcat (argv[1], skylist[0].regions[i], options.photcode, &Nstars);
    102109    case M_REFLIST:
    103       subset = find_subset (&regions[i], stars, Nstars, &Nsubset);
    104       find_matches_refstars (&regions[i], subset, Nsubset, &catalog, options);
     110      subset = find_subset (skylist[0].regions[i], stars, Nstars, &Nsubset);
     111      find_matches_refstars (skylist[0].regions[i], subset, Nsubset, &catalog, options);
    105112      if (Nsubset) free (subset);
    106113      break;
  • trunk/Ohana/src/addstar/src/args.c

    r5328 r5443  
    2828  /*** provide additional data ***/
    2929  /* restrict to a portion of the sky? (REFCAT only) */
    30   UserPatch.RA[0] = 0;
    31   UserPatch.RA[1] = 360;
    32   UserPatch.DEC[0] = -90;
    33   UserPatch.DEC[1] = +90;
     30  UserPatch.Rmin = 0;
     31  UserPatch.Rmax = 360;
     32  UserPatch.Dmin = -90;
     33  UserPatch.Dmax = +90;
    3434  if ((N = get_argument (argc, argv, "-region"))) {
    3535    remove_argument (N, &argc, argv);
    36     UserPatch.RA[0] = atof (argv[N]);
    37     remove_argument (N, &argc, argv);
    38     UserPatch.RA[1] = atof (argv[N]);
    39     remove_argument (N, &argc, argv);
    40     UserPatch.DEC[0] = atof (argv[N]);
    41     remove_argument (N, &argc, argv);
    42     UserPatch.DEC[1] = atof (argv[N]);
     36    UserPatch.Rmin = atof (argv[N]);
     37    remove_argument (N, &argc, argv);
     38    UserPatch.Rmax = atof (argv[N]);
     39    remove_argument (N, &argc, argv);
     40    UserPatch.Dmin = atof (argv[N]);
     41    remove_argument (N, &argc, argv);
     42    UserPatch.Dmax = atof (argv[N]);
    4343    remove_argument (N, &argc, argv);
    4444  }
  • trunk/Ohana/src/addstar/src/find_matches.c

    r5347 r5443  
    11# include "addstar.h"
    22
    3 void find_matches (GSCRegion *region, Stars *stars, int Nstars, Catalog *catalog, Image *image, Image *overlap, int Noverlap, Coords *mosaic, AddstarClientOptions options) {
     3void find_matches (SkyRegion *region, Stars *stars, int Nstars, Catalog *catalog, Image *image, Image *overlap, int Noverlap, Coords *mosaic, AddstarClientOptions options) {
    44
    55  int i, j, n, N, J;
  • trunk/Ohana/src/addstar/src/find_matches_closest.c

    r5381 r5443  
    11# include "addstar.h"
    22
    3 void find_matches_closest (GSCRegion *region, Stars *stars, int Nstars, Catalog *catalog, Image *image, Image *overlap, int Noverlap, Coords *mosaic, AddstarClientOptions options) {
     3void find_matches_closest (SkyRegion *region, Stars *stars, int Nstars, Catalog *catalog, Image *image, Image *overlap, int Noverlap, Coords *mosaic, AddstarClientOptions options) {
    44
    55  int i, j, n, N, J, Jmin;
  • trunk/Ohana/src/addstar/src/find_matches_refstars.c

    r5322 r5443  
    11# include "addstar.h"
    22
    3 void find_matches_refstars (GSCRegion *region, Stars **stars, int Nstars, Catalog *catalog, AddstarClientOptions options) {
     3void find_matches_refstars (SkyRegion *region, Stars **stars, int Nstars, Catalog *catalog, AddstarClientOptions options) {
    44
    55  int i, j, k, n, m, N, J;
     
    4646  /* project onto rectilinear grid with 1 arcsec pixels, sort by X */
    4747  /* reference for coords is catalog center */
    48   tcoords.crval1 = 0.5*(region[0].RA[0] + region[0].RA[1]);
    49   tcoords.crval2 = 0.5*(region[0].DEC[0] + region[0].DEC[1]);
     48  tcoords.crval1 = 0.5*(region[0].Rmin + region[0].Rmax);
     49  tcoords.crval2 = 0.5*(region[0].Dmin + region[0].Dmax);
    5050  tcoords.crpix1 = tcoords.crpix2 = 0.0;
    5151  tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0;
  • trunk/Ohana/src/addstar/src/find_subset.c

    r3361 r5443  
    22
    33/* find stars within this region */
    4 Stars **find_subset (GSCRegion *region, Stars *stars, int Nstars, int *Nsubset) {
     4Stars **find_subset (SkyRegion *region, Stars *stars, int Nstars, int *Nsubset) {
    55
    66  int i, N, NSUBSET;
     
    1111  ALLOCATE (subset, Stars *, NSUBSET);
    1212
    13   RA0  = region[0].RA[0];
    14   RA1  = region[0].RA[1];
    15   DEC0 = region[0].DEC[0];
    16   DEC1 = region[0].DEC[1];
     13  RA0  = region[0].Rmin;
     14  RA1  = region[0].Rmax;
     15  DEC0 = region[0].Dmin;
     16  DEC1 = region[0].Dmax;
    1717
    1818  if (VERBOSE) fprintf (stderr, "subset for %f - %f, %f - %f\n", RA0, RA1, DEC0, DEC1);
  • trunk/Ohana/src/addstar/src/get2mass.c

    r5386 r5443  
    22# include "2mass.h"
    33
    4 Stars *get2mass (GSCRegion *patch, int photcode, int mode, int *NSTARS) {
     4Stars *get2mass (SkyRegion *patch, int photcode, int mode, int *NSTARS) {
    55 
    66  char *path;
    7   int i, Nstars, Nrefcat, Nregions;
    8   Stars     *stars;
    9   Stars     *refcat;
    10   GSCRegion *regions;
     7  int i, Nstars, Nrefcat;
     8  Stars    *stars;
     9  Stars    *refcat;
     10  SkyTable *sky;
    1111
    1212  NAMED_PHOTCODE (TM_J, "2MASS_J");
     
    2222  if (mode == 1) path = TWO_MASS_DIR_DR2;
    2323
    24   regions = get2mass_acc (patch, &Nregions, path, "accel.dat");
     24  sky = get2mass_acc (patch, path, "accel.dat");
    2525 
    2626  Nstars = 0;
    2727  ALLOCATE (stars, Stars, 1);
    2828
    29   for (i = 0; i < Nregions; i++) {
     29  for (i = 0; i < sky[0].Nregions; i++) {
    3030    refcat = NULL;
    3131    switch (mode) {
    3232      case 0:
    33         refcat = get2mass_AS_data (&regions[i], patch, photcode, &Nrefcat);
     33        refcat = get2mass_AS_data (&sky[0].regions[i], patch, photcode, &Nrefcat);
    3434        if (VERBOSE) fprintf (stderr, "loaded %d stars from 2MASS (allsky)\n", Nrefcat);
    3535        break;
    3636      case 1:
    37         refcat = get2mass_2DR_data (&regions[i], patch, photcode, &Nrefcat);
     37        refcat = get2mass_2DR_data (&sky[0].regions[i], patch, photcode, &Nrefcat);
    3838        if (VERBOSE) fprintf (stderr, "loaded %d stars from 2MASS (dr2)\n", Nrefcat);
    3939        break;
     
    5353
    5454/* watch for patch which cross 0,360 boundary */
    55 GSCRegion *get2mass_acc (GSCRegion *patch, int *nregions, char *path, char *accel) {
     55SkyTable *get2mass_acc (SkyRegion *patch, char *path, char *accel) {
    5656
    5757  int Nregions, NREGIONS;
    58   GSCRegion *regions;
    5958  char accelfile[1024], line[256], filename[128];
    6059  FILE *f;
    6160  double Rs, Re, Ds, De;
     61
     62  SkyTable *sky;
     63  SkyRegion *regions;
    6264
    6365  sprintf (accelfile, "%s/%s", path, accel);
     
    6769  Nregions = 0;
    6870  NREGIONS = 200;
    69   ALLOCATE (regions, GSCRegion, NREGIONS);
     71  ALLOCATE (regions, SkyRegion, NREGIONS);
    7072
    7173  /* read in stars line-by-line */
     
    7779    Rs *= 15.0;
    7880    Re *= 15.0;
    79     if (Rs > patch[0].RA[1]) continue;
    80     if (Re < patch[0].RA[0]) continue;
    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);
    84     regions[Nregions].RA[0] = Rs;
    85     regions[Nregions].RA[1] = Re;
    86     regions[Nregions].DEC[0] = Ds;
    87     regions[Nregions].DEC[1] = De;
     81    if (Rs > patch[0].Rmax) continue;
     82    if (Re < patch[0].Rmin) continue;
     83    if (Ds > patch[0].Dmax) continue;
     84    if (De < patch[0].Dmin) continue;
     85    sprintf (regions[Nregions].name, "%s/%s", path, filename);
     86    regions[Nregions].Rmin = Rs;
     87    regions[Nregions].Rmax = Re;
     88    regions[Nregions].Dmin = Ds;
     89    regions[Nregions].Dmax = De;
    8890    Nregions ++;
    89     CHECK_REALLOCATE (regions, GSCRegion, NREGIONS, Nregions, 20);
     91    CHECK_REALLOCATE (regions, SkyRegion, NREGIONS, Nregions, 20);
    9092  }   
    9193  fclose (f);
    9294
    93   *nregions = Nregions;
    94   return (regions);
     95  ALLOCATE (sky, SkyTable, 1);
     96  sky[0].regions = regions;
     97  sky[0].Nregions = Nregions;
     98  return (sky);
    9599}
  • trunk/Ohana/src/addstar/src/get2mass_as.c

    r5386 r5443  
    1313e_time get2mass_time (char *ptr, char *buffer, int Nbound, int Nbyte);
    1414
    15 Stars *get2mass_AS_data (GSCRegion *region, GSCRegion *patch, int photcode, int *nstars) {
     15Stars *get2mass_AS_data (SkyRegion *region, SkyRegion *patch, int photcode, int *nstars) {
    1616 
    1717  int FilterSkip, TimeSkip;
     
    2828  ALLOCATE (buffer, char, NBYTE);
    2929
    30   RA0  = MAX (patch[0].RA[0],  UserPatch.RA[0]);
    31   RA1  = MIN (patch[0].RA[1],  UserPatch.RA[1]);
    32   DEC0 = MAX (patch[0].DEC[0], UserPatch.DEC[0]);
    33   DEC1 = MIN (patch[0].DEC[1], UserPatch.DEC[1]);
     30  RA0  = MAX (patch[0].Rmin, UserPatch.Rmin);
     31  RA1  = MIN (patch[0].Rmax, UserPatch.Rmax);
     32  DEC0 = MAX (patch[0].Dmin, UserPatch.Dmin);
     33  DEC1 = MIN (patch[0].Dmax, UserPatch.Dmax);
    3434
    3535  FilterSkip = TimeSkip = Qentry = 0;
     
    5151  if (!FilterSkip) Shutdown ("invalid photcode %s", GetPhotcodeNamebyCode(photcode));
    5252
    53   filename = region[0].filename;
     53  filename = region[0].name;
    5454  gf = gzopen (filename, "rb");
    5555  if (gf == NULL) Shutdown ("can't read 2mass data file: %s", filename);
     
    136136/* this just scans along in the file.  file is sorted by dec, so we
    137137   should be skipping large chunks - but we would need to have
    138    the size from the accel file (won't fit in GSCRegion) and need
     138   the size from the accel file (won't fit in SkyRegion) and need
    139139   to use gzseek, if it exists.
    140140*/
  • trunk/Ohana/src/addstar/src/get2mass_dr2.c

    r5328 r5443  
    55# define NLINE 30000
    66
    7 Stars *get2mass_2DR_data (GSCRegion *region, GSCRegion *patch, int photcode, int *nstars) {
     7Stars *get2mass_2DR_data (SkyRegion *region, SkyRegion *patch, int photcode, int *nstars) {
    88 
    99  int i, Nstars, NSTARS, Nbyte, Nline;
     
    2020  if (patch == NULL) exit (3);
    2121
    22   RA0  = MAX (patch[0].RA[0],  UserPatch.RA[0]);
    23   RA1  = MIN (patch[0].RA[1],  UserPatch.RA[1]);
    24   DEC0 = MAX (patch[0].DEC[0], UserPatch.DEC[0]);
    25   DEC1 = MIN (patch[0].DEC[1], UserPatch.DEC[1]);
     22  RA0  = MAX (patch[0].Rmin, UserPatch.Rmin);
     23  RA1  = MIN (patch[0].Rmax, UserPatch.Rmax);
     24  DEC0 = MAX (patch[0].Dmin, UserPatch.Dmin);
     25  DEC1 = MIN (patch[0].Dmax, UserPatch.Dmax);
    2626
    2727  fprintf (stderr, "overlap: %f - %f, %f - %f\n", RA0, RA1, DEC0, DEC1);
    2828
    29   filename = region[0].filename;
     29  filename = region[0].name;
    3030  gf = gzopen (filename, "rb");
    3131  if (gf == NULL) Shutdown ("can't read 2mass data file: %s", filename);
     
    105105   and gzseek is as expensive as gzread */
    106106/*
    107    Noffset = region[0].Nrec * (patch[0].DEC[0] + 90) / 180.0;
     107   Noffset = region[0].Nrec * (patch[0].Dmin + 90) / 180.0;
    108108   gzseek (gf, Noffset * NBYTE, SEEK_SET);
    109109   Nbyte = gzread (gf, buffer, NLINE*NBYTE);
  • trunk/Ohana/src/addstar/src/getgsc.c

    r3400 r5443  
    66static short GSC_M;
    77
    8 Stars *getgsc (GSCRegion *patch, int *NSTARS) {
     8Stars *getgsc (SkyRegion *patch, int *NSTARS) {
    99 
    1010  int i, Ngsc, Nregions, Nstars;
    1111  Stars *gsc;
    1212  Stars *stars;
    13   GSCRegion *regions;
     13  SkyList *skylist;
     14  SkyTable *sky;
    1415  char *tmp;
    1516
    1617  NAMED_PHOTCODE (GSC_M, "GSC_M");
    1718
    18   /* sort of sleaze way to get the right GSC files */
    19   tmp = strcreate (CATDIR);
    20   strcpy (CATDIR, GSCDIR);
    21   regions = gregion_patch (patch, &Nregions);
    22   strcpy (CATDIR, tmp);
    23   free (tmp);
     19  /* load regions from GSC table, restrict to patch */
     20  sky = SkyTableFromGSC (GSCFILE, 2, VERBOSE);
     21  skylist = SkyListByPatch (sky, -1, patch);
     22  SkyListSetPath (skylist, GSCDIR);
    2423 
    2524  Nstars = 0;
    2625  ALLOCATE (stars, Stars, 1);
    2726 
    28   for (i = 0; i < Nregions; i++) {
    29     gsc = rd_gsc (regions[i].filename, &Ngsc);
     27  for (i = 0; i < skylist[0].Nregions; i++) {
     28    gsc = rd_gsc (skylist[0].regions[i][0].name, &Ngsc);
    3029
    3130    REALLOCATE (stars, Stars, MAX (1, Nstars + Ngsc));
     
    6766      dparse (&stars[Nstars].R, 1, &buffer[Nbyte]);
    6867      dparse (&stars[Nstars].D, 2, &buffer[Nbyte]);
    69       if (stars[Nstars].R < UserPatch.RA[0]) continue;
    70       if (stars[Nstars].R > UserPatch.RA[1]) continue;
    71       if (stars[Nstars].D < UserPatch.DEC[0]) continue;
    72       if (stars[Nstars].D > UserPatch.DEC[1]) continue;
     68      if (stars[Nstars].R < UserPatch.Rmin) continue;
     69      if (stars[Nstars].R > UserPatch.Rmax) continue;
     70      if (stars[Nstars].D < UserPatch.Dmin) continue;
     71      if (stars[Nstars].D > UserPatch.Dmax) continue;
    7372
    7473      dparse (&stars[Nstars].M, 3, &buffer[Nbyte]);
  • trunk/Ohana/src/addstar/src/getusno.c

    r5383 r5443  
    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 Stars *getusno (GSCRegion *catstats, int photcode, int *Nstars) {
     11Stars *getusno (SkyRegion *catstats, int photcode, int *Nstars) {
    1212
    1313  long int offset;
     
    3434  /* identify ra & dec range of interest */
    3535  /* note: the use of UserPatch to restrict here limits general utility of function */
    36   iRA0  =  MAX (catstats[0].RA[0], UserPatch.RA[0]) * 360000.0;
    37   iRA1  =  MIN (catstats[0].RA[1], UserPatch.RA[1]) * 360000.0;
    38   iDEC0 = (MAX (catstats[0].DEC[0], UserPatch.DEC[0]) + 90.0) * 360000.0;
    39   iDEC1 = (MIN (catstats[0].DEC[1], UserPatch.DEC[1]) + 90.0) * 360000.0;
     36  iRA0  =  MAX (catstats[0].Rmin, UserPatch.Rmin) * 360000.0;
     37  iRA1  =  MIN (catstats[0].Rmax, UserPatch.Rmax) * 360000.0;
     38  iDEC0 = (MAX (catstats[0].Dmin, UserPatch.Dmin) + 90.0) * 360000.0;
     39  iDEC1 = (MIN (catstats[0].Dmax, UserPatch.Dmax) + 90.0) * 360000.0;
    4040 
    4141  /* data is organized in south-pole distance zones */
    42   spd_start = (int)((catstats[0].DEC[0] + 90) / 7.5) * 75.0;
    43   dec = (catstats[0].DEC[1] + 90) / 7.5;
     42  spd_start = (int)((catstats[0].Dmin + 90) / 7.5) * 75.0;
     43  dec = (catstats[0].Dmax + 90) / 7.5;
    4444  if (dec > (int)(dec)) {
    45     spd_end =   (int)(1 + (catstats[0].DEC[1] + 90) / 7.5) * 75.0;
     45    spd_end =   (int)(1 + (catstats[0].Dmax + 90) / 7.5) * 75.0;
    4646  } else {
    47     spd_end =   (int)(0 + (catstats[0].DEC[1] + 90) / 7.5) * 75.0;
     47    spd_end =   (int)(0 + (catstats[0].Dmax + 90) / 7.5) * 75.0;
    4848  }
    4949
     
    8282    fclose (f);
    8383   
    84     first = catstats[0].RA[0] / 3.75;
    85     if ((catstats[0].RA[1] / 3.75) == (int) (catstats[0].RA[1] / 3.75))
    86       last  = catstats[0].RA[1] / 3.75;
     84    first = catstats[0].Rmin / 3.75;
     85    if ((catstats[0].Rmax / 3.75) == (int) (catstats[0].Rmax / 3.75))
     86      last  = catstats[0].Rmax / 3.75;
    8787    else
    88       last  = 1 + catstats[0].RA[1] / 3.75;
     88      last  = 1 + catstats[0].Rmax / 3.75;
    8989
    9090    if ((first > Nbins) || (last > Nbins)) {
  • trunk/Ohana/src/addstar/src/gimages.c

    r5385 r5443  
    153153*/
    154154
     155# if (0)
    155156void SetImageCorners (double *X, double *Y, Image *image) {
    156157
     
    167168  }
    168169}
     170# endif
  • trunk/Ohana/src/addstar/src/greference.c

    r5328 r5443  
    33# define LOAD_DR2    1
    44
    5 Stars *grefcat (char *Refcat, GSCRegion *catstats, int photcode, int *nstars) {
     5Stars *grefcat (char *Refcat, SkyRegion *region, int photcode, int *nstars) {
    66
    77  int Nstars;
     
    99
    1010  if (VERBOSE) fprintf (stderr, "loading reference catalog data from %s\n", Refcat);
    11   if (VERBOSE) fprintf (stderr, "full region: %f - %f, %f - %f\n", catstats[0].RA[0], catstats[0].RA[1], catstats[0].DEC[0], catstats[0].DEC[1]);
     11  if (VERBOSE) fprintf (stderr, "full region: %f - %f, %f - %f\n", region[0].Rmin, region[0].Rmax, region[0].Dmin, region[0].Dmax);
    1212
    1313  Nstars = 0;
     
    1616  /* get stars from USNO for the given region */
    1717  if (!strcasecmp (Refcat, "USNO")) {
    18     stars = getusno (catstats, photcode, &Nstars);
     18    stars = getusno (region, photcode, &Nstars);
    1919  }
    2020
    2121  /* get stars from HST GSC for the given region */
    2222  if (!strcasecmp (Refcat, "GSC")) {
    23     stars = getgsc (catstats, &Nstars);
     23    stars = getgsc (region, &Nstars);
    2424  }
    2525 
    2626  /* get stars from 2MASS for the given region */
    2727  if (!strcasecmp (Refcat, "2MASS")) {
    28     stars = get2mass (catstats, photcode, LOAD_ALLSKY, &Nstars);
     28    stars = get2mass (region, photcode, LOAD_ALLSKY, &Nstars);
    2929  }
    3030 
    3131  /* get stars from 2MASS for the given region */
    3232  if (!strcasecmp (Refcat, "2MASS-ALLSKY")) {
    33     stars = get2mass (catstats, photcode, LOAD_ALLSKY, &Nstars);
     33    stars = get2mass (region, photcode, LOAD_ALLSKY, &Nstars);
    3434  }
    3535 
    3636  /* get stars from 2MASS for the given region */
    3737  if (!strcasecmp (Refcat, "2MASS-DR2")) {
    38     stars = get2mass (catstats, photcode, LOAD_DR2, &Nstars);
     38    stars = get2mass (region, photcode, LOAD_DR2, &Nstars);
    3939  }
    4040 
    41   if (VERBOSE && (Nstars == 0)) fprintf (stderr, "no ref objects in region %s\n", catstats[0].filename);
     41  if (VERBOSE && (Nstars == 0)) fprintf (stderr, "no ref objects in region %s\n", region[0].name);
    4242
    4343  *nstars = Nstars;
  • trunk/Ohana/src/addstar/src/load_pt_catalog.c

    r5322 r5443  
    11# include "addstar.h"
    22
    3 int load_pt_catalog (Catalog *catalog, GSCRegion *region) {
     3int load_pt_catalog (Catalog *catalog, SkyRegion *region) {
    44 
    5   check_permissions (region[0].filename);
     5  check_permissions (region[0].name);
    66
    77  /* don't free region before catalog! */
    8   catalog[0].filename = region[0].filename;
    9   if (VERBOSE) fprintf (stderr, "adding to %s\n", region[0].filename);
     8  catalog[0].filename = region[0].name;
     9  if (VERBOSE) fprintf (stderr, "adding to %s\n", region[0].name);
    1010   
    1111  switch (lock_catalog (catalog, LCK_XCLD)) {
  • trunk/Ohana/src/addstar/src/mkcatalog.c

    r5234 r5443  
    11# include "addstar.h"
    22
    3 void mkcatalog (GSCRegion *region, Catalog *catalog) {
     3void mkcatalog (SkyRegion *region, Catalog *catalog) {
    44 
    55  int length, status;
     
    77  time_t now;
    88
    9   if (VERBOSE) fprintf (stderr, "new catalog file: %s\n", region[0].filename);
     9  if (VERBOSE) fprintf (stderr, "new catalog file: %s\n", region[0].name);
    1010
    1111  /* set the recommended CATFORMAT */
     
    9494
    9595  /* write RA,DEC range in header */
    96   fits_modify (&catalog[0].header, "RA0",  "%lf", 1, region[0].RA[0]);
    97   fits_modify (&catalog[0].header, "DEC0", "%lf", 1, region[0].DEC[0]);
    98   fits_modify (&catalog[0].header, "RA1",  "%lf", 1, region[0].RA[1]);
    99   fits_modify (&catalog[0].header, "DEC1", "%lf", 1, region[0].DEC[1]);
     96  fits_modify (&catalog[0].header, "RA0",  "%lf", 1, region[0].Rmin);
     97  fits_modify (&catalog[0].header, "DEC0", "%lf", 1, region[0].Dmin);
     98  fits_modify (&catalog[0].header, "RA1",  "%lf", 1, region[0].Rmax);
     99  fits_modify (&catalog[0].header, "DEC1", "%lf", 1, region[0].Dmax);
    100100
    101101  /* write creation date in header */
Note: See TracChangeset for help on using the changeset viewer.