IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30976


Ignore:
Timestamp:
Mar 18, 2011, 2:11:14 PM (15 years ago)
Author:
eugene
Message:

fix group and write problems for uniphot

Location:
branches/eam_branches/ipp-20110213/Ohana/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110213/Ohana/src/relphot/src/load_images.c

    r30616 r30976  
    77  fprintf (stderr, MSG, __VA_ARGS__); }
    88
     9// This function generates a subset of the images based on selections.  Input db has already
     10// been loaded with the raw fits table data
    911SkyList *load_images (FITS_DB *db, char *regionName, SkyRegion *region, int RegionSelect) {
    1012
     
    3234  }
    3335
    34   // convert database table to internal structure
     36  // convert database table to internal structure (binary to Image)
    3537  image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped);
    3638  if (!image) {
     
    4446  MARKTIME("selected images: %f sec\n", dtime);
    4547
     48  // generate db->vtable from db->ftable based on the selection
     49  // XXX does this simply duplicate the memory needlessly?  we recreate these lines
     50  // in reload_images.  If we had saved the line numbers, we could avoid this
    4651  gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, LineNumber, Nsubset);
    4752  MARKTIME("converted ftable to vtable: %f sec\n", dtime);
    4853
     54  // save the subset of images in the static reference in ImageOps, set up indexes
    4955  initImages (subset, Nsubset);
    5056  MARKTIME("init images: %f sec\n", dtime);
    5157
     58  // match chips to mosaics (if applicable)
    5259  initMosaics (subset, Nsubset);
    5360  MARKTIME("init mosaics: %f sec\n", dtime);
  • branches/eam_branches/ipp-20110213/Ohana/src/uniphot/Makefile

    r27790 r30976  
    3434$(SRC)/update.$(ARCH).o             \
    3535$(SRC)/update_catalog.$(ARCH).o     \
     36$(SRC)/convert.$(ARCH).o            \
    3637$(SRC)/SetSignals.$(ARCH).o         \
    3738$(SRC)/Shutdown.$(ARCH).o           \
  • branches/eam_branches/ipp-20110213/Ohana/src/uniphot/include/uniphot.h

    r28717 r30976  
    2929
    3030typedef struct {
     31  char tstart[64];
     32  char tstop[64];
    3133  char label[64];
    3234  float M;
     
    124126int           update_setphot         PROTO((Image *image, off_t Nimage));
    125127void          update_catalog_setphot PROTO((Catalog *catalog, Image *image, off_t *index, off_t Nimage));
     128
     129/*** time/coord conversion functions not supplied by libohana ***/
     130time_t        TimeRef               PROTO((double time, time_t TimeReference, int TimeFormat));
     131double        TimeValue             PROTO((time_t time, time_t TimeReference, int TimeFormat));
     132
     133int           hh_hms                PROTO((double hh, int *hr, int *mn, double *sc));
     134int           dd_dms                PROTO((double dd, int *dg, int *mn, double *sc));
     135int           hms_format            PROTO((char *line, double value));
     136int           dms_format            PROTO((char *line, double value));
     137int           hh_hm                 PROTO((double hh, int *hr, double *mn));
     138int           day_to_sec            PROTO((char *string, time_t *second));
     139int           hms_to_sec            PROTO((char *string, time_t *second));
     140char         *ohana_sec_to_hms      PROTO((time_t second));
     141char         *ohana_sec_to_day      PROTO((time_t second));
     142
     143char         *meade_deg_to_str      PROTO((double deg));
     144char         *meade_ra_to_str       PROTO((double deg));
     145char         *meade_dec_to_str      PROTO((double deg));
     146char         *strptime              PROTO((const char *s, const char *format, struct tm *tm));
     147time_t        GetTimeReference      PROTO((char *reference));
     148int           GetTimeUnits          PROTO((char *name));
  • branches/eam_branches/ipp-20110213/Ohana/src/uniphot/src/dumpresult.c

    r4797 r30976  
    1717      Mgrp = tgrp[0].M;
    1818      fprintf (f, "%7.4f %7.4f %7.4f %7.4f   %10.6f %10.6f  %f %s\n",
    19                0.001*Mcal, 0.001*Mgrp, 0.001*Mset, 0.001*sgroup[i].image[j][0].dMcal,
     19               Mcal, Mgrp, Mset, sgroup[i].image[j][0].dMcal,
    2020               sgroup[i].image[j][0].coords.crval1, sgroup[i].image[j][0].coords.crval2, (sgroup[i].image[j][0].tzero-915148800)/86400.0, tgrp[0].label);
    2121    }
  • branches/eam_branches/ipp-20110213/Ohana/src/uniphot/src/find_image_sgroups.c

    r29001 r30976  
    33Group *find_image_sgroups (FITS_DB *db, ImageLink **Imlink, int *Nsgroup) {
    44
    5   off_t i, Nimage;
    6   int j, Ngroup, Nentry, NENTRY;
     5  off_t i, j, Nimage;
     6  int Ngroup, Nentry, NENTRY;
    77  double r, d, x, y, radius;
    88  Group *group;
     
    2727  ALLOCATE (group, Group, Nimage);
    2828
     29  if (VERBOSE) fprintf (stderr, "finding images\n");
     30  BuildChipMatch (image, Nimage);
     31  // MARKTIME("build chip match: %f sec\n", dtime);
     32
    2933  /* set imlink.sgroups = NULL as a marker */
    3034  for (i = 0; i < Nimage; i++) imlink[i].sgroup = NULL;
     
    3438    if (image[i].flags & ID_IMAGE_PHOTOM_NOCAL) continue;
    3539
     40    // XXX optionally, we should be able to use ONLY the DIS or NOT the DIS images
     41    // NOCAL above is used to mark images which do not match the photcode (including the DIS)
     42    // if (!strcmp(&image[i].coords.ctype[4], "-DIS")) continue;
     43
     44    // this adds 1.3 sec for 3M images
     45    if (!FindMosaicForImage (image, Nimage, i)) {
     46      fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);
     47      continue;
     48    }
     49
     50    /* define image center - note the DIS images (mosaic phu) are special */
     51    if (!strcmp(&image[i].coords.ctype[4], "-DIS")) {
     52        XY_to_RD (&r, &d, 0.0, 0.0, &image[i].coords);
     53    } else {
     54        XY_to_RD (&r, &d, 0.5*image[i].NX, 0.5*image[i].NX, &image[i].coords);
     55    }
     56
    3657    /* new sgroup, set ref coords */
    37     XY_to_RD (&r, &d, 0.5*image[i].NX, 0.5*image[i].NX, &image[i].coords);
    3858    coords.crval1 = r;
    3959    coords.crval2 = d;
     
    5979      if (image[j].flags & ID_IMAGE_PHOTOM_NOCAL) continue;
    6080      if (imlink[j].sgroup != NULL) continue;
     81      // XXX optionally, we should be able to use ONLY the DIS or NOT the DIS images
     82      // NOCAL above is used to mark images which do not match the photcode (including the DIS)
     83      // if (!strcmp(&image[j].coords.ctype[4], "-DIS")) continue;
     84
     85      // this adds 1.3 sec for 3M images
     86      if (!FindMosaicForImage (image, Nimage, j)) {
     87          fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", j);
     88          continue;
     89      }
    6190
    6291      /* project image center to local coords, check radius */
    63       XY_to_RD (&r, &d, 0.5*image[j].NX, 0.5*image[j].NX, &image[j].coords);
     92      if (!strcmp(&image[j].coords.ctype[4], "-DIS")) {
     93          XY_to_RD (&r, &d, 0.0, 0.0, &image[j].coords);
     94      } else {
     95          XY_to_RD (&r, &d, 0.5*image[j].NX, 0.5*image[j].NX, &image[j].coords);
     96      }
    6497      if (!RD_to_XY (&x, &y, r, d, &coords)) continue;
     98
    6599      /* RD_to_XY returns FALSE if opposite hemispheres */
    66100      radius = hypot (x, y);
  • branches/eam_branches/ipp-20110213/Ohana/src/uniphot/src/find_image_tgroups.c

    r29001 r30976  
    55  char *start, *stop;
    66  int j, Ngroup, NGROUP, Nentry, NENTRY;
    7   off_t i, Nimage;
     7  off_t i, Nimage, Ntime;
    88  unsigned int *time, *tmin, *tmax;
    99  Group *group;
     
    2121  /* sort time list (use only valid images?) */
    2222  ALLOCATE (time, unsigned int, Nimage);
     23  Ntime = 0;
    2324  for (i = 0; i < Nimage; i++) {
    24     time[i] = image[i].tzero;
     25    if (image[i].flags & ID_IMAGE_PHOTOM_NOCAL) continue;
     26    if (!strcmp(&image[i].coords.ctype[4], "-DIS")) continue;
     27    time[Ntime] = image[i].tzero;
     28    Ntime ++;
    2529  }
    26   sort_time (time, Nimage);
     30  sort_time (time, Ntime);
    2731
    2832  /* find groups with dt < TRANGE */
     
    3438
    3539  /* generate tgroups */
    36   for (i = 0; i < Nimage - 1; i++) {
     40  for (i = 0; i < Ntime - 1; i++) {
    3741    if (time[i+1] - time[i] < TRANGE) continue;
    3842   
     
    4751    tmin[Ngroup] = time[i + 1];
    4852  }
    49   tmax[Ngroup] = time[Nimage - 1];
     53  tmax[Ngroup] = time[Ntime - 1];
    5054  Ngroup ++;
    5155  ALLOCATE (group, Group, Ngroup);
     
    6367    stop = ohana_sec_to_date (tmax[i]);
    6468    snprintf (group[i].label, 64, "%s - %s", start, stop);
     69    strcpy(group[i].tstart, start);
     70    strcpy(group[i].tstop, stop);
    6571    free (start);
    6672    free (stop);
     
    7076      if (image[j].tzero > tmax[i]) continue;
    7177      if (image[j].flags & ID_IMAGE_PHOTOM_NOCAL) continue;
     78      if (!strcmp(&image[j].coords.ctype[4], "-DIS")) continue;
    7279     
    7380      group[i].image[Nentry] = &image[j];
  • branches/eam_branches/ipp-20110213/Ohana/src/uniphot/src/fit_groups.c

    r21508 r30976  
    2929    tgroup[i].Ngood = stats.Nmeas;
    3030   
     31    // fprintf (stderr, "tgroup %d : %f +/- %f : %d stars\n", i, stats.mean, stats.sigma, stats.Nmeas);
     32
    3133    initstats ("MEAN");
    3234    liststats (mlist, dlist, Nlist, &stats);
     
    6769    sgroup[i].Ngood = stats.Nmeas;
    6870
     71    // fprintf (stderr, "sgroup %d : %f +/- %f : %d stars\n", i, stats.mean, stats.sigma, stats.Nmeas);
     72
    6973    initstats ("MEAN");
    7074    liststats (mlist, dlist, Nlist, &stats);
  • branches/eam_branches/ipp-20110213/Ohana/src/uniphot/src/subset_images.c

    r29001 r30976  
    33int subset_images (FITS_DB *db) {
    44
    5   off_t i, Nimage, Nkeep, *keep;
     5  off_t i, Nimage;
    66  int equiv;
    77  Image *image;
    88
    9   /* use a vtable to keep the images to be calibrated */
     9  // convert from the binary I/O format to the internal structure (Image)
    1010  image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped);
    1111  if (!image) {
     
    1313      exit (2);
    1414  }
    15 
    16   Nkeep = 0;
    17   ALLOCATE (keep, off_t, Nimage);
    1815
    1916  /* mark images to be calibrated */
     
    3229    }
    3330    image[i].flags &= ~ID_IMAGE_PHOTOM_NOCAL;
    34     keep[Nkeep] = i;
    35     Nkeep ++;
    3631  }
    37 
    38   gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, keep, Nkeep);
    3932  return (TRUE);
    4033}
  • branches/eam_branches/ipp-20110213/Ohana/src/uniphot/src/uniphot.c

    r27790 r30976  
    11# include "uniphot.h"
     2
     3static char *timeref  = "2000/01/01,00:00:00";
     4static char *timeunit = "days";
    25
    36int main (int argc, char **argv) {
     
    811  FITS_DB db;
    912
     13  // set up time format stuff
     14  time_t TimeReference = GetTimeReference (timeref);
     15  int TimeUnits = GetTimeUnits (timeunit);
     16
    1017  /* get configuration info, args, lockfile */
    1118  initialize_uniphot (argc, argv);
     
    1522  if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename);
    1623  if (db.dbstate == LCK_EMPTY) Shutdown ("ERROR: No images in catalog %s (1)", db.filename);
    17   if (!UPDATE) dvo_image_unlock (&db);
    1824
    1925  /* load images */
    2026  load_images_uniphot (&db);
     27  if (!UPDATE) dvo_image_unlock (&db);
    2128 
    2229  /* filter image list by selection */
     
    3845  fprintf (stdout, "# NLOOP: %d\n", NLOOP);
    3946  fprintf (stdout, "# time groups : %d\n", Ntgroup);
     47  fprintf (stdout, "# TIMEREF : %s\n", timeref);
     48  fprintf (stdout, "# TIMEFORMAT : %s\n", timeunit);
    4049  for (i = 0; i < Ntgroup; i++) {
    41     fprintf (stdout, "%s %5d %5d %7.4f  %7.4f %7.4f\n", tgroup[i].label,
    42              tgroup[i].Nimage, tgroup[i].Ngood, 0.001*tgroup[i].M, 0.001*tgroup[i].dM, 0.001*tgroup[i].dMsub);
     50
     51    double tstart = NAN;
     52    double tstop = NAN;
     53
     54    time_t time;
     55    if (ohana_str_to_time (tgroup[i].tstart, &time)) {
     56      tstart = TimeValue (time, TimeReference, TimeUnits);
     57    }
     58    if (ohana_str_to_time (tgroup[i].tstop, &time)) {
     59      tstop = TimeValue (time, TimeReference, TimeUnits);
     60    }
     61
     62    fprintf (stdout, "%s : %12.6f %12.6f : %5d %5d %7.4f  %7.4f %7.4f\n",
     63             tgroup[i].label, tstart, tstop,
     64             tgroup[i].Nimage, tgroup[i].Ngood,
     65             tgroup[i].M, tgroup[i].dM, tgroup[i].dMsub);
    4366  }
    4467  fprintf (stdout, "\n");
     
    4770  for (i = 0; i < Nsgroup; i++) {
    4871    fprintf (stdout, "%s %5d %5d %7.4f  %7.4f %7.4f\n", sgroup[i].label,
    49              sgroup[i].Nimage, sgroup[i].Ngood, 0.001*sgroup[i].M, 0.001*sgroup[i].dM, 0.001*sgroup[i].dMsub);
     72             sgroup[i].Nimage, sgroup[i].Ngood, sgroup[i].M, sgroup[i].dM, sgroup[i].dMsub);
    5073  }
    5174  if (!UPDATE) exit (0);
  • branches/eam_branches/ipp-20110213/Ohana/src/uniphot/src/update.c

    r29001 r30976  
    44void update (FITS_DB *db, Group *sgroup, int Nsgroup) {
    55
    6   off_t i, Nimage;
     6  off_t i, Nimage, Nkeep, *keep;
    77  int j, status, Nmin;
    88  char line[256];
     
    1919  }
    2020
    21   /* clear the NOCAL flags */
     21  // create a subset list so we can make a vtable
     22  Nkeep = 0;
     23  ALLOCATE (keep, off_t, Nimage);
     24
     25  // identify the images used and clear the NOCAL flags on the rest
    2226  for (i = 0; i < Nimage; i++) {
    23     image[i].flags &= ~ID_IMAGE_PHOTOM_NOCAL;
     27      if (image[i].flags & ID_IMAGE_PHOTOM_NOCAL) {
     28          image[i].flags &= ~ID_IMAGE_PHOTOM_NOCAL;
     29          continue;
     30      }
     31      keep[Nkeep] = i;
     32      Nkeep ++;
    2433  }
    2534
     
    3140  }
    3241
    33   /** write image table **/
     42  // save the rows in the image table which were used in this analysis
     43  gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, keep, Nkeep);
     44
     45  // write image table
    3446  dvo_image_update (db, VERBOSE);
     47
     48  // XXX need to fix the update for the catalog (or make it optional)
     49  return;
    3550
    3651  // XXX this process uses the existence of the file to perform the update
Note: See TracChangeset for help on using the changeset viewer.