IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5451 for trunk/Ohana/src/opihi


Ignore:
Timestamp:
Oct 27, 2005, 7:10:17 PM (21 years ago)
Author:
eugene
Message:

working on SkyRegion conversion

Location:
trunk/Ohana/src/opihi
Files:
1 added
28 edited

Legend:

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

    r4585 r5451  
    99
    1010/* load images based on parameters and region, etc */
    11 int SetImageSelection (int mode) {
     11int SetImageSelection (int mode, int RegionSelect) {
    1212
    1313  int Ngraph;
    1414  Graphdata graphsky;
    15   int RegionSelect, TimeSelect;
     15  int TimeSelect;
    1616  time_t tzero, tend;
    1717
     
    1919  subset = NULL;
    2020 
    21   RegionSelect = GetRegionSelection();
    2221  if (RegionSelect) {
    2322    Ngraph = 0;
  • trunk/Ohana/src/opihi/dvo/Makefile

    r5442 r5451  
    2929$(SDIR)/LoadImages.$(ARCH).o            \
    3030$(SDIR)/cmpRead.$(ARCH).o               \
    31 $(SDIR)/aregion.$(ARCH).o               \
    3231$(SDIR)/compare.$(ARCH).o               \
    33 $(SDIR)/find_regions.$(ARCH).o          \
    34 $(SDIR)/get_regions.$(ARCH).o           \
    3532$(SDIR)/match_image.$(ARCH).o           \
    3633$(SDIR)/photometry.$(ARCH).o            \
     
    3936$(SDIR)/dvo.$(ARCH).o
    4037
     38# $(SDIR)/aregion.$(ARCH).o               \
     39# $(SDIR)/find_regions.$(ARCH).o                \
     40# $(SDIR)/get_regions.$(ARCH).o           \
     41
    4142cmds = \
    4243$(SDIR)/avextract.$(ARCH).o             \
     
    4445$(SDIR)/calextract.$(ARCH).o            \
    4546$(SDIR)/calmextract.$(ARCH).o           \
    46 $(SDIR)/catalog.$(ARCH).o               \
    4747$(SDIR)/ccd.$(ARCH).o                   \
    4848$(SDIR)/cmatch.$(ARCH).o                \
     
    7575$(SDIR)/lightcurve.$(ARCH).o            \
    7676$(SDIR)/mextract.$(ARCH).o              \
    77 $(SDIR)/pcat.$(ARCH).o                  \
    7877$(SDIR)/photcodes.$(ARCH).o             \
    7978$(SDIR)/pmeasure.$(ARCH).o              \
     
    101100help: cmd.basic.help cmd.data.help cmd.astro.help dvo.help
    102101
     102$(funcs) $(cmds) $(libs) : $(INC)/dvo1.h
     103
    103104.PHONY: dvo
    104105
     
    106107
    107108# deprecated functions: verify & delete
     109#$(SDIR)/catalog.$(ARCH).o              \
    108110#$(SDIR)/abszero.$(ARCH).o \
    109111#$(SDIR)/cals.$(ARCH).o \
     
    119121#$(SDIR)/dmagextract.$(ARCH).o \
    120122#$(SDIR)/ddmagextract.$(ARCH).o \
     123#$(SDIR)/pcat.$(ARCH).o                 \
    121124
    122125# future functions, not fully implemented
  • trunk/Ohana/src/opihi/dvo/avextract.c

    r5320 r5451  
    44 
    55  int i, j, m, N, NPTS, param;
    6   int Nsec, Nregions, mode;
    7   char filename[256], catdir[256], *RegionName, *RegionList, *p;
     6  int Nsec, mode;
     7  char *RegionName, *RegionList, *p;
    88
    99  Catalog catalog;
    10   RegionFile *regions;
     10  SkyList *skylist;
    1111  PhotCode *code;
    1212  Vector *vec;
    1313
    1414  /* defaults */
    15   regions = NULL;
    1615  catalog.average = NULL;
    1716  catalog.secfilt = NULL;
     
    2524  if (!InitPhotcodes ()) goto escape;
    2625  Nsec = GetPhotcodeNsecfilt ();
    27 
    28   /* find CATDIR in config system */
    29   if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    3026
    3127  /* interpret command-line options */
     
    5046
    5147  /* load region corresponding to selection above */
    52   if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
     48  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
    5349
    5450  /* create storage vector */
     
    5753  if ((vec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto escape;
    5854
    59   for (i = 0; i < Nregions; i++) {
     55  for (i = 0; i < skylist[0].Nregions; i++) {
    6056    /* lock, load, unlock catalog */
    61     sprintf (filename, "%s/%s", catdir, regions[i].name);
    62     catalog.filename = filename;
     57    catalog.filename = (char *) skylist[0].regions[i][0].filename;
    6358    switch (lock_catalog (&catalog, LCK_SOFT)) {
    6459    case 2:
     
    9085  REALLOCATE (vec[0].elements, float, MAX(1,N));
    9186
    92   if (regions != NULL) free (regions);
     87  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    9388  return (TRUE);
    9489
     
    9893
    9994escape:
    100   if (regions != NULL) free (regions);
     95  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    10196  if (catalog.average != NULL) free (catalog.average);
    10297  if (catalog.secfilt != NULL) free (catalog.secfilt);
  • trunk/Ohana/src/opihi/dvo/calextract.c

    r5320 r5451  
    55int calextract (int argc, char **argv) {
    66 
    7   int i, j, m, N, Nr, Nregions, mode[2];
     7  int i, j, m, N, Nr, mode[2];
    88  int Nsec, NSTAR;
    9   char filename[256], catdir[256], *RegionName, *RegionList;
     9  char *RegionName, *RegionList;
    1010  double M1, M2, dM2, color;
    1111
     12  PhotCode *code[2];
    1213  Catalog catalog;
    13   RegionFile *regions;
    14   PhotCode *code[2];
     14  SkyList *skylist;
    1515  Vector **vec;
    1616
    1717  /* these need to be freed in the end */
    18   regions = NULL;
    1918  catalog.average = NULL;
    2019  catalog.secfilt = NULL;
     
    2726  if (!InitPhotcodes ()) return (FALSE);
    2827  Nsec = GetPhotcodeNsecfilt ();
    29 
    30   /* find CATDIR in config system */
    31   if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    3228
    3329  /* command line arguments */
     
    5955
    6056  /* load region corresponding to selection above */
    61   if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
     57  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
    6258
    63   for (Nr = 0; Nr < Nregions; Nr++) {
     59  for (Nr = 0; Nr < skylist[0].Nregions; Nr++) {
    6460    if (Nr && !(Nr % 500)) { fprintf (stderr, "."); }
    6561
    6662    /* lock, load, unlock catalog */
    67     sprintf (filename, "%s/%s", catdir, regions[Nr].name);
    68     catalog.filename = filename;
     63    catalog.filename = (char *) skylist[0].regions[Nr][0].filename;
    6964    switch (lock_catalog (&catalog, LCK_SOFT)) {
    7065    case 2:
     
    127122    catalog.measure = (Measure *) NULL;
    128123  }
    129   if (regions != NULL) free (regions); 
     124
     125  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    130126  for (i = 0; i < NVEC; i++) {
    131127    vec[i][0].Nelements = N;
     
    141137  if (RegionName != NULL) free (RegionName);
    142138  if (RegionList != NULL) free (RegionList);
    143   if (regions != NULL) free (regions); 
     139  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    144140  for (i = 0; i < NVEC; i++) {
    145141    DeleteVector (vec[i]);
  • trunk/Ohana/src/opihi/dvo/calmextract.c

    r5320 r5451  
    77 
    88  int i, j, k, m, N, N1, Nr, mode[2];
    9   int NSTAR, Nstar, Nsec, Nregions;
    10   char filename[256], catdir[256], *RegionName, *RegionList;
     9  int NSTAR, Nstar, Nsec;
     10  char *RegionName, *RegionList;
    1111  double *M1, M2, dM2, color;
    1212
    1313  Catalog catalog;
    14   RegionFile *regions;
    1514  PhotCode *code[2];
     15  SkyList *skylist;
    1616  Vector **vec;
    1717
    1818  /* these need to be freed in the end */
    19   regions = NULL;
    2019  catalog.average = NULL;
    2120  catalog.secfilt = NULL;
     
    2827  if (!InitPhotcodes ()) goto escape;
    2928  Nsec = GetPhotcodeNsecfilt ();
    30 
    31   /* find CATDIR in config system */
    32   if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    3329
    3430  /* command line arguments */
     
    7167
    7268  /* load region corresponding to selection above */
    73   if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
    74   if (!SetImageSelection (MEAS_XMOSAIC)) goto escape;
     69  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
     70  if (!SetImageSelection (MEAS_XMOSAIC, ((RegionName == NULL) && (RegionList == NULL)))) goto escape;
    7571
    76   for (Nr = 0; Nr < Nregions; Nr++) {
     72  for (Nr = 0; Nr < skylist[0].Nregions; Nr++) {
    7773    if (Nr && !(Nr % 500)) { fprintf (stderr, "."); }
    7874
    7975    /* lock, load, unlock catalog */
    80     sprintf (filename, "%s/%s", catdir, regions[Nr].name);
    81     catalog.filename = filename;
     76    catalog.filename = (char *) skylist[0].regions[Nr][0].filename;
    8277    switch (lock_catalog (&catalog, LCK_SOFT)) {
    8378    case 2:
     
    153148    catalog.measure = (Measure *) NULL;
    154149  }
    155   if (regions != NULL) free (regions); 
     150
     151  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    156152  for (i = 0; i < NVEC; i++) {
    157153    vec[i][0].Nelements = N;
     
    167163 
    168164  FreeImageSelection ();
    169   if (regions != NULL) free (regions); 
     165  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    170166  for (i = 0; i < NVEC; i++) {
    171167    DeleteVector (vec[i]);
  • trunk/Ohana/src/opihi/dvo/ccd.c

    r5320 r5451  
    33int ccd (int argc, char **argv) {
    44 
    5   char filename[256], catdir[256], *RegionName, *RegionList;
     5  char *RegionName, *RegionList;
    66  double *M1, *M2;
    77  int i, m, k, Npts, NPTS, N;
    88  int N1, N2, i1, i2, mode[4];
    9   int Nsec, Nregions, KeepNulls;
     9  int Nsec, KeepNulls;
    1010
    1111  Catalog catalog;
    12   RegionFile *regions;
    1312  PhotCode *code[4];
     13  SkyList *skylist;
    1414  Vector *xvec, *yvec;
    1515
    1616  /* defaults */
    17   regions = NULL;
    1817  catalog.average = NULL;
    1918  catalog.secfilt = NULL;
     
    2524  if (!InitPhotcodes ()) goto escape;
    2625  Nsec = GetPhotcodeNsecfilt ();
    27 
    28   /* find CATDIR in config system */
    29   if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    3026
    3127  /* interpret command-line options */
     
    5147
    5248  /* load region corresponding to selection above */
    53   if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
     49  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
    5450
    5551  /* init vectors to save data */
     
    6056
    6157  /* loop over regions, extract data for each region */
    62   for (k = 0; k < Nregions; k++) {
     58  for (k = 0; k < skylist[0].Nregions; k++) {
    6359    /* lock, load, unlock catalog */
    64     sprintf (filename, "%s/%s", catdir, regions[k].name);
    65     catalog.filename = filename;
     60    catalog.filename = (char *) skylist[0].regions[k][0].filename;
    6661    switch (lock_catalog (&catalog, LCK_SOFT)) {
    6762      case 2:
     
    121116    catalog.measure = (Measure *) NULL;
    122117  }
    123   if (regions != NULL) free (regions);
     118  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    124119  xvec[0].Nelements = yvec[0].Nelements = Npts;
    125120  return (TRUE);
     
    130125
    131126escape:
    132   if (regions != NULL) free (regions);
     127  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    133128  if (catalog.average != NULL) free (catalog.average);
    134129  if (catalog.secfilt != NULL) free (catalog.secfilt);
  • trunk/Ohana/src/opihi/dvo/cmatch.c

    r5320 r5451  
    66  char filename[128];
    77  double radius;
    8   char catdir[256], gscdir[256];
    98  Vector *rvec, *dvec, *mvec, *drvec, *ddvec, *dmvec;
    109
    11   VarConfig ("GSCDIR", "%s", gscdir);
    12   VarConfig ("CATDIR", "%s", catdir);
    13      
    1410  if (argc != 9) {
    1511    fprintf (stderr, "USAGE: cmatch file radius (RA) (DEC) (Mag) (dRA) (dDEC) (dMag)\n");
     
    3228
    3329  /* load data from the photometry database file */
    34   sprintf (filename, "%s/%s", catdir, argv[1]);
    3530  catalog1.filename = filename;
    3631  switch (lock_catalog (&catalog1, LCK_SOFT)) {
  • trunk/Ohana/src/opihi/dvo/cmd.c

    r5320 r5451  
    33int cmd (int argc, char **argv) { /* really need to think about upper limits & how to represent them */
    44 
    5   char filename[256], catdir[256], *RegionName, *RegionList;
     5  char *RegionName, *RegionList;
    66  double *M1, *M3;
    77  int i, j, m, i1, i3, N1, N3, N;
    88  int Npts, NPTS, mode[3];
    9   int Nsec, Nregions, KeepNulls;
     9  int Nsec, KeepNulls;
    1010
     11  PhotCode *code[3];
    1112  Catalog catalog;
    12   RegionFile *regions;
    13   PhotCode *code[3];
     13  SkyList *skylist;
    1414  Vector *xvec, *yvec;
    1515
    1616  /* defaults */
    17   regions = NULL;
    1817  catalog.average = NULL;
    1918  catalog.secfilt = NULL;
     
    2524  if (!InitPhotcodes ()) goto escape;
    2625  Nsec = GetPhotcodeNsecfilt ();
    27 
    28   /* find CATDIR in config system */
    29   if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    3026
    3127  /* interpret command-line options */
     
    4945
    5046  /* load region corresponding to selection above */
    51   if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
     47  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
    5248
    5349  /* init vectors to save data */
     
    5854
    5955  /* loop over regions, extract data for each region */
    60   for (j = 0; j < Nregions; j++) {
     56  for (j = 0; j < skylist[0].Nregions; j++) {
    6157    /* lock, load, unlock catalog */
    62     sprintf (filename, "%s/%s", catdir, regions[j].name);
    63     catalog.filename = filename;
     58    catalog.filename = (char *) skylist[0].regions[j][0].filename;
    6459    switch (lock_catalog (&catalog, LCK_SOFT)) {
    6560    case 2:
     
    119114    catalog.measure = (Measure *) NULL;
    120115  }
    121   if (regions != NULL) free (regions);
     116  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    122117  xvec[0].Nelements = yvec[0].Nelements = Npts;
    123118  return (TRUE);
     
    128123
    129124escape:
    130   if (regions != NULL) free (regions);
     125  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    131126  if (catalog.average != NULL) free (catalog.average);
    132127  if (catalog.secfilt != NULL) free (catalog.secfilt);
  • trunk/Ohana/src/opihi/dvo/ddmags.c

    r5320 r5451  
    33int ddmags (int argc, char **argv) {
    44 
    5   char filename[256], catdir[256], *RegionName, *RegionList;
     5  char *RegionName, *RegionList;
    66  double *M1, *M2;
    77  int i, m, k, N, Npts, NPTS;
    88  int N1, N2, i1, i2, mode[4];
    9   int Nsec, Nregions, KeepNulls;
     9  int Nsec, KeepNulls;
    1010
    1111  Catalog catalog;
    12   RegionFile *regions;
    1312  PhotCode *code[4];
     13  SkyList *skylist;
    1414  Vector *xvec, *yvec;
    1515
    1616  /* defaults */
    17   regions = NULL;
    1817  catalog.average = NULL;
    1918  catalog.secfilt = NULL;
     
    2524  if (!InitPhotcodes ()) goto escape;
    2625  Nsec = GetPhotcodeNsecfilt ();
    27 
    28   /* find CATDIR in config system */
    29   if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    3026
    3127  /* interpret command-line options */
     
    5147
    5248  /* load region corresponding to selection above */
    53   if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
     49  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
    5450
    5551  /* init vectors to save data */
     
    6056
    6157  /* loop over regions, extract data for each region */
    62   for (k = 0; k < Nregions; k++) {
     58  for (k = 0; k < skylist[0].Nregions; k++) {
    6359    /* lock, load, unlock catalog */
    64     sprintf (filename, "%s/%s", catdir, regions[k].name);
    65     catalog.filename = filename;
     60    catalog.filename = (char *) skylist[0].regions[k][0].filename;
    6661    switch (lock_catalog (&catalog, LCK_SOFT)) {
    6762      case 2:
     
    121116    catalog.measure = (Measure *) NULL;
    122117  }
    123   if (regions != NULL) free (regions);
     118  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    124119  xvec[0].Nelements = yvec[0].Nelements = Npts;
    125120  return (TRUE);
     
    129124
    130125escape:
    131   if (regions != NULL) free (regions);
     126  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    132127  if (catalog.average != NULL) free (catalog.average);
    133128  if (catalog.secfilt != NULL) free (catalog.secfilt);
  • trunk/Ohana/src/opihi/dvo/dmagaves.c

    r5320 r5451  
    33int dmagaves (int argc, char **argv) {
    44 
    5   char filename[256], catdir[256], *RegionName, *RegionList;
     5  char *RegionName, *RegionList;
    66  double *M1, M2;
    77  int i, j, k, m, N1;
    88  int Npts, NPTS, param, mode[3];
    9   int Nsec, Nregions;
     9  int Nsec;
    1010
     11  PhotCode *code[3];
    1112  Catalog catalog;
    12   RegionFile *regions;
    13   PhotCode *code[3];
     13  SkyList *skylist;
    1414  Vector *xvec, *yvec;
    1515
    1616  /* defaults */
    17   regions = NULL;
    1817  catalog.average = NULL;
    1918  catalog.secfilt = NULL;
     
    2625  if (!InitPhotcodes ()) goto escape;
    2726  Nsec = GetPhotcodeNsecfilt ();
    28 
    29   /* find CATDIR in config system */
    30   if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    3127
    3228  /* interpret command-line options */
     
    4440
    4541  /* load region corresponding to selection above */
    46   if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
     42  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
    4743
    4844  /* init vectors to save data */
     
    5248  if ((yvec = SelectVector ("yv", ANYVECTOR, TRUE)) == NULL) goto escape;
    5349
    54   for (j = 0; j < Nregions; j++) {
     50  for (j = 0; j < skylist[0].Nregions; j++) {
    5551    /* lock, load, unlock catalog */
    56     sprintf (filename, "%s/%s", catdir, regions[j].name);
    57     catalog.filename = filename;
     52    catalog.filename = (char *) skylist[0].regions[j][0].filename;
    5853    switch (lock_catalog (&catalog, LCK_SOFT)) {
    5954    case 2:
     
    10196    catalog.measure = (Measure *) NULL;
    10297  }
    103   if (regions != NULL) free (regions);
     98  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    10499  xvec[0].Nelements = yvec[0].Nelements = Npts;
    105100  return (TRUE);
     
    110105
    111106escape:
    112   if (regions != NULL) free (regions);
     107  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    113108  if (catalog.average != NULL) free (catalog.average);
    114109  if (catalog.secfilt != NULL) free (catalog.secfilt);
  • trunk/Ohana/src/opihi/dvo/dmagmeas.c

    r5320 r5451  
    33int dmagmeas (int argc, char **argv) {
    44 
    5   char filename[256], catdir[256], *RegionName, *RegionList;
     5  char *RegionName, *RegionList;
    66  double *M1, *M3;
    77  int i, j, m, i1, i3, N1, N3, N;
    88  int Npts, NPTS, param, mode[3];
    9   int Nsec, Nregions, KeepNulls;
     9  int Nsec, KeepNulls;
    1010
    1111  Catalog catalog;
    12   RegionFile *regions;
    1312  PhotCode *code[3];
     13  SkyList *skylist;
    1414  Vector *xvec, *yvec;
    1515
    1616  /* defaults */
    17   regions = NULL;
    1817  catalog.average = NULL;
    1918  catalog.secfilt = NULL;
     
    2625  if (!InitPhotcodes ()) goto escape;
    2726  Nsec = GetPhotcodeNsecfilt ();
    28 
    29   /* find CATDIR in config system */
    30   if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    3127
    3228  /* interpret command-line options */
     
    5046
    5147  /* load region corresponding to selection above */
    52   if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
    53   if (!SetImageSelection (param)) goto escape;
     48  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
     49  if (!SetImageSelection (param, ((RegionName == NULL) && (RegionList == NULL)))) goto escape;
    5450
    5551  /* init vectors to save data */
     
    6056
    6157  /* loop over regions, extract data for each region */
    62   for (j = 0; j < Nregions; j++) {
     58  for (j = 0; j < skylist[0].Nregions; j++) {
    6359    /* lock, load, unlock catalog */
    64     sprintf (filename, "%s/%s", catdir, regions[j].name);
    65     catalog.filename = filename;
     60    catalog.filename = (char *) skylist[0].regions[j][0].filename;
    6661    switch (lock_catalog (&catalog, LCK_SOFT)) {
    6762      case 2:
     
    122117  }
    123118  FreeImageSelection ();
    124   if (regions != NULL) free (regions);
     119  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    125120  xvec[0].Nelements = yvec[0].Nelements = Npts;
    126121  return (TRUE);
     
    132127escape:
    133128  FreeImageSelection ();
    134   if (regions != NULL) free (regions);
     129  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    135130  if (catalog.average != NULL) free (catalog.average);
    136131  if (catalog.secfilt != NULL) free (catalog.secfilt);
  • trunk/Ohana/src/opihi/dvo/dmags.c

    r5320 r5451  
    33int dmags (int argc, char **argv) {
    44 
    5   char filename[256], catdir[256], *RegionName, *RegionList;
     5  char *RegionName, *RegionList;
    66  double *M1, *M3;
    77  int i, j, m, i1, i3, N1, N3, N;
    88  int Npts, NPTS, mode[3];
    9   int Nsec, Nregions, KeepNulls;
     9  int Nsec, KeepNulls;
    1010
    1111  PhotCode *code[3];
    1212  Catalog catalog;
    13   RegionFile *regions;
     13  SkyList *skylist;
    1414  Vector *xvec, *yvec;
    1515
    1616  /* defaults */
    17   regions = NULL;
    1817  catalog.average = NULL;
    1918  catalog.secfilt = NULL;
     
    2524  if (!InitPhotcodes ()) goto escape;
    2625  Nsec = GetPhotcodeNsecfilt ();
    27 
    28   /* find CATDIR in config system */
    29   if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    3026
    3127  /* interpret command-line options */
     
    4945
    5046  /* load region corresponding to selection above */
    51   if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
     47  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
    5248
    5349  /* init vectors to save data */
     
    5854
    5955  /* loop over regions, extract data for each region */
    60   for (j = 0; j < Nregions; j++) {
     56  for (j = 0; j < skylist[0].Nregions; j++) {
    6157    /* lock, load, unlock catalog */
    62     sprintf (filename, "%s/%s", catdir, regions[j].name);
    63     catalog.filename = filename;
     58    catalog.filename = (char *) skylist[0].regions[j][0].filename;
    6459    switch (lock_catalog (&catalog, LCK_SOFT)) {
    6560      case 2:
     
    119114    catalog.measure = (Measure *) NULL;
    120115  }
    121   if (regions != NULL) free (regions);
     116
     117  /* need to free SkyList / or free all regions as well */
     118  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    122119  xvec[0].Nelements = yvec[0].Nelements = Npts;
    123120  return (TRUE);
     
    132129
    133130escape:
    134   if (regions != NULL) free (regions);
     131  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    135132  if (catalog.average != NULL) free (catalog.average);
    136133  if (catalog.secfilt != NULL) free (catalog.secfilt);
  • trunk/Ohana/src/opihi/dvo/dmt.c

    r5448 r5451  
    66  int i, m, k, N, Ngraph, SaveVectors;
    77  int Ns, Nsec, NPTS;
    8   char catdir[256], filename[256];
    98  double Radius;
    109  float dt1, dt2, dmt1, dmt2;
     
    1918
    2019  if (!InitPhotcodes ()) return (FALSE);
    21 
    22   VarConfig ("CATDIR", "%s", catdir);
    2320
    2421  vec1 = vec2 = vec3 = vec4 = vec5 = NULL;
     
    5451  Ns = GetPhotcodeNsec (code[0].code);
    5552
    56   /* load sky from correct table */
    57   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
    58   SkyTableSetFilenames (sky, CATDIR, "cpt");
     53  Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
    5954
    60   Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
     55  sky = GetSkyTable ();
    6156  skylist = SkyListByRadius (sky, -1, graphsky.coords.crval1, graphsky.coords.crval2, Radius);
    6257 
     
    7469
    7570    /* lock, load, unlock catalog */
    76     catalog.filename = skylist[0].regions[k][0].filename;
     71    catalog.filename = (char *) skylist[0].regions[k][0].filename;
    7772    switch (lock_catalog (&catalog, LCK_SOFT)) {
    7873    case 2:
  • trunk/Ohana/src/opihi/dvo/dvo.c

    r4714 r5451  
    1717  InitAstro ();
    1818  InitDVO ();
     19
     20  if (SetCATDIR (NULL, TRUE)) {
     21    fprintf (stderr, "CATDIR is not defined\n");
     22  }
    1923
    2024  rl_readline_name = opihi_name;
  • trunk/Ohana/src/opihi/dvo/fitcolors.c

    r5320 r5451  
    1313  int i, k, m, NP1, NP2, NP, Np, Npts, NPTS;
    1414  int N1, N2, i1, i2, mode[4];
    15   int Nsec, Nregions, status;
    16   char catdir[256], filename[256], *RegionName, *RegionList;
     15  int Nsec, status;
     16  char *RegionName, *RegionList;
    1717  char *cmd, *outcmd, *camera;
    1818  double *M1, *M2;
     
    2020
    2121  Catalog *catalog;
    22   RegionFile *regions;
    2322  PhotCode **codelist, *tcode, *code[4];
     23  SkyList *skylist;
    2424  Vector *xvec, *yvec;
    2525  Buffer *buf;
    2626
    2727  /* defaults */
    28   regions  = NULL;
    2928  catalog  = NULL;
    3029  codelist = NULL;
     
    3433  if (!InitPhotcodes ()) goto escape;
    3534  Nsec = GetPhotcodeNsecfilt ();
    36 
    37   /* find CATDIR in config system */
    38   if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    3935
    4036  /* interpret command-line options */
     
    9793
    9894  /* load region corresponding to selection above */
    99   if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
     95  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
    10096
    10197  /* loop over regions, extract data for each region */
    102   ALLOCATE (catalog, Catalog, Nregions);
    103   for (k = 0; k < Nregions; k++) {
     98  ALLOCATE (catalog, Catalog, skylist[0].Nregions);
     99  for (k = 0; k < skylist[0].Nregions; k++) {
    104100    /* lock, load, unlock catalog */
    105     sprintf (filename, "%s/%s", catdir, regions[k].name);
    106     catalog[k].filename = filename;
     101    catalog[k].filename = (char *) skylist[0].regions[k][0].filename;
    107102    switch (lock_catalog (&catalog[k], LCK_SOFT)) {
    108103      case 2:
     
    120115    unlock_catalog (&catalog[k]);
    121116  }
    122   fprintf (stderr, "using %d regions\n", Nregions);
     117  fprintf (stderr, "using %d regions\n", skylist[0].Nregions);
    123118
    124119  /* vectors to save data */
     
    137132      /* extract all magnitude pairs from catalog tables */
    138133      Npts = 0;
    139       for (k = 0; k < Nregions; k++) {
     134      for (k = 0; k < skylist[0].Nregions; k++) {
    140135        if (catalog[k].Naverage == 0) continue;
    141136
     
    186181    }
    187182  }
     183  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
     184  if (RegionName != NULL) free (RegionName);
     185  if (RegionList != NULL) free (RegionList);
    188186  return (TRUE);
    189187
     
    196194
    197195escape:
    198   if (regions != NULL) free (regions);
     196  free_catalog (catalog, skylist[0].Nregions);
     197  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
     198  if (RegionName != NULL) free (RegionName);
     199  if (RegionList != NULL) free (RegionList);
    199200  if (codelist != NULL) free (codelist);
    200201  DeleteVector (xvec);
    201202  DeleteVector (yvec);
    202   free_catalog (catalog, Nregions);
    203203  return (FALSE);
    204204}
  • trunk/Ohana/src/opihi/dvo/gcat.c

    r5448 r5451  
    88  SkyTable *sky;
    99  SkyList *skylist;
    10   char catdir[256];
    11 
    12   VarConfig ("CATDIR", "%s", catdir);
    1310
    1411  if ((argc != 3) && (argc != 4)) {
     
    1815
    1916  /* load sky from correct table */
    20   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
    21   SkyTableSetFilenames (sky, CATDIR, "cpt");
    22 
    2317  Ra = atof (argv[1]);
    2418  Dec = atof (argv[2]);
     
    2822    Radius = 0.0001;
    2923
     24  sky = GetSkyTable ();
    3025  skylist = SkyListByRadius (sky, -1, Ra, Dec, Radius);
    3126
    3227  for (i = 0; i < skylist[0].Nregions; i++) {
    33     if (stat (skylist[0].regions[i][0].filename, &filestat) != -1) {
    34       fprintf (stderr, "%3d %s *\n", i, regions[i].name);
     28    if (stat ((char *) skylist[0].regions[i][0].filename, &filestat) != -1) {
     29      fprintf (stderr, "%3d %s *\n", i, skylist[0].regions[i][0].name);
    3530    } else {
    36       fprintf (stderr, "%3d %s\n", i, regions[i].name);
     31      fprintf (stderr, "%3d %s\n", i, skylist[0].regions[i][0].name);
    3732    }
    38     set_str_variable ("CATNAME", regions[i].name);
     33    set_str_variable ("CATNAME", (char *) skylist[0].regions[i][0].filename);
    3934  }
    4035
    4136  return (TRUE);
    42   SkyListFree (regions);
     37  SkyListFree (skylist, FALSE);
    4338}
  • trunk/Ohana/src/opihi/dvo/gstar.c

    r5448 r5451  
    55int gstar (int argc, char **argv) {
    66 
    7   char filename[128], catdir[256], *date;
     7  char *date;
    88  double Ra, Dec, Radius, Radius2, r, dec0, dec1;
    99  double Mcat, Mrel;
     
    1818  PhotCode *code;
    1919
    20   if (VarConfig ("CATDIR", "%s", catdir) == NULL) return (FALSE);
    21 
    2220  if (!InitPhotcodes ()) return (FALSE);
    2321  Nsec = GetPhotcodeNsecfilt ();
     
    5452 
    5553  /* load sky from correct table */
    56   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
    57   SkyTableSetFilenames (sky, CATDIR, "cpt");
     54  sky = GetSkyTable ();
    5855  skylist = SkyListByRadius (sky, -1, Ra, Dec, Radius);
    5956
     
    6360
    6461  /* lock, load, unlock catalog */
    65   catalog.filename = skylist[0].regions[0][0].filename;
     62  catalog.filename = (char *) skylist[0].regions[0][0].filename;
    6663  switch (lock_catalog (&catalog, LCK_SOFT)) {
    6764  case 2:
  • trunk/Ohana/src/opihi/dvo/imdata.c

    r5448 r5451  
    44 
    55  int i, j, k, I;
    6   int Nimage, N, NPTS, skip, mode, TimeSelect;
    7   int n, Nregion, Ntregion, TimeFormat;
     6  int Nimage, N, NPTS, found, mode, TimeSelect;
     7  int n, Nregions, NREGIONS, TimeFormat;
    88  int *subset, Nsubset;
    9   char filename[256];
    109  double trange;
    1110  unsigned long tzero, start, stop, TimeReference;
     
    8180
    8281  /* load sky from correct table */
    83   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
    84   SkyTableSetFilenames (sky, CATDIR, "cpt");
     82  sky = GetSkyTable ();
    8583
    8684  Nregions = 0;
    8785  NREGIONS = 10;
    8886  ALLOCATE (skylist, SkyList, 1);
    89   ALLOCATE (skylist[0].regions, SkyRegions *, NREGIONS);
     87  ALLOCATE (skylist[0].regions, SkyRegion *, NREGIONS);
    9088
    9189  /* for each image of interest, find the appropriate region files */
     
    9492
    9593    if (!FindMosaicForImage (image, Nimage, I)) continue;
    96     skyset = SkyListByImage (table, -1, &image[I]);
     94    skyset = SkyListByImage (sky, -1, &image[I]);
    9795
    9896    for (j = 0; j < skyset[0].Nregions; j++) {
    9997      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);
     98      for (k = 0; (k < skylist[0].Nregions) && !found; k++) {
     99        found = !strcmp (skylist[0].regions[k][0].name, skyset[0].regions[j][0].name);
    102100      }
    103101      if (found) continue;
    104102      skylist[0].regions[Nregions] = skyset[0].regions[j];
    105103      Nregions ++;
    106       CHECK_REALLOCATE (skylist[0].regions, SkyRegions *, NREGIONS, Nregions, 10);
    107     }
    108     SkyListFree (skyset);
     104      CHECK_REALLOCATE (skylist[0].regions, SkyRegion *, NREGIONS, Nregions, 10);
     105    }
     106    SkyListFree (skyset, FALSE);
    109107  }     
    110108  free (subset);
     
    122120
    123121    /* get file name and open */
    124     catalog.filename = skylist[0].regions[j][0].filename;
     122    catalog.filename = (char *) skylist[0].regions[j][0].filename;
    125123    switch (lock_catalog (&catalog, LCK_SOFT)) {
    126124    case 2:
  • trunk/Ohana/src/opihi/dvo/init.c

    r5448 r5451  
    112112    AddCommand (&cmds[i]);
    113113  }
    114 
    115114}
  • trunk/Ohana/src/opihi/dvo/lcat.c

    r5448 r5451  
    44 
    55  double Radius;
    6   int i, N, Nregions, ShowAll;
    7   char filename[128], exists;
     6  int i, N, ShowAll;
     7  char exists;
    88  struct stat filestat;
    9   char catdir[256];
    109  Graphdata graphmode;
    1110  int Ngraph;
     
    1514  Ngraph = 0;
    1615  if (!GetGraphData (&graphmode, NULL, &Ngraph)) return (FALSE);
    17 
    18   VarConfig ("CATDIR", "%s", catdir);
    19 
    20   /* load sky from correct table */
    21   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
    22   SkyTableSetFilenames (sky, CATDIR, "cpt");
    2316
    2417  ShowAll = FALSE;
     
    3326
    3427  Radius = MAX (fabs(graphmode.xmax), fabs(graphmode.ymax));
     28
     29  /* load sky from correct table */
     30  sky = GetSkyTable ();
    3531  skylist = SkyListByRadius (sky, -1, graphmode.coords.crval1, graphmode.coords.crval2, Radius);
    3632
    3733  for (i = 0; i < skylist[0].Nregions; i++) {
    3834    exists = 'Y';
    39     if (stat (skylist[0].regions[i][0].filename, &filestat) == -1) exists = 'N';
     35    if (stat ((char *) skylist[0].regions[i][0].filename, &filestat) == -1) exists = 'N';
    4036    if (ShowAll) {
    4137      fprintf (stderr, "%3d %s  %c\n", i, skylist[0].regions[i][0].name, exists);
     
    4743  }
    4844
     45  SkyListFree (skylist, FALSE);
    4946  return (TRUE);
    50   SkyListFree (regions);
    5147}
    5248
  • trunk/Ohana/src/opihi/dvo/lcurve.c

    r5448 r5451  
    33int lcurve (int argc, char **argv) {
    44 
    5   char filename[128], string[128], catdir[256], *p;
     5  char string[128], *p;
    66  double Ra, Dec, Radius, Radius2, r;
    77  float *RA, *DEC;
     
    1818  SkyList *skylist;
    1919
    20   VarConfig ("CATDIR", "%s", catdir);
    21 
    2220  if (!InitPhotcodes ()) return (FALSE);
    2321
     
    7068  }
    7169 
    72   /* load sky from correct table */
    73   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
    74   SkyTableSetFilenames (sky, CATDIR, "cpt");
    75 
    7670  Ra = atof (argv[1]);
    7771  Dec = atof (argv[2]);
    7872  Radius = atof (argv[3]);
    7973
     74  /* load sky from correct table */
     75  sky = GetSkyTable ();
    8076  skylist = SkyListByRadius (sky, -1, Ra, Dec, Radius);
    8177
     
    8581
    8682  /* set filename, read in header */
    87   catalog.filename = skylist[0].regions[0][0].filename;
     83  catalog.filename = (char *) skylist[0].regions[0][0].filename;
    8884  switch (lock_catalog (&catalog, LCK_SOFT)) {
    8985  case 2:
     
    202198  if (catalog.measure != 0) free (catalog.measure);
    203199 
    204   SkyListFree (skylist);
     200  SkyListFree (skylist, FALSE);
    205201  return (TRUE);
    206202}
  • trunk/Ohana/src/opihi/dvo/lightcurve.c

    r5448 r5451  
    33int lightcurve (int argc, char **argv) {
    44 
    5   char filename[128], catdir[256];
    65  double Ra, Dec, Radius, Radius2, r;
    76  float *RA, *DEC;
     
    98  int i, j, k, m, N, NPTS, Nsec, RELPHOT, *N1, TimeFormat;
    109  time_t TimeReference;
     10
     11  PhotCode *code;
     12  Catalog catalog;
     13  SkyTable *sky;
     14  SkyList *skylist;
    1115  Vector *tvec, *mvec, *dmvec;
    12   Catalog catalog;
    13   PhotCode *code;
    14 
    15   VarConfig ("CATDIR", "%s", catdir);
    1616
    1717  if (!InitPhotcodes ()) return (FALSE);
     
    4949  Radius = atof (argv[3]);
    5050
    51   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
    52   SkyTableSetFilenames (sky, CATDIR, "cpt");
     51  sky = GetSkyTable ();
    5352  skylist = SkyListByRadius (sky, -1, Ra, Dec, Radius);
    5453
     
    5857
    5958  /* set filename, read in header */
    60   catalog.filename = skylist[0].regions[0][0].filename;
     59  catalog.filename = (char *) skylist[0].regions[0][0].filename;
    6160  switch (lock_catalog (&catalog, LCK_SOFT)) {
    6261  case 2:
     
    148147  if (catalog.secfilt != 0) free (catalog.secfilt);
    149148 
    150   SkyListFree (skylist);
     149  SkyListFree (skylist, FALSE);
    151150  return (TRUE);
    152151}
  • trunk/Ohana/src/opihi/dvo/mextract.c

    r5320 r5451  
    44 
    55  int i, j, k, m, N, N1, NPTS;
    6   int param, mode, Nregions, Nsec;
    7   char filename[128], catdir[256], *RegionName, *RegionList, *p;
     6  int param, mode, Nsec;
     7  char *RegionName, *RegionList, *p;
    88  double *M1;
    99
    1010  PhotCode *code;
    1111  Catalog catalog;
    12   RegionFile *regions;
     12  SkyList *skylist;
    1313  Vector *vec;
    1414
    1515  /* defaults */
    16   regions = NULL;
    1716  catalog.average = (Average *) NULL;
    1817  catalog.secfilt = (SecFilt *) NULL;
     
    2625  if (!InitPhotcodes ()) goto escape;
    2726  Nsec = GetPhotcodeNsecfilt ();
    28 
    29   /* find CATDIR in config system */
    30   if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
    3127
    3228  /* interpret command-line options */
     
    5147
    5248  /* load region corresponding to selection above */
    53   if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
    54   if (!SetImageSelection (param)) goto escape;
     49  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
     50  if (!SetImageSelection (param, ((RegionName == NULL) && (RegionList == NULL)))) goto escape;
    5551
    5652  /* create storage vector */
     
    5955  if ((vec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto escape;
    6056
    61   for (i = 0; i < Nregions; i++) {
    62     /* lock, load, unlock catalog */
    63     sprintf (filename, "%s/%s", catdir, regions[i].name);
    64     catalog.filename = filename;
     57  for (i = 0; i < skylist[0].Nregions; i++) {
     58    catalog.filename = (char *) skylist[0].regions[i][0].filename;
    6559    switch (lock_catalog (&catalog, LCK_SOFT)) {
    6660    case 2:
     
    9791  REALLOCATE (vec[0].elements, float, MAX(1,N));
    9892
    99   if (regions != NULL) free (regions);
    10093  FreeImageSelection ();
     94  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
     95  if (RegionName != NULL) free (RegionName);
     96  if (RegionList != NULL) free (RegionList);
    10197  return (TRUE);
    10298
     
    108104escape:
    109105  FreeImageSelection ();
    110   if (regions != NULL) free (regions);
     106  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    111107  if (catalog.average != NULL) free (catalog.average);
    112108  if (catalog.secfilt != NULL) free (catalog.secfilt);
  • trunk/Ohana/src/opihi/dvo/pmeasure.c

    r5448 r5451  
    66  int i, j, k, m, N;
    77  int Ngraph;
    8   char filename[128], catdir[256];
    98  double Mz, Mr, mag;
    109  double Radius, Rmin, Rmax;
     
    2221  if (!InitPhotcodes ()) return (FALSE);
    2322  if (!GetGraph (&graphmode, NULL, &Ngraph)) return (FALSE);
    24   if (VarConfig ("CATDIR", "%s", catdir) == NULL) return (FALSE);
    2523
    2624  f = (FILE *) NULL;
     
    7674
    7775  /* load sky from correct table */
    78   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
    79   SkyTableSetFilenames (sky, CATDIR, "cpt");
     76  sky = GetSkyTable ();
    8077  skylist = SkyListByRadius (sky, -1, graphmode.coords.crval1, graphmode.coords.crval2, Radius);
    8178 
     
    8481   
    8582    /* lock, load, unlock catalog */
    86     catalog.filename = skylist[0].regions[j][0].filename;
     83    catalog.filename = (char *) skylist[0].regions[j][0].filename;
    8784    switch (lock_catalog (&catalog, LCK_SOFT)) {
    8885    case 2:
  • trunk/Ohana/src/opihi/dvo/region_list.c

    r5448 r5451  
    55   information carried back up */
    66
    7 static int RegionSelect;
     7static char *CATDIR  = NULL;
     8static SkyTable *sky = NULL;
    89
    9 int GetRegionSelection () {
    10   return (RegionSelect);
     10int SetCATDIR (char *path, int verbose) {
     11
     12  char *newpath;
     13  char catdir[256];
     14  char gscfile[256];
     15  char skyfile[256];
     16  int  skydepth;
     17
     18  /* find CATDIR in config system */
     19  if (path == NULL) {
     20    if (VarConfig ("CATDIR", "%s", catdir) == NULL) return (FALSE);
     21    newpath = catdir;
     22  } else {
     23    newpath = path;
     24  }
     25
     26  if (CATDIR != NULL) free (CATDIR);
     27  CATDIR = strcreate (newpath);
     28
     29  if (VarConfig ("GSCFILE",  "%s", gscfile) == NULL) gscfile[0] = 0;
     30  if (VarConfig ("SKYFILE",  "%s", skyfile) == NULL) skyfile[0] = 0;
     31  if (VarConfig ("SKYDEPTH", "%d", &skydepth) == NULL) skydepth = 2;
     32
     33  /* load the SkyTable at this point */
     34  /* set the image path as well */
     35
     36  if (sky != NULL) SkyTableFree (sky);
     37  sky = SkyTableLoadOptimal (catdir, skyfile, gscfile, skydepth, verbose);
     38  SkyTableSetFilenames (sky, catdir, "cpt");
     39
     40  return (TRUE);
     41}
     42
     43SkyTable *GetSkyTable () {
     44  return (sky);
    1145}
    1246
     
    1448 
    1549  int N;
    16 
    17   RegionSelect = FALSE;
    1850
    1951  /* check for Region selection */
     
    3365    return (TRUE);
    3466  }
    35   if ((*RegionName == NULL) && (*RegionList == NULL)) {
    36     RegionSelect = TRUE;
    37     return (TRUE);
    38   }
     67  if ((*RegionName == NULL) && (*RegionList == NULL)) return (TRUE);
    3968
    4069  fprintf (stderr, "-cpt and -cptlist are incompatible\n");
     
    4675}
    4776
     77/* given possible options (by name, by list, by graph region), select SkyRegions */
    4878SkyList *SelectRegions (char *RegionName, char *RegionList) {
    4979
     
    5383  SkyTable *sky;
    5484  SkyList *skylist;
     85  char filename[256];
    5586
    5687  /* determine region-file names */
    5788  if (RegionName != NULL) {
    5889    ALLOCATE (skylist, SkyList, 1);
    59     ALLOCATE (skylist[0].regions[0], SkyRegion *, 1);
    60     ALLOCATE (skylist[0].regions[0][0], SkyRegion, 1);
     90    ALLOCATE (skylist[0].regions, SkyRegion *, 1);
     91    ALLOCATE (skylist[0].regions[0], SkyRegion, 1);
    6192    strcpy (skylist[0].regions[0][0].name, RegionName);
    6293    sprintf (filename, "%s/%s.cpt", CATDIR, RegionName);
    63     skylist[0].regions[0][0].filename = strcreate (filename);
     94    skylist[0].regions[0][0].filename = (e_void) strcreate (filename);
    6495    free (RegionName);
    6596    RegionName = NULL;
     
    80111
    81112  Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
    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);
     113  skylist = SkyListByRadius (sky, -1, graphsky.coords.crval1, graphsky.coords.crval2, Radius);
    87114
    88115  return (skylist);
    89116}
    90117
    91 /* XXX EAM this should perhaps return a skytable? */
    92118/* returns a list of region files names from file */
    93 SkyList *SkyListFromFile (char *filename) {
     119SkyList *SkyListLoadFile (char *filename) {
    94120 
    95121  FILE *f;
    96   int NREGIONS, nregion;
     122  int NREGIONS, Nregions;
    97123  SkyList *skylist;
    98124
     
    115141    strcpy (skylist[0].regions[Nregions][0].name, filename);
    116142    sprintf (filename, "%s/%s.cpt", CATDIR, skylist[0].regions[Nregions][0].name);
    117     skylist[0].regions[Nregions][0].filename = strcreate (filename);
     143    skylist[0].regions[Nregions][0].filename = (e_void) strcreate (filename);
    118144    Nregions ++;
    119145    CHECK_REALLOCATE (skylist[0].regions, SkyRegion *, NREGIONS, Nregions, 50);
    120     }
    121146  }
    122 
    123   *Nregions = nregion;
    124   return (regions);
     147  skylist[0].Nregions = Nregions;
     148  return (skylist);
    125149}
    126150
  • trunk/Ohana/src/opihi/dvo/skycat.c

    r5442 r5451  
    11# include "dvo1.h"
     2
     3int RD_to_XYpic (double *x, double *y, double r, double d, Coords *coords, double Rmin, double Rmax, double Rmid, int *leftside);
    24
    35int skycat (int argc, char **argv) {
     
    57  double Radius;
    68  int i, j, N, Nregions, ShowAll, NPTS, Npts, leftside, Depth, TableDepth;
    7   char filename[128];
    89  struct stat filestat;
    910  Vector Xvec, Yvec;
    1011  Graphdata graphmode;
    1112  double X[4], Y[4], Rmin, Rmax, Rmid;
    12   char catdir[256], gscfile[256];
    1313  int Ngraph, VERBOSE;
    1414  SkyTable *sky;
    1515  SkyList *skylist;
    1616  SkyRegion **regions;
    17 
    18   VarConfig ("CATDIR", "%s", catdir);
    19   VarConfig ("GSCFILE", "%s", gscfile);
    2017
    2118  VERBOSE = FALSE;
     
    4542
    4643  Radius = MAX (fabs(graphmode.xmax), fabs(graphmode.ymax));
    47   sky = SkyTableFromGSC (gscfile, TableDepth, VERBOSE);
    48   if (sky == NULL) return (FALSE);
     44
     45  sky = GetSkyTable ();
    4946  skylist = SkyListByRadius (sky, Depth, graphmode.coords.crval1, graphmode.coords.crval2, Radius);
    5047 
     
    6663
    6764  for (i = 0; i < Nregions; i++) {
    68     sprintf (filename, "%s/%s", catdir, regions[i][0].name);
    69     if (ShowAll || (stat (filename, &filestat) != -1)) {
     65    if (ShowAll || (stat ((char *) regions[i][0].filename, &filestat) != -1)) {
    7066      if (VERBOSE) fprintf (stderr, "%3d %s %6.2f - %6.2f, %6.2f - %6.2f\n", i, regions[i][0].name,
    7167                            regions[i][0].Rmin, regions[i][0].Rmax, regions[i][0].Dmin, regions[i][0].Dmax);
     
    114110
    115111}
     112
     113
     114int RD_to_XYpic (double *x, double *y, double r, double d, Coords *coords, double Rmin, double Rmax, double Rmid, int *leftside) {
     115
     116  while (r < Rmin) { r += 360.0; }
     117  while (r > Rmax) { r -= 360.0; }
     118
     119  if (*leftside == -1) {
     120    *leftside = (r < Rmid);
     121  } else {
     122    if (  *leftside && (r > Rmid + 90)) { r -= 360.0; }
     123    if (! *leftside && (r < Rmid - 90)) { r += 360.0; }
     124  }
     125
     126  RD_to_XY (x, y, r, d, coords);
     127
     128  return (TRUE);
     129}
  • trunk/Ohana/src/opihi/dvo/subpix.c

    r5448 r5451  
    1313  double Ra, Dec, Radius, Radius2, r, Rmin;
    1414  double *RA, *DEC;
    15   char catdir[256], filename[256];
    1615 
     16  SkyTable *sky;
     17  SkyList *skylist;
    1718  Measure *measure;
    1819  Image *image;
     
    2021
    2122  if (!InitPhotcodes ()) return (FALSE);
    22 
    23   VarConfig ("CATDIR", "%s", catdir);
    2423
    2524  GetTimeFormat (&TimeReference, &TimeFormat);
     
    3433  Radius = atof (argv[3]);
    3534
    36   /* load sky from correct table */
    37   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
    38   SkyTableSetFilenames (sky, CATDIR, "cpt");
    39 
    4035  /* load star nearest position */
     36  sky = GetSkyTable ();
    4137  skylist = SkyListByRadius (sky, -1, Ra, Dec, Radius);
    4238  if (skylist[0].Nregions > 1) {
     
    4541
    4642  /* lock, load, unlock catalog */
    47   catalog.filename = skylist[0].regions[0][0].filename;
     43  catalog.filename = (char *) skylist[0].regions[0][0].filename;
    4844  switch (lock_catalog (&catalog, LCK_SOFT)) {
    4945  case 2:
     
    9490    if (catalog.average != 0) free (catalog.average);
    9591    if (catalog.measure != 0) free (catalog.measure);
    96     SkyListFree (skylist);
     92    SkyListFree (skylist, FALSE);
    9793    return (TRUE);
    9894  }
     
    160156  free (image);
    161157  free (index);
    162   SkyListFree (regions);
     158  SkyListFree (skylist, FALSE);
    163159
    164160  return (TRUE);
  • trunk/Ohana/src/opihi/include/dvo1.h

    r5442 r5451  
    5757int           GetMeasureTypeCode    PROTO((Measure *measure));
    5858int           GetPhotcodeInfo       PROTO((char *string, PhotCode **Code, int *Mode));
    59 int           GetRegionSelection    PROTO(());
    6059int           GetSelectionParam     PROTO(());
    6160int           GetTimeSelection      PROTO((time_t *tz, time_t *te));
     
    6867int           Quality               PROTO((Measure *measure, int IsDophot));
    6968int           SelectMags            PROTO((int Nphot, int Tphot, int Ns, Average *average, Measure *measure, SecFilt *secfilt, int UL));
    70 RegionFile   *SelectRegions         PROTO((char *RegionName, char *RegionList, int *nregions));
    71 int           SetImageSelection     PROTO((int mode));
     69
     70SkyList      *SelectRegions         PROTO((char *RegionName, char *RegionList));
     71SkyList      *SkyListLoadFile       PROTO((char *filename));
     72int           SetCATDIR             PROTO((char *path, int verbose));
     73SkyTable     *GetSkyTable           PROTO(());
     74SkyList      *SkyListFromFile       PROTO((char *filename));
     75int           SetRegionSelection    PROTO((int *argc, char **argv, char **RegionName, char **RegionList));
     76
     77int           SetImageSelection     PROTO((int mode, int RegionSelect));
    7278int           SetPhotSelections     PROTO((int *argc, char **argv, int Nparams));
    73 int           SetRegionSelection    PROTO((int *argc, char **argv, char **RegionName, char **RegionList));
    7479int           SetSelectionParam     PROTO((int param));
    7580int           TestAverage           PROTO((PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure));
    7681int           TestPhotSelections    PROTO((PhotCode **code, int *mode, int param));
    77 void          aregion               PROTO((GSCRegion *region, FILE *f, double ra, double dec, char *path));
    7882void          compare               PROTO((Catalog *catlog1, Catalog *catlog2, Vector *rvec,  Vector *dvec,  Vector *mvec, Vector *drvec, Vector *ddvec, Vector *dmvec, double radius));
    7983void          cprecess              PROTO((Average *average, int Naverage, double in_epoch, double out_epoch));
    80 RegionFile   *find_regions          PROTO((double Ra, double Dec, double radius, int *Nregions));
    81 GSCRegion    *get_regions           PROTO((Image *image, int *Nregions));
    8284void          image_subset          PROTO((Image *image, int Nimage, int **Subset, int *Nsubset, Graphdata *graph, int RegionSelect, unsigned long int tzero, double trange, int TimeSelect));
    8385int           match_image           PROTO((Image *image, int Nimage, unsigned int T, short int S));
    8486int           match_image_subset    PROTO((Image *image, int *subset, int Nsubset, unsigned int T, short int S));
    8587void          print_value           PROTO((FILE *f, double value, short int ival));
    86 RegionFile   *region_list           PROTO((char *filename, int *Nregions));
    8788void          sort_image_subset     PROTO((Image *image, int *subset, int N));
    8889void          sort_images           PROTO((Image *image, int N));
    8990void          sortave               PROTO((Average *ave, int N));
    90 CMPstars *cmpReadFits (FILE *f, int *nstars);
    91 CMPstars *cmpReadText (FILE *f, int *nstars);
    92 int RD_to_XYpic (double *x, double *y, double r, double d, Coords *coords, double Rmin, double Rmax, double Rmid, int *leftside);
     91CMPstars     *cmpReadFits           PROTO((FILE *f, int *nstars));
     92CMPstars     *cmpReadText           PROTO((FILE *f, int *nstars));
     93int           RD_to_XYpic           PROTO((double *x, double *y, double r, double d, Coords *coords, double Rmin, double Rmax, double Rmid, int *leftside));
     94
     95RegionFile   *find_regions          PROTO((double Ra, double Dec, double radius, int *Nregions));
     96GSCRegion    *get_regions           PROTO((Image *image, int *Nregions));
     97RegionFile   *region_list           PROTO((char *filename, int *Nregions));
     98void          aregion               PROTO((GSCRegion *region, FILE *f, double ra, double dec, char *path));
    9399
    94100# endif
Note: See TracChangeset for help on using the changeset viewer.