Changeset 31606
- Timestamp:
- Jun 6, 2011, 1:56:22 PM (15 years ago)
- Location:
- branches/czw_branch/20110406
- Files:
-
- 189 edited
- 5 copied
-
. (modified) (1 prop)
-
Ohana/Makefile.in (modified) (4 diffs)
-
Ohana/src/addstar/Makefile (modified) (1 diff)
-
Ohana/src/dvomerge/Makefile (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvo_image_merge_dbs.c (modified) (1 diff)
-
Ohana/src/dvomerge/src/dvoverify.c (modified) (4 diffs)
-
Ohana/src/dvosplit/Makefile (modified) (1 diff)
-
Ohana/src/imregister/Makefile (modified) (1 diff)
-
Ohana/src/kapa2/src/DrawObjects.c (modified) (35 diffs)
-
Ohana/src/kapa2/src/PSObjects.c (modified) (2 diffs)
-
Ohana/src/kapa2/src/bDrawObjects.c (modified) (15 diffs)
-
Ohana/src/libdvo/Makefile (modified) (2 diffs)
-
Ohana/src/libdvo/include/dvo.h (modified) (4 diffs)
-
Ohana/src/libdvo/src/dvo_catalog_split.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dvo_photcode_ops.c (modified) (1 diff)
-
Ohana/src/libkapa/include/kapa.h (modified) (1 diff)
-
Ohana/src/libkapa/src/bDrawFuncs.c (modified) (2 diffs)
-
Ohana/src/libohana/Makefile (modified) (1 diff)
-
Ohana/src/misc/Makefile (modified) (2 diffs)
-
Ohana/src/opihi/Makefile (modified) (2 diffs)
-
Ohana/src/opihi/cmd.data/Makefile (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/gridify.c (modified) (3 diffs)
-
Ohana/src/opihi/cmd.data/init.c (modified) (2 diffs)
-
Ohana/src/opihi/cmd.data/vshift.c (copied) (copied from trunk/Ohana/src/opihi/cmd.data/vshift.c )
-
Ohana/src/opihi/dvo/Makefile (modified) (1 diff)
-
Ohana/src/opihi/dvo/avextract.c (modified) (3 diffs)
-
Ohana/src/opihi/dvo/init.c (modified) (2 diffs)
-
Ohana/src/opihi/dvo/objectcoverage.c (copied) (copied from trunk/Ohana/src/opihi/dvo/objectcoverage.c )
-
Ohana/src/photdbc/src/make_subcatalog.c (modified) (2 diffs)
-
Ohana/src/relastro/src/UpdateObjects.c (modified) (1 diff)
-
Ohana/src/relastro/src/high_speed_catalogs.c (modified) (3 diffs)
-
Ohana/src/relphot/doc/allsky.txt (copied) (copied from trunk/Ohana/src/relphot/doc/allsky.txt )
-
Ohana/src/relphot/include/relphot.h (modified) (4 diffs)
-
Ohana/src/relphot/src/GridOps.c (modified) (18 diffs)
-
Ohana/src/relphot/src/ImageOps.c (modified) (16 diffs)
-
Ohana/src/relphot/src/MosaicOps.c (modified) (19 diffs)
-
Ohana/src/relphot/src/StarOps.c (modified) (31 diffs)
-
Ohana/src/relphot/src/args.c (modified) (1 diff)
-
Ohana/src/relphot/src/bcatalog.c (modified) (10 diffs)
-
Ohana/src/relphot/src/global_stats.c (modified) (1 diff)
-
Ohana/src/relphot/src/initialize.c (modified) (3 diffs)
-
Ohana/src/relphot/src/load_images.c (modified) (1 diff)
-
Ohana/src/relphot/src/plot_scatter.c (modified) (1 diff)
-
Ohana/src/relphot/src/reload_catalogs.c (modified) (4 diffs)
-
Ohana/src/relphot/src/relphot.c (modified) (10 diffs)
-
Ohana/src/relphot/src/relphot_objects.c (modified) (3 diffs)
-
Ohana/src/relphot/src/select_images.c (modified) (7 diffs)
-
Ohana/src/relphot/src/setExclusions.c (modified) (3 diffs)
-
Ohana/src/relphot/src/setMrelFinal.c (modified) (6 diffs)
-
Ohana/src/skycalc/Makefile (modified) (1 diff)
-
Ohana/src/tools/Makefile (modified) (1 diff)
-
dbconfig/changes.txt (modified) (1 diff, 1 prop)
-
ippScripts/scripts/camera_exp.pl (modified) (1 diff)
-
ippScripts/scripts/dist_advancerun.pl (modified) (1 diff)
-
ippScripts/scripts/dist_bundle.pl (modified) (6 diffs)
-
ippScripts/scripts/ipp_apply_burntool_single.pl (modified) (1 prop)
-
ippScripts/scripts/magic_destreak.pl (modified) (1 diff)
-
ippScripts/scripts/receive_file.pl (modified) (2 diffs)
-
ippScripts/scripts/register_imfile.pl (modified) (5 diffs)
-
ippScripts/scripts/warp_skycell.pl (modified) (4 diffs)
-
ippTasks/Makefile.am (modified) (1 diff)
-
ippTasks/register.pro (modified) (2 diffs)
-
ippToPsps/jython/batch.py (modified) (17 diffs)
-
ippToPsps/jython/detectionbatch.py (modified) (22 diffs)
-
ippToPsps/jython/gpc1db.py (modified) (12 diffs)
-
ippToPsps/jython/ipptopspsdb.py (modified) (8 diffs)
-
ippToPsps/jython/mysql.py (modified) (14 diffs)
-
ippToPsps/jython/scratchdb.py (modified) (11 diffs)
-
ippToPsps/jython/stackbatch.py (modified) (37 diffs)
-
ippTools/share/addtool_find_sky_id.sql (modified) (2 diffs)
-
ippTools/share/addtool_find_sky_id_dvo.sql (modified) (1 diff)
-
ippTools/share/camtool_find_pendingimfile.sql (modified) (1 prop)
-
ippTools/share/pxadmin_create_tables.sql (modified) (1 prop)
-
ippTools/share/regtool_pendingimfile.sql (modified) (1 diff)
-
ippTools/src (modified) (1 prop)
-
ippTools/src/addtool.c (modified) (4 diffs)
-
ippTools/src/addtoolConfig.c (modified) (1 diff)
-
ippTools/src/disttool.c (modified) (1 diff)
-
ippTools/src/magictool.c (modified) (2 diffs, 1 prop)
-
ippTools/src/magictoolConfig.c (modified) (1 diff)
-
ippTools/src/pstamptool.c (modified) (2 diffs)
-
ippTools/src/pubtoolConfig.c (modified) (1 diff)
-
ippTools/src/pzgetimfiles.c (modified) (2 diffs)
-
ippTools/src/pztool.c (modified) (3 diffs)
-
ippTools/src/stacktool.c (modified) (3 diffs)
-
ippTools/src/stacktoolConfig.c (modified) (1 diff)
-
ippconfig (modified) (1 prop)
-
ippconfig/gpc1/camera.config (modified) (1 diff)
-
ippconfig/gpc1/ppStack.config (modified) (1 diff)
-
ippconfig/gpc1/psastro.config (modified) (8 diffs)
-
ippconfig/gpc1/psphot.config (modified) (1 diff)
-
ippconfig/isp/psastro.config (modified) (4 diffs)
-
ippconfig/isp/psphot.config (modified) (1 diff)
-
ippconfig/recipes/nightly_science.config (modified) (1 diff)
-
ippconfig/recipes/psastro.config (modified) (1 diff)
-
ippconfig/recipes/psphot.config (modified) (2 diffs)
-
ippconfig/recipes/reductionClasses.mdc (modified) (1 diff, 1 prop)
-
ppImage/src (modified) (1 prop)
-
ppSim/src/ppSimInsertGalaxies.c (modified) (2 diffs)
-
ppSim/src/ppSimInsertStars.c (modified) (1 diff)
-
ppStack/src/ppStackPrepare.c (modified) (5 diffs)
-
ppSub/src/ppSubFlagNeighbors.c (modified) (2 diffs)
-
ppSub/src/ppSubReadoutPhotometry.c (modified) (1 diff)
-
psLib/src/fits/psFitsImage.c (modified) (1 diff)
-
psLib/src/imageops/psImageGeomManip.c (modified) (1 diff)
-
psLib/src/imageops/psImageInterpolate.c (modified) (11 diffs)
-
psLib/src/imageops/psImageMaskOps.c (modified) (2 diffs)
-
psModules/src/camera/pmFPAMaskWeight.c (modified) (1 diff)
-
psModules/src/imcombine/pmPSFEnvelope.c (modified) (1 diff)
-
psModules/src/imcombine/pmSubtractionStamps.c (modified) (5 diffs)
-
psModules/src/objects/Makefile.am (modified) (1 diff)
-
psModules/src/objects/models/pmModel_DEV.c (modified) (1 diff)
-
psModules/src/objects/models/pmModel_EXP.c (modified) (1 diff)
-
psModules/src/objects/models/pmModel_PGAUSS.c (modified) (1 diff)
-
psModules/src/objects/models/pmModel_PS1_V1.c (modified) (3 diffs)
-
psModules/src/objects/models/pmModel_QGAUSS.c (modified) (1 diff)
-
psModules/src/objects/models/pmModel_RGAUSS.c (modified) (1 diff)
-
psModules/src/objects/models/pmModel_SERSIC.c (modified) (1 diff)
-
psModules/src/objects/pmGrowthCurve.c (modified) (3 diffs)
-
psModules/src/objects/pmGrowthCurve.h (modified) (1 diff)
-
psModules/src/objects/pmGrowthCurveGenerate.c (modified) (3 diffs)
-
psModules/src/objects/pmGrowthCurveGenerate.h (copied) (copied from trunk/psModules/src/objects/pmGrowthCurveGenerate.h )
-
psModules/src/objects/pmPCMdata.c (modified) (2 diffs)
-
psModules/src/objects/pmPSF.c (modified) (3 diffs)
-
psModules/src/objects/pmPSF.h (modified) (5 diffs)
-
psModules/src/objects/pmPSF_IO.c (modified) (11 diffs)
-
psModules/src/objects/pmPSFtryFitPSF.c (modified) (2 diffs)
-
psModules/src/objects/pmPeaks.c (modified) (3 diffs)
-
psModules/src/objects/pmPeaks.h (modified) (2 diffs)
-
psModules/src/objects/pmSource.c (modified) (9 diffs)
-
psModules/src/objects/pmSource.h (modified) (4 diffs)
-
psModules/src/objects/pmSourceIO_CMF_PS1_DV1.c (modified) (2 diffs)
-
psModules/src/objects/pmSourceIO_CMF_PS1_DV2.c (modified) (2 diffs)
-
psModules/src/objects/pmSourceIO_CMF_PS1_SV1.c (modified) (3 diffs)
-
psModules/src/objects/pmSourceIO_CMF_PS1_V1.c (modified) (2 diffs)
-
psModules/src/objects/pmSourceIO_CMF_PS1_V2.c (modified) (2 diffs)
-
psModules/src/objects/pmSourceIO_CMF_PS1_V3.c (modified) (4 diffs)
-
psModules/src/objects/pmSourceIO_CMP.c (modified) (3 diffs)
-
psModules/src/objects/pmSourceIO_PS1_CAL_0.c (modified) (5 diffs)
-
psModules/src/objects/pmSourceIO_PS1_DEV_0.c (modified) (2 diffs)
-
psModules/src/objects/pmSourceIO_PS1_DEV_1.c (modified) (5 diffs)
-
psModules/src/objects/pmSourceIO_RAW.c (modified) (2 diffs)
-
psModules/src/objects/pmSourceIO_SMPDATA.c (modified) (2 diffs)
-
psModules/src/objects/pmSourceIO_SX.c (modified) (1 diff)
-
psModules/src/objects/pmSourceMasks.h (modified) (2 diffs)
-
psModules/src/objects/pmSourceMatch.c (modified) (2 diffs)
-
psModules/src/objects/pmSourceMoments.c (modified) (19 diffs)
-
psModules/src/objects/pmSourceOutputs.c (modified) (2 diffs)
-
psModules/src/objects/pmSourcePhotometry.c (modified) (14 diffs)
-
psModules/src/objects/pmSourcePhotometry.h (modified) (1 diff)
-
psModules/src/objects/pmSourceUtils.h (modified) (1 diff)
-
psModules/src/psmodules.h (modified) (1 diff)
-
psModules/test/objects/tap_pmSource.c (modified) (1 diff)
-
psModules/test/objects/tap_pmSourceIO_PS1_DEV_0.c (modified) (2 diffs)
-
psModules/test/objects/tap_pmSourceIO_PS1_DEV_1.c (modified) (3 diffs)
-
psModules/test/objects/tap_pmSourceIO_SMPDATA.c (modified) (2 diffs)
-
psModules/test/objects/tap_pmSourcePhotometry.c (modified) (1 diff)
-
psastro/src/psastroConvert.c (modified) (2 diffs)
-
psconfig/psbuild (modified) (1 diff)
-
psconfig/tagsets/ipp-3.0.libs (modified) (1 diff)
-
psphot (modified) (1 prop)
-
psphot/src/Makefile.am (modified) (1 diff)
-
psphot/src/psphot.h (modified) (2 diffs)
-
psphot/src/psphotApResid.c (modified) (6 diffs)
-
psphot/src/psphotBlendFit.c (modified) (3 diffs)
-
psphot/src/psphotChoosePSF.c (modified) (1 diff)
-
psphot/src/psphotEfficiency.c (modified) (2 diffs)
-
psphot/src/psphotExtendedSourceFits.c (modified) (2 diffs)
-
psphot/src/psphotFitSourcesLinear.c (modified) (3 diffs)
-
psphot/src/psphotFitSourcesLinearStack.c (modified) (1 diff)
-
psphot/src/psphotGuessModels.c (modified) (4 diffs)
-
psphot/src/psphotKronMasked.c (copied) (copied from trunk/psphot/src/psphotKronMasked.c )
-
psphot/src/psphotLoadSRCTEXT.c (modified) (2 diffs)
-
psphot/src/psphotMagnitudes.c (modified) (4 diffs)
-
psphot/src/psphotMakeGrowthCurve.c (modified) (2 diffs)
-
psphot/src/psphotMergeSources.c (modified) (1 diff)
-
psphot/src/psphotModelTest.c (modified) (1 diff)
-
psphot/src/psphotOutput.c (modified) (2 diffs)
-
psphot/src/psphotPetrosianStats.c (modified) (3 diffs)
-
psphot/src/psphotRadialApertures.c (modified) (2 diffs)
-
psphot/src/psphotRadiusChecks.c (modified) (2 diffs)
-
psphot/src/psphotReadout.c (modified) (3 diffs)
-
psphot/src/psphotReplaceUnfit.c (modified) (1 diff)
-
psphot/src/psphotRoughClass.c (modified) (1 diff)
-
psphot/src/psphotSetThreads.c (modified) (1 diff)
-
psphot/src/psphotSourceFits.c (modified) (7 diffs)
-
psphot/src/psphotSourceSize.c (modified) (2 diffs)
-
psphot/src/psphotSourceStats.c (modified) (16 diffs)
-
psphot/src/psphotVisual.c (modified) (2 diffs)
-
psphot/test/tap_psphot_stackphot.pro (modified) (1 diff)
-
pstamp/scripts/detectability_respond.pl (modified) (2 diffs)
-
pstamp/scripts/pstamp_job_run.pl (modified) (1 diff)
-
pstamp/scripts/pstampparse.pl (modified) (1 diff)
-
pswarp/src/pswarpTransformSources.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20110406
- Property svn:mergeinfo changed
-
branches/czw_branch/20110406/Ohana/Makefile.in
r28190 r31606 76 76 mkdir -p $(DESTLIB) 77 77 mkdir -p $(DESTBIN) 78 for i in $(LIBS); do make$$i.install || exit 1; done78 for i in $(LIBS); do $(MAKE) $$i.install || exit 1; done 79 79 chmod +x ohana-config 80 80 cp -f ohana-config $(DESTBIN)/ 81 81 82 82 bins: 83 for i in $(PROGRAM); do make$$i; done83 for i in $(PROGRAM); do $(MAKE) $$i; done 84 84 85 85 all: 86 makelibs || exit 187 for i in $(PROGRAM); do make$$i || exit 1; done86 $(MAKE) libs || exit 1 87 for i in $(PROGRAM); do $(MAKE) $$i || exit 1; done 88 88 89 89 extras: 90 for i in $(EXTRAS); do make$$i || exit 1; done90 for i in $(EXTRAS); do $(MAKE) $$i || exit 1; done 91 91 92 92 pantasks: 93 makelibs || exit 194 cd src/opihi; makepclient.install && exit 195 cd src/opihi; makepcontrol.install && exit 196 cd src/opihi; makepantasks.install && exit 193 $(MAKE) libs || exit 1 94 cd src/opihi; $(MAKE) pclient.install && exit 1 95 cd src/opihi; $(MAKE) pcontrol.install && exit 1 96 cd src/opihi; $(MAKE) pantasks.install && exit 1 97 97 98 98 mana: 99 makelibs100 makekapa2.install101 cd src/opihi; makemana.install && exit 199 $(MAKE) libs 100 $(MAKE) kapa2.install 101 cd src/opihi; $(MAKE) mana.install && exit 1 102 102 103 103 dvoshell: 104 makelibs105 makekapa2.install106 cd src/opihi; makedvo.install && exit 1104 $(MAKE) libs 105 $(MAKE) kapa2.install 106 cd src/opihi; $(MAKE) dvo.install && exit 1 107 107 108 108 clean: 109 109 @if [ "$(ARCH)" = "" ]; then echo ""; echo " *** please define ARCH ***"; echo; exit 1; fi 110 for i in $(LIBS); do make$$i.clean || exit 1; done111 for i in $(PROGRAM); do make$$i.clean || exit 1; done112 for i in $(EXTRAS); do make$$i.clean || exit 1; done110 for i in $(LIBS); do $(MAKE) $$i.clean || exit 1; done 111 for i in $(PROGRAM); do $(MAKE) $$i.clean || exit 1; done 112 for i in $(EXTRAS); do $(MAKE) $$i.clean || exit 1; done 113 113 @rm -f `find . -name .mana` 114 114 @rm -f `find . -name .dvo` … … 117 117 dist: 118 118 @if [ "$(ARCH)" = "" ]; then echo ""; echo " *** please define ARCH ***"; echo; exit 1; fi 119 for i in $(LIBS); do make$$i.dist || exit 1; done120 for i in $(PROGRAM); do make$$i.dist || exit 1; done119 for i in $(LIBS); do $(MAKE) $$i.dist || exit 1; done 120 for i in $(PROGRAM); do $(MAKE) $$i.dist || exit 1; done 121 121 @echo -n -e "\0033]0; *** Ohana: done $@ *** \0007" \ 122 122 123 123 install: 124 124 @if [ "$(ARCH)" = "" ]; then echo ""; echo " *** please define ARCH ***"; echo; exit 1; fi 125 for i in $(LIBS); do make$$i.install || exit 1; done126 for i in $(PROGRAM); do make$$i.install || exit 1; done125 for i in $(LIBS); do $(MAKE) $$i.install || exit 1; done 126 for i in $(PROGRAM); do $(MAKE) $$i.install || exit 1; done 127 127 @echo -n -e "\0033]0; *** Ohana: done $@ *** \0007" \ 128 128 129 129 install.extras: 130 for i in $(EXTRAS); do make$$i.install || exit 1; done130 for i in $(EXTRAS); do $(MAKE) $$i.install || exit 1; done 131 131 @echo -n -e "\0033]0; *** Ohana: done $@ *** \0007" \ 132 132 … … 135 135 @if [ -d "src/$@" ]; then \ 136 136 echo -n -e "\0033]0; *** Ohana: $@ *** \0007"; \ 137 (cd src/$@ && make); \137 (cd src/$@ && $(MAKE)); \ 138 138 fi 139 139 @echo -n -e "\0033]0; *** Ohana: done $@ *** \0007" \ … … 142 142 @echo -n -e "\0033]0; *** Ohana: $@ *** \0007" \ 143 143 mkdir -p bin/$(ARCH) 144 if [ -d "src/$*" ]; then (cd src/$* && makeinstall); fi144 if [ -d "src/$*" ]; then (cd src/$* && $(MAKE) install); fi 145 145 146 146 %.clean: 147 if [ -d "src/$*" ]; then (cd src/$* && makeclean); fi147 if [ -d "src/$*" ]; then (cd src/$* && $(MAKE) clean); fi 148 148 149 149 %.dist: 150 (cd src/$* && makedist)150 (cd src/$* && $(MAKE) dist) -
branches/czw_branch/20110406/Ohana/src/addstar/Makefile
r29938 r31606 267 267 268 268 %.install: 269 make$(DESTBIN)/$*269 $(MAKE) $(DESTBIN)/$* 270 270 271 271 install: 272 for i in $(INSTALL); do make$$i.install || exit; done272 for i in $(INSTALL); do $(MAKE) $$i.install || exit; done -
branches/czw_branch/20110406/Ohana/src/dvomerge/Makefile
r29938 r31606 108 108 109 109 %.install: 110 make$(DESTBIN)/$*110 $(MAKE) $(DESTBIN)/$* 111 111 112 112 install: 113 for i in $(INSTALL); do make$$i.install || exit; done113 for i in $(INSTALL); do $(MAKE) $$i.install || exit; done -
branches/czw_branch/20110406/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c
r29938 r31606 202 202 if (newID == 0) { 203 203 fprintf (stderr, "cannot find image ID "OFF_T_FMT"\n", oldID); 204 exit (2);204 // exit (2); 205 205 } 206 206 catalog[0].measure[i].imageID = newID; -
branches/czw_branch/20110406/Ohana/src/dvomerge/src/dvoverify.c
r31160 r31606 148 148 int VerifyTableFile (char *filename) { 149 149 150 int status ;150 int status, Next; 151 151 off_t Nbytes; 152 152 Header header; … … 205 205 // scan all extentions 206 206 Nbytes = 0; 207 Next = -1; 207 208 if (DEBUG) fprintf (stderr, "sizes: ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nbytes, fileStats.st_size); 208 209 while (Nbytes < fileStats.st_size) { … … 210 211 // Check on the PHU 211 212 if (!gfits_fread_header (file, &header)) { 212 fprintf (stderr, "unable to read PHU header for %s\n", filename); 213 if (Next == -1) { 214 fprintf (stderr, "unable to read PHU header for %s\n", filename); 215 } else { 216 fprintf (stderr, "unable to read header for %s, extension %d (or file has excess bytes)\n", filename, Next); 217 } 213 218 fclose(file); 214 219 return (FALSE); … … 243 248 } 244 249 } 250 Next ++; 245 251 } 246 252 if (DEBUG) fprintf (stderr, "file is good: %s\n", filename); -
branches/czw_branch/20110406/Ohana/src/dvosplit/Makefile
r15743 r31606 43 43 44 44 %.install: 45 make$(DESTBIN)/$*45 $(MAKE) $(DESTBIN)/$* 46 46 47 47 install: 48 for i in $(INSTALL); do make$$i.install || exit; done48 for i in $(INSTALL); do $(MAKE) $$i.install || exit; done -
branches/czw_branch/20110406/Ohana/src/imregister/Makefile
r16040 r31606 185 185 %.rebuild : 186 186 rm -f $(BIN)/$*.$(ARCH) 187 make$(DESTBIN)/$*187 $(MAKE) $(DESTBIN)/$* 188 188 189 189 %.install: 190 make$(DESTBIN)/$*190 $(MAKE) $(DESTBIN)/$* 191 191 192 192 install: 193 for i in $(INSTALL); do make$$i.install || exit; done193 for i in $(INSTALL); do $(MAKE) $$i.install || exit; done -
branches/czw_branch/20110406/Ohana/src/kapa2/src/DrawObjects.c
r29539 r31606 1 1 # include "Ximage.h" 2 2 3 # define DrawLine(X1,Y1,X2,Y2) (XDrawLine (graphic->display, graphic->window, graphic->gc, (int)(X1 +0.5), (int)(Y1+0.5), (int)(X2+0.5), (int)(Y2+0.5)))4 # define DrawRectangle(X1,Y1,X2,Y2) (XDrawRectangle (graphic->display, graphic->window, graphic->gc, (int)(X1 +0.5), (int)(Y1+0.5), (int)(X2+0.5), (int)(Y2+0.5)))5 # define FillRectangle(X1,Y1,X2,Y2) (XFillRectangle (graphic->display, graphic->window, graphic->gc, (int)(X1 +0.5), (int)(Y1+0.5), (int)(X2+0.5), (int)(Y2+0.5)))6 # define DrawCircle(X,Y,R) (XDrawArc (graphic->display, graphic->window, graphic->gc, (int)(X-R +0.5), (int)(Y-R+0.5), abs(2*R+0.5), abs(2*R+0.5), 0, 23040))3 # define DrawLine(X1,Y1,X2,Y2) (XDrawLine (graphic->display, graphic->window, graphic->gc, (int)(X1), (int)(Y1), (int)(X2), (int)(Y2))) 4 # define DrawRectangle(X1,Y1,X2,Y2) (XDrawRectangle (graphic->display, graphic->window, graphic->gc, (int)(X1), (int)(Y1), (int)(X2), (int)(Y2))) 5 # define FillRectangle(X1,Y1,X2,Y2) (XFillRectangle (graphic->display, graphic->window, graphic->gc, (int)(X1), (int)(Y1), (int)(X2), (int)(Y2))) 6 # define DrawCircle(X,Y,R) (XDrawArc (graphic->display, graphic->window, graphic->gc, (int)(X-R), (int)(Y-R), abs(2*R), abs(2*R), 0, 23040)) 7 7 8 8 # define CONNECT 0 9 9 # define HISTOGRAM 1 10 10 # define POINTS 2 11 12 # define XCENTER 0.0 13 # define YCENTER 0.0 14 # define CAPSTYLE CapButt 15 # define JOINSTYLE JoinMiter 11 16 12 17 static Graphic *graphic; … … 34 39 // this function calls all of the supporting Draw... functions below 35 40 graphic = GetGraphic(); 36 37 lweight = MAX (0, MIN (10, object[0].lweight)); 41 42 lweight = MAX (1, MIN (10, object[0].lweight)); 43 44 /** some notes on drawing lines in X: 45 46 "In general, drawing a thin line will be faster than drawing a wide line of width 47 one. However, because of their different drawing algorithms, thin lines may not mix 48 well aesthetically with wide lines. If it is desirable to obtain precise and uniform 49 results across all displays, a client should always use a line-width of one rather 50 than a line-width of zero." -- http://www.hpc.unimelb.edu.au/nec/g1ae02e/chap7.html 51 52 */ 38 53 39 54 /* set line type */ 40 55 switch (object[0].ltype) { 41 56 case 0: 42 XSetLineAttributes (graphic->display, graphic->gc, lweight, LineSolid, C apNotLast, JoinMiter);57 XSetLineAttributes (graphic->display, graphic->gc, lweight, LineSolid, CAPSTYLE, JOINSTYLE); 43 58 break; 44 59 case 1: 45 60 XSetDashes (graphic->display, graphic->gc, 100, dash, 2); 46 XSetLineAttributes (graphic->display, graphic->gc, lweight, LineOnOffDash, C apNotLast, JoinMiter);61 XSetLineAttributes (graphic->display, graphic->gc, lweight, LineOnOffDash, CAPSTYLE, JOINSTYLE); 47 62 break; 48 63 case 2: 49 64 XSetDashes (graphic->display, graphic->gc, 10, dot, 2); 50 XSetLineAttributes (graphic->display, graphic->gc, lweight, LineOnOffDash, C apNotLast, JoinMiter);65 XSetLineAttributes (graphic->display, graphic->gc, lweight, LineOnOffDash, CAPSTYLE, JOINSTYLE); 51 66 break; 52 67 default: 53 XSetLineAttributes (graphic->display, graphic->gc, lweight, LineSolid, C apNotLast, JoinMiter);68 XSetLineAttributes (graphic->display, graphic->gc, lweight, LineSolid, CAPSTYLE, JOINSTYLE); 54 69 break; 55 70 } … … 76 91 } 77 92 78 XSetLineAttributes (graphic->display, graphic->gc, 0, LineSolid, C apNotLast, JoinMiter);93 XSetLineAttributes (graphic->display, graphic->gc, 0, LineSolid, CAPSTYLE, JOINSTYLE); 79 94 XSetForeground (graphic->display, graphic->gc, graphic->fore); 80 95 return (TRUE); … … 111 126 for (i = 0; (i < object[0].Npts) && !(finite(x[i]) && finite(y[i])); i++); 112 127 if (i >= object[0].Npts) return; 113 sx0 = x[i]*mxi + y[i]*mxj + bx ;114 sy0 = x[i]*myi + y[i]*myj + by ;128 sx0 = x[i]*mxi + y[i]*mxj + bx + XCENTER; 129 sy0 = x[i]*myi + y[i]*myj + by + YCENTER; 115 130 116 131 for (i++; i < object[0].Npts; i++) { 117 132 if (!(finite(x[i]) && finite(y[i]))) continue; 118 sx1 = x[i]*mxi + y[i]*mxj + bx ;119 sy1 = x[i]*myi + y[i]*myj + by ;133 sx1 = x[i]*mxi + y[i]*mxj + bx + XCENTER; 134 sy1 = x[i]*myi + y[i]*myj + by + YCENTER; 120 135 121 136 ClipLine (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1); … … 213 228 214 229 /* first valid data point */ 215 sx0 = x[i]*mxi + y[i]*mxj + bx ;216 sy0 = x[i]*myi + y[i]*myj + by ;230 sx0 = x[i]*mxi + y[i]*mxj + bx + XCENTER; 231 sy0 = x[i]*myi + y[i]*myj + by + YCENTER; 217 232 sx0 = MIN (MAX (sx0, X0), X1); 218 233 sy0 = MAX (MIN (sy0, Y0), Y1); … … 223 238 224 239 /* second valid data point */ 225 sx1 = x[i]*mxi + y[i]*mxj + bx ;226 sy1 = x[i]*myi + y[i]*myj + by ;240 sx1 = x[i]*mxi + y[i]*mxj + bx + XCENTER; 241 sy1 = x[i]*myi + y[i]*myj + by + YCENTER; 227 242 sx1 = MIN (MAX (sx1, X0), X1); 228 243 sy1 = MAX (MIN (sy1, Y0), Y1); … … 246 261 for (i++; i < object[0].Npts; i++) { 247 262 if (!(finite(x[i]) && finite(y[i]))) continue; 248 sx1 = x[i]*mxi + y[i]*mxj + bx ;249 sy1 = x[i]*myi + y[i]*myj + by ;263 sx1 = x[i]*mxi + y[i]*mxj + bx + XCENTER; 264 sy1 = x[i]*myi + y[i]*myj + by + YCENTER; 250 265 sx1 = MIN (MAX (sx1, X0), X1); 251 266 sy1 = MAX (MIN (sy1, Y0), Y1); … … 298 313 299 314 /* first valid data point */ 300 sx0 = x[i]*mxi + y[i]*mxj + bx ;301 sy0 = x[i]*myi + y[i]*myj + by ;315 sx0 = x[i]*mxi + y[i]*mxj + bx + XCENTER; 316 sy0 = x[i]*myi + y[i]*myj + by + YCENTER; 302 317 sx0 = MIN (MAX (sx0, X0), X1); 303 318 sy0 = MAX (MIN (sy0, Y0), Y1); … … 308 323 309 324 /* second valid data point */ 310 sx1 = x[i]*mxi + y[i]*mxj + bx ;311 sy1 = x[i]*myi + y[i]*myj + by ;325 sx1 = x[i]*mxi + y[i]*mxj + bx + XCENTER; 326 sy1 = x[i]*myi + y[i]*myj + by + YCENTER; 312 327 sx1 = MIN (MAX (sx1, X0), X1); 313 328 sy1 = MAX (MIN (sy1, Y0), Y1); … … 330 345 for (i++; i < object[0].Npts; i++) { 331 346 if (!(finite(x[i]) && finite(y[i]))) continue; 332 sx1 = x[i]*mxi + y[i]*mxj + bx ;333 sy1 = x[i]*myi + y[i]*myj + by ;347 sx1 = x[i]*mxi + y[i]*mxj + bx + XCENTER; 348 sy1 = x[i]*myi + y[i]*myj + by + YCENTER; 334 349 sx1 = MIN (MAX (sx1, X0), X1); 335 350 sy1 = MAX (MIN (sy1, Y0), Y1); … … 356 371 float *x, *y, *z; 357 372 double mxi, mxj, myi, myj, bxi, bxj, byi, byj, bx, by; 358 double sx, sy, d, sx1, sy1, sx2, sy2;373 int sx, sy, sx1, sy1, sx2, sy2, d, D; 359 374 360 375 mxi = graph[0].axis[0].dfx / (object[0].x1 - object[0].x0); … … 375 390 d = 0.5 * (graphic->dx + graphic->dy) * 0.01; 376 391 x = object[0].x; y = object[0].y; z = object[0].z; 392 377 393 if (object[0].ptype == 0) { /* filled box */ 378 394 for (i = 0; i < object[0].Npts; i++) { 379 395 if (!(finite(x[i]) && finite(y[i]))) continue; 380 sx = x[i]*mxi + y[i]*mxj + bx; 381 sy = x[i]*myi + y[i]*myj + by; 382 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 383 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 384 { 385 FillRectangle (sx - d*z[i], sy - d*z[i], 2*d*z[i], 2*d*z[i]); 396 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 397 sy = x[i]*myi + y[i]*myj + by + YCENTER; 398 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 399 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 400 { 401 D = d*z[i]; 402 FillRectangle (sx - D, sy - D, 2*D + 1, 2*D + 1); 386 403 } 387 404 } … … 390 407 for (i = 0; i < object[0].Npts; i++) { 391 408 if (!(finite(x[i]) && finite(y[i]))) continue; 392 sx = x[i]*mxi + y[i]*mxj + bx; 393 sy = x[i]*myi + y[i]*myj + by; 394 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 395 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 396 { 397 DrawRectangle (sx - d*z[i], sy - d*z[i], 2*d*z[i], 2*d*z[i]); 409 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 410 sy = x[i]*myi + y[i]*myj + by + YCENTER; 411 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 412 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 413 { 414 D = d*z[i]; 415 DrawRectangle (sx - D, sy - D, 2*D, 2*D); 398 416 } 399 417 } … … 402 420 for (i = 0; i < object[0].Npts; i++) { 403 421 if (!(finite(x[i]) && finite(y[i]))) continue; 404 sx = x[i]*mxi + y[i]*mxj + bx; 405 sy = x[i]*myi + y[i]*myj + by; 406 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 407 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 408 { 409 DrawLine (sx - d*z[i], sy, sx + d*z[i] + 1, sy); 410 DrawLine (sx, sy - d*z[i], sx, sy + d*z[i] + 1); 422 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 423 sy = x[i]*myi + y[i]*myj + by + YCENTER; 424 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 425 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 426 { 427 D = d*z[i]; 428 DrawLine (sx - D, sy, sx + D + 1, sy); 429 DrawLine (sx, sy - D, sx, sy + D + 1); 411 430 } 412 431 } … … 415 434 for (i = 0; i < object[0].Npts; i++) { 416 435 if (!(finite(x[i]) && finite(y[i]))) continue; 417 sx = x[i]*mxi + y[i]*mxj + bx; 418 sy = x[i]*myi + y[i]*myj + by; 419 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 420 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 421 { 422 DrawLine (sx + d*z[i] + 1, sy - d*z[i] - 1, sx - d*z[i], sy + d*z[i]); 423 DrawLine (sx - d*z[i], sy - d*z[i], sx + d*z[i] + 1, sy + d*z[i] + 1); 436 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 437 sy = x[i]*myi + y[i]*myj + by + YCENTER; 438 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 439 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 440 { 441 D = d*z[i]; 442 DrawLine (sx - D, sy + D, sx + D + 1, sy - D - 1); 443 DrawLine (sx - D, sy - D, sx + D + 1, sy + D + 1); 424 444 } 425 445 } … … 429 449 for (i = 0; i < object[0].Npts; i++) { 430 450 if (!(finite(x[i]) && finite(y[i]))) continue; 431 sx = x[i]*mxi + y[i]*mxj + bx; 432 sy = x[i]*myi + y[i]*myj + by; 433 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 434 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 435 { 436 points[0].x = sx - d*z[i]; points[0].y = sy + 0.58*d*z[i]; 437 points[1].x = sx + d*z[i]; points[1].y = sy + 0.58*d*z[i]; 438 points[2].x = sx; points[2].y = sy - 1.15*d*z[i]; 439 points[3].x = sx - d*z[i]; points[3].y = sy + 0.58*d*z[i]; 451 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 452 sy = x[i]*myi + y[i]*myj + by + YCENTER; 453 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 454 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 455 { 456 D = d*z[i]; 457 points[0].x = sx - D; points[0].y = sy + 0.58*D; 458 points[1].x = sx + D; points[1].y = sy + 0.58*D; 459 points[2].x = sx; points[2].y = sy - 1.15*D; 460 points[3].x = sx - D; points[3].y = sy + 0.58*D; 440 461 XFillPolygon (graphic->display, graphic->window, graphic->gc, points, 4, Convex, CoordModeOrigin); 441 462 } … … 445 466 for (i = 0; i < object[0].Npts; i++) { 446 467 if (!(finite(x[i]) && finite(y[i]))) continue; 447 sx = x[i]*mxi + y[i]*mxj + bx; 448 sy = x[i]*myi + y[i]*myj + by; 449 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 450 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 451 { 452 DrawLine (sx - d*z[i], sy + 0.58*d*z[i], sx + d*z[i], sy + 0.58*d*z[i]); 453 DrawLine (sx + d*z[i], sy + 0.58*d*z[i], sx, sy - 1.15*d*z[i]); 454 DrawLine (sx, sy - 1.15*d*z[i], sx - d*z[i], sy + 0.58*d*z[i]); 468 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 469 sy = x[i]*myi + y[i]*myj + by + YCENTER; 470 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 471 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 472 { 473 D = d*z[i]; 474 DrawLine (sx - D, sy + 0.58*D, sx + D, sy + 0.58*D); 475 DrawLine (sx + D, sy + 0.58*D, sx, sy - 1.15*D); 476 DrawLine (sx, sy - 1.15*D, sx - D, sy + 0.58*D); 455 477 } 456 478 } … … 459 481 for (i = 0; i < object[0].Npts; i++) { 460 482 if (!(finite(x[i]) && finite(y[i]))) continue; 461 sx = x[i]*mxi + y[i]*mxj + bx; 462 sy = x[i]*myi + y[i]*myj + by; 463 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 464 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 465 { 466 DrawLine (sx, sy, sx - d*z[i], sy + 0.58*d*z[i]); 467 DrawLine (sx, sy, sx + d*z[i], sy + 0.58*d*z[i]); 468 DrawLine (sx, sy, sx, sy - 1.15*d*z[i]); 483 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 484 sy = x[i]*myi + y[i]*myj + by + YCENTER; 485 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 486 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 487 { 488 D = d*z[i]; 489 DrawLine (sx, sy, sx - D, sy - 0.58*D); 490 DrawLine (sx, sy, sx + D, sy - 0.58*D); 491 DrawLine (sx, sy, sx, sy + 1.15*D); 469 492 } 470 493 } … … 473 496 for (i = 0; i < object[0].Npts; i++) { 474 497 if (!(finite(x[i]) && finite(y[i]))) continue; 475 sx = x[i]*mxi + y[i]*mxj + bx; 476 sy = x[i]*myi + y[i]*myj + by; 477 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 478 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 479 { 480 DrawCircle (sx, sy, d*z[i]); 498 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 499 sy = x[i]*myi + y[i]*myj + by + YCENTER; 500 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 501 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 502 { 503 D = d*z[i]; 504 DrawCircle (sx, sy, D); 481 505 } 482 506 } … … 485 509 for (i = 0; i < object[0].Npts; i++) { 486 510 if (!(finite(x[i]) && finite(y[i]))) continue; 487 sx = x[i]*mxi + y[i]*mxj + bx; 488 sy = x[i]*myi + y[i]*myj + by; 489 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 490 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 491 { 492 DrawLine (sx + 0.00*d*z[i], sy - 1.00*d*z[i], sx + 0.95*d*z[i], sy - 0.31*d*z[i]); 493 DrawLine (sx + 0.95*d*z[i], sy - 0.31*d*z[i], sx + 0.58*d*z[i], sy + 0.81*d*z[i]); 494 DrawLine (sx + 0.58*d*z[i], sy + 0.81*d*z[i], sx - 0.58*d*z[i], sy + 0.81*d*z[i]); 495 DrawLine (sx - 0.58*d*z[i], sy + 0.81*d*z[i], sx - 0.95*d*z[i], sy - 0.31*d*z[i]); 496 DrawLine (sx - 0.95*d*z[i], sy - 0.31*d*z[i], sx + 0.00*d*z[i], sy - 1.00*d*z[i]); 511 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 512 sy = x[i]*myi + y[i]*myj + by + YCENTER; 513 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 514 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 515 { 516 D = d*z[i]; 517 DrawLine (sx + 0.00*D, sy - 1.00*D, sx + 0.95*D, sy - 0.31*D); 518 DrawLine (sx + 0.95*D, sy - 0.31*D, sx + 0.58*D, sy + 0.81*D); 519 DrawLine (sx + 0.58*D, sy + 0.81*D, sx - 0.58*D, sy + 0.81*D); 520 DrawLine (sx - 0.58*D, sy + 0.81*D, sx - 0.95*D, sy - 0.31*D); 521 DrawLine (sx - 0.95*D, sy - 0.31*D, sx + 0.00*D, sy - 1.00*D); 497 522 } 498 523 } … … 501 526 for (i = 0; i < object[0].Npts; i++) { 502 527 if (!(finite(x[i]) && finite(y[i]))) continue; 503 sx = x[i]*mxi + y[i]*mxj + bx; 504 sy = x[i]*myi + y[i]*myj + by; 505 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 506 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 507 { 508 DrawLine (sx - d*z[i], sy, sx - 0.50*d*z[i], sy + 0.87*d*z[i]); 509 DrawLine (sx - 0.50*d*z[i], sy + 0.87*d*z[i], sx + 0.50*d*z[i], sy + 0.87*d*z[i]); 510 DrawLine (sx + 0.50*d*z[i], sy + 0.87*d*z[i], sx + d*z[i], sy); 511 512 DrawLine (sx + d*z[i], sy, sx + 0.50*d*z[i], sy - 0.87*d*z[i]); 513 DrawLine (sx + 0.50*d*z[i], sy - 0.87*d*z[i], sx - 0.50*d*z[i], sy - 0.87*d*z[i]); 514 DrawLine (sx - 0.50*d*z[i], sy - 0.87*d*z[i], sx - d*z[i], sy); 528 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 529 sy = x[i]*myi + y[i]*myj + by + YCENTER; 530 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 531 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 532 { 533 D = d*z[i]; 534 DrawLine (sx - D, sy, sx - 0.50*D, sy + 0.87*D); 535 DrawLine (sx - 0.50*D, sy + 0.87*D, sx + 0.50*D, sy + 0.87*D); 536 DrawLine (sx + 0.50*D, sy + 0.87*D, sx + D, sy); 537 538 DrawLine (sx + D, sy, sx + 0.50*D, sy - 0.87*D); 539 DrawLine (sx + 0.50*D, sy - 0.87*D, sx - 0.50*D, sy - 0.87*D); 540 DrawLine (sx - 0.50*D, sy - 0.87*D, sx - D, sy); 515 541 } 516 542 } … … 525 551 for (i = 0; i + 1 < object[0].Npts; i+=2) { 526 552 if (!(finite(x[i]) && finite(y[i]))) continue; 527 sx1 = x[i]*mxi + y[i]*mxj + bx ;528 sy1 = x[i]*myi + y[i]*myj + by ;553 sx1 = x[i]*mxi + y[i]*mxj + bx + XCENTER; 554 sy1 = x[i]*myi + y[i]*myj + by + YCENTER; 529 555 if (!(finite(x[i+1]) && finite(y[i+1]))) continue; 530 sx2 = x[i+1]*mxi + y[i+1]*mxj + bx ;531 sy2 = x[i+1]*myi + y[i+1]*myj + by ;556 sx2 = x[i+1]*mxi + y[i+1]*mxj + bx + XCENTER; 557 sy2 = x[i+1]*myi + y[i+1]*myj + by + YCENTER; 532 558 ClipLine (sx1, sy1, sx2, sy2, X0, Y0, X1, Y1); 533 559 } … … 535 561 } 536 562 /**** points are not scaled by object.z ***/ 563 /** some rules on how the points are drawn: 564 1) the smallest point is always a dot (single pixel) 565 2) the point shape should be invarient on position 566 3) center of point is always center of a pixel 567 **/ 537 568 else { 538 d = object[0].size * 0.5 * (graphic->dx + graphic->dy) * 0.003;569 d = (int)(object[0].size * hypot((float)graphic->dx, (float)graphic->dy) * 0.003); 539 570 x = object[0].x; y = object[0].y; 540 if (object[0].ptype == 0) { /* filled box */ 541 for (i = 0; i < object[0].Npts; i++) { 542 if (!(finite(x[i]) && finite(y[i]))) continue; 543 sx = x[i]*mxi + y[i]*mxj + bx; 544 sy = x[i]*myi + y[i]*myj + by; 545 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 546 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 547 { 548 FillRectangle (sx - d, sy - d, 2*d, 2*d); 549 } 550 } 551 } 552 if (object[0].ptype == 1) { /* open box */ 553 for (i = 0; i < object[0].Npts; i++) { 554 if (!(finite(x[i]) && finite(y[i]))) continue; 555 sx = x[i]*mxi + y[i]*mxj + bx; 556 sy = x[i]*myi + y[i]*myj + by; 571 572 if (object[0].ptype == 0) { /* filled box : OK */ 573 for (i = 0; i < object[0].Npts; i++) { 574 if (!(finite(x[i]) && finite(y[i]))) continue; 575 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 576 sy = x[i]*myi + y[i]*myj + by + YCENTER; 577 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 578 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 579 { 580 FillRectangle (sx - d, sy - d, 2*d + 1, 2*d + 1); 581 } 582 } 583 } 584 if (object[0].ptype == 1) { /* open box : OK*/ 585 for (i = 0; i < object[0].Npts; i++) { 586 if (!(finite(x[i]) && finite(y[i]))) continue; 587 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 588 sy = x[i]*myi + y[i]*myj + by + YCENTER; 557 589 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 558 590 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) … … 562 594 } 563 595 } 564 if (object[0].ptype == 2) { /* cross */565 for (i = 0; i < object[0].Npts; i++) { 566 if (!(finite(x[i]) && finite(y[i]))) continue; 567 sx = x[i]*mxi + y[i]*mxj + bx ;568 sy = x[i]*myi + y[i]*myj + by ;569 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 570 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 571 { 572 DrawLine (sx - d, sy, sx + d + 1, sy); 596 if (object[0].ptype == 2) { /* cross : OK*/ 597 for (i = 0; i < object[0].Npts; i++) { 598 if (!(finite(x[i]) && finite(y[i]))) continue; 599 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 600 sy = x[i]*myi + y[i]*myj + by + YCENTER; 601 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 602 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 603 { 604 DrawLine (sx - d, sy, sx + d + 1, sy); // DrawLine does NOT draw the end pixel 573 605 DrawLine (sx, sy - d, sx, sy + d + 1); 574 606 } 575 607 } 576 608 } 577 if (object[0].ptype == 3) { /* x*/578 for (i = 0; i < object[0].Npts; i++) { 579 if (!(finite(x[i]) && finite(y[i]))) continue; 580 sx = x[i]*mxi + y[i]*mxj + bx ;581 sy = x[i]*myi + y[i]*myj + by ;609 if (object[0].ptype == 3) { /* x : OK */ 610 for (i = 0; i < object[0].Npts; i++) { 611 if (!(finite(x[i]) && finite(y[i]))) continue; 612 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 613 sy = x[i]*myi + y[i]*myj + by + YCENTER; 582 614 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 583 615 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 584 616 { 585 617 /* XDrawLine is a little funny, this is needed to fix endpost errors */ 586 DrawLine (sx + d + 1, sy - d - 1, sx - d, sy + d);618 DrawLine (sx - d, sy + d, sx + d + 1, sy - d - 1); 587 619 DrawLine (sx - d, sy - d, sx + d + 1, sy + d + 1); 588 620 } … … 593 625 for (i = 0; i < object[0].Npts; i++) { 594 626 if (!(finite(x[i]) && finite(y[i]))) continue; 595 sx = x[i]*mxi + y[i]*mxj + bx ;596 sy = x[i]*myi + y[i]*myj + by ;627 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 628 sy = x[i]*myi + y[i]*myj + by + YCENTER; 597 629 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 598 630 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) … … 609 641 for (i = 0; i < object[0].Npts; i++) { 610 642 if (!(finite(x[i]) && finite(y[i]))) continue; 611 sx = x[i]*mxi + y[i]*mxj + bx ;612 sy = x[i]*myi + y[i]*myj + by ;643 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 644 sy = x[i]*myi + y[i]*myj + by + YCENTER; 613 645 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 614 646 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) … … 623 655 for (i = 0; i < object[0].Npts; i++) { 624 656 if (!(finite(x[i]) && finite(y[i]))) continue; 625 sx = x[i]*mxi + y[i]*mxj + bx ;626 sy = x[i]*myi + y[i]*myj + by ;627 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 628 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 629 { 630 DrawLine (sx, sy, sx - d, sy +0.58*d);631 DrawLine (sx, sy, sx + d, sy +0.58*d);632 DrawLine (sx, sy, sx, sy -1.15*d);657 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 658 sy = x[i]*myi + y[i]*myj + by + YCENTER; 659 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 660 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 661 { 662 DrawLine (sx, sy, sx - d, sy - 0.58*d); 663 DrawLine (sx, sy, sx + d, sy - 0.58*d); 664 DrawLine (sx, sy, sx, sy + 1.15*d); 633 665 } 634 666 } … … 637 669 for (i = 0; i < object[0].Npts; i++) { 638 670 if (!(finite(x[i]) && finite(y[i]))) continue; 639 sx = x[i]*mxi + y[i]*mxj + bx ;640 sy = x[i]*myi + y[i]*myj + by ;671 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 672 sy = x[i]*myi + y[i]*myj + by + YCENTER; 641 673 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 642 674 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) … … 649 681 for (i = 0; i < object[0].Npts; i++) { 650 682 if (!(finite(x[i]) && finite(y[i]))) continue; 651 sx = x[i]*mxi + y[i]*mxj + bx ;652 sy = x[i]*myi + y[i]*myj + by ;683 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 684 sy = x[i]*myi + y[i]*myj + by + YCENTER; 653 685 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 654 686 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) … … 665 697 for (i = 0; i < object[0].Npts; i++) { 666 698 if (!(finite(x[i]) && finite(y[i]))) continue; 667 sx = x[i]*mxi + y[i]*mxj + bx ;668 sy = x[i]*myi + y[i]*myj + by ;699 sx = x[i]*mxi + y[i]*mxj + bx + XCENTER; 700 sy = x[i]*myi + y[i]*myj + by + YCENTER; 669 701 if ((sx > graph[0].axis[0].fx) && (sx < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 670 702 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) … … 687 719 for (i = 0; i + 1 < object[0].Npts; i+=2) { 688 720 if (!(finite(x[i]) && finite(y[i]))) continue; 689 sx1 = x[i]*mxi + y[i]*mxj + bx ;690 sy1 = x[i]*myi + y[i]*myj + by ;691 sx2 = x[i+1]*mxi + y[i+1]*mxj + bx ;692 sy2 = x[i+1]*myi + y[i+1]*myj + by ;721 sx1 = x[i]*mxi + y[i]*mxj + bx + XCENTER; 722 sy1 = x[i]*myi + y[i]*myj + by + YCENTER; 723 sx2 = x[i+1]*mxi + y[i+1]*mxj + bx + XCENTER; 724 sy2 = x[i+1]*myi + y[i+1]*myj + by + YCENTER; 693 725 ClipLine (sx1, sy1, sx2, sy2, X0, Y0, X1, Y1); 694 726 } … … 723 755 for (i = 0; i < object[0].Npts; i++) { 724 756 if (!(finite(x[i]) && finite(y[i]) && finite(dxp[i]))) continue; 725 sx0 = x[i]*mxi + y[i]*mxj + bx ;726 sy0 = x[i]*myi + y[i]*myj + by ;727 sx1 = (x[i] + dxp[i])*mxi + y[i]*mxj + bx ;728 sy1 = (x[i] + dxp[i])*myi + y[i]*myj + by ;757 sx0 = x[i]*mxi + y[i]*mxj + bx + XCENTER; 758 sy0 = x[i]*myi + y[i]*myj + by + YCENTER; 759 sx1 = (x[i] + dxp[i])*mxi + y[i]*mxj + bx + XCENTER; 760 sy1 = (x[i] + dxp[i])*myi + y[i]*myj + by + YCENTER; 729 761 if (((sx0 > graph[0].axis[0].fx) && (sx0 < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 730 762 (sy0 < graph[0].axis[1].fy) && (sy0 > graph[0].axis[1].fy + graph[0].axis[1].dfy)) || … … 740 772 } 741 773 if (!(finite(x[i]) && finite(y[i]) && finite(dxm[i]))) continue; 742 sx0 = x[i]*mxi + y[i]*mxj + bx ;743 sy0 = x[i]*myi + y[i]*myj + by ;744 sx1 = (x[i] - dxm[i])*mxi + y[i]*mxj + bx ;745 sy1 = (x[i] - dxm[i])*myi + y[i]*myj + by ;774 sx0 = x[i]*mxi + y[i]*mxj + bx + XCENTER; 775 sy0 = x[i]*myi + y[i]*myj + by + YCENTER; 776 sx1 = (x[i] - dxm[i])*mxi + y[i]*mxj + bx + XCENTER; 777 sy1 = (x[i] - dxm[i])*myi + y[i]*myj + by + YCENTER; 746 778 if (((sx0 > graph[0].axis[0].fx) && (sx0 < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 747 779 (sy0 < graph[0].axis[1].fy) && (sy0 > graph[0].axis[1].fy + graph[0].axis[1].dfy)) || … … 785 817 for (i = 0; i < object[0].Npts; i++) { 786 818 if (!(finite(x[i]) && finite(y[i]) && finite(dyp[i]))) continue; 787 sx0 = x[i]*mxi + y[i]*mxj + bx ;788 sy0 = x[i]*myi + y[i]*myj + by ;819 sx0 = x[i]*mxi + y[i]*mxj + bx + XCENTER; 820 sy0 = x[i]*myi + y[i]*myj + by + YCENTER; 789 821 sx1 = sx0 + dyp[i]*mxj; 790 822 sy1 = sy0 + dyp[i]*myj; … … 802 834 } 803 835 if (!(finite(x[i]) && finite(y[i]) && finite(dym[i]))) continue; 804 sx0 = x[i]*mxi + y[i]*mxj + bx ;805 sy0 = x[i]*myi + y[i]*myj + by ;806 sx1 = x[i]*mxi + (y[i] - dym[i])*mxj + bx ;807 sy1 = x[i]*myi + (y[i] - dym[i])*myj + by ;836 sx0 = x[i]*mxi + y[i]*mxj + bx + XCENTER; 837 sy0 = x[i]*myi + y[i]*myj + by + YCENTER; 838 sx1 = x[i]*mxi + (y[i] - dym[i])*mxj + bx + XCENTER; 839 sy1 = x[i]*myi + (y[i] - dym[i])*myj + by + YCENTER; 808 840 if (((sx0 > graph[0].axis[0].fx) && (sx0 < graph[0].axis[0].fx + graph[0].axis[0].dfx) && 809 841 (sy0 < graph[0].axis[1].fy) && (sy0 > graph[0].axis[1].fy + graph[0].axis[1].dfy)) || -
branches/czw_branch/20110406/Ohana/src/kapa2/src/PSObjects.c
r31160 r31606 365 365 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 366 366 { 367 DrawLine (sx - d*z[i], sy + 0.58*d*z[i], sx + d*z[i], sy +0.58*d*z[i]);368 DrawLine (sx + d*z[i], sy + 0.58*d*z[i], sx, sy -1.15*d*z[i]);369 DrawLine (sx, sy - 1.15*d*z[i], sx - d*z[i], sy +0.58*d*z[i]);367 DrawLine (sx - d*z[i], sy - 0.58*d*z[i], sx + d*z[i], sy - 0.58*d*z[i]); 368 DrawLine (sx + d*z[i], sy - 0.58*d*z[i], sx, sy + 1.15*d*z[i]); 369 DrawLine (sx, sy + 1.15*d*z[i], sx - d*z[i], sy - 0.58*d*z[i]); 370 370 } 371 371 } … … 538 538 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 539 539 { 540 DrawLine (sx, sy, sx - d, sy -0.58*d);541 DrawLine (sx, sy, sx + d, sy -0.58*d);542 DrawLine (sx, sy, sx, sy +1.15*d);540 DrawLine (sx, sy, sx - d, sy + 0.58*d); 541 DrawLine (sx, sy, sx + d, sy + 0.58*d); 542 DrawLine (sx, sy, sx, sy - 1.15*d); 543 543 } 544 544 } -
branches/czw_branch/20110406/Ohana/src/kapa2/src/bDrawObjects.c
r31160 r31606 4 4 # define DrawCircle(BUF,X1,Y1,R) (bDrawCircle (BUF, (X1), (Y1), (R))) 5 5 # define DrawRectangle(BUF,X,Y,dX,dY) (bDrawRectOpen (BUF, (X-0.5*dX), (Y-0.5*dY), (X+0.5*dX), (Y+0.5*dY))) 6 # define FillRectangle(BUF,X,Y,dX,dY) (bDrawRectFill (BUF, (X-0.5*dX), (Y-0.5*dY), (X+0.5*dX ), (Y+0.5*dY)))7 # define FillTriangle(BUF,X1,Y1, X2,Y2,X3,Y3) (bDrawTriFill (BUF, (X1), (Y1), (X2), (Y2), (X3), (Y3)))6 # define FillRectangle(BUF,X,Y,dX,dY) (bDrawRectFill (BUF, (X-0.5*dX), (Y-0.5*dY), (X+0.5*dX+1), (Y+0.5*dY+1))) 7 # define FillTriangle(BUF,X1,Y1,dX,dY) (bDrawTriFill (BUF, (X1), (Y1), (dX), (dY))) 8 8 # define OpenTriangle(BUF,X1,Y1,X2,Y2,X3,Y3) (bDrawTriOpen (BUF, (X1), (Y1), (X2), (Y2), (X3), (Y3))) 9 9 … … 260 260 float *x, *y, *z; 261 261 double mxi, mxj, myi, myj, bxi, bxj, byi, byj, bx, by; 262 double sx, sy, d, sx1, sy1, sx2, sy2;262 int sx, sy, sx1, sy1, sx2, sy2, d, D; 263 263 264 264 mxi = graph[0].axis[0].dfx / (object[0].x1 - object[0].x0); … … 288 288 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 289 289 { 290 FillRectangle (buffer, sx, sy, 2*d*z[i], 2*d*z[i]); 290 D = d*z[i]; 291 FillRectangle (buffer, sx, sy, 2*D, 2*D); 291 292 } 292 293 } … … 300 301 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 301 302 { 302 DrawRectangle (buffer, sx, sy, 2*d*z[i], 2*d*z[i]); 303 D = d*z[i]; 304 DrawRectangle (buffer, sx, sy, 2*D, 2*D); 303 305 } 304 306 } … … 312 314 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 313 315 { 314 DrawLine (buffer, sx - d*z[i], sy, sx + d*z[i], sy); 315 DrawLine (buffer, sx, sy - d*z[i], sx, sy + d*z[i]); 316 D = d*z[i]; 317 DrawLine (buffer, sx - D, sy, sx + D, sy); 318 DrawLine (buffer, sx, sy - D, sx, sy + D); 316 319 } 317 320 } … … 325 328 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 326 329 { 327 DrawLine (buffer, sx + d*z[i], sy - d*z[i], sx - d*z[i], sy + d*z[i]); 328 DrawLine (buffer, sx - d*z[i], sy - d*z[i], sx + d*z[i], sy + d*z[i]); 330 D = d*z[i]; 331 DrawLine (buffer, sx + D, sy - D, sx - D, sy + D); 332 DrawLine (buffer, sx - D, sy - D, sx + D, sy + D); 329 333 } 330 334 } … … 338 342 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 339 343 { 340 FillTriangle (buffer, sx - d*z[i], sy - 0.58*d*z[i], sx + d*z[i], sy - 0.58*d*z[i], sx, sy + 1.15*d*z[i]); 344 D = d*z[i]; 345 // FillTriangle (buffer, sx - D, sy - 0.58*D, sx + D, sy - 0.58*D, sx, sy + 1.15*D); 346 FillTriangle (buffer, sx, sy + 0.58*D, D, -1.73*D); 341 347 } 342 348 } … … 350 356 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 351 357 { 352 OpenTriangle (buffer, sx - d*z[i], sy + 0.58*d*z[i], sx, sy - 1.15*d*z[i], sx + d*z[i], sy + 0.58*d*z[i]); 358 D = d*z[i]; 359 OpenTriangle (buffer, sx - D, sy + 0.58*D, sx + D, sy + 0.58*D, sx, sy - 1.15*D); 353 360 } 354 361 } … … 362 369 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 363 370 { 364 DrawLine (buffer, sx, sy, sx - d*z[i], sy + 0.58*d*z[i]); 365 DrawLine (buffer, sx, sy, sx + d*z[i], sy + 0.58*d*z[i]); 366 DrawLine (buffer, sx, sy, sx, sy - 1.15*d*z[i]); 371 D = d*z[i]; 372 DrawLine (buffer, sx, sy, sx - D, sy - 0.58*D); 373 DrawLine (buffer, sx, sy, sx + D, sy - 0.58*D); 374 DrawLine (buffer, sx, sy, sx, sy + 1.15*D); 367 375 } 368 376 } … … 376 384 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 377 385 { 378 DrawCircle (buffer, sx, sy, d*z[i]); 386 D = d*z[i]; 387 DrawCircle (buffer, sx, sy, D); 379 388 } 380 389 } … … 388 397 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 389 398 { 390 DrawLine (buffer, sx + 0.00*d*z[i], sy - 1.00*d*z[i], sx + 0.95*d*z[i], sy - 0.31*d*z[i]); 391 DrawLine (buffer, sx + 0.95*d*z[i], sy - 0.31*d*z[i], sx + 0.58*d*z[i], sy + 0.81*d*z[i]); 392 DrawLine (buffer, sx + 0.58*d*z[i], sy + 0.81*d*z[i], sx - 0.58*d*z[i], sy + 0.81*d*z[i]); 393 DrawLine (buffer, sx - 0.58*d*z[i], sy + 0.81*d*z[i], sx - 0.95*d*z[i], sy - 0.31*d*z[i]); 394 DrawLine (buffer, sx - 0.95*d*z[i], sy - 0.31*d*z[i], sx + 0.00*d*z[i], sy - 1.00*d*z[i]); 399 D = d*z[i]; 400 DrawLine (buffer, sx + 0.00*D, sy - 1.00*D, sx + 0.95*D, sy - 0.31*D); 401 DrawLine (buffer, sx + 0.95*D, sy - 0.31*D, sx + 0.58*D, sy + 0.81*D); 402 DrawLine (buffer, sx + 0.58*D, sy + 0.81*D, sx - 0.58*D, sy + 0.81*D); 403 DrawLine (buffer, sx - 0.58*D, sy + 0.81*D, sx - 0.95*D, sy - 0.31*D); 404 DrawLine (buffer, sx - 0.95*D, sy - 0.31*D, sx + 0.00*D, sy - 1.00*D); 395 405 } 396 406 } … … 404 414 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 405 415 { 406 D rawLine (buffer, sx - d*z[i], sy, sx - 0.50*d*z[i], sy + 0.87*d*z[i]);407 DrawLine (buffer, sx - 0.50*d*z[i], sy + 0.87*d*z[i], sx + 0.50*d*z[i], sy + 0.87*d*z[i]);408 DrawLine (buffer, sx + 0.50*d*z[i], sy + 0.87*d*z[i], sx + d*z[i], sy);409 410 DrawLine (buffer, sx + d*z[i], sy, sx + 0.50*d*z[i], sy - 0.87*d*z[i]);411 DrawLine (buffer, sx + 0.50* d*z[i], sy - 0.87*d*z[i], sx - 0.50*d*z[i], sy - 0.87*d*z[i]);412 DrawLine (buffer, sx - 0.50* d*z[i], sy - 0.87*d*z[i], sx - d*z[i], sy);416 D = d*z[i]; 417 DrawLine (buffer, sx - D, sy, sx - 0.50*D, sy + 0.87*D); 418 DrawLine (buffer, sx - 0.50*D, sy + 0.87*D, sx + 0.50*D, sy + 0.87*D); 419 DrawLine (buffer, sx + 0.50*D, sy + 0.87*D, sx + D, sy); 420 DrawLine (buffer, sx + D, sy, sx + 0.50*D, sy - 0.87*D); 421 DrawLine (buffer, sx + 0.50*D, sy - 0.87*D, sx - 0.50*D, sy - 0.87*D); 422 DrawLine (buffer, sx - 0.50*D, sy - 0.87*D, sx - D, sy); 413 423 } 414 424 } … … 431 441 } 432 442 } else { 433 d = object[0].size * 0.5 * (graphic->dx + graphic->dy) * 0.003;443 d = (int)(object[0].size * hypot((float)graphic->dx, (float)graphic->dy) * 0.003); 434 444 x = object[0].x; y = object[0].y; 445 435 446 if (object[0].ptype == 0) { /* filled box */ 436 447 for (i = 0; i < object[0].Npts; i++) { … … 457 468 } 458 469 } 459 if (object[0].ptype == 2) { /* cross */470 if (object[0].ptype == 2) { /* cross : OK */ 460 471 for (i = 0; i < object[0].Npts; i++) { 461 472 if (!(finite(x[i]) && finite(y[i]))) continue; … … 491 502 (sy < graph[0].axis[1].fy) && (sy > graph[0].axis[1].fy + graph[0].axis[1].dfy)) 492 503 { 493 FillTriangle (buffer, sx - d, sy - 0.58*d, sx + d, sy - 0.58*d, sx, sy + 1.15*d);504 FillTriangle (buffer, sx, sy + 0.58*d, d, -1.73*d); 494 505 } 495 506 } -
branches/czw_branch/20110406/Ohana/src/libdvo/Makefile
r31160 r31606 101 101 102 102 $(AINC)/autocode.h: $(AINCS) $(ADEF)/autocode.h $(ADEF)/common.h 103 @echo " make$@ from $^"104 cd $(AUTO) && make$@103 @echo "$(MAKE) $@ from $^" 104 cd $(AUTO) && $(MAKE) $@ 105 105 106 106 # generic rule for AINCS 107 107 $(AINC)/%.h : $(ADEF)/%.d $(ADEF)/autocode.h $(ADEF)/common.h 108 @echo " make$@ from $^"109 cd $(AUTO) && make$@108 @echo "$(MAKE) $@ from $^" 109 cd $(AUTO) && $(MAKE) $@ 110 110 111 111 # generic rule for ASRC 112 112 $(ASRC)/%.c : $(ADEF)/%.d $(ADEF)/autocode.c $(AINC)/%.h 113 @echo " make$@ from $^"114 cd $(AUTO) && make$@113 @echo "$(MAKE) $@ from $^" 114 cd $(AUTO) && $(MAKE) $@ 115 115 116 116 # generic rule for AOBJS 117 117 $(ASRC)/%.$(ARCH).o : $(ASRC)/%.c 118 @echo " make$@ from $^"119 cd $(AUTO) && make$@118 @echo "$(MAKE) $@ from $^" 119 cd $(AUTO) && $(MAKE) $@ 120 120 121 121 tabletest: install … … 124 124 clean: cleandef 125 125 cleandef: 126 cd $(AUTO) && makeclean126 cd $(AUTO) && $(MAKE) clean 127 127 128 128 .PRECIOUS: $(ASRC)/%.c -
branches/czw_branch/20110406/Ohana/src/libdvo/include/dvo.h
r31160 r31606 20 20 DVO_FORMAT_PS1_DEV_2, 21 21 DVO_FORMAT_PS1_DEV_3, 22 DVO_FORMAT_PS1_REF, 22 23 DVO_FORMAT_PS1_V1, 23 24 DVO_FORMAT_PS1_V2, 24 DVO_FORMAT_PS1_REF25 25 } DVOTableFormat; 26 26 … … 210 210 } PhotCodeData; 211 211 212 // a reduced-subset structure for relphot 213 typedef struct { 214 double R; 215 double D; 216 unsigned short Nmeasure; 217 int measureOffset; 218 uint32_t flags; 219 } AverageTiny; 220 221 // a reduced-subset structure for relphot 222 typedef struct { 223 float dR; 224 float dD; 225 float M; 226 float Mcal; 227 float dM; 228 float airmass; 229 float Xccd; 230 float Yccd; 231 float dt; 232 int t; 233 unsigned int averef; 234 unsigned int imageID; 235 unsigned int dbFlags; 236 unsigned short photcode; 237 } MeasureTiny; 238 212 239 /* a catalog contains this data */ 213 240 typedef struct Catalog { … … 226 253 off_t Naves_disk, Nmeas_disk, Nmiss_disk, Nsecf_disk; /* current number of each component on disk */ 227 254 off_t Naves_off, Nmeas_off, Nmiss_off, Nsecf_off; /* index of first loaded data value */ 255 256 // note that we use these for the full-sky relphot analysis 257 AverageTiny *averageT; 258 MeasureTiny *measureT; 228 259 229 260 /* the Nsecf_* values above are number of table rows (eg, Naverage*Nsecfilt) */ … … 330 361 int PhotColor (Average *average, SecFilt *secfilt, Measure *measure, int c1, int c2, double *color); 331 362 363 float PhotInstTiny (MeasureTiny *measure); 364 float PhotCatTiny (MeasureTiny *measure); 365 float PhotAperTiny (MeasureTiny *measure); 366 float PhotSysTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt); 367 float PhotRelTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt); 368 float PhotCalTiny (MeasureTiny *thisone, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, PhotCode *code); 369 float PhotAveTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt); 370 float PhotRefTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure); 371 float PhotXmTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt); 372 float PhotdMTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt); 373 374 float PhotColorForCodeTiny (AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, PhotCode *code); 375 int PhotColorTiny (AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, int c1, int c2, double *color); 376 377 332 378 PhotCodeData *GetPhotcodeTable (void); 333 379 void SetPhotcodeTable (PhotCodeData *); -
branches/czw_branch/20110406/Ohana/src/libdvo/src/dvo_catalog_split.c
r29938 r31606 448 448 catalog[0].measure = FtableToMeasure (&ftable, &Nmeasure, &catalog[0].catformat); 449 449 if (Nmeasure != Nrows) { 450 fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nmeasure, Nrows); 450 // XXX this condition denotes the eof has been reached; not an error or a warning 451 // fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nmeasure, Nrows); 451 452 } 452 453 gfits_free_header (&header); -
branches/czw_branch/20110406/Ohana/src/libdvo/src/dvo_photcode_ops.c
r29938 r31606 536 536 return (TRUE); 537 537 } 538 539 /******** alternate photometry conversion functions using MeasureTiny and AverageTiny *********/ 540 float PhotInstTiny (MeasureTiny *measure) { 541 542 int Np; 543 float M; 544 545 Np = photcodes[0].hashcode[measure[0].photcode]; 546 if (Np == -1) return (NAN); 547 548 if (photcodes[0].code[Np].type == PHOT_REF) { 549 M = measure[0].M; 550 return (M); 551 } 552 553 M = measure[0].M - measure[0].dt - ZERO_POINT; 554 555 return (M); 556 557 } 558 559 float PhotCatTiny (MeasureTiny *measure) { 560 561 int Np; 562 float Mcat; 563 PhotCode *code; 564 565 Np = photcodes[0].hashcode[measure[0].photcode]; 566 if (Np == -1) return (NAN); 567 568 if (photcodes[0].code[Np].type == PHOT_REF) { 569 Mcat = measure[0].M; 570 return (Mcat); 571 } 572 code = &photcodes[0].code[Np]; 573 Mcat = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 574 575 return (Mcat); 576 } 577 578 # if (0) 579 float PhotAperTiny (MeasureTiny *measure) { 580 581 int Np; 582 float Mcat; 583 PhotCode *code; 584 585 Np = photcodes[0].hashcode[measure[0].photcode]; 586 if (Np == -1) return (NAN); 587 588 if (photcodes[0].code[Np].type == PHOT_REF) { 589 Mcat = measure[0].Map; 590 return (Mcat); 591 } 592 code = &photcodes[0].code[Np]; 593 Mcat = measure[0].Map - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 594 595 return (Mcat); 596 } 597 # endif 598 599 float PhotSysTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt) { 600 601 int i, Np; 602 float Mcat, Mcol, Msys, mc, Mc; 603 PhotCode *code; 604 605 Np = photcodes[0].hashcode[measure[0].photcode]; 606 if (Np == -1) return (NAN); 607 608 if (photcodes[0].code[Np].type == PHOT_REF) { 609 Msys = measure[0].M; 610 return (Msys); 611 } 612 code = &photcodes[0].code[Np]; 613 Mcat = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C; 614 615 /* for DEP, color must be made of PRI/SEC */ 616 mc = PhotColorForCodeTiny (average, secfilt, NULL, code); 617 if (isnan(mc)) return (Mcat); 618 mc = mc - SCALE*code[0].dX; 619 620 Mc = mc; 621 Mcol = 0; 622 for (i = 0; i < code[0].Nc; i++) { 623 Mcol += code[0].X[i]*Mc; 624 Mc *= mc; 625 } 626 Msys = Mcat + Mcol; 627 return (Msys); 628 } 629 630 float PhotRelTiny (MeasureTiny *measure, AverageTiny *average, SecFilt *secfilt) { 631 632 int i, Np; 633 float Mcat, Mcol, Mrel, mc, Mc; 634 PhotCode *code; 635 636 Np = photcodes[0].hashcode[measure[0].photcode]; 637 if (Np == -1) return (NAN); 638 639 if (photcodes[0].code[Np].type == PHOT_REF) { 640 Mcat = measure[0].M; 641 return (Mcat); 642 } 643 code = &photcodes[0].code[Np]; 644 Mrel = measure[0].M - ZERO_POINT + code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal; 645 646 /* for DEP, color must be made of PRI/SEC */ 647 mc = PhotColorForCodeTiny (average, secfilt, NULL, code); 648 if (isnan(mc)) return (Mrel); 649 mc = mc - SCALE*code[0].dX; 650 651 Mc = mc; 652 Mcol = 0; 653 for (i = 0; i < code[0].Nc; i++) { 654 Mcol += code[0].X[i]*Mc; 655 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 656 } 657 Mrel += Mcol; 658 return (Mrel); 659 } 660 661 /* return calibrated magnitude from measure for given photcode */ 662 float PhotCalTiny (MeasureTiny *thisone, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, PhotCode *code) { 663 664 int i, Np; 665 float Mcal, Mrel, Mcol, mc, Mc; 666 667 if (code == NULL) return NAN; 668 669 /* code must be the matching PRI/SEC code for this measurement or an equivalent ALT */ 670 Np = photcodes[0].hashcode[thisone[0].photcode]; 671 if (Np == -1) return (NAN); 672 673 if (photcodes[0].code[Np].type == PHOT_REF) { 674 Mrel = thisone[0].M; 675 return (Mrel); 676 } 677 if (code[0].code != photcodes[0].code[Np].equiv) return (NAN); 678 679 Mcal = PhotRelTiny (thisone, average, secfilt) + SCALE*code[0].C; 680 681 mc = PhotColorForCodeTiny (average, secfilt, measure, code); 682 if (isnan(mc)) return (Mcal); 683 mc = mc - SCALE*code[0].dX; 684 685 Mc = mc; 686 Mcol = 0; 687 for (i = 0; i < code[0].Nc; i++) { 688 Mcol += code[0].X[i]*Mc; 689 Mc *= mc; 690 } 691 Mcal += Mcol; 692 return (Mcal); 693 } 694 695 /* color term may not use DEP magnitude */ 696 float PhotColorForCodeTiny (AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, PhotCode *code) { 697 698 int i, Ns1, Ns2, Ns; 699 float m1, m2, mc; 700 PhotCode *color; 701 702 m1 = m2 = NAN; 703 704 if (measure == NULL) { 705 Ns1 = photcodes[0].hashNsec[code[0].c1]; 706 Ns2 = photcodes[0].hashNsec[code[0].c2]; 707 708 m1 = (Ns1 == -1) ? NAN : secfilt[Ns1].M; 709 m2 = (Ns2 == -1) ? NAN : secfilt[Ns2].M; 710 mc = (isnan(m1) || isnan(m2)) ? NAN : (m1 - m2); 711 return (mc); 712 } 713 714 /* find magnitude matching first color term */ 715 color = GetPhotcodebyCode (code[0].c1); 716 if (color == NULL) return (NAN); 717 if (color[0].type == PHOT_REF) { 718 for (i = 0; (i < average[0].Nmeasure) && (isnan(m1)); i++) { 719 if (measure[i].photcode == color[0].code) { 720 m1 = measure[i].M; 721 } 722 } 723 } else { 724 Ns = photcodes[0].hashNsec[color[0].code]; 725 m1 = (Ns == -1) ? NAN : secfilt[Ns].M; 726 } 727 728 /* find magnitude matching second color term */ 729 color = GetPhotcodebyCode (code[0].c2); 730 if (color == NULL) return (NAN); 731 if (color[0].type == PHOT_REF) { 732 for (i = 0; (i < average[0].Nmeasure) && (isnan(m2)); i++) { 733 if (measure[i].photcode == color[0].code) { 734 m2 = measure[i].M; 735 } 736 } 737 } else { 738 Ns = photcodes[0].hashNsec[color[0].code]; 739 m2 = (Ns == -1) ? NAN : secfilt[Ns].M; 740 } 741 mc = (isnan(m1) || isnan(m2)) ? NAN : (m1 - m2); 742 return (mc); 743 } 744 745 /* return calibrated magnitude from average/secfilt for given photcode */ 746 float PhotRefTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure) { 747 748 int i, Ns; 749 float Mave, Mref, Mcol, mc; 750 double Mc; 751 752 if (code == NULL) return NAN; 753 754 Ns = photcodes[0].hashNsec[code[0].code]; 755 Mave = (Ns == -1) ? NAN : secfilt[Ns].M; 756 Mref = Mave + SCALE*code[0].C; 757 758 mc = PhotColorForCodeTiny (average, secfilt, measure, code); 759 if (isnan(mc)) return (Mref); 760 mc = mc - SCALE*code[0].dX; 761 762 Mc = mc; 763 Mcol = 0; 764 for (i = 0; i < code[0].Nc; i++) { 765 Mcol += code[0].X[i]*Mc; 766 Mc *= mc; /* the 0.001 is needed for higher order terms to keep the units mag = mag^n */ 767 } 768 Mref += Mcol; 769 return (Mref); 770 } 771 772 /***/ 773 float PhotAveTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt) { 774 775 int Ns; 776 float Mave; 777 778 if (code == NULL) return NAN; 779 780 Ns = photcodes[0].hashNsec[code[0].code]; 781 Mave = (Ns == -1) ? NAN : secfilt[Ns].M; 782 return (Mave); 783 } 784 785 float PhotdMTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt) { 786 787 int Ns; 788 float dM; 789 790 if (code == NULL) return NAN; 791 792 Ns = photcodes[0].hashNsec[code[0].code]; 793 dM = (Ns == -1) ? NAN : secfilt[Ns].dM; 794 return (dM); 795 } 796 797 // XXX return NAN or NAN_S_SHORT? (secfilt->Xm is short) 798 float PhotXmTiny (PhotCode *code, AverageTiny *average, SecFilt *secfilt) { 799 800 int Ns; 801 short Mi; 802 float Xm; 803 804 if (code == NULL) return NAN; 805 806 Ns = photcodes[0].hashNsec[code[0].code]; 807 Mi = (Ns == -1) ? NAN : secfilt[Ns].Xm; 808 Xm = (isnan(Mi)) ? -1.0 : pow (10.0, 0.01*Mi); 809 return (Xm); 810 } 811 812 /* given a photcode pair c1 & c2, return the color of this star (NaN if not found) */ 813 int PhotColorTiny (AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, int c1, int c2, double *color) { 814 815 int i, Ns; 816 double M1, M2, dM; 817 PhotCode *code; 818 819 code = GetPhotcodebyCode (c1); 820 if (code == NULL) return (FALSE); 821 if (code[0].type == PHOT_REF) { 822 for (i = 0; i < average[0].Nmeasure; i++) { 823 if (measure[i].photcode == c1) { 824 M1 = measure[i].M; 825 goto filter1; 826 } 827 } 828 return (FALSE); 829 } else { 830 Ns = photcodes[0].hashNsec[code[0].code]; 831 M1 = (Ns == -1) ? NAN : secfilt[Ns].M; 832 } 833 834 filter1: 835 code = GetPhotcodebyCode (c2); 836 if (code == NULL) return (FALSE); 837 if (code[0].type == PHOT_REF) { 838 for (i = 0; i < average[0].Nmeasure; i++) { 839 if (measure[i].photcode == c2) { 840 M2 = measure[i].M; 841 goto filter2; 842 } 843 } 844 return (FALSE); 845 } else { 846 Ns = photcodes[0].hashNsec[code[0].code]; 847 M2 = (Ns == -1) ? NAN : secfilt[Ns].M; 848 } 849 850 filter2: 851 852 dM = M1 - M2; 853 *color = dM; 854 855 return (TRUE); 856 } 857 /***********************************************/ 538 858 539 859 // Create a map between the secfilt values from one photcode table to another -
branches/czw_branch/20110406/Ohana/src/libkapa/include/kapa.h
r31160 r31606 255 255 void bDrawRectFill (bDrawBuffer *buffer, double x1, double y1, double x2, double y2); 256 256 void bDrawTriOpen (bDrawBuffer *buffer, double x1, double y1, double x2, double y2, double x3, double y3); 257 void bDrawTriFill (bDrawBuffer *buffer, double x1, double y1, double x2, double y2, double x3, double y3);257 void bDrawTriFill (bDrawBuffer *buffer, double x1, double y1, double dx, double dy); 258 258 259 259 /* bDrawRotFont.c */ -
branches/czw_branch/20110406/Ohana/src/libkapa/src/bDrawFuncs.c
r29938 r31606 134 134 Y2 = MIN (MAX (ROUND (y2), 1), buffer[0].Ny - 1); 135 135 136 bDrawLineHorizontal (buffer, X1, X2 , Y1);137 bDrawLineHorizontal (buffer, X1, X2 , Y2);136 bDrawLineHorizontal (buffer, X1, X2 + 1, Y1); 137 bDrawLineHorizontal (buffer, X1, X2 + 1, Y2); 138 138 bDrawLineVertical (buffer, X1, Y1, Y2); 139 139 bDrawLineVertical (buffer, X2, Y1, Y2); … … 275 275 } 276 276 277 void bDrawTriFill (bDrawBuffer *buffer, double x1, double y1, double x2, double y2, double x3, double y3) { 278 279 bDrawTriOpen (buffer, x1, y1, x2, y2, x3, y3); 277 // upright triangle with base of width 2 dX + 1, height of dY, center of base at x1, y1 278 void bDrawTriFill (bDrawBuffer *buffer, double x1, double y1, double dx, double dy) { 279 280 int xs, xe, x, y; 281 float e, m; 282 283 double dX = fabs(dx); 284 285 xs = x1 - dX; 286 xe = x1 + dX + 1; 287 e = 0; 288 m = dX / dy; 289 290 if (dy > 0.0) { 291 for (y = y1; y < y1 + dy + 1; y++) { 292 for (x = xs; x < xe; x++) { 293 bDrawPoint (buffer, x, y); 294 } 295 e += m; 296 if (e > 0.5) { 297 xs ++; 298 xe --; 299 e -= 1.0; 300 } 301 if (e < -0.5) { 302 xs ++; 303 xe --; 304 e += 1.0; 305 } 306 } 307 } else { 308 for (y = y1; y > y1 + dy - 1; y--) { 309 for (x = xs; x < xe; x++) { 310 bDrawPoint (buffer, x, y); 311 } 312 e += m; 313 if (e > 0.5) { 314 xs ++; 315 xe --; 316 e -= 1.0; 317 } 318 if (e < -0.5) { 319 xs ++; 320 xe --; 321 e += 1.0; 322 } 323 } 324 } 325 280 326 return; 281 327 } -
branches/czw_branch/20110406/Ohana/src/libohana/Makefile
r28241 r31606 54 54 testcode: install $(TEST) 55 55 test: 56 maketestcode56 $(MAKE) testcode 57 57 for i in $(TEST); do $$i; done 58 58 -
branches/czw_branch/20110406/Ohana/src/misc/Makefile
r12842 r31606 37 37 38 38 cfhtlog: 39 make$(DESTBIN)/cfhtlog39 $(MAKE) $(DESTBIN)/cfhtlog 40 40 41 41 # copied from Makefile.Common : use a single c file: foo : foo.c … … 56 56 57 57 %.install: 58 make$(DESTBIN)/$*58 $(MAKE) $(DESTBIN)/$* 59 59 60 60 install: 61 for i in $(PROGRAMS); do make$$i.install || exit; done61 for i in $(PROGRAMS); do $(MAKE) $$i.install || exit; done 62 62 63 63 %.clean: -
branches/czw_branch/20110406/Ohana/src/opihi/Makefile
r8566 r31606 23 23 24 24 all: 25 for i in $(PROGRAM) $(SPECIAL); do make$$i || exit; done26 makepantasks_client27 makepantasks_server25 for i in $(PROGRAM) $(SPECIAL); do $(MAKE) $$i || exit; done 26 $(MAKE) pantasks_client 27 $(MAKE) pantasks_server 28 28 29 29 libs: 30 for i in $(LIBS); do make$$i || exit; done30 for i in $(LIBS); do $(MAKE) $$i || exit; done 31 31 32 32 extras: 33 for i in $(EXTRAS); do make$$i || exit; done33 for i in $(EXTRAS); do $(MAKE) $$i || exit; done 34 34 35 35 install: 36 for i in $(PROGRAM) $(SPECIAL); do make$$i.install || exit; done37 makepantasks_client.install38 makepantasks_server.install36 for i in $(PROGRAM) $(SPECIAL); do $(MAKE) $$i.install || exit; done 37 $(MAKE) pantasks_client.install 38 $(MAKE) pantasks_server.install 39 39 40 40 extras-install: 41 for i in $(EXTRAS); do make$$i.install || exit; done41 for i in $(EXTRAS); do $(MAKE) $$i.install || exit; done 42 42 43 43 clean: 44 for i in $(PROGRAM) $(SPECIAL) $(EXTRAS) $(LIBS); do make$$i.clean || exit; done44 for i in $(PROGRAM) $(SPECIAL) $(EXTRAS) $(LIBS); do $(MAKE) $$i.clean || exit; done 45 45 46 46 libs-uninstall: 47 for i in $(LIBS); do make$$i.uninstall || exit; done47 for i in $(LIBS); do $(MAKE) $$i.uninstall || exit; done 48 48 49 49 dist: clean 50 for i in $(PROGRAM) $(SPECIAL) $(EXTRAS) $(LIBS); do make$$i.dist || exit; done50 for i in $(PROGRAM) $(SPECIAL) $(EXTRAS) $(LIBS); do $(MAKE) $$i.dist || exit; done 51 51 rm -rf bin 52 52 rm -rf lib … … 55 55 56 56 pantasks_client pantasks_server: 57 if [ -d pantasks ]; then (cd pantasks && make$@); fi57 if [ -d pantasks ]; then (cd pantasks && $(MAKE) $@); fi 58 58 59 59 pantasks_client.install: pantasks_client 60 if [ -d pantasks ]; then (cd pantasks && make$@); fi60 if [ -d pantasks ]; then (cd pantasks && $(MAKE) $@); fi 61 61 62 62 pantasks_server.install: pantasks_server 63 if [ -d pantasks ]; then (cd pantasks && make$@); fi63 if [ -d pantasks ]; then (cd pantasks && $(MAKE) $@); fi 64 64 65 65 $(PROGRAM) $(LIBS) $(EXTRAS): 66 if [ -d "$@" ]; then (cd $@ && make); fi66 if [ -d "$@" ]; then (cd $@ && $(MAKE)); fi 67 67 68 68 %.install: 69 if [ -d "$*" ]; then make$*; fi70 if [ -d "$*" ]; then (cd $* && makeinstall); fi69 if [ -d "$*" ]; then $(MAKE) $*; fi 70 if [ -d "$*" ]; then (cd $* && $(MAKE) install); fi 71 71 72 72 %.clean: 73 if [ -d "$*" ]; then (cd $* && makeclean); fi73 if [ -d "$*" ]; then (cd $* && $(MAKE) clean); fi 74 74 75 75 %.dist: 76 if [ -d "$*" ]; then (cd $* && makedist); fi76 if [ -d "$*" ]; then (cd $* && $(MAKE) dist); fi 77 77 78 78 %.uninstall: 79 if [ -d "$*" ]; then (cd $* && makeuninstall); fi79 if [ -d "$*" ]; then (cd $* && $(MAKE) uninstall); fi 80 80 81 81 .PHONY: $(PROGRAM) $(LIBS) pantasks_server pantasks_client -
branches/czw_branch/20110406/Ohana/src/opihi/cmd.data/Makefile
r29938 r31606 141 141 $(SRC)/vpop.$(ARCH).o \ 142 142 $(SRC)/vroll.$(ARCH).o \ 143 $(SRC)/vshift.$(ARCH).o \ 143 144 $(SRC)/vsmooth.$(ARCH).o \ 144 145 $(SRC)/vstats.$(ARCH).o \ -
branches/czw_branch/20110406/Ohana/src/opihi/cmd.data/gridify.c
r20936 r31606 4 4 5 5 int i, Nx, Ny, Xb, Yb, Normalize, N; 6 float Xmin, Xmax, dX, Ymin, Ymax, dY ;6 float Xmin, Xmax, dX, Ymin, Ymax, dY, initValue; 7 7 float *buf, *val; 8 8 int *Nval; … … 15 15 remove_argument (N, &argc, argv); 16 16 Normalize = FALSE; 17 } 18 19 initValue = 0.0; 20 if ((N = get_argument (argc, argv, "-init-value"))) { 21 remove_argument (N, &argc, argv); 22 initValue = atof(argv[N]); 23 remove_argument (N, &argc, argv); 17 24 } 18 25 … … 69 76 buf = (float *) bf[0].matrix.buffer; 70 77 for (i = 0; i < Nx*Ny; i++) { 78 buf[i] = initValue; 71 79 if (Normalize) { 72 80 if (Nval[i] == 0) { 73 buf[i] = 0;74 81 continue; 75 82 } -
branches/czw_branch/20110406/Ohana/src/opihi/cmd.data/init.c
r29938 r31606 130 130 int vstats PROTO((int, char **)); 131 131 int vroll PROTO((int, char **)); 132 int vshift PROTO((int, char **)); 132 133 int vpop PROTO((int, char **)); 133 134 int vsmooth PROTO((int, char **)); … … 274 275 {1, "vmaxwell", vmaxwell, "fit a Maxwellian to a vector"}, 275 276 {1, "vpop", vpop, "remove first element of a vector"}, 276 {1, "vroll", vroll, "roll vector elements"}, 277 {1, "vroll", vroll, "roll vector elements by 1 entry"}, 278 {1, "vshift", vshift, "shift vector elements by arbitrary amount"}, 277 279 {1, "vsmooth", vsmooth, "Gaussian smooth of a vector"}, 278 280 {1, "vstats", vstats, "statistics on a vector"}, -
branches/czw_branch/20110406/Ohana/src/opihi/dvo/Makefile
r27594 r31606 80 80 $(SRC)/mextract.$(ARCH).o \ 81 81 $(SRC)/mmextract.$(ARCH).o \ 82 $(SRC)/objectcoverage.$(ARCH).o \ 82 83 $(SRC)/photcodes.$(ARCH).o \ 83 84 $(SRC)/pmeasure.$(ARCH).o \ -
branches/czw_branch/20110406/Ohana/src/opihi/dvo/avextract.c
r30612 r31606 5 5 off_t i, j, n, m; 6 6 int N, Npts, NPTS, last, next, state, Nfields, Nreturn, Ncstack, Nstack; 7 int Nsecfilt, mode, VERBOSE ;7 int Nsecfilt, mode, VERBOSE, needMeasures; 8 8 char **cstack, name[1024]; 9 9 void *Signal; … … 101 101 } 102 102 103 // check the requested fields : are all average/secfilt entries, or do we need measures? 104 needMeasures = FALSE; 105 for (i = 0; !needMeasures && (i < Nfields); i++) { 106 if (fields[i].magMode == MAG_NONE) continue; 107 if (fields[i].photcode == NULL) continue; // assert this? 108 if (fields[i].photcode[0].type == PHOT_REF) needMeasures = TRUE; 109 if (fields[i].photcode[0].type == PHOT_DEP) needMeasures = TRUE; 110 } 111 103 112 // grab data from all selected sky regions 104 113 Signal = signal (SIGINT, handle_interrupt); … … 107 116 /* lock, load, unlock catalog */ 108 117 catalog.filename = skylist[0].filename[i]; 109 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF; 118 catalog.catflags = LOAD_AVES | LOAD_SECF; 119 if (needMeasures) { 120 catalog.catflags |= LOAD_MEAS; 121 } 110 122 catalog.Nsecfilt = 0; 111 123 -
branches/czw_branch/20110406/Ohana/src/opihi/dvo/init.c
r27594 r31606 40 40 int lightcurve PROTO((int, char **)); 41 41 int mextract PROTO((int, char **)); 42 int mmextract PROTO((int, char **)); 42 int mmextract PROTO((int, char **)); 43 int objectcoverage PROTO((int, char **)); 43 44 int pcat PROTO((int, char **)); 44 45 int photcodes PROTO((int, char **)); … … 92 93 {1, "mextract", mextract, "extract measure data values"}, 93 94 {1, "mmextract", mmextract, "extract joined measurements"}, 95 {1, "objectcoverage", objectcoverage, "plot catalog boundaries"}, 94 96 {1, "pcat", skycat, "plot catalog boundaries"}, 95 97 {1, "photcodes", photcodes, "list photometry codes"}, -
branches/czw_branch/20110406/Ohana/src/photdbc/src/make_subcatalog.c
r30616 r31606 71 71 } 72 72 73 // if the input catalog is an old type, generate the catID entries: 74 if (catalog[0].catformat < DVO_FORMAT_PS1_V1) { 75 subcatalog[0].average[Naverage].catID = catalog[0].catID; 76 } 77 73 78 minMag = 32; 74 79 minSigma = 32; … … 127 132 subcatalog[0].measure[Nmeasure] = catalog[0].measure[offset]; 128 133 subcatalog[0].measure[Nmeasure].averef = Naverage; 134 135 // if the input catalog is an old type, generate the catID entries: 136 if (catalog[0].catformat < DVO_FORMAT_PS1_V1) { 137 subcatalog[0].measure[Nmeasure].catID = catalog[0].catID; 138 } 139 129 140 Nmeasure ++; 130 141 Nm ++; -
branches/czw_branch/20110406/Ohana/src/relastro/src/UpdateObjects.c
r31160 r31606 189 189 coords.crval1 = R[0]; 190 190 coords.crval2 = D[0]; 191 Tmean /= (float) N; 191 192 if (FIT_TARGET == TARGET_HIGH_SPEED) { 193 Tmean = 0.5*(Tmax - Tmin); 194 } else { 195 Tmean /= (float) N; 196 } 192 197 193 198 XVERB = FALSE && (catalog[i].measure[m].dM < 0.01) && (N == 6) && (mode == FIT_PM_ONLY); -
branches/czw_branch/20110406/Ohana/src/relastro/src/high_speed_catalogs.c
r28184 r31606 10 10 11 11 // load the current sky table (layout of all SkyRegions) 12 sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);12 sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, FALSE, SKY_DEPTH, VERBOSE); 13 13 SkyTableSetFilenames (sky, CATDIR, "cpt"); 14 14 … … 30 30 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 31 31 32 if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, " w")) {32 if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "r")) { 33 33 fprintf (stderr, "ERROR: failure reading catalog %s\n", catalog.filename); 34 34 exit (1); … … 43 43 high_speed_objects (skylist[0].regions[i], &catalog); 44 44 45 if (!UPDATE) { 46 dvo_catalog_unlock (&catalog); 47 dvo_catalog_free (&catalog); 48 continue; 49 } 50 51 save_catalogs (&catalog, 1); 45 dvo_catalog_unlock (&catalog); 46 dvo_catalog_free (&catalog); 52 47 } 53 48 -
branches/czw_branch/20110406/Ohana/src/relphot/include/relphot.h
r30616 r31606 11 11 unsigned int start; 12 12 unsigned int stop; 13 short photcode; 13 14 float Mcal; 14 15 float dMcal; … … 85 86 int RELPHOT_GRID_BINNING; 86 87 87 PhotCode *photcode; 88 int PhotNsec; 89 int PhotSec; 88 int *photseclist; 89 int Nphotcodes; 90 PhotCode **photcodes; 91 // int PhotSec; 92 // int PhotNsec; 90 93 91 94 PhotCode *refPhotcode; 95 96 int MaxDensityUse; 97 double MaxDensityValue; 92 98 93 99 int AreaSelect; … … 213 219 StatType statsMosaicX PROTO((Catalog *catalog)); 214 220 StatType statsMosaicdM PROTO((Catalog *catalog)); 215 StatType statsStarN PROTO((Catalog *catalog, int Ncatalog ));216 StatType statsStarS PROTO((Catalog *catalog, int Ncatalog ));217 StatType statsStarX PROTO((Catalog *catalog, int Ncatalog ));221 StatType statsStarN PROTO((Catalog *catalog, int Ncatalog, int Nsec, int seccode)); 222 StatType statsStarS PROTO((Catalog *catalog, int Ncatalog, int Nsec)); 223 StatType statsStarX PROTO((Catalog *catalog, int Ncatalog, int Nsec)); 218 224 void wcatalog PROTO((Catalog *catalog)); 219 225 void wimages PROTO((void)); … … 223 229 void relphot_usage (void); 224 230 void relphot_help (int argc, char **argv); 231 232 off_t getImageByID (off_t ID); 233 234 int rationalize_mosaics (); 235 int LimitDensityCatalog (Catalog *subcatalog, Catalog *catalog); 236 237 int populate_tiny_values (Catalog *catalog); 238 int free_tiny_values (Catalog *catalog); -
branches/czw_branch/20110406/Ohana/src/relphot/src/GridOps.c
r28241 r31606 348 348 // sums for each star which touches as cell on both bases. 349 349 350 int Nsecfilt = GetPhotcodeNsecfilt (); 351 int thisCode = photcodes[0][0].code; 352 int Nsec = GetPhotcodeNsec(thisCode); 353 350 354 for (i = 0; i < Ngrid; i++) { 351 355 … … 362 366 mx = mlist[i][j]; 363 367 c = clist[i][j]; 364 n = catalog[c].measure [mx].averef;368 n = catalog[c].measureT[mx].averef; 365 369 366 370 // if we have already visited this star, skip the stuff below … … 369 373 370 374 // skip stars marked as BAD 371 if (catalog[c]. average[n].flags & STAR_BAD) {375 if (catalog[c].secfilt[n*Nsecfilt+Nsec].flags & STAR_BAD) { 372 376 Nrel ++; 373 377 continue; … … 389 393 390 394 // skip measurements marked as BAD 391 if (catalog[c].measure [m].dbFlags & MEAS_BAD) {395 if (catalog[c].measureT[m].dbFlags & MEAS_BAD) { 392 396 Nbad ++; 393 397 continue; … … 410 414 // select the color- and airmass-corrected observed magnitude for this star 411 415 // XXX need to be able to turn off the color-correction until initial average mags are found 412 // Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n*PhotNsec]); 413 Msys = PhotCat (&catalog[c].measure[m]); 416 Msys = PhotCatTiny (&catalog[c].measureT[m]); 414 417 if (isnan(Msys)) { 415 418 Nsys++; … … 418 421 419 422 // mag-error for this measurement 420 Merr = MAX (catalog[c].measure [m].dM, MIN_ERROR);423 Merr = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 421 424 422 425 // Wsys = 1.0 / SQ(Merr); … … 528 531 if (!USE_GRID) return; 529 532 533 int Nsecfilt = GetPhotcodeNsecfilt (); 534 530 535 Nmax = Nlist[0]; 531 536 for (i = 0; i < Ngrid; i++) { … … 545 550 c = clist[i][j]; 546 551 547 if (catalog[c].measure [m].dbFlags & MEAS_BAD) {552 if (catalog[c].measureT[m].dbFlags & MEAS_BAD) { 548 553 Nbad ++; 549 554 continue; … … 565 570 } 566 571 567 n = catalog[c].measure [m].averef;568 Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n*PhotNsec]);572 n = catalog[c].measureT[m].averef; 573 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt]); 569 574 if (isnan(Msys)) { 570 575 Nsys++; … … 572 577 } 573 578 list[N] = Msys - Mrel - Mcal - Mmos; 574 dlist[N] = MAX (catalog[c].measure [m].dM, MIN_ERROR);579 dlist[N] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 575 580 N++; 576 581 } … … 613 618 if (!USE_GRID) return; 614 619 620 int Nsecfilt = GetPhotcodeNsecfilt (); 621 615 622 N = 0; 616 623 for (i = 0; i < Ngrid; i++) … … 630 637 c = clist[i][j]; 631 638 632 if (catalog[c].measure [m].dbFlags & MEAS_BAD) {639 if (catalog[c].measureT[m].dbFlags & MEAS_BAD) { 633 640 Narea ++; 634 641 continue; … … 641 648 if (isnan(Mrel)) continue; 642 649 643 n = catalog[c].measure [m].averef;644 Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n*PhotNsec]);650 n = catalog[c].measureT[m].averef; 651 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt]); 645 652 646 653 xlist[N] = Xmeas[c][m]; … … 704 711 gfits_create_matrix (&header, &matrix); 705 712 gfits_modify (&header, "NEXTEND", OFF_T_FMT, 1, Nimage + 3); 706 gfits_modify (&header, "FILTER", "%s", 1, photcode [0].name);713 gfits_modify (&header, "FILTER", "%s", 1, photcodes[0][0].name); // XXXX note that this expects a single photcode, enforced in initialize.d 707 714 gfits_modify_alt (&header, "COMMENT", "%S", 1, "Mosaic Photometry Grid Analysis"); 708 715 … … 727 734 theader.bitpix = -32; 728 735 gfits_create_Theader (&theader, "IMAGE"); 729 gfits_modify (&theader, "FILTER", "%s", 1, photcode [0].name);736 gfits_modify (&theader, "FILTER", "%s", 1, photcodes[0][0].name); 730 737 gfits_modify (&theader, "EXTNAME", "%s", 1, "MAG_OFFSET"); 731 738 gfits_create_matrix (&theader, &matrix); … … 742 749 /* save grid Nmeas values */ 743 750 gfits_modify (&theader, "EXTNAME", "%s", 1, "NMEAS"); 744 gfits_modify (&theader, "FILTER", "%s", 1, photcode [0].name);751 gfits_modify (&theader, "FILTER", "%s", 1, photcodes[0][0].name); 745 752 gfits_create_matrix (&theader, &matrix); 746 753 for (i = 0; i < gridX; i++) { … … 756 763 /* save grid sigma values */ 757 764 gfits_modify (&theader, "EXTNAME", "%s", 1, "SIGMA"); 758 gfits_modify (&theader, "FILTER", "%s", 1, photcode [0].name);765 gfits_modify (&theader, "FILTER", "%s", 1, photcodes[0][0].name); 759 766 gfits_create_matrix (&theader, &matrix); 760 767 for (i = 0; i < gridX; i++) { … … 776 783 777 784 gfits_modify (&theader, "EXTNAME", "%s", 1, camera.ccdname[N]); 778 gfits_modify (&theader, "FILTER", "%s", 1, photcode [0].name);785 gfits_modify (&theader, "FILTER", "%s", 1, photcodes[0][0].name); 779 786 gfits_modify (&theader, "NX", "%d", 1, camera.Nx); 780 787 gfits_modify (&theader, "NY", "%d", 1, camera.Ny); -
branches/czw_branch/20110406/Ohana/src/relphot/src/ImageOps.c
r30616 r31606 1 1 # include "relphot.h" 2 3 # define USE_IMAGE_ID 14 2 5 3 static off_t **bin; // link from catalog,measure to image … … 12 10 static off_t Nimage; // number of available images 13 11 14 // if we search by image ID, we sort (imageIDs, imageIdx) by imageIDs to get a sorted 15 // index 16 17 # if USE_IMAGE_ID 12 // to search by image ID, we sort (imageIDs, imageIdx) by imageIDs to get a sorted index 18 13 static off_t *imageIDs; // list of all image IDs 19 14 static off_t *imageIdx; // list of index for image IDs 20 # else21 static unsigned int *start;22 static unsigned int *stop;23 # endif24 15 25 16 Image *getimages (off_t *N) { … … 40 31 Nimage = N; 41 32 42 # if USE_IMAGE_ID43 33 ALLOCATE (imageIDs, off_t, Nimage); 44 34 ALLOCATE (imageIdx, off_t, Nimage); … … 49 39 } 50 40 llsortpair (imageIDs, imageIdx, Nimage); 51 # else52 ALLOCATE (start, unsigned, Nimage);53 ALLOCATE (stop, unsigned, Nimage);54 55 for (i = 0; i < Nimage; i++) {56 start[i] = image[i].tzero - MAX(0.01*image[i].trate*image[i].NY, 1);57 stop[i] = image[i].tzero + MAX(1.01*image[i].trate*image[i].NY, 1);58 }59 # endif60 41 } 61 42 … … 65 46 // use bisection to find the specified image ID 66 47 67 # if USE_IMAGE_ID68 48 off_t Nlo, Nhi, N; 69 49 … … 82 62 return (imageIdx[N]); 83 63 } 84 # endif85 64 86 65 return (-1); … … 128 107 } 129 108 130 /* select all image equivalent to the current photcode*/109 /* select all image equivalent to the active photcode set */ 131 110 void findImages (Catalog *catalog, int Ncatalog) { 132 111 133 112 off_t j; 134 int i, ecode; 135 136 for (i = 0; i < Ncatalog; i++) { 113 int i, ecode, Ns, found; 114 115 int Nmatch = 0; 116 for (i = 0; i < Ncatalog; i++) { 137 117 for (j = 0; j < catalog[i].Nmeasure; j++) { 138 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[j].photcode); 139 if (photcode[0].code != ecode) continue; 118 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[j].photcode); 119 found = FALSE; 120 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { 121 if (ecode == photcodes[Ns][0].code) found = TRUE; 122 } 123 if (!found) continue; 140 124 matchImage (catalog, j, i); 141 } 142 } 143 } 144 145 int findCCD (off_t idx, off_t meas, int cat, Measure *measure) { 146 147 int ccdnum; 125 Nmatch ++; 126 } 127 } 128 // fprintf (stderr, "matched %d detections to images\n", Nmatch); 129 } 130 131 int findCCD (off_t idx, off_t meas, int cat, MeasureTiny *measure) { 132 133 int ccdnum, found, Ns, ecode; 148 134 double X, Y; 149 135 char *pname, *filter, *p, base[256]; … … 151 137 /* identify the ccd on the basis of the photcode name */ 152 138 pname = GetPhotcodeNamebyCode (image[idx].photcode); 153 filter = photcode[0].name; 139 140 // XXX this seems quite terrible... 141 ecode = GetPhotcodeEquivCodebyCode (measure[0].photcode); 142 found = FALSE; 143 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { 144 if (ecode == photcodes[Ns][0].code) found = TRUE; 145 } 146 if (!found) return (FALSE); 147 148 filter = photcodes[Ns][0].name; 154 149 sprintf (base, "%s.%s.", MOSAICNAME, filter); 155 150 if (strncmp (pname, base, strlen (base))) return (FALSE); … … 170 165 171 166 // old code to add this measurement to the grid cell for this chip 172 // ave = measure [0].averef;173 // ra = catalog[cat].average [ave].R - measure[0].dR / 3600.0;174 // dec = catalog[cat].average [ave].D - measure[0].dD / 3600.0;167 // ave = measureT[0].averef; 168 // ra = catalog[cat].averageT[ave].R - measureT[0].dR / 3600.0; 169 // dec = catalog[cat].averageT[ave].D - measureT[0].dD / 3600.0; 175 170 // RD_to_XY (&X, &Y, ra, dec, &image[i].coords); 176 171 … … 183 178 } 184 179 185 # if USE_IMAGE_ID186 180 void matchImage (Catalog *catalog, off_t meas, int cat) { 187 181 188 182 off_t idx, ID; 189 183 int status; 190 Measure *measure;184 MeasureTiny *measure; 191 185 192 measure = &catalog[cat].measure [meas];186 measure = &catalog[cat].measureT[meas]; 193 187 194 188 ID = measure[0].imageID; … … 226 220 } 227 221 228 # else229 // this is the time-based match230 void matchImage (Catalog *catalog, off_t meas, int cat) {231 232 off_t i;233 int status;234 Measure *measure;235 236 measure = &catalog[cat].measure[meas];237 for (i = 0; i < Nimage; i++) {238 if (image[0].photcode == -1) continue;239 if (measure[0].photcode != image[i].photcode) continue;240 if (measure[0].t < start[i]) continue;241 if (measure[0].t > stop[i]) continue;242 243 if (USE_GRID) {244 status = findCCD(i, meas, cat);245 if (!status) continue;246 }247 248 // index for (catalog, measure) -> image249 bin[cat][meas] = i;250 251 // index for image, Nentry -> catalog252 clist[i][Nlist[i]] = cat;253 254 // index for image, Nentry -> measure255 mlist[i][Nlist[i]] = meas;256 Nlist[i] ++;257 258 if (Nlist[i] == NLIST[i]) {259 NLIST[i] += 100;260 REALLOCATE (clist[i], off_t, NLIST[i]);261 REALLOCATE (mlist[i], off_t, NLIST[i]);262 }263 return;264 }265 /* fprintf (stderr, "can't find source image for this measurement: %d (%d)\n", measure[0].t, measure[0].photcode); */266 }267 # endif268 269 222 off_t getImageEntry (off_t meas, int cat) { 270 223 … … 307 260 308 261 if (FREEZE_IMAGES) return; 262 263 int Nsecfilt = GetPhotcodeNsecfilt (); 309 264 310 265 if (PoorImages) { … … 339 294 c = clist[i][j]; 340 295 341 if (catalog[c].measure [m].dbFlags & MEAS_BAD) {296 if (catalog[c].measureT[m].dbFlags & MEAS_BAD) { 342 297 Nbad++; 343 298 continue; … … 359 314 } 360 315 361 n = catalog[c].measure [m].averef;362 Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n*PhotNsec]);316 n = catalog[c].measureT[m].averef; 317 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt]); 363 318 if (isnan(Msys)) { 364 319 Nsys++; … … 366 321 } 367 322 list[N] = Msys - Mrel - Mmos - Mgrid; 368 dlist[N] = MAX (catalog[c].measure [m].dM, MIN_ERROR);369 if (catalog[c].measure [m].dM < IMFIT_SYS_SIGMA_LIM) {323 dlist[N] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 324 if (catalog[c].measureT[m].dM < IMFIT_SYS_SIGMA_LIM) { 370 325 McalBright += list[N]; 371 326 McalBright2 += SQ(list[N]); … … 632 587 return (stats); 633 588 } 634 -
branches/czw_branch/20110406/Ohana/src/relphot/src/MosaicOps.c
r30616 r31606 9 9 static off_t **imlist; /* mosaic -> image[] */ 10 10 static off_t **bin; /* catalog, measure -> mosaic */ 11 12 // list of mosaics associated with an image 13 static off_t *mosimage; 11 14 12 15 // list of mosaic associated with each image … … 33 36 ALLOCATE (NIMLIST, off_t, NMOSAIC); 34 37 38 ALLOCATE (mosimage, off_t, Nimage); // mosaic to which image belongs 39 35 40 /* a 'mosaic' in relphot is (unlike relastro) a virtual concept: there is no 36 41 * entry in the image table that represents this mosaic. Instead, it is an … … 40 45 /* generate list of unique mosaics */ 41 46 for (i = 0; i < Nimage; i++) { 47 mosimage[i] = -1; 42 48 43 49 /* select valid mosaic images by photcode */ … … 56 62 if (start > mosaic[j].stop) continue; 57 63 found = TRUE; 64 65 // add reference from image to mosaic 66 mosimage[i] = j; 58 67 59 68 /* add image to mosaic image list */ … … 77 86 mosaic[Nmosaic].flags = image[i].flags; 78 87 mosaic[Nmosaic].secz = image[i].secz; 88 mosaic[Nmosaic].photcode = GetPhotcodeEquivCodebyCode (image[i].photcode); 79 89 80 90 /* add image to mosaic image list */ … … 84 94 imlist[Nmosaic][0] = i; 85 95 96 // add reference from image to mosaic 97 mosimage[i] = Nmosaic; 98 86 99 Nmosaic ++; 87 100 if (Nmosaic == NMOSAIC) { … … 250 263 int findMosaics (Catalog *catalog, int Ncatalog) { 251 264 252 int i, ecode ;265 int i, ecode, found, Ns; 253 266 off_t j; 254 267 255 268 if (!MOSAIC_ZEROPT) return (FALSE); 256 269 270 int Nmatch = 0; 257 271 for (i = 0; i < Ncatalog; i++) { 258 272 for (j = 0; j < catalog[i].Nmeasure; j++) { 259 273 if (TimeSelect) { 260 if (catalog[i].measure[j].t < TSTART) continue; 261 if (catalog[i].measure[j].t > TSTOP) continue; 262 } 263 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[j].photcode); 264 if (photcode[0].code != ecode) continue; 274 if (catalog[i].measureT[j].t < TSTART) continue; 275 if (catalog[i].measureT[j].t > TSTOP) continue; 276 } 277 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[j].photcode); 278 found = FALSE; 279 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { 280 if (ecode == photcodes[Ns][0].code) found = TRUE; 281 } 282 if (!found) continue; 265 283 matchMosaics (catalog, j, i); 266 } 267 } 284 Nmatch ++; 285 } 286 } 287 // fprintf (stderr, "matched %d detections to mosaics\n", Nmatch); 268 288 return (TRUE); 269 289 } … … 271 291 void matchMosaics (Catalog *catalog, off_t meas, int cat) { 272 292 273 int i; 274 275 for (i = 0; i < Nmosaic; i++) { 276 if (catalog[cat].measure[meas].t < mosaic[i].start) continue; 277 if (catalog[cat].measure[meas].t > mosaic[i].stop) continue; 293 off_t idx, ID, mosID; 294 MeasureTiny *measure; 295 296 measure = &catalog[cat].measureT[meas]; 297 298 ID = measure[0].imageID; 299 idx = getImageByID (ID); 300 if (idx == -1) { 301 if (VERBOSE2) fprintf (stderr, "missed measurement "OFF_T_FMT", %d\n", meas, cat); 302 return; 303 } 304 305 mosID = mosimage[idx]; 306 if (mosID < 0) { 307 Image *image = getimage(idx); 308 fprintf (stderr, "unmatched image %s\n", image[0].name); 309 return; 310 } 311 312 // test to check we got the right match: 313 { 314 Image *image = getimage(idx); 315 unsigned int imageStart = image[0].tzero - MAX(0.01*image[0].trate*image[0].NY, 1); 316 if (imageStart != mosaic[mosID].start) { 317 fprintf (stderr, "error in image to mosaic match\n"); 318 abort(); 319 } 320 } 321 322 bin[cat][meas] = mosID; 323 324 clist[mosID][Nlist[mosID]] = cat; 325 mlist[mosID][Nlist[mosID]] = meas; 326 Nlist[mosID] ++; 278 327 279 # ifdef GRID_V1 280 if (USE_GRID) { 281 ave = catalog[cat].measure[meas].averef; 282 ra = catalog[cat].average[ave].R - catalog[cat].measure[meas].dR / 3600.0; 283 dec = catalog[cat].average[ave].D - catalog[cat].measure[meas].dD / 3600.0; 284 285 /* X,Y always positive-definite in range 0,0 - dX, dY */ 286 RD_to_XY (&X, &Y, ra, dec, &mosaic[i].coords); 287 setGridMeasure (meas, cat, X, Y); 288 } 289 # endif 290 291 bin[cat][meas] = i; 292 293 clist[i][Nlist[i]] = cat; 294 mlist[i][Nlist[i]] = meas; 295 Nlist[i] ++; 296 297 if (Nlist[i] == NLIST[i]) { 298 NLIST[i] += 100; 299 REALLOCATE (clist[i], int, NLIST[i]); 300 REALLOCATE (mlist[i], off_t, NLIST[i]); 301 } 302 return; 303 } 304 fprintf (stderr, "missed measurement\n"); 328 if (Nlist[mosID] == NLIST[mosID]) { 329 NLIST[mosID] += 100; 330 REALLOCATE (clist[mosID], int, NLIST[mosID]); 331 REALLOCATE (mlist[mosID], off_t, NLIST[mosID]); 332 } 305 333 return; 306 334 } … … 324 352 325 353 off_t i, j, m, c, N, Nmax; 326 int n, mark, bad, Nfew, Nbad, Ncal, Nrel, Ngrid, Nsys ;354 int n, mark, bad, Nfew, Nbad, Ncal, Nrel, Ngrid, Nsys, Nsecfilt; 327 355 float Msys, Mrel, Mcal, Mgrid; 328 356 double *list, *dlist, *Mlist, *dMlist; … … 334 362 335 363 image = getimages (&N); 364 365 Nsecfilt = GetPhotcodeNsecfilt (); 336 366 337 367 if (PoorImages) { … … 364 394 c = clist[i][j]; 365 395 366 if (catalog[c].measure [m].dbFlags & MEAS_BAD) {396 if (catalog[c].measureT[m].dbFlags & MEAS_BAD) { 367 397 Nbad ++; 368 398 continue; … … 384 414 } 385 415 386 n = catalog[c].measure [m].averef;387 Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n*PhotNsec]);416 n = catalog[c].measureT[m].averef; 417 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt]); 388 418 if (isnan(Msys)) { 389 419 Nsys++; … … 391 421 } 392 422 list[N] = Msys - Mrel - Mcal - Mgrid; 393 dlist[N] = MAX (catalog[c].measure [m].dM, MIN_ERROR);423 dlist[N] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 394 424 Mlist[N] = Msys; 395 425 dMlist[N] = list[N]; … … 433 463 } 434 464 465 // When we rationalize the images/mosaics, we are driving the negative cloud images back 466 // to 0.0. At the same time, we make a guess to the effective impact on all other images, 467 // driven by the coupling of common stars. 468 int rationalize_mosaics (Catalog *catalog, int Ncatalog) { 469 470 double *imageOffset, **starOffset; 471 int **starNcount, *seclist; 472 int **Slist, *NSlist, *NSLIST; 473 int i, j, k, m, nMos, Ns, found; 474 475 off_t Nimage; 476 Image *image; 477 478 // set a test value for now 479 float CLOUD_TOLERANCE = 0.025; 480 481 if (!MOSAIC_ZEROPT) return (FALSE); 482 if (FREEZE_MOSAICS) return (FALSE); 483 484 image = getimages (&Nimage); 485 486 ALLOCATE (imageOffset, double, Nmosaic); 487 488 ALLOCATE ( Slist, int *, Nmosaic); // array of calibrated star indexes on this mosaic 489 ALLOCATE (NSlist, int, Nmosaic); // number of stars on mosaic 490 ALLOCATE (NSLIST, int, Nmosaic); // number of Slist entries allocated 491 memset (Slist, 0, Nmosaic*sizeof(int *)); 492 493 // find the images / mosaics with negative clouds and save their offset 494 for (i = 0; i < Nmosaic; i++) { 495 496 NSlist[i] = 0; 497 NSLIST[i] = 100; 498 ALLOCATE (Slist[i], int, NSLIST[i]); 499 500 imageOffset[i] = 0.0; 501 502 if (VERBOSE2 && (fabs(mosaic[i].Mcal) < CLOUD_TOLERANCE)) { 503 fprintf (stderr, "cloud-free: %s : %f\n", image[imlist[i][0]].name, mosaic[i].Mcal); 504 } 505 if (VERBOSE2 && (mosaic[i].Mcal < -CLOUD_TOLERANCE)) { 506 imageOffset[i] = -mosaic[i].Mcal; 507 // NOTE the negative sign: down below, we are going to add in the negative of Mcal 508 // to this image, and the propagated mean values for other images 509 fprintf (stderr, "anti-clouds: %s : %f\n", image[imlist[i][0]].name, mosaic[i].Mcal); 510 } 511 if (VERBOSE2 && (mosaic[i].Mcal > CLOUD_TOLERANCE)) { 512 fprintf (stderr, "cloudy : %s : %f\n", image[imlist[i][0]].name, mosaic[i].Mcal); 513 } 514 } 515 516 int Nsecfilt = GetPhotcodeNsecfilt (); 517 ALLOCATE (seclist, int, Nphotcodes); 518 for (Ns = 0; Ns < Nphotcodes; Ns ++) { 519 int thisCode = photcodes[Ns][0].code; 520 seclist[Ns] = GetPhotcodeNsec(thisCode); 521 } 522 523 // allocate an array for star offsets 524 int Nstars = 0; 525 int NSTARS = 1000; 526 ALLOCATE (starOffset, double *, NSTARS); 527 ALLOCATE (starNcount, int *, NSTARS); 528 memset (starOffset, 0, NSTARS*sizeof(double *)); 529 memset (starNcount, 0, NSTARS*sizeof(int *)); 530 531 // find the mean offset for each star 532 for (i = 0; i < Ncatalog; i++) { 533 for (j = 0; j < catalog[i].Naverage; j++) { 534 ALLOCATE (starOffset[Nstars], double, Nphotcodes); 535 ALLOCATE (starNcount[Nstars], int, Nphotcodes); 536 memset (starOffset[Nstars], 0, Nphotcodes*sizeof(double)); 537 memset (starNcount[Nstars], 0, Nphotcodes*sizeof(int)); 538 539 m = catalog[i].averageT[j].measureOffset; 540 541 // determine the mosaic for each measurement 542 for (k = 0; k < catalog[i].averageT[j].Nmeasure; k++, m++) { 543 544 // skip unused measurements 545 if (catalog[i].measureT[m].dbFlags & MEAS_BAD) continue; 546 547 // skip unused measurements 548 int Nsec; 549 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[m].photcode); 550 found = FALSE; 551 for (Ns = 0; !found && (Ns < Nphotcodes); Ns ++) { 552 if (ecode == photcodes[Ns][0].code) { 553 found = TRUE; 554 break; 555 } 556 } 557 if (!found) continue; 558 Nsec = seclist[Ns]; 559 560 // bad stars for this secfilt 561 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue; 562 563 // skip REF measurements (not tied to an image) 564 if (getImageEntry (m, i) < 0) continue; 565 566 // find the source of this measurement (skip unassigned measurements) 567 nMos = bin[i][m]; 568 if (nMos == -1) continue; 569 570 if (mosaic[nMos].photcode != ecode) { 571 fprintf (stderr, "*"); 572 } 573 574 assert (Ns >= 0); 575 assert (Ns < Nphotcodes); 576 577 // accumulate the offsets from the negative cloud images (others have 0.0 value) 578 starOffset[Nstars][Ns] += imageOffset[nMos]; 579 starNcount[Nstars][Ns] ++; 580 581 // record the mosaic->star reference 582 Slist[nMos][NSlist[nMos]] = Nstars; 583 NSlist[nMos] ++; 584 if (NSlist[nMos] == NSLIST[nMos]) { 585 NSLIST[nMos] += 100; 586 REALLOCATE (Slist[nMos], int, NSLIST[nMos]); 587 } 588 } 589 Nstars ++; 590 if (Nstars == NSTARS) { 591 NSTARS += 1000; 592 REALLOCATE (starOffset, double *, NSTARS); 593 REALLOCATE (starNcount, int *, NSTARS); 594 memset (&starOffset[NSTARS-1000], 0, 1000*sizeof(double *)); 595 memset (&starNcount[NSTARS-1000], 0, 1000*sizeof(int *)); 596 } 597 } 598 } 599 600 // find the mean offset of the images without negative clouds 601 for (i = 0; i < Nmosaic; i++) { 602 603 found = FALSE; 604 for (Ns = 0; !found && (Ns < Nphotcodes); Ns ++) { 605 if (mosaic[i].photcode == photcodes[Ns][0].code) { 606 found = TRUE; 607 break; 608 } 609 } 610 if (!found) { 611 fprintf (stderr, "invalid photcode for mosaic?\n"); 612 abort(); 613 } 614 615 // a negative cloud image (cloud: Mcal > 0; anti-clouds: Mcal < 0; imageOffset = -Mcal) 616 if (imageOffset[i] > 0.0) continue; 617 618 // we need to actually have cross-references to count 619 if (NSlist[i] < 2) continue; 620 621 float dM = 0.0; 622 for (j = 0; j < NSlist[i]; j++) { 623 Nstars = Slist[i][j]; 624 if (starNcount[Nstars][Ns] > 1) { 625 dM += (starOffset[Nstars][Ns] / starNcount[Nstars][Ns]); 626 } 627 } 628 imageOffset[i] = dM / NSlist[i]; 629 // fprintf (stderr, "adjust image: %s : (%f %d) : %f\n", image[imlist[i][0]].name, dM, NSlist[i], imageOffset[i]); 630 } 631 632 // for (i = 0; i < Nmosaic; i++) { 633 // fprintf (stderr, "correction: %s : %f\n", image[imlist[i][0]].name, imageOffset[i]); 634 // } 635 636 // apply all offset values to the mosaics 637 // find the images / mosaics with negative clouds and save their offset 638 for (i = 0; i < Nmosaic; i++) { 639 mosaic[i].Mcal += imageOffset[i]; 640 } 641 642 for (i = 0; i < Nstars; i++) { 643 free (starOffset[i]); 644 free (starNcount[i]); 645 } 646 free (starOffset); 647 free (starNcount); 648 649 for (i = 0; i < Nmosaic; i++){ 650 free (Slist[i]); 651 } 652 free (NSlist); 653 free (NSLIST); 654 free (imageOffset); 655 free (seclist); 656 return (TRUE); 657 } 658 435 659 StatType statsMosaicM (Catalog *catalog) { 436 660 … … 524 748 n++; 525 749 } 526 fprintf (stderr, "Nmosaic: "OFF_T_FMT", n: "OFF_T_FMT"\n", Nmosaic, n);750 // fprintf (stderr, "Nmosaic: "OFF_T_FMT", n: "OFF_T_FMT"\n", Nmosaic, n); 527 751 528 752 liststats (list, dlist, n, &stats); … … 563 787 void clean_mosaics () { 564 788 565 off_t i, N, mark, Nmark ;789 off_t i, N, mark, Nmark, Nscatter, Noffset; 566 790 double *mlist, *slist, *dlist; 567 791 double MaxOffset, MedOffset, MaxScatter; … … 592 816 fprintf (stderr, "Mrel: %f, dMrel: %f, Max Scatter: %f, Max Offset: %f\n", MedOffset, stats.median, MaxScatter, MaxOffset); 593 817 594 Nmark = 0;818 Nmark = Nscatter = Noffset = 0; 595 819 for (i = 0; i < Nmosaic; i++) { 596 820 mark = FALSE; 597 mark = (mosaic[i].dMcal > MaxScatter) || (fabs(mosaic[i].Mcal - MedOffset) > MaxOffset); 821 if (mosaic[i].dMcal > MaxScatter) { 822 mark = TRUE; 823 Nscatter ++; 824 } 825 if (fabs(mosaic[i].Mcal - MedOffset) > MaxOffset) { 826 mark = TRUE; 827 Noffset ++; 828 } 598 829 if (mark) { 599 830 Nmark ++; … … 604 835 } 605 836 606 fprintf (stderr, OFF_T_FMT" mosaics marked poor \n", Nmark);837 fprintf (stderr, OFF_T_FMT" mosaics marked poor ("OFF_T_FMT" scatter, "OFF_T_FMT" offset)\n", Nmark, Nscatter, Noffset); 607 838 initstats (STATMODE); 608 839 free (mlist); … … 640 871 c = clist[i][j]; 641 872 642 if (catalog[c].measure [m].dbFlags & (ID_MEAS_AREA | ID_MEAS_NOCAL)) continue;643 644 ave = catalog[c].measure [m].averef;645 xlist[N] = catalog[c].average [ave].R - catalog[c].measure[m].dR / 3600.0;646 ylist[N] = catalog[c].average [ave].D - catalog[c].measure[m].dD / 3600.0;873 if (catalog[c].measureT[m].dbFlags & (ID_MEAS_AREA | ID_MEAS_NOCAL)) continue; 874 875 ave = catalog[c].measureT[m].averef; 876 xlist[N] = catalog[c].averageT[ave].R - catalog[c].measureT[m].dR / 3600.0; 877 ylist[N] = catalog[c].averageT[ave].D - catalog[c].measureT[m].dD / 3600.0; 647 878 N++; 648 879 } -
branches/czw_branch/20110406/Ohana/src/relphot/src/StarOps.c
r29001 r31606 5 5 static double *dlist; 6 6 7 // When we rationalize the images/mosaics, we are driving the negative cloud images back 8 // to 0.0. At the same time, we make a guess to the effective impact on all other images, 9 // driven by the coupling of common stars. This array carries the impact of those offsets 10 // on each star 11 static double *Moffset; 12 7 13 void initMrel (Catalog *catalog, int Ncatalog) { 8 14 … … 12 18 for (i = 0; i < Ncatalog; i++) { 13 19 for (j = 0; j < catalog[i].Naverage; j++) { 14 Nmax = MAX (Nmax, catalog[i].average[j].Nmeasure); 15 } 16 } 17 18 ALLOCATE (list, double, MAX (1, Nmax)); 19 ALLOCATE (dlist, double, MAX (1, Nmax)); 20 Nmax = MAX (Nmax, catalog[i].averageT[j].Nmeasure); 21 } 22 } 23 24 ALLOCATE (list, double, MAX (1, Nmax)); 25 ALLOCATE (dlist, double, MAX (1, Nmax)); 26 ALLOCATE (Moffset, double, MAX (1, Nmax)); 20 27 } 21 28 22 29 float getMrel (Catalog *catalog, off_t meas, int cat) { 23 30 31 int Nsec, Nsecfilt, photcode; 24 32 int ave; 25 33 float value; 26 34 27 ave = catalog[cat].measure[meas].averef; 28 if (catalog[cat].average[ave].flags & STAR_BAD) return (NAN); 35 ave = catalog[cat].measureT[meas].averef; 36 photcode = catalog[cat].measureT[meas].photcode; 37 38 int ecode = GetPhotcodeEquivCodebyCode (photcode); 39 Nsec = GetPhotcodeNsec(ecode); 40 Nsecfilt = GetPhotcodeNsecfilt (); 41 42 // is this star OK? 43 if (catalog[cat].secfilt[Nsecfilt*ave+Nsec].flags & STAR_BAD) return (NAN); 29 44 30 value = catalog[cat].secfilt[ PhotNsec*ave+PhotSec].M;45 value = catalog[cat].secfilt[Nsecfilt*ave+Nsec].M; 31 46 return (value); 32 47 } … … 39 54 StatType stats; 40 55 56 int Nsecfilt = GetPhotcodeNsecfilt (); 41 57 Nfew = Nsys = Nbad = Ncal = Nmos = Ngrid = 0; 42 58 … … 44 60 for (j = 0; j < catalog[i].Naverage; j++) { 45 61 46 /* calculate the average value for a single star */ 47 if (catalog[i].average[j].flags & STAR_BAD) continue; 48 m = catalog[i].average[j].measureOffset; 49 50 N = 0; 51 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 52 if (catalog[i].measure[m].dbFlags & MEAS_BAD) { 53 Nbad ++; 54 continue; 55 } 56 // XXX allow REF stars (no Image Entry) to be included in the calculation this 57 // should be optionally set, and should allow for REF stars to be downweighted by 58 // more than their reported errors. how such info is carried is unclear... 59 if (getImageEntry (m, i) < 0) { 60 Mcal = Mmos = Mgrid = 0; 61 } else { 62 Mcal = getMcal (m, i); 63 if (isnan(Mcal)) { 64 Ncal ++; 62 int Ns; 63 for (Ns = 0; Ns < Nphotcodes; Ns++) { 64 65 int thisCode = photcodes[Ns][0].code; 66 int Nsec = GetPhotcodeNsec(thisCode); 67 68 /* calculate the average value for a single star */ 69 70 // skip bad stars 71 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue; 72 m = catalog[i].averageT[j].measureOffset; 73 74 N = 0; 75 for (k = 0; k < catalog[i].averageT[j].Nmeasure; k++, m++) { 76 // skip measurements that do not match the current photcode 77 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[m].photcode); 78 if (ecode != thisCode) { continue; } 79 80 if (catalog[i].measureT[m].dbFlags & MEAS_BAD) { 81 Nbad ++; 65 82 continue; 66 83 } 67 Mmos = getMmos (m, i); 68 if (isnan(Mmos)) { 69 Nmos ++; 84 // XXX allow REF stars (no Image Entry) to be included in the calculation this 85 // should be optionally set, and should allow for REF stars to be downweighted by 86 // more than their reported errors. how such info is carried is unclear... 87 if (getImageEntry (m, i) < 0) { 88 Mcal = Mmos = Mgrid = 0; 89 } else { 90 Mcal = getMcal (m, i); 91 if (isnan(Mcal)) { 92 Ncal ++; 93 continue; 94 } 95 Mmos = getMmos (m, i); 96 if (isnan(Mmos)) { 97 Nmos ++; 98 continue; 99 } 100 Mgrid = getMgrid (m, i); 101 if (isnan(Mgrid)) { 102 Ngrid++; 103 continue; 104 } 105 } 106 107 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt]); 108 if (isnan(Msys)) { 109 Nsys++; 70 110 continue; 71 111 } 72 Mgrid = getMgrid (m, i); 73 if (isnan(Mgrid)) { 74 Ngrid++; 75 continue; 112 list[N] = Msys - Mcal - Mmos - Mgrid; 113 dlist[N] = MAX (catalog[i].measureT[m].dM, MIN_ERROR); 114 115 // tie down reference photometry if the -refcode (code) option is selected 116 if (refPhotcode) { 117 if (GetPhotcodeEquivCodebyCode(catalog[i].measureT[m].photcode) == refPhotcode[0].equiv) { 118 // increase the weight by a factor of 100: 119 dlist[N] = 0.01*catalog[i].measureT[m].dM; 120 } 76 121 } 77 } 78 79 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]); 80 if (isnan(Msys)) { 81 Nsys++; 82 continue; 83 } 84 list[N] = Msys - Mcal - Mmos - Mgrid; 85 dlist[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR); 86 87 if (refPhotcode) { 88 if (GetPhotcodeEquivCodebyCode(catalog[i].measure[m].photcode) == refPhotcode[0].equiv) { 89 // increase the weight by a factor of 100: 90 dlist[N] = 0.01*catalog[i].measure[m].dM; 91 } 92 } 93 N++; 94 } 95 96 // when performing the grid analysis, STAR_TOOFEW will be set to 1; 97 98 if (N <= STAR_TOOFEW) { /* too few measurements */ 99 catalog[i].average[j].flags |= ID_STAR_FEW; 100 Nfew ++; 101 } else { 102 catalog[i].average[j].flags &= ~ID_STAR_FEW; 103 } 104 105 liststats (list, dlist, N, &stats); 106 107 catalog[i].secfilt[PhotNsec*j+PhotSec].M = stats.mean; 108 catalog[i].secfilt[PhotNsec*j+PhotSec].dM = stats.sigma; 109 catalog[i].secfilt[PhotNsec*j+PhotSec].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NAN_S_SHORT; 122 N++; 123 } 124 125 // when performing the grid analysis, STAR_TOOFEW will be set to 1; 126 if (N <= STAR_TOOFEW) { /* too few measurements */ 127 catalog[i].secfilt[Nsecfilt*j+Nsec].flags |= ID_STAR_FEW; 128 Nfew ++; 129 } else { 130 catalog[i].secfilt[Nsecfilt*j+Nsec].flags &= ~ID_STAR_FEW; 131 } 132 133 liststats (list, dlist, N, &stats); 134 135 catalog[i].secfilt[Nsecfilt*j+Nsec].M = stats.mean; 136 catalog[i].secfilt[Nsecfilt*j+Nsec].dM = stats.sigma; 137 catalog[i].secfilt[Nsecfilt*j+Nsec].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NAN_S_SHORT; 138 } 110 139 } 111 140 } … … 122 151 double *list, *dlist; 123 152 StatType stats; 153 int Nsec, Nsecfilt, ecode; 154 155 Nsecfilt = GetPhotcodeNsecfilt (); 124 156 125 157 /* Nmeasure is now different, need to reallocate */ … … 127 159 for (i = 0; i < Ncatalog; i++) { 128 160 for (j = 0; j < catalog[i].Naverage; j++) { 129 Nmax = MAX (Nmax, catalog[i].average [j].Nmeasure);161 Nmax = MAX (Nmax, catalog[i].averageT[j].Nmeasure); 130 162 } 131 163 } … … 135 167 for (i = 0; i < Ncatalog; i++) { 136 168 for (j = 0; j < catalog[i].Naverage; j++) { 137 138 169 /* skip stars already calibrated */ 139 170 if (catalog[i].found[j]) continue; 140 171 141 N = 0; 142 m = catalog[i].average[j].measureOffset; 143 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 144 if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue; 145 // XXX allow REF stars (no Image Entry) to be included in the calculation this 146 // should be optionally set, and should allow for REF stars to be downweighted by 147 // more than their reported errors. how such info is carried is unclear... 148 if (getImageEntry (m, i) < 0) { 149 Mcal = Mmos = Mgrid = 0; 150 } else { 151 Mcal = getMcal (m, i); 152 if (isnan(Mcal)) continue; 153 Mmos = getMmos (m, i); 154 if (isnan(Mmos)) continue; 155 Mgrid = getMgrid (m, i); 156 if (isnan(Mgrid)) continue; 157 } 158 159 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]); 160 list[N] = Msys - Mcal - Mmos - Mgrid; 161 dlist[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR); 162 N++; 163 } 164 if (N < 1) continue; 165 166 liststats (list, dlist, N, &stats); 167 if (mark) catalog[i].found[j] = TRUE; 168 169 /* use sigma or error in dM for output? */ 170 catalog[i].secfilt[PhotNsec*j+PhotSec].M = stats.mean; 171 catalog[i].secfilt[PhotNsec*j+PhotSec].dM = MAX (stats.error, stats.sigma); 172 catalog[i].secfilt[PhotNsec*j+PhotSec].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NAN_S_SHORT; 172 int Ns; 173 for (Ns = 0; Ns < Nphotcodes; Ns++) { 174 int thisCode = photcodes[Ns][0].code; 175 Nsec = GetPhotcodeNsec(thisCode); 176 177 N = 0; 178 m = catalog[i].averageT[j].measureOffset; 179 for (k = 0; k < catalog[i].averageT[j].Nmeasure; k++, m++) { 180 // skip measurements that do not match the current photcode 181 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[m].photcode); 182 if (ecode != thisCode) { continue; } 183 184 if (catalog[i].measureT[m].dbFlags & MEAS_BAD) continue; 185 186 // XXX allow REF stars (no Image Entry) to be included in the calculation this 187 // should be optionally set, and should allow for REF stars to be downweighted by 188 // more than their reported errors. how such info is carried is unclear... 189 if (getImageEntry (m, i) < 0) { 190 Mcal = Mmos = Mgrid = 0; 191 } else { 192 Mcal = getMcal (m, i); 193 if (isnan(Mcal)) continue; 194 Mmos = getMmos (m, i); 195 if (isnan(Mmos)) continue; 196 Mgrid = getMgrid (m, i); 197 if (isnan(Mgrid)) continue; 198 } 199 200 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt]); 201 list[N] = Msys - Mcal - Mmos - Mgrid; 202 dlist[N] = MAX (catalog[i].measureT[m].dM, MIN_ERROR); 203 N++; 204 } 205 if (N < 1) continue; 206 207 liststats (list, dlist, N, &stats); 208 if (mark) catalog[i].found[j] = TRUE; 209 210 /* use sigma or error in dM for output? */ 211 catalog[i].secfilt[Nsecfilt*j+Nsec].M = stats.mean; 212 catalog[i].secfilt[Nsecfilt*j+Nsec].dM = MAX (stats.error, stats.sigma); 213 catalog[i].secfilt[Nsecfilt*j+Nsec].Xm = (stats.Nmeas > 1) ? 100.0*log10(stats.chisq) : NAN_S_SHORT; 214 } 173 215 } 174 216 } … … 179 221 } 180 222 181 // for each average object, set the average mags based on existing equiv photometry 223 // For each average object, set the average mags based on existing equiv photometry. 224 // NOTE: this function operates on the real Measure & Average structures, not the 225 // MeasureTiny & AverageTiny structures 182 226 int setMave (Catalog *catalog, int Ncatalog) { 183 227 … … 202 246 ALLOCATE (dlist, double, MAX (1, Nmax)); 203 247 204 Nsecfilt = catalog[0].Nsecfilt;248 Nsecfilt = GetPhotcodeNsecfilt (); 205 249 206 250 # define PSFQUALSTATS 1 … … 220 264 if (GetPhotcodeEquivCodebyCode (catalog[i].measure[m].photcode) != Nc) continue; 221 265 222 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j* PhotNsec]);266 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt]); 223 267 if (isnan(Msys)) continue; 224 268 … … 321 365 for (j = 0; j < catalog[i].Naverage; j++) { 322 366 323 m = catalog[i].average [j].measureOffset;324 for (k = 0; k < catalog[i].average [j].Nmeasure; k++, m++) {325 if (catalog[i].measure [m].dbFlags & MEAS_BAD) continue;367 m = catalog[i].averageT[j].measureOffset; 368 for (k = 0; k < catalog[i].averageT[j].Nmeasure; k++, m++) { 369 if (catalog[i].measureT[m].dbFlags & MEAS_BAD) continue; 326 370 Mcal = getMcal (m, i); 327 371 if (isnan(Mcal)) continue; … … 330 374 Mgrid = getMgrid (m, i); 331 375 if (isnan(Mgrid)) continue; 376 377 // set the output calibration 332 378 catalog[i].measure[m].Mcal = Mcal + Mmos + Mgrid; 333 379 } … … 339 385 void clean_stars (Catalog *catalog, int Ncatalog) { 340 386 341 int i, j, Ndel, Nave, Ntot, mark ;387 int i, j, Ndel, Nave, Ntot, mark, Ns; 342 388 float dM, Xm; 343 389 double Chisq, MaxScatter, MaxChisq; … … 354 400 ALLOCATE (slist, double, Ntot); 355 401 ALLOCATE (dlist, double, Ntot); 356 for (i = Ntot = 0; i < Ncatalog; i++) { 357 for (j = 0; j < catalog[i].Naverage; j++) { 358 if (catalog[i].average[j].flags & STAR_BAD) continue; 359 Xm = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm; 360 if (Xm == -1) continue; 361 Chisq = pow (10.0, 0.01*Xm); 362 xlist[Ntot] = Chisq; 363 slist[Ntot] = catalog[i].secfilt[PhotNsec*j+PhotSec].dM; 364 dlist[Ntot] = 1; 365 Ntot ++; 366 } 367 } 402 403 int Nsecfilt = GetPhotcodeNsecfilt (); 404 405 // eliminate bad stars using the stats for a single secfilt at a time 406 // XXX DEP replace average.flags with secfilt flags 407 for (Ns = 0; Ns < Nphotcodes; Ns ++) { 408 409 int thisCode = photcodes[Ns][0].code; 410 int Nsec = GetPhotcodeNsec(thisCode); 411 412 for (i = Ntot = 0; i < Ncatalog; i++) { 413 for (j = 0; j < catalog[i].Naverage; j++) { 414 if ( catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD ) continue; 415 Xm = catalog[i].secfilt[Nsecfilt*j+Nsec].Xm; 416 if (Xm == -1) continue; 417 Chisq = pow (10.0, 0.01*Xm); 418 xlist[Ntot] = Chisq; 419 slist[Ntot] = catalog[i].secfilt[Nsecfilt*j+Nsec].dM; 420 dlist[Ntot] = 1; 421 Ntot ++; 422 } 423 } 368 424 369 initstats ("MEAN"); 370 liststats (xlist, dlist, Ntot, &stats); 371 MaxChisq = MAX (STAR_CHISQ, 2*stats.median); 372 liststats (slist, dlist, Ntot, &stats); 373 MaxScatter = MAX (STAR_SCATTER, 2*stats.median); 374 fprintf (stderr, "Max Scatter: %f, Max Chisq: %f\n", MaxScatter, MaxChisq); 375 376 Ndel = Nave = 0; 377 for (i = 0; i < Ncatalog; i++) { 378 for (j = 0; j < catalog[i].Naverage; j++) { 379 dM = catalog[i].secfilt[PhotNsec*j+PhotSec].dM; 380 Xm = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm; 381 Chisq = pow (10.0, 0.01*Xm); 382 mark = (dM > MaxScatter) || (Xm == NAN_S_SHORT) || (Chisq > MaxChisq); 383 if (mark) { 384 catalog[i].average[j].flags |= ID_STAR_POOR; 385 Ndel ++; 386 } else { 387 catalog[i].average[j].flags &= ~ID_STAR_POOR; 388 } 389 Nave ++; 390 } 391 } 392 fprintf (stderr, "%d stars marked variable, %d total\n", Ndel, Nave); 393 initstats (STATMODE); 425 initstats ("MEAN"); 426 liststats (xlist, dlist, Ntot, &stats); 427 MaxChisq = MAX (STAR_CHISQ, 2*stats.median); 428 liststats (slist, dlist, Ntot, &stats); 429 MaxScatter = MAX (STAR_SCATTER, 2*stats.median); 430 fprintf (stderr, "Max Scatter: %f, Max Chisq: %f\n", MaxScatter, MaxChisq); 431 432 Ndel = Nave = 0; 433 for (i = 0; i < Ncatalog; i++) { 434 for (j = 0; j < catalog[i].Naverage; j++) { 435 dM = catalog[i].secfilt[Nsecfilt*j+Nsec].dM; 436 Xm = catalog[i].secfilt[Nsecfilt*j+Nsec].Xm; 437 Chisq = pow (10.0, 0.01*Xm); 438 mark = (dM > MaxScatter) || (Xm == NAN_S_SHORT) || (Chisq > MaxChisq); 439 if (mark) { 440 catalog[i].secfilt[Nsecfilt*j+Nsec].flags |= ID_STAR_POOR; 441 Ndel ++; 442 } else { 443 catalog[i].secfilt[Nsecfilt*j+Nsec].flags &= ~ID_STAR_POOR; 444 } 445 Nave ++; 446 } 447 } 448 fprintf (stderr, "%d stars marked variable, %d total\n", Ndel, Nave); 449 initstats (STATMODE); 450 } 394 451 free (xlist); 395 452 free (slist); … … 409 466 int Ncal, Nmos, Ngrid, Nfew; 410 467 468 int Nsecfilt = GetPhotcodeNsecfilt (); 469 411 470 if (VERBOSE) fprintf (stderr, "marking poor measures\n"); 412 471 /* Nmeasure is now different, need to reallocate */ … … 414 473 for (i = 0; i < Ncatalog; i++) { 415 474 for (j = 0; j < catalog[i].Naverage; j++) { 416 Nmax = MAX (Nmax, catalog[i].average [j].Nmeasure);475 Nmax = MAX (Nmax, catalog[i].averageT[j].Nmeasure); 417 476 } 418 477 } … … 430 489 for (j = 0; j < catalog[i].Naverage; j++) { 431 490 432 /* skip bad stars to prevent them from becoming good (on inner sample) */ 433 if (catalog[i].average[j].flags & STAR_BAD) continue; 434 435 /* on final processing, skip stars already measured */ 436 if (final && catalog[i].found[j]) continue; 437 438 /* accumulate list of valid measurements */ 439 m = catalog[i].average[j].measureOffset; 440 N = 0; 441 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 442 /* if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue; */ 443 Mcal = getMcal (m, i); 444 if (isnan(Mcal)) { Ncal ++; continue; } 445 Mmos = getMmos (m, i); 446 if (isnan(Mmos)) { Nmos ++; continue; } 447 Mgrid = getMgrid (m, i); 448 if (isnan(Mgrid)) { Ngrid ++; continue; } 449 450 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]); 451 list[N] = Msys - Mcal - Mmos - Mgrid; 452 dlist[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR); 453 N++; 454 } 455 if (N <= TOOFEW) { Nfew ++; continue; } 456 457 /* 3-sigma clip based on stats of inner 50% */ 458 459 // calculated mean of inner 50% 460 initstats ("INNER_MEAN"); 461 liststats (list, dlist, N, &stats); 462 stats.sigma = MAX (MIN_ERROR, stats.sigma); /* if measurements agree too well, sigma -> 0.0 */ 463 464 // ignore entries > 3sigma from inner mean 465 for (k = m = 0; k < N; k++) { 466 if (fabs (list[k] - stats.median) < NSIGMA_CLIP*stats.sigma) { 467 list[m] = list[k]; 468 m++; 469 } 470 } 471 // recalculate the mean & sigma of the accepted measurements 472 initstats ("MEAN"); 473 liststats (list, dlist, m, &stats); 474 stats.sigma = MAX (MIN_ERROR, stats.sigma); 475 476 /* apply to list of all relevant measurements, including IMAGE_POOR & IMAGE_FEW */ 477 image_bad = IMAGE_BAD; 478 IMAGE_BAD = ID_IMAGE_PHOTOM_NOCAL; 479 m = catalog[i].average[j].measureOffset; 480 N = 0; 481 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 482 /* if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue; */ 483 Mcal = getMcal (m, i); 484 if (isnan(Mcal)) continue; 485 Mmos = getMmos (m, i); 486 if (isnan(Mmos)) continue; 487 Mgrid = getMgrid (m, i); 488 if (isnan(Mgrid)) continue; 489 490 Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]); 491 list[N] = Msys - Mcal - Mmos - Mgrid; 492 dlist[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR); 493 ilist[N] = m; 494 N++; 495 Nave ++; 496 } 497 if (N < TOOFEW) continue; 498 499 /* mark bad measures (> 3 sigma deviant) */ 500 for (k = 0; k < N; k++) { 501 if (fabs (list[k] - stats.median) > NSIGMA_REJECT*stats.sigma) { 502 catalog[i].measure[ilist[k]].dbFlags |= ID_MEAS_POOR_PHOTOM; 503 Ndel ++; 504 } 505 } 506 IMAGE_BAD = image_bad; 491 int Ns; 492 for (Ns = 0; Ns < Nphotcodes; Ns++) { 493 494 /* on final processing, skip stars already measured */ 495 if (final && catalog[i].found[j]) continue; 496 497 int thisCode = photcodes[Ns][0].code; 498 int Nsec = GetPhotcodeNsec(thisCode); 499 500 /* skip bad stars to prevent them from becoming good (on inner sample) */ 501 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue; 502 503 /* accumulate list of valid measurements */ 504 m = catalog[i].averageT[j].measureOffset; 505 N = 0; 506 for (k = 0; k < catalog[i].averageT[j].Nmeasure; k++, m++) { 507 // skip measurements that do not match the current photcode 508 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[m].photcode); 509 if (ecode != thisCode) { continue; } 510 511 /* if (catalog[i].measureT[m].dbFlags & MEAS_BAD) continue; */ 512 Mcal = getMcal (m, i); 513 if (isnan(Mcal)) { Ncal ++; continue; } 514 Mmos = getMmos (m, i); 515 if (isnan(Mmos)) { Nmos ++; continue; } 516 Mgrid = getMgrid (m, i); 517 if (isnan(Mgrid)) { Ngrid ++; continue; } 518 519 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt]); 520 list[N] = Msys - Mcal - Mmos - Mgrid; 521 dlist[N] = MAX (catalog[i].measureT[m].dM, MIN_ERROR); 522 N++; 523 } 524 if (N <= TOOFEW) { Nfew ++; continue; } 525 526 /* 3-sigma clip based on stats of inner 50% */ 527 528 // calculated mean of inner 50% 529 initstats ("INNER_MEAN"); 530 liststats (list, dlist, N, &stats); 531 stats.sigma = MAX (MIN_ERROR, stats.sigma); /* if measurements agree too well, sigma -> 0.0 */ 532 533 // ignore entries > 3sigma from inner mean 534 for (k = m = 0; k < N; k++) { 535 if (fabs (list[k] - stats.median) < NSIGMA_CLIP*stats.sigma) { 536 list[m] = list[k]; 537 m++; 538 } 539 } 540 // recalculate the mean & sigma of the accepted measurements 541 initstats ("MEAN"); 542 liststats (list, dlist, m, &stats); 543 stats.sigma = MAX (MIN_ERROR, stats.sigma); 544 545 /* apply to list of all relevant measurements, including IMAGE_POOR & IMAGE_FEW */ 546 image_bad = IMAGE_BAD; 547 IMAGE_BAD = ID_IMAGE_PHOTOM_NOCAL; 548 m = catalog[i].averageT[j].measureOffset; 549 N = 0; 550 for (k = 0; k < catalog[i].averageT[j].Nmeasure; k++, m++) { 551 // skip measurements that do not match the current photcode 552 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[m].photcode); 553 if (ecode != thisCode) { continue; } 554 555 /* if (catalog[i].measureT[m].dbFlags & MEAS_BAD) continue; */ 556 Mcal = getMcal (m, i); 557 if (isnan(Mcal)) continue; 558 Mmos = getMmos (m, i); 559 if (isnan(Mmos)) continue; 560 Mgrid = getMgrid (m, i); 561 if (isnan(Mgrid)) continue; 562 563 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt]); 564 list[N] = Msys - Mcal - Mmos - Mgrid; 565 dlist[N] = MAX (catalog[i].measureT[m].dM, MIN_ERROR); 566 ilist[N] = m; 567 N++; 568 Nave ++; 569 } 570 if (N < TOOFEW) continue; 571 572 /* mark bad measures (> 3 sigma deviant) */ 573 for (k = 0; k < N; k++) { 574 if (fabs (list[k] - stats.median) > NSIGMA_REJECT*stats.sigma) { 575 catalog[i].measureT[ilist[k]].dbFlags |= ID_MEAS_POOR_PHOTOM; 576 if (final) { 577 // for the final pass, we have a duplicate set of values in measure and measureT 578 catalog[i].measure[ilist[k]].dbFlags |= ID_MEAS_POOR_PHOTOM; 579 } 580 Ndel ++; 581 } 582 } 583 IMAGE_BAD = image_bad; 584 } 507 585 } 508 586 } … … 513 591 } 514 592 515 StatType statsStarN (Catalog *catalog, int Ncatalog ) {593 StatType statsStarN (Catalog *catalog, int Ncatalog, int Nsec, int seccode) { 516 594 517 595 off_t j, k, m, Ntot; … … 520 598 float Mcal, Mmos, Mgrid; 521 599 StatType stats; 600 // int N1, N2, N3, N4, N0; 601 // N1 = N2 = N3 = N4 = N0 = 0; 602 603 int Nsecfilt = GetPhotcodeNsecfilt (); 522 604 523 605 Ntot = 0; … … 534 616 535 617 /* calculate the average value for a single star */ 536 if (catalog[i]. average[j].flags & STAR_BAD) continue;537 m = catalog[i].average [j].measureOffset;618 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) { continue; } 619 m = catalog[i].averageT[j].measureOffset; 538 620 539 621 N = 0; 540 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 622 for (k = 0; k < catalog[i].averageT[j].Nmeasure; k++, m++) { 623 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[m].photcode); 624 if (ecode != seccode) { continue;} 541 625 Mcal = getMcal (m, i); 542 if (isnan(Mcal)) continue;626 if (isnan(Mcal)) { continue;} 543 627 Mmos = getMmos (m, i); 544 if (isnan(Mmos)) continue;628 if (isnan(Mmos)) { continue; } 545 629 Mgrid = getMgrid (m, i); 546 if (isnan(Mgrid)) continue;630 if (isnan(Mgrid)) { continue;} 547 631 N++; 548 632 } … … 554 638 } 555 639 640 // fprintf (stderr, "N1: %d, N2: %d, N3: %d, N4: %d, N0: %d\n", N1, N2, N3, N4, N0); 556 641 liststats (list, dlist, n, &stats); 557 642 free (list); … … 560 645 } 561 646 562 StatType statsStarX (Catalog *catalog, int Ncatalog) { 647 // stats for a single secfilt at a time 648 StatType statsStarX (Catalog *catalog, int Ncatalog, int Nsec) { 563 649 564 650 off_t j, Ntot; … … 567 653 StatType stats; 568 654 655 int Nsecfilt = GetPhotcodeNsecfilt (); 656 569 657 Ntot = 0; 570 658 for (i = 0; i < Ncatalog; i++) { … … 580 668 581 669 /* calculate the average value for a single star */ 582 if (catalog[i]. average[j].flags & STAR_BAD) continue;583 584 Xm = catalog[i].secfilt[ PhotNsec*j+PhotSec].Xm;670 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue; 671 672 Xm = catalog[i].secfilt[Nsecfilt*j+Nsec].Xm; 585 673 if (Xm == NAN_S_SHORT) continue; 586 674 list[n] = pow (10.0, 0.01*Xm); … … 596 684 } 597 685 598 StatType statsStarS (Catalog *catalog, int Ncatalog ) {686 StatType statsStarS (Catalog *catalog, int Ncatalog, int Nsec) { 599 687 600 688 int i, n; … … 604 692 StatType stats; 605 693 694 int Nsecfilt = GetPhotcodeNsecfilt (); 695 606 696 Ntot = 0; 607 697 for (i = 0; i < Ncatalog; i++) { … … 617 707 618 708 /* calculate the average value for a single star */ 619 if (catalog[i]. average[j].flags & STAR_BAD) continue;620 621 dM = catalog[i].secfilt[ PhotNsec*j+PhotSec].dM;709 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue; 710 711 dM = catalog[i].secfilt[Nsecfilt*j+Nsec].dM; 622 712 list[n] = dM; 623 713 dlist[n] = 1; … … 644 734 ALLOCATE (Mlist, double, NBIN); 645 735 646 for (i = 0; i < NBIN; i++) xlist[i] = 0.00025*i; 647 bzero (Mlist, NBIN*sizeof(double)); 648 for (i = 0; i < Ncatalog; i++) { 649 for (j = 0; j < catalog[i].Naverage; j++) { 650 if (catalog[i].average[j].flags & STAR_BAD) continue; 651 dMrel = catalog[i].secfilt[PhotNsec*j+PhotSec].dM; 652 bin = dMrel / 0.00025; 653 bin = MAX (0, MIN (NBIN-1, bin)); 654 Mlist[bin] += 1.0; 655 } 656 } 657 658 plot_defaults (&graphdata); 659 graphdata.style = 1; 660 plot_list (&graphdata, xlist, Mlist, NBIN, "dMrel hist", "%s.dMhist.png", OUTROOT); 661 736 int Nsecfilt = GetPhotcodeNsecfilt (); 737 738 int Ns; 739 for (Ns = 0; Ns < Nphotcodes; Ns++) { 740 741 int thisCode = photcodes[Ns][0].code; 742 int Nsec = GetPhotcodeNsec(thisCode); 743 744 for (i = 0; i < NBIN; i++) xlist[i] = 0.00025*i; 745 bzero (Mlist, NBIN*sizeof(double)); 746 for (i = 0; i < Ncatalog; i++) { 747 for (j = 0; j < catalog[i].Naverage; j++) { 748 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue; 749 dMrel = catalog[i].secfilt[Nsecfilt*j+Nsec].dM; 750 bin = dMrel / 0.00025; 751 bin = MAX (0, MIN (NBIN-1, bin)); 752 Mlist[bin] += 1.0; 753 } 754 } 755 756 plot_defaults (&graphdata); 757 graphdata.style = 1; 758 plot_list (&graphdata, xlist, Mlist, NBIN, "dMrel hist", "%s.dMhist.png", OUTROOT); 759 } 662 760 free (xlist); 663 761 free (Mlist); … … 671 769 Graphdata graphdata; 672 770 771 int Nsecfilt = GetPhotcodeNsecfilt (); 772 673 773 Ntotal = 0; 674 774 for (i = 0; i < Ncatalog; i++) Ntotal += catalog[i].Naverage; … … 677 777 ALLOCATE (ylist, double, Ntotal); 678 778 679 N = 0; 680 for (i = 0; i < Ncatalog; i++) { 681 for (j = 0; j < catalog[i].Naverage; j++) { 682 if (catalog[i].average[j].flags & STAR_BAD) continue; 683 xlist[N] = catalog[i].secfilt[PhotNsec*j+PhotSec].M; 684 value = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm; 685 if (value == NAN_S_SHORT) continue; 686 ylist[N] = 0.01*value; 687 N++; 688 } 689 } 690 691 plot_defaults (&graphdata); 692 graphdata.ymin = -3.0; 693 plot_list (&graphdata, xlist, ylist, N, "chisq", "%s.chisq.png", OUTROOT); 779 int Ns; 780 for (Ns = 0; Ns < Nphotcodes; Ns++) { 781 782 int thisCode = photcodes[Ns][0].code; 783 int Nsec = GetPhotcodeNsec(thisCode); 784 785 N = 0; 786 for (i = 0; i < Ncatalog; i++) { 787 for (j = 0; j < catalog[i].Naverage; j++) { 788 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue; 789 xlist[N] = catalog[i].secfilt[Nsecfilt*j+Nsec].M; 790 value = catalog[i].secfilt[Nsecfilt*j+Nsec].Xm; 791 if (value == NAN_S_SHORT) continue; 792 ylist[N] = 0.01*value; 793 N++; 794 } 795 } 796 797 plot_defaults (&graphdata); 798 graphdata.ymin = -3.0; 799 plot_list (&graphdata, xlist, ylist, N, "chisq", "%s.chisq.png", OUTROOT); 800 } 801 694 802 free (xlist); 695 803 free (ylist); … … 716 824 for (i = 0; i < Ncatalog; i++) { 717 825 for (j = 0; j < catalog[i].Naverage; j++) { 718 xlist[N] = catalog[i].average [j].R;719 ylist[N] = catalog[i].average [j].D;826 xlist[N] = catalog[i].averageT[j].R; 827 ylist[N] = catalog[i].averageT[j].D; 720 828 N++; 721 829 } -
branches/czw_branch/20110406/Ohana/src/relphot/src/args.c
r31160 r31606 128 128 } 129 129 130 MaxDensityUse = FALSE; 131 if ((N = get_argument (argc, argv, "-max-density"))) { 132 remove_argument (N, &argc, argv); 133 MaxDensityValue = atof(argv[N]); 134 remove_argument (N, &argc, argv); 135 MaxDensityUse = TRUE; 136 } 137 130 138 SHOW_PARAMS = FALSE; 131 139 if ((N = get_argument (argc, argv, "-params"))) { -
branches/czw_branch/20110406/Ohana/src/relphot/src/bcatalog.c
r31160 r31606 1 1 # include "relphot.h" 2 3 extern double drand48(); 4 5 int CopyAverageTiny (AverageTiny *averageT, Average *average) { 6 7 averageT[0].R = average[0].R; 8 averageT[0].D = average[0].D; 9 averageT[0].flags = average[0].flags; 10 averageT[0].Nmeasure = average[0].Nmeasure; 11 averageT[0].measureOffset = average[0].measureOffset; 12 13 // make Nmeasure & measureOffset optional? 14 15 return (TRUE); 16 } 17 18 int CopyMeasureTiny (MeasureTiny *measureT, Measure *measure) { 19 20 measureT[0].dR = measure[0].dR; 21 measureT[0].dD = measure[0].dD; 22 measureT[0].M = measure[0].M; 23 measureT[0].Mcal = measure[0].Mcal; 24 measureT[0].dM = measure[0].dM; 25 measureT[0].airmass = measure[0].airmass; 26 measureT[0].Xccd = measure[0].Xccd; 27 measureT[0].Yccd = measure[0].Yccd; 28 measureT[0].t = measure[0].t; 29 measureT[0].dt = measure[0].dt; 30 measureT[0].averef = measure[0].averef; 31 measureT[0].imageID = measure[0].imageID; 32 measureT[0].dbFlags = measure[0].dbFlags; 33 measureT[0].photcode = measure[0].photcode; 34 35 return (TRUE); 36 } 2 37 3 38 int bcatalog (Catalog *subcatalog, Catalog *catalog) { 4 39 5 40 off_t i, j, offset; 6 int ecode ;41 int ecode, found, Ns; 7 42 off_t NAVERAGE, NMEASURE, Naverage, Nmeasure, Nm; 8 43 float mag; 9 44 int Ncode, Ntime, Ndophot, Nmag, Nsigma, Nimag, Nfew, Ngalaxy, Npsfqf; 10 45 11 // XXX PhotNsec as a global is a bad idea; either get it from catalog 12 // or get it from: 13 // Nsecfilt = GetPhotcodeNsecfilt (); 14 // assert (catalog[0].Nsecfilt == Nsecfilt); 46 int Nsecfilt = GetPhotcodeNsecfilt (); 47 assert (Nsecfilt == catalog[0].Nsecfilt); 15 48 16 49 /* we are moving only the subset of measurements from catalog[0] to subcatalog[0] */ … … 18 51 NAVERAGE = 50; 19 52 NMEASURE = 1000; 20 ALLOCATE (subcatalog[0]. average, Average, NAVERAGE);21 ALLOCATE (subcatalog[0]. secfilt, SecFilt, NAVERAGE*PhotNsec);22 ALLOCATE (subcatalog[0]. measure, Measure, NMEASURE);53 ALLOCATE (subcatalog[0].measureT, MeasureTiny, NMEASURE); 54 ALLOCATE (subcatalog[0].averageT, AverageTiny, NAVERAGE); 55 ALLOCATE (subcatalog[0].secfilt, SecFilt, NAVERAGE*Nsecfilt); 23 56 Nmeasure = Naverage = 0; 24 57 … … 30 63 31 64 /* start with all stars good */ 32 subcatalog[0].average[Naverage] = catalog[0].average[i]; 33 subcatalog[0].average[Naverage].measureOffset = Nmeasure; 34 for (j = 0; j < PhotNsec; j++) { 35 subcatalog[0].secfilt[PhotNsec*Naverage+j] = catalog[0].secfilt[PhotNsec*i+j]; 65 CopyAverageTiny (&subcatalog[0].averageT[Naverage], &catalog[0].average[i]); 66 subcatalog[0].averageT[Naverage].measureOffset = Nmeasure; 67 68 for (j = 0; j < Nsecfilt; j++) { 69 subcatalog[0].secfilt[Nsecfilt*Naverage+j] = catalog[0].secfilt[Nsecfilt*i+j]; 36 70 } 37 71 38 72 if (RESET) { 39 subcatalog[0].secfilt[PhotNsec*Naverage+PhotSec].M = NAN; 40 subcatalog[0].secfilt[PhotNsec*Naverage+PhotSec].dM = NAN; 41 subcatalog[0].average[Naverage].flags &= ~ID_STAR_FEW; 42 subcatalog[0].average[Naverage].flags &= ~ID_STAR_POOR; 73 int Ns; 74 for (Ns = 0; Ns < Nphotcodes; Ns++) { 75 76 int thisCode = photcodes[Ns][0].code; 77 int Nsec = GetPhotcodeNsec(thisCode); 78 79 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].M = NAN; 80 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].dM = NAN; 81 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].flags &= ~ID_STAR_FEW; 82 subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec].flags &= ~ID_STAR_POOR; 83 } 43 84 } 44 85 … … 52 93 /* select measurements by photcode */ 53 94 ecode = GetPhotcodeEquivCodebyCode (catalog[0].measure[offset].photcode); 54 if (ecode != photcode[0].code) { Ncode ++; continue; } 95 found = FALSE; 96 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { 97 if (ecode == photcodes[Ns][0].code) found = TRUE; 98 } 99 if (!found) { 100 Ncode ++; 101 continue; 102 } 55 103 56 104 /* select measurements by time */ … … 61 109 62 110 /* select measurements by quality */ 63 // XXX ignore this criterion for REF measurements?64 // XXX chnage this to select by bitflags65 111 if (DophotSelect && ((catalog[0].measure[offset].photFlags >> 16) != DophotValue)) { Ndophot ++; continue; } 66 112 … … 70 116 // check for galaxies 71 117 if (!isnan(catalog[0].measure[offset].Map)) { 72 if (catalog[0].measure[offset].M - catalog[0].measure[offset].Map > 0.15) {73 nEXT ++;74 } else {75 nPSF ++;76 }118 if (catalog[0].measure[offset].M - catalog[0].measure[offset].Map > 0.15) { 119 nEXT ++; 120 } else { 121 nPSF ++; 122 } 77 123 } 78 124 … … 91 137 } 92 138 93 subcatalog[0].measure[Nmeasure].dbFlags &= ~ID_MEAS_SKIP_PHOTOM;94 subcatalog[0].measure [Nmeasure] = catalog[0].measure[offset];95 subcatalog[0].measure [Nmeasure].averef = Naverage;139 CopyMeasureTiny (&subcatalog[0].measureT[Nmeasure], &catalog[0].measure[offset]); 140 subcatalog[0].measureT[Nmeasure].dbFlags &= ~ID_MEAS_SKIP_PHOTOM; 141 subcatalog[0].measureT[Nmeasure].averef = Naverage; 96 142 if (RESET) { 97 subcatalog[0].measure [Nmeasure].Mcal = 0;98 subcatalog[0].measure [Nmeasure].dbFlags &= 0xff00;99 subcatalog[0].measure [Nmeasure].dbFlags &= ~ID_MEAS_POOR_PHOTOM;100 subcatalog[0].measure [Nmeasure].dbFlags &= ~ID_MEAS_AREA;101 subcatalog[0].measure [Nmeasure].dbFlags &= ~ID_MEAS_NOCAL;143 subcatalog[0].measureT[Nmeasure].Mcal = 0; 144 subcatalog[0].measureT[Nmeasure].dbFlags &= 0xff00; 145 subcatalog[0].measureT[Nmeasure].dbFlags &= ~ID_MEAS_POOR_PHOTOM; 146 subcatalog[0].measureT[Nmeasure].dbFlags &= ~ID_MEAS_AREA; 147 subcatalog[0].measureT[Nmeasure].dbFlags &= ~ID_MEAS_NOCAL; 102 148 } 103 149 Nmeasure ++; … … 105 151 if (Nmeasure == NMEASURE) { 106 152 NMEASURE += 1000; 107 REALLOCATE (subcatalog[0].measure , Measure, NMEASURE);153 REALLOCATE (subcatalog[0].measureT, MeasureTiny, NMEASURE); 108 154 } 109 155 } … … 122 168 continue; 123 169 } 124 subcatalog[0].average [Naverage].Nmeasure = Nm;170 subcatalog[0].averageT[Naverage].Nmeasure = Nm; 125 171 Naverage ++; 126 172 if (Naverage == NAVERAGE) { 127 173 NAVERAGE += 50; 128 REALLOCATE (subcatalog[0].average , Average, NAVERAGE);129 REALLOCATE (subcatalog[0].secfilt, SecFilt, NAVERAGE*PhotNsec);130 } 131 } 132 REALLOCATE (subcatalog[0].average , Average, MAX (Naverage, 1));133 REALLOCATE (subcatalog[0].measure , Measure, MAX (Nmeasure, 1));134 REALLOCATE (subcatalog[0].secfilt, SecFilt, PhotNsec*MAX (Naverage, 1));174 REALLOCATE (subcatalog[0].averageT, AverageTiny, NAVERAGE); 175 REALLOCATE (subcatalog[0].secfilt, SecFilt, NAVERAGE*Nsecfilt); 176 } 177 } 178 REALLOCATE (subcatalog[0].averageT, AverageTiny, MAX (Naverage, 1)); 179 REALLOCATE (subcatalog[0].measureT, MeasureTiny, MAX (Nmeasure, 1)); 180 REALLOCATE (subcatalog[0].secfilt, SecFilt, Nsecfilt*MAX (Naverage, 1)); 135 181 subcatalog[0].Naverage = Naverage; 136 182 subcatalog[0].Nmeasure = Nmeasure; 137 183 subcatalog[0].Nsecfilt = catalog[0].Nsecfilt; 138 184 subcatalog[0].Nsecf_mem = Naverage * catalog[0].Nsecfilt; 139 assert (PhotNsec == catalog[0].Nsecfilt); 185 186 // limit the total number of stars in the catalog 187 if (MaxDensityUse) { 188 LimitDensityCatalog (subcatalog, catalog); 189 } 140 190 141 191 if (VERBOSE) { … … 147 197 return (TRUE); 148 198 } 199 200 int LimitDensityCatalog (Catalog *subcatalog, Catalog *catalog) { 201 202 Catalog tmpcatalog; 203 204 double Rmin, Rmax, Dmin, Dmax; 205 206 int Nsecfilt = GetPhotcodeNsecfilt (); 207 208 gfits_scan (&catalog[0].header, "RA0", "%lf", 1, &Rmin); 209 gfits_scan (&catalog[0].header, "DEC0", "%lf", 1, &Dmin); 210 gfits_scan (&catalog[0].header, "RA1", "%lf", 1, &Rmax); 211 gfits_scan (&catalog[0].header, "DEC1", "%lf", 1, &Dmax); 212 213 if (VERBOSE2) fprintf (stderr, "extracting from catalog covering region %f,%f to %f,%f\n", Rmin, Dmin, Rmax, Dmax); 214 215 float AREA = fabs(Dmax - Dmin) * fabs(Rmax - Rmin) * cos (0.5*RAD_DEG*(Dmax + Dmin)); 216 assert (AREA > 0); 217 218 off_t Nmax = MaxDensityValue * AREA; 219 if (subcatalog[0].Naverage <= Nmax) { 220 if (VERBOSE) { 221 fprintf (stderr, "subcatalog has less than the max density\n"); 222 } 223 return (TRUE); 224 } 225 226 off_t Naverage = subcatalog[0].Naverage; 227 228 // select a random subset of Nmax stars from subcatalog using Fisher-Yates 229 230 // we are going to select Nmax entries by generating a random-sorted index list 231 off_t *index, tmp, i, j, ave; 232 ALLOCATE (index, off_t, Naverage); 233 for (i = 0; i < Naverage; i++) { 234 index[i] = i; 235 } 236 for (i = 0; i < Naverage; i++) { 237 j = (Naverage - i) * drand48() + i; // a number between i and Naverage 238 tmp = index[j]; 239 index[j] = index[i]; 240 index[i] = tmp; 241 } 242 243 // count the number of measurements this selection will yield 244 off_t NMEASURE = 0; 245 for (i = 0; i < Nmax; i++) { 246 ave = index[i]; 247 NMEASURE += subcatalog[0].averageT[ave].Nmeasure; 248 } 249 250 // allocate the output data 251 ALLOCATE (tmpcatalog.averageT, AverageTiny, Nmax); 252 ALLOCATE (tmpcatalog.measureT, MeasureTiny, NMEASURE); 253 ALLOCATE (tmpcatalog.secfilt, SecFilt, Nmax * Nsecfilt); 254 255 off_t Nmeasure = 0; 256 257 // copy the Nmax selected entries from subcatalog to tmpcatalog (adjusting links) 258 for (i = 0; i < Nmax; i++) { 259 ave = index[i]; 260 tmpcatalog.averageT[i] = subcatalog[0].averageT[ave]; 261 tmpcatalog.averageT[i].measureOffset = Nmeasure; 262 for (j = 0; j < tmpcatalog.averageT[i].Nmeasure; j++) { 263 off_t offset = subcatalog[0].averageT[ave].measureOffset + j; 264 tmpcatalog.measureT[Nmeasure] = subcatalog[0].measureT[offset]; 265 tmpcatalog.measureT[Nmeasure].averef = i; 266 Nmeasure ++; 267 } 268 } 269 270 if (VERBOSE) { 271 fprintf (stderr, "limited to "OFF_T_FMT" of "OFF_T_FMT" stars ("OFF_T_FMT" of "OFF_T_FMT" measures) for catalog %s\n", 272 Nmax, subcatalog[0].Naverage, Nmeasure, subcatalog[0].Nmeasure, catalog[0].filename); 273 } 274 275 free (subcatalog[0].averageT); 276 free (subcatalog[0].measureT); 277 free (subcatalog[0].secfilt); 278 279 subcatalog[0].averageT = tmpcatalog.averageT; 280 subcatalog[0].measureT = tmpcatalog.measureT; 281 subcatalog[0].secfilt = tmpcatalog.secfilt; 282 subcatalog[0].Naverage = Nmax; 283 subcatalog[0].Nmeasure = Nmeasure; 284 subcatalog[0].Nsecfilt = catalog[0].Nsecfilt; 285 subcatalog[0].Nsecf_mem = Naverage * catalog[0].Nsecfilt; 286 287 return (TRUE); 288 } 289 290 // for the cases where we are not using a subset of the data, we still need to have a copy of these fields 291 int populate_tiny_values (Catalog *catalog) { 292 293 off_t i; 294 295 ALLOCATE (catalog[0].measureT, MeasureTiny, catalog[0].Nmeasure); 296 ALLOCATE (catalog[0].averageT, AverageTiny, catalog[0].Naverage); 297 298 for (i = 0; i < catalog[0].Naverage; i++) { 299 CopyAverageTiny (&catalog[0].averageT[i], &catalog[0].average[i]); 300 } 301 302 for (i = 0; i < catalog[0].Nmeasure; i++) { 303 CopyMeasureTiny (&catalog[0].measureT[i], &catalog[0].measure[i]); 304 } 305 306 return (TRUE); 307 } 308 309 int free_tiny_values (Catalog *catalog) { 310 311 free (catalog[0].averageT); 312 free (catalog[0].measureT); 313 return (TRUE); 314 } 315 -
branches/czw_branch/20110406/Ohana/src/relphot/src/global_stats.c
r5143 r31606 7 7 initstats ("MEAN"); 8 8 9 stN = statsStarN (catalog, Ncatalog); 10 stX = statsStarX (catalog, Ncatalog); 11 stS = statsStarS (catalog, Ncatalog); 9 fprintf (stderr, "\n"); 10 fprintf (stderr, "STATS median mean sigma min max Nmeas\n"); 12 11 12 int Ns; 13 for (Ns = 0; Ns < Nphotcodes; Ns++) { 14 15 int thisCode = photcodes[Ns][0].code; 16 int Nsec = GetPhotcodeNsec(thisCode); 17 int seccode = photcodes[Ns][0].code; 18 19 stN = statsStarN (catalog, Ncatalog, Nsec, seccode); 20 stX = statsStarX (catalog, Ncatalog, Nsec); 21 stS = statsStarS (catalog, Ncatalog, Nsec); 22 23 fprintf (stderr, " --- stats for %s ---\n", photcodes[Ns][0].name); 24 fprintf (stderr, "meas / star: %7.0f %7.1f %7.1f %7.0f %7.0f %6d\n", stN.median, stN.mean, stN.sigma, stN.min, stN.max, stN.Nmeas); 25 fprintf (stderr, "dMrel star: %7.4f %7.4f %7.4f %7.4f %7.4f %6d\n", stS.median, stS.mean, stS.sigma, stS.min, stS.max, stS.Nmeas); 26 fprintf (stderr, "chisq star: %7.1f %7.1f %7.1f %7.1f %7.1f %6d\n", stX.median, stX.mean, stX.sigma, stX.min, stX.max, stX.Nmeas); 27 } 28 13 29 imN = statsImageN (catalog); 14 30 imX = statsImageX (catalog); 15 31 imM = statsImageM (catalog); 16 32 imD = statsImagedM (catalog); 17 33 18 34 msN = statsMosaicN (catalog); 19 35 msM = statsMosaicM (catalog); 20 36 msD = statsMosaicdM (catalog); 21 37 msX = statsMosaicX (catalog); 22 23 fprintf (stderr, "STATS median mean sigma min max Nmeas\n"); 38 24 39 fprintf (stderr, "meas / image: %7.0f %7.0f %7.0f %7.0f %7.0f %6d\n", imN.median, imN.mean, imN.sigma, imN.min, imN.max, imN.Nmeas); 25 fprintf (stderr, "meas / mosaic: %7.0f %7.0f %7.0f %7.0f %7.0f %6d\n", msN.median, msN.mean, msN.sigma, msN.min, msN.max, msN.Nmeas);26 fprintf (stderr, "meas / star: %7.0f %7.1f %7.1f %7.0f %7.0f %6d\n", stN.median, stN.mean, stN.sigma, stN.min, stN.max, stN.Nmeas);27 28 fprintf (stderr, "chisq image: %7.1f %7.1f %7.1f %7.1f %7.1f %6d\n", imX.median, imX.mean, imX.sigma, imX.min, imX.max, imX.Nmeas);29 fprintf (stderr, "chisq mosaic: %7.1f %7.1f %7.1f %7.1f %7.1f %6d\n", msX.median, msX.mean, msX.sigma, msX.min, msX.max, msX.Nmeas);30 fprintf (stderr, "chisq star: %7.1f %7.1f %7.1f %7.1f %7.1f %6d\n", stX.median, stX.mean, stX.sigma, stX.min, stX.max, stX.Nmeas);31 32 40 fprintf (stderr, "Mcal image: %7.4f %7.4f %7.4f %7.4f %7.4f %6d\n", imM.median, imM.mean, imM.sigma, imM.min, imM.max, imM.Nmeas); 33 41 fprintf (stderr, "dMcal image: %7.4f %7.4f %7.4f %7.4f %7.4f %6d\n", imD.median, imD.mean, imD.sigma, imD.min, imD.max, imD.Nmeas); 42 fprintf (stderr, "chisq image: %7.1f %7.1f %7.1f %7.1f %7.1f %6d\n", imX.median, imX.mean, imX.sigma, imX.min, imX.max, imX.Nmeas); 34 43 44 fprintf (stderr, "meas / mosaic: %7.0f %7.0f %7.0f %7.0f %7.0f %6d\n", msN.median, msN.mean, msN.sigma, msN.min, msN.max, msN.Nmeas); 35 45 fprintf (stderr, "Mcal mosaic: %7.4f %7.4f %7.4f %7.4f %7.4f %6d\n", msM.median, msM.mean, msM.sigma, msM.min, msM.max, msM.Nmeas); 36 46 fprintf (stderr, "dMcal mosaic: %7.4f %7.4f %7.4f %7.4f %7.4f %6d\n", msD.median, msD.mean, msD.sigma, msD.min, msD.max, msD.Nmeas); 37 38 fprintf (stderr, "dMrel star: %7.4f %7.4f %7.4f %7.4f %7.4f %6d\n\n", stS.median, stS.mean, stS.sigma, stS.min, stS.max, stS.Nmeas);47 fprintf (stderr, "chisq mosaic: %7.1f %7.1f %7.1f %7.1f %7.1f %6d\n", msX.median, msX.mean, msX.sigma, msX.min, msX.max, msX.Nmeas); 48 39 49 40 50 initstats (STATMODE); -
branches/czw_branch/20110406/Ohana/src/relphot/src/initialize.c
r30616 r31606 13 13 N = UserPatchSelect ? 1 : 2; 14 14 15 # if (0) 16 // XXX DEP 15 17 if ((photcode = GetPhotcodebyName (argv[N])) == NULL) { 16 18 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", argv[N]); … … 21 23 exit (1); 22 24 } 25 // PhotSec is used to select the single average photcode being processed 23 26 PhotSec = GetPhotcodeNsec (photcode[0].code); 27 # endif 28 29 Nphotcodes = 0; 30 photcodes = NULL; 31 int NPHOTCODES = 10; 32 ALLOCATE (photcodes, PhotCode *, NPHOTCODES); 33 34 /* parse the comma-separated list of photcodesKeep */ 35 char *myList = strcreate(argv[N]); 36 char *list = myList; 37 char *codename = NULL; 38 char *ptr = NULL; 39 while ((codename = strtok_r (list, ",", &ptr)) != NULL) { 40 list = NULL; // pass NULL on successive strtok_r calls 41 fprintf (stderr, "PHOTCODE LIST: %s\n", myList); 42 fprintf (stderr, "codename: %s\n", codename); 43 if ((photcodes[Nphotcodes] = GetPhotcodebyName (codename)) == NULL) { 44 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", codename); 45 exit (1); 46 } 47 if (photcodes[Nphotcodes][0].type != PHOT_SEC) { 48 fprintf (stderr, "photcode %s is not an filter type (SEC)\n", codename); 49 exit (1); 50 } 51 Nphotcodes ++; 52 CHECK_REALLOCATE (photcodes, PhotCode *, NPHOTCODES, Nphotcodes, 10); 53 } 24 54 } 25 26 PhotNsec = GetPhotcodeNsecfilt (); 55 // XXX DEP PhotNsec = GetPhotcodeNsecfilt (); 56 if (USE_GRID && (Nphotcodes > 1)) { 57 fprintf (stderr, "grid correction analysis currently can only operate on a single photcode\n"); 58 exit (1); 59 } 27 60 28 61 initstats (STATMODE); … … 55 88 exit (0); 56 89 } 90 91 // init the random seed 92 long A, B; 93 A = time(NULL); 94 for (B = 0; A == time(NULL); B++); 95 srand48(B); 57 96 } 58 -
branches/czw_branch/20110406/Ohana/src/relphot/src/load_images.c
r31160 r31606 44 44 // select the images which overlap the selected sky regions 45 45 subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset); 46 MARKTIME("selected images: %f sec\n", dtime);46 MARKTIME("selected %d overlapping images: %f sec\n", (int) Nsubset, dtime); 47 47 48 48 // generate db->vtable from db->ftable based on the selection -
branches/czw_branch/20110406/Ohana/src/relphot/src/plot_scatter.c
r27435 r31606 18 18 ALLOCATE (ilist, double, Ntot); 19 19 20 N = 0; 21 for (i = 0; i < Ncatalog; i++) { 22 for (j = 0; j < catalog[i].Naverage; j++) { 20 int Nsecfilt = GetPhotcodeNsecfilt (); 23 21 24 /* calculate the average value for a single star */ 25 if (catalog[i].average[j].flags & STAR_BAD) continue; 26 m = catalog[i].average[j].measureOffset; 22 int Ns; 23 for (Ns = 0; Ns < Nphotcodes; Ns++) { 27 24 28 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 29 if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue; 30 Mcal = getMcal (m, i); 31 if (isnan(Mcal)) continue; 32 Mmos = getMmos (m, i); 33 if (isnan(Mmos)) continue; 34 Mgrid = getMgrid (m, i); 35 if (isnan(Mgrid)) continue; 25 int thisCode = photcodes[Ns][0].code; 26 int Nsec = GetPhotcodeNsec(thisCode); 36 27 37 Mrel = catalog[i].secfilt[PhotNsec*j+PhotSec].M; 38 xlist[N] = Mrel; 39 ylist[N] = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]) - Mcal - Mmos - Mgrid - Mrel; 40 ilist[N] = PhotInst (&catalog[i].measure[m]); 41 N++; 42 } 28 N = 0; 29 for (i = 0; i < Ncatalog; i++) { 30 for (j = 0; j < catalog[i].Naverage; j++) { 31 32 /* calculate the average value for a single star */ 33 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue; 34 m = catalog[i].average[j].measureOffset; 35 36 for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) { 37 // skip measurements that do not match the current photcode 38 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[m].photcode); 39 if (ecode != thisCode) { continue; } 40 41 if (catalog[i].measureT[m].dbFlags & MEAS_BAD) continue; 42 Mcal = getMcal (m, i); 43 if (isnan(Mcal)) continue; 44 Mmos = getMmos (m, i); 45 if (isnan(Mmos)) continue; 46 Mgrid = getMgrid (m, i); 47 if (isnan(Mgrid)) continue; 48 49 Mrel = catalog[i].secfilt[Nsecfilt*j+Nsec].M; 50 xlist[N] = Mrel; 51 ylist[N] = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt]) - Mcal - Mmos - Mgrid - Mrel; 52 ilist[N] = PhotInstTiny (&catalog[i].measureT[m]); 53 N++; 54 } 55 } 43 56 } 57 58 plot_defaults (&graphdata); 59 graphdata.xmin = PlotMmin; 60 graphdata.xmax = PlotMmax; 61 graphdata.ymin = PlotdMmin; 62 graphdata.ymax = PlotdMmax; 63 plot_list (&graphdata, xlist, ylist, N, "mag vs dmag", "%s.Mag.png", OUTROOT); 64 65 plot_defaults (&graphdata); 66 graphdata.ymin = PlotdMmin; 67 graphdata.ymax = PlotdMmax; 68 plot_list (&graphdata, ilist, ylist, N, "imag vs dmag", "%s.iMag.png", OUTROOT); 44 69 } 45 46 plot_defaults (&graphdata);47 graphdata.xmin = PlotMmin;48 graphdata.xmax = PlotMmax;49 graphdata.ymin = PlotdMmin;50 graphdata.ymax = PlotdMmax;51 plot_list (&graphdata, xlist, ylist, N, "mag vs dmag", "%s.Mag.png", OUTROOT);52 53 plot_defaults (&graphdata);54 graphdata.ymin = PlotdMmin;55 graphdata.ymax = PlotdMmax;56 plot_list (&graphdata, ilist, ylist, N, "imag vs dmag", "%s.iMag.png", OUTROOT);57 70 free (xlist); 58 71 free (ylist); -
branches/czw_branch/20110406/Ohana/src/relphot/src/reload_catalogs.c
r15743 r31606 1 1 # include "relphot.h" 2 3 # define TIMESTAMP(TIME) \ 4 gettimeofday (&stop, (void *) NULL); \ 5 dtime = DTIME (stop, start); \ 6 TIME += dtime; \ 7 gettimeofday (&start, (void *) NULL); 2 8 3 9 void reload_catalogs (SkyList *skylist) { … … 8 14 Catalog catalog; 9 15 16 struct timeval start, stop; 17 double dtime = 0.0; 18 double time1 = 0.0; 19 double time2 = 0.0; 20 double time3 = 0.0; 21 double time4 = 0.0; 22 double time5 = 0.0; 23 double time6 = 0.0; 24 double time7 = 0.0; 25 10 26 if (VERBOSE) fprintf (stderr, "re-loading catalog data\n"); 11 27 12 28 /* load data from each region file */ 13 29 for (i = 0; i < skylist[0].Nregions; i++) { 30 gettimeofday (&start, (void *) NULL); 14 31 catalog.filename = skylist[0].filename[i]; 15 32 … … 20 37 continue; 21 38 } 39 TIMESTAMP(time1); 22 40 23 41 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data … … 36 54 continue; 37 55 } 56 TIMESTAMP(time2); 57 58 populate_tiny_values(&catalog); 38 59 39 60 initImageBins (&catalog, 1); 40 61 initMosaicBins (&catalog, 1); 41 initGridBins (&catalog, 1); 62 initGridBins (&catalog, 1); 63 TIMESTAMP(time3); 42 64 43 findImages (&catalog, 1); 44 findMosaics (&catalog, 1); 65 findImages (&catalog, 1); // FX 66 findMosaics (&catalog, 1); // 67 TIMESTAMP(time4); 45 68 46 69 setMrelFinal (&catalog); 70 TIMESTAMP(time5); 71 47 72 dvo_catalog_save (&catalog, VERBOSE); 48 73 dvo_catalog_unlock (&catalog); 74 75 free_tiny_values(&catalog); 49 76 dvo_catalog_free (&catalog); 77 TIMESTAMP(time6); 50 78 51 79 freeImageBins (1); 52 80 freeMosaicBins (1); 53 81 freeGridBins (1); 82 TIMESTAMP(time7); 54 83 } 84 85 fprintf (stderr, "time1 %f : find catalog\n", time1); 86 fprintf (stderr, "time2 %f : load catalog\n", time2); 87 fprintf (stderr, "time3 %f : init imbins\n", time3); 88 fprintf (stderr, "time4 %f : find images\n", time4); 89 fprintf (stderr, "time5 %f : set Mrel\n", time5); 90 fprintf (stderr, "time6 %f : save catalog\n", time6); 91 fprintf (stderr, "time7 %f : free catalog\n", time7); 55 92 } -
branches/czw_branch/20110406/Ohana/src/relphot/src/relphot.c
r30616 r31606 47 47 if (!dvo_image_load (&db, VERBOSE, FALSE)) Shutdown ("can't read image catalog %s", db.filename); 48 48 } 49 MARKTIME(" load image data: %f sec\n", dtime);49 MARKTIME("-- load image data: %f sec\n", dtime); 50 50 51 51 /* load regions and images based on specified sky patch */ … … 54 54 // XXX this is fairly lame: argv[1] is photcode if UserPatchSelect is true 55 55 skylist = load_images (&db, argv[1], &UserPatch, UserPatchSelect); 56 MARKTIME(" load images: %f sec\n", dtime);56 MARKTIME("-- load images: %f sec\n", dtime); 57 57 58 58 /* unlock, if we can (else, unlocked below) */ … … 61 61 /* load catalog data from region files */ 62 62 catalog = load_catalogs (skylist, &Ncatalog); 63 MARKTIME(" load catalog data: %f sec\n", dtime);63 MARKTIME("-- load catalog data: %f sec\n", dtime); 64 64 65 65 /* add in a loop over the catalogs calling dvo_catalog_chipcoords */ … … 67 67 /* match measurements with images, mosaics */ 68 68 initImageBins (catalog, Ncatalog); 69 MARKTIME(" make image bins: %f sec\n", dtime);69 MARKTIME("-- make image bins: %f sec\n", dtime); 70 70 71 71 initMosaicBins (catalog, Ncatalog); … … 74 74 75 75 findImages (catalog, Ncatalog); 76 MARKTIME(" set up image indexes: %f sec\n", dtime);76 MARKTIME("-- set up image indexes: %f sec\n", dtime); 77 77 78 78 findMosaics (catalog, Ncatalog); /* also sets Grid values */ 79 MARKTIME(" set up mosaic indexes: %f sec\n", dtime);79 MARKTIME("-- set up mosaic indexes: %f sec\n", dtime); 80 80 81 81 SAVEPLOT = FALSE; 82 82 83 83 setExclusions (catalog, Ncatalog); 84 85 global_stats (catalog, Ncatalog); 84 86 85 87 if (PLOTSTUFF) { … … 91 93 if (USE_GRID) { 92 94 int star_toofew; 93 94 # if (USE_DIRECT)95 // until we finish the grid analysis, do not reject stars out-of-hand based on ID_STAR_FEW96 // XXX this is kind of poor: need to have a better distinctions about STAR_BAD in setMrel vs getMrel97 star_toofew = STAR_TOOFEW;98 STAR_TOOFEW = 0;99 STAR_BAD = ID_STAR_POOR;100 101 showGridCount ();102 setMgridDirect (catalog, Ncatalog);103 104 STAR_BAD = ID_STAR_POOR | ID_STAR_FEW;105 STAR_TOOFEW = star_toofew;106 107 dump_grid ();108 exit (0);109 110 # else111 95 112 96 // until we finish the grid analysis, do not reject stars out-of-hand based on ID_STAR_FEW … … 122 106 STAR_BAD = ID_STAR_POOR | ID_STAR_FEW; 123 107 STAR_TOOFEW = star_toofew; 124 # endif125 108 } 126 109 … … 140 123 plot_chisq (catalog, Ncatalog); 141 124 } 142 if ((i == 1) || (i == 5) || (i == 9) || (i == 13)) clean_measures (catalog, Ncatalog, FALSE); 143 if ((i == 2) || (i == 6) || (i == 10) || (i == 14)) clean_stars (catalog, Ncatalog); 144 if ((i == 4) || (i == 8) || (i == 12) || (i == 16)) clean_mosaics (); 145 if ((i == 4) || (i == 8) || (i == 12) || (i == 16)) clean_images (); 125 if (i % 6 == 1) rationalize_mosaics (catalog, Ncatalog); 126 // if (i % 6 == 1) rationalize_images (); 127 if (i % 6 == 2) clean_measures (catalog, Ncatalog, FALSE); 128 if (i % 6 == 3) clean_stars (catalog, Ncatalog); 129 if (i % 6 == 5) clean_mosaics (); 130 if (i % 6 == 5) clean_images (); 131 132 // if ((i == 1) || (i == 5) || (i == 9) || (i == 13)) clean_measures (catalog, Ncatalog, FALSE); 133 // if ((i == 2) || (i == 6) || (i == 10) || (i == 14)) clean_stars (catalog, Ncatalog); 134 // if ((i == 4) || (i == 8) || (i == 12) || (i == 16)) clean_mosaics (); 135 // if ((i == 4) || (i == 8) || (i == 12) || (i == 16)) clean_images (); 146 136 global_stats (catalog, Ncatalog); 137 MARKTIME("-- finished loop %d: %f sec\n", i, dtime); 147 138 } 148 139 149 SAVEPLOT = TRUE; 150 plot_scatter (catalog, Ncatalog); 151 plot_grid (catalog); 152 plot_mosaics (); 153 plot_images (); 154 plot_stars (catalog, Ncatalog); 155 plot_chisq (catalog, Ncatalog); 156 140 if (PLOTSTUFF) { 141 plot_scatter (catalog, Ncatalog); 142 plot_grid (catalog); 143 plot_mosaics (); 144 plot_images (); 145 plot_stars (catalog, Ncatalog); 146 plot_chisq (catalog, Ncatalog); 147 } 148 157 149 if (USE_GRID) dump_grid (); 158 150 if (!UPDATE) exit (0); … … 161 153 setMcal (catalog, TRUE); 162 154 setMmos (catalog, TRUE); 155 MARKTIME("-- finalize Mcal values: %f sec\n", dtime); 163 156 164 157 /* at this point, we have correct cal coeffs in the image/mosaic structures */ 165 for (i = 0; i < Ncatalog; i++) dvo_catalog_free (&catalog[i]); 158 for (i = 0; i < Ncatalog; i++) { 159 free_tiny_values (&catalog[i]); 160 dvo_catalog_free (&catalog[i]); 161 } 166 162 freeImageBins (Ncatalog); 167 163 freeMosaicBins (Ncatalog); … … 170 166 /* load catalog data from region files, update Mrel include all data */ 171 167 reload_catalogs (skylist); 168 MARKTIME("-- updated all catalogs: %f sec\n", dtime); 169 172 170 setMcalFinal (); 173 174 171 reload_images (&db); 175 172 -
branches/czw_branch/20110406/Ohana/src/relphot/src/relphot_objects.c
r28241 r31606 3 3 int relphot_objects () { 4 4 5 off_t i, j, k , m;5 off_t i, j, k; 6 6 int Nsecfilt; 7 7 … … 38 38 } 39 39 40 // XXX consider what gets reset (only PHOTOM flags)40 // reset 41 41 if (RESET) { 42 42 Nsecfilt = catalog.Nsecfilt; … … 51 51 catalog.secfilt[j*Nsecfilt + k].Ncode = 0; 52 52 catalog.secfilt[j*Nsecfilt + k].Nused = 0; 53 } 54 m = catalog.average[j].measureOffset; 55 for (k = 0; k < catalog.average[j].Nmeasure; k++) { 56 catalog.measure[m+k].dbFlags = 0; 57 catalog.measure[m+k].Mcal = 0; 53 // XXX reset the photometry flags for secfilt entries? 58 54 } 59 55 } -
branches/czw_branch/20110406/Ohana/src/relphot/src/select_images.c
r31160 r31606 64 64 DmaxSkyRegion = -90.0; 65 65 66 // FILE *ftest = fopen ("relphot.dump.dat", "w"); 67 66 68 /* compare with each region file */ 67 69 for (i = 0; i < skylist[0].Nregions; i++) { … … 117 119 /* exclude images by photcode */ 118 120 ecode = GetPhotcodeEquivCodebyCode (timage[i].photcode); 119 if (ecode != photcode[0].code) continue; 121 found = FALSE; 122 int Ns; 123 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { 124 if (ecode == photcodes[Ns][0].code) found = TRUE; 125 } 126 if (!found) continue; 120 127 121 128 /* exclude images by time */ … … 130 137 continue; 131 138 } 139 140 // XXX temporary test : record center coords for each accepted and rejected chip/mosaic 141 // double RAo, DECo; 132 142 133 143 /* define image corners - note the DIS images (mosaic phu) are special */ … … 138 148 Xi[3] = -0.5*timage[i].NX; Yi[3] = +0.5*timage[i].NY; 139 149 Xi[4] = -0.5*timage[i].NX; Yi[4] = -0.5*timage[i].NY; 150 // XY_to_RD(&RAo, &DECo, 0.0, 0.0, &timage[i].coords); 140 151 } else { 141 152 Xi[0] = 0; Yi[0] = 0; … … 144 155 Xi[3] = 0; Yi[3] = timage[i].NY; 145 156 Xi[4] = 0; Yi[4] = 0; 157 // XY_to_RD(&RAo, &DECo, 0.5*timage[i].NX, 0.5*timage[i].NY, &timage[i].coords); 146 158 } 147 159 found = FALSE; 148 160 149 161 /* transform corners to ra,dec -- costs ~3sec for 3M images (pikake) */ 150 double RminImage = 360.0;151 double RmaxImage = 0.0;162 double RminImage = RmidSkyRegion + 180.0; 163 double RmaxImage = RmidSkyRegion - 180.0; 152 164 double DminImage = +90.0; 153 165 double DmaxImage = -90.0; … … 218 230 219 231 found_it: 232 // XXX We claim this is a good image: write to a test file 233 // fprintf (ftest, "%s : %lf %lf : %f %f %d %x\n", timage[i].name, RAo, DECo, timage[i].Mcal, timage[i].dMcal, timage[i].nstar, timage[i].flags); 234 220 235 image[nimage] = timage[i]; 221 236 /* always allow 'few' images to succeed, if possible */ … … 239 254 } 240 255 MARKTIME("finish image selection: %f sec\n", dtime); 256 257 // fclose (ftest); 241 258 242 259 if (VERBOSE) fprintf (stderr, "found "OFF_T_FMT" images\n", nimage); -
branches/czw_branch/20110406/Ohana/src/relphot/src/setExclusions.c
r28241 r31606 1 1 # include "relphot.h" 2 3 // this function sets the NOCAL and AREA dbFlags bits for the MeasureTiny elements these 4 // are used elsewhere (StarOps.c, ImageOps.c, MosaicOps.c, GridOps.c, etc) to skip bad 5 // measurements. The only exception is 'setMave' which is called by 'relphot_objects', 6 // and uses the bits read from disk as the test 2 7 3 8 int setExclusions (Catalog *catalog, int Ncatalog) { 4 9 5 10 off_t i, j, k, m, Narea, Nnocal, Ngood; 6 int ecode ;11 int ecode, found, Ns; 7 12 Coords *coords; 8 13 double r, d, x, y; … … 11 16 for (i = 0; i < Ncatalog; i++) { 12 17 for (j = 0; j < catalog[i].Naverage; j++) { 13 m = catalog[i].average [j].measureOffset;14 for (k = 0; k < catalog[i].average [j].Nmeasure; k++, m++) {18 m = catalog[i].averageT[j].measureOffset; 19 for (k = 0; k < catalog[i].averageT[j].Nmeasure; k++, m++) { 15 20 16 21 /* select measurements by photcode */ 17 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measure[m].photcode); 18 if (ecode != photcode[0].code) goto mark_nocal; 22 ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[m].photcode); 23 found = FALSE; 24 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { 25 if (ecode == photcodes[Ns][0].code) found = TRUE; 26 } 27 if (!found) goto mark_nocal; 19 28 20 29 /* select measurements by time */ 21 30 if (TimeSelect) { 22 if (catalog[i].measure [m].t < TSTART) goto mark_nocal;23 if (catalog[i].measure [m].t > TSTOP) goto mark_nocal;31 if (catalog[i].measureT[m].t < TSTART) goto mark_nocal; 32 if (catalog[i].measureT[m].t > TSTOP) goto mark_nocal; 24 33 } 25 34 26 35 /* select measurements by mag limit */ 27 36 if (AreaSelect) { 28 r = catalog[i].average [j].R + catalog[i].measure[m].dR / 3600.0;29 d = catalog[i].average [j].D + catalog[i].measure[m].dD / 3600.0;37 r = catalog[i].averageT[j].R + catalog[i].measureT[m].dR / 3600.0; 38 d = catalog[i].averageT[j].D + catalog[i].measureT[m].dD / 3600.0; 30 39 if ((coords = getCoords (m, i)) == NULL) goto markbad; 31 40 RD_to_XY (&x, &y, r, d, coords); … … 39 48 40 49 markbad: 41 catalog[i].measure [m].dbFlags |= ID_MEAS_AREA;50 catalog[i].measureT[m].dbFlags |= ID_MEAS_AREA; 42 51 Narea ++; 43 52 continue; 44 53 45 54 mark_nocal: 46 catalog[i].measure [m].dbFlags |= ID_MEAS_NOCAL;55 catalog[i].measureT[m].dbFlags |= ID_MEAS_NOCAL; 47 56 Nnocal ++; 48 57 continue; -
branches/czw_branch/20110406/Ohana/src/relphot/src/setMrelFinal.c
r29001 r31606 1 1 # include "relphot.h" 2 3 // we've just reloaded the data from disk; we now need to apply the Image/Mosaic/Grid 4 // calibrations determined by the rest of the program. We also need to set the final 5 // output dbFlags values 2 6 3 7 void setMrelFinal (Catalog *catalog) { … … 9 13 if (RESET) { 10 14 11 for (i = 0; i < catalog[0].Naverage; i++) { 12 catalog[0].secfilt[PhotNsec*i+PhotSec].M = NAN; 13 catalog[0].secfilt[PhotNsec*i+PhotSec].dM = NAN; 14 catalog[0].secfilt[PhotNsec*i+PhotSec].Xm = NAN_S_SHORT; 15 int Nsecfilt = GetPhotcodeNsecfilt (); 15 16 16 m = catalog[0].average[i].measureOffset;17 for (j = 0; j < catalog[0].average[i].Nmeasure; j++, m++) {17 int Ns; 18 for (Ns = 0; Ns < Nphotcodes; Ns++) { 18 19 19 /* select measurements by photcode */ 20 ecode = GetPhotcodeEquivCodebyCode (catalog[0].measure[m].photcode); 21 if (ecode != photcode[0].code) continue; 20 int thisCode = photcodes[Ns][0].code; 21 int Nsec = GetPhotcodeNsec(thisCode); 22 23 for (i = 0; i < catalog[0].Naverage; i++) { 24 catalog[0].secfilt[Nsecfilt*i+Nsec].M = NAN; 25 catalog[0].secfilt[Nsecfilt*i+Nsec].dM = NAN; 26 catalog[0].secfilt[Nsecfilt*i+Nsec].Xm = NAN_S_SHORT; 27 28 m = catalog[0].average[i].measureOffset; 29 for (j = 0; j < catalog[0].average[i].Nmeasure; j++, m++) { 22 30 23 /* select measurements by time */ 24 if (TimeSelect) { 25 if (catalog[0].measure[m].t < TSTART) continue; 26 if (catalog[0].measure[m].t > TSTOP) continue; 31 // skip measurements that do not match the current photcode 32 ecode = GetPhotcodeEquivCodebyCode (catalog[0].measure[m].photcode); 33 if (ecode != thisCode) { continue; } 34 35 /* select measurements by time */ 36 if (TimeSelect) { 37 if (catalog[0].measure[m].t < TSTART) continue; 38 if (catalog[0].measure[m].t > TSTOP) continue; 39 } 40 41 catalog[0].measure[m].Mcal = 0; 42 catalog[0].measure[m].dbFlags &= 0xff00; 43 catalog[0].measure[m].dbFlags &= ~ID_MEAS_POOR_PHOTOM; 44 catalog[0].measure[m].dbFlags &= ~ID_MEAS_SKIP_PHOTOM; 45 catalog[0].measure[m].dbFlags &= ~ID_MEAS_AREA; 46 catalog[0].measure[m].dbFlags &= ~ID_MEAS_NOCAL; 27 47 } 28 29 catalog[0].measure[m].Mcal = 0;30 catalog[0].measure[m].dbFlags &= 0xff00;31 catalog[0].measure[m].dbFlags &= ~ID_MEAS_POOR_PHOTOM;32 catalog[0].measure[m].dbFlags &= ~ID_MEAS_SKIP_PHOTOM;33 catalog[0].measure[m].dbFlags &= ~ID_MEAS_AREA;34 catalog[0].measure[m].dbFlags &= ~ID_MEAS_NOCAL;35 48 } 36 49 } 37 50 } 38 51 52 // this sets flags in the measureT element, not the measure element 39 53 setExclusions (catalog, 1); /* mark by area */ 40 54 … … 53 67 setMcalOutput (catalog, 1); 54 68 55 /* clear ID_STAR_POOR, ID_STAR_FEW, ID_MEAS_NOCAL values before writing ??? */ 69 int Nsecfilt = GetPhotcodeNsecfilt (); 70 71 /* clear ID_STAR_POOR, ID_STAR_FEW values before writing ??? */ 72 /* ID_MEAS_NOCAL is an internal bit, so it should be cleared */ 56 73 for (i = 0; i < catalog[0].Naverage; i++) { 57 74 catalog[0].average[i].flags &= ~ID_STAR_FEW; 58 75 catalog[0].average[i].flags &= ~ID_STAR_POOR; 76 for (j = 0; j < Nsecfilt; j++) { 77 catalog[0].secfilt[i*Nsecfilt+j].flags &= ~ID_STAR_FEW; 78 catalog[0].secfilt[i*Nsecfilt+j].flags &= ~ID_STAR_POOR; 79 } 59 80 m = catalog[0].average[i].measureOffset; 60 81 for (j = 0; j < catalog[0].average[i].Nmeasure; j++, m++) { … … 68 89 69 90 off_t i, k, m; 70 int ecode ;91 int ecode, found, Ns; 71 92 off_t Ntot, Ntry, Nkeep, Nskip; 72 93 float mag; … … 90 111 91 112 /* clear SKIP for all measures at first */ 92 catalog[0].measure [m].dbFlags &= ~ID_MEAS_SKIP_PHOTOM;113 catalog[0].measureT[m].dbFlags &= ~ID_MEAS_SKIP_PHOTOM; 93 114 94 115 /** never use these measurements (wrong photcode, bad time range) */ 95 116 /* skipped via NOCAL, don't mark as skipped */ 96 117 ecode = GetPhotcodeEquivCodebyCode (catalog[0].measure[m].photcode); 97 if (ecode != photcode[0].code) continue; 118 found = FALSE; 119 for (Ns = 0; !found && (Ns < Nphotcodes); Ns++) { 120 if (ecode == photcodes[Ns][0].code) found = TRUE; 121 } 122 if (!found) continue; 98 123 99 124 /* skip measurements by time range */ … … 134 159 135 160 skip: 136 catalog[0].measure[m].dbFlags |= ID_MEAS_SKIP_PHOTOM; 161 catalog[0].measure [m].dbFlags |= ID_MEAS_SKIP_PHOTOM; 162 catalog[0].measureT[m].dbFlags |= ID_MEAS_SKIP_PHOTOM; 137 163 Nskip ++; 138 164 } -
branches/czw_branch/20110406/Ohana/src/skycalc/Makefile
r30609 r31606 75 75 76 76 %.install: 77 make$(DESTBIN)/$*77 $(MAKE) $(DESTBIN)/$* 78 78 79 79 install: 80 for i in $(INSTALL); do make$$i.install || exit; done80 for i in $(INSTALL); do $(MAKE) $$i.install || exit; done -
branches/czw_branch/20110406/Ohana/src/tools/Makefile
r29938 r31606 57 57 58 58 %.install: 59 make$(DESTBIN)/$*59 $(MAKE) $(DESTBIN)/$* 60 60 61 61 install: 62 for i in $(PROGRAMS); do make$$i.install || exit; done62 for i in $(PROGRAMS); do $(MAKE) $$i.install || exit; done 63 63 64 64 -
branches/czw_branch/20110406/dbconfig/changes.txt
- Property svn:mergeinfo deleted
r31434 r31606 2132 2132 UPDATE dbversion set schema_version = '1.1.70', updated= CURRENT_TIMESTAMP(); 2133 2133 2134 -- heather discovered that we need keys for addRun: 2135 2136 alter table addRun add key(stage), add key (stage_id); -
branches/czw_branch/20110406/ippScripts/scripts/camera_exp.pl
r30071 r31606 153 153 } 154 154 chomp $cmdflags; 155 156 { # Determine if FWHM is too large to bother continuing. 157 my $command = "$ppConfigDump -camera $camera -dump-camera -"; 158 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 159 run(command => $command, verbose => $verbose); 160 unless ($success) { 161 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 162 &my_die("Unable to perform ppConfigDump: $error_code", $cam_id, $PS_EXIT_CONFIG_ERROR); 163 } 164 my $cameraConfig = $mdcParser->parse(join "", @$stdout_buf) or 165 &my_die("Unable to parse metadata config doc", $cam_id, $PS_EXIT_CONFIG_ERROR); 166 167 my $maxFWHM = metadataLookupStr($cameraConfig, 'MAX_ALLOWED_FWHM'); 168 if ($maxFWHM) { 169 my $expFWHM; 170 ($expFWHM) = $cmdflags =~ /-fwhm_major (\d+)/; 171 172 if ($expFWHM > $maxFWHM) { 173 print "Setting quality to 4007 due to large FWHM: exposure: $expFWHM maximum: $maxFWHM\n"; 174 $cmdflags .= " -quality 4007 "; # This corresponds to PSASTRO_ERR_DATA 175 $no_op = 1; 176 } 177 } 178 } 155 179 } 156 180 -
branches/czw_branch/20110406/ippScripts/scripts/dist_advancerun.pl
r30489 r31606 114 114 $tool_cmd = "$staticskytool -sky_id"; 115 115 $list_mode = "-result"; 116 $component_key = " ";116 $component_key = "skycell_id"; 117 117 } elsif ($stage eq "diff") { 118 118 $tool_cmd = "$difftool -diff_id"; -
branches/czw_branch/20110406/ippScripts/scripts/dist_bundle.pl
r30922 r31606 62 62 my $streaksrelease = can_run('streaksrelease') or (warn "Can't find streaksrelease" and $missing_tools = 1); 63 63 my $bgtool = can_run('bgtool') or (warn "Can't find bgtool" and $missing_tools = 1); 64 my $staticskytool = can_run('staticskytool') or (warn "Can't find staticskytool" and $missing_tools = 1); 64 65 my $file_cmd = can_run('file') or (warn "can't find program file" and $missing_tools = 1); 65 66 my $zcat = can_run('zcat') or (warn "can't find program zcat" and $missing_tools = 1); … … 106 107 defined $stage_id and 107 108 defined $component and 108 defined $exp_type and109 109 defined $path_base and 110 110 defined $outroot; 111 111 112 if ($stage eq 'raw' and !$clean and !$no_magic) { 113 114 # for raw stage need to have exposure type defined and if the type is OBJECT we need 115 # a chip_path_base so we can find the chip mask file 116 if (!defined $exp_type or ($exp_type eq 'OBJECT' and !defined $chip_path_base)) { 117 pod2usage( -msg => "Required options: --chip_path_base --exp_type for raw stage", -exitval => 3); 118 } 119 } 120 112 121 $ipprc->redirect_output($logfile) if $logfile; 113 122 114 if ($stage eq 'raw' and !$clean and !$no_magic) {115 # need to be able to find chip mask file116 if ($exp_type eq 'OBJECT' and !defined $chip_path_base) {117 pod2usage( -msg => "Required options: --chip_path_base for raw stage", -exitval => 3);118 }119 }120 121 123 $ipprc->define_camera($camera); 122 124 123 125 $ipprc->outroot_prepare($outroot); 124 126 127 my $num_sky_inputs; 128 if ($stage eq 'sky') { 129 $num_sky_inputs = get_num_sky_inputs($stage_id); 130 } 125 131 # Get the list of data products for this component 126 132 # note: We my_die in get_file_list if something goes wrong. 127 133 128 my $file_list = get_file_list($stage, $component, $path_base, $clean );134 my $file_list = get_file_list($stage, $component, $path_base, $clean, $num_sky_inputs); 129 135 130 136 if (($stage ne 'raw') and ($stage ne 'fake') and !$poor_quality) { … … 184 190 # it must exist) 185 191 next if $poor_quality; 192 193 # skip file stats file. Due to a bug the update process destroys them sometimes 194 # XXX: perhaps only do this for stages where we know that this happens 195 next if $file_rule =~ /STATS/; 186 196 187 197 &my_die("failed to resolve $file_name", $component, $PS_EXIT_DATA_ERROR); … … 480 490 my $path_base = shift; 481 491 my $clean = shift; 492 my $num_sky_inputs = shift; 482 493 483 494 my @file_list; … … 531 542 $config_file_rule = "PPSTACK.CONFIG"; 532 543 } elsif ($stage eq "sky") { 533 $config_file_rule = "PSPHOT.STACK.CONFIG"; 544 if ($num_sky_inputs > 1) { 545 $config_file_rule = "PSPHOT.STACK.CONFIG"; 546 } else { 547 $config_file_rule = "PSPHOT.SKY.CONFIG"; 548 } 534 549 } else { 535 550 &my_die("$stage is not a valid stage", $component, $PS_EXIT_CONFIG_ERROR); … … 627 642 return \@file_list; 628 643 } 644 sub get_num_sky_inputs { 645 my $sky_id = shift; 646 647 my $command = "$staticskytool -inputs -sky_id $sky_id -simple"; 648 $command .= " -dbname $dbname" if $dbname; 649 $command .= " | wc"; 650 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 651 run(command => $command, verbose => $verbose); 652 unless ($success) { 653 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 654 &my_die("Unable to perform $command: $error_code", $component, $error_code); 655 } 656 my ($num_inputs, $words, $chars) = split " ", (join "", @$stdout_buf); 657 if (!$num_inputs) { 658 $num_inputs = "undefined" if !defined $num_inputs; 659 &my_die("unexpected number of static sky inputs $num_inputs", $PS_EXIT_PROG_ERROR, $component, $error_code); 660 } 661 662 return $num_inputs; 663 } 629 664 630 665 sub my_die -
branches/czw_branch/20110406/ippScripts/scripts/ipp_apply_burntool_single.pl
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20110404/ippScripts/scripts/ipp_apply_burntool_single.pl (added) merged: 31439 /trunk/ippScripts/scripts/ipp_apply_burntool_single.pl merged: 31453
- Property svn:mergeinfo changed
-
branches/czw_branch/20110406/ippScripts/scripts/magic_destreak.pl
r31432 r31606 364 364 } 365 365 else { 366 print "Did not add sources because the do not appear to exist. This may be an error.\n";366 print "Did not add sources because they do not appear to exist. This may be an error.\n"; 367 367 } 368 368 $command .= " -skycelllist $skycell_list" if defined $skycell_list; -
branches/czw_branch/20110406/ippScripts/scripts/receive_file.pl
r30674 r31606 224 224 $stage = 'sky'; 225 225 # XXX: This should be skycell, but the distribution code uses exposure 226 $comp_name = ' exposure';227 $current_component = $comp_name;226 $comp_name = 'skycell_id'; 227 # $current_component = $comp_name; 228 228 } else { 229 229 &my_die( "unexpected run type line found in $filename: $runType\n", $file_id, $PS_EXIT_UNKNOWN_ERROR); … … 237 237 $new_workdir_value = "$workdir/$destdir"; 238 238 } 239 240 if ($stage eq 'sky') { 241 # the dbinfo file for a skyRun only has one component and it doesn't contain 242 # skycell_id which is the way components are listed in the dirinfo file. 243 my @ids = keys %$components; 244 &my_die( "unexpected number of components scalar @ids found in staticsky dirinfo file\n", $file_id, $PS_EXIT_UNKNOWN_ERROR) if scalar @ids != 1; 245 $current_component = $ids[0]; 246 } 247 239 248 my $component_dir; 240 249 if ($current_component) { -
branches/czw_branch/20110406/ippScripts/scripts/register_imfile.pl
r31060 r31606 40 40 41 41 my ($cache, $exp_id, $tmp_class_id, $tmp_exp_name, $uri, $bytes, $md5sum, $dbname, $verbose, $no_update, $no_op, $logfile); 42 my ($sunrise, $sunset );42 my ($sunrise, $sunset, $summit_dateobs); 43 43 GetOptions( 44 44 'caches' => \$cache, … … 51 51 'sunrise=s' => \$sunrise, 52 52 'sunset=s' => \$sunset, 53 'summit_dateobs=s' => \$summit_dateobs, 53 54 'dbname|d=s' => \$dbname, # Database name 54 55 'verbose' => \$verbose, # Print to stdout … … 181 182 if (uc(&value_for_flag ($cmdflags, "NULL", "-exp_type")) eq "NULL") { &my_die_for_add ("exp_type not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 182 183 my $dateobs = &value_for_flag($cmdflags, 0.0, "-dateobs"); 184 unless($summit_dateobs) { 185 $summit_dateobs = $dateobs; 186 } 187 183 188 my $exp_type = &value_for_flag($cmdflags, "NULL", "-exp_type"); 184 189 … … 196 201 $command .= " -data_state full"; 197 202 } 198 elsif (is_daytime($ dateobs,$sunrise,$sunset)) {203 elsif (is_daytime($summit_dateobs,$sunrise,$sunset)) { 199 204 printf STDERR "This is a daytime exposure.\n"; 200 205 $command .= " -data_state full"; … … 267 272 268 273 if ((abs($burntoolStateCurrent) != $burntoolStateTarget)&& 269 (!is_daytime($ dateobs,$sunrise,$sunset))&&274 (!is_daytime($summit_dateobs,$sunrise,$sunset))&& 270 275 (!is_ccim($tmp_exp_name,$exp_type))) { 271 276 my $mdcParser = PS::IPP::Metadata::Config->new; -
branches/czw_branch/20110406/ippScripts/scripts/warp_skycell.pl
r30825 r31606 72 72 73 73 my ($logDest, $traceDest); 74 my $do_stats; 74 75 if ($run_state eq 'new') { 75 76 $logDest = prepare_output("LOG.EXP", $outroot, $skycell_id, 0); 76 77 $traceDest = prepare_output("TRACE.EXP", $outroot, $skycell_id, 1); 78 $do_stats = 1; 77 79 } elsif ($run_state eq 'update') { 78 80 $logDest = prepare_output("LOG.EXP.UPDATE", $outroot, $skycell_id, 1); … … 162 164 my $outputBin1 = prepare_output ("PSWARP.BIN1", $outroot, $skycell_id, 1); 163 165 my $outputBin2 = prepare_output ("PSWARP.BIN2", $outroot, $skycell_id, 1); 164 my $outputStats = prepare_output ("SKYCELL.STATS", $outroot, $skycell_id, 1); 166 my $outputStats; 167 if ($do_stats) { 168 $outputStats = prepare_output ("SKYCELL.STATS", $outroot, $skycell_id, 1) if $do_stats; 169 } 165 170 my $configuration; 166 171 … … 257 262 # Run pswarp 258 263 my $cmdflags; 259 my $do_stats;260 264 unless ($no_op) { 261 265 my $command = "$pswarp"; … … 279 283 if ($run_state eq 'new') { 280 284 $command .= " -dumpconfig $configuration"; 281 $do_stats = 1;282 285 } else { 283 286 $command .= " -ipprc $configuration"; -
branches/czw_branch/20110406/ippTasks/Makefile.am
r30375 r31606 41 41 lossy_compress.pro \ 42 42 background.pro \ 43 diffphot.pro 43 diffphot.pro \ 44 lap.pro 44 45 45 46 other_files = \ -
branches/czw_branch/20110406/ippTasks/register.pro
r30992 r31606 294 294 book getword regPendingImfile $pageName workdir -var WORKDIR_TEMPLATE 295 295 book getword regPendingImfile $pageName dbname -var DBNAME 296 book getword regPendingImfile $pageName summit_dateobs -var SUMMIT_DATEOBS 296 297 297 298 # EXP_TAG is used to generate the unique, but human-readable, filenames … … 320 321 # XXX register_imfile.pl differs from the standard script : it does not have an 'outroot' argument, and it does not take '--redirect' 321 322 $run = register_imfile.pl --exp_id $EXP_ID --tmp_class_id $TMP_CLASS_ID --tmp_exp_name $TMP_EXP_NAME --uri $URI --logfile $logfile --bytes $BYTES --md5sum $MD5SUM 322 $run = $run --sunset $sunset --sunrise $sunrise 323 $run = $run --sunset $sunset --sunrise $sunrise --summit_dateobs $SUMMIT_DATEOBS 323 324 add_standard_args run 324 325 -
branches/czw_branch/20110406/ippToPsps/jython/batch.py
r31434 r31606 32 32 "../config/2/tables.vot" 33 33 ''' 34 def __init__(self, logger, batchType, inputFitsPath="", survey="", useFullTables=False): 34 def __init__(self, 35 logger, 36 gpc1Db, 37 ippToPspsDb, 38 scratchDb, 39 id, 40 batchType, 41 inputFitsPath="", 42 survey="", 43 useFullTables=False): 44 45 self.everythingOK = False 46 self.readHeader = False 35 47 36 48 # set up logging … … 40 52 41 53 # set up class variables 54 self.id = id 55 self.gpc1Db = gpc1Db 56 self.ippToPspsDb = ippToPspsDb 57 self.scratchDb = scratchDb 42 58 self.batchType = batchType; 43 59 self.pspsVoTableFilePath = "../config/" + batchType + "/tables.vot" … … 46 62 self.useFullTables = useFullTables 47 63 64 if self.alreadyProcessed(): return 65 66 # do we have an input file? 67 if self.inputFitsPath != "": 68 69 if not self.readPrimaryHeader(): return 70 48 71 # TODO 49 72 self.tablesToExport = [] … … 51 74 # open config 52 75 doc = ElementTree(file="config.xml") 53 54 # create Gpc1Db object55 self.gpc1Db = Gpc1Db(self.logger)56 self.ippToPspsDb = IppToPspsDb(logger)57 self.scratchDb = ScratchDb(logger, self.useFullTables)58 76 59 77 if self.survey != "": … … 88 106 self.dateStr = now.strftime("%Y-%m-%d") 89 107 90 if self.inputFitsPath != "":91 file = open(self.inputFitsPath)92 self.header = self.parseFitsHeader(file)93 self.logger.info("Read primary and found " + str(len(self.header)) + " header cards")94 # TODO close file?95 96 108 # create DVO tables if accessing DVO directly 97 109 if not self.useFullTables: self.scratchDb.createDvoTables() 98 110 111 self.everythingOK = True 112 99 113 ''' 100 114 Destructor … … 103 117 104 118 self.logger.debug("Batch destructor") 119 120 121 ''' 122 Reads the primary header of the FITS file 123 ''' 124 def readPrimaryHeader(self): 125 126 if self.readHeader: return True 127 128 # does it exist? 129 if not os.path.isfile(self.inputFitsPath): 130 131 self.logger.error("Cannot read file at '" + self.inputFitsPath + "'") 132 return False 133 134 file = open(self.inputFitsPath) 135 self.header = self.parseFitsHeader(file) 136 self.logger.info("Read primary header and found " + str(len(self.header)) + " header cards") 137 # TODO close file? 138 139 self.readHeader = True 140 141 return True 105 142 106 143 … … 138 175 file.seek(index + 2880, 0) 139 176 140 if found != True: self.logger.error("...could not find extension '" + name + "'") 141 else: self.logger.info("...read header at '" + name + "' and found " + str(len(header)) + " header cards") 177 if found != True: 178 self.logger.error("...could not read header in extension '" + name + "'") 179 return 180 #else: self.logger.info("...read header at '" + name + "' and found " + str(len(header)) + " header cards") 142 181 143 182 return header … … 262 301 263 302 first = True 303 304 self.totalDetections = 0 264 305 for table in tables: 265 306 266 sql = "SELECT MIN(objID), MAX(objID) FROM " + table267 rs = self.scratchDb. stmt.executeQuery(sql)307 sql = "SELECT MIN(objID), MAX(objID), COUNT(objID) FROM " + table 308 rs = self.scratchDb.executeQuery(sql) 268 309 rs.first() 310 311 self.totalDetections = self.totalDetections + rs.getLong(3) 269 312 270 313 if first: … … 276 319 277 320 first = False 321 rs.close() 278 322 279 323 self.ippToPspsDb.updateMinMaxObjID(self.batchID, self.minObjID, self.maxObjID) 324 self.logger.info("Total detections = %ld min objID = %ld max objID = %ld" % (self.totalDetections, self.minObjID, self.maxObjID)) 325 280 326 281 327 ''' … … 313 359 self.pspsTables = stilts.treads(self.pspsVoTableFilePath) 314 360 for table in self.pspsTables: 315 self.logger. info("Creating PSPS table: " + table.name)361 self.logger.debug("Creating PSPS table: " + table.name) 316 362 table.write(self.scratchDb.url + '#' + table.name) 317 363 self.tablesToExport.append(table.name) … … 337 383 Accepts a regular expression filter so not all tables need to be imported 338 384 ''' 339 def importIppTables(self, filter ):385 def importIppTables(self, filter=""): 340 386 341 387 self.logger.info("Attempting to import tables from input FITS file") … … 347 393 match = re.match(filter, table.name) 348 394 if not match: continue 349 self.logger.info(" Reading IPP table " + table.name + " from FITS file")395 self.logger.info("Reading IPP table " + table.name + " from FITS file") 350 396 table = stilts.tpipe(table, cmd='explodeall') 351 397 352 398 # drop any previous tables before import 353 self.scratchDb.dropTable(table.name)399 #self.scratchDb.dropTable(table.name) 354 400 355 401 # IPP FITS files are littered with infinities, so remove these 356 self.logger. info("Removing Infinity values from all columns")402 self.logger.debug("Removing Infinity values from all columns") 357 403 table = stilts.tpipe(table, cmd='replaceval -Infinity null *') 358 404 table = stilts.tpipe(table, cmd='replaceval Infinity null *') … … 360 406 try: 361 407 table.write(self.scratchDb.url + '#' + table.name) 408 self.scratchDb.killLastConnectionID() 409 count = count + 1 362 410 except: 363 self.logger.exception(" Problem writing table '" + table.name + "' to the database")364 count = count + 1 411 self.logger.exception("Problem writing table '" + table.name + "' to the database") 412 365 413 366 414 self.logger.info("Done. Imported %d tables" % count) 367 368 415 self.indexIppTables() 369 416 … … 373 420 def exportPspsTablesToFits(self, regex="(.*)"): 374 421 375 self.logger.info("Replacing NULLs with -999 then exporting all PSPS tables to FITS")422 self.logger.info("Replacing NULLs with -999, changing tables names using regex: " + regex) 376 423 _tables = [] 377 424 378 self.logger.info(" Selecting database tables")425 self.logger.info("Selecting database tables") 379 426 for table in self.tablesToExport: 380 427 … … 383 430 384 431 # get everything from table 385 _table = stilts.tread(self.scratchDb.url + '#SELECT * FROM ' + table) 386 432 try: 433 _table = stilts.tread(self.scratchDb.url + '#SELECT * FROM ' + table) 434 self.scratchDb.killLastConnectionID() 435 except: 436 self.logger.exception("Could not read from DB table: " + table) 437 return False 438 387 439 # replace nulls and empty fields with weird PSPS -999 pseudo-null 388 440 _table = stilts.tpipe(_table, cmd='replaceval "" -999 *') … … 395 447 _tables.append(_table) 396 448 397 self.logger.info(" Writing to FITS file '" + self.outputFitsPath + "'...") 398 stilts.twrites(_tables, self.outputFitsPath, fmt='fits') 399 self.logger.info(" ...done") 400 self.ippToPspsDb.updateProcessed(self.batchID, 1) 449 self.logger.info("Writing to FITS file '" + self.outputFitsPath + "'...") 450 try: 451 stilts.twrites(_tables, self.outputFitsPath, fmt='fits') 452 self.ippToPspsDb.updateProcessed(self.batchID, 1) 453 except: 454 self.logger.exception("Could not write to FITS") 455 return False 456 457 return True 401 458 402 459 ''' … … 447 504 ''' 448 505 def alreadyProcessed(self): 449 self.logger.info("Not implemented") 450 451 452 506 self.logger.info("Not implemented") 507 508 509 ''' 510 Creates and publishes a batch 511 ''' 512 def run(self): 513 514 if not self.everythingOK: return 515 516 self.createEmptyPspsTables() 517 self.importIppTables() 518 if self.populatePspsTables(): 519 if self.exportPspsTablesToFits(): 520 self.writeBatchManifest() 521 self.createTarball() 522 self.publishToDatastore() 523 #self.reportNullsInAllPspsTables(False) 524 #sys.exit() 525 self.logger.info("Finished.") 526 527 -
branches/czw_branch/20110406/ippToPsps/jython/detectionbatch.py
r31434 r31606 6 6 from java.lang import * 7 7 from java.sql import * 8 8 9 from batch import Batch 9 10 from gpc1db import Gpc1Db 11 from ipptopspsdb import IppToPspsDb 12 from scratchdb import ScratchDb 10 13 11 14 import logging.config … … 19 22 Constructor 20 23 ''' 21 def __init__(self, logger, camID, inputFile, test=False, useFullTables=False): 24 def __init__(self, 25 logger, 26 gpc1Db, 27 ippToPspsDb, 28 scratchDb, 29 camID, 30 inputFile, 31 test=False, 32 useFullTables=False): 33 22 34 super(DetectionBatch, self).__init__( 23 35 logger, 36 gpc1Db, 37 ippToPspsDb, 38 scratchDb, 39 camID, 24 40 "detection", 25 41 inputFile, 26 "MD04", 27 useFullTables) # TODO 42 "MD04", # TODO 28 43 #"3PI") # TODO 29 30 self.logger.info("DetectionBatch constructor. Creating batch from: '" + inputFile + "'") 31 32 meta = self.gpc1Db.getCameraStageMeta(camID) 33 34 self.expID = meta[0]; 35 self.expName = meta[1]; 36 self.distGroup = meta[2]; 37 38 self.logger.info("Processing exposure with ID: %d, name: %s and distribution group: %s" % (self.expID, self.expName, self.distGroup)) 44 useFullTables) 45 46 if not self.everythingOK: return 47 48 # meta data to the log 49 self.logger.info("New Detection Batch:") 50 self.logger.info("Cam ID: %d" % self.id) 51 self.logger.info("file: %s" % inputFile) 52 self.logger.info("Exp ID: %d" % self.expID) 53 self.logger.info("Exp name: %s" % self.expName) 54 self.logger.info("Distribution group: %s" % self.distGroup) 39 55 40 56 # create an output filename, which is {expID}.FITS … … 167 183 ," + self.header['PCA2X0Y2'] + " \ 168 184 )" 169 self.scratchDb. stmt.execute(sql)185 self.scratchDb.execute(sql) 170 186 171 187 self.scratchDb.updateAllRows("FrameMeta", "surveyID", str(self.surveyID)) … … 184 200 self.scratchDb.dropTable(tableName) 185 201 sql = "CREATE TABLE " + tableName + " LIKE ImageMeta" 186 try: self.scratchDb. stmt.execute(sql)202 try: self.scratchDb.execute(sql) 187 203 except: pass 188 204 … … 310 326 )" 311 327 312 self.scratchDb. stmt.execute(sql)328 self.scratchDb.execute(sql) 313 329 self.scratchDb.updateFilterID(tableName, self.filter) 314 330 self.scratchDb.updateAllRows(tableName, "calibModNum", str(self.calibModNum)) 315 331 self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.dataRelease)) 316 self.totalNumPhotoRef = self.totalNumPhotoRef + int(header['NASTRO'])332 if 'NASTRO' in header: self.totalNumPhotoRef = self.totalNumPhotoRef + int(header['NASTRO']) 317 333 self.scratchDb.replaceNullsInThisColumn(tableName, "polyOrder", "0") 318 334 … … 327 343 self.scratchDb.dropTable(tableName) 328 344 sql = "CREATE TABLE " + tableName + " LIKE Detection" 329 try: self.scratchDb. stmt.execute(sql)345 try: self.scratchDb.execute(sql) 330 346 except: pass 331 347 … … 375 391 ,EXT_NSIGMA \ 376 392 FROM " + ota + "_psf" 377 378 self.scratchDb.stmt.execute(sql) 393 self.scratchDb.execute(sql) 379 394 380 395 # set obsTime 381 396 sql = "UPDATE " + tableName + " SET obsTime = %f, assocDate = '%s', activeFlag = 0" % (self.obsTime, self.dateStr) 382 self.scratchDb. stmt.execute(sql)397 self.scratchDb.execute(sql) 383 398 self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.dataRelease)) 384 399 self.scratchDb.updateAllRows(tableName, "historyModNum", "0") … … 387 402 self.scratchDb.updateFilterID(tableName, self.filter) 388 403 389 # now delete bad flux 404 # now delete bad flux and bad chip positions 390 405 self.scratchDb.reportAndDeleteRowsWithNULLS(tableName, "instFlux") 391 406 self.scratchDb.reportAndDeleteRowsWithNULLS(tableName, "peakADU") … … 401 416 self.scratchDb.dropTable(tableName) 402 417 sql = "CREATE TABLE " + tableName + " LIKE SkinnyObject" 403 try: self.scratchDb. stmt.execute(sql)418 try: self.scratchDb.execute(sql) 404 419 except: pass 405 420 … … 415 430 ,surveyID \ 416 431 FROM Detection_" + ota 417 self.scratchDb. stmt.execute(sql)432 self.scratchDb.execute(sql) 418 433 419 434 self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.dataRelease)) … … 429 444 self.scratchDb.dropTable(tableName) 430 445 sql = "CREATE TABLE " + tableName + " LIKE ObjectCalColor" 431 try: self.scratchDb. stmt.execute(sql)446 try: self.scratchDb.execute(sql) 432 447 except: pass 433 448 … … 443 458 ,filterID \ 444 459 FROM Detection_" + ota 445 self.scratchDb. stmt.execute(sql)460 self.scratchDb.execute(sql) 446 461 447 462 self.scratchDb.updateAllRows(tableName, "calibModNum", str(self.calibModNum)) … … 484 499 485 500 imageID = self.scratchDb.getImageIDFromExternID(sourceID, externID) 486 self.logger. info("Updating table '" + table + "' with DVO IDs using imageID = %d" % imageID)501 self.logger.debug("Updating table '" + table + "' with DVO IDs using imageID = %d" % imageID) 487 502 sql = "UPDATE IGNORE " + table + " AS a, " + self.scratchDb.dvoDetection + " AS b SET \ 488 503 a.ippObjID = b.ippObjID, \ … … 494 509 AND b.imageID = " + str(imageID) 495 510 496 self.scratchDb. stmt.execute(sql)511 self.scratchDb.execute(sql) 497 512 498 513 … … 511 526 512 527 # loop through all OTAs and populate ImageMeta extensions 528 self.logger.info("Reading all fits headers and populating ImageMeta tables") 513 529 for x in range(self.startX, self.endX): 514 530 for y in range(self.startY, self.endY): … … 524 540 # load corresponding header into memory 525 541 header = self.findAndReadFITSHeader(ota + ".hdr", file) 542 if not header: 543 self.logger.error("No header found for OTA " + ota) 544 continue 545 526 546 527 547 # store sourceID/imageID combo in Db so DVO can look up later … … 578 598 579 599 # update ImageMeta with count of detections for this OTA and photoCodeID 580 sql = "UPDATE ImageMeta_" + ota + " SET nDetect = %d, photoCalID = %d" % (self.scratchDb.getRowCount("Detection_" + ota), self.scratchDb.getPhotoCalID(sourceIDs[ota], imageIDs[ota])) 581 self.scratchDb.stmt.execute(sql) 600 sql = "UPDATE ImageMeta_" + ota + " \ 601 SET nDetect = %d, photoCalID = %d" % (self.scratchDb.getRowCount("Detection_" + ota), self.scratchDb.getPhotoCalID(sourceIDs[ota], imageIDs[ota])) 602 self.scratchDb.execute(sql) 582 603 583 604 self.populateSkinnyObjectTable(ota) … … 603 624 # update FrameMeta with count OTAs in this file and total number of photometric reference sources 604 625 sql = "UPDATE FrameMeta SET nOTA = %d, numPhotoRef = %d" % (otaCount, self.totalNumPhotoRef) 605 self.scratchDb. stmt.execute(sql)626 self.scratchDb.execute(sql) 606 627 607 628 return True … … 613 634 614 635 sql = "UPDATE " + tableName + " SET imageID = %d%d%d" % (self.expID, x, y) 615 self.scratchDb. stmt.execute(sql)636 self.scratchDb.execute(sql) 616 637 617 638 ''' … … 619 640 ''' 620 641 def alreadyProcessed(self): 642 643 meta = self.gpc1Db.getCameraStageMeta(self.id) 644 self.expID = meta[0]; 645 self.expName = meta[1]; 646 self.distGroup = meta[2]; 621 647 622 648 return self.ippToPspsDb.alreadyProcessed("detection", "exp_id", self.expID) … … 634 660 635 661 662 ''' 663 Overriding this method. Filter to only import *.psf extensions 664 ''' 665 def importIppTables(self, filter=""): 666 return super(DetectionBatch, self).importIppTables(".*.psf") 667 668 669 ''' 670 Overriding this method. Use regex to trim off, eg _XY33 extension 671 ''' 672 def exportPspsTablesToFits(self, regex="(.*)"): 673 return super(DetectionBatch, self).exportPspsTablesToFits("([a-zA-Z]+)") 674 675 676 # TODO put in config 677 useFullTables=True 678 testMode=False 679 636 680 logging.config.fileConfig("logging.conf") 637 681 logger = logging.getLogger("detectionbatch") 682 logger.setLevel(logging.INFO) 638 683 logger.info("Starting") 639 684 640 685 gpc1Db = Gpc1Db(logger) 686 ippToPspsDb = IppToPspsDb(logger) 687 scratchDb = ScratchDb(logger, useFullTables) 688 641 689 camIDs = gpc1Db.getIDsInThisDVODbForThisStage("MD04.V2", "cam") 642 690 logger.info("Found %d exposures" % len(camIDs)) … … 645 693 for camID in camIDs: 646 694 647 logger.info("-------------------------------------------------- cam ID: %d" % camID)695 #if camID < 43764: continue # TODO 648 696 649 697 file = gpc1Db.getCameraStageSmf(camID) 650 if not os.path.isfile(file): 651 logger.error("Cannot read file at '" + file) 652 continue 653 654 detectionBatch = DetectionBatch(logger, camID, file, False, True) 655 656 if not detectionBatch.alreadyProcessed(): 657 658 detectionBatch.createEmptyPspsTables() 659 detectionBatch.importIppTables(".*.psf") 660 if detectionBatch.populatePspsTables(): 661 detectionBatch.exportPspsTablesToFits("([a-zA-Z]+)") 662 detectionBatch.writeBatchManifest() 663 #detectionBatch.reportNullsInAllPspsTables(False) 664 #detectionBatch.createTarball() 665 #detectionBatch.publishToDatastore() 666 667 i = i+1 668 # if i > 0: sys.exit() 669 698 699 detectionBatch = DetectionBatch(logger, 700 gpc1Db, 701 ippToPspsDb, 702 scratchDb, 703 camID, 704 file, 705 testMode, 706 useFullTables) 707 detectionBatch.run() 708 -
branches/czw_branch/20110406/ippToPsps/jython/gpc1db.py
r31434 r31606 29 29 self.logger.debug("Gpc1Db destructor") 30 30 31 32 ''' 33 TODO 34 ''' 35 def getIDsInThisDVODbForThisStageFudge(self): 36 37 sql = "SELECT staticskyRun.sky_id \ 38 FROM staticskyInput, staticskyRun, stackRun, staticskyResult \ 39 WHERE staticskyRun.sky_id = staticskyInput.sky_id \ 40 AND staticskyInput.stack_id = stackRun.stack_id \ 41 AND staticskyInput.sky_id = staticskyResult.sky_id \ 42 AND staticskyRun.label like 'MD04.staticsky' \ 43 AND stackRun.filter like 'i%'" 44 45 try: 46 rs = self.executeQuery(sql) 47 except: 48 self.logger.exception("Can't query for ids in DVO") 49 50 ids = [] 51 while (rs.next()): 52 ids.append(rs.getInt(1)) 53 54 rs.close() 55 56 self.logger.info("Found %d items in DVO database '" % (len(ids))) 57 58 return ids 59 31 60 ''' 32 61 Gets a list of ids in this DVO database for this stage, could be cam or staticsky (so far) … … 40 69 41 70 try: 42 rs = self. stmt.executeQuery(sql)71 rs = self.executeQuery(sql) 43 72 except: 44 73 self.logger.exception("Can't query for ids in DVO") … … 50 79 rs.close() 51 80 52 self.logger. debug("Found %d items in DVO database '%s' for stage='%s'" % (len(ids), dvoDb, stage))81 self.logger.info("Found %d items in DVO database '%s' for stage='%s'" % (len(ids), dvoDb, stage)) 53 82 54 83 return ids … … 73 102 74 103 try: 75 rs = self. stmt.executeQuery(sql)104 rs = self.executeQuery(sql) 76 105 except: 77 106 self.logger.exception("Can't query for imageIDs") … … 105 134 106 135 try: 107 rs = self. stmt.executeQuery(sql)136 rs = self.executeQuery(sql) 108 137 rs.first() 109 138 meta.append(rs.getInt(1)) … … 113 142 114 143 return meta 144 115 145 ''' 116 146 Gets some camera-stage meta data for this cam_id … … 127 157 128 158 try: 129 rs = self. stmt.executeQuery(sql)159 rs = self.executeQuery(sql) 130 160 rs.first() 131 161 meta.append(rs.getInt(1)) … … 150 180 151 181 try: 152 rs = self. stmt.executeQuery(sql)182 rs = self.executeQuery(sql) 153 183 rs.first() 154 184 except: … … 171 201 files = glob.glob(path + "/*.cmf") 172 202 203 if len(files) < 1: return "NULL" 204 173 205 return files[0] # TODO just returning first file - check 174 206 … … 186 218 187 219 try: 188 rs = self. stmt.executeQuery(sql)220 rs = self.executeQuery(sql) 189 221 rs.first() 190 222 except: … … 200 232 201 233 f=os.popen("neb-ls -p "+path+"%cmf") 202 print "neb-ls -p "+path+"%cmf"203 234 for i in f.readlines(): 204 235 files.append(i.rstrip()) 205 print i.rstrip()206 236 207 237 # or not a neb path … … 211 241 return files 212 242 243 244 ''' 245 TODO hack to get exposure time for a stack 246 ''' 247 def getStackExpTime(self, stackID): 248 249 self.logger.debug("Querying GPC1 for stack exposure time") 250 251 sql = "SELECT SUM(exp_time) * (COUNT(warp_id) - reject_images) / COUNT(warp_id) as EXPTIME \ 252 FROM staticskyRun JOIN staticskyInput using(sky_id) \ 253 JOIN stackRun using(stack_id) \ 254 JOIN stackSumSkyfile using(stack_id) \ 255 JOIN stackInputSkyfile using(stack_id) \ 256 JOIN warpRun using(warp_id) \ 257 JOIN fakeRun using(fake_id) \ 258 JOIN camRun using(cam_id) \ 259 JOIN chipRun using(chip_id) \ 260 JOIN rawExp using(exp_id) \ 261 WHERE stack_id = %d" % stackID 262 263 try: 264 rs = self.executeQuery(sql) 265 rs.first() 266 return rs.getInt(1) 267 except: 268 self.logger.exception("Can't query for exposure time") 269 270 return 0.0 271 272 -
branches/czw_branch/20110406/ippToPsps/jython/ipptopspsdb.py
r31434 r31606 37 37 )" 38 38 39 self. stmt.execute(sql)39 self.execute(sql) 40 40 41 41 sql = "SELECT MAX(batch_id) FROM batch" … … 44 44 45 45 try: 46 rs = self. stmt.executeQuery(sql)46 rs = self.executeQuery(sql) 47 47 rs.first() 48 48 batchID = rs.getInt(1) … … 64 64 WHERE batch_id = " + str(batchID) 65 65 66 self. stmt.execute(sql)66 self.execute(sql) 67 67 68 68 ''' … … 75 75 WHERE batch_id = " + str(batchID) 76 76 77 self. stmt.execute(sql)77 self.execute(sql) 78 78 79 79 ''' … … 86 86 WHERE batch_id = " + str(batchID) 87 87 88 self. stmt.execute(sql)88 self.execute(sql) 89 89 90 90 ''' … … 101 101 102 102 try: 103 rs = self. stmt.executeQuery(sql)103 rs = self.executeQuery(sql) 104 104 rs.first() 105 105 if rs.getInt(1) > 0: … … 128 128 )" 129 129 130 self. stmt.execute(sql)130 self.execute(sql) 131 131 132 132 ''' … … 149 149 )" 150 150 151 self. stmt.execute(sql)151 self.execute(sql) 152 152 153 153 -
branches/czw_branch/20110406/ippToPsps/jython/mysql.py
r31434 r31606 37 37 self.url = "jdbc:mysql://"+self.dbHost+"/"+self.dbName+"?user="+self.dbUser+"&password="+self.dbPass 38 38 self.con = DriverManager.getConnection(self.url) 39 self.stmt = self.con.createStatement() 39 self.connectionID = self.getLastConnectionID() 40 self.logger.info("MySQL connection to %s with ID %d" % (dbType, self.connectionID)) 41 42 #self.stmt = self.con.createStatement() 43 44 45 ''' 46 Disconnect from database 47 ''' 48 def disconnect(self): 49 self.con.close() 40 50 41 51 ''' … … 45 55 46 56 self.logger.debug("MySql destructor") 47 self.stmt.close() 48 self.con.close() 57 self.disconnect() 58 59 ''' 60 Kills the last connection ID, so long as it's not THIS connection ID 61 ''' 62 def killLastConnectionID(self): 63 64 connectionID = self.getLastConnectionID() 65 if connectionID == self.connectionID: 66 self.logger.error("NOT going to kill THIS connection ID") 67 return 68 69 sql = "KILL %d" % connectionID 70 self.execute(sql) 71 72 ''' 73 Gets the last connection ID 74 ''' 75 def getLastConnectionID(self): 76 77 sql = "SELECT ID \ 78 FROM INFORMATION_SCHEMA.PROCESSLIST \ 79 WHERE DB='" + self.dbName + "' \ 80 ORDER BY ID" 81 rs = self.executeQuery(sql) 82 rs.last() 83 return rs.getInt(1) 49 84 50 85 ''' … … 54 89 55 90 sql = "UPDATE " + table + " SET " + column + " = " + value 56 self. stmt.execute(sql)91 self.execute(sql) 57 92 58 93 ''' … … 62 97 63 98 sql = "DROP TABLE " + table 64 try: self. stmt.execute(sql)99 try: self.execute(sql) 65 100 except: return 66 101 … … 74 109 sql = "ALTER TABLE " + table + " ADD UNIQUE (" + column + ")" 75 110 try: 76 self. stmt.execute(sql)111 self.execute(sql) 77 112 except: pass 78 113 #self.logger.warn("Index already in place on '" + column + "' for table '" + table + "'") … … 82 117 def createIndex(self, table, column): 83 118 84 self.logger.debug("Creating index on column '"+column+"' for table '"+table+"'")119 #self.logger.debug("Creating index on column '"+column+"' for table '"+table+"'") 85 120 86 121 sql = "CREATE INDEX "+table+"_"+column+"_index ON "+table+" ("+column+")" 87 122 try: 88 self. stmt.execute(sql)123 self.execute(sql) 89 124 except: pass 90 125 #self.logger.warn("Index already in place on '" + column + "' for table '" + table + "'") 126 ''' 127 TODO 128 ''' 129 def execute(self, sql): 130 131 stmt = self.con.createStatement() 132 stmt.execute(sql) 133 stmt.close() 134 135 ''' 136 TODO 137 ''' 138 def executeQuery(self, sql): 139 140 stmt = self.con.createStatement() 141 rs = stmt.executeQuery(sql) 142 #stmt.close() 143 return rs 91 144 92 145 ''' … … 96 149 97 150 sql = "SHOW COLUMNS FROM " + tableName 98 rs = self. stmt.executeQuery(sql)151 rs = self.executeQuery(sql) 99 152 columns = [] 100 153 while (rs.next()): columns.append(rs.getString(1)) … … 109 162 110 163 sql = "UPDATE " + tableName + " SET " + column + " = " + sub + " WHERE " + column + " IS NULL" 111 self. stmt.execute(sql)164 self.execute(sql) 112 165 113 166 ''' … … 123 176 124 177 sql = "UPDATE " + tableName + " SET " + column + " = " + sub + " WHERE " + column + " IS NULL" 125 self. stmt.execute(sql)178 self.execute(sql) 126 179 127 180 ''' … … 131 184 132 185 sql = "SELECT COUNT(*) FROM " + tableName + " WHERE " + columnName + " = " + value 133 rs = self. stmt.executeQuery(sql)186 rs = self.executeQuery(sql) 134 187 rs.first() 135 nBad Flux= rs.getInt(1)136 self.logger.info("% d NULL %s values in table %s. Deleting." % (nBadFlux, columnName, tableName))188 nBad = rs.getInt(1) 189 self.logger.info("%5d NULL %s values in table %s. Deleting." % (nBad, columnName, tableName)) 137 190 138 191 sql="DELETE from " + tableName + " WHERE " + columnName + " = " + value 139 self. stmt.execute(sql)192 self.execute(sql) 140 193 141 194 ''' … … 145 198 146 199 sql = "SELECT COUNT(*) FROM " + tableName + " WHERE " + columnName + " IS NULL" 147 rs = self. stmt.executeQuery(sql)200 rs = self.executeQuery(sql) 148 201 rs.first() 149 nBad Flux= rs.getInt(1)150 self.logger.info("% d NULL %s values in table %s. Deleting." % (nBadFlux, columnName, tableName))202 nBad = rs.getInt(1) 203 self.logger.info("%5d NULL %s values in table %s. Deleting." % (nBad, columnName, tableName)) 151 204 152 205 sql="DELETE from " + tableName + " WHERE " + columnName + " IS NULL" 153 self. stmt.execute(sql)206 self.execute(sql) 154 207 155 208 ''' … … 160 213 # first, count rows 161 214 sql = "SELECT COUNT(*) FROM " + tableName 162 rs = self. stmt.executeQuery(sql)215 rs = self.executeQuery(sql) 163 216 rs.first() 164 217 numRows = rs.getInt(1) … … 175 228 176 229 sql = "SELECT COUNT(*) FROM " + tableName + " WHERE " + column + " IS NULL" 177 rs = self. stmt.executeQuery(sql)230 rs = self.executeQuery(sql) 178 231 rs.first() 179 232 if rs.getInt(1) == numRows: … … 191 244 sql = "SELECT COUNT(*) FROM " + table 192 245 try: 193 rs = self. stmt.executeQuery(sql)246 rs = self.executeQuery(sql) 194 247 rs.first() 195 248 return rs.getInt(1) -
branches/czw_branch/20110406/ippToPsps/jython/scratchdb.py
r31434 r31606 45 45 sql = "SELECT surveyID FROM Survey WHERE name = '" + name + "'" 46 46 try: 47 rs = self. stmt.executeQuery(sql)47 rs = self.executeQuery(sql) 48 48 rs.first() 49 49 return rs.getInt(1) … … 61 61 sql = "SELECT flags FROM " + self.dvoMeta + " WHERE sourceID = %s AND externID = %s" % (sourceID, externID) 62 62 try: 63 rs = self. stmt.executeQuery(sql)63 rs = self.executeQuery(sql) 64 64 rs.first() 65 65 flags = rs.getInt(1) … … 78 78 sql = "SELECT imageID FROM " + self.dvoMeta + " WHERE sourceID = %s AND externID = %s" % (sourceID, externID) 79 79 try: 80 rs = self. stmt.executeQuery(sql)80 rs = self.executeQuery(sql) 81 81 rs.first() 82 82 imageID = rs.getInt(1) … … 95 95 sql = "SELECT photcode FROM " + self.dvoMeta + " WHERE sourceID = %s AND externID = %s" % (sourceID, externID) 96 96 try: 97 rs = self. stmt.executeQuery(sql)97 rs = self.executeQuery(sql) 98 98 rs.first() 99 99 photcode = rs.getInt(1) … … 109 109 110 110 sql = "UPDATE "+table+" AS a, Filter AS b SET a.filterID=b.filterID WHERE b.filterType = '" + filter + "'" 111 self. stmt.execute(sql)111 self.execute(sql) 112 112 113 113 ''' … … 123 123 " + str(imageID) + " \ 124 124 )" 125 self. stmt.execute(sql)125 self.execute(sql) 126 126 127 127 ''' … … 131 131 132 132 sql = "INSERT INTO dvoDone (name) VALUES ('" + name + "')" 133 self. stmt.execute(sql)133 self.execute(sql) 134 134 135 135 ''' … … 141 141 142 142 try: 143 rs = self. stmt.executeQuery(sql)143 rs = self.executeQuery(sql) 144 144 rs.first() 145 145 if rs.getInt(1) > 0: … … 160 160 161 161 sql = "DROP TABLE dvoMeta" 162 try: self. stmt.execute(sql)162 try: self.execute(sql) 163 163 except: pass 164 164 165 165 sql = "DROP TABLE dvoDetection" 166 try: self. stmt.execute(sql)166 try: self.execute(sql) 167 167 except: pass 168 168 … … 175 175 )" 176 176 177 try: self. stmt.execute(sql)177 try: self.execute(sql) 178 178 except: 179 179 self.logger.error("Unable to create DVO meta-data database table") … … 193 193 #INDEX (ippDetectID) \ 194 194 195 try: self. stmt.execute(sql)195 try: self.execute(sql) 196 196 except: 197 197 self.logger.error("Unable to create DVO detection database table") -
branches/czw_branch/20110406/ippToPsps/jython/stackbatch.py
r31434 r31606 8 8 from java.sql import * 9 9 10 from batch import Batch 10 11 from gpc1db import Gpc1Db 11 from batch import Batch 12 from ipptopspsdb import IppToPspsDb 13 from scratchdb import ScratchDb 14 12 15 import logging.config 13 16 … … 20 23 Constructor 21 24 ''' 22 def __init__(self, logger, skyID, inputFile, stackType, useFullTables=False): 25 def __init__(self, 26 logger, 27 gpc1Db, 28 ippToPspsDb, 29 scratchDb, 30 skyID, 31 inputFile, 32 stackType, 33 useFullTables=False): 34 23 35 super(StackBatch, self).__init__( 24 36 logger, 37 gpc1Db, 38 ippToPspsDb, 39 scratchDb, 40 skyID, 25 41 "stack", 26 42 inputFile, … … 28 44 useFullTables) # TODO 29 45 30 self.logger.info("StackBatch constructor. Creating batch from: '" + inputFile + "'") 31 32 self.skyID = skyID 33 34 # get filterID using init table 35 self.filter = self.header['FPA.FILTER'] 36 self.filter = self.filter[0:1] 37 38 self.stackType = stackType 39 meta = self.gpc1Db.getStackStageMeta(self.skyID, self.header['FPA.FILTER']) 40 if len(meta) < 1: return 41 self.stackID = meta[0]; 42 self.skycell = meta[1]; 43 44 # determine skycell from header value 45 #self.skycell = "skycell.34" #= self.header['SKYCELL'] 46 self.skycell = self.skycell[8:] 47 48 self.logger.info("Processing stack with ID: %d, type: %s and skycell: %s filter: %s" % (self.stackID, self.stackType, self.skycell, self.filter)) 49 46 if not self.everythingOK: return 47 48 self.expTime = gpc1Db.getStackExpTime(self.stackID) 49 50 self.logger.info("got exp time of %d" % self.expTime) 51 52 # meta data to the log 53 self.logger.info("New Stack Batch:") 54 self.logger.info("Sky ID: %d" % self.id) 55 self.logger.info("File: %s" % inputFile) 56 self.logger.info("Stack ID: %d" % self.stackID) 57 self.logger.info("Stack type: %s" % self.stackType) 58 self.logger.info("Skycell: %s" % self.skycell) 59 self.logger.info("Filter: %s" % self.filter) 50 60 51 61 # delete PSPS tables … … 58 68 self.scratchDb.dropTable("ObjectCalColor") 59 69 60 # delete IPP tables61 #self.scratchDb.dropTable("SkyChip_psf")62 #self.scratchDb.dropTable("SkyChip_xsrc")63 #self.scratchDb.dropTable("SkyChip_xfit")64 #self.scratchDb.dropTable("SkyChip_xrad")65 66 self.logger.info("Stack type: " + self.safeDictionaryAccess(self.header, self.stackType))67 # obs time makes no sense except for nightly stacks68 #if self.header['STK_TYPE'] != "NIGHTLY_STACK": self.header['MJD-OBS'] = "-999"69 70 70 # create an output filename, which is {filterID}{skycellID}.FITS 71 self.outputFitsFile = "% s%07d.FITS" % (self.filter, int(self.skycell))71 self.outputFitsFile = "%08d.FITS" % self.stackID 72 72 self.outputFitsPath = "%s/%s" % (self.localOutPath, self.outputFitsFile) 73 73 … … 77 77 78 78 # insert what we know about this stack batch into the stack table 79 self.ippToPspsDb.insertStackMeta(self.batchID, self. skyID, self.stackID, self.filter, self.stackType)79 self.ippToPspsDb.insertStackMeta(self.batchID, self.id, self.stackID, self.filter, self.stackType) 80 80 81 81 # insert sourceID/imageID combo so DVO can look it up … … 89 89 90 90 sql = "UPDATE " + table + " SET stackMetaID=" + str(self.stackID) 91 self.scratchDb. stmt.execute(sql)91 self.scratchDb.execute(sql) 92 92 93 93 ''' … … 97 97 98 98 sql = "UPDATE "+table+" AS a, StackType AS b SET a.stackTypeID=b.stackTypeID WHERE b.name = '" + self.stackType + "'" 99 self.scratchDb. stmt.execute(sql)99 self.scratchDb.execute(sql) 100 100 101 101 … … 148 148 WHERE a.ippDetectID=b.IPP_IDET AND b.PSF_FWHM "+psfCondition 149 149 150 self.scratchDb. stmt.execute(sql)150 self.scratchDb.execute(sql) 151 151 152 152 ''' … … 196 196 WHERE a.ippDetectID=b.IPP_IDET AND b.MODEL_TYPE = '"+ippModelType+"'" 197 197 198 self.scratchDb. stmt.execute(sql)198 self.scratchDb.execute(sql) 199 199 200 200 # sersic fit has an extra parameter … … 213 213 WHERE a.ippDetectID=b.IPP_IDET AND b.MODEL_TYPE = '"+ippModelType+"'" 214 214 215 self.scratchDb. stmt.execute(sql)215 self.scratchDb.execute(sql) 216 216 217 217 … … 220 220 ''' 221 221 def populateStackMeta(self): 222 222 223 self.logger.info("Procesing StackMeta table") 223 224 … … 246 247 ," + str(self.scratchDb.getPhotoCalID(self.header['SOURCEID'], self.header['IMAGEID'])) + " \ 247 248 ," + self.header['FPA.ZP'] + " \ 248 ," + s elf.header['EXPTIME']+ " \249 ," + str(self.expTime) + " \ 249 250 ,'" + self.safeDictionaryAccess(self.header, 'PSFMODEL') + "' \ 250 251 ,'" + self.header['CTYPE1'] + "' \ … … 261 262 ," + self.header['PC002002'] + " \ 262 263 )" 263 self.scratchDb. stmt.execute(sql)264 self.scratchDb.execute(sql) 264 265 265 266 self.scratchDb.updateAllRows("StackMeta", "surveyID", str(self.surveyID)) … … 272 273 ''' 273 274 def populateStackDetection(self): 275 274 276 self.logger.info("Procesing StackDetection table") 275 277 … … 321 323 ,X_PSF_SIG \ 322 324 ,Y_PSF_SIG \ 323 ,POW(10.0, (-0.4*PSF_INST_MAG)) / "+s elf.header['EXPTIME']+" \324 ,ABS((PSF_INST_MAG_SIG*(POW(10.0, (-0.4*PSF_INST_MAG)) / "+s elf.header['EXPTIME']+")) / 1.085736) \325 ,POW(10.0, (-0.4*PEAK_FLUX_AS_MAG)) / "+s elf.header['EXPTIME']+" \325 ,POW(10.0, (-0.4*PSF_INST_MAG)) / "+str(self.expTime)+" \ 326 ,ABS((PSF_INST_MAG_SIG*(POW(10.0, (-0.4*PSF_INST_MAG)) / "+str(self.expTime)+")) / 1.085736) \ 327 ,POW(10.0, (-0.4*PEAK_FLUX_AS_MAG)) / "+str(self.expTime)+" \ 326 328 ,SKY \ 327 329 ,SKY_SIGMA \ … … 352 354 FROM SkyChip_psf" 353 355 354 self.scratchDb. stmt.execute(sql)356 self.scratchDb.execute(sql) 355 357 356 358 self.scratchDb.updateAllRows("StackDetection", "surveyID", str(self.surveyID)) … … 362 364 self.updateStackTypeID("StackDetection") 363 365 self.updateDvoIDs("StackDetection") 364 365 # now delete bad flux 366 sql = "ALTER TABLE StackDetection ADD PRIMARY KEY (objID, stackDetectID)" 367 self.scratchDb.execute(sql) 368 369 if self.stackType == "DEEP_STACK": 370 371 #if deep stack and instFlux = null and err not null 372 sql = "UPDATE StackDetection AS a, SkyChip_psf AS b \ 373 SET instFlux = 2*b.PSF_INST_FLUX_SIG \ 374 WHERE instFlux IS NULL \ 375 AND b.PSF_INST_FLUX_SIG IS NOT NULL" 376 self.scratchDb.execute(sql) 377 # instFlux = 2*PSF_INST_FLUX_SIG 378 366 379 self.scratchDb.reportAndDeleteRowsWithNULLS("StackDetection", "instFlux") 367 380 self.scratchDb.reportAndDeleteRowsWithNULLS("StackDetection", "objID") … … 372 385 ''' 373 386 def populateStackApFlx(self): 387 374 388 self.logger.info("Procesing StackApFlx table") 375 389 … … 381 395 382 396 try: 383 self.scratchDb. stmt.execute(sql)397 self.scratchDb.execute(sql) 384 398 except: return 385 399 386 400 # TODO temporarily loading 1st convolved fluxes into unconvolved fields 387 self.logger.info(" Adding un-convolved fluxes")401 self.logger.info("Adding un-convolved fluxes") 388 402 self.updateApFlxs("", "< 7.0") 389 self.logger.info(" Adding 1st convolved fluxes")403 self.logger.info("Adding 1st convolved fluxes") 390 404 self.updateApFlxs("c1", "< 7.0") 391 self.logger.info(" Adding 2nd convolved fluxes")405 self.logger.info("Adding 2nd convolved fluxes") 392 406 self.updateApFlxs("c2", "> 7.0") 393 407 394 self.logger.info(" Adding petrosians for extended sources")408 self.logger.info("Adding petrosians for extended sources") 395 409 sql = "UPDATE StackApFlx AS a, SkyChip_xsrc AS b SET \ 396 410 petRadius=b.PETRO_RADIUS \ … … 403 417 ,petR90Err=b.PETRO_RADIUS_90_ERR \ 404 418 WHERE a.ippDetectID=b.IPP_IDET" 405 self.scratchDb. stmt.execute(sql)419 self.scratchDb.execute(sql) 406 420 407 421 self.scratchDb.updateAllRows("StackApFlx", "surveyID", str(self.surveyID)) … … 413 427 self.updateStackTypeID("StackApFlx") 414 428 self.updateDvoIDs("StackApFlx") 429 self.scratchDb.reportAndDeleteRowsWithNULLS("StackApFlx", "objID") 430 self.deleteDetectionsNotInStackDetection("StackApFlx") 431 415 432 416 433 ''' … … 418 435 ''' 419 436 def populateStackModelFit(self): 437 420 438 self.logger.info("Procesing StackModelFit table") 421 439 … … 423 441 sql = "INSERT INTO StackModelFit (ippDetectID) SELECT DISTINCT IPP_IDET from SkyChip_xfit" 424 442 try: 425 self.scratchDb. stmt.execute(sql)443 self.scratchDb.execute(sql) 426 444 except: 427 445 return 428 446 429 430 447 # populate model parameters 431 self.logger.info(" Adding deVaucouleurs fit")448 self.logger.info("Adding deVaucouleurs fit") 432 449 self.updateModelFit("deV", "PS_MODEL_DEV") 433 self.logger.info(" Adding exponential fit")450 self.logger.info("Adding exponential fit") 434 451 self.updateModelFit("exp", "PS_MODEL_EXP") 435 self.logger.info(" Adding sersic fit")452 self.logger.info("Adding sersic fit") 436 453 self.updateModelFit("ser", "PS_MODEL_SERSIC") 437 454 … … 444 461 self.updateStackTypeID("StackModelFit") 445 462 self.updateDvoIDs("StackModelFit") 463 self.scratchDb.reportAndDeleteRowsWithNULLS("StackModelFit", "objID") 464 self.deleteDetectionsNotInStackDetection("StackModelFit") 465 466 ''' 467 Reports and deletes detections in this table that are not in StackDetection 468 ''' 469 def deleteDetectionsNotInStackDetection(self, table): 470 471 sql = "SELECT COUNT(*) FROM " + table + " WHERE ippDetectID NOT IN (SELECT ippDetectID FROM StackDetection)" 472 rs = self.scratchDb.executeQuery(sql) 473 rs.first() 474 nMissing = rs.getInt(1) 475 self.logger.info("%5d detections in %s table that are not in StackDetection. Deleting" % (nMissing, table)) 476 477 if nMissing < 1: return 478 479 sql = "DELETE FROM " + table + " WHERE ippDetectID NOT IN (SELECT ippDetectID FROM StackDetection)" 480 self.scratchDb.execute(sql) 481 446 482 447 483 ''' … … 449 485 ''' 450 486 def populateStackToImage(self): 487 451 488 self.logger.info("Procesing StackToImage table") 452 489 … … 457 494 VALUES (\ 458 495 " + str(self.stackID) + ", " + imageID + ")" 459 self.scratchDb. stmt.execute(sql)496 self.scratchDb.execute(sql) 460 497 461 498 # now update StackMeta with correct number of inputs 462 499 sql = "UPDATE StackMeta SET nP2Images = (SELECT COUNT(*) FROM StackToImage)" 463 self.scratchDb. stmt.execute(sql)500 self.scratchDb.execute(sql) 464 501 465 502 ''' … … 467 504 ''' 468 505 def populateSkinnyObject(self): 506 469 507 self.logger.info("Procesing SkinnyObject table") 470 508 … … 474 512 ) \ 475 513 SELECT \ 476 objID \514 DISTINCT objID \ 477 515 ,ippObjID \ 478 516 FROM StackDetection" 479 self.scratchDb. stmt.execute(sql)517 self.scratchDb.execute(sql) 480 518 481 519 self.scratchDb.updateAllRows("SkinnyObject", "surveyID", str(self.surveyID)) … … 486 524 ''' 487 525 def populateObjectCalColor(self): 526 488 527 self.logger.info("Procesing ObjectCalColor table") 489 528 … … 493 532 ) \ 494 533 SELECT \ 495 objID \534 DISTINCT objID \ 496 535 ,ippObjID \ 497 536 FROM StackDetection" 498 self.scratchDb. stmt.execute(sql)537 self.scratchDb.execute(sql) 499 538 500 539 self.scratchDb.updateFilterID("ObjectCalColor", self.filter) … … 508 547 509 548 self.logger.info("Altering PSPS tables") 510 self.scratchDb.makeColumnUnique("StackDetection", "objID")549 #self.scratchDb.makeColumnUnique("StackDetection", "objID") 511 550 self.scratchDb.createIndex("StackDetection", "ippDetectID") 512 551 self.scratchDb.createIndex("StackApFlx", "ippDetectID") … … 531 570 imageID = self.scratchDb.getImageIDFromExternID(self.header['SOURCEID'], self.header['IMAGEID']) 532 571 533 self.logger. info("Updating table '" + table + "' with DVO IDs...")572 self.logger.debug("Updating table '" + table + "' with DVO IDs...") 534 573 sql = "UPDATE IGNORE " + table + " AS a, dvoDetectionFull AS b SET \ 535 574 a.ippObjID = b.ippObjID, \ … … 539 578 AND b.sourceID = " + self.header['SOURCEID'] + "\ 540 579 AND b.imageID = " + str(imageID) 541 self.scratchDb.stmt.execute(sql) 542 580 self.scratchDb.execute(sql) 543 581 544 582 ''' … … 553 591 self.populateStackMeta() 554 592 self.populateStackDetection() 555 self.populateStackModelFit() 556 self.populateStackApFlx() 593 594 if self.stackType != "NIGHTLY_STACK": 595 self.populateStackModelFit() 596 self.populateStackApFlx() 597 557 598 self.populateStackToImage() 558 599 self.populateSkinnyObject() … … 560 601 561 602 self.setMinMaxObjID(["StackDetection"]) 562 603 604 if self.totalDetections < 1: 605 606 self.logger.error("No detections to publish") 607 return False 608 563 609 return True 564 610 … … 568 614 def alreadyProcessed(self): 569 615 570 return self.ippToPspsDb.alreadyProcessed("stack", "stack_id", self.stackID) 616 # sadly, we have to read the FITS primary header first 617 if not self.readPrimaryHeader(): return False 618 619 # get filterID using init table 620 self.filter = self.header['FPA.FILTER'] 621 self.filter = self.filter[0:1] 622 623 self.stackType = stackType 624 meta = self.gpc1Db.getStackStageMeta(self.id, self.header['FPA.FILTER']) 625 if len(meta) < 1: return False 626 self.stackID = meta[0]; 627 self.skycell = meta[1]; 628 self.skycell = self.skycell[8:] 629 630 #return self.ippToPspsDb.alreadyProcessed("stack", "stack_id", self.stackID) 631 return False # TODOI 632 633 634 useFullTables=True 571 635 572 636 logging.config.fileConfig("logging.conf") 573 637 logger = logging.getLogger("stackbatch") 638 logger.setLevel(logging.INFO) 574 639 logger.info("Starting") 640 575 641 gpc1Db = Gpc1Db(logger) 576 stackType = "NIGHTLY_STACK" 577 skyIDs = gpc1Db.getIDsInThisDVODbForThisStage("MD04.Staticsky", "staticsky") 578 #skyIDs = gpc1Db.getIDsInThisDVODbForThisStage("MD04.GENE.PSPSDEEP", "staticsky") 579 #stackType = "DEEP_STACK" 580 #skyIDs = [689] 642 ippToPspsDb = IppToPspsDb(logger) 643 scratchDb = ScratchDb(logger, useFullTables) 644 645 #stackType = "NIGHTLY_STACK" 646 #skyIDs = gpc1Db.getIDsInThisDVODbForThisStageFudge() 647 #skyIDs = gpc1Db.getIDsInThisDVODbForThisStage("MD04.Staticsky", "staticsky") 648 649 stackType = "DEEP_STACK" 650 skyIDs = gpc1Db.getIDsInThisDVODbForThisStage("MD04.GENE.PSPSDEEP", "staticsky") 651 652 #skyIDs = [942] 581 653 #skyIDs = [299] 582 654 #skyIDs = [302] 583 655 #skyIDs = [8508] 584 i = 0656 #i = 0 585 657 for skyID in skyIDs: 586 587 logger.info("-------------------------------------------------- sky ID: %d" % skyID) 658 659 #if skyID < 1340: continue # nightly 660 #if skyID < 238: continue # deep 588 661 589 662 cmfFiles = gpc1Db.getStackStageCmfs(skyID) … … 591 664 for file in cmfFiles: 592 665 593 if not os.path.isfile(file): 594 logger.error("Cannot read file at '" + file) 595 continue 596 597 stackBatch = StackBatch(logger, skyID, file, stackType, True) 598 599 if not stackBatch.alreadyProcessed(): 600 601 stackBatch.createEmptyPspsTables() 602 stackBatch.importIppTables("") 603 if stackBatch.populatePspsTables(): 604 605 #stackBatch.reportNullsInAllPspsTables(False) 606 stackBatch.exportPspsTablesToFits() 607 stackBatch.writeBatchManifest() 608 #stackBatch.createTarball() 609 #stackBatch.publishToDatastore() 610 611 i = i + 1 612 #if i > 0: sys.exit() 613 614 logger.info("Finished") 666 stackBatch = StackBatch(logger, 667 gpc1Db, 668 ippToPspsDb, 669 scratchDb, 670 skyID, 671 file, 672 stackType, 673 useFullTables) 674 675 stackBatch.run() 676 -
branches/czw_branch/20110406/ippTools/share/addtool_find_sky_id.sql
r31434 r31606 3 3 FROM 4 4 staticskyResult 5 join static SkyRun using (sky_id)6 join static SkyInput using (stack_id)5 join staticskyRun using (sky_id) 6 join staticskyInput using(sky_id) 7 7 JOIN stackRun USING(stack_id) 8 8 … … 13 13 ) as foo 14 14 ON sky_id = added_sky_id 15 AND stage = 's ky'15 AND stage = 'staticsky' 16 16 -- hook for qualifying the join on the previous_dvodb 17 17 AND %s -
branches/czw_branch/20110406/ippTools/share/addtool_find_sky_id_dvo.sql
r31434 r31606 1 1 SELECT staticskyRun.* FROM staticskyResult 2 2 JOIN staticskyRun USING(sky_id) 3 join staticskyInput using(sky_id) 4 JOIN stackRun USING(stack_id) 5 3 6 WHERE staticskyRun.state = 'full' and staticskyResult.quality = 0 4 7 AND sky_id NOT IN (SELECT sky_id -
branches/czw_branch/20110406/ippTools/share/camtool_find_pendingimfile.sql
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20110404/ippTools/share/camtool_find_pendingimfile.sql (added) merged: 31439
- Property svn:mergeinfo changed
-
branches/czw_branch/20110406/ippTools/share/pxadmin_create_tables.sql
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20110404/ippTools/share/pxadmin_create_tables.sql (added) merged: 31439
- Property svn:mergeinfo changed
-
branches/czw_branch/20110406/ippTools/share/regtool_pendingimfile.sql
r25418 r31606 8 8 newImfile.uri, 9 9 newImfile.bytes, 10 newImfile.md5sum 10 newImfile.md5sum, 11 summitExp.dateobs AS summit_dateobs 11 12 FROM newImfile 12 13 JOIN newExp 13 14 USING(exp_id) 15 JOIN summitExp USING(summit_id) 14 16 LEFT JOIN rawImfile 15 17 ON newExp.exp_id = rawImfile.exp_id -
branches/czw_branch/20110406/ippTools/src
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20110404/ippTools/src (added) merged: 31186,31188,31278,31439
- Property svn:mergeinfo changed
-
branches/czw_branch/20110406/ippTools/src/addtool.c
r31434 r31606 117 117 118 118 psMetadata *where = psMetadataAlloc(); 119 pxcamGetSearchArgs (config, where);119 // pxcamGetSearchArgs (config, where); 120 120 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 121 121 PXOPT_COPY_S64(config->args, where, "-stack_id", "stackRun.stack_id", "=="); … … 123 123 PXOPT_LOOKUP_STR(stage, config->args, "-stage", false, false); 124 124 if (strcmp(stage, "cam")== 0) { 125 125 pxcamGetSearchArgs (config, where); 126 126 pxAddLabelSearchArgs (config, where, "-label", "camRun.label", "=="); // define using camRun label 127 127 pxAddLabelSearchArgs (config, where, "-data_group","camRun.data_group", "=="); // define using camRun label 128 128 129 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 129 130 } … … 133 134 pxAddLabelSearchArgs (config, where, "-data_group","stackRun.data_group", "=="); // define using camRun label 134 135 PXOPT_COPY_STR(config->args, where, "-reduction", "stackRun.reduction", "=="); 136 pxAddLabelSearchArgs (config, where, "-filter", "stackRun.filter", "=="); // define using camRun label 135 137 } 136 138 if (strcmp(stage, "staticsky")== 0) { … … 139 141 pxAddLabelSearchArgs (config, where, "-data_group","staticskyRun.data_group", "=="); // define using camRun label 140 142 PXOPT_COPY_STR(config->args, where, "-reduction", "staticskyyRun.reduction", "=="); 143 pxAddLabelSearchArgs (config, where, "-filter", "stackRun.filter", "=="); // define using camRun label 141 144 } 142 145 -
branches/czw_branch/20110406/ippTools/src/addtoolConfig.c
r31434 r31606 56 56 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by camRun label", NULL); 57 57 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-data_group", PS_META_DUPLICATE_OK, "search by camRun data_group", NULL); 58 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-filter", PS_META_DUPLICATE_OK, "search by filter", NULL); 58 59 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-reduction", 0, "search by camRun reduction class", NULL); 59 60 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-destreaked", 0, "only queue destreaked runs", false); -
branches/czw_branch/20110406/ippTools/src/disttool.c
r30906 r31606 447 447 448 448 if (pretend) { 449 if (!ippdbPrintMetadatas(stdout, output, "newdistRuns", true)) {449 if (!ippdbPrintMetadatas(stdout, output, "newdistRuns", !simple)) { 450 450 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 451 451 psFree(output); -
branches/czw_branch/20110406/ippTools/src/magictool.c
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20110404/ippTools/src/magictool.c (added) merged: 31439
r31434 r31606 404 404 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 405 405 PXOPT_LOOKUP_BOOL(clearfault, config->args, "-clearfault", false); 406 406 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 407 407 408 psString setString = NULL; 408 409 if (fault || clearfault) { … … 411 412 if (note) { 412 413 psStringAppend(&setString, ", note = '%s'", note); 414 } 415 if (label) { 416 psStringAppend(&setString, ", label = '%s'", label); 413 417 } 414 418 - Property svn:mergeinfo changed
-
branches/czw_branch/20110406/ippTools/src/magictoolConfig.c
r30497 r31606 81 81 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state (required)", NULL); 82 82 psMetadataAddS16(updaterunArgs, PS_LIST_TAIL, "-set_fault", 0, "set fault code", 0); 83 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label", 0, "define label", 0); 83 84 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_note", 0, "define note", NULL); 84 85 psMetadataAddBool(updaterunArgs, PS_LIST_TAIL, "-clearfault", 0, "set fault to zero", NULL); -
branches/czw_branch/20110406/ippTools/src/pstamptool.c
r30543 r31606 843 843 psFree(where); 844 844 845 psStringAppend(&query, " ORDER BY priority DESC, req_id ");845 psStringAppend(&query, " ORDER BY priority DESC, req_id, job_id"); 846 846 847 847 // treat limit == 0 as "no limit" … … 1323 1323 psFree(where); 1324 1324 1325 psStringAppend(&query, " ORDER BY priority DESC, req_id ");1325 psStringAppend(&query, " ORDER BY priority DESC, req_id, dep_id"); 1326 1326 1327 1327 // treat limit == 0 as "no limit" -
branches/czw_branch/20110406/ippTools/src/pubtoolConfig.c
r30769 r31606 48 48 psMetadataAddStr(defineclientArgs, PS_LIST_TAIL, "-product", 0, "define product (required)", NULL); 49 49 psMetadataAddStr(defineclientArgs, PS_LIST_TAIL, "-workdir", 0, "define workdir (required)", NULL); 50 psMetadataAddS16(defineclientArgs, PS_LIST_TAIL, "-output_format", 0, "define output format", 2); 50 51 psMetadataAddStr(defineclientArgs, PS_LIST_TAIL, "-comment", 0, "define comment", NULL); 52 psMetadataAddStr(defineclientArgs, PS_LIST_TAIL, "-name", 0, "define name", NULL); 51 53 psMetadataAddBool(defineclientArgs, PS_LIST_TAIL, "-unmagicked", 0, "allow unmagicked data?", false); 52 54 -
branches/czw_branch/20110406/ippTools/src/pzgetimfiles.c
r31038 r31606 125 125 if (status != 0) { 126 126 // mark the summitExp row as faulted 127 if (!p_psDBRunQueryF(config->dbh, "UPDATE summitExp SET fault = %d WHERE summit_id = %l d", WEXITSTATUS(status),summit_id)) {127 if (!p_psDBRunQueryF(config->dbh, "UPDATE summitExp SET fault = %d WHERE summit_id = %lld", WEXITSTATUS(status), (long long) summit_id)) { 128 128 psError(PS_ERR_UNKNOWN, false, "database error"); 129 129 } … … 141 141 // download an "empty" fileset. 142 142 // mark the summitExp row as faulted 143 if (!p_psDBRunQueryF(config->dbh, "UPDATE summitExp SET fault = %d WHERE summit_id = %l d", 250,summit_id)) {143 if (!p_psDBRunQueryF(config->dbh, "UPDATE summitExp SET fault = %d WHERE summit_id = %lld", 250, (long long) summit_id)) { 144 144 psError(PS_ERR_UNKNOWN, false, "database error"); 145 145 } -
branches/czw_branch/20110406/ippTools/src/pztool.c
r31051 r31606 638 638 // set pzDownloadExp.state to 'stop' 639 639 if (!pzDownloadExpSetState(config, summit_id, "stop")) { 640 psError(PS_ERR_UNKNOWN, false, "failed to change pzDownloadExp.state for %l d",summit_id);640 psError(PS_ERR_UNKNOWN, false, "failed to change pzDownloadExp.state for %lld", (long long) summit_id); 641 641 return false; 642 642 } … … 913 913 char *query = "UPDATE pzDownloadExp SET state = '%s' WHERE summit_id = %ld"; 914 914 if (!p_psDBRunQueryF(config->dbh, query, state, summit_id)) { 915 psError(PS_ERR_UNKNOWN, false, "failed to change state for %l d",summit_id);915 psError(PS_ERR_UNKNOWN, false, "failed to change state for %lld", (long long) summit_id); 916 916 return false; 917 917 } … … 927 927 928 928 if (!pzDownloadExpSetState(config,summit_id, state)) { 929 psError(PS_ERR_UNKNOWN, false, "failed to change state for %l d",summit_id);929 psError(PS_ERR_UNKNOWN, false, "failed to change state for %lld", (long long) summit_id); 930 930 return false; 931 931 } -
branches/czw_branch/20110406/ippTools/src/stacktool.c
r31253 r31606 246 246 PXOPT_COPY_STR(config->args, where, "-select_data_group", "warpRun.data_group", "=="); 247 247 pxAddLabelSearchArgs (config, where, "-select_label", "warpRun.label", "LIKE"); // define using warp label 248 248 pxAddLabelSearchArgs (config, where, "-warp_id", "warpRun.warp_id", "=="); 249 249 250 // these are used to build the HAVING restriction 250 251 PXOPT_COPY_S32(config->args, having, "-min_num", "num_warp", ">="); … … 487 488 // Define the requested association, and insert it if it doesn't already exist 488 489 stackAssociationRow *association = pxStackAssociationDefine(config,stack_id); 489 psS64 sass_id ;490 psS64 sass_id=-1; 490 491 if (!association->sass_id) { 491 492 psTrace("stacktool.association",2,"No required Association found. Adding."); … … 508 509 association->sass_id = sass_id; 509 510 } 511 else { 512 sass_id = association->sass_id; 513 } 510 514 // Insert the map entry for this row. 511 515 stackAssociationMapRow *maprow = stackAssociationMapRowAlloc(sass_id,stack_id); -
branches/czw_branch/20110406/ippTools/src/stacktoolConfig.c
r30945 r31606 91 91 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-select_zpt_obs_max", 0, "define max zero point", NAN); 92 92 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-select_astrom", 0, "define max astrometry rms", NAN); 93 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-warp_id", PS_META_DUPLICATE_OK, "include this warp ID (multiple OK)", 0); 93 94 psMetadataAddS32(definebyqueryArgs, PS_LIST_TAIL, "-random", 0, "use this number of random elements", 0); 94 95 psMetadataAddS32(definebyqueryArgs, PS_LIST_TAIL, "-min_num", 0, "minimum number of inputs", 0); -
branches/czw_branch/20110406/ippconfig
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20110404/ippconfig (added) merged: 31393,31439
- Property svn:mergeinfo changed
-
branches/czw_branch/20110406/ippconfig/gpc1/camera.config
r31163 r31606 165 165 NPIX_INTERCHIP S32 103794483 166 166 167 # This sets the maximum size for the fwhm_major. This is roughly 3", and 98.67% of all exposures in the database are less than this. 168 MAX_ALLOWED_FWHM F32 12 169 167 170 # The set of maskbits that should not be set to NAN in "released" images 168 171 # This value is equal to CONV.POOR | STARCORE | SPIKE | SUSPECT = 0x5280 -
branches/czw_branch/20110406/ippconfig/gpc1/ppStack.config
r31163 r31606 35 35 36 36 STACK_THREEPI METADATA 37 PSF.INPUT.MAX F32 12.0 37 38 OUTPUT.NOCOMP BOOL FALSE 38 39 OUTPUT.LOGFLUX BOOL TRUE -
branches/czw_branch/20110406/ippconfig/gpc1/psastro.config
r31434 r31606 113 113 114 114 # *** make sure the choice of CATDIR (dvo database) contains the photcodes desired below 115 PSASTRO.CATDIR STR SYNTH.GRIZY 115 PSASTRO.CATDIR STR SYNTH.GRIZY 116 116 DVO.GETSTAR.PHOTCODE STR i 117 117 DVO.GETSTAR.MAX.RHO F32 3000.0 … … 129 129 FILTER STR g 130 130 ZEROPT F32 24.9 131 PHOTCODE STR g _SYNTH131 PHOTCODE STR g 132 132 GHOST_MAX_MAG F32 -20.0 133 133 END … … 135 135 FILTER STR r 136 136 ZEROPT F32 25.1 137 PHOTCODE STR r _SYNTH137 PHOTCODE STR r 138 138 GHOST_MAX_MAG F32 -20.0 139 139 END … … 141 141 FILTER STR i 142 142 ZEROPT F32 25.0 143 PHOTCODE STR i _SYNTH143 PHOTCODE STR i 144 144 GHOST_MAX_MAG F32 -25.0 145 145 END … … 147 147 FILTER STR z 148 148 ZEROPT F32 24.6 149 PHOTCODE STR z _SYNTH149 PHOTCODE STR z 150 150 GHOST_MAX_MAG F32 -25.0 151 151 END … … 153 153 FILTER STR y 154 154 ZEROPT F32 22.2 155 PHOTCODE STR y _SYNTH155 PHOTCODE STR y 156 156 GHOST_MAX_MAG F32 -25.0 157 157 END … … 159 159 FILTER STR w 160 160 ZEROPT F32 26.3 161 PHOTCODE STR r _SYNTH161 PHOTCODE STR r 162 162 GHOST_MAX_MAG F32 -20.0 163 163 END … … 345 345 PSASTRO.MATCH.FIT.NITER S32 5 346 346 END 347 348 LAP_ASTRO METADATA 349 PSASTRO.CATDIR STR 3PI.20110505.REFCAT 350 END -
branches/czw_branch/20110406/ippconfig/gpc1/psphot.config
r31163 r31606 20 20 PSF_MODEL STR PS_MODEL_PS1_V1 21 21 PSPHOT.CR.NSIGMA.SOFTEN F32 0.0025 # Softening parameter for weights in CR stat 22 23 PSPHOT.CR.MAX.SIZE F32 0.8 # guess for limit on M_minor in pix^2 24 PSPHOT.CR.MAX.MAG F32 -8.0 # guess for limit on Kron Mag 25 PSPHOT.CR.AUTOSCALE BOOL FALSE 22 26 23 27 PSF.TREND.NX S32 3 -
branches/czw_branch/20110406/ippconfig/isp/psastro.config
r27289 r31606 3 3 4 4 # nominal plate scale (microns / pixel) 5 PSASTRO.PIXEL.SCALE F32 1 0.05 PSASTRO.PIXEL.SCALE F32 1.0 6 6 7 7 # pmAstromGridMatch: 8 8 PSASTRO.GRID.MIN.ANGLE F32 -2.0 9 9 PSASTRO.GRID.MAX.ANGLE F32 +2.0 10 PSASTRO.GRID.DEL.ANGLE F32 0. 2510 PSASTRO.GRID.DEL.ANGLE F32 0.5 11 11 PSASTRO.GRID.MIN.SIGMA F32 5.0 12 12 … … 14 14 # max grid offset in FP units (microns) 15 15 # use plate-scale to make this in pixels? 16 PSASTRO.GRID.OFFSET F32 10000.17 PSASTRO.GRID.SCALE F32 50016 PSASTRO.GRID.OFFSET F32 500. 17 PSASTRO.GRID.SCALE F32 10 18 18 19 PSASTRO.GRID.NREF.MAX S32 2500 20 PSASTRO.GRID.NRAW.MAX S32 1500 21 22 PSASTRO.PLOT.INST.MAG.MAX F32 -4.0 23 PSASTRO.PLOT.INST.MAG.MIN F32 -12.0 24 PSASTRO.PLOT.REF.MAG.MIN F32 +10.0 25 PSASTRO.PLOT.REF.MAG.MAX F32 +20.0 26 27 PSASTRO.MIN.INST.MAG.RAW F32 -12 28 PSASTRO.GRID.MIN.INST.MAG.RAW F32 -12 29 PSASTRO.MAX.INST.MAG.RAW F32 -4 30 PSASTRO.GRID.MAX.INST.MAG.RAW F32 -4 31 32 #PSASTRO.MATCH.RADIUS F32 3 33 34 PSASTRO.MATCH.RADIUS.N0 F32 15 35 PSASTRO.MATCH.RADIUS.N1 F32 10 36 PSASTRO.MATCH.RADIUS.N2 F32 9 37 PSASTRO.MATCH.RADIUS.N3 F32 8 38 PSASTRO.MATCH.RADIUS.N4 F32 7 39 PSASTRO.MATCH.RADIUS.N5 F32 5 40 PSASTRO.MATCH.RADIUS.N6 F32 5 41 PSASTRO.MATCH.RADIUS.N7 F32 3 42 43 PSASTRO.MATCH.FIT.NITER S32 8 19 44 # these tweak are in FP units (pixels, currently) 20 45 PSASTRO.TWEAK.SCALE F32 1 … … 24 49 25 50 # match radius in pixels for CHIP astrometry 26 PSASTRO.MATCH.RADIUS F32 851 PSASTRO.MATCH.RADIUS F32 5 27 52 28 53 # pmAstromMatchFit … … 38 63 PSASTRO.CATDIR STR SYNTH.BRIGHT 39 64 PSASTRO.MATCH.LUMFUNC BOOL TRUE 65 PSASTRO.IGNORE STR SATURATED, DEFECT, SATSTAR, BLEND,FAIL 66 67 40 68 41 69 -
branches/czw_branch/20110406/ippconfig/isp/psphot.config
r25756 r31606 1 # cosmic ray recipe options - these were tested with o5472i0009o01.201734.ch.191131.cmf 2 3 PSPHOT.CR.MAX.SIZE F32 0.20 # guess for limit on M_minor in pix^2 4 PSPHOT.CR.MAX.MAG F32 -7.0 # guess for limit on Kron Mag 5 PSPHOT.CR.AUTOSCALE BOOL FALSE 6 1 7 2 8 # turn these on to see specific outputs -
branches/czw_branch/20110406/ippconfig/recipes/nightly_science.config
r31434 r31606 203 203 NAME STR STS 204 204 DISTRIBUTION STR STS 205 # XXX: STS observations are temporarily being taken outside the STS tessellation 206 # switch tess_id from STS.V3 to RINGS 207 TESS STR RINGS.V3 208 # TESS STR STS.V3 205 TESS STR STS.V4 209 206 OBSMODE STR STS% 210 OBJECT STR STS%207 # OBJECT STR STS% 211 208 STACKABLE BOOL FALSE 212 209 DIFFABLE BOOL FALSE 213 210 REDUCTION STR STS_DATASET 211 # bump the retention times for the time being 212 CHIP S16 60 213 WARP S16 60 214 DIFF S16 60 214 215 END 215 216 TARGETS METADATA -
branches/czw_branch/20110406/ippconfig/recipes/psastro.config
r31434 r31606 250 250 STS_DATASET METADATA 251 251 END 252 253 LAP_ASTRO METADATA 254 255 END 256 -
branches/czw_branch/20110406/ippconfig/recipes/psphot.config
r31434 r31606 318 318 PSPHOT.CRMASK.YTEST S32 0 319 319 PSPHOT.CRMASK.APPLY BOOL FALSE # TEST THIS before enabling. 320 PSPHOT.CR.MAX.SIZE F32 0 .8# guess for limit on M_minor in pix^2321 PSPHOT.CR.MAX.MAG F32 -8.0 # guess for limit on Kron Mag320 PSPHOT.CR.MAX.SIZE F32 0 # guess for limit on M_minor in pix^2 321 PSPHOT.CR.MAX.MAG F32 0 # guess for limit on Kron Mag 322 322 PSPHOT.CR.AUTOSCALE BOOL FALSE 323 323 … … 377 377 END 378 378 379 # Extended source fit parameters 380 STACKPHOT_TEST_V1 METADATA 381 EXTENDED_SOURCE_FITS BOOL F # perform any of the aperture-like measurements? 382 EXTENDED_SOURCE_ANALYSIS BOOL F # perform any of the aperture-like measurements? 383 EXTENDED_SOURCE_SN_LIM F32 20.0 384 EXTENDED_SOURCE_PETROSIAN BOOL TRUE 385 EXTENDED_SOURCE_ANNULI BOOL TRUE 386 PSPHOT.STACK.MATCH.PSF.SOURCE STR AUTO # which inputs to convolve? (RAW, CNV, AUTO) 387 PSPHOT.STACK.TARGET.PSF.AUTO BOOL F # automatically determine target PSF size? 388 PSPHOT.STACK.USE.RAW BOOL F # perform photometry & morphology analysis on the raw image 389 @PSPHOT.STACK.TARGET.PSF.FWHM F32 8.0 10.0 # FWHM of target PSF (if NOT AUTO sized; pixels) 390 RADIAL_APERTURES BOOL F # calculate flux in circular radial apertures? 391 RADIAL_APERTURES_SN_LIM F32 0.0 # S/N limit for radial aperture calculation 392 OUTPUT.FORMAT STR PS1_V3 393 394 CONSTANT_PHOTOMETRIC_WEIGHTS BOOL TRUE 395 POISSON.ERRORS.PHOT.LMM BOOL FALSE 396 PSF_APERTURE_SCALE F32 4.5 397 PSF_REF_RADIUS F32 35 398 399 EXT_FIT_MAX_RADIUS F32 50.0 400 PSF_MODEL STR PS_MODEL_QGAUSS 401 EXT_MODEL STR PS_MODEL_SERSIC 402 END 403 404 # Extended source fit parameters 405 SINGLE_TEST_V1 METADATA 406 EXTENDED_SOURCE_FITS BOOL F # perform any of the aperture-like measurements? 407 EXTENDED_SOURCE_ANALYSIS BOOL F # perform any of the aperture-like measurements? 408 EXTENDED_SOURCE_SN_LIM F32 20.0 409 EXTENDED_SOURCE_PETROSIAN BOOL TRUE 410 EXTENDED_SOURCE_ANNULI BOOL TRUE 411 PSPHOT.STACK.MATCH.PSF.SOURCE STR AUTO # which inputs to convolve? (RAW, CNV, AUTO) 412 PSPHOT.STACK.TARGET.PSF.AUTO BOOL F # automatically determine target PSF size? 413 PSPHOT.STACK.USE.RAW BOOL F # perform photometry & morphology analysis on the raw image 414 @PSPHOT.STACK.TARGET.PSF.FWHM F32 8.0 10.0 # FWHM of target PSF (if NOT AUTO sized; pixels) 415 RADIAL_APERTURES BOOL T # calculate flux in circular radial apertures? 416 RADIAL_APERTURES_SN_LIM F32 0.0 # S/N limit for radial aperture calculation 417 OUTPUT.FORMAT STR PS1_SV1 418 # OUTPUT.FORMAT STR PS1_V3 419 420 # CONSTANT_PHOTOMETRIC_WEIGHTS BOOL TRUE 421 # POISSON.ERRORS.PHOT.LMM BOOL FALSE 422 CONSTANT_PHOTOMETRIC_WEIGHTS BOOL FALSE 423 POISSON.ERRORS.PHOT.LMM BOOL TRUE 424 425 PSF_APERTURE_SCALE F32 4.5 426 PSF_REF_RADIUS F32 35 427 428 EXT_FIT_MAX_RADIUS F32 50.0 429 PSF_MODEL STR PS_MODEL_PS1_V1 430 EXT_MODEL STR PS_MODEL_SERSIC 431 END 432 379 433 STACKPHOT_SINGLE METADATA 380 434 PSPHOT.STACK.USE.RAW BOOL F # since false perform photometry & morphology analysis on the convolved images -
branches/czw_branch/20110406/ippconfig/recipes/reductionClasses.mdc
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20110404/ippconfig/recipes/reductionClasses.mdc (added) merged: 31439 /trunk/ippconfig/recipes/reductionClasses.mdc merged: 31435,31453,31456
r31434 r31606 165 165 END 166 166 167 # large area science analysis 168 LAP_SCIENCE METADATA 169 CHIP_PPIMAGE STR CHIP 170 CHIP_PSPHOT STR CHIP 171 WARP_PSWARP STR WARP 172 STACK_PPSTACK STR STACK 173 STACK_PPSUB STR STACK 174 STACK_PSPHOT STR STACK 175 DIFF_PPSUB STR DIFF 176 DIFF_PSPHOT STR DIFF 177 JPEG_BIN1 STR PPIMAGE_J1 178 JPEG_BIN2 STR PPIMAGE_J2 179 FAKEPHOT STR FAKEPHOT 180 ADDSTAR STR ADDSTAR 181 PSASTRO STR LAP_ASTRO 182 STACKPHOT_PSPHOT STR STACKPHOT 183 STACKPHOT_PPSUB STR STACKPHOT 184 STACKPHOT_PPSTACK STR STACKPHOT 185 STACKPHOT_SINGLE_PSPHOT STR STACKPHOT_SINGLE 186 BACKGROUND_PPBACKGROUND STR BACKGROUND 187 BACKGROUND_PSWARP STR BACKGROUND 188 END 189 167 190 DEFAULT_MASKTEST METADATA 168 191 CHIP_PPIMAGE STR CHIP_MASKTEST - Property svn:mergeinfo changed
-
branches/czw_branch/20110406/ppImage/src
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20110404/ppImage/src (added) merged: 31444
- Property svn:mergeinfo changed
-
branches/czw_branch/20110406/ppSim/src/ppSimInsertGalaxies.c
r29002 r31606 162 162 source->psfMag = -2.5*log10(galaxy->flux); 163 163 source->extMag = -2.5*log10(galaxy->flux); 164 source-> errMag= sqrt(Area*PS_SQR(roughNoise) + galaxy->flux) / galaxy->flux;164 source->psfMagErr = sqrt(Area*PS_SQR(roughNoise) + galaxy->flux) / galaxy->flux; 165 165 166 166 // insert the source flux in the image … … 173 173 174 174 float par8 = (model->params->n == 8) ? model->params->data.F32[7] : 0.0; 175 fprintf (outfile, "%8.3f %8.3f %10.2f %2d %7.3f %5.3f %5.3f %5.3f %5.3f %5.3f\n", galaxy->x, galaxy->y, flux, 1, source->psfMag, source-> errMag, axes.major, axes.minor, axes.theta, par8);175 fprintf (outfile, "%8.3f %8.3f %10.2f %2d %7.3f %5.3f %5.3f %5.3f %5.3f %5.3f\n", galaxy->x, galaxy->y, flux, 1, source->psfMag, source->psfMagErr, axes.major, axes.minor, axes.theta, par8); 176 176 177 177 psArrayAdd (sources, 100,source); -
branches/czw_branch/20110406/ppSim/src/ppSimInsertStars.c
r29002 r31606 121 121 122 122 source->psfMag = -2.5*log10(star->flux); 123 source-> errMag= sqrt(Area*PS_SQR(roughNoise) + flux) / flux;123 source->psfMagErr = sqrt(Area*PS_SQR(roughNoise) + flux) / flux; 124 124 125 125 // set the expected model errors 126 model->dparams->data.F32[PM_PAR_I0] = source-> errMag* model->params->data.F32[PM_PAR_I0];126 model->dparams->data.F32[PM_PAR_I0] = source->psfMagErr * model->params->data.F32[PM_PAR_I0]; 127 127 128 128 float par8 = (model->params->n == 8) ? model->params->data.F32[7] : 0.0; 129 fprintf (outfile, "%8.3f %8.3f %10.2f %2d %7.3f %5.3f %5.3f %5.3f %5.3f %5.3f\n", star->x, star->y, star->flux, 0, source->psfMag, source-> errMag, axes.major, axes.minor, axes.theta, par8);129 fprintf (outfile, "%8.3f %8.3f %10.2f %2d %7.3f %5.3f %5.3f %5.3f %5.3f %5.3f\n", star->x, star->y, star->flux, 0, source->psfMag, source->psfMagErr, axes.major, axes.minor, axes.theta, par8); 130 130 131 131 // if psfConvolve is TRUE, we will (elsewhere) convolve the image we a PSF -
branches/czw_branch/20110406/ppStack/src/ppStackPrepare.c
r31158 r31606 144 144 int numCols = 0, numRows = 0; // Size of image 145 145 options->sumExposure = 0.0; 146 int numWithSources = 0; 146 147 for (int i = 0; i < num; i++) { 147 148 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT", i); // File of interest … … 188 189 pmReadout *ro = pmFPAviewThisReadout(view, file->fpa); // Readout with sources 189 190 detections = psMetadataLookupPtr(NULL, ro->analysis, "PSPHOT.DETECTIONS"); // Sources 190 if (!detections || !detections->allSources ) {191 if (!detections || !detections->allSources || !detections->allSources->n) { 191 192 psWarning("No detections found for image %d --- rejecting.", i); 192 193 options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PPSTACK_MASK_CAL; … … 196 197 197 198 options->sourceLists->data[i] = psMemIncrRefCounter(detections->allSources); 199 numWithSources++; 198 200 } 199 201 … … 230 232 ppStackFileActivation(config, PPSTACK_FILES_PREPARE, true); 231 233 } 234 } 235 if (numWithSources < 2) { 236 // This can happen if the inputs have been destreaked 237 psErrorStackPrint(stderr, "Not enough inputs have sources"); 238 psWarning("No inputs have sources --- suspect bad data quality."); 239 if (options->quality == 0) { 240 options->quality = PPSTACK_ERR_DATA; 241 } 242 psErrorClear(); 243 psFree(view); 244 return false; 232 245 } 233 246 … … 308 321 psFree(psfs); 309 322 if (!options->psf) { 323 #if 1 310 324 psError(psErrorCodeLast(), false, "Unable to determine output PSF."); 325 #else 326 // This will repair the problem reproted in ticket 1427 but we aren't yet sure 327 // why ppStackPSF is failing so we are going to continue to fault for now 328 int errorCode = psErrorCodeLast(); 329 if (errorCode == PPSTACK_ERR_PSF) { 330 psErrorStackPrint(stderr, "Unable to determine output PSF."); 331 psWarning("Unable to determine output PSF --- suspect bad data quality."); 332 if (options->quality == 0) { 333 options->quality = errorCode; 334 } 335 psErrorClear(); 336 } else { 337 psError(psErrorCodeLast(), false, "Unable to determine output PSF."); 338 } 339 #endif // notyet 311 340 psFree(view); 312 341 return false; -
branches/czw_branch/20110406/ppSub/src/ppSubFlagNeighbors.c
r31156 r31606 112 112 bool positive = !matchRef && (sourceM1->imageID == 1); 113 113 positive |= matchRef && (sourceM1->imageID == 2); 114 float SN1 = isfinite(sourceM1-> errMag) ? 1.0 / sourceM1->errMag: NAN;114 float SN1 = isfinite(sourceM1->psfMagErr) ? 1.0 / sourceM1->psfMagErr : NAN; 115 115 if (positive) { 116 116 source->diffStats->SNp = SN1; … … 138 138 bool positive = !matchRef && (sourceM1->imageID == 1); 139 139 positive |= matchRef && (sourceM1->imageID == 2); 140 float SN1 = isfinite(sourceM1-> errMag) ? 1.0 / sourceM1->errMag: NAN;141 float SN2 = isfinite(sourceM2-> errMag) ? 1.0 / sourceM2->errMag: NAN;140 float SN1 = isfinite(sourceM1->psfMagErr) ? 1.0 / sourceM1->psfMagErr : NAN; 141 float SN2 = isfinite(sourceM2->psfMagErr) ? 1.0 / sourceM2->psfMagErr : NAN; 142 142 if (positive) { 143 143 source->diffStats->SNp = SN1; -
branches/czw_branch/20110406/ppSub/src/ppSubReadoutPhotometry.c
r31302 r31606 176 176 177 177 fprintf(sourceFile, "%f %f %f %f %f %f %f %f %d %f %f %f %f %f\n", 178 x, y, source->psfMag, source-> errMag, chi2, source->crNsigma, source->extNsigma,178 x, y, source->psfMag, source->psfMagErr, chi2, source->crNsigma, source->extNsigma, 179 179 source->pixWeight, source->mode, xMoment, yMoment, xxMoment, xyMoment, yyMoment); 180 180 } -
branches/czw_branch/20110406/psLib/src/fits/psFitsImage.c
r30636 r31606 485 485 double boffset; 486 486 int status; 487 status = 0; 487 488 fits_read_key_dbl(fits->fd, "BOFFSET", &boffset, NULL, &status); 488 outImage = psFitsScaleFromDisk(outImage,boffset); 489 psImage *newImage = psFitsScaleFromDisk(outImage,boffset); 490 psFree (outImage); 491 outImage = newImage; 489 492 } 490 493 psFree(info); -
branches/czw_branch/20110406/psLib/src/imageops/psImageGeomManip.c
r23989 r31606 702 702 } \ 703 703 /* note: output(i,j) = input(i+0.5-dx,j+0.5-dy) */ \ 704 /* positive dx,dy moves pixel i-dx,j-dy to i, y*/ \704 /* positive dx,dy moves pixel i-dx,j-dy to i,j */ \ 705 705 /* also: pixel center is 0.5,0.5 */ \ 706 706 for (int row = 0; row < numRows; row++) { \ -
branches/czw_branch/20110406/psLib/src/imageops/psImageInterpolate.c
r28667 r31606 31 31 #include "psImageConvolve.h" 32 32 33 # define IS_BILIN_SEPARABLE 0 34 33 35 #include "psImageInterpolate.h" 34 36 … … 48 50 }; 49 51 52 # if (IS_BILIN_SEPARABLE) 50 53 /// Generate a linear interpolation kernel 51 54 static inline void interpolationKernelBilinear(psF32 *kernel, // Kernel vector to populate … … 56 59 kernel[1] = frac; 57 60 } 61 # else 62 /// Generate a linear interpolation kernel 63 static inline void interpolationKernelBilinear( 64 psF32 kernel[kernelSizes[PS_INTERPOLATE_BILINEAR]][kernelSizes[PS_INTERPOLATE_BILINEAR]], // Kernel 65 float xFrac, float yFrac // Fraction of pixel 66 ) 67 { 68 // (xF*yF, (1-xF)(1-yF) = 1 - xF - yF + xFyF 69 70 kernel[0][0] = 1.0 - xFrac - yFrac + xFrac*yFrac; 71 kernel[1][0] = yFrac - xFrac*yFrac; 72 kernel[0][1] = xFrac - xFrac*yFrac; 73 kernel[1][1] = xFrac*yFrac; 74 } 75 # endif 58 76 59 77 #if 0 … … 173 191 // Nothing to pre-compute 174 192 break; 193 # if (IS_BILIN_SEPARABLE) 175 194 case PS_INTERPOLATE_BILINEAR: 176 195 interpolationKernelBilinear(kernel, frac); 177 196 break; 197 # endif 178 198 case PS_INTERPOLATE_GAUSS: 179 199 interpolationKernelGauss(kernel, kernelSizes[mode], 0.5, frac); … … 184 204 interpolationKernelLanczos(kernel, kernelSizes[mode], frac); 185 205 break; 206 # if (!IS_BILIN_SEPARABLE) 207 case PS_INTERPOLATE_BILINEAR: 208 # endif 186 209 case PS_INTERPOLATE_BIQUADRATIC: // 2D kernel 187 210 default: … … 234 257 235 258 switch (mode) { 259 # if (IS_BILIN_SEPARABLE) 236 260 case PS_INTERPOLATE_BILINEAR: 261 # endif 237 262 case PS_INTERPOLATE_GAUSS: 238 263 case PS_INTERPOLATE_LANCZOS2: … … 258 283 } 259 284 break; 285 # if (!IS_BILIN_SEPARABLE) 286 case PS_INTERPOLATE_BILINEAR: 287 # endif 260 288 case PS_INTERPOLATE_BIQUADRATIC: 261 289 // 2D kernel, would cost too much memory to pre-calculate … … 360 388 int xCentral = floor((X) - 0.5), yCentral = floor((Y) - 0.5); /* Central pixel */ \ 361 389 float xFrac = (X) - xCentral - 0.5, yFrac = (Y) - yCentral - 0.5; /* Fraction of pixel */ \ 390 bool xExact = fabsf(xFrac) < FLT_EPSILON, yExact = fabsf(yFrac) < FLT_EPSILON; /* Are shifts exact? */ \ 391 392 // Set up the kernel parameters; defines some useful values 393 // EAM : I'm unsure of the right answer here 394 #define INTERPOLATE_SETUP_EAM(X, Y) \ 395 int xCentral = floor((X)), yCentral = floor((Y)); /* Central pixel */ \ 396 float xFrac = (X) - xCentral, yFrac = (Y) - yCentral; /* Fraction of pixel */ \ 362 397 bool xExact = fabsf(xFrac) < FLT_EPSILON, yExact = fabsf(yFrac) < FLT_EPSILON; /* Are shifts exact? */ \ 363 398 … … 722 757 } 723 758 724 // Interpolation engine for ( separable) interpolation kernels759 // Interpolation engine for (non-separable) interpolation kernels 725 760 static psImageInterpolateStatus interpolateKernel(double *imageValue, double *varianceValue, 726 761 psImageMaskType *maskValue, float x, float y, … … 747 782 // Get the appropriate kernels 748 783 psF32 kernel[size][size]; 784 785 # if (IS_BILIN_SEPARABLE) 749 786 psAssert(mode == PS_INTERPOLATE_BIQUADRATIC, "Mode is %x", mode); 750 787 interpolationKernelBiquadratic(kernel, xFrac, yFrac); 788 # else 789 psAssert((mode == PS_INTERPOLATE_BIQUADRATIC) || (mode == PS_INTERPOLATE_BILINEAR), "Mode is %x", mode); 790 if (mode == PS_INTERPOLATE_BIQUADRATIC) { 791 interpolationKernelBiquadratic(kernel, xFrac, yFrac); 792 } else { 793 interpolationKernelBilinear(kernel, xFrac, yFrac); 794 } 795 # endif 796 797 # if (0) 798 for (int i = 0; i < size; i++) { 799 for (int j = 0; j < size; j++) { 800 fprintf (stderr, "%f ", kernel[i][j]); 801 } 802 fprintf (stderr, "\n"); 803 } 804 # endif 751 805 752 806 float sumKernel = 0.0; // Sum of the kernel … … 908 962 return interpolateKernel(imageValue, varianceValue, maskValue, x, y, interp); 909 963 case PS_INTERPOLATE_BILINEAR: 964 # if (!IS_BILIN_SEPARABLE) 965 return interpolateKernel(imageValue, varianceValue, maskValue, x, y, interp); 966 # endif 910 967 case PS_INTERPOLATE_GAUSS: 911 968 case PS_INTERPOLATE_LANCZOS2: -
branches/czw_branch/20110406/psLib/src/imageops/psImageMaskOps.c
r25753 r31606 146 146 for (int iy = 0; iy < image->numRows; iy++) { \ 147 147 for (int ix = 0; ix < image->numCols; ix++) { \ 148 dx = ix + image->col0 - x; \149 dy = iy + image->row0 - y; \148 dx = ix + 0.5 + image->col0 - x; \ 149 dy = iy + 0.5 + image->row0 - y; \ 150 150 r2 = PS_SQR(dx) + PS_SQR(dy); \ 151 151 if (r2 <= R2) { \ … … 197 197 for (int iy = 0; iy < image->numRows; iy++) { \ 198 198 for (int ix = 0; ix < image->numCols; ix++) { \ 199 dx = ix + image->col0 - x; \200 dy = iy + image->row0 - y; \199 dx = ix + 0.5 + image->col0 - x; \ 200 dy = iy + 0.5 + image->row0 - y; \ 201 201 r2 = PS_SQR(dx) + PS_SQR(dy); \ 202 202 if (r2 > R2) { \ -
branches/czw_branch/20110406/psModules/src/camera/pmFPAMaskWeight.c
r29544 r31606 587 587 double imageValue, varianceValue; // Image and variance value from interpolation 588 588 psImageMaskType maskValue = 0; // Mask value from interpolation 589 psImageInterpolateStatus status = psImageInterpolate(&imageValue, &varianceValue, &maskValue, x, y, interp); 589 590 // interpolate to pixel center (index + 0.5) 591 psImageInterpolateStatus status = psImageInterpolate(&imageValue, &varianceValue, &maskValue, x + 0.5, y + 0.5, interp); 590 592 if (status == PS_INTERPOLATE_STATUS_ERROR || status == PS_INTERPOLATE_STATUS_OFF) { 591 593 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate readout at %d,%d", x, y); -
branches/czw_branch/20110406/psModules/src/imcombine/pmPSFEnvelope.c
r29543 r31606 380 380 381 381 // measure the source moments: tophat windowing, no pixel S/N cutoff 382 if (!pmSourceMoments(source, maxRadius, 0.0, 0.0, maskVal)) {382 if (!pmSourceMoments(source, maxRadius, 0.0, 0.0, 0.0, maskVal)) { 383 383 // Can't do anything about it; limp along as best we can 384 384 psErrorClear(); -
branches/czw_branch/20110406/psModules/src/imcombine/pmSubtractionStamps.c
r31153 r31606 834 834 } 835 835 836 psStatsInit (stats); 837 if (!psVectorStats (stats, flux1, NULL, NULL, 0)) { 838 psAbort ("failed to generate stats"); 839 } 840 float f1 = stats->sampleMedian; 841 842 psStatsInit (stats); 843 if (!psVectorStats (stats, flux2, NULL, NULL, 0)) { 844 psAbort ("failed to generate stats"); 845 } 846 float f2 = stats->sampleMedian; 836 float f1 = NAN; 837 if (flux1->n > 0) { 838 psStatsInit (stats); 839 if (!psVectorStats (stats, flux1, NULL, NULL, 0)) { 840 psAbort ("failed to generate stats"); 841 } 842 f1 = stats->sampleMedian; 843 } 844 845 float f2 = NAN; 846 if (flux2->n > 0) { 847 psStatsInit (stats); 848 if (!psVectorStats (stats, flux2, NULL, NULL, 0)) { 849 psAbort ("failed to generate stats"); 850 } 851 f2 = stats->sampleMedian; 852 } 847 853 848 854 stamps->window1->kernel[y][x] = f1; … … 893 899 float R2 = Sr2 / Sf2; 894 900 901 if (!isfinite(R1) || !isfinite(R2)) { 902 psError(PM_ERR_STAMPS, true, "Kron Radii are not finite (failure to converge)."); 903 psFree (stats); 904 psFree (flux1); 905 psFree (flux2); 906 psFree (norm1); 907 psFree (norm2); 908 return false; 909 } 910 895 911 // Compare the Kron Radii (R1 & R2) to above to the FWHMs : if they are too discrepant, we will need to rescale 896 912 psLogMsg ("psModules.imcombine", PS_LOG_DETAIL, "Kron Radii vs FWHMs 1: fwhm: %f, kron %f\n", fwhm1, R1); … … 901 917 stamps->normWindow2 = 2.75*R2; 902 918 psLogMsg ("psModules.imcombine", PS_LOG_DETAIL, "Windows from Kron Radii: %f for 1, %f for 2\n", stamps->normWindow1, stamps->normWindow2); 919 903 920 904 921 // if the calculated normWindows are too large, we will fall off the stamps. In this case, we need to try again. … … 913 930 psFree (norm2); 914 931 return false; 915 }916 917 if (!isfinite(R1) || !isfinite(R2)) {918 psError(PM_ERR_STAMPS, true, "Kron Radii are not finite (failure to converge).");919 psFree (stats);920 psFree (flux1);921 psFree (flux2);922 psFree (norm1);923 psFree (norm2);924 return false;925 932 } 926 933 … … 1197 1204 1198 1205 // fprintf (stderr, "%f,%f : %f %f : %f %f\n", source->peak->xf, source->peak->yf, 1199 // source->psfMag, source->apMag, source->psfMag - source->apMag, source-> errMag);1206 // source->psfMag, source->apMag, source->psfMag - source->apMag, source->psfMagErr); 1200 1207 1201 1208 // XXX this is somewhat arbitrary... 1202 if (source-> errMag> 0.05) continue;1209 if (source->psfMagErr > 0.05) continue; 1203 1210 if (fabs(source->psfMag - source->apMag) > 0.5) continue; 1204 1211 -
branches/czw_branch/20110406/psModules/src/objects/Makefile.am
r31153 r31606 114 114 pmTrend2D.h \ 115 115 pmGrowthCurve.h \ 116 pmGrowthCurveGenerate.h \ 116 117 pmSourceMatch.h \ 117 118 pmDetEff.h \ -
branches/czw_branch/20110406/psModules/src/objects/models/pmModel_DEV.c
r31153 r31606 268 268 float f0 = 1.0; 269 269 float f1, f2; 270 for (z = DZ; z < 50; z += DZ) {270 for (z = DZ; z < 150; z += DZ) { 271 271 f1 = exp(-pow(z,ALPHA)); 272 272 z += DZ; -
branches/czw_branch/20110406/psModules/src/objects/models/pmModel_EXP.c
r31153 r31606 255 255 float f0 = 1.0; 256 256 float f1, f2; 257 for (z = DZ; z < 50; z += DZ) {257 for (z = DZ; z < 150; z += DZ) { 258 258 f1 = exp(-sqrt(z)); 259 259 z += DZ; -
branches/czw_branch/20110406/psModules/src/objects/models/pmModel_PGAUSS.c
r31153 r31606 239 239 float f0 = 1.0; 240 240 float f1, f2; 241 for (z = DZ; z < 50; z += DZ) {241 for (z = DZ; z < 150; z += DZ) { 242 242 f1 = 1.0 / (1 + z + z*z/2.0 + z*z*z/6.0); 243 243 z += DZ; -
branches/czw_branch/20110406/psModules/src/objects/models/pmModel_PS1_V1.c
r31153 r31606 261 261 float f0 = 1.0; 262 262 float f1, f2; 263 for (z = DZ; z < 50; z += DZ) {263 for (z = DZ; z < 150; z += DZ) { 264 264 f1 = 1.0 / (1 + PAR[PM_PAR_7]*z + pow(z, ALPHA)); 265 265 z += DZ; … … 288 288 if (PAR[PM_PAR_I0] <= 0) return 1.0; 289 289 if (flux >= PAR[PM_PAR_I0]) return 1.0; 290 if (PAR[PM_PAR_7] == 0.0) return powf(PAR[PM_PAR_I0] / flux - 1.0, 1.0 / ALPHA);291 290 292 291 shape.sx = PAR[PM_PAR_SXX] / M_SQRT2; … … 296 295 psEllipseAxes axes = psEllipseShapeToAxes (shape, 20.0); 297 296 psF64 sigma = axes.major; 297 298 if (PAR[PM_PAR_7] == 0.0) { 299 psF32 z = powf(PAR[PM_PAR_I0] / flux - 1.0, 1.0 / ALPHA); 300 return ( sigma * sqrt (2.0 * z) ); 301 } 298 302 299 303 psF64 limit = flux / PAR[PM_PAR_I0]; -
branches/czw_branch/20110406/psModules/src/objects/models/pmModel_QGAUSS.c
r31153 r31606 262 262 float f0 = 1.0; 263 263 float f1, f2; 264 for (z = DZ; z < 50; z += DZ) {264 for (z = DZ; z < 150; z += DZ) { 265 265 f1 = 1.0 / (1 + PAR[PM_PAR_7]*z + pow(z, ALPHA)); 266 266 z += DZ; -
branches/czw_branch/20110406/psModules/src/objects/models/pmModel_RGAUSS.c
r31153 r31606 251 251 float f0 = 1.0; 252 252 float f1, f2; 253 for (z = DZ; z < 50; z += DZ) {253 for (z = DZ; z < 150; z += DZ) { 254 254 f1 = 1.0 / (1 + z + pow(z, PAR[PM_PAR_7])); 255 255 z += DZ; -
branches/czw_branch/20110406/psModules/src/objects/models/pmModel_SERSIC.c
r31153 r31606 316 316 float f0 = 1.0; 317 317 float f1, f2; 318 for (z = DZ; z < 50; z += DZ) {318 for (z = DZ; z < 150; z += DZ) { 319 319 // f1 = 1.0 / (1 + PAR[PM_PAR_7]*z + pow(z, 2.25)); 320 320 f1 = exp(-pow(z,PAR[PM_PAR_7])); -
branches/czw_branch/20110406/psModules/src/objects/pmGrowthCurve.c
r29004 r31606 73 73 // Fractional pixel radii are not well defined; use integer pixel radii. Use 1 pixel steps 74 74 // until the scaling factor steps in intervals larger than 1 pixel 75 float Rlin = 1.0 / (fR - 1.0);75 // float Rlin = 1.0 / (fR - 1.0); 76 76 77 77 growth->radius = psVectorAllocEmpty (NPTS, PS_DATA_F32); … … 79 79 // there will be NPTS radii + a few extras 80 80 float radius = minRadius; 81 while (radius < Rlin) {81 while (radius < refRadius) { 82 82 // fprintf (stderr, "r: %f\n", radius); 83 psVectorAppend (growth->radius, radius );83 psVectorAppend (growth->radius, radius - 0.001); 84 84 radius += 1.0; 85 85 } 86 growth->refBin = growth->radius->n - 1; 86 87 while (radius < maxRadius) { 87 88 // fprintf (stderr, "r: %f\n", radius); 88 psVectorAppend (growth->radius, radius );89 psVectorAppend (growth->radius, radius - 0.001); 89 90 radius *= fR; 90 91 radius = (int) (radius + 0.5); … … 96 97 growth->refRadius = refRadius; 97 98 growth->maxRadius = maxRadius; 98 growth->apLoss = 0.0; 99 growth->fitMag = 0.0; 99 growth->fitMag = NAN; 100 growth->refMag = NAN; 101 growth->apRef = NAN; 102 growth->apLoss = NAN; 103 100 104 return growth; 101 105 } -
branches/czw_branch/20110406/psModules/src/objects/pmGrowthCurve.h
r15562 r31606 22 22 psF32 maxRadius; 23 23 psF32 fitMag; 24 psF32 refMag; 24 25 psF32 apRef; // apMag[refRadius] 25 26 psF32 apLoss; // fitMag - apRef 27 int refBin; 26 28 } 27 29 pmGrowthCurve; -
branches/czw_branch/20110406/psModules/src/objects/pmGrowthCurveGenerate.c
r29546 r31606 50 50 51 51 #include "pmSourcePhotometry.h" 52 53 pmGrowthCurve *pmGrowthCurveForPosition (psImage *image, pmPSF *psf, bool ignore, psImageMaskType maskVal, psImageMaskType markVal, float xc, float yc); 52 #include "pmGrowthCurveGenerate.h" 54 53 55 54 /*****************************************************************************/ … … 197 196 // mask the given aperture and measure the apMag 198 197 psImageKeepCircle (mask, xc, yc, radius, "OR", markVal); 199 if (!pmSourcePhotometryAper ( &apMag, NULL, NULL, model, pixels, NULL, mask, maskVal)) {198 if (!pmSourcePhotometryAper (NULL, &apMag, NULL, NULL, model, pixels, NULL, mask, maskVal)) { 200 199 psFree (growth); 201 200 psFree (view); … … 226 225 return growth; 227 226 } 227 228 # define DEBUG 0 229 # if (DEBUG) 230 static FILE *fgr = NULL; 231 # endif 232 233 // we generate the growth curve for the center of the image with the specified psf model 234 bool pmGrowthCurveGenerateFromSources (pmReadout *readout, pmPSF *psf, psArray *sources, bool INTERPOLATE_AP, psImageMaskType maskVal, psImageMaskType markVal) 235 { 236 PS_ASSERT_PTR_NON_NULL(readout, false); 237 PS_ASSERT_PTR_NON_NULL(readout->image, false); 238 239 // maskVal is used to test for rejected pixels, and must include markVal 240 maskVal |= markVal; 241 242 pmSourcePhotometryMode photMode = INTERPOLATE_AP ? PM_SOURCE_PHOT_INTERP : 0; 243 244 // measure the growth curve for each PSF source and average them together 245 psArray *growths = psArrayAllocEmpty (100); 246 247 # if (DEBUG) 248 fgr = fopen ("growth.mags.dat", "w"); 249 # endif 250 251 for (int i = 0; i < sources->n; i++) { 252 253 pmSource *source = sources->data[i]; 254 255 if (!(source->mode & PM_SOURCE_MODE_PSFSTAR)) continue; 256 257 pmGrowthCurve *growth = pmGrowthCurveForSource (source, psf, photMode, maskVal, markVal); 258 if (!growth) continue; 259 260 psArrayAdd (growths, 100, growth); 261 psFree (growth); 262 } 263 psAssert (growths->n, "cannot build growth curve (no valid PSF stars?)"); 264 265 # if (DEBUG) 266 fclose (fgr); 267 # endif 268 269 // just use a simple sample median to get the 'best' value from each growth curve... 270 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN); 271 272 psVector *values = psVectorAlloc (growths->n, PS_DATA_F32); 273 274 // loop over a range of source fluxes 275 // no need to interpolate since we have forced the object center 276 // to 0.5, 0.5 above 277 for (int i = 0; i < psf->growth->radius->n; i++) { 278 279 // median the values for each radial bin 280 values->n = 0; 281 for (int j = 0; j < growths->n; j++) { 282 pmGrowthCurve *growth = growths->data[j]; 283 if (!isfinite(growth->apMag->data.F32[i])) continue; 284 psVectorAppend (values, growth->apMag->data.F32[i] - growth->refMag); 285 } 286 if (values->n == 0) { 287 psf->growth->apMag->data.F32[i] = NAN; 288 } else { 289 if (!psVectorStats (stats, values, NULL, NULL, 0)) { 290 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 291 return false; 292 } 293 psf->growth->apMag->data.F32[i] = stats->sampleMedian; 294 } 295 } 296 297 psf->growth->fitMag = psf->growth->apMag->data.F32[psf->growth->radius->n-1]; 298 psf->growth->apRef = psVectorInterpolate (psf->growth->radius, psf->growth->apMag, psf->growth->refRadius); 299 psf->growth->apLoss = psf->growth->fitMag - psf->growth->apRef; 300 301 psLogMsg ("psphot.growth", 4, "GrowthCurve : apLoss : %f (fitMag - apMag @ ref : %f - %f)\n", psf->growth->apLoss, psf->growth->fitMag, psf->growth->apRef); 302 303 psFree (growths); 304 psFree (stats); 305 psFree (values); 306 307 return true; 308 } 309 310 pmGrowthCurve *pmGrowthCurveForSource (pmSource *source, pmPSF *psf, pmSourcePhotometryMode photMode, psImageMaskType maskVal, psImageMaskType markVal) { 311 312 float radius; 313 314 assert (psf->growth); 315 316 float minRadius = psf->growth->radius->data.F32[0]; 317 pmGrowthCurve *growth = pmGrowthCurveAlloc (minRadius, psf->growth->maxRadius, psf->growth->refRadius); 318 319 // measure the fitMag for this source (for normalization) 320 // pmSourcePhotometryModel (&fitMag, NULL, source->psfModel); 321 growth->fitMag = source->psfMag; 322 323 float xc = source->peak->xf; 324 float yc = source->peak->yf; 325 326 // Loop over the range of radii 327 for (int i = 0; i < growth->radius->n; i++) { 328 329 radius = growth->radius->data.F32[i]; 330 331 // mask the given aperture and measure the apMag 332 psImageKeepCircle (source->maskObj, xc, yc, radius, "OR", markVal); 333 334 if (!pmSourceMagnitudes (source, psf, photMode, maskVal, markVal, radius)) { 335 psFree (growth); 336 return NULL; 337 } 338 339 // if (!pmSourcePhotometryAper (NULL, &apMag, NULL, NULL, NULL, source->pixels, NULL, source->maskObj, maskVal)) { 340 // psFree (growth); 341 // return NULL; 342 // } 343 344 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask 345 346 growth->apMag->data.F32[i] = source->apMag; 347 } 348 psAssert(growth->refBin >= 0, "invalid growth reference bin"); 349 psAssert(growth->refBin < growth->apMag->n, "invalid growth reference bin"); 350 growth->refMag = growth->apMag->data.F32[growth->refBin]; 351 352 // Loop over the range of radii 353 # if (DEBUG) 354 for (int i = 0; i < growth->radius->n; i++) { 355 fprintf (fgr, "%f %f %f %f %f %f\n", xc, yc, growth->radius->data.F32[i], growth->apMag->data.F32[i], growth->fitMag, growth->refMag); 356 } 357 # endif 358 359 return growth; 360 } -
branches/czw_branch/20110406/psModules/src/objects/pmPCMdata.c
r31153 r31606 263 263 bool pmPCMupdate(pmPCMdata *pcm, pmSource *source, pmSourceFitOptions *fitOptions, pmModel *model) { 264 264 265 bool newWindow = (source->pixels->numRows != pcm->modelFlux->numRows) || (source->pixels->numCols != pcm->modelFlux->numCols); 265 bool sameWindow = (source->pixels->numRows == pcm->modelFlux->numRows); 266 sameWindow &= (source->pixels->numCols == pcm->modelFlux->numCols); 267 sameWindow &= (source->pixels->col0 == pcm->modelFlux->col0); 268 sameWindow &= (source->pixels->row0 == pcm->modelFlux->row0); 266 269 267 270 // re-count the number of unmasked pixels: 268 if ( newWindow) {271 if (!sameWindow) { 269 272 for (psS32 i = 0; i < source->pixels->numRows; i++) { 270 273 for (psS32 j = 0; j < source->pixels->numCols; j++) { … … 346 349 347 350 // has the source pixel window changed? 348 if ( newWindow) {351 if (!sameWindow) { 349 352 350 353 // adjust all supporting images: -
branches/czw_branch/20110406/psModules/src/objects/pmPSF.c
r31153 r31606 73 73 74 74 options->type = 0; 75 76 75 options->stats = NULL; 77 options->fitOptions = NULL; // XXX this has to be set before calling pmPSF fit functions78 76 79 77 options->psfTrendMode = PM_TREND_NONE; … … 90 88 91 89 options->chiFluxTrend = true; 92 90 options->fitOptions = NULL; // XXX this has to be set before calling pmPSF fit functions 91 92 options->fitRadius = NAN; 93 options->apRadius = NAN; 93 94 return options; 94 95 } … … 141 142 142 143 psf->type = options->type; 144 143 145 psf->chisq = 0.0; 144 146 psf->ApResid = 0.0; -
branches/czw_branch/20110406/psModules/src/objects/pmPSF.h
r29004 r31606 31 31 struct pmPSF { 32 32 pmModelType type; ///< PSF Model in use 33 psArray *params; ///< Model parameters (psPolynomial2D) 34 psStats *psfTrendStats; ///< psf parameter trend clipping stats 35 pmTrend2DMode psfTrendMode; 36 psPolynomial1D *ChiTrend; ///< Chisq vs flux fit (correction for systematic errors) 37 pmTrend2D *ApTrend; ///< ApResid vs (x,y) 38 pmTrend2D *FluxScale; ///< Flux for PSF at (x,y) for normalization = 1.0 33 34 float chisq; ///< PSF goodness statistic (unused??) 39 35 float ApResid; ///< apMag - psfMag (for PSF stars) 40 36 float dApResid; ///< scatter of ApResid 41 37 float skyBias; ///< implied residual sky offset from ApResid fit 42 38 float skySat; ///< roll-over of ApResid fit 43 float chisq; ///< PSF goodness statistic (unused??)44 39 int nPSFstars; ///< number of stars used to measure PSF 45 40 int nApResid; ///< number of stars used to measure ApResid 41 42 bool poissonErrorsPhotLMM; ///< use poission errors for non-linear model fitting 43 bool poissonErrorsPhotLin; ///< use poission errors for linear model fitting 44 bool poissonErrorsParams; ///< use poission errors for model parameter fitting 45 46 pmTrend2D *ApTrend; ///< ApResid vs (x,y) 47 pmTrend2D *FluxScale; ///< Flux for PSF at (x,y) for normalization = 1.0 48 psPolynomial1D *ChiTrend; ///< Chisq vs flux fit (correction for systematic errors) 49 50 pmGrowthCurve *growth; ///< apMag vs Radius 51 pmResiduals *residuals; ///< normalized residual image (no spatial variation) 52 53 psArray *params; ///< Model parameters (psPolynomial2D) 54 psStats *psfTrendStats; ///< psf parameter trend clipping stats 55 56 pmTrend2DMode psfTrendMode; 46 57 int trendNx; 47 58 int trendNy; … … 50 61 int fieldXo; 51 62 int fieldYo; 52 bool poissonErrorsPhotLMM; ///< use poission errors for non-linear model fitting53 bool poissonErrorsPhotLin; ///< use poission errors for linear model fitting54 bool poissonErrorsParams; ///< use poission errors for model parameter fitting55 pmGrowthCurve *growth; ///< apMag vs Radius56 pmResiduals *residuals; ///< normalized residual image (no spatial variation)57 63 }; 58 64 … … 60 66 pmModelType type; 61 67 psStats *stats; // psfTrend clipping stats 68 62 69 pmTrend2DMode psfTrendMode; 63 70 int psfTrendNx; … … 67 74 int psfFieldXo; 68 75 int psfFieldYo; 76 69 77 bool poissonErrorsPhotLMM; ///< use poission errors for non-linear model fitting 70 78 bool poissonErrorsPhotLin; ///< use poission errors for linear model fitting 71 79 bool poissonErrorsParams; ///< use poission errors for model parameter fitting 80 81 bool chiFluxTrend; // Fit a trend in Chi2 as a function of flux? 82 pmSourceFitOptions *fitOptions; 83 72 84 float fitRadius; 73 85 float apRadius; 74 bool chiFluxTrend; // Fit a trend in Chi2 as a function of flux?75 pmSourceFitOptions *fitOptions;76 86 } pmPSFOptions; 77 87 … … 94 104 double pmPSF_SXYtoModel (psF32 *fittedPar); 95 105 96 bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psImageMaskType maskVal, psImageMaskType mark);97 106 pmPSF *pmPSFBuildSimple (char *typeName, float sxx, float syy, float sxy, ...); 98 107 -
branches/czw_branch/20110406/psModules/src/objects/pmPSF_IO.c
r30031 r31606 63 63 64 64 bool pmPSFmodelReadPSFClump (psMetadata *analysis, psMetadata *header); 65 bool pmPSFmodelRead_ApTrend (pmPSF *psf, pmFPAfile *file); 66 bool pmPSFmodelWrite_ApTrend (pmFPAfile *file, pmPSF *psf); 67 68 bool pmPSFmodelRead_GrowthCurve (pmPSF *psf, pmFPAfile *file); 69 bool pmPSFmodelWrite_GrowthCurve (pmFPAfile *file, pmPSF *psf); 65 70 66 71 bool pmPSFmodelCheckDataStatusForView (const pmFPAview *view, const pmFPAfile *file) … … 197 202 psError(psErrorCodeLast(), false, "Failed to write PSF for chip"); 198 203 return false; 204 } 205 return true; 206 } 207 208 // XXX we save the model term identifiers (item) as S32, but they probably should be more flexible 209 bool pmTrend2DtoTable (psArray *table, pmTrend2D *trend, char *label, int item) { 210 211 if (trend == NULL) return true; 212 213 if (trend->mode == PM_TREND_MAP) { 214 // write the image components into a table: this is needed because they may each be a different size 215 psImageMap *map = trend->map; 216 for (int ix = 0; ix < map->map->numCols; ix++) { 217 for (int iy = 0; iy < map->map->numRows; iy++) { 218 psMetadata *row = psMetadataAlloc (); 219 psMetadataAddS32 (row, PS_LIST_TAIL, label, 0, "", item); 220 psMetadataAddS32 (row, PS_LIST_TAIL, "X_POWER", 0, "", ix); 221 psMetadataAddS32 (row, PS_LIST_TAIL, "Y_POWER", 0, "", iy); 222 psMetadataAddF32 (row, PS_LIST_TAIL, "VALUE", 0, "", map->map->data.F32[iy][ix]); 223 psMetadataAddF32 (row, PS_LIST_TAIL, "ERROR", 0, "", map->error->data.F32[iy][ix]); 224 psMetadataAddU8 (row, PS_LIST_TAIL, "MASK", 0, "", 0); // no cells are masked 225 226 psArrayAdd (table, 100, row); 227 psFree (row); 228 } 229 } 230 } else { 231 // write the polynomial components into a table 232 psPolynomial2D *poly = trend->poly; 233 for (int ix = 0; ix <= poly->nX; ix++) { 234 for (int iy = 0; iy <= poly->nY; iy++) { 235 psMetadata *row = psMetadataAlloc (); 236 psMetadataAddS32 (row, PS_LIST_TAIL, label, 0, "", item); 237 psMetadataAddS32 (row, PS_LIST_TAIL, "X_POWER", 0, "", ix); 238 psMetadataAddS32 (row, PS_LIST_TAIL, "Y_POWER", 0, "", iy); 239 psMetadataAddF32 (row, PS_LIST_TAIL, "VALUE", 0, "", poly->coeff[ix][iy]); 240 psMetadataAddF32 (row, PS_LIST_TAIL, "ERROR", 0, "", poly->coeffErr[ix][iy]); 241 psMetadataAddU8 (row, PS_LIST_TAIL, "MASK", 0, "", poly->coeffMask[ix][iy]); 242 243 psArrayAdd (table, 100, row); 244 psFree (row); 245 } 246 } 247 } 248 return true; 249 } 250 251 // extra trend2D elements from a row 252 bool pmTrend2DfromTableRow (pmTrend2D *trend, psMetadata *row) { 253 254 bool status = false; 255 256 int xPow = psMetadataLookupS32 (&status, row, "X_POWER"); 257 int yPow = psMetadataLookupS32 (&status, row, "Y_POWER"); 258 259 if (trend->mode == PM_TREND_MAP) { 260 psImageMap *map = trend->map; 261 assert (map); 262 assert (map->map); 263 assert (map->error); 264 assert (xPow >= 0); 265 assert (yPow >= 0); 266 assert (xPow < map->map->numCols); 267 assert (yPow < map->map->numRows); 268 map->map->data.F32[yPow][xPow] = psMetadataLookupF32 (&status, row, "VALUE"); 269 map->error->data.F32[yPow][xPow] = psMetadataLookupF32 (&status, row, "ERROR"); 270 } else { 271 psPolynomial2D *poly = trend->poly; 272 assert (poly); 273 assert (xPow >= 0); 274 assert (yPow >= 0); 275 assert (xPow <= poly->nX); 276 assert (yPow <= poly->nY); 277 poly->coeff[xPow][yPow] = psMetadataLookupF32 (&status, row, "VALUE"); 278 poly->coeffErr[xPow][yPow] = psMetadataLookupF32 (&status, row, "ERROR"); 279 poly->coeffMask[xPow][yPow] = psMetadataLookupU8 (&status, row, "MASK"); 199 280 } 200 281 return true; … … 403 484 404 485 if (trend->mode == PM_TREND_MAP) { 405 nX = trend->map->map->numCols;406 nY = trend->map->map->numRows;486 nX = trend->map->map->numCols; 487 nY = trend->map->map->numRows; 407 488 } else { 408 nX = trend->poly->nX;409 nY = trend->poly->nY;489 nX = trend->poly->nX; 490 nY = trend->poly->nY; 410 491 } 411 492 snprintf (name, 9, "PAR%02d_NX", i); … … 428 509 psMetadataAddF32 (header, PS_LIST_TAIL, "SKY_BIAS", PS_DATA_F32, "sky bias level", psf->skyBias); 429 510 511 float PSF_APERTURE = psMetadataLookupF32(&status, roAnalysis, "PSF_APERTURE"); 512 if (status) { 513 psMetadataAddF32 (header, PS_LIST_TAIL, "PSF_APERTURE", PS_DATA_F32, "aperture for psf objects", PSF_APERTURE); 514 } 515 float PSF_FIT_RADIUS = psMetadataLookupF32(&status, roAnalysis, "PSF_FIT_RADIUS"); 516 if (status) { 517 psMetadataAddF32 (header, PS_LIST_TAIL, "PSF_FIT_RADIUS", PS_DATA_F32, "aperture for psf objects", PSF_FIT_RADIUS); 518 } 519 430 520 // build a FITS table of the PSF parameters 431 521 psArray *psfTable = psArrayAllocEmpty (100); 432 522 for (int i = 0; i < nPar; i++) { 433 523 pmTrend2D *trend = psf->params->data[i]; 434 if (trend == NULL) continue; // skip unset parameters (eg, XPOS) 435 436 if (trend->mode == PM_TREND_MAP) { 437 // write the image components into a table: this is needed because they may each be a different size 438 psImageMap *map = trend->map; 439 for (int ix = 0; ix < map->map->numCols; ix++) { 440 for (int iy = 0; iy < map->map->numRows; iy++) { 441 psMetadata *row = psMetadataAlloc (); 442 psMetadataAddS32 (row, PS_LIST_TAIL, "MODEL_TERM", 0, "", i); 443 psMetadataAddS32 (row, PS_LIST_TAIL, "X_POWER", 0, "", ix); 444 psMetadataAddS32 (row, PS_LIST_TAIL, "Y_POWER", 0, "", iy); 445 psMetadataAddF32 (row, PS_LIST_TAIL, "VALUE", 0, "", map->map->data.F32[iy][ix]); 446 psMetadataAddF32 (row, PS_LIST_TAIL, "ERROR", 0, "", map->error->data.F32[iy][ix]); 447 psMetadataAddU8 (row, PS_LIST_TAIL, "MASK", 0, "", 0); // no cells are masked 448 449 psArrayAdd (psfTable, 100, row); 450 psFree (row); 451 } 452 } 453 } else { 454 // write the polynomial components into a table 455 psPolynomial2D *poly = trend->poly; 456 for (int ix = 0; ix <= poly->nX; ix++) { 457 for (int iy = 0; iy <= poly->nY; iy++) { 458 psMetadata *row = psMetadataAlloc (); 459 psMetadataAddS32 (row, PS_LIST_TAIL, "MODEL_TERM", 0, "", i); 460 psMetadataAddS32 (row, PS_LIST_TAIL, "X_POWER", 0, "", ix); 461 psMetadataAddS32 (row, PS_LIST_TAIL, "Y_POWER", 0, "", iy); 462 psMetadataAddF32 (row, PS_LIST_TAIL, "VALUE", 0, "", poly->coeff[ix][iy]); 463 psMetadataAddF32 (row, PS_LIST_TAIL, "ERROR", 0, "", poly->coeffErr[ix][iy]); 464 psMetadataAddU8 (row, PS_LIST_TAIL, "MASK", 0, "", poly->coeffMask[ix][iy]); 465 466 psArrayAdd (psfTable, 100, row); 467 psFree (row); 468 } 469 } 470 } 524 pmTrend2DtoTable (psfTable, trend, "MODEL_TERM", i); 471 525 } 472 526 … … 547 601 } 548 602 603 if (!pmPSFmodelWrite_ApTrend(file, psf)) { 604 psError(psErrorCodeLast(), false, "Unable to write PSF ApTrend"); 605 return false; 606 } 607 608 if (!pmPSFmodelWrite_GrowthCurve(file, psf)) { 609 psError(psErrorCodeLast(), false, "Unable to write PSF Growth Curve"); 610 return false; 611 } 612 549 613 // write a representation of the psf model 550 614 { 551 615 psMetadata *header = psMetadataAlloc (); 552 553 if (0) {554 // set some header keywords to make it clear there are no residuals?555 if (!psFitsWriteBlank (file->fits, header, residName)) {556 psError(psErrorCodeLast(), false, "Unable to write blank PSF residuals.");557 psFree(residName);558 psFree(header);559 return false;560 }561 psFree (residName);562 psFree (header);563 return true;564 }565 616 566 617 int DX = 65; … … 651 702 } 652 703 704 705 653 706 // if this file needs to have a PHU written out, write one 654 707 bool pmPSFmodelWritePHU (const pmFPAview *view, pmFPAfile *file, pmConfig *config) … … 934 987 psf->skyBias = psMetadataLookupF32 (&status, header, "SKY_BIAS"); 935 988 989 if (roAnalysis) { 990 float PSF_APERTURE = psMetadataLookupF32(&status, header, "PSF_APERTURE"); 991 if (status) { 992 psMetadataAddF32 (roAnalysis, PS_LIST_TAIL, "PSF_APERTURE", PS_DATA_F32, "aperture for psf objects", PSF_APERTURE); 993 } 994 float PSF_FIT_RADIUS = psMetadataLookupF32(&status, header, "PSF_FIT_RADIUS"); 995 if (status) { 996 psMetadataAddF32 (roAnalysis, PS_LIST_TAIL, "PSF_FIT_RADIUS", PS_DATA_F32, "aperture for psf objects", PSF_FIT_RADIUS); 997 } 998 } else { 999 psWarning ("unable to read PSF_APERTURE or PSF_FIT_RADIUS"); 1000 } 1001 936 1002 // read the raw table data 937 1003 psArray *table = psFitsReadTable (file->fits); … … 945 1011 for (int i = 0; i < table->n; i++) { 946 1012 psMetadata *row = table->data[i]; 1013 947 1014 int iPar = psMetadataLookupS32 (&status, row, "MODEL_TERM"); 948 int xPow = psMetadataLookupS32 (&status, row, "X_POWER");949 int yPow = psMetadataLookupS32 (&status, row, "Y_POWER");950 1015 951 1016 pmTrend2D *trend = psf->params->data[iPar]; … … 955 1020 } 956 1021 957 if (trend->mode == PM_TREND_MAP) { 958 psImageMap *map = trend->map; 959 assert (map); 960 assert (map->map); 961 assert (map->error); 962 assert (xPow >= 0); 963 assert (yPow >= 0); 964 assert (xPow < map->map->numCols); 965 assert (yPow < map->map->numRows); 966 map->map->data.F32[yPow][xPow] = psMetadataLookupF32 (&status, row, "VALUE"); 967 map->error->data.F32[yPow][xPow] = psMetadataLookupF32 (&status, row, "ERROR"); 968 } else { 969 psPolynomial2D *poly = trend->poly; 970 assert (poly); 971 assert (xPow >= 0); 972 assert (yPow >= 0); 973 assert (xPow <= poly->nX); 974 assert (yPow <= poly->nY); 975 poly->coeff[xPow][yPow] = psMetadataLookupF32 (&status, row, "VALUE"); 976 poly->coeffErr[xPow][yPow] = psMetadataLookupF32 (&status, row, "ERROR"); 977 poly->coeffMask[xPow][yPow] = psMetadataLookupU8 (&status, row, "MASK"); 978 } 1022 pmTrend2DfromTableRow(trend, row); 979 1023 } 980 1024 psFree (header); … … 1063 1107 } 1064 1108 1109 if (!pmPSFmodelRead_ApTrend (psf, file)) { 1110 psError(psErrorCodeLast(), false, "Unable to read PSF ApTrend data."); 1111 return false; 1112 } 1113 1114 if (!pmPSFmodelRead_GrowthCurve(psf, file)) { 1115 psError(psErrorCodeLast(), false, "Unable to read PSF Growth Curve"); 1116 return false; 1117 } 1118 1065 1119 psMetadataAdd (chipAnalysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_DATA_UNKNOWN, "psphot psf", psf); 1066 1120 psFree (psf); … … 1070 1124 psFree (header); 1071 1125 1126 return true; 1127 } 1128 1129 // write aperture trend to a FITS table 1130 bool pmPSFmodelWrite_ApTrend (pmFPAfile *file, pmPSF *psf) { 1131 1132 pmTrend2D *trend = psf->ApTrend; 1133 if (trend == NULL) { 1134 psWarning ("no PSF ApTrend to write out, skipping"); 1135 return true; 1136 } 1137 1138 // we need to write a header for the table, 1139 psMetadata *header = psMetadataAlloc(); 1140 1141 int nX = 0, nY = 0; 1142 if (trend->mode == PM_TREND_MAP) { 1143 nX = trend->map->map->numCols; 1144 nY = trend->map->map->numRows; 1145 } else { 1146 nX = trend->poly->nX; 1147 nY = trend->poly->nY; 1148 } 1149 psMetadataAddS32 (header, PS_LIST_TAIL, "TREND_NX", 0, "", nX); 1150 psMetadataAddS32 (header, PS_LIST_TAIL, "TREND_NY", 0, "", nY); 1151 char *modeName = pmTrend2DModeToString (trend->mode); 1152 psMetadataAddStr (header, PS_LIST_TAIL, "TREND_MD", 0, "", modeName); 1153 psFree (modeName); 1154 1155 // build a FITS table of the ApTrend (only 1) 1156 psArray *table = psArrayAllocEmpty (100); 1157 pmTrend2DtoTable (table, trend, "APTREND", 0); 1158 1159 // write an empty FITS segment if we have no PSF information 1160 if (table->n == 0) { 1161 psError(PM_ERR_PROG, true, "No PSF data to write."); 1162 psFree(table); 1163 psFree(header); 1164 return false; 1165 } 1166 1167 psTrace ("pmFPAfile", 5, "writing psf ApTrend data %s\n", "AP_TREND"); 1168 if (!psFitsWriteTable(file->fits, header, table, "AP_TREND")) { 1169 psError(psErrorCodeLast(), false, "Error writing psf table data %s\n", "AP_TREND"); 1170 psFree(table); 1171 psFree(header); 1172 return false; 1173 } 1174 1175 psFree (table); 1176 psFree (header); 1177 return true; 1178 } 1179 1180 // read aperture trend to a FITS table 1181 bool pmPSFmodelRead_ApTrend (pmPSF *psf, pmFPAfile *file) { 1182 1183 bool status; 1184 1185 // move fits pointer to AP_TREND section 1186 // advance to the table data extension 1187 if (!psFitsMoveExtNameClean (file->fits, "AP_TREND")) { 1188 psWarning ("no Aperture Trend data in PSF file, skipping"); 1189 return true; 1190 } 1191 1192 psMetadata *header = psFitsReadHeader (NULL, file->fits); 1193 if (!header) { 1194 psError(psErrorCodeLast(), false, "Unable to read AP_TREND header."); 1195 return false; 1196 } 1197 1198 // read the raw table data 1199 psArray *table = psFitsReadTable (file->fits); 1200 if (!table) { 1201 psError(psErrorCodeLast(), false, "Unable to read AP_TREND table."); 1202 psFree(header); 1203 return false; 1204 } 1205 1206 // XXX allow user to set this optionally? 1207 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); 1208 1209 psImageBinning *binning = psImageBinningAlloc(); 1210 binning->nXfine = psf->fieldNx; 1211 binning->nYfine = psf->fieldNy; 1212 binning->nXruff = psMetadataLookupS32 (&status, header, "TREND_NX"); 1213 binning->nYruff = psMetadataLookupS32 (&status, header, "TREND_NY"); 1214 psImageBinningSetScale (binning, PS_IMAGE_BINNING_CENTER); 1215 char *modeName = psMetadataLookupStr (&status, header, "TREND_MD"); 1216 if (!status) { 1217 psError(PM_ERR_PROG, true, "inconsistent PSF header: NX & NY defined for AP TREND, but not MD"); 1218 psFree (header); 1219 psFree (stats); 1220 psFree (table); 1221 return false; 1222 } 1223 pmTrend2DMode psfTrendMode = pmTrend2DModeFromString (modeName); 1224 if (psfTrendMode == PM_TREND_NONE) { 1225 psfTrendMode = PM_TREND_POLY_ORD; 1226 } 1227 1228 // measure Trend2D for the current spatial scale 1229 pmTrend2D *apTrend = pmTrend2DNoImageAlloc (PM_TREND_MAP, binning, stats); 1230 1231 // fill in the matching psf->params entries 1232 for (int i = 0; i < table->n; i++) { 1233 psMetadata *row = table->data[i]; 1234 pmTrend2DfromTableRow(apTrend, row); 1235 } 1236 psf->ApTrend = apTrend; 1237 1238 psFree (binning); 1239 psFree (header); 1240 psFree (stats); 1241 psFree (table); 1242 return true; 1243 } 1244 1245 // write aperture trend to a FITS table 1246 bool pmPSFmodelWrite_GrowthCurve (pmFPAfile *file, pmPSF *psf) { 1247 1248 pmGrowthCurve *growth = psf->growth; 1249 if (growth == NULL) { 1250 psWarning ("no PSF Growth Curve to write out, skipping"); 1251 return true; 1252 } 1253 1254 // we need to write a header for the table, 1255 psMetadata *header = psMetadataAlloc(); 1256 1257 psMetadataAddF32 (header, PS_LIST_TAIL, "GROWTH_MIN_RAD", 0, "", growth->radius->data.F32[0]); 1258 psMetadataAddF32 (header, PS_LIST_TAIL, "GROWTH_MAX_RAD", 0, "", growth->maxRadius); 1259 psMetadataAddF32 (header, PS_LIST_TAIL, "GROWTH_REF_RAD", 0, "", growth->refRadius); 1260 psMetadataAddF32 (header, PS_LIST_TAIL, "GROWTH_AP_LOSS", 0, "", growth->apLoss); 1261 psMetadataAddF32 (header, PS_LIST_TAIL, "GROWTH_AP_REF", 0, "", growth->apRef); 1262 psMetadataAddF32 (header, PS_LIST_TAIL, "GROWTH_FIT_MAG", 0, "", growth->fitMag); 1263 1264 // build a FITS table of the ApTrend (only 1) 1265 psArray *table = psArrayAllocEmpty (100); 1266 for (int i = 0; i < growth->apMag->n; i++) { 1267 psMetadata *row = psMetadataAlloc (); 1268 psMetadataAddF32 (row, PS_LIST_TAIL, "RADIUS", 0, "", growth->radius->data.F32[i]); 1269 psMetadataAddF32 (row, PS_LIST_TAIL, "AP_MAG", 0, "", growth->apMag->data.F32[i]); 1270 psArrayAdd (table, 100, row); 1271 psFree (row); 1272 } 1273 1274 // write an empty FITS segment if we have no PSF information 1275 if (table->n == 0) { 1276 psError(PM_ERR_PROG, true, "No PSF data to write."); 1277 psFree(table); 1278 psFree(header); 1279 return false; 1280 } 1281 1282 psTrace ("pmFPAfile", 5, "writing psf Growth Curve data %s\n", "GROWTH_CURVE"); 1283 if (!psFitsWriteTable(file->fits, header, table, "GROWTH_CURVE")) { 1284 psError(psErrorCodeLast(), false, "Error writing psf table data %s\n", "GROWTH_CURVE"); 1285 psFree(table); 1286 psFree(header); 1287 return false; 1288 } 1289 1290 psFree (table); 1291 psFree (header); 1292 return true; 1293 } 1294 1295 // read aperture trend to a FITS table 1296 bool pmPSFmodelRead_GrowthCurve (pmPSF *psf, pmFPAfile *file) { 1297 1298 bool status; 1299 1300 // move fits pointer to AP_TREND section 1301 // advance to the table data extension 1302 if (!psFitsMoveExtNameClean (file->fits, "GROWTH_CURVE")) { 1303 psWarning ("no Growth Curve data in PSF file, skipping"); 1304 return true; 1305 } 1306 1307 psMetadata *header = psFitsReadHeader (NULL, file->fits); 1308 if (!header) { 1309 psError(psErrorCodeLast(), false, "Unable to read GROWTH_CURVE header."); 1310 return false; 1311 } 1312 1313 // read the raw table data 1314 psArray *table = psFitsReadTable (file->fits); 1315 if (!table) { 1316 psError(psErrorCodeLast(), false, "Unable to read GROWTH_CURVE table."); 1317 psFree(header); 1318 return false; 1319 } 1320 1321 float minRadius = psMetadataLookupF32 (&status, header, "GROWTH_MIN_RAD"); if (!status) return false; 1322 float maxRadius = psMetadataLookupF32 (&status, header, "GROWTH_MAX_RAD"); if (!status) return false; 1323 float refRadius = psMetadataLookupF32 (&status, header, "GROWTH_REF_RAD"); if (!status) return false; 1324 1325 psf->growth = pmGrowthCurveAlloc(minRadius, maxRadius, refRadius); 1326 1327 psf->growth->apLoss = psMetadataLookupF32 (&status, header, "GROWTH_AP_LOSS"); if (!status) return false; 1328 psf->growth->apRef = psMetadataLookupF32 (&status, header, "GROWTH_AP_REF"); if (!status) return false; 1329 psf->growth->fitMag = psMetadataLookupF32 (&status, header, "GROWTH_FIT_MAG"); if (!status) return false; 1330 1331 // fill in the matching psf->params entries 1332 for (int i = 0; i < table->n; i++) { 1333 psMetadata *row = table->data[i]; 1334 psf->growth->apMag->data.F32[i] = psMetadataLookupF32 (&status, row, "AP_MAG"); if (!status) return false; 1335 } 1336 1337 psFree (header); 1338 psFree (table); 1072 1339 return true; 1073 1340 } -
branches/czw_branch/20110406/psModules/src/objects/pmPSFtryFitPSF.c
r31153 r31606 122 122 psfTry->fitMag->data.F32[i] = source->psfMag; 123 123 psfTry->metric->data.F32[i] = source->apMag - source->psfMag; 124 psfTry->metricErr->data.F32[i] = source-> errMag;124 psfTry->metricErr->data.F32[i] = source->psfMagErr; 125 125 126 126 // XXX this did not work: modifies shape of psf too much … … 131 131 source->peak->xf, source->peak->yf, 132 132 source->modelPSF->params->data.F32[PM_PAR_XPOS], source->modelPSF->params->data.F32[PM_PAR_YPOS], 133 source->psfMag, source->apMag, source-> errMag,133 source->psfMag, source->apMag, source->psfMagErr, 134 134 source->modelPSF->params->data.F32[PM_PAR_I0], 135 135 source->modelPSF->params->data.F32[PM_PAR_SXX], source->modelPSF->params->data.F32[PM_PAR_SXY], -
branches/czw_branch/20110406/psModules/src/objects/pmPeaks.c
r31153 r31606 150 150 tmp->x = x; 151 151 tmp->y = y; 152 tmp->xf = x; 153 tmp->yf = y; 154 tmp->dx = NAN; 155 tmp->dy = NAN; 152 156 tmp->detValue = value; 153 157 tmp->rawFlux = value; // set this by default: it is up to the user to supply a better value … … 155 159 tmp->smoothFlux = value; // set this by default: it is up to the user to supply a better value 156 160 tmp->smoothFluxStdev = NAN; 157 // tmp->SN = 0;158 tmp->xf = x;159 tmp->yf = y;160 161 tmp->assigned = false; 161 162 tmp->type = type; … … 166 167 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); 167 168 return(tmp); 169 } 170 171 // copy to an already allocated peak 172 bool pmPeakCopy(pmPeak *out, pmPeak *in) 173 { 174 out->x = in->x; 175 out->y = in->y; 176 out->xf = in->xf; 177 out->yf = in->yf; 178 out->dx = in->dx; 179 out->dy = in->dy; 180 out->detValue = in->detValue; 181 out->rawFlux = in->rawFlux; 182 out->rawFluxStdev = in->rawFluxStdev; 183 out->smoothFlux = in->smoothFlux; 184 out->smoothFluxStdev = in->smoothFluxStdev; 185 out->assigned = in->assigned; 186 out->type = in->type; 187 188 return true; 168 189 } 169 190 -
branches/czw_branch/20110406/psModules/src/objects/pmPeaks.h
r31153 r31606 69 69 float smoothFlux; ///< peak flux in smoothed signal image 70 70 float smoothFluxStdev; ///< peak stdev in smoothed signal image 71 // float SNestimated; ///< S/N estimated from the detection image72 71 bool assigned; ///< is peak assigned to a source? 73 72 pmPeakType type; ///< Description of peak. … … 89 88 90 89 bool psMemCheckPeak(psPtr ptr); 90 91 bool pmPeakCopy(pmPeak *out, pmPeak *in); 91 92 92 93 /** pmPeaksInVector() -
branches/czw_branch/20110406/psModules/src/objects/pmSource.c
r31153 r31606 116 116 source->psfImage = NULL; 117 117 source->moments = NULL; 118 source->blends = NULL;119 118 source->modelPSF = NULL; 120 119 source->modelEXT = NULL; … … 124 123 source->mode2 = PM_SOURCE_MODE_DEFAULT; 125 124 source->tmpFlags = 0; 126 source->extpars = NULL;127 source->diffStats = NULL;128 source->radialAper = NULL;129 source->parent = NULL;130 131 source->region = psRegionSet(NAN, NAN, NAN, NAN);132 psMemSetDeallocator(source, (psFreeFunc) sourceFree);133 125 134 126 // default values are NAN 135 127 source->psfMag = NAN; 128 source->psfMagErr = NAN; 136 129 source->psfFlux = NAN; 137 130 source->psfFluxErr = NAN; 138 131 source->extMag = NAN; 139 source->errMag = NAN;140 132 source->apMag = NAN; 141 133 source->apMagRaw = NAN; … … 143 135 source->apFlux = NAN; 144 136 source->apFluxErr = NAN; 145 source->sky = NAN; 146 source->skyErr = NAN; 137 147 138 source->pixWeightNotBad = NAN; 148 139 source->pixWeightNotPoor = NAN; … … 151 142 source->crNsigma = NAN; 152 143 source->extNsigma = NAN; 144 source->sky = NAN; 145 source->skyErr = NAN; 146 147 source->region = psRegionSet(NAN, NAN, NAN, NAN); 148 source->blends = NULL; 149 source->extpars = NULL; 150 source->diffStats = NULL; 151 source->radialAper = NULL; 152 source->parent = NULL; 153 source->imageID = -1; 154 155 psMemSetDeallocator(source, (psFreeFunc) sourceFree); 153 156 154 157 psTrace("psModules.objects", 10, "---- end ----\n"); … … 172 175 if (in->peak != NULL) { 173 176 source->peak = pmPeakAlloc (in->peak->x, in->peak->y, in->peak->detValue, in->peak->type); 174 source->peak->xf = in->peak->xf; 175 source->peak->yf = in->peak->yf; 176 source->peak->rawFlux = in->peak->rawFlux; 177 source->peak->rawFluxStdev = in->peak->rawFluxStdev; 178 source->peak->smoothFlux = in->peak->smoothFlux; 179 source->peak->smoothFluxStdev = in->peak->smoothFluxStdev; 180 // source->peak->SN = in->peak->SN; 177 pmPeakCopy(source->peak, in->peak); 181 178 } 182 179 … … 195 192 196 193 // the maskObj is a unique mask array; create a new mask image 197 source->maskObj = in->maskObj ? psImageCopy (NULL, in->maskObj, PS_TYPE_IMAGE_MASK) : NULL; 198 199 source->type = in->type; 200 source->mode = in->mode; 201 source->imageID = in->imageID; 194 source->maskObj = in->maskObj ? psImageCopy (NULL, in->maskObj, PS_TYPE_IMAGE_MASK) : NULL; 195 196 // NOTE : because of the const id element, we cannot just assign *source = *in 197 198 source->type = in->type; 199 source->mode = in->mode; 200 source->mode2 = in->mode2; 201 source->tmpFlags = in->tmpFlags; 202 source->psfMag = in->psfMag; 203 source->psfMagErr = in->psfMagErr; 204 source->psfFlux = in->psfFlux; 205 source->psfFluxErr = in->psfFluxErr; 206 source->extMag = in->extMag; 207 source->apMag = in->apMag; 208 source->apMagRaw = in->apMagRaw; 209 source->apRadius = in->apRadius; 210 source->apFlux = in->apFlux; 211 source->apFluxErr = in->apFluxErr; 212 source->pixWeightNotBad = in->pixWeightNotBad; 213 source->pixWeightNotPoor = in->pixWeightNotPoor; 214 source->psfChisq = in->psfChisq; 215 source->crNsigma = in->crNsigma; 216 source->extNsigma = in->extNsigma; 217 source->sky = in->sky; 218 source->skyErr = in->skyErr; 219 220 source->region = in->region; 202 221 203 222 return(source); … … 266 285 extend |= (mySource->maskObj == NULL); 267 286 extend |= (mySource->maskView == NULL); 287 288 // if ((fabs(x - 2020) < 5) && (fabs(y - 366) < 5)) { 289 // if (extend) { 290 // fprintf (stderr, "extend T, %f, %f : %f, %f vs %f, %f : %f, %f\n", 291 // newRegion.x0, newRegion.y0, newRegion.x1, newRegion.y1, 292 // mySource->region.x0, mySource->region.y0, mySource->region.x1, mySource->region.y1); 293 // } else { 294 // fprintf (stderr, "extend F, %f, %f : %f, %f vs %f, %f : %f, %f\n", 295 // newRegion.x0, newRegion.y0, newRegion.x1, newRegion.y1, 296 // mySource->region.x0, mySource->region.y0, mySource->region.x1, mySource->region.y1); 297 // } 298 // } 268 299 269 300 if (extend) { … … 486 517 // create vectors with Sx, Sy values in window 487 518 // clip sources based on S/N 488 for (psS32 i = 0 ; i < sources->n; i++)519 for (psS32 i = 0; i < sources->n; i++) 489 520 { 490 521 pmSource *tmpSrc = (pmSource *) sources->data[i]; … … 1175 1206 if (!source->moments) return false; // can't if there are no moments 1176 1207 if (!source->moments->nPixels) return false; // can't if the moments were not measured 1177 if (source->mode & &PM_SOURCE_MODE_MOMENTS_FAILURE) return false; // can't if the moments failed...1208 if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) return false; // can't if the moments failed... 1178 1209 1179 1210 if (source->mode & PM_SOURCE_MODE_SATSTAR) return true; // moments are best for SATSTARs -
branches/czw_branch/20110406/psModules/src/objects/pmSource.h
r31153 r31606 80 80 pmSourceMode2 mode2; ///< analysis flags set for object. 81 81 pmSourceTmpF tmpFlags; ///< internal-only flags 82 psArray *blends; ///< collection of sources thought to be confused with object 82 83 83 float psfMag; ///< calculated from flux in modelPSF 84 float psfMagErr; ///< error in psfMag 84 85 float psfFlux; ///< calculated from flux in modelPSF 85 float psfFluxErr; ///< calculated from flux in modelPSF 86 float extMag; ///< calculated from flux in modelEXT 87 float errMag; ///< error in psfMag OR extMag (depending on type) 86 float psfFluxErr; ///< error in psfFlux 87 float extMag; ///< calculated from flux in modelEXT -- NOTE this is not actually used 88 88 float apMag; ///< apMag corresponding to psfMag or extMag (depending on type) 89 89 float apMagRaw; ///< raw mag in given aperture … … 98 98 float crNsigma; ///< Nsigma deviation from PSF to CR 99 99 float extNsigma; ///< Nsigma deviation from PSF to EXT 100 float sky, skyErr; ///< The sky and its error at the center of the object 100 float sky; ///< The sky at the center of the object 101 float skyErr; ///< The sky error at the center of the object 102 101 103 psRegion region; ///< area on image covered by selected pixels 104 psArray *blends; ///< collection of sources thought to be confused with object 102 105 pmSourceExtendedPars *extpars; ///< extended source parameters 103 106 pmSourceDiffStats *diffStats; ///< extra parameters for difference detections … … 254 257 float sigma, ///< size of Gaussian window function (<= 0.0 -> skip window) 255 258 float minSN, ///< minimum pixel significance 259 float minKronRadius, ///< minimum pixel significance 256 260 psImageMaskType maskVal 257 261 ); … … 273 277 float xGuess, float yGuess); 274 278 279 float pmSourceMinKronRadius(psArray *sources, float PSF_SN_LIM); 280 275 281 pmModel *pmSourceGetModel (bool *isPSF, const pmSource *source); 276 282 -
branches/czw_branch/20110406/psModules/src/objects/pmSourceIO_CMF_PS1_DV1.c
r31153 r31606 125 125 psMetadataAdd (row, PS_LIST_TAIL, "PLTSCALE", PS_DATA_F32, "plate scale at source (arcsec/pixel)", outputs.pltScale); 126 126 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG", PS_DATA_F32, "PSF fit instrumental magnitude", source->psfMag); 127 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", source-> errMag);127 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", source->psfMagErr); 128 128 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX", PS_DATA_F32, "PSF fit instrumental magnitude", source->psfFlux); 129 129 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX_SIG",PS_DATA_F32, "Sigma of PSF instrumental magnitude", source->psfFluxErr); … … 256 256 257 257 source->psfMag = psMetadataLookupF32 (&status, row, "PSF_INST_MAG"); 258 source-> errMag= psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");258 source->psfMagErr = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG"); 259 259 source->apMag = psMetadataLookupF32 (&status, row, "AP_MAG"); 260 260 261 261 // XXX this scaling is incorrect: does not include the 2 \pi AREA factor 262 262 PAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN; 263 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source-> errMag: NAN;263 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN; 264 264 265 265 pmPSF_AxesToModel (PAR, axes); -
branches/czw_branch/20110406/psModules/src/objects/pmSourceIO_CMF_PS1_DV2.c
r31153 r31606 124 124 psMetadataAdd (row, PS_LIST_TAIL, "PLTSCALE", PS_DATA_F32, "plate scale at source (arcsec/pixel)", outputs.pltScale); 125 125 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG", PS_DATA_F32, "PSF fit instrumental magnitude", source->psfMag); 126 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", source-> errMag);126 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", source->psfMagErr); 127 127 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX", PS_DATA_F32, "PSF fit instrumental magnitude", source->psfFlux); 128 128 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX_SIG",PS_DATA_F32, "Sigma of PSF instrumental magnitude", source->psfFluxErr); … … 274 274 275 275 source->psfMag = psMetadataLookupF32 (&status, row, "PSF_INST_MAG"); 276 source-> errMag= psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");276 source->psfMagErr = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG"); 277 277 source->apMag = psMetadataLookupF32 (&status, row, "AP_MAG"); 278 278 279 279 // XXX this scaling is incorrect: does not include the 2 \pi AREA factor 280 280 PAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN; 281 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source-> errMag: NAN;281 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN; 282 282 283 283 pmPSF_AxesToModel (PAR, axes); -
branches/czw_branch/20110406/psModules/src/objects/pmSourceIO_CMF_PS1_SV1.c
r31153 r31606 125 125 psMetadataAdd (row, PS_LIST_TAIL, "PLTSCALE", PS_DATA_F32, "plate scale at source (arcsec/pixel)", outputs.pltScale); 126 126 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG", PS_DATA_F32, "PSF fit instrumental magnitude", source->psfMag); 127 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", source-> errMag);127 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", source->psfMagErr); 128 128 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX", PS_DATA_F32, "PSF fit instrumental flux (counts)", source->psfFlux); 129 129 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX_SIG",PS_DATA_F32, "Sigma of PSF instrumental flux", source->psfFluxErr); … … 273 273 // XXX use these to determine PAR[PM_PAR_I0]? 274 274 source->psfMag = psMetadataLookupF32 (&status, row, "PSF_INST_MAG"); 275 source-> errMag= psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");275 source->psfMagErr = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG"); 276 276 source->apMag = psMetadataLookupF32 (&status, row, "AP_MAG"); 277 277 278 278 // XXX this scaling is incorrect: does not include the 2 \pi AREA factor 279 279 PAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN; 280 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source-> errMag: NAN;280 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN; 281 281 282 282 pmPSF_AxesToModel (PAR, axes); … … 720 720 sprintf (keyword1, "RMIN_%02d", i); 721 721 sprintf (keyword2, "RMAX_%02d", i); 722 psMetadataAddF32 ( imageHeader, PS_LIST_TAIL, keyword1, PS_META_REPLACE, "min radius for SB profile", radMin->data.F32[i]);723 psMetadataAddF32 ( imageHeader, PS_LIST_TAIL, keyword2, PS_META_REPLACE, "min radius for SB profile", radMax->data.F32[i]);722 psMetadataAddF32 (outhead, PS_LIST_TAIL, keyword1, PS_META_REPLACE, "min radius for SB profile", radMin->data.F32[i]); 723 psMetadataAddF32 (outhead, PS_LIST_TAIL, keyword2, PS_META_REPLACE, "min radius for SB profile", radMax->data.F32[i]); 724 724 } 725 725 -
branches/czw_branch/20110406/psModules/src/objects/pmSourceIO_CMF_PS1_V1.c
r31153 r31606 118 118 psMetadataAdd (row, PS_LIST_TAIL, "PLTSCALE", PS_DATA_F32, "plate scale at source (arcsec/pixel)", outputs.pltScale); 119 119 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG", PS_DATA_F32, "PSF fit instrumental magnitude", source->psfMag); 120 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", source-> errMag);120 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", source->psfMagErr); 121 121 psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG", PS_DATA_F32, "magnitude in standard aperture", source->apMag); 122 122 psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RADIUS", PS_DATA_F32, "radius used for aperture mags", outputs.apRadius); … … 241 241 // XXX use these to determine PAR[PM_PAR_I0]? 242 242 source->psfMag = psMetadataLookupF32 (&status, row, "PSF_INST_MAG"); 243 source-> errMag= psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");243 source->psfMagErr = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG"); 244 244 source->apMag = psMetadataLookupF32 (&status, row, "AP_MAG"); 245 245 246 246 // XXX this scaling is incorrect: does not include the 2 \pi AREA factor 247 247 PAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN; 248 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source-> errMag: NAN;248 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN; 249 249 250 250 pmPSF_AxesToModel (PAR, axes); -
branches/czw_branch/20110406/psModules/src/objects/pmSourceIO_CMF_PS1_V2.c
r31153 r31606 116 116 psMetadataAdd (row, PS_LIST_TAIL, "PLTSCALE", PS_DATA_F32, "plate scale at source (arcsec/pixel)", outputs.pltScale); 117 117 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG", PS_DATA_F32, "PSF fit instrumental magnitude", source->psfMag); 118 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", source-> errMag);118 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", source->psfMagErr); 119 119 psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG", PS_DATA_F32, "magnitude in standard aperture", source->apMag); 120 120 psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RADIUS", PS_DATA_F32, "radius used for aperture mags", outputs.apRadius); … … 247 247 // XXX use these to determine PAR[PM_PAR_I0]? 248 248 source->psfMag = psMetadataLookupF32 (&status, row, "PSF_INST_MAG"); 249 source-> errMag= psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");249 source->psfMagErr = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG"); 250 250 source->apMag = psMetadataLookupF32 (&status, row, "AP_MAG"); 251 251 252 252 // XXX this scaling is incorrect: does not include the 2 \pi AREA factor 253 253 PAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN; 254 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source-> errMag: NAN;254 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN; 255 255 256 256 pmPSF_AxesToModel (PAR, axes); -
branches/czw_branch/20110406/psModules/src/objects/pmSourceIO_CMF_PS1_V3.c
r31153 r31606 116 116 psMetadataAdd (row, PS_LIST_TAIL, "PLTSCALE", PS_DATA_F32, "plate scale at source (arcsec/pixel)", outputs.pltScale); 117 117 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG", PS_DATA_F32, "PSF fit instrumental magnitude", source->psfMag); 118 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", source-> errMag);118 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", source->psfMagErr); 119 119 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX", PS_DATA_F32, "PSF fit instrumental flux (counts)", source->psfFlux); 120 120 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX_SIG",PS_DATA_F32, "Sigma of PSF instrumental flux", source->psfFluxErr); … … 161 161 psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_INNER", PS_DATA_F32, "Kron Flux (in 2.5 R1)", moments.Kinner); 162 162 psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_OUTER", PS_DATA_F32, "Kron Flux (in 2.5 R1)", moments.Kouter); 163 164 // Do NOT write these : not consistent with the definition of PS1_V3 in Ohana/src/libautocode/dev/cmf-ps1-v3.d 163 165 // psMetadataAdd (row, PS_LIST_TAIL, "KRON_CORE_FLUX", PS_DATA_F32, "Kron Flux (in 1.0 R1)", moments.KronCore); 164 // psMetadataAdd (row, PS_LIST_TAIL, "KRON_CORE_ERROR", PS_DATA_F32, "Kron Error (in 1.0 R1)", moments.KronCoreErr);166 // psMetadataAdd (row, PS_LIST_TAIL, "KRON_CORE_ERROR", PS_DATA_F32, "Kron Error (in 1.0 R1)", moments.KronCoreErr); 165 167 psMetadataAdd (row, PS_LIST_TAIL, "FLAGS", PS_DATA_U32, "psphot analysis flags", source->mode); 166 168 psMetadataAdd (row, PS_LIST_TAIL, "FLAGS2", PS_DATA_U32, "psphot analysis flags", source->mode2); … … 270 272 // XXX use these to determine PAR[PM_PAR_I0]? 271 273 source->psfMag = psMetadataLookupF32 (&status, row, "PSF_INST_MAG"); 272 source-> errMag= psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");274 source->psfMagErr = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG"); 273 275 source->apMag = psMetadataLookupF32 (&status, row, "AP_MAG"); 274 276 275 277 // XXX this scaling is incorrect: does not include the 2 \pi AREA factor 276 278 PAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN; 277 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source-> errMag: NAN;279 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN; 278 280 279 281 pmPSF_AxesToModel (PAR, axes); … … 292 294 293 295 // we no longer sort by S/N, only flux 294 // if (isfinite (source-> errMag) && (source->errMag> 0.0)) {295 // source->peak->SN = 1.0 / source-> errMag;296 // if (isfinite (source->psfMagErr) && (source->psfMagErr > 0.0)) { 297 // source->peak->SN = 1.0 / source->psfMagErr; 296 298 // } else { 297 299 // source->peak->SN = sqrt(source->peak->flux); // an alternate proxy: various functions sort by peak S/N -
branches/czw_branch/20110406/psModules/src/objects/pmSourceIO_CMP.c
r29004 r31606 137 137 axes = pmPSF_ModelToAxes (PAR, 20.0); 138 138 139 float errMag = isfinite(source->errMag) ? source->errMag: 999;139 float psfMagErr = isfinite(source->psfMagErr) ? source->psfMagErr : 999; 140 140 141 141 psLineInit (line); … … 143 143 psLineAdd (line, "%6.1f ", PAR[PM_PAR_YPOS]); 144 144 psLineAdd (line, "%6.3f ", PS_MIN (99.0, source->psfMag + ZERO_POINT)); 145 psLineAdd (line, "%03d ", PS_MIN (999, (int) errMag));145 psLineAdd (line, "%03d ", PS_MIN (999, (int)psfMagErr)); 146 146 psLineAdd (line, "%2d ", type); 147 147 psLineAdd (line, "%3.1f ", lsky); … … 280 280 source->psfMag = atof (array->data[2]); 281 281 source->extMag = atof (array->data[6]); 282 source-> errMag= atof (array->data[3]) / 1000.0;282 source->psfMagErr = atof (array->data[3]) / 1000.0; 283 283 source->apMag = atof (array->data[7]); 284 284 axes.major = atof (array->data[8]); -
branches/czw_branch/20110406/psModules/src/objects/pmSourceIO_PS1_CAL_0.c
r31153 r31606 71 71 psF32 xPos, yPos; 72 72 psF32 xErr, yErr; 73 psF32 errMag, chisq;73 psF32 psfMagErr, chisq; 74 74 75 75 pmChip *chip = readout->parent->parent; … … 121 121 chisq = model->chisq; 122 122 123 // need to determine the PSF photometry error: source-> errMagis the error on the 'best' model mag.124 errMag= model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0];123 // need to determine the PSF photometry error: source->psfMagErr is the error on the 'best' model mag. 124 psfMagErr = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0]; 125 125 } else { 126 126 xPos = source->peak->xf; … … 132 132 axes.theta = NAN; 133 133 chisq = NAN; 134 errMag= NAN;134 psfMagErr = NAN; 135 135 } 136 136 … … 167 167 psMetadataAdd (row, PS_LIST_TAIL, "Y_PSF_SIG", PS_DATA_F32, "Sigma in PSF y coordinate", yErr); 168 168 psMetadataAdd (row, PS_LIST_TAIL, "CAL_PSF_MAG", PS_DATA_F32, "Calibrated Magnitude from PSF Fit", calMag); 169 psMetadataAdd (row, PS_LIST_TAIL, "CAL_PSF_MAG_SIG", PS_DATA_F32, "Calibrated Magnitude Error", errMag);169 psMetadataAdd (row, PS_LIST_TAIL, "CAL_PSF_MAG_SIG", PS_DATA_F32, "Calibrated Magnitude Error", psfMagErr); 170 170 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG", PS_DATA_F32, "PSF fit instrumental magnitude", source->psfMag); 171 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", errMag);171 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", psfMagErr); 172 172 psMetadataAdd (row, PS_LIST_TAIL, "PEAK_FLUX_AS_MAG", PS_DATA_F32, "Peak flux expressed as magnitude", peakMag); 173 173 psMetadataAdd (row, PS_LIST_TAIL, "SKY", PS_DATA_F32, "Sky level", source->sky); … … 284 284 // XXX use these to determine PAR[PM_PAR_I0]? 285 285 source->psfMag = psMetadataLookupF32 (&status, row, "PSF_INST_MAG"); 286 source-> errMag= psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");286 source->psfMagErr = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG"); 287 287 PAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN; 288 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source-> errMag: NAN;288 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN; 289 289 290 290 pmPSF_AxesToModel (PAR, axes); -
branches/czw_branch/20110406/psModules/src/objects/pmSourceIO_PS1_DEV_0.c
r31153 r31606 113 113 psMetadataAdd (row, PS_LIST_TAIL, "Y_PSF_SIG", PS_DATA_F32, "Sigma in PSF y coordinate", yErr); 114 114 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG", PS_DATA_F32, "PSF fit instrumental magnitude", PS_MIN (99.0, source->psfMag)); 115 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", PS_MIN (99.0, source-> errMag));115 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", PS_MIN (99.0, source->psfMagErr)); 116 116 psMetadataAdd (row, PS_LIST_TAIL, "PEAK_FLUX_AS_MAG", PS_DATA_F32, "Peak flux expressed as magnitude", PS_MIN (99.0, peakMag)); 117 117 psMetadataAdd (row, PS_LIST_TAIL, "SKY", PS_DATA_F32, "Sky level", source->sky); … … 212 212 // XXX use these to determine PAR[PM_PAR_I0]? 213 213 source->psfMag = psMetadataLookupF32 (&status, row, "PSF_INST_MAG"); 214 source-> errMag= psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");214 source->psfMagErr = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG"); 215 215 216 216 pmPSF_AxesToModel (PAR, axes); -
branches/czw_branch/20110406/psModules/src/objects/pmSourceIO_PS1_DEV_1.c
r31153 r31606 70 70 psF32 xPos, yPos; 71 71 psF32 xErr, yErr; 72 psF32 errMag, chisq;72 psF32 psfMagErr, chisq; 73 73 74 74 // let's write these out in S/N order … … 103 103 chisq = model->chisq; 104 104 105 // need to determine the PSF photometry error: source-> errMagis the error on the 'best' model mag.106 errMag= model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0];105 // need to determine the PSF photometry error: source->psfMagErr is the error on the 'best' model mag. 106 psfMagErr = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0]; 107 107 } else { 108 108 xPos = source->peak->xf; … … 114 114 axes.theta = NAN; 115 115 chisq = NAN; 116 errMag= NAN;116 psfMagErr = NAN; 117 117 } 118 118 … … 128 128 psMetadataAdd (row, PS_LIST_TAIL, "Y_PSF_SIG", PS_DATA_F32, "Sigma in PSF y coordinate", yErr); 129 129 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG", PS_DATA_F32, "PSF fit instrumental magnitude", source->psfMag); 130 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", errMag);130 psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude", psfMagErr); 131 131 psMetadataAdd (row, PS_LIST_TAIL, "PEAK_FLUX_AS_MAG", PS_DATA_F32, "Peak flux expressed as magnitude", peakMag); 132 132 psMetadataAdd (row, PS_LIST_TAIL, "SKY", PS_DATA_F32, "Sky level", source->sky); … … 253 253 // XXX use these to determine PAR[PM_PAR_I0]? 254 254 source->psfMag = psMetadataLookupF32 (&status, row, "PSF_INST_MAG"); 255 source-> errMag= psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");255 source->psfMagErr = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG"); 256 256 PAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN; 257 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source-> errMag: NAN;257 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN; 258 258 259 259 pmPSF_AxesToModel (PAR, axes); -
branches/czw_branch/20110406/psModules/src/objects/pmSourceIO_RAW.c
r31153 r31606 110 110 fprintf (f, "%7.1f %7.1f %7.1f %8.4f %7.4f %7.4f ", 111 111 PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], source->sky, 112 source->psfMag, source-> errMag, dPos);112 source->psfMag, source->psfMagErr, dPos); 113 113 114 114 for (j = 4; j < model->params->n; j++) { … … 174 174 fprintf (f, "%7.1f %7.1f %7.1f %8.4f %7.4f %7.4f ", 175 175 PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], source->sky, 176 source->extMag, source-> errMag, dPos);176 source->extMag, source->psfMagErr, dPos); 177 177 178 178 for (j = 4; j < model->params->n; j++) { -
branches/czw_branch/20110406/psModules/src/objects/pmSourceIO_SMPDATA.c
r31153 r31606 106 106 psMetadataAdd (row, PS_LIST_TAIL, "Y_PIX", PS_DATA_F32, "", yPos); 107 107 psMetadataAdd (row, PS_LIST_TAIL, "MAG_RAW", PS_DATA_F32, "", PS_MIN (99.0, source->psfMag + ZERO_POINT)); 108 psMetadataAdd (row, PS_LIST_TAIL, "MAG_ERR", PS_DATA_F32, "", PS_MIN (999, 1000*source-> errMag));108 psMetadataAdd (row, PS_LIST_TAIL, "MAG_ERR", PS_DATA_F32, "", PS_MIN (999, 1000*source->psfMagErr)); 109 109 psMetadataAdd (row, PS_LIST_TAIL, "MAG_GAL", PS_DATA_F32, "", PS_MIN (99.0, source->extMag + ZERO_POINT)); 110 110 psMetadataAdd (row, PS_LIST_TAIL, "MAG_AP", PS_DATA_F32, "", PS_MIN (99.0, source->apMag + ZERO_POINT)); … … 194 194 source->psfMag = psMetadataLookupF32 (&status, row, "MAG_RAW") - ZERO_POINT; 195 195 source->extMag = psMetadataLookupF32 (&status, row, "MAG_GAL") - ZERO_POINT; 196 source-> errMag= psMetadataLookupF32 (&status, row, "MAG_ERR") * 0.001;196 source->psfMagErr = psMetadataLookupF32 (&status, row, "MAG_ERR") * 0.001; 197 197 source->apMag = psMetadataLookupF32 (&status, row, "MAG_AP") - ZERO_POINT; 198 198 -
branches/czw_branch/20110406/psModules/src/objects/pmSourceIO_SX.c
r29004 r31606 88 88 psLineAdd (line, "%11.3f", PAR[PM_PAR_YPOS]); 89 89 psLineAdd (line, "%9.4f", source->psfMag); 90 psLineAdd (line, "%9.4f", source-> errMag);90 psLineAdd (line, "%9.4f", source->psfMagErr); 91 91 psLineAdd (line, "%13.4f", source->sky); 92 92 psLineAdd (line, "%9.2f", axes.major); -
branches/czw_branch/20110406/psModules/src/objects/pmSourceMasks.h
r31153 r31606 14 14 PM_SOURCE_MODE_PSFSTAR = 0x00000040, ///< Source used to define PSF model 15 15 PM_SOURCE_MODE_SATSTAR = 0x00000080, ///< Source model peak is above saturation 16 PM_SOURCE_MODE_BLEND = 0x00000100, ///< Source is a blend with other source rs16 PM_SOURCE_MODE_BLEND = 0x00000100, ///< Source is a blend with other sources 17 17 PM_SOURCE_MODE_EXTERNAL = 0x00000200, ///< Source based on supplied input position 18 18 PM_SOURCE_MODE_BADPSF = 0x00000400, ///< Failed to get good estimate of object's PSF … … 51 51 PM_SOURCE_MODE2_ON_BURNTOOL = 0x00000020, ///< > 25% of (PSF-weighted) pixels land on burntool 52 52 PM_SOURCE_MODE2_ON_CONVPOOR = 0x00000040, ///< > 25% of (PSF-weighted) pixels land on convpoor 53 54 PM_SOURCE_MODE2_PASS1_SRC = 0x00000080, ///< source detected in first pass analysis 53 55 } pmSourceMode2; 54 56 -
branches/czw_branch/20110406/psModules/src/objects/pmSourceMatch.c
r29004 r31606 88 88 pmSource *source = sources->data[i]; // Source of interest 89 89 if (!source || (source->mode & SOURCE_MASK) || !isfinite(source->psfMag) || 90 !isfinite(source-> errMag) || source->psfMag > SOURCE_FAINTEST) {90 !isfinite(source->psfMagErr) || source->psfMag > SOURCE_FAINTEST) { 91 91 continue; 92 92 } … … 102 102 (*y)->data.F32[num] = ySrc; 103 103 (*mag)->data.F32[num] = source->psfMag; 104 (*magErr)->data.F32[num] = source-> errMag;104 (*magErr)->data.F32[num] = source->psfMagErr; 105 105 (*indices)->data.S32[num] = i; 106 106 num++; -
branches/czw_branch/20110406/psModules/src/objects/pmSourceMoments.c
r31153 r31606 66 66 // if mode & EXTERNAL or mode2 & MATCHED, do not re-calculate the centroid (use peak as centroid) 67 67 68 bool pmSourceMoments(pmSource *source, psF32 radius, psF32 sigma, psF32 minSN, psImageMaskType maskVal)68 bool pmSourceMoments(pmSource *source, float radius, float sigma, float minSN, float minKronRadius, psImageMaskType maskVal) 69 69 { 70 70 PS_ASSERT_PTR_NON_NULL(source, false); … … 74 74 75 75 // this function assumes the sky has been well-subtracted for the image 76 psF32sky = 0.0;76 float sky = 0.0; 77 77 78 78 if (source->moments == NULL) { … … 80 80 } 81 81 82 psF32Sum = 0.0;83 psF32Var = 0.0;84 psF32SumCore = 0.0;85 psF32VarCore = 0.0;86 psF32R2 = PS_SQR(radius);87 psF32minSN2 = PS_SQR(minSN);88 psF32rsigma2 = 0.5 / PS_SQR(sigma);82 float Sum = 0.0; 83 float Var = 0.0; 84 float SumCore = 0.0; 85 float VarCore = 0.0; 86 float R2 = PS_SQR(radius); 87 float minSN2 = PS_SQR(minSN); 88 float rsigma2 = 0.5 / PS_SQR(sigma); 89 89 90 90 // a note about coordinates: coordinates of objects throughout psphot refer to the primary … … 109 109 // Xn = SUM (x - xc)^n * (z - sky) 110 110 111 psF32 RF = 0.0; 112 psF32 RH = 0.0; 113 psF32 RS = 0.0; 114 psF32 XX = 0.0; 115 psF32 XY = 0.0; 116 psF32 YY = 0.0; 117 psF32 XXX = 0.0; 118 psF32 XXY = 0.0; 119 psF32 XYY = 0.0; 120 psF32 YYY = 0.0; 121 psF32 XXXX = 0.0; 122 psF32 XXXY = 0.0; 123 psF32 XXYY = 0.0; 124 psF32 XYYY = 0.0; 125 psF32 YYYY = 0.0; 111 float RFW = 0.0; 112 float RHW = 0.0; 113 114 float RF = 0.0; 115 float RH = 0.0; 116 float RS = 0.0; 117 float XX = 0.0; 118 float XY = 0.0; 119 float YY = 0.0; 120 float XXX = 0.0; 121 float XXY = 0.0; 122 float XYY = 0.0; 123 float YYY = 0.0; 124 float XXXX = 0.0; 125 float XXXY = 0.0; 126 float XXYY = 0.0; 127 float XYYY = 0.0; 128 float YYYY = 0.0; 126 129 127 130 Sum = 0.0; // the second pass may include slightly different pixels, re-determine Sum 131 132 // float dX = source->moments->Mx - source->peak->xf; 133 // float dY = source->moments->My - source->peak->yf; 134 // float dR = hypot(dX, dY); 135 // float Xo = (dR < 2.0) ? source->moments->Mx : source->peak->xf; 136 // float Yo = (dR < 2.0) ? source->moments->My : source->peak->yf; 137 float Xo = source->moments->Mx; 138 float Yo = source->moments->My; 128 139 129 140 // center of mass in subimage. Note: the calculation below uses pixel index, so we correct 130 141 // xCM, yCM from pixel coords to pixel index here. 131 psF32 xCM = source->moments->Mx- 0.5 - source->pixels->col0; // coord of peak in subimage132 psF32 yCM = source->moments->My- 0.5 - source->pixels->row0; // coord of peak in subimage142 float xCM = Xo - 0.5 - source->pixels->col0; // coord of peak in subimage 143 float yCM = Yo - 0.5 - source->pixels->row0; // coord of peak in subimage 133 144 134 145 for (psS32 row = 0; row < source->pixels->numRows ; row++) { 135 146 136 psF32yDiff = row - yCM;147 float yDiff = row - yCM; 137 148 if (fabs(yDiff) > radius) continue; 138 149 139 psF32 *vPix = source->pixels->data.F32[row]; 140 psF32 *vWgt = source->variance->data.F32[row]; 150 float *vPix = source->pixels->data.F32[row]; 151 float *vWgt = source->variance->data.F32[row]; 152 141 153 psImageMaskType *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row]; 154 // psImageMaskType *vMsk = (source->maskView == NULL) ? NULL : source->maskView->data.PS_TYPE_IMAGE_MASK_DATA[row]; 142 155 143 156 for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) { … … 151 164 if (isnan(*vPix)) continue; 152 165 153 psF32xDiff = col - xCM;166 float xDiff = col - xCM; 154 167 if (fabs(xDiff) > radius) continue; 155 168 156 169 // radius is just a function of (xDiff, yDiff) 157 psF32r2 = PS_SQR(xDiff) + PS_SQR(yDiff);170 float r2 = PS_SQR(xDiff) + PS_SQR(yDiff); 158 171 if (r2 > R2) continue; 159 172 160 psF32fDiff = *vPix - sky;161 psF32pDiff = fDiff;162 psF32wDiff = *vWgt;173 float fDiff = *vPix - sky; 174 float pDiff = fDiff; 175 float wDiff = *vWgt; 163 176 164 177 // skip pixels below specified significance level. this is allowed, but should be … … 171 184 // weighting over weights the sky for faint sources 172 185 if (sigma > 0.0) { 173 psF32z = r2 * rsigma2;186 float z = r2 * rsigma2; 174 187 assert (z >= 0.0); 175 psF32weight = exp(-z);188 float weight = exp(-z); 176 189 177 190 wDiff *= weight; … … 182 195 183 196 // Kron Flux uses the 1st radial moment (NOT Gaussian windowed?) 184 psF32 r = sqrt(r2); 185 psF32 rf = r * fDiff; 186 psF32 rh = sqrt(r) * fDiff; 187 psF32 rs = fDiff; 188 189 psF32 x = xDiff * pDiff; 190 psF32 y = yDiff * pDiff; 191 192 psF32 xx = xDiff * x; 193 psF32 xy = xDiff * y; 194 psF32 yy = yDiff * y; 195 196 psF32 xxx = xDiff * xx / r; 197 psF32 xxy = xDiff * xy / r; 198 psF32 xyy = xDiff * yy / r; 199 psF32 yyy = yDiff * yy / r; 200 201 psF32 xxxx = xDiff * xxx / r2; 202 psF32 xxxy = xDiff * xxy / r2; 203 psF32 xxyy = xDiff * xyy / r2; 204 psF32 xyyy = xDiff * yyy / r2; 205 psF32 yyyy = yDiff * yyy / r2; 197 float r = sqrt(r2); 198 float rf = r * fDiff; 199 float rh = sqrt(r) * fDiff; 200 float rs = fDiff; 201 202 float rfw = r * pDiff; 203 float rhw = sqrt(r) * pDiff; 204 205 float x = xDiff * pDiff; 206 float y = yDiff * pDiff; 207 208 float xx = xDiff * x; 209 float xy = xDiff * y; 210 float yy = yDiff * y; 211 212 float xxx = xDiff * xx / r; 213 float xxy = xDiff * xy / r; 214 float xyy = xDiff * yy / r; 215 float yyy = yDiff * yy / r; 216 217 float xxxx = xDiff * xxx / r2; 218 float xxxy = xDiff * xxy / r2; 219 float xxyy = xDiff * xyy / r2; 220 float xyyy = xDiff * yyy / r2; 221 float yyyy = yDiff * yyy / r2; 206 222 207 223 RF += rf; 208 224 RH += rh; 209 225 RS += rs; 226 227 RFW += rfw; 228 RHW += rhw; 210 229 211 230 XX += xx; … … 244 263 source->moments->Myyyy = YYYY/Sum; 245 264 246 // Calculate the Kron magnitude (make this block optional?) 247 float radKinner = 1.0*source->moments->Mrf; 248 float radKron = 2.5*source->moments->Mrf; 249 float radKouter = 4.0*source->moments->Mrf; 265 // if Mrf (first radial moment) is very small, we are getting into low-significance 266 // territory. saturate at minKronRadius. conversely, if Mrf is > radius, we are clearly 267 // making an error. saturate at radius. 268 float kronRefRadius = MIN(radius, MAX(minKronRadius, source->moments->Mrf)); 269 270 float radKinner = 1.0*kronRefRadius; 271 float radKron = 2.5*kronRefRadius; 272 float radKouter = 4.0*kronRefRadius; 250 273 251 274 int nKronPix = 0; … … 259 282 for (psS32 row = 0; row < source->pixels->numRows ; row++) { 260 283 261 psF32yDiff = row - yCM;284 float yDiff = row - yCM; 262 285 if (fabs(yDiff) > radKouter) continue; 263 286 264 psF32 *vPix = source->pixels->data.F32[row]; 265 psF32 *vWgt = source->variance->data.F32[row]; 287 float *vPix = source->pixels->data.F32[row]; 288 float *vWgt = source->variance->data.F32[row]; 289 266 290 psImageMaskType *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row]; 291 // psImageMaskType *vMsk = (source->maskView == NULL) ? NULL : source->maskView->data.PS_TYPE_IMAGE_MASK_DATA[row]; 267 292 268 293 for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) { … … 276 301 if (isnan(*vPix)) continue; 277 302 278 psF32xDiff = col - xCM;303 float xDiff = col - xCM; 279 304 if (fabs(xDiff) > radKouter) continue; 280 305 281 306 // radKron is just a function of (xDiff, yDiff) 282 psF32r2 = PS_SQR(xDiff) + PS_SQR(yDiff);283 284 psF32pDiff = *vPix - sky;285 psF32wDiff = *vWgt;307 float r2 = PS_SQR(xDiff) + PS_SQR(yDiff); 308 309 float pDiff = *vPix - sky; 310 float wDiff = *vWgt; 286 311 287 312 // skip pixels below specified significance level. this is allowed, but should be … … 290 315 if (PS_SQR(pDiff) < minSN2*wDiff) continue; 291 316 292 psF32r = sqrt(r2);317 float r = sqrt(r2); 293 318 if (r < radKron) { 294 319 Sum += pDiff; … … 335 360 } 336 361 337 bool pmSourceMomentsGetCentroid(pmSource *source, psF32 radius, psF32 sigma, psF32minSN, psImageMaskType maskVal, float xGuess, float yGuess) {362 bool pmSourceMomentsGetCentroid(pmSource *source, float radius, float sigma, float minSN, psImageMaskType maskVal, float xGuess, float yGuess) { 338 363 339 364 // First Pass: calculate the first moments (these are subtracted from the coordinates below) … … 342 367 // .. etc 343 368 344 psF32sky = 0.0;345 346 psF32peakPixel = -PS_MAX_F32;369 float sky = 0.0; 370 371 float peakPixel = -PS_MAX_F32; 347 372 psS32 numPixels = 0; 348 psF32Sum = 0.0;349 psF32Var = 0.0;350 psF32X1 = 0.0;351 psF32Y1 = 0.0;352 psF32R2 = PS_SQR(radius);353 psF32minSN2 = PS_SQR(minSN);354 psF32rsigma2 = 0.5 / PS_SQR(sigma);373 float Sum = 0.0; 374 float Var = 0.0; 375 float X1 = 0.0; 376 float Y1 = 0.0; 377 float R2 = PS_SQR(radius); 378 float minSN2 = PS_SQR(minSN); 379 float rsigma2 = 0.5 / PS_SQR(sigma); 355 380 356 381 float xPeak = xGuess - source->pixels->col0; // coord of peak in subimage … … 358 383 359 384 // we are guaranteed to have a valid pixel and variance at this location (right? right?) 360 // psF32weightNorm = source->pixels->data.F32[yPeak][xPeak] / sqrt (source->variance->data.F32[yPeak][xPeak]);385 // float weightNorm = source->pixels->data.F32[yPeak][xPeak] / sqrt (source->variance->data.F32[yPeak][xPeak]); 361 386 // psAssert (isfinite(source->pixels->data.F32[yPeak][xPeak]), "peak must be on valid pixel"); 362 387 // psAssert (isfinite(source->variance->data.F32[yPeak][xPeak]), "peak must be on valid pixel"); … … 370 395 for (psS32 row = 0; row < source->pixels->numRows ; row++) { 371 396 372 psF32yDiff = row + 0.5 - yPeak;397 float yDiff = row + 0.5 - yPeak; 373 398 if (fabs(yDiff) > radius) continue; 374 399 375 psF32 *vPix = source->pixels->data.F32[row]; 376 psF32 *vWgt = source->variance->data.F32[row]; 400 float *vPix = source->pixels->data.F32[row]; 401 float *vWgt = source->variance->data.F32[row]; 402 377 403 psImageMaskType *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row]; 404 // psImageMaskType *vMsk = (source->maskView == NULL) ? NULL : source->maskView->data.PS_TYPE_IMAGE_MASK_DATA[row]; 378 405 379 406 for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) { … … 387 414 if (isnan(*vPix)) continue; 388 415 389 psF32xDiff = col + 0.5 - xPeak;416 float xDiff = col + 0.5 - xPeak; 390 417 if (fabs(xDiff) > radius) continue; 391 418 392 419 // radius is just a function of (xDiff, yDiff) 393 psF32r2 = PS_SQR(xDiff) + PS_SQR(yDiff);420 float r2 = PS_SQR(xDiff) + PS_SQR(yDiff); 394 421 if (r2 > R2) continue; 395 422 396 psF32pDiff = *vPix - sky;397 psF32wDiff = *vWgt;423 float pDiff = *vPix - sky; 424 float wDiff = *vWgt; 398 425 399 426 // skip pixels below specified significance level. for a PSFs, this … … 408 435 // weighting over weights the sky for faint sources 409 436 if (sigma > 0.0) { 410 psF32z = r2*rsigma2;437 float z = r2*rsigma2; 411 438 assert (z >= 0.0); 412 psF32weight = exp(-z);439 float weight = exp(-z); 413 440 414 441 wDiff *= weight; … … 419 446 Sum += pDiff; 420 447 421 psF32xWght = xDiff * pDiff;422 psF32yWght = yDiff * pDiff;448 float xWght = xDiff * pDiff; 449 float yWght = yDiff * pDiff; 423 450 424 451 X1 += xWght; … … 477 504 return true; 478 505 } 506 507 float pmSourceMinKronRadius(psArray *sources, float PSF_SN_LIM) { 508 509 psVector *radii = psVectorAllocEmpty(100, PS_TYPE_F32); 510 511 for (int i = 0; i < sources->n; i++) { 512 pmSource *src = sources->data[i]; // Source of interest 513 if (!src || !src->moments) { 514 continue; 515 } 516 517 if (src->mode & PM_SOURCE_MODE_BLEND) { 518 continue; 519 } 520 521 if (!src->moments->nPixels) continue; 522 523 if (src->moments->SN < PSF_SN_LIM) continue; 524 525 // XXX put in Mxx,Myy cut based on clump location 526 527 psVectorAppend(radii, src->moments->Mrf); 528 } 529 530 // find the peak in this image 531 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN); 532 533 if (!psVectorStats (stats, radii, NULL, NULL, 0)) { 534 psError(PS_ERR_UNKNOWN, false, "Unable to get image statistics.\n"); 535 psFree(stats); 536 return NAN; 537 } 538 539 float minRadius = stats->sampleMedian; 540 541 psFree(radii); 542 psFree(stats); 543 return minRadius; 544 } 545 -
branches/czw_branch/20110406/psModules/src/objects/pmSourceOutputs.c
r31153 r31606 98 98 outputs->xPos = PAR[PM_PAR_XPOS]; 99 99 outputs->yPos = PAR[PM_PAR_YPOS]; 100 if (source->mode & PM_SOURCE_MODE_NONLINEAR_FIT) { 100 if ((source->mode & PM_SOURCE_MODE_NONLINEAR_FIT) && !(source->mode & PM_SOURCE_MODE_EXTMODEL)) { 101 // we only do non-linear PSF fits for non-extended objects 101 102 outputs->xErr = dPAR[PM_PAR_XPOS]; 102 103 outputs->yErr = dPAR[PM_PAR_YPOS]; 103 104 } else { 104 outputs->xErr = fwhmMajor * source-> errMag/ 2.35;105 outputs->yErr = fwhmMinor * source-> errMag/ 2.35;105 outputs->xErr = fwhmMajor * source->psfMagErr / 2.35; 106 outputs->yErr = fwhmMinor * source->psfMagErr / 2.35; 106 107 } 107 if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SX X]) && isfinite(PAR[PM_PAR_SXX])) {108 if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXY]) && isfinite(PAR[PM_PAR_SYY])) { 108 109 axes = pmPSF_ModelToAxes (PAR, 20.0); 109 110 outputs->psfMajor = axes.major; … … 125 126 outputs->xPos = source->moments->Mx; 126 127 outputs->yPos = source->moments->My; 127 outputs->xErr = fwhmMajor * source-> errMag/ 2.35;128 outputs->yErr = fwhmMinor * source-> errMag/ 2.35;128 outputs->xErr = fwhmMajor * source->psfMagErr / 2.35; 129 outputs->yErr = fwhmMinor * source->psfMagErr / 2.35; 129 130 } else { 130 131 outputs->xPos = source->peak->xf; -
branches/czw_branch/20110406/psModules/src/objects/pmSourcePhotometry.c
r31153 r31606 82 82 - apMag : only if S/N > AP_MIN_SN 83 83 : is optionally corrected for curve-of-growth if: 84 - the source is a STAR (PSF)85 84 - the option is selected (mode & PM_SOURCE_PHOT_GROWTH) 86 85 - psfMag : all sources with non-NULL modelPSF 87 86 : is optionally corrected for aperture residual if: 88 - the source is a STAR (PSF)89 87 - the option is selected (mode & PM_SOURCE_PHOT_APCORR) 90 91 88 - extMag : all sources with non-NULL modelEXT 92 89 **/ … … 100 97 101 98 int status = false; 102 bool isPSF;103 99 float x, y; 104 float rflux;105 100 float SN; 106 pmModel *model;107 101 108 102 source->psfMag = NAN; 109 103 source->extMag = NAN; 110 source-> errMag= NAN;104 source->psfMagErr = NAN; 111 105 source->apMag = NAN; 112 106 source->apMagRaw = NAN; … … 114 108 source->apFluxErr = NAN; 115 109 116 // we must have a valid model 117 // XXX allow aperture magnitudes for sources without a model 118 model = pmSourceGetModel (&isPSF, source); 119 if (model == NULL) { 120 psTrace ("psModules.objects", 3, "fail mag : no valid model"); 110 // XXXXXX review: 111 // Select the 'best' model -- this is used for PSF_QF,_PERFECT & ???. isPSF is true if this 112 // object is a PSF (not extended). We must have a valid model. XXX NOTE: allow aperture 113 // magnitudes for sources without a model 114 115 // select the psf model 116 pmModel *modelPSF = source->modelPSF; 117 if (modelPSF == NULL) { 118 psTrace ("psModules.objects", 3, "fail mag : no valid PSF model"); 121 119 return false; 122 120 } 123 121 124 // XXX handle negative flux, low-significance125 if (model ->dparams->data.F32[PM_PAR_I0] > 0) {126 SN = fabs(model ->params->data.F32[PM_PAR_I0] / model->dparams->data.F32[PM_PAR_I0]);127 source-> errMag= 1.0 / SN;122 // get the error on the PSF model magnitude 123 if (modelPSF->dparams->data.F32[PM_PAR_I0] > 0) { 124 SN = fabs(modelPSF->params->data.F32[PM_PAR_I0] / modelPSF->dparams->data.F32[PM_PAR_I0]); 125 source->psfMagErr = 1.0 / SN; 128 126 } else { 129 127 SN = NAN; 130 source->errMag = NAN; 131 } 132 x = model->params->data.F32[PM_PAR_XPOS]; 133 y = model->params->data.F32[PM_PAR_YPOS]; 128 source->psfMagErr = NAN; 129 } 130 // the source position is used to recenter the aperture for ap photometry 131 x = modelPSF->params->data.F32[PM_PAR_XPOS]; 132 y = modelPSF->params->data.F32[PM_PAR_YPOS]; 134 133 135 134 // measure PSF model photometry 136 // XXX TEST: do not use flux scale 137 // XXX NOTE: turn this back on? 138 if (0 && psf->FluxScale) { 139 // the source peak pixel is guaranteed to be on the image, and only minimally different from the source center 140 double fluxScale = pmTrend2DEval (psf->FluxScale, (float)source->peak->x, (float)source->peak->y); 141 psAssert (isfinite(fluxScale), "how can the flux scale be invalid? source at %d, %d\n", source->peak->x, source->peak->y); 142 psAssert (fluxScale > 0.0, "how can the flux scale be negative? source at %d, %d\n", source->peak->x, source->peak->y); 143 source->psfFlux = fluxScale * source->modelPSF->params->data.F32[PM_PAR_I0]; 144 source->psfFluxErr = fluxScale * source->modelPSF->dparams->data.F32[PM_PAR_I0]; 145 source->psfMag = -2.5*log10(source->psfFlux); 146 } else { 147 status = pmSourcePhotometryModel (&source->psfMag, &source->psfFlux, source->modelPSF); 148 source->psfFluxErr = source->psfFlux * (source->modelPSF->dparams->data.F32[PM_PAR_I0] / source->modelPSF->params->data.F32[PM_PAR_I0]); 149 } 135 status = pmSourcePhotometryModel (&source->psfMag, &source->psfFlux, modelPSF); 136 source->psfFluxErr = source->psfFlux * source->psfMagErr; 137 138 # if (0) 139 // XXX NOTE: old code to use the flux scale. test & turn this back on? if so, need to save with psf model 140 // the source peak pixel is guaranteed to be on the image, and only minimally different from the source center 141 double fluxScale = pmTrend2DEval (psf->FluxScale, (float)source->peak->x, (float)source->peak->y); 142 psAssert (isfinite(fluxScale), "how can the flux scale be invalid? source at %d, %d\n", source->peak->x, source->peak->y); 143 psAssert (fluxScale > 0.0, "how can the flux scale be negative? source at %d, %d\n", source->peak->x, source->peak->y); 144 source->psfFlux = fluxScale * modelPSF->params->data.F32[PM_PAR_I0]; 145 source->psfFluxErr = fluxScale * modelPSF->dparams->data.F32[PM_PAR_I0]; 146 source->psfMag = -2.5*log10(source->psfFlux); 147 # endif 150 148 151 149 if (mode == PM_SOURCE_PHOT_PSFONLY) { … … 153 151 } 154 152 153 // get the EXT model photometry (all EXT models) 155 154 // if we have a collection of model fits, check if one of them is a pointer to modelEXT 156 155 if (source->modelFits) { … … 173 172 } 174 173 175 // for PSFs, correct both apMag and psfMag to same system, consistent with infinite flux star in aperture RADIUS 176 // XXX add a flag for "ap_mag is corrected?" 177 if ((mode & PM_SOURCE_PHOT_APCORR) && isPSF && psf && psf->ApTrend) { 174 // Correct psfMag to match aperture magnitude system (NOTE : Growth curve is already applied to ApTrend) 175 if ((mode & PM_SOURCE_PHOT_APCORR) && psf && psf->ApTrend) { 178 176 // the source peak pixel is guaranteed to be on the image, and only minimally different from the source center 179 177 double apTrend = pmTrend2DEval (psf->ApTrend, (float)source->peak->x, (float)source->peak->y); 180 178 source->psfMag += apTrend; 181 } 182 183 // measure the contribution of included pixels 179 source->psfFlux *= pow(10.0, -0.4*apTrend); 180 source->psfFluxErr *= pow(10.0, -0.4*apTrend); 181 } 182 183 // measure the contribution of included pixels to the PSF model fit 184 184 if (mode & PM_SOURCE_PHOT_WEIGHT) { 185 pmSourcePixelWeight (source, model , source->maskObj, maskVal, radius);185 pmSourcePixelWeight (source, modelPSF, source->maskObj, maskVal, radius); 186 186 } 187 187 … … 217 217 y += dy; 218 218 219 if (!psImageShiftMask(&flux, &mask, source->pixels, source->maskObj, maskVal, dx, dy, 220 NAN, 0xff, PS_INTERPOLATE_BIQUADRATIC)) { 219 // if (!psImageShiftMask(&flux, &mask, source->pixels, source->maskObj, maskVal, dx, dy, NAN, 0xff, PS_INTERPOLATE_LANCZOS2)) { 220 // if (!psImageShiftMask(&flux, &mask, source->pixels, source->maskObj, maskVal, dx, dy, NAN, 0xff, PS_INTERPOLATE_BIQUADRATIC)) { 221 if (!psImageShiftMask(&flux, &mask, source->pixels, source->maskObj, maskVal, dx, dy, NAN, 0xff, PS_INTERPOLATE_BILINEAR)) { 221 222 // Not much we can do about it 222 223 psErrorClear(); … … 232 233 233 234 // measure object aperture photometry 234 status = pmSourcePhotometryAperSource (source, model , flux, variance, mask, maskVal);235 status = pmSourcePhotometryAperSource (source, modelPSF, flux, variance, mask, maskVal); 235 236 if (!status) { 236 237 psTrace ("psModules.objects", 3, "fail mag : bad Ap Mag"); … … 241 242 // detection limits (esp near bright neighbors) 242 243 source->apMag = source->apMagRaw; 243 if (isfinite (source->apMag) && isPSF &&psf) {244 if (isfinite (source->apMag) && psf) { 244 245 if (psf->growth && (mode & PM_SOURCE_PHOT_GROWTH)) { 245 source->apMag = source->apMagRaw + pmGrowthCurveCorrect (psf->growth, source->apRadius); 246 // XXX correct the apFlux? 247 } 248 if (mode & PM_SOURCE_PHOT_APCORR) { 249 // XXX this should be removed -- we no longer fit for the 'sky bias' 250 // XXX is this happening??? 251 rflux = pow (10.0, 0.4*source->psfMag); 252 psAssert (psf->skyBias == 0.0, "sky bias not 0"); 253 psAssert (psf->skySat == 0.0, "sky sat not 0"); 254 source->apMag -= PS_SQR(source->apRadius)*rflux * psf->skyBias + psf->skySat / rflux; 246 float apOffset = pmGrowthCurveCorrect (psf->growth, source->apRadius); 247 source->apMag = source->apMagRaw + apOffset; 248 source->apFlux *= pow(10.0, -0.4*apOffset); 249 source->apFluxErr *= pow(10.0, -0.4*apOffset); 255 250 } 256 251 } … … 309 304 310 305 bool status; 311 status = pmSourcePhotometryAper(&source->apMagRaw, &source->apFlux, &source->apFluxErr, model, image, variance, mask, maskVal); 312 306 int nPix = 0; 307 status = pmSourcePhotometryAper(&nPix, &source->apMagRaw, &source->apFlux, &source->apFluxErr, model, image, variance, mask, maskVal); 308 if (status) { 309 source->mode |= PM_SOURCE_MODE_AP_MAGS; 310 } 313 311 return status; 314 312 } 315 313 316 314 // return source aperture magnitude 317 bool pmSourcePhotometryAper ( float *apMag, float *apFluxOut, float *apFluxErr, pmModel *model, psImage *image, psImage *variance, psImage *mask, psImageMaskType maskVal)315 bool pmSourcePhotometryAper (int *nPixOut, float *apMag, float *apFluxOut, float *apFluxErr, pmModel *model, psImage *image, psImage *variance, psImage *mask, psImageMaskType maskVal) 318 316 { 319 317 PS_ASSERT_PTR_NON_NULL(apMag, false); … … 328 326 float apFlux = 0; 329 327 float apFluxVar = 0; 328 int nPix = 0; 330 329 331 330 if (DO_SKY) { … … 345 344 apFlux += imData[iy][ix] - sky; 346 345 apFluxVar += varData[iy][ix]; 347 } 348 } 346 nPix ++; 347 } 348 } 349 349 350 if (apFluxOut) *apFluxOut = apFlux; 350 351 if (apFluxErr) *apFluxErr = sqrt(fabs(apFluxVar)); 352 if (nPixOut) *nPixOut = nPix; 351 353 352 354 if (apFlux <= 0) { … … 412 414 psImageMaskType maskBad = maskVal; 413 415 maskBad &= ~maskSuspect; 416 417 psImageMaskType maskPoor = maskVal | maskSuspect; 414 418 415 419 // measure modelSum and validSum. this function is applied to a sources' subimage. the … … 446 450 447 451 // count pixels which are masked with an mask bit (bad or poor) 448 if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & mask Val)) {452 if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskPoor)) { 449 453 notPoorSum += value; 450 454 } … … 487 491 488 492 if (isfinite(source->pixWeightNotBad) && isfinite(source->pixWeightNotPoor)) { 489 psAssert (source->pixWeightNot Bad <= source->pixWeightNotPoor, "error: all bad pixels should also be poor");493 psAssert (source->pixWeightNotPoor <= source->pixWeightNotBad, "error: all bad pixels should also be poor"); 490 494 } 491 495 -
branches/czw_branch/20110406/psModules/src/objects/pmSourcePhotometry.h
r31153 r31606 45 45 46 46 bool pmSourcePhotometryAper( 47 int *nPixOut, 47 48 float *apMag, 48 49 float *apFluxOut, -
branches/czw_branch/20110406/psModules/src/objects/pmSourceUtils.h
r14652 r31606 38 38 39 39 /// @} 40 # endif /* PM_ MODEL_CLASS_H */40 # endif /* PM_SOURCE_UTILS_H */ -
branches/czw_branch/20110406/psModules/src/psmodules.h
r30623 r31606 148 148 #include <pmModelUtils.h> 149 149 #include <pmSourcePhotometry.h> 150 #include <pmGrowthCurveGenerate.h> 150 151 #include <pmSourceVisual.h> 151 152 #include <pmSourceMatch.h> -
branches/czw_branch/20110406/psModules/test/objects/tap_pmSource.c
r31153 r31606 91 91 ok(isnan(src->psfMag), "pmSourceAlloc() pmSource->psfMag correctly"); 92 92 ok(isnan(src->extMag), "pmSourceAlloc() pmSource->extMag correctly"); 93 ok(isnan(src-> errMag), "pmSourceAlloc() pmSource->errMagcorrectly");93 ok(isnan(src->psfMagErr), "pmSourceAlloc() pmSource->psfMagErr correctly"); 94 94 ok(isnan(src->apMag), "pmSourceAlloc() pmSource->apMag correctly"); 95 95 ok(isnan(src->sky), "pmSourceAlloc() pmSource->sky correctly"); -
branches/czw_branch/20110406/psModules/test/objects/tap_pmSourceIO_PS1_DEV_0.c
r21223 r31606 167 167 model->dparams->data.F32[PM_PAR_YPOS] = TEST_BASE_Y_ERR + (float) i; 168 168 src->psfMag = TEST_BASE_PSF_MAG + (float) i; 169 src-> errMag= TEST_BASE_ERR_MAG + (float) i;169 src->psfMagErr = TEST_BASE_ERR_MAG + (float) i; 170 170 src->peak->flux = TEST_BASE_PEAK_FLUX + (float) i; 171 171 src->sky = TEST_BASE_SKY + (float) i; … … 215 215 ok(src->psfMag == (TEST_BASE_PSF_MAG + (float) i), "pmSourcesRead_PS1_DEV_0() set src->psfMag correctly (is %.2f, should be %.2f)", 216 216 src->psfMag, (TEST_BASE_PSF_MAG + (float) i)); 217 ok(src-> errMag == (TEST_BASE_ERR_MAG + (float) i), "pmSourcesRead_PS1_DEV_0() set src->errMagcorrectly (is %.2f, should be %.2f)",218 src-> errMag, (TEST_BASE_ERR_MAG + (float) i));217 ok(src->psfMagErr == (TEST_BASE_ERR_MAG + (float) i), "pmSourcesRead_PS1_DEV_0() set src->psfMagErr correctly (is %.2f, should be %.2f)", 218 src->psfMagErr, (TEST_BASE_ERR_MAG + (float) i)); 219 219 220 220 // XXX: Source code always sets src->modelPSF. Is that right? -
branches/czw_branch/20110406/psModules/test/objects/tap_pmSourceIO_PS1_DEV_1.c
r24852 r31606 196 196 model->dparams->data.F32[PM_PAR_YPOS] = TEST_BASE_Y_ERR + (float) i; 197 197 src->psfMag = TEST_BASE_PSF_MAG + (float) i; 198 src-> errMag= TEST_BASE_ERR_MAG + (float) i;198 src->psfMagErr = TEST_BASE_ERR_MAG + (float) i; 199 199 src->peak->flux = TEST_BASE_PEAK_FLUX + (float) i; 200 200 src->sky = TEST_BASE_SKY + (float) i; … … 203 203 sources->data[i] = (psPtr *) src; 204 204 src->psfMag = TEST_BASE_PSF_MAG + (float) i; 205 src-> errMag= TEST_BASE_ERR_MAG + (float) i;205 src->psfMagErr = TEST_BASE_ERR_MAG + (float) i; 206 206 src->sky = TEST_BASE_SKY + (float) i; 207 207 src->skyErr = TEST_BASE_SKY_ERR + (float) i; … … 280 280 ok(src->psfMag == (TEST_BASE_PSF_MAG + (float) i), "pmSourcesRead_PS1_DEV_1() set src->psfMag correctly (is %.2f, should be %.2f)", 281 281 src->psfMag, (TEST_BASE_PSF_MAG + (float) i)); 282 ok(src-> errMag == (TEST_BASE_ERR_MAG + (float) i), "pmSourcesRead_PS1_DEV_1() set src->errMagcorrectly (is %.2f, should be %.2f)",283 src-> errMag, (TEST_BASE_ERR_MAG + (float) i));282 ok(src->psfMagErr == (TEST_BASE_ERR_MAG + (float) i), "pmSourcesRead_PS1_DEV_1() set src->psfMagErr correctly (is %.2f, should be %.2f)", 283 src->psfMagErr, (TEST_BASE_ERR_MAG + (float) i)); 284 284 285 285 // XXX: Source code always sets src->modelPSF. Is that right? -
branches/czw_branch/20110406/psModules/test/objects/tap_pmSourceIO_SMPDATA.c
r21223 r31606 167 167 model->dparams->data.F32[PM_PAR_YPOS] = TEST_BASE_Y_ERR + (float) i; 168 168 src->psfMag = TEST_BASE_PSF_MAG + (float) i; 169 src-> errMag= TEST_BASE_ERR_MAG + (float) i;169 src->psfMagErr = TEST_BASE_ERR_MAG + (float) i; 170 170 src->peak->flux = TEST_BASE_PEAK_FLUX + (float) i; 171 171 src->sky = TEST_BASE_SKY + (float) i; … … 226 226 src->psfMag, (TEST_BASE_PSF_MAG + (float) i)); 227 227 float tmpF = 0.001 * PS_MIN(999, (1000 * (TEST_BASE_ERR_MAG + (float) i))); 228 ok(src-> errMag == tmpF, "pmSourcesRead_SMPDATA() set src->errMagcorrectly (is %.2f, should be %.2f)",229 src-> errMag, tmpF);228 ok(src->psfMagErr == tmpF, "pmSourcesRead_SMPDATA() set src->psfMagErr correctly (is %.2f, should be %.2f)", 229 src->psfMagErr, tmpF); 230 230 tmpF = PS_MIN(99.0, (TEST_BASE_EXT_MAG + ZERO_POINT)) - ZERO_POINT; 231 231 ok(src->extMag == tmpF, "pmSourcesRead_SMPDATA() set src->extMag correctly (is %.2f, should be %.2f)", -
branches/czw_branch/20110406/psModules/test/objects/tap_pmSourcePhotometry.c
r25754 r31606 103 103 ok_float_tol(source->psfMag, fitMag, 0.0002, "source fitMag is %f", source->psfMag); 104 104 ok_float_tol(source->apMag, apMag, 0.0002, "source apMag is %f", source->apMag); 105 ok_float(source-> errMag, 0.001, "source errMag is %f", source->errMag);105 ok_float(source->psfMagErr, 0.001, "source psfMagErr is %f", source->psfMagErr); 106 106 float refMag = source->apMag; 107 107 -
branches/czw_branch/20110406/psastro/src/psastroConvert.c
r31434 r31606 133 133 pmSource *source = sources->data[n]; 134 134 135 psTrace ("psastro", 6, "mag: %f +/- %f, mode: %x, skip: %x\n", source->psfMag, source-> errMag, source->mode, skip);135 psTrace ("psastro", 6, "mag: %f +/- %f, mode: %x, skip: %x\n", source->psfMag, source->psfMagErr, source->mode, skip); 136 136 137 137 if (source->mode & skip) { … … 191 191 obj->pix->yErr = dPAR[PM_PAR_YPOS]; 192 192 obj->Mag = source->psfMag; 193 obj->dMag = source-> errMag;193 obj->dMag = source->psfMagErr; 194 194 195 195 // XXX do we have the information giving the readout and cell offset? -
branches/czw_branch/20110406/psconfig/psbuild
r31068 r31606 386 386 if (@ARGV != 2) { die "USAGE: psbuild -bootstrap (install_dir)\n"; } 387 387 $psconfdir = $ARGV[1]; 388 die "Target directory must be absolute, not relative: $psconfdir\n" unless $psconfdir =~ m|^/|; 388 389 389 390 # copy psconfig.csh and psconfig.bash to psconfdir -
branches/czw_branch/20110406/psconfig/tagsets/ipp-3.0.libs
r31162 r31606 30 30 lib libpthread NONE NONE NONE NONE N NONE NONE NONE 31 31 lib libncurses curses,termcap NONE ncurses-5.6.tar.gz ncurses-5.6 N NONE NONE NONE 32 # XXX : temp for buildtest 33 # lib libreadline NONE NONE readline-5.2-p14.tar.gz readline-5.2-p14 Y NONE NONE NONE 32 lib libreadline NONE NONE readline-5.2-p14.tar.gz readline-5.2-p14 Y NONE NONE NONE 34 33 lib libz NONE NONE zlib-1.2.3.tar.gz zlib-1.2.3 N --shared NONE NONE 35 34 lib libpng NONE NONE libpng-1.2.15.tar.gz libpng-1.2.15 N NONE NONE NONE -
branches/czw_branch/20110406/psphot
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20110404/psphot (added) merged: 31313-31314,31328,31337,31362,31364,31381,31384,31437,31444
- Property svn:mergeinfo changed
-
branches/czw_branch/20110406/psphot/src/Makefile.am
r31154 r31606 167 167 psphotSourcePlots.c \ 168 168 psphotRadialPlot.c \ 169 psphotKronMasked.c \ 169 170 psphotDeblendSatstars.c \ 170 171 psphotMosaicSubimage.c \ -
branches/czw_branch/20110406/psphot/src/psphot.h
r31154 r31606 149 149 bool psphotPSFstats (pmReadout *readout, pmPSF *psf); 150 150 bool psphotMomentsStats (pmReadout *readout, psArray *sources); 151 152 bool psphotKronMasked (pmConfig *config, const pmFPAview *view, const char *filerule); 153 bool psphotKronMaskedReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, pmReadout *readout, psArray *sources, pmPSF *psf); 151 154 152 155 // in psphotGuessModel.c … … 310 313 311 314 bool psphotMakeFluxScale (psImage *image, psMetadata *recipe, pmPSF *psf); 312 bool psphotMakeGrowthCurve (pmReadout *readout, psMetadata *recipe, pmPSF *psf );315 bool psphotMakeGrowthCurve (pmReadout *readout, psMetadata *recipe, pmPSF *psf, psArray *sources); 313 316 bool psphotDumpPSFStars (pmReadout *readout, pmPSFtry *try, float radius, psImageMaskType maskVal, psImageMaskType markVal); 314 317 -
branches/czw_branch/20110406/psphot/src/psphotApResid.c
r31154 r31606 1 1 # include "psphotInternal.h" 2 //# define DEBUG2 # define DEBUG 3 3 4 4 # define SKIPSTAR(MSG) { psTrace ("psphot", 3, "invalid : %s", MSG); continue; } … … 206 206 207 207 // XXX make this user-configurable? 208 if (source-> errMag> 0.01) continue;208 if (source->psfMagErr > 0.01) continue; 209 209 210 210 // aperture residual for this source … … 222 222 source->peak->xf, source->peak->yf, 223 223 source->modelPSF->params->data.F32[PM_PAR_XPOS], source->modelPSF->params->data.F32[PM_PAR_YPOS], 224 source->psfMag, source->apMag, source-> errMag,224 source->psfMag, source->apMag, source->psfMagErr, 225 225 source->modelPSF->params->data.F32[PM_PAR_I0], 226 226 source->modelPSF->params->data.F32[PM_PAR_SXX], source->modelPSF->params->data.F32[PM_PAR_SXY], source->modelPSF->params->data.F32[PM_PAR_SYY], … … 228 228 # endif 229 229 if (!isfinite(source->psfMag)) psAbort ("nan in psfMag"); 230 if (!isfinite(source-> errMag)) psAbort ("nan in errMag");230 if (!isfinite(source->psfMagErr)) psAbort ("nan in psfMagErr"); 231 231 if (!isfinite(source->apMag)) psAbort ("nan in apMag"); 232 232 if (!isfinite(model->params->data.F32[PM_PAR_XPOS])) psAbort ("nan in xPos"); … … 234 234 235 235 psVectorAppend (mag, source->psfMag); 236 psVectorAppend (dMag,source-> errMag);236 psVectorAppend (dMag,source->psfMagErr); 237 237 psVectorAppend (apResid, dap); 238 238 psVectorAppend (xPos, model->params->data.F32[PM_PAR_XPOS]); … … 328 328 psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "DAPMIFIT", PS_META_REPLACE, "ap residual scatter", psf->dApResid); 329 329 psMetadataAddS32 (readout->analysis, PS_LIST_TAIL, "NAPMIFIT", PS_META_REPLACE, "number of apresid stars", psf->nApResid); 330 psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "APLOSS", PS_META_REPLACE, "aperture loss (mag)", psf->growth ? psf->growth->apLoss : NAN); 330 331 // curve-of-growth offset 332 if (psf->growth) { 333 float gaussSigma = psMetadataLookupF32(&status, readout->analysis, "MOMENTS_GAUSS_SIGMA"); 334 if (!status) { 335 gaussSigma = psMetadataLookupF32(&status, recipe, "MOMENTS_GAUSS_SIGMA"); 336 } 337 float apScale = psMetadataLookupF32(&status, recipe, "PSF_APERTURE_SCALE"); 338 float PSF_APERTURE = (int)(apScale*gaussSigma); 339 340 float offset = pmGrowthCurveCorrect (psf->growth, PSF_APERTURE); 341 psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "APLOSS", PS_META_REPLACE, "aperture loss (mag)", psf->growth->apLoss); 342 psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "APREFOFF", PS_META_REPLACE, "offset to ref aperture", offset); 343 } else { 344 psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "APLOSS", PS_META_REPLACE, "aperture loss (mag)", NAN); 345 psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "APREFOFF", PS_META_REPLACE, "offset to ref aperture", NAN); 346 } 331 347 332 348 psLogMsg ("psphot.apresid", PS_LOG_DETAIL, "aperture residual: %f +/- %f\n", psf->ApResid, psf->dApResid); -
branches/czw_branch/20110406/psphot/src/psphotBlendFit.c
r31154 r31606 242 242 if (source->mode & PM_SOURCE_MODE_PAIR) continue; 243 243 244 // do not include MOMENTS_FAILURES in the fit 245 if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) continue; 246 244 247 // limit selection to some SN limit 245 248 if (sqrt(source->peak->detValue) < FIT_SN_LIM) continue; … … 280 283 if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) { 281 284 if (psphotFitBlob (readout, source, newSources, psf, fitOptions, maskVal, markVal)) { 282 source->type = PM_SOURCE_TYPE_EXTENDED;283 285 psTrace ("psphot", 5, "source at %7.1f, %7.1f is ext", source->peak->xf, source->peak->yf); 284 286 Next ++; 285 source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT;286 287 continue; 287 288 } … … 291 292 psTrace ("psphot", 5, "source at %7.1f, %7.1f is psf", source->peak->xf, source->peak->yf); 292 293 Npsf ++; 293 source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT;294 294 continue; 295 295 } -
branches/czw_branch/20110406/psphot/src/psphotChoosePSF.c
r31154 r31606 350 350 351 351 // build curve-of-growth vector for this psf 352 if (!psphotMakeGrowthCurve (readout, recipe, try->psf )) {352 if (!psphotMakeGrowthCurve (readout, recipe, try->psf, try->sources)) { 353 353 psError(PSPHOT_ERR_PSF, false, "Unable to construct flux scale for PSF"); 354 354 psFree (models); -
branches/czw_branch/20110406/psphot/src/psphotEfficiency.c
r30560 r31606 400 400 source->type = PM_SOURCE_TYPE_STAR; 401 401 402 source->modelPSF->fitRadius = sourceRadius; 403 source->apRadius = sourceRadius; 404 402 405 numFound++; 403 406 psArrayAdd(sources, sources->n, source); … … 468 471 source->modelPSF->params->data.F32[PM_PAR_XPOS], 469 472 source->modelPSF->params->data.F32[PM_PAR_YPOS], 470 magRef, source->psfMag, source-> errMag);473 magRef, source->psfMag, source->psfMagErr); 471 474 #endif 472 475 magDiff->data.F32[j] = source->psfMag - magRef; 473 magErr->data.F32[j] = source-> errMag;476 magErr->data.F32[j] = source->psfMagErr; 474 477 } 475 478 magDiff->n = sources->n; -
branches/czw_branch/20110406/psphot/src/psphotExtendedSourceFits.c
r31154 r31606 333 333 // this uses the footprint to judge both radius and aperture? 334 334 // XXX save the psf-based moments for output 335 if (!pmSourceMoments (source, radius, 0.0, 0.0, maskVal)) {335 if (!pmSourceMoments (source, radius, 0.0, 0.0, 0.0, maskVal)) { 336 336 fprintf (stderr, "skipping (2) %f, %f\n", source->peak->xf, source->peak->yf); 337 337 // subtract the best fit from the object, leave local sky … … 379 379 assert (status); 380 380 381 // fprintf (stderr, "xfit: %f, %f : %f\n", source->peak->xf, source->peak->yf, source->peak->SN);382 383 381 // limit selection to some SN limit 384 assert (source->peak); // how can a source not have a peak?382 // assert (source->peak); // how can a source not have a peak? 385 383 if (sqrt(source->peak->detValue) < SNlim) { 386 384 Nfaint ++; -
branches/czw_branch/20110406/psphot/src/psphotFitSourcesLinear.c
r31154 r31606 137 137 if (source->mode & PM_SOURCE_MODE_CR_LIMIT) continue; 138 138 139 // do not include MOMENTS_FAILURES in the fit 140 if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) continue; 141 139 142 // XXX count saturated stars 140 143 if (source->mode & PM_SOURCE_MODE_SATSTAR) { … … 164 167 165 168 // check the integral of the model : is it large enough? 169 // apply mask? 166 170 float modelSum = 0.0; 171 float maskedSum = 0.0; 167 172 for (int iy = 0; iy < source->modelFlux->numRows; iy++) { 168 173 for (int ix = 0; ix < source->modelFlux->numCols; ix++) { 169 174 modelSum += source->modelFlux->data.F32[iy][ix]; 175 if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskVal) continue; 176 maskedSum += source->modelFlux->data.F32[iy][ix]; 170 177 } 171 178 } 172 179 if (modelSum < 0.5) continue; // skip sources with no model constraint (somewhat arbitrary limit) 173 // if (modelSum < 0.01) continue; // skip sources with no model constraint (somewhat arbitrary limit)174 180 if (modelSum < 0.8) { 175 fprintf (stderr, "low-sig model @ %f, %f (%f sum, %f peak)\n",176 source->peak->xf, source->peak->yf, m odelSum, source->peak->rawFlux);181 fprintf (stderr, "low-sig model @ %f, %f (%f masked sum, %f sum, %f peak)\n", 182 source->peak->xf, source->peak->yf, maskedSum, modelSum, source->peak->rawFlux); 177 183 } 178 179 pmModel *model = pmSourceGetModel (NULL, source); 184 if (maskedSum < 0.5) { 185 fprintf (stderr, "worrying model @ %f, %f (%f masked sum, %f sum, %f peak)\n", 186 source->peak->xf, source->peak->yf, maskedSum, modelSum, source->peak->rawFlux); 187 } 188 189 bool isPSF = false; 190 pmModel *model = pmSourceGetModel (&isPSF, source); 180 191 181 192 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); 182 193 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, model->fitRadius, "OR", markVal); 183 194 184 source->mode |= PM_SOURCE_MODE_LINEAR_FIT; 195 // we call this function multiple times. for the first time, we have only PSF models for all objects 196 // the second time has extended sources. If we ever fit the PSF model, we should raise this bit 197 source->mode |= PM_SOURCE_MODE_LINEAR_FIT; 198 if (isPSF) { 199 source->mode |= PM_SOURCE_MODE_PSFMODEL; 200 } 201 185 202 psArrayAdd (fitSources, 100, source); 186 203 } … … 260 277 } 261 278 } 279 280 # if (0) 281 static int npass = 0; 282 char name[128]; 283 FILE *f1 = NULL; 284 int fd = -1; 285 286 snprintf (name, 128, "sparse.Aij.%02d.dat", npass); 287 f1 = fopen (name, "w"); 288 psAssert (f1, "failed to open file\n"); 289 fd = fileno (f1); 290 p_psVectorPrint (fd, sparse->Aij, "Aij"); 291 fclose (f1); 292 293 snprintf (name, 128, "sparse.Bfj.%02d.dat", npass); 294 f1 = fopen (name, "w"); 295 psAssert (f1, "failed to open file\n"); 296 fd = fileno (f1); 297 p_psVectorPrint (fd, sparse->Bfj, "Bfj"); 298 fclose (f1); 299 300 snprintf (name, 128, "sparse.Qii.%02d.dat", npass); 301 f1 = fopen (name, "w"); 302 psAssert (f1, "failed to open file\n"); 303 fd = fileno (f1); 304 p_psVectorPrint (fd, sparse->Qii, "Qii"); 305 fclose (f1); 306 npass ++; 307 # endif 262 308 263 309 psSparseResort (sparse); -
branches/czw_branch/20110406/psphot/src/psphotFitSourcesLinearStack.c
r31154 r31606 69 69 if (!pmSourceCacheModel (source, maskVal)) continue; 70 70 } 71 72 // check the integral of the model : is it large enough? 73 float modelSum = 0.0; 74 for (int iy = 0; iy < source->modelFlux->numRows; iy++) { 75 for (int ix = 0; ix < source->modelFlux->numCols; ix++) { 76 modelSum += source->modelFlux->data.F32[iy][ix]; 77 } 78 } 79 if (modelSum < 0.5) continue; // skip sources with no model constraint (somewhat arbitrary limit) 80 if (modelSum < 0.8) { 81 fprintf (stderr, "low-sig model @ %f, %f (%f sum, %f peak)\n", 82 source->peak->xf, source->peak->yf, modelSum, source->peak->rawFlux); 83 } 71 84 72 85 source->mode |= PM_SOURCE_MODE_LINEAR_FIT; -
branches/czw_branch/20110406/psphot/src/psphotGuessModels.c
r31154 r31606 160 160 pmSource *source = sources->data[i]; 161 161 162 if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) {163 fprintf (stderr, "moment failure\n");164 }165 166 162 // this is used to mark sources for which the model is measured. We check later that 167 163 // all are used. … … 169 165 170 166 // skip non-astronomical objects (very likely defects) 167 if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) continue; 171 168 if (source->type == PM_SOURCE_TYPE_DEFECT) continue; 172 169 if (source->type == PM_SOURCE_TYPE_SATURATED) continue; … … 196 193 } 197 194 195 # if (0) 198 196 if (source->mode & PM_SOURCE_MODE_SATSTAR) { 199 197 fprintf (stderr, "satstar: %f,%f vs %f,%f : %c\n", … … 202 200 (useMoments ? 'T' : 'F')); 203 201 } 202 # endif 204 203 205 204 // set PSF parameters for this model (apply 2D shape model to coordinates Xo, Yo) -
branches/czw_branch/20110406/psphot/src/psphotLoadSRCTEXT.c
r31154 r31606 52 52 53 53 // NOTE: most of these values are irrelevant for loaded source positions 54 source->seq = 0;54 source->seq = source->id; 55 55 PAR[PM_PAR_XPOS] = X; 56 56 PAR[PM_PAR_YPOS] = Y; … … 67 67 68 68 source->psfMag = 0.0; 69 source-> errMag= 0.0;69 source->psfMagErr = 0.0; 70 70 source->apMag = 0.0; 71 71 -
branches/czw_branch/20110406/psphot/src/psphotMagnitudes.c
r31154 r31606 167 167 pmSource *source = (pmSource *) sources->data[i]; 168 168 169 bool saveTest = false; 170 psImage *testImage = NULL; 171 # if (0) 172 if ((fabs(source->peak->xf-3518) < 5) && (fabs(source->peak->yf-3178) < 5)) { 173 saveTest = true; 174 psRegion subregion = psRegionSet (source->peak->xf - 200, source->peak->xf + 200, source->peak->yf - 200, source->peak->yf + 200); 175 testImage = psImageSubset ((psImage *) source->pixels->parent, subregion); 176 } 177 # endif 178 179 if (saveTest) { 180 psphotSaveImage(NULL, testImage, "test.image.1.fits"); 181 } 182 169 183 // replace object in image 170 184 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) { … … 172 186 } 173 187 188 if (saveTest) { 189 psphotSaveImage(NULL, testImage, "test.image.2.fits"); 190 } 191 192 float xPos = source->peak->xf; 193 float yPos = source->peak->yf; 194 195 pmModel *model = source->modelPSF; 196 if (model) { 197 xPos = model->params->data.F32[PM_PAR_XPOS]; 198 yPos = model->params->data.F32[PM_PAR_YPOS]; 199 } else { 200 bool useMoments = pmSourcePositionUseMoments(source); 201 if (useMoments) { 202 xPos = source->moments->Mx; 203 yPos = source->moments->My; 204 } 205 } 206 174 207 // clear the mask bit and set the circular mask pixels 175 208 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); 176 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, source->apRadius, "OR", markVal);209 psImageKeepCircle (source->maskObj, xPos, yPos, source->apRadius, "OR", markVal); 177 210 178 211 status = pmSourceMagnitudes (source, psf, photMode, maskVal, markVal, source->apRadius); 179 if (status && isfinite(source->apMag)) Nap ++; 212 if (status && isfinite(source->apFlux)) { 213 Nap ++; 214 } else { 215 fprintf (stderr, "failed to measure mag for source @ %f,%f\n", source->peak->xf, source->peak->yf); 216 } 180 217 181 218 // clear the mask bit … … 185 222 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 186 223 224 if (saveTest) { 225 psphotSaveImage(NULL, testImage, "test.image.3.fits"); 226 } 227 187 228 if (backModel) { 188 229 psAssert (binning, "if backModel is defined, so should binning be"); 189 source->sky = psImageUnbinPixel( source->peak->x, source->peak->y, backModel->image, binning);230 source->sky = psImageUnbinPixel(xPos, yPos, backModel->image, binning); 190 231 if (isnan(source->sky) && false) { 191 232 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.sky"); … … 197 238 if (backStdev) { 198 239 psAssert (binning, "if backStdev is defined, so should binning be"); 199 source->skyErr = psImageUnbinPixel( source->peak->x, source->peak->y, backStdev->image, binning);240 source->skyErr = psImageUnbinPixel(xPos, yPos, backStdev->image, binning); 200 241 if (isnan(source->skyErr) && false) { 201 242 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.skyErr"); -
branches/czw_branch/20110406/psphot/src/psphotMakeGrowthCurve.c
r31154 r31606 1 1 # include "psphotInternal.h" 2 2 3 bool psphotMakeGrowthCurve (pmReadout *readout, psMetadata *recipe, pmPSF *psf ) {3 bool psphotMakeGrowthCurve (pmReadout *readout, psMetadata *recipe, pmPSF *psf, psArray *sources) { 4 4 5 5 bool status; … … 22 22 23 23 // measure the aperture loss as a function of radius for PSF 24 bool IGNORE_GROWTH = psMetadataLookupBool (&status, recipe, "IGNORE_GROWTH");25 24 float REF_RADIUS = psMetadataLookupF32 (&status, recipe, "PSF_REF_RADIUS"); 26 25 float PSF_FIT_PAD = psMetadataLookupF32 (&status, recipe, "PSF_FIT_PADDING"); 26 27 float gaussSigma = psMetadataLookupF32(&status, readout->analysis, "MOMENTS_GAUSS_SIGMA"); 28 if (!status) { 29 gaussSigma = psMetadataLookupF32(&status, recipe, "MOMENTS_GAUSS_SIGMA"); 30 } 31 float apScale = psMetadataLookupF32(&status, recipe, "PSF_APERTURE_SCALE"); 32 float PSF_APERTURE = (int)(apScale*gaussSigma); 27 33 28 34 psf->growth = pmGrowthCurveAlloc (PSF_FIT_PAD, 100.0, REF_RADIUS); 29 35 30 if (!pmGrowthCurveGenerate (readout, psf, IGNORE_GROWTH, maskVal, markVal)) { 31 psError(PSPHOT_ERR_APERTURE, false, "Fitting aperture corrections"); 32 psFree(psf->growth); psf->growth = NULL; 33 return false; 36 bool GROWTH_FROM_SOURCES = psMetadataLookupBool (&status, recipe, "GROWTH_FROM_SOURCES"); 37 if (!status) GROWTH_FROM_SOURCES = false; 38 39 if (GROWTH_FROM_SOURCES) { 40 bool INTERPOLATE_AP = psMetadataLookupBool (&status, recipe, "INTERPOLATE_AP"); 41 if (!pmGrowthCurveGenerateFromSources (readout, psf, sources, INTERPOLATE_AP, maskVal, markVal)) { 42 psError(PSPHOT_ERR_APERTURE, false, "Fitting aperture corrections"); 43 psFree(psf->growth); psf->growth = NULL; 44 return false; 45 } 46 47 } else { 48 bool IGNORE_GROWTH = psMetadataLookupBool (&status, recipe, "IGNORE_GROWTH"); 49 if (!pmGrowthCurveGenerate (readout, psf, IGNORE_GROWTH, maskVal, markVal)) { 50 psError(PSPHOT_ERR_APERTURE, false, "Fitting aperture corrections"); 51 psFree(psf->growth); psf->growth = NULL; 52 return false; 53 } 34 54 } 35 55 36 56 psLogMsg ("psphot", PS_LOG_MINUTIA, "built growth curve: %f sec\n", psTimerMark ("psphot.growth")); 37 57 58 float offset = pmGrowthCurveCorrect (psf->growth, PSF_APERTURE); 59 psLogMsg ("psphot", PS_LOG_DETAIL, "correction from %f to %f: %f mags\n", PSF_APERTURE, REF_RADIUS, offset); 60 38 61 return true; 39 62 } -
branches/czw_branch/20110406/psphot/src/psphotMergeSources.c
r31154 r31606 137 137 pmSource *source = extSourcesTXT->data[i]; 138 138 source->mode |= PM_SOURCE_MODE_EXTERNAL; 139 140 // the supplied peak flux needs to be re-normalized 141 source->peak->rawFlux = 1.0; 142 source->peak->smoothFlux = 1.0; 143 source->peak->detValue = 1.0; 139 144 140 145 // drop the loaded source modelPSF -
branches/czw_branch/20110406/psphot/src/psphotModelTest.c
r29548 r31606 226 226 // measure the source mags 227 227 pmSourcePhotometryModel (&fitMag, model); 228 pmSourcePhotometryAper ( &obsMag, NULL, NULL, model, source->pixels, source->variance, source->maskObj, maskVal);228 pmSourcePhotometryAper (NULL, &obsMag, NULL, NULL, model, source->pixels, source->variance, source->maskObj, maskVal); 229 229 fprintf (stderr, "ap: %f, fit: %f, apmifit: %f, nIter: %d\n", obsMag, fitMag, obsMag - fitMag, model->nIter); 230 230 -
branches/czw_branch/20110406/psphot/src/psphotOutput.c
r31154 r31606 75 75 source->peak->xf, source->peak->yf, 76 76 model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], 77 source->psfMag, source->apMag, source-> errMag,77 source->psfMag, source->apMag, source->psfMagErr, 78 78 model->params->data.F32[PM_PAR_I0], 79 79 model->params->data.F32[PM_PAR_SXX], model->params->data.F32[PM_PAR_SXY], model->params->data.F32[PM_PAR_SYY], … … 251 251 psMetadataItemSupplement (&status, header, analysis, "NPSFSTAR"); 252 252 psMetadataItemSupplement (&status, header, analysis, "APLOSS"); 253 psMetadataItemSupplement (&status, header, analysis, "APREFOFF"); 253 254 254 255 psMetadataItemSupplement (&status, header, analysis, "FWHM_MAJ"); -
branches/czw_branch/20110406/psphot/src/psphotPetrosianStats.c
r31154 r31606 163 163 if (refRadius->data.F32[i] > apRadius) { 164 164 if (i == 0) { 165 psWarning ("does this case make any sense? (refRadius[0] > apRadius)");165 psWarning ("does this case make any sense? (refRadius[0] %f > apRadius %f)", refRadius->data.F32[i], apRadius); 166 166 continue; 167 167 } else { … … 188 188 if (!found50 && (fluxSum->data.F32[i] > flux50)) { 189 189 if (i == 0) { 190 psWarning ("does this case make any sense? (fluxSum[0] > flux50)");190 psWarning ("does this case make any sense? (fluxSum[0] %f > flux50 %f)", fluxSum->data.F32[i], flux50); 191 191 continue; 192 192 } else { … … 198 198 if (!found90 && (fluxSum->data.F32[i] > flux90)) { 199 199 if (i == 0) { 200 psWarning ("does this case make any sense? (fluxSum[0] > flux90)");200 psWarning ("does this case make any sense? (fluxSum[0] %f > flux90 %f)", fluxSum->data.F32[i], flux90); 201 201 continue; 202 202 } else { -
branches/czw_branch/20110406/psphot/src/psphotRadialApertures.c
r31154 r31606 95 95 if (source->type == PM_SOURCE_TYPE_SATURATED) continue; 96 96 if (source->mode & PM_SOURCE_MODE_DEFECT) continue; 97 if (source->mode & PM_SOURCE_MODE_SATSTAR) continue; 97 98 // XXX measure radial apertures even for saturated stars 99 // if (source->mode & PM_SOURCE_MODE_SATSTAR) continue; 98 100 99 101 // limit selection to some SN limit … … 257 259 float SBstdv = sqrt((fluxStd->data.F32[i] / nPix) - PS_SQR(SBmean)); 258 260 261 // XXX report the total flux or the mask-corrected flux? 259 262 // flux->data.F32[i] = SBmean * Area; 263 // fluxErr->data.F32[i] = sqrt(fluxErr->data.F32[i]) * Area / nPix; 264 265 fluxErr->data.F32[i] = sqrt(fluxErr->data.F32[i]); 260 266 fluxStd->data.F32[i] = SBstdv * Area; 261 fluxErr->data.F32[i] = sqrt(fluxErr->data.F32[i]) * Area / nPix; 262 263 // fill->data.F32[i] /= Area; 267 fill->data.F32[i] /= Area; 268 264 269 psTrace ("psphot", 5, "radial bins: %3d %5.1f : %8.1f +/- %7.2f : %8.1f +/- %8.1f : %4.2f %6.1f\n", 265 270 i, aperRadii->data.F32[i], flux->data.F32[i], fluxErr->data.F32[i], SBmean, SBstdv, fill->data.F32[i], Area); -
branches/czw_branch/20110406/psphot/src/psphotRadiusChecks.c
r29936 r31606 184 184 bool psphotSetRadiusModel (pmModel *model, pmReadout *readout, pmSource *source, psImageMaskType markVal, bool deep) { 185 185 186 psF32 *PAR = model->params->data.F32; 187 188 pmMoments *moments = source->moments; 189 if (moments == NULL) return false; 186 pmPeak *peak = source->peak; 190 187 191 188 // set the fit radius based on the object flux limit and the model … … 199 196 200 197 // redefine the pixels if needed 201 pmSourceRedefinePixels (source, readout, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->fitRadius);202 203 // set the mask to flag the excluded pixels 204 psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->fitRadius, "OR", markVal);205 return true; 206 } 198 pmSourceRedefinePixels (source, readout, peak->xf, peak->yf, model->fitRadius); 199 200 // set the mask to flag the excluded pixels 201 psImageKeepCircle (source->maskObj, peak->xf, peak->yf, model->fitRadius, "OR", markVal); 202 return true; 203 } -
branches/czw_branch/20110406/psphot/src/psphotReadout.c
r31154 r31606 200 200 psphotDumpChisqs (config, view, filerule); 201 201 202 // XXX re-measure the kron mags with models subtracted 203 psphotKronMasked(config, view, filerule); 204 202 205 // identify CRs and extended sources (only unmeasured sources are measured) 203 206 psphotSourceSize (config, view, filerule, true); // pass 1 (detections->allSources) … … 309 312 pass1finish: 310 313 314 // XXX re-measure the kron mags with models subtracted 315 psphotKronMasked(config, view, filerule); 316 311 317 // measure source size for the remaining sources 312 318 // NOTE: applies only to NEW (unmeasured) sources … … 345 351 psErrorStackPrint(stderr, "Unable to replace sky"); 346 352 psErrorClear(); 347 348 /* psLogMsg("psphot", 3, "failed on psphotSkyReplace"); */ 349 /* return(psphotReadoutCleanup(config, view, filerule)); */ 350 } 353 } 354 351 355 // drop the references to the image pixels held by each source 352 356 if (!psphotSourceFreePixels (config, view, filerule)) { // pass 1 353 357 psErrorStackPrint(stderr, "Unable to free source pixels"); 354 358 psErrorClear(); 355 356 /* psLogMsg ("psphot", 3, "failed on psphotSourceFreePixels"); */ 357 /* return(psphotReadoutCleanup(config, view, filerule)); */ 358 } 359 } 360 359 361 // create the exported-metadata and free local data 360 362 return psphotReadoutCleanup(config, view, filerule); -
branches/czw_branch/20110406/psphot/src/psphotReplaceUnfit.c
r31154 r31606 67 67 psAssert (maskVal, "missing mask value?"); 68 68 69 // bit-mask to mark pixels not used in analysis 70 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); 71 assert (markVal); 72 73 // maskVal is used to test for rejected pixels, and must include markVal 74 maskVal |= markVal; 75 69 76 for (int i = 0; i < sources->n; i++) { 70 77 source = sources->data[i]; -
branches/czw_branch/20110406/psphot/src/psphotRoughClass.c
r31154 r31606 207 207 return false; 208 208 } 209 psLogMsg ("psphot", 3, "psf clump X, Y: %f, %f : DX, DY: %f, %f : nStars %d of %d\n", psfClump.X, psfClump.Y, psfClump.dX, psfClump.dY, psfClump.nStars, psfClump.nTotal); 209 if (!havePSF) { 210 psLogMsg ("psphot", 3, "psf clump X, Y: %f, %f : DX, DY: %f, %f : nStars %d of %d\n", psfClump.X, psfClump.Y, psfClump.dX, psfClump.dY, psfClump.nStars, psfClump.nTotal); 211 } else { 212 psLogMsg ("psphot", 3, "psf clump X, Y: %f, %f : DX, DY: %f, %f : loaded from metadata\n", psfClump.X, psfClump.Y, psfClump.dX, psfClump.dY); 213 } 210 214 211 215 // get basic parameters, or set defaults -
branches/czw_branch/20110406/psphot/src/psphotSetThreads.c
r31154 r31606 25 25 psFree(task); 26 26 27 task = psThreadTaskAlloc("PSPHOT_SOURCE_STATS", 1 0);27 task = psThreadTaskAlloc("PSPHOT_SOURCE_STATS", 11); 28 28 task->function = &psphotSourceStats_Threaded; 29 29 psThreadTaskAdd(task); -
branches/czw_branch/20110406/psphot/src/psphotSourceFits.c
r31154 r31606 146 146 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 147 147 source->mode |= PM_SOURCE_MODE_BLEND_FIT; 148 source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT; 148 149 return true; 149 150 } … … 186 187 187 188 // build cached model and subtract 189 source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT; 188 190 pmSourceCacheModel (source, maskVal); 189 191 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); … … 233 235 // XXX save the psf-based moments for output 234 236 psfMoments = *source->moments; 235 if (!pmSourceMoments (source, radius, 0.0, 0.5, maskVal)) {237 if (!pmSourceMoments (source, radius, 0.0, 0.5, 0.0, maskVal)) { 236 238 *source->moments = psfMoments; 237 239 return false; … … 319 321 source->type = PM_SOURCE_TYPE_EXTENDED; 320 322 source->mode |= PM_SOURCE_MODE_EXTMODEL; 323 source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT; 321 324 322 325 // build cached model and subtract … … 346 349 source->modelPSF = psMemIncrRefCounter (DBL->data[0]); 347 350 source->mode |= PM_SOURCE_MODE_PAIR; 351 source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT; 348 352 349 353 // copy most data from the primary source (modelEXT, blends stay NULL) … … 489 493 // psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5); 490 494 pmSourceFitModel (source, model, &options, maskVal); 491 // fprintf (stderr, "chisq: %f, nIter: %d, radius: %f, npix: %d\n \n", model->chisqNorm, model->nIter, model->fitRadius, model->nPix);495 // fprintf (stderr, "chisq: %f, nIter: %d, radius: %f, npix: %d\n", model->chisqNorm, model->nIter, model->fitRadius, model->nPix); 492 496 493 497 // psTraceSetLevel("psLib.math.psMinimizeLMChi2", 0); … … 554 558 // psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5); 555 559 pmSourceFitPCM (pcm, source, &options, maskVal, markVal, psfSize); 556 // fprintf (stderr, "chisq: %f, nIter: %d, radius: %f, npix: %d\n \n", model->chisqNorm, model->nIter, model->fitRadius, model->nPix);560 // fprintf (stderr, "chisq: %f, nIter: %d, radius: %f, npix: %d\n", model->chisqNorm, model->nIter, model->fitRadius, model->nPix); 557 561 558 562 // psTraceSetLevel("psLib.math.psMinimizeLMChi2", 0); -
branches/czw_branch/20110406/psphot/src/psphotSourceSize.c
r31154 r31606 213 213 214 214 psVectorAppend (ApOff, dMag); 215 psVectorAppend (ApErr, source-> errMag);215 psVectorAppend (ApErr, source->psfMagErr); 216 216 } 217 217 if (num == 0) { … … 520 520 // set nSigmaMAG to include both systematic and poisson error terms. we include a hard 521 521 // floor on the Ap Sys Err (to be a bit generous). XXX put the floor in the recipe... 522 float nSigmaMAG = (dMag - options->ApResid) / hypot(source-> errMag, hypot(options->ApSysErr, 0.02));522 float nSigmaMAG = (dMag - options->ApResid) / hypot(source->psfMagErr, hypot(options->ApSysErr, 0.02)); 523 523 source->extNsigma = nSigmaMAG; 524 524 -
branches/czw_branch/20110406/psphot/src/psphotSourceStats.c
r31154 r31606 98 98 99 99 // generate the array of sources, define the associated pixel 100 bool firstPass = false; 100 101 if (!detections->newSources) { 101 102 detections->newSources = psArrayAllocEmpty (peaks->n); 103 firstPass = true; 102 104 } 103 105 sources = detections->newSources; … … 125 127 if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) { 126 128 fprintf (stderr, "moment failure\n"); 129 } 130 131 if (firstPass) { 132 source->mode2 |= PM_SOURCE_MODE2_PASS1_SRC; 127 133 } 128 134 … … 159 165 RADIUS = psMetadataLookupF32 (&status, recipe, "PSF_MOMENTS_RADIUS"); 160 166 } 167 float MIN_KRON_RADIUS = psMetadataLookupF32 (&status, readout->analysis, "MOMENTS_MIN_KRON"); 168 if (!status) { 169 MIN_KRON_RADIUS = 0.75*SIGMA; 170 } 161 171 162 172 // threaded measurement of the source magnitudes … … 186 196 PS_ARRAY_ADD_SCALAR(job->args, RADIUS, PS_TYPE_F32); 187 197 PS_ARRAY_ADD_SCALAR(job->args, SIGMA, PS_TYPE_F32); 198 PS_ARRAY_ADD_SCALAR(job->args, MIN_KRON_RADIUS, PS_TYPE_F32); 188 199 189 200 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); … … 215 226 } else { 216 227 psScalar *scalar = NULL; 217 scalar = job->args->data[ 7];228 scalar = job->args->data[8]; 218 229 Nmoments += scalar->data.S32; 219 scalar = job->args->data[ 8];230 scalar = job->args->data[9]; 220 231 Nfail += scalar->data.S32; 221 scalar = job->args->data[ 9];232 scalar = job->args->data[10]; 222 233 Nfaint += scalar->data.S32; 223 234 } … … 231 242 232 243 psphotVisualShowMoments (sources); 244 245 // clear the mark bits 246 // psImageMaskPixels (readout->mask, "AND", PS_NOT_IMAGE_MASK(markVal)); 233 247 234 248 if (detections->allSources) { … … 373 387 float RADIUS = PS_SCALAR_VALUE(job->args->data[3],F32); 374 388 float SIGMA = PS_SCALAR_VALUE(job->args->data[4],F32); 375 376 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[5],PS_TYPE_IMAGE_MASK_DATA); 377 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[6],PS_TYPE_IMAGE_MASK_DATA); 389 float MIN_KRON_RADIUS = PS_SCALAR_VALUE(job->args->data[5],F32); 390 391 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[6],PS_TYPE_IMAGE_MASK_DATA); 392 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[7],PS_TYPE_IMAGE_MASK_DATA); 378 393 379 394 // if no valid pixels, massive swing or very large Mrf, likely saturated source, … … 431 446 if (!(source->peak->type == PM_PEAK_SUSPECT_SATURATION)) { 432 447 // measure basic source moments (no S/N clipping on input pixels) 433 status = pmSourceMoments (source, RADIUS, SIGMA, 0.0, maskVal);448 status = pmSourceMoments (source, RADIUS, SIGMA, 0.0, MIN_KRON_RADIUS, maskVal); 434 449 } else { 435 450 // For saturated stars, choose a much larger box NOTE this is slightly sleazy, but … … 447 462 448 463 psTrace ("psphot", 4, "retrying moments for %d, %d\n", source->peak->x, source->peak->y); 449 status = pmSourceMoments (source, BIG_RADIUS, BIG_SIGMA, 0.0, maskVal);464 status = pmSourceMoments (source, BIG_RADIUS, BIG_SIGMA, 0.0, MIN_KRON_RADIUS, maskVal); 450 465 source->mode |= PM_SOURCE_MODE_BIG_RADIUS; 451 466 } … … 456 471 continue; 457 472 } 473 474 // XXX test of masking neighbors when measureing moments (does this fail?) 475 // psEllipseMoments moments = {source->moments->Mxx, source->moments->Myy, source->moments->Mxy}; 476 // psEllipseAxes axes = psEllipseMomentsToAxes(moments, 20.0); 477 // psImageMaskCircle (source->maskView, source->peak->x, source->peak->y, 3.0*axes.major, "OR", markVal); 478 458 479 Nmoments ++; 459 480 … … 492 513 float sigma[NSIGMA] = {1.0, 2.0, 3.0, 4.5, 6.0, 9.0, 12.0, 18.0}; 493 514 float Sout[NSIGMA]; 515 float Rmin[NSIGMA]; 494 516 int Nout[NSIGMA]; // number of stars found in clump : use this to control the number of regions measured by psphotRoughClass 495 517 … … 513 535 514 536 // measure basic source moments (no S/N clipping on input pixels) 515 status = pmSourceMoments (source, 4*sigma[i], sigma[i], 0.0, maskVal);537 status = pmSourceMoments (source, 4*sigma[i], sigma[i], 0.0, 0.0, maskVal); 516 538 } 517 539 … … 524 546 pmPSFClump psfClump = pmSourcePSFClump (NULL, NULL, sources, PSF_SN_LIM, PSF_CLUMP_GRID_SCALE, MOMENTS_SX_MAX, MOMENTS_SY_MAX, MOMENTS_AR_MAX); 525 547 psLogMsg ("psphot", 3, "radius %.1f, nStars: %d of %d in clump, nSigma: %5.2f, X, Y: %f, %f (%f, %f)\n", sigma[i], psfClump.nStars, psfClump.nTotal, psfClump.nSigma, psfClump.X, psfClump.Y, sqrt(psfClump.X) / sigma[i], sqrt(psfClump.Y) / sigma[i]); 548 549 Rmin[i] = pmSourceMinKronRadius(sources, PSF_SN_LIM); 526 550 527 551 #if 0 … … 549 573 // we are looking for sigma for which Sout = 0.65 (or some other value) 550 574 int Nstars = 0; 575 float minKronRadius = NAN; 551 576 float Sigma = NAN; 552 577 float minS = Sout[0]; … … 565 590 Sigma = sigma[i] + (0.65 - Sout[i])*(sigma[i+1] - sigma[i])/(Sout[i+1] - Sout[i]); 566 591 Nstars = 0.5*(Nout[i] + Nout[i+1]); 592 minKronRadius = Rmin[i] + (0.65 - Sout[i])*(Rmin[i+1] - Rmin[i])/(Sout[i+1] - Sout[i]); 567 593 } 568 594 psAssert (isfinite(Sigma), "did we miss a case?"); … … 575 601 psMetadataAddF32(analysis, PS_LIST_TAIL, "PSF_MOMENTS_RADIUS", PS_META_REPLACE, "moments limit", 4.0*Sigma); 576 602 psMetadataAddF32(analysis, PS_LIST_TAIL, "PSF_CLUMP_NSTARS", PS_META_REPLACE, "number of stars in clump", Nstars); 577 578 psLogMsg ("psphot", 3, "using window function with sigma = %f\n", Sigma); 603 psMetadataAddF32(analysis, PS_LIST_TAIL, "MOMENTS_MIN_KRON", PS_META_REPLACE, "minimum Kron Radius", minKronRadius); 604 605 psLogMsg ("psphot", 3, "using window function with sigma = %f (Min Kron Radius = %f, Nstars = %d)\n", Sigma, minKronRadius, Nstars); 579 606 return true; 580 607 } -
branches/czw_branch/20110406/psphot/src/psphotVisual.c
r31154 r31606 1867 1867 continue; 1868 1868 } 1869 if (source-> errMag> 0.1) {1869 if (source->psfMagErr > 0.1) { 1870 1870 xLOW->data.F32[nLOW] = source->moments->Mxx; 1871 1871 yLOW->data.F32[nLOW] = source->moments->Myy; … … 2591 2591 x->data.F32[n] = source->psfMag; 2592 2592 y->data.F32[n] = dMag; 2593 dy->data.F32[n] = source-> errMag;2593 dy->data.F32[n] = source->psfMagErr; 2594 2594 graphdata.xmin = PS_MIN(graphdata.xmin, x->data.F32[n]); 2595 2595 graphdata.xmax = PS_MAX(graphdata.xmax, x->data.F32[n]); -
branches/czw_branch/20110406/psphot/test/tap_psphot_stackphot.pro
r31154 r31606 1 1 #!/usr/bin/env mana 2 2 # -*-sh-*- 3 4 $KAPA = kapa -noX 3 5 4 6 # config for ppImage to generate chip, mask, weight -
branches/czw_branch/20110406/pstamp/scripts/detectability_respond.pl
r31385 r31606 718 718 foreach my $fpa_id (sort {$query{$a}{ROWNUM}[0] <=> $query{$b}{ROWNUM}[0] } (keys %query)) { 719 719 if ($fpa_id eq 'Not_Set') { 720 foreach my $index (@{ $query{$ a}{ROWNUM} }) {720 foreach my $index (@{ $query{$fpa_id}{ROWNUM} }) { 721 721 push @{ $query{$fpa_id}{PROC_ERROR} }, 23; 722 722 push @{ $query{$fpa_id}{NPIX} }, -1; … … 732 732 } 733 733 734 print "BADPLACE: $fpa_id\n"; 734 print "BADPLACE: $fpa_id $query{$fpa_id}\n"; 735 foreach my $k (keys %{ $query{$fpa_id} }) { 736 print "$k $query{$fpa_id}{$k}\n"; 737 } 738 unless (defined($query{$fpa_id}{ROWNUM})) { 739 $ 735 740 push @{$colData{'ROWNUM'}}, @{ $query{$fpa_id}{ROWNUM} }; 736 741 push @{$colData{'ERROR_CODE'}}, @{ $query{$fpa_id}{PROC_ERROR} }; -
branches/czw_branch/20110406/pstamp/scripts/pstamp_job_run.pl
r30850 r31606 146 146 # user required uncensored but since stage isn't chip we can't rebuild them 147 147 my_die("uncensored inputs not available for job $job_id", $job_id, $PSTAMP_NOT_AVAILABLE, 'stop'); 148 } elsif (($options & $PSTAMP_REQUEST_UNCENSORED) and ($params->{state} eq 'update') and ($stage ne 'chip')) {148 } elsif (($options & $PSTAMP_REQUEST_UNCENSORED) and ($params->{state} ne 'full') and ($stage ne 'chip')) { 149 149 # we can only restore pixels for chip stage images if the data has been updated. 150 # XXX: this test is not quite good enough. If all components have been updated then the151 # state will be 'full' But this will get us going.152 print "Run state is update: will make stamps from destreaked $stage images.\n";150 # the data will have been updated if the params->{state} the state when the job was queued is not 'full' ( 151 # XXX: we should probably be looking explicitly at the job and checking for a dep_id 152 print "Run state was $params->{state}: will make stamps from destreaked $stage images.\n"; 153 153 # make stamps from uncensored images 154 154 $muggle = 0; -
branches/czw_branch/20110406/pstamp/scripts/pstampparse.pl
r30793 r31606 754 754 if ( $num_jobs == 0 ) { 755 755 print STDERR "no jobs for row $rownum\n" if $verbose; 756 insertFakeJobForRow($row, 1, $PSTAMP_NO_ JOBS_QUEUED);756 insertFakeJobForRow($row, 1, $PSTAMP_NO_IMAGE_MATCH); 757 757 $num_jobs = 1; 758 $row->{job_num} = 1; 758 759 } 759 760 return $num_jobs; -
branches/czw_branch/20110406/pswarp/src/pswarpTransformSources.c
r31159 r31606 101 101 new->psfMag = source->psfMag; 102 102 new->extMag = source->extMag; 103 new-> errMag = source->errMag;103 new->psfMagErr = source->psfMagErr; 104 104 new->apMag = source->apMag; 105 105 new->pixWeightNotBad = source->pixWeightNotBad; … … 116 116 (isfinite(new->psfMag) ? pow(10.0, -0.4*new->psfMag) : NAN); 117 117 new->modelPSF->dparams->data.F32[PM_PAR_I0]= 118 (isfinite(new->psfMag) ? new-> errMag*pow(10.0, -0.4*new->psfMag) : NAN);118 (isfinite(new->psfMag) ? new->psfMagErr*pow(10.0, -0.4*new->psfMag) : NAN); 119 119 120 120 #if 0
Note:
See TracChangeset
for help on using the changeset viewer.
