Changeset 21536
- Timestamp:
- Feb 19, 2009, 7:59:50 AM (17 years ago)
- Location:
- branches/cnb_branch_20090215
- Files:
-
- 24 added
- 10 deleted
- 202 edited
-
Branches.txt (modified) (1 diff)
-
Ohana/configure.tcsh (modified) (4 diffs)
-
Ohana/src/addstar/Makefile (modified) (7 diffs)
-
Ohana/src/addstar/doc/notes.txt (modified) (1 diff)
-
Ohana/src/addstar/include/addstar.h (modified) (6 diffs)
-
Ohana/src/addstar/include/skycells.h (modified) (1 diff)
-
Ohana/src/addstar/src/ConfigInit.c (modified) (1 diff)
-
Ohana/src/addstar/src/FilterStars.c (modified) (3 diffs)
-
Ohana/src/addstar/src/GetFileMode.c (modified) (2 diffs)
-
Ohana/src/addstar/src/LoadData.c (modified) (1 diff)
-
Ohana/src/addstar/src/LoadDataPMM.c (modified) (3 diffs)
-
Ohana/src/addstar/src/LoadStars.c (modified) (3 diffs)
-
Ohana/src/addstar/src/MatchHeaders.c (modified) (1 diff)
-
Ohana/src/addstar/src/PSPS_IDs.c (added)
-
Ohana/src/addstar/src/ReadImageHeader.c (modified) (1 diff)
-
Ohana/src/addstar/src/ReadStarsFITS.c (modified) (4 diffs)
-
Ohana/src/addstar/src/ReadStarsSDSS.c (modified) (6 diffs)
-
Ohana/src/addstar/src/ReadStarsTEXT.c (modified) (3 diffs)
-
Ohana/src/addstar/src/SEDfit.c (modified) (2 diffs)
-
Ohana/src/addstar/src/SkyListForStars.c (modified) (2 diffs)
-
Ohana/src/addstar/src/StarOps.c (added)
-
Ohana/src/addstar/src/UpdateImageIDs.c (modified) (1 diff)
-
Ohana/src/addstar/src/addstar.c (modified) (1 diff)
-
Ohana/src/addstar/src/airmass.c (modified) (2 diffs)
-
Ohana/src/addstar/src/args.c (modified) (7 diffs)
-
Ohana/src/addstar/src/dump.c (modified) (1 diff)
-
Ohana/src/addstar/src/fakeimage.c (modified) (2 diffs)
-
Ohana/src/addstar/src/find_matches.c (modified) (4 diffs)
-
Ohana/src/addstar/src/find_matches_closest.c (modified) (9 diffs)
-
Ohana/src/addstar/src/find_matches_refstars.c (modified) (3 diffs)
-
Ohana/src/addstar/src/find_subset.c (modified) (1 diff)
-
Ohana/src/addstar/src/get2mass_dr2.c (modified) (1 diff)
-
Ohana/src/addstar/src/get2mass_full.c (modified) (11 diffs)
-
Ohana/src/addstar/src/get2mass_ops.c (modified) (3 diffs)
-
Ohana/src/addstar/src/getgsc.c (modified) (1 diff)
-
Ohana/src/addstar/src/gettycho.c (modified) (1 diff)
-
Ohana/src/addstar/src/getusno.c (modified) (1 diff)
-
Ohana/src/addstar/src/getusnob.c (modified) (3 diffs)
-
Ohana/src/addstar/src/greference.c (modified) (2 diffs)
-
Ohana/src/addstar/src/grefstars.c (modified) (2 diffs)
-
Ohana/src/addstar/src/load2mass_as_rawdata.c (modified) (1 diff)
-
Ohana/src/addstar/src/load2mass_catalog.c (modified) (2 diffs)
-
Ohana/src/addstar/src/replace_match.c (modified) (1 diff)
-
Ohana/src/addstar/src/sky_tessalation.c (modified) (4 diffs)
-
Ohana/src/getstar/src/ReadImageFiles.c (modified) (1 diff)
-
Ohana/src/getstar/src/ReadImageHeader.c (modified) (1 diff)
-
Ohana/src/getstar/src/write_getstar_ps1_dev_0.c (modified) (1 diff)
-
Ohana/src/getstar/src/write_getstar_ps1_dev_1.c (modified) (1 diff)
-
Ohana/src/getstar/src/write_getstar_ps1_dev_2.c (modified) (1 diff)
-
Ohana/src/imregister/imphot/modify.c (modified) (1 diff)
-
Ohana/src/imregister/imphot/output.c (modified) (1 diff)
-
Ohana/src/imregister/imphot/subset.c (modified) (1 diff)
-
Ohana/src/libautocode/Makefile.Targets (modified) (12 diffs)
-
Ohana/src/libautocode/def/Stars.d (modified) (3 diffs)
-
Ohana/src/libautocode/def/average-ps1-v1.d (added)
-
Ohana/src/libautocode/def/average.d (modified) (2 diffs)
-
Ohana/src/libautocode/def/cmf-ps1-dev-0.d (added)
-
Ohana/src/libautocode/def/cmf-ps1-dev-1.d (added)
-
Ohana/src/libautocode/def/cmf-ps1-v1.d (added)
-
Ohana/src/libautocode/def/cmf-smpdata.d (added)
-
Ohana/src/libautocode/def/getstar-ps1-v1.d (added)
-
Ohana/src/libautocode/def/image-ps1-v1.d (added)
-
Ohana/src/libautocode/def/image.d (modified) (3 diffs)
-
Ohana/src/libautocode/def/measure-panstarrs-dev-0.d (modified) (1 diff)
-
Ohana/src/libautocode/def/measure-panstarrs-dev-1.d (modified) (1 diff)
-
Ohana/src/libautocode/def/measure-ps1-dev-1.d (modified) (1 diff)
-
Ohana/src/libautocode/def/measure-ps1-dev-2.d (modified) (1 diff)
-
Ohana/src/libautocode/def/measure-ps1-v1.d (added)
-
Ohana/src/libautocode/def/measure.d (modified) (1 diff)
-
Ohana/src/libautocode/def/photcode-ps1-v1.d (added)
-
Ohana/src/libautocode/def/ps1_dev_0.d (deleted)
-
Ohana/src/libautocode/def/ps1_dev_1.d (deleted)
-
Ohana/src/libautocode/def/secfilt-ps1-v1.d (added)
-
Ohana/src/libautocode/def/secfilt.d (modified) (2 diffs)
-
Ohana/src/libautocode/def/smpdata.d (deleted)
-
Ohana/src/libautocode/doc/autocode.txt (modified) (1 diff)
-
Ohana/src/libautocode/generate (modified) (6 diffs)
-
Ohana/src/libdvo/Makefile (modified) (2 diffs)
-
Ohana/src/libdvo/doc/notes.txt (modified) (3 diffs)
-
Ohana/src/libdvo/include/dvo.h (modified) (3 diffs)
-
Ohana/src/libdvo/include/ps1_v1_defs.h (added)
-
Ohana/src/libdvo/src/LoadPhotcodesFITS.c (modified) (2 diffs)
-
Ohana/src/libdvo/src/SavePhotcodesFITS.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dvo_catalog.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dvo_catalog_raw.c (modified) (8 diffs)
-
Ohana/src/libdvo/src/dvo_convert.c (modified) (9 diffs)
-
Ohana/src/libdvo/src/dvo_convert_PS1_DEV_1.c (modified) (15 diffs)
-
Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c (modified) (17 diffs)
-
Ohana/src/libdvo/src/dvo_convert_PS1_DEV_3.c (modified) (6 diffs)
-
Ohana/src/libdvo/src/dvo_convert_PS1_V1.c (added)
-
Ohana/src/libdvo/src/dvo_convert_elixir.c (modified) (18 diffs)
-
Ohana/src/libdvo/src/dvo_convert_loneos.c (modified) (15 diffs)
-
Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c (modified) (13 diffs)
-
Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c (modified) (13 diffs)
-
Ohana/src/libdvo/src/dvo_image.c (modified) (1 diff)
-
Ohana/src/libdvo/src/dvo_image_raw.c (modified) (2 diffs)
-
Ohana/src/libdvo/src/dvosorts.c (modified) (2 diffs)
-
Ohana/src/libohana/include/ohana.h (modified) (1 diff)
-
Ohana/src/opihi/cmd.data/Makefile (modified) (5 diffs)
-
Ohana/src/opihi/cmd.data/applyfit.c (deleted)
-
Ohana/src/opihi/cmd.data/applyfit1d.c (added)
-
Ohana/src/opihi/cmd.data/clip.c (deleted)
-
Ohana/src/opihi/cmd.data/fit.c (deleted)
-
Ohana/src/opihi/cmd.data/fit1d.c (added)
-
Ohana/src/opihi/cmd.data/imclip.c (added)
-
Ohana/src/opihi/cmd.data/imstats.c (added)
-
Ohana/src/opihi/cmd.data/init.c (modified) (8 diffs)
-
Ohana/src/opihi/cmd.data/stats.c (deleted)
-
Ohana/src/opihi/cmd.data/vstat.c (deleted)
-
Ohana/src/opihi/cmd.data/vstats.c (added)
-
Ohana/src/opihi/dvo/dbExtractAverages.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/dbExtractImages.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/dbExtractMeasures.c (modified) (5 diffs)
-
Ohana/src/opihi/dvo/dbFields.c (modified) (2 diffs)
-
Ohana/src/opihi/dvo/gimages.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/gstar.c (modified) (4 diffs)
-
Ohana/src/opihi/dvo/paverage.c (modified) (1 diff)
-
Ohana/src/opihi/dvo/photometry.c (modified) (14 diffs)
-
Ohana/src/opihi/dvo/pmeasure.c (modified) (1 diff)
-
Ohana/src/opihi/include/dvoshell.h (modified) (1 diff)
-
Ohana/src/relastro/include/relastro.h (modified) (1 diff)
-
Ohana/src/relastro/src/MosaicOps.c (modified) (1 diff)
-
Ohana/src/relastro/src/UpdateObjects.c (modified) (1 diff)
-
Ohana/src/relastro/src/bcatalog.c (modified) (2 diffs)
-
Ohana/src/relastro/src/load_catalogs.c (modified) (1 diff)
-
Ohana/src/relastro/src/relastro_objects.c (modified) (1 diff)
-
Ohana/src/relastro/src/select_images.c (modified) (2 diffs)
-
Ohana/src/relphot/include/relphot.h (modified) (1 diff)
-
Ohana/src/relphot/src/GridOps.c (modified) (1 diff)
-
Ohana/src/relphot/src/ImageOps.c (modified) (9 diffs)
-
Ohana/src/relphot/src/MosaicOps.c (modified) (11 diffs)
-
Ohana/src/relphot/src/StarOps.c (modified) (12 diffs)
-
Ohana/src/relphot/src/bcatalog.c (modified) (2 diffs)
-
Ohana/src/relphot/src/plot_scatter.c (modified) (1 diff)
-
Ohana/src/relphot/src/relphot_objects.c (modified) (1 diff)
-
Ohana/src/relphot/src/select_images.c (modified) (1 diff)
-
Ohana/src/relphot/src/setMrelFinal.c (modified) (3 diffs)
-
Ohana/src/uniphot/src/find_image_sgroups.c (modified) (2 diffs)
-
Ohana/src/uniphot/src/find_image_tgroups.c (modified) (1 diff)
-
Ohana/src/uniphot/src/fit_groups.c (modified) (2 diffs)
-
Ohana/src/uniphot/src/subset_images.c (modified) (2 diffs)
-
Ohana/src/uniphot/src/update.c (modified) (1 diff)
-
doc/design/distrib.v0.txt (added)
-
doc/design/remote.copy.txt (added)
-
ippTools/share/Makefile.am (modified) (1 diff)
-
ippTools/share/chiptool_export_imfiles.sql (added)
-
ippTools/share/chiptool_export_run.sql (added)
-
ippTools/src/chiptool.c (modified) (5 diffs)
-
ippTools/src/chiptool.h (modified) (1 diff)
-
ippTools/src/chiptoolConfig.c (modified) (2 diffs)
-
ippconfig/gpc1/Makefile.am (modified) (1 diff)
-
ippconfig/gpc1/psphot.config (modified) (2 diffs)
-
ippconfig/recipes/fitstypes.mdc (modified) (3 diffs)
-
ippconfig/recipes/psphot.config (modified) (1 diff)
-
ippconfig/vysos5/camera.config (modified) (1 diff)
-
ippconfig/vysos5/format_flipped.config (modified) (2 diffs)
-
ippconfig/vysos5/psastro.config (modified) (1 diff)
-
ppImage/src/ppImageArguments.c (modified) (2 diffs)
-
ppStack/src/ppStack.c (modified) (1 diff)
-
ppStack/src/ppStackArguments.c (modified) (3 diffs)
-
ppStack/src/ppStackLoop.c (modified) (9 diffs)
-
ppStack/src/ppStackMatch.c (modified) (8 diffs)
-
ppStack/src/ppStackPhotometry.c (modified) (1 diff)
-
ppStack/src/ppStackSources.c (modified) (2 diffs)
-
ppSub/src/ppSub.c (modified) (2 diffs)
-
ppSub/src/ppSub.h (modified) (5 diffs)
-
ppSub/src/ppSubArguments.c (modified) (5 diffs)
-
ppSub/src/ppSubBackground.c (modified) (3 diffs)
-
ppSub/src/ppSubCamera.c (modified) (4 diffs)
-
ppSub/src/ppSubDefineOutput.c (modified) (3 diffs)
-
ppSub/src/ppSubLoop.c (modified) (2 diffs)
-
ppSub/src/ppSubMakePSF.c (modified) (3 diffs)
-
ppSub/src/ppSubMatchPSFs.c (modified) (6 diffs)
-
ppSub/src/ppSubReadout.c (modified) (3 diffs)
-
ppSub/src/ppSubReadoutPhotometry.c (modified) (6 diffs)
-
ppSub/src/ppSubReadoutSubtract.c (modified) (6 diffs)
-
ppSub/src/ppSubReadoutUpdate.c (modified) (4 diffs)
-
ppSub/src/ppSubSetMasks.c (modified) (5 diffs)
-
ppSub/src/ppSubVarianceFactors.c (modified) (2 diffs)
-
ppSub/src/ppSubVersion.c (modified) (1 diff)
-
psLib/m4 (modified) (1 prop)
-
psLib/m4/.cvsignore (modified) (1 diff)
-
psLib/src/math/psPolynomialUtils.c (modified) (3 diffs)
-
psModules/src/astrom/pmAstrometryVisual.c (modified) (27 diffs)
-
psModules/src/astrom/pmAstrometryVisual.h (modified) (1 diff)
-
psModules/src/camera/pmFPACopy.c (modified) (1 diff)
-
psModules/src/detrend/pmShutterCorrection.h (modified) (1 diff)
-
psModules/src/extras/pmVisual.c (modified) (5 diffs)
-
psModules/src/extras/pmVisual.h (modified) (3 diffs)
-
psModules/src/imcombine/Makefile.am (modified) (2 diffs)
-
psModules/src/imcombine/pmPSFEnvelope.c (modified) (6 diffs)
-
psModules/src/imcombine/pmStack.c (modified) (2 diffs)
-
psModules/src/imcombine/pmSubtractionIO.c (modified) (3 diffs)
-
psModules/src/imcombine/pmSubtractionVisual.c (modified) (10 diffs)
-
psModules/src/imcombine/pmSubtractionVisual.h (modified) (1 diff)
-
psModules/src/objects/Makefile.am (modified) (1 diff)
-
psModules/src/objects/pmModel.c (modified) (5 diffs)
-
psModules/src/objects/pmModel.h (modified) (4 diffs)
-
psModules/src/objects/pmPeaks.c (modified) (7 diffs)
-
psModules/src/objects/pmSource.c (modified) (7 diffs)
-
psModules/src/objects/pmSource.h (modified) (5 diffs)
-
psModules/src/objects/pmSourceFitModel.c (modified) (2 diffs)
-
psModules/src/objects/pmSourceIO.c (modified) (5 diffs)
-
psModules/src/objects/pmSourceIO.h (modified) (4 diffs)
-
psModules/src/objects/pmSourceIO_CMF_PS1_V1.c (added)
-
psModules/src/objects/pmSourceIO_PS1_CAL_0.c (modified) (19 diffs)
-
psModules/src/objects/pmSourceIO_PS1_DEV_1.c (modified) (12 diffs)
-
psModules/src/objects/pmSourcePhotometry.c (modified) (11 diffs)
-
psModules/src/objects/pmSourcePhotometry.h (modified) (2 diffs)
-
psModules/src/objects/pmSourceVisual.c (modified) (6 diffs)
-
psModules/src/objects/pmSourceVisual.h (modified) (2 diffs)
-
psastro/src/psastroArguments.c (modified) (2 diffs)
-
psastro/src/psastroCleanup.c (modified) (2 diffs)
-
psastro/src/psastroVisual.c (deleted)
-
psconfig/tagsets/ipp-2.7.perl (modified) (1 diff)
-
psphot/src/psphot.h (modified) (1 diff)
-
psphot/src/psphotAddNoise.c (modified) (1 diff)
-
psphot/src/psphotApResid.c (modified) (6 diffs)
-
psphot/src/psphotArguments.c (modified) (1 diff)
-
psphot/src/psphotBlendFit.c (modified) (6 diffs)
-
psphot/src/psphotDeblendSatstars.c (modified) (1 diff)
-
psphot/src/psphotDetectReadout.c (modified) (3 diffs)
-
psphot/src/psphotExtendedSourceAnalysis.c (modified) (6 diffs)
-
psphot/src/psphotExtendedSourceFits.c (modified) (5 diffs)
-
psphot/src/psphotExtendedSources.c (deleted)
-
psphot/src/psphotFindPeaks.c (modified) (2 diffs)
-
psphot/src/psphotFitSourcesLinear.c (modified) (6 diffs)
-
psphot/src/psphotGuessModels.c (modified) (7 diffs)
-
psphot/src/psphotMagnitudes.c (modified) (6 diffs)
-
psphot/src/psphotMergeSources.c (modified) (1 diff)
-
psphot/src/psphotReplaceUnfit.c (modified) (6 diffs)
-
psphot/src/psphotSourceFits.c (modified) (5 diffs)
-
psphot/src/psphotSourceSize.c (modified) (6 diffs)
-
psphot/src/psphotSourceStats.c (modified) (6 diffs)
-
psphot/src/psphotVisual.c (modified) (31 diffs)
-
pswarp/src/pswarpArguments.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branch_20090215/Branches.txt
r21426 r21536 1 2 eam_branch_20090208 3 * Ohana : mucking around with measure.d, average.d, etc to define the 4 initial PS1 survey DVO output formats. 1 5 2 6 eam_branch_20090203 -
branches/cnb_branch_20090215/Ohana/configure.tcsh
r19564 r21536 12 12 set memcheck = 0 13 13 set use_tcmalloc = 0 14 set use_gnu99 = 0 14 15 15 16 set prefix = "" … … 70 71 set use_tcmalloc = 1 71 72 breaksw; 73 case --use-gnu99 74 set use_gnu99 = 1 75 breaksw; 72 76 case --pedantic 73 77 set pedantic = 1 … … 167 171 set CFLAGS = "-g -O0" 168 172 endif 173 169 174 # optimize overrides user-supplied CFLAGS 170 175 if ($optimize) set CFLAGS = "-O2" … … 172 177 # profiler code 173 178 if ($profile) set CFLAGS = "$CFLAGS -pg" 179 180 # use_gnu99 181 if ($use_gnu99) set CFLAGS = "$CFLAGS -std=gnu99" 174 182 175 183 if (! $?CPPFLAGS) then -
branches/cnb_branch_20090215/Ohana/src/addstar/Makefile
r20936 r21536 27 27 mkcmf : $(BIN)/mkcmf.$(ARCH) 28 28 29 all: addstar addstarc addstard addstart sedstar load2mass skycells 29 all: addstar sedstar load2mass skycells 30 31 # I need to fix the client/server version of addstar now that I have dropped Stars 32 # as an autocode type and have converted to carrying average and measure 33 # all: addstar addstarc addstard addstart sedstar load2mass skycells 30 34 31 35 ADDSTAR = \ … … 48 52 $(SRC)/find_matches_refstars.$(ARCH).o \ 49 53 $(SRC)/find_subset.$(ARCH).o \ 50 $(SRC)/get2mass.$(ARCH).o \51 $(SRC)/get2mass_as.$(ARCH).o \52 $(SRC)/get2mass_as_raw.$(ARCH).o \53 $(SRC)/get2mass_dr2.$(ARCH).o \54 $(SRC)/get2mass_ops.$(ARCH).o \55 54 $(SRC)/getgsc.$(ARCH).o \ 56 55 $(SRC)/gettycho.$(ARCH).o \ … … 71 70 $(SRC)/replace_match.$(ARCH).o \ 72 71 $(SRC)/resort_catalog.$(ARCH).o \ 72 $(SRC)/StarOps.$(ARCH).o \ 73 73 $(SRC)/ReadStarsFITS.$(ARCH).o \ 74 74 $(SRC)/ReadStarsTEXT.$(ARCH).o \ … … 106 106 $(SRC)/find_matches_refstars.$(ARCH).o \ 107 107 $(SRC)/find_subset.$(ARCH).o \ 108 $(SRC)/get2mass.$(ARCH).o \109 $(SRC)/get2mass_as.$(ARCH).o \110 $(SRC)/get2mass_as_raw.$(ARCH).o \111 $(SRC)/get2mass_dr2.$(ARCH).o \112 $(SRC)/get2mass_ops.$(ARCH).o \113 108 $(SRC)/getgsc.$(ARCH).o \ 114 109 $(SRC)/gettycho.$(ARCH).o \ … … 141 136 $(SRC)/find_matches_refstars.$(ARCH).o \ 142 137 $(SRC)/find_subset.$(ARCH).o \ 143 $(SRC)/get2mass.$(ARCH).o \144 $(SRC)/get2mass_as.$(ARCH).o \145 $(SRC)/get2mass_as_raw.$(ARCH).o \146 $(SRC)/get2mass_dr2.$(ARCH).o \147 $(SRC)/get2mass_ops.$(ARCH).o \148 138 $(SRC)/getgsc.$(ARCH).o \ 149 139 $(SRC)/getusno.$(ARCH).o \ … … 209 199 $(SRC)/replace_match.$(ARCH).o \ 210 200 $(SRC)/update_coords.$(ARCH).o \ 201 $(SRC)/StarOps.$(ARCH).o \ 211 202 $(SRC)/ConfigInit.$(ARCH).o \ 212 203 $(SRC)/Shutdown.$(ARCH).o \ … … 252 243 $(BIN)/mkcmf.$(ARCH) : $(MKCMF) 253 244 254 INSTALL = addstar addstarc addstard addstart sedstar load2mass skycells mkcmf 245 INSTALL = addstar sedstar load2mass skycells mkcmf 246 247 # I need to fix the client/server version of addstar now that I have dropped Stars 248 # as an autocode type and have converted to carrying average and measure 249 # all: addstar addstarc addstard addstart sedstar load2mass skycells 250 # INSTALL = addstar addstarc addstard addstart sedstar load2mass skycells mkcmf 255 251 256 252 # dependancy rules for binary code ######################### -
branches/cnb_branch_20090215/Ohana/src/addstar/doc/notes.txt
r20652 r21536 1 2 2009.02.11 3 4 updating DVO tables with more fields: cleaning up the conversions 5 from external formats to the DVO internal formats: I am changing 6 the APIs to convert directly to the Measure structure, including 7 conversion functions for the compressed fields (ie, pixels carried 8 as short). 9 10 A few remaining issues: 11 12 * t_msec : I've added a field to carry the fractional seconds, but 13 nothing is yet setting this value, and the query functions do not 14 use this value. 15 16 * various fields are reported in either arcseconds or pixels (eg, 17 FWHMx, moments, error in centroid). These are currently not very 18 consistent, and should be tightened up... 19 20 ** if we store these values in pixels, then cameras with a wide 21 range of plate scales (GPC1 << SkyProbe << AllSky) will all fit 22 in field with a small dynamic range; since we also provide the 23 plate scale (as a float), conversions are easy: 24 GPC1 : 0.26 arcsec / pixel 25 SkyProbe : 4.5 arcsec / pixel 26 AllSky : 3600.0 arcsec / pixel 1 27 2 28 2008.10.11 -
branches/cnb_branch_20090215/Ohana/src/addstar/include/addstar.h
r21153 r21536 28 28 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", NAME); \ 29 29 exit (0); } 30 31 typedef struct { 32 char *exthead; 33 char *extdata; 34 char *exttype; 35 int extnum_head; 36 int extnum_data; 37 } HeaderSet; 38 39 typedef struct { 40 Average average; 41 Measure measure; 42 int found; 43 } Stars; 30 44 31 45 typedef struct { … … 39 53 char *refcat; 40 54 } DVO_DATA; 41 42 typedef struct {43 char *exthead;44 char *extdata;45 char *exttype;46 int extnum_head;47 int extnum_data;48 } HeaderSet;49 55 50 56 typedef struct sockaddr_in SockAddress; … … 92 98 /* these globals modify the behavior of gstars (KEEP) */ 93 99 double SNLIMIT; 100 int PHOTFLAG_EXCLUDE; 94 101 int ACCEPT_ASTROM; // accept even bad astrometry solutions (NASTRO == 0) 95 102 int ACCEPT_MOTION; // accept reference proper motion measurements … … 137 144 /*** addstar prototypes ***/ 138 145 146 AddstarClientOptions ConfigInit PROTO((int *argc, char **argv)); 147 AddstarClientOptions args PROTO((int argc, char **argv, AddstarClientOptions options)); 148 139 149 void AddToCalibration PROTO((Average *average, SecFilt *secfilt, Measure *measure, Measure *new, int *next, int Nstar)); 140 AddstarClientOptions ConfigInit PROTO((int *argc, char **argv));141 150 void FindCalibration PROTO((Image *image)); 142 151 FILE *GetDB PROTO((int *state)); … … 145 154 void SetProtect PROTO((int mode)); 146 155 int SetSignals PROTO((void)); 147 int Shutdown PROTO((char *message, ...) ; )156 int Shutdown PROTO((char *message, ...)); 148 157 void TrapSignal PROTO((int sig)); 149 158 float airmass PROTO((float secz_image, double ra, double dec, double st, double latitude)); 159 float azimuth PROTO((double ha, double dec, double latitude)); 150 160 void SetAirmassQuality PROTO((int quality)); 151 161 SkyTable *SkyTableFromTychoIndex PROTO((char *filename, int VERBOSE)); 152 AddstarClientOptions args PROTO((int argc, char **argv, AddstarClientOptions options));153 162 void check_permissions PROTO((char *basefile)); 154 163 int dump_rawstars PROTO((Stars *stars, int Nstars)); 155 164 int edge_check PROTO((double *x1, double *y1, double *x2, double *y2)); 156 165 Image *fakeimage PROTO((char *rootname, int *Nimage, int photcode)); 166 157 167 int find_matches PROTO((SkyRegion *region, Stars *stars, int Nstars, Catalog *catalog, AddstarClientOptions options)); 158 168 int find_matches_closest PROTO((SkyRegion *region, Stars *stars, int Nstars, Catalog *catalog, AddstarClientOptions options)); 159 169 int find_matches_refstars PROTO((SkyRegion *region, Stars **stars, int Nstars, Catalog *catalog, AddstarClientOptions options)); 170 160 171 Stars **find_subset PROTO((SkyRegion *region, Stars *stars, int Nstars, int *NSTARS)); 161 172 int gcatalog PROTO((Catalog *catalog)); 162 173 Stars *get2mass PROTO((SkyRegion *patch, int photcode, int mode, int *NSTARS)); 163 174 double get_subpix PROTO((double x, double y)); 175 176 Stars *greference PROTO((char *Refcat, SkyRegion *catstats, int photcode, int *nstars)); 164 177 Stars *getgsc PROTO((SkyRegion *patch, int *NSTARS)); 165 178 Stars *gettycho PROTO((SkyRegion *catstats, int photcode, int *Nstars)); 166 179 Stars *getusno PROTO((SkyRegion *catstats, int photcode, int *Nstars)); 167 180 Stars *getusnob PROTO((SkyRegion *catstats, int photcode, int *Nstars)); 168 Image *gimages PROTO((FITS_DB *db, Image *image, Coords *mosaic, int *Npimage)); 169 Stars *grefcat PROTO((char *Refcat, SkyRegion *catstats, int photcode, int *nstars)); 181 182 // load text-based stars (REF only in the sense of REF photcodes) 170 183 Stars *grefstars PROTO((char *file, int photcode, int *Nstars)); 171 184 … … 249 262 Stars *Convert_PS1_DEV_0 PROTO((FTable *table, int *nstars)); 250 263 Stars *Convert_PS1_DEV_1 PROTO((FTable *table, int *nstars)); 264 Stars *Convert_PS1_V1 PROTO((FTable *table, int *nstars)); 265 266 int InitStar PROTO((Stars *star)); 267 short ShortPixels PROTO((float pixels)); 268 short ShortDegree PROTO((float degrees)); 251 269 252 270 int args_skycells (int argc, char **argv); -
branches/cnb_branch_20090215/Ohana/src/addstar/include/skycells.h
r21153 r21536 30 30 int NX; 31 31 int NY; 32 int code;32 int photcode; 33 33 char name[64]; 34 34 } SkyRectangle; -
branches/cnb_branch_20090215/Ohana/src/addstar/src/ConfigInit.c
r20936 r21536 39 39 ScanConfig (config, "MIN_SN_FSTAT", "%lf", 0, &SNLIMIT); 40 40 ScanConfig (config, "ADDSTAR_SNLIMIT", "%lf", 0, &SNLIMIT); 41 42 /* exclude stars with bits that match the given photFlags bits */ 43 PHOTFLAG_EXCLUDE = 0; 44 ScanConfig (config, "ADDSTAR_PHOTFLAG_EXCLUDE", "%d", 0, &PHOTFLAG_EXCLUDE); 41 45 42 46 MAX_CERROR = 0.5; // arcseconds -
branches/cnb_branch_20090215/Ohana/src/addstar/src/FilterStars.c
r19823 r21536 1 1 # include "addstar.h" 2 # define EXTERNAL_ID FALSE 2 3 4 /* exclude some detections based on various filter options: 5 * *** S/N limit 6 * *** Acceptable window on detector 7 * *** bad photFlags 8 */ 9 10 // the imageID supplied here is the sequence **within this set** 11 // this value is updated based on the image table later 3 12 Stars *FilterStars (Stars *instars, Image *image, unsigned int imageID) { 4 13 … … 19 28 ALLOCATE (stars, Stars, image[0].nstar); 20 29 for (N = j = 0; j < image[0].nstar; j++) { 30 21 31 /* allow for some dynamic filtering of star list */ 22 if (SNLIMIT && instars[j].dM > SNLIMIT) continue; 23 if (XMAX && (instars[j].X > XMAX)) continue; 24 if (XMIN && (instars[j].X < XMIN)) continue; 25 if (YMAX && (instars[j].Y > YMAX)) continue; 26 if (YMIN && (instars[j].Y < YMIN)) continue; 32 if (SNLIMIT && instars[j].measure.dM > SNLIMIT) continue; 33 if (XMAX && (instars[j].measure.Xccd > XMAX)) continue; 34 if (XMIN && (instars[j].measure.Xccd < XMIN)) continue; 35 if (YMAX && (instars[j].measure.Yccd > YMAX)) continue; 36 if (YMIN && (instars[j].measure.Yccd < YMIN)) continue; 37 if (PHOTFLAG_EXCLUDE && (instars[j].measure.photFlags & PHOTFLAG_EXCLUDE)) continue; 38 27 39 stars[N] = instars[j]; 28 40 29 XY_to_RD (&stars[N].R, &stars[N].D, stars[N].X, stars[N].Y, &image[0].coords); 30 stars[N].R = ohana_normalize_angle (stars[N].R); 31 stars[N].found = -1; 32 stars[N].code = image[0].photcode; 41 XY_to_RD (&stars[N].average.R, &stars[N].average.D, stars[N].measure.Xccd, stars[N].measure.Yccd, &image[0].coords); 42 stars[N].average.R = ohana_normalize_angle (stars[N].average.R); 33 43 34 RMIN = MIN (RMIN, stars[N].R); 35 RMAX = MAX (RMAX, stars[N].R); 36 DMIN = MIN (DMIN, stars[N].D); 37 DMAX = MAX (DMAX, stars[N].D); 44 stars[N].measure.photcode = image[0].photcode; 45 46 // determine the full coverage of this set of measurements 47 RMIN = MIN (RMIN, stars[N].average.R); 48 RMAX = MAX (RMAX, stars[N].average.R); 49 DMIN = MIN (DMIN, stars[N].average.D); 50 DMAX = MAX (DMAX, stars[N].average.D); 51 38 52 /** additional quantities to supply to Stars based on the image data **/ 39 53 40 /* calculate accurate per-star airmass */ 41 stars[N].airmass = airmass (image[0].secz, stars[N].R, stars[N].D, image[0].sidtime, image[0].latitude); 42 stars[N].Mcal = image[0].Mcal; 43 stars[N].t = image[0].tzero + 1e-4*stars[N].Y*image[0].trate; /* trate is in 0.1 msec / row */ 44 stars[N].dt = MTIME; 54 /* calculate accurate per-star airmass and azimuth */ 55 stars[N].measure.airmass = airmass (image[0].secz, stars[N].average.R, stars[N].average.D, image[0].sidtime, image[0].latitude); 56 stars[N].measure.az = azimuth (image[0].sidtime - stars[N].average.R, stars[N].average.D, image[0].latitude); 57 stars[N].measure.Mcal = image[0].Mcal; 58 stars[N].measure.t = image[0].tzero + 1e-4*stars[N].measure.Yccd*image[0].trate; /* trate is in 0.1 msec / row */ 59 stars[N].measure.dt = MTIME; 45 60 46 if ((stars[N].M > 25.0) && (stars[N].M < 32.0)) { 61 // watch out for any strange values: 62 if ((stars[N].measure.M > 25.0) && (stars[N].measure.M < 32.0)) { 47 63 fprintf (stderr, "*"); 48 64 } 49 50 65 // stars->M is either NAN or a valid inst magnitude 51 66 // stars->dM is either NAN or a valid error … … 54 69 dMx = 0.0; 55 70 if (SUBPIX) { 56 dMs = get_subpix (stars[N].X, stars[N].Y);57 dMx = scat_subpix (stars[N]. X, stars[N].Y);58 if (!isnan(stars[N]. dM)) {59 stars[N]. dM = hypot (stars[N].dM, dMx);71 dMs = get_subpix (stars[N].measure.Xccd, stars[N].measure.Yccd); 72 dMx = scat_subpix (stars[N].measure.Xccd, stars[N].measure.Yccd); 73 if (!isnan(stars[N].measure.dM)) { 74 stars[N].measure.dM = hypot (stars[N].measure.dM, dMx); 60 75 } 61 76 } 62 77 63 if (!isnan(stars[N]. M)) {64 stars[N]. M+= MTIME - dMs;78 if (!isnan(stars[N].measure.M)) { 79 stars[N].measure.M += MTIME - dMs; 65 80 } 66 if (!isnan(stars[N]. Map)) {67 stars[N]. Map += MTIME - dMs;81 if (!isnan(stars[N].measure.Map)) { 82 stars[N].measure.Map += MTIME - dMs; 68 83 } 69 84 70 // XXX currently, this ID is internal only; 71 // should we use the psphot / other external ID, if available? 72 stars[N].detID = N; // sequence number within image 73 stars[N].imageID = imageID; // does this need to be updated? 85 // the external ID is supplied, but do we trust it? 86 if (!EXTERNAL_ID) { 87 stars[N].measure.detID = N; // sequence number within image 88 } 89 90 # if (0) 91 if (PSPS_ID) { 92 double mjd; 93 mjd = ohana_sec_to_mjd (image[0].tzero); 94 // XXX this is clearly wrong : what does PSPS want? 95 stars[N].measure.extID = PSPS_create_detectid (mjd, imageID); 96 } 97 # endif 98 99 stars[N].measure.imageID = imageID; // this value is update in UpdateImageIDs 74 100 75 101 N ++; -
branches/cnb_branch_20090215/Ohana/src/addstar/src/GetFileMode.c
r20545 r21536 7 7 int Naxis; 8 8 int simple, extend, haveNaxis, haveCTYPE; 9 int tmp, havePHOT_VER, haveTARG_VER; 9 10 10 11 gfits_scan (header, "SIMPLE", "%t", 1, &simple); … … 14 15 gfits_scan (header, "EXTEND", "%t", 1, &extend); 15 16 16 { 17 int tmp, havePHOT_VER, haveTARG_VER; 18 19 // SDSS tsObj files have a version number for the PHOTO and 20 // TS (target selection) pipelines present as header keywords 21 havePHOT_VER = gfits_scan (header, "PHOT_VER", "%s", 1, &tmp); 22 haveTARG_VER = gfits_scan (header, "TARG_VER", "%s", 1, &tmp); 23 if (havePHOT_VER && haveTARG_VER) return SDSS_OBJ; 24 } 17 // SDSS tsObj files have a version number for the PHOTO and 18 // TS (target selection) pipelines present as header keywords 19 havePHOT_VER = gfits_scan (header, "PHOT_VER", "%s", 1, &tmp); 20 haveTARG_VER = gfits_scan (header, "TARG_VER", "%s", 1, &tmp); 21 if (havePHOT_VER && haveTARG_VER) return SDSS_OBJ; 25 22 26 23 if ((Naxis == 2) || TEXTMODE || !simple) { -
branches/cnb_branch_20090215/Ohana/src/addstar/src/LoadData.c
r19259 r21536 41 41 // I need to detect them here and load them with ReadStarsTEXT instead of calling the code 42 42 // below. 43 // inStars = ReadStarsFITS (f, headers[Nhead], headers[Ndata], &images[0][Nvalid].nstar); 43 44 44 45 // XXX use something to set the chip name? EXTNAME? -
branches/cnb_branch_20090215/Ohana/src/addstar/src/LoadDataPMM.c
r19259 r21536 82 82 83 83 for (i = 0; i < Nline; i++) { 84 // fscanf (f, "%lf %lf %lf", &ra, &dec, &mag) != EOF) {85 86 84 dparse (&ra, 1, &buffer[i*NBYTE_ASC_TABLE]); 87 85 dparse (&dec, 2, &buffer[i*NBYTE_ASC_TABLE]); 88 86 dparse (&mag, 3, &buffer[i*NBYTE_ASC_TABLE]); 89 87 90 memset (&inStars[Ninstars], 0, sizeof(Stars));88 InitStar (&inStars[Ninstars]); 91 89 92 90 if (ra > 180) { … … 100 98 maxD = MAX(maxD, dec); 101 99 102 inStars[Ninstars].M = mag - ZeroPoint + ZeroPt; 103 inStars[Ninstars].R = ra; 104 inStars[Ninstars].D = dec; 105 inStars[Ninstars].t = images[0][0].tzero; 106 inStars[Ninstars].dt = images[0][0].exptime; 107 inStars[Ninstars].code = code; 108 inStars[Ninstars].airmass = airmass; 109 inStars[Ninstars].az = az; 110 inStars[Ninstars].found = -1; // found starts at -1 == not yet found 100 inStars[Ninstars].average.R = ra; 101 inStars[Ninstars].average.D = dec; 102 103 inStars[Ninstars].measure.M = mag - ZeroPoint + ZeroPt; 104 inStars[Ninstars].measure.t = images[0][0].tzero; 105 inStars[Ninstars].measure.dt = images[0][0].exptime; 106 inStars[Ninstars].measure.photcode = code; 107 inStars[Ninstars].measure.airmass = airmass; 108 inStars[Ninstars].measure.az = az; 109 111 110 Ninstars++; 112 111 CHECK_REALLOCATE (inStars, Stars, NINSTARS, Ninstars, 10000); … … 238 237 image[0].Mcal = 0.0; 239 238 image[0].Xm = NAN_S_SHORT; 240 image[0]. code= 0;239 image[0].flags = 0; 241 240 242 241 image[0].nstar = 0; -
branches/cnb_branch_20090215/Ohana/src/addstar/src/LoadStars.c
r16973 r21536 63 63 } 64 64 65 // load PMM data if specified (these are not stored as FITS-tables) 65 66 if (PMM_CCD_TABLE != NULL) { 66 67 LoadDataPMM (f, file[i], images, Nimages, &stars, Nstars); … … 68 69 } 69 70 71 // otherwise, we have FITS-table files: parse their headers to determine the contents 70 72 headers = LoadHeaders (f, &mode, &Nheaders); 71 73 headerSets = MatchHeaders (&extsize, &NheaderSets, mode, headers, Nheaders); … … 86 88 } 87 89 90 // if these are SDSS data, load with SDSS-specific wrapper 88 91 if (headerSets[0].exttype && !strcmp (headerSets[0].exttype, "SDSS_OBJ")) { 89 92 LoadDataSDSS (f, file[i], images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets); -
branches/cnb_branch_20090215/Ohana/src/addstar/src/MatchHeaders.c
r16810 r21536 51 51 if (!strcmp (exttype, "PS1_DEV_0")) goto keep; 52 52 if (!strcmp (exttype, "PS1_DEV_1")) goto keep; 53 if (!strcmp (exttype, "PS1_V1")) goto keep; 53 54 continue; 54 55 -
branches/cnb_branch_20090215/Ohana/src/addstar/src/ReadImageHeader.c
r20936 r21536 200 200 image[0].Mcal = 0.0; 201 201 image[0].Xm = NAN_S_SHORT; 202 image[0]. code= 0;202 image[0].flags = 0; 203 203 204 204 /* find expected number of stars */ -
branches/cnb_branch_20090215/Ohana/src/addstar/src/ReadStarsFITS.c
r17191 r21536 40 40 stars = Convert_PS1_DEV_1 (&table, &Nstars); 41 41 } 42 if (!strcmp (type, "PS1_V1")) { 43 stars = Convert_PS1_V1 (&table, &Nstars); 44 } 42 45 if (stars == NULL) { 43 46 fprintf (stderr, "ERROR: invalid table type %s\n", type); … … 62 65 ZeroPt = GetZeroPoint(); 63 66 64 /* XXX we need to check at least the size of the loaded table */ 65 // XXX use memset to zero-out the elements before setting 66 67 ALLOCATE (stars, Stars, Nstars); 68 for (i = 0; i < Nstars; i++) { 69 stars[i].X = smpdata[i].X; 70 stars[i].Y = smpdata[i].Y; 67 ALLOCATE (stars, Stars, Nstars); 68 for (i = 0; i < Nstars; i++) { 69 InitStar (&stars[i]); 70 71 stars[i].measure.Xccd = smpdata[i].X; 72 stars[i].measure.Yccd = smpdata[i].Y; 71 73 72 74 if ((smpdata[i].M >= ZeroPt) || isnan(smpdata[i].M)) { 73 stars[i].M = NAN; 74 stars[i].Map = NAN; 75 } else { 76 stars[i].M = smpdata[i].M; 77 stars[i].Map = smpdata[i].M; 78 } 79 80 stars[i].dM = smpdata[i].dM*0.001; 81 stars[i].dophot = smpdata[i].dophot; 82 83 stars[i].fx = smpdata[i].fx; 84 stars[i].fy = smpdata[i].fy; 85 stars[i].df = smpdata[i].df; 75 stars[i].measure.M = NAN; 76 stars[i].measure.Map = NAN; 77 } else { 78 stars[i].measure.M = smpdata[i].M; 79 stars[i].measure.Map = smpdata[i].M; 80 } 81 82 stars[i].measure.dM = smpdata[i].dM*0.001; 83 84 // the dophot type information gets pushed into the upper 2 bytes of photFlags 85 stars[i].measure.photFlags = (smpdata[i].dophot << 16); 86 87 stars[i].measure.FWx = ShortPixels (smpdata[i].fx); 88 stars[i].measure.FWy = ShortPixels (smpdata[i].fy); 89 stars[i].measure.theta = ShortDegree (smpdata[i].df); 86 90 } 87 91 *nstars = Nstars; … … 101 105 ALLOCATE (stars, Stars, Nstars); 102 106 for (i = 0; i < Nstars; i++) { 103 stars[i].X = ps1data[i].X; 104 stars[i].Y = ps1data[i].Y; 105 stars[i].dX = ps1data[i].dX; 106 stars[i].dY = ps1data[i].dY; 107 InitStar (&stars[i]); 108 stars[i].measure.Xccd = ps1data[i].X; 109 stars[i].measure.Yccd = ps1data[i].Y; 110 111 stars[i].measure.dXccd = ShortPixels(ps1data[i].dX); 112 stars[i].measure.dYccd = ShortPixels(ps1data[i].dY); 113 107 114 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 108 stars[i].M = NAN; 109 } else { 110 stars[i].M = ps1data[i].M + ZeroPt; 111 } 112 stars[i].dM = ps1data[i].dM; 113 stars[i].Mpeak = ps1data[i].Mpeak; 114 115 stars[i].sky = ps1data[i].sky; 116 stars[i].dsky = ps1data[i].dSky; 117 118 stars[i].fx = ps1data[i].fx; 119 stars[i].fy = ps1data[i].fy; 120 stars[i].df = ps1data[i].df; 121 122 stars[i].psfChisq = ps1data[i].psfChisq; 123 stars[i].psfQual = ps1data[i].psfQual; 124 125 stars[i].detID = ps1data[i].detID; 126 127 /* these are set elsewhere */ 128 stars[i].R = 0.0; 129 stars[i].D = 0.0; 130 stars[i].dR = 0.0; 131 stars[i].dD = 0.0; 132 133 stars[i].uR = 0.0; 134 stars[i].uD = 0.0; 135 stars[i].duR = 0.0; 136 stars[i].duD = 0.0; 137 138 stars[i].P = 0.0; 139 stars[i].dP = 0.0; 140 141 stars[i].Mcal = 0; 142 stars[i].t = 0; 143 stars[i].dt = 0; 144 stars[i].airmass = 0; 145 stars[i].code = 0; 146 stars[i].found = 0; 147 148 /* these are not used */ 149 stars[i].Map = NAN; 150 stars[i].dophot = 0; 115 stars[i].measure.M = NAN; 116 } else { 117 stars[i].measure.M = ps1data[i].M + ZeroPt; 118 } 119 stars[i].measure.Map = NAN; 120 stars[i].measure.dM = ps1data[i].dM; 121 stars[i].measure.Sky = ps1data[i].sky; 122 stars[i].measure.dSky = ps1data[i].dSky; 123 124 stars[i].measure.FWx = ShortPixels(ps1data[i].fx); 125 stars[i].measure.FWy = ShortPixels(ps1data[i].fy); 126 stars[i].measure.theta = ShortDegree(ps1data[i].df); 127 128 stars[i].measure.psfChisq = ps1data[i].psfChisq; 129 stars[i].measure.psfQual = ps1data[i].psfQual; 130 131 stars[i].measure.detID = ps1data[i].detID; 151 132 } 152 133 *nstars = Nstars; … … 168 149 ALLOCATE (stars, Stars, Nstars); 169 150 for (i = 0; i < Nstars; i++) { 170 stars[i].X = ps1data[i].X; 171 stars[i].Y = ps1data[i].Y; 172 stars[i].dX = ps1data[i].dX; 173 stars[i].dY = ps1data[i].dY; 151 InitStar (&stars[i]); 152 stars[i].measure.Xccd = ps1data[i].X; 153 stars[i].measure.Yccd = ps1data[i].Y; 154 155 stars[i].measure.dXccd = ShortPixels(ps1data[i].dX); 156 stars[i].measure.dYccd = ShortPixels(ps1data[i].dY); 157 174 158 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 175 stars[i].M = NAN; 176 } else { 177 stars[i].M = ps1data[i].M + ZeroPt; 178 } 179 stars[i].dM = ps1data[i].dM; 180 stars[i].Mpeak = ps1data[i].Mpeak; 181 182 stars[i].sky = ps1data[i].sky; 183 stars[i].dsky = ps1data[i].dSky; 184 185 stars[i].fx = ps1data[i].fx; 186 stars[i].fy = ps1data[i].fy; 187 stars[i].df = ps1data[i].df; 188 189 stars[i].psfChisq = ps1data[i].psfChisq; 190 stars[i].psfQual = ps1data[i].psfQual; 191 stars[i].crNsigma = ps1data[i].crNsigma; 192 stars[i].extNsigma = ps1data[i].extNsigma; 193 194 stars[i].detID = ps1data[i].detID; 195 stars[i].flags = ps1data[i].flags; 196 197 // XXX not defined anyway 198 // stars[i].stargal = ps1data[i].stargal; 199 200 /* these are set elsewhere */ 201 stars[i].R = 0.0; 202 stars[i].D = 0.0; 203 stars[i].dR = 0.0; 204 stars[i].dD = 0.0; 205 206 stars[i].uR = 0.0; 207 stars[i].uD = 0.0; 208 stars[i].duR = 0.0; 209 stars[i].duD = 0.0; 210 211 stars[i].P = 0.0; 212 stars[i].dP = 0.0; 213 214 stars[i].Mcal = 0; 215 stars[i].t = 0; 216 stars[i].dt = 0; 217 stars[i].airmass = 0; 218 stars[i].az = 0; 219 stars[i].code = 0; 220 stars[i].found = 0; 221 222 /* these are not used */ 223 stars[i].Map = NAN; 224 stars[i].dophot = 0; 225 } 226 *nstars = Nstars; 227 return (stars); 228 } 159 stars[i].measure.M = NAN; 160 } else { 161 stars[i].measure.M = ps1data[i].M + ZeroPt; 162 } 163 stars[i].measure.Map = NAN; 164 stars[i].measure.dM = ps1data[i].dM; 165 stars[i].measure.Sky = ps1data[i].sky; 166 stars[i].measure.dSky = ps1data[i].dSky; 167 168 stars[i].measure.FWx = ShortPixels(ps1data[i].fx); 169 stars[i].measure.FWy = ShortPixels(ps1data[i].fy); 170 stars[i].measure.theta = ShortDegree(ps1data[i].df); 171 172 stars[i].measure.psfChisq = ps1data[i].psfChisq; 173 stars[i].measure.psfQual = ps1data[i].psfQual; 174 stars[i].measure.crNsigma = ps1data[i].crNsigma; 175 stars[i].measure.extNsigma = ps1data[i].extNsigma; 176 177 stars[i].measure.detID = ps1data[i].detID; 178 stars[i].measure.photFlags = ps1data[i].flags; 179 } 180 *nstars = Nstars; 181 return (stars); 182 } 183 184 Stars *Convert_PS1_V1 (FTable *table, int *nstars) { 185 186 int i, Nstars; 187 double ZeroPt; 188 Stars *stars; 189 CMF_PS1_V1 *ps1data; 190 191 ps1data = gfits_table_get_CMF_PS1_V1 (table, &Nstars, NULL); 192 ZeroPt = GetZeroPoint(); 193 194 ALLOCATE (stars, Stars, Nstars); 195 for (i = 0; i < Nstars; i++) { 196 InitStar (&stars[i]); 197 stars[i].measure.Xccd = ps1data[i].X; 198 stars[i].measure.Yccd = ps1data[i].Y; 199 stars[i].measure.dXccd = ShortPixels(ps1data[i].dX); 200 stars[i].measure.dYccd = ShortPixels(ps1data[i].dY); 201 202 stars[i].measure.posangle = ShortDegree(ps1data[i].posangle); 203 stars[i].measure.pltscale = ps1data[i].pltscale; 204 205 if ((ps1data[i].M >= 0.0) || isnan(ps1data[i].M)) { 206 stars[i].measure.M = NAN; 207 } else { 208 stars[i].measure.M = ps1data[i].M + ZeroPt; 209 } 210 stars[i].measure.dM = ps1data[i].dM; 211 stars[i].measure.dMcal = ps1data[i].dMcal; 212 stars[i].measure.Map = ps1data[i].Map + ZeroPt; 213 214 stars[i].measure.Sky = ps1data[i].sky; 215 stars[i].measure.dSky = ps1data[i].dSky; 216 217 stars[i].measure.psfChisq = ps1data[i].psfChisq; 218 stars[i].measure.psfQual = ps1data[i].psfQual; 219 stars[i].measure.psfNdof = ps1data[i].psfNdof; 220 stars[i].measure.psfNpix = ps1data[i].psfNpix; 221 stars[i].measure.crNsigma = ps1data[i].crNsigma; 222 stars[i].measure.extNsigma = ps1data[i].extNsigma; 223 224 stars[i].measure.FWx = ShortPixels(ps1data[i].fx); 225 stars[i].measure.FWy = ShortPixels(ps1data[i].fy); 226 stars[i].measure.theta = ShortDegree(ps1data[i].df); 227 228 stars[i].measure.Mxx = ShortPixels(ps1data[i].Mxx); 229 stars[i].measure.Mxy = ShortPixels(ps1data[i].Mxy); 230 stars[i].measure.Myy = ShortPixels(ps1data[i].Myy); 231 232 stars[i].measure.photFlags = ps1data[i].flags; 233 234 // this is may optionally be replaced by the internal sequence (see FilterStars.c) 235 stars[i].measure.detID = ps1data[i].detID; 236 237 // the Average fields and the following Measure fields are set in FilterStars after 238 // the image metadata is in hand: dR, dD, Mcal, dt, airmass, az, t, imageID, extID, 239 // averef is set in find_matches, dbFlags is zero on ingest. 240 241 // the following fields are currently not being set anywhere: t_msec 242 } 243 *nstars = Nstars; 244 return (stars); 245 } -
branches/cnb_branch_20090215/Ohana/src/addstar/src/ReadStarsSDSS.c
r20688 r21536 140 140 for (j = 0; j < NFILTER; j++) { 141 141 N = NFILTER*i + j; 142 stars[N].X = colc[N]; 143 stars[N].Y = rowc[N]; 144 stars[N].dX = colcErr[N]; 145 stars[N].dY = rowcErr[N]; 146 stars[N].M = psfCounts[N] + ZeroPt - zeropt[j]; 147 stars[N].dM = psfCountsErr[N]; 148 stars[N].Map = fiberCounts[N] + ZeroPt - zeropt[j]; 149 stars[N].Mpeak = NAN; 150 stars[N].sky = sky[N]; // adjust this to counts? 151 stars[N].dsky = skyErr[N]; 152 stars[N].fx = seeing[j]; // reported in arcsec? 153 stars[N].fy = seeing[j]; 154 stars[N].df = 0.0; 155 stars[N].psfChisq = prob_psf[N]; // XXX not really the correct value... 156 stars[N].psfQual = 0.0; 157 stars[N].crNsigma = 0.0; 158 stars[N].extNsigma = 0.0; 159 stars[N].detID = N; 160 stars[N].R = ra[i] + dCOS(dec[i]) * offsetRa[N] / 3600.0; 161 stars[N].D = dec[i] + offsetDec[N] / 3600.0; 162 stars[N].dR = NAN; 163 stars[N].dD = NAN; 164 stars[N].uR = 0.0; // I don't trust the SDSS proper motions 165 stars[N].uD = 0.0; // I don't trust the SDSS proper motions 166 stars[N].duR = 0.0; 167 stars[N].duD = 0.0; 168 stars[N].P = 0.0; 169 stars[N].dP = 0.0; 170 stars[N].Mcal = 0.0; 171 stars[N].t = tzero[j] + clockRate*rowc[N]; // time since row 0 172 stars[N].dt = 53.907456; // is this 2048*clockRate ? 142 InitStar (&stars[N]); 143 144 // any values not explicitly set are left at 0.0 145 stars[N].average.R = ra[i] + dCOS(dec[i]) * offsetRa[N] / 3600.0; 146 stars[N].average.D = dec[i] + offsetDec[N] / 3600.0; 147 stars[N].average.dR = NAN; 148 stars[N].average.dD = NAN; 149 150 stars[N].measure.Xccd = colc[N]; 151 stars[N].measure.Yccd = rowc[N]; 152 stars[N].measure.dXccd = ShortPixels(colcErr[N]); 153 stars[N].measure.dYccd = ShortPixels(rowcErr[N]); 154 stars[N].measure.M = psfCounts[N] + ZeroPt - zeropt[j]; 155 stars[N].measure.dM = psfCountsErr[N]; 156 stars[N].measure.Map = fiberCounts[N] + ZeroPt - zeropt[j]; 157 stars[N].measure.Sky = sky[N]; // adjust this to counts? 158 stars[N].measure.dSky = skyErr[N]; 159 stars[N].measure.FWx = ShortPixels(seeing[j]); // reported in arcsec? 160 stars[N].measure.FWy = ShortPixels(seeing[j]); 161 stars[N].measure.psfChisq = prob_psf[N]; // XXX not really the correct value... 162 stars[N].measure.detID = N; 163 stars[N].measure.t = tzero[j] + clockRate*rowc[N]; // time since row 0 164 stars[N].measure.dt = 53.907456; // is this 2048*clockRate ? 173 165 174 166 SetSDSSFlags (&stars[N], flags[N], flags2[N]); … … 182 174 double Latitude = 32.7803611755; // degrees 183 175 184 jd = ohana_sec_to_jd (stars[N]. t);176 jd = ohana_sec_to_jd (stars[N].measure.t); 185 177 sidtime = 15.0*ohana_lst (jd, Longitude); // sidtime in degrees 186 altaz (&alt, &az, sidtime - stars[N].R, stars[N].D, Latitude); 187 188 stars[N].airmass = 1.0 / dCOS(90.0 - alt); 189 stars[N].az = az; 190 191 stars[N].code = photcode[j]; 192 stars[N].found = -1; 193 stars[N].dophot = 0; 178 altaz (&alt, &az, sidtime - stars[N].average.R, stars[N].average.D, Latitude); 179 180 stars[N].measure.airmass = 1.0 / dCOS(90.0 - alt); 181 stars[N].measure.az = az; 182 stars[N].measure.photcode = photcode[j]; 194 183 } 195 184 } … … 202 191 strcpy (images[N].coords.ctype, "RA---TAN"); 203 192 204 images[N].coords.crval1 = stars[0]. R;205 images[N].coords.crval2 = stars[0]. D;193 images[N].coords.crval1 = stars[0].average.R; 194 images[N].coords.crval2 = stars[0].average.D; 206 195 207 images[N].coords.crpix1 = stars[0]. X;208 images[N].coords.crpix2 = stars[0]. Y;196 images[N].coords.crpix1 = stars[0].measure.Xccd; 197 images[N].coords.crpix2 = stars[0].measure.Yccd; 209 198 images[N].coords.cdelt1 = images[N].coords.cdelt2 = 0.4 / 3600.0; 210 199 … … 251 240 252 241 images[N].trate = clockRate * 1e-4; 253 images[N].secz = stars[0]. airmass;242 images[N].secz = stars[0].measure.airmass; 254 243 images[N].ccdnum = camcol; 255 244 … … 257 246 images[N].Mcal = 0.0; 258 247 images[N].Xm = NAN_S_SHORT; 259 images[N]. code= 0;248 images[N].flags = 0; 260 249 261 250 images[N].nstar = Nstars; … … 297 286 298 287 // XXX this is wrong, need to roll left to set the correct bit 299 if (flags1 & 0x00000002) star[0]. flags |= 0x0001; // BRIGHT - 1 1300 if (flags1 & 0x00000004) star[0]. flags |= 0x0002; // EDGE - 1 2301 if (flags1 & 0x00000008) star[0]. flags |= 0x0004; // BLENDED - 1 3302 if (flags1 & 0x00000010) star[0]. flags |= 0x0008; // CHILD - 1 4303 if (flags1 & 0x00000020) star[0]. flags |= 0x0010; // PEAKCENTER - 1 5304 if (flags1 & 0x00000040) star[0]. flags |= 0x0020; // NODEBLEND - 1 6305 if (flags1 & 0x00040000) star[0]. flags |= 0x0040; // SATUR - 1 18306 if (flags1 & 0x00080000) star[0]. flags |= 0x0080; // NOTCHECKED - 1 19307 if (flags1 & 0x10000000) star[0]. flags |= 0x0100; // BINNED1 - 1 28308 if (flags1 & 0x20000000) star[0]. flags |= 0x0200; // BINNED2 - 1 29309 if (flags1 & 0x40000000) star[0]. flags |= 0x0400; // BINNED4 - 1 30310 if (flags2 & 0x00000040) star[0]. flags |= 0x0800; // LOCAL_EDGE - 2 7311 if (flags2 & 0x00000800) star[0]. flags |= 0x1000; // INTERP_CENTER - 2 12312 if (flags2 & 0x00002000) star[0]. flags |= 0x2000; // DEBLEND_NOPEAK - 2 14313 if (flags2 & 0x02000000) star[0]. flags |= 0x4000; // NOTCHECKED_CENTER - 2 26288 if (flags1 & 0x00000002) star[0].measure.photFlags |= 0x0001; // BRIGHT - 1 1 289 if (flags1 & 0x00000004) star[0].measure.photFlags |= 0x0002; // EDGE - 1 2 290 if (flags1 & 0x00000008) star[0].measure.photFlags |= 0x0004; // BLENDED - 1 3 291 if (flags1 & 0x00000010) star[0].measure.photFlags |= 0x0008; // CHILD - 1 4 292 if (flags1 & 0x00000020) star[0].measure.photFlags |= 0x0010; // PEAKCENTER - 1 5 293 if (flags1 & 0x00000040) star[0].measure.photFlags |= 0x0020; // NODEBLEND - 1 6 294 if (flags1 & 0x00040000) star[0].measure.photFlags |= 0x0040; // SATUR - 1 18 295 if (flags1 & 0x00080000) star[0].measure.photFlags |= 0x0080; // NOTCHECKED - 1 19 296 if (flags1 & 0x10000000) star[0].measure.photFlags |= 0x0100; // BINNED1 - 1 28 297 if (flags1 & 0x20000000) star[0].measure.photFlags |= 0x0200; // BINNED2 - 1 29 298 if (flags1 & 0x40000000) star[0].measure.photFlags |= 0x0400; // BINNED4 - 1 30 299 if (flags2 & 0x00000040) star[0].measure.photFlags |= 0x0800; // LOCAL_EDGE - 2 7 300 if (flags2 & 0x00000800) star[0].measure.photFlags |= 0x1000; // INTERP_CENTER - 2 12 301 if (flags2 & 0x00002000) star[0].measure.photFlags |= 0x2000; // DEBLEND_NOPEAK - 2 14 302 if (flags2 & 0x02000000) star[0].measure.photFlags |= 0x4000; // NOTCHECKED_CENTER - 2 26 314 303 return (TRUE); 315 304 -
branches/cnb_branch_20090215/Ohana/src/addstar/src/ReadStarsTEXT.c
r16810 r21536 7 7 8 8 int j, N, Nextra, Ninstar, Nskip, Nbytes, nbytes; 9 int done ;9 int done, itmp; 10 10 char *buffer, *c, *c2; 11 double tmp ;11 double tmp, fx, fy, df; 12 12 double ZeroPt; 13 13 Stars *stars; … … 66 66 Nextra = nbytes % BYTES_STAR; 67 67 for (j = 0; (j < Ninstar) && (N < *nstars); j++, N++) { 68 dparse (&stars[N].X, 1, &buffer[j*BYTES_STAR]); 69 dparse (&stars[N].Y, 2, &buffer[j*BYTES_STAR]); 70 dparse (&stars[N].M, 3, &buffer[j*BYTES_STAR]); 71 if ((stars[N].M > ZeroPt) || isnan(stars[N].M)) { 72 stars[N].M = NAN; 68 InitStar (&stars[N]); 69 fparse (&stars[N].measure.Xccd, 1, &buffer[j*BYTES_STAR]); 70 fparse (&stars[N].measure.Yccd, 2, &buffer[j*BYTES_STAR]); 71 fparse (&stars[N].measure.M, 3, &buffer[j*BYTES_STAR]); 72 if ((stars[N].measure.M > ZeroPt) || isnan(stars[N].measure.M)) { 73 stars[N].measure.M = NAN; 73 74 } 74 75 75 76 /* cmp files carry dM in millimags */ 76 77 dparse (&tmp, 4, &buffer[j*BYTES_STAR]); 77 stars[N]. dM = 0.001*tmp;78 stars[N].measure.dM = 0.001*tmp; 78 79 80 // the dophot type information get pushed into the upper 2 bytes of photFlags 79 81 dparse (&tmp, 5, &buffer[j*BYTES_STAR]); 80 stars[N].dophot = tmp; 82 itmp = tmp; 83 stars[N].measure.photFlags = (itmp << 16); 81 84 82 85 // XXX I've removed the Mgal field from the measure.d table, and am using Map … … 87 90 88 91 // dparse (&stars[N].Mgal, 7, &buffer[j*BYTES_STAR]); 89 dparse (&stars[N].Map, 8, &buffer[j*BYTES_STAR]); 90 dparse (&stars[N].fx, 9, &buffer[j*BYTES_STAR]); 91 dparse (&stars[N].fy, 10, &buffer[j*BYTES_STAR]); 92 dparse (&stars[N].df, 11, &buffer[j*BYTES_STAR]); 92 fparse (&stars[N].measure.Map, 8, &buffer[j*BYTES_STAR]); 93 dparse (&fx, 9, &buffer[j*BYTES_STAR]); 94 dparse (&fy, 10, &buffer[j*BYTES_STAR]); 95 dparse (&df, 11, &buffer[j*BYTES_STAR]); 96 97 stars[N].measure.FWx = ShortPixels (fx); 98 stars[N].measure.FWy = ShortPixels (fy); 99 stars[N].measure.theta = ShortDegree (df); 93 100 } 94 101 } -
branches/cnb_branch_20090215/Ohana/src/addstar/src/SEDfit.c
r16810 r21536 164 164 outcat[0].average[Nave].measureOffset = Nmeas; 165 165 outcat[0].average[Nave].missingOffset = -1; 166 outcat[0].average[Nave]. code= 0;166 outcat[0].average[Nave].flags = 0; 167 167 168 168 for (j = 0; j < Nsec; j++) { … … 181 181 for (j = 0; valid && (j < Nmodel); j++) { 182 182 n = modelRow[j]; 183 outcat[0].measure[Nmeas].dR = 0.0;184 outcat[0].measure[Nmeas].dD = 0.0;185 outcat[0].measure[Nmeas].M = table[0].row[minFit.row][0].mags[n] + minFit.Md;186 outcat[0].measure[Nmeas].dM = 0.0;187 outcat[0].measure[Nmeas].Mcal = 0;188 outcat[0].measure[Nmeas].t = TIMEREF;189 outcat[0].measure[Nmeas].averef = Nave;190 outcat[0].measure[Nmeas].photcode = table[0].code[n];191 outcat[0].measure[Nmeas]. dophot= 0;192 outcat[0].measure[Nmeas].dbFlags = 0;193 outcat[0].measure[Nmeas].dt = 0xffff;194 195 outcat[0].measure[Nmeas].airmass = 0;196 outcat[0].measure[Nmeas].FWx = NAN_S_SHORT;197 outcat[0].measure[Nmeas].FWy = NAN_S_SHORT;198 outcat[0].measure[Nmeas].theta = NAN_S_SHORT;183 outcat[0].measure[Nmeas].dR = 0.0; 184 outcat[0].measure[Nmeas].dD = 0.0; 185 outcat[0].measure[Nmeas].M = table[0].row[minFit.row][0].mags[n] + minFit.Md; 186 outcat[0].measure[Nmeas].dM = 0.0; 187 outcat[0].measure[Nmeas].Mcal = 0; 188 outcat[0].measure[Nmeas].t = TIMEREF; 189 outcat[0].measure[Nmeas].averef = Nave; 190 outcat[0].measure[Nmeas].photcode = table[0].code[n]; 191 outcat[0].measure[Nmeas].photFlags = 0; 192 outcat[0].measure[Nmeas].dbFlags = 0; 193 outcat[0].measure[Nmeas].dt = 0xffff; 194 195 outcat[0].measure[Nmeas].airmass = 0; 196 outcat[0].measure[Nmeas].FWx = NAN_S_SHORT; 197 outcat[0].measure[Nmeas].FWy = NAN_S_SHORT; 198 outcat[0].measure[Nmeas].theta = NAN_S_SHORT; 199 199 200 200 outcat[0].average[Nave].Nmeasure++; -
branches/cnb_branch_20090215/Ohana/src/addstar/src/SkyListForStars.c
r16040 r21536 1 1 # include "addstar.h" 2 3 void sort_stars_ra (Stars *stars, int N) { 4 5 # define SWAPFUNC(A,B){ Stars tmp; tmp = stars[A]; stars[A] = stars[B]; stars[B] = tmp; } 6 # define COMPARE(A,B)(stars[A].average.R < stars[B].average.R) 7 8 OHANA_SORT (N, COMPARE, SWAPFUNC); 9 10 # undef SWAPFUNC 11 # undef COMPARE 12 13 } 2 14 3 15 SkyList *SkyListForStars (SkyTable *table, int depth, Stars *stars, int Nstars) { … … 17 29 sort_stars_ra (stars, Nstars); /* sort by RA */ 18 30 for (i = 0; i < Nstars; i++) { 19 if (stars[i].found ) continue;20 here = SkyRegionByPoint (table, depth, stars[i]. R, stars[i].D);21 stars[i].found = TRUE;31 if (stars[i].found == -2) continue; 32 here = SkyRegionByPoint (table, depth, stars[i].average.R, stars[i].average.D); 33 stars[i].found = -2; 22 34 /* search forward for all contained stars */ 23 35 for (j = i; j < Nstars; j++) { 24 if (stars[j]. R >= here[0].regions[0][0].Rmax) break;25 if (stars[j]. R < here[0].regions[0][0].Rmin) break;26 if (stars[j]. D < here[0].regions[0][0].Dmin) continue;27 if (stars[j]. D >= here[0].regions[0][0].Dmax) continue;28 stars[j].found = TRUE;36 if (stars[j].average.R >= here[0].regions[0][0].Rmax) break; 37 if (stars[j].average.R < here[0].regions[0][0].Rmin) break; 38 if (stars[j].average.D < here[0].regions[0][0].Dmin) continue; 39 if (stars[j].average.D >= here[0].regions[0][0].Dmax) continue; 40 stars[j].found = -2; 29 41 } 30 42 list[0].regions[Nr] = here[0].regions[0]; -
branches/cnb_branch_20090215/Ohana/src/addstar/src/UpdateImageIDs.c
r20182 r21536 43 43 44 44 for (i = 0; i < Nstars; i++) { 45 stars[i]. imageID += imageID;45 stars[i].measure.imageID += imageID; 46 46 } 47 47 48 48 imageID += Nimages; 49 49 status = gfits_modify (&db.header, "IMAGEID", "%u", 1, imageID); 50 51 50 52 51 if (isEmpty) { -
branches/cnb_branch_20090215/Ohana/src/addstar/src/addstar.c
r18721 r21536 135 135 break; 136 136 case M_REFCAT: 137 stars = gref cat(argv[1], skylist[0].regions[i], options.photcode, &Nstars);137 stars = greference (argv[1], skylist[0].regions[i], options.photcode, &Nstars); 138 138 case M_REFLIST: 139 139 subset = find_subset (skylist[0].regions[i], stars, Nstars, &Nsubset); -
branches/cnb_branch_20090215/Ohana/src/addstar/src/airmass.c
r8642 r21536 1 1 # include "addstar.h" 2 2 3 static int AirmassQuality = FALSE;3 static int AirmassQuality = TRUE; 4 4 5 5 void SetAirmassQuality (int quality) { … … 25 25 return (secz); 26 26 } 27 28 // ha/dec -> az 29 float azimuth (double ha, double dec, double latitude) { 30 31 double rdec, rlat, rha; 32 double sinh, cosh; 33 float az; 34 35 rdec = RAD_DEG*dec; 36 rha = RAD_DEG*ha; 37 rlat = RAD_DEG*latitude; 38 39 sinh = - cos (rdec) * sin (rha); 40 cosh = sin (rdec) * cos (rlat) - cos (rdec) * cos (rha) * sin (rlat); 41 42 az = DEG_RAD * atan2 (sinh, cosh); 43 44 return az; 45 } -
branches/cnb_branch_20090215/Ohana/src/addstar/src/args.c
r20183 r21536 28 28 remove_argument (N, &argc, argv); 29 29 } 30 if ((N = get_argument (argc, argv, "-resort"))) { 31 options.mode = M_RESORT; 32 remove_argument (N, &argc, argv); 33 } 30 34 if ((N = get_argument (argc, argv, "-fakeimage"))) { 31 35 options.mode = M_FAKEIMAGE; … … 36 40 remove_argument (N, &argc, argv); 37 41 FAKE_THETA = atof (argv[N]); 38 remove_argument (N, &argc, argv);39 }40 if ((N = get_argument (argc, argv, "-resort"))) {41 options.mode = M_RESORT;42 42 remove_argument (N, &argc, argv); 43 43 } … … 221 221 /*** optional situations ***/ 222 222 /* choose high quality airmass vs low quality airmass (per-star vs per-image) */ 223 QUALITY_AIRMASS = FALSE;223 QUALITY_AIRMASS = TRUE; 224 224 if ((N = get_argument (argc, argv, "-quality-airmass"))) { 225 225 remove_argument (N, &argc, argv); 226 226 QUALITY_AIRMASS = TRUE; 227 } 228 if ((N = get_argument (argc, argv, "-quick-airmass"))) { 229 remove_argument (N, &argc, argv); 230 QUALITY_AIRMASS = FALSE; 227 231 } 228 232 /* choose high quality airmass vs low quality airmass (per-star vs per-image) */ … … 310 314 311 315 fprintf (stderr, "USAGE: addstar (filename)\n"); 316 fprintf (stderr, "USAGE: addstar -list (filename)\n"); 312 317 fprintf (stderr, "USAGE: addstar -cat (catalog)\n"); 313 318 fprintf (stderr, "USAGE: addstar -ref (filename)\n"); 314 319 fprintf (stderr, "USAGE: addstar -fakeimage (ra) (dec) (theta) (name)\n"); 315 320 fprintf (stderr, "USAGE: addstar -resort (SkyRegion)\n"); 321 fprintf (stderr, "USAGE: addstar -ppm (filename)\n"); 316 322 exit (2); 317 323 } … … 322 328 fprintf (stderr, " addstar (filename)\n"); 323 329 fprintf (stderr, " add specified image (cmp format) to database\n\n"); 330 fprintf (stderr, " addstar -list (filename)\n"); 331 fprintf (stderr, " add list of images (cmp format) to database\n\n"); 324 332 fprintf (stderr, " addstar -ref (filename)"); 325 333 fprintf (stderr, " add ASCII data (ra dec mag dmag) to database\n\n"); … … 328 336 fprintf (stderr, " addstar -resort (SkyRegion)"); 329 337 fprintf (stderr, " perform measure sorting for the specified catalog\n\n"); 338 fprintf (stderr, " addstar -fakeimage (ra) (dec) (theta) (name)"); 339 fprintf (stderr, " insert a fake image in the db\n\n"); 340 fprintf (stderr, " addstar -pmm (filename)"); 341 fprintf (stderr, " insert pmm table into database\n\n"); 330 342 331 343 fprintf (stderr, " optional flags:\n"); … … 340 352 fprintf (stderr, " -missed : skipped 'missed' entries\n"); 341 353 fprintf (stderr, " -replace : replace time/photcode measurements (no duplication)\n"); 342 fprintf (stderr, " -closest : use closest-star algorith\n"); 354 fprintf (stderr, " -closest : use closest-star algorith (default)\n"); 355 fprintf (stderr, " -all-matches : use all-matches algorith\n"); 343 356 fprintf (stderr, " -nosort : don't re-sort the measure entries (improves speed)\n"); 344 357 fprintf (stderr, " -update : only update the new rows (forces -nosort)\n"); 358 fprintf (stderr, " -force-sort : \n"); 345 359 fprintf (stderr, " -image : only insert image data\n"); 346 360 fprintf (stderr, " -cal : perform zero-point calibration\n"); 361 fprintf (stderr, " -excal : apply supplied zero-point calibration\n"); 362 fprintf (stderr, " -incal : perform zero-point calibration\n"); 363 fprintf (stderr, " -quality-airmass : use per-star airmass values (default)\n"); 364 fprintf (stderr, " -quick-airmass : use per-image airmass values\n"); 365 fprintf (stderr, " -subpix : apply subpixel corrections\n"); 347 366 fprintf (stderr, " -skyprobe : specify skyprobe mode\n"); 367 fprintf (stderr, " -2massquality : define 2MASS quality flags to keep\n"); 348 368 fprintf (stderr, " -accept : accept bad astrometry from header\n"); 349 369 fprintf (stderr, " -accept-astrom : accept bad astrometry from header\n"); 350 370 fprintf (stderr, " -accept-motion : accept proper-motion data from reference\n"); 371 fprintf (stderr, " -accept-time : use TZERO supplied in header\n"); 372 fprintf (stderr, " -no-stars : skip the stars\n"); 351 373 fprintf (stderr, " -force : force read of database with inconsistent info\n"); 374 fprintf (stderr, " -textmode : force textmode for file (ignore header clues)\n"); 352 375 fprintf (stderr, " -v : verbose mode\n"); 353 376 fprintf (stderr, " -dump (mode) : output test data. Currently supported values for mode are: 'rawdata', 'cal'.\n"); -
branches/cnb_branch_20090215/Ohana/src/addstar/src/dump.c
r3404 r21536 11 11 fprintf (f, "%4d %10.6f %10.6f %8.2f %8.2f %7.2f %7.2f\n", 12 12 i, 13 stars[i]. R, stars[i].D,14 stars[i]. X, stars[i].Y,15 stars[i]. M, stars[i].dM);13 stars[i].average.R, stars[i].average.D, 14 stars[i].measure.Xccd, stars[i].measure.Yccd, 15 stars[i].measure.M, stars[i].measure.dM); 16 16 } 17 17 -
branches/cnb_branch_20090215/Ohana/src/addstar/src/fakeimage.c
r16983 r21536 129 129 image[i+1].ccdnum = 0xff; 130 130 131 image[i+1].Mcal = 0.0;132 image[i+1].Xm = NAN_S_SHORT;133 image[i+1]. code= 0;131 image[i+1].Mcal = 0.0; 132 image[i+1].Xm = NAN_S_SHORT; 133 image[i+1].flags = 0; 134 134 135 135 image[i+1].nstar = 0; … … 189 189 image[0].Mcal = 0.0; 190 190 image[0].Xm = NAN_S_SHORT; 191 image[0]. code= 0;191 image[0].flags = 0; 192 192 image[0].nstar = 0; 193 193 image[0].Myyyy = 0; -
branches/cnb_branch_20090215/Ohana/src/addstar/src/find_matches.c
r20936 r21536 62 62 strcpy (tcoords.ctype, "RA---ARC"); 63 63 64 /* build spatial index (RA sort) */64 /* build spatial index (RA sort) referencing input array sequence */ 65 65 Nstars = 0; 66 66 for (i = 0; i < NstarsIn; i++) { 67 status = RD_to_XY (&X1[Nstars], &Y1[Nstars], stars[i]. R, stars[i].D, &tcoords);67 status = RD_to_XY (&X1[Nstars], &Y1[Nstars], stars[i].average.R, stars[i].average.D, &tcoords); 68 68 if (!status) continue; 69 69 N1[Nstars] = i; … … 104 104 /** find matched stars **/ 105 105 for (i = j = 0; (i < Nstars) && (j < Nave); ) { 106 if (!finite(X1[i]) || !finite(Y1[i])) {106 if (!finite(X1[i]) || !finite(Y1[i])) { 107 107 i++; 108 108 continue; … … 147 147 148 148 /** add measurements for this star **/ 149 /** dR,dD now represent arcsec **/ 150 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N].R); 149 150 // set the new measurements 151 catalog[0].measure[Nmeas] = stars[N].measure; 152 153 // the following measure elements cannot be set until here: 154 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N].average.R); 155 catalog[0].measure[Nmeas].dD = 3600.0*(catalog[0].average[n].D - stars[N].average.D); 156 catalog[0].measure[Nmeas].dbFlags = 0; 157 catalog[0].measure[Nmeas].averef = n; // this must be an absolute sequence number, if partial average is loaded 158 catalog[0].measure[Nmeas].objID = catalog[0].average[n].objID; 159 catalog[0].measure[Nmeas].catID = catalog[0].catID; 160 161 // rationalize dR: 151 162 if (catalog[0].measure[Nmeas].dR > +180.0*3600.0) { 152 163 // average on high end of boundary, move star up 153 stars[N]. R += 360.0;154 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N]. R);164 stars[N].average.R += 360.0; 165 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N].average.R); 155 166 } 156 167 if (catalog[0].measure[Nmeas].dR < -180.0*3600.0) { 157 168 // average on low end of boundary, move star down 158 stars[N]. R -= 360.0;159 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N]. R);169 stars[N].average.R -= 360.0; 170 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N].average.R); 160 171 } 161 172 if (fabs(catalog[0].measure[Nmeas].dR) > 10*RADIUS) { 162 173 fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n", 163 174 catalog[0].average[n].R, catalog[0].average[n].D, 164 stars[N]. R, stars[N].D,175 stars[N].average.R, stars[N].average.D, 165 176 X1[i], X2[J], 166 177 Y1[i], Y2[J]); 167 178 } 168 catalog[0].measure[Nmeas].dD = 3600.0*(catalog[0].average[n].D - stars[N].D); 169 170 catalog[0].measure[Nmeas].Xccd = stars[N].X; 171 catalog[0].measure[Nmeas].Yccd = stars[N].Y; 172 173 catalog[0].measure[Nmeas].M = stars[N].M; 174 catalog[0].measure[Nmeas].dM = stars[N].dM; /* error in input files stored in thousandths of mag */ 175 catalog[0].measure[Nmeas].Mcal = stars[N].Mcal; 176 catalog[0].measure[Nmeas].t = stars[N].t; 177 catalog[0].measure[Nmeas].averef = n; /* this must be an absolute sequence number, if partial average is loaded */ 178 catalog[0].measure[Nmeas].photcode = stars[N].code; /* photcode */ 179 catalog[0].measure[Nmeas].dophot = stars[N].dophot; 180 catalog[0].measure[Nmeas].dbFlags = 0; 181 catalog[0].measure[Nmeas].dt = stars[N].dt; 182 catalog[0].measure[Nmeas].airmass = stars[N].airmass; 183 184 catalog[0].measure[Nmeas].photFlags = stars[N].flags; 185 catalog[0].measure[Nmeas].qPSF = stars[N].psfQual; 186 catalog[0].measure[Nmeas].psfChisq = stars[N].psfChisq; 187 catalog[0].measure[Nmeas].crNsigma = stars[N].crNsigma; 188 catalog[0].measure[Nmeas].extNsigma = stars[N].extNsigma; 189 catalog[0].measure[Nmeas].Sky = stars[N].sky; 190 catalog[0].measure[Nmeas].dSky = stars[N].dsky; 191 192 catalog[0].measure[Nmeas].stargal = 0; // XXX not yet set 193 194 catalog[0].measure[Nmeas].detID = stars[N].detID; 195 catalog[0].measure[Nmeas].imageID = stars[N].imageID; 196 197 catalog[0].measure[Nmeas].dXccd = stars[N].dX; 198 catalog[0].measure[Nmeas].dYccd = stars[N].dY; 199 200 catalog[0].measure[Nmeas].Map = stars[N].Map; 201 catalog[0].measure[Nmeas].FWx = 100*stars[N].fx; 202 catalog[0].measure[Nmeas].FWy = 100*stars[N].fy; 203 catalog[0].measure[Nmeas].theta = (0xffff/360.0)*stars[N].df; 204 179 205 180 /* adds the measurement to the calibration if appropriate color terms are found */ 206 181 /* we call this before (optionally) setting the average magnitude to avoid auto-correlations */ … … 266 241 N = N1[i]; 267 242 if (stars[N].found >= 0) continue; 268 if (!IN_REGION (stars[N].R, stars[N].D)) continue; 269 270 catalog[0].average[Nave].R = stars[N].R; 271 catalog[0].average[Nave].D = stars[N].D; 272 catalog[0].average[Nave].Xp = 0; 243 if (!IN_REGION (stars[N].average.R, stars[N].average.D)) continue; 244 245 catalog[0].average[Nave].R = stars[N].average.R; 246 catalog[0].average[Nave].D = stars[N].average.D; 247 catalog[0].average[Nave].dR = 0; 248 catalog[0].average[Nave].dD = 0; 249 273 250 catalog[0].average[Nave].Nmeasure = 1; 274 251 catalog[0].average[Nave].Nmissing = 0; 252 catalog[0].average[Nave].Nextend = 0; 253 275 254 catalog[0].average[Nave].measureOffset = Nmeas; 276 255 catalog[0].average[Nave].missingOffset = -1; 277 catalog[0].average[Nave].code = 0; 278 279 catalog[0].average[Nave].dR = 0; 280 catalog[0].average[Nave].dD = 0; 281 catalog[0].average[Nave].uR = 0; 282 catalog[0].average[Nave].uD = 0; 283 catalog[0].average[Nave].duR = 0; 284 catalog[0].average[Nave].duD = 0; 285 catalog[0].average[Nave].P = 0; 286 catalog[0].average[Nave].dP = 0; 287 288 catalog[0].average[Nave].objID = objID; 289 catalog[0].average[Nave].catID = catID; 256 catalog[0].average[Nave].extendOffset = -1; 257 258 catalog[0].average[Nave].uR = 0; 259 catalog[0].average[Nave].uD = 0; 260 catalog[0].average[Nave].duR = 0; 261 catalog[0].average[Nave].duD = 0; 262 catalog[0].average[Nave].P = 0; 263 catalog[0].average[Nave].dP = 0; 264 265 catalog[0].average[Nave].Xp = 0; 266 catalog[0].average[Nave].ChiSq = 0.0; 267 catalog[0].average[Nave].Npos = 0; 268 269 catalog[0].average[Nave].objID = objID; 270 catalog[0].average[Nave].catID = catID; 271 catalog[0].average[Nave].flags = 0; 272 290 273 objID ++; 291 274 292 275 for (j = 0; j < Nsecfilt; j++) { 293 catalog[0].secfilt[Nave*Nsecfilt+j].M = NAN; 294 catalog[0].secfilt[Nave*Nsecfilt+j].dM = NAN; 295 catalog[0].secfilt[Nave*Nsecfilt+j].Xm = NAN_S_SHORT; 296 } 297 298 catalog[0].measure[Nmeas].Xccd = stars[N].X; 299 catalog[0].measure[Nmeas].Yccd = stars[N].Y; 300 276 catalog[0].secfilt[Nave*Nsecfilt+j].M = NAN; 277 catalog[0].secfilt[Nave*Nsecfilt+j].dM = NAN; 278 catalog[0].secfilt[Nave*Nsecfilt+j].Xm = NAN_S_SHORT; 279 catalog[0].secfilt[Nave*Nsecfilt+j].M_20 = NAN_S_SHORT; 280 catalog[0].secfilt[Nave*Nsecfilt+j].M_80 = NAN_S_SHORT; 281 catalog[0].secfilt[Nave*Nsecfilt+j].Ncode = 0; 282 catalog[0].secfilt[Nave*Nsecfilt+j].Nused = 0; 283 } 284 285 // supply the measurments from this detection 286 catalog[0].measure[Nmeas] = stars[N].measure; 287 288 // the following measure elements cannot be set until here: 301 289 catalog[0].measure[Nmeas].dR = 0.0; 302 290 catalog[0].measure[Nmeas].dD = 0.0; 303 catalog[0].measure[Nmeas].M = stars[N].M;304 catalog[0].measure[Nmeas].dM = stars[N].dM;305 catalog[0].measure[Nmeas].Mcal = stars[N].Mcal;306 catalog[0].measure[Nmeas].t = stars[N].t;307 catalog[0].measure[Nmeas].averef = Nave; /* XXX EAM : must be absolute Nave if partial read */308 catalog[0].measure[Nmeas].photcode = stars[N].code; /* photcode */309 catalog[0].measure[Nmeas].dophot = stars[N].dophot;310 291 catalog[0].measure[Nmeas].dbFlags = 0; 311 catalog[0].measure[Nmeas].dt = stars[N].dt; 312 catalog[0].measure[Nmeas].airmass = stars[N].airmass; 313 314 catalog[0].measure[Nmeas].photFlags = stars[N].flags; 315 catalog[0].measure[Nmeas].qPSF = stars[N].psfQual; 316 catalog[0].measure[Nmeas].psfChisq = stars[N].psfChisq; 317 catalog[0].measure[Nmeas].crNsigma = stars[N].crNsigma; 318 catalog[0].measure[Nmeas].extNsigma = stars[N].extNsigma; 319 catalog[0].measure[Nmeas].Sky = stars[N].sky; 320 catalog[0].measure[Nmeas].dSky = stars[N].dsky; 321 322 catalog[0].measure[Nmeas].stargal = 0; // XXX not yet set 323 324 catalog[0].measure[Nmeas].detID = stars[N].detID; 325 catalog[0].measure[Nmeas].imageID = stars[N].imageID; 326 327 catalog[0].measure[Nmeas].dXccd = stars[N].dX; 328 catalog[0].measure[Nmeas].dYccd = stars[N].dY; 329 330 catalog[0].measure[Nmeas].Map = stars[N].Map; 331 catalog[0].measure[Nmeas].FWx = 100*stars[N].fx; 332 catalog[0].measure[Nmeas].FWy = 100*stars[N].fy; 333 catalog[0].measure[Nmeas].theta = (0xffff/360.0)*stars[N].df; 334 /* XXX replace df here with theta, right? */ 292 catalog[0].measure[Nmeas].averef = Nave; // XXX EAM : must be absolute Nave if partial read 293 catalog[0].measure[Nmeas].objID = catalog[0].average[Nave].objID; 294 catalog[0].measure[Nmeas].catID = catalog[0].catID; 335 295 336 296 /* set the average magnitude if not already set and the photcode.equiv is not 0 */ -
branches/cnb_branch_20090215/Ohana/src/addstar/src/find_matches_closest.c
r20936 r21536 7 7 double *X1, *Y1, *X2, *Y2; 8 8 double dX, dY, dR; 9 int *N1, *N2, *next_meas , *next_miss;10 int Nave, NAVE, Nmeas, NMEAS, Nm iss, NMISS, Nmatch;9 int *N1, *N2, *next_meas; 10 int Nave, NAVE, Nmeas, NMEAS, Nmatch; 11 11 int Nsecfilt, Nsec; 12 12 unsigned int objID, catID; … … 37 37 Nmatch = 0; 38 38 NMEAS = Nmeas = catalog[0].Nmeasure; 39 NMISS = Nmiss = catalog[0].Nmissing;40 39 41 40 // current max obj ID for this catalog … … 66 65 Nstars = 0; 67 66 for (i = 0; i < NstarsIn; i++) { 68 status = RD_to_XY (&X1[Nstars], &Y1[Nstars], stars[i]. R, stars[i].D, &tcoords);67 status = RD_to_XY (&X1[Nstars], &Y1[Nstars], stars[i].average.R, stars[i].average.D, &tcoords); 69 68 if (!status) continue; 70 69 N1[Nstars] = i; … … 92 91 if (Nave > 1) sort_coords_index (X2, Y2, N2, Nave); 93 92 94 /* set up pointers for linked list of measure , missing*/93 /* set up pointers for linked list of measure */ 95 94 if (catalog[0].sorted && (catalog[0].Nmeasure == catalog[0].Nmeas_disk)) { 96 95 // this version is only valid if we have done a full catalog load, and if the catalog … … 100 99 next_meas = build_measure_links (catalog[0].average, Nave, catalog[0].measure, Nmeas); 101 100 } 102 next_miss = init_missing_links (catalog[0].average, Nave, catalog[0].missing, Nmiss);103 /* missing MUST be written 'sorted', or not at all */104 101 105 102 /* choose a radius for matches */ … … 167 164 168 165 /** add measurements for this star **/ 166 167 // set the new measurements 168 catalog[0].measure[Nmeas] = stars[N].measure; 169 169 170 /** dR,dD now represent arcsec **/ 170 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N].R); 171 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N].average.R); 172 catalog[0].measure[Nmeas].dD = 3600.0*(catalog[0].average[n].D - stars[N].average.D); 173 catalog[0].measure[Nmeas].dbFlags = 0; 174 catalog[0].measure[Nmeas].averef = n; 175 catalog[0].measure[Nmeas].objID = catalog[0].average[n].objID; 176 catalog[0].measure[Nmeas].catID = catalog[0].catID; 177 178 // rationalize dR 171 179 if (catalog[0].measure[Nmeas].dR > +180.0*3600.0) { 172 180 // average on high end of boundary, move star up 173 stars[N]. R += 360.0;174 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N]. R);181 stars[N].average.R += 360.0; 182 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N].average.R); 175 183 } 176 184 if (catalog[0].measure[Nmeas].dR < -180.0*3600.0) { 177 185 // average on low end of boundary, move star down 178 stars[N]. R -= 360.0;179 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N]. R);186 stars[N].average.R -= 360.0; 187 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N].average.R); 180 188 } 181 189 if (fabs(catalog[0].measure[Nmeas].dR) > 10*RADIUS) { 182 190 fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n", 183 191 catalog[0].average[n].R, catalog[0].average[n].D, 184 stars[N]. R, stars[N].D,192 stars[N].average.R, stars[N].average.D, 185 193 X1[i], X2[Jmin], 186 194 Y1[i], Y2[Jmin]); 187 195 } 188 catalog[0].measure[Nmeas].dD = 3600.0*(catalog[0].average[n].D - stars[N].D); 189 190 /* XXX need to add dX, dY : need to load into stars[N].dX,dY */ 191 /* XXX need to add stargal, Sky, dSky, qPSF, detID, imageID */ 192 catalog[0].measure[Nmeas].Xccd = stars[N].X; 193 catalog[0].measure[Nmeas].Yccd = stars[N].Y; 194 195 catalog[0].measure[Nmeas].M = stars[N].M; 196 catalog[0].measure[Nmeas].dM = stars[N].dM; /* error in input files stored in thousandths of mag */ 197 catalog[0].measure[Nmeas].Mcal = stars[N].Mcal; 198 catalog[0].measure[Nmeas].t = stars[N].t; 199 catalog[0].measure[Nmeas].averef = n; 200 catalog[0].measure[Nmeas].photcode = stars[N].code; /* photcode */ 201 catalog[0].measure[Nmeas].dophot = stars[N].dophot; 202 catalog[0].measure[Nmeas].dbFlags = 0; 203 catalog[0].measure[Nmeas].dt = stars[N].dt; 204 catalog[0].measure[Nmeas].airmass = stars[N].airmass; 205 206 catalog[0].measure[Nmeas].photFlags = stars[N].flags; 207 catalog[0].measure[Nmeas].qPSF = stars[N].psfQual; 208 catalog[0].measure[Nmeas].psfChisq = stars[N].psfChisq; 209 catalog[0].measure[Nmeas].crNsigma = stars[N].crNsigma; 210 catalog[0].measure[Nmeas].extNsigma = stars[N].extNsigma; 211 catalog[0].measure[Nmeas].Sky = stars[N].sky; 212 catalog[0].measure[Nmeas].dSky = stars[N].dsky; 213 214 catalog[0].measure[Nmeas].stargal = 0; 215 216 catalog[0].measure[Nmeas].detID = stars[N].detID; 217 catalog[0].measure[Nmeas].imageID = stars[N].imageID; 218 219 catalog[0].measure[Nmeas].dXccd = stars[N].dX; 220 catalog[0].measure[Nmeas].dYccd = stars[N].dY; 221 222 catalog[0].measure[Nmeas].Map = stars[N].Map; 223 224 // XXX saturate range for FWx, FWy, theta 225 // XXX convert to unsigned int for these... 226 catalog[0].measure[Nmeas].FWx = 100*stars[N].fx; 227 catalog[0].measure[Nmeas].FWy = 100*stars[N].fy; 228 catalog[0].measure[Nmeas].theta = (0xffff/360.0)*stars[N].df; 229 196 197 198 /* adds the measurement to the calibration if appropriate color terms are found */ 199 /* we call this before (optionally) setting the average magnitude to avoid auto-correlations */ 200 if (options.calibrate) { 201 AddToCalibration (&catalog[0].average[n], &catalog[0].secfilt[n*Nsecfilt], catalog[0].measure, &catalog[0].measure[Nmeas], next_meas, N); 202 } 203 230 204 /* set the average magnitude if not already set and the photcode.equiv is not 0 */ 231 205 /* in UPDATE mode, this value is not saved; use relphot to recalculate */ … … 234 208 catalog[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas]); 235 209 } 236 }237 238 /* adds the measurement to the calibration if appropriate color terms are found */239 if (options.calibrate) {240 AddToCalibration (&catalog[0].average[n], &catalog[0].secfilt[n*Nsecfilt], catalog[0].measure, &catalog[0].measure[Nmeas], next_meas, N);241 210 } 242 211 … … 270 239 N = N1[i]; 271 240 if (stars[N].found >= 0) continue; 272 if (!IN_REGION (stars[N].R, stars[N].D)) continue; 273 274 catalog[0].average[Nave].R = stars[N].R; 275 catalog[0].average[Nave].D = stars[N].D; 276 catalog[0].average[Nave].Xp = 0; 241 if (!IN_REGION (stars[N].average.R, stars[N].average.D)) continue; 242 243 catalog[0].average[Nave].R = stars[N].average.R; 244 catalog[0].average[Nave].D = stars[N].average.D; 245 catalog[0].average[Nave].dR = 0; 246 catalog[0].average[Nave].dD = 0; 247 277 248 catalog[0].average[Nave].Nmeasure = 1; 278 249 catalog[0].average[Nave].Nmissing = 0; 250 catalog[0].average[Nave].Nextend = 0; 251 279 252 catalog[0].average[Nave].measureOffset = Nmeas; 280 253 catalog[0].average[Nave].missingOffset = -1; 281 catalog[0].average[Nave].code = 0; 282 283 catalog[0].average[Nave].dR = 0; 284 catalog[0].average[Nave].dD = 0; 285 catalog[0].average[Nave].uR = 0; 286 catalog[0].average[Nave].uD = 0; 287 catalog[0].average[Nave].duR = 0; 288 catalog[0].average[Nave].duD = 0; 289 catalog[0].average[Nave].P = 0; 290 catalog[0].average[Nave].dP = 0; 291 292 catalog[0].average[Nave].objID = objID; 293 catalog[0].average[Nave].catID = catID; 254 catalog[0].average[Nave].extendOffset = -1; 255 256 catalog[0].average[Nave].uR = 0; 257 catalog[0].average[Nave].uD = 0; 258 catalog[0].average[Nave].duR = 0; 259 catalog[0].average[Nave].duD = 0; 260 catalog[0].average[Nave].P = 0; 261 catalog[0].average[Nave].dP = 0; 262 263 catalog[0].average[Nave].Xp = 0; 264 catalog[0].average[Nave].ChiSq = 0.0; 265 catalog[0].average[Nave].Npos = 0; 266 267 catalog[0].average[Nave].objID = objID; 268 catalog[0].average[Nave].catID = catID; 269 catalog[0].average[Nave].flags = 0; 270 294 271 objID ++; 295 272 … … 298 275 catalog[0].secfilt[Nave*Nsecfilt+j].dM = NAN; 299 276 catalog[0].secfilt[Nave*Nsecfilt+j].Xm = NAN_S_SHORT; 300 } 301 302 catalog[0].measure[Nmeas].Xccd = stars[N].X; 303 catalog[0].measure[Nmeas].Yccd = stars[N].Y; 304 277 catalog[0].secfilt[Nave*Nsecfilt+j].M_20 = NAN_S_SHORT; 278 catalog[0].secfilt[Nave*Nsecfilt+j].M_80 = NAN_S_SHORT; 279 catalog[0].secfilt[Nave*Nsecfilt+j].Ncode = 0; 280 catalog[0].secfilt[Nave*Nsecfilt+j].Nused = 0; 281 } 282 283 // supply the measurments from this detection 284 catalog[0].measure[Nmeas] = stars[N].measure; 285 286 // the following measure elements cannot be set until here: 305 287 catalog[0].measure[Nmeas].dR = 0.0; 306 288 catalog[0].measure[Nmeas].dD = 0.0; 307 catalog[0].measure[Nmeas].M = stars[N].M; 308 catalog[0].measure[Nmeas].dM = stars[N].dM; 309 catalog[0].measure[Nmeas].Mcal = stars[N].Mcal; 310 catalog[0].measure[Nmeas].t = stars[N].t; 289 catalog[0].measure[Nmeas].dbFlags = 0; 311 290 catalog[0].measure[Nmeas].averef = Nave; 312 catalog[0].measure[Nmeas].photcode = stars[N].code; /* photcode */ 313 catalog[0].measure[Nmeas].dophot = stars[N].dophot; 314 catalog[0].measure[Nmeas].dbFlags = 0; 315 catalog[0].measure[Nmeas].dt = stars[N].dt; 316 catalog[0].measure[Nmeas].airmass = stars[N].airmass; 317 318 catalog[0].measure[Nmeas].photFlags = stars[N].flags; 319 catalog[0].measure[Nmeas].qPSF = stars[N].psfQual; 320 catalog[0].measure[Nmeas].psfChisq = stars[N].psfChisq; 321 catalog[0].measure[Nmeas].crNsigma = stars[N].crNsigma; 322 catalog[0].measure[Nmeas].extNsigma = stars[N].extNsigma; 323 catalog[0].measure[Nmeas].Sky = stars[N].sky; 324 catalog[0].measure[Nmeas].dSky = stars[N].dsky; 325 326 catalog[0].measure[Nmeas].stargal = 0; 327 328 catalog[0].measure[Nmeas].detID = stars[N].detID; 329 catalog[0].measure[Nmeas].imageID = stars[N].imageID; 330 331 catalog[0].measure[Nmeas].dXccd = stars[N].dX; 332 catalog[0].measure[Nmeas].dYccd = stars[N].dY; 333 334 catalog[0].measure[Nmeas].Map = stars[N].Map; 335 catalog[0].measure[Nmeas].FWx = 100*stars[N].fx; 336 catalog[0].measure[Nmeas].FWy = 100*stars[N].fy; 337 catalog[0].measure[Nmeas].theta = (0xffff/360.0)*stars[N].df; 291 catalog[0].measure[Nmeas].objID = catalog[0].average[Nave].objID; 292 catalog[0].measure[Nmeas].catID = catalog[0].catID; 338 293 339 294 /* set the average magnitude if not already set and the photcode.equiv is not 0 */ -
branches/cnb_branch_20090215/Ohana/src/addstar/src/find_matches_refstars.c
r18374 r21536 69 69 70 70 for (i = 0; i < Nstars; i++) { 71 RD_to_XY (&X1[i], &Y1[i], stars[i][0]. R, stars[i][0].D, &tcoords);71 RD_to_XY (&X1[i], &Y1[i], stars[i][0].average.R, stars[i][0].average.D, &tcoords); 72 72 N1[i] = i; 73 73 } … … 134 134 /* find last measurement of this star */ 135 135 for (k = 0; k < catalog[0].average[n].Nmeasure - 1; k++) m = next[m]; 136 136 137 /* set up references */ 137 138 next[Nmeas] = next[m]; 138 139 next[m] = Nmeas; 140 139 141 /* last just was moved */ 140 142 if (next[Nmeas] == -1) last = Nmeas; 141 143 142 144 /** add measurements for this star **/ 145 146 // set the new measurements 147 catalog[0].measure[Nmeas] = stars[N][0].measure; 148 143 149 /** *** dR,dD now in arcsec *** **/ 144 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N][0].R); 145 catalog[0].measure[Nmeas].dD = 3600.0*(catalog[0].average[n].D - stars[N][0].D); 146 catalog[0].measure[Nmeas].M = stars[N][0].M; 147 catalog[0].measure[Nmeas].dM = stars[N][0].dM; 148 catalog[0].measure[Nmeas].Mcal = 0; 149 catalog[0].measure[Nmeas].t = (TIMEREF == 0) ? stars[N][0].t : TIMEREF; /** careful : time_t vs e_time **/ 150 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N][0].average.R); 151 catalog[0].measure[Nmeas].dD = 3600.0*(catalog[0].average[n].D - stars[N][0].average.D); 152 153 // rationalize dR: 154 if (catalog[0].measure[Nmeas].dR > +180.0*3600.0) { 155 // average on high end of boundary, move star up 156 stars[N][0].average.R += 360.0; 157 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N][0].average.R); 158 } 159 if (catalog[0].measure[Nmeas].dR < -180.0*3600.0) { 160 // average on low end of boundary, move star down 161 stars[N][0].average.R -= 360.0; 162 catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N][0].average.R); 163 } 164 150 165 catalog[0].measure[Nmeas].averef = n; 151 catalog[0].measure[Nmeas].photcode = stars[N][0].code;152 catalog[0].measure[Nmeas].dophot = 0;153 166 catalog[0].measure[Nmeas].dbFlags = 0; 154 catalog[0].measure[Nmeas].dt = 0xffff; 155 156 catalog[0].measure[Nmeas].Map = NAN; 157 catalog[0].measure[Nmeas].airmass = 0; 158 catalog[0].measure[Nmeas].FWx = stars[N][0].fx; // XXX make sure these are zero'ed as needed 159 catalog[0].measure[Nmeas].FWy = stars[N][0].fy; // XXX make sure these are zero'ed as needed 160 catalog[0].measure[Nmeas].theta = stars[N][0].df; // XXX make sure these are zero'ed as needed 161 162 catalog[0].measure[Nmeas].photFlags = stars[N][0].flags; // XXX make sure these are zero'ed as needed 163 catalog[0].measure[Nmeas].qPSF = 0; 164 catalog[0].measure[Nmeas].psfChisq = 0; 165 catalog[0].measure[Nmeas].crNsigma = 0; 166 catalog[0].measure[Nmeas].extNsigma = 0; 167 catalog[0].measure[Nmeas].Sky = 0; 168 catalog[0].measure[Nmeas].dSky = 0; 169 170 catalog[0].measure[Nmeas].stargal = 0; // XXX not yet set 171 172 catalog[0].measure[Nmeas].detID = 0; 173 catalog[0].measure[Nmeas].imageID = 0; 174 175 catalog[0].measure[Nmeas].dXccd = 0; 176 catalog[0].measure[Nmeas].dYccd = 0; 177 178 catalog[0].measure[Nmeas].Xccd = stars[N][0].X; // XXX make sure these are zero'ed as needed 179 catalog[0].measure[Nmeas].Yccd = stars[N][0].Y; // XXX make sure these are zero'ed as needed 167 catalog[0].measure[Nmeas].objID = catalog[0].average[n].objID; 168 catalog[0].measure[Nmeas].catID = catalog[0].catID; 169 170 catalog[0].measure[Nmeas].t = (TIMEREF == 0) ? stars[N][0].measure.t : TIMEREF; /** careful : time_t vs e_time **/ 171 catalog[0].measure[Nmeas].t_msec = (TIMEREF == 0) ? stars[N][0].measure.t_msec : TIMEREF; /** careful : time_t vs e_time **/ 180 172 181 173 if (ACCEPT_MOTION) { 182 catalog[0].average[n].uR = stars[N][0]. uR;183 catalog[0].average[n].uD = stars[N][0]. uD;184 catalog[0].average[n].duR = stars[N][0]. duR;185 catalog[0].average[n].duD = stars[N][0]. duD;186 catalog[0].average[n].P = stars[N][0]. P;187 catalog[0].average[n].dP = stars[N][0]. dP;174 catalog[0].average[n].uR = stars[N][0].average.uR; 175 catalog[0].average[n].uD = stars[N][0].average.uD; 176 catalog[0].average[n].duR = stars[N][0].average.duR; 177 catalog[0].average[n].duD = stars[N][0].average.duD; 178 catalog[0].average[n].P = stars[N][0].average.P; 179 catalog[0].average[n].dP = stars[N][0].average.dP; 188 180 } 189 181 … … 233 225 for (i = 0; (i < Nstars) && !options.only_match; i+=NREFSTAR_GROUP) { 234 226 N = N1[i]; 235 if (stars[N][0].found > = 0) continue;236 237 catalog[0].average[Nave].R = stars[N][0]. R;238 catalog[0].average[Nave].D = stars[N][0]. D;239 catalog[0].average[Nave].Xp = 0; 227 if (stars[N][0].found > -1) continue; 228 229 catalog[0].average[Nave].R = stars[N][0].average.R; 230 catalog[0].average[Nave].D = stars[N][0].average.D; 231 240 232 catalog[0].average[Nave].Nmeasure = NREFSTAR_GROUP; 241 233 catalog[0].average[Nave].Nmissing = 0; 234 catalog[0].average[Nave].Nextend = 0; 235 242 236 catalog[0].average[Nave].measureOffset = Nmeas; 243 237 catalog[0].average[Nave].missingOffset = -1; 244 catalog[0].average[Nave]. code = 0;238 catalog[0].average[Nave].extendOffset = -1; 245 239 246 240 if (ACCEPT_MOTION) { 247 catalog[0].average[Nave].dR = stars[N][0].dR;248 catalog[0].average[Nave].dD = stars[N][0].dD;249 catalog[0].average[Nave].uR = stars[N][0].uR;250 catalog[0].average[Nave].uD = stars[N][0].uD;251 catalog[0].average[Nave].duR = stars[N][0].duR;252 catalog[0].average[Nave].duD = stars[N][0].duD;253 catalog[0].average[Nave].P = stars[N][0].P;254 catalog[0].average[Nave].dP = stars[N][0].dP;241 catalog[0].average[Nave].dR = stars[N][0].average.dR; 242 catalog[0].average[Nave].dD = stars[N][0].average.dD; 243 catalog[0].average[Nave].uR = stars[N][0].average.uR; 244 catalog[0].average[Nave].uD = stars[N][0].average.uD; 245 catalog[0].average[Nave].duR = stars[N][0].average.duR; 246 catalog[0].average[Nave].duD = stars[N][0].average.duD; 247 catalog[0].average[Nave].P = stars[N][0].average.P; 248 catalog[0].average[Nave].dP = stars[N][0].average.dP; 255 249 } else { 256 catalog[0].average[Nave].dR = 0; 257 catalog[0].average[Nave].dD = 0; 258 catalog[0].average[Nave].uR = 0; 259 catalog[0].average[Nave].uD = 0; 260 catalog[0].average[Nave].duR = 0; 261 catalog[0].average[Nave].duD = 0; 262 catalog[0].average[Nave].P = 0; 263 catalog[0].average[Nave].dP = 0; 264 } 265 266 catalog[0].average[Nave].objID = objID; 267 catalog[0].average[Nave].catID = catID; 250 catalog[0].average[Nave].dR = 0; 251 catalog[0].average[Nave].dD = 0; 252 catalog[0].average[Nave].uR = 0; 253 catalog[0].average[Nave].uD = 0; 254 catalog[0].average[Nave].duR = 0; 255 catalog[0].average[Nave].duD = 0; 256 catalog[0].average[Nave].P = 0; 257 catalog[0].average[Nave].dP = 0; 258 catalog[0].average[Nave].Xp = 0; 259 } 260 261 catalog[0].average[Nave].Xp = 0; 262 catalog[0].average[Nave].ChiSq = 0.0; 263 catalog[0].average[Nave].Npos = 0; 264 265 catalog[0].average[Nave].objID = objID; 266 catalog[0].average[Nave].catID = catID; 267 catalog[0].average[Nave].flags = 0; 268 268 269 objID ++; 269 270 270 271 for (j = 0; j < Nsecfilt; j++) { 271 catalog[0].secfilt[Nave*Nsecfilt+j].M = NAN; 272 catalog[0].secfilt[Nave*Nsecfilt+j].dM = NAN; 273 catalog[0].secfilt[Nave*Nsecfilt+j].Xm = NAN_S_SHORT; 272 catalog[0].secfilt[Nave*Nsecfilt+j].M = NAN; 273 catalog[0].secfilt[Nave*Nsecfilt+j].dM = NAN; 274 catalog[0].secfilt[Nave*Nsecfilt+j].Xm = NAN_S_SHORT; 275 catalog[0].secfilt[Nave*Nsecfilt+j].M_20 = NAN_S_SHORT; 276 catalog[0].secfilt[Nave*Nsecfilt+j].M_80 = NAN_S_SHORT; 277 catalog[0].secfilt[Nave*Nsecfilt+j].Ncode = 0; 278 catalog[0].secfilt[Nave*Nsecfilt+j].Nused = 0; 274 279 } 275 280 276 281 for (j = 0; j < NREFSTAR_GROUP; j++) { 277 282 N = N1[i + j]; 283 284 catalog[0].measure[Nmeas] = stars[N][0].measure; 285 278 286 catalog[0].measure[Nmeas].dR = 0.0; 279 287 catalog[0].measure[Nmeas].dD = 0.0; 280 catalog[0].measure[Nmeas].M = stars[N][0].M; 281 catalog[0].measure[Nmeas]. dM = stars[N][0].dM;282 catalog[0].measure[Nmeas]. Mcal = 0;283 catalog[0].measure[Nmeas]. t = (stars[N][0].t == 0) ? TIMEREF : stars[N][0].t; /** careful : time_t vs e_time **/288 289 catalog[0].measure[Nmeas].t = (stars[N][0].measure.t == 0) ? TIMEREF : stars[N][0].measure.t; /** careful : time_t vs e_time **/ 290 catalog[0].measure[Nmeas].t_msec = (stars[N][0].measure.t == 0) ? 0 : stars[N][0].measure.t_msec; /** careful : time_t vs e_time **/ 291 catalog[0].measure[Nmeas].dbFlags = 0; 284 292 catalog[0].measure[Nmeas].averef = Nave; 285 catalog[0].measure[Nmeas].photcode = stars[N][0].code; 286 catalog[0].measure[Nmeas].dophot = 0; 287 catalog[0].measure[Nmeas].dbFlags = 0; 288 catalog[0].measure[Nmeas].dt = 0xffff; 289 290 catalog[0].measure[Nmeas].photFlags = stars[N][0].flags; // XXX make sure these are zero'ed as needed 291 catalog[0].measure[Nmeas].qPSF = 0; 292 catalog[0].measure[Nmeas].psfChisq = 0; 293 catalog[0].measure[Nmeas].crNsigma = 0; 294 catalog[0].measure[Nmeas].extNsigma = 0; 295 catalog[0].measure[Nmeas].Sky = 0; 296 catalog[0].measure[Nmeas].dSky = 0; 297 298 catalog[0].measure[Nmeas].stargal = 0; // XXX not yet set 299 300 catalog[0].measure[Nmeas].detID = 0; 301 catalog[0].measure[Nmeas].imageID = 0; 302 303 catalog[0].measure[Nmeas].dXccd = 0; 304 catalog[0].measure[Nmeas].dYccd = 0; 305 306 catalog[0].measure[Nmeas].Xccd = stars[N][0].X; // XXX make sure these are zero'ed as needed 307 catalog[0].measure[Nmeas].Yccd = stars[N][0].Y; // XXX make sure these are zero'ed as needed 308 309 catalog[0].measure[Nmeas].airmass = 0; 310 catalog[0].measure[Nmeas].Map = NAN; 311 catalog[0].measure[Nmeas].FWx = stars[N][0].fx; // XXX make sure these are zero'ed as needed 312 catalog[0].measure[Nmeas].FWy = stars[N][0].fy; // XXX make sure these are zero'ed as needed 313 catalog[0].measure[Nmeas].theta = stars[N][0].df; // XXX make sure these are zero'ed as needed 314 315 catalog[0].measure[Nmeas].Xccd = 0.0; 316 catalog[0].measure[Nmeas].Yccd = 0.0; 293 catalog[0].measure[Nmeas].objID = catalog[0].average[Nave].objID; 294 catalog[0].measure[Nmeas].catID = catalog[0].catID; 317 295 318 296 stars[N][0].found = Nmeas; -
branches/cnb_branch_20090215/Ohana/src/addstar/src/find_subset.c
r5443 r21536 20 20 /* find stars within ra,dec region */ 21 21 for (i = N = 0; i < Nstars; i++) { 22 if (stars[i]. R < RA0) continue;23 if (stars[i]. R >= RA1) continue;24 if (stars[i]. D < DEC0) continue;25 if (stars[i]. D >= DEC1) continue;22 if (stars[i].average.R < RA0) continue; 23 if (stars[i].average.R >= RA1) continue; 24 if (stars[i].average.D < DEC0) continue; 25 if (stars[i].average.D >= DEC1) continue; 26 26 27 27 subset[N] = &stars[i]; -
branches/cnb_branch_20090215/Ohana/src/addstar/src/get2mass_dr2.c
r16810 r21536 68 68 dparse (&J, 1, &buffer[NBYTE*i + 53]); 69 69 dparse (&dJ, 2, &buffer[NBYTE*i + 53]); 70 stars[Nstars].M = J;71 stars[Nstars].dM = dJ;72 stars[Nstars]. code = TM_J;70 stars[Nstars].M = J; 71 stars[Nstars].dM = dJ; 72 stars[Nstars].photcode = TM_J; 73 73 } 74 74 if (photcode == TM_H) { 75 75 dparse (&H, 1, &buffer[NBYTE*i + 72]); 76 76 dparse (&dH, 2, &buffer[NBYTE*i + 72]); 77 stars[Nstars].M = H;78 stars[Nstars].dM = dH;79 stars[Nstars]. code = TM_H;77 stars[Nstars].M = H; 78 stars[Nstars].dM = dH; 79 stars[Nstars].photcode = TM_H; 80 80 } 81 81 if (photcode == TM_K) { 82 82 dparse (&K, 1, &buffer[NBYTE*i + 91]); 83 83 dparse (&dK, 2, &buffer[NBYTE*i + 91]); 84 stars[Nstars].M = K;85 stars[Nstars].dM = dK;86 stars[Nstars]. code = TM_K;84 stars[Nstars].M = K; 85 stars[Nstars].dM = dK; 86 stars[Nstars].photcode = TM_K; 87 87 } 88 88 Nstars ++; -
branches/cnb_branch_20090215/Ohana/src/addstar/src/get2mass_full.c
r17439 r21536 15 15 ptr = next2MASSfield (ptr); // dec (assumed to be already set) 16 16 ptr = next2MASSfield (ptr); // err_maj 17 star[0][0]. fx = strtod (ptr, NULL);17 star[0][0].measure.FWx = ShortPixels(strtod (ptr, NULL)); 18 18 ptr = next2MASSfield (ptr); // err_min 19 star[0][0]. fy = strtod (ptr, NULL);19 star[0][0].measure.FWy = ShortPixels(strtod (ptr, NULL)); 20 20 ptr = next2MASSfield (ptr); // err_ang 21 star[0][0]. df = strtod (ptr, NULL);22 23 star[2][0]. fx = star[2][0].fx = star[0][0].fx;24 star[2][0]. fy = star[2][0].fy = star[0][0].fy;25 star[2][0]. df = star[2][0].df = star[0][0].df;21 star[0][0].measure.theta = ShortPixels(strtod (ptr, NULL)); 22 23 star[2][0].measure.FWx = star[2][0].measure.FWx = star[0][0].measure.FWx; 24 star[2][0].measure.FWy = star[2][0].measure.FWy = star[0][0].measure.FWy; 25 star[2][0].measure.theta = star[2][0].measure.theta = star[0][0].measure.theta; 26 26 27 27 ptr = next2MASSfield (ptr); // designation (skip) 28 28 29 29 ptr = next2MASSfield (ptr); // j_m 30 star[0][0]. M = strtod (ptr, NULL);30 star[0][0].measure.M = strtod (ptr, NULL); 31 31 ptr = next2MASSfield (ptr); // j_cmsig 32 star[0][0]. dM = strtod (ptr, NULL);32 star[0][0].measure.dM = strtod (ptr, NULL); 33 33 ptr = next2MASSfield (ptr); // j_msigcom 34 34 dMfull = strtod (ptr, NULL); 35 star[0][0]. dMcal = sqrt (SQ(dMfull) - SQ(star[0][0].dM));35 star[0][0].measure.dMcal = sqrt (SQ(dMfull) - SQ(star[0][0].measure.dM)); 36 36 ptr = next2MASSfield (ptr); // j_snr (skip) 37 37 38 38 ptr = next2MASSfield (ptr); // h_m 39 star[1][0]. M = strtod (ptr, NULL);39 star[1][0].measure.M = strtod (ptr, NULL); 40 40 ptr = next2MASSfield (ptr); // h_cmsig 41 star[1][0]. dM = strtod (ptr, NULL);41 star[1][0].measure.dM = strtod (ptr, NULL); 42 42 ptr = next2MASSfield (ptr); // h_msigcom 43 43 dMfull = strtod (ptr, NULL); 44 star[1][0]. dMcal = sqrt (SQ(dMfull) - SQ(star[1][0].dM));44 star[1][0].measure.dMcal = sqrt (SQ(dMfull) - SQ(star[1][0].measure.dM)); 45 45 ptr = next2MASSfield (ptr); // h_snr (skip) 46 46 47 47 ptr = next2MASSfield (ptr); // k_m 48 star[2][0]. M = strtod (ptr, NULL);48 star[2][0].measure.M = strtod (ptr, NULL); 49 49 ptr = next2MASSfield (ptr); // k_cmsig 50 star[2][0]. dM = strtod (ptr, NULL);50 star[2][0].measure.dM = strtod (ptr, NULL); 51 51 ptr = next2MASSfield (ptr); // k_msigcom 52 52 dMfull = strtod (ptr, NULL); 53 star[2][0]. dMcal = sqrt (SQ(dMfull) - SQ(star[2][0].dM));53 star[2][0].measure.dMcal = sqrt (SQ(dMfull) - SQ(star[2][0].measure.dM)); 54 54 ptr = next2MASSfield (ptr); // k_snr (skip) 55 55 56 star[2][0]. flags = star[1][0].flags = star[0][0].flags = 0;56 star[2][0].measure.photFlags = star[1][0].measure.photFlags = star[0][0].measure.photFlags = 0; 57 57 58 58 ptr = next2MASSfield (ptr); // ph_qual … … 99 99 100 100 ptr = next2MASSfield (ptr); // x_scan 101 star[0][0]. X= strtod (ptr, NULL);102 star[2][0]. X = star[1][0].X = star[0][0].X;101 star[0][0].measure.Xccd = strtod (ptr, NULL); 102 star[2][0].measure.Xccd = star[1][0].measure.Xccd = star[0][0].measure.Xccd; 103 103 104 104 ptr = next2MASSfield (ptr); // jdate (julian date) 105 105 jd = strtod (ptr, NULL); 106 star[0][0]. t = ohana_jd_to_sec (jd);107 star[2][0]. t = star[1][0].t = star[0][0].t;106 star[0][0].measure.t = ohana_jd_to_sec (jd); 107 star[2][0].measure.t = star[1][0].measure.t = star[0][0].measure.t; 108 108 109 109 ptr = next2MASSfield (ptr); // j_psfchi 110 star[0][0]. psfChisq = strtod (ptr, NULL);110 star[0][0].measure.psfChisq = strtod (ptr, NULL); 111 111 ptr = next2MASSfield (ptr); // h_psfchi 112 star[1][0]. psfChisq = strtod (ptr, NULL);112 star[1][0].measure.psfChisq = strtod (ptr, NULL); 113 113 ptr = next2MASSfield (ptr); // k_psfchi 114 star[2][0]. psfChisq = strtod (ptr, NULL);114 star[2][0].measure.psfChisq = strtod (ptr, NULL); 115 115 116 116 ptr = next2MASSfield (ptr); // j_m_stdap 117 star[0][0]. Map = strtod (ptr, NULL);117 star[0][0].measure.Map = strtod (ptr, NULL); 118 118 ptr = next2MASSfield (ptr); // j_msig_stdap (skip?) 119 119 120 120 ptr = next2MASSfield (ptr); // h_m_stdap 121 star[1][0]. Map = strtod (ptr, NULL);121 star[1][0].measure.Map = strtod (ptr, NULL); 122 122 ptr = next2MASSfield (ptr); // h_msig_stdap (skip?) 123 123 124 124 ptr = next2MASSfield (ptr); // k_m_stdap 125 star[2][0]. Map = strtod (ptr, NULL);125 star[2][0].measure.Map = strtod (ptr, NULL); 126 126 ptr = next2MASSfield (ptr); // k_msig_stdap (skip?) 127 127 … … 140 140 set2MASS_use_flag (star[2], ptr[0]); 141 141 142 star[0][0].code = TM_J; 143 star[0][0].found = -1; 144 star[0][0].detID = 0; 145 star[0][0].imageID = 0; 146 147 star[1][0].code = TM_H; 148 star[1][0].found = -1; 149 star[1][0].detID = 0; 150 star[1][0].imageID = 0; 151 152 star[2][0].code = TM_K; 153 star[2][0].found = -1; 154 star[2][0].detID = 0; 155 star[2][0].imageID = 0; 142 star[0][0].measure.photcode = TM_J; 143 star[0][0].measure.detID = 0; 144 star[0][0].measure.imageID = 0; 145 146 star[1][0].measure.photcode = TM_H; 147 star[1][0].measure.detID = 0; 148 star[1][0].measure.imageID = 0; 149 150 star[2][0].measure.photcode = TM_K; 151 star[2][0].measure.detID = 0; 152 star[2][0].measure.imageID = 0; 156 153 157 154 return TRUE; … … 174 171 175 172 switch (qual) { 176 case 'X': star[0]. flags |= 0x0000; break;177 case 'U': star[0]. flags |= 0x0001; break;178 case 'F': star[0]. flags |= 0x0002; break;179 case 'E': star[0]. flags |= 0x0003; break;180 case 'A': star[0]. flags |= 0x0004; break;181 case 'B': star[0]. flags |= 0x0005; break;182 case 'C': star[0]. flags |= 0x0006; break;183 case 'D': star[0]. flags |= 0x0007; break;173 case 'X': star[0].measure.photFlags |= 0x0000; break; 174 case 'U': star[0].measure.photFlags |= 0x0001; break; 175 case 'F': star[0].measure.photFlags |= 0x0002; break; 176 case 'E': star[0].measure.photFlags |= 0x0003; break; 177 case 'A': star[0].measure.photFlags |= 0x0004; break; 178 case 'B': star[0].measure.photFlags |= 0x0005; break; 179 case 'C': star[0].measure.photFlags |= 0x0006; break; 180 case 'D': star[0].measure.photFlags |= 0x0007; break; 184 181 default: 185 182 fprintf (stderr, "error!\n"); … … 192 189 193 190 switch (qual) { 194 case '0': star[0]. flags |= 0x0000; break;195 case '1': star[0]. flags |= 0x0010; break;196 case '2': star[0]. flags |= 0x0020; break;197 case '3': star[0]. flags |= 0x0030; break;198 case '4': star[0]. flags |= 0x0040; break;199 case '6': star[0]. flags |= 0x0050; break;200 case '9': star[0]. flags |= 0x0060; break;191 case '0': star[0].measure.photFlags |= 0x0000; break; 192 case '1': star[0].measure.photFlags |= 0x0010; break; 193 case '2': star[0].measure.photFlags |= 0x0020; break; 194 case '3': star[0].measure.photFlags |= 0x0030; break; 195 case '4': star[0].measure.photFlags |= 0x0040; break; 196 case '6': star[0].measure.photFlags |= 0x0050; break; 197 case '9': star[0].measure.photFlags |= 0x0060; break; 201 198 default: 202 199 fprintf (stderr, "error!\n"); … … 209 206 210 207 switch (qual) { 211 case 'p': star[0]. flags |= 0x0000; break;212 case 'c': star[0]. flags |= 0x0100; break;213 case 'd': star[0]. flags |= 0x0200; break;214 case 's': star[0]. flags |= 0x0300; break;215 case 'b': star[0]. flags |= 0x0400; break;216 case '0': star[0]. flags |= 0x0500; break;208 case 'p': star[0].measure.photFlags |= 0x0000; break; 209 case 'c': star[0].measure.photFlags |= 0x0100; break; 210 case 'd': star[0].measure.photFlags |= 0x0200; break; 211 case 's': star[0].measure.photFlags |= 0x0300; break; 212 case 'b': star[0].measure.photFlags |= 0x0400; break; 213 case '0': star[0].measure.photFlags |= 0x0500; break; 217 214 default: 218 215 fprintf (stderr, "error!\n"); … … 225 222 226 223 switch (qual) { 227 case '0': star[0]. flags &= ~0x0008; break;228 case '1': star[0]. flags &= ~0x0008; break;229 default: star[0]. flags |= 0x0008; break;224 case '0': star[0].measure.photFlags &= ~0x0008; break; 225 case '1': star[0].measure.photFlags &= ~0x0008; break; 226 default: star[0].measure.photFlags |= 0x0008; break; 230 227 } 231 228 return (TRUE); … … 235 232 236 233 switch (qual) { 237 case '0': star[0]. flags &= ~0x0080; break;238 case '1': star[0]. flags &= ~0x0080; break;234 case '0': star[0].measure.photFlags &= ~0x0080; break; 235 case '1': star[0].measure.photFlags &= ~0x0080; break; 239 236 default: 240 star[0]. flags |= 0x0080;241 star[0]. extNsigma = 100.0;237 star[0].measure.photFlags |= 0x0080; 238 star[0].measure.extNsigma = 100.0; 242 239 break; 243 240 } … … 248 245 249 246 switch (qual) { 250 case '0': star[0]. flags &= ~0x0800; break;251 case '1': star[0]. flags &= ~0x0800; break;252 default: star[0]. flags |= 0x0800; break;247 case '0': star[0].measure.photFlags &= ~0x0800; break; 248 case '1': star[0].measure.photFlags &= ~0x0800; break; 249 default: star[0].measure.photFlags |= 0x0800; break; 253 250 } 254 251 return (TRUE); … … 258 255 259 256 switch (qual) { 260 case '0': star[0]. flags &= ~0x1000; break;261 case '1': star[0]. flags &= ~0x1000; break;262 default: star[0]. flags |= 0x1000; break;257 case '0': star[0].measure.photFlags &= ~0x1000; break; 258 case '1': star[0].measure.photFlags &= ~0x1000; break; 259 default: star[0].measure.photFlags |= 0x1000; break; 263 260 } 264 261 return (TRUE); … … 268 265 269 266 switch (qual) { 270 case '0': star[0]. flags &= ~0x2000; break;271 case '1': star[0]. flags |= 0x2000; break;267 case '0': star[0].measure.photFlags &= ~0x2000; break; 268 case '1': star[0].measure.photFlags |= 0x2000; break; 272 269 default: abort(); 273 270 } -
branches/cnb_branch_20090215/Ohana/src/addstar/src/get2mass_ops.c
r17196 r21536 42 42 double M, dM; 43 43 e_time time; 44 45 InitStar (star); 44 46 45 47 ptr = skipNbounds (line, '|', FilterSkip, Nmax); … … 57 59 } 58 60 59 star[0].M = M; 60 star[0].dM = dM; 61 star[0].code = Photcode; 62 star[0].t = time; 63 star[0].found = -1; 64 star[0].detID = 0; 65 star[0].imageID = 0; 61 star[0].measure.M = M; 62 star[0].measure.dM = dM; 63 star[0].measure.photcode = Photcode; 64 star[0].measure.t = time; 65 star[0].measure.detID = 0; 66 star[0].measure.imageID = 0; 66 67 67 68 return TRUE; … … 107 108 // how many bits are being used for the 2mass flags; can we just set photFlags based on them? 108 109 109 star[0].M = J; 110 star[0].dM = dJ; 111 star[0].code = TM_J; 112 star[0].t = time; 113 star[0].found = -1; 114 star[0].detID = 0; 115 star[0].imageID = 0; 116 117 star[1].M = H; 118 star[1].dM = dH; 119 star[1].code = TM_H; 120 star[1].t = time; 121 star[1].found = -1; 122 star[1].detID = 0; 123 star[1].imageID = 0; 124 125 star[2].M = K; 126 star[2].dM = dK; 127 star[2].code = TM_K; 128 star[2].t = time; 129 star[2].found = -1; 130 star[2].detID = 0; 131 star[2].imageID = 0; 110 star[0].measure.M = J; 111 star[0].measure.dM = dJ; 112 star[0].measure.photcode = TM_J; 113 star[0].measure.t = time; 114 star[0].measure.detID = 0; 115 star[0].measure.imageID = 0; 116 117 star[1].measure.M = H; 118 star[1].measure.dM = dH; 119 star[1].measure.photcode = TM_H; 120 star[1].measure.t = time; 121 star[1].measure.detID = 0; 122 star[1].measure.imageID = 0; 123 124 star[2].measure.M = K; 125 star[2].measure.dM = dK; 126 star[2].measure.photcode = TM_K; 127 star[2].measure.t = time; 128 star[2].measure.detID = 0; 129 star[2].measure.imageID = 0; 132 130 133 131 return TRUE; -
branches/cnb_branch_20090215/Ohana/src/addstar/src/getgsc.c
r17439 r21536 67 67 Nline = nbytes / BYTES_STAR; 68 68 for (i = 0; i < Nline; i++) { 69 70 InitStar (&stars[Nstars]); 71 69 72 Nbyte = i*BYTES_STAR; 70 dparse (&stars[Nstars].R, 1, &buffer[Nbyte]); 71 dparse (&stars[Nstars].D, 2, &buffer[Nbyte]); 72 if (stars[Nstars].R < UserPatch.Rmin) continue; 73 if (stars[Nstars].R > UserPatch.Rmax) continue; 74 if (stars[Nstars].D < UserPatch.Dmin) continue; 75 if (stars[Nstars].D > UserPatch.Dmax) continue; 73 dparse (&stars[Nstars].average.R, 1, &buffer[Nbyte]); 74 dparse (&stars[Nstars].average.D, 2, &buffer[Nbyte]); 76 75 77 dparse (&stars[Nstars].M, 3, &buffer[Nbyte]); 78 stars[Nstars].dM = NAN; 79 stars[Nstars].t = 0; 80 stars[Nstars].code = GSC_M; 81 stars[Nstars].found = -1; 76 if (stars[Nstars].average.R < UserPatch.Rmin) continue; 77 if (stars[Nstars].average.R > UserPatch.Rmax) continue; 78 if (stars[Nstars].average.D < UserPatch.Dmin) continue; 79 if (stars[Nstars].average.D > UserPatch.Dmax) continue; 82 80 83 stars[Nstars].detID = 0; 84 stars[Nstars].imageID = 0; 85 86 stars[Nstars].X = 0; 87 stars[Nstars].Y = 0; 88 stars[Nstars].fx = 0; 89 stars[Nstars].fy = 0; 90 stars[Nstars].df = 0; 81 fparse (&stars[Nstars].measure.M, 3, &buffer[Nbyte]); 82 stars[Nstars].measure.dM = NAN; 83 stars[Nstars].measure.photcode = GSC_M; 84 stars[Nstars].measure.t = 0; 91 85 92 86 Nstars ++; -
branches/cnb_branch_20090215/Ohana/src/addstar/src/gettycho.c
r17439 r21536 69 69 70 70 for (j = 0; j < nitems; j++) { 71 71 72 line = &buffer[j*NBYTE]; 72 stars[Ntycho].R = atof (&line[15]);73 stars[Ntycho].D = atof (&line[28]);74 73 75 if (stars[Ntycho].R < region[0].Rmin) goto next_section; 76 if (stars[Ntycho].R > region[0].Rmax) goto next_section; 77 if (stars[Ntycho].D < region[0].Dmin) goto next_section; 78 if (stars[Ntycho].D > region[0].Dmax) goto next_section; 74 InitStar (&stars[Ntycho]); 79 75 80 if (stars[Ntycho].R < UserPatch.Rmin) continue; 81 if (stars[Ntycho].R > UserPatch.Rmax) continue; 82 if (stars[Ntycho].D < UserPatch.Dmin) continue; 83 if (stars[Ntycho].D > UserPatch.Dmax) continue; 76 stars[Ntycho].average.R = atof (&line[15]); 77 stars[Ntycho].average.D = atof (&line[28]); 84 78 85 stars[Ntycho].dR = 1000 * atof (&line[57]); 86 stars[Ntycho].dD = 1000 * atof (&line[64]); 79 if (stars[Ntycho].average.R < region[0].Rmin) goto next_section; 80 if (stars[Ntycho].average.R > region[0].Rmax) goto next_section; 81 if (stars[Ntycho].average.D < region[0].Dmin) goto next_section; 82 if (stars[Ntycho].average.D > region[0].Dmax) goto next_section; 83 84 if (stars[Ntycho].average.R < UserPatch.Rmin) continue; 85 if (stars[Ntycho].average.R > UserPatch.Rmax) continue; 86 if (stars[Ntycho].average.D < UserPatch.Dmin) continue; 87 if (stars[Ntycho].average.D > UserPatch.Dmax) continue; 88 89 stars[Ntycho].average.dR = 1000 * atof (&line[57]); 90 stars[Ntycho].average.dD = 1000 * atof (&line[64]); 87 91 88 92 /* XXX : we need to apply uR,uD to R,D to advance to 2000.0 */ 89 stars[Ntycho]. uR = atof (&line[41]);90 stars[Ntycho]. uD = atof (&line[49]);93 stars[Ntycho].average.uR = atof (&line[41]); 94 stars[Ntycho].average.uD = atof (&line[49]); 91 95 92 stars[Ntycho].duR = atof (&line[69]); 93 stars[Ntycho].duD = atof (&line[75]); 94 95 stars[Ntycho].P = 0; 96 stars[Ntycho].dP = 0; 97 98 stars[Ntycho].detID = 0; 99 stars[Ntycho].imageID = 0; 96 stars[Ntycho].average.duR = atof (&line[69]); 97 stars[Ntycho].average.duD = atof (&line[75]); 100 98 101 99 /* Tycho uses J2000 equinox and 1991.25 epoch for coordinates */ 102 100 /* the magnitudes have no temporal information */ 103 stars[Ntycho].t = TychoEpoch; 104 stars[Ntycho].found = -1; 105 106 stars[Ntycho].X = 0; 107 stars[Ntycho].Y = 0; 108 stars[Ntycho].fx = 0; 109 stars[Ntycho].fy = 0; 110 stars[Ntycho].df = 0; 101 stars[Ntycho].measure.t = TychoEpoch; 111 102 112 103 /* one pass of addstar does either r or b */ 113 104 if (photcode == TYCHO_B) { 114 stars[Ntycho]. M= atof (&line[110]);115 stars[Ntycho]. dM= atof (&line[117]);116 stars[Ntycho]. code= TYCHO_B;105 stars[Ntycho].measure.M = atof (&line[110]); 106 stars[Ntycho].measure.dM = atof (&line[117]); 107 stars[Ntycho].measure.photcode = TYCHO_B; 117 108 } else { 118 stars[Ntycho]. M= atof (&line[123]);119 stars[Ntycho]. dM= atof (&line[130]);120 stars[Ntycho]. code= TYCHO_V;109 stars[Ntycho].measure.M = atof (&line[123]); 110 stars[Ntycho].measure.dM = atof (&line[130]); 111 stars[Ntycho].measure.photcode = TYCHO_V; 121 112 } 122 113 -
branches/cnb_branch_20090215/Ohana/src/addstar/src/getusno.c
r17439 r21536 110 110 if (buf[1] > iDEC1) continue; 111 111 112 memset (&stars[Nusno], 0, sizeof(Stars)); 113 stars[Nusno].R = buf[0]/360000.0; 114 stars[Nusno].D = buf[1]/360000.0 - 90.0; 115 stars[Nusno].dM = NAN; 116 stars[Nusno].t = 0; 117 stars[Nusno].found = -1; 112 InitStar (&stars[Nusno]); 118 113 119 stars[Nusno].detID = 0; 120 stars[Nusno].imageID = 0; 121 122 stars[Nusno].X = 0; 123 stars[Nusno].Y = 0; 124 stars[Nusno].fx = 0; 125 stars[Nusno].fy = 0; 126 stars[Nusno].df = 0; 114 stars[Nusno].average.R = buf[0]/360000.0; 115 stars[Nusno].average.D = buf[1]/360000.0 - 90.0; 116 stars[Nusno].measure.dM = NAN; 127 117 128 118 /* one pass of addstar does either r or b */ 129 119 if (photcode == USNO_RED) { 130 stars[Nusno]. code= USNO_RED;131 stars[Nusno]. M= fabs (0.1*(buf[2] - 1000*((int)(buf[2]/1000))));120 stars[Nusno].measure.photcode = USNO_RED; 121 stars[Nusno].measure.M = fabs (0.1*(buf[2] - 1000*((int)(buf[2]/1000)))); 132 122 } 133 123 if (photcode == USNO_BLUE) { 134 stars[Nusno]. code= USNO_BLUE;135 stars[Nusno]. M= fabs (0.1*((int)(buf[2] - 1000000*((int)(buf[2]/1000000))) / 1000));124 stars[Nusno].measure.photcode = USNO_BLUE; 125 stars[Nusno].measure.M = fabs (0.1*((int)(buf[2] - 1000000*((int)(buf[2]/1000000))) / 1000)); 136 126 } 137 127 Nusno ++; -
branches/cnb_branch_20090215/Ohana/src/addstar/src/getusnob.c
r17439 r21536 125 125 /* USNO coords are reported for J2000 / epoch 2000.0 */ 126 126 /* extract the basic stellar data */ 127 memset (&stars[Nusno], 0, sizeof(Stars)); 128 stars[Nusno].R = buf[0]/360000.0; 129 stars[Nusno].D = buf[1]/360000.0 - 90.0; 127 InitStar (&stars[Nusno]); 128 129 stars[Nusno].average.R = buf[0]/360000.0; 130 stars[Nusno].average.D = buf[1]/360000.0 - 90.0; 130 131 131 132 /* XXX uR cos(D) or just uR ??? */ 132 stars[Nusno]. uR = 2.0 * ((buf[2] % 10000) - 5000);133 stars[Nusno]. uD = 2.0 * ((buf[2]/10000 % 10000) - 5000);133 stars[Nusno].average.uR = 2.0 * ((buf[2] % 10000) - 5000); 134 stars[Nusno].average.uD = 2.0 * ((buf[2]/10000 % 10000) - 5000); 134 135 135 stars[Nusno]. duR = (buf[3] % 1000);136 stars[Nusno]. duD = (buf[3]/1000 % 1000);136 stars[Nusno].average.duR = (buf[3] % 1000); 137 stars[Nusno].average.duD = (buf[3]/1000 % 1000); 137 138 138 stars[Nusno]. dR = 0.001 * (buf[4] % 1000);139 stars[Nusno]. dD = 0.001 * (buf[4]/1000 % 1000);139 stars[Nusno].average.dR = 0.001 * (buf[4] % 1000); 140 stars[Nusno].average.dD = 0.001 * (buf[4]/1000 % 1000); 140 141 141 stars[Nusno]. P = 0;142 stars[Nusno]. dP = 0;142 stars[Nusno].average.P = 0; 143 stars[Nusno].average.dP = 0; 143 144 144 145 /* USNO magnitude errors are reported as a fixed 0.3 mag */ 145 stars[Nusno].dM = 0.3; 146 stars[Nusno].found = -1; 147 148 stars[Nusno].detID = 0; 149 stars[Nusno].imageID = 0; 150 151 stars[Nusno].X = 0; 152 stars[Nusno].Y = 0; 153 stars[Nusno].fx = 0; 154 stars[Nusno].fy = 0; 155 stars[Nusno].df = 0; 146 stars[Nusno].measure.dM = 0.3; 156 147 157 148 /* USNO-B uses J2000 equinox and 2000.0 epoch for coordinates */ 158 149 /* the magnitudes have no temporal information */ 159 stars[Nusno]. t= USNOepoch;150 stars[Nusno].measure.t = USNOepoch; 160 151 161 152 /* one pass of addstar does r, b, or n */ … … 172 163 m2 = 0; 173 164 } 174 stars[Nusno]. code = photcode;165 stars[Nusno].measure.photcode = photcode; 175 166 176 167 /* if two mags are available, get an average */ … … 180 171 mag = (m1) ? m1 : m2; 181 172 } 182 stars[Nusno]. M = (mag == 0.0) ? 32.0 : mag;173 stars[Nusno].measure.M = (mag == 0.0) ? 32.0 : mag; 183 174 184 175 Nusno ++; -
branches/cnb_branch_20090215/Ohana/src/addstar/src/greference.c
r6683 r21536 3 3 # define LOAD_DR2 1 4 4 5 Stars *gref cat(char *Refcat, SkyRegion *region, int photcode, int *nstars) {5 Stars *greference (char *Refcat, SkyRegion *region, int photcode, int *nstars) { 6 6 7 7 int Nstars; … … 36 36 /* get stars from 2MASS for the given region */ 37 37 if (!strcasecmp (Refcat, "2MASS")) { 38 stars = get2mass (region, photcode, LOAD_ALLSKY, &Nstars); 38 // stars = get2mass (region, photcode, LOAD_ALLSKY, &Nstars); 39 fprintf (stderr, "2MASS load via addstar is deprecated: use load2mass\n"); 40 exit (2); 39 41 } 40 42 41 43 /* get stars from 2MASS for the given region */ 42 44 if (!strcasecmp (Refcat, "2MASS-ALLSKY")) { 43 stars = get2mass (region, photcode, LOAD_ALLSKY, &Nstars); 45 // stars = get2mass (region, photcode, LOAD_ALLSKY, &Nstars); 46 fprintf (stderr, "2MASS load via addstar is deprecated: use load2mass\n"); 47 exit (2); 44 48 } 45 49 46 50 /* get stars from 2MASS for the given region */ 47 51 if (!strcasecmp (Refcat, "2MASS-DR2")) { 48 stars = get2mass (region, photcode, LOAD_DR2, &Nstars); 52 // stars = get2mass (region, photcode, LOAD_DR2, &Nstars); 53 fprintf (stderr, "2MASS load via addstar is deprecated: use load2mass\n"); 54 exit (2); 49 55 } 50 56 -
branches/cnb_branch_20090215/Ohana/src/addstar/src/grefstars.c
r19823 r21536 21 21 if (line[0] == 0) continue; 22 22 if (line[0] == '#') continue; 23 dparse (&stars[N].R, 1, line);24 dparse (&stars[N].D, 2, line);25 dparse (&stars[N].M, 3, line);26 dparse (&stars[N].dM, 4, line);27 stars[N].R = ohana_normalize_angle (stars[N].R);28 stars[N].t = 0;29 stars[N].code = photcode;30 stars[N].found = FALSE;31 stars[N].detID = 0;32 stars[N].imageID = 0;33 23 34 stars[N].X = 0; 35 stars[N].Y = 0; 36 stars[N].fx = 0; 37 stars[N].fy = 0; 38 stars[N].df = 0; 24 InitStar (&stars[N]); 25 26 dparse (&stars[N].average.R, 1, line); 27 dparse (&stars[N].average.D, 2, line); 28 stars[N].average.R = ohana_normalize_angle (stars[N].average.R); 29 30 fparse (&stars[N].measure.M, 3, line); 31 fparse (&stars[N].measure.dM, 4, line); 32 33 stars[N].measure.photcode = photcode; 39 34 40 35 CHECK_REALLOCATE (stars, Stars, NSTARS, N+1, 100); … … 43 38 return (stars); 44 39 } 45 46 /* stars.found is set here to FALSE.47 find_match_refstars uses stars.found to identify the seq number of the48 star which is found. it requires an initial value of -1 XXX49 */ -
branches/cnb_branch_20090215/Ohana/src/addstar/src/load2mass_as_rawdata.c
r17439 r21536 140 140 ALLOCATE (stars[Nstars+2], Stars, 1); 141 141 142 stars[Nstars+0][0].R = tstars[j].R; 143 stars[Nstars+0][0].D = tstars[j].D; 144 stars[Nstars+1][0].R = tstars[j].R; 145 stars[Nstars+1][0].D = tstars[j].D; 146 stars[Nstars+2][0].R = tstars[j].R; 147 stars[Nstars+2][0].D = tstars[j].D; 142 InitStar (stars[Nstars+0]); 143 InitStar (stars[Nstars+1]); 144 InitStar (stars[Nstars+2]); 145 146 stars[Nstars+0][0].average.R = tstars[j].R; 147 stars[Nstars+0][0].average.D = tstars[j].D; 148 stars[Nstars+1][0].average.R = tstars[j].R; 149 stars[Nstars+1][0].average.D = tstars[j].D; 150 stars[Nstars+2][0].average.R = tstars[j].R; 151 stars[Nstars+2][0].average.D = tstars[j].D; 148 152 get2mass_3star_full (&stars[Nstars], &buffer[offset], Nbyte - offset); 149 // get2mass_star (&stars[Nstars], &buffer[offset], Nbyte - offset);150 153 151 154 tstars[j].flag = TRUE; -
branches/cnb_branch_20090215/Ohana/src/addstar/src/load2mass_catalog.c
r16810 r21536 20 20 // XXX for now, the output objects will have limited astrometric interpretation... 21 21 // XXX every 3 stars represents 3 measurements and 1 average 22 catalog[0].average[Nave].R = stars[i]. R;23 catalog[0].average[Nave].D = stars[i]. D;22 catalog[0].average[Nave].R = stars[i].average.R; 23 catalog[0].average[Nave].D = stars[i].average.D; 24 24 catalog[0].average[Nave].dR = 0; 25 25 catalog[0].average[Nave].dD = 0; … … 37 37 catalog[0].average[Nave].measureOffset = Nmeas; 38 38 catalog[0].average[Nave].missingOffset = -1; 39 catalog[0].average[Nave]. code= 0;39 catalog[0].average[Nave].flags = 0; 40 40 41 41 for (j = 0; j < Nsec; j++) { 42 catalog[0].secfilt[Nave*Nsec+j].M = NAN; 43 catalog[0].secfilt[Nave*Nsec+j].dM = NAN; 44 catalog[0].secfilt[Nave*Nsec+j].Xm = NAN_S_SHORT; 42 catalog[0].secfilt[Nave*Nsec+j].M = NAN; 43 catalog[0].secfilt[Nave*Nsec+j].dM = NAN; 44 catalog[0].secfilt[Nave*Nsec+j].Xm = NAN_S_SHORT; 45 catalog[0].secfilt[Nave*Nsec+j].M_20 = NAN_S_SHORT; 46 catalog[0].secfilt[Nave*Nsec+j].M_80 = NAN_S_SHORT; 47 catalog[0].secfilt[Nave*Nsec+j].Ncode = 0; 48 catalog[0].secfilt[Nave*Nsec+j].Nused = 0; 45 49 } 46 50 47 51 // we now have the min chisq row. use this to supply the other filter values.... 48 52 for (j = 0; j < 3; j++) { 53 catalog[0].measure[Nmeas] = stars[i+j].measure; 54 49 55 catalog[0].measure[Nmeas].dR = 0.0; 50 56 catalog[0].measure[Nmeas].dD = 0.0; 51 catalog[0].measure[Nmeas].Xccd = stars[i+j].X; 52 catalog[0].measure[Nmeas].Yccd = stars[i+j].Y; 53 catalog[0].measure[Nmeas].dXccd = 0.0; 54 catalog[0].measure[Nmeas].dYccd = 0.0; 55 catalog[0].measure[Nmeas].M = stars[i+j].M; 56 catalog[0].measure[Nmeas].dM = stars[i+j].dM; 57 catalog[0].measure[Nmeas].Mcal = 0; 58 catalog[0].measure[Nmeas].dMcal = stars[i+j].dMcal; 59 catalog[0].measure[Nmeas].t = stars[i+j].t; 60 catalog[0].measure[Nmeas].averef = Nave; 61 catalog[0].measure[Nmeas].photcode = stars[i+j].code; 62 catalog[0].measure[Nmeas].dophot = 0; 63 catalog[0].measure[Nmeas].photFlags = stars[i+j].flags; 64 catalog[0].measure[Nmeas].dbFlags = 0; 65 catalog[0].measure[Nmeas].dt = 0xffff; 66 67 catalog[0].measure[Nmeas].airmass = 0; 68 catalog[0].measure[Nmeas].FWx = stars[i+j].fx; 69 catalog[0].measure[Nmeas].FWy = stars[i+j].fy; 70 catalog[0].measure[Nmeas].theta = stars[i+j].df; 57 catalog[0].measure[Nmeas].dt = NAN_S_SHORT; 58 59 // XXX what about averef? 71 60 72 61 catalog[0].average[Nave].Nmeasure++; -
branches/cnb_branch_20090215/Ohana/src/addstar/src/replace_match.c
r16810 r21536 7 7 /* search for entry and replace values M, dM, R, D */ 8 8 for (i = 0; i < average[0].Nmeasure; i++) { 9 if (measure[i].photcode != star[0]. code) continue;10 measure[i].dR = 3600.0*(average[0].R - star[0]. R);11 measure[i].dD = 3600.0*(average[0].D - star[0]. D);12 measure[i].M = star[0]. M;13 measure[i].dM = star[0]. dM;9 if (measure[i].photcode != star[0].measure.photcode) continue; 10 measure[i].dR = 3600.0*(average[0].R - star[0].average.R); 11 measure[i].dD = 3600.0*(average[0].D - star[0].average.D); 12 measure[i].M = star[0].measure.M; 13 measure[i].dM = star[0].measure.dM; 14 14 star[0].found = average[0].measureOffset + i; 15 15 return (TRUE); -
branches/cnb_branch_20090215/Ohana/src/addstar/src/sky_tessalation.c
r21055 r21536 281 281 image[0].NY = NY; 282 282 283 image[0]. code = 1; // this needs to be set more sensibly283 image[0].photcode = 1; // this needs to be set more sensibly 284 284 285 285 image[0].Mx = xv[0]; image[0].My = yv[0]; … … 433 433 rectangle[0].NX = NX; 434 434 rectangle[0].NY = NY; 435 rectangle[0]. code = 1; // this needs to be set more sensibly435 rectangle[0].photcode = 1; // this needs to be set more sensibly 436 436 437 437 return (TRUE); … … 477 477 rectangle[0].NX = NX; 478 478 rectangle[0].NY = NY; 479 rectangle[0]. code = 1; // this needs to be set more sensibly479 rectangle[0].photcode = 1; // this needs to be set more sensibly 480 480 481 481 return (TRUE); … … 511 511 output[N].NX = NX; 512 512 output[N].NY = NY; 513 output[N]. code = input[0].code;513 output[N].photcode = input[0].photcode; 514 514 515 515 output[N].coords.crpix1 = input[0].coords.crpix1 - i*NX; -
branches/cnb_branch_20090215/Ohana/src/getstar/src/ReadImageFiles.c
r19259 r21536 64 64 /* find image rootname */ 65 65 name = filebasename (file[i]); 66 snprintf (image[N].name, DVO_IMAGE_NAME_LEN, name);66 snprintf (image[N].name, DVO_IMAGE_NAME_LEN, "%s", name); 67 67 free (name); 68 68 -
branches/cnb_branch_20090215/Ohana/src/getstar/src/ReadImageHeader.c
r20184 r21536 112 112 image[0].Mcal = 0.0; 113 113 image[0].Xm = NAN_S_SHORT; 114 image[0]. code= 0;114 image[0].flags = 0; 115 115 116 116 return (TRUE); -
branches/cnb_branch_20090215/Ohana/src/getstar/src/write_getstar_ps1_dev_0.c
r16810 r21536 46 46 output[i].D = average[i].D; 47 47 48 output[i].code = average[i]. code;48 output[i].code = average[i].flags; 49 49 output[i].photcode = code_c0; 50 50 -
branches/cnb_branch_20090215/Ohana/src/getstar/src/write_getstar_ps1_dev_1.c
r16810 r21536 49 49 output[i].P = average[i].P; 50 50 51 output[i].code = average[i]. code;51 output[i].code = average[i].flags; 52 52 output[i].photcode = code_c0; 53 53 -
branches/cnb_branch_20090215/Ohana/src/getstar/src/write_getstar_ps1_dev_2.c
r16810 r21536 55 55 output[i].dP = average[i].dP; 56 56 57 output[i].code = average[i]. code;57 output[i].code = average[i].flags; 58 58 output[i].photcode = code_c0; 59 59 -
branches/cnb_branch_20090215/Ohana/src/imregister/imphot/modify.c
r7080 r21536 13 13 if (options.modify) { 14 14 if (!strcasecmp (options.ModifyEntry, "and")) { 15 image[i]. code&= atoi (options.ModifyValue);15 image[i].flags &= atoi (options.ModifyValue); 16 16 } 17 17 if (!strcasecmp (options.ModifyEntry, "or")) { 18 image[i]. code|= atoi (options.ModifyValue);18 image[i].flags |= atoi (options.ModifyValue); 19 19 } 20 20 if (!strcasecmp (options.ModifyEntry, "xor")) { 21 image[i]. code^= atoi (options.ModifyValue);21 image[i].flags ^= atoi (options.ModifyValue); 22 22 } 23 23 if (!strcasecmp (options.ModifyEntry, "=")) { 24 image[i]. code= atoi (options.ModifyValue);24 image[i].flags = atoi (options.ModifyValue); 25 25 } 26 26 } -
branches/cnb_branch_20090215/Ohana/src/imregister/imphot/output.c
r14590 r21536 39 39 40 40 fprintf (stdout, "%s %s %s %7.4f %7.4f %7.4f %5d %02x\n", image[i].name, photstr, timestr, 41 image[i].Mcal, image[i].dMcal, image[i].secz, image[i].nstar, image[i]. code);41 image[i].Mcal, image[i].dMcal, image[i].secz, image[i].nstar, image[i].flags); 42 42 free (timestr); 43 43 } -
branches/cnb_branch_20090215/Ohana/src/imregister/imphot/subset.c
r12332 r21536 24 24 if (!status && criteria.Ntimes) continue; 25 25 if (criteria.PhotcodeSelect && (image[i].photcode != criteria.photcode)) continue; 26 if (criteria.CodeSelect && (image[i]. code!= criteria.Code)) continue;26 if (criteria.CodeSelect && (image[i].flags != criteria.Code)) continue; 27 27 if (criteria.NameSelect && strncasecmp (image[i].name, criteria.Name, NameSelectLength)) continue; 28 28 -
branches/cnb_branch_20090215/Ohana/src/libautocode/Makefile.Targets
r19185 r21536 1 2 1 AOBJS = \ 3 2 $(ASRC)/coords.$(ARCH).o \ … … 9 8 $(ASRC)/average-ps1-dev-1.$(ARCH).o \ 10 9 $(ASRC)/average-ps1-dev-2.$(ARCH).o \ 10 $(ASRC)/average-ps1-v1.$(ARCH).o \ 11 11 $(ASRC)/secfilt.$(ARCH).o \ 12 12 $(ASRC)/secfilt-loneos.$(ARCH).o \ … … 16 16 $(ASRC)/secfilt-ps1-dev-1.$(ARCH).o \ 17 17 $(ASRC)/secfilt-ps1-dev-2.$(ARCH).o \ 18 $(ASRC)/secfilt-ps1-v1.$(ARCH).o \ 18 19 $(ASRC)/measure.$(ARCH).o \ 19 20 $(ASRC)/measure-loneos.$(ARCH).o \ … … 23 24 $(ASRC)/measure-ps1-dev-1.$(ARCH).o \ 24 25 $(ASRC)/measure-ps1-dev-2.$(ARCH).o \ 26 $(ASRC)/measure-ps1-v1.$(ARCH).o \ 25 27 $(ASRC)/missing.$(ARCH).o \ 26 28 $(ASRC)/photcode.$(ARCH).o \ … … 29 31 $(ASRC)/photcode-ps1-dev-2.$(ARCH).o \ 30 32 $(ASRC)/photcode-ps1-dev-3.$(ARCH).o \ 33 $(ASRC)/photcode-ps1-v1.$(ARCH).o \ 31 34 $(ASRC)/image.$(ARCH).o \ 32 35 $(ASRC)/image-loneos.$(ARCH).o \ … … 37 40 $(ASRC)/image-ps1-dev-2.$(ARCH).o \ 38 41 $(ASRC)/image-ps1-dev-3.$(ARCH).o \ 42 $(ASRC)/image-ps1-v1.$(ARCH).o \ 39 43 $(ASRC)/regimage.$(ARCH).o \ 40 44 $(ASRC)/detreg.$(ARCH).o \ 41 45 $(ASRC)/photreg.$(ARCH).o \ 42 46 $(ASRC)/photreg-old.$(ARCH).o \ 43 $(ASRC)/ps1_dev_0.$(ARCH).o \ 44 $(ASRC)/ps1_dev_1.$(ARCH).o \ 45 $(ASRC)/smpdata.$(ARCH).o \ 47 $(ASRC)/cmf-ps1-dev-0.$(ARCH).o \ 48 $(ASRC)/cmf-ps1-dev-1.$(ARCH).o \ 49 $(ASRC)/cmf-ps1-v1.$(ARCH).o \ 50 $(ASRC)/cmf-smpdata.$(ARCH).o \ 46 51 $(ASRC)/getstar-ps1-dev-0.$(ARCH).o \ 47 52 $(ASRC)/getstar-ps1-dev-1.$(ARCH).o \ … … 49 54 $(ASRC)/spectrum.$(ARCH).o \ 50 55 $(ASRC)/spectrum-ascii.$(ARCH).o \ 51 $(ASRC)/Stars.$(ARCH).o \52 56 $(ASRC)/GSCRegion.$(ARCH).o \ 53 57 $(ASRC)/AddstarClientOptions.$(ARCH).o \ … … 63 67 $(AINC)/average-ps1-dev-1.h \ 64 68 $(AINC)/average-ps1-dev-2.h \ 69 $(AINC)/average-ps1-v1.h \ 65 70 $(AINC)/secfilt.h \ 66 71 $(AINC)/secfilt-loneos.h \ … … 70 75 $(AINC)/secfilt-ps1-dev-1.h \ 71 76 $(AINC)/secfilt-ps1-dev-2.h \ 77 $(AINC)/secfilt-ps1-v1.h \ 72 78 $(AINC)/measure.h \ 73 79 $(AINC)/measure-loneos.h \ … … 77 83 $(AINC)/measure-ps1-dev-1.h \ 78 84 $(AINC)/measure-ps1-dev-2.h \ 85 $(AINC)/measure-ps1-v1.h \ 79 86 $(AINC)/missing.h \ 80 87 $(AINC)/photcode.h \ … … 83 90 $(AINC)/photcode-ps1-dev-2.h \ 84 91 $(AINC)/photcode-ps1-dev-3.h \ 92 $(AINC)/photcode-ps1-v1.h \ 85 93 $(AINC)/image.h \ 86 94 $(AINC)/image-loneos.h \ … … 91 99 $(AINC)/image-ps1-dev-2.h \ 92 100 $(AINC)/image-ps1-dev-3.h \ 101 $(AINC)/image-ps1-v1.h \ 93 102 $(AINC)/regimage.h \ 94 103 $(AINC)/detreg.h \ 95 104 $(AINC)/photreg.h \ 96 105 $(AINC)/photreg-old.h \ 97 $(AINC)/ps1_dev_0.h \ 98 $(AINC)/ps1_dev_1.h \ 106 $(AINC)/cmf-ps1-dev-0.h \ 107 $(AINC)/cmf-ps1-dev-1.h \ 108 $(AINC)/cmf-ps1-v1.h \ 109 $(AINC)/cmf-smpdata.h \ 99 110 $(AINC)/getstar-ps1-dev-0.h \ 100 111 $(AINC)/getstar-ps1-dev-1.h \ 101 112 $(AINC)/getstar-ps1-dev-2.h \ 102 $(AINC)/smpdata.h \103 113 $(AINC)/spectrum.h \ 104 114 $(AINC)/spectrum-ascii.h \ 105 $(AINC)/Stars.h \106 115 $(AINC)/GSCRegion.h \ 107 116 $(AINC)/AddstarClientOptions.h \ 108 117 $(AINC)/SkyRegion.h 118 119 # $(ASRC)/Stars.$(ARCH).o 120 # $(AINC)/Stars.h 121 -
branches/cnb_branch_20090215/Ohana/src/libautocode/def/Stars.d
r16810 r21536 2 2 EXTNAME STARS 3 3 TYPE BINTABLE 4 SIZE 2 484 SIZE 278 5 5 6 FIELD X, X, double, x coordinate on image, pixels 7 FIELD Y, Y, double, y coordinate on image, pixels 8 FIELD dX, dX, double, x coordinate error, pixels 9 FIELD dY, dY, double, y coordinate error, pixels 6 * FIELD Xccd, X, double, x coordinate on image, pixels 7 * FIELD Yccd, Y, double, y coordinate on image, pixels 8 * FIELD dXccd, dX, double, x coordinate error, pixels 9 * FIELD dYccd, dY, double, y coordinate error, pixels 10 * FIELD posangle, POSANGLE, float 11 * FIELD pltscale, PLTSCALE, float 10 12 FIELD R, R, double, ra coordinate on sky, decimal degrees 11 13 FIELD D, D, double, dec coordinate on sky, decimal degrees … … 18 20 FIELD P, PAR, double, parallax, milliarcsec 19 21 FIELD dP, PAR_ERR, double, parallax error, milliarcsec 20 FIELD M, M, double, instrumental mag 21 FIELD dM, DM, double, error on mag 22 FIELD dMcal, DMCAL, double, systematic error on mag 23 FIELD sky, SKY, double, local sky counts 24 FIELD dsky, dSKY, double, local sky error counts 25 FIELD fx, FX, double, object FWHM x-dir, pixels? 26 FIELD fy, FY, double, object FWHM y-dir, pixels? 27 FIELD df, DF, double, object position angle, degrees 28 # FIELD Mgal, MGAL, double, alternative (galaxy) magnitude 29 FIELD Map, MAP, double, alternative (aperture) magnitude 22 23 * FIELD M, M, double, instrumental mag 24 * FIELD dM, DM, double, error on mag 25 * FIELD dMcal, DMCAL, double, systematic error on mag 26 * FIELD Sky, SKY, double, local sky counts 27 * FIELD dSky, dSKY, double, local sky error counts 28 * FIELD fx, FX, double, object FWHM x-dir, pixels? 29 * FIELD fy, FY, double, object FWHM y-dir, pixels? 30 * FIELD df, DF, double, object position angle, degrees 31 * FIELD Mcal, MCAL, float, image cal magnitude 32 * FIELD Map, MAP, double, alternative (aperture) magnitude 30 33 FIELD Mpeak, MPEAK, double, alternative (peak) magnitude 31 FIELD detID, ID, int, detection identifier32 FIELD imageID, IMAGE_ID, int, image identifier34 * FIELD detID, ID, int, detection identifier 35 * FIELD imageID, IMAGE_ID, int, image identifier 33 36 FIELD found, FOUND, int, found in database catalog? 34 FIELD t, T, e_time, date/time of exposure (UNIX) 35 FIELD dt, EXPTIME, float, exposure time, 2.5*log(exptime) 36 FIELD psfChisq, PSF_CHISQ, float 37 FIELD crNsigma, CR_NSIGMA, float 38 FIELD extNsigma, EXT_NSIGMA, float 39 FIELD psfQual, PSF_QUAL, float 40 FIELD Mcal, MCAL, float, image cal mag, mag 41 FIELD airmass, AIRMASS, float, (airmass - 1), airmass 42 FIELD az, AZ, float, azimuth 43 FIELD code, CODE, short 44 FIELD nFrames, N_FRAMES, short 45 FIELD flags, FLAGS, short 46 FIELD dophot, DOPHOT, char, dophot type code 47 FIELD dummy, DUMMY, char 48 49 # XXX I'm going to need azimuth (or load from image header?) 37 * FIELD t, T, e_time, date/time of exposure (UNIX) 38 * FIELD t_msec, T_MSEC, short, milliseconds of exposure 39 * FIELD dt, EXPTIME, float, exposure time, 2.5*log(exptime) 40 * FIELD psfQual, PSF_QUAL, float 41 * FIELD psfChisq, PSF_CHISQ, float 42 * FIELD psfNdof, PSF_NDOF, int 43 * FIELD psfNpix, PSF_NPIX, int 44 * FIELD crNsigma, CR_NSIGMA, float 45 * FIELD extNsigma, EXT_NSIGMA, float 46 * FIELD Mxx, MOMENTS_XX, float, second moment 47 * FIELD Mxy, MOMENTS_XY, float, second moment 48 * FIELD Myy, MOMENTS_YY, float, second moment 49 * FIELD airmass, AIRMASS, float, (airmass - 1), airmass 50 * FIELD az, AZ, float, azimuth 51 * FIELD photcode, CODE, short 52 * FIELD nFrames, N_FRAMES, short 53 * FIELD photFlags, FLAGS, short 54 FIELD dummy, DUMMY, char[2] 50 55 51 56 # double: 24 * 8 : 192 … … 58 63 # define down the types to floats where reasonable (all but R,D)? 59 64 # R,D should be in ICRS, J2000, epoch 2000 : precess as needed, apply p-m as needed 65 66 # XXX I'd like to merge this with Measure, but need to be careful about addstarClient -> addstarServer 67 # XXX extend photFlags to match actual psphot output -
branches/cnb_branch_20090215/Ohana/src/libautocode/def/average.d
r16810 r21536 2 2 EXTNAME DVO_AVERAGE 3 3 TYPE BINTABLE 4 SIZE 804 SIZE 94 5 5 DESCRIPTION DVO Average Object Table 6 6 7 7 # elements of data structure / FITS table 8 8 9 FIELD R, RA, double, RA, decimal degrees 10 FIELD D, DEC, double, DEC, decimal degrees 11 FIELD dR, RA_ERR, float, RA error arcsec 12 FIELD dD, DEC_ERR, float, DEC error arcsec 9 FIELD R, RA, double, RA, decimal degrees 10 FIELD D, DEC, double, DEC, decimal degrees 11 FIELD dR, RA_ERR, float, RA error arcsec 12 FIELD dD, DEC_ERR, float, DEC error arcsec 13 14 FIELD uR, U_RA, float, RA*cos(D) proper-motion, arcsec/year 15 FIELD uD, U_DEC, float, DEC proper-motion, arcsec/year 16 FIELD duR, V_RA_ERR, float, RA*cos(D) p-m error, arcsec/year 17 FIELD duD, V_DEC_ERR, float, DEC p-m error, arcsec/year 18 FIELD P, PAR, float, parallax, arcsec 19 FIELD dP, PAR_ERR, float, parallax error, arcsec 13 20 14 FIELD uR, U_RA, float, RA*cos(D) proper-motion, arcsec/year 15 FIELD uD, U_DEC, float, DEC proper-motion, arcsec/year 16 FIELD duR, V_RA_ERR, float, RA*cos(D) p-m error, arcsec/year 17 FIELD duD, V_DEC_ERR, float, DEC p-m error, arcsec/year 18 FIELD P, PAR, float, parallax, arcsec 19 FIELD dP, PAR_ERR, float, parallax error, arcsec 21 FIELD Xp, SIGMA_POS, short, position scatter, 1/100 arcsec 22 FIELD ChiSq, CHISQ_POS, float, astrometry analysis chisq 23 FIELD Npos, NUMBER_POS, unsigned short, number of detections used for astrometry 20 24 21 FIELD Xp, SIGMA_POS, short, position scatter, 1/100 arcsec 25 # this limits us to a max of 64k measurements per object 22 26 FIELD Nmeasure, NMEASURE, unsigned short, number of psf measurements 23 27 FIELD Nmissing, NMISSING, unsigned short, number of missings 24 28 FIELD Nextend, NEXTEND, unsigned short, number of extended measurements 25 FIELD measureOffset, OFF_MEASURE, int, offset to first psf measurement26 FIELD missingOffset, OFF_MISSING, int, offset to first missing obs27 FIELD extendOffset, OFF_EXTEND, int, offset to first extended measurement28 29 29 FIELD code, code, unsigned short, ID code (star; ghost; etc) 30 FIELD dummy, DUMMY, char[2], padding 30 FIELD measureOffset, OFF_MEASURE, int, offset to first psf measurement 31 FIELD missingOffset, OFF_MISSING, int, offset to first missing obs 32 FIELD extendOffset, OFF_EXTEND, int, offset to first extended measurement 31 33 32 # Pan-STARRS uses a 64-bit detection ID. keep this in two 32 bit ints 33 # for C89 compatibility. The objID is constructed based on the 34 # position of first instatiation. this is actually quite expensive 35 # because we need to include the uniqueness test to construct this, 36 # which requires a select for each new object. Therefore, I will use 37 # a table based ID (table ID + object ID), and we will have to 38 # re-number the object IDs if we change the table density, OR treat 39 # all subdivisions as entries which are from a foreign table. 34 # 'flags' was called 'code' prior to 2009.02.07 35 FIELD flags, FLAGS, uint32_t, average object flags (star; ghost; etc) 40 36 41 FIELD objID, OBJ_ID, unsigned int, unique ID for object in table 42 FIELD catID, CAT_ID, unsigned int, unique ID for table in which object was first realized 37 # objID + catID gives a unique ID for all objects in the database 38 FIELD objID, OBJ_ID, unsigned int, unique ID for object in table 39 FIELD catID, CAT_ID, unsigned int, unique ID for table in which object was first realized 40 FIELD extID, EXT_ID, uint64_t, external ID for object (eg PSPS objID) 43 41 44 42 # this structure should only be used for internal representations … … 47 45 # the index for the secfilt table is just Nsecfilt times the index for the average table. 48 46 49 # the DVO object IDs are generated internally and are not equivalent to the PSPS object IDs 50 # probably need to add position chisq 51 52 # XXX include the number of measurements used to determine the positional information? 47 # *** 20090206 : new fields : ChiSq, Npos, flags (was code, uint16_t), extID -
branches/cnb_branch_20090215/Ohana/src/libautocode/def/image.d
r20936 r21536 40 40 # 40 bytes 41 41 42 FIELD name, NAME, char[12 8], name of original image42 FIELD name, NAME, char[121], name of original image 43 43 FIELD detection_limit, DETECTION_LIMIT, unsigned char, detection limit, 10*mag 44 44 FIELD saturation_limit, SATURATION_LIMIT, unsigned char, saturation limit, 10*mag … … 47 47 FIELD fwhm_y, FWHM_Y, unsigned char, PSF y width, 25*arcsec 48 48 FIELD trate, TRATE, unsigned char, scan rate, 100 usec/pixel 49 FIELD code, CODE, char, image quality flag50 49 FIELD ccdnum, CCDNUM, unsigned char, CCD ID number 50 FIELD flags, FLAGS, unsigned int, image quality flags 51 51 FIELD imageID, IMAGE_ID, unsigned int, internal image ID 52 53 # XXX do we want to use this to handle mosaics? 54 # FIELD parentID, PARENT_ID, unsigned int, associated ref image 52 FIELD parentID, PARENT_ID, unsigned int, associated ref image 55 53 FIELD externID, EXTERN_ID, unsigned int, external image ID 56 54 FIELD sourceID, SOURCE_ID, unsigned short, analysis source ID … … 73 71 FIELD Myyyy, MYYYY, short, Mrel polyterm 74 72 # 40 bytes 73 74 # *** 20090206 : new fields : parentID, flags (was code char), changed name to 121 bytes. -
branches/cnb_branch_20090215/Ohana/src/libautocode/def/measure-panstarrs-dev-0.d
r15511 r21536 46 46 47 47 # do we need more resolution than a short? should this be a log? 48 FIELD qPSF,PSF_QF, short, psf coverage/quality factor48 FIELD psfQual, PSF_QF, short, psf coverage/quality factor 49 49 50 50 FIELD dophot, DOPHOT, char, dophot type -
branches/cnb_branch_20090215/Ohana/src/libautocode/def/measure-panstarrs-dev-1.d
r15511 r21536 46 46 47 47 # do we need more resolution than a short? should this be a log? 48 FIELD qPSF,PSF_QF, short, psf coverage/quality factor48 FIELD psfQual, PSF_QF, short, psf coverage/quality factor 49 49 50 50 FIELD dophot, DOPHOT, char, dophot type -
branches/cnb_branch_20090215/Ohana/src/libautocode/def/measure-ps1-dev-1.d
r16810 r21536 33 33 34 34 # do we need more resolution than a short? should this be a log? 35 FIELD qPSF,PSF_QF, float, psf coverage/quality factor35 FIELD psfQual, PSF_QF, float, psf coverage/quality factor 36 36 FIELD psfChisq, PSF_CHISQ, float, psf coverage/quality factor 37 37 FIELD crNsigma, CR_NSIGMA, float, psf coverage/quality factor -
branches/cnb_branch_20090215/Ohana/src/libautocode/def/measure-ps1-dev-2.d
r16810 r21536 34 34 35 35 # do we need more resolution than a short? should this be a log? 36 FIELD qPSF,PSF_QF, float, psf coverage/quality factor36 FIELD psfQual, PSF_QF, float, psf coverage/quality factor 37 37 FIELD psfChisq, PSF_CHISQ, float, psf fit chisq 38 38 FIELD crNsigma, CR_NSIGMA, float, Nsigma deviation towards CR -
branches/cnb_branch_20090215/Ohana/src/libautocode/def/measure.d
r16810 r21536 2 2 EXTNAME DVO_MEASURE 3 3 TYPE BINTABLE 4 SIZE 1 124 SIZE 146 5 5 DESCRIPTION DVO Detection Measurement Table 6 6 7 FIELD dR, D_RA, float, RA offset, arcsec8 FIELD dD, D_DEC, float, DEC offset, arcsec9 FIELD M, MAG, float, catalog mag, mag10 FIELD Mcal, M_CAL, float, image cal mag, mag11 FIELD Map, M_APER, float, aperture mag, mag12 FIELD dM, MAG_ERR, float, mag error, mag13 FIELD dMcal, MAG_CAL_ERR, float, systematic calibration error, mag14 FIELD dt, M_TIME, float, exposure time, 2.5*log(exptime)7 FIELD dR, D_RA, float, RA offset, arcsec 8 FIELD dD, D_DEC, float, DEC offset, arcsec 9 FIELD M, MAG, float, catalog mag, mag 10 FIELD Mcal, M_CAL, float, image cal mag, mag 11 FIELD Map, M_APER, float, aperture mag, mag 12 FIELD dM, MAG_ERR, float, mag error, mag 13 FIELD dMcal, MAG_CAL_ERR, float, systematic calibration error, mag 14 FIELD dt, M_TIME, float, exposure time, 2.5*log(exptime) 15 15 16 16 # note that with airmass = 1.0 / cos(90 - alt), we have full alt/az representation 17 FIELD airmass, AIRMASS, float, (airmass - 1), airmass17 FIELD airmass, AIRMASS, float, (airmass - 1), airmass 18 18 FIELD az, AZ, float, telescope azimuth 19 19 20 20 # new field elements needed for Pan-STARRS: 21 FIELD Xccd, X_CCD, float, X coord on chip, pixels22 FIELD Yccd, Y_CCD, float, Y coord on chip, pixels21 FIELD Xccd, X_CCD, float, X coord on chip, pixels 22 FIELD Yccd, Y_CCD, float, Y coord on chip, pixels 23 23 24 24 # could these be packed into fewer bits? 25 FIELD Sky, SKY_FLUX, float, local estimate of sky flux, counts/sec26 FIELD dSky, SKY_FLUX_ERR, float, local estimate of sky flux, counts/sec25 FIELD Sky, SKY_FLUX, float, local estimate of sky flux, counts/sec 26 FIELD dSky, SKY_FLUX_ERR, float, local estimate of sky flux, counts/sec 27 27 28 FIELD t, TIME, unsigned int, time in seconds (UNIX) 28 FIELD t, TIME, int, time in seconds (UNIX) 29 FIELD t_msec, TIME_MSEC, unsigned short, time fraction of second, milliseconds 29 30 FIELD averef, AVE_REF, unsigned int, reference to average entry 30 31 31 # Pan-STARRS uses a 64-bit detection ID. keep this in two 32 bit ints for backwards compatibility?32 32 FIELD detID, DET_ID, unsigned int, detection ID 33 33 FIELD imageID, IMAGE_ID, unsigned int, reference to DVO image ID 34 FIELD objID, OBJ_ID, unsigned int, unique ID for object in table 35 FIELD catID, CAT_ID, unsigned int, unique ID for table in which object was first realized 36 37 # PSPS uses a 64-bit detection ID 38 FIELD extID, EXT_ID, uint64_t, external ID (eg PSPS detID) 34 39 35 40 # do we need more resolution than a short? should this be a log? 36 FIELD qPSF,PSF_QF, float, psf coverage/quality factor41 FIELD psfQual, PSF_QF, float, psf coverage/quality factor 37 42 FIELD psfChisq, PSF_CHISQ, float, psf fit chisq 43 FIELD psfNdof, PSF_NDOF, int, psf degrees of freedom 44 FIELD psfNpix, PSF_NPIX, int, psf number of pixels 38 45 FIELD crNsigma, CR_NSIGMA, float, Nsigma deviation towards CR 39 46 FIELD extNsigma, EXT_NSIGMA, float, Nsigma deviation towards EXT 40 47 41 FIELD FWx, FWHM_MAJOR, short, object fwhm major axis, 1/100 of arcsec 42 FIELD FWy, FWHM_MINOR, short, object fwhm minor axis, 1/100 of arcsec 43 FIELD theta, PSF_THETA, short, angle wrt ccd X dir, (0xffff/360) deg 48 # model shape parameters 49 FIELD FWx, FWHM_MAJOR, short, object fwhm major axis, 1/100 of pixels 50 FIELD FWy, FWHM_MINOR, short, object fwhm minor axis, 1/100 of pixels 51 FIELD theta, PSF_THETA, short, angle wrt ccd X dir, (0xffff/360) deg 52 53 # moments 54 FIELD Mxx, MXX, short, second moments in pixel coords, 1/100 of pixels^2 55 FIELD Mxy, MXY, short, second moments in pixel coords, 1/100 of pixels^2 56 FIELD Myy, MYY, short, second moments in pixel coords, 1/100 of pixels^2 57 58 # convert this to error in pixels on load? 59 FIELD dXccd, X_CCD_ERR, short, X coord error on chip, 1/100 of pixels 60 FIELD dYccd, Y_CCD_ERR, short, Y coord error on chip, 1/100 of pixels 61 62 FIELD posangle, POSANGLE, short, position angle sky to chip, (0xffff/360) deg 63 FIELD pltscale, PLTSCALE, float, plate scale, arcsec/pixel 64 44 65 FIELD photcode, PHOTCODE, unsigned short, photcode 66 FIELD dbFlags, DB_FLAGS, unsigned int, flags supplied by analysis in database 67 FIELD photFlags, PHOT_FLAGS, unsigned int, flags supplied by photometry program 45 68 46 # convert this to error in arcsec on load?47 FIELD dXccd, X_CCD_ERR, short, X coord error on chip, pixels 48 FIELD dYccd, Y_CCD_ERR, short, Y coord error on chip, pixels 69 # *** 20090206 : new fields : t_msec, extID, Mxx, Mxy, Myy, posangle, 70 # psfNdof, psfNpix, Map_small; deprecated dophot. 71 # Changed dbFlags, photFlags : uint16_t to uint64_t 49 72 50 FIELD dbFlags, DB_FLAGS, unsigned short, flags for various uses 51 FIELD photFlags, PHOT_FLAGS, unsigned short, flags supplied by photometry program 52 53 FIELD stargal, STAR_GAL, char, star-galaxy separator 54 55 # absorb these into photFlags? 56 FIELD dophot, DOPHOT, char, dophot type 57 58 FIELD dummy, DUMMY, char[6], padding 73 # XXX unsigned int values are probably not being saved in the FITS file correctly: no BZERO, BSCALE -
branches/cnb_branch_20090215/Ohana/src/libautocode/def/secfilt.d
r12332 r21536 2 2 EXTNAME DVO_SECFILT 3 3 TYPE BINTABLE 4 SIZE 1 64 SIZE 18 5 5 DESCRIPTION DVO SecFilt : Secondary Filter Data 6 6 … … 11 11 FIELD Ncode, NCODE, short, number of detections in band 12 12 FIELD Nused, NUSED, short, number of detections used in average 13 FIELD dummy, JUNK, short, place holder 13 FIELD M_20, MAG_20, short, lower 20percent mag, millimags 14 FIELD M_80, MAG_80, short, upper 20percent mag, millimags 15 16 # *** 20090206 : new fields : M_20, M_80; dropped dummy -
branches/cnb_branch_20090215/Ohana/src/libautocode/doc/autocode.txt
r3515 r21536 1 2 2009.02.07 3 4 The autocode tables currently use type names which are ambiguous in 5 terms of their actual sizes in bits. I've added the intNN_t and 6 uintNN_t types -- this requires --use-gnu99 with configure 7 8 see libdvo/doc/notes.txt for instructions on adding new dvo catalog formats 9 10 2007.00.00 1 11 2 12 This directory contains a collection of autocoded FITS I/O routines -
branches/cnb_branch_20090215/Ohana/src/libautocode/generate
r7080 r21536 114 114 115 115 # rawshort is a short without byteswapping 116 # rawshort is a patch for old photreg tables 116 117 117 118 $pt1 = 0; … … 124 125 if ($type eq "int") { $pt1 = "J"; } 125 126 if ($type eq "unsigned int") { $pt1 = "J"; } 126 if ($type eq "e_time") { $pt1 = "J"; } 127 128 if ($type eq "int8_t") { $pt1 = "B"; } 129 if ($type eq "uint8_t") { $pt1 = "B"; } 130 if ($type eq "int16_t") { $pt1 = "I"; } 131 if ($type eq "uint16_t") { $pt1 = "I"; } 132 if ($type eq "int32_t") { $pt1 = "J"; } 133 if ($type eq "uint32_t") { $pt1 = "J"; } 134 135 # FITS tables do not allow for 64bit integers. we need to 136 # write these by splitting the value into high and low 32 bit values 137 if ($type eq "int64_t") { $pt1 = "J"; $Np = 2*$Np; } 138 if ($type eq "uint64_t") { $pt1 = "J"; $Np = 2*$Np; } 139 127 140 if ($type eq "float") { $pt1 = "E"; } 128 141 if ($type eq "double") { $pt1 = "D"; } 129 142 143 # special 'elixir' types: 144 if ($type eq "e_time") { $pt1 = "J"; } 130 145 if ($type eq "e_void") { $pt1 = "B"; $Np = 8*$Np; } 131 146 # e_void is a 64 bit pointer, cast to size_t. its value is not loaded … … 146 161 printf FILE "%-20s 1.0, 0.0);\n", "\"$unit[$i]\", "; 147 162 } 148 149 163 } 150 164 … … 217 231 if ($type eq "int") { $pt1 = sprintf "I%s", $length; } 218 232 if ($type eq "unsigned int") { $pt1 = sprintf "I%s", $length; } 219 if ($type eq "e_time") { $pt1 = sprintf "I%s", $length; } 233 234 if ($type eq "int8_t") { $pt1 = sprintf "I%s", $length; } 235 if ($type eq "uint8_t") { $pt1 = sprintf "I%s", $length; } 236 if ($type eq "int16_t") { $pt1 = sprintf "I%s", $length; } 237 if ($type eq "uint16_t") { $pt1 = sprintf "I%s", $length; } 238 if ($type eq "int32_t") { $pt1 = sprintf "I%s", $length; } 239 if ($type eq "uint32_t") { $pt1 = sprintf "I%s", $length; } 240 241 # FITS tables do not allow for 64bit integers. we need to 242 # write these by splitting the value into high and low 32 bit values 243 if ($type eq "int64_t") { $pt1 = sprintf "I%s", $length; } 244 if ($type eq "uint64_t") { $pt1 = sprintf "I%s", $length; } 245 220 246 if ($type eq "float") { $pt1 = sprintf "F%s", $length; } 221 247 if ($type eq "double") { $pt1 = sprintf "F%s", $length; } 222 248 249 # special 'elixir' types: 250 if ($type eq "e_time") { $pt1 = sprintf "I%s", $length; } 223 251 if ($type eq "e_void") { $pt1 = sprintf "I%s", $length; } 224 252 … … 283 311 if ($type eq "unsigned char") { $N += $Np; next; } 284 312 if ($type eq "rawshort") { $N += 2*$Np; next; } 313 285 314 if ($type eq "short") { $T = "BYTE"; $n = 2; } 286 315 if ($type eq "unsigned short"){ $T = "BYTE"; $n = 2; } 287 316 if ($type eq "int") { $T = "WORD"; $n = 4; } 288 317 if ($type eq "unsigned int") { $T = "WORD"; $n = 4; } 318 319 if ($type eq "int8_t") { $N += $Np; next; } 320 if ($type eq "uint8_t") { $N += $Np; next; } 321 if ($type eq "int16_t") { $T = "BYTE"; $n = 2; } 322 if ($type eq "uint16_t") { $T = "BYTE"; $n = 2; } 323 if ($type eq "int32_t") { $T = "WORD"; $n = 4; } 324 if ($type eq "uint32_t") { $T = "WORD"; $n = 4; } 325 326 # FITS tables do not allow for 64bit integers. we need to 327 # write these by splitting the value into high and low 32 bit values 328 if ($type eq "int64_t") { $T = "WORD"; $n = 4; $Np = 2*$Np; } 329 if ($type eq "uint64_t") { $T = "WORD"; $n = 4; $Np = 2*$Np; } 330 331 if ($type eq "float") { $T = "WORD"; $n = 4; } 332 if ($type eq "double") { $T = "DBLE"; $n = 8; } 333 334 # special 'elixir' types: 289 335 if ($type eq "e_time") { $T = "WORD"; $n = 4; } 290 336 if ($type eq "e_void") { $T = "DBLE"; $n = 8; } 291 if ($type eq "float") { $T = "WORD"; $n = 4; } 292 if ($type eq "double") { $T = "DBLE"; $n = 8; } 337 293 338 if (!$n) { die "unknown type $type"; } 294 339 for ($j = 0; $j < $Np; $j++) { … … 318 363 if ($type eq "int") { $Nbytes += 4*$Np; $valid = 1; } 319 364 if ($type eq "unsigned int") { $Nbytes += 4*$Np; $valid = 1; } 365 366 if ($type eq "int8_t") { $Nbytes += 1*$Np; $valid = 1; } 367 if ($type eq "uint8_t") { $Nbytes += 1*$Np; $valid = 1; } 368 if ($type eq "int16_t") { $Nbytes += 2*$Np; $valid = 1; } 369 if ($type eq "uint16_t") { $Nbytes += 2*$Np; $valid = 1; } 370 if ($type eq "int32_t") { $Nbytes += 4*$Np; $valid = 1; } 371 if ($type eq "uint32_t") { $Nbytes += 4*$Np; $valid = 1; } 372 373 # FITS tables do not allow for 64bit integers. we need to 374 # write these by splitting the value into high and low 32 bit values 375 if ($type eq "int64_t") { $Nbytes += 8*$Np; $valid = 1; } 376 if ($type eq "uint64_t") { $Nbytes += 8*$Np; $valid = 1; } 377 378 if ($type eq "float") { $Nbytes += 4*$Np; $valid = 1; } 379 if ($type eq "double") { $Nbytes += 8*$Np; $valid = 1; } 380 381 # special 'elixir' types: 320 382 if ($type eq "e_time") { $Nbytes += 4*$Np; $valid = 1; } 321 383 if ($type eq "e_void") { $Nbytes += 8*$Np; $valid = 1; } 322 if ($type eq "float") { $Nbytes += 4*$Np; $valid = 1; }323 if ($type eq "double") { $Nbytes += 8*$Np; $valid = 1; }324 384 if (!$valid) { die "unknown type $type"; } 325 385 } -
branches/cnb_branch_20090215/Ohana/src/libdvo/Makefile
r17419 r21536 31 31 $(DESTINC)/ps1_dev_1_defs.h \ 32 32 $(DESTINC)/ps1_dev_2_defs.h \ 33 $(DESTINC)/ps1_dev_3_defs.h 33 $(DESTINC)/ps1_dev_3_defs.h \ 34 $(DESTINC)/ps1_v1_defs.h 34 35 35 36 INCS = $(DEFS) $(DESTINC)/dvo.h $(DESTINC)/autocode.h … … 65 66 $(SRC)/dvo_convert_PS1_DEV_2.$(ARCH).o \ 66 67 $(SRC)/dvo_convert_PS1_DEV_3.$(ARCH).o \ 68 $(SRC)/dvo_convert_PS1_V1.$(ARCH).o \ 67 69 $(SRC)/skyregion_io.$(ARCH).o \ 68 70 $(SRC)/skyregion_gsc.$(ARCH).o \ -
branches/cnb_branch_20090215/Ohana/src/libdvo/doc/notes.txt
r12332 r21536 2 2 Adding a new dvo catalog format. Assume the new format name is 'foo'. 3 3 4 1) create the autocode definition files for average, measure, secfilt, image5 these files must be a subset of the internal versions of these same6 tables. if you intend to add fields which don't exist in the7 internal tables, you must update the internal tables as well. the8 naming convention is: average-foo.d, etc.4 1) create the autocode definition files for average, measure, secfilt, 5 image, and photcode. these files must be a subset of the internal 6 versions of these same tables. if you intend to add fields which 7 don't exist in the internal tables, you must update the internal 8 tables as well. the naming convention is: average-foo.d, etc. 9 9 10 10 2) add the new definition files to libautocode/Makefile.Targets (both … … 22 22 (libdvo/src/dvo_catalog.c). The name should be "FOO". 23 23 24 6) add entry for structure size in dvo_catalog_load_raw 25 (libdvo/src/dvo_catalog_raw.c), since this is not available from 26 the header. 24 6) in libdvo/src/dvo_catalog_raw.c, update the FORMAT_CASE lists to 25 include the new STRUCT name. 27 26 28 7) add entries in ReadRawAverage, WriteRawAverage, ReadRawMeasure, 29 WriteRawMeasure, ReadRawSecFilt, WriteRawSecFilt. Make sure to use 30 the new STRUCT names. the conversion function gfit_convert_Foo will 31 be automatically generated. 27 7) create a new conversion file dvo_convert_foo.c and define the 28 internal to Foo conversions. 32 29 33 8) add entry in WriteRawAverage, making sure to use the new STRUCT 34 name. the conversion function gfit_convert_Foo will be 35 automatically generated. 30 8) add the new format to the list of FORMAT conversion in dvo_convert.c. 36 31 37 9) create a new conversion file dvo_convert_foo.c and define the 38 internal to Foo conversions. 32 9) any changes to the internal format need to be reflected in the 33 functions in the dvo_convert_*.c files. These files are defined so 34 that changed fields are sequential in the functions. This should 35 make is easy to identify the new changes needed. 36 37 10) add the new format to the section at the end of dvo_image.c 38 39 11) add the new format to the dvo_image_raw.c 40 41 12) add the photcode format conversions to libdvo/src/LoadPhotcodesFITS.c 42 43 12) switch the output photcode format conversion ina libdvo/src/SavePhotcodesFITS.c 44 45 13) Add the conversion functions to the header file libdvo/include/foo_defs.h 39 46 40 47 * Note some esoteric format issues: … … 54 61 keywords. 55 62 63 ---- 64 65 20090207 : adding PS1_V1 66 67 measure: 68 new fields : t_msec, extID, Mxx, Mxy, Myy, dTccd; deprecated dophot 69 dbFlags, photFlags : uint16_t to uint64_t 70 71 average: 72 new fields : ChiSq, Npos, flags (was code, uint16_t), extID 73 74 secfilt: 75 new fields : M_20, M_80; dropped dummy 76 77 image: 78 new fields : parentID, flags (was code char), changed name to 121 bytes. 79 80 photcode: 81 new fields : NONE 82 83 ** parentID was added to enable easy lookups from chip->fpa for mosaic 84 astrometry. In old databases, this conversion was done by making 85 the match via the time and photcode. This conversion needs to be 86 done on load... -
branches/cnb_branch_20090215/Ohana/src/libdvo/include/dvo.h
r21153 r21536 18 18 DVO_FORMAT_PS1_DEV_1, 19 19 DVO_FORMAT_PS1_DEV_2, 20 DVO_FORMAT_PS1_DEV_3 20 DVO_FORMAT_PS1_DEV_3, 21 DVO_FORMAT_PS1_V1 21 22 } DVOTableFormat; 22 23 … … 407 408 # include "ps1_dev_2_defs.h" 408 409 # include "ps1_dev_3_defs.h" 410 # include "ps1_v1_defs.h" 409 411 410 412 /*** DVO image db I/O Functions ***/ … … 444 446 void sort_image_subset (Image *image, int *subset, int N); 445 447 void sort_coords_index (double *X, double *Y, int *S, int N); 446 void sort_stars_ra (Stars *stars, int N);447 448 void sort_regions (SkyRegion *region, int N); 448 449 -
branches/cnb_branch_20090215/Ohana/src/libdvo/src/LoadPhotcodesFITS.c
r17190 r21536 40 40 gfits_scan (&db.theader, "EXTNAME", "%s", 1, extname); 41 41 42 if (!strcmp (extname, "DVO_PHOTCODE") || !strcmp (extname, "DVO_PHOTCODE_ELIXIR")) { 42 if (!strcmp (extname, "DVO_PHOTCODE")) { 43 PhotCode_Elixir *photcode_elixir = gfits_table_get_PhotCode_Elixir (&db.ftable, &Ncode, &db.swapped); 44 photcode = PhotCode_Elixir_To_Internal (photcode_elixir, Ncode); 45 free (photcode_elixir); 46 } 47 48 if (!strcmp (extname, "DVO_PHOTCODE_ELIXIR")) { 43 49 PhotCode_Elixir *photcode_elixir = gfits_table_get_PhotCode_Elixir (&db.ftable, &Ncode, &db.swapped); 44 50 photcode = PhotCode_Elixir_To_Internal (photcode_elixir, Ncode); … … 62 68 photcode = PhotCode_PS1_DEV_3_To_Internal (photcode_ps1_dev_3, Ncode); 63 69 free (photcode_ps1_dev_3); 70 } 71 72 if (!strcmp (extname, "DVO_PHOTCODE_PS1_V1")) { 73 PhotCode_PS1_V1 *photcode_ps1_v1 = gfits_table_get_PhotCode_PS1_V1 (&db.ftable, &Ncode, &db.swapped); 74 photcode = PhotCode_PS1_V1_To_Internal (photcode_ps1_v1, Ncode); 75 free (photcode_ps1_v1); 64 76 } 65 77 -
branches/cnb_branch_20090215/Ohana/src/libdvo/src/SavePhotcodesFITS.c
r17190 r21536 29 29 // for the moment, we simply support the latest photcode format for output 30 30 // XXX update this as needed as new formats are defined 31 PhotCode_PS1_ DEV_3 *photcode_output = PhotCode_Internal_To_PS1_DEV_3(table[0].code, table[0].Ncode);31 PhotCode_PS1_V1 *photcode_output = PhotCode_Internal_To_PS1_V1 (table[0].code, table[0].Ncode); 32 32 33 33 /* convert FITS format data to internal format (byteswaps & EXTNAME) */ 34 34 gfits_db_create (&db); 35 gfits_table_set_PhotCode_PS1_ DEV_3(&db.ftable, photcode_output, table[0].Ncode);35 gfits_table_set_PhotCode_PS1_V1 (&db.ftable, photcode_output, table[0].Ncode); 36 36 gfits_db_save (&db); 37 37 gfits_db_close (&db); -
branches/cnb_branch_20090215/Ohana/src/libdvo/src/dvo_catalog.c
r20981 r21536 52 52 if (!strcasecmp (catformat, "PS1_DEV_1")) return (DVO_FORMAT_PS1_DEV_1); 53 53 if (!strcasecmp (catformat, "PS1_DEV_2")) return (DVO_FORMAT_PS1_DEV_2); 54 if (!strcasecmp (catformat, "PS1_V1")) return (DVO_FORMAT_PS1_V1); 54 55 return (DVO_FORMAT_UNDEF); 55 56 } -
branches/cnb_branch_20090215/Ohana/src/libdvo/src/dvo_catalog_raw.c
r20982 r21536 86 86 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 87 87 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 88 FORMAT_CASE (PS1_V1, PS1_V1); 88 89 89 90 default: … … 271 272 if (catalog[0].catformat == DVO_FORMAT_PS1_DEV_1) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PS1_DEV_1"); 272 273 if (catalog[0].catformat == DVO_FORMAT_PS1_DEV_2) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PS1_DEV_2"); 274 if (catalog[0].catformat == DVO_FORMAT_PS1_V1) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PS1_V1"); 273 275 274 276 /* rewind file pointers and truncate file */ … … 366 368 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 367 369 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 370 FORMAT_CASE (PS1_V1, PS1_V1); 368 371 369 372 default: … … 412 415 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 413 416 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 417 FORMAT_CASE (PS1_V1, PS1_V1); 414 418 415 419 default: … … 462 466 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 463 467 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 468 FORMAT_CASE (PS1_V1, PS1_V1); 464 469 465 470 default: … … 508 513 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 509 514 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 515 FORMAT_CASE (PS1_V1, PS1_V1); 510 516 511 517 default: … … 558 564 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 559 565 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 566 FORMAT_CASE (PS1_V1, PS1_V1); 560 567 561 568 default: … … 604 611 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 605 612 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 613 FORMAT_CASE (PS1_V1, PS1_V1); 606 614 607 615 default: -
branches/cnb_branch_20090215/Ohana/src/libdvo/src/dvo_convert.c
r19185 r21536 49 49 CONVERT_FORMAT ("DVO_AVERAGE_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1); 50 50 CONVERT_FORMAT ("DVO_AVERAGE_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2); 51 CONVERT_FORMAT ("DVO_AVERAGE_PS1_V1", PS1_V1, PS1_V1); 51 52 # undef CONVERT_FORMAT 52 53 … … 79 80 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 80 81 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 82 FORMAT_CASE (PS1_V1, PS1_V1); 81 83 # undef FORMAT_CASE 82 84 … … 122 124 CONVERT_FORMAT ("DVO_MEASURE_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1); 123 125 CONVERT_FORMAT ("DVO_MEASURE_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2); 126 CONVERT_FORMAT ("DVO_MEASURE_PS1_V1", PS1_V1, PS1_V1); 124 127 # undef CONVERT_FORMAT 125 128 … … 152 155 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 153 156 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 157 FORMAT_CASE (PS1_V1, PS1_V1); 154 158 # undef FORMAT_CASE 155 159 … … 195 199 CONVERT_FORMAT ("DVO_SECFILT_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1); 196 200 CONVERT_FORMAT ("DVO_SECFILT_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2); 201 CONVERT_FORMAT ("DVO_SECFILT_PS1_V1", PS1_V1, PS1_V1); 197 202 # undef CONVERT_FORMAT 198 203 … … 225 230 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 226 231 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 232 FORMAT_CASE (PS1_V1, PS1_V1); 227 233 # undef FORMAT_CASE 228 234 … … 288 294 CONVERT_FORMAT ("DVO_IMAGE_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1); 289 295 CONVERT_FORMAT ("DVO_IMAGE_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2); 290 CONVERT_FORMAT ("DVO_IMAGE_PS1_DEV_3", PS1_DEV_3, PS1_DEV_3); 296 CONVERT_FORMAT ("DVO_IMAGE_PS1_V1", PS1_V1, PS1_V1); 297 298 // XXX Not sure this was ever actually used -- it was not complete... 299 // CONVERT_FORMAT ("DVO_IMAGE_PS1_DEV_3", PS1_DEV_3, PS1_DEV_3); 300 291 301 # undef CONVERT_FORMAT 292 302 … … 322 332 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 323 333 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 324 FORMAT_CASE (PS1_DEV_3, PS1_DEV_3); 334 FORMAT_CASE (PS1_V1, PS1_V1); 335 336 // XXX not sure this was actually used: it was incomplete 337 // FORMAT_CASE (PS1_DEV_3, PS1_DEV_3); 325 338 # undef FORMAT_CASE 326 339 … … 372 385 FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 373 386 FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 374 FORMAT_CASE (PS1_DEV_3, PS1_DEV_3); 387 FORMAT_CASE (PS1_V1, PS1_V1); 388 389 // XXX not sure this was used, it was incomplete 390 // FORMAT_CASE (PS1_DEV_3, PS1_DEV_3); 391 375 392 # undef FORMAT_CASE 376 393 -
branches/cnb_branch_20090215/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_1.c
r19185 r21536 15 15 out[i].M = in[i].M; 16 16 out[i].Mcal = in[i].Mcal; 17 out[i].Map = in[i].Mgal;18 17 out[i].dM = in[i].dM; 19 18 out[i].dt = in[i].dt; … … 28 27 out[i].detID = in[i].detID; 29 28 out[i].imageID = in[i].imageID; 30 out[i]. qPSF = in[i].qPSF;29 out[i].psfQual = in[i].psfQual; 31 30 out[i].psfChisq = in[i].psfChisq; 32 31 out[i].crNsigma = in[i].crNsigma; … … 40 39 out[i].dbFlags = in[i].dbFlags; 41 40 out[i].photFlags = in[i].photFlags; 42 out[i].stargal = in[i].stargal; 43 out[i].dophot = in[i].dophot; 41 42 // changed or added for PS1_DEV_2 43 out[i].Map = in[i].Mgal; 44 out[i].dMcal = 0; 45 46 // changed or added for PS1_V1 47 out[i].photFlags = in[i].photFlags | (in[i].dophot << 16); 48 out[i].t_msec = 0; 49 out[i].extID = 0; 50 out[i].objID = 0; 51 out[i].catID = 0; 52 out[i].Mxx = 0.0; 53 out[i].Mxy = 0.0; 54 out[i].Myy = 0.0; 55 out[i].posangle = 0; 56 out[i].pltscale = 0; 57 out[i].psfNdof = 0; 58 out[i].psfNpix = 0; 44 59 } 45 60 return (out); … … 58 73 out[i].M = in[i].M; 59 74 out[i].Mcal = in[i].Mcal; 60 out[i].Mgal = in[i].Map;61 75 out[i].dM = in[i].dM; 62 76 out[i].dt = in[i].dt; … … 71 85 out[i].detID = in[i].detID; 72 86 out[i].imageID = in[i].imageID; 73 out[i]. qPSF = in[i].qPSF;87 out[i].psfQual = in[i].psfQual; 74 88 out[i].psfChisq = in[i].psfChisq; 75 89 out[i].crNsigma = in[i].crNsigma; … … 82 96 out[i].dYccd = in[i].dYccd; 83 97 out[i].dbFlags = in[i].dbFlags; 84 out[i].photFlags = in[i].photFlags; 85 out[i].stargal = in[i].stargal; 86 out[i].dophot = in[i].dophot; 98 99 // changed or added for PS1_DEV_2 100 out[i].Mgal = in[i].Map; 101 102 // changed or added for PS1_V1 103 out[i].photFlags = in[i].photFlags & 0x0000ffff; 104 out[i].dophot = in[i].photFlags >> 16; 87 105 } 88 106 return (out); … … 101 119 out[i].D = in[i].D; 102 120 out[i].Xp = in[i].Xp; 103 out[i].Nmeasure = in[i].Nm;104 out[i].Nmissing = in[i].Nn;105 out[i].code = in[i].code;106 out[i].measureOffset = in[i].offset;107 out[i].missingOffset = in[i].missing;108 121 out[i].dR = in[i].dR; 109 122 out[i].dD = in[i].dD; … … 116 129 out[i].objID = in[i].objID; 117 130 out[i].catID = in[i].catID; 131 132 // changed or added for PS1_DEV_2 133 out[i].Nmeasure = in[i].Nm; 134 out[i].Nmissing = in[i].Nn; 135 out[i].measureOffset = in[i].offset; 136 out[i].missingOffset = in[i].missing; 137 out[i].Nextend = 0; 138 out[i].extendOffset = 0; 139 140 // changed or added for PS1_V1 141 out[i].flags = in[i].code; 142 out[i].ChiSq = 0.0; 143 out[i].Npos = 0.0; 144 out[i].extID = 0; 118 145 } 119 146 return (out); … … 129 156 130 157 for (i = 0; i < Nvalues; i++) { 131 out[i].R = in[i].R; 132 out[i].D = in[i].D; 133 out[i].Xp = in[i].Xp; 134 out[i].Nm = in[i].Nmeasure; 135 out[i].Nn = in[i].Nmissing; 136 out[i].code = in[i].code; 137 out[i].offset = in[i].measureOffset; 138 out[i].missing = in[i].missingOffset; 139 out[i].dR = in[i].dR; 140 out[i].dD = in[i].dD; 141 out[i].uR = in[i].uR; 142 out[i].uD = in[i].uD; 143 out[i].duR = in[i].duR; 144 out[i].duD = in[i].duD; 145 out[i].P = in[i].P; 146 out[i].dP = in[i].dP; 147 out[i].objID = in[i].objID; 148 out[i].catID = in[i].catID; 158 out[i].R = in[i].R; 159 out[i].D = in[i].D; 160 out[i].Xp = in[i].Xp; 161 out[i].dR = in[i].dR; 162 out[i].dD = in[i].dD; 163 out[i].uR = in[i].uR; 164 out[i].uD = in[i].uD; 165 out[i].duR = in[i].duR; 166 out[i].duD = in[i].duD; 167 out[i].P = in[i].P; 168 out[i].dP = in[i].dP; 169 out[i].objID = in[i].objID; 170 out[i].catID = in[i].catID; 171 172 // changed or added for PS1_DEV_2 173 out[i].Nm = in[i].Nmeasure; 174 out[i].Nn = in[i].Nmissing; 175 out[i].offset = in[i].measureOffset; 176 out[i].missing = in[i].missingOffset; 177 178 // changed or added for PS1_V1 179 out[i].code = in[i].flags; 149 180 } 150 181 return (out); … … 164 195 out[i].Ncode = in[i].Ncode; 165 196 out[i].Nused = in[i].Nused; 197 198 // changed or added for PS1_V1 199 out[i].M_20 = 0; 200 out[i].M_80 = 0; 166 201 } 167 202 return (out); … … 218 253 out[i].fwhm_y = in[i].fwhm_y; 219 254 out[i].trate = in[i].trate; 220 out[i].code = in[i].code;221 255 out[i].ccdnum = in[i].ccdnum; 222 256 out[i].imageID = in[i].imageID; … … 237 271 out[i].Mxyyy = in[i].Mxyyy; 238 272 out[i].Myyyy = in[i].Myyyy; 273 274 // changed or added for PS1_DEV_2 275 out[i].externID = 0; 276 out[i].sourceID = 0; 277 278 // changed or added for PS1_V1 279 out[i].flags = in[i].code; 280 out[i].parentID = 0; 239 281 } 240 282 return (out); … … 275 317 out[i].fwhm_y = in[i].fwhm_y; 276 318 out[i].trate = in[i].trate; 277 out[i].code = in[i].code;278 319 out[i].ccdnum = in[i].ccdnum; 279 320 out[i].imageID = in[i].imageID; … … 294 335 out[i].Mxyyy = in[i].Mxyyy; 295 336 out[i].Myyyy = in[i].Myyyy; 337 338 // changed or added for PS1_V1 339 out[i].code = in[i].flags; 340 } 341 return (out); 342 } 343 344 PhotCode *PhotCode_PS1_DEV_1_To_Internal (PhotCode_PS1_DEV_1 *in, int Nvalues) { 345 346 int i; 347 PhotCode *out; 348 349 ALLOCATE (out, PhotCode, Nvalues); 350 351 for (i = 0; i < Nvalues; i++) { 352 strncpy (out[i].name, in[i].name, 31); // out[32], in[32] 353 out[i].name[31] = 0; // force termination 354 355 out[i].code = in[i].code; 356 out[i].type = in[i].type; 357 out[i].C = in[i].C; 358 out[i].dC = in[i].dC; 359 out[i].dX = in[i].dX; 360 out[i].K = in[i].K; 361 out[i].c1 = in[i].c1; 362 out[i].c2 = in[i].c2; 363 out[i].equiv = in[i].equiv; 364 out[i].Nc = in[i].Nc; 365 memcpy (out[i].X, in[i].X, 4*sizeof(float)); 366 367 out[i].astromErrMagScale = in[i].astromErrMagScale; 368 out[i].photomErrSys = in[i].photomErrSys; 369 370 // changed or added for PS1_DEV_2 371 out[i].astromErrSys = 0.0; 372 out[i].astromErrScale = 0.0; 373 374 // changed or added for PS1_V1 (also PS1_DEV_3, deprecated) 375 out[i].photomPoorMask = 0; 376 out[i].photomBadMask = 0; 377 out[i].astromPoorMask = 0; 378 out[i].astromBadMask = 0; 296 379 } 297 380 return (out); … … 323 406 out[i].astromErrMagScale = out[i].astromErrMagScale; 324 407 out[i].photomErrSys = out[i].photomErrSys; 325 326 } 327 return (out); 328 } 329 330 PhotCode *PhotCode_PS1_DEV_1_To_Internal (PhotCode_PS1_DEV_1 *in, int Nvalues) { 331 332 int i; 333 PhotCode *out; 334 335 ALLOCATE (out, PhotCode, Nvalues); 336 337 for (i = 0; i < Nvalues; i++) { 338 strncpy (out[i].name, in[i].name, 31); // out[32], in[32] 339 out[i].name[31] = 0; // force termination 340 341 out[i].code = in[i].code; 342 out[i].type = in[i].type; 343 out[i].C = in[i].C; 344 out[i].dC = in[i].dC; 345 out[i].dX = in[i].dX; 346 out[i].K = in[i].K; 347 out[i].c1 = in[i].c1; 348 out[i].c2 = in[i].c2; 349 out[i].equiv = in[i].equiv; 350 out[i].Nc = in[i].Nc; 351 352 // not defined in PS1_DEV_1 353 out[i].astromErrSys = 0.0; 354 out[i].astromErrScale = 0.0; 355 out[i].astromErrMagScale = in[i].astromErrMagScale; 356 out[i].photomErrSys = in[i].photomErrSys; 357 358 memcpy (out[i].X, in[i].X, 4*sizeof(float)); 359 360 out[i].photomPoorMask = 0; 361 out[i].photomBadMask = 0; 362 out[i].astromPoorMask = 0; 363 out[i].astromBadMask = 0; 364 } 365 return (out); 366 } 408 } 409 return (out); 410 } -
branches/cnb_branch_20090215/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c
r19185 r21536 29 29 out[i].detID = in[i].detID; 30 30 out[i].imageID = in[i].imageID; 31 out[i]. qPSF = in[i].qPSF;31 out[i].psfQual = in[i].psfQual; 32 32 out[i].psfChisq = in[i].psfChisq; 33 33 out[i].crNsigma = in[i].crNsigma; … … 40 40 out[i].dYccd = in[i].dYccd; 41 41 out[i].dbFlags = in[i].dbFlags; 42 out[i].photFlags = in[i].photFlags; 43 out[i].stargal = in[i].stargal; 44 out[i].dophot = in[i].dophot; 42 43 // changed or added for PS1_V1 44 out[i].photFlags = in[i].photFlags | (in[i].dophot << 16); 45 out[i].t_msec = 0; 46 out[i].extID = 0; 47 out[i].objID = 0; 48 out[i].catID = 0; 49 out[i].Mxx = 0.0; 50 out[i].Mxy = 0.0; 51 out[i].Myy = 0.0; 52 out[i].posangle = 0; 53 out[i].pltscale = 0; 54 out[i].psfNdof = 0; 55 out[i].psfNpix = 0; 45 56 } 46 57 return (out); … … 73 84 out[i].detID = in[i].detID; 74 85 out[i].imageID = in[i].imageID; 75 out[i]. qPSF = in[i].qPSF;86 out[i].psfQual = in[i].psfQual; 76 87 out[i].psfChisq = in[i].psfChisq; 77 88 out[i].crNsigma = in[i].crNsigma; … … 84 95 out[i].dYccd = in[i].dYccd; 85 96 out[i].dbFlags = in[i].dbFlags; 86 out[i].photFlags = in[i].photFlags; 87 out[i].stargal = in[i].stargal; 88 out[i].dophot = in[i].dophot; 97 98 // changed or added for PS1_V1 99 out[i].photFlags = in[i].photFlags & 0x0000ffff; 100 out[i].dophot = in[i].photFlags >> 16; 89 101 } 90 102 return (out); … … 114 126 out[i].Nmissing = in[i].Nmissing; 115 127 out[i].Nextend = in[i].Nextend; 116 out[i].code = in[i].code;117 128 out[i].measureOffset = in[i].measureOffset; 118 129 out[i].missingOffset = in[i].missingOffset; … … 120 131 out[i].objID = in[i].objID; 121 132 out[i].catID = in[i].catID; 133 134 // changed or added for PS1_V1 135 out[i].flags = in[i].code; 136 out[i].ChiSq = 0.0; 137 out[i].Npos = 0.0; 138 out[i].extID = 0; 122 139 } 123 140 return (out); … … 147 164 out[i].Nmissing = in[i].Nmissing; 148 165 out[i].Nextend = in[i].Nextend; 149 out[i].code = in[i].code;150 166 out[i].measureOffset = in[i].measureOffset; 151 167 out[i].missingOffset = in[i].missingOffset; … … 153 169 out[i].objID = in[i].objID; 154 170 out[i].catID = in[i].catID; 171 172 // changed or added for PS1_V1 173 out[i].code = in[i].flags; 155 174 } 156 175 return (out); … … 170 189 out[i].Ncode = in[i].Ncode; 171 190 out[i].Nused = in[i].Nused; 191 192 // changed or added for PS1_V1 193 out[i].M_20 = 0; 194 out[i].M_80 = 0; 172 195 } 173 196 return (out); … … 201 224 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 202 225 203 strncpy (out[i].name, in[i].name, 63); // out[12 8], int[64]226 strncpy (out[i].name, in[i].name, 63); // out[121], int[64] 204 227 out[i].name[63] = 0; // force termination 205 228 … … 224 247 out[i].fwhm_y = in[i].fwhm_y; 225 248 out[i].trate = in[i].trate; 226 out[i].code = in[i].code;227 249 out[i].ccdnum = in[i].ccdnum; 228 250 out[i].imageID = in[i].imageID; … … 245 267 out[i].Mxyyy = in[i].Mxyyy; 246 268 out[i].Myyyy = in[i].Myyyy; 269 270 // changed or added for PS1_V1 271 out[i].flags = in[i].code; 272 out[i].parentID = 0; 247 273 } 248 274 return (out); … … 259 285 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 260 286 261 strncpy (out[i].name, in[i].name, 63); // in[12 8], out[64]287 strncpy (out[i].name, in[i].name, 63); // in[121], out[64] 262 288 out[i].name[63] = 0; // force termination 263 289 … … 282 308 out[i].fwhm_y = in[i].fwhm_y; 283 309 out[i].trate = in[i].trate; 284 out[i].code = in[i].code;285 310 out[i].ccdnum = in[i].ccdnum; 286 311 out[i].imageID = in[i].imageID; … … 303 328 out[i].Mxyyy = in[i].Mxyyy; 304 329 out[i].Myyyy = in[i].Myyyy; 305 } 306 return (out); 307 } 308 309 PhotCode_PS1_DEV_2 *PhotCode_Internal_To_PS1_DEV_2 (PhotCode *in, int Nvalues) { 310 311 int i; 312 PhotCode_PS1_DEV_2 *out; 313 314 ALLOCATE (out, PhotCode_PS1_DEV_2, Nvalues); 330 331 // changed or added for PS1_V1 332 out[i].code = in[i].flags; 333 } 334 return (out); 335 } 336 337 PhotCode *PhotCode_PS1_DEV_2_To_Internal (PhotCode_PS1_DEV_2 *in, int Nvalues) { 338 339 int i; 340 PhotCode *out; 341 342 ALLOCATE (out, PhotCode, Nvalues); 315 343 316 344 for (i = 0; i < Nvalues; i++) { … … 334 362 out[i].astromErrMagScale = in[i].astromErrMagScale; 335 363 out[i].photomErrSys = in[i].photomErrSys; 336 } 337 return (out); 338 } 339 340 PhotCode *PhotCode_PS1_DEV_2_To_Internal (PhotCode_PS1_DEV_2 *in, int Nvalues) { 341 342 int i; 343 PhotCode *out; 344 345 ALLOCATE (out, PhotCode, Nvalues); 364 365 // changed or added for PS1_V1 (also PS1_DEV_3, deprecated) 366 out[i].photomPoorMask = 0; 367 out[i].photomBadMask = 0; 368 out[i].astromPoorMask = 0; 369 out[i].astromBadMask = 0; 370 } 371 return (out); 372 } 373 374 PhotCode_PS1_DEV_2 *PhotCode_Internal_To_PS1_DEV_2 (PhotCode *in, int Nvalues) { 375 376 int i; 377 PhotCode_PS1_DEV_2 *out; 378 379 ALLOCATE (out, PhotCode_PS1_DEV_2, Nvalues); 346 380 347 381 for (i = 0; i < Nvalues; i++) { … … 365 399 out[i].astromErrMagScale = in[i].astromErrMagScale; 366 400 out[i].photomErrSys = in[i].photomErrSys; 367 368 out[i].photomPoorMask = 0; 369 out[i].photomBadMask = 0; 370 out[i].astromPoorMask = 0; 371 out[i].astromBadMask = 0; 372 } 373 return (out); 374 } 401 } 402 return (out); 403 } -
branches/cnb_branch_20090215/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_3.c
r19185 r21536 3 3 /* convert PS1_DEV_3 formats to internal formats */ 4 4 5 // XXX EAM I am not yet ready to commit to a full PS1_DEV_3 release, but I am providingimage and photcode conversion5 // We only provide image and photcode conversion 6 6 7 7 Image *Image_PS1_DEV_3_ToInternal (Image_PS1_DEV_3 *in, int Nvalues) { … … 38 38 out[i].fwhm_y = in[i].fwhm_y; 39 39 out[i].trate = in[i].trate; 40 out[i].code = in[i].code;41 40 out[i].ccdnum = in[i].ccdnum; 42 41 out[i].imageID = in[i].imageID; … … 59 58 out[i].Mxyyy = in[i].Mxyyy; 60 59 out[i].Myyyy = in[i].Myyyy; 60 61 // changed or added for PS1_V1 62 out[i].flags = in[i].code; 63 out[i].parentID = 0; 61 64 } 62 65 return (out); … … 96 99 out[i].fwhm_y = in[i].fwhm_y; 97 100 out[i].trate = in[i].trate; 98 out[i].code = in[i].code;99 101 out[i].ccdnum = in[i].ccdnum; 100 102 out[i].imageID = in[i].imageID; … … 117 119 out[i].Mxyyy = in[i].Mxyyy; 118 120 out[i].Myyyy = in[i].Myyyy; 121 122 // changed or added for PS1_V1 123 out[i].code = in[i].flags; 124 } 125 return (out); 126 } 127 128 PhotCode *PhotCode_PS1_DEV_3_To_Internal (PhotCode_PS1_DEV_3 *in, int Nvalues) { 129 130 int i; 131 PhotCode *out; 132 133 ALLOCATE (out, PhotCode, Nvalues); 134 135 for (i = 0; i < Nvalues; i++) { 136 strncpy (out[i].name, in[i].name, 31); // out[32], in[32] 137 out[i].name[31] = 0; // force termination 138 139 out[i].code = in[i].code; 140 out[i].type = in[i].type; 141 out[i].C = in[i].C; 142 out[i].dC = in[i].dC; 143 out[i].dX = in[i].dX; 144 out[i].K = in[i].K; 145 out[i].c1 = in[i].c1; 146 out[i].c2 = in[i].c2; 147 out[i].equiv = in[i].equiv; 148 out[i].Nc = in[i].Nc; 149 memcpy (out[i].X, in[i].X, 4*sizeof(float)); 150 151 out[i].astromErrSys = in[i].astromErrSys; 152 out[i].astromErrScale = in[i].astromErrScale; 153 out[i].astromErrMagScale = in[i].astromErrMagScale; 154 out[i].photomErrSys = in[i].photomErrSys; 155 156 out[i].photomPoorMask = in[i].photomPoorMask; 157 out[i].photomBadMask = in[i].photomBadMask; 158 out[i].astromPoorMask = in[i].astromPoorMask; 159 out[i].astromBadMask = in[i].astromBadMask; 119 160 } 120 161 return (out); … … 157 198 } 158 199 159 PhotCode *PhotCode_PS1_DEV_3_To_Internal (PhotCode_PS1_DEV_3 *in, int Nvalues) {160 161 int i;162 PhotCode *out;163 164 ALLOCATE (out, PhotCode, Nvalues);165 166 for (i = 0; i < Nvalues; i++) {167 strncpy (out[i].name, in[i].name, 31); // out[32], in[32]168 out[i].name[31] = 0; // force termination169 170 out[i].code = in[i].code;171 out[i].type = in[i].type;172 out[i].C = in[i].C;173 out[i].dC = in[i].dC;174 out[i].dX = in[i].dX;175 out[i].K = in[i].K;176 out[i].c1 = in[i].c1;177 out[i].c2 = in[i].c2;178 out[i].equiv = in[i].equiv;179 out[i].Nc = in[i].Nc;180 memcpy (out[i].X, in[i].X, 4*sizeof(float));181 182 out[i].astromErrSys = in[i].astromErrSys;183 out[i].astromErrScale = in[i].astromErrScale;184 out[i].astromErrMagScale = in[i].astromErrMagScale;185 out[i].photomErrSys = in[i].photomErrSys;186 187 out[i].photomPoorMask = in[i].photomPoorMask;188 out[i].photomBadMask = in[i].photomBadMask;189 out[i].astromPoorMask = in[i].astromPoorMask;190 out[i].astromBadMask = in[i].astromBadMask;191 }192 return (out);193 } -
branches/cnb_branch_20090215/Ohana/src/libdvo/src/dvo_convert_elixir.c
r19185 r21536 10 10 11 11 for (i = 0; i < Nvalues; i++) { 12 out[i].FWx = in[i].FWx; 13 out[i].t = in[i].t; 14 out[i].averef = in[i].averef; 15 16 // changed for PANSTARRS_DEV_0 12 17 out[i].dR = (in[i].dR == NAN_S_SHORT) ? NAN : in[i].dR * 0.01; 13 18 out[i].dD = (in[i].dD == NAN_S_SHORT) ? NAN : in[i].dD * 0.01; … … 16 21 out[i].dt = (in[i].dt == NAN_S_SHORT) ? NAN : in[i].dt * 0.001; 17 22 out[i].Mcal = (in[i].Mcal == NAN_S_SHORT) ? NAN : in[i].Mcal * 0.001; 18 19 // 2008.02.26 : I've renamed Mgal to Map, and intend it to be used per aperture20 // magnitudes. Most uses of Mgal in the past were actually aperture (isophotal) mags21 23 out[i].Map = (in[i].Mgal == NAN_S_SHORT) ? NAN : in[i].Mgal * 0.001; 22 24 out[i].airmass = (in[i].airmass == NAN_S_SHORT) ? NAN : in[i].airmass* 0.001; 23 out[i].FWx = in[i].FWx;24 25 out[i].FWy = in[i].fwy * in[i].FWx * 0.01; 25 26 out[i].theta = in[i].theta*(0x10000 / 0x100); 26 out[i].dophot = in[i].dophot;27 27 out[i].photcode = in[i].source; 28 out[i].t = in[i].t;29 out[i].averef = in[i].averef;30 out[i].dbFlags = in[i].flags;31 28 32 /* these can be determined if needed / desired */ 33 out[i].Xccd = 0; 34 out[i].Yccd = 0; 35 out[i].dXccd = 0; 36 out[i].dYccd = 0; 37 38 /* these do not have a corresponding value */ 29 // added for PANSTARRS_DEV_0 30 out[i].Xccd = 0; // determine on-the-fly 31 out[i].Yccd = 0; // determine on-the-fly 32 out[i].dXccd = 0; 33 out[i].dYccd = 0; 39 34 out[i].az = 0; 40 out[i].stargal = 0;41 35 out[i].Sky = 0; 42 36 out[i].dSky = 0; 43 out[i]. qPSF= 0;37 out[i].psfQual = 0; 44 38 out[i].psfChisq = 0; 45 39 out[i].crNsigma = 0; 46 40 out[i].extNsigma = 0; 47 out[i].photFlags = 0; 48 49 /* XXX add these later */ 50 out[i].detID = 0; 51 out[i].imageID = 0; 41 out[i].detID = 0; // determine on-the-fly 42 out[i].imageID = 0; // determine on-the-fly 43 44 // changed or added for PS1_DEV_1 (2008.02.26) 45 out[i].dbFlags = in[i].flags; 46 out[i].detID = 0; 47 out[i].imageID = 0; 48 49 // changed or added for PS1_DEV_2 50 out[i].Map = in[i].Mgal; 51 out[i].dMcal = 0; 52 53 // changed or added for PS1_V1 54 out[i].photFlags = in[i].dophot << 16; 55 out[i].t_msec = 0; 56 out[i].extID = 0; 57 out[i].objID = 0; 58 out[i].catID = 0; 59 out[i].Mxx = 0.0; 60 out[i].Mxy = 0.0; 61 out[i].Myy = 0.0; 62 out[i].posangle = 0; 63 out[i].pltscale = 0; 64 out[i].psfNdof = 0; 65 out[i].psfNpix = 0; 52 66 } 53 67 return (out); … … 63 77 64 78 for (i = 0; i < Nvalues; i++) { 79 out[i].FWx = in[i].FWx; 80 out[i].t = in[i].t; 81 out[i].averef = in[i].averef; 82 83 // changed for PANSTARRS_DEV_0 65 84 out[i].dR = isnan(in[i].dR ) ? NAN_S_SHORT : in[i].dR * 100.0; 66 85 out[i].dD = isnan(in[i].dD ) ? NAN_S_SHORT : in[i].dD * 100.0; … … 71 90 out[i].Mgal = isnan(in[i].Map ) ? NAN_S_SHORT : in[i].Map * 1000.0; 72 91 out[i].airmass = isnan(in[i].airmass) ? NAN_S_SHORT : in[i].airmass * 1000.0; 92 out[i].fwy = in[i].FWy * 100.0 / in[i].FWx; 93 out[i].theta = in[i].theta*(0x100/ 0x10000); 94 out[i].source = in[i].photcode; 73 95 74 96 if (out[i].M < 0) { … … 76 98 } 77 99 78 out[i].FWx = in[i].FWx; 79 out[i].fwy = in[i].FWy * 100.0 / in[i].FWx; 80 out[i].theta = in[i].theta*(0x100/ 0x10000); 81 out[i].dophot = in[i].dophot; 82 out[i].source = in[i].photcode; 83 out[i].t = in[i].t; 84 out[i].averef = in[i].averef; 100 // changed or added for PS1_DEV_1 (2008.02.26) 85 101 out[i].flags = in[i].dbFlags; 102 103 // changed or added for PS1_V1 104 out[i].dophot = in[i].photFlags >> 16; 86 105 } 87 106 return (out); … … 101 120 out[i].D = in[i].D; 102 121 out[i].Xp = in[i].Xp; 103 out[i].Nmeasure = in[i].Nm; 104 out[i].Nmissing = in[i].Nn; 105 out[i].code = in[i].code; 106 out[i].measureOffset = in[i].offset; 107 out[i].missingOffset = in[i].missing; 108 109 /* these don't exist in Elixir */ 122 123 // changed for PANSTARRS_DEV_0 (moved from Average to Measure) 124 primary[0][i].M = (in[i].M == NAN_S_SHORT) ? NAN : in[i].M * 0.001; 125 primary[0][i].dM = (in[i].dM == NAN_S_SHORT) ? NAN : in[i].dM * 0.001; 126 primary[0][i].Xm = in[i].Xm; 127 128 primary[0][i].Ncode = 0; 129 primary[0][i].Nused = 0; 130 131 // added for PANSTARRS_DEV_0 110 132 out[i].dR = 0; 111 133 out[i].dD = 0; … … 116 138 out[i].P = 0; 117 139 out[i].dP = 0; 118 119 /* XXX add these later */ 120 out[i].objID = 0; 121 out[i].catID = 0; 122 123 primary[0][i].M = (in[i].M == NAN_S_SHORT) ? NAN : in[i].M * 0.001; 124 primary[0][i].dM = (in[i].dM == NAN_S_SHORT) ? NAN : in[i].dM * 0.001; 125 primary[0][i].Xm = in[i].Xm; 126 primary[0][i].Ncode = 0; 127 primary[0][i].Nused = 0; 140 out[i].objID = 0; // determine on-the-fly 141 out[i].catID = 0; // determine on-the-fly 142 143 // changed or added for PS1_DEV_2 144 out[i].Nmeasure = in[i].Nm; 145 out[i].Nmissing = in[i].Nn; 146 out[i].measureOffset = in[i].offset; 147 out[i].missingOffset = in[i].missing; 148 out[i].Nextend = 0; 149 out[i].extendOffset = 0; 150 151 // changed or added for PS1_V1 152 out[i].flags = in[i].code; 153 out[i].ChiSq = 0.0; 154 out[i].Npos = 0.0; 155 out[i].extID = 0; 128 156 } 129 157 return (out); … … 142 170 out[i].D = in[i].D; 143 171 out[i].Xp = in[i].Xp; 144 out[i].Nm = in[i].Nmeasure; 145 out[i].Nn = in[i].Nmissing; 146 out[i].code = in[i].code; 147 out[i].offset = in[i].measureOffset; 148 out[i].missing = in[i].missingOffset; 149 172 173 // changed for PANSTARRS_DEV_0 (moved from Average to Measure) 150 174 out[i].M = isnan(primary[i].M) ? NAN_S_SHORT : primary[i].M * 1000.0; 151 175 out[i].dM = isnan(primary[i].dM) ? NAN_S_SHORT : primary[i].dM * 1000.0; 152 176 out[i].Xm = primary[i].Xm; 177 178 // changed or added for PS1_DEV_2 179 out[i].Nm = in[i].Nmeasure; 180 out[i].Nn = in[i].Nmissing; 181 out[i].offset = in[i].measureOffset; 182 out[i].missing = in[i].missingOffset; 183 184 // changed or added for PS1_V1 185 out[i].code = in[i].flags; 153 186 } 154 187 return (out); … … 164 197 165 198 for (i = 0; i < Nvalues; i++) { 199 out[i].Xm = in[i].Xm; 200 201 // added or changed for PANSTARRS_DEV_0 166 202 out[i].M = (in[i].M == NAN_S_SHORT) ? NAN : in[i].M * 0.001; 167 203 out[i].dM = (in[i].dM == NAN_S_SHORT) ? NAN : in[i].dM * 0.001; 168 out[i].Xm = in[i].Xm;169 204 out[i].Ncode = 0; 170 205 out[i].Nused = 0; 206 207 // changed or added for PS1_V1 208 out[i].M_20 = 0; 209 out[i].M_80 = 0; 171 210 } 172 211 return (out); … … 182 221 183 222 for (i = 0; i < Nvalues; i++) { 223 out[i].Xm = in[i].Xm; 224 225 // added or changed for PANSTARRS_DEV_0 184 226 out[i].M = isnan(in[i].M) ? NAN_S_SHORT : in[i].M * 1000.0; 185 227 out[i].dM = isnan(in[i].dM) ? NAN_S_SHORT : in[i].dM * 1000.0; 186 out[i].Xm = in[i].Xm;187 228 } 188 229 return (out); … … 207 248 out[i].NX = in[i].NX; 208 249 out[i].NY = in[i].NY; 209 out[i].secz = (in[i].secz == NAN_S_SHORT) ? NAN : in[i].secz * 0.001;210 out[i].apmifit = (in[i].apmifit == NAN_S_SHORT) ? NAN : in[i].apmifit * 0.001;211 out[i].dapmifit = (in[i].dapmifit == NAN_S_SHORT) ? NAN : in[i].dapmifit * 0.001;212 out[i].Mcal = (in[i].Mcal == NAN_S_SHORT) ? NAN : in[i].Mcal * 0.001;213 out[i].dMcal = (in[i].dMcal == NAN_S_SHORT) ? NAN : in[i].dMcal * 0.001;214 250 out[i].Xm = in[i].Xm; 215 251 out[i].photcode = in[i].source; … … 221 257 out[i].fwhm_y = in[i].fwhm_y; 222 258 out[i].trate = in[i].trate; 223 out[i].code = in[i].code;224 259 out[i].ccdnum = in[i].ccdnum; 225 260 … … 240 275 out[i].Myyyy = in[i].Myyyy; 241 276 242 /* XXX add these later */ 243 out[i].imageID = 0; 244 245 // not available in ELIXIR 277 // added or changed for PANSTARRS_DEV_0 278 out[i].secz = (in[i].secz == NAN_S_SHORT) ? NAN : in[i].secz * 0.001; 279 out[i].apmifit = (in[i].apmifit == NAN_S_SHORT) ? NAN : in[i].apmifit * 0.001; 280 out[i].dapmifit = (in[i].dapmifit == NAN_S_SHORT) ? NAN : in[i].dapmifit * 0.001; 281 out[i].Mcal = (in[i].Mcal == NAN_S_SHORT) ? NAN : in[i].Mcal * 0.001; 282 out[i].dMcal = (in[i].dMcal == NAN_S_SHORT) ? NAN : in[i].dMcal * 0.001; 246 283 out[i].sidtime = NAN; 247 284 out[i].latitude = NAN; 285 out[i].imageID = 0; // determine on-the-fly 286 287 // changed or added for PS1_DEV_2 288 out[i].externID = 0; 289 out[i].sourceID = 0; 290 291 // changed or added for PS1_V1 292 out[i].flags = in[i].code; 293 out[i].parentID = 0; 248 294 } 249 295 return (out); … … 268 314 out[i].NX = in[i].NX; 269 315 out[i].NY = in[i].NY; 270 out[i].secz = isnan(in[i].secz ) ? NAN_S_SHORT : in[i].secz * 1000.0; 271 out[i].apmifit = isnan(in[i].apmifit ) ? NAN_S_SHORT : in[i].apmifit * 1000.0; 272 out[i].dapmifit = isnan(in[i].dapmifit) ? NAN_S_SHORT : in[i].dapmifit * 1000.0; 273 out[i].Mcal = isnan(in[i].Mcal ) ? NAN_S_SHORT : in[i].Mcal * 1000.0; 274 out[i].dMcal = isnan(in[i].dMcal ) ? NAN_S_SHORT : in[i].dMcal * 1000.0; 316 275 317 out[i].Xm = in[i].Xm; 276 318 out[i].source = in[i].photcode; … … 282 324 out[i].fwhm_y = in[i].fwhm_y; 283 325 out[i].trate = in[i].trate; 284 out[i].code = in[i].code;285 326 out[i].ccdnum = in[i].ccdnum; 286 327 … … 300 341 out[i].Mxyyy = in[i].Mxyyy; 301 342 out[i].Myyyy = in[i].Myyyy; 302 } 303 return (out); 304 } 305 306 PhotCode_Elixir *PhotCode_Internal_To_Elixir (PhotCode *in, int Nvalues) { 307 308 int i; 309 PhotCode_Elixir *out; 310 311 ALLOCATE (out, PhotCode_Elixir, Nvalues); 343 344 // added or changed for PANSTARRS_DEV_0 345 out[i].secz = isnan(in[i].secz ) ? NAN_S_SHORT : in[i].secz * 1000.0; 346 out[i].apmifit = isnan(in[i].apmifit ) ? NAN_S_SHORT : in[i].apmifit * 1000.0; 347 out[i].dapmifit = isnan(in[i].dapmifit) ? NAN_S_SHORT : in[i].dapmifit * 1000.0; 348 out[i].Mcal = isnan(in[i].Mcal ) ? NAN_S_SHORT : in[i].Mcal * 1000.0; 349 out[i].dMcal = isnan(in[i].dMcal ) ? NAN_S_SHORT : in[i].dMcal * 1000.0; 350 351 // changed or added for PS1_V1 352 out[i].code = in[i].flags; 353 } 354 return (out); 355 } 356 357 PhotCode *PhotCode_Elixir_To_Internal (PhotCode_Elixir *in, int Nvalues) { 358 359 int i; 360 PhotCode *out; 361 362 ALLOCATE (out, PhotCode, Nvalues); 312 363 313 364 for (i = 0; i < Nvalues; i++) { … … 326 377 out[i].Nc = in[i].Nc; 327 378 memcpy (out[i].X, in[i].X, 4*sizeof(float)); 328 } 329 return (out); 330 } 331 332 PhotCode *PhotCode_Elixir_To_Internal (PhotCode_Elixir *in, int Nvalues) { 333 334 int i; 335 PhotCode *out; 336 337 ALLOCATE (out, PhotCode, Nvalues); 379 380 // changed or added for PS1_DEV_1 381 out[i].astromErrMagScale = 0.0; 382 out[i].photomErrSys = 0.0; 383 384 // changed or added for PS1_DEV_2 385 out[i].astromErrSys = 0.0; 386 out[i].astromErrScale = 0.0; 387 388 // changed or added for PS1_V1 (also PS1_DEV_3, deprecated) 389 out[i].photomPoorMask = 0; 390 out[i].photomBadMask = 0; 391 out[i].astromPoorMask = 0; 392 out[i].astromBadMask = 0; 393 } 394 return (out); 395 } 396 397 PhotCode_Elixir *PhotCode_Internal_To_Elixir (PhotCode *in, int Nvalues) { 398 399 int i; 400 PhotCode_Elixir *out; 401 402 ALLOCATE (out, PhotCode_Elixir, Nvalues); 338 403 339 404 for (i = 0; i < Nvalues; i++) { … … 352 417 out[i].Nc = in[i].Nc; 353 418 memcpy (out[i].X, in[i].X, 4*sizeof(float)); 354 355 // not defined in Elixir: 356 out[i].astromErrSys = 0.0; 357 out[i].astromErrScale = 0.0; 358 out[i].astromErrMagScale = 0.0; 359 out[i].photomErrSys = 0.0; 360 361 out[i].photomPoorMask = 0; 362 out[i].photomBadMask = 0; 363 out[i].astromPoorMask = 0; 364 out[i].astromBadMask = 0; 365 } 366 return (out); 367 } 419 } 420 return (out); 421 } -
branches/cnb_branch_20090215/Ohana/src/libdvo/src/dvo_convert_loneos.c
r19185 r21536 10 10 11 11 for (i = 0; i < Nvalues; i++) { 12 out[i].dR = (in[i].dR == NAN_S_SHORT) ? NAN : in[i].dR * 0.01; 13 out[i].dD = (in[i].dD == NAN_S_SHORT) ? NAN : in[i].dD * 0.01; 14 out[i].M = (in[i].M == NAN_S_SHORT) ? NAN : in[i].M * 0.001; 15 out[i].dM = (in[i].dM == NAN_U_CHAR) ? NAN : in[i].dM * 0.001; 16 out[i].Mcal = (in[i].Mcal == NAN_S_SHORT) ? NAN : in[i].Mcal * 0.001; 17 out[i].dophot = in[i].dophot; 18 out[i].photcode = in[i].source; 19 out[i].t = in[i].t; 20 21 /* flags and averef are now split */ 12 out[i].t = in[i].t; 13 14 // added or changed for ELIXIR 22 15 out[i].averef = in[i].averef & 0x00ffffff; 23 16 out[i].dbFlags = (in[i].averef & 0xff000000) >> 24; 24 25 /* these values don't exist in the Loneos format */ 26 27 // 2008.02.26 : I've renamed Mgal to Map, and intend it to be used per aperture 28 // magnitudes. Most uses of Mgal in the past were actually aperture (isophotal) mags 29 out[i].Map = out[i].M; 17 out[i].t = in[i].t; 30 18 out[i].dt = 0; 31 19 out[i].airmass = 0; 20 out[i].FWy = 0; 21 out[i].FWx = 0; 22 out[i].theta = 0; 23 24 // changed for PANSTARRS_DEV_0 25 out[i].dR = (in[i].dR == NAN_S_SHORT) ? NAN : in[i].dR * 0.01; 26 out[i].dD = (in[i].dD == NAN_S_SHORT) ? NAN : in[i].dD * 0.01; 27 out[i].M = (in[i].M == NAN_S_SHORT) ? NAN : in[i].M * 0.001; 28 out[i].dM = (in[i].dM == NAN_U_CHAR) ? NAN : in[i].dM * 0.001; 29 out[i].Mcal = (in[i].Mcal == NAN_S_SHORT) ? NAN : in[i].Mcal * 0.001; 30 out[i].Map = (in[i].M == NAN_S_SHORT) ? NAN : in[i].M * 0.001; 31 out[i].photcode = in[i].source; 32 33 // added for PANSTARRS_DEV_0 34 out[i].Xccd = 0; // determine on-the-fly 35 out[i].Yccd = 0; // determine on-the-fly 36 out[i].dXccd = 0; 37 out[i].dYccd = 0; 32 38 out[i].az = 0; 33 out[i].FWx = 0;34 out[i].FWy = 0;35 out[i].theta = 0;36 out[i].stargal = 0;37 39 out[i].Sky = 0; 38 40 out[i].dSky = 0; 39 out[i]. qPSF= 0;41 out[i].psfQual = 0; 40 42 out[i].psfChisq = 0; 41 43 out[i].crNsigma = 0; 42 44 out[i].extNsigma = 0; 43 out[i].photFlags = 0; 44 45 /* these can be determined if needed / desired */ 46 out[i].Xccd = 0; 47 out[i].Yccd = 0; 48 out[i].dXccd = 0; 49 out[i].dYccd = 0; 50 51 /* XXX add these later */ 52 out[i].detID = 0; 53 out[i].imageID = 0; 45 out[i].detID = 0; // determine on-the-fly 46 out[i].imageID = 0; // determine on-the-fly 47 48 // changed or added for PS1_DEV_1 (2008.02.26) 49 out[i].detID = 0; 50 out[i].imageID = 0; 51 52 // changed or added for PS1_DEV_2 53 out[i].dMcal = 0; 54 55 // changed or added for PS1_V1 56 out[i].photFlags = in[i].dophot << 16; 57 out[i].t_msec = 0; 58 out[i].extID = 0; 59 out[i].objID = 0; 60 out[i].catID = 0; 61 out[i].Mxx = 0.0; 62 out[i].Mxy = 0.0; 63 out[i].Myy = 0.0; 64 out[i].posangle = 0; 65 out[i].pltscale = 0; 66 out[i].psfNdof = 0; 67 out[i].psfNpix = 0; 54 68 } 55 69 return (out); … … 65 79 66 80 for (i = 0; i < Nvalues; i++) { 81 82 // changed for PANSTARRS_DEV_0 67 83 out[i].dR = isnan(in[i].dR ) ? NAN_S_SHORT : in[i].dR * 100.0; 68 84 out[i].dD = isnan(in[i].dD ) ? NAN_S_SHORT : in[i].dD * 100.0; … … 70 86 out[i].dM = isnan(in[i].dM ) ? NAN_U_CHAR : in[i].dM * 1000.0; 71 87 out[i].Mcal = isnan(in[i].Mcal ) ? NAN_S_SHORT : in[i].Mcal * 1000.0; 72 out[i].dophot = in[i].dophot;73 88 out[i].source = in[i].photcode; 74 89 out[i].t = in[i].t; … … 76 91 /* flags and averef are merged in Loneos */ 77 92 out[i].averef = (in[i].averef & 0x00ffffff) | (in[i].dbFlags << 24); 93 94 // changed or added for PS1_V1 95 out[i].dophot = in[i].photFlags >> 16; 78 96 } 79 97 return (out); … … 93 111 out[i].D = in[i].D; 94 112 out[i].Xp = in[i].Xp; 95 out[i].Nmeasure = in[i].Nm; 96 out[i].Nmissing = in[i].Nn; 97 out[i].code = in[i].code; 98 out[i].measureOffset = in[i].offset; 99 out[i].missingOffset = in[i].missing; 100 101 /* these don't exist in Loneos */ 113 114 // added for ELIXIR 115 primary[0][i].dM = NAN; 116 117 // changed for PANSTARRS_DEV_0 (moved from Average to Measure) 118 primary[0][i].M = (in[i].M == NAN_S_SHORT) ? NAN : in[i].M * 0.001; 119 primary[0][i].Xm = in[i].Xm; 120 primary[0][i].Ncode = 0; 121 primary[0][i].Nused = 0; 122 123 // added for PANSTARRS_DEV_0 102 124 out[i].dR = 0; 103 125 out[i].dD = 0; … … 108 130 out[i].P = 0; 109 131 out[i].dP = 0; 110 111 /* XXX add these later */ 112 out[i].objID = 0; 113 out[i].catID = 0; 114 115 primary[0][i].M = (in[i].M == NAN_S_SHORT) ? NAN : in[i].M * 0.001; 116 primary[0][i].Xm = in[i].Xm; 117 primary[0][i].dM = NAN; 118 primary[0][i].Ncode = 0; 119 primary[0][i].Nused = 0; 132 out[i].objID = 0; // determine on-the-fly 133 out[i].catID = 0; // determine on-the-fly 134 135 // changed or added for PS1_DEV_2 136 out[i].Nmeasure = in[i].Nm; 137 out[i].Nmissing = in[i].Nn; 138 out[i].measureOffset = in[i].offset; 139 out[i].missingOffset = in[i].missing; 140 out[i].Nextend = 0; 141 out[i].extendOffset = 0; 142 143 // changed or added for PS1_V1 144 out[i].flags = in[i].code; 145 out[i].ChiSq = 0.0; 146 out[i].Npos = 0.0; 147 out[i].extID = 0; 120 148 } 121 149 return (out); … … 134 162 out[i].D = in[i].D; 135 163 out[i].Xp = in[i].Xp; 164 165 // changed for PANSTARRS_DEV_0 (moved from Average to Measure) 166 out[i].M = isnan(primary[i].M) ? NAN_S_SHORT : primary[i].M * 1000.0; 167 out[i].Xm = primary[i].Xm; 168 169 // changed or added for PS1_DEV_2 136 170 out[i].Nm = in[i].Nmeasure; 137 171 out[i].Nn = in[i].Nmissing; 138 out[i].code = in[i].code;139 172 out[i].offset = in[i].measureOffset; 140 173 out[i].missing = in[i].missingOffset; 141 174 142 out[i].M = isnan(primary[i].M) ? NAN_S_SHORT : primary[i].M * 1000.0;143 out[i]. Xm = primary[i].Xm;175 // changed or added for PS1_V1 176 out[i].code = in[i].flags; 144 177 } 145 178 return (out); … … 155 188 156 189 for (i = 0; i < Nvalues; i++) { 190 out[i].Xm = in[i].Xm; 191 192 // added for ELIXIR 193 out[i].dM = NAN; 194 195 // added or changed for PANSTARRS_DEV_0 157 196 out[i].M = (in[i].M == NAN_S_SHORT) ? NAN : in[i].M * 0.001; 158 out[i].Xm = in[i].Xm;159 out[i].dM = NAN;160 197 out[i].Ncode = 0; 161 198 out[i].Nused = 0; 199 200 // changed or added for PS1_V1 201 out[i].M_20 = 0; 202 out[i].M_80 = 0; 162 203 } 163 204 return (out); … … 173 214 174 215 for (i = 0; i < Nvalues; i++) { 216 out[i].Xm = in[i].Xm; 217 218 // added or changed for PANSTARRS_DEV_0 175 219 out[i].M = isnan(in[i].M) ? NAN_S_SHORT : in[i].M * 1000.0; 176 out[i].Xm = in[i].Xm;177 220 } 178 221 return (out); … … 197 240 out[i].NX = in[i].NX; 198 241 out[i].NY = in[i].NY; 199 200 out[i].secz = (in[i].secz == NAN_S_SHORT) ? NAN : in[i].secz * 0.001;201 out[i].apmifit = (in[i].apmifit == NAN_S_SHORT) ? NAN : in[i].apmifit * 0.001;202 out[i].dapmifit = (in[i].dapmifit == NAN_S_SHORT) ? NAN : in[i].dapmifit * 0.001;203 out[i].Mcal = (in[i].Mcal == NAN_S_SHORT) ? NAN : in[i].Mcal * 0.001;204 out[i].dMcal = (in[i].dMcal == NAN_S_SHORT) ? NAN : in[i].dMcal * 0.001;205 242 206 243 out[i].Xm = in[i].Xm; … … 213 250 out[i].fwhm_y = in[i].fwhm_y; 214 251 out[i].trate = in[i].trate; 215 out[i].code = in[i].code;216 252 out[i].ccdnum = in[i].ccdnum; 253 217 254 out[i].order = in[i].order; 218 255 out[i].Mx = in[i].Mx; … … 231 268 out[i].Myyyy = in[i].Myyyy; 232 269 233 /* XXX add these later */ 234 out[i].imageID = 0; 270 // added or changed for PANSTARRS_DEV_0 271 out[i].secz = (in[i].secz == NAN_S_SHORT) ? NAN : in[i].secz * 0.001; 272 out[i].apmifit = (in[i].apmifit == NAN_S_SHORT) ? NAN : in[i].apmifit * 0.001; 273 out[i].dapmifit = (in[i].dapmifit == NAN_S_SHORT) ? NAN : in[i].dapmifit * 0.001; 274 out[i].Mcal = (in[i].Mcal == NAN_S_SHORT) ? NAN : in[i].Mcal * 0.001; 275 out[i].dMcal = (in[i].dMcal == NAN_S_SHORT) ? NAN : in[i].dMcal * 0.001; 276 out[i].sidtime = NAN; 277 out[i].latitude = NAN; 278 out[i].imageID = 0; // determine on-the-fly 279 280 // changed or added for PS1_DEV_2 281 out[i].externID = 0; 282 out[i].sourceID = 0; 283 284 // changed or added for PS1_V1 285 out[i].flags = in[i].code; 286 out[i].parentID = 0; 235 287 } 236 288 return (out); … … 255 307 out[i].NX = in[i].NX; 256 308 out[i].NY = in[i].NY; 257 258 out[i].secz = isnan(in[i].secz ) ? NAN_S_SHORT : in[i].secz * 1000.0;259 out[i].apmifit = isnan(in[i].apmifit ) ? NAN_S_SHORT : in[i].apmifit * 1000.0;260 out[i].dapmifit = isnan(in[i].dapmifit) ? NAN_S_SHORT : in[i].dapmifit * 1000.0;261 out[i].Mcal = isnan(in[i].Mcal ) ? NAN_S_SHORT : in[i].Mcal * 1000.0;262 out[i].dMcal = isnan(in[i].dMcal ) ? NAN_S_SHORT : in[i].dMcal * 1000.0;263 309 264 310 out[i].Xm = in[i].Xm; … … 271 317 out[i].fwhm_y = in[i].fwhm_y; 272 318 out[i].trate = in[i].trate; 273 out[i].code = in[i].code;274 319 out[i].ccdnum = in[i].ccdnum; 320 275 321 out[i].order = in[i].order; 276 322 out[i].Mx = in[i].Mx; … … 288 334 out[i].Mxyyy = in[i].Mxyyy; 289 335 out[i].Myyyy = in[i].Myyyy; 290 } 291 return (out); 292 } 336 337 // added or changed for PANSTARRS_DEV_0 338 out[i].secz = isnan(in[i].secz ) ? NAN_S_SHORT : in[i].secz * 1000.0; 339 out[i].apmifit = isnan(in[i].apmifit ) ? NAN_S_SHORT : in[i].apmifit * 1000.0; 340 out[i].dapmifit = isnan(in[i].dapmifit) ? NAN_S_SHORT : in[i].dapmifit * 1000.0; 341 out[i].Mcal = isnan(in[i].Mcal ) ? NAN_S_SHORT : in[i].Mcal * 1000.0; 342 out[i].dMcal = isnan(in[i].dMcal ) ? NAN_S_SHORT : in[i].dMcal * 1000.0; 343 344 // changed or added for PS1_V1 345 out[i].code = in[i].flags; 346 } 347 return (out); 348 } -
branches/cnb_branch_20090215/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c
r19185 r21536 16 16 out[i].Mcal = in[i].Mcal; 17 17 18 // 2008.02.26 : I've renamed Mgal to Map, and intend it to be used per aperture19 // magnitudes. Most uses of Mgal in the past were actually aperture (isophotal) mags20 out[i].Map = in[i].Mgal;21 18 out[i].airmass = in[i].airmass; 22 19 out[i].az = in[i].az; … … 25 22 out[i].FWy = in[i].FWy; 26 23 out[i].theta = in[i].theta; 27 out[i].dophot = in[i].dophot;28 24 out[i].photcode = in[i].photcode; 29 25 out[i].t = in[i].t; 30 26 out[i].averef = in[i].averef; 31 out[i].dbFlags = in[i].flags;32 27 out[i].Xccd = in[i].Xccd; 33 28 out[i].Yccd = in[i].Yccd; 34 29 out[i].dXccd = in[i].dXccd; 35 30 out[i].dYccd = in[i].dYccd; 36 out[i].stargal = in[i].stargal;37 31 out[i].Sky = in[i].Sky; 38 32 out[i].dSky = in[i].dSky; 39 out[i].qPSF = (in[i].qPSF == NAN_S_SHORT) ? NAN : in[i].qPSF; 33 34 // 2008.02.26 : I've renamed Mgal to Map, and intend it to be used per aperture 35 // magnitudes. Most uses of Mgal in the past were actually aperture (isophotal) mags 36 37 // changed or added for PS1_DEV_1 (2008.02.26) 38 out[i].psfQual = (in[i].psfQual == NAN_S_SHORT) ? NAN : in[i].psfQual; 39 out[i].dbFlags = in[i].flags; 40 40 out[i].detID = in[i].detID_lo; 41 41 out[i].imageID = in[i].imageID_lo; 42 43 // these don't have a correspondence 44 out[i].psfChisq = 0; 45 out[i].crNsigma = 0; 46 out[i].extNsigma = 0; 47 out[i].photFlags = 0; 42 out[i].psfChisq = 0; 43 out[i].crNsigma = 0; 44 out[i].extNsigma = 0; 45 46 // changed or added for PS1_DEV_2 47 out[i].Map = in[i].Mgal; 48 out[i].dMcal = 0; 49 50 // changed or added for PS1_V1 51 out[i].photFlags = in[i].dophot << 16; 52 out[i].t_msec = 0; 53 out[i].extID = 0; 54 out[i].objID = 0; 55 out[i].catID = 0; 56 out[i].Mxx = 0.0; 57 out[i].Mxy = 0.0; 58 out[i].Myy = 0.0; 59 out[i].posangle = 0; 60 out[i].pltscale = 0; 61 out[i].psfNdof = 0; 62 out[i].psfNpix = 0; 48 63 } 49 64 return (out); … … 64 79 out[i].dM = in[i].dM; 65 80 out[i].Mcal = in[i].Mcal; 66 out[i].Mgal = in[i].Map;67 81 out[i].airmass = in[i].airmass; 68 82 out[i].az = in[i].az; … … 71 85 out[i].FWy = in[i].FWy; 72 86 out[i].theta = in[i].theta; 73 out[i].dophot = in[i].dophot;74 87 out[i].photcode = in[i].photcode; 75 88 out[i].t = in[i].t; 76 89 out[i].averef = in[i].averef; 77 out[i].flags = in[i].dbFlags;78 90 out[i].Xccd = in[i].Xccd; 79 91 out[i].Yccd = in[i].Yccd; 80 92 out[i].dXccd = in[i].dXccd; 81 93 out[i].dYccd = in[i].dYccd; 82 out[i].stargal = in[i].stargal;83 94 out[i].Sky = in[i].Sky; 84 95 out[i].dSky = in[i].dSky; 85 out[i].qPSF = isnan(in[i].qPSF) ? NAN_S_SHORT : in[i].qPSF; 96 97 // changed or added for PS1_DEV_1 (2008.02.26) 98 out[i].flags = in[i].dbFlags; 99 out[i].psfQual = isnan(in[i].psfQual) ? NAN_S_SHORT : in[i].psfQual; 86 100 out[i].detID_hi = 0; 87 101 out[i].detID_lo = in[i].detID; 88 102 out[i].imageID_hi = 0; 89 103 out[i].imageID_lo = in[i].imageID; 104 105 // changed or added for PS1_DEV_2 106 out[i].Mgal = in[i].Map; 107 108 // changed or added for PS1_V1 109 // out[i].photFlags = in[i].photFlags & 0x0000ffff; (only dophot pre PS1_DEV_1) 110 out[i].dophot = in[i].photFlags >> 16; 90 111 } 91 112 return (out); … … 105 126 out[i].D = in[i].D; 106 127 out[i].Xp = in[i].Xp; 107 out[i].Nmeasure = in[i].Nm;108 out[i].Nmissing = in[i].Nn;109 out[i].code = in[i].code;110 out[i].measureOffset = in[i].offset;111 out[i].missingOffset = in[i].missing;112 128 out[i].dR = in[i].dR; 113 129 out[i].dD = in[i].dD; … … 120 136 out[i].objID = in[i].objID; 121 137 out[i].catID = in[i].catID; 138 139 // changed or added for PS1_DEV_2 140 out[i].Nmeasure = in[i].Nm; 141 out[i].Nmissing = in[i].Nn; 142 out[i].measureOffset = in[i].offset; 143 out[i].missingOffset = in[i].missing; 144 out[i].Nextend = 0; 145 out[i].extendOffset = 0; 146 147 // changed or added for PS1_V1 148 out[i].flags = in[i].code; 149 out[i].ChiSq = 0.0; 150 out[i].Npos = 0.0; 151 out[i].extID = 0; 122 152 } 123 153 return (out); … … 137 167 out[i].D = in[i].D; 138 168 out[i].Xp = in[i].Xp; 139 out[i].Nm = in[i].Nmeasure;140 out[i].Nn = in[i].Nmissing;141 out[i].code = in[i].code;142 out[i].offset = in[i].measureOffset;143 out[i].missing = in[i].missingOffset;144 169 out[i].dR = in[i].dR; 145 170 out[i].dD = in[i].dD; … … 152 177 out[i].objID = in[i].objID; 153 178 out[i].catID = in[i].catID; 179 180 // changed or added for PS1_DEV_2 181 out[i].Nm = in[i].Nmeasure; 182 out[i].Nn = in[i].Nmissing; 183 out[i].offset = in[i].measureOffset; 184 out[i].missing = in[i].missingOffset; 185 186 // changed or added for PS1_V1 187 out[i].code = in[i].flags; 154 188 } 155 189 return (out); … … 170 204 out[i].Ncode = in[i].Ncode; 171 205 out[i].Nused = in[i].Nused; 206 207 // changed or added for PS1_V1 208 out[i].M_20 = 0; 209 out[i].M_80 = 0; 172 210 } 173 211 return (out); … … 226 264 out[i].fwhm_y = in[i].fwhm_y; 227 265 out[i].trate = in[i].trate; 228 out[i].code = in[i].code;229 266 out[i].ccdnum = in[i].ccdnum; 230 out[i].imageID = in[i].imageID_lo;231 267 232 268 out[i].order = in[i].order; … … 245 281 out[i].Mxyyy = in[i].Mxyyy; 246 282 out[i].Myyyy = in[i].Myyyy; 283 284 // changed or added for PS1_DEV_1 285 out[i].imageID = in[i].imageID_lo; 286 287 // changed or added for PS1_DEV_2 288 out[i].externID = 0; 289 out[i].sourceID = 0; 290 291 // changed or added for PS1_V1 292 out[i].flags = in[i].code; 293 out[i].parentID = 0; 247 294 } 248 295 return (out); … … 283 330 out[i].fwhm_y = in[i].fwhm_y; 284 331 out[i].trate = in[i].trate; 285 out[i].code = in[i].code;286 332 out[i].ccdnum = in[i].ccdnum; 287 out[i].imageID_hi = 0;288 out[i].imageID_lo = in[i].imageID;289 333 290 334 out[i].order = in[i].order; … … 303 347 out[i].Mxyyy = in[i].Mxyyy; 304 348 out[i].Myyyy = in[i].Myyyy; 305 } 306 return (out); 307 } 349 350 // changed or added for PS1_DEV_1 351 out[i].imageID_hi = 0; 352 out[i].imageID_lo = in[i].imageID; 353 354 // changed or added for PS1_V1 355 out[i].code = in[i].flags; 356 } 357 return (out); 358 } -
branches/cnb_branch_20090215/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c
r19185 r21536 16 16 out[i].Mcal = in[i].Mcal; 17 17 18 // 2008.02.26 : I've renamed Mgal to Map, and intend it to be used per aperture19 // magnitudes. Most uses of Mgal in the past were actually aperture (isophotal) mags20 out[i].Map = in[i].Mgal;21 18 out[i].airmass = in[i].airmass; 22 19 out[i].az = in[i].az; … … 25 22 out[i].FWy = in[i].FWy; 26 23 out[i].theta = in[i].theta; 27 out[i].dophot = in[i].dophot;28 24 out[i].photcode = in[i].photcode; 29 25 out[i].t = in[i].t; 30 26 out[i].averef = in[i].averef; 31 out[i].dbFlags = in[i].flags;32 27 out[i].Xccd = in[i].Xccd; 33 28 out[i].Yccd = in[i].Yccd; 34 29 out[i].dXccd = in[i].dXccd; 35 30 out[i].dYccd = in[i].dYccd; 36 out[i].stargal = in[i].stargal;37 31 out[i].Sky = in[i].Sky; 38 32 out[i].dSky = in[i].dSky; 39 out[i].qPSF = (in[i].qPSF == NAN_S_SHORT) ? NAN : in[i].qPSF; 33 34 // 2008.02.26 : I've renamed Mgal to Map, and intend it to be used per aperture 35 // magnitudes. Most uses of Mgal in the past were actually aperture (isophotal) mags 36 37 // changed or added for PS1_DEV_1 (2008.02.26) 38 out[i].psfQual = (in[i].psfQual == NAN_S_SHORT) ? NAN : in[i].psfQual; 39 out[i].dbFlags = in[i].flags; 40 40 out[i].detID = in[i].detID_lo; 41 41 out[i].imageID = in[i].imageID_lo; 42 43 // these don't have a correspondence 44 out[i].psfChisq = 0; 45 out[i].crNsigma = 0; 46 out[i].extNsigma = 0; 47 out[i].photFlags = 0; 42 out[i].psfChisq = 0; 43 out[i].crNsigma = 0; 44 out[i].extNsigma = 0; 45 46 // changed or added for PS1_DEV_2 47 out[i].Map = in[i].Mgal; 48 out[i].dMcal = 0; 49 50 // changed or added for PS1_V1 51 out[i].photFlags = in[i].dophot << 16; 52 out[i].t_msec = 0; 53 out[i].extID = 0; 54 out[i].objID = 0; 55 out[i].catID = 0; 56 out[i].Mxx = 0.0; 57 out[i].Mxy = 0.0; 58 out[i].Myy = 0.0; 59 out[i].posangle = 0; 60 out[i].pltscale = 0; 61 out[i].psfNdof = 0; 62 out[i].psfNpix = 0; 48 63 } 49 64 return (out); … … 64 79 out[i].dM = in[i].dM; 65 80 out[i].Mcal = in[i].Mcal; 66 out[i].Mgal = in[i].Map;67 81 out[i].airmass = in[i].airmass; 68 82 out[i].az = in[i].az; … … 71 85 out[i].FWy = in[i].FWy; 72 86 out[i].theta = in[i].theta; 73 out[i].dophot = in[i].dophot;74 87 out[i].photcode = in[i].photcode; 75 88 out[i].t = in[i].t; 76 89 out[i].averef = in[i].averef; 77 out[i].flags = in[i].dbFlags;78 90 out[i].Xccd = in[i].Xccd; 79 91 out[i].Yccd = in[i].Yccd; 80 92 out[i].dXccd = in[i].dXccd; 81 93 out[i].dYccd = in[i].dYccd; 82 out[i].stargal = in[i].stargal;83 94 out[i].Sky = in[i].Sky; 84 95 out[i].dSky = in[i].dSky; 85 out[i].qPSF = isnan(in[i].qPSF) ? NAN_S_SHORT : in[i].qPSF; 96 97 // changed or added for PS1_DEV_1 (2008.02.26) 98 out[i].flags = in[i].dbFlags; 99 out[i].psfQual = isnan(in[i].psfQual) ? NAN_S_SHORT : in[i].psfQual; 86 100 out[i].detID_hi = 0; 87 101 out[i].detID_lo = in[i].detID; 88 102 out[i].imageID_hi = 0; 89 103 out[i].imageID_lo = in[i].imageID; 104 105 // changed or added for PS1_DEV_2 106 out[i].Mgal = in[i].Map; 107 108 // changed or added for PS1_V1 109 // out[i].photFlags = in[i].photFlags & 0x0000ffff; (only dophot pre PS1_DEV_1) 110 out[i].dophot = in[i].photFlags >> 16; 90 111 } 91 112 return (out); … … 105 126 out[i].D = in[i].D; 106 127 out[i].Xp = in[i].Xp; 107 out[i].Nmeasure = in[i].Nm;108 out[i].Nmissing = in[i].Nn;109 out[i].code = in[i].code;110 out[i].measureOffset = in[i].offset;111 out[i].missingOffset = in[i].missing;112 128 out[i].dR = in[i].dR; 113 129 out[i].dD = in[i].dD; … … 120 136 out[i].objID = in[i].objID; 121 137 out[i].catID = in[i].catID; 138 139 // changed or added for PS1_DEV_2 140 out[i].Nmeasure = in[i].Nm; 141 out[i].Nmissing = in[i].Nn; 142 out[i].measureOffset = in[i].offset; 143 out[i].missingOffset = in[i].missing; 144 out[i].Nextend = 0; 145 out[i].extendOffset = 0; 146 147 // changed or added for PS1_V1 148 out[i].flags = in[i].code; 149 out[i].ChiSq = 0.0; 150 out[i].Npos = 0.0; 151 out[i].extID = 0; 122 152 } 123 153 return (out); … … 137 167 out[i].D = in[i].D; 138 168 out[i].Xp = in[i].Xp; 139 out[i].Nm = in[i].Nmeasure;140 out[i].Nn = in[i].Nmissing;141 out[i].code = in[i].code;142 out[i].offset = in[i].measureOffset;143 out[i].missing = in[i].missingOffset;144 169 out[i].dR = in[i].dR; 145 170 out[i].dD = in[i].dD; … … 152 177 out[i].objID = in[i].objID; 153 178 out[i].catID = in[i].catID; 179 180 // changed or added for PS1_DEV_2 181 out[i].Nm = in[i].Nmeasure; 182 out[i].Nn = in[i].Nmissing; 183 out[i].offset = in[i].measureOffset; 184 out[i].missing = in[i].missingOffset; 185 186 // changed or added for PS1_V1 187 out[i].code = in[i].flags; 154 188 } 155 189 return (out); … … 170 204 out[i].Ncode = in[i].Ncode; 171 205 out[i].Nused = in[i].Nused; 206 207 // changed or added for PS1_V1 208 out[i].M_20 = 0; 209 out[i].M_80 = 0; 172 210 } 173 211 return (out); … … 226 264 out[i].fwhm_y = in[i].fwhm_y; 227 265 out[i].trate = in[i].trate; 228 out[i].code = in[i].code;229 266 out[i].ccdnum = in[i].ccdnum; 230 out[i].imageID = in[i].imageID_lo;231 267 232 268 out[i].order = in[i].order; … … 245 281 out[i].Mxyyy = in[i].Mxyyy; 246 282 out[i].Myyyy = in[i].Myyyy; 283 284 // changed or added for PS1_DEV_1 285 out[i].imageID = in[i].imageID_lo; 286 287 // changed or added for PS1_DEV_2 288 out[i].externID = 0; 289 out[i].sourceID = 0; 290 291 // changed or added for PS1_V1 292 out[i].flags = in[i].code; 293 out[i].parentID = 0; 247 294 } 248 295 return (out); … … 283 330 out[i].fwhm_y = in[i].fwhm_y; 284 331 out[i].trate = in[i].trate; 285 out[i].code = in[i].code;286 332 out[i].ccdnum = in[i].ccdnum; 287 out[i].imageID_hi = 0;288 out[i].imageID_lo = in[i].imageID;289 333 290 334 out[i].order = in[i].order; … … 303 347 out[i].Mxyyy = in[i].Mxyyy; 304 348 out[i].Myyyy = in[i].Myyyy; 305 } 306 return (out); 307 } 349 350 // changed or added for PS1_DEV_1 351 out[i].imageID_hi = 0; 352 out[i].imageID_lo = in[i].imageID; 353 354 // changed or added for PS1_V1 355 out[i].code = in[i].flags; 356 } 357 return (out); 358 } 359 360 // XXX no photcode conversions? this may be from before we had a photcode FITS table... 361 -
branches/cnb_branch_20090215/Ohana/src/libdvo/src/dvo_image.c
r19185 r21536 196 196 if (db[0].format == DVO_FORMAT_PS1_DEV_2) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "PS1_DEV_2"); 197 197 if (db[0].format == DVO_FORMAT_PS1_DEV_3) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "PS1_DEV_3"); 198 if (db[0].format == DVO_FORMAT_PS1_V1) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "PS1_V1"); 198 199 199 200 return; -
branches/cnb_branch_20090215/Ohana/src/libdvo/src/dvo_image_raw.c
r16810 r21536 54 54 if (db[0].format == DVO_FORMAT_PS1_DEV_1) ImageSize = sizeof(Image_PS1_DEV_1); 55 55 if (db[0].format == DVO_FORMAT_PS1_DEV_2) ImageSize = sizeof(Image_PS1_DEV_2); 56 if (db[0].format == DVO_FORMAT_PS1_DEV_3) ImageSize = sizeof(Image_PS1_DEV_3); 57 if (db[0].format == DVO_FORMAT_PS1_V1) ImageSize = sizeof(Image_PS1_V1); 56 58 57 59 /* check that filesize makes sense */ … … 78 80 if (db[0].format == DVO_FORMAT_PS1_DEV_1) gfits_table_mkheader_Image_PS1_DEV_1 (&db[0].theader); 79 81 if (db[0].format == DVO_FORMAT_PS1_DEV_2) gfits_table_mkheader_Image_PS1_DEV_2 (&db[0].theader); 82 if (db[0].format == DVO_FORMAT_PS1_DEV_3) gfits_table_mkheader_Image_PS1_DEV_3 (&db[0].theader); 83 if (db[0].format == DVO_FORMAT_PS1_V1) gfits_table_mkheader_Image_PS1_V1 (&db[0].theader); 80 84 81 85 /* read data from file */ -
branches/cnb_branch_20090215/Ohana/src/libdvo/src/dvosorts.c
r16040 r21536 46 46 } 47 47 48 void sort_stars_ra (Stars *stars, int N) {49 50 # define SWAPFUNC(A,B){ Stars tmp; tmp = stars[A]; stars[A] = stars[B]; stars[B] = tmp; }51 # define COMPARE(A,B)(stars[A].R < stars[B].R)52 53 OHANA_SORT (N, COMPARE, SWAPFUNC);54 55 # undef SWAPFUNC56 # undef COMPARE57 58 }59 60 48 void sort_regions (SkyRegion *region, int N) { 61 49 … … 70 58 } 71 59 60 # if (0) 61 // deprecated along with Stars as an autocode type 62 void sort_stars_ra (Stars *stars, int N) { 63 64 # define SWAPFUNC(A,B){ Stars tmp; tmp = stars[A]; stars[A] = stars[B]; stars[B] = tmp; } 65 # define COMPARE(A,B)(stars[A].R < stars[B].R) 66 67 OHANA_SORT (N, COMPARE, SWAPFUNC); 68 69 # undef SWAPFUNC 70 # undef COMPARE 71 72 } 73 # endif -
branches/cnb_branch_20090215/Ohana/src/libohana/include/ohana.h
r21153 r21536 6 6 # include <time.h> 7 7 # include <stdlib.h> 8 # include <stdint.h> 8 9 # include <string.h> 9 10 # include <sys/socket.h> -
branches/cnb_branch_20090215/Ohana/src/opihi/cmd.data/Makefile
r17579 r21536 20 20 $(SRC)/accum.$(ARCH).o \ 21 21 $(SRC)/applyfit2d.$(ARCH).o \ 22 $(SRC)/applyfit .$(ARCH).o \22 $(SRC)/applyfit1d.$(ARCH).o \ 23 23 $(SRC)/box.$(ARCH).o \ 24 24 $(SRC)/book.$(ARCH).o \ … … 26 26 $(SRC)/center.$(ARCH).o \ 27 27 $(SRC)/clear.$(ARCH).o \ 28 $(SRC)/ clip.$(ARCH).o \28 $(SRC)/imclip.$(ARCH).o \ 29 29 $(SRC)/close.$(ARCH).o \ 30 30 $(SRC)/concat.$(ARCH).o \ … … 44 44 $(SRC)/fft1d.$(ARCH).o \ 45 45 $(SRC)/fft2d.$(ARCH).o \ 46 $(SRC)/fit1d.$(ARCH).o \ 46 47 $(SRC)/fit2d.$(ARCH).o \ 47 $(SRC)/fit.$(ARCH).o \48 48 $(SRC)/gaussj.$(ARCH).o \ 49 49 $(SRC)/gaussdeviate.$(ARCH).o \ … … 107 107 $(SRC)/spline_apply.$(ARCH).o \ 108 108 $(SRC)/spline_construct.$(ARCH).o \ 109 $(SRC)/ stats.$(ARCH).o\109 $(SRC)/imstats.$(ARCH).o \ 110 110 $(SRC)/style.$(ARCH).o \ 111 111 $(SRC)/subraster.$(ARCH).o \ … … 131 131 $(SRC)/vroll.$(ARCH).o \ 132 132 $(SRC)/vsmooth.$(ARCH).o \ 133 $(SRC)/vstat .$(ARCH).o \133 $(SRC)/vstats.$(ARCH).o \ 134 134 $(SRC)/wd.$(ARCH).o \ 135 135 $(SRC)/write_vectors.$(ARCH).o \ -
branches/cnb_branch_20090215/Ohana/src/opihi/cmd.data/init.c
r21064 r21536 3 3 int accum PROTO((int, char **)); 4 4 int applyfit PROTO((int, char **)); 5 int applyfit1d PROTO((int, char **)); 5 6 int applyfit2d PROTO((int, char **)); 6 7 int box PROTO((int, char **)); … … 11 12 int clear PROTO((int, char **)); 12 13 int clip PROTO((int, char **)); 14 int imclip PROTO((int, char **)); 13 15 int close_device PROTO((int, char **)); 14 16 int concat PROTO((int, char **)); … … 29 31 int fft1d PROTO((int, char **)); 30 32 int fft2d PROTO((int, char **)); 33 int fit PROTO((int, char **)); 34 int fit1d PROTO((int, char **)); 31 35 int fit2d PROTO((int, char **)); 32 int fit PROTO((int, char **));33 36 int gaussjordan PROTO((int, char **)); 34 37 int gaussdeviate PROTO((int, char **)); … … 92 95 int spline_construct_cmd PROTO((int, char **)); 93 96 int stats PROTO((int, char **)); 97 int imstats PROTO((int, char **)); 94 98 int style PROTO((int, char **)); 95 99 int subraster PROTO((int, char **)); … … 113 117 int vload PROTO((int, char **)); 114 118 int vzload PROTO((int, char **)); 115 int vstat PROTO((int, char **));119 int vstats PROTO((int, char **)); 116 120 int vroll PROTO((int, char **)); 117 121 int vpop PROTO((int, char **)); … … 124 128 static Command cmds[] = { 125 129 {1, "accum", accum, "accumulate vector values in another vector"}, 126 {1, "applyfit", applyfit, "apply fit to new vector"}, 130 {1, "applyfit", applyfit1d, "apply 1-d fit to new vector"}, 131 {1, "applyfit1d", applyfit1d, "apply 1-d fit to new vector"}, 127 132 {1, "applyfit2d", applyfit2d, "apply 2-d fit to new vector"}, 133 {1, "book", book_command, "commands to manipulate book/page/word data"}, 128 134 {1, "box", box, "draw a box on the plot"}, 129 {1, "book", book_command, "commands to manipulate book/page/word data"}, 135 {1, "buffers", list_buffers, "list the currently allocated buffers (images)"}, 136 {1, "images", list_buffers, "list the currently allocated images"}, 130 137 {1, "center", center, "center image on coords"}, 131 {1, "parity", parity, "set image parity"},132 138 {1, "circstats", circstats, "circular statistics"}, 133 139 {1, "clear", clear, "erase plot"}, 134 {1, "clip", clip, "clip values in a bufferto be within a range"},140 {1, "clip", imclip, "clip values in an image to be within a range"}, 135 141 {1, "close", close_device, "close the current display device"}, 136 {1, "concat", concat, " reduce vector dimension"},142 {1, "concat", concat, "append values to the end of a vector"}, 137 143 {1, "contour", contour, "create contour from image"}, 138 144 {1, "create", create, "create a new vector"}, 145 {1, "vcreate", create, "create a new vector"}, 139 146 {1, "cumulative", cumulative, "build a cumulative histogram from a specific histogram"}, 140 147 {1, "cursor", cursor, "get coords from cursor"}, … … 143 150 {1, "dbconnect", dbconnect, "setup mysql db connection"}, 144 151 {1, "dbselect", dbselect, "extract vectors from mysql database table"}, 145 {1, "delete", delete, "delete vectors or matrices"},152 {1, "delete", delete, "delete vectors or images"}, 146 153 {1, "device", device, "set / get current graphics device"}, 147 {1, "dimendown", dimendown, "convert matrix to vector"}, 148 {1, "dimenup", dimenup, "convert vector to matrix"}, 149 {1, "erase", erase, "erase objects on an overlay"}, 150 {1, "extract", extract, "extract a portion of a buffer into another buffer"}, 151 {1, "fft1d", fft1d, "fft on the pixel-stream in an image"}, 154 {1, "dimendown", dimendown, "convert image to vector"}, 155 {1, "dimenup", dimenup, "convert vector to image"}, 156 {1, "dot", dot, "plot a single point"}, 157 {1, "erase", erase, "erase objects on an image overlay"}, 158 {1, "extract", extract, "extract a portion of a image into another image"}, 159 {1, "fft1d", fft1d, "fft on a vector"}, 152 160 {1, "fft2d", fft2d, "fft on an image"}, 153 {1, "fit", fit, "fit polynomial to vector pair"}, 161 {1, "fit", fit1d, "fit polynomial to vector pair"}, 162 {1, "fit1d", fit1d, "fit polynomial to vector pair"}, 154 163 {1, "fit2d", fit2d, "fit 2-d polynomial to vector triplet"}, 155 {1, "gaussj", gaussjordan, "solve Ax = B (N-D)"},156 164 {1, "gaussdev", gaussdeviate, "generate a gaussian deviate vector"}, 157 165 {1, "gaussint", gaussintegral, "return the integrated gaussian vector"}, 158 {1, "grid", grid, "plot cartesian grid"}, 159 {1, "gridify", gridify, "convert vector triplet to buffer"}, 166 {1, "gaussj", gaussjordan, "solve Ax = B (N-Dimensional)"}, 167 {1, "grid", grid, "plot cartesian grid on graph"}, 168 {1, "gridify", gridify, "convert vector triplet to image (same as vgrid?)"}, 160 169 {1, "grow", grow, "grow a mask"}, 161 {1, "ungridify", ungridify, "convert buffer region to vector triplet"}, 162 {1, "header", header, "print buffer header"}, 170 {1, "header", header, "print image header"}, 163 171 {1, "histogram", histogram, "generate histogram from vector"}, 172 {1, "imbin", rebin, "rebin image data by factor of N"}, 173 {1, "imclip", imclip, "clip values in an image to be within a range"}, 164 174 {1, "imcut", imcut, "linear image cut between arbitrary coords"}, 165 {1, "imhist ",imhist, "histogram of an image region"},175 {1, "imhistogram", imhist, "histogram of an image region"}, 166 176 {1, "imsmooth", imsmooth, "circular gaussian smoothing"}, 177 {1, "imstats", imstats, "statistics on a portion of an image"}, 167 178 {1, "integrate", integrate, "integrate a vector"}, 168 179 {1, "interpolate", interpolate, "interpolate between vector pairs"}, 169 {1, "jpeg", jpeg, "write text line on graph"}, 170 {1, "png", jpeg, "write text line on graph"}, 171 {1, "ppm", jpeg, "write text line on graph"}, 180 {1, "jpeg", jpeg, "convert display image to JPEG"}, 172 181 {1, "kern", kern, "convolve with 3x3 kernel"}, 173 {1, "keyword", keyword, "extract a FITS keyword from bufferheader"},182 {1, "keyword", keyword, "extract a FITS keyword from image header"}, 174 183 {1, "labels", labels, "define labels for plot"}, 175 184 {1, "limits", limits, "define plot limits"}, 176 {1, "line", line, "plot line"}, 177 {1, "buffers", list_buffers, "list the currently allocated buffers"}, 178 {1, "vectors", list_vectors, "list vectors"}, 179 {1, "load", load, "load an SAOimage style overlay"}, 185 {1, "line", line, "plot a line"}, 186 {1, "load", load, "load an SAOimage/DS9 style overlay"}, 180 187 {1, "lookup", lookup, "convert vector via lookup table (vector pair)"}, 181 {1, "m krgb", mkrgb, "convert 3 images to rgb jpeg"},182 {1, " mcreate", mcreate, "create a matrix"},188 {1, "mcreate", mcreate, "create an image"}, 189 {1, "imcreate", mcreate, "create an image"}, 183 190 {1, "medacc", medacc, "accumulate vector values in another vector"}, 184 {1, "mget", mget, "extract a vector from a matrix"}, 191 {1, "mget", mget, "extract a vector from an image"}, 192 {1, "imget", mget, "extract a vector from an image"}, 185 193 {1, "minterp", minterp, "interpolate image pixels"}, 186 {1, "mset", mset, "insert a vector in a matrix"}, 194 {1, "iminterp", minterp, "interpolate image pixels"}, 195 {1, "mkrgb", mkrgb, "convert 3 images to rgb jpeg (use Kapa for better control)"}, 196 {1, "imset", mset, "insert a vector in an image"}, 197 {1, "parity", parity, "set image parity"}, 187 198 {1, "peak", peak, "find vector peak in range"}, 188 199 {1, "periodogram", periodogram, "measure periods in unevenly sampled data"}, 189 200 {1, "plot", plot, "plot a pair of vectors"}, 190 {1, "dot", dot, "plot a single point"}, 191 {1, "point", point, "load overlay with single point"}, 192 {1, "ps", ps, "define labels for plot"}, 201 {1, "png", jpeg, "convert display graphic to PNG"}, 202 {1, "point", point, "load image overlay with a single point"}, 203 {1, "ppm", jpeg, "convert display graphic to PPM"}, 204 {1, "ps", ps, "convert display to PostScript"}, 205 {1, "queuedelete", queuedelete, "delete a queue"}, 206 {1, "queuedrop", queuedrop, "drop values from queue matching a key"}, 207 {1, "queueinit", queueinit, "create an empty queue"}, 208 {1, "queuelist", queuelist, "list defined queues"}, 209 {1, "queueload", queueload, "load queue from command"}, 193 210 {1, "queuepop", queuepop, "pop value from queue to variable"}, 194 {1, "queuedrop", queuedrop, "drop values from queue matching a key"},195 211 {1, "queueprint", queueprint, "print the contents of a queue"}, 196 212 {1, "queuepush", queuepush, "push value onto queue"}, 197 {1, "queueinit", queueinit, "create an empty queue"}, 198 {1, "queuedelete", queuedelete, "delete a queue"}, 199 {1, "queuelist", queuelist, "list defined queues"}, 200 {1, "queueload", queueload, "load queue from command"}, 213 {1, "queuesize", queuesize, "show queue size"}, 201 214 {1, "queuesubstr", queuesubstr, "bulk replace strings in queue"}, 202 {1, "queuesize", queuesize, "show queue size"},203 215 {1, "rd", rd, "load fits image"}, 204 216 {1, "rdseg", rdseg, "read a segment of an image from a file"}, 205 217 {1, "read", read_vectors, "read vectors from datafile"}, 206 {1, "rebin", rebin, "rebin data by factor of N"},218 {1, "rebin", rebin, "rebin image data by factor of N"}, 207 219 {1, "resize", resize, "set graphics/image window size"}, 208 220 {1, "roll", roll, "roll image to new start point"}, 209 221 {1, "rotate", rotate, "rotate image"}, 210 {1, "save", save, "save an SAOimage style overlay"},222 {1, "save", save, "save an SAOimage style image overlay"}, 211 223 {1, "section", section, "define section of graph"}, 212 {1, "set", set, "vector math"}, 224 {1, "select", vect_select, "selective vector assignment"}, 225 {1, "set", set, "image and vector math"}, 213 226 {1, "shift", shift, "shift data in an image"}, 214 227 {1, "sort", sort_vectors, "sort list of vectors"}, 215 228 {1, "spline.apply", spline_apply_cmd, "apply spline fit to generate an image"}, 216 229 {1, "spline.const", spline_construct_cmd, "create spline 2nd deriv. terms"}, 217 {1, "stats", stats, "give statistics on a portion of a buffer"},230 {1, "stats", imstats, "statistics on a portion of an image"}, 218 231 {1, "style", style, "set the style for graph plots"}, 219 232 {1, "subraster", subraster, "subraster of fits image"}, 220 {1, "subset", subset, " expand vector dimension"},221 {1, "svd", svd, "singular value decomposition of a matrix "},233 {1, "subset", subset, "generate a vector from a portion of another vector"}, 234 {1, "svd", svd, "singular value decomposition of a matrix (image)"}, 222 235 {1, "swapbytes", swapbytes, "byte swap thing"}, 223 236 {1, "textline", textline, "write text line on graph"}, … … 225 238 {1, "tvchannel", tvchannel, "set the current tv channel"}, 226 239 {1, "tvcolors", tvcolors, "set the tv colormap"}, 227 {1, "tvcontour", tvcontour, "send contour to overlay"}, 228 {1, "tvgrid", tvgrid, "wait until return is typed"}, 240 {1, "tvcontour", tvcontour, "send contour to image overlay"}, 241 {1, "tvgrid", tvgrid, "RA/DEC grid on an image"}, 242 {1, "ungridify", ungridify, "convert image region to vector triplet"}, 229 243 {1, "uniq", uniq, "create a uniq vector subset from a vector"}, 230 244 {1, "unsign", unsign, "toggle the UNSIGN status"}, 231 {1, "vbin", vbin, " bin values in a vector to be within a range"},245 {1, "vbin", vbin, "rebin vector data by a fector of N"}, 232 246 {1, "vclip", vclip, "clip values in a vector to be within a range"}, 233 {1, "select", vect_select, "selective vector assignment"}, 234 {1, "vgauss", vgauss, ""}, 235 {1, "vmaxwell", vmaxwell, ""}, 236 {1, "vgrid", vgrid, ""}, 237 {1, "vload", vload, "load vectors on Kii"}, 238 {1, "vzload", vzload, "load vectors on Kii"}, 239 {1, "vstat", vstat, "get info from imreg database"}, 240 {1, "vsmooth", vsmooth, "gaussian smooth of a vector"}, 247 {1, "vectors", list_vectors, "list vectors"}, 248 {1, "vgauss", vgauss, "fit a Gaussian to a vector"}, 249 {1, "vgrid", vgrid, "generate an image from a triplet of vectors"}, 250 {1, "vhistogram", histogram, "generate histogram from vector"}, 251 {1, "vload", vload, "load vectors as overlay on image display"}, 252 {1, "vmaxwell", vmaxwell, "fit a Maxwellian to a vector"}, 253 {1, "vpop", vpop, "remove first element of a vector"}, 241 254 {1, "vroll", vroll, "roll vector elements"}, 242 {1, "vpop", vpop, "remove first element"}, 255 {1, "vsmooth", vsmooth, "Gaussian smooth of a vector"}, 256 {1, "vstats", vstats, "statistics on a vector"}, 257 {1, "vzload", vzload, "load vectors as overlay on image display (scaled points)"}, 243 258 {1, "wd", wd, "write an image to a file"}, 244 259 {1, "write", write_vectors, "write vectors to datafile"}, 245 {1, "zap", zap, " delete pixels"},260 {1, "zap", zap, "assign values to pixel regions"}, 246 261 {1, "zplot", zplot, "plot x y with size scaled by z"}, 247 262 }; -
branches/cnb_branch_20090215/Ohana/src/opihi/dvo/dbExtractAverages.c
r21153 r21536 121 121 break; 122 122 case AVE_FLAG: 123 value.Int = average[0]. code;123 value.Int = average[0].flags; 124 124 break; 125 125 case AVE_OBJID: -
branches/cnb_branch_20090215/Ohana/src/opihi/dvo/dbExtractImages.c
r20936 r21536 247 247 break; 248 248 case IMAGE_FLAG: 249 value.Int = image[N]. code;249 value.Int = image[N].flags; 250 250 break; 251 251 case IMAGE_CCDNUM: -
branches/cnb_branch_20090215/Ohana/src/opihi/dvo/dbExtractMeasures.c
r21153 r21536 146 146 case MAG_NPHOT: 147 147 if (equiv == NULL) { 148 value.Int = NAN;148 value.Int = 0; 149 149 break; 150 150 } … … 260 260 break; 261 261 case MEAS_OBJFLAGS: /* OK */ 262 value.Int = average[0]. code;262 value.Int = average[0].flags; 263 263 break; 264 264 // note that these represent the ra displacement relative to the average, not … … 312 312 break; 313 313 case MEAS_DOPHOT: /* OK */ 314 value. Flt = measure[0].dophot;314 value.Int = (measure[0].photFlags >> 16); 315 315 break; 316 316 case MEAS_DB_FLAGS: /* ? */ … … 394 394 break; 395 395 case MEAS_PSF_QF: /* OK */ 396 value.Flt = measure[0]. qPSF;396 value.Flt = measure[0].psfQual; 397 397 break; 398 398 case MEAS_PSF_CHISQ: /* OK */ … … 404 404 case MEAS_EXT_NSIGMA: /* OK */ 405 405 value.Flt = measure[0].extNsigma; 406 break;407 case MEAS_STARGAL: /* OK */408 value.Flt = measure[0].stargal;409 406 break; 410 407 -
branches/cnb_branch_20090215/Ohana/src/opihi/dvo/dbFields.c
r21153 r21536 170 170 if (!strcasecmp (fieldName, "FWHM_MIN")) ESCAPE (MEAS_FWHM_MIN, MAG_NONE, OPIHI_FLT); 171 171 if (!strcasecmp (fieldName, "THETA")) ESCAPE (MEAS_THETA, MAG_NONE, OPIHI_FLT); 172 if (!strcasecmp (fieldName, "DOPHOT")) ESCAPE (MEAS_DOPHOT, MAG_NONE, OPIHI_ FLT);172 if (!strcasecmp (fieldName, "DOPHOT")) ESCAPE (MEAS_DOPHOT, MAG_NONE, OPIHI_INT); 173 173 if (!strcasecmp (fieldName, "DB_FLAGS")) ESCAPE (MEAS_DB_FLAGS, MAG_NONE, OPIHI_INT); 174 174 if (!strcasecmp (fieldName, "PHOT_FLAGS")) ESCAPE (MEAS_PHOT_FLAGS, MAG_NONE, OPIHI_INT); … … 193 193 if (!strcasecmp (fieldName, "SKY")) ESCAPE (MEAS_SKY, MAG_NONE, OPIHI_FLT); 194 194 if (!strcasecmp (fieldName, "SKY_ERR")) ESCAPE (MEAS_dSKY, MAG_NONE, OPIHI_FLT); 195 if (!strcasecmp (fieldName, "STARGAL")) ESCAPE (MEAS_STARGAL, MAG_NONE, OPIHI_FLT);196 195 197 196 // for words that don't parse, try a photcode -
branches/cnb_branch_20090215/Ohana/src/opihi/dvo/gimages.c
r21153 r21536 220 220 if (PixelCoords) { 221 221 gprint (GP_LOG, "%3d %s %6.1f %6.1f %20s %5d %2d %4.2f %6.3f %5.3f %5.3f %4x\n", 222 Nfound, image[i].name, X, Y, date, image[i].nstar, image[i].photcode, image[i].secz, image[i].Mcal, image[i].dMcal, image[i].exptime, image[i]. code);222 Nfound, image[i].name, X, Y, date, image[i].nstar, image[i].photcode, image[i].secz, image[i].Mcal, image[i].dMcal, image[i].exptime, image[i].flags); 223 223 } else { 224 224 XY_to_RD (&ra, &dec, 0.5*image[i].NX, 0.5*image[i].NY, &image[i].coords); 225 225 gprint (GP_LOG, "%3d %s %8.4f %8.4f %20s %5d %2d %4.2f %6.3f %5.3f %5.3f %4x\n", 226 Nfound, image[i].name, ra, dec, date, image[i].nstar, image[i].photcode, image[i].secz, image[i].Mcal, image[i].dMcal, image[i].exptime, image[i]. code);226 Nfound, image[i].name, ra, dec, date, image[i].nstar, image[i].photcode, image[i].secz, image[i].Mcal, image[i].dMcal, image[i].exptime, image[i].flags); 227 227 } 228 228 sprintf (name, "IMAGEx:%d", Nfound); -
branches/cnb_branch_20090215/Ohana/src/opihi/dvo/gstar.c
r20936 r21536 158 158 gprint (GP_LOG, "%3d ", catalog.average[k].Nmeasure); 159 159 gprint (GP_LOG, "%4.1f ", 0.01*catalog.average[k].Xp); 160 gprint (GP_LOG, "%5d", catalog.average[k]. code);160 gprint (GP_LOG, "%5d", catalog.average[k].flags); 161 161 162 162 if (FULL_OUTPUT) { … … 211 211 gprint (GP_LOG, "%7.4f ", catalog.measure[m].dR); 212 212 gprint (GP_LOG, "%7.4f", catalog.measure[m].dD); 213 gprint (GP_LOG, "% 2d ", catalog.measure[m].dophot);213 gprint (GP_LOG, "%4x ", catalog.measure[m].photFlags); 214 214 gprint (GP_LOG, "%3x ", catalog.measure[m].dbFlags); 215 215 gprint (GP_LOG, "%5d ", catalog.measure[m].photcode); … … 233 233 gprint (GP_LOG, "%d", catalog.measure[m].detID); 234 234 gprint (GP_LOG, "%d", catalog.measure[m].imageID); 235 gprint (GP_LOG, "%f", catalog.measure[m]. qPSF);235 gprint (GP_LOG, "%f", catalog.measure[m].psfQual); 236 236 gprint (GP_LOG, "%f", catalog.measure[m].psfChisq); 237 237 gprint (GP_LOG, "%f", catalog.measure[m].crNsigma); … … 240 240 gprint (GP_LOG, "%f", 0.01*catalog.measure[m].FWy); 241 241 gprint (GP_LOG, "%f", (360.0/(float)0xffff)*catalog.measure[m].theta); 242 243 gprint (GP_LOG, "%x", catalog.measure[m].photFlags);244 gprint (GP_LOG, "%d", catalog.measure[m].stargal);245 242 } 246 243 gprint (GP_LOG, "\n"); -
branches/cnb_branch_20090215/Ohana/src/opihi/dvo/paverage.c
r20936 r21536 122 122 /* project stars to screen display coords */ 123 123 for (i = 0; (i < catalog.Naverage) && !interrupt; i++) { 124 if (IDclip && (average[i]. code!= IDchoice)) continue;124 if (IDclip && (average[i].flags != IDchoice)) continue; 125 125 average[i].R = ohana_normalize_angle (average[i].R); 126 126 while (average[i].R < Rmin) average[i].R += 360.0; -
branches/cnb_branch_20090215/Ohana/src/opihi/dvo/photometry.c
r17200 r21536 2 2 3 3 /* match code to measure */ 4 # define TESTCODE(C,M) \5 if (C != NULL) { \6 switch (C[0].type) { \7 case PHOT_DEP:\8 case PHOT_REF:\9 if (C[0].code != M.photcode) continue;\10 break;\11 case PHOT_SEC:\12 if (C[0].code != GetPhotcodeEquivCodebyCode (M.photcode)) continue; \13 break;\14 default:\15 break;\16 } }4 # define TESTCODE(C,M) \ 5 if (C != NULL) { \ 6 switch (C[0].type) { \ 7 case PHOT_DEP: \ 8 case PHOT_REF: \ 9 if (C[0].code != M.photcode) continue; \ 10 break; \ 11 case PHOT_SEC: \ 12 if (C[0].code != GetPhotcodeEquivCodebyCode (M.photcode)) continue; \ 13 break; \ 14 default: \ 15 break; \ 16 } } 17 17 18 18 /* exclusions based on measure.params */ 19 # define TESTMEASURE(M) \ 20 if (ApplySelections[SelectionParam]) { \ 21 if (TimeSelect && (M.t < tzero)) continue; \ 22 if (TimeSelect && (M.t > tend)) continue; \ 23 if (ErrSelect && (M.dM > ErrValue)) continue; \ 19 # define TESTMEASURE(M) \ 20 if (ApplySelections[SelectionParam]) { \ 21 if (TimeSelect && (M.t < tzero)) continue; \ 22 if (TimeSelect && (M.t > tend)) continue; \ 23 if (ErrSelect && (M.dM > ErrValue)) continue; \ 24 if (iMagSelect && (PhotInst (&M) < iMagMin)) continue; \ 25 if (FlagSelect && (M.dbFlags != FlagValue)) continue; \ 24 26 if (TypeSelect && (TypeValue != GetMeasureTypeCode (&M))) continue; \ 25 if (iMagSelect && (PhotInst (&M) < iMagMin)) continue; \ 26 if (FlagSelect && (M.dbFlags != FlagValue)) continue; \ 27 } 28 29 # define SETMAG(MOUT,MEAS,MODE) \ 30 MOUT = NAN; \ 31 if (MODE == MAG_INST) MOUT = PhotInst (&MEAS); \ 32 if (MODE == MAG_CAT) MOUT = PhotCat (&MEAS); \ 33 if (MODE == MAG_SYS) MOUT = PhotSys (&MEAS, average, secfilt); \ 34 if (MODE == MAG_REL) MOUT = PhotRel (&MEAS, average, secfilt); \ 27 } 28 29 # define SETMAG(MOUT,MEAS,MODE) \ 30 MOUT = NAN; \ 31 if (MODE == MAG_INST) MOUT = PhotInst (&MEAS); \ 32 if (MODE == MAG_CAT) MOUT = PhotCat (&MEAS); \ 33 if (MODE == MAG_SYS) MOUT = PhotSys (&MEAS, average, secfilt); \ 34 if (MODE == MAG_REL) MOUT = PhotRel (&MEAS, average, secfilt); \ 35 35 if (MODE == MAG_CAL) MOUT = PhotCal (&MEAS, average, secfilt, measure, GetPhotcodeEquivbyCode (MEAS.photcode)); \ 36 36 if (MODE == MAG_AVE) MOUT = PhotAve (GetPhotcodeEquivbyCode (MEAS.photcode), average, secfilt); \ 37 37 if (MODE == MAG_REF) MOUT = PhotRef (GetPhotcodeEquivbyCode (MEAS.photcode), average, secfilt, measure); \ 38 if (ApplySelections[SelectionParam]) { \39 if (MagSelect && (MOUT > MagMax)) continue; \40 if (MagSelect && (MOUT < MagMin)) continue; \38 if (ApplySelections[SelectionParam]) { \ 39 if (MagSelect && (MOUT > MagMax)) continue; \ 40 if (MagSelect && (MOUT < MagMin)) continue; \ 41 41 } 42 42 … … 182 182 if (!strcasecmp (parname, "dec")) param = MEAS_DEC; 183 183 if (!strcasecmp (parname, "mag")) param = MEAS_MAG; 184 // if (!strcasecmp (parname, "dmag")) param = MEAS_dMAG;185 184 if (!strcasecmp (parname, "airmass")) param = MEAS_AIRMASS; 186 185 if (!strcasecmp (parname, "exptime")) param = MEAS_EXPTIME; … … 190 189 if (!strcasecmp (parname, "dD")) param = MEAS_DEC_OFFSET; 191 190 if (!strcasecmp (parname, "fwhm")) param = MEAS_FWHM; 192 // if (!strcasecmp (parname, "dophot")) param = MEAS_DOPHOT;193 191 if (!strcasecmp (parname, "FLAGS")) param = MEAS_DB_FLAGS; 194 192 if (!strcasecmp (parname, "XCCD")) param = MEAS_XCCD; … … 198 196 if (!strcasecmp (parname, "help")) { 199 197 gprint (GP_ERR, "value may be one of the following:\n"); 200 gprint (GP_ERR, " ra dR dec dD mag dmag Mrel Mcal photcode time fwhm dophotxccd yccd xmosaic ymosaic flags\n");198 gprint (GP_ERR, " ra dR dec dD mag dmag Mrel Mcal photcode time fwhm xccd yccd xmosaic ymosaic flags\n"); 201 199 gprint (GP_ERR, "value may also be a valid photcode\n"); 202 200 gprint (GP_ERR, "photcodes or 'mag' may have optional magnitude type: mag,[Minst, Mcat, Msys, Mrel, Mcal]\n"); … … 311 309 312 310 if (VarConfig ("ZERO_PT", "%lf", &ZERO_POINT) == (char *) NULL) { 313 gprint (GP_ERR, "ZERO_PT undefined in config\n");314 return (FALSE);311 gprint (GP_ERR, "ZERO_PT undefined in config\n"); 312 return (FALSE); 315 313 } 316 314 SetZeroPoint (ZERO_POINT); … … 324 322 325 323 if (VarConfig ("PHOTCODE_FILE", "%s", MasterPhotcodeFile) == (char *) NULL) { 326 gprint (GP_ERR, "PHOTCODE_FILE undefined in config\n");327 return (FALSE);324 gprint (GP_ERR, "PHOTCODE_FILE undefined in config\n"); 325 return (FALSE); 328 326 } 329 327 if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) { … … 642 640 break; 643 641 case AVE_FLAG: 644 value = average[0]. code;642 value = average[0].flags; 645 643 break; 646 644 case AVE_MAG: … … 659 657 value = NAN; 660 658 for (i = 0; i < average[0].Nmeasure; i++) { 661 if (code[0].code != measure[i].photcode) continue;662 value = measure[i].M;659 if (code[0].code != measure[i].photcode) continue; 660 value = measure[i].M; 663 661 } 664 662 break; … … 675 673 break; 676 674 case AVE_TYPEFRAC: 677 value = DetermineTypefrac (average, measure, code); 675 // value = DetermineTypefrac (average, measure, code); 676 value = NAN; 678 677 break; 679 678 case AVE_NCODE: … … 719 718 if ((code != NULL) && (code[0].code != GetPhotcodeEquivCodebyCode (measure[k].photcode))) continue; 720 719 Nc ++; 721 if ( measure[k].dophot!= TypefracType) continue;720 if ((measure[k].photFlags >> 16) != TypefracType) continue; 722 721 Nt ++; 723 722 } … … 744 743 745 744 int GetMeasureTypeCode (Measure *measure) { 746 switch ( measure[0].dophot) {745 switch ((measure[0].photFlags >> 16)) { 747 746 case 0: 748 747 case 1: … … 770 769 if (IsDophot) { 771 770 772 if ( measure[0].dophot== 4) return (FALSE);771 if ((measure[0].photFlags >> 16) == 4) return (FALSE); 773 772 return (TRUE); 774 773 … … 866 865 if (ErrSelect) { 867 866 dM = PhotdM (code, average, secfilt); 868 if (dM > ErrValue) return ( NAN);867 if (dM > ErrValue) return (FALSE); 869 868 } 870 869 … … 1137 1136 value = average[0].D - measure[0].dD / 3600.0; 1138 1137 break; 1139 # if (0)1140 case MEAS_dMAG: /* OK */1141 value = measure[0].dM;1142 break;1143 1138 case MEAS_DOPHOT: /* OK */ 1144 value = measure[0].dophot; 1145 break; 1146 # endif 1139 value = (measure[0].photFlags >> 16); 1140 break; 1147 1141 case MEAS_AIRMASS: /* OK */ 1148 1142 value = measure[0].airmass; -
branches/cnb_branch_20090215/Ohana/src/opihi/dvo/pmeasure.c
r20936 r21536 192 192 /* project stars to screen display coords */ 193 193 for (i = 0; (i < catalog.Naverage) && !interrupt; i++) { 194 if (IDclip && (catalog.average[i]. code!= IDchoice)) continue;194 if (IDclip && (catalog.average[i].flags != IDchoice)) continue; 195 195 catalog.average[i].R = ohana_normalize_angle (catalog.average[i].R); 196 196 while (catalog.average[i].R < Rmin) catalog.average[i].R += 360.0; -
branches/cnb_branch_20090215/Ohana/src/opihi/include/dvoshell.h
r21153 r21536 106 106 MEAS_CR_NSIGMA, 107 107 MEAS_EXT_NSIGMA, 108 MEAS_STARGAL,109 108 }; 110 109 -
branches/cnb_branch_20090215/Ohana/src/relastro/include/relastro.h
r21153 r21536 61 61 short Xm; 62 62 float secz; 63 char code;63 char flags; 64 64 Coords coords; 65 65 } Mosaic; -
branches/cnb_branch_20090215/Ohana/src/relastro/src/MosaicOps.c
r16810 r21536 47 47 mosaic[Nmosaic].dMcal = 0.0; 48 48 mosaic[Nmosaic].Xm = 0.0; 49 mosaic[Nmosaic]. code = image[i].code;49 mosaic[Nmosaic].flags = image[i].flags; 50 50 mosaic[Nmosaic].secz = image[i].secz; 51 51 mosaic[Nmosaic].coords = image[i].coords; -
branches/cnb_branch_20090215/Ohana/src/relastro/src/UpdateObjects.c
r17419 r21536 169 169 // position, consider including the lower-quality detections 170 170 171 catalog[i].average[j]. code&= ~ID_STAR_FEW;171 catalog[i].average[j].flags &= ~ID_STAR_FEW; 172 172 173 173 // XXX add the parallax factor range as a criterion as well -
branches/cnb_branch_20090215/Ohana/src/relastro/src/bcatalog.c
r17212 r21536 36 36 // XXX define astrometry vs photometry average.dbFlags 37 37 // XXX put photometry flags in secfilt (ie, per average mag?) 38 subcatalog[0].average[Naverage]. code&= ~ID_STAR_FEW;39 subcatalog[0].average[Naverage]. code&= ~ID_STAR_POOR;38 subcatalog[0].average[Naverage].flags &= ~ID_STAR_FEW; 39 subcatalog[0].average[Naverage].flags &= ~ID_STAR_POOR; 40 40 } 41 41 … … 70 70 71 71 /* select measurements by quality */ 72 if (DophotSelect && (catalog[0].measure[offset].dophot != DophotValue)) continue; 72 // XXX FIX THIS!! 73 // if (DophotSelect && (catalog[0].measure[offset].dophot != DophotValue)) continue; 73 74 74 75 /* select measurements by quality */ -
branches/cnb_branch_20090215/Ohana/src/relastro/src/load_catalogs.c
r16810 r21536 38 38 if (RESET) { 39 39 for (j = 0; j < catalog[i].Naverage; j++) { 40 catalog[i].average[j]. code= 0;40 catalog[i].average[j].flags = 0; 41 41 m = catalog[i].average[j].measureOffset; 42 42 for (k = 0; k < catalog[i].average[j].Nmeasure; k++) { -
branches/cnb_branch_20090215/Ohana/src/relastro/src/relastro_objects.c
r17243 r21536 40 40 if (RESET) { 41 41 for (j = 0; j < catalog.Naverage; j++) { 42 catalog.average[j]. code= 0;42 catalog.average[j].flags = 0; 43 43 m = catalog.average[j].measureOffset; 44 44 for (k = 0; k < catalog.average[j].Nmeasure; k++) { -
branches/cnb_branch_20090215/Ohana/src/relastro/src/select_images.c
r17205 r21536 147 147 image[nimage] = timage[i]; 148 148 /* always allow 'few' images to succeed, if possible */ 149 if (image[nimage]. code& ID_IMAGE_FEW) {150 image[nimage]. code&= ~(ID_IMAGE_FEW | ID_IMAGE_POOR);149 if (image[nimage].flags & ID_IMAGE_FEW) { 150 image[nimage].flags &= ~(ID_IMAGE_FEW | ID_IMAGE_POOR); 151 151 } 152 152 if (RESET) { … … 154 154 assignMcal (&image[nimage], (double *) NULL, -1); 155 155 image[nimage].dMcal = NAN; 156 image[nimage]. code&= ~ID_IMAGE_POOR;156 image[nimage].flags &= ~ID_IMAGE_POOR; 157 157 } 158 158 line_number[nimage] = i; -
branches/cnb_branch_20090215/Ohana/src/relphot/include/relphot.h
r21153 r21536 23 23 short Xm; 24 24 float secz; 25 char code;25 char flags; 26 26 Coords coords; 27 27 } Mosaic; -
branches/cnb_branch_20090215/Ohana/src/relphot/src/GridOps.c
r20936 r21536 369 369 370 370 // skip stars marked as BAD 371 if (catalog[c].average[n]. code& STAR_BAD) {371 if (catalog[c].average[n].flags & STAR_BAD) { 372 372 Nrel ++; 373 373 continue; -
branches/cnb_branch_20090215/Ohana/src/relphot/src/ImageOps.c
r20936 r21536 244 244 if (i == -1) return (NAN); 245 245 246 if (image[i]. code& IMAGE_BAD) return (NAN);246 if (image[i].flags & IMAGE_BAD) return (NAN); 247 247 value = image[i].Mcal; 248 248 return (value); … … 285 285 /* on PoorImages run, skip good images */ 286 286 if (PoorImages) { 287 bad = image[i]. code& (ID_IMAGE_FEW | ID_IMAGE_POOR | ID_IMAGE_SKIP);287 bad = image[i].flags & (ID_IMAGE_FEW | ID_IMAGE_POOR | ID_IMAGE_SKIP); 288 288 if (!bad) continue; 289 289 } … … 331 331 mark = (N < IMAGE_TOOFEW) || (N < IMAGE_GOOD_FRACTION*Nlist[i]); 332 332 if (mark) { 333 image[i]. code|= ID_IMAGE_FEW;333 image[i].flags |= ID_IMAGE_FEW; 334 334 Nfew ++; 335 335 } else { 336 image[i]. code&= ~ID_IMAGE_FEW;336 image[i].flags &= ~ID_IMAGE_FEW; 337 337 } 338 338 } … … 373 373 374 374 for (i = N = 0; i < Nimage; i++) { 375 if (image[i]. code& IMAGE_BAD) continue;375 if (image[i].flags & IMAGE_BAD) continue; 376 376 mlist[N] = fabs (image[i].Mcal); 377 377 slist[N] = image[i].dMcal; … … 390 390 for (i = 0; i < Nimage; i++) { 391 391 mark = FALSE; 392 image[i]. code&= ~ID_IMAGE_POOR;392 image[i].flags &= ~ID_IMAGE_POOR; 393 393 mark = (image[i].dMcal > MaxScatter) || (fabs(image[i].Mcal - MedOffset) > MaxOffset); 394 394 if (mark) { 395 395 Nmark ++; 396 image[i]. code|= ID_IMAGE_POOR;396 image[i].flags |= ID_IMAGE_POOR; 397 397 } else { 398 image[i]. code&= ~ID_IMAGE_POOR;398 image[i].flags &= ~ID_IMAGE_POOR; 399 399 } 400 400 } … … 470 470 n = 0; 471 471 for (i = 0; i < Nimage; i++) { 472 if (image[i]. code& IMAGE_BAD) continue;472 if (image[i].flags & IMAGE_BAD) continue; 473 473 474 474 N = 0; … … 512 512 for (i = 0; i < Nimage; i++) { 513 513 514 if (image[i]. code& IMAGE_BAD) continue;514 if (image[i].flags & IMAGE_BAD) continue; 515 515 516 516 list[n] = pow (10.0, 0.01*image[i].Xm); … … 540 540 for (i = 0; i < Nimage; i++) { 541 541 542 if (image[i]. code& IMAGE_BAD) continue;542 if (image[i].flags & IMAGE_BAD) continue; 543 543 544 544 list[n] = image[i].Mcal; … … 568 568 for (i = 0; i < Nimage; i++) { 569 569 570 if (image[i]. code& IMAGE_BAD) continue;570 if (image[i].flags & IMAGE_BAD) continue; 571 571 572 572 list[n] = image[i].dMcal; -
branches/cnb_branch_20090215/Ohana/src/relphot/src/MosaicOps.c
r20323 r21536 68 68 mosaic[Nmosaic].dMcal = 0.0; 69 69 mosaic[Nmosaic].Xm = 0.0; 70 mosaic[Nmosaic]. code = image[i].code;70 mosaic[Nmosaic].flags = image[i].flags; 71 71 mosaic[Nmosaic].secz = image[i].secz; 72 72 … … 183 183 image[im].dMcal = mosaic[i].dMcal; 184 184 image[im].Xm = mosaic[i].Xm; 185 image[im]. code |= (mosaic[i].code& ID_IMAGE_FEW);186 image[im]. code |= (mosaic[i].code& ID_IMAGE_POOR);185 image[im].flags |= (mosaic[i].flags & ID_IMAGE_FEW); 186 image[im].flags |= (mosaic[i].flags & ID_IMAGE_POOR); 187 187 } 188 188 } … … 306 306 if (i == -1) return (NAN); 307 307 308 if (mosaic[i]. code& IMAGE_BAD) return (NAN);308 if (mosaic[i].flags & IMAGE_BAD) return (NAN); 309 309 value = mosaic[i].Mcal; 310 310 return (value); … … 343 343 /* on PoorImages run, skip good images */ 344 344 if (PoorImages) { 345 bad = mosaic[i]. code& (ID_IMAGE_FEW | ID_IMAGE_POOR | ID_IMAGE_SKIP);345 bad = mosaic[i].flags & (ID_IMAGE_FEW | ID_IMAGE_POOR | ID_IMAGE_SKIP); 346 346 if (!bad) continue; 347 347 } … … 393 393 if (mark) { 394 394 fprintf (stderr, "marked image %s (%d), (%d < %d) || (%d < %f*%d)\n", image[imlist[i][0]].name, i, N, IMAGE_TOOFEW, N, IMAGE_GOOD_FRACTION, Nlist[i]); 395 mosaic[i]. code|= ID_IMAGE_FEW;395 mosaic[i].flags |= ID_IMAGE_FEW; 396 396 Nfew ++; 397 397 } else { 398 mosaic[i]. code&= ~ID_IMAGE_FEW;398 mosaic[i].flags &= ~ID_IMAGE_FEW; 399 399 } 400 400 } … … 434 434 n = 0; 435 435 for (i = 0; i < Nmosaic; i++) { 436 if (mosaic[i]. code& IMAGE_BAD) continue;436 if (mosaic[i].flags & IMAGE_BAD) continue; 437 437 list[n] = mosaic[i].Mcal; 438 438 dlist[n] = 1; … … 462 462 for (i = 0; i < Nmosaic; i++) { 463 463 464 if (mosaic[i]. code& IMAGE_BAD) continue;464 if (mosaic[i].flags & IMAGE_BAD) continue; 465 465 list[n] = mosaic[i].dMcal; 466 466 dlist[n] = 1; … … 490 490 n = 0; 491 491 for (i = 0; i < Nmosaic; i++) { 492 if (mosaic[i]. code& IMAGE_BAD) continue;492 if (mosaic[i].flags & IMAGE_BAD) continue; 493 493 494 494 N = 0; … … 534 534 for (i = 0; i < Nmosaic; i++) { 535 535 536 if (mosaic[i]. code& IMAGE_BAD) continue;536 if (mosaic[i].flags & IMAGE_BAD) continue; 537 537 list[n] = pow(10.0, 0.01*mosaic[i].Xm); 538 538 dlist[n] = 1; … … 564 564 565 565 for (i = N = 0; i < Nmosaic; i++) { 566 if (mosaic[i]. code& IMAGE_BAD) continue;566 if (mosaic[i].flags & IMAGE_BAD) continue; 567 567 mlist[N] = mosaic[i].Mcal; 568 568 slist[N] = mosaic[i].dMcal; … … 584 584 if (mark) { 585 585 Nmark ++; 586 mosaic[i]. code|= ID_IMAGE_POOR;586 mosaic[i].flags |= ID_IMAGE_POOR; 587 587 } else { 588 mosaic[i]. code&= ~ID_IMAGE_POOR;588 mosaic[i].flags &= ~ID_IMAGE_POOR; 589 589 } 590 590 } -
branches/cnb_branch_20090215/Ohana/src/relphot/src/StarOps.c
r21153 r21536 26 26 27 27 ave = catalog[cat].measure[meas].averef; 28 if (catalog[cat].average[ave]. code& STAR_BAD) return (NAN);28 if (catalog[cat].average[ave].flags & STAR_BAD) return (NAN); 29 29 30 30 value = catalog[cat].secfilt[PhotNsec*ave+PhotSec].M; … … 44 44 45 45 /* calculate the average value for a single star */ 46 if (catalog[i].average[j]. code& STAR_BAD) continue;46 if (catalog[i].average[j].flags & STAR_BAD) continue; 47 47 m = catalog[i].average[j].measureOffset; 48 48 … … 89 89 90 90 if (N <= STAR_TOOFEW) { /* too few measurements */ 91 catalog[i].average[j]. code|= ID_STAR_FEW;91 catalog[i].average[j].flags |= ID_STAR_FEW; 92 92 Nfew ++; 93 93 } else { 94 catalog[i].average[j]. code&= ~ID_STAR_FEW;94 catalog[i].average[j].flags &= ~ID_STAR_FEW; 95 95 } 96 96 … … 208 208 209 209 // XXX this is a hack for the 2MASS search; better to save an average value? 210 if (catalog[i].measure[m]. qPSF< 0.85) continue;210 if (catalog[i].measure[m].psfQual < 0.85) continue; 211 211 212 212 list[N] = Msys - catalog[i].measure[m].Mcal; … … 280 280 for (i = Ntot = 0; i < Ncatalog; i++) { 281 281 for (j = 0; j < catalog[i].Naverage; j++) { 282 if (catalog[i].average[j]. code& STAR_BAD) continue;282 if (catalog[i].average[j].flags & STAR_BAD) continue; 283 283 Xm = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm; 284 284 if (Xm == -1) continue; … … 306 306 mark = (dM > MaxScatter) || (Xm == NAN_S_SHORT) || (Chisq > MaxChisq); 307 307 if (mark) { 308 catalog[i].average[j]. code|= ID_STAR_POOR;308 catalog[i].average[j].flags |= ID_STAR_POOR; 309 309 Ndel ++; 310 310 } else { 311 catalog[i].average[j]. code&= ~ID_STAR_POOR;311 catalog[i].average[j].flags &= ~ID_STAR_POOR; 312 312 } 313 313 Nave ++; … … 351 351 352 352 /* skip bad stars to prevent them from becoming good (on inner sample) */ 353 if (catalog[i].average[j]. code& STAR_BAD) continue;353 if (catalog[i].average[j].flags & STAR_BAD) continue; 354 354 355 355 /* on final processing, skip stars already measured */ … … 448 448 449 449 /* calculate the average value for a single star */ 450 if (catalog[i].average[j]. code& STAR_BAD) continue;450 if (catalog[i].average[j].flags & STAR_BAD) continue; 451 451 m = catalog[i].average[j].measureOffset; 452 452 … … 493 493 494 494 /* calculate the average value for a single star */ 495 if (catalog[i].average[j]. code& STAR_BAD) continue;495 if (catalog[i].average[j].flags & STAR_BAD) continue; 496 496 497 497 Xm = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm; … … 529 529 530 530 /* calculate the average value for a single star */ 531 if (catalog[i].average[j]. code& STAR_BAD) continue;531 if (catalog[i].average[j].flags & STAR_BAD) continue; 532 532 533 533 dM = catalog[i].secfilt[PhotNsec*j+PhotSec].dM; … … 559 559 for (i = 0; i < Ncatalog; i++) { 560 560 for (j = 0; j < catalog[i].Naverage; j++) { 561 if (catalog[i].average[j]. code& STAR_BAD) continue;561 if (catalog[i].average[j].flags & STAR_BAD) continue; 562 562 dMrel = catalog[i].secfilt[PhotNsec*j+PhotSec].dM; 563 563 bin = dMrel / 0.00025; … … 590 590 for (i = 0; i < Ncatalog; i++) { 591 591 for (j = 0; j < catalog[i].Naverage; j++) { 592 if (catalog[i].average[j]. code& STAR_BAD) continue;592 if (catalog[i].average[j].flags & STAR_BAD) continue; 593 593 xlist[N] = catalog[i].secfilt[PhotNsec*j+PhotSec].M; 594 594 value = catalog[i].secfilt[PhotNsec*j+PhotSec].Xm; -
branches/cnb_branch_20090215/Ohana/src/relphot/src/bcatalog.c
r20323 r21536 34 34 subcatalog[0].secfilt[PhotNsec*Naverage+PhotSec].M = NAN; 35 35 subcatalog[0].secfilt[PhotNsec*Naverage+PhotSec].dM = NAN; 36 subcatalog[0].average[Naverage]. code&= ~ID_STAR_FEW;37 subcatalog[0].average[Naverage]. code&= ~ID_STAR_POOR;36 subcatalog[0].average[Naverage].flags &= ~ID_STAR_FEW; 37 subcatalog[0].average[Naverage].flags &= ~ID_STAR_POOR; 38 38 } 39 39 … … 55 55 /* select measurements by quality */ 56 56 // XXX ignore this criterion for REF measurements? 57 if (DophotSelect && (catalog[0].measure[offset].dophot != DophotValue)) continue; 57 // XXX chnage this to select by bitflags 58 if (DophotSelect && ((catalog[0].measure[offset].photFlags >> 16) != DophotValue)) continue; 58 59 59 60 /* select measurements by mag limit */ -
branches/cnb_branch_20090215/Ohana/src/relphot/src/plot_scatter.c
r20193 r21536 23 23 24 24 /* calculate the average value for a single star */ 25 if (catalog[i].average[j]. code& STAR_BAD) continue;25 if (catalog[i].average[j].flags & STAR_BAD) continue; 26 26 m = catalog[i].average[j].measureOffset; 27 27 -
branches/cnb_branch_20090215/Ohana/src/relphot/src/relphot_objects.c
r21153 r21536 42 42 Nsecfilt = catalog.Nsecfilt; 43 43 for (j = 0; j < catalog.Naverage; j++) { 44 catalog.average[j]. code= 0;44 catalog.average[j].flags = 0; 45 45 for (k = 0; k < Nsecfilt; k++) { 46 catalog.secfilt[j*Nsecfilt + k].M = NAN; 47 catalog.secfilt[j*Nsecfilt + k].dM = NAN; 48 catalog.secfilt[j*Nsecfilt + k].Xm = NAN_S_SHORT; 46 catalog.secfilt[j*Nsecfilt + k].M = NAN; 47 catalog.secfilt[j*Nsecfilt + k].M_20 = NAN_S_SHORT; 48 catalog.secfilt[j*Nsecfilt + k].M_80 = NAN_S_SHORT; 49 catalog.secfilt[j*Nsecfilt + k].dM = NAN; 50 catalog.secfilt[j*Nsecfilt + k].Xm = NAN_S_SHORT; 49 51 catalog.secfilt[j*Nsecfilt + k].Ncode = 0; 50 52 catalog.secfilt[j*Nsecfilt + k].Nused = 0; 51 catalog.secfilt[j*Nsecfilt + k].dummy = 0;52 53 } 53 54 m = catalog.average[j].measureOffset; -
branches/cnb_branch_20090215/Ohana/src/relphot/src/select_images.c
r15509 r21536 133 133 image[nimage] = timage[i]; 134 134 /* always allow 'few' images to succeed, if possible */ 135 if (image[nimage]. code& ID_IMAGE_FEW) {136 image[nimage]. code&= ~(ID_IMAGE_FEW | ID_IMAGE_POOR);135 if (image[nimage].flags & ID_IMAGE_FEW) { 136 image[nimage].flags &= ~(ID_IMAGE_FEW | ID_IMAGE_POOR); 137 137 } 138 138 if (RESET) { 139 139 assignMcal (&image[nimage], (double *) NULL, -1); 140 140 image[nimage].dMcal = NAN; 141 image[nimage]. code&= ~ID_IMAGE_POOR;141 image[nimage].flags &= ~ID_IMAGE_POOR; 142 142 } 143 143 line_number[nimage] = i; -
branches/cnb_branch_20090215/Ohana/src/relphot/src/setMrelFinal.c
r17201 r21536 54 54 /* clear ID_STAR_POOR, ID_STAR_FEW, ID_MEAS_NOCAL values before writing ??? */ 55 55 for (i = 0; i < catalog[0].Naverage; i++) { 56 catalog[0].average[i]. code&= ~ID_STAR_FEW;57 catalog[0].average[i]. code&= ~ID_STAR_POOR;56 catalog[0].average[i].flags &= ~ID_STAR_FEW; 57 catalog[0].average[i].flags &= ~ID_STAR_POOR; 58 58 m = catalog[0].average[i].measureOffset; 59 59 for (j = 0; j < catalog[0].average[i].Nmeasure; j++, m++) { … … 102 102 103 103 /* skip measurements with sat. dophot values */ 104 if ((pass < 4) && (catalog[0].measure[m].dophot == 10)) goto skip; 104 // XXX we need to fix this: use the photFlags to ID saturation... 105 // if ((pass < 4) && (catalog[0].measure[m].dophot == 10)) goto skip; 105 106 106 107 /* skip measurements from BAD images and mosaics */ … … 116 117 } 117 118 118 d1 = (catalog[0].measure[m].dophot == 1); 119 d2 = (catalog[0].measure[m].dophot == 2); 119 // d1 = (catalog[0].measure[m].dophot == 1); 120 // d2 = (catalog[0].measure[m].dophot == 2); 121 fprintf (stderr, "fix the dophot / type selections!"); 122 abort (); 120 123 121 124 /* skip measurements by measurement error */ -
branches/cnb_branch_20090215/Ohana/src/uniphot/src/find_image_sgroups.c
r7080 r21536 27 27 for (i = 0; i < Nimage; i++) { 28 28 if (imlink[i].sgroup != NULL) continue; 29 if (image[i]. code& ID_IMAGE_NOCAL) continue;29 if (image[i].flags & ID_IMAGE_NOCAL) continue; 30 30 31 31 /* new sgroup, set ref coords */ … … 52 52 53 53 for (j = 0; j < Nimage; j++) { 54 if (image[j]. code& ID_IMAGE_NOCAL) continue;54 if (image[j].flags & ID_IMAGE_NOCAL) continue; 55 55 if (imlink[j].sgroup != NULL) continue; 56 56 -
branches/cnb_branch_20090215/Ohana/src/uniphot/src/find_image_tgroups.c
r16040 r21536 63 63 if (image[j].tzero < tmin[i]) continue; 64 64 if (image[j].tzero > tmax[i]) continue; 65 if (image[j]. code& ID_IMAGE_NOCAL) continue;65 if (image[j].flags & ID_IMAGE_NOCAL) continue; 66 66 67 67 group[i].image[Nentry] = &image[j]; -
branches/cnb_branch_20090215/Ohana/src/uniphot/src/fit_groups.c
r12332 r21536 16 16 for (i = 0; i < Ntgroup; i++) { 17 17 for (j = Nlist = 0; j < tgroup[i].Nimage; j++) { 18 if (tgroup[i].image[j][0]. code& IMAGE_BAD) continue;18 if (tgroup[i].image[j][0].flags & IMAGE_BAD) continue; 19 19 sgroup = (Group *) tgroup[i].imlink[j][0].sgroup; 20 20 Mcal = tgroup[i].image[j][0].Mcal; … … 54 54 for (i = 0; i < Nsgroup; i++) { 55 55 for (j = Nlist = 0; j < sgroup[i].Nimage; j++) { 56 if (sgroup[i].image[j][0]. code& IMAGE_BAD) continue;56 if (sgroup[i].image[j][0].flags & IMAGE_BAD) continue; 57 57 tgroup = (Group *) sgroup[i].imlink[j][0].tgroup; 58 58 Mcal = sgroup[i].image[j][0].Mcal; -
branches/cnb_branch_20090215/Ohana/src/uniphot/src/subset_images.c
r12332 r21536 16 16 for (i = 0; i < Nimage; i++) { 17 17 18 image[i]. code|= ID_IMAGE_NOCAL;18 image[i].flags |= ID_IMAGE_NOCAL; 19 19 20 20 /* select images by photcode */ … … 27 27 if (image[i].tzero > TSTOP) continue; 28 28 } 29 image[i]. code&= ~ID_IMAGE_NOCAL;29 image[i].flags &= ~ID_IMAGE_NOCAL; 30 30 keep[Nkeep] = i; 31 31 Nkeep ++; -
branches/cnb_branch_20090215/Ohana/src/uniphot/src/update.c
r19823 r21536 16 16 /* clear the NOCAL flags */ 17 17 for (i = 0; i < Nimage; i++) { 18 image[i]. code&= ~ID_IMAGE_NOCAL;18 image[i].flags &= ~ID_IMAGE_NOCAL; 19 19 } 20 20 -
branches/cnb_branch_20090215/ippTools/share/Makefile.am
r20973 r21536 21 21 chiptool_revertprocessedimfile.sql \ 22 22 chiptool_run.sql \ 23 chiptool_export_run.sql \ 24 chiptool_export_imfiles.sql \ 23 25 chiptool_unmasked.sql \ 24 26 detselect_search.sql \ -
branches/cnb_branch_20090215/ippTools/src/chiptool.c
r21463 r21536 54 54 static bool tofullimfileMode(pxConfig *config); 55 55 static bool topurgedimfileMode(pxConfig *config); 56 static bool exportrunMode(pxConfig *config); 57 static bool importrunMode(pxConfig *config); 56 58 57 59 # define MODECASE(caseName, func) \ … … 91 93 MODECASE(CHIPTOOL_MODE_TOFULLIMFILE, tofullimfileMode); 92 94 MODECASE(CHIPTOOL_MODE_TOPURGEDIMFILE, topurgedimfileMode); 95 MODECASE(CHIPTOOL_MODE_EXPORTRUN, exportrunMode); 96 MODECASE(CHIPTOOL_MODE_IMPORTRUN, importrunMode); 93 97 default: 94 98 psAbort("invalid option (this should not happen)"); … … 880 884 } 881 885 882 883 886 static bool pendingcleanupimfileMode(pxConfig *config) 884 887 { … … 1005 1008 return true; 1006 1009 } 1007 1008 1010 1009 1011 static bool runMode(pxConfig *config) … … 1251 1253 return change_imfile_data_state(config, "purged", "goto_purged"); 1252 1254 } 1255 1256 bool exportrunMode(pxConfig *config) 1257 { 1258 PS_ASSERT_PTR_NON_NULL(config, NULL); 1259 1260 PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", true, false); 1261 PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true, false); 1262 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1263 1264 FILE *f = fopen (outfile, "w"); 1265 if (f == NULL) { 1266 psError(PS_ERR_UNKNOWN, false, "failed to open output file"); 1267 return false; 1268 } 1269 1270 psMetadata *where = psMetadataAlloc(); 1271 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "=="); 1272 1273 // *** extract the chipRun in this section *** 1274 psString query = pxDataGet("chiptool_export_run.sql"); 1275 if (!query) { 1276 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1277 return false; 1278 } 1279 1280 if (where && psListLength(where->list)) { 1281 psString whereClause = psDBGenerateWhereSQL(where, NULL); 1282 psStringAppend(&query, " %s", whereClause); 1283 psFree(whereClause); 1284 } 1285 1286 // treat limit == 0 as "no limit" 1287 if (limit) { 1288 psString limitString = psDBGenerateLimitSQL(limit); 1289 psStringAppend(&query, " %s", limitString); 1290 psFree(limitString); 1291 } 1292 1293 if (!p_psDBRunQuery(config->dbh, query)) { 1294 psError(PS_ERR_UNKNOWN, false, "database error"); 1295 psFree(query); 1296 return false; 1297 } 1298 psFree(query); 1299 1300 psArray *output = p_psDBFetchResult(config->dbh); 1301 if (!output) { 1302 psError(PS_ERR_UNKNOWN, false, "database error"); 1303 return false; 1304 } 1305 if (!psArrayLength(output)) { 1306 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 1307 psFree(output); 1308 return true; 1309 } 1310 1311 // we must write the export table in non-simple (true) format 1312 if (!ippdbPrintMetadatas(f, output, "chipRun", true)) { 1313 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1314 psFree(output); 1315 return false; 1316 } 1317 psFree(output); 1318 1319 // *** extract the chipProcessedImfile entries in this section *** 1320 query = pxDataGet("chiptool_export_imfiles.sql"); 1321 if (!query) { 1322 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1323 return false; 1324 } 1325 1326 if (where && psListLength(where->list)) { 1327 psString whereClause = psDBGenerateWhereSQL(where, NULL); 1328 psStringAppend(&query, " %s", whereClause); 1329 psFree(whereClause); 1330 } 1331 psFree(where); 1332 1333 // treat limit == 0 as "no limit" 1334 if (limit) { 1335 psString limitString = psDBGenerateLimitSQL(limit); 1336 psStringAppend(&query, " %s", limitString); 1337 psFree(limitString); 1338 } 1339 1340 if (!p_psDBRunQuery(config->dbh, query)) { 1341 psError(PS_ERR_UNKNOWN, false, "database error"); 1342 psFree(query); 1343 return false; 1344 } 1345 psFree(query); 1346 1347 output = p_psDBFetchResult(config->dbh); 1348 if (!output) { 1349 psError(PS_ERR_UNKNOWN, false, "database error"); 1350 return false; 1351 } 1352 if (!psArrayLength(output)) { 1353 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 1354 psFree(output); 1355 return true; 1356 } 1357 1358 // we must write the export table in non-simple (true) format 1359 if (!ippdbPrintMetadatas(f, output, "chipProcessedImfiles", true)) { 1360 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1361 psFree(output); 1362 return false; 1363 } 1364 psFree(output); 1365 1366 fclose (f); 1367 1368 return true; 1369 } 1370 1371 1372 bool importrunMode(pxConfig *config) 1373 { 1374 unsigned int nFail; 1375 1376 PS_ASSERT_PTR_NON_NULL(config, NULL); 1377 1378 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false); 1379 1380 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 1381 1382 fprintf (stdout, "---- input ----\n"); 1383 psMetadataPrint (stderr, input, 1); 1384 1385 psMetadataItem *chipRunItem = psMetadataLookup (input, "chipRun"); 1386 psAssert (chipRunItem, "entry not in input?"); 1387 psAssert (chipRunItem->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1388 1389 psMetadataItem *chipRunEntry = psListGet (chipRunItem->data.list, 0); 1390 assert (chipRunEntry); 1391 assert (chipRunEntry->type == PS_DATA_METADATA); 1392 chipRunRow *chipRun = chipRunObjectFromMetadata (chipRunEntry->data.md); 1393 chipRunInsertObject (config->dbh, chipRun); 1394 1395 // fprintf (stdout, "---- chip run ----\n"); 1396 // psMetadataPrint (stderr, chipRunEntry->data.md, 1); 1397 1398 psMetadataItem *item = psMetadataLookup (input, "chipProcessedImfiles"); 1399 psAssert (item, "entry not in input?"); 1400 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1401 1402 // XXX would be better to use the iterator? 1403 for (int i = 0; i < item->data.list->n; i++) { 1404 psMetadataItem *entry = psListGet (item->data.list, i); 1405 assert (entry); 1406 assert (entry->type == PS_DATA_METADATA); 1407 chipProcessedImfileRow *chipProcessedImfile = chipProcessedImfileObjectFromMetadata (entry->data.md); 1408 chipProcessedImfileInsertObject (config->dbh, chipProcessedImfile); 1409 1410 // fprintf (stdout, "---- row %d ----\n", i); 1411 // psMetadataPrint (stderr, entry->data.md, 1); 1412 } 1413 1414 return true; 1415 } 1416 1417 -
branches/cnb_branch_20090215/ippTools/src/chiptool.h
r21463 r21536 44 44 CHIPTOOL_MODE_TOCLEANEDIMFILE, 45 45 CHIPTOOL_MODE_TOFULLIMFILE, 46 CHIPTOOL_MODE_TOPURGEDIMFILE 46 CHIPTOOL_MODE_TOPURGEDIMFILE, 47 CHIPTOOL_MODE_EXPORTRUN, 48 CHIPTOOL_MODE_IMPORTRUN 47 49 } chiptoolMode; 48 50 -
branches/cnb_branch_20090215/ippTools/src/chiptoolConfig.c
r21463 r21536 244 244 psMetadataAddStr(topurgedimfileArgs, PS_LIST_TAIL, "-class_id", 0, "class ID to update", NULL); 245 245 246 // -exportrun 247 psMetadata *exportrunArgs = psMetadataAlloc(); 248 // pxchipSetSearchArgs (exportrunArgs); XXX include search terms? 249 psMetadataAddS64(exportrunArgs, PS_LIST_TAIL, "-chip_id", 0, "export this chip ID (required)", 0); 250 psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0, "export to this file (required)", NULL); 251 psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 252 253 // -importrun 254 psMetadata *importrunArgs = psMetadataAlloc(); 255 psMetadataAddStr(importrunArgs, PS_LIST_TAIL, "-infile", 0, "import from this file (required)", NULL); 256 246 257 psMetadata *argSets = psMetadataAlloc(); 247 258 psMetadata *modes = psMetadataAlloc(); … … 264 275 PXOPT_ADD_MODE("-run", "show runs", CHIPTOOL_MODE_RUN, runArgs); 265 276 PXOPT_ADD_MODE("-tocleanedimfile", "set imfile state to cleaned", CHIPTOOL_MODE_TOCLEANEDIMFILE, tocleanedimfileArgs); 266 PXOPT_ADD_MODE("-tofullimfile", "set imfile state to full", CHIPTOOL_MODE_TOFULLIMFILE, tofullimfileArgs); 267 PXOPT_ADD_MODE("-topurgedimfile", "set imfile state to purged", CHIPTOOL_MODE_TOPURGEDIMFILE, topurgedimfileArgs); 277 PXOPT_ADD_MODE("-tofullimfile", "set imfile state to full", CHIPTOOL_MODE_TOFULLIMFILE, tofullimfileArgs); 278 PXOPT_ADD_MODE("-topurgedimfile", "set imfile state to purged", CHIPTOOL_MODE_TOPURGEDIMFILE, topurgedimfileArgs); 279 280 PXOPT_ADD_MODE("-exportrun", "export run for import on other database", CHIPTOOL_MODE_EXPORTRUN, exportrunArgs); 281 PXOPT_ADD_MODE("-importrun", "import run from metadata file", CHIPTOOL_MODE_IMPORTRUN, importrunArgs); 268 282 269 283 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { -
branches/cnb_branch_20090215/ippconfig/gpc1/Makefile.am
r20199 r21536 10 10 format_20080929.config \ 11 11 format_20081011.config \ 12 format_20090120.config \ 12 13 format_mef.config \ 13 14 format_relphot.config \ -
branches/cnb_branch_20090215/ippconfig/gpc1/psphot.config
r21057 r21536 3 3 SAVE.OUTPUT BOOL TRUE 4 4 SAVE.BACKMDL BOOL TRUE 5 #SAVE.RESID BOOL TRUE 6 #SAVE.BACKGND BOOL TRUE 7 #SAVE.BACKSUB BOOL TRUE 8 #SAVE.PSF BOOL TRUE 9 #LOAD.PSF BOOL FALSE 10 #SAVE.PLOTS BOOL TRUE 5 SAVE.PSF BOOL TRUE 6 SAVE.PLOTS BOOL TRUE 11 7 12 8 BACKGROUND.XBIN S32 256 # size of background superpixels … … 42 38 PSF.TREND.NY S32 1 43 39 44 MOMENTS_SN_MIN F32 30.040 MOMENTS_SN_MIN F32 10.0 45 41 EXT_MIN_SN F32 50.0 # fit galaxies above this S/N limit 46 42 FULL_FIT_SN_LIM F32 50.0 47 43 AP_MIN_SN F32 50.0 48 44 49 OUTPUT.FORMAT STR PS1_DEV_145 OUTPUT.FORMAT STR PS1_V1 50 46 51 47 PSF_SHAPE_NSIGMA F32 3.0 # max significance for shape variation -
branches/cnb_branch_20090215/ippconfig/recipes/fitstypes.mdc
r17523 r21536 24 24 END 25 25 DET_MASK METADATA 26 BITPIX S32 826 BITPIX S32 16 27 27 END 28 28 DET_WEIGHT METADATA … … 34 34 END 35 35 SKY_MASK METADATA 36 BITPIX S32 836 BITPIX S32 16 37 37 END 38 38 SKY_WEIGHT METADATA … … 54 54 # Compressed mask 55 55 COMP_MASK METADATA 56 BITPIX S32 856 BITPIX S32 16 57 57 COMPRESSION STR PLIO 58 58 TILE.X S32 0 -
branches/cnb_branch_20090215/ippconfig/recipes/psphot.config
r21362 r21536 49 49 # parameters to control the selection of the peak in the Sx,Sy plane 50 50 MOMENTS_SCALE F32 0.25 51 MOMENTS_SN_MIN F32 10 0.0 # min S/N to measure moments51 MOMENTS_SN_MIN F32 10.0 # min S/N to measure moments 52 52 MOMENTS_SX_MAX F32 50.0 53 53 MOMENTS_SY_MAX F32 50.0 -
branches/cnb_branch_20090215/ippconfig/vysos5/camera.config
r20102 r21536 3 3 # File formats that we know about 4 4 FORMATS METADATA 5 FLIPPED STR vysos5/format_flipped.config 5 6 SIMPLE STR vysos5/format.config 6 FLIPPED STR vysos5/format_flipped.config7 7 END 8 8 -
branches/cnb_branch_20090215/ippconfig/vysos5/format_flipped.config
r20102 r21536 5 5 TELESCOP STR VYSOS-5 6 6 INSTRUME STR Apogee USB/Net 7 FLIPSTAT STR Flip/Mirror 7 8 END 8 9 … … 60 61 CELL.READDIR S32 2 61 62 CELL.TIMESYS STR UTC 62 CELL.XPARITY S32 163 CELL.YPARITY S32 163 CELL.XPARITY S32 -1 64 CELL.YPARITY S32 -1 64 65 CHIP.XPARITY S32 1 65 66 CHIP.YPARITY S32 1 -
branches/cnb_branch_20090215/ippconfig/vysos5/psastro.config
r20652 r21536 9 9 # use plate-scale to make this in pixels? 10 10 PSASTRO.GRID.OFFSET F32 200. 11 PSASTRO.GRID.SCALE F32 5011 PSASTRO.GRID.SCALE F32 10 12 12 PSASTRO.GRID.NSTAR.MAX S32 800 # max stars accepted for fitting 13 13 14 PSASTRO.MAX.NRAW S32 1000 # max stars accepted for fitting (0 for all)15 PSASTRO.MAX.NREF S32 5000 # max stars accepted for fitting (0 for all)14 PSASTRO.MAX.NRAW S32 500 # max stars accepted for fitting (0 for all) 15 PSASTRO.MAX.NREF S32 2000 # max stars accepted for fitting (0 for all) 16 16 17 17 # extra field for ref stars: -
branches/cnb_branch_20090215/ppImage/src/ppImageArguments.c
r19943 r21536 80 80 if ((argnum = psArgumentGet(argc, argv, "-visual"))) { 81 81 psArgumentRemove(argnum, &argc, argv); 82 psphotSetVisual(true);82 pmVisualSetVisual(true); 83 83 } 84 84 … … 86 86 if ((argnum = psArgumentGet(argc, argv, "-threads"))) { 87 87 psArgumentRemove(argnum, &argc, argv); 88 int nThreads = atoi(argv[argnum]);88 int nThreads = atoi(argv[argnum]); 89 89 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "NTHREADS", 0, "number of warp threads", nThreads); 90 90 psArgumentRemove(argnum, &argc, argv); 91 91 92 // create the thread pool with number of desired threads, supplying our thread launcher function93 // XXX need to determine the number of threads from the config data94 psThreadPoolInit (nThreads);92 // create the thread pool with number of desired threads, supplying our thread launcher function 93 // XXX need to determine the number of threads from the config data 94 psThreadPoolInit (nThreads); 95 95 } 96 96 -
branches/cnb_branch_20090215/ppStack/src/ppStack.c
r21258 r21536 74 74 pmConfigDone(); 75 75 psLibFinalize(); 76 76 pmVisualClose(); 77 77 exit(exitValue); 78 78 } -
branches/cnb_branch_20090215/ppStack/src/ppStackArguments.c
r21477 r21536 176 176 psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-limit", 0, "Limit on star rejection fraction for successful iteration", NAN); 177 177 psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-sys", 0, "Estimated systematic error", NAN); 178 psMetadataAddBool(arguments, PS_LIST_TAIL, "-renorm", 0, "Renormalise variance maps?", false);179 psMetadataAddStr(arguments, PS_LIST_TAIL, "-renorm-mean", 0,180 "Statistic for mean in renormalisation", NULL);181 psMetadataAddStr(arguments, PS_LIST_TAIL, "-renorm-stdev", 0,182 "Statistic for stdev in renormalisation", NULL);183 psMetadataAddF32(arguments, PS_LIST_TAIL, "-renorm-width", 0, "Gaussian width for renormalisation", NAN);184 psMetadataAddS32(arguments, PS_LIST_TAIL, "-renorm-num", 0, "Number of samples for renormalisation", 0);185 178 psMetadataAddStr(arguments, PS_LIST_TAIL, "-temp-image", 0, "Suffix for temporary images", NULL); 186 179 psMetadataAddStr(arguments, PS_LIST_TAIL, "-temp-mask", 0, "Suffix for temporary masks", NULL); … … 189 182 "Delete temporary files on completion?", false); 190 183 psMetadataAddS32(arguments, PS_LIST_TAIL, "-threads", 0, "Number of threads to use", 0); 191 psMetadataAddBool(arguments, PS_LIST_TAIL, "- psphot-visual", 0, "psphotvisualisation", 0);184 psMetadataAddBool(arguments, PS_LIST_TAIL, "-visual", 0, "visualisation", 0); 192 185 193 186 if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 3) { … … 280 273 } 281 274 282 if (psMetadataLookupBool(NULL, arguments, "-renorm") ||283 psMetadataLookupBool(NULL, recipe, "RENORM")) {284 psMetadataAddBool(arguments, PS_LIST_TAIL, "RENORM", 0, "Renormalise variance maps?", true);285 }286 VALUE_ARG_RECIPE_INT("-renorm-num", "RENORM.NUM", S32, 0);287 VALUE_ARG_RECIPE_FLOAT("-renorm-width", "RENORM.WIDTH", F32);288 valueArgRecipeStr(arguments, recipe, "-renorm-mean", "RENORM.MEAN", recipe);289 valueArgRecipeStr(arguments, recipe, "-renorm-stdev", "RENORM.STDEV", recipe);290 291 275 valueArgRecipeStr(arguments, recipe, "-temp-image", "TEMP.IMAGE", recipe); 292 276 valueArgRecipeStr(arguments, recipe, "-temp-mask", "TEMP.MASK", recipe); -
branches/cnb_branch_20090215/ppStack/src/ppStackLoop.c
r21477 r21536 480 480 psMetadataAddF32(stats, PS_LIST_TAIL, "STAMP.NUM", PS_META_DUPLICATE_OK, 481 481 "Number of stamps", kernels->numStamps); 482 float deconv = psMetadataLookupF32(NULL, readout->analysis, 483 PM_SUBTRACTION_ANALYSIS_DECONV_MAX); // Deconvolution fraction 484 psMetadataAddF32(stats, PS_LIST_TAIL, "KERNEL.DECONV", PS_META_DUPLICATE_OK, 485 "Deconvolution fraction for kernel", deconv); 482 486 psMetadataAddF32(stats, PS_LIST_TAIL, "PPSTACK.WEIGHTING", PS_META_DUPLICATE_OK, 483 487 "Weighting for image", weightings->data.F32[i]); … … 503 507 psStringAppend(&name, "covariance_%d.fits", i); 504 508 writeImage(name, hdu->header, readout->covariance->image, config); 509 pmStackVisualPlotTestImage(readout->covariance->image, name); 505 510 psFree(name); 506 511 } … … 801 806 #ifdef TESTING 802 807 writeImage("combined_initial.fits", NULL, outRO->image, config); 808 pmStackVisualPlotTestImage(outRO->image, "combined_initial.fits"); 803 809 #endif 804 810 … … 884 890 psString name = NULL; // Name of image 885 891 psStringAppend(&name, "inspect_%03d.fits", i); 892 pmStackVisualPlotTestImage(mask, name); 886 893 psFits *fits = psFitsOpen(name, "w"); 887 894 psFree(name); … … 901 908 psString name = NULL; // Name of image 902 909 psStringAppend(&name, "reject_%03d.fits", i); 910 pmStackVisualPlotTestImage(mask, name); 903 911 psFits *fits = psFitsOpen(name, "w"); 904 912 psFree(name); … … 1034 1042 1035 1043 #ifdef TESTING 1044 pmStackVisualPlotTestImage(outRO->image, "combined_initial.fits"); 1036 1045 writeImage("combined_final.fits", NULL, outRO->image, config); 1037 1046 #endif … … 1151 1160 psLogMsg("ppStack", PS_LOG_INFO, "Stage 7 : WCS & JPEGS : %f sec", psTimerClear("PPSTACK_STEPS")); 1152 1161 1153 if (psMetadataLookupBool(&mdok, recipe, "RENORM")) {1154 // Statistics for renormalisation1155 psStatsOptions renormMean = psStatsOptionFromString(psMetadataLookupStr(&mdok, recipe,1156 "RENORM.MEAN"));1157 psStatsOptions renormStdev = psStatsOptionFromString(psMetadataLookupStr(&mdok, recipe,1158 "RENORM.STDEV"));1159 int renormNum = psMetadataLookupS32(&mdok, recipe, "RENORM.NUM"); // Number of samples1160 float renormWidth = psMetadataLookupS32(&mdok, recipe, "RENORM.WIDTH"); // Width of Gaussian phot1161 psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask1162 if (!pmReadoutVarianceRenormPhot(outRO, maskValue, renormNum, renormWidth,1163 renormMean, renormStdev, NULL)) {1164 psError(PS_ERR_UNKNOWN, false, "Unable to renormalise variances.");1165 psFree(outRO);1166 return false;1167 }1168 }1169 1170 psLogMsg("ppStack", PS_LOG_INFO, "Stage 8 : Photometry Renormalization : %f sec", psTimerClear("PPSTACK_STEPS"));1171 1172 1162 if (psMetadataLookupBool(&mdok, recipe, "PHOTOMETRY")) { 1173 1163 psTrace("ppStack", 1, "Photometering stacked image....\n"); … … 1199 1189 } 1200 1190 1201 psLogMsg("ppStack", PS_LOG_INFO, "Stage 9: Photometry Analysis : %f sec", psTimerClear("PPSTACK_STEPS"));1191 psLogMsg("ppStack", PS_LOG_INFO, "Stage 8 : Photometry Analysis : %f sec", psTimerClear("PPSTACK_STEPS")); 1202 1192 1203 1193 psThreadPoolFinalize(); … … 1254 1244 } 1255 1245 1256 psLogMsg("ppStack", PS_LOG_INFO, "Stage 10: Final Output : %f sec", psTimerClear("PPSTACK_STEPS"));1246 psLogMsg("ppStack", PS_LOG_INFO, "Stage 9 : Final Output : %f sec", psTimerClear("PPSTACK_STEPS")); 1257 1247 1258 1248 memDump("finish"); -
branches/cnb_branch_20090215/ppStack/src/ppStackMatch.c
r21477 r21536 189 189 190 190 bool mdok; // Status of MD lookup 191 bool renorm = psMetadataLookupBool(&mdok, recipe, "RENORM"); // Renormalise variances?192 191 float penalty = psMetadataLookupF32(NULL, ppsub, "PENALTY"); // Penalty for wideness 193 192 int threads = psMetadataLookupS32(NULL, config->arguments, "-threads"); // Number of threads … … 359 358 psString name = NULL; 360 359 psStringAppend(&name, "fake_%03d.fits", numInput); 360 pmStackVisualPlotTestImage(fake->image, name); 361 361 psFits *fits = psFitsOpen(name, "w"); 362 362 psFree(name); … … 368 368 psString name = NULL; 369 369 psStringAppend(&name, "real_%03d.fits", numInput); 370 pmStackVisualPlotTestImage(readout->image, name); 370 371 psFits *fits = psFitsOpen(name, "w"); 371 372 psFree(name); … … 374 375 } 375 376 #endif 376 377 // Renormalise the variances if desired378 if (renorm) {379 // Statistics for renormalisation380 psStatsOptions renormMean = psStatsOptionFromString(psMetadataLookupStr(&mdok, recipe,381 "RENORM.MEAN"));382 psStatsOptions renormStdev = psStatsOptionFromString(psMetadataLookupStr(&mdok, recipe,383 "RENORM.STDEV"));384 385 if (!pmReadoutVarianceRenormPixels(readout, maskBad, renormMean, renormStdev, rng)) {386 psError(PS_ERR_UNKNOWN, false, "Unable to renormalise variances.");387 psFree(output);388 return false;389 }390 }391 377 392 378 if (threads > 0) { … … 413 399 psString name = NULL; 414 400 psStringAppend(&name, "conv_%03d.fits", numInput); 401 pmStackVisualPlotTestImage(output->image, name); 415 402 psFits *fits = psFitsOpen(name, "w"); 416 403 psFree(name); … … 422 409 psString name = NULL; 423 410 psStringAppend(&name, "diff_%03d.fits", numInput); 411 pmStackVisualPlotTestImage(fake->image, name); 424 412 psFits *fits = psFitsOpen(name, "w"); 425 413 psFree(name); … … 562 550 } 563 551 564 // Renormalise the variances if desired565 if (renorm) {566 // Statistics for renormalisation567 psStatsOptions renormMean = psStatsOptionFromString(psMetadataLookupStr(&mdok, recipe,568 "RENORM.MEAN"));569 psStatsOptions renormStdev = psStatsOptionFromString(psMetadataLookupStr(&mdok, recipe,570 "RENORM.STDEV"));571 572 if (!pmReadoutVarianceRenormPixels(readout, maskBad, renormMean, renormStdev, rng)) {573 psError(PS_ERR_UNKNOWN, false, "Unable to renormalise variances.");574 psFree(output);575 return false;576 }577 }578 579 552 // Ensure the background value is zero 580 553 psStats *bg = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics for background … … 664 637 psString name = NULL; 665 638 psStringAppend(&name, "convolved_%03d.fits", numInput); 639 pmStackVisualPlotTestImage(output->image, name); 666 640 psFits *fits = psFitsOpen(name, "w"); 667 641 psFree(name); -
branches/cnb_branch_20090215/ppStack/src/ppStackPhotometry.c
r21259 r21536 118 118 pmFPACopy(photFile->fpa, readout->parent->parent->parent); 119 119 120 if (psMetadataLookupBool(NULL, config->arguments, "- psphot-visual")) {121 p sphotSetVisual(true);120 if (psMetadataLookupBool(NULL, config->arguments, "-visual")) { 121 pmVisualSetVisual(true); 122 122 } 123 123 -
branches/cnb_branch_20090215/ppStack/src/ppStackSources.c
r21260 r21536 69 69 psString name = NULL; 70 70 psStringAppend(&name, "start_%03d.fits", i); 71 pmStackVisualPlotTestImage(fake->image, name); 71 72 psFits *fits = psFitsOpen(name, "w"); 72 73 psFree(name); … … 154 155 int minMatches = PS_MAX (2, 0.5*num); 155 156 for (int i = 0; i < matches->n; i++) { 156 pmSourceMatch *match = matches->data[i]; // Match of interest157 if (match->num < minMatches) continue;158 159 // We need to grab a single instance of this source: just take the first available160 int nImage = match->image->data.S32[0];161 int nIndex = match->index->data.S32[0];162 psArray *sources = sourceLists->data[nImage];163 pmSource *source = sources->data[nIndex];164 165 // stick this sample source on sourcesBest166 psArrayAdd (sourcesBest, 100, source);157 pmSourceMatch *match = matches->data[i]; // Match of interest 158 if (match->num < minMatches) continue; 159 160 // We need to grab a single instance of this source: just take the first available 161 int nImage = match->image->data.S32[0]; 162 int nIndex = match->index->data.S32[0]; 163 psArray *sources = sourceLists->data[nImage]; 164 pmSource *source = sources->data[nIndex]; 165 166 // stick this sample source on sourcesBest 167 psArrayAdd (sourcesBest, 100, source); 167 168 } 168 169 psMetadataAdd (sourcesCell->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY | PS_META_REPLACE, "psphot sources", sourcesBest); -
branches/cnb_branch_20090215/ppSub/src/ppSub.c
r21424 r21536 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 09 21:26:05$8 * @version $Revision: 1.11.2.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:49 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ 12 13 #ifdef HAVE_CONFIG_H 14 #include <config.h> 15 #endif 16 17 #include <stdio.h> 18 #include <pslib.h> 19 #include <psmodules.h> 20 #include <psphot.h> 12 21 13 22 #include "ppSub.h" … … 66 75 psTimerStop(); 67 76 68 pm SubtractionVisualClose(); //close plot windows, if -visual is set77 pmVisualClose(); //close plot windows, if -visual is set 69 78 psFree(config); 70 79 pmModelClassCleanup(); -
branches/cnb_branch_20090215/ppSub/src/ppSub.h
r21360 r21536 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 01:37:17$8 * @version $Revision: 1.6.2.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:49 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ … … 14 14 #define PP_SUB_H 15 15 16 #ifdef HAVE_CONFIG_H17 #include <config.h>18 #endif19 20 #include <stdio.h>21 #include <string.h>22 16 #include <pslib.h> 23 17 #include <psmodules.h> 24 #include <psphot.h>25 #include <ppStats.h>26 18 27 19 /// @addtogroup ppSub … … 32 24 /// Setup the arguments parsing 33 25 bool ppSubArgumentsSetup(int argc, char *argv[], ///< Command-line arguments 34 pmConfig *config ///< Configuration26 pmConfig *config ///< Configuration 35 27 ); 36 28 … … 53 45 ); 54 46 55 /// generate (if needed) and set or update the masks for input and reference images56 bool ppSubSetMasks (pmConfig *config,///< Configuration57 const pmFPAview *view ///< View of active readout47 /// Generate (if needed) and set or update the masks for input and reference images 48 bool ppSubSetMasks(pmConfig *config, ///< Configuration 49 const pmFPAview *view ///< View of active readout 58 50 ); 59 51 60 /// Generate the PSF-matching kernel and convolve the images as needed. Most of this function 61 /// involves looking up the parameters in the recipe and supplying them to the function 62 /// pmSubtractionMatch() 63 bool ppSubMatchPSFs (pmConfig *config, ///< Configuration 64 const pmFPAview *view ///< View of active readout 52 /// Generate the PSF-matching kernel and convolve the images as needed. Most of this function involves 53 /// looking up the parameters in the recipe and supplying them to the function pmSubtractionMatch() 54 bool ppSubMatchPSFs(pmConfig *config, ///< Configuration 55 const pmFPAview *view ///< View of active readout 65 56 ); 66 57 67 /// generate the output readout and pass the kernel info to the header68 bool ppSubDefineOutput(pmConfig *config, ///< Configuration69 const pmFPAview *view ///< View of active readout58 /// Generate the output readout and pass the kernel info to the header 59 bool ppSubDefineOutput(pmConfig *config, ///< Configuration 60 const pmFPAview *view ///< View of active readout 70 61 ); 71 62 72 /// Calculate the variance factor for the output image based on the input images 73 bool ppSubVarianceFactors(pmConfig *config, ///< Configuration 74 psMetadata *stats, ///< Statistics, for output 75 const pmFPAview *view ///< View of active readout 76 ); 77 78 /// Photometry stage 1: measure the PSF from the minuend image 79 bool ppSubMakePSF(pmConfig *config, ///< Configuration 80 const pmFPAview *view ///< View of active readout 63 /// Photometry stage 1: measure the PSF from the minuend image 64 bool ppSubMakePSF(pmConfig *config, ///< Configuration 65 const pmFPAview *view ///< View of active readout 81 66 ); 82 67 83 68 /// Perform the actual image subtraction, update output concepts 84 bool ppSubReadoutSubtract(pmConfig *config, ///< Configuration85 const pmFPAview *view ///< View of active readout69 bool ppSubReadoutSubtract(pmConfig *config, ///< Configuration 70 const pmFPAview *view ///< View of active readout 86 71 ); 87 72 88 73 89 74 /// Photometry stage 2: find and measure sources on the subtracted image 90 bool ppSubReadoutPhotometry(pmConfig *config, ///< Configuration91 psMetadata *stats, ///< Statistics, for output92 const pmFPAview *view ///< View of active readout75 bool ppSubReadoutPhotometry(pmConfig *config, ///< Configuration 76 psMetadata *stats, ///< Statistics, for output 77 const pmFPAview *view ///< View of active readout 93 78 ); 94 79 95 80 /// Renormalize, update headers and generate JPEGs 96 bool ppSubReadoutUpdate(pmConfig *config, ///< Configuration 97 const pmFPAview *view ///< View of active readout 81 bool ppSubReadoutUpdate(pmConfig *config, ///< Configuration 82 psMetadata *stats, ///< Statistics for output, or NULL 83 const pmFPAview *view ///< View of active readout 98 84 ); 99 85 … … 107 93 ); 108 94 109 /// Generate and Set the masks if needed110 bool ppSubSetMasks (111 pmConfig *config, ///< Configuration112 const pmFPAview *view ///< view to readout113 );114 115 /// Renormalize readout for peak pixels116 bool ppSubReadoutRenormPixels (117 pmConfig *config, ///< Configuration118 psMetadata *recipe, ///< Recipe119 pmReadout *readout ///< Readout120 );121 122 /// Renormalize readout for photometry analysis123 bool ppSubReadoutRenormPhot (124 pmConfig *config, ///< Configuration125 psMetadata *recipe, ///< Recipe126 pmReadout *readout ///< Readout127 );128 95 129 96 // Copy every instance of a single keyword from one metadata to another -
branches/cnb_branch_20090215/ppSub/src/ppSubArguments.c
r21424 r21536 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.58 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 09 21:26:05$8 * @version $Revision: 1.58.2.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:49 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ 12 13 #ifdef HAVE_CONFIG_H 14 #include <config.h> 15 #endif 16 17 #include <stdio.h> 18 #include <pslib.h> 19 #include <psmodules.h> 20 #include <psphot.h> 12 21 13 22 #include "ppSub.h" … … 191 200 } 192 201 193 if ((argnum = psArgumentGet(argc, argv, "-psphot-visual"))) {194 psArgumentRemove(argnum, &argc, argv);195 psphotSetVisual(true);196 }197 202 198 203 pmConfigFileSetsMD(config->arguments, &argc, argv, "PPSUB.SOURCES", "-sources", NULL); … … 240 245 psMetadataAddS32(arguments, PS_LIST_TAIL, "-opt-order", 0, "Maximum order for optimum kernel search", -1); 241 246 psMetadataAddBool(arguments, PS_LIST_TAIL, "-dual", 0, "Dual convolution", false); 242 psMetadataAddBool(arguments, PS_LIST_TAIL, "-renorm", 0, "Renormalise variance maps?", false);243 psMetadataAddStr(arguments, PS_LIST_TAIL, "-renorm-mean", 0,244 "Statistic for mean in renormalisation", NULL);245 psMetadataAddStr(arguments, PS_LIST_TAIL, "-renorm-stdev", 0,246 "Statistic for stdev in renormalisation", NULL);247 psMetadataAddF32(arguments, PS_LIST_TAIL, "-renorm-width", 0, "Gaussian width for renormalisation", NAN);248 psMetadataAddS32(arguments, PS_LIST_TAIL, "-renorm-num", 0, "Number of samples for renormalisation", 0);249 247 psMetadataAddBool(arguments, PS_LIST_TAIL, "-photometry", 0, "Perform photometry?", false); 250 248 psMetadataAddS32(arguments, PS_LIST_TAIL, "-threads", 0, "Number of threads", 0); … … 352 350 psMetadataLookupBool(NULL, arguments, "-dual")); 353 351 354 if (psMetadataLookupBool(NULL, arguments, "-renorm") ||355 psMetadataLookupBool(NULL, recipe, "RENORM")) {356 psMetadataAddBool(arguments, PS_LIST_TAIL, "RENORM", 0, "Renormalise variance maps?", true);357 }358 VALUE_ARG_RECIPE_INT("-renorm-num", "RENORM.NUM", S32, 0);359 VALUE_ARG_RECIPE_FLOAT("-renorm-width", "RENORM.WIDTH", F32);360 valueArgRecipeStr(arguments, recipe, "-renorm-mean", "RENORM.MEAN", recipe);361 valueArgRecipeStr(arguments, recipe, "-renorm-stdev", "RENORM.STDEV", recipe);362 363 352 // Need to update this because it could have been overwritten by the camera's own recipe 364 353 if (psMetadataLookupBool(NULL, arguments, "-photometry")) { … … 367 356 368 357 if (psMetadataLookupBool(NULL, arguments, "-visual")) { 369 pm SubtractionSetVisual(true);358 pmVisualSetVisual(true); 370 359 } 371 360 -
branches/cnb_branch_20090215/ppSub/src/ppSubBackground.c
r21360 r21536 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 01:37:17$8 * @version $Revision: 1.6.2.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:49 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ 12 12 13 #ifdef HAVE_CONFIG_H 14 #include <config.h> 15 #endif 16 17 #include <stdio.h> 18 #include <pslib.h> 19 #include <psmodules.h> 20 #include <psphot.h> 21 13 22 #include "ppSub.h" 14 23 15 /**16 * Based on ppImageSubtractBackground()17 */18 24 bool ppSubBackground(pmConfig *config, const pmFPAview *view) 19 25 { 20 psAssert(config, " Needconfiguration");21 psAssert(view, " Need view to chip");26 psAssert(config, "Require configuration"); 27 psAssert(view, "Require view"); 22 28 23 bool status; // Status of metadata lookups29 bool mdok; // Status of metadata lookups 24 30 25 psMetadata *ppSubRecipe = psMetadataLookupPtr(NULL, config->recipes, PPSUB_RECIPE); 31 psMetadata *ppSubRecipe = psMetadataLookupPtr(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSub 26 32 psAssert(ppSubRecipe, "Need PPSUB recipe"); 27 28 psMetadata *psphotRecipe = psMetadataLookupPtr(NULL, config->recipes, PSPHOT_RECIPE); 33 psMetadata *psphotRecipe = psMetadataLookupPtr(NULL, config->recipes, PSPHOT_RECIPE); // Recipe for psphot 29 34 psAssert(psphotRecipe, "Need PSPHOT recipe for binning"); 30 35 31 psImageMaskType maskBad = pmConfigMaskGet("BLANK", config); 36 psImageMaskType maskBad = pmConfigMaskGet("BLANK", config); // Bits to mask 32 37 33 // select the output readout34 pmReadout * outRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT");38 pmReadout *outRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT"); // Output image 39 pmReadout *modelRO = pmFPAfileThisReadout(config->files, view, "PSPHOT.BACKMDL"); // Background model 35 40 36 // select the model readout, if it exist already; if not, generate it 37 pmReadout *modelRO = pmFPAfileThisReadout(config->files, view, "PSPHOT.BACKMDL"); 38 39 // if necessary, generate the background model 41 // Generate the background model, if required 40 42 if (!modelRO) { 41 43 // Create the background model … … 44 46 return false; 45 47 } 46 // select the model readout (should now exist)47 modelRO = pmFPAfileThisReadout(config->files, view, "PSPHOT.BACKMDL");48 // select the model readout (should now exist) 49 modelRO = pmFPAfileThisReadout(config->files, view, "PSPHOT.BACKMDL"); 48 50 if (!modelRO) { 49 51 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find background model"); … … 51 53 } 52 54 } 53 psImageBinning *binning = psMetadataLookupPtr(& status, psphotRecipe,55 psImageBinning *binning = psMetadataLookupPtr(&mdok, psphotRecipe, 54 56 "PSPHOT.BACKGROUND.BINNING"); // Binning for model 55 57 psImage *modelImage = modelRO->image; // Background model 56 57 58 psImage *image = outRO->image; // Image of interest 58 59 psImage *mask = outRO->mask; // Mask of interest -
branches/cnb_branch_20090215/ppSub/src/ppSubCamera.c
r21374 r21536 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.33 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 03:20:02$8 * @version $Revision: 1.33.2.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:49 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ 12 13 #ifdef HAVE_CONFIG_H 14 #include <config.h> 15 #endif 16 17 #include <stdio.h> 18 #include <pslib.h> 19 #include <psmodules.h> 20 #include <psphot.h> 12 21 13 22 #include "ppSub.h" … … 257 266 // psPhot input 258 267 if (psMetadataLookupBool(NULL, recipe, "PHOTOMETRY")) { 259 psphotModelClassInit (); // load implementation-specific models 260 261 262 // Internal-ish file for getting the PSF from the matched addition 268 psphotModelClassInit(); // load implementation-specific models 269 270 // Internal-ish file for getting the PSF from the minuend 263 271 pmFPAfile *psf = pmFPAfileDefineOutputFromFile(config, output, "PSPHOT.PSF.LOAD"); 264 272 if (!psf) { … … 272 280 pmFPAfileActivate(config->files, false, "PSPHOT.PSF.LOAD"); 273 281 274 pmFPAfile *psphotResid = pmFPAfileDefineOutputForFormat (config, NULL, "PSPHOT.RESID", output->cameraName, output->formatName);275 if (!psphotResid) {276 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.RESID");277 return false;278 }279 // make this optional: psphotResid->save = true;280 }281 282 // Always do this, since we're using psphot for the background model.283 // XXX Not certain that I need to generate a separate pmFPAfile for PSPHOT.INPUT284 if (0) {285 282 pmFPAfile *psphot = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.INPUT"); 286 283 if (!psphot) { … … 297 294 return false; 298 295 } 299 300 296 } 301 297 -
branches/cnb_branch_20090215/ppSub/src/ppSubDefineOutput.c
r21360 r21536 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 01:37:17$8 * @version $Revision: 1.2.4.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:49 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ 12 12 13 #ifdef HAVE_CONFIG_H 14 #include <config.h> 15 #endif 16 17 #include <stdio.h> 18 #include <pslib.h> 19 #include <psmodules.h> 20 13 21 #include "ppSub.h" 14 22 15 bool ppSubDefineOutput (pmConfig *config, const pmFPAview *view) { 23 bool ppSubDefineOutput(pmConfig *config, const pmFPAview *view) 24 { 25 psAssert(config, "Require configuration"); 26 psAssert(view, "Require view"); 16 27 17 bool mdok; 18 19 // generate an output readout 28 // generate an output readout 20 29 pmCell *outCell = pmFPAfileThisCell(config->files, view, "PPSUB.OUTPUT"); // Output cell 21 30 pmReadout *outRO = pmReadoutAlloc(outCell); // Output readout: subtraction … … 30 39 pmReadout *refConv = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); // Reference readout 31 40 32 // Add kernel descrption to header. We don't know which readout gets the kernels because 33 // it depends on which is larger (the choice is set in ppSubMatchPSFs) 34 bool inputHasKernel = true; 35 pmSubtractionKernels *kernels = psMetadataLookupPtr(&mdok, inConv->analysis, PM_SUBTRACTION_ANALYSIS_KERNEL); // Subtraction kernel 41 // Add kernel descrption to header. 42 // We don't know which readout has the kernels because it depends on which PSF is larger 43 bool mdok; // Status of MD lookup 44 psMetadata *analysis = inConv->analysis; // Analysis metadata with kernel information 45 pmSubtractionKernels *kernels = psMetadataLookupPtr(&mdok, analysis, 46 PM_SUBTRACTION_ANALYSIS_KERNEL); // Subtraction kernel 36 47 if (!kernels) { 37 kernels = psMetadataLookupPtr(&mdok, refConv->analysis, PM_SUBTRACTION_ANALYSIS_KERNEL);38 inputHasKernel = false;48 analysis = refConv->analysis; 49 kernels = psMetadataLookupPtr(&mdok, analysis, PM_SUBTRACTION_ANALYSIS_KERNEL); 39 50 } 40 51 if (!kernels) { … … 45 56 return false; 46 57 } 47 psMetadataAddStr(outHDU->header, PS_LIST_TAIL, "PPSUB.KERNEL", 0, "Subtraction kernel", kernels->description); 58 psMetadataAddStr(outHDU->header, PS_LIST_TAIL, "PPSUB.KERNEL", 0, "Subtraction kernel", 59 kernels->description); 48 60 49 if (inputHasKernel) { 50 outRO->analysis = psMetadataCopy(outRO->analysis, inConv->analysis); 51 } else { 52 outRO->analysis = psMetadataCopy(outRO->analysis, refConv->analysis); 53 } 61 outRO->analysis = psMetadataCopy(outRO->analysis, analysis); 54 62 55 63 #ifdef TESTING 56 psImage *kernelImage = NULL;57 58 if (inputHasKernel) {59 kernelImage = psMetadataLookupPtr(&mdok, inConv->analysis, "SUBTRACTION.KERNEL.IMAGE"); // Image of the kernels 60 } else {61 kernelImage = psMetadataLookupPtr(&mdok, refConv->analysis, "SUBTRACTION.KERNEL.IMAGE");64 { 65 psImage *kernelImage = psMetadataLookupPtr(&mdok, analysis, 66 "SUBTRACTION.KERNEL.IMAGE"); // Image of kernel 67 psFits *fits = psFitsOpen("kernel.fits", "w"); 68 psFitsWriteImage(fits, NULL, kernelImage, 0, NULL); 69 psFitsClose(fits); 62 70 } 63 64 psFits *fits = psFitsOpen("kernel.fits", "w");65 psFitsWriteImage(fits, NULL, kernelImage, 0, NULL);66 psFitsClose(fits);67 71 #endif 68 72 -
branches/cnb_branch_20090215/ppSub/src/ppSubLoop.c
r21360 r21536 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 01:37:17$8 * @version $Revision: 1.23.2.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:49 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ 12 13 #ifdef HAVE_CONFIG_H 14 #include <config.h> 15 #endif 16 17 #include <pslib.h> 18 #include <psmodules.h> 19 #include <ppStats.h> 12 20 13 21 #include "ppSub.h" … … 138 146 return false; 139 147 } 140 psImageMaskType maskValue = pmConfigMaskGet("MASK.VALUE", config);148 psImageMaskType maskValue = pmConfigMaskGet("MASK.VALUE", config); 141 149 ppStatsFPA(stats, output->fpa, view, maskValue, config); 142 150 } -
branches/cnb_branch_20090215/ppSub/src/ppSubMakePSF.c
r21360 r21536 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 01:37:17$8 * @version $Revision: 1.2.4.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:49 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ 12 12 13 #ifdef HAVE_CONFIG_H 14 #include <config.h> 15 #endif 16 17 #include <stdio.h> 18 #include <pslib.h> 19 #include <psmodules.h> 20 #include <psphot.h> 21 13 22 #include "ppSub.h" 14 23 15 /** 16 * Photometry stage 1: measure the PSF from the minuend image 17 */18 bool ppSubMakePSF (pmConfig *config, const pmFPAview *view) { 24 bool ppSubMakePSF(pmConfig *config, const pmFPAview *view) 25 { 26 psAssert(config, "Require configuration"); 27 psAssert(view, "Require view"); 19 28 20 bool mdok = false;21 22 // Photometry is to be performed in two stages:23 // 1. Measure the PSF using the PSF-matched images24 // 2. Find and measure sources on the subtracted image25 29 psTimerStart("PPSUB_PHOT"); 26 30 27 // Look up recipe values28 31 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSub 29 32 psAssert(recipe, "We checked this earlier, so it should be here."); 30 33 31 psMetadata *psphotRecipe = psMetadataLookupMetadata(NULL, config->recipes, PSPHOT_RECIPE); // Recipe for psphot 34 if (!psMetadataLookupBool(NULL, recipe, "PHOTOMETRY")) { 35 return true; 36 } 37 38 psMetadata *psphotRecipe = psMetadataLookupMetadata(NULL, config->recipes, PSPHOT_RECIPE);// psphot recipe 32 39 psAssert(recipe, "We checked this earlier, so it should be here."); 33 34 if (!psMetadataLookupBool(NULL, recipe, "PHOTOMETRY")) return true;35 40 36 41 bool reverse = psMetadataLookupBool(NULL, config->arguments, "REVERSE"); // Reverse sense of subtraction? 37 42 38 pmReadout *minuend = NULL; 39 pmFPAfile *minuendFile = NULL; 43 bool mdok = false; // Status of MD lookup 44 pmReadout *minuend = NULL; // Image that will be positive following subtraction 45 pmFPAfile *minuendFile = NULL; // File for minuend image 40 46 if (reverse) { 41 minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV");42 minuendFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.REF.CONV");47 minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); 48 minuendFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.REF.CONV"); 43 49 } else { 44 minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV");45 minuendFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.INPUT.CONV");50 minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV"); 51 minuendFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.INPUT.CONV"); 46 52 } 47 53 48 // supply the minuend pmFPAfile to psphot as PSPHOT.INPUT: 49 psMetadataAddPtr (config->files, PS_LIST_TAIL, "PSPHOT.INPUT", PS_DATA_UNKNOWN | PS_META_REPLACE, "psphot input : view on another pmFPAfile", minuendFile); 54 #if 1 55 pmReadout *template = minuend; 56 pmFPAfile *photFile = psMetadataLookupPtr(&mdok, config->files, "PSPHOT.INPUT"); // Photometry file 57 pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout to photometer 58 if (!photRO) { 59 pmCell *cell = pmFPAviewThisCell(view, photFile->fpa); // Cell to photometer 60 photRO = pmReadoutAlloc(cell); // Output readout: subtraction 61 } 62 photRO->image = psImageCopy(photRO->image, template->image, PS_TYPE_F32); 63 if (template->variance) { 64 photRO->variance = psImageCopy(photRO->variance, template->variance, PS_TYPE_F32); 65 } else { 66 psFree(photRO->variance); 67 photRO->variance = NULL; 68 } 69 if (template->mask) { 70 photRO->mask = psImageCopy(photRO->mask, template->mask, PS_TYPE_IMAGE_MASK); 71 } else { 72 psFree(photRO->mask); 73 photRO->mask = NULL; 74 } 75 #else 76 // Supply the minuend pmFPAfile to psphot as PSPHOT.INPUT: 77 psMetadataAddPtr(config->files, PS_LIST_TAIL, "PSPHOT.INPUT", PS_DATA_UNKNOWN | PS_META_REPLACE, 78 "psphot input: view on another pmFPAfile", minuendFile); 79 #endif 50 80 51 // old-style variance renormalization 52 if (!ppSubReadoutRenormPhot (config, recipe, minuend)) { 53 psError(PS_ERR_UNKNOWN, false, "failure in renormalization"); 54 return false; 55 } 56 57 // extract the loaded sources from the associated readout 81 // Extract the loaded sources from the associated readout, and generate PSF 82 // Here, we assume the image is background-subtracted 58 83 pmReadout *sourcesRO = pmFPAfileThisReadout(config->files, view, "PPSUB.SOURCES"); 59 84 psArray *sources = psMetadataLookupPtr(&mdok, sourcesRO->analysis, "PSPHOT.SOURCES"); 60 61 // generate PSF from the supplied sources (assumes image is background-subtracted)62 85 if (!psphotReadoutFindPSF(config, view, sources)) { 63 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry on subtracted image.");64 return false;86 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry on subtracted image."); 87 return false; 65 88 } 66 89 … … 70 93 psMetadataItemSupplement(hdu->header, psphotRecipe, "FWHM_MAJ"); 71 94 psMetadataItemSupplement(hdu->header, psphotRecipe, "FWHM_MIN"); 95 96 // Get rid of the generated header; it will be regenerated by the real photometry run 97 psMetadataRemoveKey(photRO->analysis, "PSPHOT.HEADER"); 72 98 73 99 return true; … … 87 113 88 114 // Blow away the sources psphot found --- they're irrelevant for the subtraction 89 // XXX is this still needed? These are now probably not being set 115 // XXX is this still needed? These are now probably not being set 90 116 // pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout with sources 91 117 // psMetadataRemoveKey(photRO->analysis, "PSPHOT.SOURCES"); -
branches/cnb_branch_20090215/ppSub/src/ppSubMatchPSFs.c
r21360 r21536 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 01:37:17$8 * @version $Revision: 1.2.4.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:49 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ 12 12 13 #ifdef HAVE_CONFIG_H 14 #include <config.h> 15 #endif 16 17 #include <stdio.h> 18 #include <pslib.h> 19 #include <psmodules.h> 20 #include <psphot.h> 21 13 22 #include "ppSub.h" 14 23 15 /** Generate the PSF-matching kernel and convolve the images as needed. Most of this function 16 * involves looking up the parameters in the recipe and supplying them to the function 17 * pmSubtractionMatch(); 18 */ 19 20 bool ppSubMatchPSFs (pmConfig *config, const pmFPAview *view) { 21 22 bool mdok; // Status of MD lookup 24 bool ppSubMatchPSFs(pmConfig *config, const pmFPAview *view) 25 { 26 psAssert(config, "Require configuration"); 27 psAssert(view, "Require view"); 23 28 24 29 // Look up recipe values … … 26 31 psAssert(recipe, "We checked this earlier, so it should be here."); 27 32 28 // input images33 // Input images 29 34 pmReadout *inRO = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT"); // Input readout 30 35 pmReadout *refRO = pmFPAfileThisReadout(config->files, view, "PPSUB.REF"); // Reference readout 31 36 32 // get or generate output image holders33 pmReadout *inConv = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV"); // Input convolved readout37 // Output image holders 38 pmReadout *inConv = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV"); // Input convolved 34 39 if (!inConv) { 35 pmCell *cell = pmFPAfileThisCell(config->files, view, "PPSUB.INPUT.CONV"); // Input convolved readout36 inConv = pmReadoutAlloc(cell); // Convolved version of input 40 pmCell *cell = pmFPAfileThisCell(config->files, view, "PPSUB.INPUT.CONV"); // Cell for convolved input 41 inConv = pmReadoutAlloc(cell); 37 42 } 38 pmReadout *refConv = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); // Reference convolved readout43 pmReadout *refConv = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); // Reference convolved 39 44 if (!refConv) { 40 pmCell *cell = pmFPAfileThisCell(config->files, view, "PPSUB.REF.CONV"); // Input convolved readout 41 refConv = pmReadoutAlloc(cell); // Convolved version of input 45 pmCell *cell = pmFPAfileThisCell(config->files, view, "PPSUB.REF.CONV"); // Cell for convolved ref. 46 refConv = pmReadoutAlloc(cell); 42 47 } 43 48 44 // options which control the generation of optimal parameters 45 bool optimum = psMetadataLookupBool(&mdok, recipe, "OPTIMUM"); // Derive optimum parameters? 46 float optMin = psMetadataLookupF32(&mdok, recipe, "OPTIMUM.MIN"); // Minimum width for search 47 float optMax = psMetadataLookupF32(&mdok, recipe, "OPTIMUM.MAX"); // Maximum width for search 48 float optStep = psMetadataLookupF32(&mdok, recipe, "OPTIMUM.STEP"); // Step for search 49 bool mdok; // Status of MD lookup 49 50 50 // Vector with FWHMs for optimum search 51 psVector *optWidths = NULL; 52 if (optimum) { 53 optWidths = psVectorCreate(optWidths, optMin, optMax, optStep, PS_TYPE_F32); 54 } 55 56 // Sources in image : these must be loaded from previous analysis stages 57 pmReadout *sourcesRO = pmFPAfileThisReadout(config->files, view, "PPSUB.SOURCES"); // Readout with sources 58 psArray *sources = NULL; 51 // Sources in image, used for stamps: these must be loaded from previous analysis stages 52 pmReadout *sourcesRO = pmFPAfileThisReadout(config->files, view, "PPSUB.SOURCES"); // Readout with sources 53 psArray *sources = NULL; // Sources in image; used for stamps 59 54 if (sourcesRO) { 60 55 sources = psMetadataLookupPtr(&mdok, sourcesRO->analysis, "PSPHOT.SOURCES"); … … 66 61 float spacing = psMetadataLookupF32(NULL, recipe, "STAMP.SPACING"); // Typical stamp spacing 67 62 float threshold = psMetadataLookupF32(NULL, recipe, "STAMP.THRESHOLD"); // Threshold for stmps 68 69 63 const char *stampsName = psMetadataLookupStr(&mdok, config->arguments, "STAMPS"); // Filename for stamps 70 64 71 65 const char *typeStr = psMetadataLookupStr(NULL, recipe, "KERNEL.TYPE"); // Kernel type 72 66 psAssert(typeStr, "We put it here in ppSubArguments.c"); 73 74 67 pmSubtractionKernelsType type = pmSubtractionKernelsTypeFromString(typeStr); // Type of kernel 75 68 if (type == PM_SUBTRACTION_KERNEL_NONE) { … … 87 80 int binning = psMetadataLookupS32(NULL, recipe, "SPAM.BINNING"); // Binning for SPAM kernel 88 81 float penalty = psMetadataLookupF32(NULL, recipe, "PENALTY"); // Penalty for wideness 89 90 int optOrder = psMetadataLookupS32(&mdok, recipe, "OPTIMUM.ORDER"); // Order for search91 float optThresh = psMetadataLookupF32(&mdok, recipe, "OPTIMUM.TOL"); // Tolerance for search92 93 82 int iter = psMetadataLookupS32(NULL, recipe, "ITER"); // Rejection iterations 94 83 float rej = psMetadataLookupF32(NULL, recipe, "REJ"); // Rejection threshold … … 98 87 float poorFrac = psMetadataLookupF32(&mdok, recipe, "POOR.FRACTION"); // Fraction for "poor" 99 88 100 // XXX EAM : do we need to / want to define different values for BAD and POOR subtraction vs BAD and POOR warp? 101 psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Bits to mask going in to pmSubtractionMatch 89 // Options which control the generation of optimal parameters 90 bool optimum = psMetadataLookupBool(&mdok, recipe, "OPTIMUM"); // Derive optimum parameters? 91 float optMin = psMetadataLookupF32(&mdok, recipe, "OPTIMUM.MIN"); // Minimum width for search 92 float optMax = psMetadataLookupF32(&mdok, recipe, "OPTIMUM.MAX"); // Maximum width for search 93 float optStep = psMetadataLookupF32(&mdok, recipe, "OPTIMUM.STEP"); // Step for search 94 psVector *optWidths = NULL; // Vector with FWHMs for optimum search 95 if (optimum) { 96 optWidths = psVectorCreate(optWidths, optMin, optMax, optStep, PS_TYPE_F32); 97 } 98 int optOrder = psMetadataLookupS32(&mdok, recipe, "OPTIMUM.ORDER"); // Order for search 99 float optThresh = psMetadataLookupF32(&mdok, recipe, "OPTIMUM.TOL"); // Tolerance for search 100 101 // XXX Do we need/want to define different values for BAD and POOR subtraction vs BAD and POOR warp? 102 psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Bits to mask in inputs 102 103 psImageMaskType maskPoor = pmConfigMaskGet("POOR.WARP", config); // Bits to mask for poor pixels 103 104 psImageMaskType maskBad = pmConfigMaskGet("BLANK", config); // Bits to mask for bad pixels … … 124 125 pmSubtractionThreadsFinalize(inRO, refRO); 125 126 127 psImageCovarianceTransfer(inConv->variance, inConv->covariance); 128 psImageCovarianceTransfer(refConv->variance, refConv->covariance); 129 126 130 // XXX drop the pixels associated with inRO and refRO (now that we have inConv and refConf) 127 131 -
branches/cnb_branch_20090215/ppSub/src/ppSubReadout.c
r21424 r21536 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.112 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 09 21:26:05$8 * @version $Revision: 1.112.2.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:49 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ 12 13 #ifdef HAVE_CONFIG_H 14 #include <config.h> 15 #endif 16 17 #include <stdio.h> 18 #include <pslib.h> 19 #include <psmodules.h> 12 20 13 21 #include "ppSub.h" … … 17 25 psTimerStart("PPSUB_MATCH"); 18 26 19 if (!ppSubSetMasks (config, view)) {20 psError(PS_ERR_UNKNOWN, false, "Unable to s ubtract background.");27 if (!ppSubSetMasks(config, view)) { 28 psError(PS_ERR_UNKNOWN, false, "Unable to set masks."); 21 29 return false; 22 30 } 23 31 24 if (!ppSubMatchPSFs (config, view)) {25 psError(PS_ERR_UNKNOWN, false, "Unable to subtract background.");32 if (!ppSubMatchPSFs(config, view)) { 33 psError(PS_ERR_UNKNOWN, false, "Unable to match PSFs."); 26 34 return false; 27 35 } 28 36 29 if (!ppSubDefineOutput (config, view)) { 30 psError(PS_ERR_UNKNOWN, false, "Unable to subtract background."); 31 return false; 32 } 33 34 if (!ppSubVarianceFactors (config, stats, view)) { 35 psError(PS_ERR_UNKNOWN, false, "Unable to subtract background."); 37 if (!ppSubDefineOutput(config, view)) { 38 psError(PS_ERR_UNKNOWN, false, "Unable to define output."); 36 39 return false; 37 40 } 38 41 39 42 if (!ppSubMakePSF(config, view)) { 40 psError(PS_ERR_UNKNOWN, false, "Unable to subtract background.");43 psError(PS_ERR_UNKNOWN, false, "Unable to generate PSF."); 41 44 return false; 42 45 } 43 46 44 if (!ppSubReadoutSubtract (config, view)) {45 psError(PS_ERR_UNKNOWN, false, "Unable to subtract background.");47 if (!ppSubReadoutSubtract(config, view)) { 48 psError(PS_ERR_UNKNOWN, false, "Unable to subtract images."); 46 49 return false; 47 50 } … … 53 56 } 54 57 55 if (!ppSubReadoutPhotometry (config, stats, view)) {56 psError(PS_ERR_UNKNOWN, false, "Unable to subtract background.");58 if (!ppSubReadoutPhotometry(config, stats, view)) { 59 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry."); 57 60 return false; 58 61 } 59 62 60 if (!ppSubReadoutUpdate (config, view)) {61 psError(PS_ERR_UNKNOWN, false, "Unable to subtract background.");63 if (!ppSubReadoutUpdate(config, stats, view)) { 64 psError(PS_ERR_UNKNOWN, false, "Unable to update."); 62 65 return false; 63 66 } -
branches/cnb_branch_20090215/ppSub/src/ppSubReadoutPhotometry.c
r21374 r21536 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 03:20:02$8 * @version $Revision: 1.3.4.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:49 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ 12 12 13 #ifdef HAVE_CONFIG_H 14 #include <config.h> 15 #endif 16 17 #include <stdio.h> 18 #include <pslib.h> 19 #include <psmodules.h> 20 #include <psphot.h> 21 13 22 #include "ppSub.h" 14 23 15 /** 16 * Photometry stage 2: find and measure sources on the subtracted image 17 */ 18 bool ppSubReadoutPhotometry (pmConfig *config, psMetadata *stats, const pmFPAview *view) { 19 20 bool mdok = false; 24 bool ppSubReadoutPhotometry (pmConfig *config, psMetadata *stats, const pmFPAview *view) 25 { 26 psAssert(config, "Require configuration"); 27 psAssert(view, "Require view"); 21 28 22 29 // Look up recipe values … … 32 39 // The PSF (measured in ppSubMakePSF) is stored on the chip->analysis of PSPHOT.INPUT 33 40 // In order to use an incoming PSF, it must be stored on the chip->analysis of PSPHOT.PSF.LOAD 34 pmChip *psfInputChip = pmFPAfileThisChip(config->files, view, "PSPHOT.INPUT"); 41 pmChip *psfInputChip = pmFPAfileThisChip(config->files, view, "PSPHOT.INPUT"); // Chip with PSF 35 42 psAssert (psfInputChip, "should have been generated for ppSubMakePSF"); 36 37 pmChip *psfLoadChip = pmFPAfileThisChip(config->files, view, "PSPHOT.PSF.LOAD"); 43 pmChip *psfLoadChip = pmFPAfileThisChip(config->files, view, "PSPHOT.PSF.LOAD"); // Chip to have PSF 38 44 psAssert (psfLoadChip, "PSPHOT.PSF.LOAD should have been defined in ppSubCamera"); 39 40 pmPSF *psf = psMetadataLookupPtr(NULL, psfInputChip->analysis, "PSPHOT.PSF"); 45 pmPSF *psf = psMetadataLookupPtr(NULL, psfInputChip->analysis, "PSPHOT.PSF"); // PSF for photometry 41 46 if (!psf) { 42 47 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find PSF from psphot"); 43 48 return false; 44 49 } 45 psMetadataAddPtr(psfLoadChip->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_DATA_UNKNOWN | PS_META_REPLACE, "PSF from matched addition", psf); 50 psMetadataAddPtr(psfLoadChip->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_DATA_UNKNOWN | PS_META_REPLACE, 51 "PSF from ppSubMakePSF", psf); 52 53 bool mdok = false; 46 54 47 55 // psphotReadoutMinimal performs the photometry analysis on PSPHOT.INPUT; we need to move 48 56 // around the pointers so PSPHOT.INPUT corresponds to the output image; previously, it was 49 57 // equivalent to the minuend image. 50 pmFPAfile *outputFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.OUTPUT"); 58 pmFPAfile *outputFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.OUTPUT"); // Output file 51 59 pmReadout *outRO = pmFPAviewThisReadout(view, outputFile->fpa); // Readout with the sources 52 60 53 61 // XXX possibly rename this to PPSUB.RESID? 54 pmFPAfile *photFile = psMetadataLookupPtr(&mdok, config->files, "PSPHOT. RESID");55 pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout with the sources62 pmFPAfile *photFile = psMetadataLookupPtr(&mdok, config->files, "PSPHOT.INPUT"); // Photometry file 63 pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout to photometer 56 64 if (!photRO) { 57 pmCell *cell = pmFPA fileThisCell(config->files, view, "PSPHOT.RESID"); // Output cell65 pmCell *cell = pmFPAviewThisCell(view, photFile->fpa); // Cell to photometer 58 66 photRO = pmReadoutAlloc(cell); // Output readout: subtraction 59 67 } … … 62 70 photRO->variance = psImageCopy(photRO->variance, outRO->variance, PS_TYPE_F32); 63 71 } else { 64 psFree (photRO->variance);72 psFree(photRO->variance); 65 73 photRO->variance = NULL; 66 74 } … … 68 76 photRO->mask = psImageCopy(photRO->mask, outRO->mask, PS_TYPE_IMAGE_MASK); 69 77 } else { 70 psFree (photRO->mask);78 psFree(photRO->mask); 71 79 photRO->mask = NULL; 72 80 } 73 81 74 // pmFPAfile *photFile = outputFile; 75 psMetadataAddPtr (config->files, PS_LIST_TAIL, "PSPHOT.INPUT", PS_DATA_UNKNOWN | PS_META_REPLACE, "psphot input : view on another pmFPAfile", photFile); 76 77 // old-style variance renormalization 78 if (!ppSubReadoutRenormPhot (config, recipe, photRO)) { 79 psError(PS_ERR_UNKNOWN, false, "failure in renormalization"); 80 return false; 81 } 82 #if 0 83 psMetadataAddPtr(config->files, PS_LIST_TAIL, "PSPHOT.INPUT", PS_DATA_UNKNOWN | PS_META_REPLACE, 84 "psphot input: view on another pmFPAfile", photFile); 85 #endif 82 86 83 87 if (!psphotReadoutMinimal(config, view)) { … … 86 90 psErrorClear(); 87 91 } 92 #if 1 93 photRO->data_exists = true; 94 photRO->parent->data_exists = true; 95 photRO->parent->parent->data_exists = true; 96 #endif 88 97 89 98 if (stats) { … … 101 110 } 102 111 103 // XXX not sure that this is still needed (only if psphotReadoutMinimal measures the background)104 // if (!pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL") ||105 // !pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV") ||106 // !pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND")) {107 // psError(PS_ERR_UNKNOWN, false, "Unable to drop PSPHOT internal files.");108 // return false;109 // }110 112 111 // pmFPAfileActivate(config->files, false, "PSPHOT.INPUT"); 112 // pmFPAfileActivate(config->files, false, "PSPHOT.LOAD.PSF"); 113 113 114 114 115 -
branches/cnb_branch_20090215/ppSub/src/ppSubReadoutSubtract.c
r21424 r21536 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 09 21:26:05$8 * @version $Revision: 1.4.4.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:49 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ 12 12 13 #ifdef HAVE_CONFIG_H 14 #include <config.h> 15 #endif 16 17 #include <stdio.h> 18 #include <pslib.h> 19 #include <psmodules.h> 20 13 21 #include "ppSub.h" 22 14 23 #define WCS_TOLERANCE 0.001 // Tolerance for WCS 15 24 16 bool ppSubReadoutSubtract (pmConfig *config, const pmFPAview *view) { 25 bool ppSubReadoutSubtract(pmConfig *config, const pmFPAview *view) 26 { 27 psAssert(config, "Require configuration"); 28 psAssert(view, "Require view"); 17 29 18 bool mdok = false;19 30 20 31 // Look up recipe values 21 psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, PPSUB_RECIPE); // Recipe for ppSim 32 bool mdok = false; // Status of MD lookup 33 psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, PPSUB_RECIPE); // Recipe for ppSub 22 34 psAssert(recipe, "We checked this earlier, so it should be here."); 23 35 … … 25 37 26 38 // Subtraction is: minuend - subtrahend 27 pmReadout *minuend = NULL; 28 pmReadout *subtrahend = NULL; 39 pmReadout *minuend = NULL; // Positive image 40 pmReadout *subtrahend = NULL; // Negative image 29 41 if (reverse) { 30 42 minuend = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); … … 59 71 outRO->mask = (psImage*)psBinaryOp(outRO->mask, minuend->mask, "|", subtrahend->mask); 60 72 73 psArray *covars = psArrayAlloc(2); // Covariance pseudo-matrices 74 covars->data[0] = psMemIncrRefCounter(minuend->covariance); 75 covars->data[1] = psMemIncrRefCounter(subtrahend->covariance); 76 outRO->covariance = psImageCovarianceSum(covars); 77 psFree(covars); 78 61 79 outRO->data_exists = true; 62 80 outRO->parent->data_exists = true; … … 65 83 pmSubtractionVisualShowSubtraction(minuend->image, subtrahend->image, outRO->image); 66 84 67 // copy concepts from the input to the output (XXX should this always use minuend?) 68 pmFPAfile *inFile = psMetadataLookupPtr (&mdok, config->files, "PPSUB.INPUT"); 69 pmFPA *inFPA = inFile->fpa; 70 71 pmFPAfile *outFile = psMetadataLookupPtr (&mdok, config->files, "PPSUB.OUTPUT"); 72 pmFPA *outFPA = outFile->fpa; 73 85 // Copy concepts from the input to the output 86 pmFPAfile *inFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.INPUT"); // Input file 87 pmFPA *inFPA = inFile->fpa; // Input FPA 88 pmFPAfile *outFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.OUTPUT"); // Output file 89 pmFPA *outFPA = outFile->fpa; // Output FPA 74 90 if (!pmFPACopyConcepts(outFPA, inFPA)) { 75 91 psError(PS_ERR_UNKNOWN, false, "Unable to copy concepts from input to output."); … … 78 94 } 79 95 80 // get the HDUs and output Chip to copy the astrometry81 pmHDU *inHDU = inFPA->hdu; // input HDU82 pmHDU * outHDU = outFPA->hdu;83 pm Chip *outChip = pmFPAfileThisChip(config->files, view, "PPSUB.OUTPUT");84 96 // Copy astrometry over 97 // It should find its way into the output images and photometry 98 pmHDU *inHDU = inFPA->hdu; // Input HDU 99 pmHDU *outHDU = outFPA->hdu; // Output HDU 100 pmChip *outChip = pmFPAfileThisChip(config->files, view, "PPSUB.OUTPUT"); // Output chip 85 101 if (!outHDU || !inHDU) { 86 102 psError(PS_ERR_UNKNOWN, false, "Unable to find HDU at FPA level to copy astrometry."); 87 103 return false; 88 104 } 89 90 // Copy astrometry over91 // It should get into the output images and photometry92 105 if (!pmAstromReadWCS(outFPA, outChip, inHDU->header, 1.0)) { 93 106 psError(PS_ERR_UNKNOWN, false, "Unable to read WCS astrometry from input FPA."); 94 107 return false; 95 108 } 96 97 109 if (!pmAstromWriteWCS(outHDU->header, outFPA, outChip, WCS_TOLERANCE)) { 98 110 psError(PS_ERR_UNKNOWN, false, "Unable to write WCS astrometry to output FPA."); … … 102 114 return true; 103 115 } 104 105 // XXX this test code was in place to check for and squash unexpected NANs106 107 #if 0108 pmReadoutMaskApply(outRO, maskBad);109 110 for (int y = 0; y < outRO->image->numRows; y++) {111 for (int x = 0; x < outRO->image->numCols; x++) {112 if (isnan(outRO->image->data.F32[y][x]) && !(outRO->mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) {113 printf("Unmasked NAN at %d %d --> %d\n", x, y, outRO->mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x]);114 }115 }116 }117 #endif118 -
branches/cnb_branch_20090215/ppSub/src/ppSubReadoutUpdate.c
r21396 r21536 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 07 00:15:00 $8 * @version $Revision: 1.3.4.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:50 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ 12 12 13 #ifdef HAVE_CONFIG_H 14 #include <config.h> 15 #endif 16 17 #include <stdio.h> 18 #include <pslib.h> 19 #include <psmodules.h> 20 13 21 #include "ppSub.h" 14 22 15 /** 16 * Renormalize, update headers and generate JPEGs 17 */18 bool ppSubReadoutUpdate (pmConfig *config, const pmFPAview *view) { 23 bool ppSubReadoutUpdate(pmConfig *config, psMetadata *stats, const pmFPAview *view) 24 { 25 psAssert(config, "Require configuration"); 26 psAssert(view, "Require view"); 19 27 20 bool mdok = false; 28 bool mdok = false; // Status of MD lookup 21 29 22 30 // Look up recipe values … … 24 32 psAssert(recipe, "We checked this earlier, so it should be here."); 25 33 26 // select the output readout 27 pmReadout *outRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT"); 28 29 // Renormalising for pixels, because that's what magic desires 30 if (!ppSubReadoutRenormPixels (config, recipe, outRO)) { 31 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "failure in renormalization"); 32 return false; 33 } 34 35 // select the output FPA and HDU to get the output header 36 pmFPAfile *outFile = psMetadataLookupPtr (&mdok, config->files, "PPSUB.OUTPUT"); 37 pmFPA *outFPA = outFile->fpa; 38 pmHDU *outHDU = outFPA->hdu; 34 pmFPAfile *outFile = psMetadataLookupPtr(&mdok, config->files, "PPSUB.OUTPUT"); // Output file 35 pmReadout *outRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT"); // Output image 36 pmFPA *outFPA = outFile->fpa; // Output FPA 37 pmHDU *outHDU = outFPA->hdu; // Output HDU 39 38 40 39 // Add additional data to the header … … 46 45 "Subtraction input", inFile->filename); 47 46 47 // Statistics on the matching 48 if (stats) { 49 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MODE); 50 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_STAMPS); 51 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_DEV_MEAN); 52 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_DEV_RMS); 53 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_NORM); 54 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_BGDIFF); 55 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MX); 56 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MY); 57 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MXX); 58 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MXY); 59 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MYY); 60 61 psMetadataAddF32(stats, PS_LIST_TAIL, "TIME_MATCH", 0, "Time to match PSFs", 62 psTimerClear("PPSUB_MATCH")); 63 } 64 48 65 // Generate binned JPEGs 49 66 { … … 54 71 55 72 // Target cells 56 pmCell *cell1 = pmFPAfileThisCell(config->files, view, "PPSUB.OUTPUT.JPEG1"); 57 pmCell *cell2 = pmFPAfileThisCell(config->files, view, "PPSUB.OUTPUT.JPEG2"); 73 pmCell *cell1 = pmFPAfileThisCell(config->files, view, "PPSUB.OUTPUT.JPEG1"); // Rebinned cell once 74 pmCell *cell2 = pmFPAfileThisCell(config->files, view, "PPSUB.OUTPUT.JPEG2"); // Rebinned cell twice 58 75 59 pmReadout *ro1 = pmReadoutAlloc(cell1); 60 pmReadout *ro2 = pmReadoutAlloc(cell2); // Binned readouts 76 pmReadout *ro1 = pmReadoutAlloc(cell1), *ro2 = pmReadoutAlloc(cell2); // Binned readouts 61 77 if (!pmReadoutRebin(ro1, outRO, maskBad, bin1, bin1)) { 62 78 psError(PS_ERR_UNKNOWN, false, "Unable to bin output (1st binning)"); -
branches/cnb_branch_20090215/ppSub/src/ppSubSetMasks.c
r21360 r21536 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 01:37:17$8 * @version $Revision: 1.2.4.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:50 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ 12 12 13 #ifdef HAVE_CONFIG_H 14 #include <config.h> 15 #endif 16 17 #include <stdio.h> 18 #include <pslib.h> 19 #include <psmodules.h> 20 #include <psphot.h> 21 13 22 #include "ppSub.h" 14 23 15 /** this function generates (if needed) and sets or updates the masks for both the input and 16 * reference images. this function also has the code for interpolation over bad pixels, but it 17 * is currently if-def-ed out18 */24 bool ppSubSetMasks(pmConfig *config, const pmFPAview *view) 25 { 26 psAssert(config, "Require configuration"); 27 psAssert(view, "Require view"); 19 28 20 bool ppSubSetMasks (pmConfig *config, const pmFPAview *view) { 21 22 psImageMaskType maskValue; 23 psImageMaskType markValue; 24 bool mdok = false; 25 29 psImageMaskType maskValue, markValue; // Mask values 26 30 if (!pmConfigMaskSetBits(&maskValue, &markValue, config)) { 27 31 psError(PS_ERR_UNKNOWN, false, "Unable to determine mask value."); … … 29 33 } 30 34 31 // set the mask bits needed by psphot (in psphot recipe)35 // Set the mask bits needed by psphot (in psphot recipe) 32 36 psphotSetMaskRecipe (config, maskValue, markValue); 33 37 34 38 // Look up recipe values 35 psMetadata *recipe = psMetadataLookupMetadata( &mdok, config->recipes, PPSUB_RECIPE); // Recipe for ppSim39 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim 36 40 psAssert(recipe, "We checked this earlier, so it should be here."); 37 41 38 42 psImageMaskType satValue = pmConfigMaskGet("SAT", config); 39 psAssert (satValue, "SAT must be non-zero");43 psAssert(satValue, "SAT must be non-zero"); 40 44 41 45 psImageMaskType badValue = pmConfigMaskGet("BAD", config); 42 psAssert (badValue, "BAD must be non-zero");46 psAssert(badValue, "BAD must be non-zero"); 43 47 44 48 // input images … … 49 53 psImage *reference = refRO->image; // Reference image 50 54 PS_ASSERT_IMAGES_SIZE_EQUAL(input, reference, false); 51 52 // XXX use psImageCopy below to avoid caring about image dimensions 53 int numCols = input->numCols; 54 int numRows = input->numRows; 55 int numCols = input->numCols, numRows = input->numRows; // Size of image 55 56 56 57 // Generate masks if they don't exist … … 78 79 } 79 80 if (!pmReadoutMaskNonfinite(refRO, satValue)) { 80 psError(PS_ERR_UNKNOWN, false, "Unable to mask non-finite pixels in reference.");81 return false;81 psError(PS_ERR_UNKNOWN, false, "Unable to mask non-finite pixels in reference."); 82 return false; 82 83 } 83 84 84 #if (0)85 // Look up recipe values86 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim87 psAssert(recipe, "We checked this earlier, so it should be here.");88 85 86 #if 0 87 // Interpolation over bad pixels: this takes a while! 89 88 bool mdok = false; 90 91 89 psString interpModeStr = psMetadataLookupStr(&mdok, recipe, "INTERPOLATION"); // Interpolation mode 92 90 psImageInterpolateMode interpMode = psImageInterpolateModeFromString(interpModeStr); // Interp … … 102 100 // Interpolate over bad pixels, so the bad pixels don't explode 103 101 if (!pmReadoutInterpolateBadPixels(inRO, maskVal, interpMode, poorFrac, maskPoor, maskBad)) { 104 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate bad pixels for input image.");105 return false;102 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate bad pixels for input image."); 103 return false; 106 104 } 107 105 if (!pmReadoutInterpolateBadPixels(refRO, maskVal, interpMode, poorFrac, maskPoor, maskBad)) { 108 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate bad pixels for reference image.");109 return false;106 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate bad pixels for reference image."); 107 return false; 110 108 } 111 109 maskVal |= maskBad; -
branches/cnb_branch_20090215/ppSub/src/ppSubVarianceFactors.c
r21374 r21536 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 03:20:02$8 * @version $Revision: 1.3.4.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:50 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ … … 96 96 vfItem->data.F32 = vf; 97 97 98 // Statistics on the matching99 if (stats) {100 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MODE);101 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_STAMPS);102 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_DEV_MEAN);103 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_DEV_RMS);104 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_NORM);105 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_BGDIFF);106 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MX);107 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MY);108 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MXX);109 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MXY);110 psMetadataCopySingle(stats, outRO->analysis, PM_SUBTRACTION_ANALYSIS_MYY);111 112 psMetadataAddF32(stats, PS_LIST_TAIL, "TIME_MATCH", 0, "Time to match PSFs",113 psTimerClear("PPSUB_MATCH"));114 }115 116 98 return true; 117 99 } -
branches/cnb_branch_20090215/ppSub/src/ppSubVersion.c
r21360 r21536 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 01:37:17$8 * @version $Revision: 1.3.2.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:50 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ 12 13 #ifdef HAVE_CONFIG_H 14 #include <config.h> 15 #endif 16 17 #include <stdio.h> 18 #include <pslib.h> 19 #include <psmodules.h> 20 #include <ppStats.h> 12 21 13 22 #include "ppSub.h" -
branches/cnb_branch_20090215/psLib/m4
- Property svn:ignore
-
old new 1 libtool.m4 2 ltoptions.m4 3 ltsugar.m4 4 ltversion.m4 5 lt~obsolete.m4 1 6 Makefile 2 7 Makefile.in
-
- Property svn:ignore
-
branches/cnb_branch_20090215/psLib/m4/.cvsignore
r11609 r21536 1 libtool.m4 2 ltoptions.m4 3 ltsugar.m4 4 ltversion.m4 5 lt~obsolete.m4 1 6 Makefile 2 7 Makefile.in -
branches/cnb_branch_20090215/psLib/src/math/psPolynomialUtils.c
r21183 r21536 139 139 // XXX determine the errors, and propagate to the output of psImageBicubeMin 140 140 // XXX x,y are the image pixel index, but the fit is implied for the image pixel coordinates (0.5,0.5 center) 141 // this solution is determined assuming constant weight per pixel 141 142 psPolynomial2D *psImageBicubeFit(const psImage *image, int x, int y) 142 143 { … … 179 180 psPlane psImageBicubeMin(const psPolynomial2D *poly) 180 181 { 181 psPlane min = { NAN, NAN, 0, 0}; // Minimum value to return182 psPlane min = { NAN, NAN, NAN, NAN }; // Minimum value to return 182 183 183 184 PS_ASSERT_PTR_NON_NULL(poly, min); … … 186 187 187 188 double det = 4*poly->coeff[2][0]*poly->coeff[0][2] - PS_SQR(poly->coeff[1][1]); // Determinant 188 min.x = (poly->coeff[1][1]*poly->coeff[0][1] - 2*poly->coeff[0][2]*poly->coeff[1][0]) / det; 189 min.y = (poly->coeff[1][1]*poly->coeff[1][0] - 2*poly->coeff[2][0]*poly->coeff[0][1]) / det; 189 double xn = (poly->coeff[1][1]*poly->coeff[0][1] - 2*poly->coeff[0][2]*poly->coeff[1][0]); 190 double yn = (poly->coeff[1][1]*poly->coeff[1][0] - 2*poly->coeff[2][0]*poly->coeff[0][1]); 191 192 min.x = xn / det; 193 min.y = yn / det; 194 195 // sigma_xn^2 / xn^2 = sigma_11^2 / C11 196 197 // without a supplied error, we calculate the normalized error 198 double fdetErr2 = 0.5/PS_SQR(poly->coeff[0][2]) + 0.5/PS_SQR(poly->coeff[2][0]) + 4.0/(6.0*PS_SQR(poly->coeff[1][1])); 199 double fxnErr2 = 1.0/(6.0*PS_SQR(poly->coeff[0][1])) + 1.0/(6.0*PS_SQR(poly->coeff[1][0])) + 1.0/(6.0*PS_SQR(poly->coeff[1][1])) + 0.5/PS_SQR(poly->coeff[0][2]); 200 double fynErr2 = 1.0/(6.0*PS_SQR(poly->coeff[0][1])) + 1.0/(6.0*PS_SQR(poly->coeff[1][0])) + 1.0/(6.0*PS_SQR(poly->coeff[1][1])) + 0.5/PS_SQR(poly->coeff[2][0]); 201 202 min.xErr = fabs(min.x) * sqrt(fxnErr2 + fdetErr2); 203 min.yErr = fabs(min.y) * sqrt(fynErr2 + fdetErr2); 190 204 191 205 return min; -
branches/cnb_branch_20090215/psModules/src/astrom/pmAstrometryVisual.c
r21422 r21536 23 23 24 24 //variables to determine when things are plotted 25 static bool isVisual = false;26 25 static bool plotGridMatch = true; 27 26 static bool plotTweak = true; … … 48 47 /* Initialization Routines */ 49 48 50 bool pmAstromSetVisual (bool mode) {51 isVisual = mode;52 return true;53 }54 55 56 49 bool pmAstromVisualClose() 57 50 { … … 68 61 { 69 62 // make sure we want to plot this 70 if (!plotRawStars || ! isVisual) return true;63 if (!plotRawStars || !pmVisualIsVisual()) return true; 71 64 72 65 //set up plot region 73 66 if (!pmVisualInitWindow (&kapa, "psastro:plots")){ 74 isVisual = false;75 67 return false; 76 68 } … … 222 214 223 215 // pause and wait for user input: 224 pmVisualAskUser(&plotRawStars , &isVisual);216 pmVisualAskUser(&plotRawStars); 225 217 226 218 psFree (xVec); … … 234 226 { 235 227 //make sure we want to plot this 236 if (! isVisual|| !plotRefStars) return true;228 if (!pmVisualIsVisual() || !plotRefStars) return true; 237 229 238 230 //set up plotting variables 239 231 if (!pmVisualInitWindow (&kapa, "psastro:plots")) { 240 isVisual = false;241 232 return false; 242 233 } … … 284 275 285 276 // pause and wait for user input: 286 pmVisualAskUser(&plotRefStars , &isVisual);277 pmVisualAskUser(&plotRefStars); 287 278 288 279 psFree (xVec); … … 301 292 302 293 // make sure we want to plot this 303 if ( ! isVisual|| !plotLumFunc ) return true;294 if ( !pmVisualIsVisual() || !plotLumFunc ) return true; 304 295 305 296 //set up plotting variables 306 297 if ( !pmVisualInitWindow (&kapa, "psastro:plots")){ 307 isVisual = false;308 298 return false; 309 299 } … … 377 367 378 368 // pause and wait for user input: 379 pmVisualAskUser (&plotLumFunc , &isVisual);369 pmVisualAskUser (&plotLumFunc); 380 370 } 381 371 return true; … … 391 381 392 382 //make sure we want to plot this 393 if (! isVisual|| !plotRemoveClumps) return true;383 if (!pmVisualIsVisual() || !plotRemoveClumps) return true; 394 384 395 385 //set up plot variables 396 386 if ( !pmVisualInitWindow (&kapa, "psastro:plots")) { 397 isVisual = false;398 387 return false; 399 388 } … … 480 469 481 470 //ask for user input and finish 482 pmVisualAskUser (&plotRemoveClumps , &isVisual);471 pmVisualAskUser (&plotRemoveClumps); 483 472 psFree (xVec); 484 473 psFree (yVec); … … 496 485 497 486 //make sure we want to plot this 498 if (! isVisual|| !plotOneChipFit)487 if (!pmVisualIsVisual() || !plotOneChipFit) 499 488 return true; 500 489 501 490 if(!pmVisualInitWindow(&kapa, "psastro:plots") || !pmVisualInitWindow(&kapa2, "psastro:plots")) { 502 isVisual = false;503 491 return false; 504 492 } … … 511 499 512 500 //ask for user input and finish 513 pmVisualAskUser(&plotOneChipFit , &isVisual);501 pmVisualAskUser(&plotOneChipFit); 514 502 return true; 515 503 } … … 522 510 { 523 511 //make sure we want to plot this 524 if(! isVisual|| !plotFixChips) return true;512 if(!pmVisualIsVisual() || !plotFixChips) return true; 525 513 526 514 if(!pmVisualInitWindow(&kapa, "psastro:plots")) { 527 isVisual = false;528 515 return false; 529 516 } … … 588 575 KapaPlotVector (kapa, xNew->n, yNew->data.F32, "y"); 589 576 590 pmVisualAskUser(&plotFixChips , &isVisual);577 pmVisualAskUser(&plotFixChips); 591 578 psFree(xNew); 592 579 psFree(yNew); … … 606 593 607 594 //make sure we want to plot this 608 if (! isVisual|| !plotAstromGuessCheck) return true;595 if (!pmVisualIsVisual() || !plotAstromGuessCheck) return true; 609 596 610 597 //set up graph window 611 598 if ( !pmVisualInitWindow (&kapa, "psastro:plots")) { 612 isVisual = false;613 599 return false; 614 600 } … … 686 672 psFree(xResid); 687 673 psFree(yResid); 688 pmVisualAskUser (&plotAstromGuessCheck , &isVisual);674 pmVisualAskUser (&plotAstromGuessCheck); 689 675 return true; 690 676 } … … 696 682 { 697 683 //make sure we want to plot this 698 if (! isVisual|| !plotCommonScale) return true;684 if (!pmVisualIsVisual() || !plotCommonScale) return true; 699 685 700 686 if (!pmVisualInitWindow(&kapa, "psastro:plots")){ 701 isVisual = false;702 687 return false; 703 688 } … … 736 721 KapaSendLabel (kapa, "Old Pixel Scale of FPA Chips (Not to Scale)", KAPA_LABEL_XP); 737 722 738 pmVisualAskUser (&plotCommonScale , &isVisual);723 pmVisualAskUser (&plotCommonScale); 739 724 740 725 psFree(xVec); … … 750 735 751 736 //make sure we want to plot this 752 if (! isVisual|| !plotMosaicOneChip) return true;737 if (!pmVisualIsVisual() || !plotMosaicOneChip) return true; 753 738 754 739 if(!pmVisualInitWindow(&kapa, "psastro:plots") || !pmVisualInitWindow(&kapa2, "psastro:plots")) { 755 isVisual = false;756 740 return false; 757 741 } … … 759 743 //plot the residuals 760 744 if (!residPlot(rawstars, refstars, match, recipe, "Single Chip Fit Residuals - Mosaic Mode")) { 761 isVisual = false;745 pmVisualSetVisual(false); 762 746 return false; 763 747 } 764 748 765 749 //ask for user input and finish 766 pmVisualAskUser(&plotMosaicOneChip , &isVisual);750 pmVisualAskUser(&plotMosaicOneChip); 767 751 768 752 return true; … … 775 759 { 776 760 //make sure we want to plot this 777 if (! isVisual|| !plotMosaicMatches) return true;761 if (!pmVisualIsVisual() || !plotMosaicMatches) return true; 778 762 779 763 char title[60]; … … 782 766 783 767 if(!pmVisualInitWindow(&kapa, "psastro:plots") || !pmVisualInitWindow(&kapa2, "psastro:plots")) { 784 isVisual = false;785 768 return false; 786 769 } 787 770 788 771 if (!residPlot(rawstars, refstars, match, recipe, title)){ 789 isVisual = false;772 pmVisualSetVisual(false); 790 773 return false; 791 774 } 792 775 793 776 //ask for user input 794 pmVisualAskUser (&plotMosaicMatches , &isVisual);777 pmVisualAskUser (&plotMosaicMatches); 795 778 return true; 796 779 } … … 807 790 { 808 791 //make sure we want to plot this 809 if (! isVisual|| !plotGridMatch) return true;792 if (!pmVisualIsVisual() || !plotGridMatch) return true; 810 793 if (!pmVisualInitWindow(&kapa, "psastro:plots")){ 811 isVisual = false;812 794 return false; 813 795 } … … 952 934 KapaPlotVector (kapa, 2, yslice, "y"); 953 935 954 pmVisualAskUser(&plotGridMatch , &isVisual);936 pmVisualAskUser(&plotGridMatch); 955 937 psFree(dXplot); 956 938 psFree(dYplot); … … 966 948 { 967 949 //make sure we want to plot this 968 if (! isVisual|| !plotTweak) return true;950 if (!pmVisualIsVisual() || !plotTweak) return true; 969 951 if (!pmVisualInitWindow(&kapa, "psastro:plots")) { 970 isVisual = false;971 952 return false; 972 953 } … … 1051 1032 KAPA_LABEL_XP); 1052 1033 1053 pmVisualAskUser(&plotTweak , &isVisual);1034 pmVisualAskUser(&plotTweak); 1054 1035 1055 1036 psFree(xIndices); … … 1341 1322 # else 1342 1323 1343 bool pmAstromSetVisual(bool mode) { return true; }1344 1324 bool pmAstromVisualClose() { return true; } 1345 1325 bool pmAstromVisualPlotGridMatch (const psArray *raw, const psArray *ref, psImage *gridNP, double offsetX, double offsetY, double maxOffpix, double Scale, double Offset) { return true; } -
branches/cnb_branch_20090215/psModules/src/astrom/pmAstrometryVisual.h
r21422 r21536 22 22 int sPeak; ///< sum of stars to peak bin 23 23 } pmLumFunc; 24 25 26 /** Enable or disable visual plotting for psastro routines27 * @param mode true/false to enable/disable plotting28 * @return true for success */29 bool pmAstromSetVisual(bool mode);30 24 31 25 -
branches/cnb_branch_20090215/psModules/src/camera/pmFPACopy.c
r21363 r21536 457 457 psMetadataCopy(target->parent->concepts, source->parent->concepts); 458 458 459 // Update the astrometric parameters 460 target->toFPA = psMemIncrRefCounter (source->toFPA); 461 target->fromFPA = psMemIncrRefCounter (source->fromFPA); 462 463 // Update the parent fpa astrometry parameters, or check that they match 464 pmFPA *targetFPA = target->parent; 465 pmFPA *sourceFPA = source->parent; 466 // XXX should we require that both of these exist? 467 468 if (targetFPA && sourceFPA) { 469 if (targetFPA->toSky) { 470 psAssert (targetFPA->toSky == sourceFPA->toSky, "chips within FPA have inconsistent astrometry references"); 471 } else { 472 targetFPA->toSky = psMemIncrRefCounter (sourceFPA->toSky); 473 } 474 if (targetFPA->toTPA) { 475 psAssert (targetFPA->toTPA == sourceFPA->toTPA, "chips within FPA have inconsistent astrometry references"); 476 } else { 477 targetFPA->toTPA = psMemIncrRefCounter (sourceFPA->toTPA); 478 } 479 if (targetFPA->fromTPA) { 480 psAssert (targetFPA->fromTPA == sourceFPA->fromTPA, "chips within FPA have inconsistent astrometry references"); 481 } else { 482 targetFPA->fromTPA = psMemIncrRefCounter (sourceFPA->fromTPA); 483 } 484 } 485 459 486 target->data_exists = true; 460 487 return status; -
branches/cnb_branch_20090215/psModules/src/detrend/pmShutterCorrection.h
r21457 r21536 5 5 * @author Paul Price, IfA 6 6 * 7 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $8 * @date $Date: 2009-02-1 2 19:33:30 $7 * @version $Revision: 1.23.2.1 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-02-19 17:59:50 $ 9 9 * Copyright 2006 Institute for Astronomy, University of Hawaii 10 10 */ -
branches/cnb_branch_20090215/psModules/src/extras/pmVisual.c
r21422 r21536 28 28 # define KAPAY 700 29 29 30 static bool isVisual = false; 31 32 33 bool pmVisualSetVisual(bool value) { 34 isVisual = value; 35 return true; 36 } 37 38 39 bool pmVisualIsVisual(void) {return isVisual;} 40 41 bool pmVisualClose(void) { 42 pmAstrometryVisualClose(); 43 pmSubtractionVisualClose(); 44 pmStackVisualClose(); 45 //XXX handle psphot 46 // psphotVisualClose(); 47 return true; 48 } 30 49 31 50 bool pmVisualInitWindow (int *kapid, char *name) { … … 34 53 if (*kapid == -1) { 35 54 fprintf (stderr, "Failure to open kapa.\n"); 55 isVisual = false; 36 56 return false; 37 57 } … … 52 72 53 73 54 bool pmVisualAskUser(bool *plotFlag , bool *packageFlag)74 bool pmVisualAskUser(bool *plotFlag) 55 75 { 56 76 char key[10]; … … 63 83 } 64 84 if (key[0] == 'a') { 65 *packageFlag= false;85 isVisual = false; 66 86 } 67 87 return true; … … 304 324 305 325 #else 306 326 bool pmVisualSetVisual(bool value) {return true;} 327 bool pmVisualIsVisual(void) {return false;} 328 bool pmVisualClose(void) {return true;} 307 329 bool pmVisualInitWindow(int *kapid, char *name){return true;} 308 330 bool pmVisualInitGraph (int kapa, void *section, void *graphdata){return true;} 309 331 310 bool pmVisualAskUser(bool *plotFlag , bool *packageFlag){return true;}332 bool pmVisualAskUser(bool *plotFlag){return true;} 311 333 bool pmVisualImStats(psImage *image, double *mean, 312 334 double *stdev, double *min, double *max){return true;} -
branches/cnb_branch_20090215/psModules/src/extras/pmVisual.h
r21422 r21536 10 10 11 11 #if (HAVE_KAPA) 12 13 14 /** Globally enable or disable plotting 15 * @param value - true to enable plotting 16 * @return true 17 */ 18 bool pmVisualSetVisual(bool value); 19 20 21 /** Check whether plotting is enabled 22 * @retrun true if plots should be generated 23 */ 24 bool pmVisualIsVisual(void); 25 26 27 /** Destroy plotting windows at the end of a run 28 * @return true for success */ 29 bool pmVisualClose(void); 12 30 13 31 … … 32 50 * At the user's request, this will disable diagnostic plotting. 33 51 * @param plotFlag, set to false if this plot should be disabled in the future 34 * @param packageFlag, set to false if all plots from this package (e.g. psastro, pmSubtraction)35 * should be disabled.36 52 */ 37 bool pmVisualAskUser(bool *plotFlag , bool *packageFlag);53 bool pmVisualAskUser(bool *plotFlag); 38 54 39 55 … … 115 131 116 132 // kapa-specific data types are changed to void 133 bool pmVisualSetVisual(bool value); 134 bool pmVisualIsVisual(void); 135 bool pmVisualClose(void); 117 136 bool pmVisualInitWindow (int *kapid, char *name); 118 137 bool pmVisualInitGraph (int kapa, void *section, void *graphdata); 119 bool pmVisualAskUser(bool *plotFlag , bool *packageFlag);138 bool pmVisualAskUser(bool *plotFlag); 120 139 bool pmVisualScaleImage(int kapaFD, psImage *inImage, 121 140 const char *name, int channel, bool clip); -
branches/cnb_branch_20090215/psModules/src/imcombine/Makefile.am
r21422 r21536 19 19 pmSubtractionThreads.c \ 20 20 pmPSFEnvelope.c \ 21 pmSubtractionVisual.c 21 pmSubtractionVisual.c \ 22 pmStackVisual.c 22 23 23 24 pkginclude_HEADERS = \ … … 37 38 pmSubtractionThreads.h \ 38 39 pmPSFEnvelope.h \ 39 pmSubtractionVisual.h 40 pmSubtractionVisual.h \ 41 pmStackVisual.h 40 42 41 43 CLEANFILES = *~ -
branches/cnb_branch_20090215/psModules/src/imcombine/pmPSFEnvelope.c
r21363 r21536 30 30 31 31 #include "pmPSFEnvelope.h" 32 33 34 35 //#define TESTING // Enable test output32 #include "pmStackVisual.h" 33 34 35 #define TESTING // Enable test output 36 36 #define PEAK_FLUX 1.0e4 // Peak flux for each source 37 37 #define SKY_VALUE 0.0e0 // Sky value for fake image … … 162 162 psStringAppend(&name, "psf_field_%03d.fits", i); 163 163 psFits *fits = psFitsOpen(name, "w"); 164 pmStackVisualPlotTestImage(fakeRO->image, name); 164 165 psFitsWriteImage(fits, NULL, fakeRO->image, 0, NULL); 165 166 psFitsClose(fits); … … 179 180 // Write out the envelope 180 181 psFits *fits = psFitsOpen("psf_field_envelope.fits", "w"); 182 pmStackVisualPlotTestImage(envelope, "psf_field_envelope.fits"); 181 183 psFitsWriteImage(fits, NULL, envelope, 0, NULL); 182 184 psFitsClose(fits); … … 231 233 // Write out the envelope 232 234 psFits *fits = psFitsOpen("psf_field_full.fits", "w"); 235 pmStackVisualPlotTestImage(readout->image, "psf_field_full.fits"); 233 236 psFitsWriteImage(fits, NULL, readout->image, 0, NULL); 234 237 psFitsClose(fits); … … 312 315 { 313 316 psFits *fits = psFitsOpen("psf_field_model.fits", "w"); 317 pmStackVisualPlotTestImage(generated->image, "psf_field_model.fits"); 314 318 psFitsWriteImage(fits, NULL, generated->image, 0, NULL); 315 319 psFitsClose(fits); … … 318 322 { 319 323 psFits *fits = psFitsOpen("psf_field_resid.fits", "w"); 324 pmStackVisualPlotTestImage(generated->image, "psf_field_resid.fits"); 320 325 psFitsWriteImage(fits, NULL, generated->image, 0, NULL); 321 326 psFitsClose(fits); -
branches/cnb_branch_20090215/psModules/src/imcombine/pmStack.c
r21476 r21536 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1.48 $ $Name: not supported by cvs2svn $11 * @date $Date: 2009-02-1 3 23:52:14$10 * @version $Revision: 1.48.2.1 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2009-02-19 17:59:50 $ 12 12 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii 13 13 * … … 33 33 #define NUM_DIRECT_STDEV 5 // For less than this number of values, measure stdev directly 34 34 35 //#define TESTING // Enable test output 36 //#define TEST_X 2318 // x coordinate to examine 37 //#define TEST_Y 2306 // y coordinate to examine 35 //CNB change all of these to false 36 #define TESTING // Enable test output 37 #define TEST_X 2318 // x coordinate to examine 38 #define TEST_Y 2306 // y coordinate to examine 38 39 39 40 -
branches/cnb_branch_20090215/psModules/src/imcombine/pmSubtractionIO.c
r20355 r21536 16 16 17 17 #include "pmSubtractionIO.h" 18 #include "pmStackVisual.h" 18 19 19 20 #define ARRAY_BUFFER 16 // Number to add to array at a time … … 144 145 // CVS tags, used to identify the version of this file (in case incompatibilities are introduced) 145 146 psString cvsFile = psStringCopy("$RCSfile: pmSubtractionIO.c,v $"); 146 psString cvsRev = psStringCopy("$Revision: 1.9 $");147 psString cvsDate = psStringCopy("$Date: 200 8-10-24 21:21:06$");147 psString cvsRev = psStringCopy("$Revision: 1.9.18.1 $"); 148 psString cvsDate = psStringCopy("$Date: 2009-02-19 17:59:50 $"); 148 149 psStringSubstitute(&cvsFile, NULL, "RCSfile: "); 149 150 psStringSubstitute(&cvsRev, NULL, "Revision: "); … … 167 168 168 169 psImage *image = psMetadataLookupPtr(NULL, ro->analysis, PM_SUBTRACTION_ANALYSIS_KERNEL_IMAGE); // Image 170 pmStackVisualPlotTestImage(image, "Subtraction_kernels.fits"); 171 169 172 if (image && !psFitsWriteImage(fits, header, image, 0, EXTNAME_IMAGE)) { 170 173 psError(PS_ERR_IO, false, "Unable to write subtraction kernel image."); -
branches/cnb_branch_20090215/psModules/src/imcombine/pmSubtractionVisual.c
r21422 r21536 28 28 29 29 //variables to determine when things are plotted 30 static bool isVisual = false;31 30 static bool plotConvKernels = true; 32 31 static bool plotStamps = true; … … 42 41 // Initialization Routines 43 42 44 /** start or stop plotting */45 bool pmSubtractionSetVisual (bool mode) {46 isVisual = mode;47 return true;48 }49 43 50 44 … … 65 59 * @return true for success */ 66 60 bool pmSubtractionVisualPlotConvKernels(psImage *convKernels) { 67 if (! isVisual|| !plotConvKernels) return true;61 if (!pmVisualIsVisual() || !plotConvKernels) return true; 68 62 if (!pmVisualInitWindow(&kapa, "ppSub:Images")) { 69 isVisual = false;70 63 return false; 71 64 } 72 65 pmVisualScaleImage(kapa, convKernels, "Convolution_Kernels", 0, true); 73 pmVisualAskUser(&plotConvKernels , &isVisual);66 pmVisualAskUser(&plotConvKernels); 74 67 return true; 75 68 } … … 80 73 @return true for success */ 81 74 bool pmSubtractionVisualPlotStamps(pmSubtractionStampList *stamps, pmReadout *ro) { 82 if (! isVisual|| !plotStamps) return true;75 if (!pmVisualIsVisual() || !plotStamps) return true; 83 76 if (!pmVisualInitWindow (&kapa, "ppSub:Images")) { 84 isVisual = false;85 77 return false; 86 78 } 87 79 if (!pmVisualInitWindow (&kapa2, "ppSub:StampMasterImage")) { 88 isVisual = false;89 80 return false; 90 81 } … … 145 136 pmVisualScaleImage(kapa, canvas, "Subtraction_Stamps", 0, true); 146 137 147 pmVisualAskUser(&plotStamps , &isVisual);138 pmVisualAskUser(&plotStamps); 148 139 return true; 149 140 } … … 152 143 bool pmSubtractionVisualPlotLeastSquares (pmSubtractionStampList *stamps, bool dual) { 153 144 154 if (! isVisual|| !plotLeastSquares) return true;145 if (!pmVisualIsVisual() || !plotLeastSquares) return true; 155 146 if (!pmVisualInitWindow (&kapa, "PPSub:Images")) { 156 isVisual = false;157 147 return false; 158 148 } … … 209 199 pmVisualScaleImage(kapa, canvas32, "Least_Squares", 0, true); 210 200 211 pmVisualAskUser(&plotLeastSquares , &isVisual);201 pmVisualAskUser(&plotLeastSquares); 212 202 psFree(canvas); 213 203 psFree(canvas32); … … 216 206 217 207 bool pmSubtractionVisualShowSubtraction(psImage *image, psImage *ref, psImage *sub) { 218 if (! isVisual|| !plotImage) return true;208 if (!pmVisualIsVisual() || !plotImage) return true; 219 209 if (!pmVisualInitWindow (&kapa, "PPSub:Images")) { 220 isVisual = false;221 210 return false; 222 211 } … … 225 214 pmVisualScaleImage(kapa, ref, "Reference", 1, true); 226 215 pmVisualScaleImage(kapa, sub, "Subtraction", 2, true); 227 pmVisualAskUser(&plotImage , &isVisual);216 pmVisualAskUser(&plotImage); 228 217 return true; 229 218 } … … 267 256 268 257 #else 269 bool pmSubtractionSetVisual (bool mode) {return true;}270 258 bool pmSubtractionVisualClose() {return true;} 271 259 bool pmSubtractionVisualPlotConvKernels(psImage *convKernels) {return true;} -
branches/cnb_branch_20090215/psModules/src/imcombine/pmSubtractionVisual.h
r21422 r21536 2 2 #define PM_SUBTRACTION_VISUAL_H 3 3 4 bool pmSubtractionSetVisual (bool mode);5 4 bool pmSubtractionVisualClose(); 6 5 bool pmSubtractionVisualPlotConvKernels(psImage *convKernels); -
branches/cnb_branch_20090215/psModules/src/objects/Makefile.am
r20946 r21536 36 36 pmSourceIO_PS1_DEV_1.c \ 37 37 pmSourceIO_PS1_CAL_0.c \ 38 pmSourceIO_CMF_PS1_V1.c \ 38 39 pmSourcePlots.c \ 39 40 pmSourcePlotPSFModel.c \ -
branches/cnb_branch_20090215/psModules/src/objects/pmModel.c
r21381 r21536 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.27 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 20:54:14$8 * @version $Revision: 1.27.4.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:50 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 59 59 tmp->chisqNorm = 0.0; 60 60 tmp->nDOF = 0; 61 tmp->nPix = 0; 61 62 tmp->nIter = 0; 62 63 tmp->radiusFit = 0; … … 234 235 235 236 if (model->residuals) { 236 DX = xBin*(image->col0 - xCenter - dx) + model->residuals->xCenter + 0.5;237 DY = yBin*(image->row0 - yCenter - dy) + model->residuals->yCenter + 0.5;238 Ro = (model->residuals->Ro) ? model->residuals->Ro->data.F32 : NULL;239 Rx = (model->residuals->Rx) ? model->residuals->Rx->data.F32 : NULL;240 Ry = (model->residuals->Ry) ? model->residuals->Ry->data.F32 : NULL;241 Rm = (model->residuals->mask) ? model->residuals->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL;242 if (Ro) {243 NX = model->residuals->Ro->numCols;244 NY = model->residuals->Ro->numRows;245 } 237 DX = xBin*(image->col0 - xCenter - dx) + model->residuals->xCenter + 0.5; 238 DY = yBin*(image->row0 - yCenter - dy) + model->residuals->yCenter + 0.5; 239 Ro = (model->residuals->Ro) ? model->residuals->Ro->data.F32 : NULL; 240 Rx = (model->residuals->Rx) ? model->residuals->Rx->data.F32 : NULL; 241 Ry = (model->residuals->Ry) ? model->residuals->Ry->data.F32 : NULL; 242 Rm = (model->residuals->mask) ? model->residuals->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL; 243 if (Ro) { 244 NX = model->residuals->Ro->numCols; 245 NY = model->residuals->Ro->numRows; 246 } 246 247 } 247 248 … … 255 256 256 257 // XXX should we use using 0.5 pixel offset? 257 // Convert to coordinate in parent image, with offset (dx,dy)258 // Convert to coordinate in parent image, with offset (dx,dy) 258 259 imageCol = ix + image->col0 - dx; 259 260 imageRow = iy + image->row0 - dy; … … 275 276 float rx = xBin*ix + DX; 276 277 277 int rx0 = rx - 0.5;278 int rx1 = rx + 0.5;279 int ry0 = ry - 0.5;280 int ry1 = ry + 0.5;281 282 if (rx0 < 0) goto skip;283 if (ry0 < 0) goto skip;284 if (rx1 >= NX) goto skip;285 if (ry1 >= NY) goto skip;286 287 // these go from 0.0 to 1.0 between the centers of the pixels 288 float fx = rx - 0.5 - rx0;289 float Fx = 1.0 - fx;290 float fy = ry - 0.5 - ry0;291 float Fy = 1.0 - fy;292 293 // check the residual image mask (if set). give up if any of the 4 pixels are masked.294 if (Rm) {295 if (Rm[ry0][rx0]) goto skip;296 if (Rm[ry0][rx1]) goto skip;297 if (Rm[ry1][rx0]) goto skip;298 if (Rm[ry1][rx1]) goto skip;299 }300 301 // a possible further optimization if we re-use these values302 // XXX allow for masked pixels, and add pixel weights303 float V0 = (Ro[ry0][rx0]*Fx + Ro[ry0][rx1]*fx);304 float V1 = (Ro[ry1][rx0]*Fx + Ro[ry1][rx1]*fx);305 float Vo = V0*Fy + V1*fy;306 if (!isfinite(Vo)) goto skip;307 308 float Vx = 0.0;309 float Vy = 0.0;310 311 // skip Rx,Ry if Ro is masked312 if (Rx && Ry && (mode & PM_MODEL_OP_RES1)) {313 V0 = (Rx[ry0][rx0]*Fx + Rx[ry0][rx1]*fx);314 V1 = (Rx[ry1][rx0]*Fx + Rx[ry1][rx1]*fx);315 Vx = V0*Fy + V1*fy;316 317 V0 = (Ry[ry0][rx0]*Fx + Ry[ry0][rx1]*fx);318 V1 = (Ry[ry1][rx0]*Fx + Ry[ry1][rx1]*fx);319 Vy = V0*Fy + V1*fy;320 }321 if (!isfinite(Vx)) goto skip;322 if (!isfinite(Vy)) goto skip;323 324 // 2D residual variations are set for the true source position325 pixelValue += Io*(Vo + XoSave*Vx + XoSave*Vy);278 int rx0 = rx - 0.5; 279 int rx1 = rx + 0.5; 280 int ry0 = ry - 0.5; 281 int ry1 = ry + 0.5; 282 283 if (rx0 < 0) goto skip; 284 if (ry0 < 0) goto skip; 285 if (rx1 >= NX) goto skip; 286 if (ry1 >= NY) goto skip; 287 288 // these go from 0.0 to 1.0 between the centers of the pixels 289 float fx = rx - 0.5 - rx0; 290 float Fx = 1.0 - fx; 291 float fy = ry - 0.5 - ry0; 292 float Fy = 1.0 - fy; 293 294 // check the residual image mask (if set). give up if any of the 4 pixels are masked. 295 if (Rm) { 296 if (Rm[ry0][rx0]) goto skip; 297 if (Rm[ry0][rx1]) goto skip; 298 if (Rm[ry1][rx0]) goto skip; 299 if (Rm[ry1][rx1]) goto skip; 300 } 301 302 // a possible further optimization if we re-use these values 303 // XXX allow for masked pixels, and add pixel weights 304 float V0 = (Ro[ry0][rx0]*Fx + Ro[ry0][rx1]*fx); 305 float V1 = (Ro[ry1][rx0]*Fx + Ro[ry1][rx1]*fx); 306 float Vo = V0*Fy + V1*fy; 307 if (!isfinite(Vo)) goto skip; 308 309 float Vx = 0.0; 310 float Vy = 0.0; 311 312 // skip Rx,Ry if Ro is masked 313 if (Rx && Ry && (mode & PM_MODEL_OP_RES1)) { 314 V0 = (Rx[ry0][rx0]*Fx + Rx[ry0][rx1]*fx); 315 V1 = (Rx[ry1][rx0]*Fx + Rx[ry1][rx1]*fx); 316 Vx = V0*Fy + V1*fy; 317 318 V0 = (Ry[ry0][rx0]*Fx + Ry[ry0][rx1]*fx); 319 V1 = (Ry[ry1][rx0]*Fx + Ry[ry1][rx1]*fx); 320 Vy = V0*Fy + V1*fy; 321 } 322 if (!isfinite(Vx)) goto skip; 323 if (!isfinite(Vy)) goto skip; 324 325 // 2D residual variations are set for the true source position 326 pixelValue += Io*(Vo + XoSave*Vx + XoSave*Vy); 326 327 } 327 328 328 skip:329 skip: 329 330 // add or subtract the value 330 331 if (add) { -
branches/cnb_branch_20090215/psModules/src/objects/pmModel.h
r21183 r21536 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $8 * @date $Date: 2009-0 1-27 06:39:38$7 * @version $Revision: 1.18.8.1 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-02-19 17:59:50 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 92 92 float mag; ///< integrated model magnitude 93 93 float magErr; ///< integrated model magnitude error 94 int nPix; ///< number of pixels used for fit 94 95 int nDOF; ///< number of degrees of freedom 95 96 int nIter; ///< number of iterations to reach min … … 150 151 pmModel *model, ///< The input pmModel 151 152 pmModelOpMode mode, ///< mode to control how the model is added into the image 152 psImageMaskType maskVal ///< Value to mask153 psImageMaskType maskVal ///< Value to mask 153 154 ); 154 155 … … 168 169 pmModel *model, ///< The input pmModel 169 170 pmModelOpMode mode, ///< mode to control how the model is added into the image 170 psImageMaskType maskVal ///< Value to mask171 psImageMaskType maskVal ///< Value to mask 171 172 ); 172 173 -
branches/cnb_branch_20090215/psModules/src/objects/pmPeaks.c
r20937 r21536 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.25 $ $Name: not supported by cvs2svn $9 * @date $Date: 200 8-12-08 02:51:14$8 * @version $Revision: 1.25.14.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:50 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 28 28 AddPeak(): A private function which allocates a psArray, if the peaks 29 29 argument is NULL, otherwise it adds the peak to that array. 30 XXX EAM : row,col now refer to image coords, NOT parent (since this is private) 30 XXX EAM : row,col now refer to image coords, NOT parent (since this is private) 31 31 XXX EAM : now also calculates fractional peak positions from 3x3 bicube region 32 32 *****************************************************************************/ … … 63 63 peak->xf = min.x + ix + image->col0; 64 64 peak->yf = min.y + iy + image->row0; 65 peak->dx = NAN; 66 peak->dy = NAN; 67 68 // xf,yf must land on image with 0 pixel border 69 peak->xf = PS_MAX (PS_MIN (peak->xf, image->numCols - 1), image->col0); 70 peak->yf = PS_MAX (PS_MIN (peak->yf, image->numRows - 1), image->row0); 65 66 // These errors are fractional errors, and should be scaled by the 67 // error on the peak pixel (see, eg, psphotFindPeaks) 68 peak->dx = min.xErr; 69 peak->dy = min.yErr; 70 71 // xf,yf must land on image with 0 pixel border 72 peak->xf = PS_MAX (PS_MIN (peak->xf, image->numCols - 1), image->col0); 73 peak->yf = PS_MAX (PS_MIN (peak->yf, image->numRows - 1), image->row0); 71 74 } else { 72 75 peak->xf = ix; 73 76 peak->yf = iy; 74 peak->dx = NAN;75 peak->dy = NAN;77 peak->dx = NAN; 78 peak->dy = NAN; 76 79 } 77 80 … … 86 89 getRowVectorFromImage(): a private function which simply returns a 87 90 psVector containing the specified row of data from the psImage. 88 91 89 92 XXX: Is there a better way to do this? 90 93 XXX EAM: does this really need to alloc a new vector??? … … 245 248 above the given threshold. Returns a vector of type PS_TYPE_U32 containing 246 249 the location (x value) of all peaks. 247 250 248 251 XXX: What types should be supported? Only F32 is implemented. 249 252 250 253 XXX: We currently step through the input vector twice; once to determine the 251 254 size of the output vector, then to set the values of the output vector. … … 253 256 *****************************************************************************/ 254 257 psVector *pmPeaksInVector(const psVector *vector, 255 psF32 threshold)258 psF32 threshold) 256 259 { 257 260 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); … … 347 350 above the given threshold. Returns a psArray containing location (x/y value) 348 351 of all peaks. 349 352 350 353 XXX: I'm not convinced the peak type definition in the SDRS is mutually 351 354 exclusive. Some peaks can have multiple types. Edges for sure. Also, a 352 355 digonal line with the same value at each point will have a peak for every 353 356 point on that line. 354 357 355 358 XXX: This does not work if image has either a single row, or a single column. 356 359 357 360 The peak is returned in the image parent coordinates 358 361 -
branches/cnb_branch_20090215/psModules/src/objects/pmSource.c
r21363 r21536 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.69 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 02:31:25$8 * @version $Revision: 1.69.4.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:50 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 113 113 source->type = PM_SOURCE_TYPE_UNKNOWN; 114 114 source->mode = PM_SOURCE_MODE_DEFAULT; 115 source->tmpFlags = 0; 115 116 source->extpars = NULL; 116 117 source->region = psRegionSet(NAN, NAN, NAN, NAN); … … 534 535 float INNER_RADIUS = psMetadataLookupF32 (&status, recipe, "SKY_INNER_RADIUS"); 535 536 537 pmSourceMode noMoments = PM_SOURCE_MODE_MOMENTS_FAILURE | PM_SOURCE_MODE_SKYVAR_FAILURE | PM_SOURCE_MODE_SKY_FAILURE | PM_SOURCE_MODE_BELOW_MOMENTS_SN; 538 536 539 // XXX allow clump size to be scaled relative to sigmas? 537 540 // make rough IDs based on clumpX,Y,DX,DY … … 540 543 pmSource *source = (pmSource *) sources->data[i]; 541 544 542 if (source->peak->x < region->x0) continue; 543 if (source->peak->x > region->x1) continue; 544 if (source->peak->y < region->y0) continue; 545 if (source->peak->y > region->y1) continue; 546 547 source->peak->type = 0; 545 // psf clumps are found for image subregions: 546 // skip sources not in this region 547 if (source->peak->x < region->x0) continue; 548 if (source->peak->x >= region->x1) continue; 549 if (source->peak->y < region->y0) continue; 550 if (source->peak->y >= region->y1) continue; 551 552 // should be set by pmSourceAlloc 553 psAssert (source->type == PM_SOURCE_TYPE_UNKNOWN, "source type was not init-ed?"); 548 554 549 555 // we are basically classifying by moments; use the default if not found 550 556 if (!source->moments) { 551 557 source->type = PM_SOURCE_TYPE_STAR; 558 psAssert (source->mode & noMoments, "why is this source missing moments?"); 552 559 Nstar++; 553 560 continue; … … 1049 1056 } 1050 1057 1058 // sort by Seq (ascending) 1059 int pmSourceSortBySeq (const void **a, const void **b) 1060 { 1061 pmSource *A = *(pmSource **)a; 1062 pmSource *B = *(pmSource **)b; 1063 1064 int iA = A->seq; 1065 int iB = B->seq; 1066 1067 int diff = iA - iB; 1068 if (diff > 0) return (+1); 1069 if (diff < 0) return (-1); 1070 return (0); 1071 } 1072 1051 1073 pmSourceMode pmSourceModeFromString (const char *name) { 1052 1074 if (!strcasecmp (name, "DEFAULT" )) return PM_SOURCE_MODE_DEFAULT; … … 1066 1088 if (!strcasecmp (name, "CRLIMIT" )) return PM_SOURCE_MODE_CR_LIMIT; 1067 1089 if (!strcasecmp (name, "EXTLIMIT" )) return PM_SOURCE_MODE_EXT_LIMIT; 1068 if (!strcasecmp (name, "SUBTRACTED")) return PM_SOURCE_MODE_SUBTRACTED;1069 1090 return PM_SOURCE_MODE_DEFAULT; 1070 1091 } … … 1088 1109 case PM_SOURCE_MODE_CR_LIMIT : return psStringCopy ("CRLIMIT" ); 1089 1110 case PM_SOURCE_MODE_EXT_LIMIT : return psStringCopy ("EXTLIMIT" ); 1090 case PM_SOURCE_MODE_SUBTRACTED : return psStringCopy ("SUBTRACTED");1091 1111 default: 1092 1112 return NULL; -
branches/cnb_branch_20090215/psModules/src/objects/pmSource.h
r21363 r21536 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.28 $ $Name: not supported by cvs2svn $6 * @date $Date: 2009-02- 06 02:31:25$5 * @version $Revision: 1.28.4.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2009-02-19 17:59:50 $ 7 7 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 8 8 */ … … 35 35 } pmSourceType; 36 36 37 // bit flags to distinguish analysis results 37 38 typedef enum { 38 PM_SOURCE_MODE_DEFAULT = 0x0000, ///< 39 PM_SOURCE_MODE_PSFMODEL = 0x0001, ///< Source fitted with a psf model (linear or non-linear) 40 PM_SOURCE_MODE_EXTMODEL = 0x0002, ///< Source fitted with an extended-source model 41 PM_SOURCE_MODE_FITTED = 0x0004, ///< Source fitted with non-linear model (PSF or EXT; good or bad) 42 PM_SOURCE_MODE_FAIL = 0x0008, ///< Fit (non-linear) failed (non-converge, off-edge, run to zero) 43 PM_SOURCE_MODE_POOR = 0x0010, ///< Fit succeeds, but low-SN, high-Chisq, or large (for PSF -- drop?) 44 PM_SOURCE_MODE_PAIR = 0x0020, ///< Source fitted with a double psf 45 PM_SOURCE_MODE_PSFSTAR = 0x0040, ///< Source used to define PSF model 46 PM_SOURCE_MODE_SATSTAR = 0x0080, ///< Source model peak is above saturation 47 PM_SOURCE_MODE_BLEND = 0x0100, ///< Source is a blend with other sourcers 48 PM_SOURCE_MODE_EXTERNAL = 0x0200, ///< Source based on supplied input position 49 PM_SOURCE_MODE_BADPSF = 0x0400, ///< Failed to get good estimate of object's PSF 50 PM_SOURCE_MODE_DEFECT = 0x0800, ///< Source is thought to be a defect 51 PM_SOURCE_MODE_SATURATED = 0x1000, ///< Source is thought to be saturated pixels (bleed trail) 52 PM_SOURCE_MODE_CR_LIMIT = 0x2000, ///< Source has crNsigma above limit 53 PM_SOURCE_MODE_EXT_LIMIT = 0x4000, ///< Source has extNsigma above limit 54 PM_SOURCE_MODE_SUBTRACTED = 0x8000, ///< XXX this flag is actually only used internally (move) 39 PM_SOURCE_MODE_DEFAULT = 0x00000000, ///< Initial value: resets all bits 40 PM_SOURCE_MODE_PSFMODEL = 0x00000001, ///< Source fitted with a psf model (linear or non-linear) 41 PM_SOURCE_MODE_EXTMODEL = 0x00000002, ///< Source fitted with an extended-source model 42 PM_SOURCE_MODE_FITTED = 0x00000004, ///< Source fitted with non-linear model (PSF or EXT; good or bad) 43 PM_SOURCE_MODE_FAIL = 0x00000008, ///< Fit (non-linear) failed (non-converge, off-edge, run to zero) 44 PM_SOURCE_MODE_POOR = 0x00000010, ///< Fit succeeds, but low-SN, high-Chisq, or large (for PSF -- drop?) 45 PM_SOURCE_MODE_PAIR = 0x00000020, ///< Source fitted with a double psf 46 PM_SOURCE_MODE_PSFSTAR = 0x00000040, ///< Source used to define PSF model 47 PM_SOURCE_MODE_SATSTAR = 0x00000080, ///< Source model peak is above saturation 48 PM_SOURCE_MODE_BLEND = 0x00000100, ///< Source is a blend with other sourcers 49 PM_SOURCE_MODE_EXTERNAL = 0x00000200, ///< Source based on supplied input position 50 PM_SOURCE_MODE_BADPSF = 0x00000400, ///< Failed to get good estimate of object's PSF 51 PM_SOURCE_MODE_DEFECT = 0x00000800, ///< Source is thought to be a defect 52 PM_SOURCE_MODE_SATURATED = 0x00001000, ///< Source is thought to be saturated pixels (bleed trail) 53 PM_SOURCE_MODE_CR_LIMIT = 0x00002000, ///< Source has crNsigma above limit 54 PM_SOURCE_MODE_EXT_LIMIT = 0x00004000, ///< Source has extNsigma above limit 55 PM_SOURCE_MODE_MOMENTS_FAILURE = 0x00008000, ///< could not measure the moments 56 PM_SOURCE_MODE_SKY_FAILURE = 0x00010000, ///< could not measure the local sky 57 PM_SOURCE_MODE_SKYVAR_FAILURE = 0x00020000, ///< could not measure the local sky variance 58 PM_SOURCE_MODE_BELOW_MOMENTS_SN = 0x00040000, ///< moments not measured due to low S/N 59 PM_SOURCE_MODE_BIG_RADIUS = 0x00100000, ///< poor moments for small radius, try large radius 60 PM_SOURCE_MODE_AP_MAGS = 0x00200000, ///< source has an aperture magnitude 61 PM_SOURCE_MODE_BLEND_FIT = 0x00400000, ///< source was fitted as a blend 62 PM_SOURCE_MODE_EXTENDED_FIT = 0x00800000, ///< full extended fit was used 63 PM_SOURCE_MODE_EXTENDED_STATS = 0x01000000, ///< extended aperture stats calculated 64 PM_SOURCE_MODE_LINEAR_FIT = 0x02000000, ///< source fitted with the linear fit 65 PM_SOURCE_MODE_NONLINEAR_FIT = 0x04000000, ///< source fitted with the non-linear fit 66 PM_SOURCE_MODE_RADIAL_FLUX = 0x08000000, ///< radial flux measurements calculated 67 PM_SOURCE_MODE_SIZE_SKIPPED = 0x10000000, ///< size could not be determined 55 68 } pmSourceMode; 69 70 typedef enum { 71 PM_SOURCE_TMPF_MODEL_GUESS = 0x0001, 72 PM_SOURCE_TMPF_SUBTRACTED = 0x0002, 73 } pmSourceTmpF; 56 74 57 75 /** pmSource data structure … … 68 86 */ 69 87 struct pmSource { 70 const int id; ///< Unique ID for object 71 int seq; ///< ID for output (generated on write )88 const int id; ///< Unique ID for object (generated on alloc) 89 int seq; ///< ID for output (generated on write OR set on read) 72 90 pmPeak *peak; ///< Description of peak pixel. 73 91 psImage *pixels; ///< Rectangular region including object pixels. … … 83 101 pmSourceType type; ///< Best identification of object. 84 102 pmSourceMode mode; ///< analysis flags set for object. 103 pmSourceTmpF tmpFlags; ///< internal-only flags 85 104 psArray *blends; ///< collection of sources thought to be confused with object 86 105 float psfMag; ///< calculated from flux in modelPSF … … 240 259 bool pmSourceCachePSF (pmSource *source, psImageMaskType maskVal); 241 260 242 int pmSourceSortBySN (const void **a, const void **b); 243 int pmSourceSortByY (const void **a, const void **b); 261 int pmSourceSortBySN (const void **a, const void **b); 262 int pmSourceSortByY (const void **a, const void **b); 263 int pmSourceSortBySeq (const void **a, const void **b); 244 264 245 265 pmSourceMode pmSourceModeFromString (const char *name); -
branches/cnb_branch_20090215/psModules/src/objects/pmSourceFitModel.c
r21363 r21536 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.30 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 02:31:25$8 * @version $Revision: 1.30.4.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:50 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 184 184 model->chisq = myMin->value; 185 185 model->nIter = myMin->iter; 186 model->nPix = y->n; 186 187 model->nDOF = y->n - nParams; 187 188 model->flags |= PM_MODEL_STATUS_FITTED; -
branches/cnb_branch_20090215/psModules/src/objects/pmSourceIO.c
r20937 r21536 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.69 $ $Name: not supported by cvs2svn $6 * @date $Date: 200 8-12-08 02:51:14$5 * @version $Revision: 1.69.14.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2009-02-19 17:59:50 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 488 488 } 489 489 if (!strcmp (exttype, "PS1_DEV_1")) { 490 status = pmSourcesWrite_PS1_DEV_1 (file->fits, sources, file->header, outhead, dataname , xsrcname);490 status = pmSourcesWrite_PS1_DEV_1 (file->fits, sources, file->header, outhead, dataname); 491 491 } 492 492 if (!strcmp (exttype, "PS1_CAL_0")) { 493 status = pmSourcesWrite_PS1_CAL_0 (file->fits, readout, sources, file->header, outhead, dataname, xsrcname); 493 status = pmSourcesWrite_PS1_CAL_0 (file->fits, readout, sources, file->header, outhead, dataname); 494 } 495 if (!strcmp (exttype, "PS1_V1")) { 496 status = pmSourcesWrite_CMF_PS1_V1 (file->fits, readout, sources, file->header, outhead, dataname); 494 497 } 495 498 if (xsrcname) { … … 500 503 status = pmSourcesWrite_PS1_CAL_0_XSRC (file->fits, readout, sources, file->header, xsrcname, recipe); 501 504 } 505 if (!strcmp (exttype, "PS1_V1")) { 506 status = pmSourcesWrite_CMF_PS1_V1_XSRC (file->fits, sources, xsrcname, recipe); 507 } 502 508 } 503 509 if (xfitname) { … … 507 513 if (!strcmp (exttype, "PS1_CAL_0")) { 508 514 status = pmSourcesWrite_PS1_CAL_0_XFIT (file->fits, readout, sources, file->header, xfitname); 515 } 516 if (!strcmp (exttype, "PS1_V1")) { 517 status = pmSourcesWrite_CMF_PS1_V1_XFIT (file->fits, sources, xfitname); 509 518 } 510 519 } … … 929 938 sources = pmSourcesRead_PS1_DEV_1 (file->fits, hdu->header); 930 939 } 931 if (!strcmp (exttype, "PS1_ CAL_)")) {932 sources = pmSourcesRead_ PS1_CAL_0(file->fits, hdu->header);940 if (!strcmp (exttype, "PS1_V1")) { 941 sources = pmSourcesRead_CMF_PS1_V1 (file->fits, hdu->header); 933 942 } 934 943 } -
branches/cnb_branch_20090215/psModules/src/objects/pmSourceIO.h
r20741 r21536 4 4 * @author EAM, IfA; GLG, MHPCC 5 5 * 6 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $7 * @date $Date: 200 8-11-14 02:11:45$6 * @version $Revision: 1.19.16.1 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2009-02-19 17:59:50 $ 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 9 9 * … … 26 26 bool pmSourcesWrite_SMPDATA (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname); 27 27 bool pmSourcesWrite_PS1_DEV_0 (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname); 28 bool pmSourcesWrite_PS1_DEV_1 (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname, char *xsrcname); 28 29 bool pmSourcesWrite_PS1_DEV_1 (psFits *fits, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname); 29 30 bool pmSourcesWrite_PS1_DEV_1_XSRC (psFits *fits, psArray *sources, char *extname, psMetadata *recipe); 30 31 bool pmSourcesWrite_PS1_DEV_1_XFIT (psFits *fits, psArray *sources, char *extname); 31 32 32 bool pmSourcesWrite_PS1_CAL_0 (psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname , char *xsrcname);33 bool pmSourcesWrite_PS1_CAL_0 (psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname); 33 34 bool pmSourcesWrite_PS1_CAL_0_XSRC (psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, char *extname, psMetadata *recipe); 34 35 bool pmSourcesWrite_PS1_CAL_0_XFIT (psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, char *extname); 36 37 bool pmSourcesWrite_CMF_PS1_V1 (psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname); 38 bool pmSourcesWrite_CMF_PS1_V1_XSRC (psFits *fits, psArray *sources, char *extname, psMetadata *recipe); 39 bool pmSourcesWrite_CMF_PS1_V1_XFIT (psFits *fits, psArray *sources, char *extname); 35 40 36 41 bool pmSource_CMF_WritePHU (const pmFPAview *view, pmFPAfile *file, pmConfig *config); … … 42 47 psArray *pmSourcesRead_PS1_DEV_1 (psFits *fits, psMetadata *header); 43 48 psArray *pmSourcesRead_PS1_CAL_0 (psFits *fits, psMetadata *header); 49 psArray *pmSourcesRead_CMF_PS1_V1 (psFits *fits, psMetadata *header); 44 50 45 51 bool pmSourcesWritePSFs (psArray *sources, char *filename); … … 67 73 bool pmReadoutCheckDataStatusForSources (const pmReadout *readout); 68 74 75 bool pmSourceLocalAstrometry (psSphere *ptSky, float *posAngle, float *pltScale, pmChip *chip, float xPos, float yPos); 76 69 77 /// @} 70 78 # endif /* PM_SOURCE_IO_H */ -
branches/cnb_branch_20090215/psModules/src/objects/pmSourceIO_PS1_CAL_0.c
r20937 r21536 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $6 * @date $Date: 200 8-12-08 02:51:14$5 * @version $Revision: 1.2.14.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2009-02-19 17:59:50 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 49 49 // XXX how do I generate the source tables which I need to send to PSPS? 50 50 51 bool pmSourcesWrite_PS1_CAL_0 (psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader,52 psMetadata * tableHeader, char *extname, char *xsrcname)51 bool pmSourcesWrite_PS1_CAL_0 (psFits *fits, pmReadout *readout, psArray *sources, 52 psMetadata *imageHeader, psMetadata *tableHeader, char *extname) 53 53 { 54 54 PS_ASSERT_PTR_NON_NULL(fits, false); … … 68 68 pmFPA *fpa = chip->parent; 69 69 if (!chip->toFPA || !fpa->toTPA || !fpa->toSky) { 70 psWarning ("astrometry calibration is missing, no calibrated coords");70 psWarning ("astrometry calibration is missing, no calibrated coords"); 71 71 } 72 72 … … 77 77 float zeropt = psMetadataLookupF32 (&status2, imageHeader, "ZPT_OBS"); 78 78 if (!status1 || !status2 || (exptime == 0.0)) { 79 psWarning ("exposure time or measured zero point not found for a readout, no calibrated mags");79 psWarning ("exposure time or measured zero point not found for a readout, no calibrated mags"); 80 80 } else { 81 magOffset = zeropt + 2.5*log10(exptime);81 magOffset = zeropt + 2.5*log10(exptime); 82 82 } 83 83 … … 90 90 for (i = 0; i < sources->n; i++) { 91 91 pmSource *source = (pmSource *) sources->data[i]; 92 if (source->seq == -1) {93 source->seq = i;94 }92 if (source->seq == -1) { 93 source->seq = i; 94 } 95 95 96 96 // no difference between PSF and non-PSF model … … 104 104 xErr = dPAR[PM_PAR_XPOS]; 105 105 yErr = dPAR[PM_PAR_YPOS]; 106 if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX])) {107 axes = pmPSF_ModelToAxes (PAR, 20.0);108 } else {109 axes.major = NAN;110 axes.minor = NAN;111 axes.theta = NAN;112 }113 chisq = model->chisq;114 115 // need to determine the PSF photometry error: source->errMag is the error on the 'best' model mag.116 errMag = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0];106 if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX])) { 107 axes = pmPSF_ModelToAxes (PAR, 20.0); 108 } else { 109 axes.major = NAN; 110 axes.minor = NAN; 111 axes.theta = NAN; 112 } 113 chisq = model->chisq; 114 115 // need to determine the PSF photometry error: source->errMag is the error on the 'best' model mag. 116 errMag = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0]; 117 117 } else { 118 118 xPos = source->peak->xf; … … 123 123 axes.minor = NAN; 124 124 axes.theta = NAN; 125 chisq = NAN;126 errMag = NAN;127 } 128 129 float calMag = source->psfMag + magOffset;125 chisq = NAN; 126 errMag = NAN; 127 } 128 129 float calMag = source->psfMag + magOffset; 130 130 float peakMag = (source->peak->flux > 0) ? -2.5*log10(source->peak->flux) : NAN; 131 131 psS16 nImageOverlap = 1; 132 132 133 // generate RA,DEC134 psPlane ptCH, ptFP, ptTP;135 psSphere ptSky;136 137 ptCH.x = xPos;138 ptCH.y = yPos;139 if (chip->toFPA && fpa->toTPA && fpa->toSky) {140 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCH);141 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP);142 psDeproject (&ptSky, &ptTP, fpa->toSky);143 } else {144 ptSky.r = NAN;145 ptSky.d = NAN;146 }133 // generate RA,DEC 134 psPlane ptCH, ptFP, ptTP; 135 psSphere ptSky; 136 137 ptCH.x = xPos; 138 ptCH.y = yPos; 139 if (chip->toFPA && fpa->toTPA && fpa->toSky) { 140 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCH); 141 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP); 142 psDeproject (&ptSky, &ptTP, fpa->toSky); 143 } else { 144 ptSky.r = NAN; 145 ptSky.d = NAN; 146 } 147 147 148 148 row = psMetadataAlloc (); … … 150 150 psMetadataAdd (row, PS_LIST_TAIL, "RA_PSF", PS_DATA_F32, "PSF RA coordinate (degrees)", ptSky.r*PS_DEG_RAD); 151 151 psMetadataAdd (row, PS_LIST_TAIL, "DEC_PSF", PS_DATA_F32, "PSF DEC coordinate (degrees)", ptSky.d*PS_DEG_RAD); 152 // XXX need to do the error propagation correctly..152 // XXX need to do the error propagation correctly.. 153 153 // psMetadataAdd (row, PS_LIST_TAIL, "RA_PSF_SIG", PS_DATA_F32, "Sigma of PSF fit RA", dRA); 154 154 // psMetadataAdd (row, PS_LIST_TAIL, "DEC_PSF_SIG", PS_DATA_F32, "Sigma of PSF fit DEC", dDEC); … … 170 170 psMetadataAdd (row, PS_LIST_TAIL, "EXT_NSIGMA", PS_DATA_F32, "Nsigma deviations from PSF to EXT", source->extNsigma); 171 171 172 // EXT_NSIGMA will be NAN if: 1) contour ellipse is imaginary; 2) source is not173 // subtracted174 175 // CR_NSIGMA will be NAN if: 1) source is not subtracted; 2) source is on the image176 // edge; 3) any pixels in the 3x3 peak region are masked; 172 // EXT_NSIGMA will be NAN if: 1) contour ellipse is imaginary; 2) source is not 173 // subtracted 174 175 // CR_NSIGMA will be NAN if: 1) source is not subtracted; 2) source is on the image 176 // edge; 3) any pixels in the 3x3 peak region are masked; 177 177 178 178 // XXX these should be major and minor, not 'x' and 'y' … … 277 277 source->psfMag = psMetadataLookupF32 (&status, row, "PSF_INST_MAG"); 278 278 source->errMag = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG"); 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;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; 281 281 282 282 pmPSF_AxesToModel (PAR, axes); … … 289 289 source->pixWeight = psMetadataLookupF32 (&status, row, "PSF_QF"); 290 290 291 // note that some older versions used PSF_PROBABILITY: this was not well defined.291 // note that some older versions used PSF_PROBABILITY: this was not well defined. 292 292 model->chisq = psMetadataLookupF32 (&status, row, "PSF_CHISQ"); 293 293 source->crNsigma = psMetadataLookupF32 (&status, row, "CR_NSIGMA"); … … 321 321 pmFPA *fpa = chip->parent; 322 322 if (!chip->toFPA || !fpa->toTPA || !fpa->toSky) { 323 psWarning ("astrometry calibration is missing, no calibrated coords");323 psWarning ("astrometry calibration is missing, no calibrated coords"); 324 324 } 325 325 … … 331 331 float zeropt = psMetadataLookupF32 (&status2, imageHeader, "ZPT_OBS"); 332 332 if (!status1 || !status2 || (exptime == 0.0)) { 333 psWarning ("exposure time or measured zero point not found for a readout, no calibrated mags");333 psWarning ("exposure time or measured zero point not found for a readout, no calibrated mags"); 334 334 } else { 335 magOffset = zeropt + 2.5*log10(exptime);336 calMags = true;335 magOffset = zeropt + 2.5*log10(exptime); 336 calMags = true; 337 337 } 338 338 … … 360 360 // we write out all sources, regardless of quality. the source flags tell us the state 361 361 for (int i = 0; i < sources->n; i++) { 362 // skip source if it is not a ext sourc363 // XXX we have two places that extended source parameters are measured:364 // psphotExtendedSources, which measures the aperture-like parameters and (potentially) the psf-convolved extended source models,365 // psphotFitEXT, which does the simple extended source model fit (not psf-convolved)366 // should we require both?367 368 pmSource *source = sources->data[i];369 370 // skip sources without measurements371 if (source->extpars == NULL) continue;372 373 // we require a PSF model fit (ignore the real crud)374 pmModel *model = source->modelPSF;375 if (model == NULL) continue;376 377 // XXX I need to split the extended models from the extended aperture measurements378 PAR = model->params->data.F32;379 dPAR = model->dparams->data.F32;380 xPos = PAR[PM_PAR_XPOS];381 yPos = PAR[PM_PAR_YPOS];382 xErr = dPAR[PM_PAR_XPOS];383 yErr = dPAR[PM_PAR_YPOS];384 385 // generate RA,DEC386 psPlane ptCH, ptFP, ptTP;387 psSphere ptSky;388 389 ptCH.x = xPos;390 ptCH.y = yPos;391 if (chip->toFPA && fpa->toTPA && fpa->toSky) {392 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCH);393 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP);394 psDeproject (&ptSky, &ptTP, fpa->toSky);395 } else {396 ptSky.r = NAN;397 ptSky.d = NAN;398 }362 // skip source if it is not a ext sourc 363 // XXX we have two places that extended source parameters are measured: 364 // psphotExtendedSources, which measures the aperture-like parameters and (potentially) the psf-convolved extended source models, 365 // psphotFitEXT, which does the simple extended source model fit (not psf-convolved) 366 // should we require both? 367 368 pmSource *source = sources->data[i]; 369 370 // skip sources without measurements 371 if (source->extpars == NULL) continue; 372 373 // we require a PSF model fit (ignore the real crud) 374 pmModel *model = source->modelPSF; 375 if (model == NULL) continue; 376 377 // XXX I need to split the extended models from the extended aperture measurements 378 PAR = model->params->data.F32; 379 dPAR = model->dparams->data.F32; 380 xPos = PAR[PM_PAR_XPOS]; 381 yPos = PAR[PM_PAR_YPOS]; 382 xErr = dPAR[PM_PAR_XPOS]; 383 yErr = dPAR[PM_PAR_YPOS]; 384 385 // generate RA,DEC 386 psPlane ptCH, ptFP, ptTP; 387 psSphere ptSky; 388 389 ptCH.x = xPos; 390 ptCH.y = yPos; 391 if (chip->toFPA && fpa->toTPA && fpa->toSky) { 392 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCH); 393 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP); 394 psDeproject (&ptSky, &ptTP, fpa->toSky); 395 } else { 396 ptSky.r = NAN; 397 ptSky.d = NAN; 398 } 399 399 400 400 row = psMetadataAlloc (); … … 410 410 psMetadataAdd (row, PS_LIST_TAIL, "Y_EXT_SIG", PS_DATA_F32, "Sigma in EXT y coordinate", yErr); 411 411 412 // Petrosian measurements413 // XXX insert header data: petrosian ref radius, flux ratio414 if (doPetrosian) {415 pmSourcePetrosianValues *petrosian = source->extpars->petrosian;416 if (petrosian) {417 if (calMags) {418 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_CAL", PS_DATA_F32, "Petrosian Magnitude (calibrated)", petrosian->mag + magOffset);419 } else {420 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_INST", PS_DATA_F32, "Petrosian Magnitude (instrumental)", petrosian->mag);421 }422 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_ERR", PS_DATA_F32, "Petrosian Magnitude Error", petrosian->magErr);423 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS", PS_DATA_F32, "Petrosian Radius", petrosian->rad);424 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS_ERR", PS_DATA_F32, "Petrosian Radius Error", petrosian->radErr);425 } else {426 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG", PS_DATA_F32, "Petrosian Magnitude", NAN);427 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_ERR", PS_DATA_F32, "Petrosian Magnitude Error", NAN);428 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS", PS_DATA_F32, "Petrosian Radius", NAN);429 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS_ERR", PS_DATA_F32, "Petrosian Radius Error", NAN);430 }431 } 432 433 // Kron measurements434 if (doKron) {435 pmSourceKronValues *kron = source->extpars->kron;436 if (kron) {437 if (calMags) {438 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_CAL", PS_DATA_F32, "Kron Magnitude", kron->mag + magOffset);439 } else {440 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_INST", PS_DATA_F32, "Kron Magnitude", kron->mag);441 }442 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", kron->magErr);443 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", kron->rad);444 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", kron->radErr);445 } else {446 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG", PS_DATA_F32, "Kron Magnitude", NAN);447 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", NAN);448 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", NAN);449 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", NAN);450 }451 }452 453 // Isophot measurements454 // XXX insert header data: isophotal level455 if (doIsophotal) {456 pmSourceIsophotalValues *isophot = source->extpars->isophot;457 if (isophot) {458 if (calMags) {459 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_CAL", PS_DATA_F32, "Isophot Magnitude (calibrated)", isophot->mag + magOffset);460 } else {461 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_INST", PS_DATA_F32, "Isophot Magnitude (uncalibrated)", isophot->mag);462 }463 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", isophot->magErr);464 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", isophot->rad);465 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", isophot->radErr);466 } else {467 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG", PS_DATA_F32, "Isophot Magnitude", NAN);468 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", NAN);469 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", NAN);470 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", NAN);471 }472 }473 474 // Flux Annuli475 if (doAnnuli) {476 pmSourceAnnuli *annuli = source->extpars->annuli;477 if (annuli) {478 psVector *fluxVal = annuli->flux;479 psVector *fluxErr = annuli->fluxErr;480 psVector *fluxVar = annuli->fluxVar;481 482 for (int j = 0; j < fluxVal->n; j++) {483 char name[32];484 sprintf (name, "FLUX_VAL_R_%02d", j);485 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux value in annulus", fluxVal->data.F32[j]);486 sprintf (name, "FLUX_ERR_R_%02d", j);487 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux error in annulus", fluxErr->data.F32[j]);488 sprintf (name, "FLUX_VAR_R_%02d", j);489 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux stdev in annulus", fluxVar->data.F32[j]);490 } 491 } else {492 for (int j = 0; j < radialBinsLower->n; j++) {493 char name[32];494 sprintf (name, "FLUX_VAL_R_%02d", j);495 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux value in annulus", NAN);496 sprintf (name, "FLUX_ERR_R_%02d", j);497 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux error in annulus", NAN);498 sprintf (name, "FLUX_VAR_R_%02d", j);499 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux stdev in annulus", NAN);500 } 501 }502 }503 504 psArrayAdd (table, 100, row);505 psFree (row);412 // Petrosian measurements 413 // XXX insert header data: petrosian ref radius, flux ratio 414 if (doPetrosian) { 415 pmSourcePetrosianValues *petrosian = source->extpars->petrosian; 416 if (petrosian) { 417 if (calMags) { 418 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_CAL", PS_DATA_F32, "Petrosian Magnitude (calibrated)", petrosian->mag + magOffset); 419 } else { 420 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_INST", PS_DATA_F32, "Petrosian Magnitude (instrumental)", petrosian->mag); 421 } 422 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_ERR", PS_DATA_F32, "Petrosian Magnitude Error", petrosian->magErr); 423 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS", PS_DATA_F32, "Petrosian Radius", petrosian->rad); 424 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS_ERR", PS_DATA_F32, "Petrosian Radius Error", petrosian->radErr); 425 } else { 426 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG", PS_DATA_F32, "Petrosian Magnitude", NAN); 427 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_ERR", PS_DATA_F32, "Petrosian Magnitude Error", NAN); 428 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS", PS_DATA_F32, "Petrosian Radius", NAN); 429 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS_ERR", PS_DATA_F32, "Petrosian Radius Error", NAN); 430 } 431 } 432 433 // Kron measurements 434 if (doKron) { 435 pmSourceKronValues *kron = source->extpars->kron; 436 if (kron) { 437 if (calMags) { 438 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_CAL", PS_DATA_F32, "Kron Magnitude", kron->mag + magOffset); 439 } else { 440 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_INST", PS_DATA_F32, "Kron Magnitude", kron->mag); 441 } 442 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", kron->magErr); 443 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", kron->rad); 444 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", kron->radErr); 445 } else { 446 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG", PS_DATA_F32, "Kron Magnitude", NAN); 447 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", NAN); 448 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", NAN); 449 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", NAN); 450 } 451 } 452 453 // Isophot measurements 454 // XXX insert header data: isophotal level 455 if (doIsophotal) { 456 pmSourceIsophotalValues *isophot = source->extpars->isophot; 457 if (isophot) { 458 if (calMags) { 459 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_CAL", PS_DATA_F32, "Isophot Magnitude (calibrated)", isophot->mag + magOffset); 460 } else { 461 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_INST", PS_DATA_F32, "Isophot Magnitude (uncalibrated)", isophot->mag); 462 } 463 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", isophot->magErr); 464 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", isophot->rad); 465 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", isophot->radErr); 466 } else { 467 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG", PS_DATA_F32, "Isophot Magnitude", NAN); 468 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", NAN); 469 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", NAN); 470 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", NAN); 471 } 472 } 473 474 // Flux Annuli 475 if (doAnnuli) { 476 pmSourceAnnuli *annuli = source->extpars->annuli; 477 if (annuli) { 478 psVector *fluxVal = annuli->flux; 479 psVector *fluxErr = annuli->fluxErr; 480 psVector *fluxVar = annuli->fluxVar; 481 482 for (int j = 0; j < fluxVal->n; j++) { 483 char name[32]; 484 sprintf (name, "FLUX_VAL_R_%02d", j); 485 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux value in annulus", fluxVal->data.F32[j]); 486 sprintf (name, "FLUX_ERR_R_%02d", j); 487 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux error in annulus", fluxErr->data.F32[j]); 488 sprintf (name, "FLUX_VAR_R_%02d", j); 489 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux stdev in annulus", fluxVar->data.F32[j]); 490 } 491 } else { 492 for (int j = 0; j < radialBinsLower->n; j++) { 493 char name[32]; 494 sprintf (name, "FLUX_VAL_R_%02d", j); 495 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux value in annulus", NAN); 496 sprintf (name, "FLUX_ERR_R_%02d", j); 497 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux error in annulus", NAN); 498 sprintf (name, "FLUX_VAR_R_%02d", j); 499 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux stdev in annulus", NAN); 500 } 501 } 502 } 503 504 psArrayAdd (table, 100, row); 505 psFree (row); 506 506 } 507 507 508 508 if (table->n == 0) { 509 psFitsWriteBlank (fits, outhead, extname);510 psFree (outhead);511 psFree (table);512 return true;509 psFitsWriteBlank (fits, outhead, extname); 510 psFree (outhead); 511 psFree (table); 512 return true; 513 513 } 514 514 515 515 psTrace ("pmFPAfile", 5, "writing ext data %s\n", extname); 516 516 if (!psFitsWriteTable (fits, outhead, table, extname)) { 517 psError(PS_ERR_IO, false, "writing ext data %s\n", extname);518 psFree (outhead);519 psFree(table);520 return false;517 psError(PS_ERR_IO, false, "writing ext data %s\n", extname); 518 psFree (outhead); 519 psFree(table); 520 return false; 521 521 } 522 522 psFree (outhead); … … 540 540 pmFPA *fpa = chip->parent; 541 541 if (!chip->toFPA || !fpa->toTPA || !fpa->toSky) { 542 psWarning ("astrometry calibration is missing, no calibrated coords");542 psWarning ("astrometry calibration is missing, no calibrated coords"); 543 543 } 544 544 … … 549 549 float zeropt = psMetadataLookupF32 (&status2, imageHeader, "ZPT_OBS"); 550 550 if (!status1 || !status2 || (exptime == 0.0)) { 551 psWarning ("exposure time or measured zero point not found for a readout, no calibrated mags");551 psWarning ("exposure time or measured zero point not found for a readout, no calibrated mags"); 552 552 } else { 553 magOffset = zeropt + 2.5*log10(exptime);553 magOffset = zeropt + 2.5*log10(exptime); 554 554 } 555 555 … … 566 566 int nParamMax = 0; 567 567 for (int i = 0; i < sources->n; i++) { 568 pmSource *source = sources->data[i];569 if (source->modelFits == NULL) continue;570 for (int j = 0; j < source->modelFits->n; j++) {571 pmModel *model = source->modelFits->data[j];572 assert (model);573 nParamMax = PS_MAX (nParamMax, model->params->n);574 }568 pmSource *source = sources->data[i]; 569 if (source->modelFits == NULL) continue; 570 for (int j = 0; j < source->modelFits->n; j++) { 571 pmModel *model = source->modelFits->data[j]; 572 assert (model); 573 nParamMax = PS_MAX (nParamMax, model->params->n); 574 } 575 575 } 576 576 … … 580 580 for (int i = 0; i < sources->n; i++) { 581 581 582 pmSource *source = sources->data[i];583 584 // XXX if no model fits are saved, write out modelEXT?585 if (source->modelFits == NULL) continue;586 587 // We have multiple sources : need to flag the one used to subtract the light (the 'best' model)588 for (int j = 0; j < source->modelFits->n; j++) {589 590 // choose the convolved EXT model, if available, otherwise the simple one591 pmModel *model = source->modelFits->data[j];592 assert (model);593 594 PAR = model->params->data.F32;595 dPAR = model->dparams->data.F32;596 xPos = PAR[PM_PAR_XPOS];597 yPos = PAR[PM_PAR_YPOS];598 xErr = dPAR[PM_PAR_XPOS];599 yErr = dPAR[PM_PAR_YPOS];600 601 axes = pmPSF_ModelToAxes (PAR, 20.0);602 603 // generate RA,DEC604 psPlane ptCH, ptFP, ptTP;605 psSphere ptSky;606 607 ptCH.x = xPos;608 ptCH.y = yPos;609 if (chip->toFPA && fpa->toTPA && fpa->toSky) {610 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCH);611 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP);612 psDeproject (&ptSky, &ptTP, fpa->toSky);613 } else {614 ptSky.r = NAN;615 ptSky.d = NAN;616 }617 618 row = psMetadataAlloc ();619 620 // XXX we are not writing out the mode (flags) or the type (psf, ext, etc)621 psMetadataAddU32 (row, PS_LIST_TAIL, "IPP_IDET", 0, "IPP detection identifier index", source->seq);622 psMetadataAddF32 (row, PS_LIST_TAIL, "RA_EXT", 0, "EXT model RA (degrees)", ptSky.r);623 psMetadataAddF32 (row, PS_LIST_TAIL, "DEC_EXT", 0, "EXT model DEC (degrees)", ptSky.d);624 psMetadataAddF32 (row, PS_LIST_TAIL, "X_EXT", 0, "EXT model x coordinate", xPos);625 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_EXT", 0, "EXT model y coordinate", yPos);626 psMetadataAddF32 (row, PS_LIST_TAIL, "X_EXT_SIG", 0, "Sigma in EXT x coordinate", xErr);627 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_EXT_SIG", 0, "Sigma in EXT y coordinate", yErr);628 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_CAL_MAG", 0, "EXT fit calibrated magnitude", model->mag + magOffset);629 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG", 0, "EXT fit instrumental magnitude", model->mag);630 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG_SIG", 0, "Sigma of PSF instrumental magnitude", model->magErr);631 632 psMetadataAddF32 (row, PS_LIST_TAIL, "NPARAMS", 0, "number of model parameters", model->params->n);633 psMetadataAddStr (row, PS_LIST_TAIL, "MODEL_TYPE", 0, "name of model", pmModelClassGetName (model->type));634 635 // XXX these should be major and minor, not 'x' and 'y'636 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MAJ", 0, "EXT width in x coordinate", axes.major);637 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MIN", 0, "EXT width in y coordinate", axes.minor);638 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_THETA", 0, "EXT orientation angle", axes.theta);639 640 // write out the other generic parameters641 for (int k = 0; k < nParamMax; k++) {642 if (k == PM_PAR_I0) continue;643 if (k == PM_PAR_SKY) continue;644 if (k == PM_PAR_XPOS) continue;645 if (k == PM_PAR_YPOS) continue;646 if (k == PM_PAR_SXX) continue;647 if (k == PM_PAR_SXY) continue;648 if (k == PM_PAR_SYY) continue;649 650 snprintf (name, 64, "EXT_PAR_%02d", k);651 652 if (k < model->params->n) {653 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "", model->params->data.F32[k]);654 } else {655 psMetadataAddF32 (row, PS_LIST_TAIL, name, PS_DATA_F32, "", NAN);656 }657 }658 659 // XXX other parameters which may be set.660 // XXX flag / value to define the model661 // XXX write out the model type, fit status flags662 663 psArrayAdd (table, 100, row);664 psFree (row);665 }582 pmSource *source = sources->data[i]; 583 584 // XXX if no model fits are saved, write out modelEXT? 585 if (source->modelFits == NULL) continue; 586 587 // We have multiple sources : need to flag the one used to subtract the light (the 'best' model) 588 for (int j = 0; j < source->modelFits->n; j++) { 589 590 // choose the convolved EXT model, if available, otherwise the simple one 591 pmModel *model = source->modelFits->data[j]; 592 assert (model); 593 594 PAR = model->params->data.F32; 595 dPAR = model->dparams->data.F32; 596 xPos = PAR[PM_PAR_XPOS]; 597 yPos = PAR[PM_PAR_YPOS]; 598 xErr = dPAR[PM_PAR_XPOS]; 599 yErr = dPAR[PM_PAR_YPOS]; 600 601 axes = pmPSF_ModelToAxes (PAR, 20.0); 602 603 // generate RA,DEC 604 psPlane ptCH, ptFP, ptTP; 605 psSphere ptSky; 606 607 ptCH.x = xPos; 608 ptCH.y = yPos; 609 if (chip->toFPA && fpa->toTPA && fpa->toSky) { 610 psPlaneTransformApply (&ptFP, chip->toFPA, &ptCH); 611 psPlaneTransformApply (&ptTP, fpa->toTPA, &ptFP); 612 psDeproject (&ptSky, &ptTP, fpa->toSky); 613 } else { 614 ptSky.r = NAN; 615 ptSky.d = NAN; 616 } 617 618 row = psMetadataAlloc (); 619 620 // XXX we are not writing out the mode (flags) or the type (psf, ext, etc) 621 psMetadataAddU32 (row, PS_LIST_TAIL, "IPP_IDET", 0, "IPP detection identifier index", source->seq); 622 psMetadataAddF32 (row, PS_LIST_TAIL, "RA_EXT", 0, "EXT model RA (degrees)", ptSky.r); 623 psMetadataAddF32 (row, PS_LIST_TAIL, "DEC_EXT", 0, "EXT model DEC (degrees)", ptSky.d); 624 psMetadataAddF32 (row, PS_LIST_TAIL, "X_EXT", 0, "EXT model x coordinate", xPos); 625 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_EXT", 0, "EXT model y coordinate", yPos); 626 psMetadataAddF32 (row, PS_LIST_TAIL, "X_EXT_SIG", 0, "Sigma in EXT x coordinate", xErr); 627 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_EXT_SIG", 0, "Sigma in EXT y coordinate", yErr); 628 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_CAL_MAG", 0, "EXT fit calibrated magnitude", model->mag + magOffset); 629 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG", 0, "EXT fit instrumental magnitude", model->mag); 630 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG_SIG", 0, "Sigma of PSF instrumental magnitude", model->magErr); 631 632 psMetadataAddF32 (row, PS_LIST_TAIL, "NPARAMS", 0, "number of model parameters", model->params->n); 633 psMetadataAddStr (row, PS_LIST_TAIL, "MODEL_TYPE", 0, "name of model", pmModelClassGetName (model->type)); 634 635 // XXX these should be major and minor, not 'x' and 'y' 636 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MAJ", 0, "EXT width in x coordinate", axes.major); 637 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MIN", 0, "EXT width in y coordinate", axes.minor); 638 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_THETA", 0, "EXT orientation angle", axes.theta); 639 640 // write out the other generic parameters 641 for (int k = 0; k < nParamMax; k++) { 642 if (k == PM_PAR_I0) continue; 643 if (k == PM_PAR_SKY) continue; 644 if (k == PM_PAR_XPOS) continue; 645 if (k == PM_PAR_YPOS) continue; 646 if (k == PM_PAR_SXX) continue; 647 if (k == PM_PAR_SXY) continue; 648 if (k == PM_PAR_SYY) continue; 649 650 snprintf (name, 64, "EXT_PAR_%02d", k); 651 652 if (k < model->params->n) { 653 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "", model->params->data.F32[k]); 654 } else { 655 psMetadataAddF32 (row, PS_LIST_TAIL, name, PS_DATA_F32, "", NAN); 656 } 657 } 658 659 // XXX other parameters which may be set. 660 // XXX flag / value to define the model 661 // XXX write out the model type, fit status flags 662 663 psArrayAdd (table, 100, row); 664 psFree (row); 665 } 666 666 } 667 667 668 668 if (table->n == 0) { 669 psFitsWriteBlank (fits, outhead, extname);670 psFree (outhead);671 psFree (table);672 return true;669 psFitsWriteBlank (fits, outhead, extname); 670 psFree (outhead); 671 psFree (table); 672 return true; 673 673 } 674 674 675 675 psTrace ("pmFPAfile", 5, "writing ext data %s\n", extname); 676 676 if (!psFitsWriteTable (fits, outhead, table, extname)) { 677 psError(PS_ERR_IO, false, "writing ext data %s\n", extname);678 psFree (outhead);679 psFree(table);680 return false;677 psError(PS_ERR_IO, false, "writing ext data %s\n", extname); 678 psFree (outhead); 679 psFree(table); 680 return false; 681 681 } 682 682 psFree (outhead); -
branches/cnb_branch_20090215/psModules/src/objects/pmSourceIO_PS1_DEV_1.c
r20937 r21536 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $6 * @date $Date: 200 8-12-08 02:51:14$5 * @version $Revision: 1.14.14.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2009-02-19 17:59:50 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 49 49 // XXX how do I generate the source tables which I need to send to PSPS? 50 50 51 bool pmSourcesWrite_PS1_DEV_1 (psFits *fits, psArray *sources, psMetadata *imageHeader,52 psMetadata * tableHeader, char *extname, char *xsrcname)51 bool pmSourcesWrite_PS1_DEV_1 (psFits *fits, psArray *sources, 52 psMetadata *imageHeader, psMetadata *tableHeader, char *extname) 53 53 { 54 54 PS_ASSERT_PTR_NON_NULL(fits, false); … … 73 73 for (i = 0; i < sources->n; i++) { 74 74 pmSource *source = (pmSource *) sources->data[i]; 75 if (source->seq == -1) {76 source->seq = i;77 }75 if (source->seq == -1) { 76 source->seq = i; 77 } 78 78 79 79 // no difference between PSF and non-PSF model … … 87 87 xErr = dPAR[PM_PAR_XPOS]; 88 88 yErr = dPAR[PM_PAR_YPOS]; 89 if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX])) {90 axes = pmPSF_ModelToAxes (PAR, 20.0);91 } else {92 axes.major = NAN;93 axes.minor = NAN;94 axes.theta = NAN;95 }96 chisq = model->chisq;97 98 // need to determine the PSF photometry error: source->errMag is the error on the 'best' model mag.99 errMag = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0];89 if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX])) { 90 axes = pmPSF_ModelToAxes (PAR, 20.0); 91 } else { 92 axes.major = NAN; 93 axes.minor = NAN; 94 axes.theta = NAN; 95 } 96 chisq = model->chisq; 97 98 // need to determine the PSF photometry error: source->errMag is the error on the 'best' model mag. 99 errMag = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0]; 100 100 } else { 101 101 xPos = source->peak->xf; … … 106 106 axes.minor = NAN; 107 107 axes.theta = NAN; 108 chisq = NAN;109 errMag = NAN;108 chisq = NAN; 109 errMag = NAN; 110 110 } 111 111 … … 130 130 psMetadataAdd (row, PS_LIST_TAIL, "EXT_NSIGMA", PS_DATA_F32, "Nsigma deviations from PSF to EXT", source->extNsigma); 131 131 132 // EXT_NSIGMA will be NAN if: 1) contour ellipse is imaginary; 2) source is not133 // subtracted134 135 // CR_NSIGMA will be NAN if: 1) source is not subtracted; 2) source is on the image136 // edge; 3) any pixels in the 3x3 peak region are masked; 137 138 // CR_NSIGMA and 132 // EXT_NSIGMA will be NAN if: 1) contour ellipse is imaginary; 2) source is not 133 // subtracted 134 135 // CR_NSIGMA will be NAN if: 1) source is not subtracted; 2) source is on the image 136 // edge; 3) any pixels in the 3x3 peak region are masked; 137 138 // CR_NSIGMA and 139 139 140 140 // XXX these should be major and minor, not 'x' and 'y' … … 247 247 source->psfMag = psMetadataLookupF32 (&status, row, "PSF_INST_MAG"); 248 248 source->errMag = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG"); 249 PAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN;250 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->errMag : NAN;249 PAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN; 250 dPAR[PM_PAR_I0] = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->errMag : NAN; 251 251 252 252 pmPSF_AxesToModel (PAR, axes); … … 259 259 source->pixWeight = psMetadataLookupF32 (&status, row, "PSF_QF"); 260 260 261 // note that some older versions used PSF_PROBABILITY: this was not well defined.261 // note that some older versions used PSF_PROBABILITY: this was not well defined. 262 262 model->chisq = psMetadataLookupF32 (&status, row, "PSF_CHISQ"); 263 263 source->crNsigma = psMetadataLookupF32 (&status, row, "CR_NSIGMA"); … … 311 311 // we write out all sources, regardless of quality. the source flags tell us the state 312 312 for (int i = 0; i < sources->n; i++) { 313 // skip source if it is not a ext sourc314 // XXX we have two places that extended source parameters are measured:315 // psphotExtendedSources, which measures the aperture-like parameters and (potentially) the psf-convolved extended source models,316 // psphotFitEXT, which does the simple extended source model fit (not psf-convolved)317 // should we require both?318 319 pmSource *source = sources->data[i];320 321 // skip sources without measurements322 if (source->extpars == NULL) continue;323 324 // we require a PSF model fit (ignore the real crud)325 pmModel *model = source->modelPSF;326 if (model == NULL) continue;327 328 // XXX I need to split the extended models from the extended aperture measurements329 PAR = model->params->data.F32;330 dPAR = model->dparams->data.F32;331 xPos = PAR[PM_PAR_XPOS];332 yPos = PAR[PM_PAR_YPOS];333 xErr = dPAR[PM_PAR_XPOS];334 yErr = dPAR[PM_PAR_YPOS];313 // skip source if it is not a ext sourc 314 // XXX we have two places that extended source parameters are measured: 315 // psphotExtendedSources, which measures the aperture-like parameters and (potentially) the psf-convolved extended source models, 316 // psphotFitEXT, which does the simple extended source model fit (not psf-convolved) 317 // should we require both? 318 319 pmSource *source = sources->data[i]; 320 321 // skip sources without measurements 322 if (source->extpars == NULL) continue; 323 324 // we require a PSF model fit (ignore the real crud) 325 pmModel *model = source->modelPSF; 326 if (model == NULL) continue; 327 328 // XXX I need to split the extended models from the extended aperture measurements 329 PAR = model->params->data.F32; 330 dPAR = model->dparams->data.F32; 331 xPos = PAR[PM_PAR_XPOS]; 332 yPos = PAR[PM_PAR_YPOS]; 333 xErr = dPAR[PM_PAR_XPOS]; 334 yErr = dPAR[PM_PAR_YPOS]; 335 335 336 336 row = psMetadataAlloc (); … … 343 343 psMetadataAdd (row, PS_LIST_TAIL, "Y_EXT_SIG", PS_DATA_F32, "Sigma in EXT y coordinate", yErr); 344 344 345 // Petrosian measurements346 // XXX insert header data: petrosian ref radius, flux ratio347 if (doPetrosian) {348 pmSourcePetrosianValues *petrosian = source->extpars->petrosian;349 if (petrosian) {350 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG", PS_DATA_F32, "Petrosian Magnitude", petrosian->mag);351 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_ERR", PS_DATA_F32, "Petrosian Magnitude Error", petrosian->magErr);352 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS", PS_DATA_F32, "Petrosian Radius", petrosian->rad);353 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS_ERR", PS_DATA_F32, "Petrosian Radius Error", petrosian->radErr);354 } else {355 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG", PS_DATA_F32, "Petrosian Magnitude", NAN);356 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_ERR", PS_DATA_F32, "Petrosian Magnitude Error", NAN);357 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS", PS_DATA_F32, "Petrosian Radius", NAN);358 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS_ERR", PS_DATA_F32, "Petrosian Radius Error", NAN);359 }360 } 361 362 // Kron measurements363 if (doKron) {364 pmSourceKronValues *kron = source->extpars->kron;365 if (kron) {366 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG", PS_DATA_F32, "Kron Magnitude", kron->mag);367 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", kron->magErr);368 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", kron->rad);369 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", kron->radErr);370 } else {371 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG", PS_DATA_F32, "Kron Magnitude", NAN);372 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", NAN);373 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", NAN);374 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", NAN);375 }376 }377 378 // Isophot measurements379 // XXX insert header data: isophotal level380 if (doIsophotal) {381 pmSourceIsophotalValues *isophot = source->extpars->isophot;382 if (isophot) {383 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG", PS_DATA_F32, "Isophot Magnitude", isophot->mag);384 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", isophot->magErr);385 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", isophot->rad);386 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", isophot->radErr);387 } else {388 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG", PS_DATA_F32, "Isophot Magnitude", NAN);389 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", NAN);390 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", NAN);391 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", NAN);392 }393 }394 395 // Flux Annuli396 if (doAnnuli) {397 pmSourceAnnuli *annuli = source->extpars->annuli;398 if (annuli) {399 psVector *fluxVal = annuli->flux;400 psVector *fluxErr = annuli->fluxErr;401 psVector *fluxVar = annuli->fluxVar;402 403 for (int j = 0; j < fluxVal->n; j++) {404 char name[32];405 sprintf (name, "FLUX_VAL_R_%02d", j);406 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux value in annulus", fluxVal->data.F32[j]);407 sprintf (name, "FLUX_ERR_R_%02d", j);408 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux error in annulus", fluxErr->data.F32[j]);409 sprintf (name, "FLUX_VAR_R_%02d", j);410 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux stdev in annulus", fluxVar->data.F32[j]);411 } 412 } else {413 for (int j = 0; j < radialBinsLower->n; j++) {414 char name[32];415 sprintf (name, "FLUX_VAL_R_%02d", j);416 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux value in annulus", NAN);417 sprintf (name, "FLUX_ERR_R_%02d", j);418 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux error in annulus", NAN);419 sprintf (name, "FLUX_VAR_R_%02d", j);420 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux stdev in annulus", NAN);421 } 422 }423 }424 425 psArrayAdd (table, 100, row);426 psFree (row);345 // Petrosian measurements 346 // XXX insert header data: petrosian ref radius, flux ratio 347 if (doPetrosian) { 348 pmSourcePetrosianValues *petrosian = source->extpars->petrosian; 349 if (petrosian) { 350 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG", PS_DATA_F32, "Petrosian Magnitude", petrosian->mag); 351 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_ERR", PS_DATA_F32, "Petrosian Magnitude Error", petrosian->magErr); 352 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS", PS_DATA_F32, "Petrosian Radius", petrosian->rad); 353 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS_ERR", PS_DATA_F32, "Petrosian Radius Error", petrosian->radErr); 354 } else { 355 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG", PS_DATA_F32, "Petrosian Magnitude", NAN); 356 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_MAG_ERR", PS_DATA_F32, "Petrosian Magnitude Error", NAN); 357 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS", PS_DATA_F32, "Petrosian Radius", NAN); 358 psMetadataAdd (row, PS_LIST_TAIL, "PETRO_RADIUS_ERR", PS_DATA_F32, "Petrosian Radius Error", NAN); 359 } 360 } 361 362 // Kron measurements 363 if (doKron) { 364 pmSourceKronValues *kron = source->extpars->kron; 365 if (kron) { 366 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG", PS_DATA_F32, "Kron Magnitude", kron->mag); 367 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", kron->magErr); 368 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", kron->rad); 369 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", kron->radErr); 370 } else { 371 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG", PS_DATA_F32, "Kron Magnitude", NAN); 372 psMetadataAdd (row, PS_LIST_TAIL, "KRON_MAG_ERR", PS_DATA_F32, "Kron Magnitude Error", NAN); 373 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS", PS_DATA_F32, "Kron Radius", NAN); 374 psMetadataAdd (row, PS_LIST_TAIL, "KRON_RADIUS_ERR", PS_DATA_F32, "Kron Radius Error", NAN); 375 } 376 } 377 378 // Isophot measurements 379 // XXX insert header data: isophotal level 380 if (doIsophotal) { 381 pmSourceIsophotalValues *isophot = source->extpars->isophot; 382 if (isophot) { 383 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG", PS_DATA_F32, "Isophot Magnitude", isophot->mag); 384 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", isophot->magErr); 385 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", isophot->rad); 386 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", isophot->radErr); 387 } else { 388 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG", PS_DATA_F32, "Isophot Magnitude", NAN); 389 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_MAG_ERR", PS_DATA_F32, "Isophot Magnitude Error", NAN); 390 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS", PS_DATA_F32, "Isophot Radius", NAN); 391 psMetadataAdd (row, PS_LIST_TAIL, "ISOPHOT_RADIUS_ERR", PS_DATA_F32, "Isophot Radius Error", NAN); 392 } 393 } 394 395 // Flux Annuli 396 if (doAnnuli) { 397 pmSourceAnnuli *annuli = source->extpars->annuli; 398 if (annuli) { 399 psVector *fluxVal = annuli->flux; 400 psVector *fluxErr = annuli->fluxErr; 401 psVector *fluxVar = annuli->fluxVar; 402 403 for (int j = 0; j < fluxVal->n; j++) { 404 char name[32]; 405 sprintf (name, "FLUX_VAL_R_%02d", j); 406 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux value in annulus", fluxVal->data.F32[j]); 407 sprintf (name, "FLUX_ERR_R_%02d", j); 408 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux error in annulus", fluxErr->data.F32[j]); 409 sprintf (name, "FLUX_VAR_R_%02d", j); 410 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux stdev in annulus", fluxVar->data.F32[j]); 411 } 412 } else { 413 for (int j = 0; j < radialBinsLower->n; j++) { 414 char name[32]; 415 sprintf (name, "FLUX_VAL_R_%02d", j); 416 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux value in annulus", NAN); 417 sprintf (name, "FLUX_ERR_R_%02d", j); 418 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux error in annulus", NAN); 419 sprintf (name, "FLUX_VAR_R_%02d", j); 420 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "flux stdev in annulus", NAN); 421 } 422 } 423 } 424 425 psArrayAdd (table, 100, row); 426 psFree (row); 427 427 } 428 428 429 429 if (table->n == 0) { 430 psFitsWriteBlank (fits, outhead, extname);431 psFree (outhead);432 psFree (table);433 return true;430 psFitsWriteBlank (fits, outhead, extname); 431 psFree (outhead); 432 psFree (table); 433 return true; 434 434 } 435 435 436 436 psTrace ("pmFPAfile", 5, "writing ext data %s\n", extname); 437 437 if (!psFitsWriteTable (fits, outhead, table, extname)) { 438 psError(PS_ERR_IO, false, "writing ext data %s\n", extname);439 psFree (outhead);440 psFree(table);441 return false;438 psError(PS_ERR_IO, false, "writing ext data %s\n", extname); 439 psFree (outhead); 440 psFree(table); 441 return false; 442 442 } 443 443 psFree (outhead); … … 470 470 int nParamMax = 0; 471 471 for (int i = 0; i < sources->n; i++) { 472 pmSource *source = sources->data[i];473 if (source->modelFits == NULL) continue;474 for (int j = 0; j < source->modelFits->n; j++) {475 pmModel *model = source->modelFits->data[j];476 assert (model);477 nParamMax = PS_MAX (nParamMax, model->params->n);478 }472 pmSource *source = sources->data[i]; 473 if (source->modelFits == NULL) continue; 474 for (int j = 0; j < source->modelFits->n; j++) { 475 pmModel *model = source->modelFits->data[j]; 476 assert (model); 477 nParamMax = PS_MAX (nParamMax, model->params->n); 478 } 479 479 } 480 480 … … 484 484 for (int i = 0; i < sources->n; i++) { 485 485 486 pmSource *source = sources->data[i];487 488 // XXX if no model fits are saved, write out modelEXT?489 if (source->modelFits == NULL) continue;490 491 // We have multiple sources : need to flag the one used to subtract the light (the 'best' model)492 for (int j = 0; j < source->modelFits->n; j++) {493 494 // choose the convolved EXT model, if available, otherwise the simple one495 pmModel *model = source->modelFits->data[j];496 assert (model);497 498 PAR = model->params->data.F32;499 dPAR = model->dparams->data.F32;500 xPos = PAR[PM_PAR_XPOS];501 yPos = PAR[PM_PAR_YPOS];502 xErr = dPAR[PM_PAR_XPOS];503 yErr = dPAR[PM_PAR_YPOS];504 505 axes = pmPSF_ModelToAxes (PAR, 20.0);506 507 row = psMetadataAlloc ();508 509 // XXX we are not writing out the mode (flags) or the type (psf, ext, etc)510 psMetadataAddU32 (row, PS_LIST_TAIL, "IPP_IDET", 0, "IPP detection identifier index", source->seq);511 psMetadataAddF32 (row, PS_LIST_TAIL, "X_EXT", 0, "EXT model x coordinate", xPos);512 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_EXT", 0, "EXT model y coordinate", yPos);513 psMetadataAddF32 (row, PS_LIST_TAIL, "X_EXT_SIG", 0, "Sigma in EXT x coordinate", xErr);514 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_EXT_SIG", 0, "Sigma in EXT y coordinate", yErr);515 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG", 0, "EXT fit instrumental magnitude", model->mag);516 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG_SIG", 0, "Sigma of PSF instrumental magnitude", model->magErr);517 518 psMetadataAddF32 (row, PS_LIST_TAIL, "NPARAMS", 0, "number of model parameters", model->params->n);519 psMetadataAddStr (row, PS_LIST_TAIL, "MODEL_TYPE", 0, "name of model", pmModelClassGetName (model->type));520 521 // XXX these should be major and minor, not 'x' and 'y'522 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MAJ", 0, "EXT width in x coordinate", axes.major);523 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MIN", 0, "EXT width in y coordinate", axes.minor);524 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_THETA", 0, "EXT orientation angle", axes.theta);525 526 // write out the other generic parameters527 for (int k = 0; k < nParamMax; k++) {528 if (k == PM_PAR_I0) continue;529 if (k == PM_PAR_SKY) continue;530 if (k == PM_PAR_XPOS) continue;531 if (k == PM_PAR_YPOS) continue;532 if (k == PM_PAR_SXX) continue;533 if (k == PM_PAR_SXY) continue;534 if (k == PM_PAR_SYY) continue;535 536 snprintf (name, 64, "EXT_PAR_%02d", k);537 538 if (k < model->params->n) {539 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "", model->params->data.F32[k]);540 } else {541 psMetadataAddF32 (row, PS_LIST_TAIL, name, PS_DATA_F32, "", NAN);542 }543 }544 545 // XXX other parameters which may be set.546 // XXX flag / value to define the model547 // XXX write out the model type, fit status flags548 549 psArrayAdd (table, 100, row);550 psFree (row);551 }486 pmSource *source = sources->data[i]; 487 488 // XXX if no model fits are saved, write out modelEXT? 489 if (source->modelFits == NULL) continue; 490 491 // We have multiple sources : need to flag the one used to subtract the light (the 'best' model) 492 for (int j = 0; j < source->modelFits->n; j++) { 493 494 // choose the convolved EXT model, if available, otherwise the simple one 495 pmModel *model = source->modelFits->data[j]; 496 assert (model); 497 498 PAR = model->params->data.F32; 499 dPAR = model->dparams->data.F32; 500 xPos = PAR[PM_PAR_XPOS]; 501 yPos = PAR[PM_PAR_YPOS]; 502 xErr = dPAR[PM_PAR_XPOS]; 503 yErr = dPAR[PM_PAR_YPOS]; 504 505 axes = pmPSF_ModelToAxes (PAR, 20.0); 506 507 row = psMetadataAlloc (); 508 509 // XXX we are not writing out the mode (flags) or the type (psf, ext, etc) 510 psMetadataAddU32 (row, PS_LIST_TAIL, "IPP_IDET", 0, "IPP detection identifier index", source->seq); 511 psMetadataAddF32 (row, PS_LIST_TAIL, "X_EXT", 0, "EXT model x coordinate", xPos); 512 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_EXT", 0, "EXT model y coordinate", yPos); 513 psMetadataAddF32 (row, PS_LIST_TAIL, "X_EXT_SIG", 0, "Sigma in EXT x coordinate", xErr); 514 psMetadataAddF32 (row, PS_LIST_TAIL, "Y_EXT_SIG", 0, "Sigma in EXT y coordinate", yErr); 515 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG", 0, "EXT fit instrumental magnitude", model->mag); 516 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG_SIG", 0, "Sigma of PSF instrumental magnitude", model->magErr); 517 518 psMetadataAddF32 (row, PS_LIST_TAIL, "NPARAMS", 0, "number of model parameters", model->params->n); 519 psMetadataAddStr (row, PS_LIST_TAIL, "MODEL_TYPE", 0, "name of model", pmModelClassGetName (model->type)); 520 521 // XXX these should be major and minor, not 'x' and 'y' 522 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MAJ", 0, "EXT width in x coordinate", axes.major); 523 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MIN", 0, "EXT width in y coordinate", axes.minor); 524 psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_THETA", 0, "EXT orientation angle", axes.theta); 525 526 // write out the other generic parameters 527 for (int k = 0; k < nParamMax; k++) { 528 if (k == PM_PAR_I0) continue; 529 if (k == PM_PAR_SKY) continue; 530 if (k == PM_PAR_XPOS) continue; 531 if (k == PM_PAR_YPOS) continue; 532 if (k == PM_PAR_SXX) continue; 533 if (k == PM_PAR_SXY) continue; 534 if (k == PM_PAR_SYY) continue; 535 536 snprintf (name, 64, "EXT_PAR_%02d", k); 537 538 if (k < model->params->n) { 539 psMetadataAdd (row, PS_LIST_TAIL, name, PS_DATA_F32, "", model->params->data.F32[k]); 540 } else { 541 psMetadataAddF32 (row, PS_LIST_TAIL, name, PS_DATA_F32, "", NAN); 542 } 543 } 544 545 // XXX other parameters which may be set. 546 // XXX flag / value to define the model 547 // XXX write out the model type, fit status flags 548 549 psArrayAdd (table, 100, row); 550 psFree (row); 551 } 552 552 } 553 553 554 554 if (table->n == 0) { 555 psFitsWriteBlank (fits, outhead, extname);556 psFree (outhead);557 psFree (table);558 return true;555 psFitsWriteBlank (fits, outhead, extname); 556 psFree (outhead); 557 psFree (table); 558 return true; 559 559 } 560 560 561 561 psTrace ("pmFPAfile", 5, "writing ext data %s\n", extname); 562 562 if (!psFitsWriteTable (fits, outhead, table, extname)) { 563 psError(PS_ERR_IO, false, "writing ext data %s\n", extname);564 psFree (outhead);565 psFree(table);566 return false;563 psError(PS_ERR_IO, false, "writing ext data %s\n", extname); 564 psFree (outhead); 565 psFree(table); 566 return false; 567 567 } 568 568 psFree (outhead); -
branches/cnb_branch_20090215/psModules/src/objects/pmSourcePhotometry.c
r21363 r21536 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.49 $ $Name: not supported by cvs2svn $6 * @date $Date: 2009-02- 06 02:31:25$5 * @version $Revision: 1.49.4.1 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2009-02-19 17:59:50 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 145 145 // measure the contribution of included pixels 146 146 if (mode & PM_SOURCE_PHOT_WEIGHT) { 147 pmSourcePixelWeight (&source->pixWeight, model, source-> pixels, source->maskObj, maskVal);147 pmSourcePixelWeight (&source->pixWeight, model, source->maskObj, maskVal); 148 148 } 149 149 … … 164 164 // XXX full model or just analytical? 165 165 // XXX use pmSourceAdd instead? 166 if (source-> mode & PM_SOURCE_MODE_SUBTRACTED) {166 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) { 167 167 pmModelAdd (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL, maskVal); 168 168 } … … 170 170 // if we are measuring aperture photometry and applying the growth correction, 171 171 // we need to shift the flux in the selected pixels (but not the mask) 172 // psImageShift ();173 172 psImage *flux = NULL, *mask = NULL; // Star flux and mask images, to photometer 174 173 if (mode & PM_SOURCE_PHOT_INTERP) { … … 186 185 } 187 186 188 // XXX this is test code to verify the shift is doing the right thing (seems to be)189 # if (0)190 // measure centroid of unshifted gaussian (should be 16.0,16.0)191 {192 psImage *image = source->pixels;193 float xo = 0.0;194 float yo = 0.0;195 float xo2 = 0.0;196 float yo2 = 0.0;197 float no = 0.0;198 for (int j = 0; j < image->numRows; j++)199 {200 for (int i = 0; i < image->numCols; i++) {201 xo += i*image->data.F32[j][i];202 yo += j*image->data.F32[j][i];203 xo2 += i*i*image->data.F32[j][i];204 yo2 += j*j*image->data.F32[j][i];205 no += image->data.F32[j][i];206 }207 }208 xo /= no;209 yo /= no;210 xo2 = sqrt (xo2/no - xo*xo);211 yo2 = sqrt (yo2/no - yo*yo);212 fprintf (stderr, "pre-shift centroid: %f,%f, sigma: %f,%f: flux: %f\n", xo, yo, xo2, yo2, no);213 }214 215 // measure centroid of unshifted gaussian (should be 16.0,16.0)216 {217 psImage *image = flux;218 float xo = 0.0;219 float yo = 0.0;220 float xo2 = 0.0;221 float yo2 = 0.0;222 float no = 0.0;223 for (int j = 0; j < image->numRows; j++)224 {225 for (int i = 0; i < image->numCols; i++) {226 xo += i*image->data.F32[j][i];227 yo += j*image->data.F32[j][i];228 xo2 += i*i*image->data.F32[j][i];229 yo2 += j*j*image->data.F32[j][i];230 no += image->data.F32[j][i];231 }232 }233 xo /= no;234 yo /= no;235 xo2 = sqrt (xo2/no - xo*xo);236 yo2 = sqrt (yo2/no - yo*yo);237 fprintf (stderr, "pre-shift centroid: %f,%f, sigma: %f,%f: flux: %f\n", xo, yo, xo2, yo2, no);238 }239 # endif240 241 187 } else { 242 188 flux = source->pixels; … … 269 215 // if source was originally subtracted, re-subtract object, leave local sky 270 216 // XXX replace with pmSourceSub... 271 if (source-> mode & PM_SOURCE_MODE_SUBTRACTED) {217 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) { 272 218 pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL, maskVal); 273 219 } … … 344 290 345 291 // return source aperture magnitude 346 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage * image, psImage *mask, psImageMaskType maskVal)292 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *mask, psImageMaskType maskVal) 347 293 { 348 294 PS_ASSERT_PTR_NON_NULL(pixWeight, false); 349 PS_ASSERT_PTR_NON_NULL(image, false);350 295 PS_ASSERT_PTR_NON_NULL(mask, false); 351 296 PS_ASSERT_PTR_NON_NULL(model, false); … … 377 322 Yo = params->data.F32[PM_PAR_YPOS]; 378 323 379 dX = Xo - image->col0;380 dP = image->numCols - dX;324 dX = Xo - mask->col0; 325 dP = mask->numCols - dX; 381 326 DX = PS_MAX(dX, dP); 382 NX = image->numCols;383 384 dY = Yo - image->row0;385 dP = image->numRows - dY;327 NX = mask->numCols; 328 329 dY = Yo - mask->row0; 330 dP = mask->numRows - dY; 386 331 DY = PS_MAX(dY, dP); 387 NY = image->numRows;332 NY = mask->numRows; 388 333 389 334 // measure modelSum and validSum. this function is applied to a sources' subimage. the … … 612 557 # endif 613 558 559 // determine chisq, etc for linear normalization-only fit 614 560 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *variance, 615 561 psImageMaskType maskVal) … … 632 578 } 633 579 } 580 model->nPix = Npix; 634 581 model->nDOF = Npix - 1; 635 582 model->chisq = dC; … … 817 764 } 818 765 766 // XXX this is test code to verify the shift is doing the right thing (seems to be) 767 # if (0) 768 // measure centroid of unshifted gaussian (should be 16.0,16.0) 769 { 770 psImage *image = source->pixels; 771 float xo = 0.0; 772 float yo = 0.0; 773 float xo2 = 0.0; 774 float yo2 = 0.0; 775 float no = 0.0; 776 for (int j = 0; j < image->numRows; j++) 777 { 778 for (int i = 0; i < image->numCols; i++) { 779 xo += i*image->data.F32[j][i]; 780 yo += j*image->data.F32[j][i]; 781 xo2 += i*i*image->data.F32[j][i]; 782 yo2 += j*j*image->data.F32[j][i]; 783 no += image->data.F32[j][i]; 784 } 785 } 786 xo /= no; 787 yo /= no; 788 xo2 = sqrt (xo2/no - xo*xo); 789 yo2 = sqrt (yo2/no - yo*yo); 790 fprintf (stderr, "pre-shift centroid: %f,%f, sigma: %f,%f: flux: %f\n", xo, yo, xo2, yo2, no); 791 } 792 793 // measure centroid of unshifted gaussian (should be 16.0,16.0) 794 { 795 psImage *image = flux; 796 float xo = 0.0; 797 float yo = 0.0; 798 float xo2 = 0.0; 799 float yo2 = 0.0; 800 float no = 0.0; 801 for (int j = 0; j < image->numRows; j++) 802 { 803 for (int i = 0; i < image->numCols; i++) { 804 xo += i*image->data.F32[j][i]; 805 yo += j*image->data.F32[j][i]; 806 xo2 += i*i*image->data.F32[j][i]; 807 yo2 += j*j*image->data.F32[j][i]; 808 no += image->data.F32[j][i]; 809 } 810 } 811 xo /= no; 812 yo /= no; 813 xo2 = sqrt (xo2/no - xo*xo); 814 yo2 = sqrt (yo2/no - yo*yo); 815 fprintf (stderr, "pre-shift centroid: %f,%f, sigma: %f,%f: flux: %f\n", xo, yo, xo2, yo2, no); 816 } 817 # endif -
branches/cnb_branch_20090215/psModules/src/objects/pmSourcePhotometry.h
r21183 r21536 4 4 * @author EAM, IfA; GLG, MHPCC 5 5 * 6 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $7 * @date $Date: 2009-0 1-27 06:39:38$6 * @version $Revision: 1.12.8.1 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2009-02-19 17:59:50 $ 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 9 9 */ … … 46 46 psImage *image, ///< image pixels to be used 47 47 psImage *mask, ///< mask of pixels to ignore 48 psImageMaskType maskVal ///< Value to mask48 psImageMaskType maskVal ///< Value to mask 49 49 ); 50 50 51 51 bool pmSourceMagnitudesInit (psMetadata *config); 52 52 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psImageMaskType maskVal); 53 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage * image, psImage *mask, psImageMaskType maskVal);53 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *mask, psImageMaskType maskVal); 54 54 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, psImageMaskType maskVal); 55 55 -
branches/cnb_branch_20090215/psModules/src/objects/pmSourceVisual.c
r21183 r21536 9 9 # if (HAVE_KAPA) 10 10 # include <kapa.h> 11 #include "pmVisual.h" 11 12 12 13 // functions used to visualize the analysis as it goes 13 14 // these are invoked by the -visual options 14 15 15 static bool isVisual = false;16 16 static int kapa1 = -1; 17 17 // static int kapa2 = -1; … … 20 20 bool pmSourcePlotPoints3D (int myKapa, Graphdata *graphdata, psVector *xn, psVector *yn, psVector *zn, float theta, float phi); 21 21 22 bool pmSourceSetVisual (bool mode) {23 24 isVisual = mode;25 return true;26 }27 22 28 23 bool pmSourceVisualPSFModelResid (pmTrend2D *trend, psVector *x, psVector *y, psVector *param, psVector *mask) { 29 24 30 KapaSection section; // put the positive profile in one and the residuals in another? 25 KapaSection section; // put the positive profile in one and the residuals in another? 31 26 32 27 Graphdata graphdata; 33 28 34 if (! isVisual) return true;29 if (!pmVisualIsVisual()) return true; 35 30 36 31 if (kapa1 == -1) { 37 32 kapa1 = KapaOpenNamedSocket ("kapa", "pmSource:plots"); 38 if (kapa1 == -1) {39 fprintf (stderr, "failure to open kapa; visual mode disabled\n");40 isVisual = false;41 return false;42 }43 } 33 if (kapa1 == -1) { 34 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 35 pmVisualSetVisual(false); 36 return false; 37 } 38 } 44 39 45 40 KapaClearPlots (kapa1); … … 55 50 56 51 for (int i = 0; i < x->n; i++) { 57 model->data.F32[i] = pmTrend2DEval (trend, x->data.F32[i], y->data.F32[i]);58 resid->data.F32[i] = param->data.F32[i] - model->data.F32[i];59 if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;60 min = PS_MIN (min, resid->data.F32[i]);61 max = PS_MAX (max, resid->data.F32[i]);62 Min = PS_MIN (min, param->data.F32[i]);63 Max = PS_MAX (max, param->data.F32[i]);52 model->data.F32[i] = pmTrend2DEval (trend, x->data.F32[i], y->data.F32[i]); 53 resid->data.F32[i] = param->data.F32[i] - model->data.F32[i]; 54 if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue; 55 min = PS_MIN (min, resid->data.F32[i]); 56 max = PS_MAX (max, resid->data.F32[i]); 57 Min = PS_MIN (min, param->data.F32[i]); 58 Max = PS_MAX (max, param->data.F32[i]); 64 59 } 65 60 … … 70 65 psVector *Fn = psVectorAlloc (x->n, PS_TYPE_F32); 71 66 for (int i = 0; i < x->n; i++) { 72 xn->data.F32[i] = x->data.F32[i] / 5000.0;73 yn->data.F32[i] = y->data.F32[i] / 5000.0;74 zn->data.F32[i] = (resid->data.F32[i] - min) / (max - min);75 Zn->data.F32[i] = (param->data.F32[i] - Min) / (Max - Min);76 Fn->data.F32[i] = (model->data.F32[i] - Min) / (Max - Min);67 xn->data.F32[i] = x->data.F32[i] / 5000.0; 68 yn->data.F32[i] = y->data.F32[i] / 5000.0; 69 zn->data.F32[i] = (resid->data.F32[i] - min) / (max - min); 70 Zn->data.F32[i] = (param->data.F32[i] - Min) / (Max - Min); 71 Fn->data.F32[i] = (model->data.F32[i] - Min) / (Max - Min); 77 72 } 78 73 … … 155 150 fprintf (stdout, "[c]ontinue? "); 156 151 if (!fgets(key, 8, stdin)) { 157 psWarning("Unable to read option");152 psWarning("Unable to read option"); 158 153 } 159 154 return true; … … 173 168 174 169 for (int i = 0; i < xn->n; i++) { 175 xv->data.F32[2*i+0] = +xn->data.F32[i]*cos(theta) + yn->data.F32[i]*sin(theta)*cos(phi) + zn->data.F32[i]*sin(theta)*sin(phi);176 yv->data.F32[2*i+0] = -xn->data.F32[i]*sin(theta) + yn->data.F32[i]*cos(theta)*cos(phi) + zn->data.F32[i]*cos(theta)*sin(phi);177 zv->data.F32[2*i+0] = -yn->data.F32[i]*sin(phi) + zn->data.F32[i]*cos(phi);178 xv->data.F32[2*i+1] = +xn->data.F32[i]*cos(theta) + yn->data.F32[i]*sin(theta)*cos(phi);179 yv->data.F32[2*i+1] = -xn->data.F32[i]*sin(theta) + yn->data.F32[i]*cos(theta)*cos(phi);180 zv->data.F32[2*i+1] = -yn->data.F32[i]*sin(phi);181 graphdata->xmin = PS_MIN(graphdata->xmin, xv->data.F32[2*i+0]);182 graphdata->xmax = PS_MAX(graphdata->xmax, xv->data.F32[2*i+0]);183 graphdata->ymin = PS_MIN(graphdata->ymin, zv->data.F32[2*i+0]);184 graphdata->ymax = PS_MAX(graphdata->ymax, zv->data.F32[2*i+0]);185 graphdata->xmin = PS_MIN(graphdata->xmin, xv->data.F32[2*i+1]);186 graphdata->xmax = PS_MAX(graphdata->xmax, xv->data.F32[2*i+1]);187 graphdata->ymin = PS_MIN(graphdata->ymin, zv->data.F32[2*i+1]);188 graphdata->ymax = PS_MAX(graphdata->ymax, zv->data.F32[2*i+1]);170 xv->data.F32[2*i+0] = +xn->data.F32[i]*cos(theta) + yn->data.F32[i]*sin(theta)*cos(phi) + zn->data.F32[i]*sin(theta)*sin(phi); 171 yv->data.F32[2*i+0] = -xn->data.F32[i]*sin(theta) + yn->data.F32[i]*cos(theta)*cos(phi) + zn->data.F32[i]*cos(theta)*sin(phi); 172 zv->data.F32[2*i+0] = -yn->data.F32[i]*sin(phi) + zn->data.F32[i]*cos(phi); 173 xv->data.F32[2*i+1] = +xn->data.F32[i]*cos(theta) + yn->data.F32[i]*sin(theta)*cos(phi); 174 yv->data.F32[2*i+1] = -xn->data.F32[i]*sin(theta) + yn->data.F32[i]*cos(theta)*cos(phi); 175 zv->data.F32[2*i+1] = -yn->data.F32[i]*sin(phi); 176 graphdata->xmin = PS_MIN(graphdata->xmin, xv->data.F32[2*i+0]); 177 graphdata->xmax = PS_MAX(graphdata->xmax, xv->data.F32[2*i+0]); 178 graphdata->ymin = PS_MIN(graphdata->ymin, zv->data.F32[2*i+0]); 179 graphdata->ymax = PS_MAX(graphdata->ymax, zv->data.F32[2*i+0]); 180 graphdata->xmin = PS_MIN(graphdata->xmin, xv->data.F32[2*i+1]); 181 graphdata->xmax = PS_MAX(graphdata->xmax, xv->data.F32[2*i+1]); 182 graphdata->ymin = PS_MIN(graphdata->ymin, zv->data.F32[2*i+1]); 183 graphdata->ymax = PS_MAX(graphdata->ymax, zv->data.F32[2*i+1]); 189 184 } 190 185 xv->n = xn->n; -
branches/cnb_branch_20090215/psModules/src/objects/pmSourceVisual.h
r20582 r21536 1 1 /* @file pmKapaPlots.h 2 * @brief functions to make plots with the external program 'kapa' 2 * @brief functions to make plots with the external program 'kapa' 3 3 * 4 4 * @author EAM, IfA 5 5 * 6 * @version $Revision: 1.1 $ $Name: not supported by cvs2svn $7 * @date $Date: 200 8-11-08 01:52:34$6 * @version $Revision: 1.1.16.1 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2009-02-19 17:59:50 $ 8 8 * Copyright 2006 Institute for Astronomy, University of Hawaii 9 9 */ … … 15 15 /// @{ 16 16 17 bool pmSourceSetVisual (bool mode);18 17 bool pmSourceVisualPSFModelResid (pmTrend2D *trend, psVector *x, psVector *y, psVector *param, psVector *mask); 19 18 -
branches/cnb_branch_20090215/psastro/src/psastroArguments.c
r21422 r21536 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 09 21:25:34$8 * @version $Revision: 1.34.2.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:50 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ … … 100 100 if ((N = psArgumentGet (argc, argv, "-visual"))) { 101 101 psArgumentRemove (N, &argc, argv); 102 pm AstromSetVisual (true);102 pmVisualSetVisual (true); 103 103 } 104 104 -
branches/cnb_branch_20090215/psastro/src/psastroCleanup.c
r21422 r21536 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 09 21:25:34$8 * @version $Revision: 1.8.2.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:50 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ … … 16 16 17 17 psFree (config); 18 pm AstromVisualClose ();18 pmVisualClose (); 19 19 20 20 psTimerStop (); -
branches/cnb_branch_20090215/psconfig/tagsets/ipp-2.7.perl
r21405 r21536 3 3 00 Module::Build Module-Build-0.2806.tar.gz 0.2806 4 4 01 ExtUtils::MakeMaker ExtUtils-MakeMaker-6.31.tar.gz 0 5 02 Params::Validate Params-Validate-0.87-eam .tar.gz0.775 02 Params::Validate Params-Validate-0.87-eam-v1.tar.gz 0.77 6 6 # 02 Apache::Test Apache-Test-1.29.tar.gz 1.29 7 7 03 DateTime::TimeZone DateTime-TimeZone-0.59.tar.gz 0 -
branches/cnb_branch_20090215/psphot/src/psphot.h
r21392 r21536 167 167 168 168 // psphotVisual functions 169 bool psphotSetVisual (bool mode);170 169 bool psphotVisualShowImage (pmReadout *readout); 171 170 bool psphotVisualShowBackground (pmConfig *config, const pmFPAview *view, pmReadout *readout); -
branches/cnb_branch_20090215/psphot/src/psphotAddNoise.c
r21183 r21536 50 50 51 51 // skip sources which were not subtracted 52 if (!(source-> mode & PM_SOURCE_MODE_SUBTRACTED)) continue;52 if (!(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED)) continue; 53 53 54 54 // select appropriate model -
branches/cnb_branch_20090215/psphot/src/psphotApResid.c
r21359 r21536 1 1 # include "psphotInternal.h" 2 3 bool psphotApResidMags_Unthreaded (int *nskip, int *nfail, psArray *sources, pmPSF *psf, pmSourcePhotometryMode photMode, psImageMaskType maskVal);4 2 5 3 # define SKIPSTAR(MSG) { psTrace ("psphot", 3, "invalid : %s", MSG); continue; } … … 95 93 for (int j = 0; j < cells->n; j++) { 96 94 97 if (nThreads) {98 // allocate a job -- if threads are not defined, this just runs the job99 psThreadJob *job = psThreadJobAlloc ("PSPHOT_APRESID_MAGS"); 100 101 psArrayAdd(job->args, 1, cells->data[j]); // sources102 psArrayAdd(job->args, 1, psf);103 PS_ARRAY_ADD_SCALAR(job->args, photMode, PS_TYPE_S32);104 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 105 106 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nskip107 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail 108 109 if (!psThreadJobAddPending(job)) {110 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");111 psFree (job);112 return false;113 }114 psFree(job); 115 } else { 95 // allocate a job -- if threads are not defined, this just runs the job 96 psThreadJob *job = psThreadJobAlloc ("PSPHOT_APRESID_MAGS"); 97 98 psArrayAdd(job->args, 1, cells->data[j]); // sources 99 psArrayAdd(job->args, 1, psf); 100 PS_ARRAY_ADD_SCALAR(job->args, photMode, PS_TYPE_S32); 101 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 102 103 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nskip 104 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail 105 106 if (!psThreadJobAddPending(job)) { 107 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 108 psFree (job); 109 return false; 110 } 111 psFree(job); 112 113 # if (0) 116 114 int nskip = 0; 117 115 int nfail = 0; … … 123 121 Nskip += nskip; 124 122 Nfail += nfail; 125 } 123 # endif 126 124 127 125 } 128 126 129 if (nThreads) { 130 // wait for the threads to finish and manage results 131 if (!psThreadPoolWait (false)) { 132 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 133 return false; 127 // wait for the threads to finish and manage results 128 if (!psThreadPoolWait (false)) { 129 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 130 return false; 131 } 132 133 // we have only supplied one type of job, so we can assume the types here 134 psThreadJob *job = NULL; 135 while ((job = psThreadJobGetDone()) != NULL) { 136 if (job->args->n < 1) { 137 fprintf (stderr, "error with job\n"); 138 } else { 139 psScalar *scalar = NULL; 140 scalar = job->args->data[4]; 141 Nskip += scalar->data.S32; 142 scalar = job->args->data[5]; 143 Nfail += scalar->data.S32; 134 144 } 135 136 // we have only supplied one type of job, so we can assume the types here 137 psThreadJob *job = NULL; 138 while ((job = psThreadJobGetDone()) != NULL) { 139 if (job->args->n < 1) { 140 fprintf (stderr, "error with job\n"); 141 } else { 142 psScalar *scalar = NULL; 143 scalar = job->args->data[4]; 144 Nskip += scalar->data.S32; 145 scalar = job->args->data[5]; 146 Nfail += scalar->data.S32; 147 } 148 psFree(job); 149 } 145 psFree(job); 150 146 } 151 147 } … … 497 493 continue; 498 494 } 495 source->mode |= PM_SOURCE_MODE_AP_MAGS; 499 496 } 500 497 … … 509 506 } 510 507 508 # if (0) 511 509 bool psphotApResidMags_Unthreaded (int *nskip, int *nfail, psArray *sources, pmPSF *psf, pmSourcePhotometryMode photMode, psImageMaskType maskVal) { 512 510 … … 542 540 return true; 543 541 } 542 # endif -
branches/cnb_branch_20090215/psphot/src/psphotArguments.c
r21458 r21536 82 82 if ((N = psArgumentGet (argc, argv, "-visual"))) { 83 83 psArgumentRemove (N, &argc, argv); 84 psphotSetVisual (true); 85 // pmSourceSetVisual (true); 84 pmVisualSetVisual(true); 86 85 } 87 86 -
branches/cnb_branch_20090215/psphot/src/psphotBlendFit.c
r21366 r21536 1 1 # include "psphotInternal.h" 2 3 bool psphotBlendFit_Unthreaded (int *nfit, int *npsf, int *next, int *nfail, pmReadout *readout, psMetadata *recipe, psArray *sources, pmPSF *psf, psArray *newSources);4 2 5 3 // XXX I don't like this name … … 62 60 for (int j = 0; j < cells->n; j++) { 63 61 64 if (nThreads) { 65 // allocate a job -- if threads are not defined, this just runs the job 66 psThreadJob *job = psThreadJobAlloc ("PSPHOT_BLEND_FIT"); 67 psArray *newSources = psArrayAllocEmpty(16); 68 69 psArrayAdd(job->args, 1, readout); 70 psArrayAdd(job->args, 1, recipe); 71 psArrayAdd(job->args, 1, cells->data[j]); // sources 72 psArrayAdd(job->args, 1, psf); 73 psArrayAdd(job->args, 1, newSources); // return for new sources 74 psFree (newSources); 75 76 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfit 77 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Npsf 78 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Next 79 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail 80 81 if (!psThreadJobAddPending(job)) { 82 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 83 psFree (job); 84 return NULL; 85 } 86 psFree(job); 87 } else { 62 // allocate a job -- if threads are not defined, this just runs the job 63 psThreadJob *job = psThreadJobAlloc ("PSPHOT_BLEND_FIT"); 64 psArray *newSources = psArrayAllocEmpty(16); 65 66 psArrayAdd(job->args, 1, readout); 67 psArrayAdd(job->args, 1, recipe); 68 psArrayAdd(job->args, 1, cells->data[j]); // sources 69 psArrayAdd(job->args, 1, psf); 70 psArrayAdd(job->args, 1, newSources); // return for new sources 71 psFree (newSources); 72 73 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfit 74 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Npsf 75 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Next 76 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail 77 78 if (!psThreadJobAddPending(job)) { 79 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 80 psFree (job); 81 return NULL; 82 } 83 psFree(job); 84 85 # if (0) 86 { 88 87 int nfit = 0; 89 88 int npsf = 0; … … 107 106 psFree (newSources); 108 107 } 109 } 110 111 if (nThreads) { 112 // wait for the threads to finish and manage results 113 if (!psThreadPoolWait (false)) { 114 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 115 return NULL; 116 } 117 118 // we have only supplied one type of job, so we can assume the types here 119 psThreadJob *job = NULL; 120 while ((job = psThreadJobGetDone()) != NULL) { 121 if (job->args->n < 1) { 122 fprintf (stderr, "error with job\n"); 123 } else { 124 psScalar *scalar = NULL; 125 scalar = job->args->data[5]; 126 Nfit += scalar->data.S32; 127 scalar = job->args->data[6]; 128 Npsf += scalar->data.S32; 129 scalar = job->args->data[7]; 130 Next += scalar->data.S32; 131 scalar = job->args->data[8]; 132 Nfail += scalar->data.S32; 133 134 // add these back onto sources 135 psArray *newSources = job->args->data[4]; 136 for (int j = 0; j < newSources->n; j++) { 137 psArrayAdd (sources, 16, newSources->data[j]); 138 } 139 } 140 psFree(job); 141 } 142 } 108 # endif 109 } 110 111 // wait for the threads to finish and manage results 112 if (!psThreadPoolWait (false)) { 113 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 114 return NULL; 115 } 116 117 // we have only supplied one type of job, so we can assume the types here 118 psThreadJob *job = NULL; 119 while ((job = psThreadJobGetDone()) != NULL) { 120 if (job->args->n < 1) { 121 fprintf (stderr, "error with job\n"); 122 } else { 123 psScalar *scalar = NULL; 124 scalar = job->args->data[5]; 125 Nfit += scalar->data.S32; 126 scalar = job->args->data[6]; 127 Npsf += scalar->data.S32; 128 scalar = job->args->data[7]; 129 Next += scalar->data.S32; 130 scalar = job->args->data[8]; 131 Nfail += scalar->data.S32; 132 133 // add these back onto sources 134 psArray *newSources = job->args->data[4]; 135 for (int j = 0; j < newSources->n; j++) { 136 psArrayAdd (sources, 16, newSources->data[j]); 137 } 138 } 139 psFree(job); 140 } 143 141 } 144 142 psFree (cellGroups); … … 225 223 226 224 // replace object in image 227 if (source->mode & PM_SOURCE_MODE_SUBTRACTED) { 225 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) { 226 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 227 } 228 Nfit ++; 229 230 // try fitting PSFs or extended sources depending on source->mode 231 // these functions subtract the resulting fitted source 232 if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) { 233 if (psphotFitBlob (readout, source, newSources, psf, maskVal, markVal)) { 234 source->type = PM_SOURCE_TYPE_EXTENDED; 235 psTrace ("psphot", 5, "source at %7.1f, %7.1f is ext", source->peak->xf, source->peak->yf); 236 Next ++; 237 source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT; 238 continue; 239 } 240 } else { 241 if (psphotFitBlend (readout, source, psf, maskVal, markVal)) { 242 source->type = PM_SOURCE_TYPE_STAR; 243 psTrace ("psphot", 5, "source at %7.1f, %7.1f is psf", source->peak->xf, source->peak->yf); 244 Npsf ++; 245 source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT; 246 continue; 247 } 248 } 249 250 psTrace ("psphot", 5, "source at %7.1f, %7.1f failed", source->peak->xf, source->peak->yf); 251 Nfail ++; 252 253 // re-subtract the object, leave local sky 254 pmSourceCacheModel (source, maskVal); 255 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 256 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 257 } 258 259 // change the value of a scalar on the array (wrap this and put it in psArray.h) 260 scalar = job->args->data[5]; 261 scalar->data.S32 = Nfit; 262 263 scalar = job->args->data[6]; 264 scalar->data.S32 = Npsf; 265 266 scalar = job->args->data[7]; 267 scalar->data.S32 = Next; 268 269 scalar = job->args->data[8]; 270 scalar->data.S32 = Nfail; 271 272 return true; 273 } 274 275 # if (0) 276 bool psphotBlendFit_Unthreaded (int *nfit, int *npsf, int *next, int *nfail, pmReadout *readout, psMetadata *recipe, psArray *sources, pmPSF *psf, psArray *newSources) { 277 278 bool status = false; 279 int Nfit = 0; 280 int Npsf = 0; 281 int Next = 0; 282 int Nfail = 0; 283 284 // bit-masks to test for good/bad pixels 285 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); 286 assert (maskVal); 287 288 // bit-mask to mark pixels not used in analysis 289 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); 290 assert (markVal); 291 292 // maskVal is used to test for rejected pixels, and must include markVal 293 maskVal |= markVal; 294 295 // S/N limit to perform full non-linear fits 296 float FIT_SN_LIM = psMetadataLookupF32 (&status, recipe, "FULL_FIT_SN_LIM"); 297 298 // option to limit analysis to a specific region 299 char *region = psMetadataLookupStr (&status, recipe, "ANALYSIS_REGION"); 300 psRegion AnalysisRegion = psRegionForImage (readout->image, psRegionFromString (region)); 301 if (psRegionIsNaN (AnalysisRegion)) psAbort("analysis region mis-defined"); 302 303 for (int i = 0; i < sources->n; i++) { 304 pmSource *source = sources->data[i]; 305 306 // skip non-astronomical objects (very likely defects) 307 if (source->mode & PM_SOURCE_MODE_BLEND) continue; 308 if (source->mode & PM_SOURCE_MODE_CR_LIMIT) continue; 309 if (source->type == PM_SOURCE_TYPE_DEFECT) continue; 310 if (source->type == PM_SOURCE_TYPE_SATURATED) continue; 311 312 // skip DBL second sources (ie, added by psphotFitBlob) 313 if (source->mode & PM_SOURCE_MODE_PAIR) continue; 314 315 // limit selection to some SN limit 316 if (source->peak->SN < FIT_SN_LIM) continue; 317 318 // exclude sources outside optional analysis region 319 if (source->peak->xf < AnalysisRegion.x0) continue; 320 if (source->peak->yf < AnalysisRegion.y0) continue; 321 if (source->peak->xf > AnalysisRegion.x1) continue; 322 if (source->peak->yf > AnalysisRegion.y1) continue; 323 324 // if model is NULL, we don't have a starting guess 325 if (source->modelPSF == NULL) continue; 326 327 // skip sources which are insignificant flux? 328 // XXX this is somewhat ad-hoc 329 if (source->modelPSF->params->data.F32[1] < 0.1) { 330 psTrace ("psphot", 5, "skipping near-zero source: %f, %f : %f\n", 331 source->modelPSF->params->data.F32[1], 332 source->modelPSF->params->data.F32[2], 333 source->modelPSF->params->data.F32[3]); 334 continue; 335 } 336 337 // replace object in image 338 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) { 228 339 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 229 340 } … … 254 365 pmSourceCacheModel (source, maskVal); 255 366 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 256 source->mode |= PM_SOURCE_MODE_SUBTRACTED; 257 } 258 259 // change the value of a scalar on the array (wrap this and put it in psArray.h) 260 scalar = job->args->data[5]; 261 scalar->data.S32 = Nfit; 262 263 scalar = job->args->data[6]; 264 scalar->data.S32 = Npsf; 265 266 scalar = job->args->data[7]; 267 scalar->data.S32 = Next; 268 269 scalar = job->args->data[8]; 270 scalar->data.S32 = Nfail; 271 272 return true; 273 } 274 275 bool psphotBlendFit_Unthreaded (int *nfit, int *npsf, int *next, int *nfail, pmReadout *readout, psMetadata *recipe, psArray *sources, pmPSF *psf, psArray *newSources) { 276 277 bool status = false; 278 int Nfit = 0; 279 int Npsf = 0; 280 int Next = 0; 281 int Nfail = 0; 282 283 // bit-masks to test for good/bad pixels 284 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); 285 assert (maskVal); 286 287 // bit-mask to mark pixels not used in analysis 288 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); 289 assert (markVal); 290 291 // maskVal is used to test for rejected pixels, and must include markVal 292 maskVal |= markVal; 293 294 // S/N limit to perform full non-linear fits 295 float FIT_SN_LIM = psMetadataLookupF32 (&status, recipe, "FULL_FIT_SN_LIM"); 296 297 // option to limit analysis to a specific region 298 char *region = psMetadataLookupStr (&status, recipe, "ANALYSIS_REGION"); 299 psRegion AnalysisRegion = psRegionForImage (readout->image, psRegionFromString (region)); 300 if (psRegionIsNaN (AnalysisRegion)) psAbort("analysis region mis-defined"); 301 302 for (int i = 0; i < sources->n; i++) { 303 pmSource *source = sources->data[i]; 304 305 // skip non-astronomical objects (very likely defects) 306 if (source->mode & PM_SOURCE_MODE_BLEND) continue; 307 if (source->mode & PM_SOURCE_MODE_CR_LIMIT) continue; 308 if (source->type == PM_SOURCE_TYPE_DEFECT) continue; 309 if (source->type == PM_SOURCE_TYPE_SATURATED) continue; 310 311 // skip DBL second sources (ie, added by psphotFitBlob) 312 if (source->mode & PM_SOURCE_MODE_PAIR) continue; 313 314 // limit selection to some SN limit 315 if (source->peak->SN < FIT_SN_LIM) continue; 316 317 // exclude sources outside optional analysis region 318 if (source->peak->xf < AnalysisRegion.x0) continue; 319 if (source->peak->yf < AnalysisRegion.y0) continue; 320 if (source->peak->xf > AnalysisRegion.x1) continue; 321 if (source->peak->yf > AnalysisRegion.y1) continue; 322 323 // if model is NULL, we don't have a starting guess 324 if (source->modelPSF == NULL) continue; 325 326 // skip sources which are insignificant flux? 327 // XXX this is somewhat ad-hoc 328 if (source->modelPSF->params->data.F32[1] < 0.1) { 329 psTrace ("psphot", 5, "skipping near-zero source: %f, %f : %f\n", 330 source->modelPSF->params->data.F32[1], 331 source->modelPSF->params->data.F32[2], 332 source->modelPSF->params->data.F32[3]); 333 continue; 334 } 335 336 // replace object in image 337 if (source->mode & PM_SOURCE_MODE_SUBTRACTED) { 338 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 339 } 340 Nfit ++; 341 342 // try fitting PSFs or extended sources depending on source->mode 343 // these functions subtract the resulting fitted source 344 if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) { 345 if (psphotFitBlob (readout, source, newSources, psf, maskVal, markVal)) { 346 source->type = PM_SOURCE_TYPE_EXTENDED; 347 psTrace ("psphot", 5, "source at %7.1f, %7.1f is ext", source->peak->xf, source->peak->yf); 348 Next ++; 349 continue; 350 } 351 } else { 352 if (psphotFitBlend (readout, source, psf, maskVal, markVal)) { 353 source->type = PM_SOURCE_TYPE_STAR; 354 psTrace ("psphot", 5, "source at %7.1f, %7.1f is psf", source->peak->xf, source->peak->yf); 355 Npsf ++; 356 continue; 357 } 358 } 359 360 psTrace ("psphot", 5, "source at %7.1f, %7.1f failed", source->peak->xf, source->peak->yf); 361 Nfail ++; 362 363 // re-subtract the object, leave local sky 364 pmSourceCacheModel (source, maskVal); 365 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 366 source->mode |= PM_SOURCE_MODE_SUBTRACTED; 367 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 367 368 } 368 369 … … 375 376 return true; 376 377 } 378 # endif -
branches/cnb_branch_20090215/psphot/src/psphotDeblendSatstars.c
r20453 r21536 111 111 112 112 // any peaks within this contour should be dropped (mark as blend, drop after loop is done) 113 // also drop any peaks which are too close to this pea l113 // also drop any peaks which are too close to this peak 114 114 psVector *xv = contour->data[0]; 115 115 psVector *yv = contour->data[1]; -
branches/cnb_branch_20090215/psphot/src/psphotDetectReadout.c
r21392 r21536 22 22 // Generate the mask and weight images, including the user-defined analysis region of interest 23 23 psphotSetMaskAndWeight (config, readout, recipe); 24 if (!strcasecmp (breakPt, "NOTHING")) {25 return psphotReadoutCleanup(config, readout, recipe, NULL, NULL, NULL);26 }27 24 28 25 // load the psf model, if suppled. FWHM_X,FWHM_Y,etc are saved in the recipe … … 38 35 39 36 // include externally-supplied sources (supplied as PSPHOT.INPUT.CMF) 40 pmDetections *detections = psphotDetectionsFromSources (config, inSources); 41 if (!detections || !detections->peaks) { 42 psError(PSPHOT_ERR_ARGUMENTS, true, "Can't find PSF stars"); 43 return psphotReadoutCleanup(config, readout, recipe, detections, NULL, NULL); 44 } 45 46 // construct sources and measure basic stats 47 psArray *sources = psphotSourceStats (config, readout, detections); 48 if (!sources) return false; 49 if (!strcasecmp (breakPt, "PEAKS")) { 50 return psphotReadoutCleanup(config, readout, recipe, detections, psf, sources); 51 } 52 53 // classify sources based on moments, brightness 54 if (!psphotRoughClass (readout, sources, recipe, havePSF)) { 55 psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image"); 56 return psphotReadoutCleanup (config, readout, recipe, detections, psf, sources); 57 } 37 psphotSetSourceParams (config, sources, psf); 58 38 59 39 // calculate source magnitudes … … 63 43 return psphotReadoutCleanup(config, readout, recipe, detections, psf, sources); 64 44 } 45 46 // deep in pmSourcePixelWeight, we need the following items for each location of interest: 47 // pmModel *model (should be a realized version of the PSF, can have unity normalization) 48 // psImage *mask (local subimage of mask for source) 49 // psImageMaskType maskVal (from recipe & mask header) 50 51 { 52 pmModel *model = pmModelFromPSFforXY (psf, x, y, 1.0); 53 } 54 -
branches/cnb_branch_20090215/psphot/src/psphotExtendedSourceAnalysis.c
r21183 r21536 61 61 62 62 // replace object in image 63 if (source-> mode & PM_SOURCE_MODE_SUBTRACTED) {63 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) { 64 64 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 65 65 } … … 73 73 psTrace ("psphot", 5, "failed to extract radial profile for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My); 74 74 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 75 source-> mode |= PM_SOURCE_MODE_SUBTRACTED;75 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 76 76 continue; 77 77 } 78 source->mode |= PM_SOURCE_MODE_RADIAL_FLUX; 78 79 } 79 80 … … 85 86 psTrace ("psphot", 5, "measured isophotal mags for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My); 86 87 Nisophot ++; 88 source->mode |= PM_SOURCE_MODE_EXTENDED_STATS; 87 89 } 88 90 } … … 95 97 psTrace ("psphot", 5, "measured petrosian flux & radius for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My); 96 98 Npetro ++; 99 source->mode |= PM_SOURCE_MODE_EXTENDED_STATS; 97 100 } 98 101 } … … 105 108 psTrace ("psphot", 5, "measure kron mags for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My); 106 109 Nkron ++; 110 source->mode |= PM_SOURCE_MODE_EXTENDED_STATS; 107 111 } 108 112 } … … 116 120 psTrace ("psphot", 5, "measured annuli for source at %7.1f, %7.1f", source->moments->Mx, source->moments->My); 117 121 Nannuli ++; 122 source->mode |= PM_SOURCE_MODE_EXTENDED_STATS; 118 123 } 119 124 120 125 // re-subtract the object, leave local sky 121 126 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 122 source-> mode |= PM_SOURCE_MODE_SUBTRACTED;127 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 123 128 } 124 129 -
branches/cnb_branch_20090215/psphot/src/psphotExtendedSourceFits.c
r21183 r21536 110 110 111 111 // replace object in image 112 if (source-> mode & PM_SOURCE_MODE_SUBTRACTED) {112 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) { 113 113 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 114 114 } … … 170 170 if (!(modelFit->flags & (PM_MODEL_STATUS_BADARGS | PM_MODEL_STATUS_NONCONVERGE | PM_MODEL_STATUS_OFFIMAGE))) { 171 171 NconvolvePass ++; 172 source->mode |= PM_SOURCE_MODE_EXTENDED_FIT; 172 173 } 173 174 } else { … … 184 185 if (!(modelFit->flags & (PM_MODEL_STATUS_BADARGS | PM_MODEL_STATUS_NONCONVERGE | PM_MODEL_STATUS_OFFIMAGE))) { 185 186 NplainPass ++; 187 source->mode |= PM_SOURCE_MODE_EXTENDED_FIT; 186 188 } 187 189 } … … 224 226 225 227 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 226 source-> mode |= PM_SOURCE_MODE_SUBTRACTED;228 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 227 229 228 230 psFree (modelFluxes); … … 251 253 // subtract the best fit from the object, leave local sky 252 254 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 253 source-> mode |= PM_SOURCE_MODE_SUBTRACTED;255 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 254 256 255 257 // the initial model flux is no longer needed -
branches/cnb_branch_20090215/psphot/src/psphotFindPeaks.c
r20453 r21536 21 21 } 22 22 23 // correct the peak values to S/N = sqrt(significance) 24 // get the peak flux from the unsmoothed image 25 // the peak pixel coords are guaranteed to be on the image 23 // Convert the peak values to S/N = sqrt(significance). 24 // Get the peak flux from the unsmoothed image. 25 // Rescale the peak position errors using the peak variance 26 // The peak pixel coords are guaranteed to be on the image 26 27 int row0 = readout->image->row0; 27 28 int col0 = readout->image->col0; … … 30 31 peak->SN = sqrt(peak->value); 31 32 peak->flux = readout->image->data.F32[peak->y-row0][peak->x-col0]; 33 if (readout->variance && isfinite (peak->dx)) { 34 peak->dx *= sqrt(readout->variance->data.F32[peak->y-row0][peak->x-col0]); 35 } 36 if (readout->variance && isfinite (peak->dy)) { 37 peak->dy *= sqrt(readout->variance->data.F32[peak->y-row0][peak->x-col0]); 38 } 32 39 } 33 40 -
branches/cnb_branch_20090215/psphot/src/psphotFitSourcesLinear.c
r21366 r21536 63 63 pmSource *source = sources->data[i]; 64 64 65 // turn this bit off and turn it on again if we pass this test 66 source->mode &= ~PM_SOURCE_MODE_LINEAR_FIT; 67 65 68 // skip non-astronomical objects (very likely defects) 66 69 if (source->type == PM_SOURCE_TYPE_DEFECT) continue; 67 70 if (source->type == PM_SOURCE_TYPE_SATURATED) continue; 68 71 69 // if (source->type == PM_SOURCE_TYPE_STAR && 72 // do not include CRs in the full ensemble fit 70 73 if (source->mode & PM_SOURCE_MODE_CR_LIMIT) continue; 71 74 72 75 if (final) { 73 if (source-> mode & PM_SOURCE_MODE_SUBTRACTED) continue;76 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) continue; 74 77 } else { 75 if (source->mode & PM_SOURCE_MODE_BLEND) continue;78 if (source->mode & PM_SOURCE_MODE_BLEND) continue; 76 79 } 77 80 … … 91 94 if (y > AnalysisRegion.y1) continue; 92 95 96 source->mode |= PM_SOURCE_MODE_LINEAR_FIT; 93 97 psArrayAdd (fitSources, 100, source); 94 98 } … … 185 189 psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "solve matrix: %f sec (%d elements)\n", psTimerMark ("psphot.linear"), sparse->Nelem); 186 190 191 // XXXX **** philosophical question: 192 // we measure bright objects in three passes: 1) linear fit; 2) non-linear fit; 3) linear fit: 193 // should retain the chisq and errors from the intermediate non-linear fit? 194 // the non-linear fit provides better values for the position errors, and for 195 // extended sources, the shape errors 196 187 197 // adjust I0 for fitSources and subtract 188 198 for (int i = 0; i < fitSources->n; i++) { … … 194 204 psAbort("linear fitted source is nan"); 195 205 } 206 196 207 model->params->data.F32[PM_PAR_I0] = norm->data.F32[i]; 197 208 model->dparams->data.F32[PM_PAR_I0] = errors->data.F32[i]; … … 200 211 // subtract object 201 212 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 202 source-> mode |= PM_SOURCE_MODE_SUBTRACTED;213 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 203 214 } 204 215 psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "sub models: %f sec (%d elements)\n", psTimerMark ("psphot.linear"), sparse->Nelem); … … 207 218 for (int i = 0; final && (i < fitSources->n); i++) { 208 219 pmSource *source = fitSources->data[i]; 220 if (source->mode & PM_SOURCE_MODE_NONLINEAR_FIT) continue; 209 221 pmModel *model = pmSourceGetModel (NULL, source); 210 222 pmSourceChisq (model, source->pixels, source->maskObj, source->variance, maskVal); -
branches/cnb_branch_20090215/psphot/src/psphotGuessModels.c
r21381 r21536 22 22 } 23 23 24 bool psphotGuessModel_Unthreaded (pmReadout *readout, psArray *sources, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal);25 26 24 // construct an initial PSF model for each object 27 25 bool psphotGuessModels (pmConfig *config, pmReadout *readout, psArray *sources, pmPSF *psf) { … … 67 65 for (int j = 0; j < cells->n; j++) { 68 66 69 if (nThreads) {70 // allocate a job -- if threads are not defined, this just runs the job71 psThreadJob *job = psThreadJobAlloc ("PSPHOT_GUESS_MODEL");72 psArrayAdd(job->args, 1, readout);73 psArrayAdd(job->args, 1, cells->data[j]); // sources74 psArrayAdd(job->args, 1, psf); 75 76 // XXX change these to use abstract mask type info77 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK);78 PS_ARRAY_ADD_SCALAR(job->args, markVal, PS_TYPE_IMAGE_MASK); 79 80 if (!psThreadJobAddPending(job)) {81 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");82 psFree (job);83 return false;84 }85 psFree(job); 86 } else { 67 // allocate a job -- if threads are not defined, this just runs the job 68 psThreadJob *job = psThreadJobAlloc ("PSPHOT_GUESS_MODEL"); 69 psArrayAdd(job->args, 1, readout); 70 psArrayAdd(job->args, 1, cells->data[j]); // sources 71 psArrayAdd(job->args, 1, psf); 72 73 // XXX change these to use abstract mask type info 74 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 75 PS_ARRAY_ADD_SCALAR(job->args, markVal, PS_TYPE_IMAGE_MASK); 76 77 if (!psThreadJobAddPending(job)) { 78 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 79 psFree (job); 80 return false; 81 } 82 psFree(job); 83 84 # if (0) 87 85 if (!psphotGuessModel_Unthreaded (readout, cells->data[j], psf, maskVal, markVal)) { 88 86 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 89 87 return false; 90 88 } 91 } 92 } 93 94 if (nThreads) { 95 // wait for the threads to finish and manage results 96 // wait here for the threaded jobs to finish 97 // fprintf (stderr, "wait for threads (%d, %d)\n", jx, jy); 98 if (!psThreadPoolWait (false)) { 99 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 100 return false; 101 } 102 103 // we have only supplied one type of job, so we can assume the types here 104 psThreadJob *job = NULL; 105 while ((job = psThreadJobGetDone()) != NULL) { 106 // we have no returned data from this operation 107 if (job->args->n < 1) { 108 fprintf (stderr, "error with job\n"); 109 } 110 psFree(job); 111 } 89 # endif 90 } 91 92 // wait for the threads to finish and manage results 93 // wait here for the threaded jobs to finish 94 // fprintf (stderr, "wait for threads (%d, %d)\n", jx, jy); 95 if (!psThreadPoolWait (false)) { 96 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 97 return false; 98 } 99 100 // we have only supplied one type of job, so we can assume the types here 101 psThreadJob *job = NULL; 102 while ((job = psThreadJobGetDone()) != NULL) { 103 // we have no returned data from this operation 104 if (job->args->n < 1) { 105 fprintf (stderr, "error with job\n"); 106 } 107 psFree(job); 112 108 } 113 109 } … … 116 112 int nMiss = 0; 117 113 for (int i = 0; i < sources->n; i++) { 118 119 114 pmSource *source = sources->data[i]; 120 if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) { 121 source->mode &= ~PM_SOURCE_MODE_EXT_LIMIT; 115 if (source->tmpFlags & PM_SOURCE_TMPF_MODEL_GUESS) { 122 116 continue; 123 117 } 124 125 118 nMiss ++; 126 119 } 127 ps LogMsg ("psphot.models", 4, "failedto build models for %d objects\n", nMiss);120 psAssert (nMiss == 0, "failed to attempt to build models for %d objects\n", nMiss); 128 121 129 122 psFree (cellGroups); … … 148 141 pmSource *source = sources->data[i]; 149 142 150 // XXXX this is just for a test: use this to mark sources for which the model is measured151 // check later thatall are used.152 source-> mode |= PM_SOURCE_MODE_EXT_LIMIT;143 // this is used to mark sources for which the model is measured. We check later that 144 // all are used. 145 source->tmpFlags |= PM_SOURCE_TMPF_MODEL_GUESS; 153 146 154 147 // skip non-astronomical objects (very likely defects) … … 185 178 pmModel *modelPSF = pmModelFromPSF (modelEXT, psf); // ALLOC X5 186 179 if (modelPSF == NULL) { 187 psError(PSPHOT_ERR_PSF, false, 188 "Failed to determine PSF model at r,c = (%d,%d); trying centre of image", 180 psWarning ("Failed to determine PSF model at r,c = (%d,%d); trying centre of image", 189 181 source->peak->y, source->peak->x); 190 // 191 // Try the centre of the image 192 // 182 183 // Try the center of the image 193 184 modelEXT->params->data.F32[PM_PAR_XPOS] = 0.5*readout->image->numCols; 194 185 modelEXT->params->data.F32[PM_PAR_YPOS] = 0.5*readout->image->numRows; 195 186 modelPSF = pmModelFromPSF (modelEXT, psf); 196 187 if (modelPSF == NULL) { 197 psError(PSPHOT_ERR_PSF, false, 198 "Failed to determine PSF model at centre of image"); 188 psError(PSPHOT_ERR_PSF, false, "Failed to determine PSF model at center of image"); 199 189 psFree(modelEXT); 200 190 return false; 201 191 } 202 203 192 source->mode |= PM_SOURCE_MODE_BADPSF; 204 193 } … … 221 210 } 222 211 212 # if (0) 223 213 // construct models only for sources in the specified region 224 214 bool psphotGuessModel_Unthreaded (pmReadout *readout, psArray *sources, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal) { … … 301 291 return true; 302 292 } 293 # endif -
branches/cnb_branch_20090215/psphot/src/psphotMagnitudes.c
r21392 r21536 1 1 # include "psphotInternal.h" 2 3 bool psphotMagnitudes_Unthreaded (int *nap, psArray *sources, pmPSF *psf, psImageBinning *binning, pmReadout *backModel, pmReadout *backStdev, pmSourcePhotometryMode photMode, psImageMaskType maskVal);4 2 5 3 bool psphotMagnitudes(pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources, pmPSF *psf) { … … 59 57 for (int j = 0; j < cells->n; j++) { 60 58 61 if (nThreads) {62 // allocate a job -- if threads are not defined, this just runs the job63 psThreadJob *job = psThreadJobAlloc ("PSPHOT_MAGNITUDES"); 64 65 psArrayAdd(job->args, 1, cells->data[j]); // sources66 psArrayAdd(job->args, 1, psf);67 psArrayAdd(job->args, 1, binning);68 psArrayAdd(job->args, 1, backModel);69 psArrayAdd(job->args, 1, backStdev); 70 71 PS_ARRAY_ADD_SCALAR(job->args, photMode, PS_TYPE_S32);72 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK);73 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for nAp 74 75 if (!psThreadJobAddPending(job)) {76 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");77 psFree (job);78 return false;79 }80 psFree(job); 81 } else { 59 // allocate a job -- if threads are not defined, this just runs the job 60 psThreadJob *job = psThreadJobAlloc ("PSPHOT_MAGNITUDES"); 61 62 psArrayAdd(job->args, 1, cells->data[j]); // sources 63 psArrayAdd(job->args, 1, psf); 64 psArrayAdd(job->args, 1, binning); 65 psArrayAdd(job->args, 1, backModel); 66 psArrayAdd(job->args, 1, backStdev); 67 68 PS_ARRAY_ADD_SCALAR(job->args, photMode, PS_TYPE_S32); 69 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 70 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for nAp 71 72 if (!psThreadJobAddPending(job)) { 73 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 74 psFree (job); 75 return false; 76 } 77 psFree(job); 78 79 # if (0) 82 80 int nap = 0; 83 81 if (!psphotMagnitudes_Unthreaded (&nap, cells->data[j], psf, binning, backModel, backStdev, photMode, maskVal)) { … … 86 84 } 87 85 Nap += nap; 88 } 89 } 90 91 if (nThreads) { 92 // wait for the threads to finish and manage results 93 if (!psThreadPoolWait (false)) { 94 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 95 return false; 96 } 97 98 // we have only supplied one type of job, so we can assume the types here 99 psThreadJob *job = NULL; 100 while ((job = psThreadJobGetDone()) != NULL) { 101 if (job->args->n < 1) { 102 fprintf (stderr, "error with job\n"); 103 } else { 104 psScalar *scalar = job->args->data[7]; 105 Nap += scalar->data.S32; 106 } 107 psFree(job); 108 } 86 # endif 87 } 88 89 // wait for the threads to finish and manage results 90 if (!psThreadPoolWait (false)) { 91 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 92 return false; 93 } 94 95 // we have only supplied one type of job, so we can assume the types here 96 psThreadJob *job = NULL; 97 while ((job = psThreadJobGetDone()) != NULL) { 98 if (job->args->n < 1) { 99 fprintf (stderr, "error with job\n"); 100 } else { 101 psScalar *scalar = job->args->data[7]; 102 Nap += scalar->data.S32; 103 } 104 psFree(job); 109 105 } 110 106 } … … 162 158 } 163 159 160 # if (0) 164 161 bool psphotMagnitudes_Unthreaded (int *nap, psArray *sources, pmPSF *psf, psImageBinning *binning, pmReadout *backModel, pmReadout *backStdev, pmSourcePhotometryMode photMode, psImageMaskType maskVal) { 165 162 … … 198 195 return true; 199 196 } 197 # endif 200 198 201 199 bool psphotPSFWeights(pmConfig *config, pmReadout *readout, const pmFPAview *view, psArray *sources) { … … 295 293 } 296 294 297 status = pmSourcePixelWeight (&source->pixWeight, model, source-> pixels, source->maskObj, maskVal);295 status = pmSourcePixelWeight (&source->pixWeight, model, source->maskObj, maskVal); 298 296 if (!status) { 299 297 psTrace ("psphot", 3, "fail to measure pixel weight"); -
branches/cnb_branch_20090215/psphot/src/psphotMergeSources.c
r21251 r21536 122 122 return detections; 123 123 } 124 125 // generate the detection structure for the supplied array of sources 126 bool psphotSetSourceParams (pmConfig *config, psArray *sources, pmPSF *psf) { 127 128 psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSPHOT_RECIPE); 129 if (!recipe) { 130 psError(PSPHOT_ERR_CONFIG, false, "missing recipe %s", PSPHOT_RECIPE); 131 return false; 132 } 133 134 for (int i = 0; i < sources->n; i++) { 135 pmSource *source = sources->data[i]; 136 pmModel *model = source->modelPSF; 137 138 if (source->mode & PSF_SOURCE_MASK || !isfinite(source->psfMag)) { 139 continue; 140 } 141 142 float flux = powf(10.0, -0.4 * source->psfMag); 143 float xpos = model->params->data.F32[PM_PAR_XPOS]; 144 float ypos = model->params->data.F32[PM_PAR_YPOS]; 145 146 pmPeak *peak = pmPeakAlloc(xpos, ypos, 1.0, PM_PEAK_LONE); 147 peak->xf = xpos; 148 peak->yf = ypos; 149 peak->flux = flux; // this are being set wrong, but does it matter? 150 151 if (isfinite (source->errMag) && (source->errMag > 0.0)) { 152 peak->SN = 1.0 / source->errMag; 153 } else { 154 peak->SN = 0.0; 155 } 156 157 source->peak = peak; 158 } 159 160 psLogMsg ("psphot", 3, "%ld PSF sources loaded", sources->n); 161 162 return true; 163 } -
branches/cnb_branch_20090215/psphot/src/psphotReplaceUnfit.c
r21183 r21536 17 17 replace: 18 18 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 19 source-> mode &= ~PM_SOURCE_MODE_SUBTRACTED;19 source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED; 20 20 } 21 21 psLogMsg ("psphot.replace", 3, "replace unfitted models: %f sec (%ld objects)\n", psTimerMark ("psphot.replace"), sources->n); … … 38 38 39 39 // replace other sources? 40 if (!(source-> mode & PM_SOURCE_MODE_SUBTRACTED)) continue;40 if (!(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED)) continue; 41 41 42 42 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 43 source-> mode &= ~PM_SOURCE_MODE_SUBTRACTED;43 source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED; 44 44 } 45 45 psLogMsg ("psphot.replace", PS_LOG_INFO, "replaced models for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot.replace")); … … 62 62 63 63 // replace other sources? 64 if (source-> mode & PM_SOURCE_MODE_SUBTRACTED) continue;64 if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) continue; 65 65 66 66 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 67 source-> mode |= PM_SOURCE_MODE_SUBTRACTED;67 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 68 68 } 69 69 psLogMsg ("psphot.replace", PS_LOG_INFO, "replaced models for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot.replace")); … … 75 75 76 76 // what is current state? (true : add; false : sub) 77 bool state = !(source-> mode & PM_SOURCE_MODE_SUBTRACTED);77 bool state = !(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED); 78 78 if (state && useState) return true; 79 79 … … 86 86 87 87 // what is current state? (true : sub; false : add) 88 bool state = (source-> mode & PM_SOURCE_MODE_SUBTRACTED);88 bool state = (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED); 89 89 if (state && useState) return true; 90 90 … … 97 97 98 98 // what is desired state? (true : add; false : sub) 99 bool newState = !(source-> mode & PM_SOURCE_MODE_SUBTRACTED);99 bool newState = !(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED); 100 100 if (curState == newState) return true; 101 101 -
branches/cnb_branch_20090215/psphot/src/psphotSourceFits.c
r21183 r21536 120 120 pmSourceCacheModel (blend, maskVal); 121 121 pmSourceSub (blend, PM_MODEL_OP_FULL, maskVal); 122 blend->mode |= PM_SOURCE_MODE_SUBTRACTED; 122 blend->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 123 blend->mode |= PM_SOURCE_MODE_BLEND_FIT; 123 124 } 124 125 NfitBlend += modelSet->n; … … 143 144 pmSourceCacheModel (source, maskVal); 144 145 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 145 source->mode |= PM_SOURCE_MODE_SUBTRACTED; 146 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 147 source->mode |= PM_SOURCE_MODE_BLEND_FIT; 146 148 return true; 147 149 } … … 184 186 pmSourceCacheModel (source, maskVal); 185 187 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 186 source-> mode |= PM_SOURCE_MODE_SUBTRACTED;188 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 187 189 return true; 188 190 } … … 285 287 pmSourceCacheModel (source, maskVal); 286 288 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 287 source-> mode |= PM_SOURCE_MODE_SUBTRACTED;289 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 288 290 psTrace ("psphot", 5, "blob as EXT: %f %f\n", EXT->params->data.F32[PM_PAR_XPOS], EXT->params->data.F32[PM_PAR_YPOS]); 289 291 return true; … … 296 298 psFree (source->modelPSF); 297 299 source->modelPSF = psMemIncrRefCounter (DBL->data[0]); 298 source-> mode |= PM_SOURCE_MODE_SUBTRACTED;299 source->mode |= PM_SOURCE_MODE_PAIR;300 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 301 source->mode |= PM_SOURCE_MODE_PAIR; 300 302 301 303 // copy most data from the primary source (modelEXT, blends stay NULL) -
branches/cnb_branch_20090215/psphot/src/psphotSourceSize.c
r21366 r21536 56 56 57 57 // source must have been subtracted 58 if (!(source->mode & PM_SOURCE_MODE_SUBTRACTED)) { 58 if (!(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED)) { 59 source->mode |= PM_SOURCE_MODE_SIZE_SKIPPED; 59 60 psTrace("psphot", 7, "Not calculating extNsigma,crNsigma since source is not subtracted\n"); 60 61 continue; … … 63 64 psF32 **resid = source->pixels->data.F32; 64 65 psF32 **variance = source->variance->data.F32; 65 psImageMaskType **mask = source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA;66 psImageMaskType **mask = source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA; 66 67 67 68 // check for extendedness: measure the delta flux significance at the 1 sigma contour … … 82 83 if (xPeak < 1 || xPeak > source->pixels->numCols - 2 || 83 84 yPeak < 1 || yPeak > source->pixels->numRows - 2) { 85 source->mode |= PM_SOURCE_MODE_SIZE_SKIPPED; 84 86 psTrace("psphot", 7, "Not calculating crNsigma due to edge\n"); 85 87 continue; … … 98 100 if (!keep) { 99 101 psTrace("psphot", 7, "Not calculating crNsigma due to masked pixels\n"); 102 source->mode |= PM_SOURCE_MODE_SIZE_SKIPPED; 100 103 continue; 101 104 } … … 156 159 } 157 160 source->crNsigma = (nCR > 0) ? fCR / nCR : 0.0; 158 if (!isfinite(source->crNsigma)) continue; 161 if (!isfinite(source->crNsigma)) { 162 continue; 163 } 159 164 160 165 // this source is thought to be a cosmic ray. flag the detection and mask the pixels … … 264 269 // replace the source flux 265 270 pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal); 266 source-> mode &= ~PM_SOURCE_MODE_SUBTRACTED;271 source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED; 267 272 268 273 // flag this as a CR -
branches/cnb_branch_20090215/psphot/src/psphotSourceStats.c
r21359 r21536 1 1 # include "psphotInternal.h" 2 3 bool psphotSourceStats_Unthreaded (int *nfail, int *nmoments, psArray *sources, psMetadata *recipe);4 2 5 3 psArray *psphotSourceStats (pmConfig *config, pmReadout *readout, pmDetections *detections) { … … 80 78 for (int j = 0; j < cells->n; j++) { 81 79 82 if (nThreads) {83 // allocate a job -- if threads are not defined, this just runs the job84 psThreadJob *job = psThreadJobAlloc ("PSPHOT_SOURCE_STATS"); 85 86 psArrayAdd(job->args, 1, cells->data[j]); // sources87 psArrayAdd(job->args, 1, recipe);88 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nmoments89 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail 90 91 if (!psThreadJobAddPending(job)) {92 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");93 psFree (job);94 return NULL;95 }96 psFree(job); 97 } else { 80 // allocate a job -- if threads are not defined, this just runs the job 81 psThreadJob *job = psThreadJobAlloc ("PSPHOT_SOURCE_STATS"); 82 83 psArrayAdd(job->args, 1, cells->data[j]); // sources 84 psArrayAdd(job->args, 1, recipe); 85 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nmoments 86 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail 87 88 if (!psThreadJobAddPending(job)) { 89 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 90 psFree (job); 91 return NULL; 92 } 93 psFree(job); 94 95 # if (0) 98 96 int nfail = 0; 99 97 int nmoments = 0; … … 104 102 Nfail += nfail; 105 103 Nmoments += nmoments; 104 # endif 105 } 106 107 // wait for the threads to finish and manage results 108 if (!psThreadPoolWait (false)) { 109 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 110 return NULL; 111 } 112 113 // we have only supplied one type of job, so we can assume the types here 114 psThreadJob *job = NULL; 115 while ((job = psThreadJobGetDone()) != NULL) { 116 if (job->args->n < 1) { 117 fprintf (stderr, "error with job\n"); 118 } else { 119 psScalar *scalar = NULL; 120 scalar = job->args->data[2]; 121 Nmoments += scalar->data.S32; 122 scalar = job->args->data[3]; 123 Nfail += scalar->data.S32; 106 124 } 107 } 108 109 if (nThreads) { 110 // wait for the threads to finish and manage results 111 if (!psThreadPoolWait (false)) { 112 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 113 return NULL; 114 } 115 116 // we have only supplied one type of job, so we can assume the types here 117 psThreadJob *job = NULL; 118 while ((job = psThreadJobGetDone()) != NULL) { 119 if (job->args->n < 1) { 120 fprintf (stderr, "error with job\n"); 121 } else { 122 psScalar *scalar = NULL; 123 scalar = job->args->data[2]; 124 Nmoments += scalar->data.S32; 125 scalar = job->args->data[3]; 126 Nfail += scalar->data.S32; 127 } 128 psFree(job); 129 } 125 psFree(job); 130 126 } 131 127 } … … 148 144 psArray *sources = job->args->data[0]; 149 145 psMetadata *recipe = job->args->data[1]; 146 147 float INNER = psMetadataLookupF32 (&status, recipe, "SKY_INNER_RADIUS"); 148 if (!status) return false; 149 float MIN_SN = psMetadataLookupF32 (&status, recipe, "MOMENTS_SN_MIN"); 150 if (!status) return false; 151 float RADIUS = psMetadataLookupF32 (&status, recipe, "PSF_MOMENTS_RADIUS"); 152 if (!status) return false; 153 154 // bit-masks to test for good/bad pixels 155 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); 156 assert (maskVal); 157 158 // bit-mask to mark pixels not used in analysis 159 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); 160 assert (markVal); 161 162 // maskVal is used to test for rejected pixels, and must include markVal 163 maskVal |= markVal; 164 165 // threaded measurement of the sources moments 166 int Nfail = 0; 167 int Nmoments = 0; 168 for (int i = 0; i < sources->n; i++) { 169 pmSource *source = sources->data[i]; 170 171 // skip faint sources for moments measurement 172 if (source->peak->SN < MIN_SN) { 173 source->mode |= PM_SOURCE_MODE_BELOW_MOMENTS_SN; 174 continue; 175 } 176 177 // measure a local sky value 178 // the local sky is now ignored; kept here for reference only 179 status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 180 if (!status) { 181 source->mode |= PM_SOURCE_MODE_SKY_FAILURE; 182 psErrorClear(); // XXX re-consider the errors raised here 183 Nfail ++; 184 continue; 185 } 186 187 // measure the local sky variance (needed if noise is not sqrt(signal)) 188 // XXX EAM : this should use ROBUST not SAMPLE median, but it is broken 189 status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 190 if (!status) { 191 source->mode |= PM_SOURCE_MODE_SKYVAR_FAILURE; 192 Nfail ++; 193 psErrorClear(); 194 continue; 195 } 196 197 // measure basic source moments 198 status = pmSourceMoments (source, RADIUS); 199 if (status) { 200 Nmoments ++; 201 continue; 202 } 203 204 // if no valid pixels, or massive swing, likely saturated source, 205 // try a much larger box 206 BIG_RADIUS = PS_MIN (INNER, 3*RADIUS); 207 psTrace ("psphot", 4, "retrying moments for %d, %d\n", source->peak->x, source->peak->y); 208 status = pmSourceMoments (source, BIG_RADIUS); 209 if (status) { 210 source->mode |= PM_SOURCE_MODE_BIG_RADIUS; 211 Nmoments ++; 212 continue; 213 } 214 215 source->mode |= PM_SOURCE_MODE_MOMENTS_FAILURE; 216 Nfail ++; 217 psErrorClear(); 218 continue; 219 } 220 221 // change the value of a scalar on the array (wrap this and put it in psArray.h) 222 scalar = job->args->data[2]; 223 scalar->data.S32 = Nmoments; 224 225 scalar = job->args->data[3]; 226 scalar->data.S32 = Nfail; 227 228 return true; 229 } 230 231 # if (0) 232 bool psphotSourceStats_Unthreaded (int *nfail, int *nmoments, psArray *sources, psMetadata *recipe) { 233 234 bool status = false; 235 float BIG_RADIUS; 150 236 151 237 float INNER = psMetadataLookupF32 (&status, recipe, "SKY_INNER_RADIUS"); … … 219 305 220 306 // change the value of a scalar on the array (wrap this and put it in psArray.h) 221 scalar = job->args->data[2];222 scalar->data.S32 = Nmoments;223 224 scalar = job->args->data[3];225 scalar->data.S32 = Nfail;226 227 return true;228 }229 230 bool psphotSourceStats_Unthreaded (int *nfail, int *nmoments, psArray *sources, psMetadata *recipe) {231 232 bool status = false;233 float BIG_RADIUS;234 235 float INNER = psMetadataLookupF32 (&status, recipe, "SKY_INNER_RADIUS");236 if (!status) return false;237 float MIN_SN = psMetadataLookupF32 (&status, recipe, "MOMENTS_SN_MIN");238 if (!status) return false;239 float RADIUS = psMetadataLookupF32 (&status, recipe, "PSF_MOMENTS_RADIUS");240 if (!status) return false;241 242 // bit-masks to test for good/bad pixels243 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");244 assert (maskVal);245 246 // bit-mask to mark pixels not used in analysis247 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");248 assert (markVal);249 250 // maskVal is used to test for rejected pixels, and must include markVal251 maskVal |= markVal;252 253 // threaded measurement of the sources moments254 int Nfail = 0;255 int Nmoments = 0;256 for (int i = 0; i < sources->n; i++) {257 pmSource *source = sources->data[i];258 259 // skip faint sources for moments measurement260 if (source->peak->SN < MIN_SN) {261 continue;262 }263 264 // measure a local sky value265 // the local sky is now ignored; kept here for reference only266 status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);267 if (!status) {268 psErrorClear(); // XXX re-consider the errors raised here269 Nfail ++;270 continue;271 }272 273 // measure the local sky variance (needed if noise is not sqrt(signal))274 // XXX EAM : this should use ROBUST not SAMPLE median, but it is broken275 status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);276 if (!status) {277 Nfail ++;278 psErrorClear();279 continue;280 }281 282 // measure basic source moments283 status = pmSourceMoments (source, RADIUS);284 if (status) {285 Nmoments ++;286 continue;287 }288 289 // if no valid pixels, or massive swing, likely saturated source,290 // try a much larger box291 BIG_RADIUS = PS_MIN (INNER, 3*RADIUS);292 psTrace ("psphot", 4, "retrying moments for %d, %d\n", source->peak->x, source->peak->y);293 status = pmSourceMoments (source, BIG_RADIUS);294 if (status) {295 Nmoments ++;296 continue;297 }298 299 Nfail ++;300 psErrorClear();301 continue;302 }303 304 // change the value of a scalar on the array (wrap this and put it in psArray.h)305 307 *nmoments = Nmoments; 306 308 *nfail = Nfail; … … 308 310 return true; 309 311 } 312 # endif -
branches/cnb_branch_20090215/psphot/src/psphotVisual.c
r21366 r21536 18 18 // these are invoked by the -visual options 19 19 20 static bool isVisual = false;21 20 static int kapa = -1; 22 21 static int kapa2 = -1; 23 22 static int kapa3 = -1; 24 23 25 bool psphotSetVisual (bool mode) {26 27 isVisual = mode;28 return true;29 }30 24 31 25 bool psphotVisualShowMask (int kapaFD, psImage *inImage, const char *name, int channel) { … … 135 129 bool psphotVisualShowImage (pmReadout *readout) { 136 130 137 if (! isVisual) return true;131 if (!pmVisualIsVisual()) return true; 138 132 139 133 if (kapa == -1) { … … 141 135 if (kapa == -1) { 142 136 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 143 isVisual = false;137 pmVisualSetVisual(false); 144 138 return false; 145 139 } … … 164 158 pmReadout *backgnd; 165 159 166 if (! isVisual) return true;160 if (!pmVisualIsVisual()) return true; 167 161 168 162 if (kapa == -1) { … … 170 164 if (kapa == -1) { 171 165 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 172 isVisual = false;166 pmVisualSetVisual(false); 173 167 return false; 174 168 } … … 199 193 bool psphotVisualShowSignificance (psImage *image) { 200 194 201 if (! isVisual) return true;195 if (!pmVisualIsVisual()) return true; 202 196 203 197 if (kapa == -1) { … … 205 199 if (kapa == -1) { 206 200 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 207 isVisual = false;201 pmVisualSetVisual(false); 208 202 return false; 209 203 } … … 228 222 KiiOverlay *overlay; 229 223 230 if (! isVisual) return true;224 if (!pmVisualIsVisual()) return true; 231 225 232 226 if (kapa == -1) { … … 306 300 KiiOverlay *overlay; 307 301 308 if (! isVisual) return true;302 if (!pmVisualIsVisual()) return true; 309 303 310 304 if (kapa == -1) { … … 423 417 psEllipseAxes axes; 424 418 425 if (! isVisual) return true;419 if (!pmVisualIsVisual()) return true; 426 420 427 421 if (kapa == -1) { … … 478 472 Graphdata graphdata; 479 473 480 if (! isVisual) return true;474 if (!pmVisualIsVisual()) return true; 481 475 482 476 if (kapa3 == -1) { … … 484 478 if (kapa3 == -1) { 485 479 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 486 isVisual = false;480 pmVisualSetVisual(false); 487 481 return false; 488 482 } … … 694 688 bool psphotVisualShowRoughClass (psArray *sources) { 695 689 696 if (! isVisual) return true;690 if (!pmVisualIsVisual()) return true; 697 691 698 692 if (kapa == -1) { … … 723 717 bool psphotVisualShowPSFModel (pmReadout *readout, pmPSF *psf) { 724 718 725 if (! isVisual) return true;719 if (!pmVisualIsVisual()) return true; 726 720 727 721 if (kapa2 == -1) { … … 729 723 if (kapa2 == -1) { 730 724 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 731 isVisual = false;725 pmVisualSetVisual(false); 732 726 return false; 733 727 } … … 801 795 bool status; 802 796 803 if (! isVisual) return true;797 if (!pmVisualIsVisual()) return true; 804 798 805 799 if (kapa2 == -1) { … … 807 801 if (kapa2 == -1) { 808 802 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 809 isVisual = false;803 pmVisualSetVisual(false); 810 804 return false; 811 805 } … … 961 955 bool status; 962 956 963 if (! isVisual) return true;957 if (!pmVisualIsVisual()) return true; 964 958 965 959 if (kapa2 == -1) { … … 967 961 if (kapa2 == -1) { 968 962 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 969 isVisual = false;963 pmVisualSetVisual(false); 970 964 return false; 971 965 } … … 1101 1095 Graphdata graphdata; 1102 1096 1103 bool state = !(source-> mode & PM_SOURCE_MODE_SUBTRACTED);1097 bool state = !(source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED); 1104 1098 psphotAddWithTest (source, true, maskVal); // replace source if subtracted 1105 1099 … … 1214 1208 KapaSection section; // put the positive profile in one and the residuals in another? 1215 1209 1216 if (! isVisual) return true;1210 if (!pmVisualIsVisual()) return true; 1217 1211 1218 1212 if (kapa3 == -1) { … … 1220 1214 if (kapa3 == -1) { 1221 1215 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 1222 isVisual = false;1216 pmVisualSetVisual(false); 1223 1217 return false; 1224 1218 } … … 1286 1280 psEllipseAxes axes; 1287 1281 1288 if (! isVisual) return true;1282 if (!pmVisualIsVisual()) return true; 1289 1283 1290 1284 if (kapa == -1) { … … 1387 1381 KiiOverlay *overlay; 1388 1382 1389 if (! isVisual) return true;1383 if (!pmVisualIsVisual()) return true; 1390 1384 1391 1385 if (kapa == -1) { … … 1464 1458 KapaSection section; 1465 1459 1466 if (! isVisual) return true;1460 if (!pmVisualIsVisual()) return true; 1467 1461 1468 1462 if (kapa3 == -1) { … … 1470 1464 if (kapa3 == -1) { 1471 1465 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 1472 isVisual = false;1466 pmVisualSetVisual(false); 1473 1467 return false; 1474 1468 } … … 1604 1598 bool psphotVisualShowResidualImage (pmReadout *readout) { 1605 1599 1606 if (! isVisual) return true;1600 if (!pmVisualIsVisual()) return true; 1607 1601 1608 1602 if (kapa == -1) { … … 1610 1604 if (kapa == -1) { 1611 1605 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 1612 isVisual = false;1606 pmVisualSetVisual(false); 1613 1607 return false; 1614 1608 } … … 1631 1625 Graphdata graphdata; 1632 1626 1633 if (! isVisual) return true;1627 if (!pmVisualIsVisual()) return true; 1634 1628 1635 1629 if (kapa3 == -1) { … … 1637 1631 if (kapa3 == -1) { 1638 1632 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 1639 isVisual = false;1633 pmVisualSetVisual(false); 1640 1634 return false; 1641 1635 } … … 1712 1706 # else 1713 1707 1714 bool psphotSetVisual (bool mode){}1715 1708 bool psphotVisualShowImage (pmConfig *config, pmReadout *readout) { return true; } 1716 1709 bool psphotVisualShowBackground (pmConfig *config, const pmFPAview *view, pmReadout *readout) { return true; } -
branches/cnb_branch_20090215/pswarp/src/pswarpArguments.c
r21368 r21536 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.24 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 03:10:36$8 * @version $Revision: 1.24.2.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:50 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ … … 39 39 { 40 40 int arg; ///< Argument Number 41 if ((arg = psArgumentGet(argc, argv, "- psphot-visual"))) {41 if ((arg = psArgumentGet(argc, argv, "-visual"))) { 42 42 psArgumentRemove(arg, &argc, argv); 43 p sphotSetVisual(true);43 pmVisualSetVisual(true); 44 44 } 45 45 }
Note:
See TracChangeset
for help on using the changeset viewer.
