IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38522


Ignore:
Timestamp:
Jun 23, 2015, 4:11:40 PM (11 years ago)
Author:
eugene
Message:

a bit of data structure re-org (load filenames into a structure)

Location:
branches/eam_branches/ipp-20150616/Ohana/src/addstar
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/Makefile

    r38521 r38522  
    7171$(SRC)/grefstars.$(ARCH).o \
    7272$(SRC)/GetZeroPointExposure.$(ARCH).o \
     73$(SRC)/LoadFilenames.$(ARCH).o \
    7374$(SRC)/LoadStars.$(ARCH).o \
    7475$(SRC)/LoadHeaders.$(ARCH).o \
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/include/addstar.h

    r38501 r38522  
    3333
    3434# define myAbortF(FORMAT,...) { fprintf (stderr, FORMAT, __VA_ARGS__); abort(); }
     35
     36// things that are needed for a single file
     37typedef struct {
     38  char *filename;  // name of the file on disk (full path)
     39  char *imagename; // name of the image for user reference (eg, base of neb path, full path, etc)
     40} AddstarFile;
    3541
    3642typedef struct {
     
    232238HeaderSet *MatchHeaders           PROTO((off_t **extsize, off_t *nimage, int mode, Header **headers, int Nheaders));
    233239void       HeaderSetFree          PROTO((HeaderSet *headerSets, off_t NheaderSets));
    234 int        LoadData               PROTO((FILE *f, char *file, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, int NheaderSets, AddstarClientOptions *options));
     240int        LoadData               PROTO((FILE *f, AddstarFile *file, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, int NheaderSets, AddstarClientOptions *options));
    235241int        GetZeroPointExposure   PROTO((Header **headers, HeaderSet *headerSets, off_t Nimages));
    236242
     
    336342int LoadDataUKIRT (FILE *f, char *file, Image **images, off_t *nimages, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, off_t NheaderSets);
    337343
     344AddstarFile *LoadFilenames (int *nfile, char *filename, AddstarClientOptions *options);
     345void AddstarFileFree (AddstarFile *file, int Nfile);
     346
    338347/**
    339348    there is an inconsistency to be resolved: fixed structures (like Image)
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/ImageIndex.c

    r38501 r38522  
    199199 
    200200  // extend the storage arrays
     201  // no reason to extend 'found'
    201202  REALLOCATE (index->imageID,  IDTYPE, index->Nimage + Nimages);
    202203  REALLOCATE (index->externID, IDTYPE, index->Nimage + Nimages);
     
    226227  ALLOCATE (index->imageID,  IDTYPE, 1);
    227228  ALLOCATE (index->externID, IDTYPE, 1);
     229  ALLOCATE (index->found, char, 1);
    228230  index->Nimage = 0;
    229231
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadData.c

    r38501 r38522  
    55
    66// examine the header sets and set the Image entries for the the valid images
    7 int LoadData (FILE *f, char *file, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, int Nimages, AddstarClientOptions *options) {
     7int LoadData (FILE *f, AddstarFile *file, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, int Nimages, AddstarClientOptions *options) {
    88
    9   char *name;
    109  off_t Nskip, Nvalid, NVALID;
    1110  int i, j, Nhead, Ndata;
     
    2221    REALLOCATE (images[0], Image, NVALID);
    2322  }   
    24 
    25   // find image rootname
    26   if (USE_NAME) {
    27       name = filebasename (USE_NAME);
    28   } else {
    29       name = filebasename (file);
    30   }
    3123
    3224  // if zero points are calculated for the full exposure using more than just the matched chip header,
     
    5850    // XXX use something to set the chip name? EXTNAME?
    5951    if (!strcmp(headerSets[i].exthead, "PHU") && (Nimages == 1)) {
    60       snprintf (images[0][Nvalid].name, DVO_IMAGE_NAME_LEN, "%s", name);
     52      snprintf (images[0][Nvalid].name, DVO_IMAGE_NAME_LEN, "%s", file->imagename);
    6153    } else {
    62       snprintf (images[0][Nvalid].name, DVO_IMAGE_NAME_LEN, "%s[%s]", name, headerSets[i].exthead);
     54      snprintf (images[0][Nvalid].name, DVO_IMAGE_NAME_LEN, "%s[%s]", file->imagename, headerSets[i].exthead);
    6355    }
    6456
     
    117109      stars[0][i].measure.Map += OFFSET_ZPT;
    118110    }
    119 
    120111  }
    121112
    122   free (name);
    123113  *nvalid = Nvalid;
    124114  return (TRUE);
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadDataPMM.c

    r37807 r38522  
    1515# define MAG_INDEX_ASC 22
    1616
    17 int LoadDataPMM (FILE *f, char *file, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars) {
     17int LoadDataPMM (FILE *f, char *imagename, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars) {
    1818
    1919  off_t Nvalid, NVALID;
    20   char *name, *buffer;
     20  char *buffer;
    2121  int i, fd, Nbyte, Nline, code;
    2222  double ra, dec, mag, airmass, az, ZeroPoint, ZeroPt;
     
    3838  }   
    3939
    40   // find image rootname
    41   name = filebasename (file);
    42 
    4340  // there is only one PMM image per file
    44   if (VERBOSE) fprintf (stderr, "reading data for %s\n", file);
     41  if (VERBOSE) fprintf (stderr, "reading data for %s\n", imagename);
    4542
    4643  ZeroPt = GetZeroPoint();
    4744
    4845  // need to get the metadata from the PMM_CCD_TABLE
    49   photcode = LoadMetadataPMM (name, &images[0][Nvalid]);
     46  photcode = LoadMetadataPMM (imagename, &images[0][Nvalid]);
    5047  code = photcode[0].code;
    5148  ZeroPoint = 0.001*photcode[0].C;
     
    121118
    122119  free (inStars);
    123   free (name);
    124120  *nvalid = Nvalid + 1;
    125121
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadDataSDSS.c

    r27435 r38522  
    44// there should only be a single data set (phu + table) in this file
    55// each SDSS data set corresponds to 5 images (ugriz)
    6 int LoadDataSDSS (FILE *f, char *file, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, off_t Nimages) {
     6int LoadDataSDSS (FILE *f, char *imagename, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, off_t Nimages) {
    77
    88  off_t Nskip, Nvalid, NVALID;
    9   char *name;
    109  int j, Nhead, Ndata;
    1110  unsigned int Ninstars;
     
    2120    REALLOCATE (images[0], Image, NVALID);
    2221  }   
    23 
    24   // find image rootname
    25   name = filebasename (file);
    2622
    2723  // there is only one SDSS image per file (TRUE?)
     
    4036         
    4137  // XXX I think this is an error?  should this be &images[0][Nvalid] ??
    42   inStars = ReadStarsSDSS (f, name, headers[Nhead], headers[Ndata], images[0], &Nvalid, &Ninstars);
     38  inStars = ReadStarsSDSS (f, imagename, headers[Nhead], headers[Ndata], images[0], &Nvalid, &Ninstars);
    4339  *stars = MergeStars (*stars, Nstars, inStars, Ninstars);
    4440
    45   free (name);
    4641  *nvalid = Nvalid;
    4742  return (TRUE);
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadDataUKIRT.c

    r38467 r38522  
    33// examine the header sets and set the Image entries for the the valid images
    44// UKIRT data has the WCS/image metadata header intermixed with the bintable header
    5 int LoadDataUKIRT (FILE *f, char *file, Image **images, off_t *nimages, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, off_t NheaderSets) {
     5
     6int LoadDataUKIRT (FILE *f, char *imagename, Image **images, off_t *nimages, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, off_t NheaderSets) {
    67
    78  off_t Nskip, Nvalid, NVALID;
    8   char *name;
    99  int i, j, Nhead, Ndata;
    1010  unsigned int Ninstars;
     
    2222  }   
    2323
    24   // find image rootname
    25   name = filebasename (file);
    26 
    2724  // validate the number of headers sets == 4
    2825  for (i = 0; i < NheaderSets; i++) {
     
    3835    fseeko (f, Nskip, SEEK_SET);
    3936
    40     inStars = ReadStarsUKIRT (f, name, headers[Nhead], images[0], &Nvalid, &Ninstars);
     37    inStars = ReadStarsUKIRT (f, imagename, headers[Nhead], images[0], &Nvalid, &Ninstars);
    4138    *stars = MergeStars (*stars, Nstars, inStars, Ninstars);
    4239
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadStars.c

    r38521 r38522  
    44
    55  off_t *extsize;
    6   int i, Nfile, NFILE, mode;
    7   char **file, line[4096];
    8   FILE *f;
    9   glob_t globList;
     6  int i, Nfile, mode;
    107  Stars *stars;
    118
    12   if (options[0].filelist) {
    13     // read the list of input files from the supplied file
    14     f = fopen (filename, "r");
    15     if (f == NULL) {
    16       fprintf (stderr, "can't read input list %s, giving up\n", filename);
    17       exit (1);
    18     }
    19 
    20     NFILE = 10;
    21     ALLOCATE (file, char *, NFILE);
    22     for (i = 0; (scan_line (f, line) != EOF); i++) {
    23       // find first non-whitespace char & skip commented lines
    24       for (i = 0; OHANA_WHITESPACE (line[i]); i++);
    25       if (line[i] == '#') continue;
    26       if (line[i] == 0) continue;
    27 
    28       // file lines may have:
    29       // filename
    30       // filename = nebname
    31       // filename limited to 4096 chars
    32       Nfield = sscanf (line, "%s %s %s", word1, sep, word2);
    33       if ((Nfield != 1) && (Nfield != 3)) {
    34         fprintf (stderr, "invalid *line: %s
    35       }
    36 
    37       fprintf (stderr, "file: %s\n", line);
    38       file[i] = strcreate (line);
    39       if (i == NFILE - 1) {
    40         NFILE += 10;
    41         REALLOCATE (file, char *, NFILE);
    42       }
    43     }
    44     Nfile = i;
    45   } else {
    46     // parse the filename as a glob
    47     globList.gl_offs = 0;
    48     glob (filename, 0, NULL, &globList);
    49 
    50     // if the glob does not match, save the literal word:
    51     // otherwise save all glob matches
    52     if (globList.gl_pathc == 0) {
    53       Nfile = 1;
    54       ALLOCATE (file, char *, Nfile);
    55       file[0] = strcreate (filename);
    56     } else {
    57       Nfile = globList.gl_pathc;
    58       ALLOCATE (file, char *, Nfile);
    59       for (i = 0; i < Nfile; i++) {
    60         file[i] = strcreate (globList.gl_pathv[i]);
    61       }
    62     }
    63   }
     9  AddstarFile *file = LoadFilenames (&Nfile, filename, options);
    6410
    6511  *Nimages = 0;
     
    6915
    7016  for (i = 0; i < Nfile; i++) {
    71     f = fopen (file[i], "r");
     17    FILE *f = fopen (file[i].filename, "r");
    7218    if (f == NULL) {
    73       fprintf (stderr, "can't read file %s, skipping\n", file[i]);
     19      fprintf (stderr, "can't read file %s, skipping\n", file[i].filename);
    7420      continue;
    7521    }
     
    7723    // load PMM data if specified (these are not stored as FITS-tables)
    7824    if (PMM_CCD_TABLE != NULL) {
    79       LoadDataPMM (f, file[i], images, Nimages, &stars, Nstars);
     25      LoadDataPMM (f, file[i].imagename, images, Nimages, &stars, Nstars);
    8026      continue;
    8127    }
     
    9036    headerSets = MatchHeaders (&extsize, &NheaderSets, mode, headers, Nheaders);
    9137    if (headerSets == NULL) {
    92       fprintf (stderr, "ERROR: can't read headers for %s\n", file[i]);
     38      fprintf (stderr, "ERROR: can't read headers for %s\n", file[i].filename);
    9339      goto next_file;
    9440    }
    9541    if (NheaderSets == 0) {
    96       fprintf (stderr, "no object data in file %s, skipping\n", file[i]);
     42      fprintf (stderr, "no object data in file %s, skipping\n", file[i].filename);
    9743      goto next_file;
    9844    }
    99     if (VERBOSE) fprintf (stderr, "file %s has %d headers, including "OFF_T_FMT" images\n", file[i], Nheaders,  NheaderSets);
     45    if (VERBOSE) fprintf (stderr, "file %s has %d headers, including "OFF_T_FMT" images\n", file[i].filename, Nheaders,  NheaderSets);
    10046
    10147    /* supplied photcode is incompatible with multi-chip images */
     
    11258    // if these are SDSS data, load with SDSS-specific wrapper
    11359    if (headerSets[0].exttype && !strcmp (headerSets[0].exttype, "SDSS_OBJ")) {
    114       LoadDataSDSS (f, file[i], images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets);
     60      LoadDataSDSS (f, file[i].imagename, images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets);
    11561      goto next_file;
    11662    }
     
    11864    // if these are SDSS data, load with SDSS-specific wrapper
    11965    if (headerSets[0].exttype && !strcmp (headerSets[0].exttype, "UKIRT_OBJ")) {
    120       LoadDataUKIRT (f, file[i], images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets);
     66      LoadDataUKIRT (f, file[i].imagename, images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets);
    12167      goto next_file;
    12268    }
    12369
    124     LoadData (f, file[i], images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets, options);
    125 
    126     // XXX add a function to (optionally) load the extended source measurements
    127     # if (0)
    128     if (extSources) {
    129       // not sure how to link the measurements here to the psf measurements above (though there is an ID in the det list)
    130       LoadDataXSRC (f, file[i], images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets);
    131     }
    132     if (extFits) {
    133       LoadDataXFIT (f, file[i], images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets);
    134     }
    135     # endif
     70    LoadData (f, &file[i], images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets, options);
    13671
    13772  next_file:
     
    15388    exit (0);
    15489  }
     90  ohana_memcheck (TRUE);
    15591
    156   for (i = 0; i < Nfile; i++) {
    157     FREE (file[i]);
    158   }
    159   FREE (file);
    160 
     92  AddstarFileFree (file, Nfile);
    16193  return stars;
    16294}
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/ReadStarsUKIRT.c

    r38496 r38522  
    88// given a file with the pointer at the start of the table block and the
    99// corresponding image header, load the stars from the table
    10 Stars *ReadStarsUKIRT (FILE *f, char *name, Header *header, Image *images, off_t *nimages, unsigned int *nstars) {
     10Stars *ReadStarsUKIRT (FILE *f, char *imagename, Header *header, Image *images, off_t *nimages, unsigned int *nstars) {
    1111
    1212  off_t Nrow;
     
    250250
    251251    // save the filename
    252     snprintf (images[N].name, DVO_IMAGE_NAME_LEN, "%s[%02d]", name, detID);
     252    snprintf (images[N].name, DVO_IMAGE_NAME_LEN, "%s[%02d]", imagename, detID);
    253253    *nimages = N + 1;
    254254  }
Note: See TracChangeset for help on using the changeset viewer.