IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38542


Ignore:
Timestamp:
Jun 25, 2015, 8:57:58 AM (11 years ago)
Author:
eugene
Message:

removing Stars from addstar : converting to Catalog

Location:
branches/eam_branches/ipp-20150616/Ohana/src/addstar
Files:
10 edited

Legend:

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

    r38539 r38542  
    3737mkcmf        : $(BIN)/mkcmf.$(ARCH)
    3838
    39 all: addstar addstar_client sedstar load2mass loadstarpar loadstarpar_client loadICRF loadICRF_client skycells mkcmf loadwise loadtycho loadsupercos dumpskycells findskycell
    40 
    41 INSTALL = addstar addstar_client sedstar load2mass loadstarpar loadstarpar_client loadICRF loadICRF_client skycells mkcmf loadwise loadtycho loadsupercos dumpskycells findskycell
     39old: addstar_client
     40all: addstar sedstar load2mass loadstarpar loadstarpar_client loadICRF loadICRF_client skycells mkcmf loadwise loadtycho loadsupercos dumpskycells findskycell
     41
     42INSTALL = addstar sedstar load2mass loadstarpar loadstarpar_client loadICRF loadICRF_client skycells mkcmf loadwise loadtycho loadsupercos dumpskycells findskycell
    4243
    4344# I need to fix the client/server version of addstar now that I have dropped Stars
    4445# as an autocode type and have converted to carrying average and measure
    4546# all: addstar addstarc addstard addstart sedstar load2mass skycells
     47
     48# $(SRC)/find_matches.$(ARCH).o \
     49# $(SRC)/find_matches_closest.$(ARCH).o \
     50# $(SRC)/find_matches_refstars.$(ARCH).o \
     51# $(SRC)/find_matches_closest_refstars.$(ARCH).o \
     52# $(SRC)/find_subset.$(ARCH).o \
     53# $(SRC)/getgsc.$(ARCH).o \
     54# $(SRC)/getusno.$(ARCH).o \
     55# $(SRC)/getusnob.$(ARCH).o \
     56# $(SRC)/greference.$(ARCH).o \
     57# $(SRC)/grefstars.$(ARCH).o \
     58# $(SRC)/dump.$(ARCH).o \
     59# $(SRC)/ReadStarsTEXT.$(ARCH).o \
     60# $(SRC)/StarOps.$(ARCH).o \
     61# $(SRC)/replace_match.$(ARCH).o \
     62#
    4663
    4764ADDSTAR = \
     
    5774$(SRC)/build_links.$(ARCH).o \
    5875$(SRC)/calibrate.$(ARCH).o \
    59 $(SRC)/dump.$(ARCH).o \
    6076$(SRC)/edge_check.$(ARCH).o \
    6177$(SRC)/fakeimage.$(ARCH).o \
    62 $(SRC)/find_matches.$(ARCH).o \
    6378$(SRC)/find_matches_closest.$(ARCH).o \
    64 $(SRC)/find_matches_refstars.$(ARCH).o \
    65 $(SRC)/find_matches_closest_refstars.$(ARCH).o \
    66 $(SRC)/find_subset.$(ARCH).o \
    67 $(SRC)/getgsc.$(ARCH).o \
    68 $(SRC)/getusno.$(ARCH).o \
    69 $(SRC)/getusnob.$(ARCH).o \
    70 $(SRC)/greference.$(ARCH).o \
    71 $(SRC)/grefstars.$(ARCH).o \
    7279$(SRC)/GetZeroPointExposure.$(ARCH).o \
    7380$(SRC)/LoadFilenames.$(ARCH).o \
     
    7683$(SRC)/MatchHeaders.$(ARCH).o \
    7784$(SRC)/LoadData.$(ARCH).o \
     85$(SRC)/LoadDataSDSS.$(ARCH).o \
     86$(SRC)/LoadDataUKIRT.$(ARCH).o \
     87$(SRC)/LoadDataPMM.$(ARCH).o \
    7888$(SRC)/in_image.$(ARCH).o \
    7989$(SRC)/load_subpix.$(ARCH).o \
    8090$(SRC)/opening_angle.$(ARCH).o \
    8191$(SRC)/parse_time.$(ARCH).o \
    82 $(SRC)/replace_match.$(ARCH).o \
    8392$(SRC)/resort_catalogs.$(ARCH).o \
    8493$(SRC)/resort_threaded.$(ARCH).o \
    8594$(SRC)/resort_unthreaded.$(ARCH).o \
    8695$(SRC)/resort_catalog.$(ARCH).o \
    87 $(SRC)/StarOps.$(ARCH).o \
    8896$(SRC)/ReadStarsFITS.$(ARCH).o \
    89 $(SRC)/ReadStarsTEXT.$(ARCH).o \
    9097$(SRC)/ReadStarsSDSS.$(ARCH).o \
    9198$(SRC)/ReadStarsUKIRT.$(ARCH).o \
     
    100107$(SRC)/psps_ids.$(ARCH).o
    101108
    102 ## $(SRC)/LoadDataSDSS.$(ARCH).o \
    103 ## $(SRC)/LoadDataUKIRT.$(ARCH).o \
    104 ## $(SRC)/LoadDataPMM.$(ARCH).o \
    105109##
    106110
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/include/addstar.h

    r38540 r38542  
    5050} HeaderSet;
    5151
     52# if (0)
    5253typedef struct {
    5354  Average  average;
     
    6768  char *refcat;
    6869} DVO_DATA;
     70# endif
    6971
    7072# define IDTYPE int
     
    212214SkyTable  *SkyTableFromTychoIndex PROTO((char *filename, int VERBOSE));
    213215void       check_permissions      PROTO((char *basefile));
    214 int        dump_rawstars          PROTO((Stars *stars, unsigned int Nstars));
    215216int        edge_check             PROTO((double *x1, double *y1, double *x2, double *y2));
    216217Image     *fakeimage              PROTO((char *rootname, off_t *Nimage, int photcode));
    217218
    218 int        find_matches_closest          PROTO((SkyRegion *region, Catalog *newcat, Catalog *catalog, AddstarClientOptions options));
    219 
     219double     get_subpix             PROTO((double x, double y));
     220
     221int        find_matches_closest   PROTO((SkyRegion *region, Catalog *newcat, Catalog *catalog, AddstarClientOptions options));
     222
     223# if (0)
    220224int        find_matches                  PROTO((SkyRegion *region, Stars *stars,  unsigned int Nstars, Catalog *catalog, AddstarClientOptions options));
    221 // int        find_matches_closest       PROTO((SkyRegion *region, Stars *stars,  unsigned int Nstars, Catalog *catalog, AddstarClientOptions options));
    222225int        find_matches_refstars         PROTO((SkyRegion *region, Stars **stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options));
    223226int        find_matches_closest_refstars PROTO((SkyRegion *region, Stars **stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options));
     227
     228int        dump_rawstars          PROTO((Stars *stars, unsigned int Nstars));
    224229
    225230Stars    **find_subset            PROTO((SkyRegion *region, Stars *stars, unsigned int Nstars, unsigned int *NSTARS));
    226231int        gcatalog               PROTO((Catalog *catalog));
    227232Stars     *get2mass               PROTO((SkyRegion *patch, int photcode, int mode, unsigned int *NSTARS));
    228 double     get_subpix             PROTO((double x, double y));
    229233
    230234Stars     *greference             PROTO((char *Refcat, SkyRegion *catstats, int photcode, unsigned int *nstars));
     
    235239// load text-based stars (REF only in the sense of REF photcodes)
    236240Stars     *grefstars              PROTO((char *file, int photcode, unsigned int *Nstars));
     241
     242Stars     *rd_gsc                 PROTO((char *filename, unsigned int *nstars));
     243
     244int        replace_match          PROTO((Average *average, Measure *measure, Stars *star));
     245# endif
    237246
    238247Catalog   *LoadStars              PROTO((char *file, Image **images, off_t *Nimages, AddstarClientOptions *options));
     
    250259double     opening_angle          PROTO((double x1, double y1, double x2, double y2, double x3, double y3));
    251260int        parse_time             PROTO((Header *header));
    252 Stars     *rd_gsc                 PROTO((char *filename, unsigned int *nstars));
    253 int        replace_match          PROTO((Average *average, Measure *measure, Stars *star));
    254261int        resort_catalogs        PROTO((AddstarClientOptions *options, SkyTable *sky));
    255262int        resort_catalogs_parallel PROTO((AddstarClientOptions *options, SkyList *sky));
     
    259266void       resort_catalog_old     PROTO((Catalog *catalog));
    260267
     268// Stars  *ReadStarsTEXT          PROTO((FILE *f, unsigned int *nstars));
     269
     270int        ReadImageHeader        PROTO((Header *header, Image *image, int photcode));
     271
    261272Catalog   *ReadStarsFITS          PROTO((FILE *f, Header *header, Header *in_theader));
    262 Stars     *ReadStarsTEXT          PROTO((FILE *f, unsigned int *nstars));
    263 Stars     *ReadStarsSDSS          PROTO((FILE *f, char *name, Header *header, Header *in_theader, Image *images, off_t *nimages, unsigned int *nstars));
    264 int        ReadImageHeader        PROTO((Header *header, Image *image, int photcode));
    265273Catalog   *FilterStars            PROTO((Catalog *newcat, Image *image, unsigned int imageID, const AddstarClientOptions *options));
    266 // Stars     *MergeStars             PROTO((Stars *stars, unsigned int *Nstars, Stars *instars, unsigned int Ninstars));
    267 
    268274int        ReadXradFITS           PROTO((FILE *f, Header *theader, Catalog *catalog));
     275
     276Catalog   *LoadDataSDSS           PROTO((FILE *f, char *file, Image **images, off_t *nvalid, Header **headers, off_t *extsize, HeaderSet *headerSets, off_t Nimages));
     277Catalog   *ReadStarsSDSS          PROTO((FILE *f, char *name, Header *header, Header *in_theader, Image *images, off_t *nimages));
    269278
    270279double     scat_subpix            PROTO((double x, double y));
     
    286295AddstarClientOptions args_load2mass PROTO((int argc, char **argv, AddstarClientOptions options));
    287296AddstarClientOptions args_sedstar PROTO((int argc, char **argv, AddstarClientOptions options));
     297
     298SkyList   *SkyListExistingSubset  PROTO((SkyList *input, char *path));
     299
     300// these are all for the addstar client/server which has not been maintained
     301# if (0)
    288302void       args_server            PROTO((int argc, char **argv));
    289303int        CheckPassword          PROTO((int BindSocket));
     
    298312int        UpdateDatabase_Refcat  PROTO((AddstarClientOptions *options, SkyRegion *UserPatch, char *refcat));
    299313SkyList   *SkyListForStars        PROTO((SkyTable *table, int depth, Stars *stars, unsigned int Nstars));
    300 SkyList   *SkyListExistingSubset  PROTO((SkyList *input, char *path));
    301314int        SkyListSetPath         PROTO((SkyList *list, char *path));
    302315int        InitDataset            PROTO((void));
     
    307320int        NewRefcat_Thread       PROTO((int BindSocket));
    308321int        NewReflist_Thread      PROTO((int BindSocket));
    309 
    310 int        InitStar               PROTO((Stars *star));
     322# endif
    311323
    312324int args_skycells (int argc, char **argv);
     
    317329int ImageIndexFileInit ();
    318330
    319 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);
    320 int LoadDataPMM (FILE *f, char *file, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars);
     331Catalog *LoadDataPMM (FILE *f, char *file, Image **images, off_t *nvalid);
    321332
    322333PhotCode *LoadMetadataPMM (char *datafile, Image *image);
     
    340351void saveMosaicCoords (Coords *input);
    341352
    342 Stars *ReadStarsUKIRT (FILE *f, char *name, Header *header, Image *images, off_t *nimages, unsigned int *nstars);
    343 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);
     353Catalog *ReadStarsUKIRT (FILE *f, char *name, Header *header, Image *images, off_t *nimages);
     354Catalog *LoadDataUKIRT (FILE *f, char *file, Image **images, off_t *nimages, Header **headers, off_t *extsize, HeaderSet *headerSets, off_t NheaderSets);
    344355
    345356AddstarFile *LoadFilenames (int *nfile, char *filename, AddstarClientOptions *options);
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadData.c

    r38540 r38542  
    8282    // ReadStarsFITS populates catalog->measure,Nmeasure
    8383    Catalog *newcat = ReadStarsFITS (f, headers[Nhead], headers[Ndata]);
    84     if (!newcat) {
    85       dvo_catalog_free (newcat);
    86       continue;
    87     }
     84    if (!newcat) continue;
     85
    8886    images[0][Nvalid].nstar = newcat->Nmeasure;
    8987
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadDataPMM.c

    r38522 r38542  
    1515# define MAG_INDEX_ASC 22
    1616
    17 int LoadDataPMM (FILE *f, char *imagename, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars) {
     17Catalog *LoadDataPMM (FILE *f, char *imagename, Image **images, off_t *nvalid) {
    1818
    1919  off_t Nvalid, NVALID;
     
    2222  double ra, dec, mag, airmass, az, ZeroPoint, ZeroPt;
    2323  unsigned int Ninstars, NINSTARS;
    24   Stars *inStars;
    2524  PhotCode *photcode;
    2625  gzFile gz;
     
    5857
    5958  NINSTARS = 10000;
    60   ALLOCATE (inStars, Stars, NINSTARS);
     59  Catalog *catalog = addstar_catalog_init (NINSTARS);
     60  ALLOCATE (catalog->average, Average, NINSTARS);
     61  for (i = 0; i < NINSTARS; i++) {
     62    dvo_measure_init (&catalog->measure[i]);
     63    dvo_average_init (&catalog->average[i]);
     64  }
    6165
    6266  minR0 = minR1 = 360.0;
     
    8286      dparse (&dec, 2, &buffer[i*NBYTE_ASC_TABLE]);
    8387      dparse (&mag, 3, &buffer[i*NBYTE_ASC_TABLE]);
    84 
    85       InitStar (&inStars[Ninstars]);
    8688
    8789      if (ra > 180) {
     
    9597      maxD = MAX(maxD, dec);
    9698
    97       inStars[Ninstars].average.R        = ra;
    98       inStars[Ninstars].average.D        = dec;
    99 
    100       inStars[Ninstars].measure.M        = mag - ZeroPoint + ZeroPt;
    101       inStars[Ninstars].measure.t        = images[0][0].tzero;
    102       inStars[Ninstars].measure.dt       = images[0][0].exptime;
    103       inStars[Ninstars].measure.photcode = code;
    104       inStars[Ninstars].measure.airmass  = airmass;
    105       inStars[Ninstars].measure.az       = az;
     99      catalog->average[Ninstars].R        = ra;
     100      catalog->average[Ninstars].D        = dec;
     101      catalog->average[Ninstars].Nmeasure = 1;
     102      catalog->average[Ninstars].measureOffset = Ninstars;
     103
     104      catalog->measure[Ninstars].R        = ra;
     105      catalog->measure[Ninstars].D        = dec;
     106      catalog->measure[Ninstars].M        = mag - ZeroPoint + ZeroPt;
     107      catalog->measure[Ninstars].t        = images[0][0].tzero;
     108      catalog->measure[Ninstars].dt       = images[0][0].exptime;
     109      catalog->measure[Ninstars].photcode = code;
     110      catalog->measure[Ninstars].airmass  = airmass;
     111      catalog->measure[Ninstars].az       = az;
     112
     113      // imageID, detID ?
    106114
    107115      Ninstars++;
    108       CHECK_REALLOCATE (inStars, Stars, NINSTARS, Ninstars, 10000);
     116      if (Ninstars == NINSTARS) {
     117        NINSTARS += 10000;
     118        REALLOCATE (catalog->measure, Measure, NINSTARS);
     119        REALLOCATE (catalog->average, Average, NINSTARS);
     120        for (i = Ninstars; i < NINSTARS; i++) {
     121          dvo_measure_init (&catalog->measure[i]);
     122          dvo_average_init (&catalog->average[i]);
     123        }
     124      }
    109125    }
    110126  }
     127  catalog->Nmeasure = Ninstars;
     128  catalog->Naverage = Ninstars;
    111129
    112130  fprintf (stderr, "ra ranges: %f - %f, %f - %f; dec ranges: %f - %f\n", minR0, maxR0, minR1, maxR1, minD, maxD);
     
    115133  images[0][0].imageID = 0;
    116134
    117   *stars = MergeStars (*stars, Nstars, inStars, Ninstars);
    118 
    119   free (inStars);
    120135  *nvalid = Nvalid + 1;
    121136
    122137  gzclose (gz);
    123138  free (buffer);
    124   return (TRUE);
     139
     140  return (catalog);
    125141}
    126142
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadDataSDSS.c

    r38522 r38542  
    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 *imagename, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, off_t Nimages) {
     6Catalog *LoadDataSDSS (FILE *f, char *imagename, Image **images, off_t *nvalid, Header **headers, off_t *extsize, HeaderSet *headerSets, off_t Nimages) {
    77
    88  off_t Nskip, Nvalid, NVALID;
    99  int j, Nhead, Ndata;
    10   unsigned int Ninstars;
    11   Stars *inStars;
    1210
    1311  if (images[0] == NULL) {
     
    3533  fseeko (f, Nskip, SEEK_SET);
    3634         
    37   // XXX I think this is an error?  should this be &images[0][Nvalid] ??
    38   inStars = ReadStarsSDSS (f, imagename, headers[Nhead], headers[Ndata], images[0], &Nvalid, &Ninstars);
    39   *stars = MergeStars (*stars, Nstars, inStars, Ninstars);
     35  // we pass in images[0] so the function updates the end of the array
     36  Catalog *catalog = ReadStarsSDSS (f, imagename, headers[Nhead], headers[Ndata], images[0], &Nvalid);
    4037
    4138  *nvalid = Nvalid;
    42   return (TRUE);
     39  return (catalog);
    4340}
    4441
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadDataUKIRT.c

    r38522 r38542  
    44// UKIRT data has the WCS/image metadata header intermixed with the bintable header
    55
    6 int 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) {
     6int MergeCatalogs (Catalog *tgt, Catalog *src);
     7
     8Catalog *LoadDataUKIRT (FILE *f, char *imagename, Image **images, off_t *nimages, Header **headers, off_t *extsize, HeaderSet *headerSets, off_t NheaderSets) {
    79
    810  off_t Nskip, Nvalid, NVALID;
    911  int i, j, Nhead, Ndata;
    10   unsigned int Ninstars;
    11   Stars *inStars;
     12
     13  Catalog *catalog = NULL;
     14  ALLOCATE (catalog, Catalog, 1);
     15  dvo_catalog_init (catalog, TRUE);
     16  ALLOCATE (catalog->average, Average, 1);
     17  ALLOCATE (catalog->measure, Measure, 1);
    1218
    1319  // create or update image table
     
    3541    fseeko (f, Nskip, SEEK_SET);
    3642
    37     inStars = ReadStarsUKIRT (f, imagename, headers[Nhead], images[0], &Nvalid, &Ninstars);
    38     *stars = MergeStars (*stars, Nstars, inStars, Ninstars);
     43    Catalog *newcat = ReadStarsUKIRT (f, imagename, headers[Nhead], images[0], &Nvalid);
     44    MergeCatalogs (catalog, newcat);
     45
     46    dvo_catalog_free (newcat);
     47    free (newcat);
    3948
    4049    *nimages = Nvalid;
    4150  }   
    42   return (TRUE);
     51  return (catalog);
    4352}
    4453
     54int MergeCatalogs (Catalog *tgt, Catalog *src) {
     55
     56  // this function assumes the src and tgt catalog do NOT overlap (otherwise just use find_match_closest)
     57
     58  off_t Naverage_tgt = tgt->Naverage;
     59  off_t Nmeasure_tgt = tgt->Nmeasure;
     60
     61  tgt->Naverage += src->Naverage;
     62  tgt->Nmeasure += src->Nmeasure;
     63
     64  REALLOCATE (tgt->average, Average, tgt->Naverage);
     65  REALLOCATE (tgt->measure, Measure, tgt->Nmeasure);
     66
     67  off_t i;
     68  for (i = 0; i < src->Naverage; i++) {
     69    tgt->average[i+Naverage_tgt] = src->average[i];
     70    tgt->average[i+Naverage_tgt].measureOffset += Nmeasure_tgt;
     71  }
     72
     73  for (i = 0; i < src->Nmeasure; i++) {
     74    tgt->measure[i+Nmeasure_tgt] = src->measure[i];
     75  }
     76
     77  return TRUE;
     78}
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadStars.c

    r38536 r38542  
    2525    }
    2626
    27     // load PMM data if specified (these are not stored as FITS-tables)
    28     if (PMM_CCD_TABLE != NULL) {
    29       // XXX catalog = LoadDataPMM (f, file[i].imagename, images, Nimages);
    30       continue;
    31     }
    32 
    3327    int Nheaders = 0;
    3428    Header **headers = NULL;
    3529    off_t NheaderSets = 0;
    3630    HeaderSet *headerSets = NULL;
     31
     32    off_t NimagesStart = *Nimages;
     33    Catalog *newcat = NULL;
     34
     35    // load PMM data if specified (these are not stored as FITS-tables)
     36    if (PMM_CCD_TABLE != NULL) {
     37      newcat = LoadDataPMM (f, file[i].imagename, images, Nimages);
     38      goto next_file;
     39    }
    3740
    3841    // otherwise, we have FITS-table files: parse their headers to determine the contents
     
    6265    // if these are SDSS data, load with SDSS-specific wrapper
    6366    if (headerSets[0].exttype && !strcmp (headerSets[0].exttype, "SDSS_OBJ")) {
    64       // XXX catalog = LoadDataSDSS (f, file[i].imagename, images, Nimages, headers, extsize, headerSets, NheaderSets);
     67      newcat = LoadDataSDSS (f, file[i].imagename, images, Nimages, headers, extsize, headerSets, NheaderSets);
    6568      goto next_file;
    6669    }
     
    6871    // if these are SDSS data, load with SDSS-specific wrapper
    6972    if (headerSets[0].exttype && !strcmp (headerSets[0].exttype, "UKIRT_OBJ")) {
    70       // XXX catalog = LoadDataUKIRT (f, file[i].imagename, images, Nimages, headers, extsize, headerSets, NheaderSets);
     73      newcat = LoadDataUKIRT (f, file[i].imagename, images, Nimages, headers, extsize, headerSets, NheaderSets);
    7174      goto next_file;
    7275    }
    7376
    74     off_t NimagesStart = *Nimages;
    75     Catalog *newcat = LoadData (f, &file[i], images, Nimages, headers, extsize, headerSets, NheaderSets, options);
     77    newcat = LoadData (f, &file[i], images, Nimages, headers, extsize, headerSets, NheaderSets, options);
     78
     79  next_file:
    7680
    7781    // if we added data from an image, then we can merge it in
     
    9498      find_matches_closest (&region, newcat, catalog, matchOptions);
    9599    }
    96     dvo_catalog_free (newcat);
    97     free (newcat);
    98100
    99   next_file:
     101    if (newcat) {
     102      dvo_catalog_free (newcat);
     103      free (newcat);
     104    }
     105
    100106    HeaderSetFree (headerSets, NheaderSets);
    101107    int j;
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/ReadStarsSDSS.c

    r38467 r38542  
    11# include "addstar.h"
    22
    3 int SetSDSSFlags (Stars *star, unsigned int flags1, unsigned int flags2);
     3int SetSDSSFlags (Measure *measure, unsigned int flags1, unsigned int flags2);
    44
    55# define NFILTER 5
     
    3333// given a file with the pointer at the start of the table block and the
    3434// corresponding image header, load the stars from the table
    35 Stars *ReadStarsSDSS (FILE *f, char *name, Header *header, Header *in_theader, Image *images, off_t *nimages, unsigned int *nstars) {
     35Catalog *ReadStarsSDSS (FILE *f, char *name, Header *header, Header *in_theader, Image *images, off_t *nimages) {
    3636
    3737  off_t Nskip, Nrow;
     
    4040  Header theader;
    4141  FTable table;
    42   Stars *stars;
    4342  double clockRate, mjd[5], jd, sidtime, alt, az;
    4443  float seeing[5], photErr[5], zeropt[5], ZeroPt;
     
    113112  // create a Star entry for each filter and detection
    114113  Nstars = table.header[0].Naxis[1];
    115   ALLOCATE (stars, Stars, NFILTER*Nstars);
     114
     115  Catalog *catalog = NULL;
     116  ALLOCATE (catalog, Catalog, 1);
     117  dvo_catalog_init (catalog, TRUE);
     118
     119  ALLOCATE (catalog->average, Average, Nstars);
     120  ALLOCATE (catalog->measure, Measure, NFILTER*Nstars);
     121
     122  for (i = 0; i < Nstars; i++) {
     123    for (j = 0; j < NFILTER; j++) {
     124      dvo_measure_init (&catalog->measure[i*NFILTER + j]);
     125    }
     126    dvo_average_init (&catalog->average[i]);
     127  }
    116128
    117129  GET_COLUMN_5 (rowc, float);
     
    145157
    146158  for (i = 0; i < Nstars; i++) {
     159    // any values not explicitly set are left at 0.0
     160    catalog->average[i].R             = ra[i] + dCOS(dec[i]) * offsetRa[i*NFILTER] / 3600.0;
     161    catalog->average[i].D             = dec[i] + offsetDec[i*NFILTER] / 3600.0;
     162    catalog->average[i].dR            = NAN;
     163    catalog->average[i].dD            = NAN;
     164    catalog->average[i].Nmeasure      = NFILTER;
     165    catalog->average[i].measureOffset = i*NFILTER;
     166
    147167    for (j = 0; j < NFILTER; j++) {
    148168      N = NFILTER*i + j;
    149       InitStar (&stars[N]);
    150169     
    151       // any values not explicitly set are left at 0.0
    152       stars[N].average.R         = ra[i] + dCOS(dec[i]) * offsetRa[N] / 3600.0;
    153       stars[N].average.D         = dec[i] + offsetDec[N] / 3600.0;
    154       stars[N].average.dR        = NAN;
    155       stars[N].average.dD        = NAN;
    156 
    157       stars[N].measure.R         = stars[N].average.R;
    158       stars[N].measure.D         = stars[N].average.D;
    159       stars[N].measure.Xccd      = colc[N];
    160       stars[N].measure.Yccd      = rowc[N];
    161       stars[N].measure.dXccd     = ToShortPixels(colcErr[N]);
    162       stars[N].measure.dYccd     = ToShortPixels(rowcErr[N]);
    163       stars[N].measure.M         = psfCounts[N] + ZeroPt - zeropt[j];
    164       stars[N].measure.dM        = psfCountsErr[N];
    165       stars[N].measure.Map       = fiberCounts[N] + ZeroPt - zeropt[j];
    166       stars[N].measure.Sky       = sky[N]; // adjust this to counts?
    167       stars[N].measure.dSky      = skyErr[N];
    168       stars[N].measure.FWx       = ToShortPixels(seeing[j]); // reported in arcsec?
    169       stars[N].measure.FWy       = ToShortPixels(seeing[j]);
     170      catalog->measure[N].R         = catalog->average[i].R;
     171      catalog->measure[N].D         = catalog->average[i].D;
     172      catalog->measure[N].Xccd      = colc[N];
     173      catalog->measure[N].Yccd      = rowc[N];
     174      catalog->measure[N].dXccd     = ToShortPixels(colcErr[N]);
     175      catalog->measure[N].dYccd     = ToShortPixels(rowcErr[N]);
     176      catalog->measure[N].M         = psfCounts[N] + ZeroPt - zeropt[j];
     177      catalog->measure[N].dM        = psfCountsErr[N];
     178      catalog->measure[N].Map       = fiberCounts[N] + ZeroPt - zeropt[j];
     179      catalog->measure[N].Sky       = sky[N]; // adjust this to counts?
     180      catalog->measure[N].dSky      = skyErr[N];
     181      catalog->measure[N].FWx       = ToShortPixels(seeing[j]); // reported in arcsec?
     182      catalog->measure[N].FWy       = ToShortPixels(seeing[j]);
    170183      if (prob_psf) {
    171           stars[N].measure.psfChisq  = prob_psf[N]; // XXX not really the correct value...
     184          catalog->measure[N].psfChisq  = prob_psf[N]; // XXX not really the correct value...
    172185      } else {
    173           stars[N].measure.psfChisq  = NAN;
     186          catalog->measure[N].psfChisq  = NAN;
    174187      }
    175       stars[N].measure.detID     = N;
    176       stars[N].measure.t         = tzero[j] + clockRate*rowc[N]; // time since row 0
    177       stars[N].measure.dt        = 4.32912209; // 2.5 * log(53.907456) the sdss exposure time // old comment is 53907456 is this 2048*clockRate ?
    178 
    179       SetSDSSFlags (&stars[N], flags[N], flags2[N]);
     188      catalog->measure[N].detID     = N;
     189      catalog->measure[N].t         = tzero[j] + clockRate*rowc[N]; // time since row 0
     190      catalog->measure[N].dt        = 4.32912209; // 2.5 * log(53.907456) the sdss exposure time // old comment is 53907456 is this 2048*clockRate ?
     191
     192      SetSDSSFlags (&catalog->measure[N], flags[N], flags2[N]);
    180193
    181194      // longitude and latitude for SDSS:
     
    187200      double Latitude = 32.7803611755; // degrees
    188201
    189       jd = ohana_sec_to_jd (stars[N].measure.t);
     202      jd = ohana_sec_to_jd (catalog->measure[N].t);
    190203      sidtime  = 15.0*ohana_lst (jd, Longitude); // sidtime in degrees
    191       altaz (&alt, &az, sidtime - stars[N].average.R, stars[N].average.D, Latitude);
    192 
    193       stars[N].measure.airmass   = 1.0 / dCOS(90.0 - alt);
    194       stars[N].measure.az        = az;
    195       stars[N].measure.photcode  = photcode[j];
    196       stars[N].measure.imageID   = j + *nimages; // set imageID to entry for this filter
     204      altaz (&alt, &az, sidtime - catalog->average[i].R, catalog->average[i].D, Latitude);
     205
     206      catalog->measure[N].airmass   = 1.0 / dCOS(90.0 - alt);
     207      catalog->measure[N].az        = az;
     208      catalog->measure[N].photcode  = photcode[j];
     209      catalog->measure[N].imageID   = j + *nimages; // set imageID to entry for this filter
    197210    }
    198211  }   
     
    204217    // XXX for now, we define a totally fake coordinate system centered on the first listed star
    205218    InitCoords (&images[N].coords, "DEC--TAN");
    206     images[N].coords.crval1 = stars[0].average.R;
    207     images[N].coords.crval2 = stars[0].average.D;
    208     images[N].coords.crpix1 = stars[0].measure.Xccd;
    209     images[N].coords.crpix2 = stars[0].measure.Yccd;
     219    images[N].coords.crval1 = catalog->average[0].R;
     220    images[N].coords.crval2 = catalog->average[0].D;
     221    images[N].coords.crpix1 = catalog->measure[0].Xccd;
     222    images[N].coords.crpix2 = catalog->measure[0].Yccd;
    210223    images[N].coords.cdelt1 = images[N].coords.cdelt2 = 0.4 / 3600.0;
    211224
     
    244257
    245258    images[N].trate = clockRate * 1e-4;
    246     images[N].secz = stars[0].measure.airmass;
     259    images[N].secz = catalog->measure[0].airmass;
    247260    images[N].ccdnum = camcol;
    248261
     
    263276  }
    264277
    265   NSTAR_GROUP = NFILTER;
    266278  *nimages += NFILTER;
    267   *nstars = Nstars*NFILTER;
    268   return (stars);
     279  return (catalog);
    269280}
    270281
    271 int SetSDSSFlags (Stars *star, unsigned int flags1, unsigned int flags2) {
     282int SetSDSSFlags (Measure *measure, unsigned int flags1, unsigned int flags2) {
    272283
    273284  // XXX this is wrong, need to roll left to set the correct bit
    274   if (flags1 & 0x00000002) star[0].measure.photFlags |= 0x0001; // BRIGHT            - 1  1
    275   if (flags1 & 0x00000004) star[0].measure.photFlags |= 0x0002; // EDGE              - 1  2
    276   if (flags1 & 0x00000008) star[0].measure.photFlags |= 0x0004; // BLENDED           - 1  3
    277   if (flags1 & 0x00000010) star[0].measure.photFlags |= 0x0008; // CHILD             - 1  4
    278   if (flags1 & 0x00000020) star[0].measure.photFlags |= 0x0010; // PEAKCENTER        - 1  5
    279   if (flags1 & 0x00000040) star[0].measure.photFlags |= 0x0020; // NODEBLEND         - 1  6
    280   if (flags1 & 0x00040000) star[0].measure.photFlags |= 0x0040; // SATUR             - 1 18
    281   if (flags1 & 0x00080000) star[0].measure.photFlags |= 0x0080; // NOTCHECKED        - 1 19
    282   if (flags1 & 0x10000000) star[0].measure.photFlags |= 0x0100; // BINNED1           - 1 28
    283   if (flags1 & 0x20000000) star[0].measure.photFlags |= 0x0200; // BINNED2           - 1 29
    284   if (flags1 & 0x40000000) star[0].measure.photFlags |= 0x0400; // BINNED4           - 1 30
    285   if (flags2 & 0x00000040) star[0].measure.photFlags |= 0x0800; // LOCAL_EDGE        - 2  7
    286   if (flags2 & 0x00000800) star[0].measure.photFlags |= 0x1000; // INTERP_CENTER     - 2 12
    287   if (flags2 & 0x00002000) star[0].measure.photFlags |= 0x2000; // DEBLEND_NOPEAK    - 2 14
    288   if (flags2 & 0x02000000) star[0].measure.photFlags |= 0x4000; // NOTCHECKED_CENTER - 2 26
     285  if (flags1 & 0x00000002) measure->photFlags |= 0x0001; // BRIGHT            - 1  1
     286  if (flags1 & 0x00000004) measure->photFlags |= 0x0002; // EDGE              - 1  2
     287  if (flags1 & 0x00000008) measure->photFlags |= 0x0004; // BLENDED           - 1  3
     288  if (flags1 & 0x00000010) measure->photFlags |= 0x0008; // CHILD             - 1  4
     289  if (flags1 & 0x00000020) measure->photFlags |= 0x0010; // PEAKCENTER        - 1  5
     290  if (flags1 & 0x00000040) measure->photFlags |= 0x0020; // NODEBLEND         - 1  6
     291  if (flags1 & 0x00040000) measure->photFlags |= 0x0040; // SATUR             - 1 18
     292  if (flags1 & 0x00080000) measure->photFlags |= 0x0080; // NOTCHECKED        - 1 19
     293  if (flags1 & 0x10000000) measure->photFlags |= 0x0100; // BINNED1           - 1 28
     294  if (flags1 & 0x20000000) measure->photFlags |= 0x0200; // BINNED2           - 1 29
     295  if (flags1 & 0x40000000) measure->photFlags |= 0x0400; // BINNED4           - 1 30
     296  if (flags2 & 0x00000040) measure->photFlags |= 0x0800; // LOCAL_EDGE        - 2  7
     297  if (flags2 & 0x00000800) measure->photFlags |= 0x1000; // INTERP_CENTER     - 2 12
     298  if (flags2 & 0x00002000) measure->photFlags |= 0x2000; // DEBLEND_NOPEAK    - 2 14
     299  if (flags2 & 0x02000000) measure->photFlags |= 0x4000; // NOTCHECKED_CENTER - 2 26
    289300  return (TRUE);
    290301
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/ReadStarsUKIRT.c

    r38522 r38542  
    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 *imagename, Header *header, Image *images, off_t *nimages, unsigned int *nstars) {
     10Catalog *ReadStarsUKIRT (FILE *f, char *imagename, Header *header, Image *images, off_t *nimages) {
    1111
    1212  off_t Nrow;
     
    1414  char type[80];
    1515  FTable table;
    16   Stars *stars;
    1716 
    1817  // the FITS binary table header is the same as the image header
     
    129128  // create a Star entry for each filter and detection
    130129  int Nstars = table.header[0].Naxis[1];
    131   ALLOCATE (stars, Stars, Nstars);
     130
     131  Catalog *catalog = NULL;
     132  ALLOCATE (catalog, Catalog, 1);
     133  dvo_catalog_init (catalog, TRUE);
     134
     135  ALLOCATE (catalog->average, Average, Nstars);
     136  ALLOCATE (catalog->measure, Measure, Nstars);
     137
     138  int i;
     139  for (i = 0; i < Nstars; i++) {
     140    dvo_measure_init (&catalog->measure[i]);
     141    dvo_average_init (&catalog->average[i]);
     142  }
    132143
    133144  GET_COLUMN (X_coordinate, float);
     
    153164  // ohana_memcheck (TRUE);
    154165
    155   int i;
    156166  for (i = 0; i < Nstars; i++) {
    157     InitStar (&stars[i]);
    158      
     167
    159168    // any values not explicitly set are left at 0.0
    160169    XY_to_RD (&R, &D, X_coordinate[i], Y_coordinate[i], &coords);
    161170
    162     stars[i].average.R         = R;
    163     stars[i].average.D         = D;
    164     stars[i].average.dR        = NAN;
    165     stars[i].average.dD        = NAN;
    166 
    167     stars[i].measure.R         = stars[i].average.R;
    168     stars[i].measure.D         = stars[i].average.D;
    169     stars[i].measure.Xccd      = X_coordinate[i];
    170     stars[i].measure.Yccd      = Y_coordinate[i];
    171     stars[i].measure.dXccd     = ToShortPixels(X_coordinate_err[i]);
    172     stars[i].measure.dYccd     = ToShortPixels(Y_coordinate_err[i]);
    173 
    174     stars[i].measure.M         = -2.5*log10(Aper_flux_4[i]) + ZeroPt + magtime + ApCor4;
    175     stars[i].measure.dM        = Aper_flux_4_err[i] / Aper_flux_4[i];
    176     stars[i].measure.Map       = -2.5*log10(Aper_flux_7[i]) + ZeroPt + magtime + ApCor7;
    177     stars[i].measure.dMap      = Aper_flux_7_err[i] / Aper_flux_7[i];
    178     stars[i].measure.Mkron     = -2.5*log10(Kron_flux[i]) + ZeroPt + magtime;
    179     stars[i].measure.dMkron    = Kron_flux_err[i] / Kron_flux[i];
    180     stars[i].measure.Sky       = Sky_level[i]; // adjust this to counts?
    181     stars[i].measure.dSky      = Sky_rms[i];
    182     stars[i].measure.FWx       = ToShortPixels(seeing); // reported in arcsec?
    183     stars[i].measure.FWy       = ToShortPixels(seeing);
    184 
    185     stars[i].measure.Mcal      = Mcal;
    186 
    187     stars[i].measure.detID     = i;
    188     stars[i].measure.t         = tzero; // time since row 0
    189     stars[i].measure.dt        = magtime; // 2.5 * log(exptime)
    190 
    191     altaz (&alt, &az, sidtime_deg - stars[i].average.R, stars[i].average.D, Latitude);
    192 
    193     stars[i].measure.airmass   = 1.0 / dCOS(90.0 - alt);
    194     stars[i].measure.az        = az;
    195     stars[i].measure.photcode  = photcode;
    196     stars[i].measure.imageID   = *nimages; // set imageID to entry for this filter
     171    catalog->average[i].R             = R;
     172    catalog->average[i].D             = D;
     173    catalog->average[i].dR            = NAN;
     174    catalog->average[i].dD            = NAN;
     175    catalog->average[i].Nmeasure      = 1;
     176    catalog->average[i].measureOffset = i;
     177
     178    catalog->measure[i].R         = catalog->average[i].R;
     179    catalog->measure[i].D         = catalog->average[i].D;
     180    catalog->measure[i].Xccd      = X_coordinate[i];
     181    catalog->measure[i].Yccd      = Y_coordinate[i];
     182    catalog->measure[i].dXccd     = ToShortPixels(X_coordinate_err[i]);
     183    catalog->measure[i].dYccd     = ToShortPixels(Y_coordinate_err[i]);
     184
     185    catalog->measure[i].M         = -2.5*log10(Aper_flux_4[i]) + ZeroPt + magtime + ApCor4;
     186    catalog->measure[i].dM        = Aper_flux_4_err[i] / Aper_flux_4[i];
     187    catalog->measure[i].Map       = -2.5*log10(Aper_flux_7[i]) + ZeroPt + magtime + ApCor7;
     188    catalog->measure[i].dMap      = Aper_flux_7_err[i] / Aper_flux_7[i];
     189    catalog->measure[i].Mkron     = -2.5*log10(Kron_flux[i]) + ZeroPt + magtime;
     190    catalog->measure[i].dMkron    = Kron_flux_err[i] / Kron_flux[i];
     191    catalog->measure[i].Sky       = Sky_level[i]; // adjust this to counts?
     192    catalog->measure[i].dSky      = Sky_rms[i];
     193    catalog->measure[i].FWx       = ToShortPixels(seeing); // reported in arcsec?
     194    catalog->measure[i].FWy       = ToShortPixels(seeing);
     195
     196    catalog->measure[i].Mcal      = Mcal;
     197
     198    catalog->measure[i].detID     = i;
     199    catalog->measure[i].t         = tzero; // time since row 0
     200    catalog->measure[i].dt        = magtime; // 2.5 * log(exptime)
     201
     202    altaz (&alt, &az, sidtime_deg - catalog->average[i].R, catalog->average[i].D, Latitude);
     203
     204    catalog->measure[i].airmass   = 1.0 / dCOS(90.0 - alt);
     205    catalog->measure[i].az        = az;
     206    catalog->measure[i].photcode  = photcode;
     207    catalog->measure[i].imageID   = *nimages; // set imageID to entry for this filter
    197208  }
    198209
     
    256267  // ohana_memcheck (TRUE);
    257268
    258   *nstars = Nstars;
    259   return (stars);
     269  return (catalog);
    260270}
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/SkyListForStars.c

    r27435 r38542  
    11# include "addstar.h"
    22
     3# if (0)
    34void sort_stars_ra (Stars *stars, int N) {
    45
     
    6970
    7071*/
     72# endif
Note: See TracChangeset for help on using the changeset viewer.