IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40833


Ignore:
Timestamp:
Jul 12, 2019, 10:42:03 AM (7 years ago)
Author:
eugene
Message:

basic loadukirt_uhs tool builds

Location:
branches/eam_branches/ohana.20190329/src/addstar
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20190329/src/addstar/Makefile

    r40543 r40833  
    2727loadgaia     : $(BIN)/loadgaia.$(ARCH)
    2828loadgaia_dr2 : $(BIN)/loadgaia_dr2.$(ARCH)
     29loadukirt_uhs : $(BIN)/loadukirt_uhs.$(ARCH)
    2930loadstarpar  : $(BIN)/loadstarpar.$(ARCH)
    3031loadstarpar_client : $(BIN)/loadstarpar_client.$(ARCH)
     
    4445# programs in 'SERVER' use the client-server concept and are out of date
    4546
    46 INSTALL = addstar addstar_client sedstar loadgalphot loadgaia loadgaia_dr2 loadstarpar loadstarpar_client setobjflags setobjflags_client loadICRF loadICRF_client skycells mkcmf dumpskycells findskycell load2mass loadwise loadtycho loadbsc loadsupercos
     47INSTALL = addstar addstar_client sedstar loadgalphot loadgaia loadgaia_dr2 loadukirt_uhs loadstarpar loadstarpar_client setobjflags setobjflags_client loadICRF loadICRF_client skycells mkcmf dumpskycells findskycell load2mass loadwise loadtycho loadbsc loadsupercos
    4748SERVER  = addstarc addstard addstart
    4849
     
    305306$(SRC)/psps_ids.$(ARCH).o
    306307
     308LOAD-UKIRT_UHS = \
     309$(SRC)/loadukirt_uhs.$(ARCH).o \
     310$(SRC)/ConfigInit.$(ARCH).o \
     311$(SRC)/SetSignals.$(ARCH).o \
     312$(SRC)/Shutdown.$(ARCH).o \
     313$(SRC)/args_loadukirt_uhs.$(ARCH).o \
     314$(SRC)/find_matches_ukirt_uhs.$(ARCH).o \
     315$(SRC)/loadukirt_uhs_catalog.$(ARCH).o \
     316$(SRC)/loadukirt_uhs_make_subset.$(ARCH).o \
     317$(SRC)/loadukirt_uhs_readstars.$(ARCH).o \
     318$(SRC)/loadukirt_uhs_table.$(ARCH).o \
     319$(SRC)/parse_csv.$(ARCH).o \
     320$(SRC)/resort_catalog.$(ARCH).o \
     321$(SRC)/build_links.$(ARCH).o \
     322$(SRC)/strhash.$(ARCH).o \
     323$(SRC)/sortIDs.$(ARCH).o \
     324$(SRC)/psps_ids.$(ARCH).o
     325
    307326LOAD-STARPAR = \
    308327$(SRC)/loadstarpar.$(ARCH).o \
     
    528547$(LOAD-GAIA)           : $(INC)/addstar.h $(INC)/gaia.h
    529548$(LOAD-GAIA_DR2)       : $(INC)/addstar.h $(INC)/gaia_dr2.h
     549$(LOAD-UKIRT_UHS)      : $(INC)/addstar.h $(INC)/ukirt_uhs.h
    530550$(LOAD-STARPAR)        : $(INC)/addstar.h $(INC)/loadstarpar.h
    531551$(LOAD-STARPAR-CLIENT) : $(INC)/addstar.h $(INC)/loadstarpar.h
     
    551571$(BIN)/loadgaia.$(ARCH)       : $(LOAD-GAIA)
    552572$(BIN)/loadgaia_dr2.$(ARCH)   : $(LOAD-GAIA_DR2)
     573$(BIN)/loadukirt_uhs.$(ARCH)  : $(LOAD-UKIRT_UHS)
    553574$(BIN)/loadstarpar.$(ARCH)    : $(LOAD-STARPAR)
    554575$(BIN)/loadstarpar_client.$(ARCH) : $(LOAD-STARPAR-CLIENT)
  • branches/eam_branches/ohana.20190329/src/addstar/include/ukirt_uhs.h

    r40832 r40833  
    11
    2 // measure[0] = g, measure[1] = b, measure[2] = r,
     2// measure[1] = J
    33
    44typedef struct {
    55  Average average;
    6   Measure measure[3];
     6  Measure measure[1];
    77  int flag; // in a subset?
    88  int found; // assigned to an object?
  • branches/eam_branches/ohana.20190329/src/addstar/src/loadukirt_uhs_readstars.c

    r40832 r40833  
    7878
    7979  // XXX I need a UKIRT UHS Mean Epoch
    80   time_t UKIRT_UHS_EPOCH = ohana_date_to_sec ("2016/01/01,00:00:00");
    81   fprintf (stderr, "WARNING: using an invalid UKIRT_UHS_EPOCH (see loadukirt_uhs_readstars.c:60)\n");
     80  // time_t UKIRT_UHS_EPOCH = ohana_date_to_sec ("2016/01/01,00:00:00");
     81  // fprintf (stderr, "WARNING: using an invalid UKIRT_UHS_EPOCH (see loadukirt_uhs_readstars.c:60)\n");
    8282
    8383  // read in the full FITS files
     
    9090  int NELEM = 10000;  // currently-allocated number of output rows
    9191
    92   // for initial testing, a minimal subset:
    93   ALLOCATE_PTR (sourceID, uint64_t, NELEM);
    94   ALLOCATE_PTR (Rg,       double, NELEM);
    95   ALLOCATE_PTR (Dg,       double, NELEM);
    96   ALLOCATE_PTR (chiSq,    double, NELEM);
    97   ALLOCATE_PTR (drg,      double, NELEM);
    98 
    99   ALLOCATE_PTR (sourceID, , NELEM);
    100   ALLOCATE_PTR (frameSetID,  , NELEM);
    101   ALLOCATE_PTR (ra,  , NELEM);
    102   ALLOCATE_PTR (dec,  , NELEM);
    103   ALLOCATE_PTR (pStar,  , NELEM);
    104   ALLOCATE_PTR (pGalaxy,  , NELEM);
    105   ALLOCATE_PTR (jHallMag,  , NELEM);
    106   ALLOCATE_PTR (jHallMagErr,  , NELEM);
    107   ALLOCATE_PTR (jAperMag3,  , NELEM);
    108   ALLOCATE_PTR (jAperMag3Err,  , NELEM);
    109   ALLOCATE_PTR (jAperMag4,  , NELEM);
    110   ALLOCATE_PTR (jAperMag4Err,  , NELEM);
    111   ALLOCATE_PTR (jPA,  , NELEM);
    112   ALLOCATE_PTR (jClass,  , NELEM);
    113   ALLOCATE_PTR (jppErrBits,  , NELEM);
    114   ALLOCATE_PTR (photFlags2,  , NELEM);
    115   ALLOCATE_PTR (jSeqNum,  , NELEM);
     92  // vectors to hold the data loaded from the csv file (names are UKIRT native names)
     93  ALLOCATE_PTR (sourceID,     uint64_t, NELEM);
     94  ALLOCATE_PTR (frameSetID,   uint64_t, NELEM); // XXX doc says 8-bytes for this value!
     95  ALLOCATE_PTR (ra,           double,   NELEM);
     96  ALLOCATE_PTR (dec,          double,   NELEM);
     97  ALLOCATE_PTR (priOrSec,     uint64_t, NELEM);
     98  ALLOCATE_PTR (mergedClass,  int,      NELEM); // XXX doc says 2-bytes (could use a short)
     99  ALLOCATE_PTR (pStar,        double,   NELEM);
     100  ALLOCATE_PTR (pGalaxy,      double,   NELEM);
     101  ALLOCATE_PTR (jHallMag,     double,   NELEM);
     102  ALLOCATE_PTR (jHallMagErr,  double,   NELEM);
     103  ALLOCATE_PTR (jAperMag3,    double,   NELEM);
     104  ALLOCATE_PTR (jAperMag3Err, double,   NELEM);
     105  ALLOCATE_PTR (jAperMag4,    double,   NELEM);
     106  ALLOCATE_PTR (jAperMag4Err, double,   NELEM);
     107  ALLOCATE_PTR (jPA,          double,   NELEM);
     108  ALLOCATE_PTR (jClass,       int,      NELEM);
     109  ALLOCATE_PTR (jppErrBits,   int,      NELEM);
     110  ALLOCATE_PTR (jSeqNum,      int,      NELEM);
    116111
    117112  // we allocate one extra byte into which we never read so there will always be a NULL terminating the string
     
    178173      if (*c0 == '!')          { if (!EndOfFile) { c0 = c1 + 1; } continue; }
    179174
    180       // XXX for Gaia, we know which columns we want in advance
     175      // for UKIRT UHS, we know which columns we want in advance
    181176
    182177      int lineStatus = TRUE;
     
    189184      cA = c0;
    190185
    191       // Tref == 2015.5 for DR2
     186      // Tref : TBD for UHS
    192187
    193188      // the start of the line is the 1st element (fields are 1-counting)
     
    207202      dPARSE (30, 29, jAperMag4Err, "jAperMag4Err");
    208203      dPARSE (35, 30, jPA,          "jPA");
    209       dPARSE (38, 35, jClass,       "jClass");
     204      iPARSE (38, 35, jClass,       "jClass");
    210205      iPARSE (40, 38, jppErrBits,   "jppErrBits");
    211206      iPARSE (41, 40, jSeqNum,      "jSeqNum");
     
    223218        NELEM += 1000;
    224219
    225         REALLOCATE (sourceID, uint64_t, NELEM);
    226         REALLOCATE (ra, double, NELEM);
    227         REALLOCATE (dec, double, NELEM);
    228         REALLOCATE (priOrSec, uint64_t, NELEM);
    229         REALLOCATE (mergedClass, int, NELEM);
    230         REALLOCATE (pStar, double, NELEM);
    231         REALLOCATE (pGalaxy, double, NELEM);
    232         REALLOCATE (jHallMag, double, NELEM);
    233         REALLOCATE (jHallMagErr, double, NELEM);
    234         REALLOCATE (jAperMag3, double, NELEM);
    235         REALLOCATE (jAperMag3Err, double, NELEM);
    236         REALLOCATE (jAperMag4, double, NELEM);
    237         REALLOCATE (jAperMag4Err, double, NELEM);
    238         REALLOCATE (jPA, double, NELEM);
    239         REALLOCATE (jClass,  double, NELEM);
    240         REALLOCATE (jppErrBits, int, NELEM);
    241         REALLOCATE (jSeqNum, int, NELEM);
     220        REALLOCATE (sourceID,     uint64_t, NELEM);
     221        REALLOCATE (frameSetID,   uint64_t, NELEM);
     222        REALLOCATE (ra,           double,   NELEM);
     223        REALLOCATE (dec,          double,   NELEM);
     224        REALLOCATE (priOrSec,     uint64_t, NELEM);
     225        REALLOCATE (mergedClass,  int,      NELEM);
     226        REALLOCATE (pStar,        double,   NELEM);
     227        REALLOCATE (pGalaxy,      double,   NELEM);
     228        REALLOCATE (jHallMag,     double,   NELEM);
     229        REALLOCATE (jHallMagErr,  double,   NELEM);
     230        REALLOCATE (jAperMag3,    double,   NELEM);
     231        REALLOCATE (jAperMag3Err, double,   NELEM);
     232        REALLOCATE (jAperMag4,    double,   NELEM);
     233        REALLOCATE (jAperMag4Err, double,   NELEM);
     234        REALLOCATE (jPA,          double,   NELEM);
     235        REALLOCATE (jClass,       int,      NELEM);
     236        REALLOCATE (jppErrBits,   int,      NELEM);
     237        REALLOCATE (jSeqNum,      int,      NELEM);
    242238      }
    243239      if (!EndOfFile) {
     
    267263  for (int i = 0; i < NstarsIn; i++) {
    268264
    269     Rmin = MIN (Rmin, Rg[i]);
    270     Rmax = MAX (Rmax, Rg[i]);
    271     Dmin = MIN (Dmin, Dg[i]);
    272     Dmax = MAX (Dmax, Dg[i]);
    273 
    274     // each Gaia DR2 source corresponds to 3 measurements: Gg, Gr, Gb:
    275 
     265    Rmin = MIN (Rmin, ra[i]);
     266    Rmax = MAX (Rmax, ra[i]);
     267    Dmin = MIN (Dmin, dec[i]);
     268    Dmax = MAX (Dmax, dec[i]);
     269
     270    // we have one UKIRT UHS (J-band) measurement per object
    276271    dvo_average_init (&stars[Nstars].average);
    277     dvo_measure_init (&stars[Nstars].measure);
     272    dvo_measure_init (&stars[Nstars].measure[0]);
    278273
    279274    stars[Nstars].average.R = ra[i];
     
    286281
    287282    int isPrimary   = (!priOrSec[i] || (priOrSec[i] == frameSetID[i])) ? ID_MEAS_STACK_PRIMARY : 0x00;
    288     int isGalaxy    = (mergedClass[i] == 1)  ? 0x01 : 0x00;
    289     int isNoise     = (mergedClass[i] == 0)  ? 0x02 : 0x00;
    290     int isStar      = (mergedClass[i] == -1) ? 0x04 : 0x00;
    291     int maybeStar   = (mergedClass[i] == -2) ? 0x08 : 0x00;
    292     int maybeGalaxy = (mergedClass[i] == -3) ? 0x10 : 0x00;
    293     int isSaturated = (mergedClass[i] == -9) ? 0x20 : 0x00;
    294 
    295     int photFlags2 = isGalaxy | isNoise | isStar | maybeStar | maybeGalaxy | isSaturated | isPrimary;
    296 
    297     stars[Nstars].measure[0].extID     = sourceID[i];
    298     stars[Nstars].measure[0].imageID   = frameSetID[i];
    299     stars[Nstars].measure[0].R         = ra[i];
    300     stars[Nstars].measure[0].D         = dec[i];
    301     stars[Nstars].measure[0].psfChisq  = pStar[i];
    302     stars[Nstars].measure[0].extNsigma = pGalaxy[i];
    303     stars[Nstars].measure[0].M         = jHallMag[i];
    304     stars[Nstars].measure[0].dM        = jHallMagErr[i];
    305     stars[Nstars].measure[0].Map       = jAperMag3[i];
    306     stars[Nstars].measure[0].dMap      = jAperMag3Err[i];
    307     stars[Nstars].measure[0].Mkron     = jAperMag4[i];
    308     stars[Nstars].measure[0].dMkron    = jAperMag4Err[i];
    309     stars[Nstars].measure[0].posangle  = jPA[i]; // XXX units
    310     stars[Nstars].measure[0].psfQF     = jClass[i];
    311 
     283    int photFlags2 = isPrimary;
     284    switch (mergedClass[i]) {
     285      case  1: photFlags2 |= 0x01; break; // Galaxy
     286      case  0: photFlags2 |= 0x02; break; // Noise
     287      case -1: photFlags2 |= 0x04; break; // Star
     288      case -2: photFlags2 |= 0x08; break; // probably star
     289      case -3: photFlags2 |= 0x10; break; // probably galaxy
     290      case -9: photFlags2 |= 0x20; break; // saturated
     291      default: break;
     292    }
     293
     294    stars[Nstars].measure[0].extID      = sourceID[i];
     295    stars[Nstars].measure[0].imageID    = frameSetID[i]; // XXX check for frameSetID > 31-bit int
     296    stars[Nstars].measure[0].R          = ra[i];
     297    stars[Nstars].measure[0].D          = dec[i];
     298    stars[Nstars].measure[0].psfChisq   = pStar[i];
     299    stars[Nstars].measure[0].extNsigma  = pGalaxy[i];
     300    stars[Nstars].measure[0].M          = jHallMag[i];
     301    stars[Nstars].measure[0].dM         = jHallMagErr[i];
     302    stars[Nstars].measure[0].Map        = jAperMag3[i];
     303    stars[Nstars].measure[0].dMap       = jAperMag3Err[i];
     304    stars[Nstars].measure[0].Mkron      = jAperMag4[i];
     305    stars[Nstars].measure[0].dMkron     = jAperMag4Err[i];
     306    stars[Nstars].measure[0].posangle   = jPA[i]; // XXX units
     307    stars[Nstars].measure[0].psfQF      = jClass[i];
    312308    stars[Nstars].measure[0].photFlags  = jppErrBits[i];
    313     stars[Nstars].measure[0].photFlags2 = photFlags2[i];
     309    stars[Nstars].measure[0].photFlags2 = photFlags2;
    314310    stars[Nstars].measure[0].detID      = jSeqNum[i];
    315 
    316     stars[Nstars].measure[0].photcode  = codeJ;
     311    stars[Nstars].measure[0].photcode   = codeJ;
    317312
    318313    stars[Nstars].average.Nmeasure = 1;
     
    322317  }
    323318
    324   free (srcID);
    325   free (Rg);
    326   free (dRg);
    327   free (Dg);
    328   free (dDg);
    329   free (plx);
    330   free (dplx);
    331   free (uR);
    332   free (duR);
    333   free (uD);
    334   free (duD);
    335   free (nObs);
    336   free (nGood);
    337   free (goFit);
    338   free (chiSq);
    339   free (exNoise);
    340   free (exNoiseSig);
    341   free (nPeriods);
    342   free (dupSource);
    343   free (gg);
    344   free (dgg);
    345   free (bg);
    346   free (dbg);
    347   free (rg);
    348   free (drg);
    349   free (procMode);
     319  FREE (sourceID);
     320  FREE (frameSetID);
     321  FREE (ra);
     322  FREE (dec);
     323  FREE (priOrSec);
     324  FREE (mergedClass);
     325  FREE (pStar);
     326  FREE (pGalaxy);
     327  FREE (jHallMag);
     328  FREE (jHallMagErr);
     329  FREE (jAperMag3);
     330  FREE (jAperMag3Err);
     331  FREE (jAperMag4);
     332  FREE (jAperMag4Err);
     333  FREE (jPA);
     334  FREE (jClass);
     335  FREE (jppErrBits);
     336  FREE (jSeqNum);
    350337
    351338  free (buffer);
Note: See TracChangeset for help on using the changeset viewer.