IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 27, 2005, 10:38:30 AM (21 years ago)
Author:
eugene
Message:

implementing SkyRegions in all DVO programs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/dvo/region_list.c

    r4689 r5448  
    11# include "dvo1.h"
     2
     3/* XXX note : for RegionName or RegionList, we need to free the skylist
     4   elements, but not in the case of radius selection - this implies
     5   information carried back up */
    26
    37static int RegionSelect;
     
    4246}
    4347
    44 RegionFile *SelectRegions (char *RegionName, char *RegionList, int *nregions) {
     48SkyList *SelectRegions (char *RegionName, char *RegionList) {
    4549
    4650  double Radius;
    4751  int Ngraph;
    4852  Graphdata graphsky;
    49   RegionFile *regions;
     53  SkyTable *sky;
     54  SkyList *skylist;
    5055
    5156  /* determine region-file names */
    5257  if (RegionName != NULL) {
    53     *nregions = 1;
    54     ALLOCATE (regions, RegionFile, 1);
    55     strcpy (regions[0].name, RegionName);
     58    ALLOCATE (skylist, SkyList, 1);
     59    ALLOCATE (skylist[0].regions[0], SkyRegion *, 1);
     60    ALLOCATE (skylist[0].regions[0][0], SkyRegion, 1);
     61    strcpy (skylist[0].regions[0][0].name, RegionName);
     62    sprintf (filename, "%s/%s.cpt", CATDIR, RegionName);
     63    skylist[0].regions[0][0].filename = strcreate (filename);
    5664    free (RegionName);
    5765    RegionName = NULL;
    58     return (regions);
     66    return (skylist);
    5967  }
    6068  if (RegionList != NULL) {
    61     regions = region_list (RegionList, nregions);
     69    skylist = SkyListLoadFile (RegionList);
    6270    free (RegionList);
    6371    RegionList = NULL;
    64     return (regions);
     72    return (skylist);
    6573  }
    6674
     
    7280
    7381  Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
    74   regions = find_regions (graphsky.coords.crval1, graphsky.coords.crval2, Radius, nregions);
    75   return (regions);
     82
     83  /* load sky from correct table */
     84  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
     85  SkyTableSetFilenames (sky, CATDIR, "cpt");
     86  skylist = SkyListByRadius (sky, -1, graphmode.coords.crval1, graphmode.coords.crval2, Radius);
     87
     88  return (skylist);
    7689}
    7790
     91/* XXX EAM this should perhaps return a skytable? */
    7892/* returns a list of region files names from file */
    79 RegionFile *region_list (char *filename, int *Nregions) {
     93SkyList *SkyListFromFile (char *filename) {
    8094 
     95  FILE *f;
    8196  int NREGIONS, nregion;
    82   RegionFile *regions;
    83   FILE *f;
     97  SkyList *skylist;
     98
     99  ALLOCATE (skylist, SkyList, 1);
    84100
    85101  f = fopen (filename, "r");
    86102  if (f == NULL) {
    87103    fprintf (stderr, "ERROR: can't find region list file %s\n", filename);
    88     *Nregions = 0;
    89     return (NULL);
     104    skylist[0].Nregions = 0;
     105    skylist[0].regions = NULL;
     106    return (skylist);
    90107  }
    91108 
     109  Nregions = 0;
    92110  NREGIONS = 50;
    93   ALLOCATE (regions, RegionFile, NREGIONS);
    94   nregion = 0;
     111  ALLOCATE (skylist[0].regions, SkyRegion *, NREGIONS);
    95112
    96   while (fscanf (f, "%s", regions[nregion].name) != EOF) {
    97     nregion ++;
    98     if (nregion == NREGIONS) {
    99       NREGIONS += 50;
    100       REALLOCATE (regions, RegionFile, NREGIONS);
     113  while (fscanf (f, "%s", filename) != EOF) {
     114    ALLOCATE (skylist[0].regions[Nregions], SkyRegion, 1);
     115    strcpy (skylist[0].regions[Nregions][0].name, filename);
     116    sprintf (filename, "%s/%s.cpt", CATDIR, skylist[0].regions[Nregions][0].name);
     117    skylist[0].regions[Nregions][0].filename = strcreate (filename);
     118    Nregions ++;
     119    CHECK_REALLOCATE (skylist[0].regions, SkyRegion *, NREGIONS, Nregions, 50);
    101120    }
    102121  }
Note: See TracChangeset for help on using the changeset viewer.