Changeset 38542
- Timestamp:
- Jun 25, 2015, 8:57:58 AM (11 years ago)
- Location:
- branches/eam_branches/ipp-20150616/Ohana/src/addstar
- Files:
-
- 10 edited
-
Makefile (modified) (4 diffs)
-
include/addstar.h (modified) (11 diffs)
-
src/LoadData.c (modified) (1 diff)
-
src/LoadDataPMM.c (modified) (6 diffs)
-
src/LoadDataSDSS.c (modified) (2 diffs)
-
src/LoadDataUKIRT.c (modified) (2 diffs)
-
src/LoadStars.c (modified) (4 diffs)
-
src/ReadStarsSDSS.c (modified) (9 diffs)
-
src/ReadStarsUKIRT.c (modified) (5 diffs)
-
src/SkyListForStars.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20150616/Ohana/src/addstar/Makefile
r38539 r38542 37 37 mkcmf : $(BIN)/mkcmf.$(ARCH) 38 38 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 39 old: addstar_client 40 all: addstar sedstar load2mass loadstarpar loadstarpar_client loadICRF loadICRF_client skycells mkcmf loadwise loadtycho loadsupercos dumpskycells findskycell 41 42 INSTALL = addstar sedstar load2mass loadstarpar loadstarpar_client loadICRF loadICRF_client skycells mkcmf loadwise loadtycho loadsupercos dumpskycells findskycell 42 43 43 44 # I need to fix the client/server version of addstar now that I have dropped Stars 44 45 # as an autocode type and have converted to carrying average and measure 45 46 # 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 # 46 63 47 64 ADDSTAR = \ … … 57 74 $(SRC)/build_links.$(ARCH).o \ 58 75 $(SRC)/calibrate.$(ARCH).o \ 59 $(SRC)/dump.$(ARCH).o \60 76 $(SRC)/edge_check.$(ARCH).o \ 61 77 $(SRC)/fakeimage.$(ARCH).o \ 62 $(SRC)/find_matches.$(ARCH).o \63 78 $(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 \72 79 $(SRC)/GetZeroPointExposure.$(ARCH).o \ 73 80 $(SRC)/LoadFilenames.$(ARCH).o \ … … 76 83 $(SRC)/MatchHeaders.$(ARCH).o \ 77 84 $(SRC)/LoadData.$(ARCH).o \ 85 $(SRC)/LoadDataSDSS.$(ARCH).o \ 86 $(SRC)/LoadDataUKIRT.$(ARCH).o \ 87 $(SRC)/LoadDataPMM.$(ARCH).o \ 78 88 $(SRC)/in_image.$(ARCH).o \ 79 89 $(SRC)/load_subpix.$(ARCH).o \ 80 90 $(SRC)/opening_angle.$(ARCH).o \ 81 91 $(SRC)/parse_time.$(ARCH).o \ 82 $(SRC)/replace_match.$(ARCH).o \83 92 $(SRC)/resort_catalogs.$(ARCH).o \ 84 93 $(SRC)/resort_threaded.$(ARCH).o \ 85 94 $(SRC)/resort_unthreaded.$(ARCH).o \ 86 95 $(SRC)/resort_catalog.$(ARCH).o \ 87 $(SRC)/StarOps.$(ARCH).o \88 96 $(SRC)/ReadStarsFITS.$(ARCH).o \ 89 $(SRC)/ReadStarsTEXT.$(ARCH).o \90 97 $(SRC)/ReadStarsSDSS.$(ARCH).o \ 91 98 $(SRC)/ReadStarsUKIRT.$(ARCH).o \ … … 100 107 $(SRC)/psps_ids.$(ARCH).o 101 108 102 ## $(SRC)/LoadDataSDSS.$(ARCH).o \103 ## $(SRC)/LoadDataUKIRT.$(ARCH).o \104 ## $(SRC)/LoadDataPMM.$(ARCH).o \105 109 ## 106 110 -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/include/addstar.h
r38540 r38542 50 50 } HeaderSet; 51 51 52 # if (0) 52 53 typedef struct { 53 54 Average average; … … 67 68 char *refcat; 68 69 } DVO_DATA; 70 # endif 69 71 70 72 # define IDTYPE int … … 212 214 SkyTable *SkyTableFromTychoIndex PROTO((char *filename, int VERBOSE)); 213 215 void check_permissions PROTO((char *basefile)); 214 int dump_rawstars PROTO((Stars *stars, unsigned int Nstars));215 216 int edge_check PROTO((double *x1, double *y1, double *x2, double *y2)); 216 217 Image *fakeimage PROTO((char *rootname, off_t *Nimage, int photcode)); 217 218 218 int find_matches_closest PROTO((SkyRegion *region, Catalog *newcat, Catalog *catalog, AddstarClientOptions options)); 219 219 double get_subpix PROTO((double x, double y)); 220 221 int find_matches_closest PROTO((SkyRegion *region, Catalog *newcat, Catalog *catalog, AddstarClientOptions options)); 222 223 # if (0) 220 224 int 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));222 225 int find_matches_refstars PROTO((SkyRegion *region, Stars **stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options)); 223 226 int find_matches_closest_refstars PROTO((SkyRegion *region, Stars **stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options)); 227 228 int dump_rawstars PROTO((Stars *stars, unsigned int Nstars)); 224 229 225 230 Stars **find_subset PROTO((SkyRegion *region, Stars *stars, unsigned int Nstars, unsigned int *NSTARS)); 226 231 int gcatalog PROTO((Catalog *catalog)); 227 232 Stars *get2mass PROTO((SkyRegion *patch, int photcode, int mode, unsigned int *NSTARS)); 228 double get_subpix PROTO((double x, double y));229 233 230 234 Stars *greference PROTO((char *Refcat, SkyRegion *catstats, int photcode, unsigned int *nstars)); … … 235 239 // load text-based stars (REF only in the sense of REF photcodes) 236 240 Stars *grefstars PROTO((char *file, int photcode, unsigned int *Nstars)); 241 242 Stars *rd_gsc PROTO((char *filename, unsigned int *nstars)); 243 244 int replace_match PROTO((Average *average, Measure *measure, Stars *star)); 245 # endif 237 246 238 247 Catalog *LoadStars PROTO((char *file, Image **images, off_t *Nimages, AddstarClientOptions *options)); … … 250 259 double opening_angle PROTO((double x1, double y1, double x2, double y2, double x3, double y3)); 251 260 int 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));254 261 int resort_catalogs PROTO((AddstarClientOptions *options, SkyTable *sky)); 255 262 int resort_catalogs_parallel PROTO((AddstarClientOptions *options, SkyList *sky)); … … 259 266 void resort_catalog_old PROTO((Catalog *catalog)); 260 267 268 // Stars *ReadStarsTEXT PROTO((FILE *f, unsigned int *nstars)); 269 270 int ReadImageHeader PROTO((Header *header, Image *image, int photcode)); 271 261 272 Catalog *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));265 273 Catalog *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 268 274 int ReadXradFITS PROTO((FILE *f, Header *theader, Catalog *catalog)); 275 276 Catalog *LoadDataSDSS PROTO((FILE *f, char *file, Image **images, off_t *nvalid, Header **headers, off_t *extsize, HeaderSet *headerSets, off_t Nimages)); 277 Catalog *ReadStarsSDSS PROTO((FILE *f, char *name, Header *header, Header *in_theader, Image *images, off_t *nimages)); 269 278 270 279 double scat_subpix PROTO((double x, double y)); … … 286 295 AddstarClientOptions args_load2mass PROTO((int argc, char **argv, AddstarClientOptions options)); 287 296 AddstarClientOptions args_sedstar PROTO((int argc, char **argv, AddstarClientOptions options)); 297 298 SkyList *SkyListExistingSubset PROTO((SkyList *input, char *path)); 299 300 // these are all for the addstar client/server which has not been maintained 301 # if (0) 288 302 void args_server PROTO((int argc, char **argv)); 289 303 int CheckPassword PROTO((int BindSocket)); … … 298 312 int UpdateDatabase_Refcat PROTO((AddstarClientOptions *options, SkyRegion *UserPatch, char *refcat)); 299 313 SkyList *SkyListForStars PROTO((SkyTable *table, int depth, Stars *stars, unsigned int Nstars)); 300 SkyList *SkyListExistingSubset PROTO((SkyList *input, char *path));301 314 int SkyListSetPath PROTO((SkyList *list, char *path)); 302 315 int InitDataset PROTO((void)); … … 307 320 int NewRefcat_Thread PROTO((int BindSocket)); 308 321 int NewReflist_Thread PROTO((int BindSocket)); 309 310 int InitStar PROTO((Stars *star)); 322 # endif 311 323 312 324 int args_skycells (int argc, char **argv); … … 317 329 int ImageIndexFileInit (); 318 330 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); 331 Catalog *LoadDataPMM (FILE *f, char *file, Image **images, off_t *nvalid); 321 332 322 333 PhotCode *LoadMetadataPMM (char *datafile, Image *image); … … 340 351 void saveMosaicCoords (Coords *input); 341 352 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);353 Catalog *ReadStarsUKIRT (FILE *f, char *name, Header *header, Image *images, off_t *nimages); 354 Catalog *LoadDataUKIRT (FILE *f, char *file, Image **images, off_t *nimages, Header **headers, off_t *extsize, HeaderSet *headerSets, off_t NheaderSets); 344 355 345 356 AddstarFile *LoadFilenames (int *nfile, char *filename, AddstarClientOptions *options); -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadData.c
r38540 r38542 82 82 // ReadStarsFITS populates catalog->measure,Nmeasure 83 83 Catalog *newcat = ReadStarsFITS (f, headers[Nhead], headers[Ndata]); 84 if (!newcat) { 85 dvo_catalog_free (newcat); 86 continue; 87 } 84 if (!newcat) continue; 85 88 86 images[0][Nvalid].nstar = newcat->Nmeasure; 89 87 -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadDataPMM.c
r38522 r38542 15 15 # define MAG_INDEX_ASC 22 16 16 17 int LoadDataPMM (FILE *f, char *imagename, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars) {17 Catalog *LoadDataPMM (FILE *f, char *imagename, Image **images, off_t *nvalid) { 18 18 19 19 off_t Nvalid, NVALID; … … 22 22 double ra, dec, mag, airmass, az, ZeroPoint, ZeroPt; 23 23 unsigned int Ninstars, NINSTARS; 24 Stars *inStars;25 24 PhotCode *photcode; 26 25 gzFile gz; … … 58 57 59 58 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 } 61 65 62 66 minR0 = minR1 = 360.0; … … 82 86 dparse (&dec, 2, &buffer[i*NBYTE_ASC_TABLE]); 83 87 dparse (&mag, 3, &buffer[i*NBYTE_ASC_TABLE]); 84 85 InitStar (&inStars[Ninstars]);86 88 87 89 if (ra > 180) { … … 95 97 maxD = MAX(maxD, dec); 96 98 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 ? 106 114 107 115 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 } 109 125 } 110 126 } 127 catalog->Nmeasure = Ninstars; 128 catalog->Naverage = Ninstars; 111 129 112 130 fprintf (stderr, "ra ranges: %f - %f, %f - %f; dec ranges: %f - %f\n", minR0, maxR0, minR1, maxR1, minD, maxD); … … 115 133 images[0][0].imageID = 0; 116 134 117 *stars = MergeStars (*stars, Nstars, inStars, Ninstars);118 119 free (inStars);120 135 *nvalid = Nvalid + 1; 121 136 122 137 gzclose (gz); 123 138 free (buffer); 124 return (TRUE); 139 140 return (catalog); 125 141 } 126 142 -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadDataSDSS.c
r38522 r38542 4 4 // there should only be a single data set (phu + table) in this file 5 5 // 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) {6 Catalog *LoadDataSDSS (FILE *f, char *imagename, Image **images, off_t *nvalid, Header **headers, off_t *extsize, HeaderSet *headerSets, off_t Nimages) { 7 7 8 8 off_t Nskip, Nvalid, NVALID; 9 9 int j, Nhead, Ndata; 10 unsigned int Ninstars;11 Stars *inStars;12 10 13 11 if (images[0] == NULL) { … … 35 33 fseeko (f, Nskip, SEEK_SET); 36 34 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); 40 37 41 38 *nvalid = Nvalid; 42 return ( TRUE);39 return (catalog); 43 40 } 44 41 -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadDataUKIRT.c
r38522 r38542 4 4 // UKIRT data has the WCS/image metadata header intermixed with the bintable header 5 5 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) { 6 int MergeCatalogs (Catalog *tgt, Catalog *src); 7 8 Catalog *LoadDataUKIRT (FILE *f, char *imagename, Image **images, off_t *nimages, Header **headers, off_t *extsize, HeaderSet *headerSets, off_t NheaderSets) { 7 9 8 10 off_t Nskip, Nvalid, NVALID; 9 11 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); 12 18 13 19 // create or update image table … … 35 41 fseeko (f, Nskip, SEEK_SET); 36 42 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); 39 48 40 49 *nimages = Nvalid; 41 50 } 42 return ( TRUE);51 return (catalog); 43 52 } 44 53 54 int 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 25 25 } 26 26 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 33 27 int Nheaders = 0; 34 28 Header **headers = NULL; 35 29 off_t NheaderSets = 0; 36 30 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 } 37 40 38 41 // otherwise, we have FITS-table files: parse their headers to determine the contents … … 62 65 // if these are SDSS data, load with SDSS-specific wrapper 63 66 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); 65 68 goto next_file; 66 69 } … … 68 71 // if these are SDSS data, load with SDSS-specific wrapper 69 72 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); 71 74 goto next_file; 72 75 } 73 76 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: 76 80 77 81 // if we added data from an image, then we can merge it in … … 94 98 find_matches_closest (®ion, newcat, catalog, matchOptions); 95 99 } 96 dvo_catalog_free (newcat);97 free (newcat);98 100 99 next_file: 101 if (newcat) { 102 dvo_catalog_free (newcat); 103 free (newcat); 104 } 105 100 106 HeaderSetFree (headerSets, NheaderSets); 101 107 int j; -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/ReadStarsSDSS.c
r38467 r38542 1 1 # include "addstar.h" 2 2 3 int SetSDSSFlags ( Stars *star, unsigned int flags1, unsigned int flags2);3 int SetSDSSFlags (Measure *measure, unsigned int flags1, unsigned int flags2); 4 4 5 5 # define NFILTER 5 … … 33 33 // given a file with the pointer at the start of the table block and the 34 34 // 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) {35 Catalog *ReadStarsSDSS (FILE *f, char *name, Header *header, Header *in_theader, Image *images, off_t *nimages) { 36 36 37 37 off_t Nskip, Nrow; … … 40 40 Header theader; 41 41 FTable table; 42 Stars *stars;43 42 double clockRate, mjd[5], jd, sidtime, alt, az; 44 43 float seeing[5], photErr[5], zeropt[5], ZeroPt; … … 113 112 // create a Star entry for each filter and detection 114 113 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 } 116 128 117 129 GET_COLUMN_5 (rowc, float); … … 145 157 146 158 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 147 167 for (j = 0; j < NFILTER; j++) { 148 168 N = NFILTER*i + j; 149 InitStar (&stars[N]);150 169 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]); 170 183 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... 172 185 } else { 173 stars[N].measure.psfChisq = NAN;186 catalog->measure[N].psfChisq = NAN; 174 187 } 175 stars[N].measure.detID = N;176 stars[N].measure.t = tzero[j] + clockRate*rowc[N]; // time since row 0177 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]); 180 193 181 194 // longitude and latitude for SDSS: … … 187 200 double Latitude = 32.7803611755; // degrees 188 201 189 jd = ohana_sec_to_jd ( stars[N].measure.t);202 jd = ohana_sec_to_jd (catalog->measure[N].t); 190 203 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 filter204 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 197 210 } 198 211 } … … 204 217 // XXX for now, we define a totally fake coordinate system centered on the first listed star 205 218 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; 210 223 images[N].coords.cdelt1 = images[N].coords.cdelt2 = 0.4 / 3600.0; 211 224 … … 244 257 245 258 images[N].trate = clockRate * 1e-4; 246 images[N].secz = stars[0].measure.airmass;259 images[N].secz = catalog->measure[0].airmass; 247 260 images[N].ccdnum = camcol; 248 261 … … 263 276 } 264 277 265 NSTAR_GROUP = NFILTER;266 278 *nimages += NFILTER; 267 *nstars = Nstars*NFILTER; 268 return (stars); 279 return (catalog); 269 280 } 270 281 271 int SetSDSSFlags ( Stars *star, unsigned int flags1, unsigned int flags2) {282 int SetSDSSFlags (Measure *measure, unsigned int flags1, unsigned int flags2) { 272 283 273 284 // XXX this is wrong, need to roll left to set the correct bit 274 if (flags1 & 0x00000002) star[0].measure.photFlags |= 0x0001; // BRIGHT - 1 1275 if (flags1 & 0x00000004) star[0].measure.photFlags |= 0x0002; // EDGE - 1 2276 if (flags1 & 0x00000008) star[0].measure.photFlags |= 0x0004; // BLENDED - 1 3277 if (flags1 & 0x00000010) star[0].measure.photFlags |= 0x0008; // CHILD - 1 4278 if (flags1 & 0x00000020) star[0].measure.photFlags |= 0x0010; // PEAKCENTER - 1 5279 if (flags1 & 0x00000040) star[0].measure.photFlags |= 0x0020; // NODEBLEND - 1 6280 if (flags1 & 0x00040000) star[0].measure.photFlags |= 0x0040; // SATUR - 1 18281 if (flags1 & 0x00080000) star[0].measure.photFlags |= 0x0080; // NOTCHECKED - 1 19282 if (flags1 & 0x10000000) star[0].measure.photFlags |= 0x0100; // BINNED1 - 1 28283 if (flags1 & 0x20000000) star[0].measure.photFlags |= 0x0200; // BINNED2 - 1 29284 if (flags1 & 0x40000000) star[0].measure.photFlags |= 0x0400; // BINNED4 - 1 30285 if (flags2 & 0x00000040) star[0].measure.photFlags |= 0x0800; // LOCAL_EDGE - 2 7286 if (flags2 & 0x00000800) star[0].measure.photFlags |= 0x1000; // INTERP_CENTER - 2 12287 if (flags2 & 0x00002000) star[0].measure.photFlags |= 0x2000; // DEBLEND_NOPEAK - 2 14288 if (flags2 & 0x02000000) star[0].measure.photFlags |= 0x4000; // NOTCHECKED_CENTER - 2 26285 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 289 300 return (TRUE); 290 301 -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/ReadStarsUKIRT.c
r38522 r38542 8 8 // given a file with the pointer at the start of the table block and the 9 9 // 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) {10 Catalog *ReadStarsUKIRT (FILE *f, char *imagename, Header *header, Image *images, off_t *nimages) { 11 11 12 12 off_t Nrow; … … 14 14 char type[80]; 15 15 FTable table; 16 Stars *stars;17 16 18 17 // the FITS binary table header is the same as the image header … … 129 128 // create a Star entry for each filter and detection 130 129 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 } 132 143 133 144 GET_COLUMN (X_coordinate, float); … … 153 164 // ohana_memcheck (TRUE); 154 165 155 int i;156 166 for (i = 0; i < Nstars; i++) { 157 InitStar (&stars[i]); 158 167 159 168 // any values not explicitly set are left at 0.0 160 169 XY_to_RD (&R, &D, X_coordinate[i], Y_coordinate[i], &coords); 161 170 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 197 208 } 198 209 … … 256 267 // ohana_memcheck (TRUE); 257 268 258 *nstars = Nstars; 259 return (stars); 269 return (catalog); 260 270 } -
branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/SkyListForStars.c
r27435 r38542 1 1 # include "addstar.h" 2 2 3 # if (0) 3 4 void sort_stars_ra (Stars *stars, int N) { 4 5 … … 69 70 70 71 */ 72 # endif
Note:
See TracChangeset
for help on using the changeset viewer.
