IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 16, 2019, 4:10:57 PM (7 years ago)
Author:
eugene
Message:

add options to loadukirt for multiple surveys

Location:
branches/eam_branches/ohana.20190329/src/addstar
Files:
2 added
8 edited

Legend:

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

    r40833 r40886  
    316316$(SRC)/loadukirt_uhs_make_subset.$(ARCH).o \
    317317$(SRC)/loadukirt_uhs_readstars.$(ARCH).o \
     318$(SRC)/loadukirt_uhs_readstars_uhs.$(ARCH).o \
     319$(SRC)/loadukirt_uhs_readstars_ugcs.$(ARCH).o \
    318320$(SRC)/loadukirt_uhs_table.$(ARCH).o \
    319321$(SRC)/parse_csv.$(ARCH).o \
  • branches/eam_branches/ohana.20190329/src/addstar/include/ukirt_uhs.h

    r40881 r40886  
     1
     2typedef enum {UKIRT_MODE_NONE, UKIRT_MODE_UHS, UKIRT_MODE_UGCS} UkirtMode;
     3
     4# define NSTARS_MAX 10000000
     5// # define NSTARS_MAX 10
    16
    27# define BUFFER_SIZE 0x100000
    38// # define BUFFER_SIZE 900
    49
    5 // measure[1] = J
    6 
    710typedef struct {
    811  Average average;
    9   Measure measure[1];
     12  Measure *measure;
    1013  int flag; // in a subset?
    1114  int found; // assigned to an object?
    12 } UKIRT_UHS_Stars;
     15} UKIRT_Stars;
    1316
    1417int   HOST_ID;
     
    1619char *CPT_FILE;
    1720char *INPUT;
     21int   UKIRT_NFILTER;
     22
     23UkirtMode UKIRT_MODE;
    1824
    1925AddstarClientOptions args_loadukirt_uhs (int *argc, char **argv, AddstarClientOptions options);
     
    2228int loadukirt_uhs_table (SkyList *skylistInput, char *filename, AddstarClientOptions *options);
    2329
    24 UKIRT_UHS_Stars *loadukirt_uhs_make_subset (UKIRT_UHS_Stars *stars, int Nstars, int start, SkyRegion *region, int *nsubset);
     30UKIRT_Stars *loadukirt_uhs_make_subset (UKIRT_Stars *stars, int Nstars, int start, SkyRegion *region, int *nsubset);
    2531
    26 // int loadukirt_uhs_save_remote (UKIRT_UHS_Stars *stars, int Nstars, HostTable *hosts, SkyRegion *region, char *fullname, AddstarClientOptions *options);
     32// int loadukirt_uhs_save_remote (UKIRT_Stars *stars, int Nstars, HostTable *hosts, SkyRegion *region, char *fullname, AddstarClientOptions *options);
    2733// int save_remote_host (HostInfo *host);
    2834
     
    3339// int harvest_host (void);
    3440
    35 int loadukirt_uhs_catalog (UKIRT_UHS_Stars *stars, int Nstars, SkyRegion *region, char *filename, AddstarClientOptions *options);
     41int loadukirt_uhs_catalog (UKIRT_Stars *stars, int Nstars, SkyRegion *region, char *filename, AddstarClientOptions *options);
    3642
    3743// int galactic_to_celestial (double *R, double *D, double l, double b);
    3844
    39 int find_matches_ukirt_uhs (SkyRegion *region, UKIRT_UHS_Stars *stars, int Nstars, Catalog *catalog, AddstarClientOptions *options);
     45int find_matches_ukirt_uhs (SkyRegion *region, UKIRT_Stars *stars, int Nstars, Catalog *catalog, AddstarClientOptions *options);
    4046
    41 int loadukirt_uhs_save_stars (char *filename, UKIRT_UHS_Stars *stars, int Nstars);
    42 // UKIRT_UHS_Stars *loadukirt_uhs_load_stars (char *filename, int *nstars);
     47int loadukirt_uhs_save_stars (char *filename, UKIRT_Stars *stars, int Nstars);
     48// UKIRT_Stars *loadukirt_uhs_load_stars (char *filename, int *nstars);
    4349
    44 UKIRT_UHS_Stars *loadukirt_uhs_readstars (FILE *f, char *buffer, int *nstart, AddstarClientOptions *options, int *nstars);
     50UKIRT_Stars *loadukirt_uhs_readstars (FILE *f, char *buffer, int *nstart, AddstarClientOptions *options, int *nstars);
    4551
    46 int loadukirt_uhs_sortStars (UKIRT_UHS_Stars *stars, int Nstars);
     52UKIRT_Stars *loadukirt_uhs_readstars_ugcs (FILE *f, char *buffer, int *nstart, AddstarClientOptions *options, int *nstars);
     53UKIRT_Stars *loadukirt_uhs_readstars_uhs (FILE *f, char *buffer, int *nstart, AddstarClientOptions *options, int *nstars);
     54
     55
     56int loadukirt_uhs_sortStars (UKIRT_Stars *stars, int Nstars);
    4757
    4858// int loadukirt_uhs_tmpdir (void);
  • branches/eam_branches/ohana.20190329/src/addstar/src/args_loadukirt_uhs.c

    r40881 r40886  
    1111  if (get_argument (*argc, argv, "-help") ||
    1212      get_argument (*argc, argv, "-h")) {
     13    help ();
     14  }
     15
     16  // UKIRT_MODE is global
     17  UKIRT_MODE = UKIRT_MODE_NONE;
     18  if ((N = get_argument (*argc, argv, "-uhs"))) {
     19    UKIRT_MODE = UKIRT_MODE_UHS;
     20    UKIRT_NFILTER = 1;
     21    remove_argument (N, argc, argv);
     22  }
     23  if ((N = get_argument (*argc, argv, "-ugcs"))) {
     24    UKIRT_MODE = UKIRT_MODE_UGCS;
     25    UKIRT_NFILTER = 6;
     26    remove_argument (N, argc, argv);
     27  }
     28  if (UKIRT_MODE == UKIRT_MODE_NONE) {
     29    fprintf (stderr, "missing or invalid ukirt mode\n");
    1330    help ();
    1431  }
  • branches/eam_branches/ohana.20190329/src/addstar/src/find_matches_ukirt_uhs.c

    r40832 r40886  
    22# include "ukirt_uhs.h"
    33
    4 int find_matches_ukirt_uhs (SkyRegion *region, UKIRT_UHS_Stars *stars, int NstarsIn, Catalog *tgtcat, AddstarClientOptions *options) {
     4int find_matches_ukirt_uhs (SkyRegion *region, UKIRT_Stars *stars, int NstarsIn, Catalog *tgtcat, AddstarClientOptions *options) {
    55
    66  int Nsecfilt = GetPhotcodeNsecfilt ();
  • branches/eam_branches/ohana.20190329/src/addstar/src/loadukirt_uhs_catalog.c

    r40832 r40886  
    22# include "ukirt_uhs.h"
    33
    4 int loadukirt_uhs_catalog (UKIRT_UHS_Stars *stars, int Nstars, SkyRegion *region, char *filename, AddstarClientOptions *options) {
     4int loadukirt_uhs_catalog (UKIRT_Stars *stars, int Nstars, SkyRegion *region, char *filename, AddstarClientOptions *options) {
    55
    66  Catalog catalog;
  • branches/eam_branches/ohana.20190329/src/addstar/src/loadukirt_uhs_make_subset.c

    r40832 r40886  
    55// first entry in stars array in this region)
    66
    7 UKIRT_UHS_Stars *loadukirt_uhs_make_subset (UKIRT_UHS_Stars *stars, int Nstars, int start, SkyRegion *region, int *nsubset) {
     7UKIRT_Stars *loadukirt_uhs_make_subset (UKIRT_Stars *stars, int Nstars, int start, SkyRegion *region, int *nsubset) {
    88
    99  int i;
    10 
    11   UKIRT_UHS_Stars *subset = NULL;
    1210
    1311  // collect array of (Stars *) stars in a new output catalog
    1412  int Nsubset = 0;
    1513  int NSUBSET = 3000;
    16   ALLOCATE (subset, UKIRT_UHS_Stars, NSUBSET);
     14
     15  ALLOCATE_PTR (subset, UKIRT_Stars, NSUBSET);
     16  // for (int i = 0; i < NSUBSET; i++) {
     17  //   ALLOCATE (subset[i].measure, Measure, UKIRT_NFILTER);
     18  // }
    1719
    1820  // find the rest of the stars in this output region
     
    3234    if (stars[i].average.D > UserPatch.Dmax) continue;
    3335         
     36    // the *measure value is a copy of the version allocated to stars[i]
     37    // do NOT free subset[i].measure
    3438    subset[Nsubset] = stars[i];
    3539    Nsubset ++;
    3640
    3741    stars[i].flag = TRUE;
     42   
     43    CHECK_REALLOCATE (subset, UKIRT_Stars, NSUBSET, Nsubset, 10000);
    3844
    39     CHECK_REALLOCATE (subset, UKIRT_UHS_Stars, NSUBSET, Nsubset, 10000);
     45    /*
     46    if (NSTARS >= Nstars) {
     47      NSTARS += 10000;
     48      REALLOCATE (stars, UKIRT_Stars, NSTARS);
     49      for (int j = Nstars; j < NSTARS; j++) {
     50        ALLOCATE (stars[j].measure, Measure, NFILTER);
     51      }
     52    }
     53    */
    4054  }
    4155
  • branches/eam_branches/ohana.20190329/src/addstar/src/loadukirt_uhs_readstars.c

    r40881 r40886  
    11# include "addstar.h"
    22# include "ukirt_uhs.h"
    3 # define NSTARS_MAX 10000000
    4 // # define NSTARS_MAX 10
    53
    6 /* this function reads the values of interest from the UKIRT UHS CSV files:
     4UKIRT_Stars *loadukirt_uhs_readstars (FILE *f, char *buffer, int *nstart, AddstarClientOptions *options, int *nstars) {
    75
    8   data model description: doc/mapping_UKIDSS_unWISE_DVO.pdf
    9 
    10   N -- field (column) number in CSV file (1 counting)
    11   | UKIRT field name          : DVO measure field
    12   1 sourceID                  : extID
    13   2 cuEventID                 :
    14   3 frameSetID                : imageID (assumes we do not try to go backwards for these photcodes)
    15   4 ra                        : R
    16   5 dec                       : D
    17   6 cx                        :
    18   7 cy                        :
    19   8 cz                        :
    20   9 htmID                     :
    21  10 l                         :
    22  11 b                         :
    23  12 lambda                    :
    24  13 eta                       :
    25  14 priOrSec                  : primary bit in dbFlags
    26  15 mergedClassStat           :
    27  16 mergedClass               : psfQFperf or photFlags2
    28  17 pStar                     : psfChisq
    29  18 pGalaxy                   : extNsigma
    30  19 pNoise                    :
    31  20 pSaturated                :
    32  21 eBV                       :
    33  22 aJ                        :
    34  23 jHallMag                  : M
    35  24 jHallMagErr               : dM
    36  25 jPetroMag                 :
    37  26 jPetroMagErr              :
    38  27 jAperMag3                 : Map
    39  28 jAperMag3Err              : dMap
    40  29 jAperMag4                 : Mkron
    41  30 jAperMag4Err              : dMron
    42  31 jAperMag6                 :
    43  32 jAperMag6Err              :
    44  33 jGausig                   :
    45  34 jEll                      :
    46  35 jPA                       : posangle
    47  36 jErrBits                  :
    48  37 jDeblend                  :
    49  38 jClass                    : psfQF
    50  39 jClassStat                :
    51  40 jppErrBits                : photFlags
    52  41 jSeqNum                   : detID
    53 
    54 */
    55 
    56 # define iPARSE(NS,NE,FIELD,NAME) {                                     \
    57     cA = iparse_csv_rpt (&ivalue, (NS), (NE), cA, &readStatus);         \
    58     if (!readStatus && VERBOSE) {                                       \
    59       gprint (GP_ERR, "suspect field: %d (%s) in %s\n",   (NS), NAME, c0); \
    60     }                                                                   \
    61     lineStatus &= readStatus; FIELD[Nelem] = ivalue; }
    62 
    63 # define jPARSE(NS,NE,FIELD,NAME) {                                     \
    64     cA = jparse_csv_rpt (&jvalue, (NS), (NE), cA, &readStatus);         \
    65     if (!readStatus && VERBOSE) {                                       \
    66       gprint (GP_ERR, "suspect field: %d (%s) in %s\n",   (NS), NAME, c0); \
    67     }                                                                   \
    68     lineStatus &= readStatus; FIELD[Nelem] = jvalue; }
    69 
    70 # define dPARSE(NS,NE,FIELD,NAME) {                                     \
    71     cA = dparse_csv_rpt (&dvalue, (NS), (NE), cA, &readStatus);         \
    72     if (!readStatus && VERBOSE) {                                       \
    73       gprint (GP_ERR, "suspect field: %d (%s) in %s\n",   (NS), NAME, c0); \
    74     }                                                                   \
    75     lineStatus &= readStatus; FIELD[Nelem] = dvalue; }
    76 
    77 static int Nline_read = 0; // track number of lines read so far (use to skip lines as well)
    78 static int Nskip = 1; // UKIRT UHS CSV files have a single header row (and no special character to mark)
    79 
    80 UKIRT_UHS_Stars *loadukirt_uhs_readstars (FILE *f, char *buffer, int *nstart, AddstarClientOptions *options, int *nstars) {
    81 
    82   int codeJ = GetPhotcodeCodebyName ("UKIRT_UHS_J"); if (!codeJ) Shutdown ("missing photcode UKIRT_UHS_J");
    83 
    84   // XXX I need a UKIRT UHS Mean Epoch
    85   // time_t UKIRT_UHS_EPOCH = ohana_date_to_sec ("2016/01/01,00:00:00");
    86   // fprintf (stderr, "WARNING: using an invalid UKIRT_UHS_EPOCH (see loadukirt_uhs_readstars.c:60)\n");
    87 
    88   int Nelem = 0;      // number of valid rows read (vector elements)
    89   int NELEM = 10000;  // currently-allocated number of output rows
    90 
    91   // vectors to hold the data loaded from the csv file (names are UKIRT native names)
    92   ALLOCATE_PTR (sourceID,     uint64_t, NELEM);
    93   ALLOCATE_PTR (frameSetID,   uint64_t, NELEM); // XXX doc says 8-bytes for this value!
    94   ALLOCATE_PTR (ra,           double,   NELEM);
    95   ALLOCATE_PTR (dec,          double,   NELEM);
    96   ALLOCATE_PTR (priOrSec,     uint64_t, NELEM);
    97   ALLOCATE_PTR (mergedClass,  int,      NELEM); // XXX doc says 2-bytes (could use a short)
    98   ALLOCATE_PTR (pStar,        double,   NELEM);
    99   ALLOCATE_PTR (pGalaxy,      double,   NELEM);
    100   ALLOCATE_PTR (jHallMag,     double,   NELEM);
    101   ALLOCATE_PTR (jHallMagErr,  double,   NELEM);
    102   ALLOCATE_PTR (jAperMag3,    double,   NELEM);
    103   ALLOCATE_PTR (jAperMag3Err, double,   NELEM);
    104   ALLOCATE_PTR (jAperMag4,    double,   NELEM);
    105   ALLOCATE_PTR (jAperMag4Err, double,   NELEM);
    106   ALLOCATE_PTR (jPA,          double,   NELEM);
    107   ALLOCATE_PTR (jClass,       int,      NELEM);
    108   ALLOCATE_PTR (jppErrBits,   int,      NELEM);
    109   ALLOCATE_PTR (jSeqNum,      int,      NELEM);
    110 
    111   // we have a working buffer read from the file. we parse the lines in the working buffer
    112   // until we reach the last chunk without an EOL char.  at that point, we shift the start
    113   // of the last (partial) line to the start of the buffer and re-fill.
    114 
    115   // we treat \n\r pair as a single EOL char to handle mac files:
    116 
    117   int Nstart = *nstart; // location of the last valid byte in the buffer (start filling here)
    118   int EndOfFile = FALSE;
    119   while (!EndOfFile && (Nelem < NSTARS_MAX)) {
    120     int Nbytes = BUFFER_SIZE - Nstart;
    121     // we have allocated one extra byte into which we never read so there will always be a NULL terminating the string
    122     bzero (&buffer[Nstart], Nbytes + 1);
    123     int Nread = fread (&buffer[Nstart], 1, Nbytes, f);
    124     if (ferror (f)) {
    125       perror ("error reading data file");
    126       break;
     6  switch (UKIRT_MODE) {
     7    case UKIRT_MODE_UHS: {
     8      UKIRT_Stars *stars = loadukirt_uhs_readstars_uhs (f, buffer, nstart, options, nstars);
     9      return stars;
    12710    }
    128 
    129     // we still need to parse the rest of the buffer, but there might not be an EOL on the last line
    130     if (Nread == 0) {
    131       EndOfFile = TRUE;
     11     
     12    case UKIRT_MODE_UGCS: {
     13      UKIRT_Stars *stars = loadukirt_uhs_readstars_ugcs (f, buffer, nstart, options, nstars);
     14      return stars;
    13215    }
    133    
    134     int bufferStatus = TRUE;
    135     char *c0 = buffer; // c0 always marks the start of a line
    136     char *cA = NULL; // cA will carry the curr point within the line
    137     while (bufferStatus) {
    138 
    139       // find the end of this current line (\n or \r).  if we hit the end of the buffer (NULL),
    140       // attempt to read more data.  finish up when we hit the end of the file
    141       char *c1 = strchr (c0, '\n'); // find the end of this current line (also valid for a Mac: \r\n)
    142       if (!c1) {
    143         c1 = strchr (c0, '\r'); // try \r for Windows files
    144       }
    145       if (!c1) {
    146         Nstart = strlen (c0);
    147         if (EndOfFile) {
    148           // if we have reached EOF, we need to do one last pass in case there is a line without a return
    149           c1 = c0 + Nstart;
    150           bufferStatus = FALSE;
    151           if (Nstart == 0) continue; // if we have reached EOF and c0 points at the last valid character, we are done
    152         } else {
    153           // if we have not reached EOF, we need to shift the buffer to the start of this line and read more data
    154           memmove (buffer, c0, Nstart);
    155           bufferStatus = FALSE;
    156           continue;
    157         }
    158       }
    159       *c1 = 0; // mark the end of the line
    160       Nline_read ++;
    161 
    162       // skip to the next line (but if EOF, do not overrun buffer)
    163       if (Nline_read <= Nskip) { if (!EndOfFile) { c0 = c1 + 1; } continue; }
    164 
    165       // these are not needed: Gaia CSV files do not have any commented-out lines
    166       if (*c0 == '#')          { if (!EndOfFile) { c0 = c1 + 1; } continue; }
    167       if (*c0 == '!')          { if (!EndOfFile) { c0 = c1 + 1; } continue; }
    168 
    169       // for UKIRT UHS, we know which columns we want in advance
    170 
    171       int lineStatus = TRUE;
    172       int readStatus;
    173       double dvalue;
    174       int ivalue;
    175       uint64_t jvalue;
    176 
    177       // cA will follow the currently extracted field, c0 points to the start of the line
    178       cA = c0;
    179 
    180       // Tref : TBD for UHS
    181 
    182       // the start of the line is the 1st element (fields are 1-counting)
    183       jPARSE ( 1,  1, sourceID,     "sourceID");
    184       iPARSE ( 3,  1, frameSetID,   "frameSetID");
    185       dPARSE ( 4,  3, ra,           "ra");
    186       dPARSE ( 5,  4, dec,          "dec");
    187       jPARSE (14,  5, priOrSec,     "priOrSec");
    188       iPARSE (16, 14, mergedClass,  "mergedClass");
    189       dPARSE (17, 16, pStar,        "pStar");
    190       dPARSE (18, 17, pGalaxy,      "pGalaxy");
    191       dPARSE (23, 18, jHallMag,     "jHallMag");
    192       dPARSE (24, 23, jHallMagErr,  "jHallMagErr");
    193       dPARSE (27, 24, jAperMag3,    "jAperMag3");
    194       dPARSE (28, 27, jAperMag3Err, "jAperMag3Err");
    195       dPARSE (29, 28, jAperMag4,    "jAperMag4");
    196       dPARSE (30, 29, jAperMag4Err, "jAperMag4Err");
    197       dPARSE (35, 30, jPA,          "jPA");
    198       iPARSE (38, 35, jClass,       "jClass");
    199       iPARSE (40, 38, jppErrBits,   "jppErrBits");
    200       iPARSE (41, 40, jSeqNum,      "jSeqNum");
    201 
    202       if (!lineStatus && VERBOSE) {
    203         // why do I need to copy temp here, does gprint modify the value of temp?
    204         char temp[32];
    205         strncpy (temp, c0, 32);
    206         temp[31] = 0;
    207         gprint (GP_ERR, "skip line %s\n\n", temp);
    208       }
    209 
    210       Nelem ++;
    211       if (Nelem == NELEM) {
    212         NELEM += 1000;
    213 
    214         REALLOCATE (sourceID,     uint64_t, NELEM);
    215         REALLOCATE (frameSetID,   uint64_t, NELEM);
    216         REALLOCATE (ra,           double,   NELEM);
    217         REALLOCATE (dec,          double,   NELEM);
    218         REALLOCATE (priOrSec,     uint64_t, NELEM);
    219         REALLOCATE (mergedClass,  int,      NELEM);
    220         REALLOCATE (pStar,        double,   NELEM);
    221         REALLOCATE (pGalaxy,      double,   NELEM);
    222         REALLOCATE (jHallMag,     double,   NELEM);
    223         REALLOCATE (jHallMagErr,  double,   NELEM);
    224         REALLOCATE (jAperMag3,    double,   NELEM);
    225         REALLOCATE (jAperMag3Err, double,   NELEM);
    226         REALLOCATE (jAperMag4,    double,   NELEM);
    227         REALLOCATE (jAperMag4Err, double,   NELEM);
    228         REALLOCATE (jPA,          double,   NELEM);
    229         REALLOCATE (jClass,       int,      NELEM);
    230         REALLOCATE (jppErrBits,   int,      NELEM);
    231         REALLOCATE (jSeqNum,      int,      NELEM);
    232       }
    233       if (!EndOfFile) {
    234         c0 = c1 + 1;
    235       }
    236     }
     16     
     17    default:
     18      fprintf (stderr, "programming error: invalid mode\n");
     19      exit (1);
    23720  }
    238 
    239   // Nelem is now the number of items (objects,stars) read from the Gaia CSV file
    240   int NstarsIn = Nelem;
    241 
    242   double Rmin = +360.0;
    243   double Rmax = -360.0;
    244   double Dmin = +360.0;
    245   double Dmax = -360.0;
    246 
    247   // start off where we finished on a previous read
    248   int Nstars = *nstars;
    249   int NSTARS = Nstars + 0.1*NstarsIn;
    250 
    251   ALLOCATE_PTR (stars, UKIRT_UHS_Stars, NSTARS);
    252 
    253   for (int i = 0; i < NstarsIn; i++) {
    254 
    255     Rmin = MIN (Rmin, ra[i]);
    256     Rmax = MAX (Rmax, ra[i]);
    257     Dmin = MIN (Dmin, dec[i]);
    258     Dmax = MAX (Dmax, dec[i]);
    259 
    260     // we have one UKIRT UHS (J-band) measurement per object
    261     dvo_average_init (&stars[Nstars].average);
    262     dvo_measure_init (&stars[Nstars].measure[0]);
    263 
    264     stars[Nstars].average.R = ra[i];
    265     stars[Nstars].average.D = dec[i];
    266     stars[Nstars].average.dR = NAN;
    267     stars[Nstars].average.dD = NAN;
    268 
    269     stars[Nstars].flag  = FALSE;
    270     stars[Nstars].found = FALSE;
    271 
    272     int isPrimary   = (!priOrSec[i] || (priOrSec[i] == frameSetID[i])) ? ID_MEAS_STACK_PRIMARY : 0x00;
    273     int photFlags2 = isPrimary;
    274     switch (mergedClass[i]) {
    275       case  1: photFlags2 |= 0x01; break; // Galaxy
    276       case  0: photFlags2 |= 0x02; break; // Noise
    277       case -1: photFlags2 |= 0x04; break; // Star
    278       case -2: photFlags2 |= 0x08; break; // probably star
    279       case -3: photFlags2 |= 0x10; break; // probably galaxy
    280       case -9: photFlags2 |= 0x20; break; // saturated
    281       default: break;
    282     }
    283 
    284     stars[Nstars].measure[0].extID      = sourceID[i];
    285     stars[Nstars].measure[0].imageID    = frameSetID[i]; // XXX check for frameSetID > 31-bit int
    286     stars[Nstars].measure[0].R          = ra[i];
    287     stars[Nstars].measure[0].D          = dec[i];
    288     stars[Nstars].measure[0].psfChisq   = pStar[i];
    289     stars[Nstars].measure[0].extNsigma  = pGalaxy[i];
    290     stars[Nstars].measure[0].M          = jHallMag[i];
    291     stars[Nstars].measure[0].dM         = jHallMagErr[i];
    292     stars[Nstars].measure[0].Map        = jAperMag3[i];
    293     stars[Nstars].measure[0].dMap       = jAperMag3Err[i];
    294     stars[Nstars].measure[0].Mkron      = jAperMag4[i];
    295     stars[Nstars].measure[0].dMkron     = jAperMag4Err[i];
    296     stars[Nstars].measure[0].posangle   = jPA[i]; // XXX units
    297     stars[Nstars].measure[0].psfQF      = jClass[i];
    298     stars[Nstars].measure[0].photFlags  = jppErrBits[i];
    299     stars[Nstars].measure[0].photFlags2 = photFlags2;
    300     stars[Nstars].measure[0].detID      = jSeqNum[i];
    301     stars[Nstars].measure[0].photcode   = codeJ;
    302 
    303     stars[Nstars].average.Nmeasure = 1;
    304     Nstars ++;
    305 
    306     CHECK_REALLOCATE (stars, UKIRT_UHS_Stars, NSTARS, Nstars, 10000);
    307   }
    308 
    309   FREE (sourceID);
    310   FREE (frameSetID);
    311   FREE (ra);
    312   FREE (dec);
    313   FREE (priOrSec);
    314   FREE (mergedClass);
    315   FREE (pStar);
    316   FREE (pGalaxy);
    317   FREE (jHallMag);
    318   FREE (jHallMagErr);
    319   FREE (jAperMag3);
    320   FREE (jAperMag3Err);
    321   FREE (jAperMag4);
    322   FREE (jAperMag4Err);
    323   FREE (jPA);
    324   FREE (jClass);
    325   FREE (jppErrBits);
    326   FREE (jSeqNum);
    327 
    328   *nstars = Nstars;
    329   *nstart = Nstart;
    330   return (stars);
     21  return NULL;
    33122}
    33223
    333 int loadukirt_uhs_sortStars (UKIRT_UHS_Stars *stars, int Nstars) {
     24int loadukirt_uhs_sortStars (UKIRT_Stars *stars, int Nstars) {
    33425
    335 # define SWAPFUNC(A,B){ UKIRT_UHS_Stars temp = stars[A]; stars[A] = stars[B]; stars[B] = temp; }
     26# define SWAPFUNC(A,B){ UKIRT_Stars temp = stars[A]; stars[A] = stars[B]; stars[B] = temp; }
    33627# define COMPARE(A,B)(stars[A].average.R < stars[B].average.R)
    33728
  • branches/eam_branches/ohana.20190329/src/addstar/src/loadukirt_uhs_table.c

    r40881 r40886  
    2424
    2525    int Nstars = 0;
    26     UKIRT_UHS_Stars *stars = loadukirt_uhs_readstars (f, buffer, &Nstart, options, &Nstars);
     26    UKIRT_Stars *stars = loadukirt_uhs_readstars (f, buffer, &Nstart, options, &Nstars);
    2727    if (!Nstars) {
    2828      fclose (f);
     
    3333    fprintf (stderr, "writing %d stars to dvo\n", Nstars);
    3434
    35     // sort the stars by RA
     35    // sort the stars by RA (Nmeasure agnostic)
    3636    loadukirt_uhs_sortStars (stars, Nstars);
    3737
     
    5555      SkyRegion *region = skylist[0].regions[0];
    5656
    57       // select stars matching this region
     57      // select stars matching this region (Nmeasure agnostic)
    5858      int Nsubset;
    59       UKIRT_UHS_Stars *subset = loadukirt_uhs_make_subset (stars, Nstars, i, region, &Nsubset);
     59      UKIRT_Stars *subset = loadukirt_uhs_make_subset (stars, Nstars, i, region, &Nsubset);
    6060
    6161      // In parallel mode, write out the subset to a disk file.  Block until a remote host
     
    6363      // NOTE: disable parallel mode for now:
    6464      // loadukirt_uhs_save_remote (subset, Nsubset, hosts, region, skylist[0].filename[0], options);
     65      // loadukirt_uhs_catalog (Nmeasure agnostic)
    6566      loadukirt_uhs_catalog (subset, Nsubset, region, skylist[0].filename[0], options);
     67     
     68      // for (int j = 0; j < Nsubset; j++) {
     69      //        free (subset[j].measure);
     70      // }
    6671      free (subset);
     72
    6773      SkyListFree (skylist);
    6874    }
Note: See TracChangeset for help on using the changeset viewer.