IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35416


Ignore:
Timestamp:
Apr 19, 2013, 4:31:05 PM (13 years ago)
Author:
eugene
Message:

merge changes from eam_branches/ipp-20130307 : parallelize dvosecfilt, use dvo_average,measure,secfilt_init functions more broadly; move image calibration to relphot_images; add synthetic photometry referece (w-band); put relphot MARKTIME & INITTIME in macros; in dvo_clients, mextract fields which need image data use a subset image metadata table (instead of loading full Images.dat table); create FIELD and MOSAIC fields for mextract; somewhat better rules for photcode:ave & similar selections in mextract; add hpm_* concept in relastro (high-speed proper motions); fix precision errors in dvopsps; check for dvopsps exit conditions; error-bar clipping to limits of plotting window; parallelize delstar -dup-images; do NOT delete parents (because parent IDs are broken after dvomerge); minor handshake when setting up KAPA connection; avextract and related do not need to launch remote jobs on all clients if region does not include tables from all hosts; add fitplx and xsection functions to mana; enable addstar of diff cmfs (at least PS1_DV3)

Location:
trunk/Ohana
Files:
69 edited
15 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana

  • trunk/Ohana/src/addstar/src/GetFileMode.c

    r35108 r35416  
    2020  havePHOT_VER = gfits_scan (header, "PHOT_VER", "%s", 1, ctmp);
    2121  haveTARG_VER = gfits_scan (header, "TARG_VER", "%s", 1, ctmp);
    22   if (havePHOT_VER && haveTARG_VER) return SDSS_OBJ;
     22  if (havePHOT_VER && haveTARG_VER) {
     23    if (VERBOSE) fprintf (stderr, "found SDSS objects\n");
     24    return SDSS_OBJ;
     25  }
    2326
    2427  if (haveNaxis && (Naxis == 2)) {
     
    2831    if ((Nx > 0) && (Ny > 0)) {
    2932      if (haveCTYPE && !strcmp (&ctype[4], "-WRP")) {
     33        if (VERBOSE) fprintf (stderr, "found MOSAIC CMP\n");
    3034        return MOSAIC_CMP;
    3135      }
     36      if (VERBOSE) fprintf (stderr, "found SIMPLE CMP\n");
    3237      return SIMPLE_CMP;
    3338    }
     
    3641  if (haveNaxis && (TEXTMODE || !simple)) {
    3742    if (haveCTYPE && !strcmp (&ctype[4], "-WRP")) {
     43      if (VERBOSE) fprintf (stderr, "found MOSAIC CMP\n");
    3844      return MOSAIC_CMP;
    3945    }
     46    if (VERBOSE) fprintf (stderr, "found SIMPLE CMP\n");
    4047    return SIMPLE_CMP;
    4148  }
     
    4350  if (!extend && strcmp (&ctype[4], "-DIS")) {
    4451    if (!strcmp (&ctype[4], "-WRP")) {
     52      if (VERBOSE) fprintf (stderr, "found MOSAIC CMF\n");
    4553      return MOSAIC_CMF;
    4654    }
     55    if (VERBOSE) fprintf (stderr, "found SIMPLE CMF\n");
    4756    return SIMPLE_CMF;
    4857  }
    4958
    5059  if (!extend && !strcmp (&ctype[4], "-DIS")) {
     60    if (VERBOSE) fprintf (stderr, "found MOSAIC PHU\n");
    5161    return MOSAIC_PHU;
    5262  }
    5363
    5464  if (extend && strcmp (&ctype[4], "-DIS")) {
     65    if (VERBOSE) fprintf (stderr, "found SIMPLE MEF\n");
    5566    return SIMPLE_MEF;
    5667  }
    5768
    5869  if (extend && !strcmp (&ctype[4], "-DIS")) {
     70    if (VERBOSE) fprintf (stderr, "found MOSAIC MEF\n");
    5971    return MOSAIC_MEF;
    6072  }
    6173
     74  if (VERBOSE) fprintf (stderr, "extension type is unknown\n");
    6275  return (NONE);
    6376}
  • trunk/Ohana/src/addstar/src/MatchHeaders.c

    r34405 r35416  
    6161    if (!strcmp (exttype, "PS1_SV1")) goto keep;
    6262    if (!strcmp (exttype, "PS1_SV2")) goto keep;
     63    if (!strcmp (exttype, "PS1_DV3")) {
     64      goto keep;
     65    }
    6366    continue;
    6467
  • trunk/Ohana/src/addstar/src/ReadStarsFITS.c

    r34580 r35416  
    1515Stars     *Convert_PS1_SV1_Alt    PROTO((FTable *table, unsigned int *nstars));
    1616Stars     *Convert_PS1_SV2        PROTO((FTable *table, unsigned int *nstars));
     17Stars     *Convert_PS1_DV3        PROTO((FTable *table, unsigned int *nstars));
    1718
    1819// given a file with the pointer at the start of the table block and the
     
    7879    stars = Convert_PS1_SV2 (&table, &Nstars);
    7980  }
     81  if (!strcmp (type, "PS1_DV3")) {
     82    stars = Convert_PS1_DV3 (&table, &Nstars);
     83  }
    8084  if (stars == NULL) {
    8185    fprintf (stderr, "invalid table type %s\n", type);
     
    962966}
    963967
    964 
     968Stars *Convert_PS1_DV3 (FTable *table, unsigned int *nstars) {
     969
     970  off_t Nstars;
     971  unsigned int i;
     972  double ZeroPt;
     973  Stars *stars;
     974  CMF_PS1_DV3 *ps1data;
     975
     976  ps1data = gfits_table_get_CMF_PS1_DV3 (table, &Nstars, NULL);
     977  if (!ps1data) {
     978    fprintf (stderr, "skipping inconsistent entry\n");
     979    return (NULL);
     980  }
     981  ZeroPt = GetZeroPoint();
     982
     983  ALLOCATE (stars, Stars, Nstars);
     984  for (i = 0; i < Nstars; i++) {
     985    InitStar (&stars[i]);
     986    stars[i].measure.Xccd       = ps1data[i].X;
     987    stars[i].measure.Yccd       = ps1data[i].Y;
     988    stars[i].measure.dXccd      = ToShortPixels(ps1data[i].dX);
     989    stars[i].measure.dYccd      = ToShortPixels(ps1data[i].dY);
     990
     991    stars[i].measure.posangle   = ToShortDegrees(ps1data[i].posangle);
     992    stars[i].measure.pltscale   = ps1data[i].pltscale;
     993
     994    if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) {
     995      stars[i].measure.M      = NAN;
     996    } else {
     997      stars[i].measure.M      = ps1data[i].M + ZeroPt;
     998    }
     999    stars[i].measure.dM         = ps1data[i].dM;
     1000    stars[i].measure.dMcal      = ps1data[i].dMcal;
     1001    stars[i].measure.Map        = ps1data[i].Map + ZeroPt;
     1002                       
     1003    stars[i].measure.Mkron      = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN;
     1004    stars[i].measure.dMkron     = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN;
     1005                       
     1006    // these fluxes are converted from counts to counts/sec in FilterStars.c
     1007    stars[i].measure.FluxPSF    = ps1data[i].Flux;
     1008    stars[i].measure.dFluxPSF   = ps1data[i].dFlux;
     1009    stars[i].measure.FluxKron   = ps1data[i].kronFlux;
     1010    stars[i].measure.dFluxKron  = ps1data[i].kronFluxErr;
     1011
     1012    stars[i].measure.Sky        = ps1data[i].sky;
     1013    stars[i].measure.dSky       = ps1data[i].dSky;
     1014                       
     1015    stars[i].measure.psfChisq   = ps1data[i].psfChisq;
     1016    stars[i].measure.psfQF      = ps1data[i].psfQF;
     1017    stars[i].measure.psfQFperf  = ps1data[i].psfQFperf;
     1018    stars[i].measure.psfNdof    = ps1data[i].psfNdof;
     1019    stars[i].measure.psfNpix    = ps1data[i].psfNpix;
     1020    stars[i].measure.crNsigma   = ps1data[i].crNsigma;
     1021    stars[i].measure.extNsigma  = ps1data[i].extNsigma;
     1022
     1023    stars[i].measure.FWx        = ToShortPixels(ps1data[i].fx);
     1024    stars[i].measure.FWy        = ToShortPixels(ps1data[i].fy);
     1025    stars[i].measure.theta      = ToShortDegrees(ps1data[i].df);
     1026
     1027    stars[i].measure.Mxx        = ToShortPixels(ps1data[i].Mxx);
     1028    stars[i].measure.Mxy        = ToShortPixels(ps1data[i].Mxy);
     1029    stars[i].measure.Myy        = ToShortPixels(ps1data[i].Myy);
     1030                       
     1031    stars[i].measure.photFlags  = ps1data[i].flags;
     1032
     1033    // this is may optionally be replaced by the internal sequence (see FilterStars.c)
     1034    stars[i].measure.detID      = ps1data[i].detID;
     1035
     1036    // the Average fields and the following Measure fields are set in FilterStars after
     1037    // the image metadata is in hand:  dR, dD, Mcal, dt, airmass, az, t, imageID, extID.
     1038
     1039    // averef is set in find_matches
     1040
     1041    // dbFlags is zero on ingest.
     1042
     1043    // the following fields are currently not being set anywhere: t_msec
     1044  }   
     1045  *nstars = Nstars;
     1046  return (stars);
     1047}
     1048
     1049
     1050
  • trunk/Ohana/src/addstar/src/load2mass_catalog.c

    r34405 r35416  
    2020    // XXX for now, the output objects will have limited astrometric interpretation...
    2121    // XXX every 3 stars represents 3 measurements and 1 average
     22    dvo_average_init (&catalog[0].average[Nave]);
    2223    catalog[0].average[Nave].R     = stars[i].average.R;
    2324    catalog[0].average[Nave].D     = stars[i].average.D;
    24     catalog[0].average[Nave].dR    = 0;
    25     catalog[0].average[Nave].dD    = 0;
    26     catalog[0].average[Nave].uR    = 0;
    27     catalog[0].average[Nave].uD    = 0;
    28     catalog[0].average[Nave].duR   = 0;
    29     catalog[0].average[Nave].duD   = 0;
    30     catalog[0].average[Nave].P     = 0;
    31     catalog[0].average[Nave].dP    = 0;
    32 
    33     // XXX for now, set the average mag data to NULL
    34     catalog[0].average[Nave].Nmeasure      = 0;
    35     catalog[0].average[Nave].Nmissing      = 0;
    36     catalog[0].average[Nave].ChiSqAve      = NAN_S_SHORT;
    3725    catalog[0].average[Nave].measureOffset = Nmeas;
    38     catalog[0].average[Nave].missingOffset = -1;
    39     catalog[0].average[Nave].flags         = 0;
    4026
    4127    for (j = 0; j < Nsec; j++) {
    42       catalog[0].secfilt[Nave*Nsec+j].M     = NAN;
    43       catalog[0].secfilt[Nave*Nsec+j].dM    = NAN;
    44       catalog[0].secfilt[Nave*Nsec+j].Xm    = NAN_S_SHORT;
    45       catalog[0].secfilt[Nave*Nsec+j].M_20  = NAN_S_SHORT;
    46       catalog[0].secfilt[Nave*Nsec+j].M_80  = NAN_S_SHORT;
    47       catalog[0].secfilt[Nave*Nsec+j].Ncode = 0;
    48       catalog[0].secfilt[Nave*Nsec+j].Nused = 0;
     28      dvo_secfilt_init (&catalog[0].secfilt[Nave*Nsec+j]);
    4929    }
    5030
  • trunk/Ohana/src/delstar/Makefile

    r35237 r35416  
    3838$(SRC)/find_matches.$(ARCH).o     \
    3939$(SRC)/parse_time.$(ARCH).o       \
     40$(SRC)/ImageIDsOps.$(ARCH).o       \
    4041$(SRC)/check_permissions.$(ARCH).o \
    4142$(SRC)/Shutdown.$(ARCH).o         
     
    4950$(SRC)/delete_photcodes.$(ARCH).o \
    5051$(SRC)/delete_photcodes_single.$(ARCH).o \
     52$(SRC)/ImageIDsOps.$(ARCH).o       \
    5153$(SRC)/Shutdown.$(ARCH).o         
    5254
  • trunk/Ohana/src/delstar/include/delstar.h

    r35243 r35416  
    117117int delete_duplicate_images (int hostID, char *hostpath, FITS_DB *db);
    118118int delete_duplicate_image_measures (int hostID, char *hostpath, IndexArray *imageID);
    119 int delete_duplicate_image_measures_parallel (SkyList *sky);
     119int delete_duplicate_image_measures_parallel (SkyList *sky, IndexArray *imageID);
    120120int delete_duplicate_image_measures_catalog (Catalog *catalog, IndexArray *imageID);
    121121
     
    123123IndexArray *make_index_array (Image *image, off_t Nimage, int mode);
    124124
     125IndexArray *ImageIDLoad(char *filename);
     126int ImageIDSave(char *filename, IndexArray *imageID);
  • trunk/Ohana/src/delstar/src/args.c

    r35237 r35416  
    328328    remove_argument (N, &argc, argv);
    329329  }
     330  if ((N = get_argument (argc, argv, "-dup-images"))) {
     331    if (MODE != MODE_NONE) usage();
     332    MODE = MODE_DUP_IMAGES;
     333    remove_argument (N, &argc, argv);
     334  }
    330335
    331336  if (MODE == MODE_NONE) delstar_client_usage ();
  • trunk/Ohana/src/delstar/src/delete_duplicate_images.c

    r35265 r35416  
    8484  // launch the remote jobs
    8585  if (PARALLEL && !hostID) {
    86     int status = delete_duplicate_image_measures_parallel (skylist);
     86    int status = delete_duplicate_image_measures_parallel (skylist, imageID);
    8787    return status;
    8888  }
     
    128128
    129129// CATDIR is supplied globally
    130 int delete_duplicate_image_measures_parallel (SkyList *sky) {
     130int delete_duplicate_image_measures_parallel (SkyList *sky, IndexArray *imageID) {
     131
     132  // write out the subset table of image information
     133  char imageFile[512];
     134  snprintf (imageFile, 512, "%s/ImageIDs.tmp.fits", CATDIR);
     135
     136  if (!ImageIDSave (imageFile, imageID)) {
     137    fprintf (stderr, "failed to write image ID table\n");
     138    exit (1);
     139  }
    131140
    132141  // launch the delstar_client jobs to the parallel hosts
     
    157166
    158167    fprintf (stderr, "command: %s\n", command);
    159 
    160     fprintf (stderr, "parallel version is not ready (need to save / load the imageID array\n");
    161168
    162169    if (PARALLEL_MANUAL) continue;
     
    463470    // XXX this is probably bad : it assumes all chips
    464471    // should be deleted for a given exposure
    465     off_t parentID = image[i].parentID;
    466     if (parentID) {
    467       off_t Np = parentID - imageID->minID;
    468       myAssert (Np >= 0, "oops");
    469       myAssert (Np < imageID->range, "oops");
    470       imageID->value[Np] = TRUE;
    471     }
     472    // off_t parentID = image[i].parentID;
     473    // if (parentID) {
     474    //   off_t Np = parentID - imageID->minID;
     475    //   myAssert (Np >= 0, "oops");
     476    //   myAssert (Np < imageID->range, "oops");
     477    //   imageID->value[Np] = TRUE;
     478    // }
    472479  }
    473480
  • trunk/Ohana/src/delstar/src/delstar_client.c

    r34844 r35416  
    66int main (int argc, char **argv) {
    77
     8  char imageFile[512];
     9
    810  SetSignals ();
    911  ConfigInit (&argc, argv);
    1012  args_client (argc, argv);
    1113
    12   // load the current sky table (layout of all SkyRegions)
    13   SkyTable *sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, TRUE, -1, VERBOSE);
    14   if (!sky) {
    15       fprintf (stderr, "ERROR running loading sky table from %s\n", CATDIR);
    16       exit (2);
    17   }
    18   SkyTableSetFilenames (sky, CATDIR, "cpt");
    19 
    20   SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch);
    21   if (!skylist) {
    22       fprintf (stderr, "ERROR setting up skylist for %s\n", CATDIR);
    23       exit (2);
    24   }
    25 
    2614  switch (MODE) {
     15    case MODE_DUP_IMAGES:
     16      // read the subset table of image information
     17      snprintf (imageFile, 512, "%s/ImageIDs.tmp.fits", CATDIR);
     18     
     19      IndexArray *imageID = ImageIDLoad (imageFile);
     20      if (!imageID) {
     21        fprintf (stderr, "failed to read image ID table\n");
     22        exit (1);
     23      }
     24      if (!delete_duplicate_image_measures (HOST_ID, HOSTDIR, imageID)) exit (1);
     25      exit (0);
     26      break;
    2727    case MODE_IMAGEFILE:
    2828      break;
  • trunk/Ohana/src/dvomerge/Makefile

    r34405 r35416  
    2323dvoverify_client : $(BIN)/dvoverify_client.$(ARCH)
    2424
    25 all: dvomerge dvomerge_client dvoconvert dvosecfilt dvoverify dvoverify_client
     25all: dvomerge dvomerge_client dvoconvert dvosecfilt dvosecfilt_client dvoverify dvoverify_client
    2626
    2727#  $(SRC)/dvomergeContinue.$(ARCH).o
     
    9393DVOSECFILT = \
    9494$(SRC)/dvosecfilt.$(ARCH).o \
     95$(SRC)/dvosecfilt_catalogs.$(ARCH).o \
    9596$(SRC)/SetSignals.$(ARCH).o \
    9697$(SRC)/ConfigInit.$(ARCH).o \
     
    101102$(DVOSECFILT)  : $(INC)/dvomerge.h
    102103$(BIN)/dvosecfilt.$(ARCH) : $(DVOSECFILT)
     104
     105DVOSECFILT_CLIENT = \
     106$(SRC)/dvosecfilt_client.$(ARCH).o \
     107$(SRC)/dvosecfilt_catalogs.$(ARCH).o \
     108$(SRC)/SetSignals.$(ARCH).o \
     109$(SRC)/ConfigInit.$(ARCH).o \
     110$(SRC)/Shutdown.$(ARCH).o \
     111$(SRC)/help.$(ARCH).o \
     112$(SRC)/args.$(ARCH).o
     113
     114$(DVOSECFILT_CLIENT)  : $(INC)/dvomerge.h
     115$(BIN)/dvosecfilt_client.$(ARCH) : $(DVOSECFILT_CLIENT)
    103116
    104117DVOREPAIR = \
     
    136149$(BIN)/dvoverify_client.$(ARCH) : $(DVOVERIFY_CLIENT)
    137150
    138 INSTALL = dvomerge dvomerge_client dvoconvert dvosecfilt dvorepair dvoverify dvoverify_client
     151INSTALL = dvomerge dvomerge_client dvoconvert dvosecfilt dvosecfilt_client dvorepair dvoverify dvoverify_client
    139152
    140153# dependancy rules for binary code #########################
  • trunk/Ohana/src/dvomerge/include/dvomerge.h

    r34405 r35416  
    3636int    REPLACE_BY_PHOTCODE;
    3737
     38char *SINGLE_CPT;
    3839SkyRegion UserPatch;  // used by MODE CAT
    3940
     
    103104void       dvosecfilt_help        PROTO((int argc, char **argv));
    104105int        dvosecfilt_args        PROTO((int *argc, char **argv));
     106
     107void       dvosecfilt_client_usage PROTO((void));
     108void       dvosecfilt_client_help  PROTO((int argc, char **argv));
     109int        dvosecfilt_client_args  PROTO((int *argc, char **argv));
     110
     111int        dvosecfilt_catalogs     PROTO((int Nsecfilt));
     112int        dvosecfilt_parallel     PROTO((SkyTable *insky, int Nsecfilt));
    105113
    106114int        SkyTablePopulatedRange PROTO((off_t *ns, off_t *ne, SkyTable *sky, off_t Nstart));
  • trunk/Ohana/src/dvomerge/src/args.c

    r34260 r35416  
    170170  int N;
    171171
    172   /* extra error messages */
    173   VERBOSE = FALSE;
    174   if ((N = get_argument (*argc, argv, "-v"))) {
    175     VERBOSE = TRUE;
     172  HOST_ID = 0;
     173
     174  /* extra error messages */
     175  VERBOSE = FALSE;
     176  if ((N = get_argument (*argc, argv, "-v"))) {
     177    VERBOSE = TRUE;
     178    remove_argument (N, argc, argv);
     179  }
     180
     181  SINGLE_CPT = NULL;
     182  if ((N = get_argument (*argc, argv, "-cpt"))) {
     183    remove_argument (N, argc, argv);
     184    SINGLE_CPT = strcreate (argv[N]);
     185    remove_argument (N, argc, argv);
     186  }
     187
     188  /* specify portion of the sky : allow default of all sky? */
     189  UserPatch.Rmin = 0;
     190  UserPatch.Rmax = 360;
     191  UserPatch.Dmin = -90;
     192  UserPatch.Dmax = +90;
     193  if ((N = get_argument (*argc, argv, "-region"))) {
     194    remove_argument (N, argc, argv);
     195    UserPatch.Rmin = atof (argv[N]);
     196    remove_argument (N, argc, argv);
     197    UserPatch.Rmax = atof (argv[N]);
     198    remove_argument (N, argc, argv);
     199    UserPatch.Dmin = atof (argv[N]);
     200    remove_argument (N, argc, argv);
     201    UserPatch.Dmax = atof (argv[N]);
     202    remove_argument (N, argc, argv);
     203  }
     204
     205  PARALLEL = FALSE;
     206  if ((N = get_argument (*argc, argv, "-parallel"))) {
     207    PARALLEL = TRUE;
     208    remove_argument (N, argc, argv);
     209  }
     210  // this is a test mode : rather than launching the remote jobs and waiting for completion,
     211  // relphot will simply list the remote command and wait for the user to signal completion
     212  PARALLEL_MANUAL = FALSE;
     213  if ((N = get_argument (*argc, argv, "-parallel-manual"))) {
     214    PARALLEL = TRUE; // -parallel-manual implies -parallel
     215    PARALLEL_MANUAL = TRUE;
     216    remove_argument (N, argc, argv);
     217  }
     218  // this is a test mode : rather than launching the relphot_client jobs remotely, they are
     219  // run in serial via 'system'
     220  PARALLEL_SERIAL = FALSE;
     221  if ((N = get_argument (*argc, argv, "-parallel-serial"))) {
     222    if (PARALLEL_MANUAL) {
     223      fprintf (stderr, "ERROR: cannot mix -parallel-manual and -parallel-serial\n");
     224      exit (1);
     225    }
     226    PARALLEL = TRUE; // -parallel-serial implies -parallel
     227    PARALLEL_SERIAL = TRUE;
    176228    remove_argument (N, argc, argv);
    177229  }
     
    180232  return TRUE;
    181233}
     234
     235/*** check for command line options ***/
     236int dvosecfilt_client_args (int *argc, char **argv) {
     237 
     238  int N;
     239
     240  // by definition, the client is not parallel
     241  PARALLEL = FALSE;
     242  PARALLEL_MANUAL = FALSE;
     243  PARALLEL_SERIAL = FALSE;
     244
     245  SINGLE_CPT = NULL;
     246  if ((N = get_argument (*argc, argv, "-cpt"))) {
     247    remove_argument (N, argc, argv);
     248    SINGLE_CPT = strcreate (argv[N]);
     249    remove_argument (N, argc, argv);
     250  }
     251
     252  /* specify portion of the sky : allow default of all sky? */
     253  UserPatch.Rmin = 0;
     254  UserPatch.Rmax = 360;
     255  UserPatch.Dmin = -90;
     256  UserPatch.Dmax = +90;
     257  if ((N = get_argument (*argc, argv, "-region"))) {
     258    remove_argument (N, argc, argv);
     259    UserPatch.Rmin = atof (argv[N]);
     260    remove_argument (N, argc, argv);
     261    UserPatch.Rmax = atof (argv[N]);
     262    remove_argument (N, argc, argv);
     263    UserPatch.Dmin = atof (argv[N]);
     264    remove_argument (N, argc, argv);
     265    UserPatch.Dmax = atof (argv[N]);
     266    remove_argument (N, argc, argv);
     267  }
     268
     269  HOST_ID = 0;
     270  if ((N = get_argument (*argc, argv, "-hostID"))) {
     271    remove_argument (N, argc, argv);
     272    HOST_ID = atoi (argv[N]);
     273    remove_argument (N, argc, argv);
     274  }
     275  if (!HOST_ID) dvosecfilt_client_usage();
     276
     277  HOSTDIR = NULL;
     278  if ((N = get_argument (*argc, argv, "-hostdir"))) {
     279    remove_argument (N, argc, argv);
     280    HOSTDIR = strcreate (argv[N]);
     281    remove_argument (N, argc, argv);
     282  }
     283  if (!HOSTDIR) dvosecfilt_client_usage();
     284
     285  /* extra error messages */
     286  VERBOSE = FALSE;
     287  if ((N = get_argument (*argc, argv, "-v"))) {
     288    VERBOSE = TRUE;
     289    remove_argument (N, argc, argv);
     290  }
     291
     292  if (*argc != 3) dvosecfilt_client_usage();
     293  return TRUE;
     294}
  • trunk/Ohana/src/dvomerge/src/dvosecfilt.c

    r29001 r35416  
    33// modify the number of average photcodes : change only secfilt tables in place
    44int main (int argc, char **argv) {
    5 
    6   char filename[256], *input;
    7   off_t i, j, k, Nsecfilt, NsecInput, Nstart;
    8   SkyTable *insky;
    9   Catalog catalog;
    10   SecFilt *insec, *outsec;
    115
    126  SetSignals ();
     
    159  dvosecfilt_args (&argc, argv);
    1610
    17   input = argv[1];
    18   Nsecfilt = atoi(argv[2]);
     11  strcpy (CATDIR, argv[1]);
     12  int Nsecfilt = atoi(argv[2]);
    1913
    20   // load the sky table for the existing database
    21   insky = SkyTableLoadOptimal (input, NULL, NULL, FALSE, SKY_DEPTH_HST, VERBOSE);
    22   SkyTableSetFilenames (insky, input, "cpt");
    23 
    24   // loop over all input catalogs
    25   for (i = 0; i < insky[0].Nregions; i++) {
    26     if (!insky[0].regions[i].table) continue;
    27     if (VERBOSE) fprintf (stderr, "table: %s\n", insky[0].regions[i].name);
    28 
    29     // set the parameters which guide catalog open/load/create
    30     catalog.filename  = insky[0].filename[i];
    31     catalog.Nsecfilt  = 0;
    32 
    33     // always load all of the data (if any exists)
    34     catalog.catflags  = LOAD_SECF;
    35     catalog.catformat = dvo_catalog_catformat (CATFORMAT);  // set the default catformat from config data
    36     catalog.catmode   = dvo_catalog_catmode (CATMODE);      // set the default catmode from config data
    37 
    38     if (!dvo_catalog_open (&catalog, &insky[0].regions[i], VERBOSE, "w")) {
    39         fprintf (stderr, "ERROR: failure to open catalog file %s\n", filename);
    40         exit (2);
    41     }
    42 
    43     if (catalog.Naves_disk == 0) {
    44       dvo_catalog_unlock (&catalog);
    45       dvo_catalog_free (&catalog);
    46       continue;
    47     }
    48 
    49     if (Nsecfilt == catalog.Nsecfilt) {
    50       dvo_catalog_unlock (&catalog);
    51       dvo_catalog_free (&catalog);
    52       continue;
    53     }
    54 
    55     NsecInput = catalog.Nsecfilt;
    56     Nstart = MIN(Nsecfilt, NsecInput);
    57 
    58     insec = catalog.secfilt;
    59     ALLOCATE (outsec, SecFilt, catalog.Naves_disk * Nsecfilt);
    60 
    61     for (k = 0; k < catalog.Naves_disk; k++) {
    62       for (j = 0; (j < catalog.Nsecfilt) && (j < Nsecfilt); j++) {
    63         outsec[k*Nsecfilt + j].M  = insec[k*NsecInput + j].M;
    64         outsec[k*Nsecfilt + j].dM = insec[k*NsecInput + j].dM;
    65         outsec[k*Nsecfilt + j].Xm = insec[k*NsecInput + j].Xm;
    66         outsec[k*Nsecfilt + j].flags  = insec[k*NsecInput + j].flags;
    67         outsec[k*Nsecfilt + j].Ncode  = insec[k*NsecInput + j].Ncode;
    68         outsec[k*Nsecfilt + j].Nused  = insec[k*NsecInput + j].Nused;
    69         outsec[k*Nsecfilt + j].M_20   = insec[k*NsecInput + j].M_20;
    70         outsec[k*Nsecfilt + j].M_80   = insec[k*NsecInput + j].M_80;
    71       }
    72       for (j = Nstart; j < Nsecfilt; j++) {
    73         outsec[k*Nsecfilt + j].M  = NAN;
    74         outsec[k*Nsecfilt + j].dM = NAN;
    75         outsec[k*Nsecfilt + j].Xm = NAN_S_SHORT;
    76       }
    77     }
    78     free (catalog.secfilt);
    79     catalog.secfilt = outsec;
    80     catalog.Nsecfilt = Nsecfilt;
    81     catalog.Nsecf_mem = Nsecfilt * catalog.Naves_disk;
    82     catalog.Nsecf_disk = Nsecfilt * catalog.Naves_disk;
    83 
    84     dvo_catalog_save (&catalog, VERBOSE);
    85     dvo_catalog_unlock (&catalog);
    86     dvo_catalog_free (&catalog);
    87   }
     14  dvosecfilt_catalogs (Nsecfilt);
    8815
    8916  exit (0);
  • trunk/Ohana/src/dvomerge/src/help.c

    r33963 r35416  
    2525void dvosecfilt_usage(void) {
    2626
    27   fprintf (stderr, "USAGE: dvosecfilt (catdir) (Nsecfilt)\n");
     27  fprintf (stderr, "USAGE: dvosecfilt (catdir) (Nsecfilt)\n\n");
     28  fprintf (stderr, "  optional flags:\n");
     29  fprintf (stderr, "  -v                          : verbose mode\n");
     30
     31  exit (2);
     32}
     33
     34void dvosecfilt_client_usage(void) {
     35
     36  fprintf (stderr, "USAGE: dvosecfilt_client (catdir) (Nsecfilt)\n\n");
     37  fprintf (stderr, "  optional flags:\n");
     38  fprintf (stderr, "  -v                          : verbose mode\n");
    2839
    2940  exit (2);
     
    123134}
    124135
     136void dvosecfilt_client_help (int argc, char **argv) {
     137
     138  /* check for help request */
     139  if (get_argument (argc, argv, "-help")) goto show_help;
     140  if (get_argument (argc, argv, "-h"))    goto show_help;
     141  return;
     142
     143show_help:
     144
     145  fprintf (stderr, "USAGE\n");
     146  fprintf (stderr, "  dvosecfilt_client (catdir) (Nsecfilt)\n\n");
     147
     148  fprintf (stderr, "  change number of secfilt entries in photcode table (updates secfilt tables (cps), NSECFILT in cpt files)\n");
     149  fprintf (stderr, "  NOTE: the user must change the photcode table to reflect the change (use photcode-table -export / -import)\n");
     150 
     151  fprintf (stderr, "  optional flags:\n");
     152  fprintf (stderr, "  -v                          : verbose mode\n");
     153  fprintf (stderr, "  -help                       : this list\n");
     154  fprintf (stderr, "  -h                          : this list\n\n");
     155  exit (2);
     156}
     157
    125158void dvorepair_help (int argc, char **argv) {
    126159
  • trunk/Ohana/src/dvomerge/src/merge_catalogs_old.c

    r34405 r35416  
    299299
    300300    // XXX should we accept the input measurements for these fields?
    301 
     301    dvo_average_init (&output[0].average[Nave]);
    302302    output[0].average[Nave].R              = input[0].average[N].R;
    303303    output[0].average[Nave].D              = input[0].average[N].D;
    304     output[0].average[Nave].dR             = 0;
    305     output[0].average[Nave].dD             = 0;
    306 
    307     output[0].average[Nave].Nmeasure       = 0; // this value is update as the measurements are associated with this entry below
    308     output[0].average[Nave].Nmissing       = 0;
    309     output[0].average[Nave].Nextend        = 0;
    310 
    311304    output[0].average[Nave].measureOffset  = Nmeas;
    312     output[0].average[Nave].missingOffset  = -1;
    313     output[0].average[Nave].extendOffset   = -1;
    314 
    315     output[0].average[Nave].uR             = 0;
    316     output[0].average[Nave].uD             = 0;
    317     output[0].average[Nave].duR            = 0;
    318     output[0].average[Nave].duD            = 0;
    319     output[0].average[Nave].P              = 0;
    320     output[0].average[Nave].dP             = 0;
    321 
    322     output[0].average[Nave].stargal        = 0;
    323     output[0].average[Nave].ChiSqAve       = 0.0;
    324     output[0].average[Nave].ChiSqPM        = 0.0;
    325     output[0].average[Nave].ChiSqPar       = 0.0;
    326     output[0].average[Nave].Tmean          = 0;
    327     output[0].average[Nave].Trange         = 0;
    328     output[0].average[Nave].Npos           = 0;
    329 
    330305    output[0].average[Nave].objID          = objID; // we create objID values in the context of the output db
    331306    output[0].average[Nave].catID          = catID; // we create catID values in the context of the output db
    332     output[0].average[Nave].flags          = 0;  // XXX why reset these?
     307
    333308    if (PSPS_ID) {
    334309      output[0].average[Nave].extID = CreatePSPSObjectID(output[0].average[Nave].R, output[0].average[Nave].D);
    335     } else {
    336       output[0].average[Nave].extID = 0;
    337     }
     310    }
    338311
    339312    objID ++;
    340313
     314    // init the new secfilt entries
    341315    for (j = 0; j < NsecfiltOut; j++) {
    342316        int outputIndex = (Nave * NsecfiltOut) + j;
    343         output[0].secfilt[outputIndex].M     = NAN;
    344         output[0].secfilt[outputIndex].dM    = NAN;
    345         output[0].secfilt[outputIndex].Xm    = NAN_S_SHORT;
    346         output[0].secfilt[outputIndex].M_20  = NAN_S_SHORT;
    347         output[0].secfilt[outputIndex].M_80  = NAN_S_SHORT;
    348         output[0].secfilt[outputIndex].Ncode = 0;
    349         output[0].secfilt[outputIndex].Nused = 0;
     317        dvo_secfilt_init (&output[0].secfilt[outputIndex]);
    350318    }
    351319
     
    359327   
    360328      if (isfinite(input[0].secfilt[N*NsecfiltIn+j].M)) {
    361         output[0].secfilt[outputIndex].M     = input[0].secfilt[N*NsecfiltIn+j].M;
    362         output[0].secfilt[outputIndex].dM    = input[0].secfilt[N*NsecfiltIn+j].dM;
    363         output[0].secfilt[outputIndex].Xm    = input[0].secfilt[N*NsecfiltIn+j].Xm;
    364         output[0].secfilt[outputIndex].M_20  = input[0].secfilt[N*NsecfiltIn+j].M_20;
    365         output[0].secfilt[outputIndex].M_80  = input[0].secfilt[N*NsecfiltIn+j].M_80;
    366         output[0].secfilt[outputIndex].Ncode = input[0].secfilt[N*NsecfiltIn+j].Ncode;
    367         output[0].secfilt[outputIndex].Nused = input[0].secfilt[N*NsecfiltIn+j].Nused;
     329        output[0].secfilt[outputIndex] = input[0].secfilt[N*NsecfiltIn+j];
    368330      }
    369331    }
  • trunk/Ohana/src/dvopsps/src/insert_detections_dvopsps.c

    r35221 r35416  
    5757  }
    5858
     59  int status = TRUE;
    5960  // select measurements for each populated catalog
    6061  for (i = 0; i < skylist[0].Nregions; i++) {
     
    8687    // NOTE: this is where the real action happens
    8788    if (SAVE_REMOTE && HOST_ID) {
    88       append_detections_dvopsps_catalog (&catalog);
     89      if (!append_detections_dvopsps_catalog (&catalog)) {
     90        fprintf (stderr, "ERROR: failure to append detections to output catalog\n");
     91        status = FALSE;
     92      }
    8993    } else {
    90       insert_detections_dvopsps_catalog (&catalog, mysqlReal);
     94      if (!insert_detections_dvopsps_catalog (&catalog, mysqlReal)) {
     95        fprintf (stderr, "ERROR: failure to insert detections into mysql database\n");
     96        status = FALSE;
     97      }
    9198    }
    9299
     
    97104
    98105  if (SAVE_REMOTE && HOST_ID) {
    99     save_detections_dvopsps ();
    100   }
    101 
    102   return (TRUE);
     106    if (!save_detections_dvopsps ()) {
     107      fprintf (stderr, "ERROR: failure to save output file with detections\n");
     108      status = FALSE;
     109    }
     110  }
     111
     112  return (status);
    103113}     
    104114
     
    189199
    190200    for (i = 0; i < table->Nhosts; i++) {
    191       while ((detections = DetectionsLoad (table->hosts[i].results, &Ndetections)) == NULL) {
     201      if ((detections = DetectionsLoad (table->hosts[i].results, &Ndetections)) == NULL) {
    192202        // failed to get the data from this host.  This can happen for various reasons.  Give the user a chance to try again...
     203        // fprintf (stderr, "you may run the command manually\n");
    193204        fprintf (stderr, "failed to read data from %s\n", table->hosts[i].hostname);
    194         fprintf (stderr, "you may run the command manually\n");
     205        return FALSE;
    195206      }
    196207      free (table->hosts[i].results);
    197208      table->hosts[i].results = NULL;
    198209   
    199       insert_detections_mysql_array (mysql, detections, Ndetections);
     210      if (!insert_detections_mysql_array (mysql, detections, Ndetections)) {
     211        fprintf (stderr, "failed to insert data for %s\n", table->hosts[i].hostname);
     212        return FALSE;
     213      }
    200214
    201215      free (detections);
     
    218232  insert_detections_mysql_init (&buffer);
    219233
     234  int status = TRUE;
     235
    220236  gettimeofday (&start, (void *) NULL);
    221237  for (i = 0; i < Ndetections; i++) {
     
    224240    insert_detections_mysql_detvalue (&buffer, &detections[i]);
    225241    if (buffer.Nbuffer > MAX_BUFFER) {
    226       insert_detections_mysql_commit (&buffer, mysql);
     242      if (!insert_detections_mysql_commit (&buffer, mysql)) {
     243        fprintf (stderr, "failure to insert detections in mysql (commit)\n");
     244        status = FALSE;
     245      }
    227246      buffer.Nbuffer = 0;
    228247      bzero (buffer.buffer, buffer.Nalloc);
     
    230249    }
    231250  }
    232   insert_detections_mysql_commit (&buffer, mysql);
     251  if (!insert_detections_mysql_commit (&buffer, mysql)) {
     252    fprintf (stderr, "failure to insert detections in mysql (commit 2)\n");
     253    status = FALSE;
     254  }
    233255  FreeIOBuffer (&buffer);
    234256
     257  if (!status) {
     258    MARKTIME("-- failed to insert %d rows in %f sec\n", Ndetections, dtime);
     259    return FALSE;
     260  }
     261
    235262  MARKTIME("-- inserted %d rows in %f sec\n", Ndetections, dtime);
    236   return (TRUE);
     263  return TRUE;
    237264}
    238265
  • trunk/Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c

    r35221 r35416  
    7474int save_detections_dvopsps () {
    7575
     76  int status = TRUE;
     77
    7678  if (!DetectionsSave (RESULT_FILE, detections, Ndetections)) {
    7779    fprintf (stderr, "failed to save detection file %s\n", RESULT_FILE);
     80    status = FALSE;
    7881  }
    7982
    8083  free (detections);
    8184  Ndetections = 0;
    82   return (TRUE);
     85  return (status);
    8386}
    8487
     
    101104  int Ninsert = 0;
    102105
     106  int status = TRUE;
     107
    103108  // NOTE for testing, just do a few objects
    104109  if (!mysql) {
     
    115120
    116121      // XXX check return status
    117       insert_detections_mysql_value (&buffer, &average[i], &measure[m+j]);
     122      if (!insert_detections_mysql_value (&buffer, &average[i], &measure[m+j])) {
     123        fprintf (stderr, "failure to insert detections in mysql\n");
     124        status = FALSE;
     125      }
    118126
    119127      if (buffer.Nbuffer > MAX_BUFFER) {
    120         insert_detections_mysql_commit (&buffer, mysql);
     128        if (!insert_detections_mysql_commit (&buffer, mysql)) {
     129          fprintf (stderr, "failure to insert detections in mysql (commit)\n");
     130          status = FALSE;
     131        }
    121132        if (DEBUG) fprintf (stderr, "inserted %d rows\n", Ninsert);
    122133        Ninsert = 0;
     
    134145    }
    135146  }
    136   insert_detections_mysql_commit (&buffer, mysql);
     147  if (!insert_detections_mysql_commit (&buffer, mysql)) {
     148    fprintf (stderr, "failure to insert detections in mysql (commit)\n");
     149    status = FALSE;
     150  }
     151 
    137152  if (VERBOSE) fprintf (stderr, "inserted %d rows\n", Ninsert);
    138153  FreeIOBuffer (&buffer);
     154
     155  if (!status) {
     156    MARKTIME("-- failed to insert "OFF_T_FMT" rows in %f sec\n", found, dtime);
     157    return (FALSE);
     158  }
    139159
    140160  MARKTIME("-- inserted "OFF_T_FMT" rows in %f sec, skipped %d without IDs\n", found, dtime, missingID);
     
    188208  PrintIOBuffer (buffer, "%lu, ", average->extID);        // objID
    189209  PrintIOBuffer (buffer, "%u, ", measure->dbFlags);       // flags
     210
    190211  float zp = code->C * 0.001 + code->K * (measure->airmass - 1) - measure->Mcal;
    191212  float exptime = pow(10.0, 0.4 * measure->dt);
     
    211232  MYSQL_RES *result;
    212233
     234  int status = TRUE;
     235
    213236  // check that the last two chars are ,\n and replace with ;\n
    214237  if (!strcmp(&buffer->buffer[buffer->Nbuffer-2], ",\n")) {
     
    222245  if (mysql) {
    223246    if (DEBUG) fprintf (stderr, "%s\n", buffer->buffer);
    224     int status = mysql_query(mysql, buffer->buffer);
    225     if (status) {
     247    int mysqlStatus = mysql_query(mysql, buffer->buffer);
     248    if (mysqlStatus) {
    226249      fprintf (stderr, "error with insert:\n");
    227250      fprintf (stderr, "%s\n", mysql_error(mysql));
    228251      fprintf (stderr, "Nbuffer: %d\n", buffer->Nbuffer);
     252      status = FALSE;
    229253    }
    230254    result = mysql_store_result (mysql);
     
    234258  }
    235259
    236   return TRUE;
    237 }
     260  return status;
     261}
  • trunk/Ohana/src/dvopsps/src/insert_objects_dvopsps_catalog.c

    r35221 r35416  
    9696
    9797  PrintIOBuffer (&buffer, "CREATE TABLE %s_cpt ("
    98                  "RA FLOAT,  "         
    99                  "DEC_ FLOAT,  "         
    100                  "RA_ERR REAL,  "     
    101                  "DEC_ERR REAL,  "     
    102                  "U_RA REAL,  "       
    103                  "U_DEC REAL,  "       
    104                  "V_RA_ERR REAL,  "   
    105                  "V_DEC_ERR REAL,  "   
    106                  "PAR REAL,  "         
    107                  "PAR_ERR REAL,  "     
    108                  "CHISQ_POS REAL,  "   
    109                  "CHISQ_PM REAL,  "   
    110                  "CHISQ_PAP REAL,  "   
     98                 "RA DOUBLE,  "         
     99                 "DEC_ DOUBLE,  "         
     100                 "RA_ERR FLOAT,  "     
     101                 "DEC_ERR FLOAT,  "     
     102                 "U_RA FLOAT,  "       
     103                 "U_DEC FLOAT,  "       
     104                 "V_RA_ERR FLOAT,  "   
     105                 "V_DEC_ERR FLOAT,  "   
     106                 "PAR FLOAT,  "         
     107                 "PAR_ERR FLOAT,  "     
     108                 "CHISQ_POS FLOAT,  "   
     109                 "CHISQ_PM FLOAT,  "   
     110                 "CHISQ_PAP FLOAT,  "   
    111111                 "MEAN_EPOCH INT,  " 
    112112                 "TIME_RANGE INT,  " 
    113                  "PSF_QF REAL, "     
    114                  "PSF_QF_PERF REAL,  "
    115                  "STARGAL_SEP REAL,  "
     113                 "PSF_QF FLOAT, "     
     114                 "PSF_QF_PERF FLOAT,  "
     115                 "STARGAL_SEP FLOAT,  "
    116116                 "NUMBER_POS SMALLINT,  " 
    117117                 "NMEASURE SMALLINT,  "   
     
    152152
    153153  PrintIOBuffer (&buffer, "CREATE TABLE %s_cps ("
    154                  "MAG REAL,  "             
    155                  "MAG_AP REAL,  "             
    156                  "MAG_KRON REAL,  "       
    157                  "MAG_KRON_ERR REAL,  "   
    158                  "MAG_ERR REAL,  "         
    159                  "MAG_CHI REAL,  "         
    160                  "FLUX_PSF REAL,  "       
    161                  "FLUX_PSF_ERR REAL,  "   
    162                  "FLUX_KRON REAL,  "       
    163                  "FLUX_KRON_ERR REAL,  "   
     154                 "MAG FLOAT,  "             
     155                 "MAG_AP FLOAT,  "             
     156                 "MAG_KRON FLOAT,  "       
     157                 "MAG_KRON_ERR FLOAT,  "   
     158                 "MAG_ERR FLOAT,  "         
     159                 "MAG_CHI FLOAT,  "         
     160                 "FLUX_PSF FLOAT,  "       
     161                 "FLUX_PSF_ERR FLOAT,  "   
     162                 "FLUX_KRON FLOAT,  "       
     163                 "FLUX_KRON_ERR FLOAT,  "   
    164164                 "FLAGS INT,  "           
    165165                 "NCODE SMALLINT,  "           
  • trunk/Ohana/src/dvopsps/src/mysql_dvopsps.c

    r35098 r35416  
    5858  // dump_result (connection);
    5959   
    60   sprintf (query, "show variables like 'max_allowed_packet';");
    61   if (mysql_query (connection, query)) {
    62     fprintf (stderr, "failed to set max_allowed_packet\n");
    63     fprintf (stderr, "%s\n", mysql_error (connection));
    64     return NULL;
    65   }
    66   dump_result (connection);
     60  // sprintf (query, "show variables like 'max_allowed_packet';");
     61  // if (mysql_query (connection, query)) {
     62  //   fprintf (stderr, "failed to set max_allowed_packet\n");
     63  //   fprintf (stderr, "%s\n", mysql_error (connection));
     64  //   return NULL;
     65  // }
     66  // dump_result (connection);
    6767   
    6868  if (0) {
  • trunk/Ohana/src/kapa2/src/DrawObjects.c

    r32346 r35416  
    633633  float *x, *y, *dxm, *dxp;
    634634  double mxi, mxj, myi, myj, bxi, bxj, byi, byj, bx, by;
    635   double sx0, sy0, sx1, sy1, sz, sx10, sx11;
     635  double sx0, sy0, sx1, sy1, sz, sx10, sx11, X0, X1, Y0, Y1;
    636636
    637637  mxi = graph[0].axis[0].dfx / (object[0].x1 - object[0].x0);
     
    651651  bar = object[0].ebar; sz = object[0].size*graph[0].axis[1].dfy*0.03;
    652652 
     653  X0 = graph[0].axis[0].fx;
     654  X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     655  Y0 = graph[0].axis[1].fy;
     656  Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     657
    653658  for (i = 0; i < object[0].Npts; i++) {
    654659    if (!(finite(x[i]) && finite(y[i]) && finite(dxp[i]))) continue;
     
    662667         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    663668    {
    664       DrawLine (sx0, sy0, sx1, sy1);
     669      ClipLine (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
    665670      if (bar) {
    666671        sx10 = sy1 - sz;
    667672        sx11 = sy1 + sz;
    668         DrawLine (sx1, sx10, sx1, sx11);
     673        ClipLine (sx1, sx10, sx1, sx11, X0, Y0, X1, Y1);
    669674      }
    670675    }
     
    679684         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    680685    {
    681       DrawLine (sx0, sy0, sx1, sy1);
     686      ClipLine (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
    682687      if (bar) {
    683688        sx10 = sy1 - sz;
    684689        sx11 = sy1 + sz;
    685         DrawLine (sx1, sx10, sx1, sx11);
     690        ClipLine (sx1, sx10, sx1, sx11, X0, Y0, X1, Y1);
    686691      }
    687692    }
     
    695700  float *x, *y, *dym, *dyp;
    696701  double mxi, mxj, myi, myj, bxi, bxj, byi, byj, bx, by;
    697   double sx0, sy0, sx1, sy1, sz, sx10, sx11;
     702  double sx0, sy0, sx1, sy1, sz, sx10, sx11, X0, X1, Y0, Y1;
    698703
    699704  mxi = graph[0].axis[0].dfx / (object[0].x1 - object[0].x0);
     
    713718  bar = object[0].ebar; sz = object[0].size*graph[0].axis[0].dfx*0.03;
    714719 
     720  X0 = graph[0].axis[0].fx;
     721  X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     722  Y0 = graph[0].axis[1].fy;
     723  Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     724
    715725  for (i = 0; i < object[0].Npts; i++) {
    716726    if (!(finite(x[i]) && finite(y[i]) && finite(dyp[i]))) continue;
     
    724734         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    725735    {
    726       DrawLine (sx0, sy0, sx1, sy1);
     736      ClipLine (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
    727737      if (bar) {
    728738        sx10 = sx1 - sz;
    729739        sx11 = sx1 + sz;
    730         DrawLine (sx10, sy1, sx11, sy1);
     740        ClipLine (sx10, sy1, sx11, sy1, X0, Y0, X1, Y1);
    731741      }
    732742    }
     
    741751         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    742752    {
    743       DrawLine (sx0, sy0, sx1, sy1);
     753      ClipLine (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
    744754      if (bar) {
    745755        sx10 = sx1 - sz;
    746756        sx11 = sx1 + sz;
    747         DrawLine (sx10, sy1, sx11, sy1);
    748       }
    749     }
    750   }
    751 }
     757        ClipLine (sx10, sy1, sx11, sy1, X0, Y0, X1, Y1);
     758      }
     759    }
     760  }
     761}
  • trunk/Ohana/src/kapa2/src/PSObjects.c

    r32346 r35416  
    578578  bar = object[0].ebar; sz = object[0].size*graph[0].axis[1].dfy*0.03;
    579579   
     580  double X0 = graph[0].axis[0].fx;
     581  double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     582  double Y0 = graph[0].axis[1].fy;
     583  double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     584
    580585  for (i = 0; i < object[0].Npts; i++) {
    581586    if (!(finite(x[i]) && finite(y[i]) && finite(dxp[i]))) continue;
     
    589594         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    590595      {
    591         DrawLine (sx0, sy0, sx1, sy1);
     596        ClipLinePS (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1, f);
     597        // DrawLine (sx0, sy0, sx1, sy1);
    592598        if (bar) {
    593599          sx10 = sy1 - sz;
    594600          sx11 = sy1 + sz;
    595           DrawLine (sx1, sx10, sx1, sx11);
     601          ClipLinePS (sx1, sx10, sx1, sx11, X0, Y0, X1, Y1, f);
     602          // DrawLine (sx1, sx10, sx1, sx11);
    596603        }
    597604      }
     
    606613         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    607614      {
    608         DrawLine (sx0, sy0, sx1, sy1);
     615        ClipLinePS (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1, f);
     616        // DrawLine (sx0, sy0, sx1, sy1);
    609617        if (bar) {
    610618          sx10 = sy1 - sz;
    611619          sx11 = sy1 + sz;
    612           DrawLine (sx1, sx10, sx1, sx11);
     620          ClipLinePS (sx1, sx10, sx1, sx11, X0, Y0, X1, Y1, f);
     621          // DrawLine (sx1, sx10, sx1, sx11);
    613622        }
    614623      }
     
    641650  bar = object[0].ebar; sz = object[0].size*graph[0].axis[0].dfx*0.03;
    642651 
     652  double X0 = graph[0].axis[0].fx;
     653  double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     654  double Y0 = graph[0].axis[1].fy;
     655  double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     656
    643657  for (i = 0; i < object[0].Npts; i++) {
    644658    if (!(finite(x[i]) && finite(y[i]) && finite(dyp[i]))) continue;
     
    652666         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    653667      {
    654         DrawLine (sx0, sy0, sx1, sy1);
     668        ClipLinePS (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1, f);
     669        // DrawLine (sx0, sy0, sx1, sy1);
    655670        if (bar) {
    656671          sx10 = sx1 - sz;
    657672          sx11 = sx1 + sz;
    658           DrawLine (sx10, sy1, sx11, sy1);
     673          ClipLinePS (sx10, sy1, sx11, sy1, X0, Y0, X1, Y1, f);
     674          // DrawLine (sx10, sy1, sx11, sy1);
    659675        }
    660676      }
     
    669685         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    670686      {
    671         DrawLine (sx0, sy0, sx1, sy1);
     687        ClipLinePS (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1, f);
     688        // DrawLine (sx0, sy0, sx1, sy1);
    672689        if (bar) {
    673690          sx10 = sx1 - sz;
    674691          sx11 = sx1 + sz;
    675           DrawLine (sx10, sy1, sx11, sy1);
     692          ClipLinePS (sx10, sy1, sx11, sy1, X0, Y0, X1, Y1, f);
     693          // DrawLine (sx10, sy1, sx11, sy1);
    676694        }
    677695      }
  • trunk/Ohana/src/kapa2/src/bDrawObjects.c

    r32346 r35416  
    578578  bar = object[0].ebar; sz = object[0].size*graph[0].axis[1].dfy*0.03;
    579579   
     580  double X0 = graph[0].axis[0].fx;
     581  double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     582  double Y0 = graph[0].axis[1].fy;
     583  double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     584
    580585  for (i = 0; i < object[0].Npts; i++) {
    581586    if (!(finite(x[i]) && finite(y[i]) && finite(dxp[i]))) continue;
     
    589594         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    590595    {
    591       DrawLine (buffer, sx0, sy0, sx1, sy1);
     596      bDrawClipLine (buffer, sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
     597      //   DrawLine (buffer, sx0, sy0, sx1, sy1);
    592598      if (bar) {
    593599        sx10 = sy1 - sz;
    594600        sx11 = sy1 + sz;
    595         DrawLine (buffer, sx1, sx10, sx1, sx11);
     601        bDrawClipLine (buffer, sx1, sx10, sx1, sx11, X0, Y0, X1, Y1);
     602        //   DrawLine (buffer, sx1, sx10, sx1, sx11);
    596603      }
    597604    }
     
    606613         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    607614    {
    608       DrawLine (buffer, sx0, sy0, sx1, sy1);
     615      bDrawClipLine (buffer, sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
     616      //   DrawLine (buffer, sx0, sy0, sx1, sy1);
    609617      if (bar) {
    610618        sx10 = sy1 - sz;
    611619        sx11 = sy1 + sz;
    612         DrawLine (buffer, sx1, sx10, sx1, sx11);
     620        bDrawClipLine (buffer, sx1, sx10, sx1, sx11, X0, Y0, X1, Y1);
     621        //   DrawLine (buffer, sx1, sx10, sx1, sx11);
    613622      }
    614623    }
     
    640649  bar = object[0].ebar; sz = object[0].size*graph[0].axis[0].dfx*0.03;
    641650 
     651  double X0 = graph[0].axis[0].fx;
     652  double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     653  double Y0 = graph[0].axis[1].fy;
     654  double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     655
    642656  for (i = 0; i < object[0].Npts; i++) {
    643657    if (!(finite(x[i]) && finite(y[i]) && finite(dyp[i]))) continue;
     
    651665         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    652666    {
    653       DrawLine (buffer, sx0, sy0, sx1, sy1);
     667      bDrawClipLine (buffer, sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
     668      //   DrawLine (buffer, sx0, sy0, sx1, sy1);
    654669      if (bar) {
    655670        sx10 = sx1 - sz;
    656671        sx11 = sx1 + sz;
    657         DrawLine (buffer, sx10, sy1, sx11, sy1);
     672        bDrawClipLine (buffer, sx10, sy1, sx11, sy1, X0, Y0, X1, Y1);
     673        //   DrawLine (buffer, sx10, sy1, sx11, sy1);
    658674      }
    659675    }
     
    668684         (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
    669685    {
    670       DrawLine (buffer, sx0, sy0, sx1, sy1);
     686      bDrawClipLine (buffer, sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
     687      //   DrawLine (buffer, sx0, sy0, sx1, sy1);
    671688      if (bar) {
    672689        sx10 = sx1 - sz;
    673690        sx11 = sx1 + sz;
    674         DrawLine (buffer, sx10, sy1, sx11, sy1);
     691        bDrawClipLine (buffer, sx10, sy1, sx11, sy1, X0, Y0, X1, Y1);
     692        //   DrawLine (buffer, sx10, sy1, sx11, sy1);
    675693      }
    676694    }
  • trunk/Ohana/src/libdvo/Makefile

    r35263 r35416  
    3636$(DESTINC)/ps1_v3_defs.h \
    3737$(DESTINC)/ps1_v4_defs.h \
    38 $(DESTINC)/ps1_ref_defs.h
     38$(DESTINC)/ps1_ref_defs.h \
     39$(DESTINC)/cmf-ps1-dv3.h
    3940
    4041INCS = $(DEFS) $(DESTINC)/dvo.h $(DESTINC)/autocode.h $(DESTINC)/dvo_util.h $(DESTINC)/dvodb.h $(DESTINC)/libdvo_astro.h $(DESTINC)/convert.h $(DESTINC)/get_graphdata.h
     
    8485$(SRC)/cmf-ps1-v1-alt.$(ARCH).o \
    8586$(SRC)/cmf-ps1-sv1-alt.$(ARCH).o \
     87$(SRC)/cmf-ps1-dv3.$(ARCH).o \
    8688$(SRC)/dvo_util.$(ARCH).o \
    8789$(SRC)/dbBooleanCond.$(ARCH).o          \
  • trunk/Ohana/src/libdvo/include/dvo.h

    r35102 r35416  
    129129  ID_MEAS_BLEND_MEAS_X   = 0x00001000,  // detection is within radius of multiple objects across catalogs                   
    130130  ID_MEAS_ARTIFACT       = 0x00002000,  // detection is thought to be non-astronomical                               
    131   ID_MEAS_UNDEF_5        = 0x00004000,  // unused
     131  ID_MEAS_SYNTH_MAG      = 0x00004000,  // magnitude is synthetic
    132132  ID_MEAS_PHOTOM_UBERCAL = 0x00008000,  // externally-supplied zero point from ubercal analysis
    133133  ID_MEAS_STACK_PRIMARY  = 0x00010000,  // this stack measurement is in the primary skycell
     
    288288CMF_PS1_SV1 *gfits_table_get_CMF_PS1_SV1_Alt (FTable *ftable, off_t *Ndata, char *swapped);
    289289
     290// another special case : does not match byte-boundaries
     291# include "cmf-ps1-dv3.h"
     292
    290293typedef struct {
    291294  int Ncode;                                      // number of photcodes
     
    717720
    718721void dvo_average_init (Average *average);
     722void dvo_averageT_init (AverageTiny *average);
    719723void dvo_secfilt_init (SecFilt *secfilt);
    720724void dvo_measure_init (Measure *measure);
     725void dvo_measureT_init (MeasureTiny *measure);
    721726
    722727# endif // DVO_H
  • trunk/Ohana/src/libdvo/include/dvodb.h

    r35263 r35416  
    125125      MEAS_YFIX,
    126126      MEAS_POS_SYS_ERR,
     127      MEAS_XFIELD,
     128      MEAS_YFIELD,
    127129      MEAS_XMOSAIC,
    128130      MEAS_YMOSAIC,
     
    301303  double crval1;
    302304  double crval2;
     305  float theta;
    303306  unsigned int imageID;
    304307  unsigned int externID;
     
    382385ImageMetadata *MatchImageMetadataDVO (unsigned int imageID);
    383386Coords *MatchMosaicMetadata (unsigned int imageID);
     387Coords *MatchFieldMetadata (unsigned int imageID);
    384388off_t match_image_by_ID (ImageMetadata *image, off_t Nimage, unsigned int ID);
    385389void sort_image_metadata (ImageMetadata *image, off_t Nimage);
  • trunk/Ohana/src/libdvo/src/ImageMetadata.c

    r35263 r35416  
    6363  GET_COLUMN (crval1,   "CRVAL1",         double);
    6464  GET_COLUMN (crval2,   "CRVAL2",         double);
     65  GET_COLUMN (theta,    "THETA",          float);
    6566  GET_COLUMN (Mcal,     "MCAL",           float);
    6667  GET_COLUMN (secz,     "SECZ",           float);
     
    7576    image[i].crval1   = crval1[i]  ;
    7677    image[i].crval2   = crval2[i]  ;
     78    image[i].theta    = theta[i]  ;
    7779    image[i].Mcal     = Mcal[i]    ;
    7880    image[i].secz     = secz[i]    ;
     
    8789  free (crval1);
    8890  free (crval2);
     91  free (theta);
    8992  free (Mcal);
    9093  free (secz);
     
    112115  FTable ftable;
    113116
     117  BuildChipMatch (image, Nimage);
     118
    114119  gfits_init_header (&header);
    115120  header.extend = TRUE;
     
    124129  gfits_define_bintable_column (&theader, "D", "CRVAL1", "ra at center", "degrees", 1.0, 0.0);
    125130  gfits_define_bintable_column (&theader, "D", "CRVAL2", "dec at center", "degrees", 1.0, 0.0);
     131  gfits_define_bintable_column (&theader, "E", "THETA", "camera rot angle", "degrees", 1.0, 0.0);
    126132  gfits_define_bintable_column (&theader, "E", "MCAL", "zero point offset", "magnitudes", 1.0, 0.0);
    127133  gfits_define_bintable_column (&theader, "E", "SECZ", "airmass", "none", 1.0, 0.0);
     
    134140  unsigned int *imageID, *externID, *expname;
    135141  double *crval1, *crval2;
    136   float *Mcal, *Xcenter, *Ycenter, *secz;
     142  float *Mcal, *Xcenter, *Ycenter, *secz, *theta;
    137143
    138144  // create intermediate storage arrays
     
    142148  ALLOCATE (crval1,   double,         Nimage);
    143149  ALLOCATE (crval2,   double,         Nimage);
     150  ALLOCATE (theta,    float,          Nimage);
    144151  ALLOCATE (Mcal,     float,          Nimage);
    145152  ALLOCATE (secz,     float,          Nimage);
     
    149156  // assign the storage arrays
    150157  for (i = 0; i < Nimage; i++) {
     158    int Nmosaic = FindMosaicForImage (image, Nimage, i);
     159    if (!Nmosaic) continue;
     160    Nmosaic --;
    151161    imageID[i]  = image[i].imageID;
    152162    externID[i] = image[i].externID;
    153     crval1[i]   = image[i].coords.crval1;
    154     crval2[i]   = image[i].coords.crval2;
     163    crval1[i]   = image[Nmosaic].coords.crval1;
     164    crval2[i]   = image[Nmosaic].coords.crval2;
     165
     166    theta[i]    = DEG_RAD*atan2(image[Nmosaic].coords.pc1_2, image[Nmosaic].coords.pc1_1);
     167
    155168    Mcal[i]     = image[i].Mcal;
    156169    secz[i]     = image[i].secz;
     
    172185  gfits_set_bintable_column (&theader, &ftable, "CRVAL1",         crval1,  Nimage);
    173186  gfits_set_bintable_column (&theader, &ftable, "CRVAL2",         crval2,  Nimage);
     187  gfits_set_bintable_column (&theader, &ftable, "THETA",          theta,   Nimage);
    174188  gfits_set_bintable_column (&theader, &ftable, "MCAL",           Mcal,    Nimage);
    175189  gfits_set_bintable_column (&theader, &ftable, "SECZ",           secz,    Nimage);
     
    182196  free (crval1);
    183197  free (crval2);
     198  free (theta);
    184199  free (Mcal);
    185200  free (secz);
  • trunk/Ohana/src/libdvo/src/ImageMetadataSelection.c

    r35263 r35416  
    55static off_t Nimage = 0;
    66static Coords mosaic;
     7static Coords field;
    78
    89/* load images based on parameters and region, etc */
     
    1112  image = NULL;
    1213 
     14  /* field defines a frame with 0,0 at the field center, and 1 arcsec / pixel */
     15  field.crpix1 = field.crpix2 = 0.0;
     16  field.cdelt1 = field.cdelt2 = 1.0 / 3600;
     17  field.pc1_1  = field.pc2_2  = 1.0;
     18  field.pc1_2  = field.pc2_1  = 0.0;
     19  field.Npolyterms = 0;
     20  strcpy (field.ctype, "RA---SIN");
     21
    1322  /* mosaic defines a frame with 0,0 at the mosaic center, and 1 arcsec / pixel */
    1423  mosaic.crpix1 = mosaic.crpix2 = 0.0;
     
    4251}
    4352
     53Coords *MatchFieldMetadata (unsigned int imageID) {
     54
     55  int m;
     56
     57  m = match_image_by_ID (image, Nimage, imageID);
     58  if (m == -1) return (NULL);
     59
     60  // if WRP, return the image, otherwise return NULL
     61  // if (strcmp(&image[m].coords.ctype[4], "-WRP")) return NULL;
     62  // return (&image[m].coords);
     63
     64  field.crval1 = image[m].crval1;
     65  field.crval2 = image[m].crval2;
     66  return (&field);
     67}
     68
    4469Coords *MatchMosaicMetadata (unsigned int imageID) {
    4570
     
    4873  m = match_image_by_ID (image, Nimage, imageID);
    4974  if (m == -1) return (NULL);
     75
     76  // if WRP, return the image, otherwise return NULL
     77  // if (strcmp(&image[m].coords.ctype[4], "-WRP")) return NULL;
     78  // return (&image[m].coords);
     79
    5080  mosaic.crval1 = image[m].crval1;
    5181  mosaic.crval2 = image[m].crval2;
     82
     83  mosaic.pc1_1 =  cos(RAD_DEG*image[m].theta);
     84  mosaic.pc1_2 =  sin(RAD_DEG*image[m].theta);
     85  mosaic.pc2_2 =  cos(RAD_DEG*image[m].theta);
     86  mosaic.pc2_1 = -sin(RAD_DEG*image[m].theta);
     87
    5288  return (&mosaic);
    5389}
  • trunk/Ohana/src/libdvo/src/ImageSelection.c

    r35263 r35416  
    9393  int m;
    9494
     95  // mosaic.crval1 = 0;
     96  // mosaic.crval2 = 0;
    9597  m = match_image_subset (image, subset, Nsubset, time, source);
    9698  if (m == -1) return (NULL);
    97   mosaic.crval1 = image[m].coords.crval1;
    98   mosaic.crval2 = image[m].coords.crval2;
    99   return (&mosaic);
     99  // mosaic = image[m].coords.crval1;
     100  // mosaic = image[m].coords.crval2;
     101
     102  // if WRP, return the image, otherwise return NULL
     103  if (strcmp(&image[m].coords.ctype[4], "-WRP")) return NULL;
     104  return (&image[m].coords);
    100105}
  • trunk/Ohana/src/libdvo/src/dbExtractAverages.c

    r34844 r35416  
    141141      value.Flt = average[0].ChiSqPar;
    142142      break;
     143
     144    // XXX case AVE_PM_GROUPS:
     145    // XXX   value.Int = GetProperMotionGroups (average, measure);
     146    // XXX   break;
    143147
    144148    case AVE_TMEAN:
     
    278282
    279283
     284// XXX int GetProperMotionGroups (Average *average, Measure *measure) {
     285// XXX   // need the times, excluding ignored detections
     286// XXX   // sort the images
     287// XXX   for (i = 0; i < Ntimes - 1; i++)  {
     288// XXX     if (time[i+1] - time[i] < TRANGE) Ngroup ++;
     289// XXX   }
     290// XXX   return Ngroup;
     291// XXX }
     292// XXX
  • trunk/Ohana/src/libdvo/src/dbExtractMeasures.c

    r35263 r35416  
    1616static int REMOTE_CLIENT = FALSE;
    1717
     18// the following values are calculated together in a single function, eg.,
     19// ApplyTransform() returning Glon & Glat.  for a single measurement, we want to do this
     20// calculation once and save both values in case both are requested (usually both are if
     21// either is)
    1822static int haveGalacticAve = FALSE;
    1923static double GLON_AVE = 0.0;
     
    3135static double ELON_MEAS = 0.0;
    3236static double ELAT_MEAS = 0.0;
     37
     38static int haveMosaicMeas = FALSE;
     39static double XMOS_MEAS = 0.0;
     40static double YMOS_MEAS = 0.0;
     41
     42static int haveFieldMeas = FALSE;
     43static double XFIELD_MEAS = 0.0;
     44static double YFIELD_MEAS = 0.0;
    3345
    3446int dbExtractMeasuresInit (int isRemoteClient) {
     
    6678
    6779int dbExtractMeasuresInitMeas () {
     80  haveMosaicMeas   = FALSE;
    6881  haveGalacticMeas = FALSE;
    6982  haveEclipticMeas = FALSE;
     
    7689  int Nsec;
    7790  dbValue value;
    78   double ra, dec, x, y, dT;
    79 
    80   Coords *mosaic;
     91  double dT;
     92
     93  Coords *mosaic, *fieldc;
     94
    8195  PhotCode *equiv;
    8296
     
    8599
    86100  switch (field->ID) {
    87     case MEAS_MAG: /* magnitudes are already determined above */
    88       equiv = GetPhotcodeEquivbyCode (measure[0].photcode);
    89 
    90       // we return the magnitude for this measure if:
    91       if (field->photcode->type == PHOT_MAG) goto valid_photcode;
     101    case MEAS_MAG: { /* magnitudes are already determined above */
     102      PhotCode *myEquiv = GetPhotcodeEquivbyCode (measure[0].photcode);
     103
     104      // if we request mag:ave, use equiv for photcode
     105      if  (field->photcode->type == PHOT_MAG) {
     106        equiv = myEquiv;
     107        goto valid_photcode;
     108      }
     109
     110      // if we ask for 2MASS_K, etc (REF values), return NAN unless measure->code matches
    92111      if ((field->photcode->type == PHOT_REF) && (measure[0].photcode == field->photcode->code)) goto valid_photcode;
     112
     113      // if we ask for GPC1.g.XY03:rel, etc (DEP values), return NAN unless measure->code matches
    93114      if ((field->photcode->type == PHOT_DEP) && (measure[0].photcode == field->photcode->code)) goto valid_photcode;
    94115
    95       if ((equiv != NULL) && (field->photcode->type == PHOT_SEC) && (equiv[0].code == field->photcode->code)) goto valid_photcode;
     116      // if we ask for g:ave, or other SEC-level values, return the corresponding field
     117      if (field->photcode->type == PHOT_SEC) {
     118        switch (field->magMode) {
     119          // measure-like : return non-NAN if measure.equiv.photcode matches field.photcode
     120          case MAG_INST:
     121          case MAG_CAT:
     122          case MAG_SYS:
     123          case MAG_REL:
     124          case MAG_CAL:
     125          case MAG_APER:
     126          case MAG_APER_INST:
     127          case MAG_KRON:
     128          case MAG_KRON_INST:
     129          case MAG_KRON_ERR:
     130          case MAG_ERR:
     131          case MAG_PHOT_FLAGS:
     132            equiv = myEquiv;
     133            if (equiv && (equiv->code == field->photcode->code)) goto valid_photcode;
     134            break;
     135
     136            // mean-like : return value for the given photcode
     137          case MAG_AVE:
     138          case MAG_REF:
     139          case MAG_CHISQ:
     140          case MAG_AVE_ERR:
     141          case MAG_NCODE:
     142          case MAG_NPHOT:
     143          case MAG_FLUX_PSF:
     144          case MAG_FLUX_PSF_ERR:
     145          case MAG_FLUX_KRON:
     146          case MAG_FLUX_KRON_ERR:
     147            equiv = field->photcode;
     148            goto valid_photcode;
     149            break;
     150          default:
     151            fprintf (stderr, "error");
     152            return value;
     153        }
     154      }
    96155      break;
    97156
     
    182241      }
    183242      break;
     243    }
    184244    case MEAS_RA: /* OK */
    185245      value.Flt = average[0].R - measure[0].dR / 3600.0;
     
    465525      value.Flt = FromShortPixels(measure[0].dRsys);
    466526      break;
    467     case MEAS_XMOSAIC: /* OK */
    468       ra  = average[0].R - measure[0].dR / 3600.0;
    469       dec = average[0].D - measure[0].dD / 3600.0;
    470       mosaic = MatchMosaicMetadata (measure[0].imageID);
    471       if (mosaic == NULL) break;
    472       RD_to_XY (&x, &y, ra, dec, mosaic);
    473       value.Flt = x;
     527
     528    case MEAS_XFIELD: /* offset relative to exposure center in ra,dec space */
     529      if (!haveFieldMeas) {
     530        if (REMOTE_CLIENT) {
     531          fieldc = MatchFieldMetadata (measure[0].imageID);
     532        } else {
     533          fprintf (stderr, "non-parallel Xmos broken\n");
     534          abort();
     535          // fieldc = MatchField (measure[0].t, measure[0].photcode);
     536        }
     537        if (fieldc == NULL) break;
     538        double Rm = average[0].R - measure[0].dR / 3600.0;
     539        double Dm = average[0].D - measure[0].dD / 3600.0;
     540        RD_to_XY (&XFIELD_MEAS, &YFIELD_MEAS, Rm, Dm, fieldc);
     541      }
     542      value.Flt = XFIELD_MEAS;
     543      break;
     544    case MEAS_YFIELD: /* OK */
     545      if (!haveFieldMeas) {
     546        if (REMOTE_CLIENT) {
     547          fieldc = MatchFieldMetadata (measure[0].imageID);
     548        } else {
     549          fprintf (stderr, "non-parallel Xmos broken\n");
     550          abort();
     551          // fieldc = MatchField (measure[0].t, measure[0].photcode);
     552        }
     553        if (fieldc == NULL) break;
     554        double Rm = average[0].R - measure[0].dR / 3600.0;
     555        double Dm = average[0].D - measure[0].dD / 3600.0;
     556        RD_to_XY (&XFIELD_MEAS, &YFIELD_MEAS, Rm, Dm, fieldc);
     557      }
     558      value.Flt = YFIELD_MEAS;
     559      break;
     560
     561    case MEAS_XMOSAIC: /* offset relative to exposure center in camera coords */
     562      if (!haveMosaicMeas) {
     563        if (REMOTE_CLIENT) {
     564          mosaic = MatchMosaicMetadata (measure[0].imageID);
     565        } else {
     566          fprintf (stderr, "non-parallel Xmos broken\n");
     567          abort();
     568          mosaic = MatchMosaic (measure[0].t, measure[0].photcode);
     569        }
     570        if (mosaic == NULL) break;
     571        double Rm = average[0].R - measure[0].dR / 3600.0;
     572        double Dm = average[0].D - measure[0].dD / 3600.0;
     573        RD_to_XY (&XMOS_MEAS, &YMOS_MEAS, Rm, Dm, mosaic);
     574      }
     575      value.Flt = XMOS_MEAS;
    474576      break;
    475577    case MEAS_YMOSAIC: /* OK */
    476       ra  = average[0].R - measure[0].dR / 3600.0;
    477       dec = average[0].D - measure[0].dD / 3600.0;
    478       mosaic = MatchMosaic (measure[0].t, measure[0].photcode);
    479       if (mosaic == NULL) break;
    480       RD_to_XY (&x, &y, ra, dec, mosaic);
    481       value.Flt = y;
     578      if (!haveMosaicMeas) {
     579        if (REMOTE_CLIENT) {
     580          mosaic = MatchMosaicMetadata (measure[0].imageID);
     581        } else {
     582          fprintf (stderr, "non-parallel Xmos broken\n");
     583          abort();
     584          mosaic = MatchMosaic (measure[0].t, measure[0].photcode);
     585        }
     586        if (mosaic == NULL) break;
     587        double Rm = average[0].R - measure[0].dR / 3600.0;
     588        double Dm = average[0].D - measure[0].dD / 3600.0;
     589        RD_to_XY (&XMOS_MEAS, &YMOS_MEAS, Rm, Dm, mosaic);
     590      }
     591      value.Flt = YMOS_MEAS;
    482592      break;
    483593
  • trunk/Ohana/src/libdvo/src/dbFields.c

    r35237 r35416  
    8787    strcpy (code[0].name, "MAG");
    8888    code[0].type = PHOT_MAG;
     89    // the field call 'mag' is only valid for mextract
     90    // it should default to REL, but other types should default to AVE
     91    if (useDefault) {
     92      *mode = MAG_REL;
     93    }
    8994    free (tmpstring);
    9095    return (code);
     
    220225  if (!strcasecmp (fieldName, "YFIX"))           ESCAPE (MEAS_YFIX,           MAG_NONE, OPIHI_FLT);
    221226  if (!strcasecmp (fieldName, "POS_SYS_ERR"))    ESCAPE (MEAS_POS_SYS_ERR,    MAG_NONE, OPIHI_FLT);
     227  if (!strcasecmp (fieldName, "XFIELD"))         ESCAPE (MEAS_XFIELD,         MAG_NONE, OPIHI_FLT);
     228  if (!strcasecmp (fieldName, "YFIELD"))         ESCAPE (MEAS_YFIELD,         MAG_NONE, OPIHI_FLT);
    222229  if (!strcasecmp (fieldName, "XMOSAIC"))        ESCAPE (MEAS_XMOSAIC,        MAG_NONE, OPIHI_FLT);
    223230  if (!strcasecmp (fieldName, "YMOSAIC"))        ESCAPE (MEAS_YMOSAIC,        MAG_NONE, OPIHI_FLT);
     
    254261
    255262  // check for code:mode in photcode name
    256   code = ParsePhotcodeField (fieldName, &mode, MAG_REL);
     263  code = ParsePhotcodeField (fieldName, &mode, MAG_AVE);
    257264  if (code == NULL) {
    258265    gprint (GP_ERR, "unknown field '%s' for measurement table in DVO database\n", fieldName);
  • trunk/Ohana/src/libdvo/src/dvo_catalog.c

    r35102 r35416  
    112112
    113113// init all data, or just catalog data
     114void dvo_averageT_init (AverageTiny *average) {
     115  average->R               = 0;
     116  average->D               = 0;
     117  average->flags           = 0;
     118  average->Nmeasure        = 0;
     119  average->measureOffset   = -1;
     120  average->catID           = 0;
     121}
     122
     123// init all data, or just catalog data
    114124void dvo_secfilt_init (SecFilt *secfilt) {
    115125  secfilt->M           = NAN;
     
    142152 measure->dR        = NAN;
    143153 measure->dD        = NAN;
    144  measure->M         = NAN;
    145154 measure->Mcal      = NAN;
    146155 measure->Map       = NAN;
     
    203212 measure->dbFlags   = 0;
    204213 measure->photFlags = 0;
     214}
     215
     216void dvo_measureT_init (MeasureTiny *measure) {
     217 measure->dR        = NAN;
     218 measure->dD        = NAN;
     219 measure->M         = NAN;
     220 measure->Mcal      = NAN;
     221 measure->dM        = NAN;
     222
     223 measure->airmass   = NAN;
     224 measure->Xccd      = NAN;
     225 measure->Yccd      = NAN;
     226 measure->Xfix      = NAN;
     227 measure->Yfix      = NAN;
     228
     229 measure->t         = 0;
     230 measure->dt        = NAN;
     231 measure->averef    = 0;
     232
     233 measure->imageID   = 0;
     234
     235 measure->dbFlags   = 0;
     236 measure->photFlags = 0;
     237 measure->photcode  = 0;
     238
     239 measure->catID     = 0;
     240
     241 measure->dXccd     = 0;
     242 measure->dYccd     = 0;
     243 measure->dRsys     = 0;
    205244}
    206245
  • trunk/Ohana/src/libkapa/src/KapaOpen.c

    r35237 r35416  
    120120  return (-1);
    121121
    122 accepted:
     122 accepted:
     123  {
     124    // we need to do some minimal handshake here.  I will send out
     125    // a 4 char message : KAPA
     126    int Nout = write (BindSocket, "KAPA", 4);
     127    if (Nout != 4) {
     128      if (DEBUG) fprintf (stderr, "connection failed\n");
     129      close (BindSocket);
     130      return (-1);
     131    }
     132  }
     133 
    123134  if (DEBUG) fprintf (stderr, "connection accepted\n");
    124135  return (BindSocket);
     
    203214    perror ("connect: ");
    204215    exit (2);
     216  }
     217
     218  // apparently, I can connect on someone else's port (eg GoogleTalkPlugin)
     219  // do a simple handshake before we set !NONBLOCK:
     220  char line[5];
     221  int Nout = read (InitSocket, line, 4);
     222  if (Nout != 4) {
     223    if (DEBUG) fprintf (stderr, "connection failed\n");
     224    close (InitSocket);
     225    return (-1);
     226  }
     227  if (strncmp (line, "KAPA", 4)) {
     228    if (DEBUG) fprintf (stderr, "connection to the wrong server\n");
     229    close (InitSocket);
     230    return (-1);
    205231  }
    206232
     
    290316
    291317  if (name == NULL) {
    292     sprintf (temp, "%s -socket %s &", kapa_exec, socket_name);
     318    sprintf (temp, "%s -socket %s", kapa_exec, socket_name);
    293319  } else {
    294     sprintf (temp, "%s -socket %s -name %s &", kapa_exec, socket_name, name);
     320    sprintf (temp, "%s -socket %s -name %s", kapa_exec, socket_name, name);
    295321  }
    296322
  • trunk/Ohana/src/libohana/src

  • trunk/Ohana/src/opihi

  • trunk/Ohana/src/opihi/cmd.astro

  • trunk/Ohana/src/opihi/cmd.astro/Makefile

    r34342 r35416  
    3030$(SRC)/drizzle.$(ARCH).o           \
    3131$(SRC)/flux.$(ARCH).o              \
     32$(SRC)/fitplx.$(ARCH).o    \
    3233$(SRC)/fixwrap.$(ARCH).o           \
    3334$(SRC)/fixcols.$(ARCH).o           \
  • trunk/Ohana/src/opihi/cmd.astro/init.c

    r34342 r35416  
    1414int drizzle                 PROTO((int, char **));
    1515int flux                    PROTO((int, char **));
     16int fitplx                  PROTO((int, char **));
    1617int fixwrap                 PROTO((int, char **));
    1718int fiximage                PROTO((int, char **));
     
    7172  {1, "drizzle",     drizzle,      "transform image to image"},
    7273  {1, "flux",        flux,         "flux in a convex contour"},
     74  {1, "fitplx",      fitplx,       "fit proper motion and parallax"},
    7375  {1, "fixwrap",     fixwrap,      "fix megacam over-wrapped pixels"},
    7476  {1, "fiximage",    fiximage,     "fix pixels in an image by interpolation"},
  • trunk/Ohana/src/opihi/cmd.data

  • trunk/Ohana/src/opihi/cmd.data/Makefile

    r35237 r35416  
    150150$(SRC)/vsmooth.$(ARCH).o           \
    151151$(SRC)/vstats.$(ARCH).o            \
     152$(SRC)/xsection.$(ARCH).o          \
    152153$(SRC)/wd.$(ARCH).o                \
    153154$(SRC)/write_vectors.$(ARCH).o     \
  • trunk/Ohana/src/opihi/cmd.data/init.c

    r35237 r35416  
    141141int wd               PROTO((int, char **));
    142142int write_vectors    PROTO((int, char **));
     143int xsection         PROTO((int, char **));
    143144int zap              PROTO((int, char **));
    144145int zplot            PROTO((int, char **));
     
    299300  {1, "wd",           wd,               "write an image to a file"},
    300301  {1, "write",        write_vectors,    "write vectors to datafile"},
     302  {1, "xsection",     xsection,         "generate cross-section histogram for an image (or region)"},
    301303  {1, "zap",          zap,              "assign values to pixel regions"},
    302304  {1, "zplot",        zplot,            "plot x y with size scaled by z"},
  • trunk/Ohana/src/opihi/dvo/avextract.c

    r34749 r35416  
    137137  // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
    138138  if (PARALLEL && !HOST_ID) {
    139     int status = HostTableParallelOps (argc, argv, RESULT_FILE, TRUE, 0, VERBOSE);
     139      int status = HostTableParallelOps (skylist, argc, argv, RESULT_FILE, TRUE, 0, VERBOSE);
    140140
    141141    dbFreeFields (fields, Nfields);
  • trunk/Ohana/src/opihi/dvo/avmatch.c

    r34749 r35416  
    9595
    9696    // I need to pass the RA & DEC vectors to the remote clients...
    97     int status = HostTableParallelOps (argc, argv, RESULT_FILE, TRUE, RAvec->Nelements, VERBOSE);
     97    int status = HostTableParallelOps (skylist, argc, argv, RESULT_FILE, TRUE, RAvec->Nelements, VERBOSE);
    9898    if (vec) free (vec);
    9999   
  • trunk/Ohana/src/opihi/dvo/dvo_host_utils.c

    r35109 r35416  
    88# define DIE(WHO,MSG) { perror(WHO); myAbort(MSG); }
    99
    10 int HostTableLaunchJobs (HostTable *table, char *basecmd, char *options, int VERBOSE) {
     10int HostTableLaunchJobs (SkyList *sky, HostTable *table, char *basecmd, char *options, int VERBOSE) {
    1111
    1212  char uniquer[12];
     
    3535
    3636  int top_status = TRUE;
    37   int i;
     37  int i, j;
    3838  for (i = 0; i < table->Nhosts; i++) {
     39
     40      if (sky && (sky->Nregions < table->Nhosts)) {
     41      // do any of the regions want this host?
     42      int wantThisHost = FALSE;
     43      for (j = 0; j < sky->Nregions; j++) {
     44        if (HostTableTestHost (sky->regions[j], table->hosts[i].hostID)) {
     45          wantThisHost = TRUE;
     46          break;
     47        }
     48      }
     49      if (!wantThisHost) {
     50        // fprintf (stderr, "skip host %s\n", table->hosts[i].hostname);
     51        continue;
     52      }
     53      // fprintf (stderr, "not skip host %s\n", table->hosts[i].hostname);
     54    }
    3955
    4056    // ensure that the paths are absolute path names
     
    88104// an alternative ending step ignores the result files and instead saves the names into
    89105// the list 'result:n' for the user to access as desired
    90 int HostTableParallelOps (int argc, char **argv, char *ResultFile, int ReadVectors, int Nelements, int VERBOSE) {
     106int HostTableParallelOps (SkyList *sky, int argc, char **argv, char *ResultFile, int ReadVectors, int Nelements, int VERBOSE) {
    91107
    92108  int i;
    93109
    94   // load the list of hosts
    95   SkyTable *sky = GetSkyTable();
    96   if (!sky) {
    97     gprint (GP_ERR, "failed to load sky table for database\n");
    98     return FALSE;
    99   }
     110  // XX // load the list of hosts
     111  // XX SkyTable *sky = GetSkyTable();
     112  // XX if (!sky) {
     113  // XX   gprint (GP_ERR, "failed to load sky table for database\n");
     114  // XX   return FALSE;
     115  // XX }
    100116
    101117  char *tmppath = GetCATDIR ();
     
    145161
    146162  // launch this command remotely
    147   HostTableLaunchJobs (table, basecmd, options, VERBOSE);
     163  HostTableLaunchJobs (sky, table, basecmd, options, VERBOSE);
    148164  free (options);
    149165  free (basecmd);
     
    183199
    184200    if (table->hosts[i].status) continue;
     201    if (!table->hosts[i].pid) continue;
    185202
    186203    if (ReadVectors) {
  • trunk/Ohana/src/opihi/dvo/mextract.c

    r35263 r35416  
    1616    if (field->ID == MEAS_CENTER_OFFSET)  return TRUE; // 0.5*NX, 0.5*NY
    1717    if (field->ID == MEAS_EXPNAME_AS_INT) return TRUE; // expname (or as int)
    18     if (field->ID == MEAS_AIRMASS)        return TRUE; // airmass
     18    if (field->ID == MEAS_MEAN_AIRMASS)   return TRUE; // airmass
    1919    return FALSE;
    2020}
     
    171171
    172172    // call the remote client
    173     int status = HostTableParallelOps (targc, targv, RESULT_FILE, TRUE, 0, VERBOSE);
     173    int status = HostTableParallelOps (skylist, targc, targv, RESULT_FILE, TRUE, 0, VERBOSE);
    174174
    175175    dbFreeFields (fields, Nfields);
  • trunk/Ohana/src/opihi/dvo/mmatch.c

    r35263 r35416  
    106106  RAvec  = NULL;
    107107  DECvec = NULL;
    108   if (PARALLEL && !HOST_ID) {
    109 
    110     // We need to copy the args to a temp array and modify them so that we send the
    111     // correct set to the remote client.  The args list looks like this:
    112     // if (!CoordsFile) : mmatch (RA) (DEC) (RADIUS) field, ...
    113     // if ( CoordsFile) : mmatch (RADIUS) field, ... [because we stripped off the -coords filename elements]
    114 
    115     // allocate the temp array and copy all but (RA) (DEC)
    116     int targc = 0;
    117     char **targv = NULL;
    118     ALLOCATE (targv, char *, argc + 2);
    119     for (i = 0; i < argc; i++) {
    120       if (!CoordsFile && (i == 1)) continue;
    121       if (!CoordsFile && (i == 2)) continue;
    122       targv[targc] = strcreate (argv[i]);
    123       targc ++;
    124     }
    125 
    126     // if not specified, create the coords.fits input file
    127     if (!CoordsFile) {
    128       // get vectors corresponding to coordinates of interest
    129       if ((RAvec  = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto help;
    130       if ((DECvec = SelectVector (argv[2], ANYVECTOR, TRUE)) == NULL) goto help;
    131      
    132       ALLOCATE (vec, Vector *, 2);
    133       vec[0] = RAvec;
    134       vec[1] = DECvec;
    135 
    136       CoordsFile = abspath("coords.fits", 1024);
    137       int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, NULL);
    138       if (!status) goto escape;
    139     }
    140 
    141     // add the coords file to the args list
    142     targv[targc+0] = strcreate ("-coords");
    143     targv[targc+1] = CoordsFile; // this gets freed with targv
    144     targc += 2;
    145    
    146     // if needed, add the index vector to the args list
    147     if (IDXvec) {
    148       REALLOCATE (targv, char *, targc + 2);
    149       targv[targc+0] = strcreate ("-index");
    150       targv[targc+1] = strcreate (IDXvec[0].name);
    151       targc += 2;
    152     }     
    153 
    154     if (loadImages) {
    155       Image *image;
    156       off_t Nimage;
    157       if ((image = LoadImagesDVO (&Nimage)) == NULL) goto escape;
    158 
    159       char *filename = abspath("image.metadata.fits", DVO_MAX_PATH);
    160       ImageMetadataSave (filename, image, Nimage);
    161 
    162       REALLOCATE (targv, char *, targc + 2);
    163       targv[targc+0] = strcreate ("-image-metadata");
    164       targv[targc+1] = strcreate (filename);
    165       targc += 2;
    166     }
    167 
    168     // call the remote client
    169     int status = HostTableParallelOps (targc, targv, RESULT_FILE, TRUE, 0, VERBOSE);
    170     if (vec) free (vec);
    171    
    172     // free up targv
    173     for (i = 0; i < targc; i++) {
    174       free (targv[i]);
    175     }
    176     free (targv);
    177 
    178     return status;
    179   }
    180108
    181109  // get vectors corresponding to coordinates of interest
     
    193121    remove_argument (1, &argc, argv);
    194122  }
     123
     124  /* load regions which contain all supplied RA,DEC coordinates */
     125  if ((skylist = SelectRegionsByCoordVectors (RAvec, DECvec)) == NULL) goto escape;
     126
     127  if (PARALLEL && !HOST_ID) {
     128
     129    // We need to copy the args to a temp array and modify them so that we send the
     130    // correct set to the remote client.  The args list looks like this:
     131    // if (!CoordsFile) : mmatch (RADIUS) field, ... [we removed RA & DEC above]
     132    // if ( CoordsFile) : mmatch (RADIUS) field, ... [because we stripped off the -coords filename elements]
     133
     134    // allocate the temp array and copy all but (RA) (DEC)
     135    int targc = 0;
     136    char **targv = NULL;
     137    ALLOCATE (targv, char *, argc + 2);
     138    for (i = 0; i < argc; i++) {
     139      targv[targc] = strcreate (argv[i]);
     140      targc ++;
     141    }
     142
     143    // if not specified, create the coords.fits input file
     144    // NOTE: RAvec, DECvec were set above
     145    if (!CoordsFile) {
     146      ALLOCATE (vec, Vector *, 2);
     147      vec[0] = RAvec;
     148      vec[1] = DECvec;
     149
     150      // XXX this is now set for both cases...
     151      CoordsFile = abspath("coords.fits", 1024);
     152      int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, NULL);
     153      if (!status) goto escape;
     154    }
     155
     156    // add the coords file to the args list
     157    targv[targc+0] = strcreate ("-coords");
     158    targv[targc+1] = CoordsFile; // this gets freed with targv
     159    targc += 2;
     160   
     161    // if needed, add the index vector to the args list
     162    if (IDXvec) {
     163      REALLOCATE (targv, char *, targc + 2);
     164      targv[targc+0] = strcreate ("-index");
     165      targv[targc+1] = strcreate (IDXvec[0].name);
     166      targc += 2;
     167    }     
     168
     169    if (loadImages) {
     170      Image *image;
     171      off_t Nimage;
     172      if ((image = LoadImagesDVO (&Nimage)) == NULL) goto escape;
     173
     174      char *filename = abspath("image.metadata.fits", DVO_MAX_PATH);
     175      ImageMetadataSave (filename, image, Nimage);
     176
     177      REALLOCATE (targv, char *, targc + 2);
     178      targv[targc+0] = strcreate ("-image-metadata");
     179      targv[targc+1] = strcreate (filename);
     180      targc += 2;
     181    }
     182
     183    // call the remote client
     184    int status = HostTableParallelOps (skylist, targc, targv, RESULT_FILE, TRUE, 0, VERBOSE);
     185    if (vec) free (vec);
     186   
     187    // free up targv
     188    for (i = 0; i < targc; i++) {
     189      free (targv[i]);
     190    }
     191    free (targv);
     192
     193    return status;
     194  } // END of remote call section
     195
    195196  RADIUS = atof (argv[1]);
    196197  remove_argument (1, &argc, argv);
     
    209210  }
    210211
    211   /* load regions which contain all supplied RA,DEC coordinates */
    212   if ((skylist = SelectRegionsByCoordVectors (RAvec, DECvec)) == NULL) goto escape;
    213212
    214213  /* create output storage vectors */
  • trunk/Ohana/src/opihi/dvo/photometry.c

    r34405 r35416  
    11271127  double value;
    11281128  Image *image;
    1129   Coords *mosaic;
     1129  // Coords *mosaic;
    11301130
    11311131  value = 0;
     
    11931193# endif
    11941194      break;
     1195# if 0
    11951196    case MEAS_XMOSAIC: /* OK */
    11961197      ra  = average[0].R - measure[0].dR / 3600.0;
    11971198      dec = average[0].D - measure[0].dD / 3600.0;
    1198       mosaic = MatchMosaic (measure[0].t, measure[0].photcode);
     1199      mosaic = MatchMosaic (measure[0].t, measure[0].photcode); // XXX not used anymore
    11991200      if (mosaic == NULL) break;
    12001201      RD_to_XY (&x, &y, ra, dec, mosaic);
     
    12041205      ra  = average[0].R - measure[0].dR / 3600.0;
    12051206      dec = average[0].D - measure[0].dD / 3600.0;
    1206       mosaic = MatchMosaic (measure[0].t, measure[0].photcode);
     1207      mosaic = MatchMosaic (measure[0].t, measure[0].photcode); // XXX not used anymore
    12071208      if (mosaic == NULL) break;
    12081209      RD_to_XY (&x, &y, ra, dec, mosaic);
    12091210      value = y;
    12101211      break;
     1212# endif
    12111213  }
    12121214  return (value);
  • trunk/Ohana/src/opihi/dvo/remote.c

    r35109 r35416  
    6161  }
    6262
     63  // load the list of hosts
     64  SkyTable *sky = GetSkyTable();
     65  if (!sky) {
     66    gprint (GP_ERR, "failed to load sky table for database\n");
     67    return FALSE;
     68  }
     69  SkyList *skylist = NULL;
     70  ALLOCATE (skylist, SkyList, 1);
     71  skylist[0].Nregions = sky[0].Nregions;
     72  strcpy (skylist[0].hosts, sky[0].hosts);
     73
    6374  // strip of the 'remote' and send the remaining arguments to the remote machine
    64   int status = HostTableParallelOps (argc - 1, &argv[1], NULL, ReadVectors, 0, VERBOSE);
     75  int status = HostTableParallelOps (skylist, argc - 1, &argv[1], NULL, ReadVectors, 0, VERBOSE);
     76  free (skylist);
    6577  return status;
    6678}
  • trunk/Ohana/src/opihi/dvo/skyregion.c

    r33662 r35416  
    9898  new[0].Nregions = 0;
    9999  new[0].ownElements = FALSE; // this list is only holding a view to the elements
     100  strcpy (new[0].hosts, sky[0].hosts);
    100101
    101102  // output list
     
    107108  list[0].Nregions = 0;
    108109  list[0].ownElements = FALSE; // this list is only holding a view to the elements
     110  strcpy (list[0].hosts, sky[0].hosts);
    109111
    110112  for (i = 0; i < Npts; i++) {
  • trunk/Ohana/src/opihi/include/dvoshell.h

    r35109 r35416  
    9999dbValue      dbExtractImages        PROTO((Image *image, off_t Nimage, off_t N, dbField *field));
    100100
    101 int          HostTableLaunchJobs    PROTO((HostTable *table, char *basecmd, char *options, int VERBOSE));
    102 int          HostTableParallelOps   PROTO((int argc, char **argv, char *ResultFile, int ReadVectors, int Nelements, int VERBOSE));
     101int          HostTableLaunchJobs    PROTO((SkyList *sky, HostTable *table, char *basecmd, char *options, int VERBOSE));
     102int          HostTableParallelOps   PROTO((SkyList *sky, int argc, char **argv, char *ResultFile, int ReadVectors, int Nelements, int VERBOSE));
    103103int          HostTableReloadResults PROTO((char *uniquer, int VERBOSE));
    104104int          HostTableGetResults    PROTO((char *uniquer, int VERBOSE));
  • trunk/Ohana/src/relastro/Makefile

    r33652 r35416  
    6464$(SRC)/high_speed_objects.$(ARCH).o  \
    6565$(SRC)/high_speed_utils.$(ARCH).o  \
     66$(SRC)/hpm_catalogs.$(ARCH).o  \
     67$(SRC)/hpm_objects.$(ARCH).o  \
    6668$(SRC)/relastro_merge_source.$(ARCH).o  \
    6769$(SRC)/resort_catalog.$(ARCH).o  \
     
    106108$(SRC)/high_speed_objects.$(ARCH).o  \
    107109$(SRC)/high_speed_utils.$(ARCH).o  \
     110$(SRC)/hpm_catalogs.$(ARCH).o  \
     111$(SRC)/hpm_objects.$(ARCH).o  \
    108112$(SRC)/relastro_merge_source.$(ARCH).o  \
    109113$(SRC)/resort_catalog.$(ARCH).o  \
  • trunk/Ohana/src/relastro/include/relastro.h

    r35105 r35416  
    2020typedef enum {FIT_NONE, FIT_AVERAGE, FIT_PM_ONLY, FIT_PAR_ONLY, FIT_PM_AND_PAR} FitMode;
    2121
    22 typedef enum {TARGET_NONE, TARGET_SIMPLE, TARGET_CHIPS, TARGET_MOSAICS, TARGET_HIGH_SPEED, TARGET_MERGE_SOURCE, TARGET_UPDATE_OBJECTS, TARGET_UPDATE_OFFSETS, TARGET_LOAD_OBJECTS} FitTarget;
     22typedef enum {TARGET_NONE, TARGET_SIMPLE, TARGET_CHIPS, TARGET_MOSAICS, TARGET_HIGH_SPEED, TARGET_MERGE_SOURCE, TARGET_UPDATE_OBJECTS, TARGET_UPDATE_OFFSETS, TARGET_LOAD_OBJECTS, TARGET_HPM} FitTarget;
    2323
    2424typedef enum {
     
    442442
    443443PhotCode **ParsePhotcodeList (char *rawlist, int *nphotcodes, int needAve);
     444
     445int hpm_catalogs (SkyTable *sky, SkyList *skylist, int hostID, char *hostpath);
     446int hpm_catalogs_parallel (SkyList *skylist);
     447int hpm_objects (SkyRegion *region, Catalog *catalog);
  • trunk/Ohana/src/relastro/src

  • trunk/Ohana/src/relastro/src/UpdateObjects.c

    r34749 r35416  
    224224
    225225      if ((mode == FIT_PM_ONLY) || (mode == FIT_PM_AND_PAR)) {
    226         // project all of the R,D coordinates to a plane centered on this coordinate set
     226        // project all of the R,D coordinates to a plane centered on this coordinate. set
    227227        // the times to be relative to Tmean (this is required for parallax as well)
    228228        for (k = 0; k < N; k++) {
     
    270270          catalog[i].average[j].flags |= ID_STAR_FIT_PAR;
    271271          Npar ++;
     272        } else {
     273          // need to set mode = FIT_PM_ONLY if we do not fit for parallax
     274          mode = FIT_PM_ONLY;
    272275        }
    273276      }   
     
    321324                          fit.uD);
    322325
    323       //make sure that the fit succeeded
     326      // make sure that the fit succeeded
    324327      status = TRUE;
    325328      status &= finite(fit.Ro);
     
    364367      catalog[i].average[j].ChiSqPM   = fitPM.chisq;
    365368      catalog[i].average[j].ChiSqPar  = fitPAR.chisq;
    366       catalog[i].average[j].Tmean = (Tmean * 86400 * 365.26) + T2000;
    367       catalog[i].average[j].Trange = (Trange * 86400 * 365.26);
     369      catalog[i].average[j].Tmean = (Tmean * 86400 * 365.25) + T2000;
     370      catalog[i].average[j].Trange = (Trange * 86400 * 365.25);
    368371      catalog[i].average[j].Npos = fit.Nfit;
    369372      if (XVERB) fprintf (stderr, "%f %f -> %f %f (%f,%f) pm=(%f %f) chisq=(%f, %f, %f)\n",
     
    385388  }
    386389
    387   fprintf (stderr, "fitted "OFF_T_FMT" objects ("OFF_T_FMT" ave, "OFF_T_FMT" pm, "OFF_T_FMT" par), skipped "OFF_T_FMT"\n",  (NaveSum + NpmSum + NparSum),  NaveSum,  NpmSum,  NparSum,  NskipSum);
     390  if (VERBOSE) fprintf (stderr, "fitted "OFF_T_FMT" objects ("OFF_T_FMT" ave, "OFF_T_FMT" pm, "OFF_T_FMT" par), skipped "OFF_T_FMT"\n",  (NaveSum + NpmSum + NparSum),  NaveSum,  NpmSum,  NparSum,  NskipSum);
    388391  return (TRUE);
    389392}
  • trunk/Ohana/src/relastro/src/args.c

    r34749 r35416  
    8989  if ((N = get_argument (argc, argv, "-high-speed"))) {
    9090    // XXX include a parallax / no-parallax option
    91     if (N >= argc - 3) usage();
     91    if (N >= argc - 4) usage();
    9292    FIT_TARGET = TARGET_HIGH_SPEED;
    9393    remove_argument (N, &argc, argv);
     
    9595    remove_argument (N, &argc, argv);
    9696    PHOTCODE_B_LIST = strcreate(argv[N]);
     97    remove_argument (N, &argc, argv);
     98    RADIUS = atof(argv[N]);
     99    remove_argument (N, &argc, argv);
     100    HIGH_SPEED_DIR = abspath(argv[N], DVO_MAX_PATH);
     101    remove_argument (N, &argc, argv);
     102  }
     103
     104  if ((N = get_argument (argc, argv, "-hpm"))) {
     105    if (N >= argc - 2) usage();
     106    FIT_TARGET = TARGET_HPM;
    97107    remove_argument (N, &argc, argv);
    98108    RADIUS = atof(argv[N]);
     
    106116    remove_argument (N, &argc, argv);
    107117    PARALLEL_OUTPUT = TRUE;
    108     if (FIT_TARGET != TARGET_HIGH_SPEED) {
    109       fprintf (stderr, "-parallel-output only valid for -high-speed mode\n");
     118    if ((FIT_TARGET != TARGET_HIGH_SPEED) && (FIT_TARGET != TARGET_HPM)) {
     119      fprintf (stderr, "-parallel-output only valid for -high-speed or -hpm modes\n");
    110120      exit (1);
    111121    }
     
    456466  if ((N = get_argument (argc, argv, "-high-speed"))) {
    457467    // XXX include a parallax / no-parallax option
    458     if (N >= argc - 3) usage_client();
     468    if (N >= argc - 5) usage_client();
    459469    FIT_TARGET = TARGET_HIGH_SPEED;
    460470    remove_argument (N, &argc, argv);
     
    466476    remove_argument (N, &argc, argv);
    467477    HIGH_SPEED_DIR = strcreate(argv[N]);
     478    remove_argument (N, &argc, argv);
     479  }
     480
     481  if ((N = get_argument (argc, argv, "-hpm"))) {
     482    if (N >= argc - 3) usage();
     483    FIT_TARGET = TARGET_HPM;
     484    remove_argument (N, &argc, argv);
     485    RADIUS = atof(argv[N]);
     486    remove_argument (N, &argc, argv);
     487    HIGH_SPEED_DIR = abspath(argv[N], DVO_MAX_PATH);
    468488    remove_argument (N, &argc, argv);
    469489  }
     
    668688  fprintf (stderr, "       OR:    relastro -update-objects [options]\n");
    669689  fprintf (stderr, "       OR:    relastro -high-speed [options]\n");
     690  fprintf (stderr, "       OR:    relastro -hpm [options]\n");
    670691  fprintf (stderr, "       OR:    relastro -merge-source [options]\n\n");
    671692
     
    679700  fprintf (stderr, "  -update-mosaics\n");
    680701  fprintf (stderr, "  -high-speed (code[,code,code]) (code[,code,code]) (radius) (output catdir)\n");
     702  fprintf (stderr, "  -hpm (radius) (output catdir)\n");
    681703  fprintf (stderr, "  -merge-source (objID) (catID) into (objID) (catID)\n\n");
    682704
  • trunk/Ohana/src/relastro/src/relastro.c

    r33652 r35416  
    1919      /* high-speed is a 2pt cross-correlation process for linking moving objects (high PM) */
    2020      high_speed_catalogs (sky, skylist, 0, NULL);
     21      exit (0);
     22
     23    case TARGET_HPM:
     24      hpm_catalogs (sky, skylist, 0, NULL);
    2125      exit (0);
    2226
  • trunk/Ohana/src/relastro/src/relastro_client.c

    r33652 r35416  
    5858    }
    5959
     60    case TARGET_HPM: {
     61      // USAGE: relastro_client -high-speed
     62      hpm_catalogs (sky, skylist, HOST_ID, HOSTDIR);
     63      break;
     64    }
     65
    6066      // XXX loading the images is fairly costly -- see if we can do an image subset
    6167    case TARGET_UPDATE_OFFSETS: {
  • trunk/Ohana/src/relphot/Makefile

    r34844 r35416  
    4040$(SRC)/load_catalogs.$(ARCH).o   \
    4141$(SRC)/load_images.$(ARCH).o     \
     42$(SRC)/synthetic_mags.$(ARCH).o  \
    4243$(SRC)/plot_scatter.$(ARCH).o    \
    4344$(SRC)/plotstuff.$(ARCH).o       \
    4445$(SRC)/reload_catalogs.$(ARCH).o \
    4546$(SRC)/relphot.$(ARCH).o         \
     47$(SRC)/relphot_images.$(ARCH).o  \
    4648$(SRC)/relphot_objects.$(ARCH).o         \
    4749$(SRC)/select_images.$(ARCH).o   \
     
    6971$(SRC)/args.$(ARCH).o            \
    7072$(SRC)/help.$(ARCH).o            \
     73$(SRC)/synthetic_mags.$(ARCH).o  \
    7174$(SRC)/plotstuff.$(ARCH).o       \
    7275$(SRC)/liststats.$(ARCH).o       \
  • trunk/Ohana/src/relphot/include/relphot.h

    r35104 r35416  
    44# include <signal.h>
    55# include <pthread.h>
     6
     7# define MARKTIME(MSG,...) {                    \
     8    gettimeofday (&stopTimer, (void *) NULL);   \
     9    float dtime = DTIME (stopTimer, startTimer);        \
     10    fprintf (stderr, MSG, __VA_ARGS__); }
     11
     12# define INITTIME \
     13  struct timeval startTimer, stopTimer; \
     14  gettimeofday (&startTimer, (void *) NULL);
    615
    716/* # define GRID_V1 */
     
    193202int    UpdateAverages;
    194203int    ApplyOffsets;
     204int    SyntheticPhotometry;
    195205
    196206char  *PhotcodeList;
     
    353363void          write_coords        PROTO((Header *header, Coords *coords));
    354364int relphot_objects (int hostID, char *hostpath);
     365int relphot_images (void);
    355366
    356367void relphot_usage (void);
     
    390401
    391402void SetMrelInfoInit (SetMrelInfo *results, int allocLists);
     403
     404int init_synthetic_mags ();
     405int add_synthetic_mags (AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, off_t *Nmeasure, off_t *Nm);
  • trunk/Ohana/src/relphot/src/MosaicOps.c

    r34088 r35416  
    152152}
    153153
    154 # define MARKTIME(MSG,...) { \
    155   float dtime; \
    156   gettimeofday (&stopTimer, (void *) NULL); \
    157   dtime = DTIME (stopTimer, startTimer); \
    158   fprintf (stderr, MSG, __VA_ARGS__); }
    159 
    160154/* find mosaic frames (unique time periods) (NOTE : we do NOT require matching photcodes...)
    161155   this function will also identify the images NOT in the subset which belong to a selected mosaic
     
    167161  char *pname;
    168162
    169   struct timeval startTimer, stopTimer;
    170 
    171163  if (!MOSAIC_ZEROPT) return;
    172164
    173   gettimeofday (&startTimer, (void *) NULL);
     165  INITTIME;
    174166
    175167  /* a 'mosaic' in relphot is (unlike relastro) a virtual concept: there is no
     
    264256    }
    265257  }
    266   fprintf (stderr, "%d total images, %d overlap skyregion, %d do not overlap, but match overlapping mosaics\n", (int) Nimage, (int) Nskip, (int) Nmark);
     258  fprintf (stderr, "%d total images, %d overlap skyregion & match selection criteria, %d do not overlap, but match overlapping mosaics\n", (int) Nimage, (int) Nskip, (int) Nmark);
    267259  MARKTIME("find unselected images matching selected mosaics: %f sec\n", dtime);
    268260
  • trunk/Ohana/src/relphot/src/args.c

    r35104 r35416  
    251251    remove_argument (N, &argc, argv);
    252252    MOSAIC_ZEROPT = TRUE;
     253    if (!strcasecmp (MOSAICNAME, "none")) {
     254      fprintf (stderr, "mosaic astrometry selected by MOSAICNAME not defined\n");
     255      exit (2);
     256    }
    253257  }
    254258
     
    315319    remove_argument (N, &argc, argv);
    316320    DophotSelect = TRUE;
     321  }
     322
     323  SyntheticPhotometry = FALSE;
     324  if ((N = get_argument (argc, argv, "-synthphot"))) {
     325    remove_argument (N, &argc, argv);
     326    SyntheticPhotometry = TRUE;
     327    init_synthetic_mags();
    317328  }
    318329
     
    516527  }
    517528
     529  SyntheticPhotometry = FALSE;
     530  if ((N = get_argument (argc, argv, "-synthphot"))) {
     531    remove_argument (N, &argc, argv);
     532    SyntheticPhotometry = FALSE;
     533    init_synthetic_mags();
     534  }
     535
    518536  ImagSelect = FALSE;
    519537  if ((N = get_argument (argc, argv, "-instmag"))) {
  • trunk/Ohana/src/relphot/src/bcatalog.c

    r34405 r35416  
    179179        REALLOCATE (subcatalog[0].measureT, MeasureTiny, NMEASURE);
    180180      }
     181      myAssert (Nmeasure < NMEASURE, "realloc failure");
    181182    }
    182183
     
    204205      continue;
    205206    }
     207
     208    // for w-band photometry (& other cases?) convert gri photometry
     209    // to a synthetic w-band magnitude
     210    add_synthetic_mags (&subcatalog[0].averageT[Naverage],
     211                        &subcatalog[0].secfilt[Nsecfilt*Naverage],
     212                        &subcatalog[0].measureT[Nmeasure],
     213                        &Nmeasure,
     214                        &Nm);
     215    if (Nmeasure == NMEASURE) {
     216      NMEASURE += 1000;
     217      REALLOCATE (subcatalog[0].measureT, MeasureTiny, NMEASURE);
     218    }
     219    myAssert (Nmeasure < NMEASURE, "realloc failure");
    206220
    207221    subcatalog[0].averageT[Naverage].Nmeasure = Nm;
  • trunk/Ohana/src/relphot/src/global_stats.c

    r33963 r35416  
    11# include "relphot.h"
    2 
    3 # define MARKTIME(MSG,...) { \
    4   float dtime; \
    5   gettimeofday (&stopTimer, (void *) NULL); \
    6   dtime = DTIME (stopTimer, startTimer); \
    7   fprintf (stderr, MSG, __VA_ARGS__); }
    82
    93void global_stats (Catalog *catalog, int Ncatalog, FlatCorrectionTable *flatcorr) {
     
    115  StatType stN, stX, stS, imN, imX, imM, imD, msM, msX, msN, msD;
    126
    13   // struct timeval startTimer, stopTimer;
     7  // INITTIME;
    148
    159  fprintf (stderr, "\n");
    1610  fprintf (stderr, "STATS            median     mean    sigma      min      max   Nmeas\n");
    17 
    18   // gettimeofday (&startTimer, (void *) NULL);
    1911
    2012  int Ns;
  • trunk/Ohana/src/relphot/src/load_catalogs.c

    r34642 r35416  
    148148
    149149    char tmpline[1024];
    150     if (VERBOSE)       { snprintf (tmpline, 1024, "%s -v",              command);                    strcpy (command, tmpline); }
    151     if (VERBOSE2)      { snprintf (tmpline, 1024, "%s -vv",             command);                    strcpy (command, tmpline); }
    152     if (RESET)         { snprintf (tmpline, 1024, "%s -reset",          command);                    strcpy (command, tmpline); }
    153     if (RESET_ZEROPTS) { snprintf (tmpline, 1024, "%s -reset-zpts",     command);                    strcpy (command, tmpline); }
    154     if (!KEEP_UBERCAL) { snprintf (tmpline, 1024, "%s -reset-ubercal",  command);                    strcpy (command, tmpline); }
    155     if (DophotSelect)  { snprintf (tmpline, 1024, "%s -dophot %d",      command, DophotValue);       strcpy (command, tmpline); }
    156     if (ImagSelect)    { snprintf (tmpline, 1024, "%s -instmag %f %f",  command, ImagMin, ImagMax);  strcpy (command, tmpline); }
    157     if (MaxDensityUse) { snprintf (tmpline, 1024, "%s -max-density %f", command, MaxDensityValue);   strcpy (command, tmpline); }
     150    if (VERBOSE)             { snprintf (tmpline, 1024, "%s -v",              command);                   strcpy (command, tmpline); }
     151    if (VERBOSE2)            { snprintf (tmpline, 1024, "%s -vv",             command);                   strcpy (command, tmpline); }
     152    if (RESET)               { snprintf (tmpline, 1024, "%s -reset",          command);                   strcpy (command, tmpline); }
     153    if (RESET_ZEROPTS)       { snprintf (tmpline, 1024, "%s -reset-zpts",     command);                   strcpy (command, tmpline); }
     154    if (!KEEP_UBERCAL)       { snprintf (tmpline, 1024, "%s -reset-ubercal",  command);                   strcpy (command, tmpline); }
     155    if (DophotSelect)        { snprintf (tmpline, 1024, "%s -dophot %d",      command, DophotValue);      strcpy (command, tmpline); }
     156    if (ImagSelect)          { snprintf (tmpline, 1024, "%s -instmag %f %f",  command, ImagMin, ImagMax); strcpy (command, tmpline); }
     157    if (MaxDensityUse)       { snprintf (tmpline, 1024, "%s -max-density %f", command, MaxDensityValue);  strcpy (command, tmpline); }
     158    if (SyntheticPhotometry) { snprintf (tmpline, 1024, "%s -synthphot",      command);                   strcpy (command, tmpline); }
     159
    158160    if (TimeSelect) {
    159161      char *tstart = ohana_sec_to_date (TSTART);
  • trunk/Ohana/src/relphot/src/load_images.c

    r33963 r35416  
    11# include "relphot.h"
    2 
    3 # define MARKTIME(MSG,...) { \
    4   float dtime; \
    5   gettimeofday (&stop, (void *) NULL); \
    6   dtime = DTIME (stop, start); \
    7   fprintf (stderr, MSG, __VA_ARGS__); }
    82
    93// This function generates a subset of the images based on selections.  Input db has already
     
    148  off_t      Nimage, Nsubset, Nchar;
    159  off_t     *LineNumber;
    16   struct timeval start, stop;
    1710  char *inSubset;
    1811
     
    2013  SkyList *skylist = NULL;
    2114
    22   gettimeofday (&start, (void *) NULL);
     15  INITTIME;
    2316
    2417  // load the current sky table (layout of all SkyRegions)
     
    9386  }
    9487
    95 # if (1)
     88# if (0)
    9689  FILE *ftest = fopen ("skydump.dat", "w");
    9790  int i;
  • trunk/Ohana/src/relphot/src/relphot.c

    r33963 r35416  
    11# include "relphot.h"
    22
    3 # define MARKTIME(MSG,...) {                    \
    4     float dtime;                                \
    5     gettimeofday (&stop, (void *) NULL);        \
    6     dtime = DTIME (stop, start);                \
    7     fprintf (stderr, MSG, __VA_ARGS__); }
    8 
    93int main (int argc, char **argv) {
    10 
    11   int i, status, Ncatalog;
    12   Catalog *catalog = NULL;
    13   FITS_DB db;
    14   struct timeval start, stop;
    15   SkyList *skylist = NULL;
    16 
    17   gettimeofday (&start, (void *) NULL);
    184
    195  /* get configuration info, args */
     
    3622  }
    3723
    38   /* register database handle with shutdown procedure */
    39   set_db (&db);
    40   db.mode   = dvo_catalog_catmode (CATMODE);
    41   db.format = dvo_catalog_catformat (CATFORMAT);
    42 
    43   /* lock and load the image db table */
    44   status = dvo_image_lock (&db, ImageCat, 60.0, (UPDATE ? LCK_XCLD : LCK_SOFT));
    45   if (!status && UPDATE) {
    46     fprintf (stderr, "error\n");
    47     Shutdown ("ERROR: failure to lock image catalog %s", db.filename);
    48   }
    49   // if the file is missing, db.dbstate will have a value of either:
    50   // LCK_EMPTY (if UPDATE) or LCK_MISSING (if !UPDATE)
    51   if ((db.dbstate == LCK_EMPTY) || (db.dbstate == LCK_MISSING)) {
    52 
    53     // 25.0 is the nominal zero point for measurements in the database
    54     // for all measurements except PHOT_REF:
    55     // measure.M contains: -2.5*log(DN) + 2.5*log(exptime) + 25.0
    56     // for measurements using PHOT_REF:
    57     // measure.M contains: -2.5*log(DN) + 2.5*log(exptime) + True Zero Point (but exptime and ZP are known)
    58     dvo_image_create (&db, 25.0);
    59 
    60     // XXX why are we running relphot on an empty database?
    61   } else {
    62     if (!dvo_image_load (&db, VERBOSE, FALSE)) Shutdown ("can't read image catalog %s", db.filename);
    63   }
    64   MARKTIME("-- load image data: %f sec\n", dtime);
    65 
    66   /* load regions and images based on specified sky patch and/or catalog */
    67   skylist = load_images (&db, UserCatalog, &UserPatch);
    68   MARKTIME("-- load images: %f sec\n", dtime);
    69 
    70   /* unlock, if we can (else, unlocked below) */
    71   if (!UPDATE) dvo_image_unlock (&db);
    72 
    73   // load the flat correction table (if defined)
    74   char flatcorrfile[256];
    75   sprintf (flatcorrfile, "%s/flatcorr.fits", CATDIR);
    76   FlatCorrectionTable *flatcorr = FlatCorrectionLoad (flatcorrfile, VERBOSE);
    77 
    78   if (NLOOP > 0) {
    79     /* load catalog data from region files (hostID is 0 since we are not a client */
    80     catalog = load_catalogs (skylist, &Ncatalog, 0, NULL);
    81     MARKTIME("-- load catalog data: %f sec\n", dtime);
    82  
    83     /* add in a loop over the catalogs calling dvo_catalog_chipcoords */
    84 
    85     /* match measurements with images, mosaics */
    86     initImageBins  (catalog, Ncatalog, TRUE);
    87     MARKTIME("-- make image bins: %f sec\n", dtime);
    88 
    89     initMosaicBins (catalog, Ncatalog, TRUE);
    90     initGridBins   (catalog, Ncatalog);
    91     initMrel (catalog, Ncatalog);
    92 
    93     findImages (catalog, Ncatalog, TRUE);
    94     MARKTIME("-- set up image indexes: %f sec\n", dtime);
    95 
    96     findMosaics (catalog, Ncatalog, TRUE);  /* also sets Grid values */
    97     MARKTIME("-- set up mosaic indexes: %f sec\n", dtime);
    98 
    99     SAVEPLOT = FALSE;
    100 
    101     setExclusions (catalog, Ncatalog, TRUE);
    102 
    103     global_stats (catalog, Ncatalog, flatcorr);
    104 
    105     if (PLOTSTUFF) {
    106       plot_star_coords (catalog, Ncatalog);
    107       // plot_mosaic_fields (catalog);
    108     }
    109 
    110     // if we are measuring the flat-field correction grid, we need to perform a number of iterations first:
    111     if (USE_GRID) {
    112       int star_toofew;
    113 
    114       // until we finish the grid analysis, do not reject stars out-of-hand based on ID_STAR_FEW
    115       // XXX this is kind of poor: need to have a better distinctions about STAR_BAD in setMrel vs getMrel
    116       star_toofew = STAR_TOOFEW;
    117       STAR_TOOFEW = 0;
    118       for (i = 0; i < NGRID; i++) {
    119         STAR_BAD = ID_STAR_POOR;
    120         setMrel  (catalog, Ncatalog, flatcorr);
    121         STAR_BAD  = ID_STAR_POOR | ID_STAR_FEW;
    122         setMgrid (catalog, flatcorr);
    123       }
    124       STAR_BAD  = ID_STAR_POOR | ID_STAR_FEW;
    125       STAR_TOOFEW = star_toofew;
    126     }
    127 
    128     /* determine fit values */
    129     for (i = 0; i < NLOOP; i++) {
    130       if (PLOTSTUFF) {
    131         plot_scatter (catalog, Ncatalog, flatcorr);
    132       }
    133       setMrel  (catalog, Ncatalog, flatcorr); // threaded
    134       if (PLOTSTUFF) {
    135         plot_scatter (catalog, Ncatalog, flatcorr);
    136       }
    137       setMcal  (catalog, FALSE, flatcorr);
    138       setMmos  (catalog, FALSE, flatcorr);
    139       setMgrid (catalog, flatcorr);
    140       MARKTIME("-- set Mrel, Mcal, Mmos, Mgrid : %f sec\n", dtime);
    141    
    142       if (PLOTSTUFF) {
    143         plot_scatter (catalog, Ncatalog, flatcorr);
    144         plot_grid (catalog, flatcorr);
    145         plot_mosaics ();
    146         plot_images ();
    147         plot_stars (catalog, Ncatalog);
    148         plot_chisq (catalog, Ncatalog);
    149       }
    150       // if (i < NLOOP - 1) rationalize_mosaics (catalog, Ncatalog);
    151       // if (i % 6 == 1) rationalize_images ();
    152 
    153       // NOTE : in the past, I was not iterating enough before cleaning.  make sure we do
    154       // at least 8 loops first -- that should get the systematic errors down to the ~1%
    155       // level, even in cases where we have an even split between photometric data and
    156       // data with 1 mag of extinction.
    157 
    158       if ((i > 8) && (i % 8 == 2)) clean_measures (catalog, Ncatalog, FALSE, flatcorr);
    159       if ((i > 8) && (i % 8 == 3)) clean_stars (catalog, Ncatalog);
    160       if ((i > 8) && (i % 8 == 5)) clean_mosaics ();
    161       if ((i > 8) && (i % 8 == 5)) clean_images ();
    162 
    163       // if ((i == 1) || (i == 5) || (i ==  9) || (i == 13)) clean_measures (catalog, Ncatalog, FALSE);
    164       // if ((i == 2) || (i == 6) || (i == 10) || (i == 14)) clean_stars (catalog, Ncatalog);
    165       // if ((i == 4) || (i == 8) || (i == 12) || (i == 16)) clean_mosaics ();
    166       // if ((i == 4) || (i == 8) || (i == 12) || (i == 16)) clean_images ();
    167       if (i % 3 == 2) global_stats (catalog, Ncatalog, flatcorr);
    168       MARKTIME("-- finished loop %d: %f sec\n", i, dtime);
    169     }
    170 
    171     if (PLOTSTUFF) {
    172       plot_scatter (catalog, Ncatalog, flatcorr);
    173       plot_grid (catalog, flatcorr);
    174       plot_mosaics ();
    175       plot_images ();
    176       plot_stars (catalog, Ncatalog);
    177       plot_chisq (catalog, Ncatalog);
    178     }
    179  
    180     if (USE_GRID) dump_grid ();
    181 
    182     /* set Mcal & Mmos for bad images */
    183     setMcal  (catalog, TRUE, flatcorr);
    184     setMmos  (catalog, TRUE, flatcorr);
    185     MARKTIME("-- finalize Mcal values: %f sec\n", dtime);
    186 
    187     setMcalFinal (); // copy per-mosaic calibrations to the images
    188 
    189     if (SAVE_IMAGE_UPDATES) {
    190 
    191       FITS_DB dbX;
    192       off_t *LineNumber;
    193       Image *image, *subset;
    194       off_t Nimage, Nsubset, i, Nx;
    195       char filename[1024];
    196 
    197       gfits_db_init (&dbX);
    198       dbX.lockstate = LCK_XCLD;
    199       dbX.timeout   = 60.0;
    200       dbX.mode      = db.mode;
    201       dbX.format    = db.format;
    202 
    203       snprintf (filename, 1024, "%s.bck", ImageCat);
    204       if (!gfits_db_lock (&dbX, filename)) {
    205         fprintf (stderr, "can't lock backup image image catalog\n");
    206         return (FALSE);
    207       }
    208    
    209       // apply the changes from the image subset to the full table:
    210 
    211       // convert database table to internal structure (binary to Image)
    212       // 'image' points to the same memory as db->ftable->buffer
    213       image = gfits_table_get_Image (&db.ftable, &Nimage, &db.swapped);
    214       if (!image) {
    215         fprintf (stderr, "ERROR: failed to read images\n");
    216         exit (2);
    217       }
    218       gfits_scan (db.ftable.header, "NAXIS1", OFF_T_FMT, 1,  &Nx);
    219 
    220       subset = getimages (&Nsubset, &LineNumber);
    221       for (i = 0; i < Nsubset; i++) {
    222         if (LineNumber[i] == -1) continue;
    223         memcpy (&image[LineNumber[i]], &subset[i], Nx);
    224       }
    225 
    226       // copy Images.dat data (all or only the subset / vtable elements?)  I think I need to dump
    227       // the entire Image table, but with the updates in place I think this says: re-work the
    228       // ftable/vtable usage in this program to be more sensible...
    229       gfits_copy_header (&db.header,  &dbX.header);
    230       gfits_copy_matrix (&db.matrix,  &dbX.matrix);
    231       gfits_copy_header (&db.theader, &dbX.theader);
    232       gfits_copy_ftable (&db.ftable,  &dbX.ftable);
    233 
    234       dbX.ftable.header = &dbX.theader;
    235       dbX.virtual = FALSE;
    236 
    237       // save Images.dat using the copied structure
    238       if (UPDATE_CATFORMAT) {
    239         // ensure the db format is updated
    240         dbX.format = dvo_catalog_catformat (UPDATE_CATFORMAT);
    241         char photcodeFile[1024];
    242         sprintf (photcodeFile, "%s/Photcodes.dat", CATDIR);
    243         SavePhotcodesFITS (photcodeFile);
    244       }
    245       dvo_image_save (&dbX, VERBOSE);
    246       dvo_image_unlock (&dbX);
    247       MARKTIME("-- save Image.dat.bck: %f sec\n", dtime);
    248     }
    249 
    250     /* at this point, we have correct cal coeffs in the image/mosaic structures */
    251     for (i = 0; i < Ncatalog; i++) {
    252       free_tiny_values (&catalog[i]);
    253       dvo_catalog_free (&catalog[i]);
    254     }
    255     freeImageBins (Ncatalog, TRUE);
    256     freeMosaicBins (Ncatalog, TRUE);
    257     freeGridBins (Ncatalog);
    258 
    259   } // (NLOOP > 0) : this loop determines the offsets per chip
    260 
    261   reload_images (&db);
    262 
    263   // only change the real database files if -update is requested
    264   if (!UPDATE) exit (0);
    265  
    266   /* load catalog data from region files, update Mrel include all data */
    267   reload_catalogs (skylist, flatcorr, 0, NULL);
    268   MARKTIME("-- updated all catalogs: %f sec\n", dtime);
    269 
    270   if (UPDATE_CATFORMAT) {
    271     // ensure the db format is updated
    272     db.format = dvo_catalog_catformat (UPDATE_CATFORMAT);
    273   }
    274   dvo_image_update (&db, VERBOSE);
    275   dvo_image_unlock (&db);
     24  relphot_images ();
    27625
    27726  exit (0);
  • trunk/Ohana/src/relphot/src/select_images.c

    r34642 r35416  
    1717off_t getRegionStartByRA (double R, double *Rref, off_t Nregions);
    1818
    19 # define MARKTIME(MSG,...) { \
    20   float dtime; \
    21   gettimeofday (&stop, (void *) NULL); \
    22   dtime = DTIME (stop, start); \
    23   fprintf (stderr, MSG, __VA_ARGS__); }
    24 
    2519Image *select_images (SkyList *skylist, Image *timage, off_t Ntimage, char *inSubset, off_t **LineNumber, off_t *Nimage, SkyRegion *region) {
    2620 
     
    3125  double Ri[5], Di[5], Xi[5], Yi[5];
    3226  Coords tcoords;
    33   struct timeval start, stop;
    3427 
    3528  if (skylist[0].Nregions < 1) {
     
    4033  }
    4134
    42   gettimeofday (&start, (void *) NULL);
     35  INITTIME;
    4336
    4437  // the comparison is made in the catalog local projection. below we set crval1,2
     
    8275  }
    8376
    84 # if (1)
     77# if (0)
    8578  // XXX quick test of the dec bands:
    8679  FILE *fout = fopen ("dec.bands.dat", "w");
     
    132125    // this adds 1.3 sec for 3M images
    133126    if (!FindMosaicForImage (timage, Ntimage, i)) {
    134       fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);
     127      if (VERBOSE2) fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);
    135128      continue;
    136129    }
  • trunk/Ohana/src/uniphot/src/match_flatcorr_to_images.c

    r33654 r35416  
    4343  for (i = 0; i < Nimage; i++) {
    4444    if (!image[i].photcode) continue; // skip PHU images
     45    if (image[i].photcode > maxCode) continue; // skip PHU images
    4546
    4647    int found = FALSE;
Note: See TracChangeset for help on using the changeset viewer.