IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36630 for trunk


Ignore:
Timestamp:
Apr 1, 2014, 12:03:17 PM (12 years ago)
Author:
eugene
Message:

merge changes from EAM dev branches 20140206 (relastro, relphot extensions to parallel processing)

Location:
trunk
Files:
57 edited
24 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/Ohana/src/libdvo/Makefile

    r36490 r36630  
    103103$(SRC)/ImageMetadata.$(ARCH).o \
    104104$(SRC)/ImageOps.$(ARCH).o               \
     105$(SRC)/RegionHostTable.$(ARCH).o                \
    105106$(SRC)/match_image.$(ARCH).o            \
    106107$(SRC)/db_utils.$(ARCH).o               \
  • trunk/Ohana/src/libdvo/include/dvo.h

    r36528 r36630  
    285285} HostTable;
    286286
     287// A RegionHost processes data for some region in parallel with other regions
     288typedef struct RegionHostInfo {
     289  double Rmin;        // (Rmin,Rmax),(Dmin,Dmax) arehard RA,DEC boundaries of the
     290  double Rmax;        // region for which each host is responsible.  A given host
     291  double Dmin;        // calibrates the images for which the fiducial point (center)
     292  double Dmax;        // lands in the region, and all objects in the region
     293
     294  double RminCat;      // (RminCat,RmaxCat),(DminCat,DmaxCat) are the region for which
     295  double RmaxCat;      // the catalogs need to be loaded : this is the outer bounds
     296  double DminCat;      // of the region containing all images completely
     297  double DmaxCat;
     298
     299  char *hostname;
     300
     301  int hostID;                 // remove machine ID in SkyTable
     302  int stdio[3];               // fd's for communication with the remote host
     303  int pid;                    // remote process ID
     304  int status;
     305  IOBuffer stdout;
     306  IOBuffer stderr;
     307
     308  off_t Nimage;
     309  off_t NIMAGE;
     310  Image *image;
     311  off_t *imseq;
     312
     313  int *neighbors;             // list of neighbor index values
     314  int Nneighbors;             // number of neighbors
     315  char isNeighbor;            // TRUE if I am a neighbor to the current region host
     316} RegionHostInfo;
     317
     318typedef struct {
     319  double Rmin;
     320  double Rmax;
     321  double Dmin;
     322  double Dmax;
     323
     324  int Nhosts;
     325  RegionHostInfo *hosts;
     326  short *index;
     327} RegionHostTable;
     328
    287329// special-case function:
    288330CMF_PS1_V2 *gfits_table_get_CMF_PS1_V1_Alt (FTable *ftable, off_t *Ndata, char *swapped);
     
    385427  uint32_t       flags;
    386428  int            catID;
     429  int            objID;
     430  int            nOwn;
    387431} AverageTiny;
    388432
     
    410454  short          dYccd;
    411455  short          dRsys;
     456  char           myDet;
    412457} MeasureTiny;
    413458
     
    555600  float *X;
    556601  float *Y;
     602  int   *nOwn; // relastro uses this to count owned detections per object
    557603
    558604} Catalog;
     
    616662float PhotInst (Measure *measure);
    617663float PhotCat (Measure *measure);
    618 float PhotAper (Measure *measure);
    619 float PhotKron (Measure *measure);
    620664float PhotSys (Measure *measure, Average *average, SecFilt *secfilt);
    621665float PhotRel (Measure *measure, Average *average, SecFilt *secfilt);
     
    623667float PhotAve (PhotCode *code, Average *average, SecFilt *secfilt);
    624668float PhotRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure);
     669float PhotAveErr (PhotCode *code, Average *average, SecFilt *secfilt);
     670
     671float PhotAperInst (Measure *measure);
     672float PhotAperCat (Measure *measure);
     673float PhotAperSys (Measure *measure, Average *average, SecFilt *secfilt);
     674float PhotAperRel (Measure *measure, Average *average, SecFilt *secfilt);
     675float PhotAperCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code);
     676float PhotAperAve (PhotCode *code, Average *average, SecFilt *secfilt);
     677float PhotAperRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure);
     678
     679float PhotKronInst (Measure *measure);
     680float PhotKronCat (Measure *measure);
     681float PhotKronSys (Measure *measure, Average *average, SecFilt *secfilt);
     682float PhotKronRel (Measure *measure, Average *average, SecFilt *secfilt);
     683float PhotKronCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code);
     684float PhotKronAve (PhotCode *code, Average *average, SecFilt *secfilt);
     685float PhotKronRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure);
     686float PhotKronAveErr (PhotCode *code, Average *average, SecFilt *secfilt);
     687
    625688float PhotXm (PhotCode *code, Average *average, SecFilt *secfilt);
    626 float PhotdM (PhotCode *code, Average *average, SecFilt *secfilt);
    627 
    628 float PhotAperInst (Measure *measure);
    629 float PhotAperAve (PhotCode *code, Average *average, SecFilt *secfilt);
    630 float PhotKronInst (Measure *measure);
    631 float PhotKronAve (PhotCode *code, Average *average, SecFilt *secfilt);
    632 float PhotKronAveErr (PhotCode *code, Average *average, SecFilt *secfilt);
    633689
    634690float PhotZeroPoint (Measure *measure, Average *average, SecFilt *secfilt);
     
    855911void dvo_measureT_init (MeasureTiny *measure);
    856912
     913void InitRegionHosts (RegionHostInfo *hosts, int Nhosts, int NHOSTS);
     914void FreeRegionHosts (RegionHostInfo *hosts, int Nhosts);
     915void FreeRegionHostTable (RegionHostTable *table);
     916RegionHostTable *RegionHostTableLoad (char *catdir, char *rootname);
     917int RegionHostTableWaitJobs (RegionHostTable *regionHosts, char *file, int lineno);
     918int RegionHostTableWaitJobsGetIO (RegionHostTable *regionHosts, char *file, int lineno, int VERBOSE);
     919int RegionHostFindNeighbors (RegionHostTable *table, int Nhost);
     920
    857921# endif // DVO_H
  • trunk/Ohana/src/libdvo/include/dvodb.h

    r36490 r36630  
    2323/* magnitude types */
    2424enum {MAG_NONE,
    25       MAG_INST,
    26       MAG_CAT,
    27       MAG_APER,
    28       MAG_APER_INST,
    29       MAG_KRON,
    30       MAG_KRON_INST,
    31       MAG_KRON_ERR,
    32       MAG_SYS,
    33       MAG_REL,
    34       MAG_CAL,
     25
     26      // these magnitude types are from the measurement table (or derived therein)
     27      // the following imply PSF magnitudes:
     28      MAG_INST, // -2.5*log(DN) [ie, not DN/sec]
     29      MAG_CAT,  // MAG_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1)
     30      MAG_SYS,  // MAG_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode]
     31      MAG_REL,  // MAG_SYS - Mcal [specific zero point for image]
     32      MAG_CAL,  // MAG_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode]
     33      MAG_ERR,  // error on PSF MAG
     34
     35      // the following imply APERTURE magnitudes:
     36      MAG_APER_INST, // -2.5*log(DN) [ie, not DN/sec]
     37      MAG_APER_CAT,  // MAG_APER_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1)
     38      MAG_APER_SYS,  // MAG_APER_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode]
     39      MAG_APER_REL,  // MAG_APER_SYS - Mcal [specific zero point for image]
     40      MAG_APER_CAL,  // MAG_APER_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode]
     41      MAG_APER_ERR,  // error on APER MAG (if known, else psf error)
     42      MAG_APER,      // in mextract -> MAG_APER_REL, in avextract -> MAG_APER_AVE
     43
     44      // the following imply KRON magnitudes:
     45      MAG_KRON_INST, // -2.5*log(DN) [ie, not DN/sec]
     46      MAG_KRON_CAT,  // MAG_KRON_INST + 2.5*log(exptime) + C_lambda + K_lambda*(airmass - 1)
     47      MAG_KRON_SYS,  // MAG_KRON_CAT + \sum_i A_i * (color_i - color_o) [color correction for measure photcode]
     48      MAG_KRON_REL,  // MAG_KRON_SYS - Mcal [specific zero point for image]
     49      MAG_KRON_CAL,  // MAG_KRON_REL + \sum_i A_i * (color_i - color_o) [color correction for average photcode]
     50      MAG_KRON_ERR,  // error on KRON MAG
     51      MAG_KRON,      // in mextract -> MAG_KRON_REL, in avextract -> MAG_KRON_AVE
     52
     53      // these magnitude types are from the average (secfilt) table:
     54      // the following imply PSF magnitudes (or fluxes)
    3555      MAG_AVE,
    3656      MAG_REF,
    37       MAG_ERR,
    3857      MAG_STDEV,
    3958      MAG_AVE_ERR,
     59      MAG_CHISQ,
     60      MAG_20,
     61      MAG_80,
     62      MAG_FLUX_PSF,
     63      MAG_FLUX_PSF_ERR,
     64
     65      // the following imply APERTURE magnitudes:
     66      MAG_APER_AVE,
     67      MAG_APER_REF,
     68
     69      // the following imply KRON magnitudes or fluxes:
     70      MAG_KRON_AVE,
     71      MAG_KRON_REF,
     72      MAG_FLUX_KRON,
     73      MAG_FLUX_KRON_ERR,
     74
     75      // other secfilt fields of interest
    4076      MAG_PHOT_FLAGS,
    41       MAG_CHISQ,
    4277      MAG_NCODE,
    4378      MAG_NPHOT,
    44       MAG_20,
    45       MAG_80,
    4679      MAG_UC_DIST,
    4780      MAG_STACK_DET_ID,
    48       MAG_FLUX_PSF,
    49       MAG_FLUX_PSF_ERR,
    50       MAG_FLUX_KRON,
    51       MAG_FLUX_KRON_ERR,
    5281};
    5382
  • trunk/Ohana/src/libdvo/src/dbExtractAverages.c

    r36528 r36630  
    211211            }
    212212          } else {
    213             value.Flt = PhotdM (field->photcode, average, secfilt);
     213            value.Flt = PhotAveErr (field->photcode, average, secfilt);
    214214          }
    215215          break;
     
    244244
    245245        case MAG_APER:
     246        case MAG_APER_AVE:
    246247          value.Flt = PhotAperAve (field->photcode, average, secfilt);
    247248          break;
    248249
     250        case MAG_APER_REF:
     251          value.Flt = PhotAperRef (field->photcode, average, secfilt, measure);
     252          break;
     253
    249254        case MAG_KRON:
     255        case MAG_KRON_AVE:
    250256          value.Flt = PhotKronAve (field->photcode, average, secfilt);
     257          break;
     258
     259        case MAG_KRON_REF:
     260          value.Flt = PhotKronRef (field->photcode, average, secfilt, measure);
    251261          break;
    252262
     
    283293      break;
    284294    case AVE_dMAG:
    285       value.Flt = PhotdM (field->photcode, average, secfilt);
     295      value.Flt = PhotAveErr (field->photcode, average, secfilt);
    286296      break;
    287297    case AVE_Xm:
  • trunk/Ohana/src/libdvo/src/dbExtractMeasures.c

    r35508 r36630  
    123123          case MAG_REL:
    124124          case MAG_CAL:
    125           case MAG_APER:
     125          case MAG_ERR:
     126
    126127          case MAG_APER_INST:
    127           case MAG_KRON:
     128          case MAG_APER_CAT:
     129          case MAG_APER_SYS:
     130          case MAG_APER_REL:
     131          case MAG_APER_CAL:
     132          case MAG_APER_ERR:
     133
    128134          case MAG_KRON_INST:
     135          case MAG_KRON_CAT:
     136          case MAG_KRON_SYS:
     137          case MAG_KRON_REL:
     138          case MAG_KRON_CAL:
    129139          case MAG_KRON_ERR:
    130           case MAG_ERR:
     140
    131141          case MAG_PHOT_FLAGS:
    132142            equiv = myEquiv;
     
    137147          case MAG_AVE:
    138148          case MAG_REF:
     149          case MAG_STDEV:
     150          case MAG_AVE_ERR:
    139151          case MAG_CHISQ:
    140           case MAG_AVE_ERR:
     152          case MAG_FLUX_PSF:
     153          case MAG_FLUX_PSF_ERR:
     154
     155          case MAG_APER_AVE:
     156
     157          case MAG_KRON_AVE:
     158          case MAG_FLUX_KRON:
     159          case MAG_FLUX_KRON_ERR:
     160
     161          case MAG_20:
     162          case MAG_80:
     163          case MAG_UC_DIST:
     164          case MAG_STACK_DET_ID:
     165
    141166          case MAG_NCODE:
    142167          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:
    147168            equiv = field->photcode;
    148169            goto valid_photcode;
     
    178199          value.Flt = PhotRef  (equiv, average, secfilt, measure);
    179200          break;
    180         case MAG_APER:
    181           value.Flt = PhotAper (measure);
    182           break;
     201        case MAG_ERR:
     202          value.Flt = measure[0].dM;
     203          break;
     204        case MAG_AVE_ERR:
     205          value.Flt = PhotAveErr  (equiv, average, secfilt);
     206          break;
     207
    183208        case MAG_APER_INST:
    184209          value.Flt = PhotAperInst (measure);
    185210          break;
    186         case MAG_KRON:
    187           value.Flt = PhotKron (measure);
    188           break;
     211        case MAG_APER_CAT:
     212          value.Flt = PhotAperCat (measure);
     213          break;
     214        case MAG_APER_SYS:
     215          value.Flt = PhotAperSys (measure, average, secfilt);
     216          break;
     217        case MAG_APER:
     218        case MAG_APER_REL:
     219          value.Flt = PhotAperRel (measure, average, secfilt);
     220          break;
     221        case MAG_APER_CAL:
     222          value.Flt = PhotAperCal (measure, average, secfilt, measure, equiv);
     223          break;
     224        case MAG_APER_AVE:
     225          value.Flt = PhotAperAve (equiv, average, secfilt);
     226          break;
     227        case MAG_APER_REF:
     228          value.Flt = PhotAperRef (equiv, average, secfilt, measure);
     229          break;
     230        case MAG_APER_ERR:
     231          value.Flt = measure[0].dM;
     232          break;
     233
    189234        case MAG_KRON_INST:
    190235          value.Flt = PhotKronInst (measure);
    191236          break;
     237        case MAG_KRON_CAT:
     238          value.Flt = PhotKronCat (measure);
     239          break;
     240        case MAG_KRON_SYS:
     241          value.Flt = PhotKronSys (measure, average, secfilt);
     242          break;
     243        case MAG_KRON:
     244        case MAG_KRON_REL:
     245          value.Flt = PhotKronRel (measure, average, secfilt);
     246          break;
     247        case MAG_KRON_CAL:
     248          value.Flt = PhotKronCal (measure, average, secfilt, measure, equiv);
     249          break;
     250        case MAG_KRON_AVE:
     251          value.Flt = PhotKronAve (equiv, average, secfilt);
     252          break;
     253        case MAG_KRON_REF:
     254          value.Flt = PhotKronRef (equiv, average, secfilt, measure);
     255          break;
    192256        case MAG_KRON_ERR:
    193           value.Flt = measure[0].dMkron;
    194           break;
    195         case MAG_ERR:
    196           value.Flt = measure[0].dM;
    197           break;
    198         case MAG_AVE_ERR:
    199           value.Flt = PhotdM  (equiv, average, secfilt);
    200           break;
     257          value.Flt = measure[0].dMkron;
     258          break;
     259
    201260        case MAG_PHOT_FLAGS:
    202261          if ((field->photcode->type == PHOT_REF) || (field->photcode->type == PHOT_DEP)) {
    203262            value.Int = measure[0].photFlags;
    204           } else {
    205             value.Int = 0;
    206263          }
    207264          break;
    208         case MAG_CHISQ:
    209           value.Flt = PhotXm  (equiv, average, secfilt);
    210           break;
     265
    211266        case MAG_NCODE:
    212           if (equiv == NULL) {
    213             value.Int = 0;
    214             break;
    215           }
     267          if (equiv == NULL) break;
    216268          Nsec = GetPhotcodeNsec (equiv->code);
    217269          if (Nsec == -1) break;
     
    219271          break;
    220272        case MAG_NPHOT:
    221           if (equiv == NULL) {
    222             value.Int = 0;
    223             break;
    224           }
     273          if (equiv == NULL) break;
    225274          Nsec = GetPhotcodeNsec (equiv->code);
    226275          if (Nsec == -1) break;
    227276          value.Int = secfilt[Nsec].Nused;
    228277          break;
     278
     279        case MAG_CHISQ:
     280          value.Flt = PhotXm (equiv, average, secfilt);
     281          break;
     282        case MAG_STDEV:
     283          value.Flt = PhotMstdev (equiv, average, secfilt);
     284          break;
     285        case MAG_20:
     286          value.Flt = PhotM20 (equiv, average, secfilt);
     287          break;
     288        case MAG_80:
     289          value.Flt = PhotM80 (equiv, average, secfilt);
     290          break;
     291        case MAG_UC_DIST:
     292          value.Flt = PhotUCdist (equiv, average, secfilt);
     293          break;
     294
    229295        case MAG_FLUX_PSF:
    230296          value.Flt = PhotAveFluxPSF (field->photcode, average, secfilt);
     
    531597          fieldc = MatchFieldMetadata (measure[0].imageID);
    532598        } else {
    533           fprintf (stderr, "non-parallel Xmos broken\n");
    534           abort();
     599          // fprintf (stderr, "non-parallel Xmos broken\n");
     600          // abort();
    535601          // fieldc = MatchField (measure[0].t, measure[0].photcode);
     602          fieldc = MatchFieldMetadata (measure[0].imageID);
    536603        }
    537604        if (fieldc == NULL) break;
     
    547614          fieldc = MatchFieldMetadata (measure[0].imageID);
    548615        } else {
    549           fprintf (stderr, "non-parallel Xmos broken\n");
    550           abort();
     616          // fprintf (stderr, "non-parallel Xmos broken\n");
     617          // abort();
    551618          // fieldc = MatchField (measure[0].t, measure[0].photcode);
     619          fieldc = MatchFieldMetadata (measure[0].imageID);
    552620        }
    553621        if (fieldc == NULL) break;
     
    564632          mosaic = MatchMosaicMetadata (measure[0].imageID);
    565633        } else {
    566           fprintf (stderr, "non-parallel Xmos broken\n");
    567           abort();
    568           mosaic = MatchMosaic (measure[0].t, measure[0].photcode);
     634          // fprintf (stderr, "non-parallel Xmos broken\n");
     635          // abort();
     636          // mosaic = MatchMosaic (measure[0].t, measure[0].photcode);
     637          mosaic = MatchMosaicMetadata (measure[0].imageID);
    569638        }
    570639        if (mosaic == NULL) break;
     
    580649          mosaic = MatchMosaicMetadata (measure[0].imageID);
    581650        } else {
    582           fprintf (stderr, "non-parallel Xmos broken\n");
    583           abort();
    584           mosaic = MatchMosaic (measure[0].t, measure[0].photcode);
     651          // fprintf (stderr, "non-parallel Xmos broken\n");
     652          // abort();
     653          // mosaic = MatchMosaic (measure[0].t, measure[0].photcode);
     654          mosaic = MatchMosaicMetadata (measure[0].imageID);
    585655        }
    586656        if (mosaic == NULL) break;
  • trunk/Ohana/src/libdvo/src/dbFields.c

    r36084 r36630  
    3030int GetMagMode (char *string) {
    3131
     32  // these all imply PSF mags:
    3233  if (!strcasecmp (string, "inst"))        return (MAG_INST);
    3334  if (!strcasecmp (string, "cat"))         return (MAG_CAT);
     
    3738  if (!strcasecmp (string, "ave"))         return (MAG_AVE);
    3839  if (!strcasecmp (string, "ref"))         return (MAG_REF);
     40  if (!strcasecmp (string, "err"))         return (MAG_ERR);
     41  if (!strcasecmp (string, "aveerr"))      return (MAG_AVE_ERR);
     42
     43  // these are explicit PSF mags:
     44  if (!strcasecmp (string, "psf_inst"))    return (MAG_INST);
     45  if (!strcasecmp (string, "psf_cat"))     return (MAG_CAT);
     46  if (!strcasecmp (string, "psf_sys"))     return (MAG_SYS);
     47  if (!strcasecmp (string, "psf_rel"))     return (MAG_REL);
     48  if (!strcasecmp (string, "psf_cal"))     return (MAG_CAL);
     49  if (!strcasecmp (string, "psf_ave"))     return (MAG_AVE);
     50  if (!strcasecmp (string, "psf_ref"))     return (MAG_REF);
     51  if (!strcasecmp (string, "psf_err"))     return (MAG_ERR);
     52  if (!strcasecmp (string, "psf_aveerr"))  return (MAG_AVE_ERR);
     53
     54  // these are aper mags:
    3955  if (!strcasecmp (string, "ap"))          return (MAG_APER);
    4056  if (!strcasecmp (string, "aper"))        return (MAG_APER);
    4157  if (!strcasecmp (string, "aperinst"))    return (MAG_APER_INST);
    4258  if (!strcasecmp (string, "aper_inst"))   return (MAG_APER_INST);
     59  if (!strcasecmp (string, "aper_cat"))    return (MAG_APER_CAT);
     60  if (!strcasecmp (string, "aper_sys"))    return (MAG_APER_SYS);
     61  if (!strcasecmp (string, "aper_rel"))    return (MAG_APER_REL);
     62  if (!strcasecmp (string, "aper_cal"))    return (MAG_APER_CAL);
     63  if (!strcasecmp (string, "aper_ave"))    return (MAG_APER_AVE);
     64  if (!strcasecmp (string, "aper_ref"))    return (MAG_APER_REF);
     65  if (!strcasecmp (string, "aper_err"))    return (MAG_APER_ERR);
     66
     67  // these are kron mags:
    4368  if (!strcasecmp (string, "kron"))        return (MAG_KRON);
     69  if (!strcasecmp (string, "kron_inst"))   return (MAG_KRON_INST);
     70  if (!strcasecmp (string, "kron_cat"))    return (MAG_KRON_CAT);
     71  if (!strcasecmp (string, "kron_sys"))    return (MAG_KRON_SYS);
     72  if (!strcasecmp (string, "kron_rel"))    return (MAG_KRON_REL);
     73  if (!strcasecmp (string, "kron_cal"))    return (MAG_KRON_CAL);
     74  if (!strcasecmp (string, "kron_ave"))    return (MAG_KRON_AVE);
     75  if (!strcasecmp (string, "kron_ref"))    return (MAG_KRON_REF);
     76  if (!strcasecmp (string, "kron_err"))    return (MAG_KRON_ERR);
    4477  if (!strcasecmp (string, "kroninst"))    return (MAG_KRON_INST);
    45   if (!strcasecmp (string, "kron_inst"))   return (MAG_KRON_INST);
    4678  if (!strcasecmp (string, "kronerr"))     return (MAG_KRON_ERR);
    47   if (!strcasecmp (string, "err"))         return (MAG_ERR);
    48   if (!strcasecmp (string, "aveerr"))      return (MAG_AVE_ERR);
     79
     80  // other fields:
    4981  if (!strcasecmp (string, "photflags"))   return (MAG_PHOT_FLAGS);
    5082  if (!strcasecmp (string, "flags"))       return (MAG_PHOT_FLAGS);
  • trunk/Ohana/src/libdvo/src/dvo_catalog.c

    r35416 r36630  
    119119  average->measureOffset   = -1;
    120120  average->catID           = 0;
     121  average->nOwn            = 0;
    121122}
    122123
     
    242243 measure->dYccd     = 0;
    243244 measure->dRsys     = 0;
     245 measure->myDet     = FALSE;
    244246}
    245247
  • trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V4.c

    r36528 r36630  
    549549}
    550550
     551// XXX note that there are 2 bad versions of PS1_V4 : the other one does have have PSF_QF_PERFECT, but has PAD instead
    551552int gfits_convert_Measure_PS1_V4alt (Measure_PS1_V4alt *data, off_t size, off_t nitems) {
    552553
     
    708709# ifdef BYTE_SWAP
    709710  byte = (unsigned char *) data;
    710   for (i = 0; i < nitems; i++, byte += 129) {
     711  for (i = 0; i < nitems; i++, byte += 120) {
    711712    /** BYTE SWAP **/
    712713    SWAP_DBLE (0); // RA
     
    754755  Ncols = ftable[0].header[0].Naxis[0];
    755756  if (Ncols != 120) {
    756     fprintf (stderr, "ERROR: mis-match in table size: width is %d but should be %d bytes\n", Ncols, 176);
     757    fprintf (stderr, "ERROR: mis-match in table size: width is %d but should be %d bytes\n", Ncols, 120);
    757758    return NULL;
    758759  }
  • trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c

    r36528 r36630  
    169169}
    170170
     171// returns Nsec if code is PRI/SEC, else -1
    171172int GetPhotcodeNsec (int code) {
    172173 
     
    259260}
    260261
    261 float PhotAper (Measure *measure) {
    262 
    263   int Np;
    264   float Mcat;
    265   PhotCode *code;
    266 
    267   Np = photcodes[0].hashcode[measure[0].photcode];
    268   if (Np == -1) return (NAN);
    269 
    270   if (photcodes[0].code[Np].type == PHOT_REF) {
    271     Mcat = measure[0].Map;
    272     return (Mcat);
    273   }
    274   code = &photcodes[0].code[Np];
    275   Mcat = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C;
    276  
    277   return (Mcat);
    278 }
    279 
    280 float PhotAperInst (Measure *measure) {
    281 
    282   int Np;
    283   float Minst;
    284 
    285   Np = photcodes[0].hashcode[measure[0].photcode];
    286   if (Np == -1) return (NAN);
    287 
    288   if (photcodes[0].code[Np].type == PHOT_REF) {
    289     Minst = measure[0].Map;
    290     return (Minst);
    291   }
    292   Minst = measure[0].Map - measure[0].dt - ZERO_POINT;
    293  
    294   return (Minst);
    295 }
    296 
    297 float PhotKron (Measure *measure) {
    298 
    299   int Np;
    300   float Mcat;
    301   PhotCode *code;
    302 
    303   Np = photcodes[0].hashcode[measure[0].photcode];
    304   if (Np == -1) return (NAN);
    305 
    306   if (photcodes[0].code[Np].type == PHOT_REF) {
    307     Mcat = measure[0].Mkron;
    308     return (Mcat);
    309   }
    310   code = &photcodes[0].code[Np];
    311   Mcat = measure[0].Mkron - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C;
    312  
    313   return (Mcat);
    314 }
    315 
    316 float PhotKronInst (Measure *measure) {
    317 
    318   int Np;
    319   float Minst;
    320 
    321   Np = photcodes[0].hashcode[measure[0].photcode];
    322   if (Np == -1) return (NAN);
    323 
    324   if (photcodes[0].code[Np].type == PHOT_REF) {
    325     Minst = measure[0].Mkron;
    326     return (Minst);
    327   }
    328   Minst = measure[0].Mkron - measure[0].dt - ZERO_POINT;
    329  
    330   return (Minst);
    331 }
    332 
    333262float PhotSys (Measure *measure, Average *average, SecFilt *secfilt) {
    334263
     
    362291}
    363292
    364 float PhotZeroPoint (Measure *measure, Average *average, SecFilt *secfilt) {
    365 
    366   int Np;
    367   float ZP;
    368   PhotCode *code;
    369 
    370   Np = photcodes[0].hashcode[measure[0].photcode];
    371   if (Np == -1) return (NAN);
    372 
    373   if (photcodes[0].code[Np].type == PHOT_REF) {
    374     ZP = 0.0;
    375     return (ZP);
    376   }
    377   code = &photcodes[0].code[Np];
    378   ZP = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C;
    379 
    380   return (ZP);
    381 }
    382 
    383293float PhotRel (Measure *measure, Average *average, SecFilt *secfilt) {
    384294
     
    444354  Mcal += Mcol;
    445355  return (Mcal);
     356}
     357
     358/***/
     359float PhotAve (PhotCode *code, Average *average, SecFilt *secfilt) {
     360
     361  int Ns;
     362  float Mave;
     363
     364  if (code == NULL) return NAN;
     365
     366  Ns = photcodes[0].hashNsec[code[0].code];
     367  Mave = (Ns == -1) ? NAN : secfilt[Ns].M;
     368  return (Mave);
     369}
     370
     371/* return calibrated magnitude from average/secfilt for given photcode */
     372float PhotRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure) {
     373
     374  int i, Ns;
     375  float Mave, Mref, Mcol, mc;
     376  double Mc;
     377
     378  if (code == NULL) return NAN;
     379
     380  Ns = photcodes[0].hashNsec[code[0].code];
     381  Mave = (Ns == -1) ? NAN : secfilt[Ns].M;
     382  Mref = Mave + SCALE*code[0].C;
     383
     384  mc = PhotColorForCode (average, secfilt, measure, code);
     385  if (isnan(mc)) return (Mref);
     386  mc = mc - SCALE*code[0].dX;
     387
     388  Mc = mc;
     389  Mcol = 0;
     390  for (i = 0; i < code[0].Nc; i++) {
     391    Mcol += code[0].X[i]*Mc;
     392    Mc *= mc;    /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */
     393  }
     394  Mref += Mcol;
     395  return (Mref);
     396}
     397
     398float PhotAveErr (PhotCode *code, Average *average, SecFilt *secfilt) {
     399
     400  int Ns;
     401  float dM;
     402
     403  if (code == NULL) return NAN;
     404
     405  Ns = photcodes[0].hashNsec[code[0].code];
     406  dM  = (Ns == -1) ? NAN : secfilt[Ns].dM;
     407  return (dM);
     408}
     409
     410/************************************** APERTURE-related Magnitudes ***********************************************/
     411
     412float PhotAperInst (Measure *measure) {
     413
     414  int Np;
     415  float Minst;
     416
     417  Np = photcodes[0].hashcode[measure[0].photcode];
     418  if (Np == -1) return (NAN);
     419
     420  if (photcodes[0].code[Np].type == PHOT_REF) {
     421    Minst = measure[0].Map;
     422    return (Minst);
     423  }
     424  Minst = measure[0].Map - measure[0].dt - ZERO_POINT;
     425 
     426  return (Minst);
     427}
     428
     429float PhotAperCat (Measure *measure) {
     430
     431  int Np;
     432  float Mcat;
     433  PhotCode *code;
     434
     435  Np = photcodes[0].hashcode[measure[0].photcode];
     436  if (Np == -1) return (NAN);
     437
     438  if (photcodes[0].code[Np].type == PHOT_REF) {
     439    Mcat = measure[0].Map;
     440    return (Mcat);
     441  }
     442  code = &photcodes[0].code[Np];
     443  Mcat = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C;
     444 
     445  return (Mcat);
     446}
     447
     448float PhotAperSys (Measure *measure, Average *average, SecFilt *secfilt) {
     449
     450  int i, Np;
     451  float Mcat, Mcol, Msys, mc, Mc;
     452  PhotCode *code;
     453
     454  Np = photcodes[0].hashcode[measure[0].photcode];
     455  if (Np == -1) return (NAN);
     456
     457  if (photcodes[0].code[Np].type == PHOT_REF) {
     458    Mcat = measure[0].Map;
     459    return (Mcat);
     460  }
     461  code = &photcodes[0].code[Np];
     462  Mcat = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C;
     463 
     464  /* for DEP, color must be made of PRI/SEC */
     465  mc = PhotColorForCode (average, secfilt, NULL, code);
     466  if (isnan(mc)) return (Mcat);
     467  mc = mc - SCALE*code[0].dX;
     468
     469  Mc = mc;
     470  Mcol = 0;
     471  for (i = 0; i < code[0].Nc; i++) {
     472    Mcol += code[0].X[i]*Mc;
     473    Mc *= mc;
     474  }
     475  Msys = Mcat + Mcol;
     476  return (Msys);
     477}
     478
     479float PhotAperRel (Measure *measure, Average *average, SecFilt *secfilt) {
     480
     481  int i, Np;
     482  float Mcat, Mcol, Mrel, mc, Mc;
     483  PhotCode *code;
     484
     485  Np = photcodes[0].hashcode[measure[0].photcode];
     486  if (Np == -1) return (NAN);
     487
     488  if (photcodes[0].code[Np].type == PHOT_REF) {
     489    Mcat = measure[0].Map;
     490    return (Mcat);
     491  }
     492  code = &photcodes[0].code[Np];
     493  Mrel = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal;
     494
     495  /* for DEP, color must be made of PRI/SEC */
     496  mc = PhotColorForCode (average, secfilt, NULL, code);
     497  if (isnan(mc)) return (Mrel);
     498  mc = mc - SCALE*code[0].dX;
     499
     500  Mc = mc;
     501  Mcol = 0;
     502  for (i = 0; i < code[0].Nc; i++) {
     503    Mcol += code[0].X[i]*Mc;
     504    Mc *= mc;    /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */
     505  }
     506  Mrel += Mcol;
     507  return (Mrel);
     508}
     509
     510/* return calibrated magnitude from measure for given photcode */
     511float PhotAperCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code) {
     512
     513  int i, Np;
     514  float Mcal, Mrel, Mcol, mc, Mc;
     515
     516  if (code == NULL) return NAN;
     517
     518  /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */
     519  Np = photcodes[0].hashcode[thisone[0].photcode];
     520  if (Np == -1) return (NAN);
     521
     522  if (photcodes[0].code[Np].type == PHOT_REF) {
     523    Mrel = thisone[0].Map;
     524    return (Mrel);
     525  }
     526  if (code[0].code != photcodes[0].code[Np].equiv) return (NAN);
     527
     528  Mcal = PhotAperRel (thisone, average, secfilt) + SCALE*code[0].C;
     529
     530  mc = PhotColorForCode (average, secfilt, measure, code);
     531  if (isnan(mc)) return (Mcal);
     532  mc = mc - SCALE*code[0].dX;
     533
     534  Mc = mc;
     535  Mcol = 0;
     536  for (i = 0; i < code[0].Nc; i++) {
     537    Mcol += code[0].X[i]*Mc;
     538    Mc *= mc;
     539  }
     540  Mcal += Mcol;
     541  return (Mcal);
     542}
     543
     544float PhotAperAve (PhotCode *code, Average *average, SecFilt *secfilt) {
     545
     546  int Ns;
     547  float Maper;
     548
     549  if (code == NULL) return NAN;
     550
     551  Ns = photcodes[0].hashNsec[code[0].code];
     552  Maper = (Ns == -1) ? NAN : secfilt[Ns].Map;
     553  return (Maper);
     554}
     555
     556/* return calibrated magnitude from average/secfilt for given photcode */
     557float PhotAperRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure) {
     558
     559  int i, Ns;
     560  float Mave, Mref, Mcol, mc;
     561  double Mc;
     562
     563  if (code == NULL) return NAN;
     564
     565  Ns = photcodes[0].hashNsec[code[0].code];
     566  Mave = (Ns == -1) ? NAN : secfilt[Ns].Map;
     567  Mref = Mave + SCALE*code[0].C;
     568
     569  mc = PhotColorForCode (average, secfilt, measure, code);
     570  if (isnan(mc)) return (Mref);
     571  mc = mc - SCALE*code[0].dX;
     572
     573  Mc = mc;
     574  Mcol = 0;
     575  for (i = 0; i < code[0].Nc; i++) {
     576    Mcol += code[0].X[i]*Mc;
     577    Mc *= mc;    /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */
     578  }
     579  Mref += Mcol;
     580  return (Mref);
     581}
     582
     583/************************************** KRON-related Magnitudes ***********************************************/
     584
     585float PhotKronInst (Measure *measure) {
     586
     587  int Np;
     588  float Minst;
     589
     590  Np = photcodes[0].hashcode[measure[0].photcode];
     591  if (Np == -1) return (NAN);
     592
     593  if (photcodes[0].code[Np].type == PHOT_REF) {
     594    Minst = measure[0].Mkron;
     595    return (Minst);
     596  }
     597  Minst = measure[0].Mkron - measure[0].dt - ZERO_POINT;
     598 
     599  return (Minst);
     600}
     601
     602float PhotKronCat (Measure *measure) {
     603
     604  int Np;
     605  float Mcat;
     606  PhotCode *code;
     607
     608  Np = photcodes[0].hashcode[measure[0].photcode];
     609  if (Np == -1) return (NAN);
     610
     611  if (photcodes[0].code[Np].type == PHOT_REF) {
     612    Mcat = measure[0].Mkron;
     613    return (Mcat);
     614  }
     615  code = &photcodes[0].code[Np];
     616  Mcat = measure[0].Mkron - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C;
     617 
     618  return (Mcat);
     619}
     620
     621float PhotKronSys (Measure *measure, Average *average, SecFilt *secfilt) {
     622
     623  int i, Np;
     624  float Mcat, Mcol, Msys, mc, Mc;
     625  PhotCode *code;
     626
     627  Np = photcodes[0].hashcode[measure[0].photcode];
     628  if (Np == -1) return (NAN);
     629
     630  if (photcodes[0].code[Np].type == PHOT_REF) {
     631    Msys = measure[0].Mkron;
     632    return (Msys);
     633  }
     634  code = &photcodes[0].code[Np];
     635  Mcat = measure[0].Mkron - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C;
     636
     637  /* for DEP, color must be made of PRI/SEC */
     638  mc = PhotColorForCode (average, secfilt, NULL, code);
     639  if (isnan(mc)) return (Mcat);
     640  mc = mc - SCALE*code[0].dX;
     641
     642  Mc = mc;
     643  Mcol = 0;
     644  for (i = 0; i < code[0].Nc; i++) {
     645    Mcol += code[0].X[i]*Mc;
     646    Mc *= mc;
     647  }
     648  Msys = Mcat + Mcol;
     649  return (Msys);
     650}
     651
     652float PhotKronRel (Measure *measure, Average *average, SecFilt *secfilt) {
     653
     654  int i, Np;
     655  float Mcat, Mcol, Mrel, mc, Mc;
     656  PhotCode *code;
     657
     658  Np = photcodes[0].hashcode[measure[0].photcode];
     659  if (Np == -1) return (NAN);
     660
     661  if (photcodes[0].code[Np].type == PHOT_REF) {
     662    Mcat = measure[0].Mkron;
     663    return (Mcat);
     664  }
     665  code = &photcodes[0].code[Np];
     666  Mrel = measure[0].Mkron - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal;
     667
     668  /* for DEP, color must be made of PRI/SEC */
     669  mc = PhotColorForCode (average, secfilt, NULL, code);
     670  if (isnan(mc)) return (Mrel);
     671  mc = mc - SCALE*code[0].dX;
     672
     673  Mc = mc;
     674  Mcol = 0;
     675  for (i = 0; i < code[0].Nc; i++) {
     676    Mcol += code[0].X[i]*Mc;
     677    Mc *= mc;    /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */
     678  }
     679  Mrel += Mcol;
     680  return (Mrel);
     681}
     682
     683/* return calibrated magnitude from measure for given photcode */
     684float PhotKronCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code) {
     685
     686  int i, Np;
     687  float Mcal, Mrel, Mcol, mc, Mc;
     688
     689  if (code == NULL) return NAN;
     690
     691  /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */
     692  Np = photcodes[0].hashcode[thisone[0].photcode];
     693  if (Np == -1) return (NAN);
     694
     695  if (photcodes[0].code[Np].type == PHOT_REF) {
     696    Mrel = thisone[0].Mkron;
     697    return (Mrel);
     698  }
     699  if (code[0].code != photcodes[0].code[Np].equiv) return (NAN);
     700
     701  Mcal = PhotKronRel (thisone, average, secfilt) + SCALE*code[0].C;
     702
     703  mc = PhotColorForCode (average, secfilt, measure, code);
     704  if (isnan(mc)) return (Mcal);
     705  mc = mc - SCALE*code[0].dX;
     706
     707  Mc = mc;
     708  Mcol = 0;
     709  for (i = 0; i < code[0].Nc; i++) {
     710    Mcol += code[0].X[i]*Mc;
     711    Mc *= mc;
     712  }
     713  Mcal += Mcol;
     714  return (Mcal);
     715}
     716
     717float PhotKronAve (PhotCode *code, Average *average, SecFilt *secfilt) {
     718
     719  int Ns;
     720  float Mkron;
     721
     722  if (code == NULL) return NAN;
     723
     724  Ns = photcodes[0].hashNsec[code[0].code];
     725  Mkron = (Ns == -1) ? NAN : secfilt[Ns].Mkron;
     726  return (Mkron);
     727}
     728
     729/* return calibrated magnitude from average/secfilt for given photcode */
     730float PhotKronRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure) {
     731
     732  int i, Ns;
     733  float Mave, Mref, Mcol, mc;
     734  double Mc;
     735
     736  if (code == NULL) return NAN;
     737
     738  Ns = photcodes[0].hashNsec[code[0].code];
     739  Mave = (Ns == -1) ? NAN : secfilt[Ns].Mkron;
     740  Mref = Mave + SCALE*code[0].C;
     741
     742  mc = PhotColorForCode (average, secfilt, measure, code);
     743  if (isnan(mc)) return (Mref);
     744  mc = mc - SCALE*code[0].dX;
     745
     746  Mc = mc;
     747  Mcol = 0;
     748  for (i = 0; i < code[0].Nc; i++) {
     749    Mcol += code[0].X[i]*Mc;
     750    Mc *= mc;    /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */
     751  }
     752  Mref += Mcol;
     753  return (Mref);
     754}
     755
     756float PhotKronAveErr (PhotCode *code, Average *average, SecFilt *secfilt) {
     757
     758  int Ns;
     759  float dMkron;
     760
     761  if (code == NULL) return NAN;
     762
     763  Ns = photcodes[0].hashNsec[code[0].code];
     764  dMkron = (Ns == -1) ? NAN : secfilt[Ns].dMkron;
     765  return (dMkron);
     766}
     767
     768/********************* other support functions ********************************/
     769
     770float PhotZeroPoint (Measure *measure, Average *average, SecFilt *secfilt) {
     771
     772  int Np;
     773  float ZP;
     774  PhotCode *code;
     775
     776  Np = photcodes[0].hashcode[measure[0].photcode];
     777  if (Np == -1) return (NAN);
     778
     779  if (photcodes[0].code[Np].type == PHOT_REF) {
     780    ZP = 0.0;
     781    return (ZP);
     782  }
     783  code = &photcodes[0].code[Np];
     784  ZP = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C;
     785
     786  return (ZP);
    446787}
    447788
     
    496837}
    497838
    498 /* return calibrated magnitude from average/secfilt for given photcode */
    499 float PhotRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure) {
    500 
    501   int i, Ns;
    502   float Mave, Mref, Mcol, mc;
    503   double Mc;
    504 
    505   if (code == NULL) return NAN;
    506 
    507   Ns = photcodes[0].hashNsec[code[0].code];
    508   Mave = (Ns == -1) ? NAN : secfilt[Ns].M;
    509   Mref = Mave + SCALE*code[0].C;
    510 
    511   mc = PhotColorForCode (average, secfilt, measure, code);
    512   if (isnan(mc)) return (Mref);
    513   mc = mc - SCALE*code[0].dX;
    514 
    515   Mc = mc;
    516   Mcol = 0;
    517   for (i = 0; i < code[0].Nc; i++) {
    518     Mcol += code[0].X[i]*Mc;
    519     Mc *= mc;    /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */
    520   }
    521   Mref += Mcol;
    522   return (Mref);
    523 }
    524 
    525 /***/
    526 float PhotAve (PhotCode *code, Average *average, SecFilt *secfilt) {
    527 
    528   int Ns;
    529   float Mave;
    530 
    531   if (code == NULL) return NAN;
    532 
    533   Ns = photcodes[0].hashNsec[code[0].code];
    534   Mave = (Ns == -1) ? NAN : secfilt[Ns].M;
    535   return (Mave);
    536 }
    537 
    538 float PhotdM (PhotCode *code, Average *average, SecFilt *secfilt) {
    539 
    540   int Ns;
    541   float dM;
    542 
    543   if (code == NULL) return NAN;
    544 
    545   Ns = photcodes[0].hashNsec[code[0].code];
    546   dM  = (Ns == -1) ? NAN : secfilt[Ns].dM;
    547   return (dM);
    548 }
    549 
    550839float PhotMstdev (PhotCode *code, Average *average, SecFilt *secfilt) {
    551840
     
    558847  Mstdev  = (Ns == -1) ? NAN : 0.001*secfilt[Ns].Mstdev;
    559848  return (Mstdev);
    560 }
    561 
    562 float PhotAperAve (PhotCode *code, Average *average, SecFilt *secfilt) {
    563 
    564   int Ns;
    565   float Maper;
    566 
    567   if (code == NULL) return NAN;
    568 
    569   Ns = photcodes[0].hashNsec[code[0].code];
    570   Maper = (Ns == -1) ? NAN : secfilt[Ns].Map;
    571   return (Maper);
    572 }
    573 
    574 float PhotKronAve (PhotCode *code, Average *average, SecFilt *secfilt) {
    575 
    576   int Ns;
    577   float Mkron;
    578 
    579   if (code == NULL) return NAN;
    580 
    581   Ns = photcodes[0].hashNsec[code[0].code];
    582   Mkron = (Ns == -1) ? NAN : secfilt[Ns].Mkron;
    583   return (Mkron);
    584 }
    585 
    586 float PhotKronAveErr (PhotCode *code, Average *average, SecFilt *secfilt) {
    587 
    588   int Ns;
    589   float dMkron;
    590 
    591   if (code == NULL) return NAN;
    592 
    593   Ns = photcodes[0].hashNsec[code[0].code];
    594   dMkron = (Ns == -1) ? NAN : secfilt[Ns].dMkron;
    595   return (dMkron);
    596849}
    597850
  • trunk/Ohana/src/libdvo/src/dvo_tiny_values.c

    r35102 r36630  
    88  averageT[0].measureOffset = average[0].measureOffset;
    99  averageT[0].catID         = average[0].catID;
     10  averageT[0].objID         = average[0].objID;
     11  averageT[0].nOwn          = -1;
    1012  return;
    1113}
     
    3335  measureT[0].dYccd      = measure[0].dYccd;
    3436  measureT[0].dRsys      = measure[0].dRsys;
     37  measureT[0].myDet      = 0;
    3538  return ;
    3639}
  • trunk/Ohana/src/libfits/table/F_get_column.c

    r35101 r36630  
    174174int gfits_get_bintable_column (Header *header, FTable *table, char *label, void **data) {
    175175
    176   off_t Nx, Ny;
    177   int i, N, Nfields, Nval, Nbytes, Nstart, Nv, Nb;
    178   char tlabel[80], field[80], format[80], type[16], tmpline[16];
    179   char *Pin, *Pout, *array;
    180   double Bscale, Bzero;
    181 
    182   if (label == (char *) NULL) return (FALSE);
    183   if (label[0] == 0) return (FALSE);
    184 
    185   /* find label in header */
    186   tlabel[0] = 0;
    187   gfits_scan (header, "TFIELDS", "%d", 1, &Nfields);
    188   for (i = 1; strcasecmp (label, tlabel) && (i < Nfields + 1); i++) {
    189     sprintf (field, "TTYPE%d", i);
    190     gfits_scan (header, field, "%s", 1, tlabel);
    191   }
    192   if (strcasecmp (label, tlabel)) return (FALSE);
    193   N = i - 1;
    194 
    195   Bscale = 1;
    196   Bzero  = 0;
    197 
    198   /* interpret format */
    199   sprintf (field, "TSCAL%d", N);
    200   gfits_scan (header, field, "%lf", 1, &Bscale);
    201   sprintf (field, "TZERO%d", N);
    202   gfits_scan (header, field, "%lf", 1, &Bzero);
    203   sprintf (field, "TFORM%d", N);
    204   gfits_scan (header, field, "%s", 1, format);
    205 
    206   if (!gfits_bintable_format (format, type, &Nval, &Nbytes)) return (FALSE);
    207  
    208   /* check existing table dimensions */
    209   gfits_scan (header, "NAXIS1",  OFF_T_FMT, 1,  &Nx);
    210   gfits_scan (header, "NAXIS2",  OFF_T_FMT, 1,  &Ny);
    211 
    212   /* scan columns to find insert point */
    213   Nstart = 0;
    214   for (i = 1; i < N; i++) {
    215     sprintf (field, "TFORM%d", i);
    216     gfits_scan (header, field, "%s", 1, format);
    217     gfits_bintable_format (format, tmpline, &Nv, &Nb);
    218     Nstart += Nv*Nb;
    219   }
    220 
    221   /* extract bytes from table into temporary array */
    222   ALLOCATE (array, char, Nbytes*Nval*Ny);
    223   Pin  = table[0].buffer + Nstart;
    224   Pout = array;
    225   for (i = 0; i < Ny; i++, Pin += Nx, Pout += Nval*Nbytes) {
    226     memcpy (Pout, Pin, Nval*Nbytes);
    227   }
    228 
    229   /* convert data in-situ with correct type, byte swap and Bzero/Bscale */
    230   Pin  = array;
    231   Pout = array;
    232   if (!strcmp (type, "char")) {
    233     for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
    234       *(char *)Pout = *(char *)Pin*Bscale + Bzero;
    235     }
    236   }
    237   if (!strcmp (type, "short")) {
    238     for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
    239 # ifdef BYTE_SWAP
    240       SWAP_BYTE;
    241 # endif
    242       *(short *)Pout = *(short *)Pin*Bscale + Bzero;
    243     } 
    244   }
    245   if (!strcmp (type, "int")) {
    246     for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
    247 # ifdef BYTE_SWAP
    248       SWAP_WORD;
    249 # endif
    250       *(int *)Pout = *(int *)Pin*Bscale + Bzero;
    251     }
    252   }
    253   if (!strcmp (type, "int64_t")) {
    254     // XXX 64 bit int operations with Bzero & Bscale are inaccurate even with doubles
    255     if ((Bzero == 0.0) && (Bscale == 1.0)) {
    256       for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
    257 # ifdef BYTE_SWAP
    258         SWAP_DBLE;
    259 # endif
    260         *(int64_t *)Pout = *(int64_t *)Pin;
    261       }
    262     } else {
    263       for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
    264 # ifdef BYTE_SWAP
    265         SWAP_DBLE;
    266 # endif
    267         *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero;
    268       }
    269     }
    270   }
    271   if (!strcmp (type, "float")) {
    272     for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
    273 # ifdef BYTE_SWAP
    274       SWAP_WORD;
    275 # endif
    276       *(float *)Pout = *(float *)Pin*Bscale + Bzero;
    277     }
    278   }
    279   if (!strcmp (type, "double")) {
    280     for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
    281 # ifdef BYTE_SWAP
    282       SWAP_DBLE;
    283 # endif
    284       *(double *)Pout = *(double *)Pin*Bscale + Bzero;
    285     }
    286   }
     176  char type[16];
     177  off_t Nrow;
     178  int Ncol;
     179
     180  char *array = gfits_get_bintable_column_data (header, table, label, type, &Nrow, &Ncol);
     181  if (array == NULL) return (FALSE);
    287182
    288183  *data = array;
    289   return (TRUE);
     184  return TRUE;
    290185}
    291186
  • trunk/Ohana/src/libohana/src

  • trunk/Ohana/src/opihi/dvo/photometry.c

    r35416 r36630  
    662662      break;
    663663    case AVE_dMAG:
    664       value = PhotdM (code, average, secfilt);
     664      value = PhotAveErr (code, average, secfilt);
    665665      break;
    666666    case AVE_Xm:
     
    865865  /* for ErrSelect, check average errors */
    866866  if (ErrSelect) {
    867     dM = PhotdM (code, average, secfilt);
     867    dM = PhotAveErr (code, average, secfilt);
    868868    if (dM > ErrValue) return (FALSE);
    869869  }
  • trunk/Ohana/src/relastro/Makefile

    r35416 r36630  
    6969$(SRC)/resort_catalog.$(ARCH).o  \
    7070$(SRC)/BrightCatalog.$(ARCH).o  \
     71$(SRC)/assign_images.$(ARCH).o \
     72$(SRC)/launch_region_hosts.$(ARCH).o \
     73$(SRC)/relastro_parallel_images.$(ARCH).o \
     74$(SRC)/relastro_parallel_regions.$(ARCH).o \
     75$(SRC)/MeanPosIO.$(ARCH).o \
     76$(SRC)/share_mean_pos.$(ARCH).o \
     77$(SRC)/share_images_pos.$(ARCH).o \
     78$(SRC)/ImagePosIO.$(ARCH).o \
     79$(SRC)/ImageTable.$(ARCH).o \
     80$(SRC)/markObjects.$(ARCH).o \
     81$(SRC)/indexCatalogs.$(ARCH).o \
     82$(SRC)/syncfile.$(ARCH).o \
    7183$(SRC)/relastroVisual.$(ARCH).o
    7284
  • trunk/Ohana/src/relastro/include/relastro.h

    r35763 r36630  
    66# include <pthread.h>
    77
     8# define MARKTIME(MSG,...) {                    \
     9    gettimeofday (&stopTimer, (void *) NULL);   \
     10    float dtime = DTIME (stopTimer, startTimer);        \
     11    fprintf (stderr, MSG, __VA_ARGS__); }
     12
     13# define INITTIME \
     14  struct timeval startTimer, stopTimer; \
     15  gettimeofday (&startTimer, (void *) NULL);
     16
    817// choose off_t or int depending on full-scale relphot analysis resources
    918// # define IDX_T off_t
     
    2029typedef enum {FIT_NONE, FIT_AVERAGE, FIT_PM_ONLY, FIT_PAR_ONLY, FIT_PM_AND_PAR} FitMode;
    2130
    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, TARGET_HPM} FitTarget;
     31typedef enum {OP_NONE, OP_IMAGES, OP_HIGH_SPEED, OP_MERGE_SOURCE, OP_UPDATE_OBJECTS, OP_UPDATE_OFFSETS, OP_LOAD_OBJECTS, OP_HPM, OP_PARALLEL_REGIONS, OP_PARALLEL_IMAGES} RelastroOp;
     32
     33typedef enum {TARGET_NONE, TARGET_SIMPLE, TARGET_CHIPS, TARGET_MOSAICS} FitTarget;
    2334
    2435typedef enum {
     
    3041  MARK_BIG_OFFSET    = 0x0010,
    3142} MeasurementMask;
     43
     44typedef struct {
     45  float R;
     46  float D;
     47  unsigned int objID;
     48  unsigned int catID;
     49} MeanPos;
     50
     51typedef struct {
     52  Coords coords;
     53  float dXpixSys;
     54  float dYpixSys;
     55  unsigned int imageID;
     56  int nFitAstrom;
     57  int flags;
     58} ImagePos;
    3259
    3360typedef struct {
     
    93120  unsigned int start;
    94121  unsigned int stop;
     122  off_t myImage;
    95123  float Mcal;
    96124  float dMcal;
     
    113141} StatType;
    114142
    115 # define MARKTIME(MSG,...) { \
    116   float dtime; \
    117   gettimeofday (&stop, (void *) NULL); \
    118   dtime = DTIME (stop, start); \
    119   fprintf (stderr, MSG, __VA_ARGS__); }
    120 
    121143/* global variables set in parameter file */
    122144# define DVO_MAX_PATH 1024
     
    129151char   SKY_TABLE[DVO_MAX_PATH];
    130152int    SKY_DEPTH;  /** XXX EAM : depth of catalog tables, fix usage */
     153
     154// globals for parallel region operations
     155char  *REGION_FILE;
     156char  *IMAGE_TABLE;
     157int    REGION_HOST_ID;
     158int    PARALLEL_REGIONS_MANUAL;
    131159
    132160int          HOST_ID;
     
    208236FitMode FIT_MODE;
    209237
     238RelastroOp RELASTRO_OP;
    210239FitTarget FIT_TARGET;
    211240
     
    450479int hpm_catalogs_parallel (SkyList *skylist);
    451480int hpm_objects (SkyRegion *region, Catalog *catalog);
     481
     482int strextend (char *input, char *format,...);
     483int launch_region_hosts (RegionHostTable *regionHosts);
     484
     485int assign_images (FITS_DB *db, RegionHostTable *regionHosts);
     486int select_images_hostregion (RegionHostTable *regionHosts, Image *image, off_t Nimage);
     487int calculate_image_bounds (Image *image, double *rmin, double *rmax, double *dmin, double *dmax, double Rmid);
     488int calculate_host_image_bounds (RegionHostTable *regionHosts);
     489int find_host_for_coords (RegionHostTable *regionHosts, double Rc, double Dc);
     490
     491int relastro_parallel_regions ();
     492int relastro_parallel_images ();
     493
     494char *make_filename (char *dirname, char *hostname, int hostID, char *tailname);
     495int check_sync_file (char *filename, int nloop);
     496int clear_sync_file (char *filename);
     497int update_sync_file (char *filename, int nloop);
     498
     499int share_mean_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop);
     500int slurp_mean_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop);
     501int set_mean_pos (MeanPos *meanpos, Average *average);
     502MeanPos *merge_mean_pos (MeanPos *target, int *ntarget, MeanPos *source, int Nsource);
     503
     504int MeanPosSave(char *filename, MeanPos *meanpos, off_t Nmeanpos);
     505MeanPos *MeanPosLoad(char *filename, off_t *nmeanpos);
     506
     507int indexCatalogs (Catalog *catalog, int Ncatalog);
     508int catID_and_objID_to_seq (int catID, int objID, int *catSeq, off_t *objSeq);
     509
     510int markObjects (Catalog *catalog, int Ncatalog);
     511
     512int ImagePosSave(char *filename, ImagePos *image_pos, off_t Nimage_pos);
     513ImagePos *ImagePosLoad(char *filename, off_t *nimage_pos);
     514
     515int share_image_pos (RegionHostTable *regionHosts, int nloop);
     516int slurp_image_pos (RegionHostTable *regionHosts, int nloop);
     517ImagePos *merge_image_pos (ImagePos *target, int *ntarget, ImagePos *source, int Nsource);
     518int set_image_pos (ImagePos *image_pos, Image *image);
     519
     520Image *ImageTableLoad(char *filename, off_t *nimage);
     521int ImageTableSave (char *filename, Image *images, off_t Nimages);
     522int select_mosaics_hostregion (RegionHostTable *regionHosts, Image *image, off_t Nimage);
  • trunk/Ohana/src/relastro/src/ConfigInit.c

    r35105 r36630  
    1818  if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file);
    1919
    20   GetConfig (config, "RELASTRO_SIGMA_LIM",         "%lf", 0, &SIGMA_LIM); // exclude measurements on this basis
    21   GetConfig (config, "RELASTRO_SRC_MEAS_TOOFEW",   "%d",  0, &SRC_MEAS_TOOFEW);
     20  // set defaults for all of these if they are not used by parallel / remote clients
     21  if (!ScanConfig (config, "RELASTRO_SIGMA_LIM",         "%lf", 0, &SIGMA_LIM))       SIGMA_LIM = 0.01;
     22  if (!ScanConfig (config, "RELASTRO_SRC_MEAS_TOOFEW",   "%d",  0, &SRC_MEAS_TOOFEW)) SRC_MEAS_TOOFEW = 3;
    2223
    2324  if (!ScanConfig (config, "RELASTRO_IMFIT_CLIP_NITER",    "%d",  0, &IMFIT_CLIP_NITER))    IMFIT_CLIP_NITER  = 3;
     
    2526  if (!ScanConfig (config, "RELASTRO_IMFIT_SYS_SIGMA_LIM", "%lf", 0, &IMFIT_SYS_SIGMA_LIM)) IMFIT_SYS_SIGMA_LIM = 0.01;
    2627
    27   GetConfig (config, "PM_DT_MIN",              "%lf", 0, &PM_DT_MIN);
    28   GetConfig (config, "PM_TOOFEW",              "%d",  0, &PM_TOOFEW);
    29   GetConfig (config, "POS_TOOFEW",             "%d",  0, &POS_TOOFEW);
     28  if (!ScanConfig (config, "PM_DT_MIN",              "%lf", 0, &PM_DT_MIN))        PM_DT_MIN = 0.25;   
     29  if (!ScanConfig (config, "PM_TOOFEW",              "%d",  0, &PM_TOOFEW))        PM_TOOFEW = 4;   
     30  if (!ScanConfig (config, "POS_TOOFEW",             "%d",  0, &POS_TOOFEW))       POS_TOOFEW = 1; 
     31  if (!ScanConfig (config, "PAR_FACTOR_MIN",         "%lf", 0, &PAR_FACTOR_MIN))   PAR_FACTOR_MIN = 0.2;
     32  if (!ScanConfig (config, "RELASTRO_MAP_NX",        "%d",  0, &NX_MAP))           NX_MAP = 5;
     33  if (!ScanConfig (config, "RELASTRO_MAP_NY",        "%d",  0, &NY_MAP))           NY_MAP = 5;
     34  if (!ScanConfig (config, "RELASTRO_DPOS_MAX",      "%lf", 0, &DPOS_MAX))         DPOS_MAX = 6.0;   
     35  if (!ScanConfig (config, "ADDSTAR_RADIUS",         "%lf", 0, &ADDSTAR_RADIUS))   ADDSTAR_RADIUS = 1.0;
    3036
    31   GetConfig (config, "PAR_FACTOR_MIN",         "%lf", 0, &PAR_FACTOR_MIN);
    32 
    33   GetConfig (config, "RELASTRO_MAP_NX",        "%d",  0, &NX_MAP);
    34   GetConfig (config, "RELASTRO_MAP_NY",        "%d",  0, &NY_MAP);
    35   GetConfig (config, "RELASTRO_DPOS_MAX",      "%lf", 0, &DPOS_MAX);
    36   GetConfig (config, "ADDSTAR_RADIUS",         "%lf", 0, &ADDSTAR_RADIUS);
    37 
    38   if (!ScanConfig (config, "USE_FIXED_PIXCOORDS", "%d", 0, &USE_FIXED_PIXCOORDS)) {
    39     USE_FIXED_PIXCOORDS = FALSE;
    40   }
     37  if (!ScanConfig (config, "USE_FIXED_PIXCOORDS", "%d", 0, &USE_FIXED_PIXCOORDS))  USE_FIXED_PIXCOORDS = FALSE;
    4138
    4239  // force CATDIR to be absolute (so parallel mode will work)
     
    5653  sprintf (ImageCat, "%s/Images.dat", CATDIR);
    5754
    58   if (!ScanConfig (config, "SKY_DEPTH",         "%d",  0, &SKY_DEPTH)) {
    59     SKY_DEPTH = 2;
    60   }
    61   if (!ScanConfig (config, "SKY_TABLE",         "%s",  0, SKY_TABLE)) {
    62     SKY_TABLE[0] = 0;
    63   }
     55  if (!ScanConfig (config, "SKY_DEPTH",         "%d",  0, &SKY_DEPTH)) SKY_DEPTH = 2;
     56  if (!ScanConfig (config, "SKY_TABLE",         "%s",  0, SKY_TABLE)) SKY_TABLE[0] = 0;
    6457
    6558  if (*CATMODE == 0) strcpy (CATMODE, "RAW");
  • trunk/Ohana/src/relastro/src/ImageOps.c

    r35763 r36630  
    226226    Measure *measureBig = &catalog[cat].measure[meas];
    227227    int TESTPT = FALSE;
    228     TESTPT |= (measureBig->imageID == CAT_ID_SRC) && (measureBig->detID == OBJ_ID_SRC);
    229     TESTPT |= (measureBig->imageID == CAT_ID_DST) && (measureBig->detID == OBJ_ID_DST);
     228    TESTPT |= CAT_ID_SRC && OBJ_ID_SRC && (measureBig->imageID == CAT_ID_SRC) && (measureBig->detID == OBJ_ID_SRC);
     229    TESTPT |= CAT_ID_DST && OBJ_ID_DST && (measureBig->imageID == CAT_ID_DST) && (measureBig->detID == OBJ_ID_DST);
    230230    if (TESTPT) {
    231231      fprintf (stderr, "got test det\n");
     
    462462    int TESTPT = FALSE;
    463463
    464     TESTPT |= (measure->imageID == CAT_ID_SRC) && (measure->detID == OBJ_ID_SRC);
    465     TESTPT |= (measure->imageID == CAT_ID_DST) && (measure->detID == OBJ_ID_DST);
     464    TESTPT |= CAT_ID_SRC && OBJ_ID_SRC && (measure->imageID == CAT_ID_SRC) && (measure->detID == OBJ_ID_SRC);
     465    TESTPT |= CAT_ID_DST && OBJ_ID_DST && (measure->imageID == CAT_ID_DST) && (measure->detID == OBJ_ID_DST);
    466466    if (TESTPT) {
    467467      fprintf (stderr, "got test det\n");
  • trunk/Ohana/src/relastro/src/MosaicOps.c

    r27581 r36630  
    1111
    1212// list of mosaic associated with each image 
    13 static off_t    Nmosaic_for_images; // number of images (for off_ternal checks)
     13static off_t    Nmosaic_for_images; // number of images (for internal checks)
    1414static off_t    *mosaic_for_images; // array of: image -> mosaic
    1515
     
    105105    mosaic[Nmosaic].secz  = image[i].secz;
    106106    mosaic[Nmosaic].coords = image[i].coords;
     107    mosaic[Nmosaic].myImage = i;
    107108
    108109    // init the mosaic_own_images array data
     
    135136  ALLOCATE (mosaic_for_images, off_t, Nmosaic_for_images);
    136137
     138  // emit an error if we miss mosaics, but stop if we miss too many
     139  int NmissMosaic = 0;
     140  int NtestMosaic = 0;
     141
    137142  /* now assign the WRP images to these mosaics */
    138143  for (i = 0; i < Nimage; i++) {
     
    140145
    141146    if (strcmp(&image[i].coords.ctype[4], "-WRP")) continue;
     147    NtestMosaic ++;
    142148
    143149    /* set image time range */
     
    147153    Nmos = getMosaicByTimes (start, stop, startMos, stopMos, indexMos);
    148154    if (Nmos == -1) {
    149       fprintf (stderr, "cannot match mosaic for %s\n", image[i].name);
     155      if (NmissMosaic < 1000) {
     156        fprintf (stderr, "cannot match mosaic for %s\n", image[i].name);
     157      }
     158      NmissMosaic ++;
    150159      continue;
    151160    }
     
    164173  }
    165174
     175  fprintf (stderr, "mosaic matching : %d of possible %d failed to match\n", NmissMosaic, NtestMosaic);
     176  if (NmissMosaic > 0.5*NtestMosaic) {
     177    fprintf (stderr, "serious problem with mosaic matching\n");
     178    exit (5);
     179  }
     180
    166181  free (startMos);
    167182  free (stopMos);
     
    250265  if (im >= Nmosaic_for_images) abort();
    251266
    252   // search for the mosaic that
     267  // search for the mosaic that matches this image
    253268  mos = mosaic_for_images[im];
    254269  if (mos < 0) return NULL;
     
    256271  return &mosaic[mos];
    257272}
     273
     274// extend each host image table to include the mosaic 'images' needed by the host
     275int select_mosaics_hostregion (RegionHostTable *regionHosts, Image *image, off_t Nimage) {
     276
     277  int i;
     278  off_t j;
     279  char *mosaicUsed;
     280
     281  ALLOCATE (mosaicUsed, char, Nmosaic);
     282
     283  // we need to add the mosaics to each of the region hosts lists of images
     284  for (i = 0; i < regionHosts->Nhosts; i++) {
     285
     286    int Nadd = 0;
     287    int NADD = 100;
     288    off_t *addMosaic = NULL;
     289    ALLOCATE (addMosaic, off_t, NADD);
     290
     291    // reset the mosaicUsed flags (valid only for this host)
     292    memset (mosaicUsed, 0, Nmosaic * sizeof(char));
     293
     294    RegionHostInfo *host = &regionHosts->hosts[i];
     295
     296    // find the mosaics associated with a given
     297    for (j = 0; j < host->Nimage; j++) {
     298
     299      int im = host->imseq[j];
     300     
     301      if (im < 0) abort();
     302      if (im >= Nmosaic_for_images) abort();
     303
     304      // search for the mosaic that matches this image (skip unmatched images)
     305      off_t mos = mosaic_for_images[im];
     306      if (mos < 0) continue;
     307
     308      if (mosaicUsed[mos]) continue;
     309
     310      mosaicUsed[mos] = TRUE;
     311      addMosaic[Nadd] = mos;
     312      Nadd ++;
     313     
     314      CHECK_REALLOCATE (addMosaic, off_t, NADD, Nadd, 100);
     315    }
     316
     317    REALLOCATE (host->image, Image, host->Nimage + Nadd);
     318
     319    for (j = 0; j < Nadd; j++) {
     320      off_t mos = addMosaic[j];
     321      off_t mos_im = mosaic[mos].myImage;
     322
     323      host->image[host->Nimage + j] = image[mos_im];
     324    }
     325   
     326    host->Nimage += Nadd;
     327  }
     328  return TRUE;
     329}
     330
  • trunk/Ohana/src/relastro/src/StarMaps.c

    r35105 r36630  
    5959  off_t i, N, Nimages;
    6060  int xbin, ybin;
    61   struct timeval start, stop;
    6261
    63   gettimeofday (&start, (void *) NULL);
     62  INITTIME;
    6463
    6564  // Images *images = getimages(&Nimages, NULL); return value ignored
  • trunk/Ohana/src/relastro/src/UpdateObjects.c

    r36482 r36630  
    11# include "relastro.h"
    22
    3 static off_t   Nmax;
     3static off_t Nmax;
    44static double *X, *dX;
    55static double *Y, *dY;
     
    3636  ALLOCATE (pX, double, MAX (1, Nmax));
    3737  ALLOCATE (pY, double, MAX (1, Nmax));
     38
     39
     40void freeObjectData () {
     41
     42  free (R);
     43  free (D);
     44  free (T);
     45  free (X);
     46  free (Y);
     47
     48  free (dR);
     49  free (dD);
     50  free (dT);
     51  free (dX);
     52  free (dY);
     53
     54  free (pX);
     55  free (pY);
    3856
    3957
     
    205223      if (((mode == FIT_PM_ONLY) || (mode == FIT_PM_AND_PAR)) && (N <= PM_TOOFEW)) mode = FIT_AVERAGE;
    206224
    207       if (FIT_TARGET == TARGET_HIGH_SPEED) {
     225      if (RELASTRO_OP == OP_HIGH_SPEED) {
    208226          Tmean = 0.5*(Tmax - Tmin);
    209227      } else {
     
    412430  }
    413431
     432  freeObjectData ();
     433
    414434  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", "OFF_T_FMT" have too large an offset\n",  (NaveSum + NpmSum + NparSum),  NaveSum,  NpmSum,  NparSum,  NskipSum, NoffSum);
    415435  return (TRUE);
  • trunk/Ohana/src/relastro/src/args.c

    r35763 r36630  
    1313  /* possible operations */
    1414  FIT_TARGET = TARGET_NONE;
     15  RELASTRO_OP = OP_NONE;
    1516  FIT_MODE = FIT_AVERAGE;
    1617
     
    2122    if (N > argc - 6) usage_merge_source();
    2223    if (strcmp(argv[N+3], "into")) usage_merge_source();
    23     FIT_TARGET = TARGET_MERGE_SOURCE;
     24    RELASTRO_OP = OP_MERGE_SOURCE;
    2425    remove_argument (N, &argc, argv);
    2526    OBJ_ID_SRC = strtol(argv[N], &endptr, 0);
     
    4344  if ((N = get_argument (argc, argv, "-update-objects"))) {
    4445    remove_argument (N, &argc, argv);
    45     FIT_TARGET = TARGET_UPDATE_OBJECTS;
     46    RELASTRO_OP = OP_UPDATE_OBJECTS;
    4647  }
    4748
    4849  if ((N = get_argument (argc, argv, "-update-offsets"))) {
    4950    remove_argument (N, &argc, argv);
    50     FIT_TARGET = TARGET_UPDATE_OFFSETS;
     51    RELASTRO_OP = OP_UPDATE_OFFSETS;
     52  }
     53
     54  // elements needed for parallel regions / parallel images
     55  REGION_FILE = NULL;
     56  if ((N = get_argument (argc, argv, "-region-hosts"))) {
     57    remove_argument (N, &argc, argv);
     58    REGION_FILE = strcreate (argv[N]);
     59    remove_argument (N, &argc, argv);
     60  }
     61
     62  REGION_HOST_ID = 0;
     63  if ((N = get_argument (argc, argv, "-region-hostID"))) {
     64    remove_argument (N, &argc, argv);
     65    REGION_HOST_ID = atoi (argv[N]);
     66    remove_argument (N, &argc, argv);
     67  }
     68
     69  IMAGE_TABLE = NULL;
     70  if ((N = get_argument (argc, argv, "-parallel-images"))) {
     71    remove_argument (N, &argc, argv);
     72    RELASTRO_OP = OP_PARALLEL_IMAGES;
     73    if (N >= argc) usage();
     74    IMAGE_TABLE = strcreate (argv[N]);
     75    remove_argument (N, &argc, argv);
     76    if (!REGION_FILE) usage();
     77  }
     78
     79  if ((N = get_argument (argc, argv, "-images"))) {
     80    remove_argument (N, &argc, argv);
     81    RELASTRO_OP = OP_IMAGES;
     82  }
     83
     84  PARALLEL_REGIONS_MANUAL = FALSE;
     85  if ((N = get_argument (argc, argv, "-parallel-regions"))) {
     86    remove_argument (N, &argc, argv);
     87    RELASTRO_OP = OP_PARALLEL_REGIONS;
     88    if (!REGION_FILE) usage();
     89    if ((N = get_argument (argc, argv, "-parallel-regions-manual"))) {
     90      remove_argument (N, &argc, argv);
     91      PARALLEL_REGIONS_MANUAL = TRUE;
     92    }
    5193  }
    5294
     
    90132    // XXX include a parallax / no-parallax option
    91133    if (N >= argc - 4) usage();
    92     FIT_TARGET = TARGET_HIGH_SPEED;
     134    RELASTRO_OP = OP_HIGH_SPEED;
    93135    remove_argument (N, &argc, argv);
    94136    PHOTCODE_A_LIST = strcreate(argv[N]);
     
    104146  if ((N = get_argument (argc, argv, "-hpm"))) {
    105147    if (N >= argc - 2) usage();
    106     FIT_TARGET = TARGET_HPM;
     148    RELASTRO_OP = OP_HPM;
    107149    remove_argument (N, &argc, argv);
    108150    RADIUS = atof(argv[N]);
     
    116158    remove_argument (N, &argc, argv);
    117159    PARALLEL_OUTPUT = TRUE;
    118     if ((FIT_TARGET != TARGET_HIGH_SPEED) && (FIT_TARGET != TARGET_HPM)) {
     160    if ((RELASTRO_OP != OP_HIGH_SPEED) && (RELASTRO_OP != OP_HPM)) {
    119161      fprintf (stderr, "-parallel-output only valid for -high-speed or -hpm modes\n");
    120162      exit (1);
     
    143185  }
    144186
    145   if (FIT_TARGET == TARGET_NONE) usage();
     187  if (RELASTRO_OP == OP_NONE) usage();
     188
     189  if (((RELASTRO_OP == OP_IMAGES) || (RELASTRO_OP == OP_PARALLEL_REGIONS) || (RELASTRO_OP == OP_PARALLEL_IMAGES)) && (FIT_TARGET == TARGET_NONE)) usage();
    146190
    147191  /* specify portion of the sky : allow default of all sky? */
     
    427471
    428472  /* possible operations */
    429   FIT_TARGET = TARGET_NONE;
     473  RELASTRO_OP = TARGET_NONE;
    430474  FIT_MODE = FIT_AVERAGE;
    431475
     
    437481  BCATALOG = NULL;
    438482
     483  REGION_FILE = NULL;
     484  REGION_HOST_ID = 0;
     485  IMAGE_TABLE = NULL;
     486  PARALLEL_REGIONS_MANUAL = FALSE;
     487
    439488  HOST_ID = 0;
    440489  if ((N = get_argument (argc, argv, "-hostID"))) {
     
    457506    BCATALOG = strcreate(argv[N]);
    458507    remove_argument (N, &argc, argv);
    459     FIT_TARGET = TARGET_LOAD_OBJECTS;
     508    RELASTRO_OP = OP_LOAD_OBJECTS;
    460509  }
    461510
    462511  if ((N = get_argument (argc, argv, "-update-objects"))) {
    463512    remove_argument (N, &argc, argv);
    464     FIT_TARGET = TARGET_UPDATE_OBJECTS;
     513    RELASTRO_OP = OP_UPDATE_OBJECTS;
    465514  }
    466515
    467516  if ((N = get_argument (argc, argv, "-update-offsets"))) {
    468517    remove_argument (N, &argc, argv);
    469     FIT_TARGET = TARGET_UPDATE_OFFSETS;
     518    RELASTRO_OP = OP_UPDATE_OFFSETS;
    470519  }
    471520
     
    487536    // XXX include a parallax / no-parallax option
    488537    if (N >= argc - 5) usage_client();
    489     FIT_TARGET = TARGET_HIGH_SPEED;
     538    RELASTRO_OP = OP_HIGH_SPEED;
    490539    remove_argument (N, &argc, argv);
    491540    PHOTCODE_A_LIST = strcreate(argv[N]);
     
    501550  if ((N = get_argument (argc, argv, "-hpm"))) {
    502551    if (N >= argc - 3) usage();
    503     FIT_TARGET = TARGET_HPM;
     552    RELASTRO_OP = OP_HPM;
    504553    remove_argument (N, &argc, argv);
    505554    RADIUS = atof(argv[N]);
     
    539588  }
    540589
    541   if (FIT_TARGET == TARGET_NONE) usage_client();
     590  if (RELASTRO_OP == OP_NONE) usage_client();
    542591
    543592  /* specify portion of the sky : allow default of all sky? */
     
    718767
    719768void usage () {
    720   fprintf (stderr, "ERROR: USAGE: relastro -update-simple [options]\n");
    721   fprintf (stderr, "       OR:    relastro -update-chips [options]\n");
    722   fprintf (stderr, "       OR:    relastro -update-mosaic [options]\n");
     769  fprintf (stderr, "ERROR: USAGE: relastro -images -update-simple [options]\n");
     770  fprintf (stderr, "       OR:    relastro -images -update-chips [options]\n");
     771  fprintf (stderr, "       OR:    relastro -images -update-mosaic [options]\n");
     772  fprintf (stderr, "       OR:    relastro -parallel-regions -update-simple [options]\n");
     773  fprintf (stderr, "       OR:    relastro -parallel-regions -update-chips [options]\n");
     774  fprintf (stderr, "       OR:    relastro -parallel-regions -update-mosaic [options]\n");
     775  fprintf (stderr, "       OR:    relastro -parallel-images -update-simple [options]\n");
     776  fprintf (stderr, "       OR:    relastro -parallel-images -update-chips [options]\n");
     777  fprintf (stderr, "       OR:    relastro -parallel-images -update-mosaic [options]\n");
    723778  fprintf (stderr, "       OR:    relastro -update-objects [options]\n");
    724779  fprintf (stderr, "       OR:    relastro -high-speed [options]\n");
  • trunk/Ohana/src/relastro/src/initialize.c

    r34429 r36630  
    66  args (argc, argv);
    77
    8   if (FIT_TARGET == TARGET_MERGE_SOURCE) return;
     8  if (RELASTRO_OP == OP_MERGE_SOURCE) return;
    99
    1010  fprintf (stderr, "PHOTCODE_KEEP_LIST: %s\n", PHOTCODE_KEEP_LIST);
  • trunk/Ohana/src/relastro/src/load_catalogs.c

    r35105 r36630  
    115115Catalog *load_catalogs_parallel (SkyList *sky, int *Ncatalog) {
    116116
     117  char uniquer[12];
     118  int TIME = time(NULL);
     119  int PID = getpid();
     120  snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
     121
    117122  // load the list of hosts
    118123  HostTable *table = HostTableLoad (CATDIR, sky->hosts);
     
    131136
    132137    ALLOCATE (table->hosts[i].results, char, 1024);
    133     snprintf (table->hosts[i].results, 1024, "%s/relastro.catalog.subset.dat", table->hosts[i].pathname);
     138    snprintf (table->hosts[i].results, 1024, "%s/relastro.catalog.%s.dat", table->hosts[i].pathname, uniquer);
    134139
    135140    // options / arguments that can affect relastro_client -load:
  • trunk/Ohana/src/relastro/src/load_images.c

    r35763 r36630  
    11# include "relastro.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
    93int load_images (FITS_DB *db, SkyList *skylist, int UseFullOverlap) {
     
    126  off_t      Nimage, Nsubset;
    137  off_t     *LineNumber;
    14   struct timeval start, stop;
    158
    16   gettimeofday (&start, (void *) NULL);
     9  INITTIME;
    1710
    1811  // convert database table to internal structure
     
    3528 
    3629  /* unlock, if we can (else, unlocked below) */
    37   int unlockImages = !UPDATE || (FIT_TARGET == TARGET_UPDATE_OFFSETS);
     30  int unlockImages = !UPDATE || (RELASTRO_OP == OP_UPDATE_OFFSETS);
    3831  if (unlockImages) dvo_image_unlock (db);
    3932
  • trunk/Ohana/src/relastro/src/relastro.c

    r35763 r36630  
    1010  SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch);
    1111
    12   switch (FIT_TARGET) {
    13     case TARGET_UPDATE_OBJECTS:
     12  switch (RELASTRO_OP) {
     13    case OP_UPDATE_OBJECTS:
    1414      /* the object analysis is a separate process iterating over catalogs */
    1515      relastro_objects (skylist, 0, NULL);
    1616      exit (0);
    1717
    18     case TARGET_HIGH_SPEED:
     18    case OP_HIGH_SPEED:
    1919      /* high-speed is a 2pt cross-correlation process for linking moving objects (high PM) */
    2020      high_speed_catalogs (sky, skylist, 0, NULL);
    2121      exit (0);
    2222
    23     case TARGET_HPM:
     23    case OP_HPM:
    2424      hpm_catalogs (sky, skylist, 0, NULL);
    2525      exit (0);
    2626
    27     case TARGET_MERGE_SOURCE:
     27    case OP_MERGE_SOURCE:
    2828      /* a special method to manually merge unlinked detections of sources togther (not parallel) */
    2929      relastro_merge_source (sky);
    3030      exit (0);
    3131
    32     case TARGET_SIMPLE:
    33     case TARGET_CHIPS:
    34     case TARGET_MOSAICS:
     32    case OP_IMAGES:
    3533      relastro_images (skylist);
    3634      exit (0);
    3735
    38     case TARGET_UPDATE_OFFSETS:
     36    case OP_UPDATE_OFFSETS:
    3937      // iterate over catalogs to make detection coordinates consistant
    4038      UpdateObjectOffsets (skylist, 0, NULL);
     39      exit (0);
     40
     41    case OP_PARALLEL_REGIONS:
     42      // run image updates in parallel across multiple remote machines
     43      relastro_parallel_regions ();
     44      exit (0);
     45
     46    case OP_PARALLEL_IMAGES:
     47      // operation on the remote machines in the PARALLEL_REGION mode
     48      relastro_parallel_images ();
    4149      exit (0);
    4250
  • trunk/Ohana/src/relastro/src/relastro_client.c

    r35763 r36630  
    2828  SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch);
    2929
    30   switch (FIT_TARGET) {
     30  switch (RELASTRO_OP) {
    3131
    32     case TARGET_LOAD_OBJECTS: {
     32    case OP_LOAD_OBJECTS: {
    3333      // USAGE: relastro_client -load-objects
    3434      int Ncatalog;
    3535      Catalog *catalog = load_catalogs (skylist, &Ncatalog, TRUE, HOST_ID, HOSTDIR);
    3636      if (!catalog) {
    37           fprintf (stderr, "ERROR loading catalogs from %s\n", CATDIR);
    38           exit (2);
     37        fprintf (stderr, "ERROR loading catalogs from %s\n", CATDIR);
     38        exit (2);
    3939      }
    4040      BrightCatalog *bcatalog = BrightCatalogMerge (catalog, Ncatalog);
    4141      if (!BrightCatalogSave (BCATALOG, bcatalog)) {
    42           fprintf (stderr, "ERROR saving bright catalog from %s\n", CATDIR);
    43           exit (2);
     42        fprintf (stderr, "ERROR saving bright catalog from %s\n", CATDIR);
     43        exit (2);
    4444      }
    4545      break;
    4646    }
    4747     
    48     case TARGET_UPDATE_OBJECTS: {
     48    case OP_UPDATE_OBJECTS: {
    4949      // USAGE: relastro_client -update-objects
    5050      relastro_objects (skylist, HOST_ID, HOSTDIR);
     
    5252    }
    5353
    54     case TARGET_HIGH_SPEED: {
     54    case OP_HIGH_SPEED: {
    5555      // USAGE: relastro_client -high-speed
    5656      high_speed_catalogs (sky, skylist, HOST_ID, HOSTDIR);
     
    5858    }
    5959
    60     case TARGET_HPM: {
     60    case OP_HPM: {
    6161      // USAGE: relastro_client -high-speed
    6262      hpm_catalogs (sky, skylist, HOST_ID, HOSTDIR);
     
    6464    }
    6565
    66       // XXX loading the images is fairly costly -- see if we can do an image subset
    67     case TARGET_UPDATE_OFFSETS: {
     66      // XXX loading the images is fairly costly -- see if we can do an image subset?
     67    case OP_UPDATE_OFFSETS: {
    6868      FITS_DB db;
    6969     
  • trunk/Ohana/src/relastro/src/relastro_images.c

    r35763 r36630  
    66  Catalog *catalog;
    77  FITS_DB db;
    8   struct timeval start, stop;
    98
    10   gettimeofday (&start, (void *) NULL);
     9  INITTIME;
    1110
    1211  /* register database handle with shutdown procedure */
  • trunk/Ohana/src/relastro/src/relastro_objects.c

    r35763 r36630  
    144144    // PM_TOOFEW
    145145    // SRC_MEAS_TOOFEW
    146     // FIT_TARGET
    147146
    148147    char command[1024];
  • trunk/Ohana/src/relastro/src/resort_catalog.c

    r34088 r36630  
    3030  if (catalog[0].sorted == TRUE) return;
    3131
    32   // struct timeval start, stop;
    33   // gettimeofday (&start, NULL);
     32  // INITTIME;
    3433
    3534  /* internal counters */
  • trunk/Ohana/src/relastro/src/select_images.c

    r36482 r36630  
    1515void dsortindex (double *X, off_t *Y, int N);
    1616off_t getRegionStartByRA (double R, double *Rref, off_t Nregions);
    17 
    18 # define MARKTIME(MSG,...) { \
    19   float dtime; \
    20   gettimeofday (&stop, (void *) NULL); \
    21   dtime = DTIME (stop, start); \
    22   fprintf (stderr, MSG, __VA_ARGS__); }
    2317
    2418Image *select_images (SkyList *skylist, Image *timage, off_t Ntimage, off_t **LineNumber, off_t *Nimage, int UseFullOverlap) {
     
    3125  Coords tcoords;
    3226  SkyRegionCoords *skycoords;
    33   struct timeval start, stop;
    3427 
    3528  double RmaxSkyRegion, RminSkyRegion, RmidSkyRegion, DminSkyRegion, DmaxSkyRegion;
     
    5043  }
    5144
    52   gettimeofday (&start, (void *) NULL);
     45  INITTIME;
    5346
    5447  // the comparison is made in the catalog local projection. below we set crval1,2
     
    132125    if (NphotcodesKeep > 0) {
    133126      found = FALSE;
    134       // XXX this bit of code excludes DIS mosaics and should be fixed
     127      // we have to keep DIS mosaics explicitly (photcode = 0)
     128      if (!strcmp(&timage[i].coords.ctype[4], "-DIS")) found = TRUE;
    135129      for (k = 0; (k < NphotcodesKeep) && !found; k++) {
    136130        if (photcodesKeep[k][0].code == timage[i].photcode) found = TRUE;
  • trunk/Ohana/src/relphot/Makefile

    r35416 r36630  
    4747$(SRC)/relphot_images.$(ARCH).o  \
    4848$(SRC)/relphot_objects.$(ARCH).o         \
     49$(SRC)/relphot_parallel_regions.$(ARCH).o \
     50$(SRC)/relphot_parallel_images.$(ARCH).o \
    4951$(SRC)/select_images.$(ARCH).o   \
     52$(SRC)/assign_images.$(ARCH).o   \
     53$(SRC)/launch_region_hosts.$(ARCH).o     \
     54$(SRC)/ImageTable.$(ARCH).o      \
     55$(SRC)/ImageMagIO.$(ARCH).o      \
     56$(SRC)/syncfile.$(ARCH).o        \
     57$(SRC)/share_image_mags.$(ARCH).o        \
     58$(SRC)/share_mean_mags.$(ARCH).o         \
     59$(SRC)/MeanMagIO.$(ARCH).o       \
     60$(SRC)/indexCatalog.$(ARCH).o    \
    5061$(SRC)/client_logger.$(ARCH).o   \
    5162$(SRC)/setExclusions.$(ARCH).o   \
  • trunk/Ohana/src/relphot/doc/parallel.txt

    r33651 r36630  
     1
     22014.02.15
     3
     4Nearly done with the relphot mods.  some outstanding questions;
     5
     6 * image vs mosaic?
     7 * how do decide which images need to be shared?
     8
     92014.02.14
     10
     11 more relphot notes:
     12
     13 * I load the catalogs, with a 
     14
     152014.02.12
     16
     17I am making progess on the relphot -parallel-regions implementation.  some things I need to deal with:
     18
     19 * assign_images: select mosaics for all images saved for a given host (need to supply them as well)
     20   ** I need to decide on the Image / Mosaic split.  If I am calibrating by image, then the image center defines ownership
     21   ** if I am calibrating by exposure, then the mosaic center must define ownership
     22 o determine SkyList covering the images for region host
     23 o tag detections and objects which I own or do not own
     24   o ImageOps.c / matchImage matches detections to images and needs to handle mine / not mine cases
     25   o ditto for matchMosaics
     26 o load_catalogs : I need to make my requested catalogs unique (just add uniquer to load_catalogs.c:130
     27 o figure out what fields I'm saving in meanmags and how to construct it
     28   -- mag, objID, catID, photcode, (dmag or other stats?)
     29 * from which hosts do I slurp mean mags?
     30 o function to merge a new meanmag array into the existing one
     31 o how to go from (objID,catID) to a given catalog[i].average[j]
     32
     332014.02.06
     34
     35** a single region-level host owns images for which the center lands
     36   in its region.
     37
     38** it owns detections which come from images which it owns
     39   
     40** it owns objects which land in its region
     41
     42Extending parallel relphot processing to split the sky (and images)
     43into regions, each of which runs in parallel at the same time:
     44
     45Top Level (relphot -parallel-images):
     46 * define regions of the sky -> hosts
     47 * load images, assign to hosts
     48 * launch region-level jobs on remote hosts
     49
     50 Region Level (relphot -parallel-images-region)
     51  * load my image subset table
     52  * request objects and detections for my skyregion
     53  * match images & objects, etc
     54
     55  * update my image parameters
     56  * update my detections
     57  * write out detections
     58  * load detections from my border hosts
     59  * match to my objects
     60  * update my objects
     61  * write out objects
     62  * load objects from my border hosts
     63  * update images
     64    (iterate N times)
     65  * write out image parameters
     66
     67Top Level
     68  * read image parameters, update
     69  * update objects
    170
    2712012.02.13
  • trunk/Ohana/src/relphot/include/relphot.h

    r36528 r36630  
    2323// # define IDX_T off_t
    2424# define IDX_T int
     25
     26typedef enum {
     27  MODE_ERROR = 0,
     28  UPDATE_IMAGES,
     29  UPDATE_AVERAGES,
     30  PARALLEL_REGIONS,
     31  PARALLEL_IMAGES,
     32  APPLY_OFFSETS,
     33} RelphotMode;
    2534
    2635typedef enum {
     
    108117
    109118typedef struct {
     119  float M;
     120  float dM;
     121  float Xm;
     122  int Nsec;
     123  unsigned int objID;
     124  unsigned int catID;
     125  int photcode;
     126} MeanMag;
     127
     128typedef struct {
     129  float Mcal;
     130  float dMcal;
     131  float dMagSys;
     132  float Xm;
     133  int nFitPhotom;
     134  int flags;
     135  unsigned int imageID;
     136  short ubercalDist;
     137} ImageMag;
     138
     139typedef struct {
    110140  AverageTiny *average;       // array of (minimal) average data
    111141  MeasureTiny *measure;       // array of (minimal) measure data
     
    155185int    SKY_DEPTH;  /** XXX EAM : depth of catalog tables, fix usage */
    156186
     187// globals for parallel region operations
     188char  *REGION_FILE;
     189char  *IMAGE_TABLE;
     190int    REGION_HOST_ID;
     191
    157192int          HOST_ID;
    158193char        *HOSTDIR;
     
    179214int    PARALLEL_MANUAL;
    180215int    PARALLEL_SERIAL;
     216
     217int    PARALLEL_REGIONS_MANUAL;
    181218
    182219int    NTHREADS;
     
    266303void          InterpolateGrid     PROTO((float *buffer, int Nx, int Ny, Coords *ccd, Coords *gcoords));
    267304off_t        *SelectRefMosaic     PROTO((Mosaic **refmosaic, off_t *Nimage));
    268 int           args                PROTO((int argc, char **argv));
     305RelphotMode   args                PROTO((int argc, char **argv));
    269306int           args_client         PROTO((int argc, char **argv));
    270307int           bcatalog            PROTO((Catalog *subcatalog, Catalog *catalog, int Ncat));
     
    279316void          findImages          PROTO((Catalog *catalog, int Ncatalog, int doImageList));
    280317int           findMosaics         PROTO((Catalog *catalog, int Ncatalog, int doMosaicList));
     318
     319void makeMosaics (Image *image, off_t Nimage);
     320Mosaic *getMosaicForImage (off_t im);
     321void setMosaicCenters (Image *image, off_t Nimage);
    281322
    282323void set_db (FITS_DB *in);
     
    315356void          initMosaics         PROTO((Image *subset, off_t Nsubset, Image *image, char *inSubset, off_t Nimage));
    316357void          initMrel            PROTO((Catalog *catalog, int Ncatalog));
    317 void          initialize          PROTO((int argc, char **argv));
     358RelphotMode   initialize          PROTO((int argc, char **argv));
    318359void          initialize_client   PROTO((int argc, char **argv));
    319360void          liststats_setmode   PROTO((StatType *stats, char *strmode));
     
    426467int init_synthetic_mags ();
    427468int add_synthetic_mags (AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, off_t *Nmeasure, off_t *Nm);
     469
     470int relphot_parallel_regions ();
     471
     472int assign_images (FITS_DB *db, RegionHostTable *regionHosts);
     473int select_images_hostregion (RegionHostTable *hosts, Image *image, off_t Nimage);
     474int find_host_for_coords (RegionHostTable *regionHosts, double R, double d);
     475int calculate_image_bounds (Image *image, double *rmin, double *rmax, double *dmin, double *dmax, double Rmid);
     476
     477int launch_region_hosts (RegionHostTable *regionHosts);
     478int strextend (char *input, char *format,...);
     479
     480Image *ImageTableLoad(char *filename, off_t *nimage);
     481int ImageTableSave (char *filename, Image *images, off_t Nimages);
     482
     483int indexCatalogs (Catalog *catalog, int Ncatalog);
     484int catID_and_objID_to_seq (int catID, int objID, int *catSeq, off_t *objSeq);
     485
     486int check_sync_file (char *filename, int nloop);
     487int clear_sync_file (char *filename);
     488int update_sync_file (char *filename, int nloop);
     489char *make_filename (char *dirname, char *hostname, int hostID, char *tailname);
     490
     491int share_mean_mags (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop);
     492int slurp_mean_mags (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop);
     493int set_mean_mags (MeanMag *meanmags, AverageTiny *average, SecFilt *secfilt, int Nsec);
     494MeanMag *merge_mean_mags (MeanMag *target, int *ntarget, MeanMag *source, int Nsource);
     495
     496MeanMag *MeanMagLoad(char *filename, off_t *nmeanmags);
     497int MeanMagSave(char *filename, MeanMag *meanmags, off_t Nmeanmags);
     498
     499int share_image_mags (RegionHostTable *regionHosts, int nloop);
     500int slurp_image_mags (RegionHostTable *regionHosts, int nloop);
     501int set_image_mags (ImageMag *image_mags, Image *image);
     502ImageMag *merge_image_mags (ImageMag *target, int *ntarget, ImageMag *source, int Nsource);
     503
     504ImageMag *ImageMagLoad(char *filename, off_t *nimage_mags);
     505int ImageMagSave(char *filename, ImageMag *image_mags, off_t Nimage_mags);
     506
     507int markObjects (Catalog *catalog, int Ncatalog);
     508
     509int relphot_parallel_images ();
     510int relphot_parallel_regions ();
  • trunk/Ohana/src/relphot/src/BrightCatalog.c

    r33651 r36630  
    101101      measure[i].catID     = catID[i];
    102102      measure[i].photcode  = photcode[i];
     103      measure[i].myDet     = FALSE;
    103104    }
    104105    fprintf (stderr, "loaded data for %lld measure\n", (long long) Nrow);
     
    141142    GET_COLUMN(flags,         "FLAGS",       int);
    142143    GET_COLUMN(catID,         "CAT_ID",      int);
     144    GET_COLUMN(objID,         "OBJ_ID",      int);
    143145    gfits_free_header (&theader);
    144146    gfits_free_table  (&ftable);
     
    153155      average[i].flags          = flags[i];
    154156      average[i].catID          = catID[i];
     157      average[i].objID          = objID[i];
     158      average[i].nOwn           = 0;
    155159    }
    156160    fprintf (stderr, "loaded data for %lld average\n", (long long) Nrow);
     
    162166    free (flags         );
    163167    free (catID         );
     168    free (objID         );
    164169
    165170    catalog->average = average;
     
    370375    gfits_define_bintable_column (&theader, "J", "FLAGS",       "flags",                  NULL,    1.0, 0.0);
    371376    gfits_define_bintable_column (&theader, "J", "CAT_ID",      "catalog ref",            NULL,    1.0, 0.0);
     377    gfits_define_bintable_column (&theader, "J", "OBJ_ID",      "object ref",             NULL,    1.0, 0.0);
    372378
    373379    // generate the output array that carries the data
     
    381387    int   *flags          ; ALLOCATE (flags,         int,    catalog->Naverage);
    382388    int   *catID          ; ALLOCATE (catID,         int,    catalog->Naverage);
     389    int   *objID          ; ALLOCATE (objID,         int,    catalog->Naverage);
    383390
    384391    // assign the storage arrays
     
    391398      flags[i]          = average[i].flags;
    392399      catID[i]          = average[i].catID;
     400      objID[i]          = average[i].objID;
    393401    }
    394402
     
    400408    gfits_set_bintable_column (&theader, &ftable, "FLAGS",       flags,         catalog->Naverage);
    401409    gfits_set_bintable_column (&theader, &ftable, "CAT_ID",      catID,         catalog->Naverage);
     410    gfits_set_bintable_column (&theader, &ftable, "OBJ_ID",      objID,         catalog->Naverage);
    402411
    403412    free (R             );
     
    407416    free (flags         );
    408417    free (catID         );
     418    free (objID         );
    409419
    410420    gfits_fwrite_Theader (f, &theader);
  • trunk/Ohana/src/relphot/src/ImageOps.c

    r36491 r36630  
    244244 
    245245  int Nmatch = 0;
    246  for (i = 0; i < Ncatalog; i++) {
     246  for (i = 0; i < Ncatalog; i++) {
    247247    for (j = 0; j < catalog[i].Nmeasure; j++) {
     248      catalog[i].measureT[j].myDet = FALSE; // a detetion is not mine until proven otherwise
    248249      ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[j].photcode);
     250
     251      // skip measurements which do not match one of the requested photcodes (
     252      // (do we not already exclude in bcatalog -- maybe needed for reload_objects?
    249253      found = FALSE;
    250254      for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) {
     
    252256      }
    253257      if (!found) continue;
     258
     259      // if we match one of our images, myDet gets set to TRUE
    254260      matchImage (catalog, j, i, doImageList);
    255261      Nmatch ++;
     
    322328    return;
    323329  }
     330  catalog[cat].measureT[meas].myDet = TRUE;
    324331
    325332  if (USE_GRID) {
  • trunk/Ohana/src/relphot/src/MosaicOps.c

    r36491 r36630  
    320320}
    321321
     322/* find mosaic frames (unique time periods) (NOTE : we do NOT require matching photcodes but we
     323   match images by MOSAICNAME.  this last point is weak: it forces a single camera at a time.
     324   we can extend the logic to multiple cameras if we make list of MOSAICNAMES (better to assign a camera ID)
     325 */
     326void makeMosaics (Image *image, off_t Nimage) {
     327
     328  off_t i, j, status, found, NMOSAIC, *MosaicN_IMAGE;
     329  unsigned int start, stop, *startTimes, *startTimesMosaic;
     330  char *pname;
     331
     332  if (!MOSAIC_ZEROPT) return;
     333
     334  INITTIME;
     335
     336  /* a 'mosaic' in relphot is (unlike relastro) a virtual concept: there is no
     337   * entry in the image table that represents this mosaic.  Instead, it is an
     338   * internal construct that defines a group of related images
     339   */
     340
     341  // generate a list of all image start times
     342  ALLOCATE (startTimes, unsigned int, Nimage);
     343  for (i = 0; i < Nimage; i++) {
     344    startTimes[i] = image[i].tzero;
     345  }
     346  sort_times (startTimes, Nimage);
     347  MARKTIME("create array of all image obstimes: %f sec\n", dtime);
     348 
     349  Nmosaic = 0;
     350  NMOSAIC = 1000;
     351  ALLOCATE (startTimesMosaic, unsigned int, NMOSAIC);
     352  startTimesMosaic[0] = startTimes[0];
     353
     354  // generate a list of the unique start times (these define the mosaics)
     355  for (i = 0; i < Nimage; i++) {
     356    if (startTimes[i] < startTimesMosaic[Nmosaic]) {
     357      fprintf (stderr, "error?\n");
     358      abort();
     359    }
     360    if (startTimes[i] == startTimesMosaic[Nmosaic]) continue;
     361    Nmosaic ++;
     362    if (Nmosaic >= NMOSAIC) {
     363      NMOSAIC += 1000;
     364      REALLOCATE (startTimesMosaic, unsigned int, NMOSAIC);
     365    }
     366    startTimesMosaic[Nmosaic] = startTimes[i];
     367  }
     368  Nmosaic ++;
     369  MARKTIME("create array of mosaic obstimes: %f sec\n", dtime);
     370
     371  // now I have a list of uniq start times, and they are in order
     372  // create the mosaic arrays for these times
     373  ALLOCATE (mosaic, Mosaic, Nmosaic);
     374
     375  ALLOCATE (MosaicToImage, off_t *, Nmosaic);
     376  ALLOCATE (MosaicN_Image, off_t,   Nmosaic);
     377  ALLOCATE (MosaicN_IMAGE, off_t,   Nmosaic);
     378
     379  // init the mosaic array values
     380  for (i = 0; i < Nmosaic; i++) {
     381    mosaic[i].start = startTimesMosaic[i];
     382    mosaic[i].stop  = 0;
     383    mosaic[i].Mcal  = 0.0;
     384    mosaic[i].dMcal = 0.0;
     385    mosaic[i].dMsys = 0.0;
     386    mosaic[i].Xm    = 0.0;
     387    mosaic[i].flags = 0;
     388    mosaic[i].secz  = NAN;
     389    mosaic[i].photcode = 0;
     390    mosaic[i].skipCal = FALSE;
     391   
     392    memset (&mosaic[i].coords, 0, sizeof(Coords));
     393
     394    MosaicN_IMAGE[i] = 10;
     395    MosaicN_Image[i] = 0;
     396    ALLOCATE (MosaicToImage[i], off_t, MosaicN_IMAGE[i]);
     397    MosaicToImage[i][0] = -1;
     398  }
     399
     400  ALLOCATE (ImageToMosaic, off_t, Nimage); // mosaic to which image belongs
     401
     402  // assign each image to a mosaic
     403  for (i = 0; i < Nimage; i++) {
     404    ImageToMosaic[i] = -1;
     405
     406    /* select valid mosaic images by photcode */
     407    pname = GetPhotcodeNamebyCode (image[i].photcode);
     408    if (!pname) continue;
     409
     410    status = strncmp (pname, MOSAICNAME, strlen (MOSAICNAME));
     411    if (status) continue;
     412
     413    start = image[i].tzero;
     414    stop  = image[i].tzero + MAX(1.01*image[i].trate*image[i].NY, 1);
     415
     416    j = findMosaic(startTimesMosaic, Nmosaic, start);
     417    if (j == -1) {
     418      fprintf (stderr, "programming error? all image images should belong to a mosaic\n");
     419      abort();
     420    }
     421
     422    // add reference from image to mosaic
     423    ImageToMosaic[i] = j;
     424
     425    // have we already found this mosaic?
     426    found = (MosaicN_Image[j] > 0);
     427
     428    /* add image to mosaic image list */
     429    MosaicToImage[j][MosaicN_Image[j]] = i;
     430    MosaicN_Image[j] ++;
     431    if (MosaicN_Image[j] == MosaicN_IMAGE[j]) {
     432      MosaicN_IMAGE[j] += 10;
     433      REALLOCATE (MosaicToImage[j], off_t, MosaicN_IMAGE[j]);
     434    }
     435    if (found) continue;
     436   
     437    /* a new mosaic, define ranges */
     438    if (mosaic[j].start != start) {
     439      fprintf (stderr, "error?\n");
     440      abort();
     441    }
     442    mosaic[j].stop  = stop;
     443    mosaic[j].Mcal  = 0.0;
     444    mosaic[j].dMcal = 0.0;
     445    mosaic[j].Xm    = 0.0;
     446    mosaic[j].dMsys = image[i].flags;
     447    mosaic[j].flags = image[i].flags;
     448    mosaic[j].secz  = image[i].secz;
     449    mosaic[j].photcode = GetPhotcodeEquivCodebyCode (image[i].photcode);
     450  }
     451  MARKTIME("assign images to mosaic: %f sec\n", dtime);
     452
     453  // free this or not?
     454  free (MosaicN_IMAGE);
     455  free (startTimes);
     456  free (startTimesMosaic);
     457
     458  fprintf (stderr, "matched %d images to %d mosaics\n", (int) Nimage, (int) Nmosaic);
     459
     460  return;
     461}
     462
     463Mosaic *getMosaicForImage (off_t im) {
     464
     465  if (im < 0) return NULL;
     466  if (!ImageToMosaic) return NULL;
     467
     468  off_t m = ImageToMosaic[im];
     469  if (m < 0) return NULL;
     470  if (m >= Nmosaic) return NULL;
     471
     472  return (&mosaic[m]);
     473}
     474
    322475// use bisection to find the overlapping mosaic (returns exact match)
    323476// startTimes is a sorted, unique list of times
     
    350503  }
    351504  return (-1);
     505}
     506
     507void setMosaicCenters (Image *image, off_t Nimage) {
     508
     509  /* find max dR, dD range for all mosaics */
     510  /* define mosaic.coords to cover dR, dD */
     511  /* send results to initGridBins */
     512
     513  off_t i, j, m, NX, NY, NC, Nc;
     514  double R, D, Rmid, Dmid;
     515  double Mcal, dMcal, Xm;
     516  double *Rc, *Dc;
     517
     518  NC = 100;
     519  ALLOCATE (Rc, double, NC);
     520  ALLOCATE (Dc, double, NC);
     521
     522  for (i = 0; i < Nmosaic; i++) {
     523    Nc = 0;
     524    Rmid = Dmid = NAN;
     525    Mcal = dMcal = Xm = 0;
     526    for (j = 0; j < MosaicN_Image[i]; j++) {
     527      m = MosaicToImage[i][j];
     528
     529      if (!FindMosaicForImage (image, Nimage, m)) {
     530        if (VERBOSE2) fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);
     531        continue;
     532      }
     533
     534      NX = image[m].NX;
     535      NY = image[m].NY;
     536      XY_to_RD (&R, &D, 0.5*NX, 0.5*NY, &image[m].coords);
     537      R = ohana_normalize_angle_to_midpoint (R, 180.0);
     538
     539      // Exclude images with crazy astrometry
     540      // XXX NOTE : this is gpc1-specific
     541      {
     542        double dP1 = hypot(image[m].coords.pc1_1, image[m].coords.pc1_2);
     543        double dP2 = hypot(image[m].coords.pc2_1, image[m].coords.pc2_2);
     544        if (fabs(dP1 - 1.0) > 0.02) continue;
     545        if (fabs(dP2 - 1.0) > 0.02) continue;
     546
     547        double X00, Y00, X10, Y10, X01, Y01;
     548        XY_to_LM (&X00, &Y00, 0.0, 0.0, &image[m].coords);
     549        XY_to_LM (&X10, &Y10, image[m].NX, 0.0, &image[m].coords);
     550        XY_to_LM (&X01, &Y01, 0.0, image[m].NY, &image[m].coords);
     551        double dS0 = hypot ((X00 - X10), (Y00 - Y10));
     552        double dS1 = hypot ((X00 - X01), (Y00 - Y01));
     553        if (dS0 > 6000) continue;
     554        if (dS1 > 6500) continue;
     555      }
     556
     557      Rc[Nc] = R;
     558      Dc[Nc] = D;
     559      Nc ++;
     560      if (Nc >= NC) {
     561        NC += 100;
     562        REALLOCATE (Rc, double, NC);
     563        REALLOCATE (Dc, double, NC);
     564      }
     565
     566      Mcal  += image[m].Mcal;
     567      dMcal += image[m].dMcal;
     568      Xm    += image[m].Xm;
     569
     570      // for ubercal images, we (elsewhere) keep Mcal frozen
     571
     572      /* we are using mosaic.Mcal, not image.Mcal. reset image.Mcal */
     573      image[m].Mcal  = 0.0;
     574      image[m].dMcal = NAN;
     575      image[m].Xm    = NAN_S_SHORT;
     576    }
     577
     578    if (Nc > 0) {
     579      dsort (Rc, Nc);
     580      if (Rc[Nc-1] - Rc[0] > 180.0) {
     581        // in our list, Rc is in the range 0.0 to 360.0. 
     582        // any mosaic which is close to the 0.0, 360.0 boundary may have some on
     583        // one side or the other.  count how many have values more than Rc[0] + 180.
     584        // if more than half are at the large end, re-normalize to that range
     585        int Nbig = 0;
     586        for (j = 1; j < Nc; j++) {
     587          if (Rc[j] - Rc[0] > 180.0) Nbig ++;
     588        }
     589        if (Nbig  > 0.5*Nc) {
     590          for (j = 0; j < Nc; j++) {
     591            Rc[j] = ohana_normalize_angle_to_midpoint (Rc[j], 360.0);
     592          }
     593          dsort (Rc, Nc);
     594        } else if (Nbig > 0) {
     595          for (j = 0; j < Nc; j++) {
     596            Rc[j] = ohana_normalize_angle_to_midpoint (Rc[j], 0.0);
     597          }
     598          dsort (Rc, Nc);
     599        }
     600      }
     601      dsort (Dc, Nc);
     602
     603      Rmid = Rc[(int)(0.5*Nc)];
     604      Dmid = Dc[(int)(0.5*Nc)];
     605    }
     606
     607    strcpy (mosaic[i].coords.ctype, "DEC--TAN");
     608    mosaic[i].coords.crval1 = Rmid;
     609    mosaic[i].coords.crval2 = Dmid;
     610    mosaic[i].coords.crpix1 = 0.0;
     611    mosaic[i].coords.crpix2 = 0.0;
     612    mosaic[i].coords.cdelt1 = 1.0 / 3600.0;
     613    mosaic[i].coords.cdelt2 = 1.0 / 3600.0;
     614    mosaic[i].coords.pc1_1  = 1.0;
     615    mosaic[i].coords.pc2_2  = 1.0;
     616    mosaic[i].coords.pc1_2  = 0.0;
     617    mosaic[i].coords.pc2_1  = 0.0;
     618
     619    mosaic[i].Mcal  = Mcal / MosaicN_Image[i];
     620    mosaic[i].dMcal = dMcal / MosaicN_Image[i];
     621    mosaic[i].Xm    = Xm / MosaicN_Image[i];
     622  }
     623  return;
    352624}
    353625
     
    527799
    528800  if (!MOSAIC_ZEROPT) return (FALSE);
     801  // if we are calibrating by mosaic, redefine myDet == on one of my mosaics
    529802
    530803  int Nmatch = 0;
    531804  for (i = 0; i < Ncatalog; i++) {
    532805    for (j = 0; j < catalog[i].Nmeasure; j++) {
     806      catalog[i].measureT[j].myDet = FALSE; // a detetion is not mine until proven otherwise
     807
    533808      if (TimeSelect) {
    534809        if (catalog[i].measureT[j].t < TSTART) continue;
     
    582857  }
    583858
     859  // this measurement is on one of my mosaics, mark it as mine.
     860  catalog[cat].measureT[meas].myDet = TRUE;
    584861  MeasureToMosaic[cat][meas] = mosID;
    585862
  • trunk/Ohana/src/relphot/src/StarOps.c

    r36528 r36630  
    908908}
    909909
     910int markObjects (Catalog *catalog, int Ncatalog) {
     911
     912  int i, n;
     913  off_t j;
     914
     915  // How strongly do I own this object?
     916  for (i = 0; i < Ncatalog; i++) {
     917    for (j = 0; j < catalog[i].Naverage; j++) {
     918      int nOwn = 0;
     919      int m = catalog[i].averageT[j].measureOffset;
     920      for (n = 0; n < catalog[i].averageT[j].Nmeasure; n++) {
     921        if (!catalog[i].measureT[m+n].myDet) continue;
     922        nOwn ++;
     923      }
     924      catalog[i].averageT[j].nOwn = nOwn;
     925    }
     926  }
     927  return TRUE;
     928}
     929
     930int dumpObjects (char *filename, Catalog *catalog, int Ncatalog) {
     931
     932  int i, n;
     933  off_t j;
     934
     935  FILE *ftest = fopen (filename, "w");
     936
     937  for (i = 0; i < Ncatalog; i++) {
     938    for (j = 0; j < catalog[i].Naverage; j++) {
     939      int m = catalog[i].averageT[j].measureOffset;
     940      for (n = 0; n < catalog[i].averageT[j].Nmeasure; n++) {
     941        fprintf (ftest, "%08x %08x %10.6f %10.6f  %3d %1d\n", catalog[i].averageT[j].catID, catalog[i].averageT[j].objID, catalog[i].averageT[j].R, catalog[i].averageT[j].D, catalog[i].averageT[j].Nmeasure, catalog[i].measureT[m+n].myDet);
     942      }
     943    }
     944  }
     945  fclose (ftest);
     946  return TRUE;
     947}
     948
    910949void clean_stars (Catalog *catalog, int Ncatalog) {
    911950
  • trunk/Ohana/src/relphot/src/args.c

    r36491 r36630  
    11# include "relphot.h"
    22
    3 int args (int argc, char **argv) {
     3RelphotMode args (int argc, char **argv) {
    44
    55  int N;
    66  double trange;
     7
     8  /* define time */
     9  TimeSelect = FALSE;
     10  if ((N = get_argument (argc, argv, "-time"))) {
     11    remove_argument (N, &argc, argv);
     12    if (!ohana_str_to_time (argv[N], &TSTART)) {
     13      fprintf (stderr, "ERROR: syntax error\n");
     14      return (MODE_ERROR);
     15    }
     16    remove_argument (N, &argc, argv);
     17    if (!ohana_str_to_dtime (argv[N], &trange)) {
     18      if (!ohana_str_to_time (argv[N], &TSTOP)) {
     19        fprintf (stderr, "ERROR: syntax error\n");
     20        return (MODE_ERROR);
     21      }
     22    } else {
     23      if (trange < 0) {
     24        trange = fabs (trange);
     25        TSTOP = TSTART;
     26        TSTART -= trange;
     27      } else {
     28        TSTOP = TSTART + trange;
     29      }
     30    }
     31    remove_argument (N, &argc, argv);
     32    TimeSelect = TRUE;
     33  }
     34
     35  /* specify portion of the sky */
     36  UserPatch.Rmin = 0;
     37  UserPatch.Rmax = 360;
     38  UserPatch.Dmin = -90;
     39  UserPatch.Dmax = +90;
     40  if ((N = get_argument (argc, argv, "-region"))) {
     41    remove_argument (N, &argc, argv);
     42    UserPatch.Rmin = atof (argv[N]);
     43    remove_argument (N, &argc, argv);
     44    UserPatch.Rmax = atof (argv[N]);
     45    remove_argument (N, &argc, argv);
     46    UserPatch.Dmin = atof (argv[N]);
     47    remove_argument (N, &argc, argv);
     48    UserPatch.Dmax = atof (argv[N]);
     49    remove_argument (N, &argc, argv);
     50  }
     51
     52  /* specify region file by name (eg n0000/0000.00) */
     53  UserCatalog = NULL;
     54  if ((N = get_argument (argc, argv, "-catalog"))) {
     55    remove_argument (N, &argc, argv);
     56    UserCatalog = strcreate (argv[N]);
     57    remove_argument (N, &argc, argv);
     58  }
     59
     60  USE_BASIC_CHECK = FALSE;
     61  if ((N = get_argument (argc, argv, "-basic-image-search"))) {
     62    remove_argument (N, &argc, argv);
     63    USE_BASIC_CHECK = TRUE;
     64  }
     65
     66  USE_FULL_OVERLAP = TRUE;
     67  if ((N = get_argument (argc, argv, "-sloppy-image-overlap"))) {
     68    remove_argument (N, &argc, argv);
     69    USE_FULL_OVERLAP = FALSE;
     70  }
     71
     72  SET_MREL_VERSION = 1;
     73  if ((N = get_argument (argc, argv, "-set-mrel-version"))) {
     74    remove_argument (N, &argc, argv);
     75    SET_MREL_VERSION = atof(argv[N]);
     76    remove_argument (N, &argc, argv);
     77  }
     78
     79  VERBOSE = VERBOSE2 = FALSE;
     80  if ((N = get_argument (argc, argv, "-v"))) {
     81    VERBOSE = TRUE;
     82    remove_argument (N, &argc, argv);
     83  }
     84  if ((N = get_argument (argc, argv, "-vv"))) {
     85    VERBOSE2 = VERBOSE = TRUE;
     86    remove_argument (N, &argc, argv);
     87  }
     88
     89  NTHREADS = 0;
     90  if ((N = get_argument (argc, argv, "-threads"))) {
     91    remove_argument (N, &argc, argv);
     92    NTHREADS = atof (argv[N]);
     93    remove_argument (N, &argc, argv);
     94  }
     95
     96  // XXX for the moment, make this selection manual.  it needs to be automatic
     97  // based on the state of the SkyTable
     98  HOST_ID = 0;
     99  PARALLEL = FALSE;
     100  if ((N = get_argument (argc, argv, "-parallel"))) {
     101    PARALLEL = TRUE;
     102    remove_argument (N, &argc, argv);
     103  }
     104  // this is a test mode : rather than launching the remote jobs and waiting for completion,
     105  // relphot will simply list the remote command and wait for the user to signal completion
     106  PARALLEL_MANUAL = FALSE;
     107  if ((N = get_argument (argc, argv, "-parallel-manual"))) {
     108    PARALLEL = TRUE; // -parallel-manual implies -parallel
     109    PARALLEL_MANUAL = TRUE;
     110    remove_argument (N, &argc, argv);
     111  }
     112  // this is a test mode : rather than launching the relphot_client jobs remotely, they are
     113  // run in serial via 'system'
     114  PARALLEL_SERIAL = FALSE;
     115  if ((N = get_argument (argc, argv, "-parallel-serial"))) {
     116    if (PARALLEL_MANUAL) {
     117      fprintf (stderr, "ERROR: cannot mix -parallel-manual and -parallel-serial\n");
     118      exit (1);
     119    }
     120    PARALLEL = TRUE; // -parallel-serial implies -parallel
     121    PARALLEL_SERIAL = TRUE;
     122    remove_argument (N, &argc, argv);
     123  }
     124
     125  PLOTSTUFF = FALSE;
     126  if ((N = get_argument (argc, argv, "-plot"))) {
     127    PLOTSTUFF = TRUE;
     128    remove_argument (N, &argc, argv);
     129  }
     130
     131  PLOTDELAY = 500000;
     132  if ((N = get_argument (argc, argv, "-plotdelay"))) {
     133    remove_argument (N, &argc, argv);
     134    PLOTDELAY = 1e6*atof(argv[N]);
     135    PLOTSTUFF = TRUE; // always turn on plotting if i request a plot delay
     136    remove_argument (N, &argc, argv);
     137  }
     138
     139  if ((N = get_argument (argc, argv, "-outroot"))) {
     140    remove_argument (N, &argc, argv);
     141    OUTROOT = strcreate (argv[N]);
     142    remove_argument (N, &argc, argv);
     143  } else {
     144    OUTROOT = strcreate ("relphot");
     145  }     
     146
     147  strcpy (STATMODE, "WT_MEAN");
     148  if ((N = get_argument (argc, argv, "-statmode"))) {
     149    remove_argument (N, &argc, argv);
     150    strcpy (STATMODE, argv[N]);
     151    remove_argument (N, &argc, argv);
     152  }
     153
     154  NLOOP = 8;
     155  if ((N = get_argument (argc, argv, "-n"))) {
     156    remove_argument (N, &argc, argv);
     157    NLOOP = atof (argv[N]);
     158    remove_argument (N, &argc, argv);
     159  }
     160  if ((N = get_argument (argc, argv, "-nloop"))) {
     161    remove_argument (N, &argc, argv);
     162    NLOOP = atof (argv[N]);
     163    remove_argument (N, &argc, argv);
     164  }
     165
     166  NGRID = 8;
     167  if ((N = get_argument (argc, argv, "-ngrid"))) {
     168    remove_argument (N, &argc, argv);
     169    NGRID = atof (argv[N]);
     170    remove_argument (N, &argc, argv);
     171  }
     172
     173  RESET = FALSE;
     174  if ((N = get_argument (argc, argv, "-reset"))) {
     175    remove_argument (N, &argc, argv);
     176    RESET = TRUE;
     177  }
     178
     179  RESET_ZEROPTS = FALSE;
     180  if ((N = get_argument (argc, argv, "-reset-zpts"))) {
     181    remove_argument (N, &argc, argv);
     182    RESET_ZEROPTS = TRUE;
     183  }
     184
     185  UPDATE = FALSE;
     186  if ((N = get_argument (argc, argv, "-update"))) {
     187    remove_argument (N, &argc, argv);
     188    UPDATE = TRUE;
     189  }
     190
     191  UPDATE_CATFORMAT = NULL;
     192  if ((N = get_argument (argc, argv, "-update-catformat"))) {
     193    remove_argument (N, &argc, argv);
     194    UPDATE_CATFORMAT = strcreate (argv[N]);
     195    remove_argument (N, &argc, argv);
     196  }
     197
     198  SAVE_IMAGE_UPDATES = TRUE;
     199  if ((N = get_argument (argc, argv, "-skip-image-updates"))) {
     200    remove_argument (N, &argc, argv);
     201    SAVE_IMAGE_UPDATES = FALSE;
     202  }
     203
     204  MaxDensityUse = FALSE;
     205  if ((N = get_argument (argc, argv, "-max-density"))) {
     206    remove_argument (N, &argc, argv);
     207    MaxDensityValue = atof(argv[N]);
     208    remove_argument (N, &argc, argv);
     209    MaxDensityUse = TRUE;
     210  }
     211
     212  CLOUD_TOLERANCE = 0.02;
     213  if ((N = get_argument (argc, argv, "-cloud-limit"))) {
     214    remove_argument (N, &argc, argv);
     215    CLOUD_TOLERANCE = atof(argv[N]);
     216    remove_argument (N, &argc, argv);
     217  }
     218
     219  // XXX should we load a tree from CATDIR by default?
     220  // NOTE: a given catdir needs an appropriate boundary tree
     221  BOUNDARY_TREE = NULL;
     222  if ((N = get_argument (argc, argv, "-boundary-tree"))) {
     223    remove_argument (N, &argc, argv);
     224    BOUNDARY_TREE = strcreate(argv[N]);
     225    load_tess (BOUNDARY_TREE);
     226    remove_argument (N, &argc, argv);
     227  }
     228
     229  SHOW_PARAMS = FALSE;
     230  if ((N = get_argument (argc, argv, "-params"))) {
     231    remove_argument (N, &argc, argv);
     232    SHOW_PARAMS = TRUE;
     233  }
     234
     235  PlotMmin = 10.0; PlotMmax = 20.0; PlotdMmin = -1.0; PlotdMmax = 1.0;
     236  if ((N = get_argument (argc, argv, "-plrange"))) {
     237    remove_argument (N, &argc, argv);
     238    PlotMmin = atof (argv[N]);
     239    remove_argument (N, &argc, argv);
     240    PlotMmax = atof (argv[N]);
     241    remove_argument (N, &argc, argv);
     242    PlotdMmin = atof (argv[N]);
     243    remove_argument (N, &argc, argv);
     244    PlotdMmax = atof (argv[N]);
     245    remove_argument (N, &argc, argv);
     246  }
     247
     248  /* XXX this argument used to do two things: specify the camera name and tell the analysis to
     249     calculate a common zero point for a single mosaic.  I've moved the MOSAICNAME concept into the
     250     config system, but need to use this argument to specify that the mosaic zeropoints should be
     251     calculated. */
     252  MOSAIC_ZEROPT = FALSE;
     253  if ((N = get_argument (argc, argv, "-mosaic"))) {
     254    remove_argument (N, &argc, argv);
     255    MOSAIC_ZEROPT = TRUE;
     256    if (!strcasecmp (MOSAICNAME, "none")) {
     257      fprintf (stderr, "mosaic astrometry selected by MOSAICNAME not defined\n");
     258      exit (2);
     259    }
     260  }
     261
     262  FREEZE_IMAGES = FALSE;
     263  if ((N = get_argument (argc, argv, "-imfreeze"))) {
     264    remove_argument (N, &argc, argv);
     265    FREEZE_IMAGES = TRUE;
     266  }
     267
     268  FREEZE_MOSAICS = FALSE;
     269  if ((N = get_argument (argc, argv, "-mosfreeze"))) {
     270    remove_argument (N, &argc, argv);
     271    FREEZE_MOSAICS = TRUE;
     272  }
     273
     274  // USE_GRID is not valid for all cases, probably should be its own mode...
     275  USE_GRID = FALSE;
     276  if ((N = get_argument (argc, argv, "-grid"))) {
     277    remove_argument (N, &argc, argv);
     278    USE_GRID = TRUE;
     279  }
     280
     281  KEEP_UBERCAL = TRUE;
     282  if ((N = get_argument (argc, argv, "-reset-ubercal"))) {
     283    remove_argument (N, &argc, argv);
     284    KEEP_UBERCAL = FALSE;
     285  }
     286
     287  MIN_ERROR = 0.001;
     288  if ((N = get_argument (argc, argv, "-minerror"))) {
     289    remove_argument (N, &argc, argv);
     290    MIN_ERROR = atof (argv[N]);
     291    remove_argument (N, &argc, argv);
     292    /* require MIN_ERROR > 0 */
     293  } 
     294
     295  AreaSelect = FALSE;
     296  if ((N = get_argument (argc, argv, "-area"))) {
     297    remove_argument (N, &argc, argv);
     298    AreaXmin = atof (argv[N]);
     299    remove_argument (N, &argc, argv);
     300    AreaXmax = atof (argv[N]);
     301    remove_argument (N, &argc, argv);
     302    AreaYmin = atof (argv[N]);
     303    remove_argument (N, &argc, argv);
     304    AreaYmax = atof (argv[N]);
     305    remove_argument (N, &argc, argv);
     306    AreaSelect = TRUE;
     307  }
     308
     309  ImagSelect = FALSE;
     310  if ((N = get_argument (argc, argv, "-instmag"))) {
     311    remove_argument (N, &argc, argv);
     312    ImagMin = atof (argv[N]);
     313    remove_argument (N, &argc, argv);
     314    ImagMax = atof (argv[N]);
     315    remove_argument (N, &argc, argv);
     316    ImagSelect = TRUE;
     317  }
     318
     319  DophotSelect = FALSE;
     320  if ((N = get_argument (argc, argv, "-dophot"))) {
     321    remove_argument (N, &argc, argv);
     322    DophotValue = atof (argv[N]);
     323    remove_argument (N, &argc, argv);
     324    DophotSelect = TRUE;
     325  }
     326
     327  SyntheticPhotometry = FALSE;
     328  if ((N = get_argument (argc, argv, "-synthphot"))) {
     329    remove_argument (N, &argc, argv);
     330    SyntheticPhotometry = TRUE;
     331    init_synthetic_mags();
     332  }
     333
     334  refPhotcode = NULL;
     335  if ((N = get_argument (argc, argv, "-refcode"))) {
     336    remove_argument (N, &argc, argv);
     337    refPhotcode = GetPhotcodebyName (argv[N]);
     338    if (!refPhotcode) {
     339      fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", argv[N]);
     340      exit (1);
     341    }
     342    remove_argument (N, &argc, argv);
     343  }
     344
     345  REGION_FILE = NULL;
     346  if ((N = get_argument (argc, argv, "-region-hosts"))) {
     347    remove_argument (N, &argc, argv);
     348    REGION_FILE = strcreate (argv[N]);
     349    remove_argument (N, &argc, argv);
     350  }
     351
     352  REGION_HOST_ID = 0;
     353  if ((N = get_argument (argc, argv, "-region-hostID"))) {
     354    remove_argument (N, &argc, argv);
     355    REGION_HOST_ID = atoi (argv[N]);
     356    remove_argument (N, &argc, argv);
     357  }
     358
     359  RelphotMode mode = MODE_ERROR;
     360  if ((N = get_argument (argc, argv, "-images"))) {
     361    remove_argument (N, &argc, argv);
     362    mode = UPDATE_IMAGES;
     363  }
     364  if ((N = get_argument (argc, argv, "-averages"))) {
     365    remove_argument (N, &argc, argv);
     366    mode = UPDATE_AVERAGES;
     367  }
     368  if ((N = get_argument (argc, argv, "-apply-offsets"))) {
     369    remove_argument (N, &argc, argv);
     370    mode = APPLY_OFFSETS;
     371  }
     372  IMAGE_TABLE = NULL;
     373  if ((N = get_argument (argc, argv, "-parallel-images"))) {
     374    remove_argument (N, &argc, argv);
     375    mode = PARALLEL_IMAGES;
     376    if (N >= argc) relphot_usage();
     377    IMAGE_TABLE = strcreate (argv[N]);
     378    remove_argument (N, &argc, argv);
     379    if (!REGION_FILE) relphot_usage();
     380  }
     381
     382  PARALLEL_REGIONS_MANUAL = FALSE;
     383  if ((N = get_argument (argc, argv, "-parallel-regions"))) {
     384    remove_argument (N, &argc, argv);
     385    mode = PARALLEL_REGIONS;
     386    if (!REGION_FILE) relphot_usage();
     387    if ((N = get_argument (argc, argv, "-parallel-regions-manual"))) {
     388      remove_argument (N, &argc, argv);
     389      PARALLEL_REGIONS_MANUAL = TRUE;
     390    }
     391  }
     392
     393  switch (mode) {
     394    case UPDATE_AVERAGES:
     395      if (argc != 1) relphot_usage();
     396      break;
     397     
     398    case UPDATE_IMAGES:
     399    case PARALLEL_IMAGES:
     400    case PARALLEL_REGIONS:
     401      PhotcodeList = strcreate (argv[1]);
     402      photcodes = ParsePhotcodeList (PhotcodeList, &Nphotcodes, TRUE); // require SEC photcodes
     403      remove_argument (1, &argc, argv);
     404      break;
     405
     406    default:
     407      fprintf (stderr, "no valid mode selected\n");
     408      relphot_usage();
     409      break;
     410  }
     411  if (argc != 1) relphot_usage ();
     412
     413  return mode;
     414}
     415
     416int args_client (int argc, char **argv) {
     417
     418  int N;
     419  double trange;
     420
     421  // by definition, the client is not parallel
     422  PARALLEL = FALSE;
     423  PARALLEL_MANUAL = FALSE;
     424  PARALLEL_SERIAL = FALSE;
     425
     426  HOST_ID = 0;
     427  if ((N = get_argument (argc, argv, "-hostID"))) {
     428    remove_argument (N, &argc, argv);
     429    HOST_ID = atoi (argv[N]);
     430    remove_argument (N, &argc, argv);
     431  }
     432  if (!HOST_ID) relphot_client_usage();
     433
     434  HOSTDIR = NULL;
     435  if ((N = get_argument (argc, argv, "-hostdir"))) {
     436    remove_argument (N, &argc, argv);
     437    HOSTDIR = strcreate (argv[N]);
     438    remove_argument (N, &argc, argv);
     439  }
     440  if (!HOSTDIR) relphot_client_usage();
     441
     442  IMAGES = NULL; // used in -update mode
     443  BCATALOG = NULL; // used in -load mode
     444  MODE = MODE_NONE;
     445  if ((N = get_argument (argc, argv, "-load"))) {
     446    MODE = MODE_LOAD;
     447    remove_argument (N, &argc, argv);
     448    BCATALOG = strcreate (argv[N]);
     449    remove_argument (N, &argc, argv);
     450  }
     451  if ((N = get_argument (argc, argv, "-update-catalogs"))) {
     452    if (MODE) {
     453      fprintf (stderr, "ERROR: cannot mix modes (-load, -update-catalogs, -update-objects)\n");
     454      relphot_client_usage();
     455    }
     456    MODE = MODE_UPDATE;
     457    remove_argument (N, &argc, argv);
     458    IMAGES = strcreate (argv[N]);
     459    remove_argument (N, &argc, argv);
     460  }
     461  if ((N = get_argument (argc, argv, "-update-objects"))) {
     462    if (MODE) {
     463      fprintf (stderr, "ERROR: cannot mix modes (-load, -update-catalogs, -update-objects)\n");
     464      relphot_client_usage();
     465    }
     466    MODE = MODE_UPDATE_OBJECTS;
     467    remove_argument (N, &argc, argv);
     468  }
     469  if (!MODE) relphot_client_usage();
     470
     471  strcpy (STATMODE, "WT_MEAN");
     472  if ((N = get_argument (argc, argv, "-statmode"))) {
     473    remove_argument (N, &argc, argv);
     474    strcpy (STATMODE, argv[N]);
     475    remove_argument (N, &argc, argv);
     476  }
     477
     478  BOUNDARY_TREE = NULL;
     479  if ((N = get_argument (argc, argv, "-boundary-tree"))) {
     480    remove_argument (N, &argc, argv);
     481    BOUNDARY_TREE = strcreate(argv[N]);
     482    load_tess (BOUNDARY_TREE);
     483    remove_argument (N, &argc, argv);
     484  }
     485
     486  /* specify portion of the sky */
     487  UserPatch.Rmin = 0;
     488  UserPatch.Rmax = 360;
     489  UserPatch.Dmin = -90;
     490  UserPatch.Dmax = +90;
     491  if ((N = get_argument (argc, argv, "-region"))) {
     492    remove_argument (N, &argc, argv);
     493    UserPatch.Rmin = atof (argv[N]);
     494    remove_argument (N, &argc, argv);
     495    UserPatch.Rmax = atof (argv[N]);
     496    remove_argument (N, &argc, argv);
     497    UserPatch.Dmin = atof (argv[N]);
     498    remove_argument (N, &argc, argv);
     499    UserPatch.Dmax = atof (argv[N]);
     500    remove_argument (N, &argc, argv);
     501  }
     502
     503  SET_MREL_VERSION = 1;
     504  if ((N = get_argument (argc, argv, "-set-mrel-version"))) {
     505    remove_argument (N, &argc, argv);
     506    SET_MREL_VERSION = atof(argv[N]);
     507    remove_argument (N, &argc, argv);
     508  }
     509
     510  VERBOSE = VERBOSE2 = FALSE;
     511  if ((N = get_argument (argc, argv, "-v"))) {
     512    VERBOSE = TRUE;
     513    remove_argument (N, &argc, argv);
     514  }
     515  if ((N = get_argument (argc, argv, "-vv"))) {
     516    VERBOSE2 = VERBOSE = TRUE;
     517    remove_argument (N, &argc, argv);
     518  }
     519
     520  RESET = FALSE;
     521  if ((N = get_argument (argc, argv, "-reset"))) {
     522    remove_argument (N, &argc, argv);
     523    RESET = TRUE;
     524  }
     525
     526  RESET_ZEROPTS = FALSE;
     527  if ((N = get_argument (argc, argv, "-reset-zpts"))) {
     528    remove_argument (N, &argc, argv);
     529    RESET_ZEROPTS = TRUE;
     530  }
     531
     532  KEEP_UBERCAL = TRUE;
     533  if ((N = get_argument (argc, argv, "-reset-ubercal"))) {
     534    remove_argument (N, &argc, argv);
     535    KEEP_UBERCAL = FALSE;
     536  }
    7537
    8538  /* define time */
     
    33563  }
    34564
    35   /* specify portion of the sky */
    36   UserPatch.Rmin = 0;
    37   UserPatch.Rmax = 360;
    38   UserPatch.Dmin = -90;
    39   UserPatch.Dmax = +90;
    40   if ((N = get_argument (argc, argv, "-region"))) {
    41     remove_argument (N, &argc, argv);
    42     UserPatch.Rmin = atof (argv[N]);
    43     remove_argument (N, &argc, argv);
    44     UserPatch.Rmax = atof (argv[N]);
    45     remove_argument (N, &argc, argv);
    46     UserPatch.Dmin = atof (argv[N]);
    47     remove_argument (N, &argc, argv);
    48     UserPatch.Dmax = atof (argv[N]);
    49     remove_argument (N, &argc, argv);
    50   }
    51 
    52   /* specify region file by name (eg n0000/0000.00) */
    53   UserCatalog = NULL;
    54   if ((N = get_argument (argc, argv, "-catalog"))) {
    55     remove_argument (N, &argc, argv);
    56     UserCatalog = strcreate (argv[N]);
    57     remove_argument (N, &argc, argv);
    58   }
    59 
    60   USE_BASIC_CHECK = FALSE;
    61   if ((N = get_argument (argc, argv, "-basic-image-search"))) {
    62     remove_argument (N, &argc, argv);
    63     USE_BASIC_CHECK = TRUE;
    64   }
    65 
    66   USE_FULL_OVERLAP = TRUE;
    67   if ((N = get_argument (argc, argv, "-sloppy-image-overlap"))) {
    68     remove_argument (N, &argc, argv);
    69     USE_FULL_OVERLAP = FALSE;
    70   }
    71 
    72   SET_MREL_VERSION = 1;
    73   if ((N = get_argument (argc, argv, "-set-mrel-version"))) {
    74     remove_argument (N, &argc, argv);
    75     SET_MREL_VERSION = atof(argv[N]);
    76     remove_argument (N, &argc, argv);
    77   }
    78 
    79   VERBOSE = VERBOSE2 = FALSE;
    80   if ((N = get_argument (argc, argv, "-v"))) {
    81     VERBOSE = TRUE;
    82     remove_argument (N, &argc, argv);
    83   }
    84   if ((N = get_argument (argc, argv, "-vv"))) {
    85     VERBOSE2 = VERBOSE = TRUE;
    86     remove_argument (N, &argc, argv);
    87   }
    88 
    89   NTHREADS = 0;
    90   if ((N = get_argument (argc, argv, "-threads"))) {
    91     remove_argument (N, &argc, argv);
    92     NTHREADS = atof (argv[N]);
    93     remove_argument (N, &argc, argv);
    94   }
    95 
    96   // XXX for the moment, make this selection manual.  it needs to be automatic
    97   // based on the state of the SkyTable
    98   HOST_ID = 0;
    99   PARALLEL = FALSE;
    100   if ((N = get_argument (argc, argv, "-parallel"))) {
    101     PARALLEL = TRUE;
    102     remove_argument (N, &argc, argv);
    103   }
    104   // this is a test mode : rather than launching the remote jobs and waiting for completion,
    105   // relphot will simply list the remote command and wait for the user to signal completion
    106   PARALLEL_MANUAL = FALSE;
    107   if ((N = get_argument (argc, argv, "-parallel-manual"))) {
    108     PARALLEL = TRUE; // -parallel-manual implies -parallel
    109     PARALLEL_MANUAL = TRUE;
    110     remove_argument (N, &argc, argv);
    111   }
    112   // this is a test mode : rather than launching the relphot_client jobs remotely, they are
    113   // run in serial via 'system'
    114   PARALLEL_SERIAL = FALSE;
    115   if ((N = get_argument (argc, argv, "-parallel-serial"))) {
    116     if (PARALLEL_MANUAL) {
    117       fprintf (stderr, "ERROR: cannot mix -parallel-manual and -parallel-serial\n");
    118       exit (1);
    119     }
    120     PARALLEL = TRUE; // -parallel-serial implies -parallel
    121     PARALLEL_SERIAL = TRUE;
    122     remove_argument (N, &argc, argv);
    123   }
    124 
    125   PLOTSTUFF = FALSE;
    126   if ((N = get_argument (argc, argv, "-plot"))) {
    127     PLOTSTUFF = TRUE;
    128     remove_argument (N, &argc, argv);
    129   }
    130 
    131   PLOTDELAY = 500000;
    132   if ((N = get_argument (argc, argv, "-plotdelay"))) {
    133     remove_argument (N, &argc, argv);
    134     PLOTDELAY = 1e6*atof(argv[N]);
    135     PLOTSTUFF = TRUE; // always turn on plotting if i request a plot delay
    136     remove_argument (N, &argc, argv);
    137   }
    138 
    139   if ((N = get_argument (argc, argv, "-outroot"))) {
    140     remove_argument (N, &argc, argv);
    141     OUTROOT = strcreate (argv[N]);
    142     remove_argument (N, &argc, argv);
    143   } else {
    144     OUTROOT = strcreate ("relphot");
    145   }     
    146 
    147   strcpy (STATMODE, "WT_MEAN");
    148   if ((N = get_argument (argc, argv, "-statmode"))) {
    149     remove_argument (N, &argc, argv);
    150     strcpy (STATMODE, argv[N]);
    151     remove_argument (N, &argc, argv);
    152   }
    153 
    154   NLOOP = 8;
    155   if ((N = get_argument (argc, argv, "-n"))) {
    156     remove_argument (N, &argc, argv);
    157     NLOOP = atof (argv[N]);
    158     remove_argument (N, &argc, argv);
    159   }
    160   if ((N = get_argument (argc, argv, "-nloop"))) {
    161     remove_argument (N, &argc, argv);
    162     NLOOP = atof (argv[N]);
    163     remove_argument (N, &argc, argv);
    164   }
    165 
    166   NGRID = 8;
    167   if ((N = get_argument (argc, argv, "-ngrid"))) {
    168     remove_argument (N, &argc, argv);
    169     NGRID = atof (argv[N]);
    170     remove_argument (N, &argc, argv);
    171   }
    172 
    173   RESET = FALSE;
    174   if ((N = get_argument (argc, argv, "-reset"))) {
    175     remove_argument (N, &argc, argv);
    176     RESET = TRUE;
    177   }
    178 
    179   RESET_ZEROPTS = FALSE;
    180   if ((N = get_argument (argc, argv, "-reset-zpts"))) {
    181     remove_argument (N, &argc, argv);
    182     RESET_ZEROPTS = TRUE;
    183   }
     565
     566  MIN_ERROR = 0.001;
     567  if ((N = get_argument (argc, argv, "-minerror"))) {
     568    remove_argument (N, &argc, argv);
     569    MIN_ERROR = atof (argv[N]);
     570    remove_argument (N, &argc, argv);
     571    /* require MIN_ERROR > 0 */
     572  } 
    184573
    185574  UPDATE = FALSE;
     
    196585  }
    197586
    198   SAVE_IMAGE_UPDATES = TRUE;
    199   if ((N = get_argument (argc, argv, "-skip-image-updates"))) {
    200     remove_argument (N, &argc, argv);
    201     SAVE_IMAGE_UPDATES = FALSE;
     587  AreaSelect = FALSE;
     588  if ((N = get_argument (argc, argv, "-area"))) {
     589    remove_argument (N, &argc, argv);
     590    AreaXmin = atof (argv[N]);
     591    remove_argument (N, &argc, argv);
     592    AreaXmax = atof (argv[N]);
     593    remove_argument (N, &argc, argv);
     594    AreaYmin = atof (argv[N]);
     595    remove_argument (N, &argc, argv);
     596    AreaYmax = atof (argv[N]);
     597    remove_argument (N, &argc, argv);
     598    AreaSelect = TRUE;
     599  }
     600
     601  SyntheticPhotometry = FALSE;
     602  if ((N = get_argument (argc, argv, "-synthphot"))) {
     603    remove_argument (N, &argc, argv);
     604    SyntheticPhotometry = FALSE;
     605    init_synthetic_mags();
     606  }
     607
     608  ImagSelect = FALSE;
     609  if ((N = get_argument (argc, argv, "-instmag"))) {
     610    remove_argument (N, &argc, argv);
     611    ImagMin = atof (argv[N]);
     612    remove_argument (N, &argc, argv);
     613    ImagMax = atof (argv[N]);
     614    remove_argument (N, &argc, argv);
     615    ImagSelect = TRUE;
     616  }
     617
     618  DophotSelect = FALSE;
     619  if ((N = get_argument (argc, argv, "-dophot"))) {
     620    remove_argument (N, &argc, argv);
     621    DophotValue = atof (argv[N]);
     622    remove_argument (N, &argc, argv);
     623    DophotSelect = TRUE;
    202624  }
    203625
     
    210632  }
    211633
    212   CLOUD_TOLERANCE = 0.02;
    213   if ((N = get_argument (argc, argv, "-cloud-limit"))) {
    214     remove_argument (N, &argc, argv);
    215     CLOUD_TOLERANCE = atof(argv[N]);
    216     remove_argument (N, &argc, argv);
    217   }
    218 
    219   // XXX should we load a tree from CATDIR by default?
    220   // NOTE: a given catdir needs an appropriate boundary tree
    221   BOUNDARY_TREE = NULL;
    222   if ((N = get_argument (argc, argv, "-boundary-tree"))) {
    223     remove_argument (N, &argc, argv);
    224     BOUNDARY_TREE = strcreate(argv[N]);
    225     load_tess (BOUNDARY_TREE);
    226     remove_argument (N, &argc, argv);
    227   }
    228 
    229   SHOW_PARAMS = FALSE;
    230   if ((N = get_argument (argc, argv, "-params"))) {
    231     remove_argument (N, &argc, argv);
    232     SHOW_PARAMS = TRUE;
    233   }
    234 
    235   PlotMmin = 10.0; PlotMmax = 20.0; PlotdMmin = -1.0; PlotdMmax = 1.0;
    236   if ((N = get_argument (argc, argv, "-plrange"))) {
    237     remove_argument (N, &argc, argv);
    238     PlotMmin = atof (argv[N]);
    239     remove_argument (N, &argc, argv);
    240     PlotMmax = atof (argv[N]);
    241     remove_argument (N, &argc, argv);
    242     PlotdMmin = atof (argv[N]);
    243     remove_argument (N, &argc, argv);
    244     PlotdMmax = atof (argv[N]);
    245     remove_argument (N, &argc, argv);
    246   }
    247 
    248   /* XXX this argument used to do two things: specify the camera name and tell the analysis to
    249      calculate a common zero point for a single mosaic.  I've moved the MOSAICNAME concept into the
    250      config system, but need to use this argument to specify that the mosaic zeropoints should be
    251      calculated. */
    252   MOSAIC_ZEROPT = FALSE;
    253   if ((N = get_argument (argc, argv, "-mosaic"))) {
    254     remove_argument (N, &argc, argv);
    255     MOSAIC_ZEROPT = TRUE;
    256     if (!strcasecmp (MOSAICNAME, "none")) {
    257       fprintf (stderr, "mosaic astrometry selected by MOSAICNAME not defined\n");
    258       exit (2);
    259     }
    260   }
    261 
    262   FREEZE_IMAGES = FALSE;
    263   if ((N = get_argument (argc, argv, "-imfreeze"))) {
    264     remove_argument (N, &argc, argv);
    265     FREEZE_IMAGES = TRUE;
    266   }
    267 
    268   FREEZE_MOSAICS = FALSE;
    269   if ((N = get_argument (argc, argv, "-mosfreeze"))) {
    270     remove_argument (N, &argc, argv);
    271     FREEZE_MOSAICS = TRUE;
    272   }
    273 
    274   USE_GRID = FALSE;
    275   if ((N = get_argument (argc, argv, "-grid"))) {
    276     remove_argument (N, &argc, argv);
    277     USE_GRID = TRUE;
    278   }
    279 
    280   KEEP_UBERCAL = TRUE;
    281   if ((N = get_argument (argc, argv, "-reset-ubercal"))) {
    282     remove_argument (N, &argc, argv);
    283     KEEP_UBERCAL = FALSE;
    284   }
    285 
    286   MIN_ERROR = 0.001;
    287   if ((N = get_argument (argc, argv, "-minerror"))) {
    288     remove_argument (N, &argc, argv);
    289     MIN_ERROR = atof (argv[N]);
    290     remove_argument (N, &argc, argv);
    291     /* require MIN_ERROR > 0 */
    292   } 
    293 
    294   AreaSelect = FALSE;
    295   if ((N = get_argument (argc, argv, "-area"))) {
    296     remove_argument (N, &argc, argv);
    297     AreaXmin = atof (argv[N]);
    298     remove_argument (N, &argc, argv);
    299     AreaXmax = atof (argv[N]);
    300     remove_argument (N, &argc, argv);
    301     AreaYmin = atof (argv[N]);
    302     remove_argument (N, &argc, argv);
    303     AreaYmax = atof (argv[N]);
    304     remove_argument (N, &argc, argv);
    305     AreaSelect = TRUE;
    306   }
    307 
    308   ImagSelect = FALSE;
    309   if ((N = get_argument (argc, argv, "-instmag"))) {
    310     remove_argument (N, &argc, argv);
    311     ImagMin = atof (argv[N]);
    312     remove_argument (N, &argc, argv);
    313     ImagMax = atof (argv[N]);
    314     remove_argument (N, &argc, argv);
    315     ImagSelect = TRUE;
    316   }
    317 
    318   DophotSelect = FALSE;
    319   if ((N = get_argument (argc, argv, "-dophot"))) {
    320     remove_argument (N, &argc, argv);
    321     DophotValue = atof (argv[N]);
    322     remove_argument (N, &argc, argv);
    323     DophotSelect = TRUE;
    324   }
    325 
    326   SyntheticPhotometry = FALSE;
    327   if ((N = get_argument (argc, argv, "-synthphot"))) {
    328     remove_argument (N, &argc, argv);
    329     SyntheticPhotometry = TRUE;
    330     init_synthetic_mags();
    331   }
    332 
    333   refPhotcode = NULL;
    334   if ((N = get_argument (argc, argv, "-refcode"))) {
    335     remove_argument (N, &argc, argv);
    336     refPhotcode = GetPhotcodebyName (argv[N]);
    337     if (!refPhotcode) {
    338       fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", argv[N]);
    339       exit (1);
    340     }
    341     remove_argument (N, &argc, argv);
    342   }
    343 
    344   UpdateAverages = FALSE;
    345   if ((N = get_argument (argc, argv, "-averages"))) {
    346     remove_argument (N, &argc, argv);
    347     UpdateAverages = TRUE;
    348   }
    349 
    350   ApplyOffsets = FALSE;
    351   if ((N = get_argument (argc, argv, "-apply-offsets"))) {
    352     remove_argument (N, &argc, argv);
    353     ApplyOffsets = TRUE;
    354   }
    355 
    356   if (UpdateAverages && (argc == 1)) return TRUE;
    357   if (argc != 2) relphot_usage ();
     634  if ((MODE == MODE_UPDATE_OBJECTS)  && (argc == 1)) return TRUE;
     635  if (argc != 2) relphot_client_usage ();
    358636
    359637  return TRUE;
    360638}
    361639
    362 int args_client (int argc, char **argv) {
    363 
    364   int N;
    365   double trange;
    366 
    367   // by definition, the client is not parallel
    368   PARALLEL = FALSE;
    369   PARALLEL_MANUAL = FALSE;
    370   PARALLEL_SERIAL = FALSE;
    371 
    372   HOST_ID = 0;
    373   if ((N = get_argument (argc, argv, "-hostID"))) {
    374     remove_argument (N, &argc, argv);
    375     HOST_ID = atoi (argv[N]);
    376     remove_argument (N, &argc, argv);
    377   }
    378   if (!HOST_ID) relphot_client_usage();
    379 
    380   HOSTDIR = NULL;
    381   if ((N = get_argument (argc, argv, "-hostdir"))) {
    382     remove_argument (N, &argc, argv);
    383     HOSTDIR = strcreate (argv[N]);
    384     remove_argument (N, &argc, argv);
    385   }
    386   if (!HOSTDIR) relphot_client_usage();
    387 
    388   IMAGES = NULL; // used in -update mode
    389   BCATALOG = NULL; // used in -load mode
    390   MODE = MODE_NONE;
    391   if ((N = get_argument (argc, argv, "-load"))) {
    392     MODE = MODE_LOAD;
    393     remove_argument (N, &argc, argv);
    394     BCATALOG = strcreate (argv[N]);
    395     remove_argument (N, &argc, argv);
    396   }
    397   if ((N = get_argument (argc, argv, "-update-catalogs"))) {
    398     if (MODE) {
    399       fprintf (stderr, "ERROR: cannot mix modes (-load, -update-catalogs, -update-objects)\n");
    400       relphot_client_usage();
    401     }
    402     MODE = MODE_UPDATE;
    403     remove_argument (N, &argc, argv);
    404     IMAGES = strcreate (argv[N]);
    405     remove_argument (N, &argc, argv);
    406   }
    407   if ((N = get_argument (argc, argv, "-update-objects"))) {
    408     if (MODE) {
    409       fprintf (stderr, "ERROR: cannot mix modes (-load, -update-catalogs, -update-objects)\n");
    410       relphot_client_usage();
    411     }
    412     MODE = MODE_UPDATE_OBJECTS;
    413     remove_argument (N, &argc, argv);
    414   }
    415   if (!MODE) relphot_client_usage();
    416 
    417   strcpy (STATMODE, "WT_MEAN");
    418   if ((N = get_argument (argc, argv, "-statmode"))) {
    419     remove_argument (N, &argc, argv);
    420     strcpy (STATMODE, argv[N]);
    421     remove_argument (N, &argc, argv);
    422   }
    423 
    424   BOUNDARY_TREE = NULL;
    425   if ((N = get_argument (argc, argv, "-boundary-tree"))) {
    426     remove_argument (N, &argc, argv);
    427     BOUNDARY_TREE = strcreate(argv[N]);
    428     load_tess (BOUNDARY_TREE);
    429     remove_argument (N, &argc, argv);
    430   }
    431 
    432   /* specify portion of the sky */
    433   UserPatch.Rmin = 0;
    434   UserPatch.Rmax = 360;
    435   UserPatch.Dmin = -90;
    436   UserPatch.Dmax = +90;
    437   if ((N = get_argument (argc, argv, "-region"))) {
    438     remove_argument (N, &argc, argv);
    439     UserPatch.Rmin = atof (argv[N]);
    440     remove_argument (N, &argc, argv);
    441     UserPatch.Rmax = atof (argv[N]);
    442     remove_argument (N, &argc, argv);
    443     UserPatch.Dmin = atof (argv[N]);
    444     remove_argument (N, &argc, argv);
    445     UserPatch.Dmax = atof (argv[N]);
    446     remove_argument (N, &argc, argv);
    447   }
    448 
    449   SET_MREL_VERSION = 1;
    450   if ((N = get_argument (argc, argv, "-set-mrel-version"))) {
    451     remove_argument (N, &argc, argv);
    452     SET_MREL_VERSION = atof(argv[N]);
    453     remove_argument (N, &argc, argv);
    454   }
    455 
    456   VERBOSE = VERBOSE2 = FALSE;
    457   if ((N = get_argument (argc, argv, "-v"))) {
    458     VERBOSE = TRUE;
    459     remove_argument (N, &argc, argv);
    460   }
    461   if ((N = get_argument (argc, argv, "-vv"))) {
    462     VERBOSE2 = VERBOSE = TRUE;
    463     remove_argument (N, &argc, argv);
    464   }
    465 
    466   RESET = FALSE;
    467   if ((N = get_argument (argc, argv, "-reset"))) {
    468     remove_argument (N, &argc, argv);
    469     RESET = TRUE;
    470   }
    471 
    472   RESET_ZEROPTS = FALSE;
    473   if ((N = get_argument (argc, argv, "-reset-zpts"))) {
    474     remove_argument (N, &argc, argv);
    475     RESET_ZEROPTS = TRUE;
    476   }
    477 
    478   KEEP_UBERCAL = TRUE;
    479   if ((N = get_argument (argc, argv, "-reset-ubercal"))) {
    480     remove_argument (N, &argc, argv);
    481     KEEP_UBERCAL = FALSE;
    482   }
    483 
    484   /* define time */
    485   TimeSelect = FALSE;
    486   if ((N = get_argument (argc, argv, "-time"))) {
    487     remove_argument (N, &argc, argv);
    488     if (!ohana_str_to_time (argv[N], &TSTART)) {
    489       fprintf (stderr, "ERROR: syntax error\n");
    490       return (FALSE);
    491     }
    492     remove_argument (N, &argc, argv);
    493     if (!ohana_str_to_dtime (argv[N], &trange)) {
    494       if (!ohana_str_to_time (argv[N], &TSTOP)) {
    495         fprintf (stderr, "ERROR: syntax error\n");
    496         return (FALSE);
    497       }
    498     } else {
    499       if (trange < 0) {
    500         trange = fabs (trange);
    501         TSTOP = TSTART;
    502         TSTART -= trange;
    503       } else {
    504         TSTOP = TSTART + trange;
    505       }
    506     }
    507     remove_argument (N, &argc, argv);
    508     TimeSelect = TRUE;
    509   }
    510 
    511 
    512   MIN_ERROR = 0.001;
    513   if ((N = get_argument (argc, argv, "-minerror"))) {
    514     remove_argument (N, &argc, argv);
    515     MIN_ERROR = atof (argv[N]);
    516     remove_argument (N, &argc, argv);
    517     /* require MIN_ERROR > 0 */
    518   } 
    519 
    520   UPDATE = FALSE;
    521   if ((N = get_argument (argc, argv, "-update"))) {
    522     remove_argument (N, &argc, argv);
    523     UPDATE = TRUE;
    524   }
    525 
    526   UPDATE_CATFORMAT = NULL;
    527   if ((N = get_argument (argc, argv, "-update-catformat"))) {
    528     remove_argument (N, &argc, argv);
    529     UPDATE_CATFORMAT = strcreate (argv[N]);
    530     remove_argument (N, &argc, argv);
    531   }
    532 
    533   AreaSelect = FALSE;
    534   if ((N = get_argument (argc, argv, "-area"))) {
    535     remove_argument (N, &argc, argv);
    536     AreaXmin = atof (argv[N]);
    537     remove_argument (N, &argc, argv);
    538     AreaXmax = atof (argv[N]);
    539     remove_argument (N, &argc, argv);
    540     AreaYmin = atof (argv[N]);
    541     remove_argument (N, &argc, argv);
    542     AreaYmax = atof (argv[N]);
    543     remove_argument (N, &argc, argv);
    544     AreaSelect = TRUE;
    545   }
    546 
    547   SyntheticPhotometry = FALSE;
    548   if ((N = get_argument (argc, argv, "-synthphot"))) {
    549     remove_argument (N, &argc, argv);
    550     SyntheticPhotometry = FALSE;
    551     init_synthetic_mags();
    552   }
    553 
    554   ImagSelect = FALSE;
    555   if ((N = get_argument (argc, argv, "-instmag"))) {
    556     remove_argument (N, &argc, argv);
    557     ImagMin = atof (argv[N]);
    558     remove_argument (N, &argc, argv);
    559     ImagMax = atof (argv[N]);
    560     remove_argument (N, &argc, argv);
    561     ImagSelect = TRUE;
    562   }
    563 
    564   DophotSelect = FALSE;
    565   if ((N = get_argument (argc, argv, "-dophot"))) {
    566     remove_argument (N, &argc, argv);
    567     DophotValue = atof (argv[N]);
    568     remove_argument (N, &argc, argv);
    569     DophotSelect = TRUE;
    570   }
    571 
    572   MaxDensityUse = FALSE;
    573   if ((N = get_argument (argc, argv, "-max-density"))) {
    574     remove_argument (N, &argc, argv);
    575     MaxDensityValue = atof(argv[N]);
    576     remove_argument (N, &argc, argv);
    577     MaxDensityUse = TRUE;
    578   }
    579 
    580   if ((MODE == MODE_UPDATE_OBJECTS)  && (argc == 1)) return TRUE;
    581   if (argc != 2) relphot_client_usage ();
    582 
    583   return TRUE;
    584 }
    585 
  • trunk/Ohana/src/relphot/src/client_logger.c

    r33963 r36630  
    55
    66static FILE *logfile = NULL;
    7 int client_logger_init () {
     7int client_logger_init (char *dirname) {
    88
    99  char filename[DVO_MAX_PATH];
    1010
    11   snprintf (filename, DVO_MAX_PATH, "%s/log.rlpc.XXXXXX", HOSTDIR);
     11  snprintf (filename, DVO_MAX_PATH, "%s/log.rlpc.XXXXXX", dirname);
    1212   
    1313  int fd = mkstemp (filename);
    1414  if (fd == -1) {
    15     fprintf (stderr, "failed to open client logger, exiting\n");
     15    fprintf (stderr, "failed to open client logger %s, exiting\n", filename);
    1616    exit (50);
    1717  }
     
    3232  vfprintf (logfile, format, argp);
    3333  va_end (argp);
     34
     35  fflush (logfile);
    3436  return TRUE;
    3537}
  • trunk/Ohana/src/relphot/src/help.c

    r33651 r36630  
    22
    33void relphot_usage (void) {
    4   fprintf (stderr, "ERROR: USAGE: relphot (photcodes) -region RA RA DEC DEC\n");
    5   fprintf (stderr, "       or:    relphot (photcodes) -catalog (name)\n");
    6   fprintf (stderr, "       or:    relphot -averages -region RA RA DEC DEC\n");
     4  fprintf (stderr, "ERROR: USAGE: relphot (photcodes) -images\n");
     5  fprintf (stderr, "       or:    relphot -averages\n");
     6  fprintf (stderr, "       or:    relphot -apply-offsets\n");
     7  fprintf (stderr, "       or:    relphot (photcodes) -parallel-regions -region-hosts (RegionFile)\n");
     8  fprintf (stderr, "       or:    relphot (photcodes) -parallel-images (ImageTable) -region-hosts (RegionFile)\n\n");
     9  fprintf (stderr, "  regions:    -region RA RA DEC DEC)\n");
     10  fprintf (stderr, "       or:    -catalog (name)\n");
    711  fprintf (stderr, "  use -h for more usage information\n");
    812  exit (2);
     
    1822
    1923show_help:
    20   fprintf (stderr, "ERROR: USAGE: relphot (photcode) -region RA RA DEC DEC\n");
    21   fprintf (stderr, "       or:    relphot (photcode) -catalog (name)\n");
    22   fprintf (stderr, "       or:    relphot -averages -region RA RA DEC DEC\n");
     24  fprintf (stderr, "ERROR: USAGE: relphot (photcodes) -images\n");
     25  fprintf (stderr, "       or:    relphot -averages\n");
     26  fprintf (stderr, "       or:    relphot -apply-offsets\n");
     27  fprintf (stderr, "       or:    relphot (photcodes) -parallel-regions -region-hosts (RegionFile)\n");
     28  fprintf (stderr, "       or:    relphot (photcodes) -parallel-images (ImageTable) -region-hosts (RegionFile)\n\n");
     29  fprintf (stderr, "  regions:    -region RA RA DEC DEC)\n");
     30  fprintf (stderr, "       or:    -catalog (name)\n");
    2331  fprintf (stderr, "  options: \n");
    2432  fprintf (stderr, "  -time (start) (stop)\n");
  • trunk/Ohana/src/relphot/src/initialize.c

    r34429 r36630  
    11# include "relphot.h"
    22
    3 void initialize (int argc, char **argv) {
     3RelphotMode initialize (int argc, char **argv) {
    44
    55  relphot_help (argc, argv);
    66  ConfigInit (&argc, argv);
    7   args (argc, argv);
     7  RelphotMode mode = args (argc, argv);
     8  if (!mode) exit (2);
    89
    9   if (!UpdateAverages) {
    10     // load the list of photcodes into the globals (photcodes, Nphotcodes)
    11     // only a single remaining argument in this mode (the list of photcodes, eg g,r,i)
    12     PhotcodeList = strcreate (argv[1]);
    13     photcodes = ParsePhotcodeList (PhotcodeList, &Nphotcodes, TRUE); // require SEC photcodes
    14   } else {
     10  // UPDATE_AVERAGES always operates on all photcodes?
     11  if (mode == UPDATE_AVERAGES) {
    1512    char tmpline1[256];
    1613    int Ns;
     
    6764  for (B = 0; A == time(NULL); B++);
    6865  srand48(B);
     66
     67  return mode;
    6968}
    7069
  • trunk/Ohana/src/relphot/src/load_catalogs.c

    r35416 r36630  
    8989
    9090  fprintf (stderr, "using "OFF_T_FMT" of "OFF_T_FMT" stars ("OFF_T_FMT" of "OFF_T_FMT" measurements)\n", Nstar, Nstar_total, Nmeas, Nmeas_total);
    91   if (!hostID && (Nstar < 1)) Shutdown ("%s", "ERROR: no stars match the minimum requirements; exiting \n");
     91  if (!hostID && !REGION_HOST_ID && (Nstar < 1)) Shutdown ("%s", "ERROR: no stars match the minimum requirements; exiting \n");
    9292  // in regular relphot, we shutdown here; in relphot_client, we generate and return an empty table (for consistency)
    93    
    9493
    9594  // XXX consider only returning the populated catalogs
     
    107106# define DEBUG 1
    108107Catalog *load_catalogs_parallel (SkyList *sky, int *Ncatalog) {
     108
     109  char uniquer[12];
     110  int TIME = time(NULL);
     111  int PID = getpid();
     112  snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
    109113
    110114  int Nsecfilt  = GetPhotcodeNsecfilt ();               // set the desired number in case we need to create the catalog
     
    128132
    129133    ALLOCATE (table->hosts[i].results, char, 1024);
    130     snprintf (table->hosts[i].results, 1024, "%s/relphot.catalog.subset.dat", table->hosts[i].pathname);
     134    snprintf (table->hosts[i].results, 1024, "%s/relphot.catalog.%s.dat", table->hosts[i].pathname, uniquer);
    131135
    132136    // options / arguments that can affect relphot_client -load:
  • trunk/Ohana/src/relphot/src/reload_catalogs.c

    r35806 r36630  
    156156  // load the list of hosts
    157157  HostTable *table = HostTableLoad (CATDIR, sky->hosts);
     158  if (!table) {
     159    fprintf (stderr, "ERROR: problem with parallel host table\n");
     160    exit (2);
     161  }
    158162
    159163  if (BOUNDARY_TREE) {
  • trunk/Ohana/src/relphot/src/relphot.c

    r35416 r36630  
    33int main (int argc, char **argv) {
    44
    5   /* get configuration info, args */
    6   initialize (argc, argv);
     5  // get configuration info, args
     6  RelphotMode mode = initialize (argc, argv);
     7  if (!mode) exit (2);
    78
    8   /* the object analysis is a separate process iterating over catalogs */
    9   if (UpdateAverages) {
    10     relphot_objects (0, NULL);
    11     exit (0);
     9  switch (mode) {
     10    case UPDATE_IMAGES:
     11      relphot_images ();
     12      exit (0);
     13
     14    case UPDATE_AVERAGES:
     15      // take the current set of detections and set the mean magnitudes
     16      relphot_objects (0, NULL);
     17      exit (0);
     18
     19    case PARALLEL_REGIONS:
     20      // run image updates in parallel across multiple remote machines
     21      relphot_parallel_regions ();
     22      exit (0);
     23
     24    case PARALLEL_IMAGES:
     25      // operation on the remote machines in the PARALLEL_REGION mode
     26      relphot_parallel_images ();
     27      exit (0);
     28
     29    case APPLY_OFFSETS:
     30      // re-run this step from a previous attempt (assumes an existing Images.subset.dat file)
     31      if (!PARALLEL) {
     32        fprintf (stderr, "-apply-offsets only makes sense in an parallel context\n");
     33        exit (2);
     34      }
     35      reload_catalogs (NULL, NULL, 0, NULL);
     36      exit (0);
     37
     38    default:
     39      fprintf (stderr, "ERROR: no valid relphot mode chosen\n");
     40      exit (2);
    1241  }
    13 
    14   if (ApplyOffsets) {
    15     // re-run this step from a previous attempt (assumes an existing Images.subset.dat file)
    16     if (!PARALLEL) {
    17       fprintf (stderr, "-apply-offsets only makes sense in an parallel context\n");
    18       exit (2);
    19     }
    20     reload_catalogs (NULL, NULL, 0, NULL);
    21     exit (0);
    22   }
    23 
    24   relphot_images ();
    25 
    26   exit (0);
     42  fprintf (stderr, "IMPOSSIBLE: skipped out of switch?\n");
     43  exit (1);
    2744}
    28 
  • trunk/Ohana/src/relphot/src/relphot_client.c

    r33963 r36630  
    1919  // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, etc)
    2020  initialize_client (argc, argv);
    21   client_logger_init ();
     21  client_logger_init (HOSTDIR);
    2222
    2323  // load the current sky table (layout of all SkyRegions)
  • trunk/Ohana/src/relphot/src/relphot_images.c

    r35806 r36630  
    244244  if (!UPDATE) exit (0);
    245245 
    246   /* load catalog data from region files, update Mrel include all data */
     246  /* Load catalog data from region files, update Mrel include all data.  In a parallel
     247     context, this function writes the image parameters as a subset table for the remote
     248     clients */
    247249  reload_catalogs (skylist, flatcorr, 0, NULL);
    248250  MARKTIME("-- updated all catalogs: %f sec\n", dtime);
  • trunk/Ohana/src/relphot/src/setMrelCatalog.c

    r36528 r36630  
    255255
    256256        // Map (Maplist) and Mkron (Mkronlist,dkronlist) are used to calculate mean mags per filter
    257         float Map = PhotAper (&measure[k]);
     257        float Map = PhotAperCat (&measure[k]);
    258258        if (!isnan(Map)) {
    259259            Maplist[Nap] = Map - Mcal - Mmos - Mgrid;
     
    263263        }
    264264
    265         float Mkron = PhotKron (&measure[k]);
     265        float Mkron = PhotKronCat (&measure[k]);
    266266        if (!isnan(Mkron)) {
    267267          Mkronlist[Nkron] = Mkron - Mcal - Mmos - Mgrid;
     
    282282      wpsflist[Npsf] = isUbercal ? 10.0 : 1.0;
    283283
     284      // NOTE:
     285      // Msys is measure[i].M + zp corrections
     286      // Mcal is image[j].Mcal
     287      // Mmos and Mgrid are offsets for mosaic and grid
    284288
    285289      // tie down reference photometry if the -refcode (code) option is selected
  • trunk/Ohana/src/uniphot/src/update_dvo_setphot.c

    r35103 r36630  
    22int update_dvo_setphot_parallel (SkyTable *sky, Image *image, off_t Nimage);
    33
     4// XXX convert this to use the ImageSubset to save space
    45int update_dvo_setphot (Image *image, off_t Nimage, FlatCorrectionTable *flatcorr) {
    56
  • trunk/ippScripts/scripts/ipp_apply_burntool_single.pl

  • trunk/ippScripts/scripts/publish_file.pl

  • trunk/ippconfig/recipes/ppSub.config

  • trunk/ippconfig/recipes/reductionClasses.mdc

  • trunk/psphot/src

  • trunk/psphot/src/psphotFullForceReadout.c

    r36375 r36630  
    100100    psphotMagnitudes(config, view, filerule);
    101101
     102    // calculate lensing parameters
     103    if (!psphotLensing(config, view, filerule)) {
     104        psErrorStackPrint(stderr, "Unable to do lensing parameters.");
     105        psErrorClear();
     106    }
     107
    102108    // replace background in residual image
    103109    psphotSkyReplace (config, view, filerule);
  • trunk/psphot/src/psphotStackImageLoop.c

  • trunk/psphot/src/psphotStackReadout.c

    r36542 r36630  
    418418    // calculate source magnitudes
    419419    psphotMagnitudes(config, view, STACK_RAW);
     420
     421    // calculate lensing parameters
     422    if (!psphotLensing(config, view, STACK_RAW)) {
     423        psErrorStackPrint(stderr, "Unable to do lensing parameters.");
     424        psErrorClear();
     425    }
    420426
    421427    if (!psphotEfficiency(config, view, STACK_RAW)) {
Note: See TracChangeset for help on using the changeset viewer.