IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3593


Ignore:
Timestamp:
Mar 31, 2005, 7:38:37 AM (21 years ago)
Author:
eugene
Message:

working to autocode detreg

Location:
trunk/Ohana/src
Files:
2 added
13 edited

Legend:

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

    r3536 r3593  
    8181
    8282DETOBJ  = \
    83 $(DETREND)/db.$(ARCH).o        \
    84 $(DETREND)/define.$(ARCH).o    \
    8583$(DETREND)/criteria.$(ARCH).o  \
    8684$(DETREND)/define.$(ARCH).o    \
  • trunk/Ohana/src/imregister/detrend/altpath.c

    r2803 r3593  
    22# include "detrend.h"
    33
    4 int SetAltpath (Match *match, int Nmatch) {
     4int SetAltpath (FITS_DB *db, DetReg *image, int Nimage, Match *match, int Nmatch) {
    55 
    6   int i, j, n, found, status;
    7   int Nimage, Nlist;
     6  int i, j, n, found, status, Nlist;
    87  int *list, *current;
    98  char *dBPath, infile[256], outfile[256], line[1024];
    10   DetReg *image;
    119  struct stat statbuf;
    1210
    13   image = get_images (&Nimage);
    1411  ALLOCATE (current, int, Nimage);
    15 
    1612  ALLOCATE (list, int, Nimage);
    1713  Nlist = 0;
     
    4945      image[i].altpath = TRUE;
    5046    }
    51     update_db (list, Nlist);
    52     close_db ();
     47
     48    /** we may later want to pull this out and put it elsewhere **/
     49    fits_vtable_from_ftable (&db[0].ftable, &vtable, list, Nlist);
     50    for (i = 0; i < Nmatch; i++) {
     51      fits_convert_DetReg ((DetReg *) vtable.buffer[i], sizeof (DetReg), 1);
     52    }
     53    fits_db_update (db, &vtable);
     54    fits_db_close (db);
     55    fits_db_free (db);
     56
    5357    fprintf (stderr, "SUCCESS\n");
    5458    exit (0);
     
    7882      }
    7983    }
    80     update_db (list, Nlist);
    81     close_db ();
     84
     85    /** we may later want to pull this out and put it elsewhere **/
     86    fits_vtable_from_ftable (&db[0].ftable, &vtable, list, Nlist);
     87    for (i = 0; i < Nmatch; i++) {
     88      fits_convert_DetReg ((DetReg *) vtable.buffer[i], sizeof (DetReg), 1);
     89    }
     90    fits_db_update (db, &vtable);
     91    fits_db_close (db);
     92    fits_db_free (db);
     93
    8294    fprintf (stderr, "SUCCESS\n");
    8395    exit (0);
     
    99111      image[i].altpath = found;
    100112    }
    101     update_db (list, Nlist);
    102     close_db ();
     113
     114    /** we may later want to pull this out and put it elsewhere **/
     115    fits_vtable_from_ftable (&db[0].ftable, &vtable, list, Nlist);
     116    for (i = 0; i < Nmatch; i++) {
     117      fits_convert_DetReg ((DetReg *) vtable.buffer[i], sizeof (DetReg), 1);
     118    }
     119    fits_db_update (db, &vtable);
     120    fits_db_close (db);
     121    fits_db_free (db);
     122
    103123    fprintf (stderr, "SUCCESS\n");
    104124    exit (0);
  • trunk/Ohana/src/imregister/detrend/criteria.c

    r2803 r3593  
    6060*/
    6161
    62 Match *ExptimeCriteria (Match *match, int *nmatch) {
    63 
    64   int i, j, Nimage, Nmatch, Nnew, NNEW, entry;
     62Match *ExptimeCriteria (DetReg *image, int Nimage, Match *match, int *nmatch) {
     63
     64  int i, j, Nmatch, Nnew, NNEW, entry;
    6565  unsigned long dtime;
    6666  float Chi, ChiMin;
    67   DetReg *image;
    6867  Match *new;
    6968
    7069  Nmatch = *nmatch;
    71   image = get_images (&Nimage);
    7270
    7371  Nnew = 0;
     
    134132}
    135133
    136 Match *CloseCriteria (Match *match, int *nmatch) {
    137 
    138   int i, j, Nimage, Nmatch, Nnew, NNEW, Ngood, entry;
     134Match *CloseCriteria (DetReg *image, int Nimage, Match *match, int *nmatch) {
     135
     136  int i, j, Nmatch, Nnew, NNEW, Ngood, entry;
    139137  unsigned long dmin, dtime;
    140138  Match *new;
    141   DetReg *image;
    142 
    143   image = get_images (&Nimage);
    144139
    145140  Nmatch = *nmatch;
  • trunk/Ohana/src/imregister/detrend/delete.c

    r2823 r3593  
    22# include "detrend.h"
    33
    4 void DeleteSubset (Match *match, int Nmatch) {
     4void DeleteSubset (FITS_DB *db, DetReg *image, int Nimage, Match *match, int Nmatch) {
    55
    66  int i, j;
    7   int *keep, Ndel, Nimage, Nsubset;
    8   DetReg *image, *subset;
    9 
    10   image = get_images (&Nimage);
     7  int *keep, Ndel, Nsubset;
     8  DetReg *subset;
    119
    1210  ALLOCATE (keep, int, MAX (Nimage, 1));
     
    2321  }
    2422  fprintf (stderr, "delete %d images\n", Ndel);
    25  
    2623  if (Ndel == 0) {
    2724    fprintf (stderr, "SUCCESS\n");
    28     close_db ();
     25    fits_close_db (&db);
    2926    exit (0);
    3027  }
     
    3936    j ++;
    4037  }
    41 
    4238  free (keep);
    4339  free (image);
    44   set_images (subset, Nsubset);
    4540
    46   save_db ();
     41  /** we may later want to pull this out and put it elsewhere **/
     42  /** free db[0].theader, db[0].table.buffer? **/
     43  fits_table_set_DetReg (&db[0].ftable, subset, Nsubset);
     44  fits_db_save (db);
     45  fits_db_close (db);
     46  fits_db_free (db);
     47
    4748  fprintf (stderr, "SUCCESS\n");
    4849  exit (0);
  • trunk/Ohana/src/imregister/detrend/match.c

    r3 r3593  
    22# include "detrend.h"
    33
    4 Match *MatchCriteria (int *nmatch) {
     4Match *MatchCriteria (DetReg *image, int Nimage, int *nmatch) {
    55
    66  int i;
    7   int Nmatch, NMATCH, Nimage;
     7  int Nmatch, NMATCH;
    88  Match result, *match;
    9   DetReg *image;
    10 
    11   image = get_images (&Nimage);
    129
    1310  /* find entries that matches criteria */
  • trunk/Ohana/src/imregister/detrend/modify.c

    r2803 r3593  
    22# include "detrend.h"
    33
    4 int ModifySubset (Match *match, int Nmatch) {
     4int ModifySubset (FITS_DB *db, DetReg *image, int Nimage, Match *match, int Nmatch) {
    55 
    6   int i, j, Nimage, value;
     6  int i, j, value;
    77  int *list;
    8   DetReg *image;
    98 
    109  value = M_UNDEF;
    11   image = get_images (&Nimage);
    1210
    1311  ALLOCATE (list, int, Nimage);
     
    4543  }
    4644
    47   update_db (list, Nmatch);
    48   close_db ();
     45  /** we may later want to pull this out and put it elsewhere **/
     46  fits_vtable_from_ftable (&db[0].ftable, &vtable, match, Nmatch);
     47  for (i = 0; i < Nmatch; i++) {
     48    fits_convert_DetReg ((DetReg *) vtable.buffer[i], sizeof (DetReg), 1);
     49  }
     50  fits_db_update (db, &vtable);
     51  fits_db_close (db);
     52  fits_db_free (db);
     53
    4954  fprintf (stderr, "SUCCESS\n");
    5055  exit (0);
  • trunk/Ohana/src/imregister/detrend/output.c

    r2803 r3593  
    55extern double drand48();
    66
    7 int OutputSubset (Match *match, int Nmatch) {
    8 
    9   int Nimage;
    10   DetReg *image;
     7int OutputSubset (DetReg *image, int Nimage, Match *match, int Nmatch) {
    118
    129  image = get_images (&Nimage);
     
    3229  FTable table;
    3330  DetReg *subset;
    34 
    35   /* define table layout */
    36   define_table (&header, &matrix, &theader, &table);
     31  FILE *f;
    3732
    3833  ALLOCATE (subset, DetReg, MAX (1, Nmatch));
     
    4136    memcpy (&subset[i], &image[j], sizeof (DetReg));
    4237  }
    43   ConvertStruct ((char *) subset, sizeof (DetReg), Nmatch, "detreg");
    44   fits_add_rows (&table, (char *) subset, Nmatch, sizeof (DetReg));
    45 
    46   fits_write_header  (filename, &header);
    47   fits_write_matrix  (filename, &matrix);
    48   fits_write_Theader (filename, &theader);
    49   fits_write_table   (filename, &table);
     38
     39  /* open file for output */
     40  f = fopen (filename, "w");
     41  if (f == NULL) {
     42    fprintf (stderr, "ERROR: can't open output file %s\n", filename);
     43    exit (1);
     44  }
     45
     46  /* create primary header */
     47  fits_init_header (&header);   
     48  header.extend = TRUE;
     49  fits_create_header (&header);
     50  fits_create_matrix (&header, &matrix);
     51  fits_print (&header, "NEXTEND", "%d", 1, 1);
     52
     53  ftable.header = &theader;
     54  fits_table_set_DetReg (&ftable, subset, Nmatch);
     55
     56  fits_write_header  (f, &header);
     57  fits_write_matrix  (f, &matrix);
     58  fits_write_Theader (f, &theader);
     59  fits_write_table   (f, &table);
    5060  exit (0);
    5161}
     
    7888  fits_modify (&header,  "DATE", "%s", 1, datestr);
    7989  fits_modify (&theader, "DATE", "%s", 1, datestr);
     90  free (datestr);
    8091
    8192  /* define table layout */
  • trunk/Ohana/src/imregister/detrend/unique.c

    r2450 r3593  
    33
    44/* define a list of best images which have unique properties */
    5 Match *UniqueSubset (Match *match, int *nmatch) {
     5Match *UniqueSubset (DetReg *image, int Nimage, Match *match, int *nmatch) {
    66
    77  int Nsubset, Nunique, Ncrit, NCRIT;
    8   int i, j, N, Nmatch, Nimage, found;
     8  int i, j, N, Nmatch, found;
    99  Criteria *crit;
    1010  Match *subset, *unique, *local;
    11   DetReg *image;
    1211
    1312  Nmatch = *nmatch;
    1413  ALLOCATE (local, Match, Nmatch);
    15 
    16   image = get_images (&Nimage);
    1714
    1815  /* create a set of complete criteria derived from the images */
  • trunk/Ohana/src/imregister/include/detrend.h

    r3466 r3593  
    7272int args (int argc, char **argv);
    7373int DefineImage (char *filename, Descriptor *descriptor);
    74 int define_table (Header *header, Matrix *matrix, Header *theader, FTable *table);
     74DetReg DefineEntry (Descriptor descriptor);
     75
    7576char *get_dBPath ();
    76 DetReg DefineEntry (Descriptor descriptor);
    7777int SaveEntry (char *input, DetReg *newdata, char *ID);
    78 
    79 void init_db ();
    80 int load_db ();
    81 int save_db ();
    82 int update_db (int *match, int Nmatch);
    83 int append_db (DetReg *new, int Nnew);
    84 int create_db ();
    85 int close_db ();
    8678
    8779char **LoadRecipe (char *filter, int *nrecipe);
    8880
    89 Match *MatchCriteria (int *nmatch);
    90 Match *UniqueSubset (Match *match, int *nmatch);
    91 Match *CloseCriteria (Match *match, int *nmatch);
    92 Match *ExptimeCriteria (Match *match, int *nmatch);
     81Match *MatchCriteria (DetReg *image, int Nimage, int *nmatch);
     82Match *UniqueSubset (DetReg *image, int Nimage, Match *match, int *nmatch);
     83Match *ExptimeCriteria (DetReg *image, int Nimage, Match *match, int *nmatch);
     84Match *CloseCriteria (DetReg *image, int Nimage, Match *match, int *nmatch);
    9385
    9486Match CheckCriteria (DetReg *image);
    95 DetReg *get_images (int *N);
    96 int set_images (DetReg *new, int Nnew);
    9787
    9888int delete_image (DetReg *image);
    99 int OutputSubset (Match *match, int Nmatch);
     89int OutputSubset (DetReg *image, int Nimage, Match *match, int Nmatch);
    10090int DumpFitsTable (char *filename, DetReg *detdata, Match *match, int Nmatch);
    10191int PrintSubset (DetReg *detdata, Match *match, int Nmatch);
    10292Match SelectEntry (Match *list, int Nlist, Criteria *crit);
    10393
    104 int ModifySubset (Match *match, int Nmatch);
    105 void DeleteSubset (Match *match, int Nmatch);
     94int ModifySubset (DetReg *image, int Nimage, Match *match, int Nmatch);
     95void DeleteSubset (DetReg *image, int Nimage, Match *match, int Nmatch);
     96
    10697int usage ();
    10798Criteria *MosaicCriteria (Criteria base, char *filename, int *ncrit);
  • trunk/Ohana/src/imregister/spreg/delete.c

    r3509 r3593  
    2020  }
    2121  fprintf (stderr, "delete %d spectra\n", Nbad);
     22  if (Nbad == 0) {
     23    fprintf (stderr, "SUCCESS\n");
     24    fits_close_db (&db);
     25    exit (0);
     26  }
    2227
    2328  Nsubset = Nspectrum - Nbad;
     
    2934    j++;
    3035  }
    31 
    3236  free (keep);
     37  free (spectrum);
    3338
    3439  /** we may later want to pull this out and put it elsewhere **/
  • trunk/Ohana/src/imregister/src/detsearch.c

    r2823 r3593  
    11# include "imregister.h"
    22# include "detrend.h"
    3 static char *version = "detsearch $Revision: 3.3 $";
     3static char *version = "detsearch $Revision: 3.4 $";
    44
    55int main (int argc, char **argv) {
     
    1515  if (output.Criteria) PrintCriteria ();
    1616       
    17   init_db ();
    18   status = load_db ();
    19   if (!status) {
    20     close_db ();
    21     fprintf (stderr, "database missing or empty\n");
    22     exit (0);
     17  db.lockstate = (output.modify || output.delete) ? LCK_HARD : LCK_SOFT;
     18  db.timeout   = 300.0;
     19  fits_db_init (&db);
     20
     21  dBFile = set_db_name ();
     22  if (!fits_db_lock (&db, dBFile)) {
     23    fits_db_close (&db);
     24    exit (1);
    2325  }
    24   if (!output.Modify && !output.Delete && !output.Altpath) close_db ();
    2526 
    26   match = MatchCriteria (&Nmatch);          /* match basic criteria */
    27   match = ExptimeCriteria (match, &Nmatch); /* reduce matches based on Exptime */
    28   match = CloseCriteria (match, &Nmatch);   /* reduce matches based on closeness */
     27  if (!fits_db_load (&db)) {
     28    fits_db_close (&db);
     29    exit (1);
     30  }
     31
     32  if (!output.Modify && !output.Delete && !output.Altpath) fits_close_db (&db);
     33  detrend = fits_table_get_DetReg (&db.ftable, &Ndetrend);
     34 
     35  match = MatchCriteria (detrend, Ndetrend, &Nmatch);          /* match basic criteria */
     36  match = ExptimeCriteria (detrend, Ndetrend, match, &Nmatch); /* reduce matches based on Exptime */
     37  match = CloseCriteria (detrend, Ndetrend, match, &Nmatch);   /* reduce matches based on closeness */
    2938
    3039  if (output.Select) {
    31     match = UniqueSubset (match, &Nmatch);
     40    match = UniqueSubset (detrend, Ndetrend, match, &Nmatch);
    3241    if (Nmatch == 0) {
    3342      if (output.verbose) fprintf (stderr, "ERROR: can't find any valid detrend files (%s %s %d)\n", get_type_name(criteria[0].Type), filtername[criteria[0].Filter], criteria[0].CCD);
    34       close_db ();
     43      fits_close_db (&db);
    3544      exit (1);
    3645    }
    3746  }
    3847
    39   if (output.Altpath) SetAltpath (match, Nmatch);
    40   if (output.Modify) ModifySubset (match, Nmatch);
    41   if (output.Delete) DeleteSubset (match, Nmatch);
     48  if (output.Altpath) SetAltpath (&db, detrend, Ndetrend, match, Nmatch);
     49  if (output.Modify) ModifySubset (&db, detrend, Ndetrend, match, Nmatch);
     50  if (output.Delete) DeleteSubset (&db, detrend, Ndetrend, match, Nmatch);
    4251
    43   OutputSubset (match, Nmatch);
     52  OutputSubset (detrend, Ndetrend, match, Nmatch);
    4453  exit (0);
    4554}
  • trunk/Ohana/src/libautocode/Makefile

    r3536 r3593  
    2929# remember to add entries here to libohana/Makefile:AOBJ as well
    3030LIBOBJ = \
     31$(SRC)/detreg.$(ARCH).o \
    3132$(SRC)/photreg.$(ARCH).o \
    3233$(SRC)/photreg-old.$(ARCH).o \
     
    3637
    3738LIBINC = \
     39$(INC)/detreg.h \
    3840$(INC)/photreg.h \
    3941$(INC)/photreg-old.h \
  • trunk/Ohana/src/libohana/Makefile

    r3536 r3593  
    4848
    4949AOBJ = \
     50$(ASRC)/detreg.$(ARCH).o \
    5051$(ASRC)/photreg.$(ARCH).o \
    5152$(ASRC)/photreg-old.$(ARCH).o \
Note: See TracChangeset for help on using the changeset viewer.