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/imdata.c

    r5320 r5448  
    11# include "dvo1.h"
    2 void copy_region (GSCRegion *in, GSCRegion *out);
    32
    43int imdata (int argc, char **argv) {
     
    1312  Image *image;
    1413  Catalog catalog;
    15   GSCRegion *region, *tregion;
     14  SkyTable *sky;
     15  SkyList *skylist, *skyset;
    1616  Vector *vec;
    1717
     
    8080  GetTimeFormat (&TimeReference, &TimeFormat);
    8181
     82  /* load sky from correct table */
     83  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
     84  SkyTableSetFilenames (sky, CATDIR, "cpt");
     85
     86  Nregions = 0;
     87  NREGIONS = 10;
     88  ALLOCATE (skylist, SkyList, 1);
     89  ALLOCATE (skylist[0].regions, SkyRegions *, NREGIONS);
     90
    8291  /* for each image of interest, find the appropriate region files */
    83   Nregion = 0;
    84   ALLOCATE (region, GSCRegion, 1);
    8592  for (i = 0; i < Nsubset; i++) {
    8693    I = subset[i];
     94
    8795    if (!FindMosaicForImage (image, Nimage, I)) continue;
    88     tregion = get_regions (&image[I], &Ntregion);
    89     REALLOCATE (region, GSCRegion, MAX (1, Nregion + Ntregion));
    90     for (j = 0; j < Ntregion; j++) {
    91       skip = FALSE;
    92       for (k = 0; (k < Nregion) && !skip; k++) {
    93         if (!strcmp (region[k].filename, tregion[j].filename)) skip = TRUE;
    94       }
    95       if (!skip) {
    96         copy_region (&tregion[j], &region[Nregion]);
    97         Nregion ++;
    98       }
    99     }
    100     free (tregion);
     96    skyset = SkyListByImage (table, -1, &image[I]);
     97
     98    for (j = 0; j < skyset[0].Nregions; j++) {
     99      found = FALSE;
     100      for (k = 0; (k < skylist[0].Nregion) && !found; k++) {
     101        found = !strcmp (skylist[0].regions[k].name, skyset[0].regions[j].name);
     102      }
     103      if (found) continue;
     104      skylist[0].regions[Nregions] = skyset[0].regions[j];
     105      Nregions ++;
     106      CHECK_REALLOCATE (skylist[0].regions, SkyRegions *, NREGIONS, Nregions, 10);
     107    }
     108    SkyListFree (skyset);
    101109  }     
    102110  free (subset);
    103   for (i = 0; i < Nregion; i++) {
    104     fprintf (stderr, "try %s\n", region[i].filename);
     111  for (i = 0; i < skylist[0].Nregions; i++) {
     112    fprintf (stderr, "try %s\n", skylist[0].regions[i][0].name);
    105113  }
    106114 
     
    111119
    112120  /* for each region file, extract the data of interest in the right time range */
    113   for (j = 0; j < Nregion; j++) {
     121  for (j = 0; j < skylist[0].Nregions; j++) {
    114122
    115123    /* get file name and open */
    116     strcpy (filename, region[j].filename);
    117     catalog.filename = filename;
     124    catalog.filename = skylist[0].regions[j][0].filename;
    118125    switch (lock_catalog (&catalog, LCK_SOFT)) {
    119126    case 2:
     
    210217  return (TRUE);
    211218}
    212 
    213 
    214 void copy_region (GSCRegion *in, GSCRegion *out) {
    215    
    216   out[0].RA[0]  = in[0].RA[0];
    217   out[0].RA[1]  = in[0].RA[1];
    218   out[0].DEC[0] = in[0].DEC[0];
    219   out[0].DEC[1] = in[0].DEC[1];
    220   strcpy (out[0].filename, in[0].filename);
    221 }
    222 
Note: See TracChangeset for help on using the changeset viewer.