Changeset 38553
- Timestamp:
- Jun 25, 2015, 10:41:05 PM (11 years ago)
- Location:
- trunk/Ohana/src
- Files:
-
- 2 deleted
- 104 edited
- 18 copied
-
addstar/Makefile (modified) (9 diffs)
-
addstar/doc/ff.and.diff.txt (copied) (copied from branches/eam_branches/ipp-20150616/Ohana/src/addstar/doc/ff.and.diff.txt )
-
addstar/include/addstar.h (modified) (12 diffs)
-
addstar/include/loadgalphot.h (copied) (copied from branches/eam_branches/ipp-20150616/Ohana/src/addstar/include/loadgalphot.h )
-
addstar/src/ConfigInit.c (modified) (2 diffs)
-
addstar/src/FilterStars.c (modified) (6 diffs)
-
addstar/src/ImageIndex.c (modified) (10 diffs)
-
addstar/src/LoadData.c (modified) (6 diffs)
-
addstar/src/LoadDataPMM.c (modified) (6 diffs)
-
addstar/src/LoadDataSDSS.c (modified) (3 diffs)
-
addstar/src/LoadDataUKIRT.c (modified) (3 diffs)
-
addstar/src/LoadFilenames.c (copied) (copied from branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadFilenames.c )
-
addstar/src/LoadHeaders.c (modified) (1 diff)
-
addstar/src/LoadStars.c (modified) (4 diffs)
-
addstar/src/MatchHeaders.c (modified) (5 diffs)
-
addstar/src/ReadStarsFITS.c (modified) (43 diffs)
-
addstar/src/ReadStarsSDSS.c (modified) (9 diffs)
-
addstar/src/ReadStarsUKIRT.c (modified) (8 diffs)
-
addstar/src/ReadXradFITS.c (modified) (3 diffs)
-
addstar/src/SkyListForStars.c (modified) (2 diffs)
-
addstar/src/UpdateImageIDs.c (modified) (3 diffs)
-
addstar/src/addstar.c (modified) (9 diffs)
-
addstar/src/args_loadgalphot.c (copied) (copied from branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/args_loadgalphot.c )
-
addstar/src/find_matches.c (modified) (11 diffs)
-
addstar/src/find_matches_closest.c (modified) (11 diffs)
-
addstar/src/find_matches_galphot.c (copied) (copied from branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/find_matches_galphot.c )
-
addstar/src/loadgalphot.c (copied) (copied from branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/loadgalphot.c )
-
addstar/src/loadgalphot_catalog.c (copied) (copied from branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/loadgalphot_catalog.c )
-
addstar/src/loadgalphot_fit2d.c (copied) (copied from branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/loadgalphot_fit2d.c )
-
addstar/src/loadgalphot_join.c (copied) (copied from branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/loadgalphot_join.c )
-
addstar/src/loadgalphot_make_subset.c (copied) (copied from branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/loadgalphot_make_subset.c )
-
addstar/src/loadgalphot_readstars.c (copied) (copied from branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/loadgalphot_readstars.c )
-
addstar/src/loadgalphot_table.c (copied) (copied from branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/loadgalphot_table.c )
-
addstar/src/sortIDs.c (copied) (copied from branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/sortIDs.c )
-
addstar/src/strhash.c (copied) (copied from branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/strhash.c )
-
addstar/test (modified) (1 prop)
-
addstar/test/compress.dvo (modified) (2 diffs)
-
addstar/test/dvomerge.dvo (modified) (19 diffs)
-
addstar/test/groups.dvo (copied) (copied from branches/eam_branches/ipp-20150616/Ohana/src/addstar/test/groups.dvo )
-
addstar/test/ptolemy.dvo (copied) (copied from branches/eam_branches/ipp-20150616/Ohana/src/addstar/test/ptolemy.dvo )
-
addstar/test/relastro.dvo (modified) (2 diffs)
-
addstar/test/relphot.dvo (modified) (2 diffs)
-
addstar/test/relphot.flatcorr.dvo (modified) (3 diffs)
-
addstar/test/relphot.parallel.dvo (modified) (1 diff)
-
addstar/test/relphot.reject.dvo (modified) (1 diff)
-
addstar/test/simple.dvo (modified) (2 diffs)
-
dvomerge/include/dvomerge.h (modified) (5 diffs)
-
dvomerge/include/dvoverify.h (modified) (2 diffs)
-
dvomerge/src/ConfigInit.c (modified) (1 diff)
-
dvomerge/src/args.c (modified) (3 diffs)
-
dvomerge/src/dvo_image_merge_dbs.c (modified) (1 diff)
-
dvomerge/src/dvomerge.c (modified) (2 diffs)
-
dvomerge/src/dvomergeHistory.c (modified) (8 diffs)
-
dvomerge/src/dvomergeImageIDs.c (modified) (3 diffs)
-
dvomerge/src/dvomergeUpdate.c (modified) (4 diffs)
-
dvomerge/src/dvoverify.c (modified) (3 diffs)
-
dvomerge/src/dvoverify_args.c (modified) (1 diff)
-
dvomerge/src/dvoverify_catalogs.c (modified) (6 diffs)
-
dvomerge/src/dvoverify_utils.c (modified) (6 diffs)
-
imregister/photreg/output.c (modified) (1 diff)
-
kapa2/src/bDrawIt.c (modified) (2 diffs)
-
libautocode/Makefile.Targets (modified) (2 diffs)
-
libautocode/def/galphot-ps1-v5.d (copied) (copied from branches/eam_branches/ipp-20150616/Ohana/src/libautocode/def/galphot-ps1-v5.d )
-
libautocode/def/galphot.d (copied) (copied from branches/eam_branches/ipp-20150616/Ohana/src/libautocode/def/galphot.d )
-
libautocode/def/galshape-ps1-v5.d (deleted)
-
libautocode/def/galshape.d (deleted)
-
libdvo/include/cmf-ps1-v5-r2-lensing.h (modified) (1 diff)
-
libdvo/include/convert.h (modified) (1 diff)
-
libdvo/include/dvo.h (modified) (2 diffs)
-
libdvo/src/HostTable.c (modified) (1 diff)
-
libdvo/src/LoadImages.c (modified) (1 diff)
-
libdvo/src/LoadPhotcodesFITS.c (modified) (2 diffs)
-
libdvo/src/RegionHostTable.c (modified) (1 diff)
-
libdvo/src/SavePhotcodesFITS.c (modified) (1 diff)
-
libdvo/src/cmf-ps1-v5-r2-lensing.c (modified) (1 diff)
-
libdvo/src/convert.c (modified) (9 diffs)
-
libdvo/src/coordops.c (modified) (2 diffs)
-
libdvo/src/dvo_catalog.c (modified) (5 diffs)
-
libdvo/src/dvo_catalog_create.c (modified) (2 diffs)
-
libdvo/src/dvo_catalog_split.c (modified) (12 diffs)
-
libdvo/src/dvo_convert.c (modified) (1 diff)
-
libdvo/src/dvo_convert_PS1_V5.c (modified) (3 diffs)
-
libdvo/src/dvo_image.c (modified) (2 diffs)
-
libdvo/src/dvo_photcode_ops.c (modified) (1 diff)
-
libdvo/src/dvo_util.c (modified) (2 diffs)
-
libdvo/src/skydb.c (modified) (4 diffs)
-
libdvo/src/skyregion_gsc.c (modified) (17 diffs)
-
libdvo/src/skyregion_io.c (modified) (5 diffs)
-
libdvo/src/skyregion_ops.c (modified) (1 diff)
-
libfits/header/F_write_H.c (modified) (2 diffs)
-
libfits/include/gfitsio.h (modified) (1 diff)
-
libfits/matrix/F_write_M.c (modified) (1 diff)
-
libfits/table/F_compress_T.c (modified) (4 diffs)
-
libfits/table/F_create_TH.c (modified) (2 diffs)
-
libfits/table/F_define_column.c (modified) (7 diffs)
-
libfits/table/F_get_T_column.c (modified) (2 diffs)
-
libfits/table/F_get_T_value.c (modified) (2 diffs)
-
libfits/table/F_get_column.c (modified) (16 diffs)
-
libfits/table/F_set_column.c (modified) (12 diffs)
-
libfits/table/F_table_column.c (modified) (4 diffs)
-
libfits/table/F_table_format.c (modified) (9 diffs)
-
libfits/table/F_table_varlength.c (modified) (2 diffs)
-
libfits/table/F_uncompress_T.c (modified) (4 diffs)
-
libfits/table/F_write_T.c (modified) (2 diffs)
-
libfits/table/F_write_TH.c (modified) (2 diffs)
-
libfits/test (modified) (1 prop)
-
libfits/test/imagecomp.c (modified) (4 diffs)
-
libfits/test/tablecomp.c (modified) (1 diff)
-
libfits/test/tcomptiming.c (modified) (1 diff)
-
libohana/include/ohana.h (modified) (1 diff)
-
libohana/include/ohana_allocate.h (modified) (3 diffs)
-
libohana/src/config.c (modified) (4 diffs)
-
libohana/src/findexec.c (modified) (4 diffs)
-
libohana/src/gaussj.c (modified) (1 diff)
-
libohana/src/glockfile.c (modified) (2 diffs)
-
libohana/src/ohana_allocate.c (modified) (17 diffs)
-
libohana/src/time.c (modified) (2 diffs)
-
opihi/cmd.astro/radec.c (modified) (1 diff)
-
opihi/cmd.astro/sexigesimal.c (modified) (1 diff)
-
opihi/cmd.data/read_vectors.c (modified) (1 diff)
-
opihi/dimm/telescope_cmds.c (modified) (1 diff)
-
opihi/lib.shell/stack_math.c (modified) (6 diffs)
-
relastro/src/BrightCatalog.c (modified) (4 diffs)
-
relastro/src/FrameCorrectionUtils.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/Makefile
r38467 r38553 24 24 sedstar : $(BIN)/sedstar.$(ARCH) 25 25 load2mass : $(BIN)/load2mass.$(ARCH) 26 loadgalphot : $(BIN)/loadgalphot.$(ARCH) 26 27 loadstarpar : $(BIN)/loadstarpar.$(ARCH) 27 28 loadstarpar_client : $(BIN)/loadstarpar_client.$(ARCH) … … 36 37 mkcmf : $(BIN)/mkcmf.$(ARCH) 37 38 38 all: addstar addstar_client sedstar load2mass loadstarpar loadstarpar_client loadICRF loadICRF_client skycells mkcmf loadwise loadtycho loadsupercos dumpskycells findskycell 39 40 INSTALL = addstar addstar_client sedstar load2mass loadstarpar loadstarpar_client loadICRF loadICRF_client skycells mkcmf loadwise loadtycho loadsupercos dumpskycells findskycell 39 # programs in 'OTHERS' have not been updated since moving from Stars to Catalog as an internal carrier 40 # programs in 'SERVER' use the client-server concept and are out of date 41 42 INSTALL = addstar sedstar loadstarpar loadstarpar_client loadICRF loadICRF_client skycells mkcmf dumpskycells findskycell 43 OTHERS = load2mass loadwise loadtycho loadsupercos 44 SERVER = addstar_client addstarc addstard addstart 45 46 old: $(OTHERS) 47 all: $(INSTALL) 41 48 42 49 # I need to fix the client/server version of addstar now that I have dropped Stars 43 50 # as an autocode type and have converted to carrying average and measure 44 # all: addstar addstarc addstard addstart sedstar load2mass skycells 51 # all: addstar sedstar load2mass skycells 52 53 # $(SRC)/find_matches.$(ARCH).o \ 54 # $(SRC)/find_matches_closest.$(ARCH).o \ 55 # $(SRC)/find_matches_refstars.$(ARCH).o \ 56 # $(SRC)/find_matches_closest_refstars.$(ARCH).o \ 57 # $(SRC)/find_subset.$(ARCH).o \ 58 # $(SRC)/getgsc.$(ARCH).o \ 59 # $(SRC)/getusno.$(ARCH).o \ 60 # $(SRC)/getusnob.$(ARCH).o \ 61 # $(SRC)/greference.$(ARCH).o \ 62 # $(SRC)/grefstars.$(ARCH).o \ 63 # $(SRC)/dump.$(ARCH).o \ 64 # $(SRC)/ReadStarsTEXT.$(ARCH).o \ 65 # $(SRC)/StarOps.$(ARCH).o \ 66 # $(SRC)/replace_match.$(ARCH).o \ 67 # 45 68 46 69 ADDSTAR = \ … … 56 79 $(SRC)/build_links.$(ARCH).o \ 57 80 $(SRC)/calibrate.$(ARCH).o \ 58 $(SRC)/dump.$(ARCH).o \59 81 $(SRC)/edge_check.$(ARCH).o \ 60 82 $(SRC)/fakeimage.$(ARCH).o \ 61 83 $(SRC)/find_matches.$(ARCH).o \ 62 84 $(SRC)/find_matches_closest.$(ARCH).o \ 63 $(SRC)/find_matches_refstars.$(ARCH).o \64 $(SRC)/find_matches_closest_refstars.$(ARCH).o \65 $(SRC)/find_subset.$(ARCH).o \66 $(SRC)/getgsc.$(ARCH).o \67 $(SRC)/getusno.$(ARCH).o \68 $(SRC)/getusnob.$(ARCH).o \69 $(SRC)/greference.$(ARCH).o \70 $(SRC)/grefstars.$(ARCH).o \71 85 $(SRC)/GetZeroPointExposure.$(ARCH).o \ 86 $(SRC)/LoadFilenames.$(ARCH).o \ 72 87 $(SRC)/LoadStars.$(ARCH).o \ 73 88 $(SRC)/LoadHeaders.$(ARCH).o \ … … 81 96 $(SRC)/opening_angle.$(ARCH).o \ 82 97 $(SRC)/parse_time.$(ARCH).o \ 83 $(SRC)/replace_match.$(ARCH).o \84 98 $(SRC)/resort_catalogs.$(ARCH).o \ 85 99 $(SRC)/resort_threaded.$(ARCH).o \ 86 100 $(SRC)/resort_unthreaded.$(ARCH).o \ 87 101 $(SRC)/resort_catalog.$(ARCH).o \ 88 $(SRC)/StarOps.$(ARCH).o \89 102 $(SRC)/ReadStarsFITS.$(ARCH).o \ 90 $(SRC)/ReadStarsTEXT.$(ARCH).o \91 103 $(SRC)/ReadStarsSDSS.$(ARCH).o \ 92 104 $(SRC)/ReadStarsUKIRT.$(ARCH).o \ … … 100 112 $(SRC)/update_coords.$(ARCH).o \ 101 113 $(SRC)/psps_ids.$(ARCH).o 114 115 ## 102 116 103 117 # this is the client for parallel operations … … 244 258 $(SRC)/psps_ids.$(ARCH).o 245 259 260 LOAD-GALPHOT = \ 261 $(SRC)/loadgalphot.$(ARCH).o \ 262 $(SRC)/ConfigInit.$(ARCH).o \ 263 $(SRC)/SetSignals.$(ARCH).o \ 264 $(SRC)/Shutdown.$(ARCH).o \ 265 $(SRC)/args_loadgalphot.$(ARCH).o \ 266 $(SRC)/find_matches_galphot.$(ARCH).o \ 267 $(SRC)/loadgalphot_catalog.$(ARCH).o \ 268 $(SRC)/loadgalphot_make_subset.$(ARCH).o \ 269 $(SRC)/loadgalphot_readstars.$(ARCH).o \ 270 $(SRC)/loadgalphot_fit2d.$(ARCH).o \ 271 $(SRC)/loadgalphot_join.$(ARCH).o \ 272 $(SRC)/loadgalphot_table.$(ARCH).o \ 273 $(SRC)/strhash.$(ARCH).o \ 274 $(SRC)/sortIDs.$(ARCH).o \ 275 $(SRC)/psps_ids.$(ARCH).o 276 277 # $(SRC)/SkyRegionUtils.$(ARCH).o 278 # $(SRC)/loadstarpar_io.$(ARCH).o 279 # $(SRC)/loadgalphot_remote_hosts.$(ARCH).o 280 # $(SRC)/loadgalphot_save_remote.$(ARCH).o 281 246 282 LOAD-STARPAR = \ 247 283 $(SRC)/loadstarpar.$(ARCH).o \ … … 338 374 $(SRC)/find_matches_closest_refstars.$(ARCH).o \ 339 375 $(SRC)/build_links.$(ARCH).o \ 340 $(SRC)/replace_match.$(ARCH).o \341 376 $(SRC)/SetSignals.$(ARCH).o \ 342 377 $(SRC)/update_coords.$(ARCH).o \ … … 404 439 $(FINDSKYCELL) : $(INC)/addstar.h 405 440 $(LOAD-2MASS) : $(INC)/addstar.h $(INC)/2mass.h 441 $(LOAD-GALPHOT) : $(INC)/addstar.h $(INC)/loadgalphot.h 406 442 $(LOAD-STARPAR) : $(INC)/addstar.h $(INC)/loadstarpar.h 407 443 $(LOAD-STARPAR-CLIENT) : $(INC)/addstar.h $(INC)/loadstarpar.h … … 421 457 $(BIN)/loadwise.$(ARCH) : $(LOAD-WISE) 422 458 $(BIN)/loadtycho.$(ARCH) : $(LOAD-TYCHO) 459 $(BIN)/loadgalphot.$(ARCH) : $(LOAD-GALPHOT) 423 460 $(BIN)/loadstarpar.$(ARCH) : $(LOAD-STARPAR) 424 461 $(BIN)/loadstarpar_client.$(ARCH) : $(LOAD-STARPAR-CLIENT) -
trunk/Ohana/src/addstar/include/addstar.h
r38467 r38553 33 33 34 34 # define myAbortF(FORMAT,...) { fprintf (stderr, FORMAT, __VA_ARGS__); abort(); } 35 36 // things that are needed for a single file 37 typedef 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; 35 41 36 42 typedef struct { … … 44 50 } HeaderSet; 45 51 52 # if (0) 46 53 typedef struct { 47 54 Average average; … … 61 68 char *refcat; 62 69 } DVO_DATA; 70 # endif 63 71 64 72 # define IDTYPE int … … 190 198 AddstarClientOptions args PROTO((int argc, char **argv, AddstarClientOptions options)); 191 199 AddstarClientOptions args_parallel_client PROTO((int argc, char **argv, AddstarClientOptions options)); 200 void FreeConfig PROTO((void)); 192 201 193 202 void AddToCalibration PROTO((Average *average, SecFilt *secfilt, Measure *measure, Measure *new, off_t *next, off_t Nstar)); … … 205 214 SkyTable *SkyTableFromTychoIndex PROTO((char *filename, int VERBOSE)); 206 215 void check_permissions PROTO((char *basefile)); 207 int dump_rawstars PROTO((Stars *stars, unsigned int Nstars));208 216 int edge_check PROTO((double *x1, double *y1, double *x2, double *y2)); 209 217 Image *fakeimage PROTO((char *rootname, off_t *Nimage, int photcode)); 210 218 211 int find_matches PROTO((SkyRegion *region, Stars *stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options)); 212 int find_matches_closest PROTO((SkyRegion *region, Stars *stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options)); 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 int find_matches PROTO((SkyRegion *region, Catalog *newcat, Catalog *catalog, AddstarClientOptions options)); 223 224 # if (0) 213 225 int find_matches_refstars PROTO((SkyRegion *region, Stars **stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options)); 214 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)); 215 229 216 230 Stars **find_subset PROTO((SkyRegion *region, Stars *stars, unsigned int Nstars, unsigned int *NSTARS)); 217 231 int gcatalog PROTO((Catalog *catalog)); 218 232 Stars *get2mass PROTO((SkyRegion *patch, int photcode, int mode, unsigned int *NSTARS)); 219 double get_subpix PROTO((double x, double y));220 233 221 234 Stars *greference PROTO((char *Refcat, SkyRegion *catstats, int photcode, unsigned int *nstars)); … … 227 240 Stars *grefstars PROTO((char *file, int photcode, unsigned int *Nstars)); 228 241 229 Stars *LoadStars PROTO((char *file, unsigned int *Nstars, Image **images, off_t *Nimages, AddstarClientOptions *options)); 242 Stars *rd_gsc PROTO((char *filename, unsigned int *nstars)); 243 244 int replace_match PROTO((Average *average, Measure *measure, Stars *star)); 245 # endif 246 247 Catalog *LoadStars PROTO((char *file, Image **images, off_t *Nimages, AddstarClientOptions *options)); 230 248 Header **LoadHeaders PROTO((FILE *f, int *mode, int *Nheader)); 231 249 HeaderSet *MatchHeaders PROTO((off_t **extsize, off_t *nimage, int mode, Header **headers, int Nheaders)); 232 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)); 250 void HeaderSetFree PROTO((HeaderSet *headerSets, off_t NheaderSets)); 251 Catalog *LoadData PROTO((FILE *f, AddstarFile *file, Image **images, off_t *nvalid, Header **headers, off_t *extsize, HeaderSet *headerSets, int NheaderSets, AddstarClientOptions *options)); 233 252 int GetZeroPointExposure PROTO((Header **headers, HeaderSet *headerSets, off_t Nimages)); 234 253 … … 240 259 double opening_angle PROTO((double x1, double y1, double x2, double y2, double x3, double y3)); 241 260 int parse_time PROTO((Header *header)); 242 Stars *rd_gsc PROTO((char *filename, unsigned int *nstars));243 int replace_match PROTO((Average *average, Measure *measure, Stars *star));244 261 int resort_catalogs PROTO((AddstarClientOptions *options, SkyTable *sky)); 245 262 int resort_catalogs_parallel PROTO((AddstarClientOptions *options, SkyList *sky)); … … 249 266 void resort_catalog_old PROTO((Catalog *catalog)); 250 267 251 Stars *ReadStarsFITS PROTO((FILE *f, Header *header, Header *in_theader, unsigned int *nstars)); 252 Stars *ReadStarsTEXT PROTO((FILE *f, unsigned int *nstars)); 253 Stars *ReadStarsSDSS PROTO((FILE *f, char *name, Header *header, Header *in_theader, Image *images, off_t *nimages, unsigned int *nstars)); 268 // Stars *ReadStarsTEXT PROTO((FILE *f, unsigned int *nstars)); 269 254 270 int ReadImageHeader PROTO((Header *header, Image *image, int photcode)); 255 Stars *FilterStars PROTO((Stars *instars, Image *image, unsigned int imageID, const AddstarClientOptions *options)); 256 Stars *MergeStars PROTO((Stars *stars, unsigned int *Nstars, Stars *instars, unsigned int Ninstars)); 257 258 int ReadXradFITS PROTO((FILE *f, Header *theader, Stars *stars, unsigned int Nstars)); 271 272 Catalog *ReadStarsFITS PROTO((FILE *f, Header *header, Header *in_theader)); 273 Catalog *FilterStars PROTO((Catalog *newcat, Image *image, unsigned int imageID, const AddstarClientOptions *options)); 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)); 259 278 260 279 double scat_subpix PROTO((double x, double y)); … … 276 295 AddstarClientOptions args_load2mass PROTO((int argc, char **argv, AddstarClientOptions options)); 277 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) 278 302 void args_server PROTO((int argc, char **argv)); 279 303 int CheckPassword PROTO((int BindSocket)); … … 288 312 int UpdateDatabase_Refcat PROTO((AddstarClientOptions *options, SkyRegion *UserPatch, char *refcat)); 289 313 SkyList *SkyListForStars PROTO((SkyTable *table, int depth, Stars *stars, unsigned int Nstars)); 290 SkyList *SkyListExistingSubset PROTO((SkyList *input, char *path));291 314 int SkyListSetPath PROTO((SkyList *list, char *path)); 292 315 int InitDataset PROTO((void)); … … 297 320 int NewRefcat_Thread PROTO((int BindSocket)); 298 321 int NewReflist_Thread PROTO((int BindSocket)); 299 300 int InitStar PROTO((Stars *star)); 322 # endif 301 323 302 324 int args_skycells (int argc, char **argv); 303 325 int ConfigInit_skycells (int *argc, char **argv); 304 int UpdateImageIDs ( Stars *stars, unsigned int Nstars, Image *images, off_t Nimages);326 int UpdateImageIDs (Catalog *catalog, Image *images, off_t Nimages); 305 327 306 328 int CheckDuplicateImageIDs (Image *images, off_t Nimages); 307 329 int ImageIndexFileInit (); 308 330 309 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); 310 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); 311 332 312 333 PhotCode *LoadMetadataPMM (char *datafile, Image *image); … … 330 351 void saveMosaicCoords (Coords *input); 331 352 332 333 Stars *ReadStarsUKIRT (FILE *f, char *name, Header *header, Image *images, off_t *nimages, unsigned int *nstars); 334 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); 355 356 AddstarFile *LoadFilenames (int *nfile, char *filename, AddstarClientOptions *options); 357 void AddstarFileFree (AddstarFile *file, int Nfile); 358 359 Catalog *addstar_catalog_init (int Nstars); 335 360 336 361 /** -
trunk/Ohana/src/addstar/src/ConfigInit.c
r38441 r38553 224 224 } 225 225 226 FreeConfigFile(); 226 227 free (config); 227 228 free (file); … … 240 241 return; 241 242 } 243 244 void FreeConfig (void) { 245 FREE (CATDIR); 246 } -
trunk/Ohana/src/addstar/src/FilterStars.c
r38467 r38553 10 10 // the imageID supplied here is the sequence **within this set** 11 11 // this value is updated based on the image table later (in UpdateImageIDs) 12 Stars *FilterStars (Stars *instars, Image *image, unsigned int imageID, const AddstarClientOptions *options) {12 Catalog *FilterStars (Catalog *newcat, Image *image, unsigned int imageID, const AddstarClientOptions *options) { 13 13 14 14 int j, N; 15 15 float MTIME, dMs, dMx; 16 Stars *stars;17 16 float RMIN, RMAX, DMIN, DMAX; 18 17 … … 26 25 27 26 /* modify resulting star list */ 28 ALLOCATE (stars, Stars, image[0].nstar); 29 for (N = j = 0; j < image[0].nstar; j++) { 30 31 if (instars[j].measure.photFlags & options->detectionFilter) continue; 27 Catalog *outcat = addstar_catalog_init (newcat->Nmeasure); 28 ALLOCATE (outcat->average, Average, newcat->Nmeasure); 29 if (newcat->lensing) { 30 ALLOCATE (outcat->lensing, Lensing, newcat->Nlensing); 31 } 32 33 for (N = j = 0; j < newcat->Nmeasure; j++) { 34 35 if (newcat->measure[j].photFlags & options->detectionFilter) continue; 32 36 33 37 /* allow for some dynamic filtering of star list */ 34 if (SNLIMIT && instars[j].measure.dM > SNLIMIT) continue; 35 if (XMAX && (instars[j].measure.Xccd > XMAX)) continue; 36 if (XMIN && (instars[j].measure.Xccd < XMIN)) continue; 37 if (YMAX && (instars[j].measure.Yccd > YMAX)) continue; 38 if (YMIN && (instars[j].measure.Yccd < YMIN)) continue; 39 if (PHOTFLAG_EXCLUDE && (instars[j].measure.photFlags & PHOTFLAG_EXCLUDE)) continue; 40 41 stars[N] = instars[j]; 42 43 XY_to_RD (&stars[N].average.R, &stars[N].average.D, stars[N].measure.Xccd, stars[N].measure.Yccd, &image[0].coords); 44 stars[N].average.R = ohana_normalize_angle (stars[N].average.R); 45 stars[N].measure.R = stars[N].average.R; 46 stars[N].measure.D = stars[N].average.D; 47 48 stars[N].measure.photcode = image[0].photcode; 38 if (SNLIMIT && newcat->measure[j].dM > SNLIMIT) continue; 39 if (XMAX && (newcat->measure[j].Xccd > XMAX)) continue; 40 if (XMIN && (newcat->measure[j].Xccd < XMIN)) continue; 41 if (YMAX && (newcat->measure[j].Yccd > YMAX)) continue; 42 if (YMIN && (newcat->measure[j].Yccd < YMIN)) continue; 43 if (PHOTFLAG_EXCLUDE && (newcat->measure[j].photFlags & PHOTFLAG_EXCLUDE)) continue; 44 45 dvo_average_init (&outcat->average[N]); 46 outcat->measure[N] = newcat->measure[j]; 47 48 if (newcat->lensing) { 49 outcat->lensing[N] = newcat->lensing[j]; 50 outcat->average[N].Nlensing = 1; 51 outcat->average[N].lensingOffset = N; 52 } 53 54 outcat->average[N].Nmeasure = 1; 55 outcat->average[N].measureOffset = N; 56 57 XY_to_RD (&outcat->average[N].R, &outcat->average[N].D, outcat->measure[N].Xccd, outcat->measure[N].Yccd, &image[0].coords); 58 outcat->average[N].R = ohana_normalize_angle (outcat->average[N].R); 59 outcat->measure[N].R = outcat->average[N].R; 60 outcat->measure[N].D = outcat->average[N].D; 61 62 outcat->measure[N].photcode = image[0].photcode; 49 63 50 64 // determine the full coverage of this set of measurements 51 RMIN = MIN (RMIN, stars[N].average.R);52 RMAX = MAX (RMAX, stars[N].average.R);53 DMIN = MIN (DMIN, stars[N].average.D);54 DMAX = MAX (DMAX, stars[N].average.D);65 RMIN = MIN (RMIN, outcat->average[N].R); 66 RMAX = MAX (RMAX, outcat->average[N].R); 67 DMIN = MIN (DMIN, outcat->average[N].D); 68 DMAX = MAX (DMAX, outcat->average[N].D); 55 69 56 70 /** additional quantities to supply to Stars based on the image data **/ 57 71 58 72 /* calculate accurate per-star airmass and azimuth */ 59 stars[N].measure.airmass = airmass (image[0].secz, stars[N].average.R, stars[N].average.D, image[0].sidtime, image[0].latitude);60 stars[N].measure.az = azimuth (15.0*image[0].sidtime - stars[N].average.R, stars[N].average.D, image[0].latitude);61 stars[N].measure.Mcal = image[0].Mcal;62 stars[N].measure.t = image[0].tzero + 1e-4*stars[N].measure.Yccd*image[0].trate; /* trate is in 0.1 msec / row */63 stars[N].measure.dt = MTIME;73 outcat->measure[N].airmass = airmass (image[0].secz, outcat->average[N].R, outcat->average[N].D, image[0].sidtime, image[0].latitude); 74 outcat->measure[N].az = azimuth (15.0*image[0].sidtime - outcat->average[N].R, outcat->average[N].D, image[0].latitude); 75 outcat->measure[N].Mcal = image[0].Mcal; 76 outcat->measure[N].t = image[0].tzero + 1e-4*outcat->measure[N].Yccd*image[0].trate; /* trate is in 0.1 msec / row */ 77 outcat->measure[N].dt = MTIME; 64 78 65 79 // watch out for any strange values: 66 if (( stars[N].measure.M > 25.0) && (stars[N].measure.M < 32.0)) {80 if ((outcat->measure[N].M > 25.0) && (outcat->measure[N].M < 32.0)) { 67 81 fprintf (stderr, "*"); 68 82 } … … 73 87 dMx = 0.0; 74 88 if (SUBPIX) { 75 dMs = get_subpix ( stars[N].measure.Xccd, stars[N].measure.Yccd);76 dMx = scat_subpix ( stars[N].measure.Xccd, stars[N].measure.Yccd);77 if (!isnan( stars[N].measure.dM)) {78 stars[N].measure.dM = hypot (stars[N].measure.dM, dMx);89 dMs = get_subpix (outcat->measure[N].Xccd, outcat->measure[N].Yccd); 90 dMx = scat_subpix (outcat->measure[N].Xccd, outcat->measure[N].Yccd); 91 if (!isnan(outcat->measure[N].dM)) { 92 outcat->measure[N].dM = hypot (outcat->measure[N].dM, dMx); 79 93 } 80 94 } 81 95 82 if (!isnan(stars[N].measure.M)) { 83 stars[N].measure.M += MTIME - dMs; 84 } 85 if (!isnan(stars[N].measure.Map)) { 86 stars[N].measure.Map += MTIME - dMs; 87 } 88 if (!isnan(stars[N].measure.Mkron)) { 89 stars[N].measure.Mkron += MTIME - dMs; 90 } 91 if (!isnan(stars[N].measure.FluxPSF)) { 92 stars[N].measure.FluxPSF /= image[0].exptime; 93 } 94 if (!isnan(stars[N].measure.dFluxPSF)) { 95 stars[N].measure.dFluxPSF /= image[0].exptime; 96 } 97 if (!isnan(stars[N].measure.FluxKron)) { 98 stars[N].measure.FluxKron /= image[0].exptime; 99 } 100 if (!isnan(stars[N].measure.dFluxKron)) { 101 stars[N].measure.dFluxKron /= image[0].exptime; 102 } 103 if (!isnan(stars[N].measure.FluxAp)) { 104 stars[N].measure.FluxAp /= image[0].exptime; 105 } 106 if (!isnan(stars[N].measure.dFluxAp)) { 107 stars[N].measure.dFluxAp /= image[0].exptime; 108 } 109 if (stars[N].lensing) { 110 if (!isnan(stars[N].lensing-> F_ApR5)) stars[N].lensing-> F_ApR5 /= image[0].exptime; 111 if (!isnan(stars[N].lensing->dF_ApR5)) stars[N].lensing->dF_ApR5 /= image[0].exptime; 112 if (!isnan(stars[N].lensing->sF_ApR5)) stars[N].lensing->sF_ApR5 /= image[0].exptime; 113 if (!isnan(stars[N].lensing->fF_ApR5)) stars[N].lensing->fF_ApR5 /= image[0].exptime; 114 115 if (!isnan(stars[N].lensing-> F_ApR6)) stars[N].lensing-> F_ApR6 /= image[0].exptime; 116 if (!isnan(stars[N].lensing->dF_ApR6)) stars[N].lensing->dF_ApR6 /= image[0].exptime; 117 if (!isnan(stars[N].lensing->sF_ApR6)) stars[N].lensing->sF_ApR6 /= image[0].exptime; 118 if (!isnan(stars[N].lensing->fF_ApR6)) stars[N].lensing->fF_ApR6 /= image[0].exptime; 119 120 if (!isnan(stars[N].lensing-> F_ApR7)) stars[N].lensing-> F_ApR7 /= image[0].exptime; 121 if (!isnan(stars[N].lensing->dF_ApR7)) stars[N].lensing->dF_ApR7 /= image[0].exptime; 122 if (!isnan(stars[N].lensing->sF_ApR7)) stars[N].lensing->sF_ApR7 /= image[0].exptime; 123 if (!isnan(stars[N].lensing->fF_ApR7)) stars[N].lensing->fF_ApR7 /= image[0].exptime; 96 if (!isnan(outcat->measure[N].M)) { 97 outcat->measure[N].M += MTIME - dMs; 98 } 99 if (!isnan(outcat->measure[N].Map)) { 100 outcat->measure[N].Map += MTIME - dMs; 101 } 102 if (!isnan(outcat->measure[N].Mkron)) { 103 outcat->measure[N].Mkron += MTIME - dMs; 104 } 105 if (!isnan(outcat->measure[N].FluxPSF)) { 106 outcat->measure[N].FluxPSF /= image[0].exptime; 107 } 108 if (!isnan(outcat->measure[N].dFluxPSF)) { 109 outcat->measure[N].dFluxPSF /= image[0].exptime; 110 } 111 if (!isnan(outcat->measure[N].FluxKron)) { 112 outcat->measure[N].FluxKron /= image[0].exptime; 113 } 114 if (!isnan(outcat->measure[N].dFluxKron)) { 115 outcat->measure[N].dFluxKron /= image[0].exptime; 116 } 117 if (!isnan(outcat->measure[N].FluxAp)) { 118 outcat->measure[N].FluxAp /= image[0].exptime; 119 } 120 if (!isnan(outcat->measure[N].dFluxAp)) { 121 outcat->measure[N].dFluxAp /= image[0].exptime; 122 } 123 if (outcat->lensing) { 124 // correct things which scale like exptime with the exptime 125 if (!isnan(outcat->lensing[N]. F_ApR5)) outcat->lensing[N]. F_ApR5 /= image[0].exptime; 126 if (!isnan(outcat->lensing[N].dF_ApR5)) outcat->lensing[N].dF_ApR5 /= image[0].exptime; 127 if (!isnan(outcat->lensing[N].sF_ApR5)) outcat->lensing[N].sF_ApR5 /= image[0].exptime; 128 if (!isnan(outcat->lensing[N]. F_ApR6)) outcat->lensing[N]. F_ApR6 /= image[0].exptime; 129 if (!isnan(outcat->lensing[N].dF_ApR6)) outcat->lensing[N].dF_ApR6 /= image[0].exptime; 130 if (!isnan(outcat->lensing[N].sF_ApR6)) outcat->lensing[N].sF_ApR6 /= image[0].exptime; 131 if (!isnan(outcat->lensing[N]. F_ApR7)) outcat->lensing[N]. F_ApR7 /= image[0].exptime; 132 if (!isnan(outcat->lensing[N].dF_ApR7)) outcat->lensing[N].dF_ApR7 /= image[0].exptime; 133 if (!isnan(outcat->lensing[N].sF_ApR7)) outcat->lensing[N].sF_ApR7 /= image[0].exptime; 124 134 } 125 135 126 136 // the external ID is supplied, but do we trust it? 127 137 if (!EXTERNAL_ID) { 128 stars[N].measure.detID = N; // sequence number within image138 outcat->measure[N].detID = N; // sequence number within image 129 139 } 130 140 … … 135 145 136 146 if (isStack) { 137 stars[N].measure.extID = CreatePSPSStackDetectionID(image[0].sourceID, image[0].externID, stars[N].measure.detID);147 outcat->measure[N].extID = CreatePSPSStackDetectionID(image[0].sourceID, image[0].externID, outcat->measure[N].detID); 138 148 } else { 139 stars[N].measure.extID = CreatePSPSDetectionID(mjd, image[0].ccdnum, stars[N].measure.detID);149 outcat->measure[N].extID = CreatePSPSDetectionID(mjd, image[0].ccdnum, outcat->measure[N].detID); 140 150 } 141 151 } else { 142 stars[N].measure.extID = 0;143 } 144 145 stars[N].measure.imageID = imageID; // this value is updated in UpdateImageIDs152 outcat->measure[N].extID = 0; 153 } 154 155 outcat->measure[N].imageID = imageID; // this value is updated in UpdateImageIDs 146 156 147 157 // add imageID to lensing entry, if it exists 148 if ( stars[N].lensing) {149 stars[N].lensing->imageID = imageID;158 if (outcat->lensing) { 159 outcat->lensing[N].imageID = imageID; 150 160 } 151 161 … … 156 166 157 167 image[0].nstar = N; 158 REALLOCATE (stars, Stars, image[0].nstar); 159 free (instars); 160 161 if (VERBOSE) fprintf (stderr, "read %d stars from target file\n", image[0].nstar); 168 169 REALLOCATE (outcat->measure, Measure, N); 170 REALLOCATE (outcat->average, Average, N); 171 if (outcat->lensing) { 172 REALLOCATE (outcat->average, Average, N); 173 } 174 dvo_catalog_free (newcat); 175 free (newcat); 176 177 outcat->Naverage = N; 178 outcat->Nmeasure = N; 179 outcat->Nlensing = outcat->lensing ? N : 0; 180 181 if (VERBOSE) fprintf (stderr, "read %d stars from target file\n", N); 162 182 if (VERBOSE) fprintf (stderr, "stars cover region %f,%f - %f,%f\n", RMIN, DMIN, RMAX, DMAX); 163 return (stars); 183 184 return (outcat); 164 185 } 165 186 187 # if (0) 166 188 Stars *MergeStars (Stars *stars, unsigned int *Nstars, Stars *instars, unsigned int Ninstars) { 167 189 … … 181 203 return (stars); 182 204 } 205 # endif -
trunk/Ohana/src/addstar/src/ImageIndex.c
r35579 r38553 1 1 # include "addstar.h" 2 3 void ImageIndexFree (ImageIndex *index) { 4 if (!index) return; 5 FREE (index->externID); 6 FREE (index->imageID); 7 FREE (index->found); 8 FREE (index); 9 } 2 10 3 11 ImageIndex *ImageIndexLoad (char *filename) { … … 16 24 if (!f) { 17 25 fprintf (stderr, "ERROR: cannot open image index file %s\n", filename); 26 FREE (index); 18 27 return NULL; 19 28 } … … 23 32 if (VERBOSE) fprintf (stderr, "can't read image index header\n"); 24 33 fclose (f); 34 FREE (index); 25 35 return NULL; 26 36 } … … 28 38 if (VERBOSE) fprintf (stderr, "can't read image index matrix\n"); 29 39 gfits_free_header (&header); 30 fclose (f);31 return NULL;32 }33 40 FREE (index); 41 fclose (f); 42 return NULL; 43 } 34 44 ftable.header = &theader; 35 45 … … 37 47 if (!gfits_load_header (f, &theader)) { 38 48 fclose (f); 49 gfits_free_header (&header); 50 FREE (index); 39 51 return NULL; 40 52 } … … 43 55 if (!gfits_fread_ftable_data (f, &ftable, FALSE)) { 44 56 fclose (f); 57 gfits_free_header (&header); 58 gfits_free_header (&theader); 59 FREE (index); 45 60 return (NULL); 46 61 } … … 76 91 } 77 92 93 gfits_free_header (&header); 94 gfits_free_matrix (&matrix); 95 gfits_free_header (&theader); 96 gfits_free_table (&ftable); 97 78 98 return index; 79 99 } … … 179 199 180 200 // extend the storage arrays 201 // no reason to extend 'found' 181 202 REALLOCATE (index->imageID, IDTYPE, index->Nimage + Nimages); 182 203 REALLOCATE (index->externID, IDTYPE, index->Nimage + Nimages); … … 192 213 // do this as an 'extend' operation 193 214 ImageIndexSave (filename, index); 215 ImageIndexFree (index); 194 216 return TRUE; 195 217 } … … 205 227 ALLOCATE (index->imageID, IDTYPE, 1); 206 228 ALLOCATE (index->externID, IDTYPE, 1); 229 ALLOCATE (index->found, char, 1); 207 230 index->Nimage = 0; 208 231 209 232 // do this as an 'extend' operation 210 233 ImageIndexSave (filename, index); 234 ImageIndexFree (index); 211 235 return TRUE; 212 236 } -
trunk/Ohana/src/addstar/src/LoadData.c
r37807 r38553 1 1 # include "addstar.h" 2 2 3 // XXX this function is somewhat specific to the elixir format output files 4 // it is capable of distinguishing several format versions defined for elixir/psphot 3 // load photometry data from psphot, sextractor, and a few other formats 4 // examine the header sets and set the Image entries for the the valid images 5 Catalog *LoadData (FILE *f, AddstarFile *file, Image **images, off_t *nvalid, Header **headers, off_t *extsize, HeaderSet *headerSets, int Nimages, AddstarClientOptions *options) { 5 6 6 // examine the header sets and set the Image entries for the the valid images7 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) {8 9 char *name;10 7 off_t Nskip, Nvalid, NVALID; 11 8 int i, j, Nhead, Ndata; 12 9 uint32_t parentID = UINT32_MAX; 13 Stars *inStars; 10 11 Catalog *catalog = NULL; 12 ALLOCATE (catalog, Catalog, 1); 13 dvo_catalog_init (catalog, TRUE); 14 ALLOCATE (catalog->average, Average, 1); 15 ALLOCATE (catalog->measure, Measure, 1); 16 ALLOCATE (catalog->lensing, Lensing, 1); 14 17 15 18 if (images[0] == NULL) { … … 22 25 REALLOCATE (images[0], Image, NVALID); 23 26 } 24 25 // find image rootname26 if (USE_NAME) {27 name = filebasename (USE_NAME);28 } else {29 name = filebasename (file);30 }31 27 32 28 // if zero points are calculated for the full exposure using more than just the matched chip header, … … 58 54 // XXX use something to set the chip name? EXTNAME? 59 55 if (!strcmp(headerSets[i].exthead, "PHU") && (Nimages == 1)) { 60 snprintf (images[0][Nvalid].name, DVO_IMAGE_NAME_LEN, "%s", name);56 snprintf (images[0][Nvalid].name, DVO_IMAGE_NAME_LEN, "%s", file->imagename); 61 57 } else { 62 snprintf (images[0][Nvalid].name, DVO_IMAGE_NAME_LEN, "%s[%s]", name, headerSets[i].exthead);58 snprintf (images[0][Nvalid].name, DVO_IMAGE_NAME_LEN, "%s[%s]", file->imagename, headerSets[i].exthead); 63 59 } 64 60 … … 84 80 fseeko (f, Nskip, SEEK_SET); 85 81 86 inStars = ReadStarsFITS (f, headers[Nhead], headers[Ndata], &images[0][Nvalid].nstar);87 if (!inStars) {88 // XXX need to free the data here or in ReadStarsFITS on error89 continue; 90 }82 // ReadStarsFITS populates catalog->measure,Nmeasure 83 Catalog *newcat = ReadStarsFITS (f, headers[Nhead], headers[Ndata]); 84 if (!newcat) continue; 85 86 images[0][Nvalid].nstar = newcat->Nmeasure; 91 87 92 88 // XRAD : if we want to read the xrad table, skip to that table here: … … 99 95 fseeko (f, Nskip, SEEK_SET); 100 96 101 if (!ReadXradFITS (f, headers[Nxrad], inStars, images[0][Nvalid].nstar)) {97 if (!ReadXradFITS (f, headers[Nxrad], newcat)) { 102 98 fprintf (stderr, "problem reading the radial flux data for %s\n", headerSets[i].extdata); 103 99 } 104 100 } 105 101 106 inStars = FilterStars (inStars, &images[0][Nvalid], Nvalid, options); 107 *stars = MergeStars (*stars, Nstars, inStars, images[0][Nvalid].nstar); 102 // replace full input catalog newcat with subset version 103 newcat = FilterStars (newcat, &images[0][Nvalid], Nvalid, options); 104 105 double Rref, Dref; 106 XY_to_RD (&Rref, &Dref, 0.0, 0.0, &images[0][Nvalid].coords); 107 SkyRegion region; 108 region.Rmin = Rref - 180.0; 109 region.Rmax = Rref + 180.0; 110 region.Dmin = Dref - 90.0; 111 region.Dmax = Dref + 90.0; 112 113 AddstarClientOptions matchOptions = *options; 114 matchOptions.radius = 0.4; // tight radius at this stage 115 matchOptions.calibrate = FALSE; 116 matchOptions.only_match = FALSE; 117 matchOptions.nosort = FALSE; 118 matchOptions.photcode = 0; // use an invalid photcode to avoid touching secfilt 119 120 find_matches_closest (®ion, newcat, catalog, matchOptions); 121 dvo_catalog_free (newcat); 122 free (newcat); 123 108 124 Nvalid++; 109 125 CHECK_REALLOCATE (images[0], Image, NVALID, Nvalid, 10); … … 111 127 112 128 if (isfinite(OFFSET_ZPT)) { 113 for (i = 0; i < *Nstars; i++) {114 stars[0][i].measure.M += OFFSET_ZPT;115 stars[0][i].measure.Map += OFFSET_ZPT;129 for (i = 0; i < catalog->Nmeasure; i++) { 130 catalog->measure[i].M += OFFSET_ZPT; 131 catalog->measure[i].Map += OFFSET_ZPT; 116 132 } 117 118 133 } 119 134 120 free (name);121 135 *nvalid = Nvalid; 122 return (TRUE);136 return catalog; 123 137 } 124 138 139 // thoughts: 140 // 1) I read the data from a single image file into a catalog structure (instead of Stars) 141 // 2) merge these into a single catalog here or in LoadData above? -
trunk/Ohana/src/addstar/src/LoadDataPMM.c
r37807 r38553 15 15 # define MAG_INDEX_ASC 22 16 16 17 int LoadDataPMM (FILE *f, char *file, 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; 20 char * name, *buffer;20 char *buffer; 21 21 int i, fd, Nbyte, Nline, code; 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; … … 38 37 } 39 38 40 // find image rootname41 name = filebasename (file);42 43 39 // there is only one PMM image per file 44 if (VERBOSE) fprintf (stderr, "reading data for %s\n", file);40 if (VERBOSE) fprintf (stderr, "reading data for %s\n", imagename); 45 41 46 42 ZeroPt = GetZeroPoint(); 47 43 48 44 // need to get the metadata from the PMM_CCD_TABLE 49 photcode = LoadMetadataPMM ( name, &images[0][Nvalid]);45 photcode = LoadMetadataPMM (imagename, &images[0][Nvalid]); 50 46 code = photcode[0].code; 51 47 ZeroPoint = 0.001*photcode[0].C; … … 61 57 62 58 NINSTARS = 10000; 63 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 } 64 65 65 66 minR0 = minR1 = 360.0; … … 85 86 dparse (&dec, 2, &buffer[i*NBYTE_ASC_TABLE]); 86 87 dparse (&mag, 3, &buffer[i*NBYTE_ASC_TABLE]); 87 88 InitStar (&inStars[Ninstars]);89 88 90 89 if (ra > 180) { … … 98 97 maxD = MAX(maxD, dec); 99 98 100 inStars[Ninstars].average.R = ra; 101 inStars[Ninstars].average.D = dec; 102 103 inStars[Ninstars].measure.M = mag - ZeroPoint + ZeroPt; 104 inStars[Ninstars].measure.t = images[0][0].tzero; 105 inStars[Ninstars].measure.dt = images[0][0].exptime; 106 inStars[Ninstars].measure.photcode = code; 107 inStars[Ninstars].measure.airmass = airmass; 108 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 ? 109 114 110 115 Ninstars++; 111 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 } 112 125 } 113 126 } 127 catalog->Nmeasure = Ninstars; 128 catalog->Naverage = Ninstars; 114 129 115 130 fprintf (stderr, "ra ranges: %f - %f, %f - %f; dec ranges: %f - %f\n", minR0, maxR0, minR1, maxR1, minD, maxD); … … 118 133 images[0][0].imageID = 0; 119 134 120 *stars = MergeStars (*stars, Nstars, inStars, Ninstars);121 122 free (inStars);123 free (name);124 135 *nvalid = Nvalid + 1; 125 136 126 137 gzclose (gz); 127 138 free (buffer); 128 return (TRUE); 139 140 return (catalog); 129 141 } 130 142 -
trunk/Ohana/src/addstar/src/LoadDataSDSS.c
r27435 r38553 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 *file, 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 char *name;10 9 int j, Nhead, Ndata; 11 unsigned int Ninstars;12 Stars *inStars;13 10 14 11 if (images[0] == NULL) { … … 21 18 REALLOCATE (images[0], Image, NVALID); 22 19 } 23 24 // find image rootname25 name = filebasename (file);26 20 27 21 // there is only one SDSS image per file (TRUE?) … … 39 33 fseeko (f, Nskip, SEEK_SET); 40 34 41 // 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); 43 *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); 44 37 45 free (name);46 38 *nvalid = Nvalid; 47 return ( TRUE);39 return (catalog); 48 40 } 49 41 -
trunk/Ohana/src/addstar/src/LoadDataUKIRT.c
r38467 r38553 3 3 // examine the header sets and set the Image entries for the the valid images 4 4 // 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 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) { 6 9 7 10 off_t Nskip, Nvalid, NVALID; 8 char *name;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 … … 21 27 REALLOCATE (images[0], Image, NVALID); 22 28 } 23 24 // find image rootname25 name = filebasename (file);26 29 27 30 // validate the number of headers sets == 4 … … 38 41 fseeko (f, Nskip, SEEK_SET); 39 42 40 inStars = ReadStarsUKIRT (f, name, headers[Nhead], images[0], &Nvalid, &Ninstars); 41 *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); 42 48 43 49 *nimages = Nvalid; 44 50 } 45 return ( TRUE);51 return (catalog); 46 52 } 47 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 } -
trunk/Ohana/src/addstar/src/LoadHeaders.c
r38467 r38553 17 17 status = gfits_fread_header (f, headers[i]); 18 18 if (!status) { 19 gfits_free_header (headers[i]); 20 FREE (headers[i]); 19 21 *Nheaders = i; 20 22 return (headers); -
trunk/Ohana/src/addstar/src/LoadStars.c
r38467 r38553 1 1 # include "addstar.h" 2 2 3 Stars *LoadStars (char *filename, unsigned int *Nstars, Image **images, off_t *Nimages, AddstarClientOptions *options) {3 Catalog *LoadStars (char *filename, Image **images, off_t *Nimages, AddstarClientOptions *options) { 4 4 5 off_t *extsize, NheaderSets; 6 int i, Nfile, NFILE, Nheaders, mode; 7 char **file, line[1024]; 8 FILE *f; 9 glob_t globList; 10 Header **headers; 11 Stars *stars; 12 HeaderSet *headerSets; 5 off_t *extsize; 6 int i, Nfile, mode; 13 7 14 if (options[0].filelist) { 15 // read the list of input files from the supplied file 16 f = fopen (filename, "r"); 17 if (f == NULL) { 18 fprintf (stderr, "can't read input list %s, giving up\n", filename); 19 exit (1); 20 } 21 22 NFILE = 10; 23 ALLOCATE (file, char *, NFILE); 24 for (i = 0; (fscanf (f, "%s", line) != EOF); i++) { 25 // filename limited to 1024 chars 26 fprintf (stderr, "file: %s\n", line); 27 file[i] = strcreate (line); 28 if (i == NFILE - 1) { 29 NFILE += 10; 30 REALLOCATE (file, char *, NFILE); 31 } 32 } 33 Nfile = i; 34 } else { 35 // parse the filename as a glob 36 globList.gl_offs = 0; 37 glob (filename, 0, NULL, &globList); 38 39 // if the glob does not match, save the literal word: 40 // otherwise save all glob matches 41 if (globList.gl_pathc == 0) { 42 Nfile = 1; 43 ALLOCATE (file, char *, Nfile); 44 file[0] = strcreate (filename); 45 } else { 46 Nfile = globList.gl_pathc; 47 ALLOCATE (file, char *, Nfile); 48 for (i = 0; i < Nfile; i++) { 49 file[i] = strcreate (globList.gl_pathv[i]); 50 } 51 } 52 } 8 AddstarFile *file = LoadFilenames (&Nfile, filename, options); 53 9 54 10 *Nimages = 0; 55 *Nstars = 0;56 11 *images = NULL; 57 stars = NULL; 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); 18 ALLOCATE (catalog->lensing, Lensing, 1); 58 19 59 20 for (i = 0; i < Nfile; i++) { 60 f = fopen (file[i], "r");21 FILE *f = fopen (file[i].filename, "r"); 61 22 if (f == NULL) { 62 fprintf (stderr, "can't read file %s, skipping\n", file[i] );23 fprintf (stderr, "can't read file %s, skipping\n", file[i].filename); 63 24 continue; 64 25 } 65 26 27 int Nheaders = 0; 28 Header **headers = NULL; 29 off_t NheaderSets = 0; 30 HeaderSet *headerSets = NULL; 31 32 off_t NimagesStart = *Nimages; 33 Catalog *newcat = NULL; 34 66 35 // load PMM data if specified (these are not stored as FITS-tables) 67 36 if (PMM_CCD_TABLE != NULL) { 68 LoadDataPMM (f, file[i], images, Nimages, &stars, Nstars);69 continue;37 newcat = LoadDataPMM (f, file[i].imagename, images, Nimages); 38 goto next_file; 70 39 } 71 40 … … 74 43 headerSets = MatchHeaders (&extsize, &NheaderSets, mode, headers, Nheaders); 75 44 if (headerSets == NULL) { 76 fprintf (stderr, "ERROR: can't read headers for %s\n", file[i] );77 continue;45 fprintf (stderr, "ERROR: can't read headers for %s\n", file[i].filename); 46 goto next_file; 78 47 } 79 48 if (NheaderSets == 0) { 80 fprintf (stderr, "no object data in file %s, skipping\n", file[i] );81 continue;49 fprintf (stderr, "no object data in file %s, skipping\n", file[i].filename); 50 goto next_file; 82 51 } 83 if (VERBOSE) fprintf (stderr, "file %s has %d headers, including "OFF_T_FMT" images\n", file[i] , Nheaders, NheaderSets);52 if (VERBOSE) fprintf (stderr, "file %s has %d headers, including "OFF_T_FMT" images\n", file[i].filename, Nheaders, NheaderSets); 84 53 85 54 /* supplied photcode is incompatible with multi-chip images */ … … 96 65 // if these are SDSS data, load with SDSS-specific wrapper 97 66 if (headerSets[0].exttype && !strcmp (headerSets[0].exttype, "SDSS_OBJ")) { 98 LoadDataSDSS (f, file[i], images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets);99 continue;67 newcat = LoadDataSDSS (f, file[i].imagename, images, Nimages, headers, extsize, headerSets, NheaderSets); 68 goto next_file; 100 69 } 101 70 102 71 // if these are SDSS data, load with SDSS-specific wrapper 103 72 if (headerSets[0].exttype && !strcmp (headerSets[0].exttype, "UKIRT_OBJ")) { 104 LoadDataUKIRT (f, file[i], images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets);105 continue;73 newcat = LoadDataUKIRT (f, file[i].imagename, images, Nimages, headers, extsize, headerSets, NheaderSets); 74 goto next_file; 106 75 } 107 76 108 LoadData (f, file[i], images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets, options);77 newcat = LoadData (f, &file[i], images, Nimages, headers, extsize, headerSets, NheaderSets, options); 109 78 110 // XXX add a function to (optionally) load the extended source measurements 111 # if (0) 112 if (extSources) { 113 // not sure how to link the measurements here to the psf measurements above (though there is an ID in the det list) 114 LoadDataXSRC (f, file[i], images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets); 79 next_file: 80 81 // if we added data from an image, then we can merge it in 82 if (*Nimages > NimagesStart) { 83 double Rref, Dref; 84 XY_to_RD (&Rref, &Dref, 0.0, 0.0, &images[0][*Nimages-1].coords); 85 SkyRegion region; 86 region.Rmin = Rref - 180.0; 87 region.Rmax = Rref + 180.0; 88 region.Dmin = Dref - 90.0; 89 region.Dmax = Dref + 90.0; 90 91 AddstarClientOptions matchOptions = *options; 92 matchOptions.radius = 0.4; // tight radius at this stage 93 matchOptions.calibrate = FALSE; 94 matchOptions.only_match = FALSE; 95 matchOptions.nosort = FALSE; 96 matchOptions.photcode = 0; // use an invalid photcode to avoid touching secfilt 97 98 find_matches_closest (®ion, newcat, catalog, matchOptions); 115 99 } 116 if (extFits) { 117 LoadDataXFIT (f, file[i], images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets); 100 101 if (newcat) { 102 dvo_catalog_free (newcat); 103 free (newcat); 118 104 } 119 # endif120 105 106 HeaderSetFree (headerSets, NheaderSets); 107 int j; 108 for (j = 0; j < Nheaders; j++) { 109 gfits_free_header (headers[j]); 110 FREE (headers[j]); 111 } 112 FREE (headers); 113 FREE (extsize); 121 114 } 122 115 … … 129 122 } 130 123 131 return stars; 124 AddstarFileFree (file, Nfile); 125 return catalog; 132 126 } 133 127 -
trunk/Ohana/src/addstar/src/MatchHeaders.c
r38467 r38553 2 2 3 3 // XXX largely psphot specific 4 5 void HeaderSetFree (HeaderSet *headerSets, off_t NheaderSets) { 6 int i; 7 8 if (!headerSets) return; 9 for (i = 0; i < NheaderSets; i++) { 10 FREE (headerSets[i].exthead); 11 FREE (headerSets[i].exttype); 12 FREE (headerSets[i].extdata); 13 FREE (headerSets[i].extxrad); 14 } 15 FREE (headerSets); 16 } 4 17 5 18 HeaderSet *MatchHeaders (off_t **extsize, off_t *nimage, int mode, Header **headers, int Nheaders) { … … 22 35 headerSets[Nimage].exthead = strcreate ("PHU"); 23 36 headerSets[Nimage].extdata = strcreate ("NONE"); 37 headerSets[Nimage].exttype = NULL; 38 headerSets[Nimage].extxrad = NULL; 24 39 headerSets[Nimage].extnum_data = -1; 25 40 headerSets[Nimage].extnum_head = 0; … … 34 49 headerSets[0].exttype = strcreate ("SDSS_OBJ"); 35 50 headerSets[0].exthead = strcreate ("PHU"); 51 headerSets[0].extxrad = NULL; 36 52 headerSets[0].extnum_head = 0; 37 53 headerSets[0].extnum_data = 1; … … 112 128 113 129 keep: 114 headerSets[Nimage].exttype = strcreate (exttype);115 116 130 gfits_scan (headers[i], ExtnameKeyword, "%s", 1, extname); 117 131 gfits_scan (headers[i], "EXTHEAD", "%s", 1, exthead); 118 132 133 headerSets[Nimage].exttype = strcreate (exttype); 119 134 headerSets[Nimage].extdata = strcreate (extname); 120 135 headerSets[Nimage].exthead = strcreate (exthead); … … 171 186 headerSets[Nimage].exttype = strcreate ("SMPDATA"); 172 187 headerSets[Nimage].exthead = strcreate ("PHU"); 188 headerSets[Nimage].extxrad = NULL; 173 189 headerSets[Nimage].extnum_head = 0; 174 190 headerSets[Nimage].extnum_data = 1; -
trunk/Ohana/src/addstar/src/ReadStarsFITS.c
r38441 r38553 4 4 // (excluding SDSS data and reference database info, such as 2MASS) 5 5 // NOTE: these must also be listed in MatchHeaders.c (line ~ 62) 6 Stars *Convert_SMPDATA PROTO((FTable *table, unsigned int *nstars)); 7 Stars *Convert_PS1_DEV_0 PROTO((FTable *table, unsigned int *nstars)); 8 Stars *Convert_PS1_DEV_1 PROTO((FTable *table, unsigned int *nstars)); 9 Stars *Convert_PS1_V1 PROTO((FTable *table, unsigned int *nstars)); 10 Stars *Convert_PS1_V1_Alt PROTO((FTable *table, unsigned int *nstars)); 11 Stars *Convert_PS1_V2 PROTO((FTable *table, unsigned int *nstars)); 12 Stars *Convert_PS1_V3 PROTO((FTable *table, unsigned int *nstars)); 13 Stars *Convert_PS1_V4 PROTO((FTable *table, unsigned int *nstars)); 14 Stars *Convert_PS1_V5 PROTO((FTable *table, unsigned int *nstars)); 15 Stars *Convert_PS1_V5_R0_Lensing PROTO((FTable *table, unsigned int *nstars)); 16 Stars *Convert_PS1_V5_R1_Lensing PROTO((FTable *table, unsigned int *nstars)); 17 Stars *Convert_PS1_V5_R2_Lensing PROTO((FTable *table, unsigned int *nstars)); 18 Stars *Convert_PS1_SV1 PROTO((FTable *table, unsigned int *nstars)); 19 Stars *Convert_PS1_SV1_Alt PROTO((FTable *table, unsigned int *nstars)); 20 Stars *Convert_PS1_SV2 PROTO((FTable *table, unsigned int *nstars)); 21 Stars *Convert_PS1_SV3 PROTO((FTable *table, unsigned int *nstars)); 22 Stars *Convert_PS1_SV4 PROTO((FTable *table, unsigned int *nstars)); 23 Stars *Convert_PS1_DV3 PROTO((FTable *table, unsigned int *nstars)); 24 Stars *Convert_PS1_DV4 PROTO((FTable *table, unsigned int *nstars)); 25 Stars *Convert_PS1_DV5 PROTO((FTable *table, unsigned int *nstars)); 6 Catalog *Convert_SMPDATA PROTO((FTable *table)); 7 Catalog *Convert_PS1_DEV_0 PROTO((FTable *table)); 8 Catalog *Convert_PS1_DEV_1 PROTO((FTable *table)); 9 Catalog *Convert_PS1_V1 PROTO((FTable *table)); 10 Catalog *Convert_PS1_V1_Alt PROTO((FTable *table)); 11 Catalog *Convert_PS1_V2 PROTO((FTable *table)); 12 Catalog *Convert_PS1_V3 PROTO((FTable *table)); 13 Catalog *Convert_PS1_V4 PROTO((FTable *table)); 14 Catalog *Convert_PS1_V5 PROTO((FTable *table)); 15 Catalog *Convert_PS1_V5_R0_Lensing PROTO((FTable *table)); 16 Catalog *Convert_PS1_V5_R1_Lensing PROTO((FTable *table)); 17 Catalog *Convert_PS1_V5_R2_Lensing PROTO((FTable *table)); 18 Catalog *Convert_PS1_SV1 PROTO((FTable *table)); 19 Catalog *Convert_PS1_SV1_Alt PROTO((FTable *table)); 20 Catalog *Convert_PS1_SV2 PROTO((FTable *table)); 21 Catalog *Convert_PS1_SV3 PROTO((FTable *table)); 22 Catalog *Convert_PS1_SV4 PROTO((FTable *table)); 23 Catalog *Convert_PS1_DV3 PROTO((FTable *table)); 24 Catalog *Convert_PS1_DV4 PROTO((FTable *table)); 25 Catalog *Convert_PS1_DV5 PROTO((FTable *table)); 26 27 Catalog *addstar_catalog_init (int Nstars) { 28 Catalog *catalog = NULL; 29 ALLOCATE (catalog, Catalog, 1); 30 dvo_catalog_init (catalog, TRUE); 31 32 ALLOCATE (catalog->measure, Measure, Nstars); 33 34 int i; 35 for (i = 0; i < Nstars; i++) { 36 dvo_measure_init (&catalog->measure[i]); 37 } 38 catalog->Nmeasure = Nstars; 39 return catalog; 40 } 26 41 27 42 // given a file with the pointer at the start of the table block and the 28 43 // corresponding image header, load the stars from the table 29 Stars *ReadStarsFITS (FILE *f, Header *header, Header *in_theader, unsigned int *nstars) {44 Catalog *ReadStarsFITS (FILE *f, Header *header, Header *in_theader) { 30 45 31 46 off_t Nskip; 32 unsigned int Nstars;33 47 char type[80]; 34 48 Header theader; 35 49 FTable table; 36 Stars *stars; // Stars contains Average and Measure37 50 38 51 if (in_theader == NULL) { … … 55 68 } 56 69 57 stars= NULL;70 Catalog *catalog = NULL; 58 71 if (!strcmp (type, "SMPDATA")) { 59 stars = Convert_SMPDATA (&table, &Nstars);72 catalog = Convert_SMPDATA (&table); 60 73 } 61 74 if (!strcmp (type, "PS1_DEV_0")) { 62 stars = Convert_PS1_DEV_0 (&table, &Nstars);75 catalog = Convert_PS1_DEV_0 (&table); 63 76 } 64 77 if (!strcmp (type, "PS1_DEV_1")) { 65 stars = Convert_PS1_DEV_1 (&table, &Nstars);78 catalog = Convert_PS1_DEV_1 (&table); 66 79 } 67 80 if (!strcmp (type, "PS1_V1")) { 68 stars = Convert_PS1_V1 (&table, &Nstars);81 catalog = Convert_PS1_V1 (&table); 69 82 } 70 83 if (!strcmp (type, "PS1_V2")) { … … 73 86 return (NULL); 74 87 } 75 stars = Convert_PS1_V2 (&table, &Nstars);88 catalog = Convert_PS1_V2 (&table); 76 89 } 77 90 if (!strcmp (type, "PS1_V3")) { 78 stars = Convert_PS1_V3 (&table, &Nstars);91 catalog = Convert_PS1_V3 (&table); 79 92 } 80 93 if (!strcmp (type, "PS1_V4")) { 81 stars = Convert_PS1_V4 (&table, &Nstars);94 catalog = Convert_PS1_V4 (&table); 82 95 } 83 96 if (!strcmp (type, "PS1_V5")) { 84 97 switch (table.header[0].Naxis[0]) { 85 98 case 232: 86 stars = Convert_PS1_V5 (&table, &Nstars);87 break;99 catalog = Convert_PS1_V5 (&table); 100 break; 88 101 case 312: 89 stars = Convert_PS1_V5_R0_Lensing (&table, &Nstars);90 break;102 catalog = Convert_PS1_V5_R0_Lensing (&table); 103 break; 91 104 case 320: 92 stars = Convert_PS1_V5_R1_Lensing (&table, &Nstars);93 break;105 catalog = Convert_PS1_V5_R1_Lensing (&table); 106 break; 94 107 case 328: 95 stars = Convert_PS1_V5_R2_Lensing (&table, &Nstars);96 break;108 catalog = Convert_PS1_V5_R2_Lensing (&table); 109 break; 97 110 default: 98 fprintf (stderr, "invalid PS1_V5 table size %d\n", (int) table.header[0].Naxis[0]);99 return NULL;111 fprintf (stderr, "invalid PS1_V5 table size %d\n", (int) table.header[0].Naxis[0]); 112 return NULL; 100 113 } 101 114 } 102 115 if (!strcmp (type, "PS1_SV1")) { 103 stars = Convert_PS1_SV1 (&table, &Nstars);116 catalog = Convert_PS1_SV1 (&table); 104 117 } 105 118 if (!strcmp (type, "PS1_SV2")) { 106 stars = Convert_PS1_SV2 (&table, &Nstars);119 catalog = Convert_PS1_SV2 (&table); 107 120 } 108 121 if (!strcmp (type, "PS1_SV3")) { 109 stars = Convert_PS1_SV3 (&table, &Nstars);122 catalog = Convert_PS1_SV3 (&table); 110 123 } 111 124 if (!strcmp (type, "PS1_SV4")) { 112 stars = Convert_PS1_SV4 (&table, &Nstars);125 catalog = Convert_PS1_SV4 (&table); 113 126 } 114 127 if (!strcmp (type, "PS1_DV3")) { 115 stars = Convert_PS1_DV3 (&table, &Nstars);128 catalog = Convert_PS1_DV3 (&table); 116 129 } 117 130 if (!strcmp (type, "PS1_DV4")) { 118 stars = Convert_PS1_DV4 (&table, &Nstars);131 catalog = Convert_PS1_DV4 (&table); 119 132 } 120 133 if (!strcmp (type, "PS1_DV5")) { 121 stars = Convert_PS1_DV5 (&table, &Nstars);122 } 123 if ( stars== NULL) {134 catalog = Convert_PS1_DV5 (&table); 135 } 136 if (catalog == NULL) { 124 137 fprintf (stderr, "invalid table type %s\n", type); 125 138 return (NULL); 126 139 } 127 // Nstars is not necessarily == *nstars (The former is the number of detections, the 128 // latter are the 'good' detections reported by the photometry system. 129 *nstars = Nstars; 130 131 return stars; 140 141 gfits_free_table (&table); 142 return catalog; 132 143 } 133 144 … … 149 160 } 150 161 151 Stars *Convert_SMPDATA (FTable *table, unsigned int *nstars) {162 Catalog *Convert_SMPDATA (FTable *table) { 152 163 153 164 off_t Nstars; 154 165 unsigned int i; 155 166 double ZeroPt; 156 Stars *stars = NULL;157 167 SMPData *smpdata = NULL; 158 168 … … 164 174 ZeroPt = GetZeroPoint(); 165 175 166 ALLOCATE (stars, Stars, Nstars); 167 for (i = 0; i < Nstars; i++) { 168 InitStar (&stars[i]); 169 170 stars[i].measure.Xccd = smpdata[i].X; 171 stars[i].measure.Yccd = smpdata[i].Y; 172 stars[i].measure.dXccd = NAN_S_SHORT; // not provided by SMPDATA: 173 stars[i].measure.dYccd = NAN_S_SHORT; // not provided by SMPDATA: 176 Catalog *catalog = addstar_catalog_init (Nstars); 177 178 for (i = 0; i < Nstars; i++) { 179 catalog->measure[i].Xccd = smpdata[i].X; 180 catalog->measure[i].Yccd = smpdata[i].Y; 181 catalog->measure[i].dXccd = NAN_S_SHORT; // not provided by SMPDATA: 182 catalog->measure[i].dYccd = NAN_S_SHORT; // not provided by SMPDATA: 174 183 175 stars[i].measure.posangle= NAN_S_SHORT; // not provided by SMPDATA:176 stars[i].measure.pltscale= NAN; // not provided by SMPDATA:184 catalog->measure[i].posangle = NAN_S_SHORT; // not provided by SMPDATA: 185 catalog->measure[i].pltscale = NAN; // not provided by SMPDATA: 177 186 178 187 if ((smpdata[i].M >= ZeroPt) || isnan(smpdata[i].M)) { 179 stars[i].measure.M = NAN;180 stars[i].measure.Map = NAN;181 stars[i].measure.FluxPSF = NAN;182 stars[i].measure.dFluxPSF = NAN;183 } else { 184 stars[i].measure.M = smpdata[i].M;185 stars[i].measure.Map = smpdata[i].M;186 stars[i].measure.FluxPSF = pow(10.0, -0.4*smpdata[i].M);187 stars[i].measure.dFluxPSF = stars[i].measure.FluxPSF * smpdata[i].dM;188 } 189 stars[i].measure.dM = smpdata[i].dM*0.001;190 stars[i].measure.dMcal= NAN; // not provided by SMPDATA:191 192 stars[i].measure.Mkron= NAN; // not provided by SMPDATA:193 stars[i].measure.dMkron= NAN; // not provided by SMPDATA:194 stars[i].measure.FluxKron = NAN; // not provided by SMPDATA:195 stars[i].measure.dFluxKron = NAN; // not provided by SMPDATA:196 197 stars[i].measure.Sky= NAN; // not provided by SMPDATA:198 stars[i].measure.dSky= NAN; // not provided by SMPDATA:199 200 stars[i].measure.psfChisq = NAN;// not provided by SMPDATA:201 stars[i].measure.psfQF = NAN;// not provided by SMPDATA:202 stars[i].measure.psfNdof = NAN_S_INT; // not provided by SMPDATA:203 stars[i].measure.psfNpix = NAN_S_INT; // not provided by SMPDATA:204 stars[i].measure.extNsigma = NAN;// not provided by SMPDATA:205 206 stars[i].measure.FWx = ToShortPixels (smpdata[i].fx);207 stars[i].measure.FWy = ToShortPixels (smpdata[i].fy);208 stars[i].measure.theta = ToShortDegrees (smpdata[i].df);209 210 stars[i].measure.Mxx = NAN_S_SHORT; // not provided by SMPDATA:211 stars[i].measure.Mxy = NAN_S_SHORT; // not provided by SMPDATA:212 stars[i].measure.Myy = NAN_S_SHORT; // not provided by SMPDATA:188 catalog->measure[i].M = NAN; 189 catalog->measure[i].Map = NAN; 190 catalog->measure[i].FluxPSF = NAN; 191 catalog->measure[i].dFluxPSF = NAN; 192 } else { 193 catalog->measure[i].M = smpdata[i].M; 194 catalog->measure[i].Map = smpdata[i].M; 195 catalog->measure[i].FluxPSF = pow(10.0, -0.4*smpdata[i].M); 196 catalog->measure[i].dFluxPSF = catalog->measure[i].FluxPSF * smpdata[i].dM; 197 } 198 catalog->measure[i].dM = smpdata[i].dM*0.001; 199 catalog->measure[i].dMcal = NAN; // not provided by SMPDATA: 200 201 catalog->measure[i].Mkron = NAN; // not provided by SMPDATA: 202 catalog->measure[i].dMkron = NAN; // not provided by SMPDATA: 203 catalog->measure[i].FluxKron = NAN; // not provided by SMPDATA: 204 catalog->measure[i].dFluxKron = NAN; // not provided by SMPDATA: 205 206 catalog->measure[i].Sky = NAN; // not provided by SMPDATA: 207 catalog->measure[i].dSky = NAN; // not provided by SMPDATA: 208 209 catalog->measure[i].psfChisq = NAN; // not provided by SMPDATA: 210 catalog->measure[i].psfQF = NAN; // not provided by SMPDATA: 211 catalog->measure[i].psfNdof = NAN_S_INT; // not provided by SMPDATA: 212 catalog->measure[i].psfNpix = NAN_S_INT; // not provided by SMPDATA: 213 catalog->measure[i].extNsigma = NAN; // not provided by SMPDATA: 214 215 catalog->measure[i].FWx = ToShortPixels (smpdata[i].fx); 216 catalog->measure[i].FWy = ToShortPixels (smpdata[i].fy); 217 catalog->measure[i].theta = ToShortDegrees (smpdata[i].df); 218 219 catalog->measure[i].Mxx = NAN_S_SHORT; // not provided by SMPDATA: 220 catalog->measure[i].Mxy = NAN_S_SHORT; // not provided by SMPDATA: 221 catalog->measure[i].Myy = NAN_S_SHORT; // not provided by SMPDATA: 213 222 214 223 // the dophot type information gets pushed into the upper 2 bytes of photFlags 215 stars[i].measure.photFlags = (smpdata[i].dophot << 16); 216 } 217 *nstars = Nstars; 218 return (stars); 219 } 220 221 Stars *Convert_PS1_DEV_0 (FTable *table, unsigned int *nstars) { 224 catalog->measure[i].photFlags = (smpdata[i].dophot << 16); 225 } 226 return catalog; 227 } 228 229 Catalog *Convert_PS1_DEV_0 (FTable *table) { 222 230 223 231 off_t Nstars; 224 232 unsigned int i; 225 233 double ZeroPt; 226 Stars *stars;227 234 PS1_DEV_0 *ps1data; 228 235 … … 234 241 ZeroPt = GetZeroPoint(); 235 242 236 ALLOCATE (stars, Stars,Nstars);237 for (i = 0; i < Nstars; i++) { 238 InitStar (&stars[i]);239 stars[i].measure.Xccd= ps1data[i].X;240 stars[i].measure.Yccd= ps1data[i].Y;241 stars[i].measure.dXccd= ToShortPixels(ps1data[i].dX);242 stars[i].measure.dYccd= ToShortPixels(ps1data[i].dY);243 Catalog *catalog = addstar_catalog_init (Nstars); 244 245 for (i = 0; i < Nstars; i++) { 246 catalog->measure[i].Xccd = ps1data[i].X; 247 catalog->measure[i].Yccd = ps1data[i].Y; 248 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 249 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 243 250 244 stars[i].measure.posangle= NAN_S_SHORT; // not provided by PS1_DEV_0:245 stars[i].measure.pltscale= NAN; // not provided by PS1_DEV_0:251 catalog->measure[i].posangle = NAN_S_SHORT; // not provided by PS1_DEV_0: 252 catalog->measure[i].pltscale = NAN; // not provided by PS1_DEV_0: 246 253 247 254 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 248 stars[i].measure.M = NAN; 249 stars[i].measure.FluxPSF = NAN; 250 stars[i].measure.dFluxPSF = NAN; 251 } else { 252 stars[i].measure.M = ps1data[i].M + ZeroPt; 253 stars[i].measure.FluxPSF = pow(10.0, -0.4*ps1data[i].M); 254 stars[i].measure.dFluxPSF = stars[i].measure.FluxPSF * ps1data[i].dM; 255 } 256 stars[i].measure.dM = ps1data[i].dM; 257 stars[i].measure.dMcal = NAN; // not provided by PS1_DEV_0: 258 stars[i].measure.Map = NAN; // not provided by PS1_DEV_0: 259 260 stars[i].measure.Mkron = NAN; // not provided by PS1_DEV_0: 261 stars[i].measure.dMkron = NAN; // not provided by PS1_DEV_0: 262 stars[i].measure.FluxKron = NAN; // not provided by PS1_DEV_0: 263 stars[i].measure.dFluxKron = NAN; // not provided by PS1_DEV_0: 264 265 stars[i].measure.Sky = ps1data[i].sky; 266 stars[i].measure.dSky = ps1data[i].dSky; 267 268 stars[i].measure.psfChisq = ps1data[i].psfChisq; 269 stars[i].measure.psfQF = ps1data[i].psfQF; 270 stars[i].measure.psfNdof = NAN_S_INT; // not provided by PS1_DEV_0: 271 stars[i].measure.psfNpix = NAN_S_INT; // not provided by PS1_DEV_0: 272 stars[i].measure.extNsigma = NAN; // not provided by PS1_DEV_0: 273 274 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx); 275 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy); 276 stars[i].measure.theta = ToShortDegrees(ps1data[i].df); 277 278 stars[i].measure.Mxx = NAN_S_SHORT; // not provided by PS1_DEV_0: 279 stars[i].measure.Mxy = NAN_S_SHORT; // not provided by PS1_DEV_0: 280 stars[i].measure.Myy = NAN_S_SHORT; // not provided by PS1_DEV_0: 281 282 stars[i].measure.photFlags = 0; // not provided by PS1_DEV_0: 283 284 stars[i].measure.detID = ps1data[i].detID; 285 } 286 *nstars = Nstars; 287 return (stars); 255 catalog->measure[i].M = NAN; 256 catalog->measure[i].FluxPSF = NAN; 257 catalog->measure[i].dFluxPSF = NAN; 258 } else { 259 catalog->measure[i].M = ps1data[i].M + ZeroPt; 260 catalog->measure[i].FluxPSF = pow(10.0, -0.4*ps1data[i].M); 261 catalog->measure[i].dFluxPSF = catalog->measure[i].FluxPSF * ps1data[i].dM; 262 } 263 catalog->measure[i].dM = ps1data[i].dM; 264 catalog->measure[i].dMcal = NAN; // not provided by PS1_DEV_0: 265 catalog->measure[i].Map = NAN; // not provided by PS1_DEV_0: 266 267 catalog->measure[i].Mkron = NAN; // not provided by PS1_DEV_0: 268 catalog->measure[i].dMkron = NAN; // not provided by PS1_DEV_0: 269 catalog->measure[i].FluxKron = NAN; // not provided by PS1_DEV_0: 270 catalog->measure[i].dFluxKron = NAN; // not provided by PS1_DEV_0: 271 272 catalog->measure[i].Sky = ps1data[i].sky; 273 catalog->measure[i].dSky = ps1data[i].dSky; 274 275 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 276 catalog->measure[i].psfQF = ps1data[i].psfQF; 277 catalog->measure[i].psfNdof = NAN_S_INT; // not provided by PS1_DEV_0: 278 catalog->measure[i].psfNpix = NAN_S_INT; // not provided by PS1_DEV_0: 279 catalog->measure[i].extNsigma = NAN; // not provided by PS1_DEV_0: 280 281 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 282 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 283 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 284 285 catalog->measure[i].Mxx = NAN_S_SHORT; // not provided by PS1_DEV_0: 286 catalog->measure[i].Mxy = NAN_S_SHORT; // not provided by PS1_DEV_0: 287 catalog->measure[i].Myy = NAN_S_SHORT; // not provided by PS1_DEV_0: 288 289 catalog->measure[i].photFlags = 0; // not provided by PS1_DEV_0: 290 291 catalog->measure[i].detID = ps1data[i].detID; 292 } 293 return catalog; 288 294 } 289 295 290 296 // XXX I need to make the IPP I/O functions and these functions 291 297 // consistent wrt ZERO_POINT.... 292 Stars *Convert_PS1_DEV_1 (FTable *table, unsigned int *nstars) {298 Catalog *Convert_PS1_DEV_1 (FTable *table) { 293 299 294 300 off_t Nstars; 295 301 unsigned int i; 296 302 double ZeroPt; 297 Stars *stars;298 303 PS1_DEV_1 *ps1data; 299 304 … … 305 310 ZeroPt = GetZeroPoint(); 306 311 307 ALLOCATE (stars, Stars,Nstars);308 for (i = 0; i < Nstars; i++) { 309 InitStar (&stars[i]);310 stars[i].measure.Xccd = ps1data[i].X;311 stars[i].measure.Yccd = ps1data[i].Y;312 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX);313 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY);314 315 stars[i].measure.posangle = NAN_S_SHORT; // not provided by PS1_DEV_1:316 stars[i].measure.pltscale = NAN; // not provided by PS1_DEV_1:312 Catalog *catalog = addstar_catalog_init (Nstars); 313 314 for (i = 0; i < Nstars; i++) { 315 catalog->measure[i].Xccd = ps1data[i].X; 316 catalog->measure[i].Yccd = ps1data[i].Y; 317 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 318 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 319 320 catalog->measure[i].posangle = NAN_S_SHORT; // not provided by PS1_DEV_1: 321 catalog->measure[i].pltscale = NAN; // not provided by PS1_DEV_1: 317 322 318 323 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 319 stars[i].measure.M = NAN; 320 stars[i].measure.FluxPSF = NAN; 321 stars[i].measure.dFluxPSF = NAN; 322 } else { 323 stars[i].measure.M = ps1data[i].M + ZeroPt; 324 stars[i].measure.FluxPSF = pow(10.0, -0.4*ps1data[i].M); 325 stars[i].measure.dFluxPSF = stars[i].measure.FluxPSF * ps1data[i].dM; 326 } 327 stars[i].measure.dM = ps1data[i].dM; 328 stars[i].measure.dMcal = NAN; // not provided by PS1_DEV_1: 329 stars[i].measure.Map = NAN; // not provided by PS1_DEV_1: 330 331 stars[i].measure.Mkron = NAN; // not provided by PS1_DEV_1: 332 stars[i].measure.dMkron = NAN; // not provided by PS1_DEV_1: 333 stars[i].measure.FluxKron = NAN; // not provided by PS1_DEV_1: 334 stars[i].measure.dFluxKron = NAN; // not provided by PS1_DEV_1: 335 336 stars[i].measure.Sky = ps1data[i].sky; 337 stars[i].measure.dSky = ps1data[i].dSky; 338 339 stars[i].measure.psfChisq = ps1data[i].psfChisq; 340 stars[i].measure.psfQF = ps1data[i].psfQF; 341 stars[i].measure.psfNdof = NAN_S_INT; // not provided by PS1_DEV_1: 342 stars[i].measure.psfNpix = NAN_S_INT; // not provided by PS1_DEV_1: 343 stars[i].measure.extNsigma = ps1data[i].extNsigma; 344 345 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx); 346 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy); 347 stars[i].measure.theta = ToShortDegrees(ps1data[i].df); 348 349 stars[i].measure.Mxx = NAN_S_SHORT; // not provided by PS1_DEV_1: 350 stars[i].measure.Mxy = NAN_S_SHORT; // not provided by PS1_DEV_1: 351 stars[i].measure.Myy = NAN_S_SHORT; // not provided by PS1_DEV_1: 352 353 stars[i].measure.photFlags = ps1data[i].flags; 354 355 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 356 stars[i].measure.detID = ps1data[i].detID; 357 } 358 *nstars = Nstars; 359 return (stars); 360 } 361 362 Stars *Convert_PS1_V1 (FTable *table, unsigned int *nstars) { 324 catalog->measure[i].M = NAN; 325 catalog->measure[i].FluxPSF = NAN; 326 catalog->measure[i].dFluxPSF = NAN; 327 } else { 328 catalog->measure[i].M = ps1data[i].M + ZeroPt; 329 catalog->measure[i].FluxPSF = pow(10.0, -0.4*ps1data[i].M); 330 catalog->measure[i].dFluxPSF = catalog->measure[i].FluxPSF * ps1data[i].dM; 331 } 332 catalog->measure[i].dM = ps1data[i].dM; 333 catalog->measure[i].dMcal = NAN; // not provided by PS1_DEV_1: 334 catalog->measure[i].Map = NAN; // not provided by PS1_DEV_1: 335 336 catalog->measure[i].Mkron = NAN; // not provided by PS1_DEV_1: 337 catalog->measure[i].dMkron = NAN; // not provided by PS1_DEV_1: 338 catalog->measure[i].FluxKron = NAN; // not provided by PS1_DEV_1: 339 catalog->measure[i].dFluxKron = NAN; // not provided by PS1_DEV_1: 340 341 catalog->measure[i].Sky = ps1data[i].sky; 342 catalog->measure[i].dSky = ps1data[i].dSky; 343 344 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 345 catalog->measure[i].psfQF = ps1data[i].psfQF; 346 catalog->measure[i].psfNdof = NAN_S_INT; // not provided by PS1_DEV_1: 347 catalog->measure[i].psfNpix = NAN_S_INT; // not provided by PS1_DEV_1: 348 catalog->measure[i].extNsigma = ps1data[i].extNsigma; 349 350 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 351 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 352 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 353 354 catalog->measure[i].Mxx = NAN_S_SHORT; // not provided by PS1_DEV_1: 355 catalog->measure[i].Mxy = NAN_S_SHORT; // not provided by PS1_DEV_1: 356 catalog->measure[i].Myy = NAN_S_SHORT; // not provided by PS1_DEV_1: 357 358 catalog->measure[i].photFlags = ps1data[i].flags; 359 360 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 361 catalog->measure[i].detID = ps1data[i].detID; 362 } 363 return catalog; 364 } 365 366 Catalog *Convert_PS1_V1 (FTable *table) { 363 367 364 368 off_t Nstars; 365 369 unsigned int i; 366 370 double ZeroPt; 367 Stars *stars;368 371 CMF_PS1_V1 *ps1data; 369 372 … … 377 380 378 381 if (table[0].header[0].Naxis[0] == 136) { 379 stars = Convert_PS1_V1_Alt (table, nstars);380 return (stars);382 Catalog *catalog = Convert_PS1_V1_Alt (table); 383 return catalog; 381 384 } 382 385 … … 388 391 ZeroPt = GetZeroPoint(); 389 392 390 ALLOCATE (stars, Stars,Nstars);391 for (i = 0; i < Nstars; i++) { 392 InitStar (&stars[i]);393 stars[i].measure.Xccd = ps1data[i].X;394 stars[i].measure.Yccd = ps1data[i].Y;395 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX);396 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY);397 398 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle);399 stars[i].measure.pltscale = ps1data[i].pltscale;393 Catalog *catalog = addstar_catalog_init (Nstars); 394 395 for (i = 0; i < Nstars; i++) { 396 catalog->measure[i].Xccd = ps1data[i].X; 397 catalog->measure[i].Yccd = ps1data[i].Y; 398 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 399 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 400 401 catalog->measure[i].posangle = ToShortDegrees(ps1data[i].posangle); 402 catalog->measure[i].pltscale = ps1data[i].pltscale; 400 403 401 404 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 402 stars[i].measure.M = NAN;403 stars[i].measure.FluxPSF = NAN;404 stars[i].measure.dFluxPSF = NAN;405 } else { 406 stars[i].measure.M = ps1data[i].M + ZeroPt;407 stars[i].measure.FluxPSF = pow(10.0, -0.4*ps1data[i].M);408 stars[i].measure.dFluxPSF = stars[i].measure.FluxPSF * ps1data[i].dM;409 } 410 stars[i].measure.dM = ps1data[i].dM;411 stars[i].measure.dMcal = ps1data[i].dMcal;412 stars[i].measure.Map = ps1data[i].Map + ZeroPt;413 stars[i].measure.dMap = ps1data[i].dM; // a proxy measure414 415 stars[i].measure.Mkron = NAN; // not provided by PS1_V1:416 stars[i].measure.dMkron = NAN; // not provided by PS1_V1:417 stars[i].measure.FluxKron = NAN; // not provided by PS1_V1:418 stars[i].measure.dFluxKron = NAN; // not provided by PS1_V1:419 420 stars[i].measure.Sky = ps1data[i].sky;421 stars[i].measure.dSky = ps1data[i].dSky;422 423 stars[i].measure.psfChisq = ps1data[i].psfChisq;424 stars[i].measure.psfQF = ps1data[i].psfQF;425 stars[i].measure.psfNdof = ps1data[i].psfNdof;426 stars[i].measure.psfNpix = ps1data[i].psfNpix;427 stars[i].measure.extNsigma = ps1data[i].extNsigma;428 429 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx);430 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy);431 stars[i].measure.theta = ToShortDegrees(ps1data[i].df);432 433 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx);434 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy);435 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy);436 437 stars[i].measure.photFlags = ps1data[i].flags;438 439 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 440 stars[i].measure.detID = ps1data[i].detID;405 catalog->measure[i].M = NAN; 406 catalog->measure[i].FluxPSF = NAN; 407 catalog->measure[i].dFluxPSF = NAN; 408 } else { 409 catalog->measure[i].M = ps1data[i].M + ZeroPt; 410 catalog->measure[i].FluxPSF = pow(10.0, -0.4*ps1data[i].M); 411 catalog->measure[i].dFluxPSF = catalog->measure[i].FluxPSF * ps1data[i].dM; 412 } 413 catalog->measure[i].dM = ps1data[i].dM; 414 catalog->measure[i].dMcal = ps1data[i].dMcal; 415 catalog->measure[i].Map = ps1data[i].Map + ZeroPt; 416 catalog->measure[i].dMap = ps1data[i].dM; // a proxy measure 417 418 catalog->measure[i].Mkron = NAN; // not provided by PS1_V1: 419 catalog->measure[i].dMkron = NAN; // not provided by PS1_V1: 420 catalog->measure[i].FluxKron = NAN; // not provided by PS1_V1: 421 catalog->measure[i].dFluxKron = NAN; // not provided by PS1_V1: 422 423 catalog->measure[i].Sky = ps1data[i].sky; 424 catalog->measure[i].dSky = ps1data[i].dSky; 425 426 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 427 catalog->measure[i].psfQF = ps1data[i].psfQF; 428 catalog->measure[i].psfNdof = ps1data[i].psfNdof; 429 catalog->measure[i].psfNpix = ps1data[i].psfNpix; 430 catalog->measure[i].extNsigma = ps1data[i].extNsigma; 431 432 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 433 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 434 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 435 436 catalog->measure[i].Mxx = ToShortPixels(ps1data[i].Mxx); 437 catalog->measure[i].Mxy = ToShortPixels(ps1data[i].Mxy); 438 catalog->measure[i].Myy = ToShortPixels(ps1data[i].Myy); 439 440 catalog->measure[i].photFlags = ps1data[i].flags; 441 442 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 443 catalog->measure[i].detID = ps1data[i].detID; 441 444 442 445 // the Average fields and the following Measure fields are set in FilterStars after … … 446 449 // the following fields are currently not being set anywhere: t_msec 447 450 } 448 *nstars = Nstars; 449 return (stars); 450 } 451 452 Stars *Convert_PS1_V1_Alt (FTable *table, unsigned int *nstars) { 451 return catalog; 452 } 453 454 Catalog *Convert_PS1_V1_Alt (FTable *table) { 453 455 454 456 off_t Nstars; 455 457 unsigned int i; 456 458 double ZeroPt; 457 Stars *stars;458 459 CMF_PS1_V2 *ps1data; 459 460 … … 466 467 // call a special conversion function if it is found. 467 468 468 ps1data = gfits_table_get_CMF_PS1_V1_Alt (table, &Nstars, NULL); 469 ps1data = gfits_table_get_CMF_PS1_V1_Alt (table, &Nstars, NULL); 469 470 if (!ps1data) { 470 471 fprintf (stderr, "skipping inconsistent entry\n"); … … 473 474 ZeroPt = GetZeroPoint(); 474 475 475 ALLOCATE (stars, Stars,Nstars);476 for (i = 0; i < Nstars; i++) { 477 InitStar (&stars[i]);478 stars[i].measure.Xccd = ps1data[i].X;479 stars[i].measure.Yccd = ps1data[i].Y;480 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX);481 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY);482 483 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle);484 stars[i].measure.pltscale = ps1data[i].pltscale;476 Catalog *catalog = addstar_catalog_init (Nstars); 477 478 for (i = 0; i < Nstars; i++) { 479 catalog->measure[i].Xccd = ps1data[i].X; 480 catalog->measure[i].Yccd = ps1data[i].Y; 481 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 482 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 483 484 catalog->measure[i].posangle = ToShortDegrees(ps1data[i].posangle); 485 catalog->measure[i].pltscale = ps1data[i].pltscale; 485 486 486 487 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 487 stars[i].measure.M = NAN;488 stars[i].measure.FluxPSF = NAN;489 stars[i].measure.dFluxPSF = NAN;490 } else { 491 stars[i].measure.M = ps1data[i].M + ZeroPt;492 stars[i].measure.FluxPSF = pow(10.0, -0.4*ps1data[i].M);493 stars[i].measure.dFluxPSF = stars[i].measure.FluxPSF * ps1data[i].dM;494 } 495 stars[i].measure.dM = ps1data[i].dM;496 stars[i].measure.dMcal = ps1data[i].dMcal;497 stars[i].measure.Map = ps1data[i].Map + ZeroPt;498 stars[i].measure.dMap = ps1data[i].dM; // a proxy measure499 500 stars[i].measure.Mkron = NAN; // not provided by PS1_V1_Alt:501 stars[i].measure.dMkron = NAN; // not provided by PS1_V1_Alt:502 stars[i].measure.FluxKron = NAN; // not provided by PS1_V1_Alt:503 stars[i].measure.dFluxKron = NAN; // not provided by PS1_V1_Alt:504 505 stars[i].measure.Sky = ps1data[i].sky;506 stars[i].measure.dSky = ps1data[i].dSky;507 508 stars[i].measure.psfChisq = ps1data[i].psfChisq;509 stars[i].measure.psfQF = ps1data[i].psfQF;510 stars[i].measure.psfNdof = ps1data[i].psfNdof;511 stars[i].measure.psfNpix = ps1data[i].psfNpix;512 stars[i].measure.extNsigma = ps1data[i].extNsigma;513 514 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx);515 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy);516 stars[i].measure.theta = ToShortDegrees(ps1data[i].df);517 518 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx);519 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy);520 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy);521 522 stars[i].measure.photFlags = ps1data[i].flags;523 524 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 525 stars[i].measure.detID = ps1data[i].detID;488 catalog->measure[i].M = NAN; 489 catalog->measure[i].FluxPSF = NAN; 490 catalog->measure[i].dFluxPSF = NAN; 491 } else { 492 catalog->measure[i].M = ps1data[i].M + ZeroPt; 493 catalog->measure[i].FluxPSF = pow(10.0, -0.4*ps1data[i].M); 494 catalog->measure[i].dFluxPSF = catalog->measure[i].FluxPSF * ps1data[i].dM; 495 } 496 catalog->measure[i].dM = ps1data[i].dM; 497 catalog->measure[i].dMcal = ps1data[i].dMcal; 498 catalog->measure[i].Map = ps1data[i].Map + ZeroPt; 499 catalog->measure[i].dMap = ps1data[i].dM; // a proxy measure 500 501 catalog->measure[i].Mkron = NAN; // not provided by PS1_V1_Alt: 502 catalog->measure[i].dMkron = NAN; // not provided by PS1_V1_Alt: 503 catalog->measure[i].FluxKron = NAN; // not provided by PS1_V1_Alt: 504 catalog->measure[i].dFluxKron = NAN; // not provided by PS1_V1_Alt: 505 506 catalog->measure[i].Sky = ps1data[i].sky; 507 catalog->measure[i].dSky = ps1data[i].dSky; 508 509 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 510 catalog->measure[i].psfQF = ps1data[i].psfQF; 511 catalog->measure[i].psfNdof = ps1data[i].psfNdof; 512 catalog->measure[i].psfNpix = ps1data[i].psfNpix; 513 catalog->measure[i].extNsigma = ps1data[i].extNsigma; 514 515 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 516 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 517 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 518 519 catalog->measure[i].Mxx = ToShortPixels(ps1data[i].Mxx); 520 catalog->measure[i].Mxy = ToShortPixels(ps1data[i].Mxy); 521 catalog->measure[i].Myy = ToShortPixels(ps1data[i].Myy); 522 523 catalog->measure[i].photFlags = ps1data[i].flags; 524 525 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 526 catalog->measure[i].detID = ps1data[i].detID; 526 527 527 528 // the Average fields and the following Measure fields are set in FilterStars after … … 531 532 // the following fields are currently not being set anywhere: t_msec 532 533 } 533 *nstars = Nstars; 534 return (stars); 535 } 536 537 Stars *Convert_PS1_V2 (FTable *table, unsigned int *nstars) { 534 return catalog; 535 } 536 537 Catalog *Convert_PS1_V2 (FTable *table) { 538 538 539 539 off_t Nstars; 540 540 unsigned int i; 541 541 double ZeroPt; 542 Stars *stars;543 542 CMF_PS1_V2 *ps1data; 544 543 … … 550 549 ZeroPt = GetZeroPoint(); 551 550 552 ALLOCATE (stars, Stars,Nstars);553 for (i = 0; i < Nstars; i++) { 554 InitStar (&stars[i]);555 stars[i].measure.Xccd = ps1data[i].X;556 stars[i].measure.Yccd = ps1data[i].Y;557 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX);558 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY);559 560 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle);561 stars[i].measure.pltscale = ps1data[i].pltscale;551 Catalog *catalog = addstar_catalog_init (Nstars); 552 553 for (i = 0; i < Nstars; i++) { 554 catalog->measure[i].Xccd = ps1data[i].X; 555 catalog->measure[i].Yccd = ps1data[i].Y; 556 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 557 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 558 559 catalog->measure[i].posangle = ToShortDegrees(ps1data[i].posangle); 560 catalog->measure[i].pltscale = ps1data[i].pltscale; 562 561 563 562 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 564 stars[i].measure.M = NAN;565 stars[i].measure.FluxPSF = NAN;566 stars[i].measure.dFluxPSF = NAN;567 } else { 568 stars[i].measure.M = ps1data[i].M + ZeroPt;569 stars[i].measure.FluxPSF = pow(10.0, -0.4*ps1data[i].M);570 stars[i].measure.dFluxPSF = stars[i].measure.FluxPSF * ps1data[i].dM;571 } 572 stars[i].measure.dM = ps1data[i].dM;573 stars[i].measure.dMcal = ps1data[i].dMcal;574 stars[i].measure.Map = ps1data[i].Map + ZeroPt;575 stars[i].measure.dMap = ps1data[i].dM; // a proxy measure576 577 stars[i].measure.Mkron = NAN; // not provided by PS1_V2:578 stars[i].measure.dMkron = NAN; // not provided by PS1_V2:579 stars[i].measure.FluxKron = NAN; // not provided by PS1_V2:580 stars[i].measure.dFluxKron = NAN; // not provided by PS1_V2:581 582 stars[i].measure.Sky = ps1data[i].sky;583 stars[i].measure.dSky = ps1data[i].dSky;584 585 stars[i].measure.psfChisq = ps1data[i].psfChisq;586 stars[i].measure.psfQF = ps1data[i].psfQF;587 stars[i].measure.psfNdof = ps1data[i].psfNdof;588 stars[i].measure.psfNpix = ps1data[i].psfNpix;589 stars[i].measure.extNsigma = ps1data[i].extNsigma;590 591 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx);592 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy);593 stars[i].measure.theta = ToShortDegrees(ps1data[i].df);594 595 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx);596 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy);597 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy);598 599 stars[i].measure.photFlags = ps1data[i].flags;600 601 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 602 stars[i].measure.detID = ps1data[i].detID;563 catalog->measure[i].M = NAN; 564 catalog->measure[i].FluxPSF = NAN; 565 catalog->measure[i].dFluxPSF = NAN; 566 } else { 567 catalog->measure[i].M = ps1data[i].M + ZeroPt; 568 catalog->measure[i].FluxPSF = pow(10.0, -0.4*ps1data[i].M); 569 catalog->measure[i].dFluxPSF = catalog->measure[i].FluxPSF * ps1data[i].dM; 570 } 571 catalog->measure[i].dM = ps1data[i].dM; 572 catalog->measure[i].dMcal = ps1data[i].dMcal; 573 catalog->measure[i].Map = ps1data[i].Map + ZeroPt; 574 catalog->measure[i].dMap = ps1data[i].dM; // a proxy measure 575 576 catalog->measure[i].Mkron = NAN; // not provided by PS1_V2: 577 catalog->measure[i].dMkron = NAN; // not provided by PS1_V2: 578 catalog->measure[i].FluxKron = NAN; // not provided by PS1_V2: 579 catalog->measure[i].dFluxKron = NAN; // not provided by PS1_V2: 580 581 catalog->measure[i].Sky = ps1data[i].sky; 582 catalog->measure[i].dSky = ps1data[i].dSky; 583 584 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 585 catalog->measure[i].psfQF = ps1data[i].psfQF; 586 catalog->measure[i].psfNdof = ps1data[i].psfNdof; 587 catalog->measure[i].psfNpix = ps1data[i].psfNpix; 588 catalog->measure[i].extNsigma = ps1data[i].extNsigma; 589 590 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 591 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 592 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 593 594 catalog->measure[i].Mxx = ToShortPixels(ps1data[i].Mxx); 595 catalog->measure[i].Mxy = ToShortPixels(ps1data[i].Mxy); 596 catalog->measure[i].Myy = ToShortPixels(ps1data[i].Myy); 597 598 catalog->measure[i].photFlags = ps1data[i].flags; 599 600 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 601 catalog->measure[i].detID = ps1data[i].detID; 603 602 604 603 // the Average fields and the following Measure fields are set in FilterStars after … … 608 607 // the following fields are currently not being set anywhere: t_msec 609 608 } 610 *nstars = Nstars; 611 return (stars); 612 } 613 614 Stars *Convert_PS1_V3 (FTable *table, unsigned int *nstars) { 609 return catalog; 610 } 611 612 Catalog *Convert_PS1_V3 (FTable *table) { 615 613 616 614 off_t Nstars; 617 615 unsigned int i; 618 616 double ZeroPt; 619 Stars *stars;620 617 CMF_PS1_V3 *ps1data; 621 618 … … 627 624 ZeroPt = GetZeroPoint(); 628 625 629 ALLOCATE (stars, Stars,Nstars);630 for (i = 0; i < Nstars; i++) { 631 InitStar (&stars[i]);632 stars[i].measure.Xccd = ps1data[i].X;633 stars[i].measure.Yccd = ps1data[i].Y;634 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX);635 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY);636 637 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle);638 stars[i].measure.pltscale = ps1data[i].pltscale;626 Catalog *catalog = addstar_catalog_init (Nstars); 627 628 for (i = 0; i < Nstars; i++) { 629 catalog->measure[i].Xccd = ps1data[i].X; 630 catalog->measure[i].Yccd = ps1data[i].Y; 631 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 632 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 633 634 catalog->measure[i].posangle = ToShortDegrees(ps1data[i].posangle); 635 catalog->measure[i].pltscale = ps1data[i].pltscale; 639 636 640 637 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 641 stars[i].measure.M = NAN;642 } else { 643 stars[i].measure.M = ps1data[i].M + ZeroPt;644 } 645 stars[i].measure.dM = ps1data[i].dM;646 stars[i].measure.dMcal = ps1data[i].dMcal;647 stars[i].measure.Map = ps1data[i].Map + ZeroPt;648 stars[i].measure.dMap = ps1data[i].dM; // a proxy measure649 650 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN;651 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN;638 catalog->measure[i].M = NAN; 639 } else { 640 catalog->measure[i].M = ps1data[i].M + ZeroPt; 641 } 642 catalog->measure[i].dM = ps1data[i].dM; 643 catalog->measure[i].dMcal = ps1data[i].dMcal; 644 catalog->measure[i].Map = ps1data[i].Map + ZeroPt; 645 catalog->measure[i].dMap = ps1data[i].dM; // a proxy measure 646 647 catalog->measure[i].Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 648 catalog->measure[i].dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 652 649 653 650 // these fluxes are converted from counts to counts/sec in FilterStars.c 654 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M);655 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM);656 stars[i].measure.FluxKron = ps1data[i].kronFlux;657 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr;658 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (NAN, ps1data[i].Map);659 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (NAN, stars[i].measure.FluxAp, stars[i].measure.dMap);660 661 stars[i].measure.Sky = ps1data[i].sky;662 stars[i].measure.dSky = ps1data[i].dSky;663 664 stars[i].measure.psfChisq = ps1data[i].psfChisq;665 stars[i].measure.psfQF = ps1data[i].psfQF;666 stars[i].measure.psfQFperf = ps1data[i].psfQFperf;667 stars[i].measure.psfNdof = ps1data[i].psfNdof;668 stars[i].measure.psfNpix = ps1data[i].psfNpix;669 stars[i].measure.extNsigma = ps1data[i].extNsigma;670 671 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx);672 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy);673 stars[i].measure.theta = ToShortDegrees(ps1data[i].df);674 675 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx);676 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy);677 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy);678 679 stars[i].measure.photFlags = ps1data[i].flags;680 stars[i].measure.photFlags2 = ps1data[i].flags2;681 682 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 683 stars[i].measure.detID = ps1data[i].detID;651 catalog->measure[i].FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 652 catalog->measure[i].dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, catalog->measure[i].FluxPSF, ps1data[i].dM); 653 catalog->measure[i].FluxKron = ps1data[i].kronFlux; 654 catalog->measure[i].dFluxKron = ps1data[i].kronFluxErr; 655 catalog->measure[i].FluxAp = GetFluxFromFluxOrMag (NAN, ps1data[i].Map); 656 catalog->measure[i].dFluxAp = GetFluxErrFromFluxOrMag (NAN, catalog->measure[i].FluxAp, catalog->measure[i].dMap); 657 658 catalog->measure[i].Sky = ps1data[i].sky; 659 catalog->measure[i].dSky = ps1data[i].dSky; 660 661 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 662 catalog->measure[i].psfQF = ps1data[i].psfQF; 663 catalog->measure[i].psfQFperf = ps1data[i].psfQFperf; 664 catalog->measure[i].psfNdof = ps1data[i].psfNdof; 665 catalog->measure[i].psfNpix = ps1data[i].psfNpix; 666 catalog->measure[i].extNsigma = ps1data[i].extNsigma; 667 668 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 669 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 670 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 671 672 catalog->measure[i].Mxx = ToShortPixels(ps1data[i].Mxx); 673 catalog->measure[i].Mxy = ToShortPixels(ps1data[i].Mxy); 674 catalog->measure[i].Myy = ToShortPixels(ps1data[i].Myy); 675 676 catalog->measure[i].photFlags = ps1data[i].flags; 677 catalog->measure[i].photFlags2 = ps1data[i].flags2; 678 679 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 680 catalog->measure[i].detID = ps1data[i].detID; 684 681 685 682 // the Average fields and the following Measure fields are set in FilterStars after … … 692 689 // the following fields are currently not being set anywhere: t_msec 693 690 } 694 *nstars = Nstars; 695 return (stars); 696 } 697 698 Stars *Convert_PS1_V4 (FTable *table, unsigned int *nstars) { 691 return catalog; 692 } 693 694 Catalog *Convert_PS1_V4 (FTable *table) { 699 695 700 696 off_t Nstars; 701 697 unsigned int i; 702 698 double ZeroPt; 703 Stars *stars;704 699 CMF_PS1_V4 *ps1data; 705 700 … … 711 706 ZeroPt = GetZeroPoint(); 712 707 713 ALLOCATE (stars, Stars,Nstars);714 for (i = 0; i < Nstars; i++) { 715 InitStar (&stars[i]);716 stars[i].measure.Xccd = ps1data[i].X;717 stars[i].measure.Yccd = ps1data[i].Y;718 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX);719 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY);720 721 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle);722 stars[i].measure.pltscale = ps1data[i].pltscale;708 Catalog *catalog = addstar_catalog_init (Nstars); 709 710 for (i = 0; i < Nstars; i++) { 711 catalog->measure[i].Xccd = ps1data[i].X; 712 catalog->measure[i].Yccd = ps1data[i].Y; 713 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 714 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 715 716 catalog->measure[i].posangle = ToShortDegrees(ps1data[i].posangle); 717 catalog->measure[i].pltscale = ps1data[i].pltscale; 723 718 724 719 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 725 stars[i].measure.M = NAN;726 } else { 727 stars[i].measure.M = ps1data[i].M + ZeroPt;728 } 729 stars[i].measure.dM = ps1data[i].dM;730 stars[i].measure.dMcal = ps1data[i].dMcal;731 stars[i].measure.Map = ps1data[i].Map + ZeroPt;732 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN;733 734 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN;735 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN;720 catalog->measure[i].M = NAN; 721 } else { 722 catalog->measure[i].M = ps1data[i].M + ZeroPt; 723 } 724 catalog->measure[i].dM = ps1data[i].dM; 725 catalog->measure[i].dMcal = ps1data[i].dMcal; 726 catalog->measure[i].Map = ps1data[i].Map + ZeroPt; 727 catalog->measure[i].dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 728 729 catalog->measure[i].Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 730 catalog->measure[i].dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 736 731 737 732 // these fluxes are converted from counts to counts/sec in FilterStars.c 738 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M);739 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM);740 stars[i].measure.FluxKron = ps1data[i].kronFlux;741 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr;742 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map);743 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap);744 745 stars[i].measure.Sky = ps1data[i].sky;746 stars[i].measure.dSky = ps1data[i].dSky;747 748 stars[i].measure.psfChisq = ps1data[i].psfChisq;749 stars[i].measure.psfQF = ps1data[i].psfQF;750 stars[i].measure.psfQFperf = ps1data[i].psfQFperf;751 752 stars[i].measure.psfNdof = ps1data[i].psfNdof;753 stars[i].measure.psfNpix = ps1data[i].psfNpix;754 stars[i].measure.extNsigma = ps1data[i].extNsigma;755 756 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx);757 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy);758 stars[i].measure.theta = ToShortDegrees(ps1data[i].df);759 760 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx);761 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy);762 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy);763 764 stars[i].measure.photFlags = ps1data[i].flags;765 stars[i].measure.photFlags2 = ps1data[i].flags2;766 767 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 768 stars[i].measure.detID = ps1data[i].detID;733 catalog->measure[i].FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 734 catalog->measure[i].dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, catalog->measure[i].FluxPSF, ps1data[i].dM); 735 catalog->measure[i].FluxKron = ps1data[i].kronFlux; 736 catalog->measure[i].dFluxKron = ps1data[i].kronFluxErr; 737 catalog->measure[i].FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 738 catalog->measure[i].dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, catalog->measure[i].FluxAp, catalog->measure[i].dMap); 739 740 catalog->measure[i].Sky = ps1data[i].sky; 741 catalog->measure[i].dSky = ps1data[i].dSky; 742 743 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 744 catalog->measure[i].psfQF = ps1data[i].psfQF; 745 catalog->measure[i].psfQFperf = ps1data[i].psfQFperf; 746 747 catalog->measure[i].psfNdof = ps1data[i].psfNdof; 748 catalog->measure[i].psfNpix = ps1data[i].psfNpix; 749 catalog->measure[i].extNsigma = ps1data[i].extNsigma; 750 751 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 752 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 753 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 754 755 catalog->measure[i].Mxx = ToShortPixels(ps1data[i].Mxx); 756 catalog->measure[i].Mxy = ToShortPixels(ps1data[i].Mxy); 757 catalog->measure[i].Myy = ToShortPixels(ps1data[i].Myy); 758 759 catalog->measure[i].photFlags = ps1data[i].flags; 760 catalog->measure[i].photFlags2 = ps1data[i].flags2; 761 762 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 763 catalog->measure[i].detID = ps1data[i].detID; 769 764 770 765 // the Average fields and the following Measure fields are set in FilterStars after … … 777 772 // the following fields are currently not being set anywhere: t_msec 778 773 } 779 *nstars = Nstars; 780 return (stars); 781 } 782 783 Stars *Convert_PS1_V5 (FTable *table, unsigned int *nstars) { 774 return catalog; 775 } 776 777 Catalog *Convert_PS1_V5 (FTable *table) { 784 778 785 779 off_t Nstars; 786 780 unsigned int i; 787 781 double ZeroPt; 788 Stars *stars;789 782 CMF_PS1_V5 *ps1data; 790 783 … … 796 789 ZeroPt = GetZeroPoint(); 797 790 798 ALLOCATE (stars, Stars,Nstars);799 for (i = 0; i < Nstars; i++) { 800 InitStar (&stars[i]);801 stars[i].measure.Xccd = ps1data[i].X;802 stars[i].measure.Yccd = ps1data[i].Y;803 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX);804 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY);805 806 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle);807 stars[i].measure.pltscale = ps1data[i].pltscale;791 Catalog *catalog = addstar_catalog_init (Nstars); 792 793 for (i = 0; i < Nstars; i++) { 794 catalog->measure[i].Xccd = ps1data[i].X; 795 catalog->measure[i].Yccd = ps1data[i].Y; 796 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 797 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 798 799 catalog->measure[i].posangle = ToShortDegrees(ps1data[i].posangle); 800 catalog->measure[i].pltscale = ps1data[i].pltscale; 808 801 809 802 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 810 stars[i].measure.M = NAN;811 } else { 812 stars[i].measure.M = ps1data[i].M + ZeroPt;813 } 814 stars[i].measure.dM = ps1data[i].dM;815 stars[i].measure.dMcal = ps1data[i].dMcal;816 stars[i].measure.Map = ps1data[i].Map + ZeroPt;817 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN;818 819 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN;820 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN;803 catalog->measure[i].M = NAN; 804 } else { 805 catalog->measure[i].M = ps1data[i].M + ZeroPt; 806 } 807 catalog->measure[i].dM = ps1data[i].dM; 808 catalog->measure[i].dMcal = ps1data[i].dMcal; 809 catalog->measure[i].Map = ps1data[i].Map + ZeroPt; 810 catalog->measure[i].dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 811 812 catalog->measure[i].Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 813 catalog->measure[i].dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 821 814 822 815 // these fluxes are converted from counts to counts/sec in FilterStars.c 823 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M);824 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM);825 stars[i].measure.FluxKron = ps1data[i].kronFlux;826 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr;827 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map);828 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap);829 830 stars[i].measure.Sky = ps1data[i].sky;831 stars[i].measure.dSky = ps1data[i].dSky;832 833 stars[i].measure.psfChisq = ps1data[i].psfChisq;834 stars[i].measure.psfQF = ps1data[i].psfQF;835 stars[i].measure.psfQFperf = ps1data[i].psfQFperf;836 837 stars[i].measure.psfNdof = ps1data[i].psfNdof;838 stars[i].measure.psfNpix = ps1data[i].psfNpix;839 stars[i].measure.extNsigma = ps1data[i].extNsigma;840 841 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx);842 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy);843 stars[i].measure.theta = ToShortDegrees(ps1data[i].df);844 845 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx);846 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy);847 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy);848 849 stars[i].measure.photFlags = ps1data[i].flags;850 stars[i].measure.photFlags2 = ps1data[i].flags2;851 852 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 853 stars[i].measure.detID = ps1data[i].detID;816 catalog->measure[i].FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 817 catalog->measure[i].dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, catalog->measure[i].FluxPSF, ps1data[i].dM); 818 catalog->measure[i].FluxKron = ps1data[i].kronFlux; 819 catalog->measure[i].dFluxKron = ps1data[i].kronFluxErr; 820 catalog->measure[i].FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 821 catalog->measure[i].dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, catalog->measure[i].FluxAp, catalog->measure[i].dMap); 822 823 catalog->measure[i].Sky = ps1data[i].sky; 824 catalog->measure[i].dSky = ps1data[i].dSky; 825 826 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 827 catalog->measure[i].psfQF = ps1data[i].psfQF; 828 catalog->measure[i].psfQFperf = ps1data[i].psfQFperf; 829 830 catalog->measure[i].psfNdof = ps1data[i].psfNdof; 831 catalog->measure[i].psfNpix = ps1data[i].psfNpix; 832 catalog->measure[i].extNsigma = ps1data[i].extNsigma; 833 834 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 835 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 836 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 837 838 catalog->measure[i].Mxx = ToShortPixels(ps1data[i].Mxx); 839 catalog->measure[i].Mxy = ToShortPixels(ps1data[i].Mxy); 840 catalog->measure[i].Myy = ToShortPixels(ps1data[i].Myy); 841 842 catalog->measure[i].photFlags = ps1data[i].flags; 843 catalog->measure[i].photFlags2 = ps1data[i].flags2; 844 845 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 846 catalog->measure[i].detID = ps1data[i].detID; 854 847 855 848 // the Average fields and the following Measure fields are set in FilterStars after … … 862 855 // the following fields are currently not being set anywhere: t_msec 863 856 } 864 *nstars = Nstars; 865 return (stars); 866 } 867 868 Stars *Convert_PS1_V5_R0_Lensing (FTable *table, unsigned int *nstars) { 857 return catalog; 858 } 859 860 Catalog *Convert_PS1_V5_R0_Lensing (FTable *table) { 869 861 870 862 off_t Nstars; 871 863 unsigned int i; 872 864 double ZeroPt; 873 Stars *stars;874 865 CMF_PS1_V5_R0_Lensing *ps1data; 875 866 … … 881 872 ZeroPt = GetZeroPoint(); 882 873 883 ALLOCATE (stars, Stars, Nstars); 884 for (i = 0; i < Nstars; i++) { 885 InitStar (&stars[i]); 886 stars[i].measure.Xccd = ps1data[i].X; 887 stars[i].measure.Yccd = ps1data[i].Y; 888 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX); 889 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY); 890 891 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle); 892 stars[i].measure.pltscale = ps1data[i].pltscale; 874 Catalog *catalog = addstar_catalog_init (Nstars); 875 ALLOCATE (catalog->lensing, Lensing, Nstars); 876 catalog->Nlensing = Nstars; 877 878 for (i = 0; i < Nstars; i++) { 879 catalog->measure[i].Xccd = ps1data[i].X; 880 catalog->measure[i].Yccd = ps1data[i].Y; 881 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 882 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 883 884 catalog->measure[i].posangle = ToShortDegrees(ps1data[i].posangle); 885 catalog->measure[i].pltscale = ps1data[i].pltscale; 893 886 894 887 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 895 stars[i].measure.M = NAN;896 } else { 897 stars[i].measure.M = ps1data[i].M + ZeroPt;898 } 899 stars[i].measure.dM = ps1data[i].dM;900 stars[i].measure.dMcal = ps1data[i].dMcal;901 stars[i].measure.Map = ps1data[i].Map + ZeroPt;902 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN;903 904 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN;905 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN;888 catalog->measure[i].M = NAN; 889 } else { 890 catalog->measure[i].M = ps1data[i].M + ZeroPt; 891 } 892 catalog->measure[i].dM = ps1data[i].dM; 893 catalog->measure[i].dMcal = ps1data[i].dMcal; 894 catalog->measure[i].Map = ps1data[i].Map + ZeroPt; 895 catalog->measure[i].dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 896 897 catalog->measure[i].Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 898 catalog->measure[i].dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 906 899 907 900 // these fluxes are converted from counts to counts/sec in FilterStars.c 908 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 909 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 910 stars[i].measure.FluxKron = ps1data[i].kronFlux; 911 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 912 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 913 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap); 914 915 stars[i].measure.Sky = ps1data[i].sky; 916 stars[i].measure.dSky = ps1data[i].dSky; 917 918 stars[i].measure.psfChisq = ps1data[i].psfChisq; 919 stars[i].measure.psfQF = ps1data[i].psfQF; 920 stars[i].measure.psfQFperf = ps1data[i].psfQFperf; 921 922 stars[i].measure.psfNdof = ps1data[i].psfNdof; 923 stars[i].measure.psfNpix = ps1data[i].psfNpix; 924 stars[i].measure.extNsigma = ps1data[i].extNsigma; 925 926 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx); 927 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy); 928 stars[i].measure.theta = ToShortDegrees(ps1data[i].df); 929 930 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx); 931 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy); 932 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy); 933 934 stars[i].measure.photFlags = ps1data[i].flags; 935 stars[i].measure.photFlags2 = ps1data[i].flags2; 936 937 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 938 stars[i].measure.detID = ps1data[i].detID; 939 940 ALLOCATE (stars[i].lensing, Lensing, 1); 941 dvo_lensing_init (stars[i].lensing); 942 943 stars[i].lensing->X11_sm_obj = ps1data[i].X11_sm_obj; 944 stars[i].lensing->X12_sm_obj = ps1data[i].X12_sm_obj; 945 stars[i].lensing->X22_sm_obj = ps1data[i].X22_sm_obj; 946 stars[i].lensing->E1_sm_obj = ps1data[i].E1_sm_obj; 947 stars[i].lensing->E2_sm_obj = ps1data[i].E2_sm_obj; 948 949 stars[i].lensing->X11_sh_obj = ps1data[i].X11_sh_obj; 950 stars[i].lensing->X12_sh_obj = ps1data[i].X12_sh_obj; 951 stars[i].lensing->X22_sh_obj = ps1data[i].X22_sh_obj; 952 stars[i].lensing->E1_sh_obj = ps1data[i].E1_sh_obj; 953 stars[i].lensing->E2_sh_obj = ps1data[i].E2_sh_obj; 954 955 stars[i].lensing->X11_sm_psf = ps1data[i].X11_sm_psf; 956 stars[i].lensing->X12_sm_psf = ps1data[i].X12_sm_psf; 957 stars[i].lensing->X22_sm_psf = ps1data[i].X22_sm_psf; 958 stars[i].lensing->E1_sm_psf = ps1data[i].E1_sm_psf; 959 stars[i].lensing->E2_sm_psf = ps1data[i].E2_sm_psf; 960 961 stars[i].lensing->X11_sh_psf = ps1data[i].X11_sh_psf; 962 stars[i].lensing->X12_sh_psf = ps1data[i].X12_sh_psf; 963 stars[i].lensing->X22_sh_psf = ps1data[i].X22_sh_psf; 964 stars[i].lensing->E1_sh_psf = ps1data[i].E1_sh_psf; 965 stars[i].lensing->E2_sh_psf = ps1data[i].E2_sh_psf; 966 967 // stars[i].lensing->F_ApR5 = ps1data[i].F_ApR5; 968 // stars[i].lensing->dF_ApR5 = ps1data[i].dF_ApR5; 969 // stars[i].lensing->sF_ApR5 = ps1data[i].sF_ApR5; 970 // stars[i].lensing->fF_ApR5 = ps1data[i].fF_ApR5; 901 catalog->measure[i].FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 902 catalog->measure[i].dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, catalog->measure[i].FluxPSF, ps1data[i].dM); 903 catalog->measure[i].FluxKron = ps1data[i].kronFlux; 904 catalog->measure[i].dFluxKron = ps1data[i].kronFluxErr; 905 catalog->measure[i].FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 906 catalog->measure[i].dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, catalog->measure[i].FluxAp, catalog->measure[i].dMap); 907 908 catalog->measure[i].Sky = ps1data[i].sky; 909 catalog->measure[i].dSky = ps1data[i].dSky; 910 911 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 912 catalog->measure[i].psfQF = ps1data[i].psfQF; 913 catalog->measure[i].psfQFperf = ps1data[i].psfQFperf; 914 915 catalog->measure[i].psfNdof = ps1data[i].psfNdof; 916 catalog->measure[i].psfNpix = ps1data[i].psfNpix; 917 catalog->measure[i].extNsigma = ps1data[i].extNsigma; 918 919 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 920 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 921 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 922 923 catalog->measure[i].Mxx = ToShortPixels(ps1data[i].Mxx); 924 catalog->measure[i].Mxy = ToShortPixels(ps1data[i].Mxy); 925 catalog->measure[i].Myy = ToShortPixels(ps1data[i].Myy); 926 927 catalog->measure[i].photFlags = ps1data[i].flags; 928 catalog->measure[i].photFlags2 = ps1data[i].flags2; 929 930 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 931 catalog->measure[i].detID = ps1data[i].detID; 932 933 dvo_lensing_init (&catalog->lensing[i]); 934 935 catalog->lensing[i].X11_sm_obj = ps1data[i].X11_sm_obj; 936 catalog->lensing[i].X12_sm_obj = ps1data[i].X12_sm_obj; 937 catalog->lensing[i].X22_sm_obj = ps1data[i].X22_sm_obj; 938 catalog->lensing[i].E1_sm_obj = ps1data[i].E1_sm_obj; 939 catalog->lensing[i].E2_sm_obj = ps1data[i].E2_sm_obj; 940 941 catalog->lensing[i].X11_sh_obj = ps1data[i].X11_sh_obj; 942 catalog->lensing[i].X12_sh_obj = ps1data[i].X12_sh_obj; 943 catalog->lensing[i].X22_sh_obj = ps1data[i].X22_sh_obj; 944 catalog->lensing[i].E1_sh_obj = ps1data[i].E1_sh_obj; 945 catalog->lensing[i].E2_sh_obj = ps1data[i].E2_sh_obj; 946 947 catalog->lensing[i].X11_sm_psf = ps1data[i].X11_sm_psf; 948 catalog->lensing[i].X12_sm_psf = ps1data[i].X12_sm_psf; 949 catalog->lensing[i].X22_sm_psf = ps1data[i].X22_sm_psf; 950 catalog->lensing[i].E1_sm_psf = ps1data[i].E1_sm_psf; 951 catalog->lensing[i].E2_sm_psf = ps1data[i].E2_sm_psf; 952 953 catalog->lensing[i].X11_sh_psf = ps1data[i].X11_sh_psf; 954 catalog->lensing[i].X12_sh_psf = ps1data[i].X12_sh_psf; 955 catalog->lensing[i].X22_sh_psf = ps1data[i].X22_sh_psf; 956 catalog->lensing[i].E1_sh_psf = ps1data[i].E1_sh_psf; 957 catalog->lensing[i].E2_sh_psf = ps1data[i].E2_sh_psf; 958 959 // catalog->lensing[i].F_ApR5 = ps1data[i].F_ApR5; 960 // catalog->lensing[i].dF_ApR5 = ps1data[i].dF_ApR5; 961 // catalog->lensing[i].sF_ApR5 = ps1data[i].sF_ApR5; 962 // catalog->lensing[i].fF_ApR5 = ps1data[i].fF_ApR5; 971 963 // 972 // stars[i].lensing->F_ApR6 = ps1data[i].F_ApR6;973 // stars[i].lensing->dF_ApR6 = ps1data[i].dF_ApR6;974 // stars[i].lensing->sF_ApR6 = ps1data[i].sF_ApR6;975 // stars[i].lensing->fF_ApR6 = ps1data[i].fF_ApR6;976 977 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 978 stars[i].lensing->detID = ps1data[i].detID;964 // catalog->lensing[i].F_ApR6 = ps1data[i].F_ApR6; 965 // catalog->lensing[i].dF_ApR6 = ps1data[i].dF_ApR6; 966 // catalog->lensing[i].sF_ApR6 = ps1data[i].sF_ApR6; 967 // catalog->lensing[i].fF_ApR6 = ps1data[i].fF_ApR6; 968 969 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 970 catalog->lensing[i].detID = ps1data[i].detID; 979 971 980 972 // the Average fields and the following Measure fields are set in FilterStars after … … 987 979 // the following fields are currently not being set anywhere: t_msec 988 980 } 989 *nstars = Nstars; 990 return (stars); 991 } 992 993 Stars *Convert_PS1_V5_R1_Lensing (FTable *table, unsigned int *nstars) { 981 return catalog; 982 } 983 984 Catalog *Convert_PS1_V5_R1_Lensing (FTable *table) { 994 985 995 986 off_t Nstars; 996 987 unsigned int i; 997 988 double ZeroPt; 998 Stars *stars;999 989 CMF_PS1_V5_R1_Lensing *ps1data; 1000 990 … … 1006 996 ZeroPt = GetZeroPoint(); 1007 997 1008 ALLOCATE (stars, Stars, Nstars); 1009 for (i = 0; i < Nstars; i++) { 1010 InitStar (&stars[i]); 1011 stars[i].measure.Xccd = ps1data[i].X; 1012 stars[i].measure.Yccd = ps1data[i].Y; 1013 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX); 1014 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY); 1015 1016 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle); 1017 stars[i].measure.pltscale = ps1data[i].pltscale; 998 Catalog *catalog = addstar_catalog_init (Nstars); 999 ALLOCATE (catalog->lensing, Lensing, Nstars); 1000 catalog->Nlensing = Nstars; 1001 1002 for (i = 0; i < Nstars; i++) { 1003 catalog->measure[i].Xccd = ps1data[i].X; 1004 catalog->measure[i].Yccd = ps1data[i].Y; 1005 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 1006 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 1007 1008 catalog->measure[i].posangle = ToShortDegrees(ps1data[i].posangle); 1009 catalog->measure[i].pltscale = ps1data[i].pltscale; 1018 1010 1019 1011 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1020 stars[i].measure.M = NAN;1021 } else { 1022 stars[i].measure.M = ps1data[i].M + ZeroPt;1023 } 1024 stars[i].measure.dM = ps1data[i].dM;1025 stars[i].measure.dMcal = ps1data[i].dMcal;1026 stars[i].measure.Map = ps1data[i].Map + ZeroPt;1027 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN;1028 1029 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN;1030 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN;1012 catalog->measure[i].M = NAN; 1013 } else { 1014 catalog->measure[i].M = ps1data[i].M + ZeroPt; 1015 } 1016 catalog->measure[i].dM = ps1data[i].dM; 1017 catalog->measure[i].dMcal = ps1data[i].dMcal; 1018 catalog->measure[i].Map = ps1data[i].Map + ZeroPt; 1019 catalog->measure[i].dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 1020 1021 catalog->measure[i].Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1022 catalog->measure[i].dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1031 1023 1032 1024 // these fluxes are converted from counts to counts/sec in FilterStars.c 1033 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1034 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 1035 stars[i].measure.FluxKron = ps1data[i].kronFlux; 1036 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 1037 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1038 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap); 1039 1040 stars[i].measure.Sky = ps1data[i].sky; 1041 stars[i].measure.dSky = ps1data[i].dSky; 1042 1043 stars[i].measure.psfChisq = ps1data[i].psfChisq; 1044 stars[i].measure.psfQF = ps1data[i].psfQF; 1045 stars[i].measure.psfQFperf = ps1data[i].psfQFperf; 1046 1047 stars[i].measure.psfNdof = ps1data[i].psfNdof; 1048 stars[i].measure.psfNpix = ps1data[i].psfNpix; 1049 stars[i].measure.extNsigma = ps1data[i].extNsigma; 1050 1051 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx); 1052 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy); 1053 stars[i].measure.theta = ToShortDegrees(ps1data[i].df); 1054 1055 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx); 1056 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy); 1057 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy); 1058 1059 stars[i].measure.photFlags = ps1data[i].flags; 1060 stars[i].measure.photFlags2 = ps1data[i].flags2; 1061 1062 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1063 stars[i].measure.detID = ps1data[i].detID; 1064 1065 ALLOCATE (stars[i].lensing, Lensing, 1); 1066 dvo_lensing_init (stars[i].lensing); 1067 1068 stars[i].lensing->X11_sm_obj = ps1data[i].X11_sm_obj; 1069 stars[i].lensing->X12_sm_obj = ps1data[i].X12_sm_obj; 1070 stars[i].lensing->X22_sm_obj = ps1data[i].X22_sm_obj; 1071 stars[i].lensing->E1_sm_obj = ps1data[i].E1_sm_obj; 1072 stars[i].lensing->E2_sm_obj = ps1data[i].E2_sm_obj; 1073 1074 stars[i].lensing->X11_sh_obj = ps1data[i].X11_sh_obj; 1075 stars[i].lensing->X12_sh_obj = ps1data[i].X12_sh_obj; 1076 stars[i].lensing->X22_sh_obj = ps1data[i].X22_sh_obj; 1077 stars[i].lensing->E1_sh_obj = ps1data[i].E1_sh_obj; 1078 stars[i].lensing->E2_sh_obj = ps1data[i].E2_sh_obj; 1079 1080 stars[i].lensing->X11_sm_psf = ps1data[i].X11_sm_psf; 1081 stars[i].lensing->X12_sm_psf = ps1data[i].X12_sm_psf; 1082 stars[i].lensing->X22_sm_psf = ps1data[i].X22_sm_psf; 1083 stars[i].lensing->E1_sm_psf = ps1data[i].E1_sm_psf; 1084 stars[i].lensing->E2_sm_psf = ps1data[i].E2_sm_psf; 1085 1086 stars[i].lensing->X11_sh_psf = ps1data[i].X11_sh_psf; 1087 stars[i].lensing->X12_sh_psf = ps1data[i].X12_sh_psf; 1088 stars[i].lensing->X22_sh_psf = ps1data[i].X22_sh_psf; 1089 stars[i].lensing->E1_sh_psf = ps1data[i].E1_sh_psf; 1090 stars[i].lensing->E2_sh_psf = ps1data[i].E2_sh_psf; 1091 1092 // stars[i].lensing->F_ApR5 = ps1data[i].F_ApR5; 1093 // stars[i].lensing->dF_ApR5 = ps1data[i].dF_ApR5; 1094 // stars[i].lensing->sF_ApR5 = ps1data[i].sF_ApR5; 1095 // stars[i].lensing->fF_ApR5 = ps1data[i].fF_ApR5; 1025 catalog->measure[i].FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1026 catalog->measure[i].dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, catalog->measure[i].FluxPSF, ps1data[i].dM); 1027 catalog->measure[i].FluxKron = ps1data[i].kronFlux; 1028 catalog->measure[i].dFluxKron = ps1data[i].kronFluxErr; 1029 catalog->measure[i].FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1030 catalog->measure[i].dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, catalog->measure[i].FluxAp, catalog->measure[i].dMap); 1031 1032 catalog->measure[i].Sky = ps1data[i].sky; 1033 catalog->measure[i].dSky = ps1data[i].dSky; 1034 1035 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 1036 catalog->measure[i].psfQF = ps1data[i].psfQF; 1037 catalog->measure[i].psfQFperf = ps1data[i].psfQFperf; 1038 1039 catalog->measure[i].psfNdof = ps1data[i].psfNdof; 1040 catalog->measure[i].psfNpix = ps1data[i].psfNpix; 1041 catalog->measure[i].extNsigma = ps1data[i].extNsigma; 1042 1043 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 1044 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 1045 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 1046 1047 catalog->measure[i].Mxx = ToShortPixels(ps1data[i].Mxx); 1048 catalog->measure[i].Mxy = ToShortPixels(ps1data[i].Mxy); 1049 catalog->measure[i].Myy = ToShortPixels(ps1data[i].Myy); 1050 1051 catalog->measure[i].photFlags = ps1data[i].flags; 1052 catalog->measure[i].photFlags2 = ps1data[i].flags2; 1053 1054 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1055 catalog->measure[i].detID = ps1data[i].detID; 1056 1057 dvo_lensing_init (&catalog->lensing[i]); 1058 1059 catalog->lensing[i].X11_sm_obj = ps1data[i].X11_sm_obj; 1060 catalog->lensing[i].X12_sm_obj = ps1data[i].X12_sm_obj; 1061 catalog->lensing[i].X22_sm_obj = ps1data[i].X22_sm_obj; 1062 catalog->lensing[i].E1_sm_obj = ps1data[i].E1_sm_obj; 1063 catalog->lensing[i].E2_sm_obj = ps1data[i].E2_sm_obj; 1064 1065 catalog->lensing[i].X11_sh_obj = ps1data[i].X11_sh_obj; 1066 catalog->lensing[i].X12_sh_obj = ps1data[i].X12_sh_obj; 1067 catalog->lensing[i].X22_sh_obj = ps1data[i].X22_sh_obj; 1068 catalog->lensing[i].E1_sh_obj = ps1data[i].E1_sh_obj; 1069 catalog->lensing[i].E2_sh_obj = ps1data[i].E2_sh_obj; 1070 1071 catalog->lensing[i].X11_sm_psf = ps1data[i].X11_sm_psf; 1072 catalog->lensing[i].X12_sm_psf = ps1data[i].X12_sm_psf; 1073 catalog->lensing[i].X22_sm_psf = ps1data[i].X22_sm_psf; 1074 catalog->lensing[i].E1_sm_psf = ps1data[i].E1_sm_psf; 1075 catalog->lensing[i].E2_sm_psf = ps1data[i].E2_sm_psf; 1076 1077 catalog->lensing[i].X11_sh_psf = ps1data[i].X11_sh_psf; 1078 catalog->lensing[i].X12_sh_psf = ps1data[i].X12_sh_psf; 1079 catalog->lensing[i].X22_sh_psf = ps1data[i].X22_sh_psf; 1080 catalog->lensing[i].E1_sh_psf = ps1data[i].E1_sh_psf; 1081 catalog->lensing[i].E2_sh_psf = ps1data[i].E2_sh_psf; 1082 1083 // catalog->lensing[i].F_ApR5 = ps1data[i].F_ApR5; 1084 // catalog->lensing[i].dF_ApR5 = ps1data[i].dF_ApR5; 1085 // catalog->lensing[i].sF_ApR5 = ps1data[i].sF_ApR5; 1086 // catalog->lensing[i].fF_ApR5 = ps1data[i].fF_ApR5; 1096 1087 // 1097 // stars[i].lensing->F_ApR6 = ps1data[i].F_ApR6;1098 // stars[i].lensing->dF_ApR6 = ps1data[i].dF_ApR6;1099 // stars[i].lensing->sF_ApR6 = ps1data[i].sF_ApR6;1100 // stars[i].lensing->fF_ApR6 = ps1data[i].fF_ApR6;1101 1102 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1103 stars[i].lensing->detID = ps1data[i].detID;1088 // catalog->lensing[i].F_ApR6 = ps1data[i].F_ApR6; 1089 // catalog->lensing[i].dF_ApR6 = ps1data[i].dF_ApR6; 1090 // catalog->lensing[i].sF_ApR6 = ps1data[i].sF_ApR6; 1091 // catalog->lensing[i].fF_ApR6 = ps1data[i].fF_ApR6; 1092 1093 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1094 catalog->lensing[i].detID = ps1data[i].detID; 1104 1095 1105 1096 // the Average fields and the following Measure fields are set in FilterStars after … … 1112 1103 // the following fields are currently not being set anywhere: t_msec 1113 1104 } 1114 *nstars = Nstars; 1115 return (stars); 1116 } 1117 1118 Stars *Convert_PS1_V5_R2_Lensing (FTable *table, unsigned int *nstars) { 1105 return catalog; 1106 } 1107 1108 Catalog *Convert_PS1_V5_R2_Lensing (FTable *table) { 1119 1109 1120 1110 off_t Nstars; 1121 1111 unsigned int i; 1122 1112 double ZeroPt; 1123 Stars *stars;1124 1113 CMF_PS1_V5_R2_Lensing *ps1data; 1125 1114 1126 ps1data = gfits_table_get_CMF_PS1_V5_R2_Lensing (table, &Nstars, NULL); 1115 // this code expects the output cmf files to have a fixed column order 1116 // unfortunatly, psphot is not consistent for the obj lensing values: 1117 // if the first object in the list is not a valid object for the lensing measurement, then 1118 // the lensingOBJ structure is not allocated for that source and the corresponding rows 1119 // are not added to the output metadata until an object which does include the 1120 // measurement. 1121 1122 char field[128]; 1123 gfits_scan (table->header, "TTYPE45", "%s", 1, field); 1124 1125 int mode = 0; 1126 if (!strcmp (field, "LENS_X11_SM_OBJ")) { mode = 1; } 1127 if (!strcmp (field, "LENS_X11_SM_PSF")) { mode = 2; } 1128 myAssert (mode, "invalid table layout\n"); 1129 1130 if (mode == 1) { 1131 ps1data = gfits_table_get_CMF_PS1_V5_R2_Lensing (table, &Nstars, NULL); 1132 fprintf (stderr, "PS1_V5_R2_Lensing mode 1\n"); 1133 } 1134 if (mode == 2) { 1135 ps1data = gfits_table_get_CMF_PS1_V5_R2x_Lensing (table, &Nstars, NULL); 1136 fprintf (stderr, "PS1_V5_R2_Lensing mode 2\n"); 1137 } 1138 1127 1139 if (!ps1data) { 1128 1140 fprintf (stderr, "skipping inconsistent entry\n"); … … 1131 1143 ZeroPt = GetZeroPoint(); 1132 1144 1133 ALLOCATE (stars, Stars, Nstars); 1134 for (i = 0; i < Nstars; i++) { 1135 InitStar (&stars[i]); 1136 stars[i].measure.Xccd = ps1data[i].X; 1137 stars[i].measure.Yccd = ps1data[i].Y; 1138 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX); 1139 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY); 1140 1141 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle); 1142 stars[i].measure.pltscale = ps1data[i].pltscale; 1145 Catalog *catalog = addstar_catalog_init (Nstars); 1146 ALLOCATE (catalog->lensing, Lensing, Nstars); 1147 catalog->Nlensing = Nstars; 1148 1149 for (i = 0; i < Nstars; i++) { 1150 catalog->measure[i].Xccd = ps1data[i].X; 1151 catalog->measure[i].Yccd = ps1data[i].Y; 1152 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 1153 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 1154 1155 catalog->measure[i].posangle = ToShortDegrees(ps1data[i].posangle); 1156 catalog->measure[i].pltscale = ps1data[i].pltscale; 1143 1157 1144 1158 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1145 stars[i].measure.M = NAN;1146 } else { 1147 stars[i].measure.M = ps1data[i].M + ZeroPt;1148 } 1149 stars[i].measure.dM = ps1data[i].dM;1150 stars[i].measure.dMcal = ps1data[i].dMcal;1151 stars[i].measure.Map = ps1data[i].Map + ZeroPt;1152 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN;1153 1154 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN;1155 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN;1159 catalog->measure[i].M = NAN; 1160 } else { 1161 catalog->measure[i].M = ps1data[i].M + ZeroPt; 1162 } 1163 catalog->measure[i].dM = ps1data[i].dM; 1164 catalog->measure[i].dMcal = ps1data[i].dMcal; 1165 catalog->measure[i].Map = ps1data[i].Map + ZeroPt; 1166 catalog->measure[i].dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 1167 1168 catalog->measure[i].Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1169 catalog->measure[i].dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1156 1170 1157 1171 // these fluxes are converted from counts to counts/sec in FilterStars.c 1158 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1159 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM); 1160 stars[i].measure.FluxKron = ps1data[i].kronFlux; 1161 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr; 1162 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1163 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap); 1164 1165 stars[i].measure.Sky = ps1data[i].sky; 1166 stars[i].measure.dSky = ps1data[i].dSky; 1167 1168 stars[i].measure.psfChisq = ps1data[i].psfChisq; 1169 stars[i].measure.psfQF = ps1data[i].psfQF; 1170 stars[i].measure.psfQFperf = ps1data[i].psfQFperf; 1171 1172 stars[i].measure.psfNdof = ps1data[i].psfNdof; 1173 stars[i].measure.psfNpix = ps1data[i].psfNpix; 1174 stars[i].measure.extNsigma = ps1data[i].extNsigma; 1175 1176 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx); 1177 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy); 1178 stars[i].measure.theta = ToShortDegrees(ps1data[i].df); 1179 1180 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx); 1181 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy); 1182 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy); 1183 1184 stars[i].measure.photFlags = ps1data[i].flags; 1185 stars[i].measure.photFlags2 = ps1data[i].flags2; 1186 1187 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1188 stars[i].measure.detID = ps1data[i].detID; 1189 1190 ALLOCATE (stars[i].lensing, Lensing, 1); 1191 dvo_lensing_init (stars[i].lensing); 1192 1193 stars[i].lensing->X11_sm_obj = ps1data[i].X11_sm_obj; 1194 stars[i].lensing->X12_sm_obj = ps1data[i].X12_sm_obj; 1195 stars[i].lensing->X22_sm_obj = ps1data[i].X22_sm_obj; 1196 stars[i].lensing->E1_sm_obj = ps1data[i].E1_sm_obj; 1197 stars[i].lensing->E2_sm_obj = ps1data[i].E2_sm_obj; 1198 1199 stars[i].lensing->X11_sh_obj = ps1data[i].X11_sh_obj; 1200 stars[i].lensing->X12_sh_obj = ps1data[i].X12_sh_obj; 1201 stars[i].lensing->X22_sh_obj = ps1data[i].X22_sh_obj; 1202 stars[i].lensing->E1_sh_obj = ps1data[i].E1_sh_obj; 1203 stars[i].lensing->E2_sh_obj = ps1data[i].E2_sh_obj; 1204 1205 stars[i].lensing->X11_sm_psf = ps1data[i].X11_sm_psf; 1206 stars[i].lensing->X12_sm_psf = ps1data[i].X12_sm_psf; 1207 stars[i].lensing->X22_sm_psf = ps1data[i].X22_sm_psf; 1208 stars[i].lensing->E1_sm_psf = ps1data[i].E1_sm_psf; 1209 stars[i].lensing->E2_sm_psf = ps1data[i].E2_sm_psf; 1210 1211 stars[i].lensing->X11_sh_psf = ps1data[i].X11_sh_psf; 1212 stars[i].lensing->X12_sh_psf = ps1data[i].X12_sh_psf; 1213 stars[i].lensing->X22_sh_psf = ps1data[i].X22_sh_psf; 1214 stars[i].lensing->E1_sh_psf = ps1data[i].E1_sh_psf; 1215 stars[i].lensing->E2_sh_psf = ps1data[i].E2_sh_psf; 1216 1217 stars[i].lensing->E1_psf = ps1data[i].E1_psf; 1218 stars[i].lensing->E2_psf = ps1data[i].E2_psf; 1219 1220 // stars[i].lensing->F_ApR5 = ps1data[i].F_ApR5; 1221 // stars[i].lensing->dF_ApR5 = ps1data[i].dF_ApR5; 1222 // stars[i].lensing->sF_ApR5 = ps1data[i].sF_ApR5; 1223 // stars[i].lensing->fF_ApR5 = ps1data[i].fF_ApR5; 1224 // 1225 // stars[i].lensing->F_ApR6 = ps1data[i].F_ApR6; 1226 // stars[i].lensing->dF_ApR6 = ps1data[i].dF_ApR6; 1227 // stars[i].lensing->sF_ApR6 = ps1data[i].sF_ApR6; 1228 // stars[i].lensing->fF_ApR6 = ps1data[i].fF_ApR6; 1229 1230 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1231 stars[i].lensing->detID = ps1data[i].detID; 1172 catalog->measure[i].FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1173 catalog->measure[i].dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, catalog->measure[i].FluxPSF, ps1data[i].dM); 1174 catalog->measure[i].FluxKron = ps1data[i].kronFlux; 1175 catalog->measure[i].dFluxKron = ps1data[i].kronFluxErr; 1176 catalog->measure[i].FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1177 catalog->measure[i].dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, catalog->measure[i].FluxAp, catalog->measure[i].dMap); 1178 1179 catalog->measure[i].Sky = ps1data[i].sky; 1180 catalog->measure[i].dSky = ps1data[i].dSky; 1181 1182 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 1183 catalog->measure[i].psfQF = ps1data[i].psfQF; 1184 catalog->measure[i].psfQFperf = ps1data[i].psfQFperf; 1185 1186 catalog->measure[i].psfNdof = ps1data[i].psfNdof; 1187 catalog->measure[i].psfNpix = ps1data[i].psfNpix; 1188 catalog->measure[i].extNsigma = ps1data[i].extNsigma; 1189 1190 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 1191 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 1192 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 1193 1194 catalog->measure[i].Mxx = ToShortPixels(ps1data[i].Mxx); 1195 catalog->measure[i].Mxy = ToShortPixels(ps1data[i].Mxy); 1196 catalog->measure[i].Myy = ToShortPixels(ps1data[i].Myy); 1197 1198 catalog->measure[i].photFlags = ps1data[i].flags; 1199 catalog->measure[i].photFlags2 = ps1data[i].flags2; 1200 1201 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1202 catalog->measure[i].detID = ps1data[i].detID; 1203 1204 dvo_lensing_init (&catalog->lensing[i]); 1205 1206 catalog->lensing[i].X11_sm_obj = ps1data[i].X11_sm_obj; 1207 catalog->lensing[i].X12_sm_obj = ps1data[i].X12_sm_obj; 1208 catalog->lensing[i].X22_sm_obj = ps1data[i].X22_sm_obj; 1209 catalog->lensing[i].E1_sm_obj = ps1data[i].E1_sm_obj; 1210 catalog->lensing[i].E2_sm_obj = ps1data[i].E2_sm_obj; 1211 1212 catalog->lensing[i].X11_sh_obj = ps1data[i].X11_sh_obj; 1213 catalog->lensing[i].X12_sh_obj = ps1data[i].X12_sh_obj; 1214 catalog->lensing[i].X22_sh_obj = ps1data[i].X22_sh_obj; 1215 catalog->lensing[i].E1_sh_obj = ps1data[i].E1_sh_obj; 1216 catalog->lensing[i].E2_sh_obj = ps1data[i].E2_sh_obj; 1217 1218 catalog->lensing[i].X11_sm_psf = ps1data[i].X11_sm_psf; 1219 catalog->lensing[i].X12_sm_psf = ps1data[i].X12_sm_psf; 1220 catalog->lensing[i].X22_sm_psf = ps1data[i].X22_sm_psf; 1221 catalog->lensing[i].E1_sm_psf = ps1data[i].E1_sm_psf; 1222 catalog->lensing[i].E2_sm_psf = ps1data[i].E2_sm_psf; 1223 1224 catalog->lensing[i].X11_sh_psf = ps1data[i].X11_sh_psf; 1225 catalog->lensing[i].X12_sh_psf = ps1data[i].X12_sh_psf; 1226 catalog->lensing[i].X22_sh_psf = ps1data[i].X22_sh_psf; 1227 catalog->lensing[i].E1_sh_psf = ps1data[i].E1_sh_psf; 1228 catalog->lensing[i].E2_sh_psf = ps1data[i].E2_sh_psf; 1229 1230 catalog->lensing[i].E1_psf = ps1data[i].E1_psf; 1231 catalog->lensing[i].E2_psf = ps1data[i].E2_psf; 1232 1233 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1234 catalog->lensing[i].detID = ps1data[i].detID; 1232 1235 1233 1236 // the Average fields and the following Measure fields are set in FilterStars after … … 1240 1243 // the following fields are currently not being set anywhere: t_msec 1241 1244 } 1242 *nstars = Nstars; 1243 return (stars); 1244 } 1245 1246 Stars *Convert_PS1_SV1 (FTable *table, unsigned int *nstars) { 1245 return catalog; 1246 } 1247 1248 Catalog *Convert_PS1_SV1 (FTable *table) { 1247 1249 1248 1250 off_t Nstars; 1249 1251 unsigned int i; 1250 1252 double ZeroPt; 1251 Stars *stars;1252 1253 CMF_PS1_SV1 *ps1data; 1253 1254 1254 1255 if (table[0].header[0].Naxis[0] == 196) { 1255 stars = Convert_PS1_SV1_Alt (table, nstars);1256 return (stars);1256 Catalog *catalog = Convert_PS1_SV1_Alt (table); 1257 return catalog; 1257 1258 } 1258 1259 … … 1264 1265 ZeroPt = GetZeroPoint(); 1265 1266 1266 ALLOCATE (stars, Stars,Nstars);1267 for (i = 0; i < Nstars; i++) { 1268 InitStar (&stars[i]);1269 stars[i].measure.Xccd = ps1data[i].X;1270 stars[i].measure.Yccd = ps1data[i].Y;1271 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX);1272 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY);1273 1274 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle);1275 stars[i].measure.pltscale = ps1data[i].pltscale;1267 Catalog *catalog = addstar_catalog_init (Nstars); 1268 1269 for (i = 0; i < Nstars; i++) { 1270 catalog->measure[i].Xccd = ps1data[i].X; 1271 catalog->measure[i].Yccd = ps1data[i].Y; 1272 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 1273 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 1274 1275 catalog->measure[i].posangle = ToShortDegrees(ps1data[i].posangle); 1276 catalog->measure[i].pltscale = ps1data[i].pltscale; 1276 1277 1277 1278 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1278 stars[i].measure.M = NAN;1279 } else { 1280 stars[i].measure.M = ps1data[i].M + ZeroPt;1281 } 1282 stars[i].measure.dM = ps1data[i].dM;1283 stars[i].measure.dMcal = ps1data[i].dMcal;1284 stars[i].measure.Map = ps1data[i].Map + ZeroPt;1285 stars[i].measure.dMap = ps1data[i].dM; // a proxy measure1286 1287 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN;1288 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN;1279 catalog->measure[i].M = NAN; 1280 } else { 1281 catalog->measure[i].M = ps1data[i].M + ZeroPt; 1282 } 1283 catalog->measure[i].dM = ps1data[i].dM; 1284 catalog->measure[i].dMcal = ps1data[i].dMcal; 1285 catalog->measure[i].Map = ps1data[i].Map + ZeroPt; 1286 catalog->measure[i].dMap = ps1data[i].dM; // a proxy measure 1287 1288 catalog->measure[i].Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1289 catalog->measure[i].dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1289 1290 1290 1291 // these fluxes are converted from counts to counts/sec in FilterStars.c 1291 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M);1292 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM);1293 stars[i].measure.FluxKron = ps1data[i].kronFlux;1294 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr;1295 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (NAN, ps1data[i].Map);1296 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (NAN, stars[i].measure.FluxAp, stars[i].measure.dMap);1297 1298 stars[i].measure.Sky = ps1data[i].sky;1299 stars[i].measure.dSky = ps1data[i].dSky;1300 1301 stars[i].measure.psfChisq = ps1data[i].psfChisq;1302 stars[i].measure.psfQF = ps1data[i].psfQF;1303 stars[i].measure.psfQFperf = ps1data[i].psfQFperf;1304 1305 stars[i].measure.psfNdof = ps1data[i].psfNdof;1306 stars[i].measure.psfNpix = ps1data[i].psfNpix;1307 stars[i].measure.extNsigma = ps1data[i].extNsigma;1308 1309 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx);1310 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy);1311 stars[i].measure.theta = ToShortDegrees(ps1data[i].df);1312 1313 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx);1314 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy);1315 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy);1316 1317 stars[i].measure.photFlags = ps1data[i].flags;1318 stars[i].measure.photFlags2 = ps1data[i].flags2;1319 1320 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1321 stars[i].measure.detID = ps1data[i].detID;1292 catalog->measure[i].FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1293 catalog->measure[i].dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, catalog->measure[i].FluxPSF, ps1data[i].dM); 1294 catalog->measure[i].FluxKron = ps1data[i].kronFlux; 1295 catalog->measure[i].dFluxKron = ps1data[i].kronFluxErr; 1296 catalog->measure[i].FluxAp = GetFluxFromFluxOrMag (NAN, ps1data[i].Map); 1297 catalog->measure[i].dFluxAp = GetFluxErrFromFluxOrMag (NAN, catalog->measure[i].FluxAp, catalog->measure[i].dMap); 1298 1299 catalog->measure[i].Sky = ps1data[i].sky; 1300 catalog->measure[i].dSky = ps1data[i].dSky; 1301 1302 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 1303 catalog->measure[i].psfQF = ps1data[i].psfQF; 1304 catalog->measure[i].psfQFperf = ps1data[i].psfQFperf; 1305 1306 catalog->measure[i].psfNdof = ps1data[i].psfNdof; 1307 catalog->measure[i].psfNpix = ps1data[i].psfNpix; 1308 catalog->measure[i].extNsigma = ps1data[i].extNsigma; 1309 1310 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 1311 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 1312 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 1313 1314 catalog->measure[i].Mxx = ToShortPixels(ps1data[i].Mxx); 1315 catalog->measure[i].Mxy = ToShortPixels(ps1data[i].Mxy); 1316 catalog->measure[i].Myy = ToShortPixels(ps1data[i].Myy); 1317 1318 catalog->measure[i].photFlags = ps1data[i].flags; 1319 catalog->measure[i].photFlags2 = ps1data[i].flags2; 1320 1321 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1322 catalog->measure[i].detID = ps1data[i].detID; 1322 1323 1323 1324 // the Average fields and the following Measure fields are set in FilterStars after … … 1327 1328 // the following fields are currently not being set anywhere: t_msec 1328 1329 } 1329 *nstars = Nstars; 1330 return (stars); 1331 } 1332 1333 Stars *Convert_PS1_SV1_Alt (FTable *table, unsigned int *nstars) { 1330 return catalog; 1331 } 1332 1333 Catalog *Convert_PS1_SV1_Alt (FTable *table) { 1334 1334 1335 1335 off_t Nstars; 1336 1336 unsigned int i; 1337 1337 double ZeroPt; 1338 Stars *stars;1339 1338 CMF_PS1_SV1 *ps1data; 1340 1339 1341 1340 // some test output files were produced called CMF_PS1_SV1 but with mismatch byte boundaries 1342 1343 1341 ps1data = gfits_table_get_CMF_PS1_SV1_Alt (table, &Nstars, NULL); 1344 1342 if (!ps1data) { … … 1348 1346 ZeroPt = GetZeroPoint(); 1349 1347 1350 ALLOCATE (stars, Stars,Nstars);1351 for (i = 0; i < Nstars; i++) { 1352 InitStar (&stars[i]);1353 stars[i].measure.Xccd = ps1data[i].X;1354 stars[i].measure.Yccd = ps1data[i].Y;1355 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX);1356 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY);1357 1358 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle);1359 stars[i].measure.pltscale = ps1data[i].pltscale;1348 Catalog *catalog = addstar_catalog_init (Nstars); 1349 1350 for (i = 0; i < Nstars; i++) { 1351 catalog->measure[i].Xccd = ps1data[i].X; 1352 catalog->measure[i].Yccd = ps1data[i].Y; 1353 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 1354 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 1355 1356 catalog->measure[i].posangle = ToShortDegrees(ps1data[i].posangle); 1357 catalog->measure[i].pltscale = ps1data[i].pltscale; 1360 1358 1361 1359 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1362 stars[i].measure.M = NAN;1363 } else { 1364 stars[i].measure.M = ps1data[i].M + ZeroPt;1365 } 1366 stars[i].measure.dM = ps1data[i].dM;1367 stars[i].measure.dMcal = ps1data[i].dMcal;1368 stars[i].measure.Map = ps1data[i].Map + ZeroPt;1369 stars[i].measure.dMap = ps1data[i].dM; // a proxy measure1370 1371 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN;1372 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN;1360 catalog->measure[i].M = NAN; 1361 } else { 1362 catalog->measure[i].M = ps1data[i].M + ZeroPt; 1363 } 1364 catalog->measure[i].dM = ps1data[i].dM; 1365 catalog->measure[i].dMcal = ps1data[i].dMcal; 1366 catalog->measure[i].Map = ps1data[i].Map + ZeroPt; 1367 catalog->measure[i].dMap = ps1data[i].dM; // a proxy measure 1368 1369 catalog->measure[i].Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1370 catalog->measure[i].dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1373 1371 1374 1372 // these fluxes are converted from counts to counts/sec in FilterStars.c 1375 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M);1376 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM);1377 stars[i].measure.FluxKron = ps1data[i].kronFlux;1378 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr;1379 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (NAN, ps1data[i].Map);1380 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (NAN, stars[i].measure.FluxAp, stars[i].measure.dMap);1381 1382 stars[i].measure.Sky = ps1data[i].sky;1383 stars[i].measure.dSky = ps1data[i].dSky;1384 1385 stars[i].measure.psfChisq = ps1data[i].psfChisq;1386 stars[i].measure.psfQF = ps1data[i].psfQF;1387 stars[i].measure.psfNdof = ps1data[i].psfNdof;1388 stars[i].measure.psfNpix = ps1data[i].psfNpix;1389 stars[i].measure.extNsigma = ps1data[i].extNsigma;1390 1391 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx);1392 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy);1393 stars[i].measure.theta = ToShortDegrees(ps1data[i].df);1394 1395 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx);1396 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy);1397 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy);1398 1399 stars[i].measure.photFlags = ps1data[i].flags;1400 stars[i].measure.photFlags2 = ps1data[i].flags2;1401 1402 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1403 stars[i].measure.detID = ps1data[i].detID;1373 catalog->measure[i].FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1374 catalog->measure[i].dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, catalog->measure[i].FluxPSF, ps1data[i].dM); 1375 catalog->measure[i].FluxKron = ps1data[i].kronFlux; 1376 catalog->measure[i].dFluxKron = ps1data[i].kronFluxErr; 1377 catalog->measure[i].FluxAp = GetFluxFromFluxOrMag (NAN, ps1data[i].Map); 1378 catalog->measure[i].dFluxAp = GetFluxErrFromFluxOrMag (NAN, catalog->measure[i].FluxAp, catalog->measure[i].dMap); 1379 1380 catalog->measure[i].Sky = ps1data[i].sky; 1381 catalog->measure[i].dSky = ps1data[i].dSky; 1382 1383 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 1384 catalog->measure[i].psfQF = ps1data[i].psfQF; 1385 catalog->measure[i].psfNdof = ps1data[i].psfNdof; 1386 catalog->measure[i].psfNpix = ps1data[i].psfNpix; 1387 catalog->measure[i].extNsigma = ps1data[i].extNsigma; 1388 1389 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 1390 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 1391 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 1392 1393 catalog->measure[i].Mxx = ToShortPixels(ps1data[i].Mxx); 1394 catalog->measure[i].Mxy = ToShortPixels(ps1data[i].Mxy); 1395 catalog->measure[i].Myy = ToShortPixels(ps1data[i].Myy); 1396 1397 catalog->measure[i].photFlags = ps1data[i].flags; 1398 catalog->measure[i].photFlags2 = ps1data[i].flags2; 1399 1400 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1401 catalog->measure[i].detID = ps1data[i].detID; 1404 1402 1405 1403 // the Average fields and the following Measure fields are set in FilterStars after … … 1409 1407 // the following fields are currently not being set anywhere: t_msec 1410 1408 } 1411 *nstars = Nstars; 1412 return (stars); 1413 } 1414 1415 Stars *Convert_PS1_SV2 (FTable *table, unsigned int *nstars) { 1409 return catalog; 1410 } 1411 1412 Catalog *Convert_PS1_SV2 (FTable *table) { 1416 1413 1417 1414 off_t Nstars; 1418 1415 unsigned int i; 1419 1416 double ZeroPt; 1420 Stars *stars;1421 1417 CMF_PS1_SV2 *ps1data; 1422 1418 … … 1428 1424 ZeroPt = GetZeroPoint(); 1429 1425 1430 ALLOCATE (stars, Stars,Nstars);1431 for (i = 0; i < Nstars; i++) { 1432 InitStar (&stars[i]);1433 stars[i].measure.Xccd = ps1data[i].X;1434 stars[i].measure.Yccd = ps1data[i].Y;1435 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX);1436 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY);1437 1438 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle);1439 stars[i].measure.pltscale = ps1data[i].pltscale;1426 Catalog *catalog = addstar_catalog_init (Nstars); 1427 1428 for (i = 0; i < Nstars; i++) { 1429 catalog->measure[i].Xccd = ps1data[i].X; 1430 catalog->measure[i].Yccd = ps1data[i].Y; 1431 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 1432 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 1433 1434 catalog->measure[i].posangle = ToShortDegrees(ps1data[i].posangle); 1435 catalog->measure[i].pltscale = ps1data[i].pltscale; 1440 1436 1441 1437 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1442 stars[i].measure.M = NAN;1443 } else { 1444 stars[i].measure.M = ps1data[i].M + ZeroPt;1445 } 1446 stars[i].measure.dM = ps1data[i].dM;1447 stars[i].measure.dMcal = ps1data[i].dMcal;1448 stars[i].measure.Map = ps1data[i].Map + ZeroPt;1449 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN;1450 1451 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN;1452 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN;1438 catalog->measure[i].M = NAN; 1439 } else { 1440 catalog->measure[i].M = ps1data[i].M + ZeroPt; 1441 } 1442 catalog->measure[i].dM = ps1data[i].dM; 1443 catalog->measure[i].dMcal = ps1data[i].dMcal; 1444 catalog->measure[i].Map = ps1data[i].Map + ZeroPt; 1445 catalog->measure[i].dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 1446 1447 catalog->measure[i].Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1448 catalog->measure[i].dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1453 1449 1454 1450 // these fluxes are converted from counts to counts/sec in FilterStars.c 1455 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M);1456 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM);1457 stars[i].measure.FluxKron = ps1data[i].kronFlux;1458 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr;1459 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map);1460 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap);1461 1462 stars[i].measure.Sky = ps1data[i].sky;1463 stars[i].measure.dSky = ps1data[i].dSky;1464 1465 stars[i].measure.psfChisq = ps1data[i].psfChisq;1466 stars[i].measure.psfQF = ps1data[i].psfQF;1467 stars[i].measure.psfQFperf = ps1data[i].psfQFperf;1468 1469 stars[i].measure.psfNdof = ps1data[i].psfNdof;1470 stars[i].measure.psfNpix = ps1data[i].psfNpix;1471 stars[i].measure.extNsigma = ps1data[i].extNsigma;1472 1473 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx);1474 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy);1475 stars[i].measure.theta = ToShortDegrees(ps1data[i].df);1476 1477 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx);1478 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy);1479 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy);1480 1481 stars[i].measure.photFlags = ps1data[i].flags;1482 stars[i].measure.photFlags2 = ps1data[i].flags2;1483 1484 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1485 stars[i].measure.detID = ps1data[i].detID;1451 catalog->measure[i].FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1452 catalog->measure[i].dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, catalog->measure[i].FluxPSF, ps1data[i].dM); 1453 catalog->measure[i].FluxKron = ps1data[i].kronFlux; 1454 catalog->measure[i].dFluxKron = ps1data[i].kronFluxErr; 1455 catalog->measure[i].FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1456 catalog->measure[i].dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, catalog->measure[i].FluxAp, catalog->measure[i].dMap); 1457 1458 catalog->measure[i].Sky = ps1data[i].sky; 1459 catalog->measure[i].dSky = ps1data[i].dSky; 1460 1461 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 1462 catalog->measure[i].psfQF = ps1data[i].psfQF; 1463 catalog->measure[i].psfQFperf = ps1data[i].psfQFperf; 1464 1465 catalog->measure[i].psfNdof = ps1data[i].psfNdof; 1466 catalog->measure[i].psfNpix = ps1data[i].psfNpix; 1467 catalog->measure[i].extNsigma = ps1data[i].extNsigma; 1468 1469 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 1470 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 1471 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 1472 1473 catalog->measure[i].Mxx = ToShortPixels(ps1data[i].Mxx); 1474 catalog->measure[i].Mxy = ToShortPixels(ps1data[i].Mxy); 1475 catalog->measure[i].Myy = ToShortPixels(ps1data[i].Myy); 1476 1477 catalog->measure[i].photFlags = ps1data[i].flags; 1478 catalog->measure[i].photFlags2 = ps1data[i].flags2; 1479 1480 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1481 catalog->measure[i].detID = ps1data[i].detID; 1486 1482 1487 1483 // the Average fields and the following Measure fields are set in FilterStars after … … 1491 1487 // the following fields are currently not being set anywhere: t_msec 1492 1488 } 1493 *nstars = Nstars; 1494 return (stars); 1495 } 1496 1497 Stars *Convert_PS1_SV3 (FTable *table, unsigned int *nstars) { 1489 return catalog; 1490 } 1491 1492 Catalog *Convert_PS1_SV3 (FTable *table) { 1498 1493 1499 1494 off_t Nstars; 1500 1495 unsigned int i; 1501 1496 double ZeroPt; 1502 Stars *stars;1503 1497 CMF_PS1_SV3 *ps1data; 1504 1498 … … 1510 1504 ZeroPt = GetZeroPoint(); 1511 1505 1512 ALLOCATE (stars, Stars,Nstars);1513 for (i = 0; i < Nstars; i++) { 1514 InitStar (&stars[i]);1515 stars[i].measure.Xccd = ps1data[i].X;1516 stars[i].measure.Yccd = ps1data[i].Y;1517 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX);1518 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY);1519 1520 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle);1521 stars[i].measure.pltscale = ps1data[i].pltscale;1506 Catalog *catalog = addstar_catalog_init (Nstars); 1507 1508 for (i = 0; i < Nstars; i++) { 1509 catalog->measure[i].Xccd = ps1data[i].X; 1510 catalog->measure[i].Yccd = ps1data[i].Y; 1511 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 1512 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 1513 1514 catalog->measure[i].posangle = ToShortDegrees(ps1data[i].posangle); 1515 catalog->measure[i].pltscale = ps1data[i].pltscale; 1522 1516 1523 1517 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1524 stars[i].measure.M = NAN;1525 } else { 1526 stars[i].measure.M = ps1data[i].M + ZeroPt;1527 } 1528 stars[i].measure.dM = ps1data[i].dM;1529 stars[i].measure.dMcal = ps1data[i].dMcal;1530 stars[i].measure.Map = ps1data[i].Map + ZeroPt;1531 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN;1532 1533 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN;1534 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN;1518 catalog->measure[i].M = NAN; 1519 } else { 1520 catalog->measure[i].M = ps1data[i].M + ZeroPt; 1521 } 1522 catalog->measure[i].dM = ps1data[i].dM; 1523 catalog->measure[i].dMcal = ps1data[i].dMcal; 1524 catalog->measure[i].Map = ps1data[i].Map + ZeroPt; 1525 catalog->measure[i].dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 1526 1527 catalog->measure[i].Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1528 catalog->measure[i].dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1535 1529 1536 1530 // these fluxes are converted from counts to counts/sec in FilterStars.c 1537 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M);1538 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM);1539 stars[i].measure.FluxKron = ps1data[i].kronFlux;1540 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr;1541 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map);1542 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap);1543 1544 stars[i].measure.Sky = ps1data[i].sky;1545 stars[i].measure.dSky = ps1data[i].dSky;1546 1547 stars[i].measure.psfChisq = ps1data[i].psfChisq;1548 stars[i].measure.psfQF = ps1data[i].psfQF;1549 stars[i].measure.psfQFperf = ps1data[i].psfQFperf;1550 1551 stars[i].measure.psfNdof = ps1data[i].psfNdof;1552 stars[i].measure.psfNpix = ps1data[i].psfNpix;1553 stars[i].measure.extNsigma = ps1data[i].extNsigma;1554 1555 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx);1556 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy);1557 stars[i].measure.theta = ToShortDegrees(ps1data[i].df);1558 1559 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx);1560 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy);1561 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy);1562 1563 stars[i].measure.photFlags = ps1data[i].flags;1564 stars[i].measure.photFlags2 = ps1data[i].flags2;1565 1566 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1567 stars[i].measure.detID = ps1data[i].detID;1531 catalog->measure[i].FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1532 catalog->measure[i].dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, catalog->measure[i].FluxPSF, ps1data[i].dM); 1533 catalog->measure[i].FluxKron = ps1data[i].kronFlux; 1534 catalog->measure[i].dFluxKron = ps1data[i].kronFluxErr; 1535 catalog->measure[i].FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1536 catalog->measure[i].dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, catalog->measure[i].FluxAp, catalog->measure[i].dMap); 1537 1538 catalog->measure[i].Sky = ps1data[i].sky; 1539 catalog->measure[i].dSky = ps1data[i].dSky; 1540 1541 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 1542 catalog->measure[i].psfQF = ps1data[i].psfQF; 1543 catalog->measure[i].psfQFperf = ps1data[i].psfQFperf; 1544 1545 catalog->measure[i].psfNdof = ps1data[i].psfNdof; 1546 catalog->measure[i].psfNpix = ps1data[i].psfNpix; 1547 catalog->measure[i].extNsigma = ps1data[i].extNsigma; 1548 1549 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 1550 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 1551 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 1552 1553 catalog->measure[i].Mxx = ToShortPixels(ps1data[i].Mxx); 1554 catalog->measure[i].Mxy = ToShortPixels(ps1data[i].Mxy); 1555 catalog->measure[i].Myy = ToShortPixels(ps1data[i].Myy); 1556 1557 catalog->measure[i].photFlags = ps1data[i].flags; 1558 catalog->measure[i].photFlags2 = ps1data[i].flags2; 1559 1560 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1561 catalog->measure[i].detID = ps1data[i].detID; 1568 1562 1569 1563 // the Average fields and the following Measure fields are set in FilterStars after … … 1573 1567 // the following fields are currently not being set anywhere: t_msec 1574 1568 } 1575 *nstars = Nstars; 1576 return (stars); 1577 } 1578 1579 Stars *Convert_PS1_SV4 (FTable *table, unsigned int *nstars) { 1569 return catalog; 1570 } 1571 1572 Catalog *Convert_PS1_SV4 (FTable *table) { 1580 1573 1581 1574 off_t Nstars; 1582 1575 unsigned int i; 1583 1576 double ZeroPt; 1584 Stars *stars;1585 1577 CMF_PS1_SV4 *ps1data; 1586 1578 … … 1592 1584 ZeroPt = GetZeroPoint(); 1593 1585 1594 ALLOCATE (stars, Stars,Nstars);1595 for (i = 0; i < Nstars; i++) { 1596 InitStar (&stars[i]);1597 stars[i].measure.Xccd = ps1data[i].X;1598 stars[i].measure.Yccd = ps1data[i].Y;1599 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX);1600 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY);1601 1602 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle);1603 stars[i].measure.pltscale = ps1data[i].pltscale;1586 Catalog *catalog = addstar_catalog_init (Nstars); 1587 1588 for (i = 0; i < Nstars; i++) { 1589 catalog->measure[i].Xccd = ps1data[i].X; 1590 catalog->measure[i].Yccd = ps1data[i].Y; 1591 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 1592 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 1593 1594 catalog->measure[i].posangle = ToShortDegrees(ps1data[i].posangle); 1595 catalog->measure[i].pltscale = ps1data[i].pltscale; 1604 1596 1605 1597 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1606 stars[i].measure.M = NAN;1607 } else { 1608 stars[i].measure.M = ps1data[i].M + ZeroPt;1609 } 1610 stars[i].measure.dM = ps1data[i].dM;1611 stars[i].measure.dMcal = ps1data[i].dMcal;1612 stars[i].measure.Map = ps1data[i].Map + ZeroPt;1613 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN;1614 1615 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN;1616 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN;1598 catalog->measure[i].M = NAN; 1599 } else { 1600 catalog->measure[i].M = ps1data[i].M + ZeroPt; 1601 } 1602 catalog->measure[i].dM = ps1data[i].dM; 1603 catalog->measure[i].dMcal = ps1data[i].dMcal; 1604 catalog->measure[i].Map = ps1data[i].Map + ZeroPt; 1605 catalog->measure[i].dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 1606 1607 catalog->measure[i].Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1608 catalog->measure[i].dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1617 1609 1618 1610 // these fluxes are converted from counts to counts/sec in FilterStars.c 1619 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M);1620 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM);1621 stars[i].measure.FluxKron = ps1data[i].kronFlux;1622 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr;1623 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map);1624 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap);1625 1626 stars[i].measure.Sky = ps1data[i].sky;1627 stars[i].measure.dSky = ps1data[i].dSky;1628 1629 stars[i].measure.psfChisq = ps1data[i].psfChisq;1630 stars[i].measure.psfQF = ps1data[i].psfQF;1631 stars[i].measure.psfQFperf = ps1data[i].psfQFperf;1632 1633 stars[i].measure.psfNdof = ps1data[i].psfNdof;1634 stars[i].measure.psfNpix = ps1data[i].psfNpix;1635 stars[i].measure.extNsigma = ps1data[i].extNsigma;1636 1637 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx);1638 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy);1639 stars[i].measure.theta = ToShortDegrees(ps1data[i].df);1640 1641 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx);1642 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy);1643 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy);1644 1645 stars[i].measure.photFlags = ps1data[i].flags;1646 stars[i].measure.photFlags2 = ps1data[i].flags2;1647 1648 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1649 stars[i].measure.detID = ps1data[i].detID;1611 catalog->measure[i].FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1612 catalog->measure[i].dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, catalog->measure[i].FluxPSF, ps1data[i].dM); 1613 catalog->measure[i].FluxKron = ps1data[i].kronFlux; 1614 catalog->measure[i].dFluxKron = ps1data[i].kronFluxErr; 1615 catalog->measure[i].FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1616 catalog->measure[i].dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, catalog->measure[i].FluxAp, catalog->measure[i].dMap); 1617 1618 catalog->measure[i].Sky = ps1data[i].sky; 1619 catalog->measure[i].dSky = ps1data[i].dSky; 1620 1621 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 1622 catalog->measure[i].psfQF = ps1data[i].psfQF; 1623 catalog->measure[i].psfQFperf = ps1data[i].psfQFperf; 1624 1625 catalog->measure[i].psfNdof = ps1data[i].psfNdof; 1626 catalog->measure[i].psfNpix = ps1data[i].psfNpix; 1627 catalog->measure[i].extNsigma = ps1data[i].extNsigma; 1628 1629 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 1630 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 1631 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 1632 1633 catalog->measure[i].Mxx = ToShortPixels(ps1data[i].Mxx); 1634 catalog->measure[i].Mxy = ToShortPixels(ps1data[i].Mxy); 1635 catalog->measure[i].Myy = ToShortPixels(ps1data[i].Myy); 1636 1637 catalog->measure[i].photFlags = ps1data[i].flags; 1638 catalog->measure[i].photFlags2 = ps1data[i].flags2; 1639 1640 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1641 catalog->measure[i].detID = ps1data[i].detID; 1650 1642 1651 1643 // the Average fields and the following Measure fields are set in FilterStars after … … 1655 1647 // the following fields are currently not being set anywhere: t_msec 1656 1648 } 1657 *nstars = Nstars; 1658 return (stars); 1659 } 1660 1661 Stars *Convert_PS1_DV3 (FTable *table, unsigned int *nstars) { 1649 return catalog; 1650 } 1651 1652 Catalog *Convert_PS1_DV3 (FTable *table) { 1662 1653 1663 1654 off_t Nstars; 1664 1655 unsigned int i; 1665 1656 double ZeroPt; 1666 Stars *stars;1667 1657 CMF_PS1_DV3 *ps1data; 1668 1658 … … 1674 1664 ZeroPt = GetZeroPoint(); 1675 1665 1676 ALLOCATE (stars, Stars,Nstars);1677 for (i = 0; i < Nstars; i++) { 1678 InitStar (&stars[i]);1679 stars[i].measure.Xccd = ps1data[i].X;1680 stars[i].measure.Yccd = ps1data[i].Y;1681 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX);1682 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY);1683 1684 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle);1685 stars[i].measure.pltscale = ps1data[i].pltscale;1666 Catalog *catalog = addstar_catalog_init (Nstars); 1667 1668 for (i = 0; i < Nstars; i++) { 1669 catalog->measure[i].Xccd = ps1data[i].X; 1670 catalog->measure[i].Yccd = ps1data[i].Y; 1671 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 1672 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 1673 1674 catalog->measure[i].posangle = ToShortDegrees(ps1data[i].posangle); 1675 catalog->measure[i].pltscale = ps1data[i].pltscale; 1686 1676 1687 1677 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1688 stars[i].measure.M = NAN;1689 } else { 1690 stars[i].measure.M = ps1data[i].M + ZeroPt;1691 } 1692 stars[i].measure.dM = ps1data[i].dM;1693 stars[i].measure.dMcal = ps1data[i].dMcal;1694 stars[i].measure.Map = ps1data[i].Map + ZeroPt;1695 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN;1696 1697 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN;1698 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN;1678 catalog->measure[i].M = NAN; 1679 } else { 1680 catalog->measure[i].M = ps1data[i].M + ZeroPt; 1681 } 1682 catalog->measure[i].dM = ps1data[i].dM; 1683 catalog->measure[i].dMcal = ps1data[i].dMcal; 1684 catalog->measure[i].Map = ps1data[i].Map + ZeroPt; 1685 catalog->measure[i].dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 1686 1687 catalog->measure[i].Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1688 catalog->measure[i].dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1699 1689 1700 1690 // these fluxes are converted from counts to counts/sec in FilterStars.c 1701 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M);1702 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM);1703 stars[i].measure.FluxKron = ps1data[i].kronFlux;1704 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr;1705 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map);1706 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap);1707 1708 stars[i].measure.Sky = ps1data[i].sky;1709 stars[i].measure.dSky = ps1data[i].dSky;1710 1711 stars[i].measure.psfChisq = ps1data[i].psfChisq;1712 stars[i].measure.psfQF = ps1data[i].psfQF;1713 stars[i].measure.psfQFperf = ps1data[i].psfQFperf;1714 stars[i].measure.psfNdof = ps1data[i].psfNdof;1715 stars[i].measure.psfNpix = ps1data[i].psfNpix;1716 stars[i].measure.extNsigma = ps1data[i].extNsigma;1717 1718 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx);1719 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy);1720 stars[i].measure.theta = ToShortDegrees(ps1data[i].df);1721 1722 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx);1723 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy);1724 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy);1725 1726 stars[i].measure.photFlags = ps1data[i].flags;1727 stars[i].measure.photFlags2 = ps1data[i].flags2;1728 1729 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1730 stars[i].measure.detID = ps1data[i].detID;1691 catalog->measure[i].FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1692 catalog->measure[i].dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, catalog->measure[i].FluxPSF, ps1data[i].dM); 1693 catalog->measure[i].FluxKron = ps1data[i].kronFlux; 1694 catalog->measure[i].dFluxKron = ps1data[i].kronFluxErr; 1695 catalog->measure[i].FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1696 catalog->measure[i].dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, catalog->measure[i].FluxAp, catalog->measure[i].dMap); 1697 1698 catalog->measure[i].Sky = ps1data[i].sky; 1699 catalog->measure[i].dSky = ps1data[i].dSky; 1700 1701 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 1702 catalog->measure[i].psfQF = ps1data[i].psfQF; 1703 catalog->measure[i].psfQFperf = ps1data[i].psfQFperf; 1704 catalog->measure[i].psfNdof = ps1data[i].psfNdof; 1705 catalog->measure[i].psfNpix = ps1data[i].psfNpix; 1706 catalog->measure[i].extNsigma = ps1data[i].extNsigma; 1707 1708 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 1709 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 1710 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 1711 1712 catalog->measure[i].Mxx = ToShortPixels(ps1data[i].Mxx); 1713 catalog->measure[i].Mxy = ToShortPixels(ps1data[i].Mxy); 1714 catalog->measure[i].Myy = ToShortPixels(ps1data[i].Myy); 1715 1716 catalog->measure[i].photFlags = ps1data[i].flags; 1717 catalog->measure[i].photFlags2 = ps1data[i].flags2; 1718 1719 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1720 catalog->measure[i].detID = ps1data[i].detID; 1731 1721 1732 1722 // the Average fields and the following Measure fields are set in FilterStars after … … 1739 1729 // the following fields are currently not being set anywhere: t_msec 1740 1730 } 1741 *nstars = Nstars; 1742 return (stars); 1743 } 1744 1745 Stars *Convert_PS1_DV4 (FTable *table, unsigned int *nstars) { 1731 return catalog; 1732 } 1733 1734 Catalog *Convert_PS1_DV4 (FTable *table) { 1746 1735 1747 1736 off_t Nstars; 1748 1737 unsigned int i; 1749 1738 double ZeroPt; 1750 Stars *stars;1751 1739 CMF_PS1_DV4 *ps1data; 1752 1740 … … 1760 1748 fprintf (stderr, "WARNING: Convert_PS1_DV4 not yet updated to match real format\n"); 1761 1749 1762 ALLOCATE (stars, Stars,Nstars);1763 for (i = 0; i < Nstars; i++) { 1764 InitStar (&stars[i]);1765 stars[i].measure.Xccd = ps1data[i].X;1766 stars[i].measure.Yccd = ps1data[i].Y;1767 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX);1768 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY);1769 1770 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle);1771 stars[i].measure.pltscale = ps1data[i].pltscale;1750 Catalog *catalog = addstar_catalog_init (Nstars); 1751 1752 for (i = 0; i < Nstars; i++) { 1753 catalog->measure[i].Xccd = ps1data[i].X; 1754 catalog->measure[i].Yccd = ps1data[i].Y; 1755 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 1756 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 1757 1758 catalog->measure[i].posangle = ToShortDegrees(ps1data[i].posangle); 1759 catalog->measure[i].pltscale = ps1data[i].pltscale; 1772 1760 1773 1761 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1774 stars[i].measure.M = NAN;1775 } else { 1776 stars[i].measure.M = ps1data[i].M + ZeroPt;1777 } 1778 stars[i].measure.dM = ps1data[i].dM;1779 stars[i].measure.dMcal = ps1data[i].dMcal;1780 stars[i].measure.Map = ps1data[i].Map + ZeroPt;1781 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN;1782 1783 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN;1784 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN;1762 catalog->measure[i].M = NAN; 1763 } else { 1764 catalog->measure[i].M = ps1data[i].M + ZeroPt; 1765 } 1766 catalog->measure[i].dM = ps1data[i].dM; 1767 catalog->measure[i].dMcal = ps1data[i].dMcal; 1768 catalog->measure[i].Map = ps1data[i].Map + ZeroPt; 1769 catalog->measure[i].dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 1770 1771 catalog->measure[i].Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1772 catalog->measure[i].dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1785 1773 1786 1774 // these fluxes are converted from counts to counts/sec in FilterStars.c 1787 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M);1788 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM);1789 stars[i].measure.FluxKron = ps1data[i].kronFlux;1790 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr;1791 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map);1792 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap);1793 1794 stars[i].measure.Sky = ps1data[i].sky;1795 stars[i].measure.dSky = ps1data[i].dSky;1796 1797 stars[i].measure.psfChisq = ps1data[i].psfChisq;1798 stars[i].measure.psfQF = ps1data[i].psfQF;1799 stars[i].measure.psfQFperf = ps1data[i].psfQFperf;1800 stars[i].measure.psfNdof = ps1data[i].psfNdof;1801 stars[i].measure.psfNpix = ps1data[i].psfNpix;1802 stars[i].measure.extNsigma = ps1data[i].extNsigma;1803 1804 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx);1805 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy);1806 stars[i].measure.theta = ToShortDegrees(ps1data[i].df);1807 1808 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx);1809 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy);1810 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy);1811 1812 stars[i].measure.photFlags = ps1data[i].flags;1813 stars[i].measure.photFlags2 = ps1data[i].flags2;1814 1815 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1816 stars[i].measure.detID = ps1data[i].detID;1775 catalog->measure[i].FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1776 catalog->measure[i].dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, catalog->measure[i].FluxPSF, ps1data[i].dM); 1777 catalog->measure[i].FluxKron = ps1data[i].kronFlux; 1778 catalog->measure[i].dFluxKron = ps1data[i].kronFluxErr; 1779 catalog->measure[i].FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1780 catalog->measure[i].dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, catalog->measure[i].FluxAp, catalog->measure[i].dMap); 1781 1782 catalog->measure[i].Sky = ps1data[i].sky; 1783 catalog->measure[i].dSky = ps1data[i].dSky; 1784 1785 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 1786 catalog->measure[i].psfQF = ps1data[i].psfQF; 1787 catalog->measure[i].psfQFperf = ps1data[i].psfQFperf; 1788 catalog->measure[i].psfNdof = ps1data[i].psfNdof; 1789 catalog->measure[i].psfNpix = ps1data[i].psfNpix; 1790 catalog->measure[i].extNsigma = ps1data[i].extNsigma; 1791 1792 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 1793 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 1794 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 1795 1796 catalog->measure[i].Mxx = ToShortPixels(ps1data[i].Mxx); 1797 catalog->measure[i].Mxy = ToShortPixels(ps1data[i].Mxy); 1798 catalog->measure[i].Myy = ToShortPixels(ps1data[i].Myy); 1799 1800 catalog->measure[i].photFlags = ps1data[i].flags; 1801 catalog->measure[i].photFlags2 = ps1data[i].flags2; 1802 1803 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1804 catalog->measure[i].detID = ps1data[i].detID; 1817 1805 1818 1806 // the Average fields and the following Measure fields are set in FilterStars after … … 1825 1813 // the following fields are currently not being set anywhere: t_msec 1826 1814 } 1827 *nstars = Nstars; 1828 return (stars); 1829 } 1830 1831 Stars *Convert_PS1_DV5 (FTable *table, unsigned int *nstars) { 1815 return catalog; 1816 } 1817 1818 Catalog *Convert_PS1_DV5 (FTable *table) { 1832 1819 1833 1820 off_t Nstars; 1834 1821 unsigned int i; 1835 1822 double ZeroPt; 1836 Stars *stars;1837 1823 CMF_PS1_DV5 *ps1data; 1838 1824 … … 1844 1830 ZeroPt = GetZeroPoint(); 1845 1831 1846 ALLOCATE (stars, Stars,Nstars);1847 for (i = 0; i < Nstars; i++) { 1848 InitStar (&stars[i]);1849 stars[i].measure.Xccd = ps1data[i].X;1850 stars[i].measure.Yccd = ps1data[i].Y;1851 stars[i].measure.dXccd = ToShortPixels(ps1data[i].dX);1852 stars[i].measure.dYccd = ToShortPixels(ps1data[i].dY);1853 1854 stars[i].measure.posangle = ToShortDegrees(ps1data[i].posangle);1855 stars[i].measure.pltscale = ps1data[i].pltscale;1832 Catalog *catalog = addstar_catalog_init (Nstars); 1833 1834 for (i = 0; i < Nstars; i++) { 1835 catalog->measure[i].Xccd = ps1data[i].X; 1836 catalog->measure[i].Yccd = ps1data[i].Y; 1837 catalog->measure[i].dXccd = ToShortPixels(ps1data[i].dX); 1838 catalog->measure[i].dYccd = ToShortPixels(ps1data[i].dY); 1839 1840 catalog->measure[i].posangle = ToShortDegrees(ps1data[i].posangle); 1841 catalog->measure[i].pltscale = ps1data[i].pltscale; 1856 1842 1857 1843 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 1858 stars[i].measure.M = NAN;1859 } else { 1860 stars[i].measure.M = ps1data[i].M + ZeroPt;1861 } 1862 stars[i].measure.dM = ps1data[i].dM;1863 stars[i].measure.dMcal = ps1data[i].dMcal;1864 stars[i].measure.Map = ps1data[i].Map + ZeroPt;1865 stars[i].measure.dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN;1866 1867 stars[i].measure.Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN;1868 stars[i].measure.dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN;1844 catalog->measure[i].M = NAN; 1845 } else { 1846 catalog->measure[i].M = ps1data[i].M + ZeroPt; 1847 } 1848 catalog->measure[i].dM = ps1data[i].dM; 1849 catalog->measure[i].dMcal = ps1data[i].dMcal; 1850 catalog->measure[i].Map = ps1data[i].Map + ZeroPt; 1851 catalog->measure[i].dMap = (ps1data[i].apFlux > 0.0) ? fabs(ps1data[i].apFluxErr / ps1data[i].apFlux) : NAN; 1852 1853 catalog->measure[i].Mkron = (ps1data[i].kronFlux > 0.0) ? -2.5*log10(ps1data[i].kronFlux) + ZeroPt : NAN; 1854 catalog->measure[i].dMkron = (ps1data[i].kronFlux > 0.0) ? ps1data[i].kronFluxErr / ps1data[i].kronFlux : NAN; 1869 1855 1870 1856 // these fluxes are converted from counts to counts/sec in FilterStars.c 1871 stars[i].measure.FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M);1872 stars[i].measure.dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, stars[i].measure.FluxPSF, ps1data[i].dM);1873 stars[i].measure.FluxKron = ps1data[i].kronFlux;1874 stars[i].measure.dFluxKron = ps1data[i].kronFluxErr;1875 stars[i].measure.FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map);1876 stars[i].measure.dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, stars[i].measure.FluxAp, stars[i].measure.dMap);1877 1878 stars[i].measure.Sky = ps1data[i].sky;1879 stars[i].measure.dSky = ps1data[i].dSky;1880 1881 stars[i].measure.psfChisq = ps1data[i].psfChisq;1882 stars[i].measure.psfQF = ps1data[i].psfQF;1883 stars[i].measure.psfQFperf = ps1data[i].psfQFperf;1884 stars[i].measure.psfNdof = ps1data[i].psfNdof;1885 stars[i].measure.psfNpix = ps1data[i].psfNpix;1886 stars[i].measure.extNsigma = ps1data[i].extNsigma;1887 1888 stars[i].measure.FWx = ToShortPixels(ps1data[i].fx);1889 stars[i].measure.FWy = ToShortPixels(ps1data[i].fy);1890 stars[i].measure.theta = ToShortDegrees(ps1data[i].df);1891 1892 stars[i].measure.Mxx = ToShortPixels(ps1data[i].Mxx);1893 stars[i].measure.Mxy = ToShortPixels(ps1data[i].Mxy);1894 stars[i].measure.Myy = ToShortPixels(ps1data[i].Myy);1895 1896 stars[i].measure.photFlags = ps1data[i].flags;1897 stars[i].measure.photFlags2 = ps1data[i].flags2;1898 1899 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1900 stars[i].measure.detID = ps1data[i].detID;1857 catalog->measure[i].FluxPSF = GetFluxFromFluxOrMag (ps1data[i].Flux, ps1data[i].M); 1858 catalog->measure[i].dFluxPSF = GetFluxErrFromFluxOrMag (ps1data[i].dFlux, catalog->measure[i].FluxPSF, ps1data[i].dM); 1859 catalog->measure[i].FluxKron = ps1data[i].kronFlux; 1860 catalog->measure[i].dFluxKron = ps1data[i].kronFluxErr; 1861 catalog->measure[i].FluxAp = GetFluxFromFluxOrMag (ps1data[i].apFlux, ps1data[i].Map); 1862 catalog->measure[i].dFluxAp = GetFluxErrFromFluxOrMag (ps1data[i].apFluxErr, catalog->measure[i].FluxAp, catalog->measure[i].dMap); 1863 1864 catalog->measure[i].Sky = ps1data[i].sky; 1865 catalog->measure[i].dSky = ps1data[i].dSky; 1866 1867 catalog->measure[i].psfChisq = ps1data[i].psfChisq; 1868 catalog->measure[i].psfQF = ps1data[i].psfQF; 1869 catalog->measure[i].psfQFperf = ps1data[i].psfQFperf; 1870 catalog->measure[i].psfNdof = ps1data[i].psfNdof; 1871 catalog->measure[i].psfNpix = ps1data[i].psfNpix; 1872 catalog->measure[i].extNsigma = ps1data[i].extNsigma; 1873 1874 catalog->measure[i].FWx = ToShortPixels(ps1data[i].fx); 1875 catalog->measure[i].FWy = ToShortPixels(ps1data[i].fy); 1876 catalog->measure[i].theta = ToShortDegrees(ps1data[i].df); 1877 1878 catalog->measure[i].Mxx = ToShortPixels(ps1data[i].Mxx); 1879 catalog->measure[i].Mxy = ToShortPixels(ps1data[i].Mxy); 1880 catalog->measure[i].Myy = ToShortPixels(ps1data[i].Myy); 1881 1882 catalog->measure[i].photFlags = ps1data[i].flags; 1883 catalog->measure[i].photFlags2 = ps1data[i].flags2; 1884 1885 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 1886 catalog->measure[i].detID = ps1data[i].detID; 1901 1887 1902 1888 // the Average fields and the following Measure fields are set in FilterStars after … … 1909 1895 // the following fields are currently not being set anywhere: t_msec 1910 1896 } 1911 *nstars = Nstars; 1912 return (stars); 1913 } 1914 1915 1916 1897 return catalog; 1898 } -
trunk/Ohana/src/addstar/src/ReadStarsSDSS.c
r38467 r38553 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 -
trunk/Ohana/src/addstar/src/ReadStarsUKIRT.c
r38467 r38553 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 *name, 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 18 // ohana_memcheck_func (TRUE); 19 16 20 17 // the FITS binary table header is the same as the image header 21 18 table.header = header; … … 30 27 exit (1); 31 28 } 32 33 // ohana_memcheck_func (TRUE);34 29 35 30 Coords coords; … … 110 105 } 111 106 112 // ohana_memcheck _func(TRUE);107 // ohana_memcheck (TRUE); 113 108 114 109 double mjd; … … 129 124 float ZeroPt = GetZeroPoint(); 130 125 131 // ohana_memcheck _func(TRUE);126 // ohana_memcheck (TRUE); 132 127 133 128 // create a Star entry for each filter and detection 134 129 int Nstars = table.header[0].Naxis[1]; 135 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 } 136 143 137 144 GET_COLUMN (X_coordinate, float); … … 155 162 double R, D, alt, az; 156 163 157 // ohana_memcheck_func (TRUE); 158 159 int i; 164 // ohana_memcheck (TRUE); 165 160 166 for (i = 0; i < Nstars; i++) { 161 InitStar (&stars[i]); 162 167 163 168 // any values not explicitly set are left at 0.0 164 169 XY_to_RD (&R, &D, X_coordinate[i], Y_coordinate[i], &coords); 165 170 166 stars[i].average.R = R; 167 stars[i].average.D = D; 168 stars[i].average.dR = NAN; 169 stars[i].average.dD = NAN; 170 171 stars[i].measure.R = stars[i].average.R; 172 stars[i].measure.D = stars[i].average.D; 173 stars[i].measure.Xccd = X_coordinate[i]; 174 stars[i].measure.Yccd = Y_coordinate[i]; 175 stars[i].measure.dXccd = ToShortPixels(X_coordinate_err[i]); 176 stars[i].measure.dYccd = ToShortPixels(Y_coordinate_err[i]); 177 178 stars[i].measure.M = -2.5*log10(Aper_flux_4[i]) + ZeroPt + magtime + ApCor4; 179 stars[i].measure.dM = Aper_flux_4_err[i] / Aper_flux_4[i]; 180 stars[i].measure.Map = -2.5*log10(Aper_flux_7[i]) + ZeroPt + magtime + ApCor7; 181 stars[i].measure.dMap = Aper_flux_7_err[i] / Aper_flux_7[i]; 182 stars[i].measure.Mkron = -2.5*log10(Kron_flux[i]) + ZeroPt + magtime; 183 stars[i].measure.dMkron = Kron_flux_err[i] / Kron_flux[i]; 184 stars[i].measure.Sky = Sky_level[i]; // adjust this to counts? 185 stars[i].measure.dSky = Sky_rms[i]; 186 stars[i].measure.FWx = ToShortPixels(seeing); // reported in arcsec? 187 stars[i].measure.FWy = ToShortPixels(seeing); 188 189 stars[i].measure.Mcal = Mcal; 190 191 stars[i].measure.detID = i; 192 stars[i].measure.t = tzero; // time since row 0 193 stars[i].measure.dt = magtime; // 2.5 * log(exptime) 194 195 altaz (&alt, &az, sidtime_deg - stars[i].average.R, stars[i].average.D, Latitude); 196 197 stars[i].measure.airmass = 1.0 / dCOS(90.0 - alt); 198 stars[i].measure.az = az; 199 stars[i].measure.photcode = photcode; 200 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 201 208 } 202 209 … … 204 211 int N = *nimages; 205 212 206 // ohana_memcheck _func(TRUE);213 // ohana_memcheck (TRUE); 207 214 208 215 images[N].coords = coords; … … 254 261 255 262 // save the filename 256 snprintf (images[N].name, DVO_IMAGE_NAME_LEN, "%s[%02d]", name, detID);263 snprintf (images[N].name, DVO_IMAGE_NAME_LEN, "%s[%02d]", imagename, detID); 257 264 *nimages = N + 1; 258 265 } 259 266 260 // ohana_memcheck_func (TRUE); 261 262 *nstars = Nstars; 263 return (stars); 267 // ohana_memcheck (TRUE); 268 269 return (catalog); 264 270 } -
trunk/Ohana/src/addstar/src/ReadXradFITS.c
r38153 r38553 3 3 // given a file with the pointer at the start of the table block and the 4 4 // corresponding image header, load the xrad data from the table 5 int ReadXradFITS (FILE *f, Header *theader, Stars *stars, unsigned int Nstars) {5 int ReadXradFITS (FILE *f, Header *theader, Catalog *catalog) { 6 6 7 7 FTable table; … … 51 51 myAssert (Nrow == NrowAlt, "column mismatch?"); 52 52 53 if (Nrow > Nstars) {53 if (Nrow > catalog->Nmeasure) { 54 54 myAbort("more radial measurements than stars? seems like a bug\n"); 55 55 } 56 56 57 myAssert (catalog->lensing, "lensing is not allocated"); 58 // we could allocate here, or just insist this is an error? 59 // if (!catalog->lensing) { 60 // ALLOCATE (catalog->lensing, Lensing, catalog->Nmeasure); 61 // } 62 57 63 int i; 58 64 int Nap = 0; 59 for (i = 0; i < Nstars; i++) {60 if ( stars[i].measure.detID < RadID[Nap]) {61 continue; // this star does not have an aperture65 for (i = 0; i < catalog->Nmeasure; i++) { 66 if (catalog->measure[i].detID < RadID[Nap]) { 67 myAbort("star without radial aperture, seems like a bug"); // this star does not have an aperture 62 68 } 63 if ( stars[i].measure.detID > RadID[Nap]) {69 if (catalog->measure[i].detID > RadID[Nap]) { 64 70 myAbort("radial apertures out of order? seems like a bug\n"); 65 71 } 66 72 67 // we could allocate here, or just insist this is an error? 68 if (!stars[i].lensing) { 69 fprintf (stderr, "!"); 70 ALLOCATE (stars[i].lensing, Lensing, 1); 71 dvo_lensing_init (stars[i].lensing); 72 } 73 // we assumed we have already set up lensing in ReadStarsFITS.c 73 74 74 75 // XXX this is all hard-wired and should make use of the headers. … … 77 78 // SDSS 3, 4, 5, 6, 7 78 79 79 stars[i].lensing->F_ApR5 = AperFlux [Nap*Ncol + 2];80 stars[i].lensing->dF_ApR5 = AperFluxErr[Nap*Ncol + 2];81 stars[i].lensing->sF_ApR5 = AperFluxStd[Nap*Ncol + 2];82 stars[i].lensing->fF_ApR5 = AperFill [Nap*Ncol + 2];80 catalog->lensing[i]. F_ApR5 = AperFlux [Nap*Ncol + 2]; 81 catalog->lensing[i].dF_ApR5 = AperFluxErr[Nap*Ncol + 2]; 82 catalog->lensing[i].sF_ApR5 = AperFluxStd[Nap*Ncol + 2]; 83 catalog->lensing[i].fF_ApR5 = AperFill [Nap*Ncol + 2]; 83 84 84 stars[i].lensing->F_ApR6 = AperFlux [Nap*Ncol + 3];85 stars[i].lensing->dF_ApR6 = AperFluxErr[Nap*Ncol + 3];86 stars[i].lensing->sF_ApR6 = AperFluxStd[Nap*Ncol + 3];87 stars[i].lensing->fF_ApR6 = AperFill [Nap*Ncol + 3];85 catalog->lensing[i]. F_ApR6 = AperFlux [Nap*Ncol + 3]; 86 catalog->lensing[i].dF_ApR6 = AperFluxErr[Nap*Ncol + 3]; 87 catalog->lensing[i].sF_ApR6 = AperFluxStd[Nap*Ncol + 3]; 88 catalog->lensing[i].fF_ApR6 = AperFill [Nap*Ncol + 3]; 88 89 89 stars[i].lensing->F_ApR7 = AperFlux [Nap*Ncol + 4];90 stars[i].lensing->dF_ApR7 = AperFluxErr[Nap*Ncol + 4];91 stars[i].lensing->sF_ApR7 = AperFluxStd[Nap*Ncol + 4];92 stars[i].lensing->fF_ApR7 = AperFill [Nap*Ncol + 4];90 catalog->lensing[i]. F_ApR7 = AperFlux [Nap*Ncol + 4]; 91 catalog->lensing[i].dF_ApR7 = AperFluxErr[Nap*Ncol + 4]; 92 catalog->lensing[i].sF_ApR7 = AperFluxStd[Nap*Ncol + 4]; 93 catalog->lensing[i].fF_ApR7 = AperFill [Nap*Ncol + 4]; 93 94 Nap ++; 94 95 } 96 catalog->Nlensing = Nap; 97 98 gfits_free_table (&table); 99 free (AperFlux); 100 free (AperFluxErr); 101 free (AperFluxStd); 102 free (AperFill); 103 free (RadID); 95 104 96 105 return TRUE; -
trunk/Ohana/src/addstar/src/SkyListForStars.c
r27435 r38553 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 -
trunk/Ohana/src/addstar/src/UpdateImageIDs.c
r38467 r38553 1 1 # include "addstar.h" 2 2 3 int UpdateImageIDs ( Stars *stars, unsigned int Nstars, Image *images, off_t Nimages) {3 int UpdateImageIDs (Catalog *catalog, Image *images, off_t Nimages) { 4 4 5 5 int i, status, isEmpty; … … 54 54 } 55 55 56 for (i = 0; i < Nstars; i++) { 57 stars[i].measure.imageID += imageID; 58 if (stars[i].lensing) { 59 stars[i].lensing->imageID += imageID; 56 off_t j, m; 57 for (i = 0; i < catalog->Naverage; i++) { 58 m = catalog->average[i].measureOffset; 59 for (j = 0; j < catalog->average[i].Nmeasure; j++, m++) { 60 catalog->measure[m].imageID += imageID; 61 } 62 m = catalog->average[i].lensingOffset; 63 for (j = 0; j < catalog->average[i].Nlensing; j++, m++) { 64 catalog->lensing[m].imageID += imageID; 60 65 } 61 66 } … … 87 92 88 93 dvo_image_unlock (&db); 94 gfits_db_free (&db); 89 95 90 96 return TRUE; -
trunk/Ohana/src/addstar/src/addstar.c
r38471 r38553 6 6 int main (int argc, char **argv) { 7 7 8 unsigned int Nstars, Nsubset;9 8 int Nmatch, status, loadObjects; 10 9 off_t i, Nimages; 11 10 off_t Naverage, Nmeasure, Nlensing; 12 Stars *stars, **subset;13 Image *images;14 11 Catalog catalog; 15 12 FITS_DB db; … … 48 45 MARKTIME ("init and config: %f sec\n", dtime); RESETTIME; 49 46 50 stars = NULL; 47 Catalog *newcat = NULL; 48 Image *images = NULL; 51 49 52 50 /*** load in the new data (images, stars) ***/ 53 51 switch (options.mode) { 54 52 case ADDSTAR_MODE_IMAGE: 55 stars = LoadStars (argv[1], &Nstars, &images, &Nimages, &options);53 newcat = LoadStars (argv[1], &images, &Nimages, &options); 56 54 MARKTIME ("load smf: %f sec\n", dtime); RESETTIME; 57 55 58 56 // set and update the imageID sequence 59 UpdateImageIDs ( stars, Nstars, images, Nimages);60 61 if ((DUMP != NULL) && !strcmp (DUMP, "rawstars")) dump_rawstars (stars, Nstars);57 UpdateImageIDs (newcat, images, Nimages); 58 59 // if ((DUMP != NULL) && !strcmp (DUMP, "rawstars")) dump_rawstars (stars, Nstars); 62 60 for (i = 0; i < Nimages; i++) { 63 61 newlist = SkyListByImage (sky, -1, &images[i]); … … 68 66 ImageOptions (&options, images, Nimages); 69 67 break; 68 # if (0) 70 69 case ADDSTAR_MODE_REFLIST: 71 70 stars = grefstars (argv[1], options.photcode, &Nstars); … … 81 80 skylist[0].ownElements = FALSE; 82 81 break; 82 # endif 83 83 84 84 default: … … 146 146 switch (options.mode) { 147 147 case ADDSTAR_MODE_IMAGE: 148 Nsubset = Nstars;148 // Nsubset = Nstars; 149 149 if (options.closest) { 150 Nmatch += find_matches_closest (skylist[0].regions[i], stars, Nstars, &catalog, options);150 Nmatch += find_matches_closest (skylist[0].regions[i], newcat, &catalog, options); 151 151 } else { 152 Nmatch += find_matches (skylist[0].regions[i], stars, Nstars, &catalog, options);152 Nmatch += find_matches (skylist[0].regions[i], newcat, &catalog, options); 153 153 } 154 154 break; 155 # if (0) 155 156 case ADDSTAR_MODE_REFCAT: 156 157 stars = greference (argv[1], skylist[0].regions[i], options.photcode, &Nstars); 157 case ADDSTAR_MODE_REFLIST: 158 subset = find_subset (skylist[0].regions[i], stars, Nstars, &Nsubset);158 case ADDSTAR_MODE_REFLIST: { 159 Stars **subset = find_subset (skylist[0].regions[i], stars, Nstars, &Nsubset); 159 160 if (options.closest) { 160 161 Nmatch += find_matches_closest_refstars (skylist[0].regions[i], subset, Nsubset, &catalog, options); … … 164 165 if (Nsubset) free (subset); 165 166 break; 167 } 168 # endif 169 default: 170 abort(); 166 171 } 167 172 if (VERBOSE) MARKTIME ("match stars: %f sec\n", dtime); RESETTIME; … … 173 178 174 179 // write out catalog, if appropriate 175 if ( Nsubset&& !options.only_images) {180 if (newcat->Naverage && !options.only_images) { 176 181 SetProtect (TRUE); 177 182 if (options.update) { … … 187 192 if (VERBOSE) MARKTIME ("save cpt: %f sec\n", dtime); RESETTIME; 188 193 189 if (options.mode == ADDSTAR_MODE_REFCAT) free (stars); 190 } 194 if (options.mode == ADDSTAR_MODE_REFCAT) dvo_catalog_free (newcat); 195 } 196 SkyListFree (skylist); 191 197 192 198 // We only measure a single value for the entire mosaic (add all images to this function) … … 218 224 SetProtect (FALSE); 219 225 } 226 FREE (images); 220 227 dvo_image_unlock (&db); /* unlock? */ 228 gfits_db_free (&db); /* unlock? */ 221 229 222 230 gettimeofday (&stopAddstar, (void *) NULL); 223 231 float dtime = DTIME (stopAddstar, startAddstar); 224 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for %5d stars (%5d matches), "OFF_T_FMT" average, "OFF_T_FMT" measure, "OFF_T_FMT" lensing\n", dtime, Nstars, Nmatch, Naverage, Nmeasure, Nlensing); 225 232 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for "OFF_T_FMT" stars (%5d matches), "OFF_T_FMT" average, "OFF_T_FMT" measure, "OFF_T_FMT" lensing\n", dtime, newcat->Naverage, Nmatch, Naverage, Nmeasure, Nlensing); 233 234 if (options.mode != ADDSTAR_MODE_REFCAT) { 235 dvo_catalog_free (newcat); 236 free (newcat); 237 } 238 239 // XXX test 240 FreeConfig (); 241 FreePhotcodeTable (); 242 SkyTableFree (sky); 243 ohana_memcheck (1); 244 ohana_memdump (1); 226 245 exit (0); 227 246 } -
trunk/Ohana/src/addstar/src/find_matches.c
r38467 r38553 1 1 # include "addstar.h" 2 2 3 int find_matches (SkyRegion *region, Stars *stars, unsigned int NstarsIn, Catalog *catalog, AddstarClientOptions options) {4 5 off_t i, j, n, N, J, Nstars ;3 int find_matches (SkyRegion *region, Catalog *srccat, Catalog *tgtcat, AddstarClientOptions options) { 4 5 off_t i, j, n, N, J, Nstars, mSrc; 6 6 double RADIUS, RADIUS2; 7 7 double *X1, *Y1, *X2, *Y2; 8 8 double dX, dY, dR; 9 off_t *N1, *N2 , *next_meas;9 off_t *N1, *N2; 10 10 off_t Nave, NAVE, Nmeas, NMEAS, Nmatch; 11 11 int Nsecfilt, Nsec, status; … … 13 13 Coords tcoords; 14 14 15 if (NSTAR_GROUP <= 0) {16 fprintf (stderr, "ERROR: NSTAR_GROUP NOT SET!\n");17 exit (1);18 }19 20 15 /* photcode data - must by of type DEP; options.photcode is equiv photcode for all input 21 16 images this function requires incoming stars to have the same photcode.equiv value. if … … 27 22 28 23 /** allocate local arrays (stars) **/ 29 ALLOCATE (X1, double, NstarsIn); 30 ALLOCATE (Y1, double, NstarsIn); 31 ALLOCATE (N1, off_t, NstarsIn); 32 33 /** allocate local arrays (catalog) **/ 34 NAVE = Nave = catalog[0].Naverage; 24 ALLOCATE (X1, double, srccat->Naverage); 25 ALLOCATE (Y1, double, srccat->Naverage); 26 ALLOCATE (N1, off_t, srccat->Naverage); 27 28 myAbort ("figure out if found_t needs to be tracking Naverage or Nmeasure"); 29 if (!srccat->found_t) { 30 ALLOCATE (srccat->found_t, off_t, srccat->Naverage); 31 for (i = 0; i < srccat->Naverage; i++) { 32 srccat->found_t[i] = -1; 33 } 34 } 35 36 /** allocate local arrays (tgtcat) **/ 37 NAVE = Nave = tgtcat[0].Naverage; 35 38 ALLOCATE (X2, double, NAVE); 36 39 ALLOCATE (Y2, double, NAVE); 37 40 ALLOCATE (N2, off_t, NAVE); 38 ALLOCATE (catalog[0].found_t, off_t, NAVE); 41 42 if (!tgtcat->found_t) { 43 ALLOCATE (tgtcat[0].found_t, off_t, NAVE); 44 for (i = 0; i < NAVE; i++) { 45 tgtcat->found_t[i] = -1; 46 } 47 } 39 48 /* for secfilt j and star i, secfilt[i*Nsecfilt+j] */ 40 49 41 50 /* internal counters */ 42 51 Nmatch = 0; 43 NMEAS = Nmeas = catalog[0].Nmeasure;52 NMEAS = Nmeas = tgtcat[0].Nmeasure; 44 53 45 // current max obj ID for this catalog 46 objID = catalog[0].objID; 47 catID = catalog[0].catID; 54 off_t *next_meas = NULL; 55 56 // current max obj ID for this tgtcat 57 objID = tgtcat[0].objID; 58 catID = tgtcat[0].catID; 48 59 49 60 /* project onto rectilinear grid with 1 arcsec pixels. the choice of ZEA projection has the … … 51 62 * possible X,Y points map back to R,D and the local plate scale changes substantially far from 52 63 * the projection pole. a better mapping might be ARC, not yet implemented (see 53 * coordops.update.c). We use the center of the region ( catalog) for crval1,2.64 * coordops.update.c). We use the center of the region (tgtcat) for crval1,2. 54 65 */ 55 66 InitCoords (&tcoords, "DEC--ARC"); … … 64 75 /* build spatial index (RA sort) referencing input array sequence */ 65 76 Nstars = 0; 66 for (i = 0; i < NstarsIn; i++) {67 status = RD_to_XY (&X1[Nstars], &Y1[Nstars], s tars[i].average.R, stars[i].average.D, &tcoords);77 for (i = 0; i < srccat->Naverage; i++) { 78 status = RD_to_XY (&X1[Nstars], &Y1[Nstars], srccat->average[i].R, srccat->average[i].D, &tcoords); 68 79 if (!status) continue; 69 80 N1[Nstars] = i; … … 71 82 } 72 83 if (Nstars < 1) { 73 if (VERBOSE) fprintf (stderr, "skipping %s, no overlapping stars\n", catalog[0].filename);84 if (VERBOSE) fprintf (stderr, "skipping %s, no overlapping stars\n", tgtcat[0].filename); 74 85 free (X1); 75 86 free (Y1); … … 84 95 /* build spatial index (RA sort) */ 85 96 for (i = 0; i < Nave; i++) { 86 RD_to_XY (&X2[i], &Y2[i], catalog[0].average[i].R, catalog[0].average[i].D, &tcoords);97 RD_to_XY (&X2[i], &Y2[i], tgtcat[0].average[i].R, tgtcat[0].average[i].D, &tcoords); 87 98 N2[i] = i; 88 catalog[0].found_t[N2[i]] = -1;99 tgtcat[0].found_t[N2[i]] = -1; 89 100 } 90 101 if (Nave > 1) sort_coords_index (X2, Y2, N2, Nave); 91 102 92 103 /* set up pointers for linked list of measure */ 93 if ( catalog[0].sorted && (catalog[0].Nmeasure == catalog[0].Nmeasure_disk)) {94 next_meas = init_measure_links ( catalog[0].average, Nave, catalog[0].measure, Nmeas);104 if (tgtcat[0].sorted && (tgtcat[0].Nmeasure == tgtcat[0].Nmeasure_disk)) { 105 next_meas = init_measure_links (tgtcat[0].average, Nave, tgtcat[0].measure, Nmeas); 95 106 } else { 96 next_meas = build_measure_links ( catalog[0].average, Nave, catalog[0].measure, Nmeas);107 next_meas = build_measure_links (tgtcat[0].average, Nave, tgtcat[0].measure, Nmeas); 97 108 } 98 109 … … 102 113 103 114 /** find matched stars **/ 104 // XXX could use NSTAR_GROUP to do this match more quicky if NSTAR_GROUP > 1105 115 for (i = j = 0; (i < Nstars) && (j < Nave); ) { 106 116 if (!finite(X1[i]) || !finite(Y1[i])) { … … 138 148 139 149 /* make sure there is space for next entry */ 140 if (Nmeas >= NMEAS ) {141 NMEAS = Nmeas + 1000 ;150 if (Nmeas >= NMEAS - srccat->average[N].Nmeasure) { 151 NMEAS = Nmeas + 1000 + srccat->average[N].Nmeasure; 142 152 REALLOCATE (next_meas, off_t, NMEAS); 143 144 REALLOCATE (catalog[0].measure, Measure, NMEAS); 145 } 146 147 /* add to end of measurement list */ 148 add_meas_link (&catalog[0].average[n], next_meas, Nmeas, NMEAS); 153 REALLOCATE (tgtcat[0].measure, Measure, NMEAS); 154 } 149 155 150 156 /** add measurements for this star **/ 151 152 // set the new measurements 153 catalog[0].measure[Nmeas] = stars[N].measure; 154 155 // the following measure elements cannot be set until here: 156 catalog[0].measure[Nmeas].dbFlags = 0; 157 catalog[0].measure[Nmeas].averef = n; // this must be an absolute sequence number, if partial average is loaded 158 catalog[0].measure[Nmeas].objID = catalog[0].average[n].objID; 159 catalog[0].measure[Nmeas].catID = catalog[0].catID; 160 161 float dRoff = dvoOffsetR(&catalog[0].measure[Nmeas], &catalog[0].average[n]); 162 163 // rationalize R: 164 if (dRoff > +180.0*3600.0) { 165 // average on high end of boundary, move star up 166 catalog[0].measure[Nmeas].R += 360.0; 167 dRoff -= 360.0*3600.0; 168 } 169 if (dRoff < -180.0*3600.0) { 170 // average on low end of boundary, move star down 171 catalog[0].measure[Nmeas].R -= 360.0; 172 dRoff += 360.0*3600.0; 173 } 174 if (fabs(dRoff) > 10*RADIUS) { 175 // take declination into account and check again. 176 double cosD = cos(RAD_DEG*catalog[0].average[n].D); 177 if (fabs(dRoff*cosD) > 10*RADIUS) { 178 fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n", 179 catalog[0].average[n].R, catalog[0].average[n].D, 180 stars[N].average.R, stars[N].average.D, 181 X1[i], X2[J], 182 Y1[i], Y2[J]); 183 } 184 } 185 186 /* adds the measurement to the calibration if appropriate color terms are found */ 187 /* we call this before (optionally) setting the average magnitude to avoid auto-correlations */ 188 if (options.calibrate) { 189 AddToCalibration (&catalog[0].average[n], &catalog[0].secfilt[n*Nsecfilt], catalog[0].measure, &catalog[0].measure[Nmeas], next_meas, N); 190 } 191 192 /* set the average magnitude if not already set and if photcode.equiv is not 0 */ 193 /* in UPDATE mode, this value is not saved; use relphot to recalculate */ 194 if (Nsec > -1) { 195 if (isnan(catalog[0].secfilt[n*Nsecfilt+Nsec].M)) { 196 catalog[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas], MAG_CLASS_PSF); 197 } 198 } 199 200 /*** flag multiple stars */ 201 /* this image star matches more than one catalog star */ 202 if (stars[N].found > -1) { 203 catalog[0].measure[stars[N].found].dbFlags |= ID_MEAS_BLEND_MEAS; 204 catalog[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_MEAS; 205 } 206 if (stars[N].found == -2) { /* this image star matches a catalog star on a neighboring catalog */ 207 catalog[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_MEAS_X; 208 } 209 if (stars[N].found == -1) { /* this image star matches only this catalog star */ 210 stars[N].found = Nmeas; /* save first match, in case coincidences are found */ 211 } 212 /* this catalog star matches more than one image star */ 213 if (catalog[0].found_t[n] > -1) { 214 catalog[0].measure[catalog[0].found_t[n]].dbFlags |= ID_MEAS_BLEND_OBJ; 215 catalog[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_OBJ; 216 } else { 217 catalog[0].found_t[n] = Nmeas; 218 } 219 /* Nm is updated, but not written out in -update mode (for existing entries) 220 Nm is recalculated in build_meas_links if loaded table is not sorted */ 221 catalog[0].average[n].Nmeasure ++; 222 Nmeas ++; 157 off_t mOff = srccat->average[N].measureOffset; 158 for (mSrc = 0; mSrc < srccat->average[N].Nmeasure; mSrc++) { 159 /* add to end of measurement list */ 160 add_meas_link (&tgtcat[0].average[n], next_meas, Nmeas, NMEAS); 161 162 /** add measurements for this star **/ 163 164 // set the new measurements 165 tgtcat[0].measure[Nmeas] = srccat->measure[mSrc + mOff]; 166 167 // the following measure elements cannot be set until here: 168 tgtcat[0].measure[Nmeas].dbFlags = 0; 169 tgtcat[0].measure[Nmeas].averef = n; // this must be an absolute sequence number, if partial average is loaded 170 tgtcat[0].measure[Nmeas].objID = tgtcat[0].average[n].objID; 171 tgtcat[0].measure[Nmeas].catID = tgtcat[0].catID; 172 173 float dRoff = dvoOffsetR(&tgtcat[0].measure[Nmeas], &tgtcat[0].average[n]); 174 175 // rationalize R: 176 if (dRoff > +180.0*3600.0) { 177 // average on high end of boundary, move star up 178 tgtcat[0].measure[Nmeas].R += 360.0; 179 dRoff -= 360.0*3600.0; 180 } 181 if (dRoff < -180.0*3600.0) { 182 // average on low end of boundary, move star down 183 tgtcat[0].measure[Nmeas].R -= 360.0; 184 dRoff += 360.0*3600.0; 185 } 186 if (fabs(dRoff) > 10*RADIUS) { 187 // take declination into account and check again. 188 double cosD = cos(RAD_DEG*tgtcat[0].average[n].D); 189 if (fabs(dRoff*cosD) > 10*RADIUS) { 190 fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n", 191 tgtcat[0].average[n].R, tgtcat[0].average[n].D, 192 srccat->average[N].R, srccat->average[N].D, 193 X1[i], X2[J], 194 Y1[i], Y2[J]); 195 } 196 } 197 198 /* adds the measurement to the calibration if appropriate color terms are found */ 199 /* we call this before (optionally) setting the average magnitude to avoid auto-correlations */ 200 if (options.calibrate) { 201 AddToCalibration (&tgtcat[0].average[n], &tgtcat[0].secfilt[n*Nsecfilt], tgtcat[0].measure, &tgtcat[0].measure[Nmeas], next_meas, N); 202 } 203 204 /* set the average magnitude if not already set and if photcode.equiv is not 0 */ 205 /* in UPDATE mode, this value is not saved; use relphot to recalculate */ 206 if (Nsec > -1) { 207 if (isnan(tgtcat[0].secfilt[n*Nsecfilt+Nsec].M)) { 208 tgtcat[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&tgtcat[0].measure[Nmeas], MAG_CLASS_PSF); 209 } 210 } 211 212 myAbort ("fix logic on multiple detections"); 213 214 /*** flag multiple stars */ 215 /* this image star matches more than one tgtcat star */ 216 if (srccat->found_t[N] > -1) { 217 tgtcat[0].measure[srccat->found_t[N]].dbFlags |= ID_MEAS_BLEND_MEAS; 218 tgtcat[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_MEAS; 219 } 220 if (srccat->found_t[N] == -2) { /* this image star matches a tgtcat star on a neighboring tgtcat */ 221 tgtcat[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_MEAS_X; 222 } 223 if (srccat->found_t[N] == -1) { /* this image star matches only this tgtcat star */ 224 srccat->found_t[N] = Nmeas; /* save first match, in case coincidences are found */ 225 } 226 /* this tgtcat star matches more than one image star */ 227 if (tgtcat[0].found_t[n] > -1) { 228 tgtcat[0].measure[tgtcat[0].found_t[n]].dbFlags |= ID_MEAS_BLEND_OBJ; 229 tgtcat[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_OBJ; 230 } else { 231 tgtcat[0].found_t[n] = Nmeas; 232 } 233 /* Nm is updated, but not written out in -update mode (for existing entries) 234 Nm is recalculated in build_meas_links if loaded table is not sorted */ 235 tgtcat[0].average[n].Nmeasure ++; 236 Nmeas ++; 237 } 223 238 224 239 if (!options.update) { 225 240 /* in UPDATE mode, newly calculated coordinates are not saved */ 226 update_coords (& catalog[0].average[n], &catalog[0].measure[0], next_meas);241 update_coords (&tgtcat[0].average[n], &tgtcat[0].measure[0], next_meas); 227 242 } 228 243 } … … 230 245 } 231 246 232 /* incorporate unmatched image stars, if this star is in field of this catalog*/247 /* incorporate unmatched image stars, if this star is in field of this tgtcat */ 233 248 /* these new entries are all written out in UPDATE mode */ 234 for (i = 0; (i < Nstars) && !options.only_match; i + = NSTAR_GROUP) {249 for (i = 0; (i < Nstars) && !options.only_match; i ++) { 235 250 /* make sure there is space for next entry */ 236 if (Nmeas >= NMEAS - NSTAR_GROUP) {237 NMEAS = Nmeas + 1000 ;251 if (Nmeas >= NMEAS - srccat->average[i].Nmeasure) { 252 NMEAS = Nmeas + 1000 + srccat->average[i].Nmeasure; 238 253 REALLOCATE (next_meas, off_t, NMEAS); 239 REALLOCATE ( catalog[0].measure, Measure, NMEAS);254 REALLOCATE (tgtcat[0].measure, Measure, NMEAS); 240 255 } 241 256 if (Nave >= NAVE) { 242 257 NAVE = Nave + 1000; 243 REALLOCATE (catalog[0].average, Average, NAVE); 244 REALLOCATE (catalog[0].secfilt, SecFilt, NAVE*catalog[0].Nsecfilt); 245 } 246 247 if (stars[i].found >= 0) continue; 248 if (!IN_REGION (stars[i].average.R, stars[i].average.D)) continue; 249 250 dvo_average_init (&catalog[0].average[Nave]); 251 catalog[0].average[Nave].R = stars[i].average.R; 252 catalog[0].average[Nave].D = stars[i].average.D; 253 254 catalog[0].average[Nave].Nmeasure = NSTAR_GROUP; 255 catalog[0].average[Nave].measureOffset = Nmeas; 256 catalog[0].average[Nave].objID = objID; 257 catalog[0].average[Nave].catID = catID; 258 REALLOCATE (tgtcat[0].average, Average, NAVE); 259 if (tgtcat[0].secfilt) { 260 // we only update the secfilt table if it has been allocated for output 261 REALLOCATE (tgtcat[0].secfilt, SecFilt, NAVE*tgtcat[0].Nsecfilt); 262 } 263 } 264 265 if (srccat->found_t[i] >= 0) continue; 266 if (!IN_REGION (srccat->average[i].R, srccat->average[i].D)) continue; 267 268 dvo_average_init (&tgtcat[0].average[Nave]); 269 tgtcat[0].average[Nave].R = srccat->average[i].R; 270 tgtcat[0].average[Nave].D = srccat->average[i].D; 271 272 tgtcat[0].average[Nave].Nmeasure = srccat->average[i].Nmeasure; 273 tgtcat[0].average[Nave].measureOffset = Nmeas; 274 tgtcat[0].average[Nave].objID = objID; 275 tgtcat[0].average[Nave].catID = catID; 258 276 259 277 if (PSPS_ID) { 260 catalog[0].average[Nave].extID = CreatePSPSObjectID(catalog[0].average[Nave].R, catalog[0].average[Nave].D);278 tgtcat[0].average[Nave].extID = CreatePSPSObjectID(tgtcat[0].average[Nave].R, tgtcat[0].average[Nave].D); 261 279 } 262 280 263 281 objID ++; 264 282 265 for (j = 0; j < Nsecfilt; j++) { 266 dvo_secfilt_init (&catalog[0].secfilt[Nave*Nsecfilt+j], SECFILT_RESET_ALL); 267 } 268 269 for (j = 0; j < NSTAR_GROUP; j++) { 283 for (j = 0; tgtcat[0].secfilt && (j < Nsecfilt); j++) { 284 dvo_secfilt_init (&tgtcat[0].secfilt[Nave*Nsecfilt+j], SECFILT_RESET_ALL); 285 } 286 287 off_t mOff = srccat->average[i].measureOffset; 288 for (mSrc = 0; mSrc < srccat->average[i].Nmeasure; mSrc++) { 270 289 // supply the measurments from this detection 271 catalog[0].measure[Nmeas] = stars[i + j].measure; 290 dvo_measure_init (&tgtcat[0].measure[Nmeas]); 291 tgtcat[0].measure[Nmeas] = srccat->measure[mSrc + mOff]; 272 292 273 293 // the following measure elements cannot be set until here: 274 catalog[0].measure[Nmeas].dbFlags = 0;275 catalog[0].measure[Nmeas].averef = Nave; // XXX EAM : must be absolute Nave if partial read276 catalog[0].measure[Nmeas].objID = catalog[0].average[Nave].objID;277 catalog[0].measure[Nmeas].catID = catalog[0].catID;294 tgtcat[0].measure[Nmeas].dbFlags = 0; 295 tgtcat[0].measure[Nmeas].averef = Nave; // XXX EAM : must be absolute Nave if partial read 296 tgtcat[0].measure[Nmeas].objID = tgtcat[0].average[Nave].objID; 297 tgtcat[0].measure[Nmeas].catID = tgtcat[0].catID; 278 298 279 299 /* set the average magnitude if not already set and the photcode.equiv is not 0 */ 280 300 /* in UPDATE mode, this value is not saved; use relphot to recalculate */ 281 301 if (Nsec > -1) { 282 catalog[0].secfilt[Nave*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas], MAG_CLASS_PSF);302 tgtcat[0].secfilt[Nave*Nsecfilt+Nsec].M = PhotCat (&tgtcat[0].measure[Nmeas], MAG_CLASS_PSF); 283 303 } 284 304 285 305 /* next[Nmeas] should always be -1 in this context (it is always the only 286 306 measurement for the star) */ 287 stars[i].found = Nmeas; 288 next_meas[Nmeas] = -1; // initial value here update below 307 srccat->found_t[i] = Nmeas; 289 308 Nmeas ++; 290 } 291 for (j = 0; j < NSTAR_GROUP - 1; j++) {292 next_meas[Nmeas - NSTAR_GROUP + j] = Nmeas - NSTAR_GROUP + j +1;309 310 // update the next_meas pointer for this entry (last one for this star is -1) 311 next_meas[Nmeas-1] = (mSrc < srccat->average[i].Nmeasure - 1) ? Nmeas : -1; 293 312 } 294 313 Nave ++; 295 314 } 296 315 297 REALLOCATE ( catalog[0].average, Average, Nave);298 REALLOCATE ( catalog[0].measure, Measure, Nmeas);316 REALLOCATE (tgtcat[0].average, Average, Nave); 317 REALLOCATE (tgtcat[0].measure, Measure, Nmeas); 299 318 300 319 if (options.nosort) { 301 catalog[0].sorted = FALSE;320 tgtcat[0].sorted = FALSE; 302 321 } else { 303 catalog[0].sorted = TRUE;304 catalog[0].measure = sort_measure (catalog[0].average, Nave, catalog[0].measure, Nmeas, next_meas);305 } 306 307 /* note stars which have been found in this catalog*/308 for (i = 0; i < NstarsIn; i++) {309 if (s tars[i].found> -1) {310 s tars[i].found= -2;311 } 312 } 313 314 /* check if the cataloghas changed? if no change, no need to write */315 catalog[0].objID = objID; // new max value, save on catalogclose316 catalog[0].Naverage = Nave;317 catalog[0].Nmeasure = Nmeas;318 catalog[0].Nsecfilt_mem = Nave*Nsecfilt;322 tgtcat[0].sorted = TRUE; 323 tgtcat[0].measure = sort_measure (tgtcat[0].average, Nave, tgtcat[0].measure, Nmeas, next_meas); 324 } 325 326 /* note stars which have been found in this tgtcat */ 327 for (i = 0; i < srccat->Nmeasure; i++) { 328 if (srccat->found_t[i] > -1) { 329 srccat->found_t[i] = -2; 330 } 331 } 332 333 /* check if the tgtcat has changed? if no change, no need to write */ 334 tgtcat[0].objID = objID; // new max value, save on tgtcat close 335 tgtcat[0].Naverage = Nave; 336 tgtcat[0].Nmeasure = Nmeas; 337 tgtcat[0].Nsecfilt_mem = Nave*Nsecfilt; 319 338 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT", ("OFF_T_FMT" matches)\n", Nstars, Nave, Nmeas, Nmatch); 320 339 … … 333 352 notes: 334 353 335 for finding if a catalog star is in an image or an image star is in the catalog:354 for finding if a tgtcat star is in an image or an image star is in the tgtcat: 336 355 337 catalogs have boundaries defined by RA and DEC, but they may curve in projection356 tgtcats have boundaries defined by RA and DEC, but they may curve in projection 338 357 images have boundaries which are lines in pixels coords, but curve in RA and DEC 339 358 340 catalog[0].found[Ncat] but stars[Nstar].found359 tgtcat[0].found[Ncat] but stars[Nstar].found 341 360 342 361 */ -
trunk/Ohana/src/addstar/src/find_matches_closest.c
r38467 r38553 1 1 # include "addstar.h" 2 2 3 int find_matches_closest (SkyRegion *region, Stars *stars, unsigned int NstarsIn, Catalog *catalog, AddstarClientOptions options) {4 5 off_t i, j, n, N, J, Jmin, status, Nstars ;3 int find_matches_closest (SkyRegion *region, Catalog *srccat, Catalog *tgtcat, AddstarClientOptions options) { 4 5 off_t i, j, n, N, J, Jmin, status, Nstars, mSrc; 6 6 double RADIUS, RADIUS2, Rmin; 7 7 double *X1, *Y1, *X2, *Y2; 8 8 double dX, dY, dR; 9 off_t *N1, *N2 , *next_meas, *next_lens;9 off_t *N1, *N2; 10 10 off_t Nave, NAVE, Nmeas, NMEAS, Nmatch, Nlens, NLENS; 11 11 int Nsecfilt, Nsec; … … 13 13 Coords tcoords; 14 14 15 if (NSTAR_GROUP <= 0) {16 fprintf (stderr, "ERROR: NSTAR_GROUP NOT SET!\n");17 exit (1);18 }19 20 15 /* photcode data - must by of type DEP; options.photcode is equiv photcode for all input 21 16 images this function requires incoming stars to have the same photcode.equiv value. if … … 26 21 Nsec = GetPhotcodeNsec (options.photcode); 27 22 28 /** allocate local arrays (stars) **/ 29 ALLOCATE (X1, double, NstarsIn); 30 ALLOCATE (Y1, double, NstarsIn); 31 ALLOCATE (N1, off_t, NstarsIn); 32 33 /** allocate local arrays (catalog) **/ 34 NAVE = Nave = catalog[0].Naverage; 23 /** allocate local arrays (srccat) **/ 24 ALLOCATE (X1, double, srccat->Naverage); 25 ALLOCATE (Y1, double, srccat->Naverage); 26 ALLOCATE (N1, off_t, srccat->Naverage); 27 28 if (!srccat->found_t) { 29 ALLOCATE (srccat->found_t, off_t, srccat->Naverage); 30 for (i = 0; i < srccat->Naverage; i++) { 31 srccat->found_t[i] = -1; 32 } 33 } 34 35 /** allocate local arrays (tgtcat) **/ 36 NAVE = Nave = tgtcat[0].Naverage; 35 37 ALLOCATE (X2, double, NAVE); 36 38 ALLOCATE (Y2, double, NAVE); 37 39 ALLOCATE (N2, off_t, NAVE); 38 ALLOCATE (catalog[0].found_t, off_t, NAVE); 40 41 if (!tgtcat->found_t) { 42 ALLOCATE (tgtcat[0].found_t, off_t, NAVE); 43 for (i = 0; i < NAVE; i++) { 44 tgtcat->found_t[i] = -1; 45 } 46 } 39 47 /* for secfilt j and star i, secfilt[i*Nsecfilt+j] */ 40 48 41 49 /* internal counters */ 42 50 Nmatch = 0; 43 NMEAS = Nmeas = catalog[0].Nmeasure; 44 NLENS = Nlens = catalog[0].Nlensing; 45 46 // current max obj ID for this catalog 47 objID = catalog[0].objID; 48 catID = catalog[0].catID; 51 NMEAS = Nmeas = tgtcat[0].Nmeasure; 52 NLENS = Nlens = tgtcat[0].Nlensing; 53 54 off_t *next_meas = NULL; 55 off_t *next_lens = NULL; 56 57 // current max obj ID for this tgtcat 58 objID = tgtcat[0].objID; 59 catID = tgtcat[0].catID; 49 60 50 61 /* project onto rectilinear grid with 1 arcsec pixels. the choice of ARC projection has 51 62 * the advantage that every point in R,D has a mapping to a unique X,Y. However, note 52 63 * that not all possible X,Y points map back to R,D and the local plate scale changes 53 * far from the projection pole. We use the center of the region ( catalog) for crval1,2.64 * far from the projection pole. We use the center of the region (tgtcat) for crval1,2. 54 65 */ 55 66 InitCoords (&tcoords, "DEC--ARC"); … … 64 75 /* build spatial index (RA sort) referencing input array sequence */ 65 76 Nstars = 0; 66 for (i = 0; i < NstarsIn; i++) {67 status = RD_to_XY (&X1[Nstars], &Y1[Nstars], s tars[i].average.R, stars[i].average.D, &tcoords);77 for (i = 0; i < srccat->Naverage; i++) { 78 status = RD_to_XY (&X1[Nstars], &Y1[Nstars], srccat->average[i].R, srccat->average[i].D, &tcoords); 68 79 if (!status) continue; 69 80 N1[Nstars] = i; … … 71 82 } 72 83 if (Nstars < 1) { 73 if (VERBOSE) fprintf (stderr, "skipping %s, no overlapping stars\n", catalog[0].filename);84 if (VERBOSE) fprintf (stderr, "skipping %s, no overlapping stars\n", tgtcat[0].filename); 74 85 free (X1); 75 86 free (Y1); … … 79 90 free (N2); 80 91 return (0); 92 // XXX check on this 81 93 } 82 94 if (Nstars > 1) sort_coords_index (X1, Y1, N1, Nstars); … … 84 96 /* build spatial index (RA sort) */ 85 97 for (i = 0; i < Nave; i++) { 86 RD_to_XY (&X2[i], &Y2[i], catalog[0].average[i].R, catalog[0].average[i].D, &tcoords);98 RD_to_XY (&X2[i], &Y2[i], tgtcat[0].average[i].R, tgtcat[0].average[i].D, &tcoords); 87 99 N2[i] = i; 88 catalog[0].found_t[N2[i]] = -1;100 tgtcat[0].found_t[N2[i]] = -1; 89 101 } 90 102 if (Nave > 1) sort_coords_index (X2, Y2, N2, Nave); 91 103 92 104 /* set up pointers for linked list of measure */ 93 if ( catalog[0].sorted && (catalog[0].Nmeasure == catalog[0].Nmeasure_disk)) {94 // this version is only valid if we have done a full catalog load, and if the catalog105 if (tgtcat[0].sorted && (tgtcat[0].Nmeasure == tgtcat[0].Nmeasure_disk)) { 106 // this version is only valid if we have done a full tgtcat load, and if the tgtcat 95 107 // is sorted while processed 96 next_meas = init_measure_links ( catalog[0].average, Nave, catalog[0].measure, Nmeas);97 next_lens = init_lensing_links ( catalog[0].average, Nave, catalog[0].lensing, Nlens);108 next_meas = init_measure_links (tgtcat[0].average, Nave, tgtcat[0].measure, Nmeas); 109 next_lens = init_lensing_links (tgtcat[0].average, Nave, tgtcat[0].lensing, Nlens); 98 110 } else { 99 next_meas = build_measure_links ( catalog[0].average, Nave, catalog[0].measure, Nmeas);100 next_lens = build_lensing_links ( catalog[0].average, Nave, catalog[0].lensing, Nlens);111 next_meas = build_measure_links (tgtcat[0].average, Nave, tgtcat[0].measure, Nmeas); 112 next_lens = build_lensing_links (tgtcat[0].average, Nave, tgtcat[0].lensing, Nlens); 101 113 } 102 114 … … 105 117 RADIUS2 = RADIUS*RADIUS; 106 118 107 /** find matched stars**/108 // XXX could use NSTAR_GROUP to do this match more quicky if NSTAR_GROUP > 1 119 /****************** find matched stars ********************/ 120 109 121 for (i = j = 0; (i < Nstars) && (j < Nave); ) { 110 122 if (!finite(X1[i]) || !finite(Y1[i])) { … … 129 141 } 130 142 131 if (stars[N1[i]].found != -1) { 132 /* this star has already been assigned to an object in this or another catalog */ 143 // XXX check that this is allocated 144 if (srccat->found_t[N1[i]] != -1) { 145 /* this star has already been assigned to an object in this or another tgtcat */ 133 146 i++; 134 147 continue; … … 169 182 170 183 /* make sure there is space for next entry */ 171 if (Nmeas >= NMEAS ) {172 NMEAS = Nmeas + 1000 ;184 if (Nmeas >= NMEAS - srccat->average[N].Nmeasure) { 185 NMEAS = Nmeas + 1000 + srccat->average[N].Nmeasure; 173 186 REALLOCATE (next_meas, off_t, NMEAS); 174 REALLOCATE ( catalog[0].measure, Measure, NMEAS);175 } 176 if (Nlens >= NLENS ) {177 NLENS = Nlens + 1000 ;187 REALLOCATE (tgtcat[0].measure, Measure, NMEAS); 188 } 189 if (Nlens >= NLENS - srccat->average[N].Nlensing) { 190 NLENS = Nlens + 1000 + srccat->average[N].Nlensing; 178 191 REALLOCATE (next_lens, off_t, NLENS); 179 REALLOCATE (catalog[0].lensing, Lensing, NLENS); 180 } 181 182 /* add to end of measurement list */ 183 add_meas_link (&catalog[0].average[n], next_meas, Nmeas, NMEAS); 184 192 REALLOCATE (tgtcat[0].lensing, Lensing, NLENS); 193 } 194 185 195 /** add measurements for this star **/ 186 187 // set the new measurements 188 catalog[0].measure[Nmeas] = stars[N].measure; 189 190 // measure now carries R,D (not dR,dD) 191 catalog[0].measure[Nmeas].dbFlags = 0; 192 catalog[0].measure[Nmeas].averef = n; 193 catalog[0].measure[Nmeas].objID = catalog[0].average[n].objID; 194 catalog[0].measure[Nmeas].catID = catalog[0].catID; 195 196 float dRoff = dvoOffsetR(&catalog[0].measure[Nmeas], &catalog[0].average[n]); 197 198 // rationalize dR 199 if (dRoff > +180.0*3600.0) { 200 // average on high end of boundary, move star up 201 catalog[0].measure[Nmeas].R += 360.0; 202 dRoff -= 360.0*3600.0; 203 } 204 if (dRoff < -180.0*3600.0) { 205 // average on low end of boundary, move star down 206 catalog[0].measure[Nmeas].R -= 360.0; 207 dRoff += 360.0*3600.0; 208 } 209 if (fabs(dRoff) > 10*RADIUS) { 196 off_t mOff = srccat->average[N].measureOffset; 197 for (mSrc = 0; mSrc < srccat->average[N].Nmeasure; mSrc++) { 198 /* add to end of measurement list */ 199 add_meas_link (&tgtcat[0].average[n], next_meas, Nmeas, NMEAS); 200 201 // set the new measurements 202 tgtcat[0].measure[Nmeas] = srccat->measure[mSrc + mOff]; 203 204 // measure now carries R,D (not dR,dD) 205 tgtcat[0].measure[Nmeas].dbFlags = 0; 206 tgtcat[0].measure[Nmeas].averef = n; 207 tgtcat[0].measure[Nmeas].objID = tgtcat[0].average[n].objID; 208 tgtcat[0].measure[Nmeas].catID = tgtcat[0].catID; 209 210 float dRoff = dvoOffsetR(&tgtcat[0].measure[Nmeas], &tgtcat[0].average[n]); 211 212 // rationalize dR 213 if (dRoff > +180.0*3600.0) { 214 // average on high end of boundary, move star up 215 tgtcat[0].measure[Nmeas].R += 360.0; 216 dRoff -= 360.0*3600.0; 217 } 218 if (dRoff < -180.0*3600.0) { 219 // average on low end of boundary, move star down 220 tgtcat[0].measure[Nmeas].R -= 360.0; 221 dRoff += 360.0*3600.0; 222 } 223 if (fabs(dRoff) > 10*RADIUS) { 210 224 // take declination into account and check again. 211 double cosD = cos(RAD_DEG* catalog[0].average[n].D);225 double cosD = cos(RAD_DEG*tgtcat[0].average[n].D); 212 226 if (fabs(dRoff*cosD) > 10*RADIUS) { 213 fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n",214 catalog[0].average[n].R, catalog[0].average[n].D,215 stars[N].average.R, stars[N].average.D,216 X1[i], X2[Jmin],217 Y1[i], Y2[Jmin]);218 // XXX abort on this? -- this is a bad failure...227 fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n", 228 tgtcat[0].average[n].R, tgtcat[0].average[n].D, 229 srccat->average[N].R, srccat->average[N].D, 230 X1[i], X2[Jmin], 231 Y1[i], Y2[Jmin]); 232 // XXX abort on this? -- this is a bad failure... 219 233 } 220 } 221 222 // add the lensing values if they exist 223 if (stars[N].lensing) { 224 add_lens_link (&catalog[0].average[n], next_lens, Nlens, NLENS); // ? 225 catalog[0].lensing[Nlens] = stars[N].lensing[0]; 226 227 catalog[0].lensing[Nlens].averef = n; 228 catalog[0].lensing[Nlens].objID = catalog[0].average[n].objID; 229 catalog[0].lensing[Nlens].catID = catalog[0].catID; 230 catalog[0].average[n].Nlensing ++; 231 Nlens ++; 232 } 233 234 /* adds the measurement to the calibration if appropriate color terms are found */ 235 /* we call this before (optionally) setting the average magnitude to avoid auto-correlations */ 236 if (options.calibrate) { 237 AddToCalibration (&catalog[0].average[n], &catalog[0].secfilt[n*Nsecfilt], catalog[0].measure, &catalog[0].measure[Nmeas], next_meas, N); 238 } 239 240 /* set the average magnitude if not already set and the photcode.equiv is not 0 */ 241 /* in UPDATE mode, this value is not saved; use relphot to recalculate */ 242 if (Nsec > -1) { 243 if (isnan(catalog[0].secfilt[n*Nsecfilt+Nsec].M)) { 244 catalog[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas], MAG_CLASS_PSF); 245 } 246 } 247 248 /* if we choose to flag close encounters, see find_matches.c */ 249 /* if we choose to calculate RA,DEC averages, see update_coords.c */ 250 251 /* Nm is updated, but not written out in -update mode (for existing entries) 252 Nm is recalculated in build_meas_links if loaded table is not sorted */ 253 stars[N].found = Nmeas; 254 catalog[0].found_t[n] = Nmeas; 255 catalog[0].average[n].Nmeasure ++; 256 Nmeas ++; 257 i++; 258 } 259 260 /** incorporate unmatched image stars, if this star is in field of this catalog **/ 261 /* these new entries are all written out in UPDATE mode */ 262 for (i = 0; (i < Nstars) && !options.only_match; i += NSTAR_GROUP) { 263 /* make sure there is space for next entry */ 264 if (Nmeas >= NMEAS - NSTAR_GROUP) { 265 NMEAS = Nmeas + 1000; 266 REALLOCATE (next_meas, off_t, NMEAS); 267 REALLOCATE (catalog[0].measure, Measure, NMEAS); 268 } 269 if (Nlens >= NLENS - NSTAR_GROUP) { 270 NLENS = Nlens + 1000; 271 REALLOCATE (next_lens, off_t, NLENS); 272 REALLOCATE (catalog[0].lensing, Lensing, NLENS); 273 } 274 if (Nave >= NAVE) { 275 NAVE = Nave + 1000; 276 REALLOCATE (catalog[0].average, Average, NAVE); 277 REALLOCATE (catalog[0].secfilt, SecFilt, NAVE*catalog[0].Nsecfilt); 278 } 279 280 if (stars[i].found != -1) continue; 281 if (!IN_REGION (stars[i].average.R, stars[i].average.D)) continue; 282 283 dvo_average_init (&catalog[0].average[Nave]); 284 catalog[0].average[Nave].R = stars[i].average.R; 285 catalog[0].average[Nave].D = stars[i].average.D; 286 287 catalog[0].average[Nave].Nmeasure = NSTAR_GROUP; 288 catalog[0].average[Nave].measureOffset = Nmeas; 289 catalog[0].average[Nave].objID = objID; 290 catalog[0].average[Nave].catID = catID; 291 292 if (PSPS_ID) { 293 catalog[0].average[Nave].extID = CreatePSPSObjectID(catalog[0].average[Nave].R, catalog[0].average[Nave].D); 294 } 295 296 objID ++; 297 298 for (j = 0; j < Nsecfilt; j++) { 299 dvo_secfilt_init (&catalog[0].secfilt[Nave*Nsecfilt+j], SECFILT_RESET_ALL); 300 } 301 302 for (j = 0; j < NSTAR_GROUP; j++) { 303 // supply the measurments from this detection 304 dvo_measure_init (&catalog[0].measure[Nmeas]); 305 catalog[0].measure[Nmeas] = stars[i + j].measure; 306 307 // the following measure elements cannot be set until here: 308 catalog[0].measure[Nmeas].dbFlags = 0; 309 catalog[0].measure[Nmeas].averef = Nave; 310 catalog[0].measure[Nmeas].objID = catalog[0].average[Nave].objID; 311 catalog[0].measure[Nmeas].catID = catalog[0].catID; 234 } 235 236 /* adds the measurement to the calibration if appropriate color terms are found */ 237 /* we call this before (optionally) setting the average magnitude to avoid auto-correlations */ 238 if (options.calibrate) { 239 AddToCalibration (&tgtcat[0].average[n], &tgtcat[0].secfilt[n*Nsecfilt], tgtcat[0].measure, &tgtcat[0].measure[Nmeas], next_meas, N); 240 } 312 241 313 242 /* set the average magnitude if not already set and the photcode.equiv is not 0 */ 314 243 /* in UPDATE mode, this value is not saved; use relphot to recalculate */ 315 244 if (Nsec > -1) { 316 catalog[0].secfilt[Nave*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas], MAG_CLASS_PSF); 317 } 318 319 /* next[Nmeas] should always be -1 in this context (it is always the only 320 measurement for the star) */ 321 stars[i+j].found = Nmeas; 322 next_meas[Nmeas] = -1; // inital value here update below 245 if (isnan(tgtcat[0].secfilt[n*Nsecfilt+Nsec].M)) { 246 tgtcat[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&tgtcat[0].measure[Nmeas], MAG_CLASS_PSF); 247 } 248 } 249 250 /* Nm is updated, but not written out in -update mode (for existing entries) 251 Nm is recalculated in build_meas_links if loaded table is not sorted */ 252 tgtcat[0].average[n].Nmeasure ++; 323 253 Nmeas ++; 324 254 } 325 for (j = 0; j < NSTAR_GROUP - 1; j++) { 326 next_meas[Nmeas - NSTAR_GROUP + j] = Nmeas - NSTAR_GROUP + j + 1; 327 } 255 256 // add the lensing values if they exist 257 if (srccat->lensing) { 258 /** add measurements for this star **/ 259 off_t mOff = srccat->average[N].lensingOffset; 260 for (mSrc = 0; mSrc < srccat->average[N].Nlensing; mSrc++) { 261 /* add to end of lensing list */ 262 263 add_lens_link (&tgtcat[0].average[n], next_lens, Nlens, NLENS); // ? 264 tgtcat[0].lensing[Nlens] = srccat->lensing[mSrc + mOff]; 265 266 tgtcat[0].lensing[Nlens].averef = n; 267 tgtcat[0].lensing[Nlens].objID = tgtcat[0].average[n].objID; 268 tgtcat[0].lensing[Nlens].catID = tgtcat[0].catID; 269 tgtcat[0].average[n].Nlensing ++; 270 Nlens ++; 271 } 272 } 273 274 /* if we choose to flag close encounters, see find_matches.c */ 275 /* if we choose to calculate RA,DEC averages, see update_coords.c */ 276 277 srccat->found_t[N] = n; 278 tgtcat[0].found_t[n] = -1; 279 i++; 280 } 281 282 /*************** add unmatched stars *************************/ 283 284 /** incorporate unmatched image stars, if this star is in field of this tgtcat **/ 285 /* these new entries are all written out in UPDATE mode */ 286 for (i = 0; (i < Nstars) && !options.only_match; i++) { 287 /* make sure there is space for next entry */ 288 if (Nmeas >= NMEAS - srccat->average[i].Nmeasure) { 289 NMEAS = Nmeas + 1000 + srccat->average[i].Nmeasure; 290 REALLOCATE (next_meas, off_t, NMEAS); 291 REALLOCATE (tgtcat[0].measure, Measure, NMEAS); 292 } 293 if (Nlens >= NLENS - srccat->average[i].Nlensing) { 294 NLENS = Nlens + 1000 + srccat->average[i].Nlensing; 295 REALLOCATE (next_lens, off_t, NLENS); 296 REALLOCATE (tgtcat[0].lensing, Lensing, NLENS); 297 } 298 if (Nave >= NAVE) { 299 NAVE = Nave + 1000; 300 REALLOCATE (tgtcat[0].average, Average, NAVE); 301 REALLOCATE (tgtcat[0].found_t, off_t, NAVE); 302 if (tgtcat[0].secfilt) { 303 // we only update the secfilt table if it has been allocated for output 304 REALLOCATE (tgtcat[0].secfilt, SecFilt, NAVE*tgtcat[0].Nsecfilt); 305 } 306 } 307 308 if (srccat->found_t[i] != -1) continue; 309 if (!IN_REGION (srccat->average[i].R, srccat->average[i].D)) continue; 310 311 dvo_average_init (&tgtcat[0].average[Nave]); 312 tgtcat[0].average[Nave].R = srccat->average[i].R; 313 tgtcat[0].average[Nave].D = srccat->average[i].D; 314 315 tgtcat[0].average[Nave].Nmeasure = srccat->average[i].Nmeasure; 316 tgtcat[0].average[Nave].measureOffset = Nmeas; 317 tgtcat[0].average[Nave].objID = objID; 318 tgtcat[0].average[Nave].catID = catID; 319 320 // this star has not yet been merged into another tgtcat 321 tgtcat[0].found_t[Nave] = -1; 322 323 if (PSPS_ID) { 324 tgtcat[0].average[Nave].extID = CreatePSPSObjectID(tgtcat[0].average[Nave].R, tgtcat[0].average[Nave].D); 325 } 326 327 objID ++; 328 329 // we only update the secfilt table if it has been allocated for output 330 for (j = 0; tgtcat[0].secfilt && (j < Nsecfilt); j++) { 331 dvo_secfilt_init (&tgtcat[0].secfilt[Nave*Nsecfilt+j], SECFILT_RESET_ALL); 332 } 333 334 off_t mOff = srccat->average[i].measureOffset; 335 for (mSrc = 0; mSrc < srccat->average[i].Nmeasure; mSrc++) { 336 // supply the measurements from this detection 337 dvo_measure_init (&tgtcat[0].measure[Nmeas]); 338 tgtcat[0].measure[Nmeas] = srccat->measure[mSrc + mOff]; 339 340 // the following measure elements cannot be set until here: 341 tgtcat[0].measure[Nmeas].dbFlags = 0; 342 tgtcat[0].measure[Nmeas].averef = Nave; 343 tgtcat[0].measure[Nmeas].objID = tgtcat[0].average[Nave].objID; 344 tgtcat[0].measure[Nmeas].catID = tgtcat[0].catID; 345 346 /* set the average magnitude if not already set and the photcode.equiv is not 0 */ 347 /* in UPDATE mode, this value is not saved; use relphot to recalculate */ 348 if (Nsec > -1) { 349 tgtcat[0].secfilt[Nave*Nsecfilt+Nsec].M = PhotCat (&tgtcat[0].measure[Nmeas], MAG_CLASS_PSF); 350 } 351 352 Nmeas ++; 353 354 // update the next_meas pointer for this entry (last one for this star is -1) 355 next_meas[Nmeas-1] = (mSrc < srccat->average[i].Nmeasure - 1) ? Nmeas : -1; 356 } 357 srccat->found_t[i] = Nave; 328 358 329 359 // if we have lensing data, insert that as well 330 if (s tars[i].lensing) {331 catalog[0].average[Nave].Nlensing = NSTAR_GROUP;332 catalog[0].average[Nave].lensingOffset = Nlens;333 for (j = 0; j < NSTAR_GROUP; j++) { 334 // add the lensing values if they exist 335 if (stars[i + j].lensing) {336 dvo_lensing_init (&catalog[0].lensing[Nlens]);337 catalog[0].lensing[Nlens] = stars[i + j].lensing[0];360 if (srccat->lensing) { 361 tgtcat[0].average[Nave].Nlensing = srccat->average[i].Nlensing; 362 tgtcat[0].average[Nave].lensingOffset = Nlens; 363 364 off_t mOff = srccat->average[i].lensingOffset; 365 for (mSrc = 0; mSrc < srccat->average[i].Nlensing; mSrc++) { 366 dvo_lensing_init (&tgtcat[0].lensing[Nlens]); 367 tgtcat[0].lensing[Nlens] = srccat->lensing[mSrc + mOff]; 338 368 339 catalog[0].lensing[Nlens].averef = Nave; 340 catalog[0].lensing[Nlens].objID = catalog[0].average[Nave].objID; 341 catalog[0].lensing[Nlens].catID = catalog[0].catID; 342 next_lens[Nlens] = -1; 343 Nlens ++; 344 } 345 } 346 for (j = 0; j < NSTAR_GROUP - 1; j++) { 347 next_lens[Nlens - NSTAR_GROUP + j] = Nlens - NSTAR_GROUP + j + 1; 348 } 349 } 350 369 tgtcat[0].lensing[Nlens].averef = Nave; 370 tgtcat[0].lensing[Nlens].objID = tgtcat[0].average[Nave].objID; 371 tgtcat[0].lensing[Nlens].catID = tgtcat[0].catID; 372 Nlens ++; 373 next_lens[Nlens-1] = (mSrc < srccat->average[i].Nlensing - 1) ? Nlens : -1; 374 } 375 } 351 376 Nave ++; 352 377 } 353 354 REALLOCATE ( catalog[0].average, Average, Nave);355 REALLOCATE ( catalog[0].measure, Measure, Nmeas);356 REALLOCATE ( catalog[0].lensing, Lensing, Nlens);378 379 REALLOCATE (tgtcat[0].average, Average, Nave); 380 REALLOCATE (tgtcat[0].measure, Measure, Nmeas); 381 REALLOCATE (tgtcat[0].lensing, Lensing, Nlens); 357 382 358 383 if (options.nosort) { 359 catalog[0].sorted = FALSE;384 tgtcat[0].sorted = FALSE; 360 385 } else { 361 catalog[0].sorted = TRUE;362 catalog[0].measure = sort_measure (catalog[0].average, Nave, catalog[0].measure, Nmeas, next_meas);363 catalog[0].lensing = sort_lensing (catalog[0].average, Nave, catalog[0].lensing, Nlens, next_lens);364 } 365 366 /* note stars which have been found in this catalog*/367 for (i = 0; i < NstarsIn; i++) {368 if (s tars[i].found> -1) {369 s tars[i].found= -2;370 } 371 } 372 373 /* check if the cataloghas changed? if no change, no need to write */374 catalog[0].objID = objID; // new max value, save on catalogclose375 catalog[0].Naverage = Nave;376 catalog[0].Nmeasure = Nmeas;377 catalog[0].Nlensing = Nlens;378 catalog[0].Nsecfilt_mem = Nave*Nsecfilt;386 tgtcat[0].sorted = TRUE; 387 tgtcat[0].measure = sort_measure (tgtcat[0].average, Nave, tgtcat[0].measure, Nmeas, next_meas); 388 tgtcat[0].lensing = sort_lensing (tgtcat[0].average, Nave, tgtcat[0].lensing, Nlens, next_lens); 389 } 390 391 /* note stars which have been found in this tgtcat */ 392 for (i = 0; i < srccat->Naverage; i++) { 393 if (srccat->found_t[i] > -1) { 394 srccat->found_t[i] = -2; 395 } 396 } 397 398 /* check if the tgtcat has changed? if no change, no need to write */ 399 tgtcat[0].objID = objID; // new max value, save on tgtcat close 400 tgtcat[0].Naverage = Nave; 401 tgtcat[0].Nmeasure = Nmeas; 402 tgtcat[0].Nlensing = Nlens; 403 tgtcat[0].Nsecfilt_mem = tgtcat[0].secfilt ? Nave*Nsecfilt : 0; 379 404 if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas, Nlens: "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT", ("OFF_T_FMT" matches)\n", Nstars, Nave, Nmeas, Nlens, Nmatch); 380 405 … … 394 419 notes: 395 420 396 for finding if a catalog star is in an image or an image star is in the catalog:421 for finding if a tgtcat star is in an image or an image star is in the tgtcat: 397 422 398 catalogs have boundaries defined by RA and DEC, but they may curve in projection423 tgtcats have boundaries defined by RA and DEC, but they may curve in projection 399 424 images have boundaries which are lines in pixels coords, but curve in RA and DEC 400 425 401 catalog[0].found[Ncat] but stars[Nstar].found426 tgtcat[0].found[Ncat] but stars[Nstar].found 402 427 403 428 */ -
trunk/Ohana/src/addstar/test
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20150616/Ohana/src/addstar/test (added) merged: 38501,38524,38536-38537
- Property svn:mergeinfo changed
-
trunk/Ohana/src/addstar/test/compress.dvo
r38441 r38553 2 2 3 3 input tap.dvo 4 input ptolemy.dvo 5 6 # generates ptolemy.rc, dvo.photcodes, $zpt_nominal:g,r $klam_nominal:g,r 7 mkptolemy.rc 8 4 9 $CATDIR = catdir.test.v0 5 10 … … 38 43 mkinput 39 44 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC -type $1 $NO_NOISE 40 tapEXEC addstar -D CATCOMPRESS $3 -D CATDIR $CATDIR -D CAMERA simtesttest.cmf -D CATFORMAT $2 -quick-airmass45 tapEXEC addstar -D CATCOMPRESS $3 -D CATDIR $CATDIR -D CAMERA gpc1 test.cmf -D CATFORMAT $2 -quick-airmass 41 46 42 47 list testfields -copy testfields_$1 -
trunk/Ohana/src/addstar/test/dvomerge.dvo
r29938 r38553 2 2 3 3 input tap.dvo 4 input ptolemy.dvo 5 6 # generates ptolemy.rc, dvo.photcodes, $zpt_nominal:g,r $klam_nominal:g,r 7 mkptolemy.rc 8 9 macro test.all 10 $TAP_VERBOSE = 1 11 test.dvomerge.update.new 12 end 4 13 5 14 # create 2 populated catdirs, each with a couple of cmf files … … 8 17 tapPLAN 51 9 18 10 execrm -rf catdir.test111 execrm -rf catdir.test212 execrm -rf catdir.test319 tapEXEC rm -rf catdir.test1 20 tapEXEC rm -rf catdir.test2 21 tapEXEC rm -rf catdir.test3 13 22 14 23 $RA = 10.0 … … 16 25 17 26 mkinput 18 execmkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec 10.0 20.019 exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf20 21 execmkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec 10.0 20.022 exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf23 24 execmkcmf test.in.txt test.cmf -date 2008/1/1 -time 03:00:00 -radec 9.9 20.025 exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf26 27 execmkcmf test.in.txt test.cmf -date 2008/1/1 -time 04:00:00 -radec 9.9 20.028 exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf29 30 execmkcmf test.in.txt test.cmf -date 2008/1/1 -time 05:00:00 -radec 10.0 19.931 exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf32 33 execmkcmf test.in.txt test.cmf -date 2008/1/1 -time 06:00:00 -radec 10.0 19.934 exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf35 36 execmkcmf test.in.txt test.cmf -date 2008/1/1 -time 07:00:00 -radec 9.9 19.937 exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf38 39 execmkcmf test.in.txt test.cmf -date 2008/1/1 -time 08:00:00 -radec 9.9 19.940 exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf27 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec 10.0 20.0 28 tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA gpc1 test.cmf -quick-airmass 29 30 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec 10.0 20.0 31 tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA gpc1 test.cmf -quick-airmass 32 33 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 03:00:00 -radec 9.9 20.0 34 tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA gpc1 test.cmf -quick-airmass 35 36 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 04:00:00 -radec 9.9 20.0 37 tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA gpc1 test.cmf -quick-airmass 38 39 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 05:00:00 -radec 10.0 19.9 40 tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA gpc1 test.cmf -quick-airmass 41 42 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 06:00:00 -radec 10.0 19.9 43 tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA gpc1 test.cmf -quick-airmass 44 45 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 07:00:00 -radec 9.9 19.9 46 tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA gpc1 test.cmf -quick-airmass 47 48 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 08:00:00 -radec 9.9 19.9 49 tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA gpc1 test.cmf -quick-airmass 41 50 42 51 break 43 52 44 execrsync -auc catdir.test2/ catdir.test3/53 tapEXEC rsync -auc catdir.test2/ catdir.test3/ 45 54 46 55 date -var t1 -seconds -reftime 1276000000 47 execdvomerge catdir.test1 into catdir.test356 tapEXEC dvomerge catdir.test1 into catdir.test3 48 57 date -var t2 -seconds -reftime 1276000000 49 58 echo "merge time: {$t2 - $t1}" … … 114 123 end 115 124 116 # execrm test.in.txt test.cmf117 # execrm -rf catdir.test1118 # execrm -rf catdir.test2119 # execrm -rf catdir.test3125 # tapEXEC rm test.in.txt test.cmf 126 # tapEXEC rm -rf catdir.test1 127 # tapEXEC rm -rf catdir.test2 128 # tapEXEC rm -rf catdir.test3 120 129 121 130 tapDONE … … 127 136 tapPLAN 51 128 137 129 execrm -rf catdir.test1130 execrm -rf catdir.test2131 execrm -rf catdir.test3138 tapEXEC rm -rf catdir.test1 139 tapEXEC rm -rf catdir.test2 140 tapEXEC rm -rf catdir.test3 132 141 133 142 $RA = 10.0 … … 135 144 136 145 mkinput 137 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC 138 exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf 139 140 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec $RA $DEC 141 exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf 142 143 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 03:00:00 -radec $RA $DEC 144 exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf 145 146 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 04:00:00 -radec $RA $DEC 147 exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf 148 149 break 150 151 exec rsync -auc catdir.test2/ catdir.test3/ 146 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC 147 tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA gpc1 test.cmf -quick-airmass 148 149 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec $RA $DEC 150 tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA gpc1 test.cmf -quick-airmass 151 152 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 03:00:00 -radec $RA $DEC 153 tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA gpc1 test.cmf -quick-airmass 154 155 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 04:00:00 -radec $RA $DEC 156 tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA gpc1 test.cmf -quick-airmass 157 158 tapEXEC rsync -auc catdir.test2/ catdir.test3/ 152 159 153 160 date -var t1 -seconds -reftime 1276000000 154 execdvomerge catdir.test1 into catdir.test3161 tapEXEC dvomerge catdir.test1 into catdir.test3 155 162 date -var t2 -seconds -reftime 1276000000 156 163 echo "merge time: {$t2 - $t1}" … … 221 228 end 222 229 223 # execrm test.in.txt test.cmf224 # execrm -rf catdir.test1225 # execrm -rf catdir.test2226 # execrm -rf catdir.test3230 # tapEXEC rm test.in.txt test.cmf 231 # tapEXEC rm -rf catdir.test1 232 # tapEXEC rm -rf catdir.test2 233 # tapEXEC rm -rf catdir.test3 227 234 228 235 tapDONE … … 234 241 tapPLAN 51 235 242 236 execrm -rf catdir.test1237 execrm -rf catdir.test2243 tapEXEC rm -rf catdir.test1 244 tapEXEC rm -rf catdir.test2 238 245 239 246 $RA = 10.0 … … 241 248 242 249 mkinput 243 execmkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC244 exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf245 246 execmkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec $RA $DEC247 exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf250 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC 251 tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA gpc1 test.cmf -quick-airmass 252 253 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec $RA $DEC 254 tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA gpc1 test.cmf -quick-airmass 248 255 249 256 date -var t1 -seconds -reftime 1276000000 250 execdvomerge catdir.test1 into catdir.test2257 tapEXEC dvomerge catdir.test1 into catdir.test2 251 258 date -var t2 -seconds -reftime 1276000000 252 259 echo "merge time: {$t2 - $t1}" … … 297 304 end 298 305 299 # execrm test.in.txt test.cmf300 # execrm -rf catdir.test1301 # execrm -rf catdir.test2302 # execrm -rf catdir.test3306 # tapEXEC rm test.in.txt test.cmf 307 # tapEXEC rm -rf catdir.test1 308 # tapEXEC rm -rf catdir.test2 309 # tapEXEC rm -rf catdir.test3 303 310 304 311 tapDONE … … 310 317 tapPLAN 51 311 318 312 execrm -rf catdir.test1313 execrm -rf catdir.test2314 execrm -rf catdir.test3319 tapEXEC rm -rf catdir.test1 320 tapEXEC rm -rf catdir.test2 321 tapEXEC rm -rf catdir.test3 315 322 316 323 $RA = 10.0 … … 318 325 319 326 mkinput 320 execmkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC321 exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf322 323 execmkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec $RA $DEC324 exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf327 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC 328 tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA gpc1 test.cmf -quick-airmass 329 330 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec $RA $DEC 331 tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA gpc1 test.cmf -quick-airmass 325 332 326 333 # generate a few extra unmatched sources 327 334 mkinput.extras 328 execmkcmf test.in.txt test.cmf -date 2008/1/1 -time 03:00:00 -radec $RA $DEC329 exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf330 331 execmkcmf test.in.txt test.cmf -date 2008/1/1 -time 04:00:00 -radec $RA $DEC332 exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf333 334 execrsync -auc catdir.test2/ catdir.test3/335 336 execdvomerge catdir.test1 into catdir.test3335 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 03:00:00 -radec $RA $DEC 336 tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA gpc1 test.cmf -quick-airmass 337 338 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 04:00:00 -radec $RA $DEC 339 tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA gpc1 test.cmf -quick-airmass 340 341 tapEXEC rsync -auc catdir.test2/ catdir.test3/ 342 343 tapEXEC dvomerge catdir.test1 into catdir.test3 337 344 338 345 catdir catdir.test3 … … 401 408 end 402 409 403 # execrm test.in.txt test.cmf404 # execrm -rf catdir.test1405 # execrm -rf catdir.test2406 # execrm -rf catdir.test3410 # tapEXEC rm test.in.txt test.cmf 411 # tapEXEC rm -rf catdir.test1 412 # tapEXEC rm -rf catdir.test2 413 # tapEXEC rm -rf catdir.test3 407 414 408 415 tapDONE … … 414 421 tapPLAN 21 415 422 416 execrm -rf catdir.test1417 execrm -rf catdir.test2418 execrm -rf catdir.test3423 tapEXEC rm -rf catdir.test1 424 tapEXEC rm -rf catdir.test2 425 tapEXEC rm -rf catdir.test3 419 426 420 427 $RA = 10.0 … … 422 429 423 430 mkinput 424 execmkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC425 exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf426 427 execmkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec $RA $DEC428 exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf429 430 execmkcmf test.in.txt test.cmf -date 2008/1/1 -time 03:00:00 -radec $RA $DEC431 exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf432 433 execmkcmf test.in.txt test.cmf -date 2008/1/1 -time 04:00:00 -radec $RA $DEC434 exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf435 436 execdvomerge catdir.test1 and catdir.test2 to catdir.test3431 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC 432 tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA gpc1 test.cmf -quick-airmass 433 434 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec $RA $DEC 435 tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA gpc1 test.cmf -quick-airmass 436 437 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 03:00:00 -radec $RA $DEC 438 tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA gpc1 test.cmf -quick-airmass 439 440 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 04:00:00 -radec $RA $DEC 441 tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA gpc1 test.cmf -quick-airmass 442 443 tapEXEC dvomerge catdir.test1 and catdir.test2 to catdir.test3 437 444 438 445 catdir catdir.test3 … … 501 508 end 502 509 503 # execrm test.in.txt test.cmf504 # execrm -rf catdir.test1505 # execrm -rf catdir.test2506 # execrm -rf catdir.test3510 # tapEXEC rm test.in.txt test.cmf 511 # tapEXEC rm -rf catdir.test1 512 # tapEXEC rm -rf catdir.test2 513 # tapEXEC rm -rf catdir.test3 507 514 508 515 tapDONE … … 511 518 # make a simple input file for mkcmf 512 519 macro mkinput.alt 513 execrm -f test.in.txt520 tapEXEC rm -f test.in.txt 514 521 515 522 output test.in.txt … … 524 531 # make a simple input file for mkcmf 525 532 macro mkinput 526 execrm -f test.in.txt533 tapEXEC rm -f test.in.txt 527 534 528 535 output test.in.txt … … 537 544 # make a simple input file for mkcmf 538 545 macro mkinput.extras 539 execrm -f test.in.txt546 tapEXEC rm -f test.in.txt 540 547 541 548 output test.in.txt -
trunk/Ohana/src/addstar/test/relastro.dvo
r27582 r38553 2 2 3 3 input tap.dvo 4 input ptolemy.dvo 5 6 # generates ptolemy.rc, dvo.photcodes, $zpt_nominal:g,r $klam_nominal:g,r 7 mkptolemy.rc 4 8 5 9 macro test.all … … 60 64 mkinput $offset:$i 61 65 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time $i\:00:00 -radec $RA $DEC -type $1 62 exec addstar -D CATDIR catdir.test -D CAMERA simtesttest.cmf -D CATFORMAT $266 exec addstar -D CATDIR catdir.test -D CAMERA gpc1 test.cmf -D CATFORMAT $2 63 67 end 64 68 -
trunk/Ohana/src/addstar/test/relphot.dvo
r38441 r38553 3 3 4 4 input tap.dvo 5 input ptolemy.dvo 6 7 # generates ptolemy.rc, dvo.photcodes, $zpt_nominal:g,r $klam_nominal:g,r 8 mkptolemy.rc 5 9 6 10 macro test.all … … 39 43 mkinput $offset:$i 40 44 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time $i\:00:00 -radec $RA $DEC -type $1 41 exec addstar -D CATDIR catdir.test -D CAMERA simtesttest.cmf -D CATFORMAT $2 -quick-airmass45 exec addstar -D CATDIR catdir.test -D CAMERA gpc1 test.cmf -D CATFORMAT $2 -quick-airmass 42 46 end 43 47 -
trunk/Ohana/src/addstar/test/relphot.flatcorr.dvo
r38471 r38553 17 17 $TAP_VERBOSE = 1 18 18 input tap.dvo 19 input ptolemy.dvo 19 20 20 21 # set globals … … 31 32 # set various global variables 32 33 macro init 33 # generate a fake ptolemy.rc (to make this a contained test) 34 exec rm -f ptolemy.rc 35 output ptolemy.rc 36 echo "\#" 37 echo PHOTCODE_FILE dvo.photcodes 38 echo GSCFILE GSCregions.tbl 39 echo ZERO_PT 25.0 40 echo ADDSTAR_RADIUS 1.0 41 echo CATMODE SPLIT 42 echo CATFORMAT PS1_V5 43 # echo CATFORMAT PS1_V2 -- must be at least PS1_V3 for ubercaldist to work 44 echo SKY_DEPTH 4 45 echo CAMERA gpc1 46 echo CAMERA_CONFIG dvo.layout 47 echo "input dvo.config" 48 output stdout 49 50 # we need to define a photcode table consistent with the fake construction 51 $zpt_nominal:g = 24.0 52 $zpt_nominal:r = 24.5 53 54 # klam is negative, so klam*(airmass - 1) increases the zero point 55 $klam_nominal:g = -0.15 56 $klam_nominal:r = -0.10 57 58 # generate a fake dvo.photcode 59 exec rm -f dvo.photcodes 60 output dvo.photcodes 61 echo "\# code name type zero slope offset c1 c2 slope zero equiv sys scale scale sys poor bad poor bad" 62 echo "1 g sec 0.000 0.000 0.000 1 3 0.0000 0 1051 0.000 0.000 0.000 0.000 0x0000 0x0000 0x0000 0x0000" 63 echo "2 r sec 0.000 0.000 0.000 2 3 0.0000 0 1052 0.000 0.000 0.000 0.000 0x0000 0x0000 0x0000 0x0000" 64 echo "10000 GPC1.g.XY00 dep $zpt_nominal:g $klam_nominal:g 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 65 echo "10001 GPC1.g.XY01 dep $zpt_nominal:g $klam_nominal:g 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 66 echo "10010 GPC1.g.XY10 dep $zpt_nominal:g $klam_nominal:g 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 67 echo "10011 GPC1.g.XY11 dep $zpt_nominal:g $klam_nominal:g 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 68 echo "10100 GPC1.r.XY00 dep $zpt_nominal:r $klam_nominal:r 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 69 echo "10101 GPC1.r.XY01 dep $zpt_nominal:r $klam_nominal:r 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 70 echo "10110 GPC1.r.XY10 dep $zpt_nominal:r $klam_nominal:r 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 71 echo "10111 GPC1.r.XY11 dep $zpt_nominal:r $klam_nominal:r 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 72 echo "2011 2MASS_J ref 0.000 0.000 0.000 - - 0.0000 0 6 0.080 0.000 2.000 0.000 0x0000 0x0000 0x0000 0x0000" 73 echo "3001 SYNTH.g ref 0.000 0.000 0.000 - - 0.0000 0 1 nan 0.000 2.000 0.600 0x0000 0x0000 0x0000 0x0000" 74 echo "2020 TYCHO_B ref 0.000 0.000 0.000 - - 0.0000 0 - 0.000 0.000 0.000 0.000 0x0000 0x0000 0x0000 0x0000" 75 output stdout 34 35 # generates ptolemy.rc, dvo.photcodes, $zpt_nominal:g,r $klam_nominal:g,r 36 mkptolemy.rc 76 37 77 38 $RA_CENTER = 10.0 … … 897 858 mkinput test.in.txt $offset:$i 898 859 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time $i\:00:00 -radec $RA $DEC -type $1 899 exec addstar -D CATDIR catdir.test -D CAMERA simtesttest.cmf -D CATFORMAT $2860 exec addstar -D CATDIR catdir.test -D CAMERA gpc1 test.cmf -D CATFORMAT $2 900 861 end 901 862 -
trunk/Ohana/src/addstar/test/relphot.parallel.dvo
r37807 r38553 5 5 6 6 input tap.dvo 7 input ptolemy.dvo 8 9 # generates ptolemy.rc, dvo.photcodes, $zpt_nominal:g,r $klam_nominal:g,r 10 mkptolemy.rc 7 11 8 12 # set globals -
trunk/Ohana/src/addstar/test/relphot.reject.dvo
r33653 r38553 15 15 16 16 input tap.dvo 17 input ptolemy.dvo 18 19 # generates ptolemy.rc, dvo.photcodes, $zpt_nominal:g,r $klam_nominal:g,r 20 mkptolemy.rc 17 21 18 22 # set globals -
trunk/Ohana/src/addstar/test/simple.dvo
r38441 r38553 2 2 3 3 input tap.dvo 4 input ptolemy.dvo 5 6 # generates ptolemy.rc, dvo.photcodes, $zpt_nominal:g,r $klam_nominal:g,r 7 mkptolemy.rc 8 9 macro test.one 10 test.fields PS1_V5 PS1_V5 11 end 4 12 5 13 macro test.all … … 54 62 55 63 mkinput 56 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC -type $1 $NO_NOISE 57 tapEXEC addstar -D CATDIR catdir.test -D CAMERA simtest test.cmf -D CATFORMAT $2 -quick-airmass 64 # tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC -type $1 $NO_NOISE 65 66 $options = 67 $options = $options -type $1 68 $options = $options -radec $RA $DEC 69 $options = $options -mjd 54466.041667 70 $options = $options -date 2008/1/1 -time 01:00:00 71 $options = $options -photcode GPC1.g.XY00 72 $options = $options $NO_NOISE 73 74 # $options = $options -flags 75 # $options = $options -bad-psfqf-frac $DEFECT_FRAC 76 # $options = $options -size $CHIP_DX $CHIP_DY 77 # $options = $options -crpix {0.5*$CHIP_DX} {0.5*$CHIP_DY} 78 # $options = $options -airmass $AIRMASS 79 # $options = $options -exptime $EXPTIME 80 # $options = $options -coords 81 82 tapEXEC mkcmf test.in.txt test.cmf $options 83 tapEXEC addstar -D CATDIR catdir.test -D CAMERA gpc1 test.cmf -D CATFORMAT $2 -quick-airmass 58 84 59 85 list testfields -copy testfields_$1 -
trunk/Ohana/src/dvomerge/include/dvomerge.h
r38468 r38553 30 30 int VERIFY_CATALOG_ONLY; 31 31 int IMAGES_ONLY; 32 char CATDIR[ 256];33 char GSCFILE[ 256];34 char CATMODE[16]; /* raw, mef, split, mysql */35 char CAT FORMAT[16]; /* internal, elixir, loneos, panstarrs*/36 char ImageCat[256];32 char CATDIR[DVO_MAX_PATH]; 33 char GSCFILE[DVO_MAX_PATH]; 34 char ImageCat[DVO_MAX_PATH]; 35 char CATMODE[256]; /* raw, mef, split, mysql */ 36 char CATFORMAT[256]; /* internal, elixir, loneos, panstarrs */ 37 37 float RADIUS; 38 38 int SKY_DEPTH; 39 39 int NTHREADS; 40 char *ALTERNATE_PHOTCODE_FILE;41 40 int REPLACE_BY_PHOTCODE; 42 41 int REPLACE_TYCHO; 43 42 int FORCE_MERGE; 44 43 int MAX_CLIENTS; 44 char *ALTERNATE_PHOTCODE_FILE; 45 45 char *UPDATE_CATFORMAT; 46 46 char *UPDATE_CATCOMPRESS; … … 116 116 void dvomerge_help PROTO((int argc, char **argv)); 117 117 int dvomerge_args PROTO((int *argc, char **argv)); 118 void dvomerge_args_free PROTO((void)); 118 119 119 120 void dvomerge_client_usage PROTO((void)); … … 174 175 off_t dvo_map_image_ID PROTO((IDmapType *IDmap, off_t oldID)); 175 176 int dvo_update_image_IDs PROTO((IDmapType *IDmap, Catalog *catalog)); 177 void dvo_image_map_free PROTO((IDmapType *IDmap)); 178 void dvo_image_map_init PROTO((IDmapType *IDmap)); 176 179 177 180 // dvorepair prototypes … … 212 215 int dmhObjectCheck (dmhObject *history, dmhObjectStats *inStats); 213 216 dmhObject *dmhObjectRead (char *filename); 217 dmhObject *dmhObjectAlloc (void); 218 void dmhObjectFree (dmhObject *history); 214 219 215 220 void dmhObjectStatsFree (dmhObjectStats *stats); … … 217 222 218 223 int dmhImageAdd (FITS_DB *db, dmhImage *history, char *dbID); 219 dmhImage *dmhImageRead (FITS_DB *db) ;224 dmhImage *dmhImageRead (FITS_DB *db); 220 225 int dmhImageCheck (dmhImage *history, char *dbID); 226 void dmhImageFree(dmhImage *history); 221 227 222 228 char *dmhImageReadID (FITS_DB *db); -
trunk/Ohana/src/dvomerge/include/dvoverify.h
r37360 r38553 53 53 void AddFailures (char *filename); 54 54 char **GetFailures (int *N); 55 void FreeFailures (void); 55 56 56 57 int LoadImageIDs (char *catdir); … … 59 60 int SaveImageIDsSmall(char *filename); 60 61 int LoadImageIDsSmall (char *filename); 62 63 void FreeImageIDs (void); -
trunk/Ohana/src/dvomerge/src/ConfigInit.c
r27435 r38553 47 47 VERBOSE = TRUE; 48 48 49 FreeConfigFile(); 49 50 free (config); 50 51 free (file); -
trunk/Ohana/src/dvomerge/src/args.c
r38468 r38553 6 6 int N; 7 7 8 HOSTDIR = NULL; 9 SINGLE_CPT = NULL; 10 8 11 /* extra error messages */ 9 12 VERBOSE = FALSE; … … 53 56 54 57 /* use a different photcode file to define mean values */ 58 ALTERNATE_PHOTCODE_FILE = NULL; 55 59 if ((N = get_argument (*argc, argv, "-photcode-file"))) { 56 60 remove_argument (N, argc, argv); … … 156 160 } 157 161 162 void dvomerge_args_free (void) { 163 FREE (HOSTDIR); 164 FREE (ALTERNATE_PHOTCODE_FILE); 165 FREE (UPDATE_CATFORMAT); 166 FREE (UPDATE_CATCOMPRESS); 167 FREE (SINGLE_CPT); 168 } 169 158 170 /*** check for command line options ***/ 159 171 int dvomerge_client_args (int *argc, char **argv) { -
trunk/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c
r38441 r38553 5 5 void SortTgtByTimes (e_time *S, off_t *I, short *C, off_t N); 6 6 off_t getTgtIndex (e_time start, e_time stop, short photcode, off_t *TgtIndex, e_time *TgtTimes, short *TgtCodes, off_t NimagesTgt); 7 8 void dvo_image_map_init (IDmapType *IDmap) { 9 // we don't own the IDmap, just the elements 10 IDmap->old = NULL; 11 IDmap->new = NULL; 12 IDmap->notFound = NULL; 13 IDmap->Nmap = 0; 14 } 15 16 void dvo_image_map_free (IDmapType *IDmap) { 17 // we don't own the IDmap, just the elements 18 FREE (IDmap->old); 19 FREE (IDmap->new); 20 FREE (IDmap->notFound); 21 } 7 22 8 23 // we have two tables; 'tgt' contains some exposures from 'src' : find them and match a map -
trunk/Ohana/src/dvomerge/src/dvomerge.c
r35765 r38553 7 7 ConfigInit (&argc, argv); 8 8 dvomerge_args (&argc, argv); 9 10 if ((argc < 4) || (argc > 6)) dvomerge_usage(); 9 11 10 12 if (argc == 6) { … … 38 40 } 39 41 } 40 dvomerge_usage(); 41 exit (2); // cannot reach here. 42 dvomerge_args_free (); 43 ohana_memcheck (TRUE); 44 ohana_memdump (TRUE); 45 exit (0); 42 46 } 43 47 -
trunk/Ohana/src/dvomerge/src/dvomergeHistory.c
r34578 r38553 28 28 char *ID = strcreate (dbID); 29 29 return ID; 30 } 31 32 void dmhImageFree(dmhImage *history) { 33 if (!history) return; 34 35 int i; 36 for (i = 0; i < history->Nmerge; i++) { 37 FREE (history->IDs[i]); 38 } 39 FREE (history->IDs); 40 FREE (history); 30 41 } 31 42 … … 125 136 } 126 137 138 dmhObject *dmhObjectAlloc (void) { 139 140 dmhObject *history = NULL; 141 ALLOCATE (history, dmhObject, 1); 142 history->Nmerge = 0; 143 144 // ALLOCATE full list 145 ALLOCATE (history->size, off_t, history->Nmerge); 146 ALLOCATE (history->time, time_t, history->Nmerge); 147 ALLOCATE (history->date, char *, history->Nmerge); 148 return history; 149 } 150 151 void dmhObjectFree (dmhObject *history) { 152 if (!history) return; 153 154 FREE (history->size); 155 FREE (history->time); 156 157 if (history->date) { 158 int i; 159 for (i = 0; i < history->Nmerge; i++) { 160 FREE (history->date[i]); 161 } 162 } 163 FREE (history->date); 164 FREE (history); 165 return; 166 } 167 127 168 // read the array of merged history information from this file's header 128 169 dmhObject *dmhObjectRead (char *filename) { … … 133 174 if (stat_result) { 134 175 if (errno == ENOENT) { 135 dmhObject *history = NULL; 136 ALLOCATE (history, dmhObject, 1); 137 history->Nmerge = 0; 138 139 // ALLOCATE full list 140 ALLOCATE (history->size, off_t, history->Nmerge); 141 ALLOCATE (history->time, time_t, history->Nmerge); 142 ALLOCATE (history->date, char *, history->Nmerge); 176 dmhObject *history = dmhObjectAlloc(); 143 177 return history; 144 178 } … … 162 196 fclose (fout); 163 197 164 dmhObject *history = NULL; 165 ALLOCATE (history, dmhObject, 1); 198 dmhObject *history = dmhObjectAlloc(); 166 199 167 200 int status = gfits_scan (&outheader, "NMERGE", "%d", 1, &history->Nmerge); … … 171 204 172 205 // ALLOCATE full list 173 ALLOCATE (history->size, off_t, history->Nmerge);174 ALLOCATE (history->time, time_t, history->Nmerge);175 ALLOCATE (history->date, char *, history->Nmerge);206 REALLOCATE (history->size, off_t, history->Nmerge); 207 REALLOCATE (history->time, time_t, history->Nmerge); 208 REALLOCATE (history->date, char *, history->Nmerge); 176 209 177 210 int i; … … 199 232 history->time[i] = ohana_date_to_sec (date); 200 233 } 234 gfits_free_header (&outheader); 201 235 return history; 202 236 } … … 239 273 history->size[last] = inStats->size; 240 274 history->time[last] = inStats->time; 241 history->date[last] = inStats->date;275 history->date[last] = strcreate (inStats->date); 242 276 243 277 char name[16]; … … 280 314 int i; 281 315 for (i = 0; i < N; i++) { 282 if (outstat[i].history) { free (outstat[i].history); }316 if (outstat[i].history) { dmhObjectFree (outstat[i].history); } 283 317 if (outstat[i].filename) { free (outstat[i].filename); } 284 318 } -
trunk/Ohana/src/dvomerge/src/dvomergeImageIDs.c
r38441 r38553 64 64 dvo_image_match_dbs(IDmap, &outDB, &inDB); 65 65 dvo_image_unlock (&outDB); // unlock output 66 67 gfits_db_free (&inDB); 68 gfits_db_free (&outDB); 69 dmhImageFree (history); 70 FREE (indbID); 66 71 return TRUE; 67 72 } … … 80 85 SetProtect (FALSE); 81 86 dvo_image_unlock (&outDB); // unlock output 87 88 gfits_db_free (&inDB); 89 gfits_db_free (&outDB); 90 91 dmhImageFree (history); 92 FREE (indbID); 82 93 83 94 return TRUE; … … 136 147 dvo_image_match_dbs(IDmap, &outDB, &inDB); 137 148 149 gfits_db_free (&inDB); 150 gfits_db_free (&outDB); 151 138 152 return TRUE; 139 153 } -
trunk/Ohana/src/dvomerge/src/dvomergeUpdate.c
r38468 r38553 8 8 char filename[256], *input, *output; 9 9 IDmapType IDmap; 10 PhotCodeData *inputPhotcodes;11 PhotCodeData *outputPhotcodes;12 10 int *secfiltMap = NULL; 13 11 int NsecfiltInput, NsecfiltOutput; 14 12 15 13 INITTIME; 14 15 dvo_image_map_init (&IDmap); 16 16 17 17 CONTINUE = FALSE; … … 34 34 exit (1); 35 35 } 36 37 PhotCodeData *inputPhotcodes = NULL; 38 PhotCodeData *outputPhotcodes = NULL; 36 39 37 40 SetPhotcodeTable(NULL); … … 120 123 exit (1); 121 124 } 125 FREE (skyfile); 126 127 SkyTableFree (insky); 128 SkyTableFree (outsky); 129 SkyListFree (inlist); 130 131 FREE (secfiltMap); 132 dvo_image_map_free (&IDmap); 133 if (outputPhotcodes != inputPhotcodes) { FreePhotcodeData (outputPhotcodes); } 134 FreePhotcodeData (inputPhotcodes); 135 FreePhotcodeTable (); 122 136 123 137 if (!status) { … … 127 141 128 142 MARKTIME ("SUCCESS: elapsed time %9.4f sec\n", dtime); 129 exit (0);143 return TRUE; 130 144 } -
trunk/Ohana/src/dvomerge/src/dvoverify.c
r34405 r38553 24 24 25 25 // check the photcode table 26 sprintf (filename, "%s/Photcodes.dat", CATDIR);26 myAssert (snprintf (filename, DVO_MAX_PATH, "%s/Photcodes.dat", CATDIR) < DVO_MAX_PATH, "overflow"); 27 27 if (!VerifyTableFile (filename)) { 28 28 Nbad ++; … … 34 34 Nbad ++; 35 35 } 36 free (skyfile); 36 37 37 38 // check the image table 38 sprintf (filename, "%s/Images.dat", CATDIR);39 myAssert (snprintf (filename, DVO_MAX_PATH, "%s/Images.dat", CATDIR) < DVO_MAX_PATH, "overflow"); 39 40 if (!VerifyTableFile (filename)) { 40 41 Nbad ++; … … 71 72 fprintf (stderr, "NOTE: %d files are not sorted\n", NNotSorted); 72 73 } 74 75 FreeImageIDs (); 76 FreeFailures (); 77 SkyTableFree (sky); 78 SkyListFree (skylist); 79 80 ohana_memcheck (TRUE); 81 ohana_memdump (TRUE); 73 82 exit (0); 74 83 } -
trunk/Ohana/src/dvomerge/src/dvoverify_args.c
r37360 r38553 45 45 } 46 46 47 CHECK_IMAGE_ID = FALSE; 48 47 49 int isGood = dvoverify_single (filename); 50 free (filename); 51 52 ohana_memcheck (TRUE); 53 ohana_memdump (TRUE); 54 48 55 if (!isGood) exit (1); 49 56 exit (0); -
trunk/Ohana/src/dvomerge/src/dvoverify_catalogs.c
r37360 r38553 27 27 if (!HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue; 28 28 29 sprintf (filename, "%s/%s.cpt", mycatdir, skylist[0].regions[i][0].name);29 myAssert (snprintf (filename, DVO_MAX_PATH, "%s/%s.cpt", mycatdir, skylist[0].regions[i][0].name) < DVO_MAX_PATH, "overflow"); 30 30 if (!VerifyTableFile (filename)) { 31 31 Nbad ++; … … 34 34 } 35 35 36 sprintf (filename, "%s/%s.cps", mycatdir, skylist[0].regions[i][0].name);36 myAssert (snprintf (filename, DVO_MAX_PATH, "%s/%s.cps", mycatdir, skylist[0].regions[i][0].name) < DVO_MAX_PATH, "overflow"); 37 37 if (!VerifyTableFile (filename)) { 38 38 Nbad ++; … … 40 40 } 41 41 42 sprintf (filename, "%s/%s.cpm", mycatdir, skylist[0].regions[i][0].name);42 myAssert (snprintf (filename, DVO_MAX_PATH, "%s/%s.cpm", mycatdir, skylist[0].regions[i][0].name) < DVO_MAX_PATH, "overflow"); 43 43 if (!VerifyTableFile (filename)) { 44 44 Nbad ++; … … 47 47 } 48 48 49 sprintf (filename, "%s/%s.cpx", mycatdir, skylist[0].regions[i][0].name);49 myAssert (snprintf (filename, DVO_MAX_PATH, "%s/%s.cpx", mycatdir, skylist[0].regions[i][0].name) < DVO_MAX_PATH, "overflow"); 50 50 if (!VerifyTableFile (filename)) { 51 51 Nbad ++; … … 54 54 } 55 55 56 sprintf (filename, "%s/%s.cpy", mycatdir, skylist[0].regions[i][0].name);56 myAssert (snprintf (filename, DVO_MAX_PATH, "%s/%s.cpy", mycatdir, skylist[0].regions[i][0].name) < DVO_MAX_PATH, "overflow"); 57 57 if (!VerifyTableFile (filename)) { 58 58 Nbad ++; … … 61 61 } 62 62 63 sprintf (filename, "%s/%s.cpt", mycatdir, skylist[0].regions[i][0].name);63 myAssert (snprintf (filename, DVO_MAX_PATH, "%s/%s.cpt", mycatdir, skylist[0].regions[i][0].name) < DVO_MAX_PATH, "overflow"); 64 64 if (!skipIndexCheck) { 65 65 if (!CheckCatalogIndexes(filename, skylist[0].regions[i])){ -
trunk/Ohana/src/dvomerge/src/dvoverify_utils.c
r38471 r38553 5 5 static char **failures = NULL; 6 6 7 void InitFailures () { 8 ALLOCATE (failures, char *, NFAILURES); 7 void InitFailures (void) { 8 ALLOCATE_ZERO (failures, char *, NFAILURES); 9 } 10 11 void FreeFailures (void) { 12 int i; 13 14 if (!failures) return; 15 for (i = 0; i < NFAILURES; i++) { 16 FREE (failures[i]); 17 } 18 FREE (failures); 9 19 } 10 20 … … 128 138 fprintf (stderr, "unable to read header for %s, extension %d (or file has excess bytes)\n", filename, Next); 129 139 } 130 fclose(file); 140 fclose (file); 141 gfits_free_header (&header); 131 142 return (FALSE); 132 143 } … … 175 186 176 187 // set the parameters which guide catalog open/load/create 177 dvo_catalog_init (&catalog, TRUE);188 dvo_catalog_init (&catalog, TRUE); 178 189 catalog.filename = filename; 179 190 catalog.catflags = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_LENSING | DVO_LOAD_LENSOBJ; … … 183 194 if (!dvo_catalog_open (&catalog, region, VERBOSE, "r")) { 184 195 fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename); 196 dvo_catalog_free (&catalog); 185 197 return FALSE; 186 198 } … … 463 475 464 476 char ImageCat[DVO_MAX_PATH]; 465 snprintf (ImageCat, DVO_MAX_PATH, "%s/Images.dat", catdir);477 myAssert (snprintf (ImageCat, DVO_MAX_PATH, "%s/Images.dat", catdir) < DVO_MAX_PATH, "overflow"); 466 478 467 479 // load the iage database table … … 506 518 IDlist[id] = i; 507 519 } 508 509 // free image table here? 520 510 521 // (in the future, I'll have to do the image table read in segments 511 522 // it is just getting to be too large...) 512 523 dvo_image_unlock (&inDB); // unlock input 524 gfits_db_free (&inDB); 513 525 514 526 return TRUE; 527 } 528 529 void FreeImageIDs (void) { 530 FREE (IDlist); 515 531 } 516 532 -
trunk/Ohana/src/imregister/photreg/output.c
r38441 r38553 96 96 extname = strcreate ("SUMMARY_ZPTS"); 97 97 } 98 98 99 gfits_create_table_header (&theader, "TABLE", extname); 99 100 -
trunk/Ohana/src/kapa2/src/bDrawIt.c
r38465 r38553 3 3 bDrawBuffer *bDrawIt (png_color *palette, int Npalette, int Nbyte) { 4 4 5 int i, Nsection;5 int i, j, Nsection; 6 6 bDrawBuffer *buffer; 7 7 bDrawColor black; … … 23 23 section = GetSectionByNumber (i); 24 24 bDrawImage (buffer, section->image, graphic); 25 for ( i = 0; section->image && (i < NOVERLAYS); i++) {26 if (section->image->overlay[ i].active) bDrawOverlay (buffer, section->image, i);25 for (j = 0; section->image && (j < NOVERLAYS); j++) { 26 if (section->image->overlay[j].active) bDrawOverlay (buffer, section->image, j); 27 27 } 28 28 bDrawGraph (buffer, section->graph); -
trunk/Ohana/src/libautocode/Makefile.Targets
r38441 r38553 55 55 $(ASRC)/starpar-ps1-v5.$(ARCH).o \ 56 56 $(ASRC)/starpar-ps1-sim.$(ARCH).o \ 57 $(ASRC)/gal shape.$(ARCH).o \58 $(ASRC)/gal shape-ps1-v5.$(ARCH).o \57 $(ASRC)/galphot.$(ARCH).o \ 58 $(ASRC)/galphot-ps1-v5.$(ARCH).o \ 59 59 $(ASRC)/missing.$(ARCH).o \ 60 60 $(ASRC)/photcode.$(ARCH).o \ … … 167 167 $(AINC)/starpar-ps1-v5.h \ 168 168 $(AINC)/starpar-ps1-sim.h \ 169 $(AINC)/gal shape.h \170 $(AINC)/gal shape-ps1-v5.h \169 $(AINC)/galphot.h \ 170 $(AINC)/galphot-ps1-v5.h \ 171 171 $(AINC)/missing.h \ 172 172 $(AINC)/photcode.h \ -
trunk/Ohana/src/libdvo/include/cmf-ps1-v5-r2-lensing.h
r37993 r38553 95 95 96 96 CMF_PS1_V5_R2_Lensing *gfits_table_get_CMF_PS1_V5_R2_Lensing (FTable *table, off_t *Ndata, char *swapped); 97 CMF_PS1_V5_R2_Lensing *gfits_table_get_CMF_PS1_V5_R2x_Lensing (FTable *ftable, off_t *Ndata, char *swapped); 98 97 99 int gfits_table_set_CMF_PS1_V5_R2_Lensing (FTable *ftable, CMF_PS1_V5_R2_Lensing *data, off_t Ndata); 98 100 int gfits_table_mkheader_CMF_PS1_V5_R2_Lensing (Header *header); -
trunk/Ohana/src/libdvo/include/convert.h
r31635 r38553 13 13 int hh_hms PROTO((double hh, int *hr, int *mn, double *sc)); 14 14 int dd_dms PROTO((double dd, int *dg, int *mn, double *sc)); 15 int hms_format PROTO((char *line, double value));16 int dms_format PROTO((char *line, double value));15 int hms_format PROTO((char *line, int length, double value)); 16 int dms_format PROTO((char *line, int length, double value)); 17 17 int hh_hm PROTO((double hh, int *hr, double *mn)); 18 18 int day_to_sec PROTO((char *string, time_t *second)); -
trunk/Ohana/src/libdvo/include/dvo.h
r38472 r38553 259 259 typedef struct { 260 260 off_t Nregions; 261 off_t Nalloc; 261 262 char **filename; 262 263 SkyRegion *regions; … … 920 921 PhotCodeData *GetPhotcodeTable (void); 921 922 void SetPhotcodeTable (PhotCodeData *); 923 void FreePhotcodeData (PhotCodeData *myPhotcodes); 924 void FreePhotcodeTable (void); 922 925 923 926 int *GetSecFiltMap(PhotCodeData *ouput, PhotCodeData* input); -
trunk/Ohana/src/libdvo/src/HostTable.c
r38441 r38553 62 62 char *filename = NULL; 63 63 64 ALLOCATE (filename, char, strlen(catdir) + strlen(rootname) + 2); // one slash and one EOL 65 sprintf (filename, "%s/%s", catdir, rootname); 64 int Nchar = strlen(catdir) + strlen(rootname) + 16; 65 ALLOCATE (filename, char, Nchar); // one slash and one EOL 66 snprintf (filename, Nchar, "%s/%s", catdir, rootname); 66 67 67 68 FILE *f = fopen (filename, "r"); -
trunk/Ohana/src/libdvo/src/LoadImages.c
r38441 r38553 23 23 24 24 catdir = dvo_get_catdir (); 25 s printf (filename, "%s/Images.dat", catdir);25 snprintf (filename, 256, "%s/Images.dat", catdir); 26 26 27 27 if (lastFilename) { -
trunk/Ohana/src/libdvo/src/LoadPhotcodesFITS.c
r38441 r38553 51 51 } \ 52 52 photcode = PhotCode_##FORMAT##_To_Internal (photcode_input, Ncode); \ 53 free (photcode_input); \54 53 } 55 54 … … 65 64 CONVERT_FORMAT("DVO_PHOTCODE_PS1_V4", PS1_V4); 66 65 CONVERT_FORMAT("DVO_PHOTCODE_PS1_V5", PS1_V5); 66 67 gfits_db_free (&db); 67 68 68 69 table = GetPhotcodeTable (); -
trunk/Ohana/src/libdvo/src/RegionHostTable.c
r37807 r38553 64 64 char *filename = NULL; 65 65 66 ALLOCATE (filename, char, strlen(catdir) + strlen(rootname) + 2); // one slash and one EOL 67 sprintf (filename, "%s/%s", catdir, rootname); 66 int Nchar = strlen(catdir) + strlen(rootname) + 16; 67 68 ALLOCATE (filename, char, Nchar); // one slash and one EOL 69 snprintf (filename, Nchar, "%s/%s", catdir, rootname); 68 70 69 71 FILE *f = fopen (filename, "r"); -
trunk/Ohana/src/libdvo/src/SavePhotcodesFITS.c
r38441 r38553 37 37 if (!gfits_db_save (&db)) return (FALSE); 38 38 if (!gfits_db_close (&db)) return (FALSE); 39 if (!gfits_db_free (&db)) return (FALSE); 39 40 40 41 free (photcode_output); -
trunk/Ohana/src/libdvo/src/cmf-ps1-v5-r2-lensing.c
r37992 r38553 480 480 } 481 481 482 /** ****/ 483 int fix_lensing (char *data, int Nrows) { 484 485 off_t i; 486 487 int Nbytes = sizeof (CMF_PS1_V5_R2_Lensing); 488 489 char buffer[64]; 490 491 char *ptr = data; 492 for (i = 0; i < Nrows; i++, ptr += Nbytes) { 493 // bytes 184 - 224 (exclusive) are now at 288 - 328 (exclusive) 494 memcpy (buffer, &ptr[288], 40); 495 memmove (&ptr[224], &ptr[184], 104); 496 memcpy (&ptr[184], buffer, 40); 497 } 498 return TRUE; 499 } 500 501 /**************************************/ 502 CMF_PS1_V5_R2_Lensing *gfits_table_get_CMF_PS1_V5_R2x_Lensing (FTable *ftable, off_t *Ndata, char *swapped) { 503 504 int Ncols; 505 CMF_PS1_V5_R2_Lensing *data; 506 507 Ncols = ftable[0].header[0].Naxis[0]; 508 if (Ncols != ST_SIZE) { 509 fprintf (stderr, "ERROR: mis-match in table size: width is %d but should be %d bytes\n", Ncols, ST_SIZE); 510 return NULL; 511 } 512 513 *Ndata = ftable[0].header[0].Naxis[1]; 514 515 fix_lensing (ftable[0].buffer, *Ndata); 516 data = (CMF_PS1_V5_R2_Lensing *) ftable[0].buffer; 517 if ((swapped == NULL) || (*swapped == FALSE)) { 518 if (!gfits_convert_CMF_PS1_V5_R2_Lensing ((unsigned char *) data, sizeof (CMF_PS1_V5_R2_Lensing), *Ndata, TRUE)) { 519 return NULL; 520 } 521 off_t i; 522 for (i = 0; i < *Ndata; i++) { 523 data[i].detID += 0x80000000; 524 data[i].flags += 0x80000000; 525 data[i].flags2 += 0x80000000; 526 data[i].nFrames += 0x8000; 527 } 528 // gfits_table_scale_data (ftable); 529 if (swapped != NULL) *swapped = TRUE; 530 } 531 return (data); 532 } 533 -
trunk/Ohana/src/libdvo/src/convert.c
r31635 r38553 46 46 } 47 47 48 int hms_format (char *line, double value) {48 int hms_format (char *line, int length, double value) { 49 49 50 50 int hr, mn; … … 54 54 hr = (int) value; 55 55 if (isnan (value)) 56 s printf (line, "xx:xx:xx.xx");56 snprintf (line, length, "xx:xx:xx.xx"); 57 57 else { 58 58 if (value < 0) { 59 s printf (line, "-%02d:%02d:%05.2f", abs(hr), mn, sc);59 snprintf (line, length, "-%02d:%02d:%05.2f", abs(hr), mn, sc); 60 60 } else { 61 s printf (line, "+%02d:%02d:%05.2f", hr, mn, sc);61 snprintf (line, length, "+%02d:%02d:%05.2f", hr, mn, sc); 62 62 } 63 63 } … … 65 65 } 66 66 67 int dms_format (char *line, double value) {67 int dms_format (char *line, int length, double value) { 68 68 69 69 int dg, mn; … … 72 72 dd_dms (value, &dg, &mn, &sc); 73 73 if (value < 0) { 74 s printf (line, "-%02d:%02d:%05.2f", abs(dg), mn, sc);74 snprintf (line, length, "-%02d:%02d:%05.2f", abs(dg), mn, sc); 75 75 } else { 76 s printf (line, "+%02d:%02d:%05.2f", dg, mn, sc);76 snprintf (line, length, "+%02d:%02d:%05.2f", dg, mn, sc); 77 77 } 78 78 return (TRUE); … … 134 134 ALLOCATE (line, char, 64); 135 135 gmt = gmtime (&second); 136 s printf (line, "%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);136 snprintf (line, 64, "%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 137 137 return (line); 138 138 } … … 148 148 switch (gmt[0].tm_wday) { 149 149 case 0: 150 s printf (line, "Sun@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);150 snprintf (line, 64, "Sun@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 151 151 break; 152 152 case 1: 153 s printf (line, "Mon@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);153 snprintf (line, 64, "Mon@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 154 154 break; 155 155 case 2: 156 s printf (line, "Tue@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);156 snprintf (line, 64, "Tue@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 157 157 break; 158 158 case 3: 159 s printf (line, "Wed@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);159 snprintf (line, 64, "Wed@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 160 160 break; 161 161 case 4: 162 s printf (line, "Thu@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);162 snprintf (line, 64, "Thu@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 163 163 break; 164 164 case 5: 165 s printf (line, "Fri@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);165 snprintf (line, 64, "Fri@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 166 166 break; 167 167 case 6: 168 s printf (line, "Sat@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);168 snprintf (line, 64, "Sat@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 169 169 break; 170 170 } … … 195 195 hh_hm (deg, &hr, &mn); 196 196 197 s printf (line, "%03d:%04.1f", abs(hr), mn);197 snprintf (line, 16, "%03d:%04.1f", abs(hr), mn); 198 198 return (line); 199 199 } … … 209 209 hh_hm (deg/15.0, &hr, &mn); 210 210 211 s printf (line, "%02d:%04.1f", abs(hr), mn);211 snprintf (line, 16, "%02d:%04.1f", abs(hr), mn); 212 212 return (line); 213 213 } … … 224 224 225 225 if (deg < 0) { 226 s printf (line, "-%02d:%04.1f", abs(hr), mn);226 snprintf (line, 16, "-%02d:%04.1f", abs(hr), mn); 227 227 } else { 228 s printf (line, "+%02d:%04.1f", hr, mn);228 snprintf (line, 16, "+%02d:%04.1f", hr, mn); 229 229 } 230 230 return (line); -
trunk/Ohana/src/libdvo/src/coordops.c
r38462 r38553 740 740 for (i = 0; i < 14; i++) { 741 741 char name[64]; 742 s printf (name, "PV2_%d", i);742 snprintf (name, 64, "PV2_%d", i); 743 743 if (i < 7) { 744 744 found = gfits_scan (header, name, "%f", 1, &coords[0].polyterms[0][i]); … … 834 834 if (!strncmp (coords[0].ctype, "SLAT", 4)) strcpy (csys, "SLON"); 835 835 if (!strcmp (csys, "NONE")) return (FALSE); 836 s printf (ctype, "%s-%s", csys, &coords[0].ctype[5]);836 snprintf (ctype, 16, "%s-%s", csys, &coords[0].ctype[5]); 837 837 gfits_modify (header, "CTYPE1", "%s", 1, ctype); 838 838 } -
trunk/Ohana/src/libdvo/src/dvo_catalog.c
r38462 r38553 85 85 86 86 // we can return a static string here unless we run multiple outputs threads at once 87 static char compress_string[16];88 87 char *dvo_catalog_compress_string (DVOCatCompress catcompress) { 89 88 char *compress_string = NULL; 90 89 switch (catcompress) { 91 90 case DVO_COMPRESS_NONE: 92 strcpy (compress_string,"NONE");91 compress_string = strcreate("NONE"); 93 92 break; 94 93 case DVO_COMPRESS_AUTO: 95 strcpy (compress_string,"AUTO");94 compress_string = strcreate("AUTO"); 96 95 break; 97 96 case DVO_COMPRESS_GZIP_1: 98 strcpy (compress_string,"GZIP_1");97 compress_string = strcreate("GZIP_1"); 99 98 break; 100 99 case DVO_COMPRESS_GZIP_2: 101 strcpy (compress_string,"GZIP_2");100 compress_string = strcreate("GZIP_2"); 102 101 break; 103 102 case DVO_COMPRESS_NONE_1: 104 strcpy (compress_string,"NONE_1");103 compress_string = strcreate("NONE_1"); 105 104 break; 106 105 case DVO_COMPRESS_NONE_2: 107 strcpy (compress_string,"NONE_2");106 compress_string = strcreate("NONE_2"); 108 107 break; 109 108 case DVO_COMPRESS_RICE_1: 110 strcpy (compress_string,"RICE_1");109 compress_string = strcreate("RICE_1"); 111 110 break; 112 111 default: … … 532 531 galphot->minorAxisErr = NAN; 533 532 galphot->theta = NAN; 534 galphot->theta _err= NAN;533 galphot->thetaErr = NAN; 535 534 galphot->index = NAN; 536 535 galphot->chisq = NAN; … … 541 540 galphot->catID = -1; 542 541 galphot->imageID = -1; 542 galphot->averef = 0; 543 543 544 544 galphot->photcode = 0; … … 1157 1157 return FALSE; 1158 1158 } 1159 1159 1160 int outStatus = TRUE; 1160 1161 status = unlink (tmpfilename); 1161 1162 if (status) { 1163 perror ("unlink: "); 1162 1164 fprintf (stderr, "failed to unlink catalog %s~\n", catalog->filename); 1163 returnFALSE;1165 outStatus = FALSE; 1164 1166 } 1165 1167 … … 1167 1169 if (catalog[0].measure_catalog != NULL) { 1168 1170 if (!dvo_catalog_unlink_backup (catalog[0].measure_catalog, FALSE)) { 1169 returnFALSE;1171 outStatus = FALSE; 1170 1172 } 1171 1173 } 1172 1174 if (catalog[0].missing_catalog != NULL) { 1173 1175 if (!dvo_catalog_unlink_backup (catalog[0].missing_catalog, FALSE)) { 1174 returnFALSE;1176 outStatus = FALSE; 1175 1177 } 1176 1178 } 1177 1179 if (catalog[0].secfilt_catalog != NULL) { 1178 1180 if (!dvo_catalog_unlink_backup (catalog[0].secfilt_catalog, FALSE)) { 1179 returnFALSE;1181 outStatus = FALSE; 1180 1182 } 1181 1183 } 1182 1184 if ((catalog[0].lensing_catalog != NULL) && (catalog[0].Nlensing_disk > 0)) { 1183 1185 if (!dvo_catalog_unlink_backup (catalog[0].lensing_catalog, FALSE)) { 1184 returnFALSE;1186 outStatus = FALSE; 1185 1187 } 1186 1188 } 1187 1189 if ((catalog[0].lensobj_catalog != NULL) && (catalog[0].Nlensobj_disk > 0)) { 1188 1190 if (!dvo_catalog_unlink_backup (catalog[0].lensobj_catalog, FALSE)) { 1189 returnFALSE;1191 outStatus = FALSE; 1190 1192 } 1191 1193 } 1192 1194 if ((catalog[0].starpar_catalog != NULL) && (catalog[0].Nstarpar_disk > 0)) { 1193 1195 if (!dvo_catalog_unlink_backup (catalog[0].starpar_catalog, FALSE)) { 1194 returnFALSE;1196 outStatus = FALSE; 1195 1197 } 1196 1198 } 1197 1199 if ((catalog[0].galphot_catalog != NULL) && (catalog[0].Ngalphot_disk > 0)) { 1198 1200 if (!dvo_catalog_unlink_backup (catalog[0].galphot_catalog, FALSE)) { 1199 returnFALSE;1200 } 1201 } 1202 } 1203 return TRUE;1204 } 1205 1206 1201 outStatus = FALSE; 1202 } 1203 } 1204 } 1205 return outStatus; 1206 } 1207 1208 -
trunk/Ohana/src/libdvo/src/dvo_catalog_create.c
r38441 r38553 105 105 char *path = pathname (catalog[0].filename); 106 106 char *root = filerootname (catalog[0].filename); 107 int length = strlen(path) + strlen(root) + 6; 107 108 int length = strlen(path) + strlen(root) + 16; 108 109 109 110 Catalog *subcat; … … 120 121 ALLOCATE (subcat->filename, char, length); 121 122 122 s printf (subcat->filename, "%s/%s.%s", path, root, ext);123 snprintf (subcat->filename, length, "%s/%s.%s", path, root, ext); 123 124 124 125 char *file = filebasename (subcat->filename); -
trunk/Ohana/src/libdvo/src/dvo_catalog_split.c
r38441 r38553 90 90 int dvo_catalog_save_subcat (Catalog *catalog, FTable *ftable, off_t start, off_t Nrows, off_t Ndisk, off_t Ntotal) { 91 91 92 Matrix matrix; 93 94 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 92 if (OHANA_MEMCHECK) ohana_memcheck (TRUE); 95 93 96 94 /* rewind file pointers and truncate (file is still open) */ … … 108 106 off_t fullsize = catalog->header.datasize; 109 107 108 # if (1) 110 109 // write the PHU matrix; this is probably a NOP, do I have to keep it in? 110 Matrix matrix; 111 111 gfits_create_matrix (&catalog->header, &matrix); 112 112 if (!gfits_fwrite_matrix (catalog->f, &matrix)) { … … 117 117 fullsize += matrix.datasize; 118 118 gfits_free_matrix (&matrix); 119 # endif 119 120 120 121 FTable *outtable = ftable; … … 128 129 int isCompressed = output_is_compressed (start, Nrows, Ntotal, catalog->catcompress); 129 130 130 if (OHANA_MEMCHECK) ohana_memcheck _func(TRUE);131 if (OHANA_MEMCHECK) ohana_memcheck (TRUE); 131 132 132 133 if (isCompressed) { … … 136 137 if (!gfits_compress_table (ftable, &cmptable, 1000, compressMode)) { 137 138 fprintf (stderr, "compression failure\n"); 139 free (compressMode); 138 140 return (FALSE); 139 141 } 140 142 if (!byteswap_varlength_ftable (&cmpheader, &cmptable)) { 141 143 fprintf (stderr, "failed to swap varlength column\n"); 144 free (compressMode); 142 145 return FALSE; 143 146 } 144 147 if (!gfits_modify (cmptable.header, "DVO_CMP", "%s", 1, compressMode)) { 145 148 fprintf (stderr, "can't save compression mode\n"); 146 return (FALSE); 147 } 149 free (compressMode); 150 return (FALSE); 151 } 152 free (compressMode); 148 153 outtable = &cmptable; 149 154 } 150 155 151 if (OHANA_MEMCHECK) ohana_memcheck _func(TRUE);156 if (OHANA_MEMCHECK) ohana_memcheck (TRUE); 152 157 153 158 // write the table data … … 169 174 fullsize += outtable->datasize + outtable->header->datasize; 170 175 171 if (OHANA_MEMCHECK) ohana_memcheck_func (TRUE); 176 // XXX test of repeated failure 177 if (0) { 178 Matrix myMatrix; 179 180 // write the PHU matrix; this is probably a NOP, do I have to keep it in? 181 gfits_create_matrix (&catalog->header, &myMatrix); 182 183 int niter; 184 for (niter = 0; niter < 5; niter ++) { 185 char name[1024]; 186 snprintf (name, 1024, "%s.v.%d", catalog->filename, niter); 187 FILE *f = fopen (name, "w"); 188 189 myAssert (gfits_fwrite_header (f, &catalog->header), "failed to write header"); 190 myAssert (gfits_fwrite_matrix (f, &myMatrix), "failed to write matrix"); 191 myAssert (gfits_fwrite_Theader (f, outtable->header), "can't write table header"); 192 myAssert (gfits_fwrite_table (f, outtable), "can't write table data"); 193 myAssert (!fflush (f), "failed to flush"); 194 myAssert (!fclose (f), "failed to close"); 195 int fd = fileno(f); 196 myAssert (fsync(fd), "failed to sync"); 197 fprintf (stderr, "wrote to %s\n", name); 198 } 199 gfits_free_matrix (&myMatrix); 200 } 201 202 if (OHANA_MEMCHECK) ohana_memcheck (TRUE); 172 203 173 204 // since we init'ed the structures above, these operations are safe whether or not we compressed the table … … 191 222 off_t Nskip; 192 223 int status; 193 char *path, string[ 80];224 char *path, string[256]; 194 225 Catalog *subcat; 195 226 … … 215 246 return (DVO_CAT_OPEN_FAIL); 216 247 } 217 ALLOCATE (subcat[0].filename, char, strlen(path) + strlen(string) + 2); 218 sprintf (subcat[0].filename, "%s/%s", path, string); 248 int Nchar = strlen(path) + strlen(string) + 10; 249 ALLOCATE (subcat[0].filename, char, Nchar); 250 snprintf (subcat[0].filename, Nchar, "%s/%s", path, string); 219 251 free (path); 220 252 … … 282 314 } 283 315 284 char compressMode[ 80];316 char compressMode[256]; 285 317 if (!gfits_scan (ftable->header, "DVO_CMP", "%s", 1, compressMode)) { 286 318 strcpy (compressMode, "AUTO"); … … 759 791 } 760 792 793 # if (0) 794 void compare_file_ptr (FILE *copy_ptr, FILE *real_ptr, char *name) { 795 return; 796 797 int i; 798 799 char *real = (char *) real_ptr; 800 char *copy = (char *) copy_ptr; 801 802 for (i = 0; i < sizeof(FILE); i++, real++, copy++) { 803 if (*real != *copy) { 804 fprintf (stderr, "file pointers %s differ @ %d\n", name, (int) ((char *) real - (char *) real_ptr)); 805 } 806 } 807 } 808 # endif 809 761 810 /* save_catalog_split writes all data currently in memory to disk */ 762 811 int dvo_catalog_save_split (Catalog *catalog, char VERBOSE) { … … 845 894 goto failure; 846 895 } 896 847 897 gfits_free_header (&header); 848 898 gfits_free_table (&ftable); … … 887 937 goto failure; 888 938 } 939 889 940 gfits_free_header (&header); 890 941 gfits_free_table (&ftable); -
trunk/Ohana/src/libdvo/src/dvo_convert.c
r38441 r38553 1035 1035 Nimage = theader[0].Naxis[1]; 1036 1036 1037 # define FORMAT_CASE(FORMAT, TYPE) \1038 case DVO_FORMAT_##FORMAT: {\1039 Image_##TYPE *tmpImage;\1037 # define FORMAT_CASE(FORMAT, TYPE) \ 1038 case DVO_FORMAT_##FORMAT: { \ 1039 Image_##TYPE *tmpImage; \ 1040 1040 tmpImage = ImageInternalTo_##TYPE ((Image *) ftable[0].buffer, Nimage); \ 1041 free (ftable[0].buffer); \ 1042 gfits_table_set_Image_##TYPE (ftable, tmpImage, Nimage, TRUE); \ 1043 free (tmpImage); \ 1044 break; } 1041 free (ftable[0].buffer); \ 1042 gfits_free_header (ftable->header); \ 1043 gfits_table_set_Image_##TYPE (ftable, tmpImage, Nimage, TRUE); \ 1044 free (tmpImage); \ 1045 break; } 1045 1046 1046 1047 /* convert from the internal format */ -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V5.c
r38462 r38553 990 990 991 991 out[i].Xfit = in[i].Xfit; 992 out[i]. Yfit = in[i]. Yfit; 993 out[i]. mag = in[i]. mag; 994 out[i]. magErr = in[i]. magErr; 995 out[i]. majorAxis = in[i]. majorAxis; 996 out[i]. minorAxis = in[i]. minorAxis; 997 out[i]. majorAxisErr = in[i]. majorAxisErr; 998 out[i]. minorAxisErr = in[i]. minorAxisErr; 999 out[i]. theta = in[i]. theta; 1000 out[i]. theta_err = in[i]. theta_err; 1001 out[i]. index = in[i]. index; 1002 out[i]. chisq = in[i]. chisq; 1003 out[i]. Npix = in[i]. Npix; 1004 out[i]. objID = in[i]. objID; 1005 out[i]. catID = in[i]. catID; 1006 out[i]. detID = in[i]. detID; 1007 out[i]. imageID = in[i]. imageID; 1008 out[i]. photcode = in[i]. photcode; 1009 out[i]. modelType = in[i]. modelType; 992 out[i].Yfit = in[i].Yfit; 993 out[i].mag = in[i].mag; 994 out[i].magErr = in[i].magErr; 995 out[i].majorAxis = in[i].majorAxis; 996 out[i].minorAxis = in[i].minorAxis; 997 out[i].majorAxisErr = in[i].majorAxisErr; 998 out[i].minorAxisErr = in[i].minorAxisErr; 999 out[i].theta = in[i].theta; 1000 out[i].thetaErr = in[i].thetaErr; 1001 out[i].index = in[i].index; 1002 out[i].chisq = in[i].chisq; 1003 out[i].Npix = in[i].Npix; 1004 out[i].objID = in[i].objID; 1005 out[i].catID = in[i].catID; 1006 out[i].detID = in[i].detID; 1007 out[i].imageID = in[i].imageID; 1008 out[i].averef = in[i].averef; 1009 out[i].photcode = in[i].photcode; 1010 out[i].modelType = in[i].modelType; 1010 1011 } 1011 1012 return (out); … … 1029 1030 out[i].minorAxisErr = in[i].minorAxisErr; 1030 1031 out[i].theta = in[i].theta; 1031 out[i].theta _err = in[i].theta_err;1032 out[i].thetaErr = in[i].thetaErr; 1032 1033 out[i].index = in[i].index; 1033 1034 out[i].chisq = in[i].chisq; … … 1037 1038 out[i].detID = in[i].detID; 1038 1039 out[i].imageID = in[i].imageID; 1040 out[i].averef = in[i].averef; 1039 1041 out[i].photcode = in[i].photcode; 1040 1042 out[i].modelType = in[i].modelType; -
trunk/Ohana/src/libdvo/src/dvo_image.c
r38441 r38553 231 231 int dvo_image_createID (Header *header) { 232 232 233 char dbID[ 33];233 char dbID[64]; 234 234 235 235 if (!header->buffer) return FALSE; … … 259 259 int i; 260 260 for (i = 0; i < 32; i++) { 261 sprintf (&dbID[i], "%1x", (int)(16.0*drand48()));261 myAssert (snprintf (&dbID[i], 2, "%1x", (int)(16.0*drand48())) < 2, "overflow"); 262 262 } 263 263 -
trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c
r38153 r38553 43 43 } 44 44 45 // set the photcode table. This is used to switch between serveral previously 45 // free a specified photcode set 46 void FreePhotcodeData (PhotCodeData *myPhotcodes) { 47 if (!myPhotcodes) return; 48 FREE(myPhotcodes->code); 49 FREE(myPhotcodes); 50 } 51 52 // free the internal table 53 void FreePhotcodeTable (void) { 54 FreePhotcodeData (photcodes); 55 FREE(genericCodeMag); 56 FREE(genericCodeFlux); 57 } 58 59 // set the photcode table. This is used to switch between several previously 46 60 // allocated tables 47 61 void SetPhotcodeTable (PhotCodeData *new) { -
trunk/Ohana/src/libdvo/src/dvo_util.c
r38471 r38553 63 63 } 64 64 65 s printf (dvoConfig->photcodeFile, "%s/Photcodes.dat", dvoConfig->catdir);65 snprintf (dvoConfig->photcodeFile, 256, "%s/Photcodes.dat", dvoConfig->catdir); 66 66 if (!LoadPhotcodes (dvoConfig->photcodeFile, MasterPhotcodeFile, FALSE)) { 67 67 fprintf (stderr, "error loading photcode table %s or master file %s\n", … … 101 101 char filename[256]; 102 102 103 s printf (filename, "%s/Images.dat", dvoConfig->catdir);103 snprintf (filename, 256, "%s/Images.dat", dvoConfig->catdir); 104 104 105 105 gfits_db_init (&dvoConfig->imageDB); -
trunk/Ohana/src/libdvo/src/skydb.c
r19823 r38553 224 224 /* north dec bands */ 225 225 for (dec = 0; dec < 90; dec += 7.5) { 226 sprintf (db[N].name, "n%04d.cpt", (int) 100*dec);226 myAssert (snprintf (db[N].name, 18, "n%04d.cpt", (int) 100*dec) < 18, "overflow"); 227 227 db[N].Rmin = 0; db[N].Rmax = 360; 228 228 db[N].Dmin = dec; db[N].Dmax = dec + 7.5; … … 233 233 /* south dec bands */ 234 234 for (dec = 0; dec > -90; dec -= 7.5) { 235 sprintf (db[N].name, "s%04d.cpt", (int) 100*dec);235 myAssert (snprintf (db[N].name, 18, "s%04d.cpt", (int) 100*dec) < 18, "overflow"); 236 236 db[N].Rmin = 0; db[N].Rmax = 360; 237 237 db[N].Dmin = dec - 7.5; db[N].Dmax = dec; … … 276 276 new[Nnew].child = FALSE; 277 277 strncpy (root, db[i].name, 5); root[5] = 0; 278 sprintf (new[Nnew].name, "%s/r%04d.cpt", root, Rnumber);278 myAssert (snprintf (new[Nnew].name, 18, "%s/r%04d.cpt", root, Rnumber) < 18, "overflow"); 279 279 Rnumber ++; 280 280 Nnew ++; … … 365 365 db[N].child = FALSE; 366 366 strncpy (root, db[i].name, 10); root[10] = 0; 367 sprintf (db[N].name, "%s.%02d.cpt", root, Rnumber);367 myAssert (snprintf (db[N].name, 18, "%s.%02d.cpt", root, Rnumber) < 18, "overflow"); 368 368 Rnumber ++; 369 369 N ++; -
trunk/Ohana/src/libdvo/src/skyregion_gsc.c
r37807 r38553 46 46 FTable ftable; 47 47 SkyTable *skytable; 48 SkyTable *band;49 48 SkyTable L0, L1, L2, L3, L4; 50 49 SkyRegionZone *zones; … … 79 78 /* L0 : full sky */ 80 79 L0.Nregions = 1; 81 ALLOCATE (L0.regions, SkyRegion, L0.Nregions); 80 L0.Nalloc = 1; 81 ALLOCATE (L0.regions, SkyRegion, L0.Nalloc); 82 82 L0.regions[0].Rmin = 0; 83 83 L0.regions[0].Rmax = 360; … … 99 99 /* allocate space for all levels */ 100 100 L1.Nregions = L2.Nregions = L3.Nregions = L4.Nregions = 0; 101 ALLOCATE (L1.regions, SkyRegion, 1);102 ALLOCATE (L2.regions, SkyRegion, 1);103 ALLOCATE (L3.regions, SkyRegion, 1);104 ALLOCATE (L4.regions, SkyRegion, 1);101 L1.Nalloc = NDECBANDS; ALLOCATE (L1.regions, SkyRegion, L1.Nalloc); 102 L2.Nalloc = NDECBANDS*0x10; ALLOCATE (L2.regions, SkyRegion, L2.Nalloc); 103 L3.Nalloc = NDECBANDS*0x100; ALLOCATE (L3.regions, SkyRegion, L3.Nalloc); 104 L4.Nalloc = NDECBANDS*0x1000; ALLOCATE (L4.regions, SkyRegion, L4.Nalloc); 105 105 106 106 // skipLines = 0; … … 130 130 131 131 /* load all GSC Regions in this band */ 132 band = SkyRegionForDecBand (&ftable.buffer[skipLines*48], DecLines[i], DecNames[i], L1.regions[i].Dmin, L1.regions[i].Dmax);132 SkyTable *band = SkyRegionForDecBand (&ftable.buffer[skipLines*48], DecLines[i], DecNames[i], L1.regions[i].Dmin, L1.regions[i].Dmax); 133 133 skipLines += DecLines[i]; 134 134 … … 151 151 152 152 L1.Nregions ++; 153 REALLOCATE (L1.regions, SkyRegion, L1.Nregions + 1);153 myAssert (L1.Nregions <= NDECBANDS, "too many L1 regions"); 154 154 } 155 155 … … 225 225 226 226 temp[5] = 0; 227 s printf (name, "%s/%s", DecName, &temp[1]);227 snprintf (name, 80, "%s/%s", DecName, &temp[1]); 228 228 strcpy (regions[i].name, name); 229 229 } … … 231 231 band[0].regions = regions; 232 232 band[0].Nregions = Nregions; 233 band[0].Nalloc = Nregions; 233 234 return (band); 234 235 } … … 277 278 Nregions = band[0].Nregions; 278 279 279 NZ = 10 ;280 NZ = 100; 280 281 ALLOCATE (zones, SkyRegionZone, NZ); 281 282 … … 312 313 /* go to the next zone */ 313 314 Nz++; 314 CHECK_REALLOCATE (zones, SkyRegionZone, NZ, Nz, 10 );315 CHECK_REALLOCATE (zones, SkyRegionZone, NZ, Nz, 100); 315 316 316 317 /* start info for the new zone */ … … 365 366 band[0].regions[Nregions + i].Dmax = -86.250; 366 367 } 367 sprintf (band[0].regions[Nregions + i].name, "%s.%d", basename, i);368 myAssert (snprintf (band[0].regions[Nregions + i].name, 18, "%s.%d", basename, i) < 18, "overflow"); 368 369 } 369 370 band[0].regions[Nregions + i].Rmin = 0.0; … … 376 377 band[0].regions[Nregions + i].Dmax = -88.125; 377 378 } 378 sprintf (band[0].regions[Nregions + i].name, "%s.%d", basename, i);379 myAssert (snprintf (band[0].regions[Nregions + i].name, 18, "%s.%d", basename, i) < 18, "overflow"); 379 380 380 381 zones[0].Nset = 6; … … 401 402 void SkyTableL2fromZone (SkyTable *L2, SkyTable *L3, SkyTable *L4, SkyTable *band, SkyRegionZone *zone, int parent) { 402 403 403 int i, N r, Ns, Ne;404 int i, Ns, Ne; 404 405 char *p, name[80]; 405 406 406 Nr = L2[0].Nregions;407 REALLOCATE (L2[0].regions, SkyRegion, Nr + 1);407 int Nr = L2[0].Nregions; 408 CHECK_REALLOCATE (L2[0].regions, SkyRegion, L2[0].Nalloc, L2[0].Nregions, 100); 408 409 409 410 /* divide this zone into L2 regions with Nset L3 regions each (fewer on ends) */ … … 435 436 } 436 437 *p = 0; 437 sprintf (name, "%s/z%03d", band[0].regions[Ns].name, Nr);438 myAssert (snprintf (name, 80, "%s/z%03d", band[0].regions[Ns].name, Nr) < 80, "overflow"); 438 439 *p = '/'; 439 440 strcpy (L2[0].regions[Nr].name, name); … … 444 445 445 446 Nr++; 446 REALLOCATE (L2[0].regions, SkyRegion, Nr + 1);447 CHECK_REALLOCATE (L2[0].regions, SkyRegion, L2[0].Nalloc, Nr, 100); 447 448 } 448 449 L2[0].Nregions = Nr; … … 456 457 Nr = L3[0].Nregions; 457 458 L3[0].Nregions += Ne - Ns; 458 REALLOCATE (L3[0].regions, SkyRegion, L3[0].Nregions);459 CHECK_REALLOCATE (L3[0].regions, SkyRegion, L3[0].Nalloc, L3[0].Nregions, 0.5*L3[0].Nalloc); 459 460 460 461 L2[0].child = TRUE; … … 498 499 Nr = L4[0].Nregions; 499 500 L4[0].Nregions += NDIV*NDIV; 500 REALLOCATE (L4[0].regions, SkyRegion, L4[0].Nregions);501 CHECK_REALLOCATE (L4[0].regions, SkyRegion, L4[0].Nalloc, L4[0].Nregions, 0.5*L4[0].Nalloc); 501 502 502 503 L3[0].child = TRUE; … … 531 532 L4[0].regions[Nr].backupID = 0; 532 533 533 sprintf (name, "%s.%02d", L3[0].name, Nbox);534 myAssert (snprintf (name, 80, "%s.%02d", L3[0].name, Nbox) < 80, "overflow"); 534 535 strcpy (L4[0].regions[Nr].name, name); 535 536 if (DEBUG >= 4) SkyRegionPrint (&L4[0].regions[Nr]); -
trunk/Ohana/src/libdvo/src/skyregion_io.c
r38441 r38553 113 113 fclose (f); 114 114 115 gfits_free_header (&header); 116 gfits_free_matrix (&matrix); 117 gfits_free_header (&theader); 118 gfits_free_table (&ftable); 119 115 120 return (TRUE); 116 121 } … … 131 136 exit (1); 132 137 } 138 free (filename); 133 139 return (sky); 134 140 … … 195 201 // this generates the names, be sure to free when not needed 196 202 for (i = 0; i < list[0].Nregions; i++) { 197 s printf (line, "%s/%s.%s", path, list[0].regions[i][0].name, ext);203 snprintf (line, 256, "%s/%s.%s", path, list[0].regions[i][0].name, ext); 198 204 list[0].filename[i] = strcreate (line); 199 205 } … … 209 215 // this generates the names, be sure to free when not needed 210 216 for (i = 0; i < sky[0].Nregions; i++) { 211 s printf (line, "%s/%s.%s", path, sky[0].regions[i].name, ext);217 snprintf (line, 256, "%s/%s.%s", path, sky[0].regions[i].name, ext); 212 218 sky[0].filename[i] = strcreate (line); 213 219 } … … 222 228 223 229 char *skyfile; 224 ALLOCATE (skyfile, char, strlen(catdir) + strlen("/SkyTable.fits") + 1); 225 sprintf (skyfile, "%s/SkyTable.fits", catdir); 230 231 int Nchar = strlen(catdir) + strlen("/SkyTable.fits") + 16; 232 ALLOCATE (skyfile, char, Nchar); 233 snprintf (skyfile, Nchar, "%s/SkyTable.fits", catdir); 226 234 227 235 return skyfile; -
trunk/Ohana/src/libdvo/src/skyregion_ops.c
r37807 r38553 550 550 } 551 551 free (list[0].regions); 552 free (list[0].filename); 552 553 } 553 554 free (list); -
trunk/Ohana/src/libfits/header/F_write_H.c
r27435 r38553 5 5 int gfits_write_header (char *filename, Header *header) { 6 6 7 FILE *f; 8 off_t Nbytes; 9 int status; 10 11 status = TRUE; 7 FILE *f = fopen (filename, "w"); 8 if (!f) return (FALSE); 12 9 13 f = fopen (filename, "w"); 14 if (f == (FILE *) NULL) return (FALSE); 15 16 Nbytes = fwrite (header[0].buffer, sizeof(char), header[0].datasize, f); 17 18 if (Nbytes != header[0].datasize) { 19 status = FALSE; 20 } 21 10 int status = gfits_fwrite_header (f, header); 22 11 fclose (f); 23 12 … … 29 18 30 19 off_t Nbytes; 31 int status; 32 33 status = TRUE; 20 21 # ifdef OHANA_MEMORY 22 { // check memory before writing: 23 // memblock of supplied pointer 24 OhanaMemblock *myBlock = (OhanaMemblock *) header[0].buffer - 1; 25 myAssert (myBlock->startblock == OHANA_MEMMAGIC, "bad memory"); 26 myAssert (myBlock->endblock == OHANA_MEMMAGIC, "bad memory"); 27 myAssert (myBlock->size >= header[0].datasize, "overflow"); 28 } 29 # endif 34 30 35 31 Nbytes = fwrite (header[0].buffer, sizeof(char), header[0].datasize, f); 36 37 if (Nbytes != header[0].datasize) {38 status = FALSE;32 if (Nbytes != header[0].datasize) { 33 perror ("fwrite: "); 34 return FALSE; 39 35 } 40 41 return (status); 36 return TRUE; 42 37 } 43 38 44 39 45 40 int gfits_fwrite_header (FILE *f, Header *header) { 46 47 int status; 48 status = gfits_save_header (f, header); 41 int status = gfits_save_header (f, header); 49 42 return (status); 50 43 } -
trunk/Ohana/src/libfits/include/gfitsio.h
r38441 r38553 99 99 100 100 typedef struct { 101 char ttype[ 16]; // TTYPE field of original table102 char ttype_cmt[ 80]; // comment associated with TTYPE103 char tunit[ 16]; // TUNIT field of original table104 char tunit_cmt[ 80]; // comment associated with TUNIT105 char tformat[ 16]; // TFORM field of original table106 char tformat_cmt[ 80];// comment associated with TFORM107 char zctype[ 80]; // compression type for this field101 char ttype[256]; // TTYPE field of original table 102 char ttype_cmt[256]; // comment associated with TTYPE 103 char tunit[256]; // TUNIT field of original table 104 char tunit_cmt[256]; // comment associated with TUNIT 105 char tformat[256]; // TFORM field of original table 106 char tformat_cmt[256]; // comment associated with TFORM 107 char zctype[256]; // compression type for this field 108 108 VarLengthColumn zdef; // description of the output variable length column 109 109 110 char datatype[ 80]; // named data type associated with ttype (eg, 18J -> int, 18D -> double)110 char datatype[256]; // named data type associated with ttype (eg, 18J -> int, 18D -> double) 111 111 int Nvalues; // number of values per row (eg 18J -> 18 int values) 112 112 int pixsize; // number of bytes per value of this row (eg, 18J -> 4 bytes) -
trunk/Ohana/src/libfits/matrix/F_write_M.c
r33648 r38553 35 35 else 36 36 nbytes = FT_RECORD_SIZE * ((off_t) (matrix[0].datasize / FT_RECORD_SIZE)); 37 38 // fprintf (stderr, "write matrix: %d bytes (%d datasize)\n", (int) nbytes, (int) matrix[0].datasize); 39 if (nbytes == 0) return TRUE; 37 40 38 41 # define DOSWAP(A,B) { char tmp = A; A = B; B = tmp; } -
trunk/Ohana/src/libfits/table/F_compress_T.c
r38471 r38553 57 57 char *raw = NULL; 58 58 char *zdata = NULL; 59 TableField *fields = NULL; 59 60 60 61 Header *srcheader = srctable->header; … … 100 101 gettimeofday (&startTimer, (void *) NULL); 101 102 102 TableField *fields = NULL;103 103 ALLOCATE_ZERO (fields, TableField, Nfields); 104 104 for (i = 0; i < Nfields; i++) { … … 351 351 gfits_dump_cmp_table (tgttable, "cmp"); 352 352 353 free (raw); 354 free (zdata); 353 FREE (raw); 354 FREE (zdata); 355 FREE (fields); 355 356 return (TRUE); 356 357 … … 358 359 FREE (raw); 359 360 FREE (zdata); 361 FREE (fields); 360 362 return FALSE; 361 363 } -
trunk/Ohana/src/libfits/table/F_create_TH.c
r28241 r38553 11 11 12 12 int i; 13 char axis[1 0];13 char axis[128]; 14 14 15 15 header[0].datasize = NBYTES; 16 16 17 myAssert (!header->buffer, "failed to init header or free buffer?"); 17 18 ALLOCATE (header[0].buffer, char, NBYTES); 18 19 … … 26 27 27 28 for (i = 0; i < header[0].Naxes; i++) { 28 s printf (axis, "NAXIS%d", i + 1);29 snprintf (axis, 64, "NAXIS%d", i + 1); 29 30 gfits_modify (header, axis, OFF_T_FMT, 1, header[0].Naxis[i]); 30 31 } -
trunk/Ohana/src/libfits/table/F_define_column.c
r38441 r38553 11 11 off_t Naxis1; 12 12 int Nfields, Nbytes, Nval; 13 char type[ 16], field[16];13 char type[64], field[64]; 14 14 15 15 if (!gfits_bintable_format (format, type, &Nval, &Nbytes)) return (FALSE); … … 21 21 Naxis1 += Nbytes*Nval; 22 22 23 s printf (field, "TTYPE%d", Nfields);23 snprintf (field, 64, "TTYPE%d", Nfields); 24 24 gfits_modify (header, field, "%s", 1, label); 25 25 gfits_modify_alt (header, field, "%C", 1, comment); 26 s printf (field, "TUNIT%d", Nfields);26 snprintf (field, 64, "TUNIT%d", Nfields); 27 27 gfits_modify (header, field, "%s", 1, unit); 28 s printf (field, "TFORM%d", Nfields);28 snprintf (field, 64, "TFORM%d", Nfields); 29 29 gfits_modify (header, field, "%s", 1, format); 30 30 31 31 // add scaling parameters unless they amount to a noop 32 32 if ((bscale != 1.0) || (bzero != 0.0)) { 33 s printf (field, "TSCAL%d", Nfields);33 snprintf (field, 64, "TSCAL%d", Nfields); 34 34 gfits_modify (header, field, "%lf", 1, bscale); 35 s printf (field, "TZERO%d", Nfields);35 snprintf (field, 64, "TZERO%d", Nfields); 36 36 gfits_modify (header, field, "%lf", 1, bzero); 37 37 } … … 54 54 off_t Naxis1; 55 55 int Nfields, Nbytes, Nval; 56 char type[ 16], field[16];56 char type[64], field[64]; 57 57 58 58 if (!gfits_bintable_format (format, type, &Nval, &Nbytes)) return (FALSE); … … 64 64 Naxis1 += Nbytes*Nval; 65 65 66 s printf (field, "TTYPE%d", Nfields);66 snprintf (field, 64, "TTYPE%d", Nfields); 67 67 gfits_modify (header, field, "%s", 1, label); 68 68 if (comment) { … … 70 70 } 71 71 if (unit) { 72 s printf (field, "TUNIT%d", Nfields);72 snprintf (field, 64, "TUNIT%d", Nfields); 73 73 gfits_modify (header, field, "%s", 1, unit); 74 74 } 75 s printf (field, "TFORM%d", Nfields);75 snprintf (field, 64, "TFORM%d", Nfields); 76 76 gfits_modify (header, field, "%s", 1, format); 77 77 78 78 // add scaling parameters unless they amount to a noop 79 79 if ((bscale != 1.0) || (bzero != 0.0)) { 80 s printf (field, "TSCAL%d", Nfields);80 snprintf (field, 64, "TSCAL%d", Nfields); 81 81 gfits_modify (header, field, "%lf", 1, bscale); 82 s printf (field, "TZERO%d", Nfields);82 snprintf (field, 64, "TZERO%d", Nfields); 83 83 gfits_modify (header, field, "%lf", 1, bzero); 84 84 } … … 97 97 off_t Naxis1; 98 98 int Nstart, Nfields, Nbytes, Nval; 99 char type[ 16], field[16], cformat[16];99 char type[64], field[64], cformat[64]; 100 100 101 101 strcpy (cformat, format); … … 109 109 Naxis1 += Nbytes*Nval; 110 110 111 s printf (field, "TTYPE%d", Nfields);111 snprintf (field, 64, "TTYPE%d", Nfields); 112 112 gfits_modify (header, field, "%s", 1, label); 113 113 gfits_modify_alt (header, field, "%C", 1, comment); 114 s printf (field, "TUNIT%d", Nfields);114 snprintf (field, 64, "TUNIT%d", Nfields); 115 115 gfits_modify (header, field, "%s", 1, unit); 116 s printf (field, "TFORM%d", Nfields);116 snprintf (field, 64, "TFORM%d", Nfields); 117 117 gfits_modify (header, field, "%s", 1, format); 118 118 119 s printf (field, "TBCOL%d", Nfields);119 snprintf (field, 64, "TBCOL%d", Nfields); 120 120 gfits_modify (header, field, "%d", 1, Nstart); 121 121 -
trunk/Ohana/src/libfits/table/F_get_T_column.c
r7054 r38553 9 9 { 10 10 11 char Tform[ 100], field[100], tmp[100];11 char Tform[256], field[256], tmp[256]; 12 12 int start, Nchar, i, N; 13 13 … … 22 22 /* should I count fields from 0 or from 1? */ 23 23 24 s printf (field, "TBCOL%d\0", X);24 snprintf (field, 256, "TBCOL%d\0", X); 25 25 gfits_scan (&table[0].header, field, "%d", &start, 1); 26 26 start --; 27 s printf (field, "TFORM%d\0", X);27 snprintf (field, 256, "TFORM%d\0", X); 28 28 gfits_scan (&table[0].header, field, "%s", Tform, 1); 29 29 Nchar = atof (&Tform[1]); -
trunk/Ohana/src/libfits/table/F_get_T_value.c
r7054 r38553 10 10 { 11 11 12 char Tform[ 100], field[100];12 char Tform[256], field[256]; 13 13 int start, Nchar, byte; 14 14 char tmp[1000]; … … 16 16 /* no error checking, all sorts of problems! */ 17 17 18 s printf (field, "TBCOL%d\0", X);18 snprintf (field, 256, "TBCOL%d\0", X); 19 19 gfits_scan (&table[0].header, field, "%d", &start, 1); 20 20 start --; 21 21 22 s printf (field, "TFORM%d\0", X);22 snprintf (field, 256, "TFORM%d\0", X); 23 23 gfits_scan (&table[0].header, field, "%s", Tform, 1); 24 24 Nchar = atof (&Tform[1]); 25 myAssert (Nchar < 999, "overflow"); 25 26 26 27 byte = Y*table[0].Naxis[0] + start; -
trunk/Ohana/src/libfits/table/F_get_column.c
r38441 r38553 25 25 off_t Nx, Ny; 26 26 int i, N, Nfields, Nval, Nbytes, Nstart, Nv, Nb; 27 char tlabel[ 80], field[80], format[80], tmpline[16];27 char tlabel[256], field[256], format[256], tmpline[64]; 28 28 char *Pin, *Pout, *array; 29 29 double Bscale, Bzero; … … 36 36 if (!gfits_scan (header, "TFIELDS", "%d", 1, &Nfields)) return (NULL); 37 37 for (i = 1; strcasecmp (label, tlabel) && (i < Nfields + 1); i++) { 38 s printf (field, "TTYPE%d", i);38 snprintf (field, 256, "TTYPE%d", i); 39 39 gfits_scan (header, field, "%s", 1, tlabel); 40 40 } … … 46 46 47 47 /* interpret format */ 48 s printf (field, "TSCAL%d", N);48 snprintf (field, 256, "TSCAL%d", N); 49 49 gfits_scan (header, field, "%lf", 1, &Bscale); 50 s printf (field, "TZERO%d", N);50 snprintf (field, 256, "TZERO%d", N); 51 51 gfits_scan (header, field, "%lf", 1, &Bzero); 52 s printf (field, "TFORM%d", N);52 snprintf (field, 256, "TFORM%d", N); 53 53 gfits_scan (header, field, "%s", 1, format); 54 54 … … 62 62 Nstart = 0; 63 63 for (i = 1; i < N; i++) { 64 s printf (field, "TFORM%d", i);64 snprintf (field, 256, "TFORM%d", i); 65 65 gfits_scan (header, field, "%s", 1, format); 66 66 gfits_bintable_format (format, tmpline, &Nv, &Nb); … … 145 145 146 146 int Nbytes; 147 char field[ 80], format[80];147 char field[256], format[256]; 148 148 149 149 assert (N > 0); 150 150 151 s printf (field, "TFORM%d", N);151 snprintf (field, 256, "TFORM%d", N); 152 152 if (!gfits_scan (header, field, "%s", 1, format)) return FALSE; 153 153 if (!gfits_bintable_format (format, type, Nval, &Nbytes)) return (FALSE); … … 159 159 160 160 int i, N, Nfields; 161 char tlabel[ 80], field[80];161 char tlabel[256], field[256]; 162 162 163 163 if (label == (char *) NULL) return (FALSE); … … 168 168 gfits_scan (header, "TFIELDS", "%d", 1, &Nfields); 169 169 for (i = 1; strcasecmp (label, tlabel) && (i < Nfields + 1); i++) { 170 s printf (field, "TTYPE%d", i);170 snprintf (field, 256, "TTYPE%d", i); 171 171 gfits_scan (header, field, "%s", 1, tlabel); 172 172 } … … 181 181 int gfits_get_bintable_column_raw (Header *header, FTable *table, char *label, void **data, char nativeOrder) { 182 182 183 char type[ 16];183 char type[64]; 184 184 off_t Nrow; 185 185 int Ncol; … … 195 195 int gfits_get_bintable_column (Header *header, FTable *table, char *label, void **data) { 196 196 197 char type[ 16];197 char type[64]; 198 198 off_t Nrow; 199 199 int Ncol; … … 229 229 230 230 int i, N, Nfields, Nval, Nbytes; 231 char tlabel[ 80], field[80], format[80];231 char tlabel[256], field[256], format[256]; 232 232 233 233 if (label == (char *) NULL) return (FALSE); … … 238 238 gfits_scan (header, "TFIELDS", "%d", 1, &Nfields); 239 239 for (i = 1; strcasecmp (label, tlabel) && (i < Nfields + 1); i++) { 240 s printf (field, "TTYPE%d", i);240 snprintf (field, 256, "TTYPE%d", i); 241 241 gfits_scan (header, field, "%s", 1, tlabel); 242 242 } … … 245 245 246 246 /* interpret format */ 247 s printf (field, "TFORM%d", N);247 snprintf (field, 256, "TFORM%d", N); 248 248 gfits_scan (header, field, "%s", 1, format); 249 249 … … 257 257 off_t Nx, Ny; 258 258 int i, N, Nfields, Nval, Nbytes, Nstart, Nv, Nb; 259 char tlabel[ 80], field[80], format[80], cformat[80], type[16], tmp[16];259 char tlabel[256], field[256], format[256], cformat[256], type[64], tmp[64]; 260 260 char *array, *Pin, *Pout, *line; 261 261 … … 268 268 gfits_scan (header, "TFIELDS", "%d", 1, &Nfields); 269 269 for (i = 1; strcasecmp (label, tlabel) && (i < Nfields + 1); i++) { 270 s printf (field, "TTYPE%d", i);270 snprintf (field, 256, "TTYPE%d", i); 271 271 gfits_scan (header, field, "%s", 1, tlabel); 272 272 } … … 275 275 276 276 /* interpret format */ 277 s printf (field, "TFORM%d", N);277 snprintf (field, 256, "TFORM%d", N); 278 278 gfits_scan (header, field, "%s", 1, format); 279 279 … … 288 288 Nstart = 0; 289 289 for (i = 1; i < N; i++) { 290 s printf (field, "TFORM%d", i);290 snprintf (field, 256, "TFORM%d", i); 291 291 gfits_scan (header, field, "%s", 1, format); 292 292 gfits_table_format (format, tmp, &Nv, &Nb); -
trunk/Ohana/src/libfits/table/F_set_column.c
r38441 r38553 30 30 int i, N, Nfields; 31 31 int Nval, Nbytes, Nstart, Nv, Nb; 32 char tlabel[ 80], field[80], format[80], type[16], tmpline[16];32 char tlabel[256], field[256], format[256], type[64], tmpline[64]; 33 33 char *Pin, *Pout, *array; 34 34 double Bscale, Bzero; … … 41 41 gfits_scan (header, "TFIELDS", "%d", 1, &Nfields); 42 42 for (i = 1; strcasecmp (label, tlabel) && (i < Nfields + 1); i++) { 43 s printf (field, "TTYPE%d", i);43 snprintf (field, 256, "TTYPE%d", i); 44 44 gfits_scan (header, field, "%s", 1, tlabel); 45 45 } … … 48 48 49 49 /* interpret format */ 50 s printf (field, "TSCAL%d", N);50 snprintf (field, 256, "TSCAL%d", N); 51 51 if (!gfits_scan (header, field, "%lf", 1, &Bscale)) { 52 52 Bscale = 1.0; 53 53 } 54 s printf (field, "TZERO%d", N);54 snprintf (field, 256, "TZERO%d", N); 55 55 if (!gfits_scan (header, field, "%lf", 1, &Bzero)) { 56 56 Bzero = 0.0; 57 57 } 58 s printf (field, "TFORM%d", N);58 snprintf (field, 256, "TFORM%d", N); 59 59 gfits_scan (header, field, "%s", 1, format); 60 60 … … 75 75 Nstart = 0; 76 76 for (i = 1; i < N; i++) { 77 s printf (field, "TFORM%d", i);77 snprintf (field, 256, "TFORM%d", i); 78 78 gfits_scan (header, field, "%s", 1, format); 79 79 gfits_bintable_format (format, tmpline, &Nv, &Nb); … … 190 190 int i, N, Nfields; 191 191 int Nval, NbytesOut, Nstart, Nv, Nb; 192 char tlabel[ 80], field[80], format[80], outtype[16], tmpline[16];192 char tlabel[256], field[256], format[256], outtype[64], tmpline[64]; 193 193 char *Pin, *Pout, *array; 194 194 double Bscale, Bzero; … … 201 201 gfits_scan (header, "TFIELDS", "%d", 1, &Nfields); 202 202 for (i = 1; strcasecmp (label, tlabel) && (i < Nfields + 1); i++) { 203 s printf (field, "TTYPE%d", i);203 snprintf (field, 256, "TTYPE%d", i); 204 204 gfits_scan (header, field, "%s", 1, tlabel); 205 205 } … … 208 208 209 209 /* interpret format */ 210 s printf (field, "TSCAL%d", N);210 snprintf (field, 256, "TSCAL%d", N); 211 211 if (!gfits_scan (header, field, "%lf", 1, &Bscale)) { 212 212 Bscale = 1.0; 213 213 } 214 s printf (field, "TZERO%d", N);214 snprintf (field, 256, "TZERO%d", N); 215 215 if (!gfits_scan (header, field, "%lf", 1, &Bzero)) { 216 216 Bzero = 0.0; 217 217 } 218 s printf (field, "TFORM%d", N);218 snprintf (field, 256, "TFORM%d", N); 219 219 gfits_scan (header, field, "%s", 1, format); 220 220 … … 233 233 Nstart = 0; 234 234 for (i = 1; i < N; i++) { 235 s printf (field, "TFORM%d", i);235 snprintf (field, 256, "TFORM%d", i); 236 236 gfits_scan (header, field, "%s", 1, format); 237 237 gfits_bintable_format (format, tmpline, &Nv, &Nb); … … 780 780 off_t Nx, Ny; 781 781 int i, N, Nfields, Nval, Nbytes, Nstart, Nv, Nb; 782 char tlabel[ 80], field[80], format[80], cformat[80], type[16], tmp[16];782 char tlabel[256], field[256], format[256], cformat[256], type[64], tmp[64]; 783 783 char *array, *Pin, *Pout, *line; 784 784 … … 790 790 gfits_scan (header, "TFIELDS", "%d", 1, &Nfields); 791 791 for (i = 1; strcmp (label, tlabel) && (i < Nfields + 1); i++) { 792 s printf (field, "TTYPE%d", i);792 snprintf (field, 256, "TTYPE%d", i); 793 793 gfits_scan (header, field, "%s", 1, tlabel); 794 794 } … … 797 797 798 798 /* interpret format */ 799 s printf (field, "TFORM%d", N);799 snprintf (field, 256, "TFORM%d", N); 800 800 gfits_scan (header, field, "%s", 1, format); 801 801 … … 815 815 Nstart = 0; 816 816 for (i = 1; i < N; i++) { 817 s printf (field, "TFORM%d", i);817 snprintf (field, 256, "TFORM%d", i); 818 818 gfits_scan (header, field, "%s", 1, format); 819 819 gfits_table_format (format, tmp, &Nv, &Nb); -
trunk/Ohana/src/libfits/table/F_table_column.c
r7054 r38553 6 6 /* we expect one more field: the pointer to the array we read in */ 7 7 8 char string[ 80], this_field[80], form[80], temp[80];8 char string[256], this_field[256], form[256], temp[256]; 9 9 int i, j, N, start, end, width, M; 10 10 va_list argp; … … 18 18 /* find the correct field */ 19 19 for (i = 0; i < table[0].Nfields; i++) { 20 s printf (string, "TTYPE%d\0", i+1);20 snprintf (string, 256, "TTYPE%d\0", i+1); 21 21 gfits_scan (&table[0].header, string, "%s", 1, this_field); 22 22 if (!strcmp (field, this_field)) { … … 32 32 N = i + 1; 33 33 34 s printf (string, "TBCOL%d\0", N);34 snprintf (string, 256, "TBCOL%d\0", N); 35 35 gfits_scan (&table[0].header, string, "%d", 1, &start); 36 s printf (string, "TFORM%d\0", N);36 snprintf (string, 256, "TFORM%d\0", N); 37 37 gfits_scan (&table[0].header, string, "%s", 1, form); 38 38 /* we could use some error checking from the FITS table form, but … … 42 42 end = table[0].Naxis[0]; 43 43 } else { 44 s printf (string, "TBCOL%d\0", N+1);44 snprintf (string, 256, "TBCOL%d\0", N+1); 45 45 gfits_scan (&table[0].header, string, "%d", 1, &end); 46 46 } -
trunk/Ohana/src/libfits/table/F_table_format.c
r38441 r38553 113 113 if (!*Nbytes) { return (FALSE); } 114 114 115 // XXXX : check usage: 116 myAbort ("need to check length"); 115 117 sprintf (format, "%%-%s%c", Size, Type); 116 118 … … 191 193 off_t Nx, off; 192 194 int i, Nchar, Nval, Nbytes, Nfields; 193 char *line, format[64], field[ 16], type[16];195 char *line, format[64], field[64], type[64]; 194 196 va_list argp; 195 197 … … 204 206 for (i = 1; i <= Nfields; i++) { 205 207 206 s printf (field, "TFORM%d", i);208 snprintf (field, 64, "TFORM%d", i); 207 209 gfits_scan (table[0].header, field, "%s", 1, format); /* get field format */ 208 210 gfits_table_format (format, type, &Nval, &Nbytes); /* convert to c-style */ … … 232 234 int i, j, n, Nfields; 233 235 int Nchar, Nval, Nbytes, status; 234 char format[64], field[ 16], type[16];236 char format[64], field[64], type[64]; 235 237 double tzero, tscale; 236 238 char *tmpChar; … … 246 248 247 249 for (i = 1; i <= Nfields; i++) { 248 s printf (field, "TFORM%d", i);250 snprintf (field, 64, "TFORM%d", i); 249 251 gfits_scan (ftable[0].header, field, "%s", 1, format); /* get field format */ 250 252 gfits_bintable_format (format, type, &Nval, &Nbytes); /* convert to c-style */ 251 253 Nchar = Nval * Nbytes; 252 254 253 s printf (field, "TZERO%d", i);255 snprintf (field, 64, "TZERO%d", i); 254 256 status = gfits_scan (ftable[0].header, field, "%lf", 1, &tzero); /* get field format */ 255 257 if (!status) { … … 258 260 } 259 261 260 s printf (field, "TSCAL%d", i);262 snprintf (field, 64, "TSCAL%d", i); 261 263 status = gfits_scan (ftable[0].header, field, "%lf", 1, &tscale); /* get field format */ 262 264 if (!status) { … … 325 327 int i, j, n, Nfields; 326 328 int Nchar, Nval, Nbytes, status; 327 char format[64], field[ 16], type[16];329 char format[64], field[64], type[64]; 328 330 double tzero, tscale; 329 331 char *tmpChar; … … 339 341 340 342 for (i = 1; i <= Nfields; i++) { 341 s printf (field, "TFORM%d", i);343 snprintf (field, 64, "TFORM%d", i); 342 344 gfits_scan (ftable[0].header, field, "%s", 1, format); /* get field format */ 343 345 gfits_bintable_format (format, type, &Nval, &Nbytes); /* convert to c-style */ 344 346 Nchar = Nval * Nbytes; 345 347 346 s printf (field, "TZERO%d", i);348 snprintf (field, 64, "TZERO%d", i); 347 349 status = gfits_scan (ftable[0].header, field, "%lf", 1, &tzero); /* get field format */ 348 350 if (!status) { … … 351 353 } 352 354 353 s printf (field, "TSCAL%d", i);355 snprintf (field, 64, "TSCAL%d", i); 354 356 status = gfits_scan (ftable[0].header, field, "%lf", 1, &tscale); /* get field format */ 355 357 if (!status) { -
trunk/Ohana/src/libfits/table/F_table_varlength.c
r38441 r38553 8 8 int Nv, Nb; 9 9 char *p1, *p2, *p3; 10 char field[ 81];11 char format[ 81];12 char tmpline[ 81];10 char field[256]; 11 char format[256]; 12 char tmpline[256]; 13 13 14 14 // grab the value of TFORMn for this column … … 61 61 def->offset = 0; 62 62 for (i = 1; i < column; i++) { 63 s printf (field, "TFORM%d", i);63 snprintf (field, 256, "TFORM%d", i); 64 64 gfits_scan (ftable->header, field, "%s", 1, format); 65 65 gfits_bintable_format (format, tmpline, &Nv, &Nb); -
trunk/Ohana/src/libfits/table/F_uncompress_T.c
r38471 r38553 78 78 int i; 79 79 80 char keyword[ 81];80 char keyword[256]; 81 81 82 82 char *raw = NULL; 83 83 char *zdata = NULL; 84 TableField *fields = NULL; 84 85 85 86 Header *srcheader = srctable->header; … … 111 112 int offset = 0; 112 113 113 TableField *fields = NULL;114 114 ALLOCATE (fields, TableField, Nfields); 115 115 for (i = 0; i < Nfields; i++) { … … 336 336 free (raw); 337 337 free (zdata); 338 free (fields); 338 339 return (TRUE); 339 340 … … 341 342 FREE (raw); 342 343 FREE (zdata); 344 FREE (fields); 343 345 return FALSE; 344 346 } -
trunk/Ohana/src/libfits/table/F_write_T.c
r38441 r38553 5 5 int gfits_write_table (char *filename, FTable *table) { 6 6 7 FILE *f; 8 int status; 9 10 status = TRUE; 11 12 f = fopen (filename, "a+"); 7 FILE *f = fopen (filename, "a+"); 13 8 if (f == (FILE *) NULL) return (FALSE); 14 9 15 status = fseeko (f, 0LL, SEEK_END); /* write table to end of file! */10 int status = fseeko (f, 0LL, SEEK_END); /* write table to end of file! */ 16 11 if (status) { perror ("fseeko: "); return (FALSE); } 17 12 status = gfits_fwrite_table (f, table); … … 25 20 26 21 off_t Nbytes; 27 22 23 # ifdef OHANA_MEMORY 24 { // check memory before writing: 25 // memblock of supplied pointer 26 OhanaMemblock *myBlock = (OhanaMemblock *) table[0].buffer - 1; 27 myAssert (myBlock->startblock == OHANA_MEMMAGIC, "bad memory"); 28 myAssert (myBlock->endblock == OHANA_MEMMAGIC, "bad memory"); 29 myAssert (myBlock->size >= table[0].datasize, "overflow"); 30 } 31 # endif 32 28 33 Nbytes = fwrite (table[0].buffer, sizeof(char), table[0].datasize, f); 29 if (Nbytes != table[0].datasize) { perror ("fwrite: "); return (FALSE); } 34 if (Nbytes != table[0].datasize) { 35 perror ("fwrite: "); 36 return (FALSE); 37 } 30 38 return (TRUE); 31 39 } -
trunk/Ohana/src/libfits/table/F_write_TH.c
r38441 r38553 5 5 int gfits_write_Theader (char *filename, Header *header) { 6 6 7 FILE *f ;8 i nt status;7 FILE *f = fopen (filename, "a+"); 8 if (!f) return (FALSE); 9 9 10 status = TRUE; 11 12 f = fopen (filename, "a+"); 13 if (f == (FILE *) NULL) return (FALSE); 14 15 status = fseeko (f, 0LL, SEEK_END); /* write header to end of file! */ 10 int status = fseeko (f, 0LL, SEEK_END); /* write header to end of file! */ 16 11 if (status) { perror ("fseeko: "); return (FALSE); } 17 12 status = gfits_fwrite_Theader (f, header); … … 26 21 off_t Nbytes; 27 22 23 # ifdef OHANA_MEMORY 24 { 25 // memblock of supplied pointer 26 OhanaMemblock *myBlock = (OhanaMemblock *) header[0].buffer - 1; 27 myAssert (myBlock->startblock == OHANA_MEMMAGIC, "bad memory"); 28 myAssert (myBlock->endblock == OHANA_MEMMAGIC, "bad memory"); 29 myAssert (myBlock->size >= header[0].datasize, "overflow"); 30 } 31 # endif 32 28 33 Nbytes = fwrite (header[0].buffer, sizeof(char), header[0].datasize, f); 29 if (Nbytes != header[0].datasize) { perror ("fwrite: "); return (FALSE); } 34 if (Nbytes != header[0].datasize) { 35 perror ("fwrite: "); 36 return (FALSE); 37 } 30 38 31 39 return (TRUE); -
trunk/Ohana/src/libfits/test
- Property svn:ignore
-
old new 2 2 ricetest 3 3 tablecomp 4 tcomptiming 4 5 test.cmp.fits 5 6 test.fpk.fits
-
- Property svn:ignore
-
trunk/Ohana/src/libfits/test/imagecomp.c
r38427 r38553 11 11 int bitpix[] = {8, 16, 32, -32, -64, 0}; 12 12 13 // char *cmptype[] = {"GZIP_1", NULL};14 // int bitpix[] = {16, 0};13 // char *cmptype[] = {"NONE", NULL}; 14 // int bitpix[] = {16, 0}; 15 15 16 16 static int NX = 10; … … 31 31 test_compress_fulltile (bitpix[j], cmptype[i]); 32 32 test_compress_fullrange (bitpix[j], cmptype[i]); 33 ok (ohana_memcheck (TRUE), "no memory corruption"); 33 34 } 34 35 } … … 42 43 test_compress_fulltile (bitpix[j], cmptype[i]); 43 44 test_compress_fullrange (bitpix[j], cmptype[i]); 45 ok (ohana_memcheck (TRUE), "no memory corruption"); 44 46 } 45 47 } … … 53 55 test_compress_fulltile (bitpix[j], cmptype[i]); 54 56 test_compress_fullrange (bitpix[j], cmptype[i]); 57 ok (ohana_memcheck (TRUE), "no memory corruption"); 55 58 } 56 59 } -
trunk/Ohana/src/libfits/test/tablecomp.c
r38418 r38553 27 27 test_compress_fullrange (cmptype[i]); 28 28 test_compress_empty (cmptype[i]); 29 ok (ohana_memcheck _func(TRUE), "no memory corruption");29 ok (ohana_memcheck (TRUE), "no memory corruption"); 30 30 } 31 31 -
trunk/Ohana/src/libfits/test/tcomptiming.c
r38429 r38553 29 29 gfits_uncompress_timing(); 30 30 } 31 ok (ohana_memcheck _func(TRUE), "no memory corruption");31 ok (ohana_memcheck (TRUE), "no memory corruption"); 32 32 33 33 return exit_status(); -
trunk/Ohana/src/libohana/include/ohana.h
r38459 r38553 333 333 char *SelectConfigFile PROTO((int *argc, char **argv, char *progname)); 334 334 char *LoadConfigFile PROTO((char *filename)); 335 void FreeConfigFile PROTO((void)); 335 336 char *ScanConfig PROTO((char *config, char *field, char *mode, int N,...)) OHANA_FORMAT(scanf, 3, 5); 336 337 char *expandline PROTO((char *line, char *config)); -
trunk/Ohana/src/libohana/include/ohana_allocate.h
r38441 r38553 1 1 # ifndef OHANA_ALLOCATE 2 2 # define OHANA_ALLOCATE 3 4 # define OHANA_MEMMAGIC (uint32_t) 0xdeadbeef 5 6 typedef struct OhanaMemblock { 7 uint32_t startblock; // endpost marker 8 struct OhanaMemblock *prevBlock; // previously allocated memory 9 struct OhanaMemblock *nextBlock; // next allocated memory 10 size_t size; // size of memory 11 const char *file; // file (re)allocated 12 const char *func; // func (re)allocated 13 int line; // line (re)allocated 14 int freed; // memory has been freed 15 int dummy; // need to put endblock on the endpost 16 uint32_t endblock; // endpost marker 17 } OhanaMemblock; 3 18 4 19 typedef struct { … … 29 44 void real_free (void *in); 30 45 31 # define ohana_memcheck(X) ohana_memcheck_func (X) ;46 # define ohana_memcheck(X) ohana_memcheck_func (X) 32 47 # define ohana_memdump(X) ohana_memdump_func (X); 33 48 … … 56 71 # else /* below: not OHANA_MEMORY */ 57 72 58 # define ohana_memcheck(X) TRUE 73 int ohana_memcheck_noop (int mode); 74 75 # define ohana_memcheck(X) ohana_memcheck_noop (X) 59 76 # define ohana_memdump(X) /* NOP */ 60 77 void real_free (void *in); -
trunk/Ohana/src/libohana/src/config.c
r38459 r38553 7 7 static char **DefineVariable; 8 8 static char **DefineValue; 9 10 void FreeConfigFile (void) { 11 int i; 12 for (i = 0; i < NDefineVariable; i++) { 13 free (DefineVariable[i]); 14 free (DefineValue[i]); 15 } 16 free (DefineVariable); 17 free (DefineValue); 18 free (ConfigVariable); 19 } 9 20 10 21 char *SelectConfigFile (int *argc, char **argv, char *progname) { … … 80 91 uid = getuid(); 81 92 gid = getgid(); 82 ALLOCATE (find, char, strlen(progname) + 32); 93 94 int Nchar = strlen(progname) + 32; 95 ALLOCATE (find, char, Nchar); 83 96 84 97 /* look for progname.rc */ 85 s printf (find, "%s.rc", progname);98 snprintf (find, Nchar, "%s.rc", progname); 86 99 status = stat (find, &filestat); 87 100 if (status == 0) { … … 114 127 if (home == (char *) NULL) { return ((char *) NULL); } 115 128 ALLOCATE (find, char, 1024); 116 s printf (find, "%s/.%src", home, progname);129 snprintf (find, 1024, "%s/.%src", home, progname); 117 130 status = stat (find, &filestat); 118 131 if (status == 0) { … … 264 277 va_start (argp, Nentry); 265 278 266 ALLOCATE (tfield, char, strlen (field) + 3); 267 sprintf (tfield, "\n%s", field); 279 int Nchar = strlen (field) + 16; 280 ALLOCATE (tfield, char, Nchar); 281 snprintf (tfield, Nchar, "\n%s", field); 268 282 269 283 /* we search for Nentry matching fields, -
trunk/Ohana/src/libohana/src/findexec.c
r38062 r38553 113 113 /* check permission to write to backup file */ 114 114 if (BACKUP) { 115 ALLOCATE (filename, char, strlen(basefile) + 2); 116 sprintf (filename, "%s~", basefile); 115 int Nchar = strlen(basefile) + 16; 116 ALLOCATE (filename, char, Nchar); 117 snprintf (filename, Nchar, "%s~", basefile); 117 118 status = stat (filename, &filestat); 118 119 if (status == 0) { /* file exists, are permissions OK? */ … … 289 290 e = strchr (c, ':'); 290 291 } 291 s printf (name, "%s/%s", path, argv[0]);292 snprintf (name, 1024, "%s/%s", path, argv[0]); 292 293 status = check_file_exec (name); 293 294 … … 374 375 int status, cmode; 375 376 struct stat filestat; 376 char line[ 256];377 char line[1024]; 377 378 378 379 status = stat (filename, &filestat); 379 380 if (status == 0) { /* file exists, make backup copy */ 380 s printf (line, "cp %s %s~", filename, filename);381 snprintf (line, 1024, "cp %s %s~", filename, filename); 381 382 status = system (line); 382 383 if (status) { … … 385 386 } 386 387 cmode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; 387 s printf (line, "%s~", filename);388 snprintf (line, 1024, "%s~", filename); 388 389 chmod (line, cmode); 389 390 } -
trunk/Ohana/src/libohana/src/gaussj.c
r37807 r38553 144 144 if (fabs(growth) > MAX_RANGE) { 145 145 fprintf (stderr, "max range\n"); 146 # if (VERY_VERBOSE) 147 fprintf (stderr, "full A matrix:\n"); 148 for (row = 0; row < N; row++) { 149 for (col = 0; col < N; col++) { 150 fprintf (stderr, "%10.3e ", A[row][col]); 151 } 152 fprintf (stderr, "\n"); 153 } 154 fprintf (stderr, "\n"); 155 # endif 146 156 goto escape; 147 157 } -
trunk/Ohana/src/libohana/src/glockfile.c
r37807 r38553 152 152 path = pathname (filename); 153 153 file = filebasename (filename); 154 ALLOCATE (lockname, char, strlen (path) + strlen (file) + 10); 155 sprintf (lockname, "%s/.%s.lck", path, file); 154 int Nchar = strlen (path) + strlen (file) + 16; 155 ALLOCATE (lockname, char, Nchar); 156 snprintf (lockname, Nchar, "%s/.%s.lck", path, file); 156 157 157 158 status = stat (lockname, &filestat); … … 261 262 path = pathname (filename); 262 263 file = filebasename (filename); 263 ALLOCATE (lockname, char, strlen (path) + strlen (file) + 10); 264 sprintf (lockname, "%s/.%s.lck", path, file); 264 int Nchar = strlen (path) + strlen (file) + 16; 265 ALLOCATE (lockname, char, Nchar); 266 snprintf (lockname, Nchar, "%s/.%s.lck", path, file); 265 267 266 268 /* check for lockfile existance */ -
trunk/Ohana/src/libohana/src/ohana_allocate.c
r38441 r38553 4 4 # include <stdint.h> 5 5 # include <pthread.h> 6 # include <string.h> 7 8 # define TEST_SAVE_FREE_BLOCKS 0 9 # define TEST_SAVE_DROP_BLOCKS 0 6 10 7 11 # undef OHANA_MEMORY … … 13 17 # define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) 14 18 15 # define OHANA_MEMMAGIC (uint32_t) 0xdeadbeef 16 17 typedef struct Memblock { 18 uint32_t startblock; // endpost marker 19 struct Memblock *prevBlock; // previously allocated memory 20 struct Memblock *nextBlock; // next allocated memory 21 size_t size; // size of memory 22 const char *file; // file (re)allocated 23 const char *func; // func (re)allocated 24 int line; // line (re)allocated 25 uint32_t endblock; // endpost marker 26 } Memblock; 27 28 static Memblock *lastBlock = NULL; 19 static OhanaMemblock *lastBlock = NULL; 20 21 # if (TEST_SAVE_FREE_BLOCKS) 22 static OhanaMemblock *freeBlock = NULL; 23 # endif 24 25 # if (TEST_SAVE_DROP_BLOCKS) 26 static OhanaMemblock *dropBlock = NULL; 27 # endif 29 28 30 29 static pthread_mutex_t memBlockListMutex = PTHREAD_MUTEX_INITIALIZER; … … 46 45 47 46 void *ptr; // actual user memory allocated 48 Memblock *new; // new memblock created to track the user memory47 OhanaMemblock *new; // new memblock created to track the user memory 49 48 size_t size; // total number of bytes requested (not items) 50 49 … … 53 52 54 53 // total size is : memblock + data + endpost 55 new = ( Memblock *) malloc (sizeof(Memblock) + size + sizeof(void *));54 new = (OhanaMemblock *) malloc (sizeof(OhanaMemblock) + size + sizeof(void *)); 56 55 if (new == NULL) ohana_memabort ("failed to allocate memory (%s, %d, %s)\n", file, line, func); 57 56 … … 69 68 new->line = line; 70 69 new->func = func; 70 new->freed = FALSE; 71 72 // to be clean, zero out the memory 73 // memset (ptr, 0, new->size); 71 74 72 75 // new memblock becomes the 'lastBlock': … … 99 102 void *ohana_realloc (const char *file, int line, const char *func, void *in, size_t Nelem, size_t esize) { 100 103 101 void *ptr; // actual user memory allocated 102 Memblock *old; // original memblock associated with user memory 103 Memblock *new; // new memblock associated with user memory 104 OhanaMemblock *old; // original memblock associated with user memory 105 OhanaMemblock *new; // new memblock associated with user memory 104 106 size_t size; 105 107 106 108 // just allocate if not previously allocated 107 109 if (!in) { 108 ptr = ohana_malloc (file, line, func, Nelem, esize);110 void *ptr = ohana_malloc (file, line, func, Nelem, esize); 109 111 return ptr; 110 112 } 111 113 112 114 // memblock of supplied pointer 113 old = ( Memblock *) in - 1;115 old = (OhanaMemblock *) in - 1; 114 116 115 117 if (old->startblock != OHANA_MEMMAGIC) ohana_memabort ("corrupt memory (%s, %d, %s)\n", file, line, func); … … 126 128 pthread_mutex_lock(&memBlockListMutex); 127 129 128 Memblock *nextBlock = old->nextBlock;129 Memblock *prevBlock = old->prevBlock;130 OhanaMemblock *nextBlock = old->nextBlock; 131 OhanaMemblock *prevBlock = old->prevBlock; 130 132 131 133 int isLast = (old == lastBlock); 132 134 135 // ask for new memory 136 137 # if (TEST_SAVE_DROP_BLOCKS) 138 // XXX for a test, we are going to always alloc a new block, copy the old data to the new block 139 // poison the old block, then free it 140 new = (OhanaMemblock *) malloc (sizeof(OhanaMemblock) + size + sizeof(void *)); 141 if (new == NULL) ohana_memabort ("failed to reallocate memory (%s, %d, %s)\n", file, line, func); 142 void *ptr_new = (char *) (new + 1); 143 void *ptr_old = (char *) (old + 1); 144 size_t copy_bytes = old->size < size ? old->size : size; 145 memcpy (ptr_new, ptr_old, copy_bytes); 146 memset (ptr_old, 0x7f, old->size); 147 new->nextBlock = old->nextBlock; 148 new->prevBlock = old->prevBlock; 149 # else 133 150 // ask for new memory 134 151 // total size is : memblock + data + endpost 135 new = ( Memblock *) realloc (old, sizeof(Memblock) + size + sizeof(void *));152 new = (OhanaMemblock *) realloc (old, sizeof(OhanaMemblock) + size + sizeof(void *)); 136 153 if (new == NULL) ohana_memabort ("failed to reallocate memory (%s, %d, %s)\n", file, line, func); 137 ptr = (char *) (new + 1); 138 139 // give the realloc location: 154 void *ptr_new = (char *) (new + 1); 155 # endif 156 157 // set the end-post values 158 new->startblock = OHANA_MEMMAGIC; 159 new->endblock = OHANA_MEMMAGIC; 160 *(uint32_t *)(ptr_new + size) = OHANA_MEMMAGIC; 161 162 // set the memory metadata 140 163 new->size = size; 141 164 new->file = file; 142 165 new->line = line; 143 166 new->func = func; 167 new->freed = FALSE; 144 168 145 169 // update the endpost (the others were set originally 146 *(uint32_t *)(ptr + size) = OHANA_MEMMAGIC;170 *(uint32_t *)(ptr_new + size) = OHANA_MEMMAGIC; 147 171 148 172 // need to reset lastBlock in case we moved … … 159 183 } 160 184 185 // XXX FOR TESTING, save the realloc blocks 186 # if (TEST_SAVE_DROP_BLOCKS) 187 if (dropBlock) { 188 dropBlock->nextBlock = old; 189 } 190 old->nextBlock = NULL; 191 old->prevBlock = dropBlock; 192 dropBlock = old; 193 # endif 194 161 195 pthread_mutex_unlock(&memBlockListMutex); 162 196 163 return (ptr );197 return (ptr_new); 164 198 } 165 199 … … 174 208 void ohana_free (const char *file, int line, const char *func, void *in) { 175 209 176 Memblock *ref;210 OhanaMemblock *ref; 177 211 178 212 if (!in) return; … … 180 214 // fprintf (stderr, "free %zx\n", (size_t) in); 181 215 182 ref = (Memblock *) in - 1; 216 ref = (OhanaMemblock *) in - 1; 217 218 if (ref->freed) ohana_memabort ("memory already freed (%s, %d, %s [%d bytes])\n", ref->file, ref->line, ref->func, ref->size); 219 ref->freed = TRUE; 183 220 184 221 // fprintf (stderr, " file: %s, line: %d, func: %s, size: %zd, addr: %zx\n", … … 187 224 pthread_mutex_lock(&memBlockListMutex); 188 225 189 Memblock *nextBlock = ref->nextBlock; 190 Memblock *prevBlock = ref->prevBlock; 191 226 OhanaMemblock *nextBlock = ref->nextBlock; 227 OhanaMemblock *prevBlock = ref->prevBlock; 228 229 // remove this memBlock from the list 192 230 if (nextBlock) { 193 231 nextBlock->prevBlock = prevBlock; … … 200 238 } 201 239 240 // XXX FOR TESTING, save the freed blocks 241 # if (TEST_SAVE_FREE_BLOCKS) 242 if (freeBlock) { 243 freeBlock->nextBlock = ref; 244 } 245 ref->nextBlock = NULL; 246 ref->prevBlock = freeBlock; 247 freeBlock = ref; 248 # endif 249 250 // pointer to the start of the user memory 251 void *ptr = (char *)(ref + 1); 252 memset (ptr, 0x77, ref->size); 253 202 254 pthread_mutex_unlock(&memBlockListMutex); 203 255 256 # if (!TEST_SAVE_FREE_BLOCKS) 204 257 free (ref); 258 # endif 205 259 206 260 return; 261 } 262 263 int ohana_memcheck_noop (int allmemory) { 264 return TRUE; 207 265 } 208 266 … … 211 269 if (!lastBlock) { 212 270 fprintf (stderr, "no memory allocated\n"); 213 return TRUE; 214 } 215 216 Memblock *thisBlock = lastBlock; 271 } 272 273 OhanaMemblock *thisBlock = lastBlock; 217 274 218 275 size_t Ngood = 0; … … 220 277 size_t Ntotal = 0; 221 278 size_t Nbytes = 0; 279 int status = TRUE; 222 280 223 281 while (thisBlock) { … … 250 308 thisBlock = thisBlock->prevBlock; 251 309 } 310 fprintf (stderr, "%zd memory blocks allocated (%zd bytes total), %zd good, %zd bad\n", Ntotal, Nbytes, Ngood, Nbad); 311 if (Nbad) status = FALSE; 312 313 # if (TEST_SAVE_FREE_BLOCKS) 252 314 253 fprintf (stderr, "%zd memory blocks allocated (%zd bytes total), %zd good, %zd bad\n", Ntotal, Nbytes, Ngood, Nbad); 254 255 if (Nbad) return FALSE; 256 return TRUE; 315 thisBlock = freeBlock; 316 317 size_t Ngood_free = 0; 318 size_t Nbad_free = 0; 319 size_t Ntotal_free = 0; 320 size_t Nbytes_free = 0; 321 322 while (thisBlock) { 323 324 int i; 325 int good = TRUE; 326 327 if (thisBlock->startblock != OHANA_MEMMAGIC) good = FALSE; 328 if (thisBlock->endblock != OHANA_MEMMAGIC) good = FALSE; 329 330 // pointer to the end of the user memory 331 char *ptr = (char *)(thisBlock + 1) + thisBlock->size; 332 uint32_t endpost = *(uint32_t *)ptr; 333 if (endpost != OHANA_MEMMAGIC) good = FALSE; 334 335 // pointer to the start of the user memory 336 ptr = (char *)(thisBlock + 1); 337 for (i = 0; i < thisBlock->size; i++, ptr++) { 338 if (*ptr != 0x77) good = FALSE; 339 } 340 341 // XXX keep checking even if memory is corrupted? 342 if (!good) { 343 if (Nbad_free < 1) { 344 fprintf (stderr, "memory corruption\n"); 345 } 346 if (Nbad_free < 100) { 347 fprintf (stderr, " file: %s, line: %d, func: %s\n", thisBlock->file, thisBlock->line, thisBlock->func); 348 } 349 Nbad_free ++; 350 } else { 351 Ngood_free ++; 352 } 353 Ntotal_free ++; 354 Nbytes_free += thisBlock->size; 355 356 thisBlock = thisBlock->prevBlock; 357 } 358 fprintf (stderr, "%zd memory blocks freed (%zd bytes total), %zd good, %zd bad\n", Ntotal_free, Nbytes_free, Ngood_free, Nbad_free); 359 if (Nbad_free) status = FALSE; 360 361 # endif 362 363 # if (TEST_SAVE_DROP_BLOCKS) 364 thisBlock = dropBlock; 365 366 size_t Ngood_drop = 0; 367 size_t Nbad_drop = 0; 368 size_t Ntotal_drop = 0; 369 size_t Nbytes_drop = 0; 370 371 while (thisBlock) { 372 373 int i; 374 int good = TRUE; 375 376 if (thisBlock->startblock != OHANA_MEMMAGIC) good = FALSE; 377 if (thisBlock->endblock != OHANA_MEMMAGIC) good = FALSE; 378 379 // pointer to the end of the user memory 380 char *ptr = (char *)(thisBlock + 1) + thisBlock->size; 381 uint32_t endpost = *(uint32_t *)ptr; 382 if (endpost != OHANA_MEMMAGIC) good = FALSE; 383 384 // pointer to the start of the user memory 385 ptr = (char *)(thisBlock + 1); 386 for (i = 0; i < thisBlock->size; i++, ptr++) { 387 if (*ptr != 0x7f) good = FALSE; 388 } 389 390 // XXX keep checking even if memory is corrupted? 391 if (!good) { 392 if (Nbad_drop < 1) { 393 fprintf (stderr, "memory corruption\n"); 394 } 395 if (Nbad_drop < 100) { 396 fprintf (stderr, " file: %s, line: %d, func: %s\n", thisBlock->file, thisBlock->line, thisBlock->func); 397 } 398 Nbad_drop ++; 399 } else { 400 Ngood_drop ++; 401 } 402 Ntotal_drop ++; 403 Nbytes_drop += thisBlock->size; 404 405 thisBlock = thisBlock->prevBlock; 406 } 407 fprintf (stderr, "%zd memory blocks dropped (%zd bytes total), %zd good, %zd bad\n", Ntotal_drop, Nbytes_drop, Ngood_drop, Nbad_drop); 408 if (Nbad_drop) status = FALSE; 409 # endif 410 411 return status; 257 412 } 258 413 … … 264 419 } 265 420 266 Memblock *thisBlock = lastBlock;421 OhanaMemblock *thisBlock = lastBlock; 267 422 268 423 size_t Ntotal = 0; … … 312 467 memstats.Nbad = 0; 313 468 314 Memblock *thisBlock = lastBlock;469 OhanaMemblock *thisBlock = lastBlock; 315 470 316 471 while (thisBlock) { -
trunk/Ohana/src/libohana/src/time.c
r34088 r38553 141 141 ALLOCATE (tmpline, char, 64); 142 142 gmt = gmtime (&tsec); 143 s printf (tmpline, "%04d/%02d/%02d,%s", 1900 + gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday, &line[6]);143 snprintf (tmpline, 64, "%04d/%02d/%02d,%s", 1900 + gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday, &line[6]); 144 144 *second = ohana_date_to_sec (tmpline); 145 145 free (tmpline); … … 251 251 ALLOCATE (line, char, 64); 252 252 gmt = gmtime (&second); 253 s printf (line, "%04d/%02d/%02d,%02d:%02d:%02d", 1900 + gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday, gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);253 snprintf (line, 64, "%04d/%02d/%02d,%02d:%02d:%02d", 1900 + gmt[0].tm_year, gmt[0].tm_mon+1, gmt[0].tm_mday, gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 254 254 return (line); 255 255 -
trunk/Ohana/src/opihi/cmd.astro/radec.c
r18718 r38553 45 45 46 46 // convert to hms, dms 47 hms_format (ra_string, ra/15.0);48 hms_format (dec_string, dec);47 hms_format (ra_string, 32, ra/15.0); 48 hms_format (dec_string, 32, dec); 49 49 50 50 set_str_variable ("RA", ra_string); -
trunk/Ohana/src/opihi/cmd.astro/sexigesimal.c
r14590 r38553 35 35 } else { 36 36 value = atof (argv[1]); 37 hms_format (string, value);37 hms_format (string, 80, value); 38 38 if (argc == 3) { 39 39 set_str_variable (argv[2], string); -
trunk/Ohana/src/opihi/cmd.data/read_vectors.c
r38441 r38553 77 77 if ((argc < 3) || !(argc % 2)) { 78 78 gprint (GP_ERR, "USAGE: read name N name N ...\n"); 79 gprint (GP_ERR, " options:\n"); 80 gprint (GP_ERR, " -fits EXTNAME : read a fits file from the given extension (vector names are column names)\n"); 81 gprint (GP_ERR, " -v : verbose mode\n"); 82 gprint (GP_ERR, " -csv : comma-separated values (columns may be identified in excel-style: A, AC\n"); 83 gprint (GP_ERR, " -skip N : skip N lines before reading\n"); 84 gprint (GP_ERR, " column names may include a type: name:type\n"); 85 gprint (GP_ERR, " type is int, float, char, time\n"); 86 gprint (GP_ERR, " for char, values are placed into a list $name:0 - $name:n\n"); 87 gprint (GP_ERR, " for time, values are human-readable date/time strings YYYY/MM/DD,hh:mm:ss\n"); 88 gprint (GP_ERR, " the resulting vector is a float based on the TIMEFORMAT, TIMEREF values\n"); 79 89 return (FALSE); 80 90 } -
trunk/Ohana/src/opihi/dimm/telescope_cmds.c
r23530 r38553 87 87 set_variable ("RA", ra); 88 88 set_variable ("DEC", dec); 89 dms_format (line, (ra/15.0));89 dms_format (line, 64, (ra/15.0)); 90 90 set_str_variable ("Rs", line); 91 dms_format (line, dec);91 dms_format (line, 64, dec); 92 92 set_str_variable ("Ds", line); 93 93 -
trunk/Ohana/src/opihi/lib.shell/stack_math.c
r38441 r38553 32 32 33 33 switch (op[0]) { 34 case '?': SSS_FUNC(M1 ? M2: M3);35 default:36 snprintf (line, 512, "error: op %c not defined!", op[0]);37 push_error (line);38 return (FALSE);39 }34 case '?': SSS_FUNC(M1 ? M2: M3); 35 default: 36 snprintf (line, 512, "error: op %c not defined!", op[0]); 37 push_error (line); 38 return (FALSE); 39 } 40 40 # undef SSS_FUNC 41 41 … … 447 447 448 448 switch (op[0]) { 449 case '+': SV_FUNC(ST_SCALAR_INT, M1 + *M2);450 case '-': SV_FUNC(ST_SCALAR_INT, M1 - *M2);451 case '*': SV_FUNC(ST_SCALAR_INT, M1 * *M2);452 case '/': SV_FUNC(ST_SCALAR_FLT, M1 / (opihi_flt) *M2);453 case '%': SV_FUNC(ST_SCALAR_INT, (long long) M1 % (long long) *M2);454 case '^': SV_FUNC(ST_SCALAR_FLT, pow (M1, *M2));455 case '@': SV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, *M2));456 case 'a': SV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, *M2));457 case 'D': SV_FUNC(ST_SCALAR_INT, MIN (M1, *M2));458 case 'U': SV_FUNC(ST_SCALAR_INT, MAX (M1, *M2));459 case '<': SV_FUNC(ST_SCALAR_INT, (M1 < *M2) ? 1 : 0);460 case '>': SV_FUNC(ST_SCALAR_INT, (M1 > *M2) ? 1 : 0);461 case '&': SV_FUNC(ST_SCALAR_INT, ((long long)M1 & (long long)*M2));462 case '|': SV_FUNC(ST_SCALAR_INT, ((long long)M1 | (long long)*M2));463 case 'E': SV_FUNC(ST_SCALAR_INT, (M1 == *M2) ? 1 : 0);464 case 'N': SV_FUNC(ST_SCALAR_INT, (M1 != *M2) ? 1 : 0);465 case 'L': SV_FUNC(ST_SCALAR_INT, (M1 <= *M2) ? 1 : 0);466 case 'G': SV_FUNC(ST_SCALAR_INT, (M1 >= *M2) ? 1 : 0);467 case 'A': SV_FUNC(ST_SCALAR_INT, (M1 && *M2) ? 1 : 0);468 case 'O': SV_FUNC(ST_SCALAR_INT, (M1 || *M2) ? 1 : 0);469 default:470 snprintf (line, 512, "error: op %c not defined!", op[0]);471 push_error (line);472 return (FALSE);473 }449 case '+': SV_FUNC(ST_SCALAR_INT, M1 + *M2); 450 case '-': SV_FUNC(ST_SCALAR_INT, M1 - *M2); 451 case '*': SV_FUNC(ST_SCALAR_INT, M1 * *M2); 452 case '/': SV_FUNC(ST_SCALAR_FLT, M1 / (opihi_flt) *M2); 453 case '%': SV_FUNC(ST_SCALAR_INT, (long long) M1 % (long long) *M2); 454 case '^': SV_FUNC(ST_SCALAR_FLT, pow (M1, *M2)); 455 case '@': SV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, *M2)); 456 case 'a': SV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, *M2)); 457 case 'D': SV_FUNC(ST_SCALAR_INT, MIN (M1, *M2)); 458 case 'U': SV_FUNC(ST_SCALAR_INT, MAX (M1, *M2)); 459 case '<': SV_FUNC(ST_SCALAR_INT, (M1 < *M2) ? 1 : 0); 460 case '>': SV_FUNC(ST_SCALAR_INT, (M1 > *M2) ? 1 : 0); 461 case '&': SV_FUNC(ST_SCALAR_INT, ((long long)M1 & (long long)*M2)); 462 case '|': SV_FUNC(ST_SCALAR_INT, ((long long)M1 | (long long)*M2)); 463 case 'E': SV_FUNC(ST_SCALAR_INT, (M1 == *M2) ? 1 : 0); 464 case 'N': SV_FUNC(ST_SCALAR_INT, (M1 != *M2) ? 1 : 0); 465 case 'L': SV_FUNC(ST_SCALAR_INT, (M1 <= *M2) ? 1 : 0); 466 case 'G': SV_FUNC(ST_SCALAR_INT, (M1 >= *M2) ? 1 : 0); 467 case 'A': SV_FUNC(ST_SCALAR_INT, (M1 && *M2) ? 1 : 0); 468 case 'O': SV_FUNC(ST_SCALAR_INT, (M1 || *M2) ? 1 : 0); 469 default: 470 snprintf (line, 512, "error: op %c not defined!", op[0]); 471 push_error (line); 472 return (FALSE); 473 } 474 474 # undef SV_FUNC 475 475 476 476 /** free up any temporary buffers: **/ 477 477 if (V2[0].type == ST_VECTOR_TMP) { 478 free (V2[0].vector[0].elements.Ptr);479 free (V2[0].vector);480 }478 free (V2[0].vector[0].elements.Ptr); 479 free (V2[0].vector); 480 } 481 481 482 482 clear_stack (V1); … … 554 554 555 555 switch (op[0]) { 556 case '+': VS_FUNC(ST_SCALAR_INT, *M1 + M2);557 case '-': VS_FUNC(ST_SCALAR_INT, *M1 - M2);558 case '*': VS_FUNC(ST_SCALAR_INT, *M1 * M2);559 case '/': VS_FUNC(ST_SCALAR_FLT, *M1 / (opihi_flt) M2);560 case '%': VS_FUNC(ST_SCALAR_INT, (long long) *M1 % (long long) M2);561 case '^': VS_FUNC(ST_SCALAR_FLT, pow (*M1, M2));562 case '@': VS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, M2));563 case 'a': VS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, M2));564 case 'D': VS_FUNC(ST_SCALAR_INT, MIN (*M1, M2));565 case 'U': VS_FUNC(ST_SCALAR_INT, MAX (*M1, M2));566 case '<': VS_FUNC(ST_SCALAR_INT, (*M1 < M2) ? 1 : 0);567 case '>': VS_FUNC(ST_SCALAR_INT, (*M1 > M2) ? 1 : 0);568 case '&': VS_FUNC(ST_SCALAR_INT, ((long long)*M1 & (long long)M2));569 case '|': VS_FUNC(ST_SCALAR_INT, ((long long)*M1 | (long long)M2));570 case 'E': VS_FUNC(ST_SCALAR_INT, (*M1 == M2) ? 1 : 0);571 case 'N': VS_FUNC(ST_SCALAR_INT, (*M1 != M2) ? 1 : 0);572 case 'L': VS_FUNC(ST_SCALAR_INT, (*M1 <= M2) ? 1 : 0);573 case 'G': VS_FUNC(ST_SCALAR_INT, (*M1 >= M2) ? 1 : 0);574 case 'A': VS_FUNC(ST_SCALAR_INT, (*M1 && M2) ? 1 : 0);575 case 'O': VS_FUNC(ST_SCALAR_INT, (*M1 || M2) ? 1 : 0);576 default:577 snprintf (line, 512, "error: op %c not defined!", op[0]);578 push_error (line);579 return (FALSE);580 }556 case '+': VS_FUNC(ST_SCALAR_INT, *M1 + M2); 557 case '-': VS_FUNC(ST_SCALAR_INT, *M1 - M2); 558 case '*': VS_FUNC(ST_SCALAR_INT, *M1 * M2); 559 case '/': VS_FUNC(ST_SCALAR_FLT, *M1 / (opihi_flt) M2); 560 case '%': VS_FUNC(ST_SCALAR_INT, (long long) *M1 % (long long) M2); 561 case '^': VS_FUNC(ST_SCALAR_FLT, pow (*M1, M2)); 562 case '@': VS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, M2)); 563 case 'a': VS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, M2)); 564 case 'D': VS_FUNC(ST_SCALAR_INT, MIN (*M1, M2)); 565 case 'U': VS_FUNC(ST_SCALAR_INT, MAX (*M1, M2)); 566 case '<': VS_FUNC(ST_SCALAR_INT, (*M1 < M2) ? 1 : 0); 567 case '>': VS_FUNC(ST_SCALAR_INT, (*M1 > M2) ? 1 : 0); 568 case '&': VS_FUNC(ST_SCALAR_INT, ((long long)*M1 & (long long)M2)); 569 case '|': VS_FUNC(ST_SCALAR_INT, ((long long)*M1 | (long long)M2)); 570 case 'E': VS_FUNC(ST_SCALAR_INT, (*M1 == M2) ? 1 : 0); 571 case 'N': VS_FUNC(ST_SCALAR_INT, (*M1 != M2) ? 1 : 0); 572 case 'L': VS_FUNC(ST_SCALAR_INT, (*M1 <= M2) ? 1 : 0); 573 case 'G': VS_FUNC(ST_SCALAR_INT, (*M1 >= M2) ? 1 : 0); 574 case 'A': VS_FUNC(ST_SCALAR_INT, (*M1 && M2) ? 1 : 0); 575 case 'O': VS_FUNC(ST_SCALAR_INT, (*M1 || M2) ? 1 : 0); 576 default: 577 snprintf (line, 512, "error: op %c not defined!", op[0]); 578 push_error (line); 579 return (FALSE); 580 } 581 581 # undef VS_FUNC 582 582 … … 584 584 585 585 if (V1[0].type == ST_VECTOR_TMP) { 586 free (V1[0].vector[0].elements.Ptr);587 free (V1[0].vector);588 }586 free (V1[0].vector[0].elements.Ptr); 587 free (V1[0].vector); 588 } 589 589 590 590 clear_stack (V1); … … 1061 1061 1062 1062 switch (op[0]) { 1063 case '+': SS_FUNC(ST_SCALAR_INT, M1 + M2);1064 case '-': SS_FUNC(ST_SCALAR_INT, M1 - M2);1065 case '*': SS_FUNC(ST_SCALAR_INT, M1 * M2);1066 case '/': SS_FUNC(ST_SCALAR_FLT, M1 / (opihi_flt) M2);1067 case '%': SS_FUNC(ST_SCALAR_INT, (long long) M1 % (long long) M2);1068 case '^': SS_FUNC(ST_SCALAR_FLT, pow (M1, M2));1069 case '@': SS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, M2));1070 case 'a': SS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, M2));1071 case 'D': SS_FUNC(ST_SCALAR_INT, MIN (M1, M2));1072 case 'U': SS_FUNC(ST_SCALAR_INT, MAX (M1, M2));1073 case '<': SS_FUNC(ST_SCALAR_INT, (M1 < M2) ? 1 : 0);1074 case '>': SS_FUNC(ST_SCALAR_INT, (M1 > M2) ? 1 : 0);1075 case '&': SS_FUNC(ST_SCALAR_INT, ((long long)M1 & (long long)M2));1076 case '|': SS_FUNC(ST_SCALAR_INT, ((long long)M1 | (long long)M2));1077 case 'E': SS_FUNC(ST_SCALAR_INT, (M1 == M2) ? 1 : 0);1078 case 'N': SS_FUNC(ST_SCALAR_INT, (M1 != M2) ? 1 : 0);1079 case 'L': SS_FUNC(ST_SCALAR_INT, (M1 <= M2) ? 1 : 0);1080 case 'G': SS_FUNC(ST_SCALAR_INT, (M1 >= M2) ? 1 : 0);1081 case 'A': SS_FUNC(ST_SCALAR_INT, (M1 && M2) ? 1 : 0);1082 case 'O': SS_FUNC(ST_SCALAR_INT, (M1 || M2) ? 1 : 0);1083 default:1084 snprintf (line, 512, "error: op %c not defined!", op[0]);1085 push_error (line);1086 return (FALSE);1087 }1063 case '+': SS_FUNC(ST_SCALAR_INT, M1 + M2); 1064 case '-': SS_FUNC(ST_SCALAR_INT, M1 - M2); 1065 case '*': SS_FUNC(ST_SCALAR_INT, M1 * M2); 1066 case '/': SS_FUNC(ST_SCALAR_FLT, M1 / (opihi_flt) M2); 1067 case '%': SS_FUNC(ST_SCALAR_INT, (long long) M1 % (long long) M2); 1068 case '^': SS_FUNC(ST_SCALAR_FLT, pow (M1, M2)); 1069 case '@': SS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, M2)); 1070 case 'a': SS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, M2)); 1071 case 'D': SS_FUNC(ST_SCALAR_INT, MIN (M1, M2)); 1072 case 'U': SS_FUNC(ST_SCALAR_INT, MAX (M1, M2)); 1073 case '<': SS_FUNC(ST_SCALAR_INT, (M1 < M2) ? 1 : 0); 1074 case '>': SS_FUNC(ST_SCALAR_INT, (M1 > M2) ? 1 : 0); 1075 case '&': SS_FUNC(ST_SCALAR_INT, ((long long)M1 & (long long)M2)); 1076 case '|': SS_FUNC(ST_SCALAR_INT, ((long long)M1 | (long long)M2)); 1077 case 'E': SS_FUNC(ST_SCALAR_INT, (M1 == M2) ? 1 : 0); 1078 case 'N': SS_FUNC(ST_SCALAR_INT, (M1 != M2) ? 1 : 0); 1079 case 'L': SS_FUNC(ST_SCALAR_INT, (M1 <= M2) ? 1 : 0); 1080 case 'G': SS_FUNC(ST_SCALAR_INT, (M1 >= M2) ? 1 : 0); 1081 case 'A': SS_FUNC(ST_SCALAR_INT, (M1 && M2) ? 1 : 0); 1082 case 'O': SS_FUNC(ST_SCALAR_INT, (M1 || M2) ? 1 : 0); 1083 default: 1084 snprintf (line, 512, "error: op %c not defined!", op[0]); 1085 push_error (line); 1086 return (FALSE); 1087 } 1088 1088 # undef SS_FUNC 1089 1089 … … 1133 1133 case 'E': 1134 1134 value = strcmp (V1[0].name, V2[0].name) ? 0 : 1; 1135 break;1135 break; 1136 1136 case 'N': 1137 1137 value = strcmp (V1[0].name, V2[0].name) ? 1 : 0; 1138 break;1138 break; 1139 1139 default: 1140 1140 snprintf (line, 512, "error: op %c not defined for string operations!", op[0]); -
trunk/Ohana/src/relastro/src/BrightCatalog.c
r38441 r38553 349 349 /*** MeasureTiny ***/ 350 350 { 351 ohana_memcheck _func(1);351 ohana_memcheck (1); 352 352 gfits_create_table_header (&theader, "BINTABLE", "MEASURE_TINY"); 353 353 354 ohana_memcheck _func(1);354 ohana_memcheck (1); 355 355 gfits_define_bintable_column (&theader, "D", "RA", "ra", "degrees", 1.0, 0.0); 356 356 gfits_define_bintable_column (&theader, "D", "DEC", "dec", "degrees", 1.0, 0.0); … … 375 375 376 376 // generate the output array that carries the data 377 ohana_memcheck _func(1);377 ohana_memcheck (1); 378 378 gfits_create_table (&theader, &ftable); 379 ohana_memcheck _func(1);379 ohana_memcheck (1); 380 380 381 381 // create intermediate storage arrays … … 400 400 int *catID ; ALLOCATE (catID , int , catalog->Nmeasure); 401 401 short *photcode ; ALLOCATE (photcode , short, catalog->Nmeasure); 402 ohana_memcheck _func(1);402 ohana_memcheck (1); 403 403 404 404 // assign the storage arrays … … 426 426 photcode[i] = measure[i].photcode ; 427 427 } 428 ohana_memcheck _func(1);428 ohana_memcheck (1); 429 429 430 430 // add the columns to the output array 431 431 gfits_set_bintable_column (&theader, &ftable, "RA", R, catalog->Nmeasure); 432 ohana_memcheck _func(1);432 ohana_memcheck (1); 433 433 gfits_set_bintable_column (&theader, &ftable, "DEC", D, catalog->Nmeasure); 434 ohana_memcheck _func(1);434 ohana_memcheck (1); 435 435 gfits_set_bintable_column (&theader, &ftable, "ROFF_GAL", RoffGAL, catalog->Nmeasure); 436 436 gfits_set_bintable_column (&theader, &ftable, "DOFF_GAL", DoffGAL, catalog->Nmeasure); -
trunk/Ohana/src/relastro/src/FrameCorrectionUtils.c
r37807 r38553 62 62 ALLOCATE (frame->Roff[i], double, frame->Nra[i]); 63 63 ALLOCATE (frame->Doff[i], double, frame->Nra[i]); 64 // ohana_memcheck _func(TRUE);64 // ohana_memcheck (TRUE); 65 65 // fprintf (stderr, "alloc : %d : %lx %lx\n", i, (long unsigned int)(size_t *) frame->Roff[i], (long unsigned int) (size_t *) frame->Doff[i]); 66 66 }
Note:
See TracChangeset
for help on using the changeset viewer.
