IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27770


Ignore:
Timestamp:
Apr 25, 2010, 1:37:59 PM (16 years ago)
Author:
eugene
Message:

finish setphot so it now works (tested against yz.20100320/catdir.setphot)

Location:
branches/eam_branches/Ohana.20100407/src/uniphot
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/Ohana.20100407/src/uniphot/Makefile

    r12842 r27770  
    1 default: uniphot
     1default: uniphot setphot
    22help:
    3         @echo "make options: uniphot (default)"
     3@echo "make options: uniphot setphot default help install default (uniphot setphot)"
    44
    55include ../../Makefile.System
     
    1818
    1919uniphot: $(BIN)/uniphot.$(ARCH)
    20 install: $(DESTBIN)/uniphot
     20setphot: $(BIN)/setphot.$(ARCH)
     21install: $(DESTBIN)/uniphot $(DESTBIN)/setphot
    2122
    2223UNIPHOT = \
     
    2425$(SRC)/initialize.$(ARCH).o         \
    2526$(SRC)/ConfigInit.$(ARCH).o         \
    26 $(SRC)/args.$(ARCH).o               \
     27$(SRC)/args.$(ARCH).o               \
    2728$(SRC)/liststats.$(ARCH).o          \
    2829$(SRC)/load_images.$(ARCH).o        \
     
    3940$(UNIPHOT): $(INC)/uniphot.h
    4041$(BIN)/uniphot.$(ARCH): $(UNIPHOT)
     42
     43SETPHOT = \
     44$(SRC)/setphot.$(ARCH).o            \
     45$(SRC)/initialize.$(ARCH).o         \
     46$(SRC)/ConfigInit.$(ARCH).o         \
     47$(SRC)/args.$(ARCH).o               \
     48$(SRC)/liststats.$(ARCH).o          \
     49$(SRC)/load_zpt_table.$(ARCH).o     \
     50$(SRC)/load_images.$(ARCH).o        \
     51$(SRC)/match_zpts_to_images.$(ARCH).o       \
     52$(SRC)/update_catalog_setphot.$(ARCH).o \
     53$(SRC)/SetSignals.$(ARCH).o         \
     54$(SRC)/Shutdown.$(ARCH).o           
     55
     56$(SETPHOT): $(INC)/uniphot.h
     57$(BIN)/setphot.$(ARCH): $(SETPHOT)
  • branches/eam_branches/Ohana.20100407/src/uniphot/include/uniphot.h

    r27435 r27770  
    3939} Group;
    4040
     41typedef struct {
     42    float zpt;
     43    e_time time;
     44    int found;
     45} ZptTable;
     46
    4147/* global variables set in parameter file */
    4248char         ImageCat[256];
     
    4450char         CATMODE[16];    /* raw, mef, split, mysql */
    4551char         CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
     52char         SKY_TABLE[256];
     53int          SKY_DEPTH;  /** XXX EAM : depth of catalog tables, fix usage */
     54char         GSCFILE[256];
    4655char         STATMODE[64];
    4756int          VERBOSE;
     
    6675
    6776/***** prototypes ****/
    68 void          ConfigInit         PROTO((int *argc, char **argv));
    69 void          DonePlotting       PROTO((Graphdata *graphmode, int N));
    70 void          JpegPlot           PROTO((Graphdata *graphmode, int N, char *filename));
    71 void          PSPlot             PROTO((Graphdata *graphmode, int N, char *filename));
    72 void          PlotLabel          PROTO((char *string, int N));
    73 void          PlotVector         PROTO((int Npts, double *vect, int mode, int N));
    74 void          PrepPlotting       PROTO((int Npts, Graphdata *graphmode, int N));
    75 void          XDead              PROTO((void));
    76 int           args               PROTO((int argc, char **argv));
    77 void          dumpresult         PROTO((void));
    78 Group        *find_image_sgroups PROTO((FITS_DB *db, ImageLink **imlink, int *Nsgroup));
    79 Group        *find_image_tgroups PROTO((FITS_DB *db, ImageLink **imlink, int *Ntgroup));
    80 void          fit_sgroup         PROTO((Group *sgroup, int Nsgroup));
    81 void          fit_tgroup         PROTO((Group *tgroup, int Ntgroup));
    82 int           gcatalog           PROTO((Catalog *catalog));
    83 void          initialize         PROTO((int argc, char **argv));
    84 void          initstats          PROTO((char *mode));
    85 int           liststats          PROTO((double *value, double *dvalue, int N, StatType *stats));
    86 int           load_images        PROTO((FITS_DB *db));
    87 int           main               PROTO((int argc, char **argv));
    88 int           open_graph         PROTO((int N));
    89 void          sort               PROTO((unsigned int *X, int N));
    90 void          sortB              PROTO((double *X, double *Y, int N));
    91 void          sortD              PROTO((double *X, double *Y, double *Z, int N));
    92 void          update_dvo_catalog PROTO((Catalog *catalog, Group *sgroup, int warn));
    93 void          wcatalog           PROTO((Catalog *catalog));
    94 void          wimages            PROTO((Image *image, int Nimage));
    95 void          check_permissions  PROTO((char *basefile));
    96 void          lock_image_db      PROTO((FITS_DB *db, char *filename));
    97 void          unlock_image_db    PROTO((FITS_DB *db));
    98 void          create_image_db    PROTO((FITS_DB *db));
    99 void          set_db             PROTO((FITS_DB *in));
    100 int           Shutdown           PROTO((char *format, ...) OHANA_FORMAT(printf, 1, 2) );
    101 void          TrapSignal         PROTO((int sig));
    102 void          SetProtect         PROTO((int mode));
    103 int           SetSignals         PROTO((void));
    104 int           subset_images      PROTO((FITS_DB *db));
    105 void          update             PROTO((FITS_DB *db, Group *sgroup, int Nsgroup));
    106 void          sort_time          PROTO((unsigned int *value, int N));
     77void          ConfigInit          PROTO((int *argc, char **argv));
     78void          DonePlotting        PROTO((Graphdata *graphmode, int N));
     79void          JpegPlot            PROTO((Graphdata *graphmode, int N, char *filename));
     80void          PSPlot              PROTO((Graphdata *graphmode, int N, char *filename));
     81void          PlotLabel           PROTO((char *string, int N));
     82void          PlotVector          PROTO((int Npts, double *vect, int mode, int N));
     83void          PrepPlotting        PROTO((int Npts, Graphdata *graphmode, int N));
     84void          XDead               PROTO((void));
     85int           args_uniphot        PROTO((int argc, char **argv));
     86int           args_setphot        PROTO((int argc, char **argv));
     87void          dumpresult          PROTO((void));
     88Group        *find_image_sgroups  PROTO((FITS_DB *db, ImageLink **imlink, int *Nsgroup));
     89Group        *find_image_tgroups  PROTO((FITS_DB *db, ImageLink **imlink, int *Ntgroup));
     90void          fit_sgroup          PROTO((Group *sgroup, int Nsgroup));
     91void          fit_tgroup          PROTO((Group *tgroup, int Ntgroup));
     92int           gcatalog            PROTO((Catalog *catalog));
     93void          initialize_uniphot  PROTO((int argc, char **argv));
     94void          initialize_setphot  PROTO((int argc, char **argv));
     95void          initstats           PROTO((char *mode));
     96int           liststats           PROTO((double *value, double *dvalue, int N, StatType *stats));
     97int           load_images_uniphot PROTO((FITS_DB *db));
     98int           main                PROTO((int argc, char **argv));
     99int           open_graph          PROTO((int N));
     100void          sort                PROTO((unsigned int *X, int N));
     101void          sortB               PROTO((double *X, double *Y, int N));
     102void          sortD               PROTO((double *X, double *Y, double *Z, int N));
     103void          update_dvo_catalog  PROTO((Catalog *catalog, Group *sgroup, int warn));
     104void          wcatalog            PROTO((Catalog *catalog));
     105void          wimages             PROTO((Image *image, int Nimage));
     106void          check_permissions   PROTO((char *basefile));
     107void          lock_image_db       PROTO((FITS_DB *db, char *filename));
     108void          unlock_image_db     PROTO((FITS_DB *db));
     109void          create_image_db     PROTO((FITS_DB *db));
     110void          set_db              PROTO((FITS_DB *in));
     111int           Shutdown            PROTO((char *format, ...) OHANA_FORMAT(printf, 1, 2) );
     112void          TrapSignal          PROTO((int sig));
     113void          SetProtect          PROTO((int mode));
     114int           SetSignals          PROTO((void));
     115int           subset_images       PROTO((FITS_DB *db));
     116void          update              PROTO((FITS_DB *db, Group *sgroup, int Nsgroup));
     117void          sort_time           PROTO((unsigned int *value, int N));
     118
     119// setphot-specific prototypes
     120ZptTable     *load_zpt_table         PROTO((char *filename, int *nzpts));
     121Image        *load_images_setphot    PROTO((FITS_DB *db, off_t *Nimage));
     122int           match_zpts_to_images   PROTO((Image *image, off_t Nimage, ZptTable *zpts, int Nzpts));
     123int           update_setphot         PROTO((Image *image, off_t Nimage));
     124void          update_catalog_setphot PROTO((Catalog *catalog, Image *image, off_t *index, off_t Nimage));
  • branches/eam_branches/Ohana.20100407/src/uniphot/src/ConfigInit.c

    r25757 r27770  
    11# include "uniphot.h"
     2
     3void GetConfig (char *config, char *field, char *format, int N, void *ptr);
    24
    35void ConfigInit (int *argc, char **argv) {
     
    1820  if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file);
    1921
    20   ScanConfig (config, "CATDIR",                 "%s",  0, CATDIR);
     22  GetConfig (config, "CATDIR",                 "%s",  0, CATDIR);
    2123  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
    2224  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
     
    2426
    2527  sprintf (ImageCat, "%s/Images.dat", CATDIR);
     28
     29  GetConfig (config, "GSCFILE",                 "%s",  0, GSCFILE);
     30  if (!ScanConfig (config, "SKY_DEPTH",         "%d",  0, &SKY_DEPTH)) {
     31    SKY_DEPTH = 2;
     32  }
     33  if (!ScanConfig (config, "SKY_TABLE",         "%s",  0, SKY_TABLE)) {
     34    SKY_TABLE[0] = 0;
     35  }
    2636
    2737  ScanConfig (config, "ZERO_PT",                "%lf", 0, &ZERO_POINT);
     
    4252
    4353}
     54
     55void GetConfig (char *config, char *field, char *format, int N, void *ptr) {
     56
     57  char *status;
     58
     59  status = ScanConfig (config, field, format, N, ptr);
     60  if (status == NULL) {
     61    fprintf (stderr, "error in config, cannot find %s\n", field);
     62    exit (1);
     63  }
     64  return;
     65}
  • branches/eam_branches/Ohana.20100407/src/uniphot/src/Shutdown.c

    r7080 r27770  
    2323  SetProtect (TRUE);
    2424  gfits_db_close (db);
    25   fprintf (stderr, "ERROR: addstar halted\n");
     25  fprintf (stderr, "ERROR: halted\n");
    2626  exit (1);
    2727}
  • branches/eam_branches/Ohana.20100407/src/uniphot/src/args.c

    r14590 r27770  
    11# include "uniphot.h"
    22
    3 int args (int argc, char **argv) {
     3int args_uniphot (int argc, char **argv) {
    44
    55  int N;
     
    7272}
    7373
     74int args_setphot (int argc, char **argv) {
     75
     76  int N;
     77
     78  VERBOSE = FALSE;
     79  if ((N = get_argument (argc, argv, "-v"))) {
     80    VERBOSE = TRUE;
     81    remove_argument (N, &argc, argv);
     82  }
     83
     84  UPDATE = FALSE;
     85  if ((N = get_argument (argc, argv, "-update"))) {
     86    remove_argument (N, &argc, argv);
     87    UPDATE = TRUE;
     88  }
     89
     90  if (argc != 2) {
     91    fprintf (stderr, "ERROR: USAGE: setphot (zptfile) [options]\n");
     92    exit (2);
     93  }
     94
     95  return (TRUE);
     96}
     97
  • branches/eam_branches/Ohana.20100407/src/uniphot/src/initialize.c

    r2492 r27770  
    11# include "uniphot.h"
    22
    3 void initialize (int argc, char **argv) {
     3void initialize_uniphot (int argc, char **argv) {
    44
    55  /* are these set correctly? */
    66  ConfigInit (&argc, argv);
    7   args (argc, argv);
     7  args_uniphot (argc, argv);
    88
    99  if ((photcode = GetPhotcodebyName (argv[1])) == NULL) {
     
    2121}
    2222
     23void initialize_setphot (int argc, char **argv) {
     24
     25  /* are these set correctly? */
     26  ConfigInit (&argc, argv);
     27  args_setphot (argc, argv);
     28}
     29
  • branches/eam_branches/Ohana.20100407/src/uniphot/src/load_images.c

    r27768 r27770  
    11# include "uniphot.h"
    22
    3 int load_images (FITS_DB *db) {
     3int load_images_uniphot (FITS_DB *db) {
    44
    55  if (VERBOSE) fprintf (stderr, "finding images\n");
     
    2323  image = gfits_table_get_Image (&db[0].ftable, Nimage, &db[0].swapped);
    2424
     25  fprintf (stderr, "loaded %lld images\n", (long long) *Nimage);
     26
    2527  return (image);
    2628}
  • branches/eam_branches/Ohana.20100407/src/uniphot/src/load_zpt_table.c

    r27768 r27770  
    1 # include "setphot.h"
     1# include "uniphot.h"
    22
    33ZptTable *load_zpt_table (char *filename, int *nzpts) {
     
    2323  while ((status = fscanf (f, "%lf %lf", &mjd, &zpt)) == 2) {
    2424    zpts[Nzpts].zpt = zpt;
    25     zpts[Nzpts].time = ohana_mjd_to_sec(mjd);
     25    zpts[Nzpts].time = ohana_mjd_to_sec (mjd);
     26    zpts[Nzpts].found = FALSE;
    2627
    2728    Nzpts ++;
     
    3435  }
    3536
     37  fprintf (stderr, "loaded %d zero points\n", Nzpts);
     38
    3639  *nzpts = Nzpts;
    3740  return zpts;
  • branches/eam_branches/Ohana.20100407/src/uniphot/src/match_zpts_to_images.c

    r27768 r27770  
    22
    33/* sort a coordinate pair (X,Y) and the associated index (S) */
    4 void sort_zpts_by_time (ZptTable *zpts, int Nzpts) {
     4static void sort_zpts_by_time (ZptTable *zpts, int Nzpts) {
    55 
    66# define SWAPFUNC(A,B){ ZptTable tmp;           \
    7     tmp = X[A]; X[A] = X[B]; X[B] = tmp;        \
     7    tmp = zpts[A]; zpts[A] = zpts[B]; zpts[B] = tmp;    \
    88  }
    9 # define COMPARE(A,B)(X[A].time < X[B].time)
     9# define COMPARE(A,B)(zpts[A].time < zpts[B].time)
    1010
    11   OHANA_SORT (N, COMPARE, SWAPFUNC);
     11  OHANA_SORT (Nzpts, COMPARE, SWAPFUNC);
    1212
    1313# undef SWAPFUNC
    1414# undef COMPARE
    1515}
     16
     17# define SCALE 0.001
    1618
    1719int match_zpts_to_images (Image *image, off_t Nimage, ZptTable *zpts, int Nzpts) {
     
    2527  int dT, NImatch, Nmatch;
    2628  off_t i, Ni, Nz, *index;
     29  PhotCode *code;
    2730
    2831  // create index and sort
     
    3134    index[i] = i;
    3235  }
    33   sort_image_subset(image, index, Nimage);  // slightly misnamed sort function
     36  sort_image_subset(image, index, Nimage);  // slightly misnamed sort function from libdvo
    3437
    3538  // sort the zpts
     
    3841  NImatch = 0; // matched images
    3942  for (i = Nz = 0; (i < Nimage) && (Nz < Nzpts); ) {
     43
     44    if (i % 1000 == 0) fprintf (stderr, ".");
     45    if (Nz % 100 == 0) fprintf (stderr, "!");
    4046
    4147    Ni = index[i];
     
    5561    }
    5662
     63    // check that we have a valid photcode (skip mosaic images)
     64    code = GetPhotcodebyCode(image[Ni].photcode);
     65    if (!code) {
     66      i++;
     67      continue;
     68    }
     69
    5770    // we have a match: set zpt and record the match
    58     image[Ni].Mcal = zpts[Nz].zpt; // XXX watch out for offset..
     71    image[Ni].Mcal = SCALE*code[0].C - zpts[Nz].zpt;
    5972    image[Ni].flags &= ~ID_IMAGE_NOCAL; // clear the NOCAL flag
    6073    zpts[Nz].found = TRUE;
     
    6881  Nmatch = 0;
    6982  for (Nz = 0; Nz < Nzpts; Nz++) {
    70     if (image[Nz].found) Nmatch ++;
     83    if (zpts[Nz].found) Nmatch ++;
    7184  }
    7285
    73   fprintf (stderr, "found %d zpt matches\n",
     86  fprintf (stderr, "found %d zpt matches, %d image matches\n", Nmatch, NImatch);
    7487
    7588  return (TRUE);
  • branches/eam_branches/Ohana.20100407/src/uniphot/src/setphot.c

    r27768 r27770  
    1 # include "setphot.h"
     1# include "uniphot.h"
    22
    33int main (int argc, char **argv) {
    44
    55  off_t Nimage;
    6   int Nzpts;
     6  int status, Nzpts;
    77  FITS_DB db;
    88  ZptTable *zpts;
     
    1010
    1111  /* get configuration info, args, lockfile */
    12   initialize (argc, argv);
     12  initialize_setphot (argc, argv);
    1313
    1414  set_db (&db);
     
    1616  if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename);
    1717  if (db.dbstate == LCK_EMPTY) Shutdown ("ERROR: No images in catalog %s (1)", db.filename);
    18   if (!UPDATE) dvo_image_unlock (&db);
    1918
    2019  zpts = load_zpt_table (argv[1], &Nzpts);
    2120
    22   /* load images */
     21  // load images
    2322  image  = load_images_setphot (&db, &Nimage);
     23  if (!UPDATE) dvo_image_unlock (&db);
    2424 
    2525  match_zpts_to_images (image, Nimage, zpts, Nzpts);
    2626
    27   update_catalogs();
     27  update_setphot(image, Nimage);
    2828
    29   /** write image table **/
    30   dvo_image_update (db, VERBOSE);
     29  // write image table
     30  if (UPDATE) {
     31    dvo_image_save (&db, VERBOSE);
     32  }
    3133
    3234  exit (0);
  • branches/eam_branches/Ohana.20100407/src/uniphot/src/uniphot.c

    r6238 r27770  
    99
    1010  /* get configuration info, args, lockfile */
    11   initialize (argc, argv);
     11  initialize_uniphot (argc, argv);
    1212
    1313  set_db (&db);
     
    1818
    1919  /* load images */
    20   load_images (&db);
     20  load_images_uniphot (&db);
    2121 
    2222  /* filter image list by selection */
  • branches/eam_branches/Ohana.20100407/src/uniphot/src/update_catalog_setphot.c

    r27768 r27770  
    22# include <glob.h>
    33
    4 intax update_setphot (Image *image, off_t Nimage) {
     4int update_setphot (Image *image, off_t Nimage) {
    55
     6  SkyRegion UserPatch;
    67  SkyTable *sky = NULL;
    78  SkyList *skylist = NULL;
    89  Catalog catalog;
    9 
    10   off_t i, Nimage, maxID, *index;
    11   int j, status, Nmin;
     10  off_t i, maxID, *index;
    1211
    1312  // create an index for the image IDs
     
    1817  ALLOCATE (index, off_t, maxID + 1);
    1918  for (i = 0; i < Nimage; i++) {
    20     if (image[i].imageID < 0) continue;
     19    if (!image[i].imageID) continue; // images with ID == 0 are virtual
    2120    index[image[i].imageID] = i;
    2221  }
     
    2827 
    2928  // determine the populated SkyRegions overlapping the requested area (default depth)
     29  UserPatch.Rmin = 0;
     30  UserPatch.Rmax = 360;
     31  UserPatch.Dmin = -90;
     32  UserPatch.Dmax = +90;
    3033  skylist = SkyListByPatch (sky, -1, &UserPatch);
    3134
     
    7982    for (j = 0; j < catalog[0].average[i].Nmeasure; j++, m++) {
    8083      idx = catalog[0].measure[m].imageID;
    81       if (idx < 0) continue;
     84      if (idx <= 0) continue; // detections with imageID == 0 do not have a valid image (eg, ref photcode)
    8285
    8386      id = index[idx];
     
    9093
    9194  if (found) {
    92     fprintf (stderr, "found %d matches\n", found);
     95    fprintf (stderr, "found %lld matches\n", (long long) found);
    9396  }
    9497}
Note: See TracChangeset for help on using the changeset viewer.