IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31160


Ignore:
Timestamp:
Apr 4, 2011, 1:19:27 PM (15 years ago)
Author:
eugene
Message:

updates from eam branch

Location:
trunk/Ohana
Files:
58 edited
6 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/configure.tcsh

    r28241 r31160  
    321321   set sysincpath = "$sysincpath /sw/include"
    322322   set dlltype = dylib
    323    set CFLAGS = "$CFLAGS -D_DARWIN_C_SOURCE"
    324    set defines = "-D_DARWIN_C_SOURCE"
     323   # set CFLAGS = "$CFLAGS -D_DARWIN_C_SOURCE"
     324   # set defines = "-D_DARWIN_C_SOURCE"
    325325   breaksw;
    326326 case HP-UX:
  • trunk/Ohana/src/addstar/include/addstar.h

    r30613 r31160  
    263263Stars     *Convert_PS1_V2         PROTO((FTable *table, unsigned int *nstars));
    264264Stars     *Convert_PS1_V3         PROTO((FTable *table, unsigned int *nstars));
     265Stars     *Convert_PS1_SV1        PROTO((FTable *table, unsigned int *nstars));
     266Stars     *Convert_PS1_SV1_Alt    PROTO((FTable *table, unsigned int *nstars));
    265267
    266268int        InitStar               PROTO((Stars *star));
  • trunk/Ohana/src/addstar/src/MatchHeaders.c

    r29541 r31160  
    5858    if (!strcmp (exttype, "PS1_V2")) goto keep;
    5959    if (!strcmp (exttype, "PS1_V3")) goto keep;
     60    if (!strcmp (exttype, "PS1_SV1")) goto keep;
    6061    continue;
    6162
  • trunk/Ohana/src/addstar/src/ReadStarsFITS.c

    r30725 r31160  
    5454    stars = Convert_PS1_V3 (&table, &Nstars);
    5555  }
     56  if (!strcmp (type, "PS1_SV1")) {
     57    stars = Convert_PS1_SV1 (&table, &Nstars);
     58  }
    5659  if (stars == NULL) {
    5760    fprintf (stderr, "invalid table type %s\n", type);
     
    501504  return (stars);
    502505}
     506
     507Stars *Convert_PS1_SV1 (FTable *table, unsigned int *nstars) {
     508
     509  off_t Nstars;
     510  unsigned int i;
     511  double ZeroPt;
     512  Stars *stars;
     513  CMF_PS1_SV1 *ps1data;
     514
     515  if (table[0].header[0].Naxis[0] == 196) {
     516      stars = Convert_PS1_SV1_Alt (table, nstars);
     517      return (stars);
     518  }
     519
     520  ps1data = gfits_table_get_CMF_PS1_SV1 (table, &Nstars, NULL);
     521  if (!ps1data) {
     522    fprintf (stderr, "skipping inconsistent entry\n");
     523    return (NULL);
     524  }
     525  ZeroPt = GetZeroPoint();
     526
     527  ALLOCATE (stars, Stars, Nstars);
     528  for (i = 0; i < Nstars; i++) {
     529    InitStar (&stars[i]);
     530    stars[i].measure.Xccd       = ps1data[i].X;
     531    stars[i].measure.Yccd       = ps1data[i].Y;
     532    stars[i].measure.dXccd      = ToShortPixels(ps1data[i].dX);
     533    stars[i].measure.dYccd      = ToShortPixels(ps1data[i].dY);
     534
     535    stars[i].measure.posangle   = ToShortDegrees(ps1data[i].posangle);
     536    stars[i].measure.pltscale   = ps1data[i].pltscale;
     537
     538    if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) {
     539        stars[i].measure.M      = NAN;
     540    } else {
     541        stars[i].measure.M      = ps1data[i].M + ZeroPt;
     542    }
     543    stars[i].measure.dM         = ps1data[i].dM;
     544    stars[i].measure.dMcal      = ps1data[i].dMcal;
     545    stars[i].measure.Map        = ps1data[i].Map + ZeroPt;
     546                       
     547    stars[i].measure.Sky        = ps1data[i].sky;
     548    stars[i].measure.dSky       = ps1data[i].dSky;
     549                       
     550    stars[i].measure.psfChisq   = ps1data[i].psfChisq;
     551    stars[i].measure.psfQual    = ps1data[i].psfQual;
     552    stars[i].measure.psfNdof    = ps1data[i].psfNdof;
     553    stars[i].measure.psfNpix    = ps1data[i].psfNpix;
     554    stars[i].measure.crNsigma   = ps1data[i].crNsigma;
     555    stars[i].measure.extNsigma  = ps1data[i].extNsigma;
     556
     557    stars[i].measure.FWx        = ToShortPixels(ps1data[i].fx);
     558    stars[i].measure.FWy        = ToShortPixels(ps1data[i].fy);
     559    stars[i].measure.theta      = ToShortDegrees(ps1data[i].df);
     560
     561    stars[i].measure.Mxx        = ToShortPixels(ps1data[i].Mxx);
     562    stars[i].measure.Mxy        = ToShortPixels(ps1data[i].Mxy);
     563    stars[i].measure.Myy        = ToShortPixels(ps1data[i].Myy);
     564                       
     565    stars[i].measure.photFlags  = ps1data[i].flags;
     566
     567    // this is may optionally be replaced by the internal sequence (see FilterStars.c)
     568    stars[i].measure.detID      = ps1data[i].detID;
     569
     570    // the Average fields and the following Measure fields are set in FilterStars after
     571    // the image metadata is in hand:  dR, dD, Mcal, dt, airmass, az, t, imageID, extID,
     572    // averef is set in find_matches, dbFlags is zero on ingest.
     573
     574    // the following fields are currently not being set anywhere: t_msec
     575  }   
     576  *nstars = Nstars;
     577  return (stars);
     578}
     579
     580Stars *Convert_PS1_SV1_Alt (FTable *table, unsigned int *nstars) {
     581
     582  off_t Nstars;
     583  unsigned int i;
     584  double ZeroPt;
     585  Stars *stars;
     586  CMF_PS1_SV1 *ps1data;
     587
     588  // some test output files were produced called CMF_PS1_SV1 but with mismatch byte boundaries
     589
     590  ps1data = gfits_table_get_CMF_PS1_SV1_Alt (table, &Nstars, NULL);
     591  if (!ps1data) {
     592    fprintf (stderr, "skipping inconsistent entry\n");
     593    return (NULL);
     594  }
     595  ZeroPt = GetZeroPoint();
     596
     597  ALLOCATE (stars, Stars, Nstars);
     598  for (i = 0; i < Nstars; i++) {
     599    InitStar (&stars[i]);
     600    stars[i].measure.Xccd       = ps1data[i].X;
     601    stars[i].measure.Yccd       = ps1data[i].Y;
     602    stars[i].measure.dXccd      = ToShortPixels(ps1data[i].dX);
     603    stars[i].measure.dYccd      = ToShortPixels(ps1data[i].dY);
     604
     605    stars[i].measure.posangle   = ToShortDegrees(ps1data[i].posangle);
     606    stars[i].measure.pltscale   = ps1data[i].pltscale;
     607
     608    if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) {
     609        stars[i].measure.M      = NAN;
     610    } else {
     611        stars[i].measure.M      = ps1data[i].M + ZeroPt;
     612    }
     613    stars[i].measure.dM         = ps1data[i].dM;
     614    stars[i].measure.dMcal      = ps1data[i].dMcal;
     615    stars[i].measure.Map        = ps1data[i].Map + ZeroPt;
     616                       
     617    stars[i].measure.Sky        = ps1data[i].sky;
     618    stars[i].measure.dSky       = ps1data[i].dSky;
     619                       
     620    stars[i].measure.psfChisq   = ps1data[i].psfChisq;
     621    stars[i].measure.psfQual    = ps1data[i].psfQual;
     622    stars[i].measure.psfNdof    = ps1data[i].psfNdof;
     623    stars[i].measure.psfNpix    = ps1data[i].psfNpix;
     624    stars[i].measure.crNsigma   = ps1data[i].crNsigma;
     625    stars[i].measure.extNsigma  = ps1data[i].extNsigma;
     626
     627    stars[i].measure.FWx        = ToShortPixels(ps1data[i].fx);
     628    stars[i].measure.FWy        = ToShortPixels(ps1data[i].fy);
     629    stars[i].measure.theta      = ToShortDegrees(ps1data[i].df);
     630
     631    stars[i].measure.Mxx        = ToShortPixels(ps1data[i].Mxx);
     632    stars[i].measure.Mxy        = ToShortPixels(ps1data[i].Mxy);
     633    stars[i].measure.Myy        = ToShortPixels(ps1data[i].Myy);
     634                       
     635    stars[i].measure.photFlags  = ps1data[i].flags;
     636
     637    // this is may optionally be replaced by the internal sequence (see FilterStars.c)
     638    stars[i].measure.detID      = ps1data[i].detID;
     639
     640    // the Average fields and the following Measure fields are set in FilterStars after
     641    // the image metadata is in hand:  dR, dD, Mcal, dt, airmass, az, t, imageID, extID,
     642    // averef is set in find_matches, dbFlags is zero on ingest.
     643
     644    // the following fields are currently not being set anywhere: t_msec
     645  }   
     646  *nstars = Nstars;
     647  return (stars);
     648}
     649
  • trunk/Ohana/src/addstar/src/resort_catalog.c

    r30613 r31160  
    9292    averageSeq[i] = measure[i].averef;
    9393   
    94     myAssert(average[averageSeq[i]].objID == measure[measureSeq[i]].objID, "object / detection mismatch");
    95     myAssert(average[averageSeq[i]].catID == measure[measureSeq[i]].catID, "object / detection mismatch");
     94    if (catalog[0].catformat >= DVO_FORMAT_PS1_V1) {
     95      // earlier formats did not carry the objID or catID, so they are not available (we could assign on load, but we don't)
     96      myAssert(average[averageSeq[i]].objID == measure[measureSeq[i]].objID, "object / detection mismatch");
     97      myAssert(average[averageSeq[i]].catID == measure[measureSeq[i]].catID, "object / detection mismatch");
     98    }
    9699  }
    97100 
  • trunk/Ohana/src/dvomerge/src/dvoverify.c

    r30830 r31160  
    1313# define DEBUG 0
    1414
    15 int VERBOSE;
    16 int CHECKSORTED;
     15int VERBOSE = FALSE;
    1716int NNotSorted = 0;
    1817
     
    2827  // Catalog catalog;
    2928
    30   VERBOSE = FALSE;
     29  int CHECKSORTED;
     30
    3131  if ((N = get_argument (argc, argv, "-v"))) {
    3232    VERBOSE = TRUE;
    3333    remove_argument (N, &argc, argv);
    3434  }
     35  if ((N = get_argument (argc, argv, "-verbose"))) {
     36    VERBOSE = TRUE;
     37    remove_argument (N, &argc, argv);
     38  }
    3539  if ((N = get_argument (argc, argv, "-s"))) {
    3640    CHECKSORTED = TRUE;
    3741    remove_argument (N, &argc, argv);
    3842  }
    39 
     43  if ((N = get_argument (argc, argv, "-sorted"))) {
     44    CHECKSORTED = TRUE;
     45    remove_argument (N, &argc, argv);
     46  }
    4047
    4148  // restrict to a portion of the sky
     
    5764
    5865  if (argc != 2) {
    59     fprintf (stderr, "USAGE: dvoverify (catdir) [-region Rmin Rmax Dmin Dmax] [-v -s]\n\n -v = verbose \n -s = checks if sorted, return error if not\n");
    60     fprintf (stderr, "  catdir : database of interest\n");
     66    fprintf (stderr, "USAGE: dvoverify (catdir) [-region Rmin Rmax Dmin Dmax] [-v] [-s]\n\n");
     67    fprintf (stderr, "  -v : VERBOSE\n");
     68    fprintf (stderr, "  -s : checks if sorted, return error if not\n");
     69    fprintf (stderr, "  (catdir) : database of interest\n");
    6170    exit (2);
    6271  }
     
    96105  for (i = 0; i < inlist[0].Nregions; i++) {
    97106    if (!inlist[0].regions[i][0].table) continue;
    98     if ((NNotSorted > 0) && CHECKSORTED) continue;
    99107    if (i % 1000 == 0) fprintf (stderr, ".");
    100108
     
    116124    if (!CheckCatalogIndexes(catdir, inlist[0].filename[i], inlist[0].regions[i])){
    117125      Nbad ++;
     126    }
     127
     128    // exit immediately if any file are unsorted and we require sorted tables
     129    if (CHECKSORTED && NNotSorted) {
     130      fprintf (stderr, "ERROR: files are not sorted\n");
     131      exit (1);
    118132    }
    119133  }
     
    123137    exit (1);
    124138  }
    125   if ((NNotSorted > 0) && CHECKSORTED) {
    126     fprintf (stderr, "ERROR: files are not sorted\n");
    127      exit (1);
    128   }
    129139
    130140  fprintf (stderr, "SUCCESS: no files are bad\n");
     141  if (NNotSorted) {
     142    fprintf (stderr, "NOTE: %d files are not sorted\n", NNotSorted);
     143  }
    131144  exit (0);
    132145}
  • trunk/Ohana/src/kapa2/src/PSObjects.c

    r30606 r31160  
    270270  float *x, *y, *z;
    271271  double mxi, mxj, myi, myj, bxi, bxj, byi, byj, bx, by;
    272   double sx, sy, d, sx1, sy1, sx2, sy2;
     272  double sx, sy, d, sx1, sy1, sx2, sy2, X0, Y0, X1, Y1;
    273273
    274274  mxi = graph[0].axis[0].dfx / (object[0].x1 - object[0].x0);
     
    432432    }
    433433    if (object[0].ptype == 100) {       /* connect a pair of points */
     434        X0 = graph[0].axis[0].fx;
     435        X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     436        Y0 = graph[0].axis[1].fy;
     437        Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     438
    434439      for (i = 0; i + 1 < object[0].Npts; i+=2) {
    435440        if (!(finite(x[i]) && finite(y[i]))) continue;
     
    438443        sx2 = x[i+1]*mxi + y[i+1]*mxj + bx;
    439444        sy2 = x[i+1]*myi + y[i+1]*myj + by;
    440         DrawLine (sx1, sy1, sx2, sy2);
     445        ClipLinePS (sx1, sy1, sx2, sy2, X0, Y0, X1, Y1, f);
    441446      }
    442447    }
     
    585590    }
    586591    if (object[0].ptype == 100) {       
     592        X0 = graph[0].axis[0].fx;
     593        X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     594        Y0 = graph[0].axis[1].fy;
     595        Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     596
    587597      for (i = 0; i + 1 < object[0].Npts; i+=2) {
    588598        if (!(finite(x[i]) && finite(y[i]))) continue;
     
    591601        sx2 = x[i+1]*mxi + y[i+1]*mxj + bx;
    592602        sy2 = x[i+1]*myi + y[i+1]*myj + by;
    593         DrawLine (sx1, sy1, sx2, sy2);
     603        ClipLinePS (sx1, sy1, sx2, sy2, X0, Y0, X1, Y1, f);
    594604      }
    595605    }
  • trunk/Ohana/src/kapa2/src/SetImageData.c

    r27435 r31160  
    128128  Picture_to_Image (&Xmax, &Ymax, image[0].picture.dx, image[0].picture.dy, &image[0].picture);
    129129
    130   KiiSendMessage (sock, "%g %g %g %g", Xmin, Xmax, Ymin, Ymax);
     130  KiiSendMessage (sock, "%g %g %g %g %d %d", Xmin, Xmax, Ymin, Ymax, image[0].picture.dx, image[0].picture.dy);
    131131
    132132  return (TRUE);
  • trunk/Ohana/src/kapa2/src/bDrawObjects.c

    r30606 r31160  
    415415    }
    416416    if (object[0].ptype == 100) {       /* connect a pair of points */
     417
     418      double X0 = graph[0].axis[0].fx;
     419      double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     420      double Y0 = graph[0].axis[1].fy;
     421      double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     422
    417423      for (i = 0; i + 1 < object[0].Npts; i+=2) {
    418424        if (!(finite(x[i]) && finite(y[i]))) continue;
     
    421427        sx2 = x[i+1]*mxi + y[i+1]*mxj + bx;
    422428        sy2 = x[i+1]*myi + y[i+1]*myj + by;
    423         DrawLine (buffer, sx1, sy1, sx2, sy2);
     429        bDrawClipLine (buffer, sx1, sy1, sx2, sy2, X0, Y0, X1, Y1);
    424430      }
    425431    }
     
    561567    }
    562568    if (object[0].ptype == 100) {       
     569
     570      double X0 = graph[0].axis[0].fx;
     571      double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     572      double Y0 = graph[0].axis[1].fy;
     573      double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     574
    563575      for (i = 0; i + 1 < object[0].Npts; i+=2) {
    564576        if (!(finite(x[i]) && finite(y[i]))) continue;
     
    567579        sx2 = x[i+1]*mxi + y[i+1]*mxj + bx;
    568580        sy2 = x[i+1]*myi + y[i+1]*myj + by;
    569         DrawLine (buffer, sx1, sy1, sx2, sy2);
     581        bDrawClipLine (buffer, sx1, sy1, sx2, sy2, X0, Y0, X1, Y1);
    570582      }
    571583    }
  • trunk/Ohana/src/libautocode/Makefile.Targets

    r29537 r31160  
    6060$(ASRC)/cmf-ps1-v2.$(ARCH).o \
    6161$(ASRC)/cmf-ps1-v3.$(ARCH).o \
     62$(ASRC)/cmf-ps1-sv1.$(ARCH).o \
    6263$(ASRC)/cmf-smpdata.$(ARCH).o \
    6364$(ASRC)/getstar-ps1-dev-0.$(ARCH).o \
     
    131132$(AINC)/cmf-ps1-v2.h \
    132133$(AINC)/cmf-ps1-v3.h \
     134$(AINC)/cmf-ps1-sv1.h \
    133135$(AINC)/cmf-smpdata.h \
    134136$(AINC)/getstar-ps1-dev-0.h \
  • trunk/Ohana/src/libdvo/Makefile

    r30605 r31160  
    7474$(SRC)/skyregion_ops.$(ARCH).o \
    7575$(SRC)/cmf-ps1-v1-alt.$(ARCH).o \
     76$(SRC)/cmf-ps1-sv1-alt.$(ARCH).o \
    7677$(SRC)/dvo_util.$(ARCH).o
    7778
  • trunk/Ohana/src/libdvo/include/dvo.h

    r29938 r31160  
    199199// special-case function:
    200200CMF_PS1_V2 *gfits_table_get_CMF_PS1_V1_Alt (FTable *ftable, off_t *Ndata, char *swapped);
     201CMF_PS1_SV1 *gfits_table_get_CMF_PS1_SV1_Alt (FTable *ftable, off_t *Ndata, char *swapped);
    201202
    202203typedef struct {
  • trunk/Ohana/src/libdvo/lib

    • Property svn:ignore
      •  

        old new  
        11*.a
        22*.so
         3*.dylib
  • trunk/Ohana/src/libfits/lib

    • Property svn:ignore
      •  

        old new  
        11*.a
        22*.so
         3*.dylib
  • trunk/Ohana/src/libkapa/include/kapa.h

    r29938 r31160  
    33
    44/* linux is happy with this, not solaris */
    5 # include <netinet/ip.h>
     5//# include <netinet/in_systm.h>
     6//# include <netinet/ip.h>
     7
     8# include <sys/types.h>
     9# include <sys/socket.h>
     10# include <netinet/in.h>
    611# include <netdb.h>
    712# include <arpa/inet.h>
    813
    9 # include <sys/types.h>
    10 # include <sys/socket.h>
    1114# include <X11/Xlib.h>
    1215# include <png.h>
     
    151154int KapaSetImageCoords (int fd, Coords *coords);
    152155int KapaGetImageCoords (int fd, Coords *coords);
    153 int KapaGetImageRange (int fd, double *Xmin, double *Xmax, double *Ymin, double *Ymax);
     156int KapaGetImageRange (int fd, double *Xmin, double *Xmax, double *Ymin, double *Ymax, int *dX, int *dY);
    154157
    155158/* KiiOverlay.c */
  • trunk/Ohana/src/libkapa/lib

    • Property svn:ignore
      •  

        old new  
        11*.a
        22*.so
         3*.dylib
  • trunk/Ohana/src/libkapa/src/KiiPicture.c

    r27761 r31160  
    203203}
    204204
    205 int KapaGetImageRange (int fd, double *Xmin, double *Xmax, double *Ymin, double *Ymax) {
     205int KapaGetImageRange (int fd, double *Xmin, double *Xmax, double *Ymin, double *Ymax, int *dX, int *dY) {
    206206
    207207  /* tell kapa to look for the incoming image */
    208208  KiiSendCommand (fd, 4, "GIMR");
    209209 
    210   KiiScanMessage (fd, "%lf %lf %lf %lf", Xmin, Xmax, Ymin, Ymax);
     210  KiiScanMessage (fd, "%lf %lf %lf %lf %d %d", Xmin, Xmax, Ymin, Ymax, dX, dY);
    211211
    212212  KiiWaitAnswer (fd, "DONE");
  • trunk/Ohana/src/libohana/include/ohana.h

    r30602 r31160  
    155155# define OFF_T_FMT "%jd"
    156156# endif
    157 # ifdef _DARWIN_C_SOURCE
     157// # ifdef _DARWIN_C_SOURCE
     158// # define OFF_T_FMT "%lld"
     159// # endif
     160# ifdef darwin_x86
    158161# define OFF_T_FMT "%lld"
    159 #endif
     162# endif
    160163# ifndef OFF_T_FMT
    161164# define OFF_T_FMT "%ld"
  • trunk/Ohana/src/libohana/lib

    • Property svn:ignore
      •  

        old new  
        11*.a
        22*.so
         3*.dylib
  • trunk/Ohana/src/libohana/test

    • Property svn:ignore
      •  

        old new  
        22*.lin64
        33*.sol
         4*.darwin_x86
         5*.dSYM
  • trunk/Ohana/src/libohana/test/typetest.c

    r28241 r31160  
    6868        fprintf (stderr, "STDC_VERSION is not set\n");
    6969# endif
     70    }
    7071
    71     }
     72    // 3) have we defined OFF_T_FMT correctly?
     73    off_t big_value;
     74
     75    big_value = 10;
     76    fprintf (stderr, "this is a bit int: "OFF_T_FMT" n'est pas?\n", big_value);
     77
    7278    exit (status);
    7379}
  • trunk/Ohana/src/libtap/lib

    • Property svn:ignore
      •  

        old new  
        11*.a
        22*.so
         3*.dylib
  • trunk/Ohana/src/opihi/cmd.astro/region.c

    r30611 r31160  
    55  double Ra, Dec, Radius;
    66  float dx, dy;
    7   int N, kapa, NoClear;
     7  int N, kapa, NoClear, dXpix, dYpix;
    88  char *name;
    99  Graphdata graphmode;
     
    2727    remove_argument (N, &argc, argv);
    2828    KapaGetImageCoords (kapa, &graphmode.coords);
    29     KapaGetImageRange (kapa, &graphmode.xmin, &graphmode.xmax, &graphmode.ymax, &graphmode.ymin);
     29    KapaGetImageRange (kapa, &graphmode.xmin, &graphmode.xmax, &graphmode.ymax, &graphmode.ymin, &dXpix, &dYpix);
    3030
    3131    set_variable ("XMIN", graphmode.xmin);
  • trunk/Ohana/src/opihi/cmd.data/densify.c

    r29938 r31160  
    11# include "data.h"
     2
     3# define CHECKVAL(ARG) if (!isfinite(ARG)) { gprint (GP_ERR, "illegal value for %s: %f\n", #ARG, ARG); return (FALSE); }
    24
    35int densify (int argc, char **argv) {
    46
    5   int i, Nx, Ny, Xb, Yb, Normalize, N;
    6   float Xmin, Xmax, dX, Ymin, Ymax, dY;
     7  int i, Nx, Ny, Xb, Yb, Normalize, N, Xpix, Ypix, good, UseGraph;
     8  double Xmin, Xmax, dX, Ymin, Ymax, dY;
    79  float *val;
    810  Buffer *bf;
     
    1618  }
    1719
    18   if (argc != 10) {
     20  UseGraph = FALSE;
     21  if ((N = get_argument (argc, argv, "-graph"))) {
     22    remove_argument (N, &argc, argv);
     23    UseGraph = TRUE;
     24  }
     25
     26  good = UseGraph ? (argc == 4) : (argc == 10);
     27  if (!good) {
    1928    gprint (GP_ERR, "USAGE: densify buffer x y Xmin Xmax dX Ymin Ymax dY\n");
     29    gprint (GP_ERR, "   OR: densify buffer x y -graph\n");
    2030    return (FALSE);
    2131  }
     
    3040  REQUIRE_VECTOR_FLT (vy, FALSE);
    3141
    32   Xmin = atof (argv[4]);
    33   Xmax = atof (argv[5]);
    34   dX   = atof (argv[6]);
     42  if (UseGraph) {
     43    int kapa;
     44    Graphdata graphmode;
     45    if (!GetGraph (&graphmode, &kapa, NULL)) return (FALSE);
     46    KapaGetImageRange (kapa, &Xmin, &Xmax, &Ymax, &Ymin, &Xpix, &Ypix);
     47    Xmax = graphmode.xmax;
     48    Xmin = graphmode.xmin;
     49    Ymax = graphmode.ymax;
     50    Ymin = graphmode.ymin;
     51    dX = (Xmax - Xmin) / (Xpix - 1);
     52    dY = (Ymax - Ymin) / (Ypix - 1);
     53  } else {
     54    Xmin = atof (argv[4]);
     55    Xmax = atof (argv[5]);
     56    dX   = atof (argv[6]);
    3557
    36   Ymin = atof (argv[7]);
    37   Ymax = atof (argv[8]);
    38   dY   = atof (argv[9]);
     58    Ymin = atof (argv[7]);
     59    Ymax = atof (argv[8]);
     60    dY   = atof (argv[9]);
     61  }
     62
     63  CHECKVAL(Xmin);
     64  CHECKVAL(Xmax);
     65  CHECKVAL(dX);
     66
     67  CHECKVAL(Ymin);
     68  CHECKVAL(Ymax);
     69  CHECKVAL(dY);
    3970
    4071  Nx = (Xmax - Xmin) / dX + 1;
  • trunk/Ohana/src/opihi/cmd.data/fit1d.c

    r27817 r31160  
    4242
    4343  if (argc != 4) {
    44     gprint (GP_ERR, "USAGE: fit x y order [-dy wt] [-quiet/-q] [-clip Nsigma Niter]\n");
     44    gprint (GP_ERR, "USAGE: fit1d x y order [-dy wt] [-quiet/-q] [-clip Nsigma Niter]\n");
    4545    return (FALSE);
    4646  }
  • trunk/Ohana/src/opihi/cmd.data/fit2d.c

    r29001 r31160  
    4848
    4949  if (argc != 5) {
    50     gprint (GP_ERR, "USAGE: fit x y z order [-dz wt]\n");
     50    gprint (GP_ERR, "USAGE: fit2d x y z order [-dz wt] [-quiet/-q] [-clip Nsigma Niter]\n");
    5151    return (FALSE);
    5252  }
  • trunk/Ohana/src/opihi/cmd.data/histogram.c

    r27817 r31160  
    6161    opihi_int *V = xvec[0].elements.Int;
    6262    for (i = 0; i < xvec[0].Nelements; i++, V++) {
    63       if (isnan(*V)) continue;
    6463      bin = MIN (MAX (0, (*V - start) / delta), Nbins - 1);
    6564      OUT[bin]++;
  • trunk/Ohana/src/opihi/cmd.data/limits.c

    r30610 r31160  
    33int limits (int argc, char **argv) {
    44
    5   int N, APPLY;
     5  int N, APPLY, dX, dY;
    66  int kapa;
    77  char *name;
     
    2828  if ((N = get_argument (argc, argv, "-image"))) {
    2929    remove_argument (N, &argc, argv);
    30     KapaGetImageRange (kapa, &graphmode.xmin, &graphmode.xmax, &graphmode.ymax, &graphmode.ymin);
     30    KapaGetImageRange (kapa, &graphmode.xmin, &graphmode.xmax, &graphmode.ymax, &graphmode.ymin, &dX, &dY);
    3131
    3232    set_variable ("XMIN", graphmode.xmin);
     
    3434    set_variable ("YMIN", graphmode.ymin);
    3535    set_variable ("YMAX", graphmode.ymax);
     36
     37    set_variable ("KAPA_XMIN", graphmode.xmin);
     38    set_variable ("KAPA_XMAX", graphmode.xmax);
     39    set_variable ("KAPA_YMIN", graphmode.ymin);
     40    set_variable ("KAPA_YMAX", graphmode.ymax);
     41
     42    set_variable ("KAPA_XPIX", dX);
     43    set_variable ("KAPA_YPIX", dY);
    3644
    3745    // if (!NoClear) KapaClearSections (kapa);
  • trunk/Ohana/src/opihi/cmd.data/section.c

    r29938 r31160  
    6868  if ((argc == 1) && (action == NONE)) {
    6969    KapaGetSection (kapa, "*");
    70     gprint (GP_ERR, "USAGE: section name [x y dx dy] [options]\n");
     70    gprint (GP_ERR, "USAGE: section name [x y dx dy] or [options]\n");
    7171    gprint (GP_ERR, "OPTIONS: -list   : show properties of all sections\n");
    7272    gprint (GP_ERR, "         -up     : move section up in display stack\n");
     
    7676    gprint (GP_ERR, "         -imtool (position) : set location of image zoom / status box\n");
    7777    gprint (GP_ERR, "                 (position may be: -x, +x, -y, +y, none)\n");
     78    gprint (GP_ERR, "         -image  : define section upper-right corner so image fills the section\n");
     79    gprint (GP_ERR, "         -bg (color) : set background color (see style -c help for color choices)\n");
     80   
    7881    return (TRUE);
    7982  }
    8083 
     84  if ((argc != 2) && (action != NONE)) {
     85      gprint (GP_ERR, "can only use dash options without numbers\n");
     86      return (FALSE);
     87  }
     88
    8189  if (argc == 2) {
    8290    /* select / show section */
  • trunk/Ohana/src/opihi/dvo/dbExtractImages.c

    r30612 r31160  
    5959  time_t t;
    6060  dbValue value;
     61  off_t Nmosaic;
    6162
    6263  value.Flt = NAN;
     
    236237      value.Flt = image[N].fwhm_y / 25.0;
    237238      break;
     239
     240    case IMAGE_FWHM_MEDIAN:
     241      if (!(Nmosaic = FindMosaicForImage (image, Nimage, N))) return value;
     242      Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1
     243      value.Flt = (image[Nmosaic].fwhm_x + image[Nmosaic].fwhm_y) / 50.0;
     244      break;
     245    case IMAGE_FWHM_MAJ_MEDIAN:
     246      if (!(Nmosaic = FindMosaicForImage (image, Nimage, N))) return value;
     247      Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1
     248      value.Flt = image[Nmosaic].fwhm_x / 25.0;
     249      break;
     250    case IMAGE_FWHM_MIN_MEDIAN:
     251      if (!(Nmosaic = FindMosaicForImage (image, Nimage, N))) return value;
     252      Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1
     253      value.Flt = image[Nmosaic].fwhm_y / 25.0;
     254      break;
     255
    238256    case IMAGE_TRATE:
    239257      value.Flt = image[N].trate / 10000.0;
  • trunk/Ohana/src/opihi/dvo/dbFields.c

    r30612 r31160  
    395395  if (!strcasecmp (fieldName, "cerror"   )) ESCAPE (IMAGE_CERROR,    MAG_NONE, OPIHI_FLT);
    396396
    397   if (!strcasecmp (fieldName, "FWHM"     )) ESCAPE (IMAGE_FWHM,      MAG_NONE, OPIHI_FLT);
    398   if (!strcasecmp (fieldName, "FWHM_MAJ" )) ESCAPE (IMAGE_FWHM_MAJ,  MAG_NONE, OPIHI_FLT);
    399   if (!strcasecmp (fieldName, "FWHM_MIN" )) ESCAPE (IMAGE_FWHM_MIN,  MAG_NONE, OPIHI_FLT);
     397  if (!strcasecmp (fieldName, "FWHM"       )) ESCAPE (IMAGE_FWHM,      MAG_NONE, OPIHI_FLT);
     398  if (!strcasecmp (fieldName, "FWHM_MAJ"   )) ESCAPE (IMAGE_FWHM_MAJ,  MAG_NONE, OPIHI_FLT);
     399  if (!strcasecmp (fieldName, "FWHM_MIN"   )) ESCAPE (IMAGE_FWHM_MIN,  MAG_NONE, OPIHI_FLT);
     400  if (!strcasecmp (fieldName, "FWHM_MAJOR" )) ESCAPE (IMAGE_FWHM_MAJ,  MAG_NONE, OPIHI_FLT);
     401  if (!strcasecmp (fieldName, "FWHM_MINOR" )) ESCAPE (IMAGE_FWHM_MIN,  MAG_NONE, OPIHI_FLT);
     402
     403  if (!strcasecmp (fieldName, "FWHM_MEDIAN"    ))   ESCAPE (IMAGE_FWHM_MEDIAN,      MAG_NONE, OPIHI_FLT);
     404  if (!strcasecmp (fieldName, "FWHM_MAJ_MEDIAN"))   ESCAPE (IMAGE_FWHM_MAJ_MEDIAN,  MAG_NONE, OPIHI_FLT);
     405  if (!strcasecmp (fieldName, "FWHM_MIN_MEDIAN"))   ESCAPE (IMAGE_FWHM_MIN_MEDIAN,  MAG_NONE, OPIHI_FLT);
     406  if (!strcasecmp (fieldName, "FWHM_MAJOR_MEDIAN")) ESCAPE (IMAGE_FWHM_MAJ_MEDIAN,  MAG_NONE, OPIHI_FLT);
     407  if (!strcasecmp (fieldName, "FWHM_MINOR_MEDIAN")) ESCAPE (IMAGE_FWHM_MIN_MEDIAN,  MAG_NONE, OPIHI_FLT);
     408
    400409  if (!strcasecmp (fieldName, "trate"    )) ESCAPE (IMAGE_TRATE,     MAG_NONE, OPIHI_FLT);
    401410
  • trunk/Ohana/src/opihi/dvo/imextract.c

    r30612 r31160  
    197197    gprint (GP_ERR, "  cerror : astrometric scatter\n");
    198198
    199     gprint (GP_ERR, "  FWHM : mean fwhm of exposure\n");
    200     gprint (GP_ERR, "  FWHM_MAJ : fwhm of major axis\n");
    201     gprint (GP_ERR, "  FWHM_MIN : fwhm of minor axis\n");
     199    gprint (GP_ERR, "  -- Note: the follow FWHM are from the PSF model --\n");
     200    gprint (GP_ERR, "  FWHM : mean fwhm of chip\n");
     201    gprint (GP_ERR, "  FWHM_MAJ : fwhm of chip (major axis)\n");
     202    gprint (GP_ERR, "  FWHM_MIN : fwhm of chip (minor axis)\n");
     203    gprint (GP_ERR, "  FWHM_MAJOR : fwhm of chip (major axis)\n");
     204    gprint (GP_ERR, "  FWHM_MININ : fwhm of chip (minor axis)\n");
     205
     206    gprint (GP_ERR, "  FWHM_MEDIAN : median fwhm of exposure\n");
     207    gprint (GP_ERR, "  FWHM_MAJ_MEDIAN : median fwhm of major axis\n");
     208    gprint (GP_ERR, "  FWHM_MIN_MEDIAN : median fwhm of minor axis\n");
     209    gprint (GP_ERR, "  FWHM_MAJOR_MEDIAN : median fwhm of major axis\n");
     210    gprint (GP_ERR, "  FWHM_MININ_MEDIAN : median fwhm of minor axis\n");
     211
    202212    gprint (GP_ERR, "  trate : tracking rate for TDI images\n");
    203213
  • trunk/Ohana/src/opihi/dvo/skycoverage.c

    r29540 r31160  
    55int skycoverage (int argc, char **argv) {
    66
    7   int WITH_MOSAIC, SOLO_MOSAIC;
     7  int WITH_MOSAIC, SOLO_MOSAIC, ShowDensity;
    88  off_t i, Nimage;
    99  int N, status, TimeSelect, ByName, xs, ys;
     
    6060  }
    6161
     62  ShowDensity = FALSE;
     63  if ((N = get_argument (argc, argv, "-density"))) {
     64    remove_argument (N, &argc, argv);
     65    ShowDensity = TRUE;
     66  }
     67
    6268  ByName = FALSE;
    6369  if ((N = get_argument (argc, argv, "-name"))) {
     
    141147  if (argc != 3) {
    142148    gprint (GP_ERR, "USAGE: skycoverage (buffer) (Npts)\n");
    143     gprint (GP_ERR, "  options: [-scale pixscale] [-center ra dec] [-size Nx Nx] [-proj projection] [-time start range] [-trange start stop] [-name name] [-photcode name] [+mosaic] [-mosaic]\n");
     149    gprint (GP_ERR, "  options: [-scale pixscale] [-center ra dec] [-size Nx Nx] [-proj projection] [-time start range] [-trange start stop] [-name name] [-photcode name] [+mosaic] [-mosaic] [-density]\n");
    144150    gprint (GP_ERR, "       (buffer) saves bitmapped image\n");
    145151    gprint (GP_ERR, "       (Npts) gives the number of test points per image in each dimension\n");
     
    148154    gprint (GP_ERR, "       -size (Nx) (Ny)    : specifies the size of the image [360/scale, 180/scale]\n");
    149155    gprint (GP_ERR, "       -proj (projection) : specifies the projection choice [AIT]\n");
     156    gprint (GP_ERR, "       -density           : create image with relative density (else binary on/off)\n");
    150157    gprint (GP_ERR, "       note: we need 64800 / (pixscale)^2 pixels to represent the sky\n");
    151158    return (FALSE);
     
    186193
    187194  V = (float *)buf[0].matrix.buffer;
    188   bzero (V, Nx*Ny*sizeof(float));
    189195
    190196  for (ys = 0; ys < Ny; ys++) {
     
    194200      status &= (r <= 360);
    195201      if (status) {
    196         V[ys*Nx + xs] = 2;
     202        V[ys*Nx + xs] = ShowDensity ?  0 : 2;
     203      } else {
     204        V[ys*Nx + xs] = ShowDensity ? -1 : 0;
    197205      }
    198206    }
     
    249257          xs = (int)Xs;
    250258          ys = (int)Ys;
    251           V[ys*Nx + xs] = 1;
     259          if (ShowDensity) {
     260              V[ys*Nx + xs] += 1;
     261          } else {
     262              V[ys*Nx + xs] = 1;
     263          }
    252264        }
    253265      }
  • trunk/Ohana/src/opihi/include/dvoshell.h

    r30614 r31160  
    179179      IMAGE_TIME,
    180180      IMAGE_FWHM,
     181      IMAGE_FWHM_MEDIAN,
    181182      IMAGE_EXPTIME,
    182183      IMAGE_NSTAR,
     
    200201      IMAGE_FWHM_MAJ,
    201202      IMAGE_FWHM_MIN,
     203      IMAGE_FWHM_MAJ_MEDIAN,
     204      IMAGE_FWHM_MIN_MEDIAN,
    202205      IMAGE_TRATE,
    203206      IMAGE_IMAGE_ID,
  • trunk/Ohana/src/opihi/lib.data/graphtools.c

    r20936 r31160  
    5959  set_variable ("YMIN", graphmode[0].ymin);
    6060  set_variable ("YMAX", graphmode[0].ymax);
     61
     62  set_variable ("KAPA_XMIN", graphmode[0].xmin);
     63  set_variable ("KAPA_XMAX", graphmode[0].xmax);
     64  set_variable ("KAPA_YMIN", graphmode[0].ymin);
     65  set_variable ("KAPA_YMAX", graphmode[0].ymax);
    6166}
    6267
     
    95100  SetGraph (graphmode);
    96101
     102  set_variable ("KAPA_XMIN", graphmode[0].xmin);
     103  set_variable ("KAPA_XMAX", graphmode[0].xmax);
     104  set_variable ("KAPA_YMIN", graphmode[0].ymin);
     105  set_variable ("KAPA_YMAX", graphmode[0].ymax);
     106
    97107  set_variable ("XMIN", graphmode[0].xmin);
    98108  set_variable ("XMAX", graphmode[0].xmax);
  • trunk/Ohana/src/opihi/lib.shell/VectorOps.c

    r30614 r31160  
    218218    }
    219219    free (vec[0].elements.Int);
    220     vec[0].elements.Flt = vo;
     220    vec[0].elements.Flt = temp;
    221221    vec[0].type = OPIHI_FLT;
    222222  } else {
     
    229229    }
    230230    free (vec[0].elements.Flt);
    231     vec[0].elements.Int = vo;
     231    vec[0].elements.Int = temp;
    232232    vec[0].type = OPIHI_INT;
    233233  }
  • trunk/Ohana/src/relastro/include/relastro.h

    r30616 r31160  
    8989char   GSCFILE[256];
    9090char   CATDIR[256];
     91char   *HIGH_SPEED_DIR;
    9192char   CATMODE[16];    /* raw, mef, split, mysql */
    9293char   CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
     
    9596
    9697double SIGMA_LIM;
    97 int    SRC_MEAS_TOOFEW; //catalog objects wich fewer detections then this are ignored
     98int SRC_MEAS_TOOFEW; //catalog objects wich fewer detections then this are ignored
    9899double MIN_ERROR;
    99100
  • trunk/Ohana/src/relastro/src/UpdateObjects.c

    r30616 r31160  
    9292      }
    9393# endif
     94
     95      if (catalog[i].average[j].Nmeasure == 0) {
     96          continue;
     97      }
    9498
    9599      N = 0;
  • trunk/Ohana/src/relastro/src/args.c

    r30616 r31160  
    3939    remove_argument (N, &argc, argv);
    4040    RADIUS = atof(argv[N]);
     41    remove_argument (N, &argc, argv);
     42    HIGH_SPEED_DIR = strcreate(argv[N]);
    4143    remove_argument (N, &argc, argv);
    4244  }
  • trunk/Ohana/src/relastro/src/high_speed_objects.c

    r29938 r31160  
    2222  int zcode, zNsec, ycode, yNsec, jcode, jNsec, hcode, hNsec, kcode, kNsec, USNO_R, USNO_N, Nsecfilt;
    2323  char filename[1024];
    24   char outdir[]="/data/ipp022.0/ndeacon/hispeedzy";
    2524  Noff = strlen(CATDIR);
    26   sprintf (filename, "%s/%s", outdir, &catalog[0].filename[Noff]);
     25  sprintf (filename, "%s/%s", HIGH_SPEED_DIR, &catalog[0].filename[Noff]);
     26  printf("%s\n",filename);
    2727  dvo_catalog_init(&catalog1, TRUE); /*initialise new catalogue*/
    2828  catalog1.filename = strcreate(filename);
     
    121121    foundA = FALSE;
    122122    for (j = 0; !foundA && (j < catalog[0].average[i].Nmeasure); j++, m++) {
    123       if((catalog[0].average[i].R>204.1923)&&(catalog[0].average[i].R<204.1924)&&(catalog[0].average[i].D>11.376)&&(catalog[0].average[i].D<11.377))
    124         {
    125           printf("Hello");
    126         }
    127123
    128124      if (MeasMatchesPhotcode(&catalog[0].measure[m], photcodesGroupA, NphotcodesGroupA)) {
     
    135131    foundB = FALSE;
    136132    for (j = 0; !foundB && (j < catalog[0].average[i].Nmeasure); j++, m++) {
    137                                                    
    138       if((catalog[0].average[i].R>204.192)&&(catalog[0].average[i].R<204.1925)&&(catalog[0].average[i].D>11.376)&&(catalog[0].average[i].D<11.377))
    139         {
    140           printf("Hello");
    141         }
     133         
    142134
    143135      if (MeasMatchesPhotcode(&catalog[0].measure[m], photcodesGroupB, NphotcodesGroupB)) {
     
    158150    if (foundA && !foundB) {
    159151      // average-based tests:
    160                                                    
    161       if((catalog[0].average[i].R>204.1923)&&(catalog[0].average[i].R<204.1924)&&(catalog[0].average[i].D>11.376)&&(catalog[0].average[i].D<11.377))
    162         {
    163           printf("Hello");
    164         }
     152         
    165153
    166154      valid = TRUE;
     
    204192
    205193      // average-based tests:
    206       if((catalog[0].average[i].R>204.192)&&(catalog[0].average[i].R<204.193)&&(catalog[0].average[i].D>11.372)&&(catalog[0].average[i].D<11.373))
    207         {
    208           printf("Hello");
    209         }
    210194      valid = TRUE;
    211195      valid &= ((catalog[0].average[i].flags & 0x01000000) == 0);
     
    214198
    215199      valid &= ((catalog[0].secfilt[i*Nsecfilt + jNsec].M < 1.0)||(isnan(catalog[0].secfilt[i*Nsecfilt + jNsec].M)));
    216       valid &= (catalog[0].secfilt[i*Nsecfilt + yNsec].Nused > 1);
    217       valid &= (catalog[0].secfilt[i*Nsecfilt + yNsec].dM < 0.2);
     200      valid &= ((catalog[0].secfilt[i*Nsecfilt + yNsec].Nused > 1)||(catalog[0].secfilt[i*Nsecfilt + zNsec].Nused > 1));
     201      valid &= ((catalog[0].secfilt[i*Nsecfilt + yNsec].dM < 0.2)||(catalog[0].secfilt[i*Nsecfilt + zNsec].dM < 0.2));
    218202
    219203      /*if ((catalog[0].secfilt[i*Nsecfilt + zNsec].M < 1.0) || (catalog[0].secfilt[i*Nsecfilt + zNsec].Nused == 1)) {
  • trunk/Ohana/src/relastro/src/select_images.c

    r30616 r31160  
    144144    }
    145145   
     146    // this adds 1.3 sec for 3M images
    146147    if (!FindMosaicForImage (timage, Ntimage, i)) {
    147       fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n",  i);
     148      fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);
    148149      continue;
    149150    }
     
    165166    found = FALSE;
    166167
    167     /* transform corners to ra,dec */
     168    /* transform corners to ra,dec -- costs ~3sec for 3M images (pikake) */
    168169    double RminImage = 360.0;
    169170    double RmaxImage =   0.0;
    170171    double DminImage = +90.0;
    171172    double DmaxImage = -90.0;
    172     // int leftside = FALSE;
    173173    for (j = 0; j < 5; j++) {
    174174      XY_to_RD (&Ri[j], &Di[j], Xi[j], Yi[j], &timage[i].coords);
     
    197197    if (USE_BASIC_CHECK) goto found_it;
    198198
    199     // RA(nStart) is guaranteed to be < RminImage:
     199    // RA(nStart) is guaranteed to be < RminImage: -- costs 0.5sec for 3M images
    200200    nStart = getRegionStartByRA (RminImage, RmaxSky, skylist[0].Nregions);
    201201
     
    258258  }
    259259  MARKTIME("finish image selection: %f sec\n", dtime);
    260    
    261   if (VERBOSE) fprintf (stderr, "found "OFF_T_FMT" images\n",  nimage);
     260
     261  if (VERBOSE) fprintf (stderr, "found "OFF_T_FMT" images\n", nimage);
    262262
    263263  REALLOCATE (image, Image, MAX (nimage, 1));
  • trunk/Ohana/src/relphot/src/args.c

    r30616 r31160  
    7878    remove_argument (N, &argc, argv);
    7979    PLOTDELAY = 1e6*atof(argv[N]);
     80    PLOTSTUFF = TRUE; // always turn on plotting if i request a plot delay
    8081    remove_argument (N, &argc, argv);
    8182  }
  • trunk/Ohana/src/relphot/src/bcatalog.c

    r30616 r31160  
    77  off_t NAVERAGE, NMEASURE, Naverage, Nmeasure, Nm;
    88  float mag;
    9   int Ncode, Ntime, Ndophot, Nmag, Nsigma, Nimag, Nfew;
     9  int Ncode, Ntime, Ndophot, Nmag, Nsigma, Nimag, Nfew, Ngalaxy, Npsfqf;
    1010
    1111  // XXX PhotNsec as a global is a bad idea; either get it from catalog
     
    2323  Nmeasure = Naverage = 0;
    2424
    25   Ncode = Ntime = Ndophot = Nmag = Nsigma = Nimag = Nfew = 0;
     25  Ncode = Ntime = Ndophot = Nmag = Nsigma = Nimag = Nfew = Npsfqf = Ngalaxy = 0;
    2626
    2727  /* exclude stars not in range or with too few measurements */
     
    4444
    4545    Nm = 0;
     46    int nEXT = 0;
     47    int nPSF = 0;
    4648    for (j = 0; j < catalog[0].average[i].Nmeasure; j++) {
    4749
     
    6264      // XXX chnage this to select by bitflags
    6365      if (DophotSelect && ((catalog[0].measure[offset].photFlags >> 16) != DophotValue)) { Ndophot ++; continue; }
     66
     67      // skip garbage measurements
     68      if (catalog[0].measure[offset].psfQual < 0.85) { Npsfqf ++; continue; }
     69
     70      // check for galaxies
     71      if (!isnan(catalog[0].measure[offset].Map)) {
     72          if (catalog[0].measure[offset].M - catalog[0].measure[offset].Map > 0.15) {
     73              nEXT ++;
     74          } else {
     75              nPSF ++;
     76          }
     77      }
    6478
    6579      /* select measurements by mag limit */
     
    95109    }
    96110
     111    // skip object if it is likely to be a galaxy
     112    if (nEXT >= nPSF) {
     113      Nmeasure -= Nm;
     114      Ngalaxy ++;
     115      continue;
     116    }
     117
    97118    // XXXX test : what checks do I need to make elsewhere to avoid problems here?
    98119    if (Nm <= STAR_TOOFEW) { /* enough measurements in band? */
     
    121142    fprintf (stderr, "using "OFF_T_FMT" stars ("OFF_T_FMT" measures) of "OFF_T_FMT" for catalog %s\n",
    122143             subcatalog[0].Naverage,  subcatalog[0].Nmeasure,  i, catalog[0].filename);
    123     fprintf (stderr, "rejections: %d code, %d time, %d dophot, %d mag, %d sigma, %d imag, %d few\n",
    124              Ncode, Ntime, Ndophot, Nmag, Nsigma, Nimag, Nfew);
     144    fprintf (stderr, "rejections: %d code, %d time, %d dophot, %d mag, %d sigma, %d imag, %d few, %d psfqf, %d galaxies\n",
     145             Ncode, Ntime, Ndophot, Nmag, Nsigma, Nimag, Nfew, Npsfqf, Ngalaxy);
    125146  }
    126147  return (TRUE);
  • trunk/Ohana/src/relphot/src/load_images.c

    r30616 r31160  
    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);
  • trunk/Ohana/src/relphot/src/select_images.c

    r30616 r31160  
    3333  struct timeval start, stop;
    3434 
    35   double RmaxSkyRegion, RminSkyRegion, DminSkyRegion, DmaxSkyRegion, RmidSkyRegion;
     35  double RmaxSkyRegion, RminSkyRegion, RmidSkyRegion, DminSkyRegion, DmaxSkyRegion;
    3636
    3737  double *RmaxSky;
     
    131131    }
    132132
    133     /* define image corners */
    134     Xi[0] = 0;            Yi[0] = 0;
    135     Xi[1] = timage[i].NX; Yi[1] = 0;
    136     Xi[2] = timage[i].NX; Yi[2] = timage[i].NY;
    137     Xi[3] = 0;            Yi[3] = timage[i].NY;
    138     Xi[4] = 0;            Yi[4] = 0;
     133    /* define image corners - note the DIS images (mosaic phu) are special */
     134    if (!strcmp(&timage[i].coords.ctype[4], "-DIS")) {
     135      Xi[0] = -0.5*timage[i].NX; Yi[0] = -0.5*timage[i].NY;
     136      Xi[1] = +0.5*timage[i].NX; Yi[1] = -0.5*timage[i].NY;
     137      Xi[2] = +0.5*timage[i].NX; Yi[2] = +0.5*timage[i].NY;
     138      Xi[3] = -0.5*timage[i].NX; Yi[3] = +0.5*timage[i].NY;
     139      Xi[4] = -0.5*timage[i].NX; Yi[4] = -0.5*timage[i].NY;
     140    } else {
     141      Xi[0] = 0;            Yi[0] = 0;
     142      Xi[1] = timage[i].NX; Yi[1] = 0;
     143      Xi[2] = timage[i].NX; Yi[2] = timage[i].NY;
     144      Xi[3] = 0;            Yi[3] = timage[i].NY;
     145      Xi[4] = 0;            Yi[4] = 0;
     146    }
    139147    found = FALSE;
    140148
    141     /* transform corners to ra,dec -- costs ~3sec for 3M images */
     149    /* transform corners to ra,dec -- costs ~3sec for 3M images (pikake) */
    142150    double RminImage = 360.0;
    143151    double RmaxImage =   0.0;
     
    147155      XY_to_RD (&Ri[j], &Di[j], Xi[j], Yi[j], &timage[i].coords);
    148156      Ri[j] = ohana_normalize_angle_to_midpoint (Ri[j], RmidSkyRegion);
    149      
     157
    150158      RminImage = MIN(RminImage, Ri[j]);
    151159      RmaxImage = MAX(RmaxImage, Ri[j]);
     
    158166        RminImage = tmp - 360.0;
    159167    }
    160    
     168
    161169    // check that this image is even in range of the searched region
    162170    if (DminImage > DmaxSkyRegion) continue;
     
    182190      tcoords.crval2 = skycoords[m].Dc;
    183191
    184       /* transform to ra,dec */
     192      /* transform corner coords to X,Y in this catalog system */
    185193      InRange = TRUE;
    186194      for (j = 0; (j < 5) && InRange; j++) {
     
    352360  return (Nlo);
    353361}
    354 
    355 off_t getRegionStopByRA (double R, double *Rref, off_t Nregions) {
    356 
    357   // use bisection to find the overlapping mosaic
    358 
    359   off_t Nlo, Nhi, N;
    360 
    361   // find the last mosaic before start
    362   Nlo = 0; Nhi = Nregions;
    363   while (Nhi - Nlo > 10) {
    364     N = 0.5*(Nlo + Nhi);
    365     if (Rref[N] < R) {
    366       Nlo = MAX(N, 0);
    367     } else {
    368       Nhi = MIN(N, Nregions);
    369     }
    370   }
    371   return (Nlo);
    372 }
  • trunk/Ohana/src/tools/src/fhead.c

    r27491 r31160  
    11# include <ohana.h>
    22# include <gfitsio.h>
     3# include <regex.h>
    34
    45int main (int argc, char **argv) {
    56
    6   int N, Extend, Nextend, status;
     7  int N, Extnum, Nextend, status;
    78  int i, j;
    89  off_t nbytes;
    910  Header head;
    10   char *p;
     11  char *p, *CCDKeyword, *Extname, extname[80];
     12  FILE *f;
     13  off_t Nbytes;
     14  regex_t preg;
    1115
    12   Extend = FALSE;
     16  CCDKeyword = NULL;
     17  if ((N = get_argument (argc, argv, "-keyword"))) {
     18    remove_argument (N, &argc, argv);
     19    CCDKeyword = strcreate (argv[N]);
     20    remove_argument (N, &argc, argv);
     21  }
     22  if (CCDKeyword == NULL) {
     23    CCDKeyword = strcreate ("EXTNAME");
     24  }
     25
     26  Extnum = FALSE;
    1327  Nextend = 0;
    1428  if ((N = get_argument (argc, argv, "-x"))) {
    15     Extend = TRUE;
     29    Extnum = TRUE;
    1630    remove_argument (N, &argc, argv);
    1731    Nextend = atoi (argv[N]);
    1832    remove_argument (N, &argc, argv);
     33  }
     34
     35  Extname = NULL;
     36  if ((N = get_argument (argc, argv, "-n"))) {
     37    remove_argument (N, &argc, argv);
     38    Extname = strcreate (argv[N]);
     39    remove_argument (N, &argc, argv);
     40    regcomp (&preg, Extname, REG_EXTENDED);
    1941  }
    2042
     
    2345      fprintf (stdout, "------> %s <------\n", argv[i]);
    2446   
    25     if (Extend) {
    26       status = gfits_read_Xheader (argv[i], &head, Nextend);
    27     } else {
    28       status = gfits_read_header (argv[i], &head);
    29     }     
    30 
    31     if (!status) continue;
    32 
    33     for (j = 79; j < head.datasize; j+= 80) {
    34       head.buffer[j] = 10;
     47    status = FALSE;
     48    if (!Extnum && !Extname) {
     49      if (!gfits_read_header (argv[i], &head)) {
     50        continue;
     51      }
     52    }
     53    if (Extnum) {
     54      if (!gfits_read_Xheader (argv[i], &head, Nextend)) {
     55        continue;
     56      }
     57    }
     58    if (Extname) {
     59      /* keep reading headers until we reach the one we want */
     60      Nextend = 0;
     61      f = fopen (argv[i], "r");
     62      if (f == NULL) continue;
     63      while (gfits_fread_header (f, &head)) {
     64        /* extract the EXTNAME (or other CCDKeyword) for this component (set to PHU for 0th component) */
     65        if (!gfits_scan (&head, CCDKeyword, "%s", 1, extname)) {
     66          if (Nextend == 0) {
     67            strcpy (extname, "PHU");
     68          } else {
     69            strcpy (extname, "UNKNOWN");
     70          }
     71        }
     72        if (!regexec (&preg, extname, 0, NULL, 0)) {
     73          goto done;
     74        }
     75   
     76        Nbytes = gfits_data_size (&head);
     77        fseeko (f, Nbytes, SEEK_CUR);
     78        Nextend ++;
     79      }
     80      // failed to find the desired header
     81      continue;
    3582    }
    3683
    37     p = gfits_header_field (&head, "END", 1);
    38     nbytes = p - head.buffer;
    39     fwrite (head.buffer, nbytes, 1, stdout);
    40     gfits_free_header (&head);
     84  done:
     85      for (j = 79; j < head.datasize; j+= 80) {
     86        head.buffer[j] = 10;
     87      }
    4188
     89      p = gfits_header_field (&head, "END", 1);
     90      nbytes = p - head.buffer;
     91      fwrite (head.buffer, nbytes, 1, stdout);
     92      gfits_free_header (&head);
     93
     94    }
     95    exit (0);
    4296  }
    43   exit (0);
    44 }
  • trunk/Ohana/src/tools/src/ftable.c

    r28241 r31160  
    33# include "inttypes.h"
    44
    5 char *print_table_row (char *row, Header *header);
     5int print_table_rows (FTable *table, int start, int Nrows);
    66FILE *load_extension (char *file, int Nextend, char *Extname, Header *header);
    77void print_column (FTable *table, int Column, char *Colname);
     
    1313int main (int argc, char **argv) {
    1414
    15   off_t i, Nx, Ny, Nbytes, Nread, Row;
     15  off_t Nx, Ny, Nbytes, Nread, Row;
    1616  int N, Nextend, Column, ListExtname, Layout;
    17   char *Extname, *Colname, *line, ttype[80];
     17  char *Extname, *Colname, ttype[80];
    1818  FTable table;
    1919  Header header;
     
    104104  /* print a row */
    105105  if (Row) {
    106     line = print_table_row (&table.buffer[Nx*Row], table.header);
    107     fprintf (stdout, "%s\n", line);
    108     free (line);
     106    if (!print_table_rows (&table, Row, 1)) {
     107      fprintf (stderr, "failed to print row\n");
     108    }
    109109    exit (0);
    110110  }
    111111
    112112  /* print complete table */
    113   for (i = 0; i < Ny; i++) {
    114     line = print_table_row (&table.buffer[Nx*i], table.header);
    115     fprintf (stdout, "%s\n", line);
    116     free (line);
     113  if (!print_table_rows (&table, 0, Ny)) {
     114    fprintf (stderr, "failed to print table\n");
    117115  }   
    118116  exit (0);
    119117}
    120118
    121 /* print an ASCII table to a row with single spaces separating value */
    122 char *print_table_row (char *row, Header *header) {
     119# define SWAP_BYTE(BYTE)                                        \
     120  tmp = BYTE[0]; BYTE[0] = BYTE[1]; BYTE[1] = tmp;
     121# define SWAP_WORD(BYTE) \
     122  tmp = BYTE[0]; BYTE[0] = BYTE[3]; BYTE[3] = tmp; \
     123  tmp = BYTE[1]; BYTE[1] = BYTE[2]; BYTE[2] = tmp;
     124# define SWAP_DBLE(BYTE) \
     125  tmp = BYTE[0]; BYTE[0] = BYTE[7]; BYTE[7] = tmp; \
     126  tmp = BYTE[1]; BYTE[1] = BYTE[6]; BYTE[6] = tmp; \
     127  tmp = BYTE[2]; BYTE[2] = BYTE[5]; BYTE[5] = tmp; \
     128  tmp = BYTE[3]; BYTE[3] = BYTE[4]; BYTE[4] = tmp;
     129
     130/* print Nrows of the given table starting at row 'start' */
     131int print_table_rows (FTable *table, int start, int Nrows) {
    123132 
    124   off_t Nx;
    125   int i, j, Nfields, Nbytes, Nvals, Oout, Oin;
    126   char field[16], type[16], format[16], *line;
    127 
    128   gfits_scan (header, "NAXIS1",  OFF_T_FMT, 1,  &Nx);
    129   gfits_scan (header, "TFIELDS", "%d", 1, &Nfields);
     133  off_t Nx, Ny;
     134  int n, i, j, Nfields, *Nbyte, *Nvals, Oout, Oin, Nv, Nb, byte, status;
     135  char field[16], **types, format[16], type[80], *line, *row, tmp;
     136  double *Tzero, *Tscal;
     137
     138  gfits_scan (table->header, "NAXIS1",  OFF_T_FMT, 1,  &Nx);
     139  gfits_scan (table->header, "NAXIS2",  OFF_T_FMT, 1,  &Ny);
     140  gfits_scan (table->header, "TFIELDS", "%d", 1, &Nfields);
     141
     142  if (start <   0) return FALSE;
     143  if (start >= Ny) return FALSE;
     144  if (Nrows <   0) return FALSE;
     145  if (start + Nrows > Ny) return FALSE;
    130146
    131147  /* assume we have one space per byte column */
    132   ALLOCATE (line, char, 2*Nx + 1);
    133 
    134   Oin = Oout = 0;
    135   for (i = 1; i <= Nfields; i++) {
    136     sprintf (field, "TFORM%d", i);
    137     gfits_scan (header, field, "%s", 1, format); /* get field format */
    138     gfits_table_format (format, type, &Nvals, &Nbytes);    /* convert to c-style */
    139     memcpy (&line[Oout], &row[Oin], Nvals*Nbytes);
    140     for (j = 0; j < Nvals*Nbytes; j++) if (line[Oout+j] == 0) line[Oout+j] = ' ';
    141     line[Oout+Nvals*Nbytes] = ' ';
    142     Oout += Nvals*Nbytes + 1;
    143     Oin += Nvals*Nbytes;
    144   }
    145 
    146   return (line);
     148  ALLOCATE (line, char, MAX(2*Nx+1,512));
     149
     150  ALLOCATE (types, char *, Nfields);
     151  ALLOCATE (Nvals, int, Nfields);
     152  ALLOCATE (Nbyte, int, Nfields);
     153  ALLOCATE (Tzero, double, Nfields);
     154  ALLOCATE (Tscal, double, Nfields);
     155
     156  // determine the layout of the columns
     157  for (i = 0; i < Nfields; i++) {
     158    sprintf (field, "TFORM%d", i+1);
     159    gfits_scan (table->header, field, "%s", 1, format); /* get field format */
     160
     161    if (Binary)  {
     162      gfits_bintable_format (format, type, &Nv, &Nb);    /* convert to c-style */
     163
     164      sprintf (field, "TZERO%d", i+1);
     165      status = gfits_scan (table[0].header, field, "%lf", 1, &Tzero[i]);       /* get field format */
     166      if (!status) Tzero[i] = 0.0;
     167     
     168      sprintf (field, "TSCAL%d", i+1);
     169      status = gfits_scan (table[0].header, field, "%lf", 1, &Tscal[i]);       /* get field format */
     170      if (!status) Tscal[i] = 1.0;
     171    } else {
     172      gfits_table_format (format, type, &Nv, &Nb);    /* convert to c-style */
     173    }
     174   
     175    types[i] = strcreate (type);
     176    Nvals[i] = Nv;
     177    Nbyte[i] = Nb;
     178  }
     179
     180  for (n = start; n < start + Nrows; n++) {
     181
     182    row = &table->buffer[Nx*n];
     183
     184    if (Binary) {
     185      byte = 0;  // counter for byte element of this row
     186      for (i = 0; i < Nfields; i++) {
     187        int found = FALSE;
     188        if (!strcmp (types[i], "char")) {
     189          memcpy (line, &row[byte], Nvals[i]*Nbyte[i]);
     190          fprintf (stdout, "%s ", line);
     191          found = TRUE;
     192        } else {
     193          for (j = 0; j < Nvals[i]; j++) {
     194            memcpy (line, &row[byte + Nbyte[i]*j], Nbyte[i]);
     195            if (!strcmp (types[i], "int")) {
     196# ifdef BYTE_SWAP
     197              SWAP_WORD (line);
     198# endif
     199              fprintf (stdout, "%d ", (int)(*(int *)line * Tscal[i] + Tzero[i]));
     200              found = TRUE;
     201            }
     202            if (!strcmp (types[i], "short")) {
     203# ifdef BYTE_SWAP
     204              SWAP_BYTE (line);
     205# endif
     206              fprintf (stdout, "%d ", (int)(*(short *)line * Tscal[i] + Tzero[i]));
     207              found = TRUE;
     208            }
     209            if (!strcmp (types[i], "int64_t")) {
     210# ifdef BYTE_SWAP
     211              SWAP_DBLE (line);
     212# endif
     213              fprintf (stdout, "%" PRId64" ",  (int64_t)(*(int64_t*)line * Tscal[i] + Tzero[i]));
     214              found = TRUE;
     215            }
     216            if (!strcmp (types[i], "float")) {
     217# ifdef BYTE_SWAP
     218              SWAP_WORD (line);
     219# endif
     220              fprintf (stdout, "%e ", (*(float *)line * Tscal[i] + Tzero[i]));
     221              found = TRUE;
     222            }
     223            if (!strcmp (types[i], "double")) {
     224# ifdef BYTE_SWAP
     225              SWAP_DBLE (line);
     226# endif
     227              fprintf (stdout, "%e ", (*(double *)line * Tscal[i] + Tzero[i]));
     228              found = TRUE;
     229            }
     230          }
     231        }
     232        byte += Nvals[i]*Nbyte[i];
     233        if (!found) {
     234          fprintf (stderr, "failed to find format for %d : %s\n", i, types[i]);
     235        }
     236      }
     237    } else {
     238      Oout = 0;
     239      Oin = 0;
     240      for (i = 0; i < Nfields; i++) {
     241        memcpy (&line[Oout], &row[Oin], Nvals[i]*Nbyte[i]);
     242        for (j = 0; j < Nvals[i]*Nbyte[i]; j++) if (line[Oout+j] == 0) line[Oout+j] = ' ';
     243        line[Oout+Nvals[i]*Nbyte[i]] = ' ';
     244        Oout += Nvals[i]*Nbyte[i] + 1;
     245        Oin += Nvals[i]*Nbyte[i];
     246      }
     247      fprintf (stdout, "%s ", line);
     248    }
     249    fprintf (stdout, "\n");
     250  }
     251  return (TRUE);
    147252}
    148253
     
    325430    sprintf (field, "TFORM%d", i);
    326431    gfits_scan (header, field, "%s", 1, format);
    327     if (Binary)
     432    if (Binary)  {
     433      gfits_bintable_format (format, type, &Nv, &Nb);
     434    } else {
    328435      gfits_table_format (format, type, &Nv, &Nb);
    329     else
    330       gfits_bintable_format (format, type, &Nv, &Nb);
     436    }
    331437    Nstart += Nv*Nb;
    332438  }
     
    334440  sprintf (field, "TFORM%d", Column);
    335441  gfits_scan (header, field, "%s", 1, format);
    336   if (Binary)
     442  if (Binary)  {
    337443    gfits_bintable_format (format, type, &Nv, &Nb);    /* convert to c-style */
    338   else
     444  } else {
    339445    gfits_table_format (format, type, &Nv, &Nb);    /* convert to c-style */
    340 
     446  }
    341447  ALLOCATE (line, char, Nv*Nb + 1);
    342448
  • trunk/Ohana/src/uniphot/Makefile

    r27790 r31160  
    1 default: uniphot setphot
     1default: uniphot setphot setfwhm
    22help:
    3 @echo "make options: uniphot setphot default help install default (uniphot setphot)"
     3@echo "make options: uniphot setphot setfwhm default help install default (uniphot setphot setfwhm)"
    44
    55include ../../Makefile.System
     
    1919uniphot: $(BIN)/uniphot.$(ARCH)
    2020setphot: $(BIN)/setphot.$(ARCH)
    21 install: $(DESTBIN)/uniphot $(DESTBIN)/setphot
     21setfwhm: $(BIN)/setfwhm.$(ARCH)
     22install: $(DESTBIN)/uniphot $(DESTBIN)/setphot $(DESTBIN)/setfwhm
    2223
    2324UNIPHOT = \
     
    3435$(SRC)/update.$(ARCH).o             \
    3536$(SRC)/update_catalog.$(ARCH).o     \
     37$(SRC)/convert.$(ARCH).o            \
    3638$(SRC)/SetSignals.$(ARCH).o         \
    3739$(SRC)/Shutdown.$(ARCH).o           \
     
    5658$(SETPHOT): $(INC)/uniphot.h
    5759$(BIN)/setphot.$(ARCH): $(SETPHOT)
     60
     61SETFWHM =                           \
     62$(SRC)/setfwhm.$(ARCH).o            \
     63$(SRC)/initialize.$(ARCH).o         \
     64$(SRC)/ConfigInit.$(ARCH).o         \
     65$(SRC)/args.$(ARCH).o               \
     66$(SRC)/liststats.$(ARCH).o          \
     67$(SRC)/load_fwhm_table.$(ARCH).o    \
     68$(SRC)/load_images.$(ARCH).o        \
     69$(SRC)/match_fwhm_to_images.$(ARCH).o       \
     70$(SRC)/SetSignals.$(ARCH).o         \
     71$(SRC)/Shutdown.$(ARCH).o           
     72
     73$(SETFWHM): $(INC)/uniphot.h
     74$(BIN)/setfwhm.$(ARCH): $(SETFWHM)
  • trunk/Ohana/src/uniphot/include/uniphot.h

    r28717 r31160  
    2929
    3030typedef struct {
     31  char tstart[64];
     32  char tstop[64];
    3133  char label[64];
    3234  float M;
     
    4547    int found;
    4648} ZptTable;
     49
     50typedef struct {
     51    float fwhm_major;
     52    float fwhm_minor;
     53    e_time time;
     54    int found;
     55    unsigned short photcode;
     56} FWHMTable;
    4757
    4858/* global variables set in parameter file */
     
    124134int           update_setphot         PROTO((Image *image, off_t Nimage));
    125135void          update_catalog_setphot PROTO((Catalog *catalog, Image *image, off_t *index, off_t Nimage));
     136
     137/*** time/coord conversion functions not supplied by libohana ***/
     138time_t        TimeRef               PROTO((double time, time_t TimeReference, int TimeFormat));
     139double        TimeValue             PROTO((time_t time, time_t TimeReference, int TimeFormat));
     140
     141int           hh_hms                PROTO((double hh, int *hr, int *mn, double *sc));
     142int           dd_dms                PROTO((double dd, int *dg, int *mn, double *sc));
     143int           hms_format            PROTO((char *line, double value));
     144int           dms_format            PROTO((char *line, double value));
     145int           hh_hm                 PROTO((double hh, int *hr, double *mn));
     146int           day_to_sec            PROTO((char *string, time_t *second));
     147int           hms_to_sec            PROTO((char *string, time_t *second));
     148char         *ohana_sec_to_hms      PROTO((time_t second));
     149char         *ohana_sec_to_day      PROTO((time_t second));
     150
     151char         *meade_deg_to_str      PROTO((double deg));
     152char         *meade_ra_to_str       PROTO((double deg));
     153char         *meade_dec_to_str      PROTO((double deg));
     154char         *strptime              PROTO((const char *s, const char *format, struct tm *tm));
     155time_t        GetTimeReference      PROTO((char *reference));
     156int           GetTimeUnits          PROTO((char *name));
     157
     158void          initialize_setfwhm    PROTO((int argc, char **argv));
     159int           args_setfwhm          PROTO((int argc, char **argv));
     160FWHMTable    *load_fwhm_table       PROTO((char *filename, int *nfwhm));
     161int           match_fwhm_to_images  PROTO((Image *image, off_t Nimage, FWHMTable *fwhm, int Nfwhm));
     162
  • trunk/Ohana/src/uniphot/src/args.c

    r27790 r31160  
    9696}
    9797
     98int args_setfwhm (int argc, char **argv) {
     99
     100  int N;
     101
     102  VERBOSE = FALSE;
     103  if ((N = get_argument (argc, argv, "-v"))) {
     104    VERBOSE = TRUE;
     105    remove_argument (N, &argc, argv);
     106  }
     107
     108  UPDATE = FALSE;
     109  if ((N = get_argument (argc, argv, "-update"))) {
     110    remove_argument (N, &argc, argv);
     111    UPDATE = TRUE;
     112  }
     113
     114  if (argc != 2) {
     115    fprintf (stderr, "ERROR: USAGE: setfwhm (fwhmfile) [options]\n");
     116    exit (2);
     117  }
     118
     119  return (TRUE);
     120}
     121
  • trunk/Ohana/src/uniphot/src/dumpresult.c

    r4797 r31160  
    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    }
  • trunk/Ohana/src/uniphot/src/find_image_sgroups.c

    r29001 r31160  
    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);
  • trunk/Ohana/src/uniphot/src/find_image_tgroups.c

    r29001 r31160  
    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];
  • trunk/Ohana/src/uniphot/src/fit_groups.c

    r21508 r31160  
    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);
  • trunk/Ohana/src/uniphot/src/initialize.c

    r29001 r31160  
    2828}
    2929
     30void initialize_setfwhm (int argc, char **argv) {
     31
     32  /* are these set correctly? */
     33  ConfigInit (&argc, argv);
     34  args_setfwhm (argc, argv);
     35}
     36
  • trunk/Ohana/src/uniphot/src/subset_images.c

    r29001 r31160  
    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}
  • trunk/Ohana/src/uniphot/src/uniphot.c

    r27790 r31160  
    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);
  • trunk/Ohana/src/uniphot/src/update.c

    r29001 r31160  
    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.