Changeset 38348
- Timestamp:
- Jun 2, 2015, 8:52:24 AM (11 years ago)
- Location:
- branches/eam_branches/ohana.20150429/src
- Files:
-
- 19 edited
- 3 copied
-
addstar/test (modified) (2 props)
-
addstar/test/GSCregions.tbl (copied) (copied from branches/eam_branches/ipp-20150419/Ohana/src/addstar/test/GSCregions.tbl )
-
addstar/test/dvo.config (copied) (copied from branches/eam_branches/ipp-20150419/Ohana/src/addstar/test/dvo.config )
-
addstar/test/dvo.layout (copied) (copied from branches/eam_branches/ipp-20150419/Ohana/src/addstar/test/dvo.layout )
-
addstar/test/relphot.dvo (modified) (2 diffs)
-
addstar/test/relphot.flatcorr.dvo (modified) (19 diffs)
-
addstar/test/simple.dvo (modified) (3 diffs)
-
addstar/test/tap.dvo (modified) (2 diffs)
-
dvomerge/src/dvorepairDeleteImageList.c (modified) (1 diff)
-
dvomerge/src/dvorepairDeleteImagesByExternID.c (modified) (2 diffs)
-
dvomerge/src/dvorepairFixCPT.c (modified) (2 diffs)
-
dvomerge/src/dvorepairImagesVsMeasures.c (modified) (1 diff)
-
libdvo/include/dvo.h (modified) (1 diff)
-
libdvo/src/dvo_catalog_create.c (modified) (5 diffs)
-
libdvo/src/dvo_catalog_mef.c (modified) (12 diffs)
-
libdvo/src/dvo_catalog_split.c (modified) (48 diffs)
-
libdvo/src/dvo_convert.c (modified) (25 diffs)
-
libfits/header/F_copy_H.c (modified) (1 diff)
-
libfits/include/gfitsio.h (modified) (1 diff)
-
libfits/table/F_compress_T.c (modified) (2 diffs)
-
libfits/table/F_copy_T.c (modified) (1 diff)
-
libfits/table/F_uncompress_T.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/addstar/test
- Property svn:ignore
-
old new 17 17 relphot.Mcal.dMcal.png 18 18 catdir.wise.test 19 dvo.photcodes 20 ptolemy.rc 21 tap.log
-
- Property svn:mergeinfo set to
- Property svn:ignore
-
branches/eam_branches/ohana.20150429/src/addstar/test/relphot.dvo
r35760 r38348 1 1 # -*-sh-*- 2 if (not($?VERBOSE)) set VERBOSE = 0 2 3 3 4 input tap.dvo … … 41 42 end 42 43 43 echo relphot -D CATDIR catdir.test r -region {$RA-1.0} {$RA+1.0} {$DEC-1.0} {$DEC+1.0} -update -nloop 10.0 44 exec relphot -D CATDIR catdir.test r -region {$RA-1.0} {$RA+1.0} {$DEC-1.0} {$DEC+1.0} -update -nloop 10.0 >& /dev/null 44 $output = >& /dev/null 45 if ($VERBOSE > 2) 46 $output = 47 end 48 $command = relphot -D CATDIR catdir.test -region {$RA-1.0} {$RA+1.0} {$DEC-1.0} {$DEC+1.0} -update -nloop 10.0 -images r 49 echo $command 50 exec $command $output 45 51 46 52 catdir catdir.test -
branches/eam_branches/ohana.20150429/src/addstar/test/relphot.flatcorr.dvo
r33653 r38348 14 14 # * no other mechanism to tell DVO about a flat-field correction 15 15 16 $TAP_BREAK = 1 17 $TAP_VERBOSE = 1 16 18 input tap.dvo 17 19 18 20 # set globals 19 if (not($?PLOT)) set PLOT = 0 21 if (not($?PLOT)) set PLOT = 0 22 23 $USE_CELL_OFFSETS = 1; # turn on non-zero cell offsets 24 $SET_UC_RESID = 1; # write a non-zero resid value to the ubercal table (should not have an impact) 25 $DO_2MASS = 1 26 $DO_SYNTH = 1 27 $DO_TYCHO = 1 28 $NC_CLOUDS = 0.08 29 $UC_CLOUDS = 0.02 20 30 21 31 # set various global variables 22 32 macro init 33 # generate a fake ptolemy.rc (to make this a contained test) 34 exec rm -f ptolemy.rc 35 output ptolemy.rc 36 echo "\#" 37 echo PHOTCODE_FILE dvo.photcodes 38 echo GSCFILE GSCregions.tbl 39 echo ZERO_PT 25.0 40 echo ADDSTAR_RADIUS 1.0 41 echo CATMODE SPLIT 42 echo CATFORMAT PS1_V5 43 # echo CATFORMAT PS1_V2 -- must be at least PS1_V3 for ubercaldist to work 44 echo SKY_DEPTH 4 45 echo CAMERA gpc1 46 echo CAMERA_CONFIG dvo.layout 47 echo "input dvo.config" 48 output stdout 49 50 # we need to define a photcode table consistent with the fake construction 51 $zpt_nominal:g = 24.0 52 $zpt_nominal:r = 24.5 53 54 # klam is negative, so klam*(airmass - 1) increases the zero point 55 $klam_nominal:g = -0.15 56 $klam_nominal:r = -0.10 57 58 # generate a fake dvo.photcode 59 exec rm -f dvo.photcodes 60 output dvo.photcodes 61 echo "\# code name type zero slope offset c1 c2 slope zero equiv sys scale scale sys poor bad poor bad" 62 echo "1 g sec 0.000 0.000 0.000 1 3 0.0000 0 1051 0.000 0.000 0.000 0.000 0x0000 0x0000 0x0000 0x0000" 63 echo "2 r sec 0.000 0.000 0.000 2 3 0.0000 0 1052 0.000 0.000 0.000 0.000 0x0000 0x0000 0x0000 0x0000" 64 echo "10000 GPC1.g.XY00 dep $zpt_nominal:g $klam_nominal:g 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 65 echo "10001 GPC1.g.XY01 dep $zpt_nominal:g $klam_nominal:g 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 66 echo "10010 GPC1.g.XY10 dep $zpt_nominal:g $klam_nominal:g 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 67 echo "10011 GPC1.g.XY11 dep $zpt_nominal:g $klam_nominal:g 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 68 echo "10100 GPC1.r.XY00 dep $zpt_nominal:r $klam_nominal:r 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 69 echo "10101 GPC1.r.XY01 dep $zpt_nominal:r $klam_nominal:r 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 70 echo "10110 GPC1.r.XY10 dep $zpt_nominal:r $klam_nominal:r 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 71 echo "10111 GPC1.r.XY11 dep $zpt_nominal:r $klam_nominal:r 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 72 echo "2011 2MASS_J ref 0.000 0.000 0.000 - - 0.0000 0 6 0.080 0.000 2.000 0.000 0x0000 0x0000 0x0000 0x0000" 73 echo "3001 SYNTH.g ref 0.000 0.000 0.000 - - 0.0000 0 1 nan 0.000 2.000 0.600 0x0000 0x0000 0x0000 0x0000" 74 echo "2020 TYCHO_B ref 0.000 0.000 0.000 - - 0.0000 0 - 0.000 0.000 0.000 0.000 0x0000 0x0000 0x0000 0x0000" 75 output stdout 76 23 77 $RA_CENTER = 10.0 24 78 $DEC_CENTER = 20.0 … … 32 86 $CHIP_DX = 1000 33 87 $CHIP_DY = 1000 34 35 # images are loaded into dvo with GPC1 photcodes, so we need to get the nominal zps for those filters 36 $zpt_nominal:g = 24.58 37 $zpt_nominal:r = 24.80 38 $zpt_nominal:i = 24.74 39 $zpt_nominal:z = 24.26 40 $zpt_nominal:y = 23.41 41 42 # klam is negative, so klam*(airmass - 1) increase the zero point 43 $klam_nominal:g = -0.15 44 $klam_nominal:r = -0.10 45 $klam_nominal:i = -0.04 46 $klam_nominal:z = -0.03 47 $klam_nominal:y = -0.03 88 $DEFECT_FRAC = 0.05 89 $OFFSET_FRAC_UC = 0.0 90 $OFFSET_FRAC_NC = 0.5 48 91 49 92 # we have two sets of images: ubercaled and not-ubercaled 50 93 51 # sequence to count images (only used in this function) 52 create tmpseq 0 9 53 54 $filt_uc:n = 9 55 $filt_uc:0 = g 56 $filt_uc:1 = g 57 $filt_uc:2 = g 58 $filt_uc:3 = r 59 $filt_uc:4 = r 60 $filt_uc:5 = r 61 $filt_uc:6 = i 62 $filt_uc:7 = i 63 $filt_uc:8 = i 64 65 # airmass slopes for these sequnece 94 # the number of exposures is defined by filt_uc:n 95 list filt_uc -split g g g g r r r r 96 $filt_uc:n = 4 97 98 # tmpseq is used to generate vectors in this function 99 create tmpseq 0 $filt_uc:n 100 101 # exptime and airmasses for uc images 102 set exptime_uc = 10.0 + zero(tmpseq) 103 set airmass_uc = 1.3 + zero(tmpseq) 66 104 set klam_uc = zero(tmpseq) 67 for i 0 tmpseq[] 68 klam_uc[$i] = $klam_nominal:$filt_uc:$i 69 end 70 71 # mjd and zpt values for ubercal'ed imaged 72 set exptime_uc = 10.0 + zero(tmpseq) 73 set airmass_uc = 1.3 + zero(tmpseq) 105 set zpt_uc = zero(tmpseq) 74 106 75 107 # ubercal zero points are defined as ZP_nominal + 2.5log(exptime) + K*(airmass - 1.0) 76 108 # note that K is defined as a negative value (is this sensible?) 77 set zpt_uc = 25.0 + 2.5*log(exptime_uc) + klam_uc*(airmass_uc - 1.0) + tmpseq*0.0050 - 0.0025 78 79 set mjd_uc = zero(zpt_uc) 80 mjd_uc[0] = 55000.01 81 mjd_uc[1] = 55000.02 82 mjd_uc[2] = 55000.03 83 mjd_uc[3] = 55015.01 84 mjd_uc[4] = 55015.02 85 mjd_uc[5] = 55015.03 86 mjd_uc[6] = 55025.01 87 mjd_uc[7] = 55025.02 88 mjd_uc[8] = 55025.03 109 110 # zero points and airmass slopes for these sequnece 111 for i 0 $filt_uc:n 112 klam_uc[$i] = $klam_nominal:$filt_uc:$i 113 zpt_uc[$i] = $zpt_nominal:$filt_uc:$i + 2.5*log(exptime_uc[$i]) + klam_uc[$i]*(airmass_uc[$i] - 1.0) + $UC_CLOUDS*(rnd(klam_uc[$i]) - 0.5) 114 end 115 set mjd_uc = 55000.00 + 0.01*(tmpseq % 3) + 10.0*int(tmpseq / 3) 89 116 90 117 # mjd and zpt values for not-ubercal'ed images 91 $filt_nc:n = 9 92 $filt_nc:0 = g 93 $filt_nc:1 = g 94 $filt_nc:2 = g 95 $filt_nc:3 = r 96 $filt_nc:4 = r 97 $filt_nc:5 = r 98 $filt_nc:6 = i 99 $filt_nc:7 = i 100 $filt_nc:8 = i 118 list filt_nc -split g g g g r r r r 119 $filt_nc:n = 4 120 121 # tmpseq is used to generate vectors in this function 122 create tmpseq 0 $filt_nc:n 123 124 # place this within a valid season (55000.0 - 55010.0 - 55020.0 - 55030.0) 125 set exptime_nc = 10.0 + zero(tmpseq) 126 set airmass_nc = 1.6 + zero(tmpseq) 127 set klam_nc = zero(tmpseq) 128 set zpt_nc = zero(tmpseq) 101 129 102 130 # airmass slopes for these sequnece 103 set klam_nc = zero(tmpseq)104 for i 0 tmpseq[]105 klam_nc[$i] = $klam_nominal:$filt_nc:$i131 for i 0 $filt_nc:n 132 klam_nc[$i] = $klam_nominal:$filt_nc:$i 133 zpt_nc[$i] = $zpt_nominal:$filt_nc:$i + 2.5*log(exptime_nc[$i]) + klam_nc[$i]*(airmass_nc[$i] - 1.0) + $NC_CLOUDS*(rnd(klam_nc[$i]) - 0.5) 106 134 end 107 108 # place this within a valid season (55000.0 - 55010.0 - 55020.0 - 55030.0) 109 set exptime_nc = 15.0 + zero(tmpseq) 110 set airmass_nc = 1.6 + zero(tmpseq) 111 112 # ubercal zero points are defined as ZP_nominal + 2.5log(exptime) + K*(airmass - 1.0) 113 set zpt_nc = 25.0 + 2.5*log(exptime_nc) + klam_nc*(airmass_nc - 1.0) - tmpseq*0.0050 + 0.0025 114 115 set mjd_nc = zero(zpt_nc) 116 mjd_nc[0] = 55000.11 117 mjd_nc[1] = 55000.12 118 mjd_nc[2] = 55000.13 119 mjd_nc[3] = 55015.11 120 mjd_nc[4] = 55015.12 121 mjd_nc[5] = 55015.13 122 mjd_nc[6] = 55025.11 123 mjd_nc[7] = 55025.12 124 mjd_nc[8] = 55025.13 135 set mjd_nc = 55000.10 + 0.01*(tmpseq % 3) + 10.0*int(tmpseq / 3) 136 137 delete tmpseq 125 138 end 126 139 … … 139 152 mkdir $rootdir 140 153 154 break -auto off 141 155 exec rm -rf $catdir 156 exec rm -rf $fileroot* 157 break -auto on 142 158 143 159 init 144 160 mkzptfile 145 mkstars 500 161 mkstars 1000 162 163 catdir $catdir 164 165 mk2mass $fileroot $catdir 166 ck2mass addstar 167 168 mksynth $fileroot $catdir 169 cksynth addstar 170 171 # to add a valid tycho test, I need to generate a zpt table for tycho as well 172 mktycho $fileroot $catdir 173 cktycho addstar 146 174 147 175 tapPLAN {((mjd_uc[]*4 + mjd_nc[]*4) + (mjd_uc[] + mjd_nc[]) + (mjd_uc[] + mjd_nc[])) / 3} … … 149 177 # generate the basic images and check they were correctly ingested by dvo 150 178 mksequence $fileroot $catdir 151 for i 0 mjd_uc[] 3152 ckexposure catdir.testmjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i raw153 end 154 for i 0 mjd_nc[] 3155 ckexposure catdir.testmjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i raw179 for i 0 mjd_uc[] 180 ckexposure $catdir mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i raw 181 end 182 for i 0 mjd_nc[] 183 ckexposure $catdir mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i raw 156 184 end 157 185 158 186 # run setphot on the db and check that the images now match the expected values 159 execsetphot -update -ubercal testzpt.fits -D CATDIR $catdir160 for i 0 mjd_uc[] 3161 ckexposure catdir.testmjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i setphot_uc162 end 163 for i 0 mjd_nc[] 3164 ckexposure catdir.testmjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i setphot_nc187 tapEXEC setphot -update -ubercal testzpt.fits -D CATDIR $catdir 188 for i 0 mjd_uc[] 189 ckexposure $catdir mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i setphot_uc 190 end 191 for i 0 mjd_nc[] 192 ckexposure $catdir mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i setphot_nc 165 193 end 166 194 167 195 # run relphot on the db and check that the images now match the expected values 168 exec relphot g,r,i -v -region 9.5 10.5 19.5 20.5 -D CATDIR catdir.test -D STAR_TOOFEW 1 -D SIGMA_LIM 0.07 -statmode WT_MEAN -cloud-limit 0.5 -keep-ubercal -D IMAGE_OFFSET 0.5 -update >& tmp.log 169 for i 0 mjd_uc[] 3 170 ckexposure catdir.test mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i relphot 171 end 172 for i 0 mjd_nc[] 3 173 ckexposure catdir.test mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i relphot 174 end 196 tapEXEC relphot -images g,r -v -region 9.5 10.5 19.5 20.5 -D CATDIR $catdir -D STAR_TOOFEW 1 -D SIGMA_LIM 0.07 -statmode WT_MEAN -cloud-limit 0.5 -D IMAGE_OFFSET 0.5 -update -synthphot_zpts $fileroot.synthzpts.fits 197 for i 0 mjd_uc[] 198 ckexposure $catdir mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i relphot_uc 199 end 200 for i 0 mjd_nc[] 201 ckexposure $catdir mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i relphot_nc 202 end 203 ck2mass relphot 204 cksynth relphot 205 cktycho relphot 175 206 176 207 tapDONE 208 end 209 210 macro try.relphot 211 if ($0 != 3) 212 echo "go (fileroot) (catdir)" 213 break 214 end 215 216 local i fileroot rootdir catdir 217 218 $fileroot = $1 219 $catdir = $2 220 221 # run relphot on the db and check that the images now match the expected values 222 tapEXEC relphot -images g,r -v -region 9.5 10.5 19.5 20.5 -D CATDIR $catdir -D STAR_TOOFEW 1 -D SIGMA_LIM 0.07 -statmode WT_MEAN -cloud-limit 0.5 -D IMAGE_OFFSET 0.5 -update -synthphot_zpts $fileroot.synthzpts.fits -nloop 24 223 224 for i 0 mjd_uc[] 225 # ckexposure $catdir mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i relphot_uc 226 ckexposure $catdir mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i relphot_uc 227 end 228 for i 0 mjd_nc[] 229 # ckexposure $catdir mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i relphot_nc 230 ckexposure $catdir mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i relphot_nc 231 end 177 232 end 178 233 … … 215 270 $AIRMASS = $5 216 271 $FILTER = $6 217 $ MODE= $7272 $FUNC_MODE = $7 218 273 219 274 # XXX need a function to extract the nominal zpt for a given filter / photcode from the db … … 235 290 236 291 skyregion {$RA_CENTER - 0.2/dcos($DEC_CENTER)} {$RA_CENTER + 0.2/dcos($DEC_CENTER)} {$DEC_CENTER - 0.2} {$DEC_CENTER + 0.2} 237 mextract ra dec mag xccd yccd where (abs(time - $MJD_IMAGE) < 0.0001)292 mextract ra dec mag xccd yccd dbflags photflags where (abs(time - $MJD_IMAGE) < 0.0001) 238 293 239 294 match2d -closest ra dec stars_ra stars_dec 0.001 -index1 index1 -index2 index2 … … 246 301 set dm = mag - stars_mag_m 247 302 303 set good_photom = (not(photflags & 0x02)) 304 foreach field dm xccd yccd 305 subset $field\_good = $field if good_photom 306 end 307 248 308 if ($PLOT) 249 309 dev -n 1 250 lim mag dm; clear; box; plot mag dm 251 end 252 253 set cell_xbin = int(xccd / ($CHIP_DX / $NCELL_X)) 254 set cell_ybin = int(yccd / ($CHIP_DY / $NCELL_Y)) 255 subset dm00 = dm if (cell_xbin == 0) && (cell_ybin == 0) 256 subset dm01 = dm if (cell_xbin == 0) && (cell_ybin == 1) 257 subset dm10 = dm if (cell_xbin == 1) && (cell_ybin == 0) 258 subset dm11 = dm if (cell_xbin == 1) && (cell_ybin == 1) 310 lim mag dm; clear; box; plot mag dm; plot -c red -pt 7 mag dm where (photflags & 0x00000002) 311 dev -n 2 312 lim xccd dm; clear; box; plot xccd dm; plot -c red -pt 7 xccd dm where (photflags & 0x00000002) 313 dev -n 3 314 lim ra dm; clear; box; plot ra dm; plot -c red -pt 7 ra dm where (photflags & 0x00000002) 315 echo "red points are known bad photometry" 316 end 317 318 # reproduce eddie's esoteric padding 319 set cell_xbin = max(0 , min(1 , int((xccd_good + 8) / ($CHIP_DX / $NCELL_X)))) 320 set cell_ybin = max(0 , min(1 , int((yccd_good + 10) / ($CHIP_DY / $NCELL_Y)))) 321 subset dm00 = dm_good if (cell_xbin == 0) && (cell_ybin == 0) 322 subset dm01 = dm_good if (cell_xbin == 0) && (cell_ybin == 1) 323 subset dm10 = dm_good if (cell_xbin == 1) && (cell_ybin == 0) 324 subset dm11 = dm_good if (cell_xbin == 1) && (cell_ybin == 1) 259 325 260 326 # uncorrected values behave like this: … … 273 339 $ZPT_REAL_NORM = $ZPT_REAL - 2.5*log($EXPTIME) - $KLAM_NOMINAL*($AIRMASS - 1.0) 274 340 275 if ("$ MODE" == "raw")341 if ("$FUNC_MODE" == "raw") 276 342 for ix 0 $NCELL_X 277 343 for iy 0 $NCELL_Y … … 280 346 281 347 set dm_adjust = dm$ix\$iy - $ZPT_NOMINAL + $ZPT_REAL_NORM + cell_off[$ix][$iy] 348 # echo set dm_adjust = dm$ix\$iy - $ZPT_NOMINAL + $ZPT_REAL_NORM + cell_off[$ix][$iy] 349 282 350 vstat -q dm_adjust 283 tapOK {abs($MEAN) < 0.005} "addstar raw ZP $MJD_IMAGE $FILTER" 351 sprintf line "addstar raw ZP %8.2f $FILTER %6.3f %6.3f %6.3f: %7.4f %7.4f : cell%d%d %6.3f : %3d" $MJD_IMAGE $ZPT_REAL $ZPT_REAL_NORM $ZPT_NOMINAL $MEAN $SIGMA $ix $iy cell_off[$ix][$iy] dm_adjust[] 352 tapOK {abs($MEAN) < 0.005} "$line" 284 353 end 285 354 end … … 287 356 end 288 357 289 if ("$MODE" == "setphot_uc") 290 vstat -q dm 291 tapOK {abs($MEAN) < 0.005} "setphot_uc ZP $MJD_IMAGE $FILTER" 358 if ("$FUNC_MODE" == "setphot_uc") 359 vstat -q dm_good 360 sprintf line "setphot_uc ZP %8.2f $FILTER %6.3f %6.3f %6.3f: %7.4f %7.4f : %3d" $MJD_IMAGE $ZPT_REAL $ZPT_REAL_NORM $ZPT_NOMINAL $MEAN $SIGMA dm_good[] 361 tapOK {abs($MEAN) < 0.005} "$line" 362 363 subset tmp = dm if (dbflags & 0x00008000) 364 tapOK {tmp[] == dm[]} "ubercal detections have ubercal bit set" 365 366 imextract MCAL FLAGS where (abs(time - $MJD_IMAGE) < 0.0001) 367 subset tmp = FLAGS if (FLAGS & 0x0000200) 368 tapOK {tmp[] == FLAGS[]} "ubercal images have ubercal bit set" 369 292 370 return 293 371 end 294 372 295 if ("$MODE" == "setphot_nc") 296 vstat -q dm 297 tapOK {abs($MEAN - $ZPT_NOMINAL + $ZPT_REAL_NORM) < 0.005} "setphot_nc ZP $MJD_IMAGE $FILTER" 373 if ("$FUNC_MODE" == "setphot_nc") 374 vstat -q dm_good 375 sprintf line "setphot_nc ZP %8.2f $FILTER %6.3f %6.3f %6.3f: %7.4f %7.4f : %3d" $MJD_IMAGE $ZPT_REAL $ZPT_REAL_NORM $ZPT_NOMINAL $MEAN $SIGMA dm_good[] 376 tapOK {abs($MEAN - $ZPT_NOMINAL + $ZPT_REAL_NORM) < 0.005} "$line" 377 378 subset tmp = dm if (not(dbflags & 0x00008000)) 379 tapOK {tmp[] == dm[]} "non-ubercal detections do NOT have ubercal bit set" 380 381 imextract FLAGS where (abs(time - $MJD_IMAGE) < 0.0001) 382 subset tmp = FLAGS if (not(FLAGS & 0x0000200)) 383 tapOK {tmp[] == FLAGS[]} "non-ubercal images do NOT have ubercal bit set" 384 298 385 return 299 386 end 300 387 301 if ("$MODE" == "relphot") 302 vstat -q dm 303 tapOK {abs($MEAN) < 0.005} "relphot ZP $MJD_IMAGE $FILTER" 388 if (("$FUNC_MODE" == "relphot_uc") || ("$FUNC_MODE" == "relphot_nc")) 389 vstat -q dm_good 390 sprintf line "relphot ZP %8.2f $FILTER %6.3f %6.3f %6.3f: %7.4f %7.4f : %3d" $MJD_IMAGE $ZPT_REAL $ZPT_REAL_NORM $ZPT_NOMINAL $MEAN $SIGMA dm_good[] 391 392 if ("$FUNC_MODE" == "relphot_uc") 393 tapOK {abs($MEAN) < 0.001} "$line" 394 tapOK {abs($SIGMA) < 0.001} "$line" 395 end 396 if ("$FUNC_MODE" == "relphot_nc") 397 # XXX NOTE relaxed condition : bad photometry points are partly clipped but still cause a bias 398 tapOK {abs($MEAN) < 0.020} "$line" 399 tapOK {abs($SIGMA) < 0.020} "$line" 400 end 401 402 mextract ra dec mag dbflags 403 subset rs = ra if ((dbflags & 0x8000) && (mag > 13.5)) 404 subset ds = dec if ((dbflags & 0x8000) && (mag > 13.5)) 405 avmatch rs ds 0.1 $FILTER\:flags $FILTER\:uc_dist 406 407 subset tmp = rs if (($FILTER\:flags & 0x8) || ($FILTER\:flags & 0x4)) 408 tapOK {tmp[] == rs[]} "objects with ubercal detections have ubercal bit set or used SYNTH photometry (tmp[] vs rs[])" 409 410 subset tmp = rs if (($FILTER\:uc_dist < 0.1) || ($FILTER\:flags & 0x4)) 411 tapOK {tmp[] == rs[]} "objects with ubercal detections have ubercal dist of 0.0 or used SYNTH photometry" 304 412 return 305 413 end 414 415 echo "ERROR: unknown mode for ckexposure : $FUNC_MODE" 306 416 307 417 end … … 316 426 317 427 # we have defined a set of mjd and zero point values for ubercal'ed images 318 # for i 0 mjd_uc[] 319 for i 0 mjd_uc[] 3 428 for i 0 mjd_uc[] 320 429 mkexposure $1.uc.$i $RA_CENTER $DEC_CENTER zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] mjd_uc[$i] $filt_uc:$i $2 321 430 end 322 431 323 432 # we have a second set of mjd and zero point values for non-ubercal'ed images 324 # for i 0 mjd_nc[] 325 for i 0 mjd_nc[] 3 433 for i 0 mjd_nc[] 326 434 mkexposure $1.nc.$i $RA_CENTER $DEC_CENTER zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] mjd_nc[$i] $filt_nc:$i $2 327 435 end … … 334 442 end 335 443 336 local ix iy date time datetime ra dec ROOT RAo DECo ZPT MJD FILTER EXPTIME AIRMASS CATDIR 444 local ix iy date time datetime ra dec ROOT RAo DECo ZPT MJD FILTER EXPTIME AIRMASS CATDIR cmd 337 445 338 446 $ROOT = $1 … … 366 474 $options = -mjd $MJD 367 475 $options = $options -radec $ra $dec 368 $options = $options -type PS1_V2 476 477 #$options = $options -type PS1_V2 478 #$options = $options -type PS1_V3 479 #$options = $options -type PS1_V4 480 $options = $options -type PS1_V5 481 369 482 $options = $options -coords 370 483 $options = $options -photcode GPC1.$FILTER.XY$ix\$iy 371 484 $options = $options -no-noise 485 $options = $options -flags 486 $options = $options -bad-psfqf-frac $DEFECT_FRAC 372 487 $options = $options -size $CHIP_DX $CHIP_DY 373 488 $options = $options -crpix {0.5*$CHIP_DX} {0.5*$CHIP_DY} 374 489 $options = $options -airmass $AIRMASS 375 490 $options = $options -exptime $EXPTIME 376 exec mkcmf test.in.txt $ROOT.$ix.$iy.cmf $options 377 echo mkcmf test.in.txt $ROOT.$ix.$iy.cmf $options378 491 492 tapEXEC mkcmf test.in.txt $ROOT.$ix.$iy.cmf $options 493 379 494 # the fake images have inconsistent ra,dec and airmass,sidtime values 380 echo addstar $ROOT.$ix.$iy.cmf -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass 381 exec addstar $ROOT.$ix.$iy.cmf -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass >& tmp.log 495 tapEXEC addstar $ROOT.$ix.$iy.cmf -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass 382 496 end 383 497 end … … 405 519 subset stars_mr = stars_mag if valid 406 520 407 set cell_x = int(stars_x / ($CHIP_DX / $NCELL_X)) 408 set cell_y = int(stars_y / ($CHIP_DX / $NCELL_X)) 521 # note eddie's esoteric padding rule: 522 set cell_x = max(0 , min(1 , int((stars_x + 8) / ($CHIP_DX / $NCELL_X)))) 523 set cell_y = max(0 , min(1 , int((stars_y + 10) / ($CHIP_DX / $NCELL_X)))) 409 524 410 525 # eddie says: M_real = M_inst + zpt + ff_offset … … 418 533 end 419 534 420 write -f "%10.6f %10.6f %7.3f %6.1f %6.1f %7.3f" $1 stars_r stars_d stars_mr stars_x stars_y stars_mi 535 # create bad detections / detections to ignore or avoid, save to a file? 536 537 # create 3 types of things to ignore / avoid 538 # * badPhot (deviate the photometry) 539 # * badFlag (set a bad flag bit) 540 # * poorFlag (set a bad flag bit) 541 set badPhot = rnd(stars_r) < $DEFECT_FRAC 542 set badFlag = rnd(stars_r) < $DEFECT_FRAC 543 set poorFlag = rnd(stars_r) < $DEFECT_FRAC 544 545 # create deviant photometry (1%) 546 # I'm setting the flag value 0x02 (EXTMODEL) if the object is deviated. This is a simple way to pass the info 547 # note that outlier rejection only occurs for Nmeas > 5 548 set stars_mi = stars_mi + 0.2*badPhot 549 set stars_fl = zero(stars_mi) + 0x00000080*badFlag + 0x00000100*poorFlag + 0x00000002*badPhot 550 551 # bad flags that we sould respect: 552 # PM_SOURCE_MODE_FAIL = 0x00000008, ///< Fit (non-linear) failed (non-converge, off-edge, run to zero) 553 # PM_SOURCE_MODE_SATSTAR = 0x00000080, ///< Source model peak is above saturation 554 # PM_SOURCE_MODE_BADPSF = 0x00000400, ///< Failed to get good estimate of object's PSF 555 # PM_SOURCE_MODE_DEFECT = 0x00000800, ///< Source is thought to be a defect 556 # PM_SOURCE_MODE_SATURATED = 0x00001000, ///< Source is thought to be saturated pixels (bleed trail) 557 # PM_SOURCE_MODE_CR_LIMIT = 0x00002000, ///< Source has crNsigma above limit 558 # PM_SOURCE_MODE_MOMENTS_FAILURE = 0x00008000, ///< could not measure the moments 559 # PM_SOURCE_MODE_SKY_FAILURE = 0x00010000, ///< could not measure the local sky 560 # PM_SOURCE_MODE_SKYVAR_FAILURE = 0x00020000, ///< could not measure the local sky variance 561 # PM_SOURCE_MODE_SIZE_SKIPPED = 0x10000000, ///< size could not be determined 562 563 # poor flags that we should respect: 564 # PM_SOURCE_MODE_POOR = 0x00000010, ///< Fit succeeds, but low-SN, high-Chisq, or large (for PSF -- drop?) 565 # PM_SOURCE_MODE_PAIR = 0x00000020, ///< Source fitted with a double psf 566 # PM_SOURCE_MODE_BLEND = 0x00000100, ///< Source is a blend with other sources 567 # PM_SOURCE_MODE_BELOW_MOMENTS_SN = 0x00040000, ///< moments not measured due to low S/N 568 # PM_SOURCE_MODE_BLEND_FIT = 0x00400000, ///< source was fitted as a blend 569 # PM_SOURCE_MODE_ON_SPIKE = 0x20000000, ///< peak lands on diffraction spike 570 # PM_SOURCE_MODE_ON_GHOST = 0x40000000, ///< peak lands on ghost or glint 571 # PM_SOURCE_MODE_OFF_CHIP = 0x80000000, ///< peak lands off edge of chip 572 573 write -f "%10.6f %10.6f %7.3f %6.1f %6.1f %7.3f 0x%x" $1 stars_r stars_d stars_mr stars_x stars_y stars_mi stars_fl 421 574 end 422 575 … … 439 592 set stars_ra = $RA_CENTER + $RA_RANGE * (rnd(tmp) - 0.5) / 3600 / dcos ($DEC_CENTER) 440 593 set stars_dec = $DEC_CENTER + $DEC_RANGE * (rnd(tmp) - 0.5) / 3600 441 set stars_mag = 15.0 + 4.0 * rnd(tmp) 594 set stars_mag = 10.0 + 10.0 * rnd(tmp) 595 set stars_dmag = 0.02 + 0.1*rnd(tmp) 596 end 597 598 macro mk2mass 599 if ($0 != 3) 600 echo "USAGE: mk2mass (fileroot) (catdir)" 601 break 602 end 603 604 if (not($DO_2MASS)) return 605 606 local ROOT CATDIR 607 608 $ROOT = $1 609 $CATDIR = $2 610 611 set stars_flags = 0x00c00000*(rnd(stars_ra) < 0.1) + 0x7*(rnd(stars_ra) < 0.8) 612 write $ROOT.2mass.dat -f "%10.6f %10.6f %6.3f %6.3f 0x%x" stars_ra stars_dec stars_mag stars_dmag stars_flags 613 614 tapEXEC addstar -ref $ROOT.2mass.dat -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass -photcode 2MASS_J 615 616 set r_2mass = stars_ra 617 set d_2mass = stars_dec 618 set m_2mass = stars_mag 619 set dm_2mass = stars_dmag 620 set fl_2mass = stars_flags 621 end 622 623 macro ck2mass 624 if ($0 != 2) 625 echo "USAGE: ck2mass (stage)" 626 break 627 end 628 629 if (not($DO_2MASS)) return 630 631 if ("$1" == "addstar") 632 skyregion {$RA_CENTER - 0.2/dcos($DEC_CENTER)} {$RA_CENTER + 0.2/dcos($DEC_CENTER)} {$DEC_CENTER - 0.2} {$DEC_CENTER + 0.2} 633 mextract ra dec mag xccd yccd dbflags photflags where (photcode == 2011) 634 tapOK {ra[] == r_2mass[]} "read in as many 2mass stars as we generated" 635 636 match2d -closest ra dec r_2mass d_2mass 0.001 -index1 index1 -index2 index2 637 subset tmp = index1 if (index1 >= 0) 638 tapOK {tmp[] == ra[]} "2mass sources match those generated" 639 end 640 641 if ("$1" == "relphot") 642 subset rs = r_2mass if (fl_2mass & 0x00c00000) 643 subset ds = d_2mass if (fl_2mass & 0x00c00000) 644 avmatch rs ds 0.1 flags 645 subset tmp = rs if (flags & 0x02000000); # extended in 2mass 646 tapOK {tmp[] == rs[]} "2mass extended objects properly marked" 647 648 subset rs = r_2mass if (fl_2mass & 0x07) 649 subset ds = d_2mass if (fl_2mass & 0x07) 650 avmatch rs ds 0.1 flags 651 subset tmp = rs if (flags & 0x08000000); # extended in 2mass 652 tapOK {tmp[] == rs[]} "2mass good objects properly marked" 653 end 654 end 655 656 macro mksynth 657 if ($0 != 3) 658 echo "USAGE: mksynth (fileroot) (catdir)" 659 break 660 end 661 662 if (not($DO_SYNTH)) return 663 664 local ROOT CATDIR 665 666 $ROOT = $1 667 $CATDIR = $2 668 669 subset r_synth = stars_ra if (stars_mag < 17) 670 subset d_synth = stars_dec if (stars_mag < 17) 671 subset m_synth = stars_mag if (stars_mag < 17) 672 subset dm_synth = stars_dmag if (stars_mag < 17) 673 subset fl_synth = stars_flags if (stars_mag < 17) 674 675 write $ROOT.synth.dat -f "%10.6f %10.6f %6.3f %6.3f 0x%x" r_synth d_synth m_synth dm_synth fl_synth 676 677 tapEXEC addstar -ref $ROOT.synth.dat -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass -photcode SYNTH.g 678 end 679 680 macro cksynth 681 if ($0 != 2) 682 echo "USAGE: cksynth (stage)" 683 break 684 end 685 686 if (not($DO_SYNTH)) return 687 688 if ("$1" == "addstar") 689 skyregion {$RA_CENTER - 0.2/dcos($DEC_CENTER)} {$RA_CENTER + 0.2/dcos($DEC_CENTER)} {$DEC_CENTER - 0.2} {$DEC_CENTER + 0.2} 690 mextract ra dec mag xccd yccd dbflags photflags where (photcode == 3001) 691 tapOK {ra[] == r_synth[]} "read in as many synth stars as we generated" 692 693 match2d -closest ra dec r_synth d_synth 0.001 -index1 index1 -index2 index2 694 subset tmp = index1 if (index1 >= 0) 695 tapOK {tmp[] == ra[]} "synth sources match those generated" 696 end 697 698 if ("$1" == "relphot") 699 subset rs = r_synth if (m_synth < 13.5) 700 subset ds = d_synth if (m_synth < 13.5) 701 avmatch rs ds 0.1 g:flags 702 subset tmp = rs if (g:flags & 0x04); # synth used for photometry 703 tapOK {tmp[] == rs[]} "synth objects used for photometry properly marked" 704 end 705 end 706 707 macro mktycho 708 if ($0 != 3) 709 echo "USAGE: mktycho (fileroot) (catdir)" 710 break 711 end 712 713 if (not($DO_TYCHO)) return 714 715 local ROOT CATDIR 716 717 $ROOT = $1 718 $CATDIR = $2 719 720 subset r_tycho = stars_ra if (stars_mag < 12) 721 subset d_tycho = stars_dec if (stars_mag < 12) 722 subset m_tycho = stars_mag if (stars_mag < 12) 723 subset dm_tycho = stars_dmag if (stars_mag < 12) 724 subset fl_tycho = stars_flags if (stars_mag < 12) 725 726 write $ROOT.tycho.dat -f "%10.6f %10.6f %6.3f %6.3f 0x%x" r_tycho d_tycho m_tycho dm_tycho fl_tycho 727 728 tapEXEC addstar -ref $ROOT.tycho.dat -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass -photcode TYCHO_B 729 730 $KAPA = kapa -noX 731 dev -n tmpdev 732 # resize 100 100 733 resize 50 50 734 region $RA_CENTER $DEC_CENTER 0.2 735 section default -imtool none 736 # causes trouble for this to come before region... 737 create tmp 0 1 738 cdensify tmpmap tmp tmp 739 set map = zero(tmpmap) + 0.2 740 close 741 $KAPA = kapa 742 743 local filter 744 foreach filter g r i z y 745 if ("$filter" == "g") 746 wd map $ROOT.synthzpts.fits -bitpix -32 -bzero 0.0 -bscale 1.0 747 end 748 keyword map EXTNAME -w "map_$filter" 749 wd map $ROOT.synthzpts.fits -bitpix -32 -bzero 0.0 -bscale 1.0 -extend 750 end 751 end 752 753 macro cktycho 754 if ($0 != 2) 755 echo "USAGE: cktycho (stage)" 756 break 757 end 758 759 if (not($DO_TYCHO)) return 760 761 if ("$1" == "addstar") 762 skyregion {$RA_CENTER - 0.2/dcos($DEC_CENTER)} {$RA_CENTER + 0.2/dcos($DEC_CENTER)} {$DEC_CENTER - 0.2} {$DEC_CENTER + 0.2} 763 mextract ra dec mag xccd yccd dbflags photflags where (photcode == 2020) 764 tapOK {ra[] == r_tycho[]} "read in as many tycho stars as we generated" 765 766 match2d -closest ra dec r_tycho d_tycho 0.001 -index1 index1 -index2 index2 767 subset tmp = index1 if (index1 >= 0) 768 tapOK {tmp[] == ra[]} "tycho sources match those generated" 769 end 770 771 if ("$1" == "relphot") 772 subset rst = r_tycho if (m_tycho < 12) 773 subset dst = d_tycho if (m_tycho < 12) 774 # XXX : should not restrict to 'g' 775 avmatch rst dst 0.1 g:flags 776 subset tmp = rst if (g:flags & 0x40); # tycho used for photometry 777 tapOK {tmp[] == rst[]} "tycho objects used for photometry properly marked" 778 779 # non-tycho stars with synth phot should be repaired 780 subset rsn = r_synth if (m_synth > 12) && (m_synth < 13.5) 781 subset dsn = d_synth if (m_synth > 12) && (m_synth < 13.5) 782 # XXX : should not restrict to 'g' 783 avmatch rsn dsn 0.1 g:flags 784 subset tmp = rsn if (g:flags & 0x80); # synth photometry repaired 785 tapOK {tmp[] == rsn[]} "tycho objects used for photometry properly marked" 786 end 442 787 end 443 788 … … 456 801 457 802 # define the season boundaries 458 keyword phu TS0_0000 -wf 55000.0459 keyword phu TS1_0000 -wf 55010.0460 keyword phu TS0_0001 -wf 55010.0461 keyword phu TS1_0001 -wf 55020.0462 keyword phu TS0_0002 -wf 55020.0463 keyword phu TS1_0002 -wf 55030.0803 keyword phu S0_MJD0 -wf 55000.0 804 keyword phu S1_MJD0 -wf 55010.0 805 keyword phu S0_MJD1 -wf 55010.0 806 keyword phu S1_MJD1 -wf 55020.0 807 keyword phu S0_MJD2 -wf 55020.0 808 keyword phu S1_MJD2 -wf 55030.0 464 809 465 810 # create a single flat-field correction map for a single chip 466 811 mcreate cell_off 2 2 467 cell_off[0][0] = 0.01 468 cell_off[1][0] = -0.01 469 cell_off[0][1] = 0.02 470 cell_off[1][1] = -0.02 812 if ($USE_CELL_OFFSETS) 813 cell_off[0][0] = 0.05 814 cell_off[1][0] = -0.03 815 cell_off[0][1] = 0.08 816 cell_off[1][1] = -0.10 817 end 471 818 472 819 # in the correction table, we have an image of the full exposure … … 481 828 for iyc 0 $NCELL_Y 482 829 for ix 0 $NCHIP_X 830 set tcell_off = cell_off 831 if ($ix < 4) 832 rotate tcell_off 180 833 end 483 834 for ixc 0 $NCELL_X 484 concat cell_off[$ixc][$iyc] image_offset835 concat tcell_off[$ixc][$iyc] image_offset 485 836 end 486 837 end … … 498 849 set mjd_obs = mjd_uc 499 850 set zp = zpt_uc 500 set resid = 0.02*rnd(zpt_uc) - 0.01 851 852 if ($SET_UC_RESID) 853 set resid = 0.02*rnd(zpt_uc) - 0.01 854 else 855 set resid = zero(zpt_uc) 856 end 501 857 502 858 delete -q flatcorr -
branches/eam_branches/ohana.20150429/src/addstar/test/simple.dvo
r38347 r38348 54 54 55 55 mkinput 56 echo mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC -type $1 $NO_NOISE 57 exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC -type $1 $NO_NOISE 58 if ($TAP_VERBOSE) 59 echo exec addstar -D CATDIR catdir.test -D CAMERA simtest test.cmf -D CATFORMAT $2 -quick-airmass 60 exec addstar -D CATDIR catdir.test -D CAMERA simtest test.cmf -D CATFORMAT $2 -quick-airmass 61 else 62 echo addstar -D CATDIR catdir.test -D CAMERA simtest test.cmf -D CATFORMAT $2 -quick-airmass 63 exec addstar -D CATDIR catdir.test -D CAMERA simtest test.cmf -D CATFORMAT $2 -quick-airmass >& tmp.log 64 end 65 66 echo list testfields -copy testfields_$1 56 tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC -type $1 $NO_NOISE 57 tapEXEC addstar -D CATDIR catdir.test -D CAMERA simtest test.cmf -D CATFORMAT $2 -quick-airmass 58 67 59 list testfields -copy testfields_$1 68 60 … … 94 86 set d = $name:0 - $name:2 95 87 vstat -q d 96 tapOK {abs($MEAN) < 0.001} "$name:0 vs $name:2 (MEAN )"97 tapOK {abs($SIGMA) < 0.001} "$name:0 vs $name:2 (SIGMA )"88 tapOK {abs($MEAN) < 0.001} "$name:0 vs $name:2 (MEAN = $MEAN)" 89 tapOK {abs($SIGMA) < 0.001} "$name:0 vs $name:2 (SIGMA = $SIGMA)" 98 90 99 91 # detection ID must be first for this to work: … … 144 136 if ("$name:0" == "PSF_THETA") 145 137 # echo $MEAN 146 tapOK {abs($MEAN) < 0.006} "$name:0 vs $name:2 (MEAN )"147 tapOK {abs($SIGMA) < 0.001} "$name:0 vs $name:2 (SIGMA )"138 tapOK {abs($MEAN) < 0.006} "$name:0 vs $name:2 (MEAN = $MEAN)" 139 tapOK {abs($SIGMA) < 0.001} "$name:0 vs $name:2 (SIGMA = $SIGMA)" 148 140 continue 149 141 end 150 142 151 tapOK {abs($MEAN) < 0.001} "$name:0 vs $name:2 (MEAN )"152 tapOK {abs($SIGMA) < 0.001} "$name:0 vs $name:2 (SIGMA )"143 tapOK {abs($MEAN) < 0.001} "$name:0 vs $name:2 (MEAN = $MEAN)" 144 tapOK {abs($SIGMA) < 0.001} "$name:0 vs $name:2 (SIGMA = $MEAN)" 153 145 end 154 146 -
branches/eam_branches/ohana.20150429/src/addstar/test/tap.dvo
r34405 r38348 3 3 if (not($?TAP_BREAK)) set TAP_BREAK = 0 4 4 if (not($?TAP_VERBOSE)) set TAP_VERBOSE = 0 5 6 macro tapEXEC 7 if ($0 < 3) 8 echo "USAGE: tapEXEC (command)" 9 break 10 end 11 12 local i cmd result 13 14 $cmd = "" 15 for i 1 $0 16 $cmd = $cmd $$i 17 end 18 19 if ($TAP_VERBOSE >= 2) echo $cmd 20 21 break -auto off 22 exec $cmd >& tap.log 23 $result = $STATUS 24 break -auto on 25 26 if (not($result)) 27 exec cat tap.log 28 echo "not ok : $cmd" 29 $TAP_NFAIL ++ 30 $TAP_LAST = 0 31 if ($TAP_BREAK) 32 break 33 end 34 else 35 if ($TAP_VERBOSE >= 1) echo "ok : $cmd" 36 $TAP_LAST = 1 37 end 38 $TAP_NDONE ++ 39 end 5 40 6 41 macro tapOK … … 11 46 12 47 if ($1) 13 if ($TAP_VERBOSE )48 if ($TAP_VERBOSE >= 1) 14 49 echo "ok : $2" 15 50 end -
branches/eam_branches/ohana.20150429/src/dvomerge/src/dvorepairDeleteImageList.c
r38345 r38348 46 46 FILE *cpmFile = NULL; 47 47 48 charcatformat;48 DVOCatFormat catformat; 49 49 50 50 N = get_argument (argc, argv, "-delete-image-list"); -
branches/eam_branches/ohana.20150429/src/dvomerge/src/dvorepairDeleteImagesByExternID.c
r38346 r38348 38 38 char *imageFilename = NULL; 39 39 40 charcatformat;40 DVOCatFormat catformat; 41 41 42 42 N = get_argument (argc, argv, "-delete-images-by-extern-id"); … … 279 279 gfits_scan(&cpmHeaderTBL, "NAXIS1", "%d", 1, &NbytesPerRow); 280 280 281 myAbort ("fix compression"); 282 281 283 // this function can only handle PS1_V5 and later formats 282 284 // NOTE: FtableToMeasure (and equivalent) free the data associated with cpmFtable. -
branches/eam_branches/ohana.20150429/src/dvomerge/src/dvorepairFixCPT.c
r37046 r38348 86 86 Matrix matrix; 87 87 88 charcatformat;88 DVOCatFormat catformat; 89 89 90 90 cpmFtable.header = &cpmHeaderTBL; … … 120 120 } 121 121 122 myAbort ("fix cpts"); 122 123 measure = FtableToMeasure (&cpmFtable, NULL, &Nmeasure, &catformat); 123 124 myAssert(measure, "failed to convert ftable to measure data"); -
branches/eam_branches/ohana.20150429/src/dvomerge/src/dvorepairImagesVsMeasures.c
r37046 r38348 32 32 FILE *cpmFile = NULL; 33 33 34 charcatformat;34 DVOCatFormat catformat; 35 35 36 36 N = get_argument (argc, argv, "-images-vs-measures"); -
branches/eam_branches/ohana.20150429/src/libdvo/include/dvo.h
r38346 r38348 974 974 DVOCatFormat FtableGetFormat (FTable *ftable); 975 975 976 Measure *FtableToMeasure (FTable *ftable, Average *average, off_t *Nmeasure, DVOCatFormat *format );977 Average *FtableToAverage (FTable *ftable, off_t *Naverage, DVOCatFormat *format, SecFilt **primary, char native Bytes);978 SecFilt *FtableToSecFilt (FTable *ftable, off_t *Nsecfilt, DVOCatFormat *format );979 Lensing *FtableToLensing (FTable *ftable, off_t *Nlensing, DVOCatFormat *format );980 Lensobj *FtableToLensobj (FTable *ftable, off_t *Nlensobj, DVOCatFormat *format );981 StarPar *FtableToStarPar (FTable *ftable, off_t *Nstarpar, DVOCatFormat *format );982 GalShape *FtableToGalShape (FTable *ftable, off_t *Ngalshape, DVOCatFormat *format );976 Measure *FtableToMeasure (FTable *ftable, Average *average, off_t *Nmeasure, DVOCatFormat *format, char nativeOrder); 977 Average *FtableToAverage (FTable *ftable, off_t *Naverage, DVOCatFormat *format, SecFilt **primary, char nativeOrder); 978 SecFilt *FtableToSecFilt (FTable *ftable, off_t *Nsecfilt, DVOCatFormat *format, char nativeOrder); 979 Lensing *FtableToLensing (FTable *ftable, off_t *Nlensing, DVOCatFormat *format, char nativeOrder); 980 Lensobj *FtableToLensobj (FTable *ftable, off_t *Nlensobj, DVOCatFormat *format, char nativeOrder); 981 StarPar *FtableToStarPar (FTable *ftable, off_t *Nstarpar, DVOCatFormat *format, char nativeOrder); 982 GalShape *FtableToGalShape (FTable *ftable, off_t *Ngalshape, DVOCatFormat *format, char nativeOrder); 983 983 984 984 int FtableToImage (FTable *ftable, Header *theader, DVOCatFormat *format); 985 985 986 int MeasureToFtable (FTable *ftable, Average *average, Measure *measure, off_t Nmeasure, DVOCatFormat format );986 int MeasureToFtable (FTable *ftable, Average *average, Measure *measure, off_t Nmeasure, DVOCatFormat format, int swapFromNative); 987 987 int AverageToFtable (FTable *ftable, Average *average, off_t Naverage, DVOCatFormat format, SecFilt *primary, int swapFromNative); 988 int SecFiltToFtable (FTable *ftable, SecFilt *secfilt, off_t Nsecfilt, DVOCatFormat format );989 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, DVOCatFormat format );990 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, DVOCatFormat format );991 int StarParToFtable (FTable *ftable, StarPar *starpar, off_t Nstarpar, DVOCatFormat format );992 int GalShapeToFtable (FTable *ftable, GalShape *galshape, off_t Ngalshape, DVOCatFormat format );988 int SecFiltToFtable (FTable *ftable, SecFilt *secfilt, off_t Nsecfilt, DVOCatFormat format, int swapFromNative); 989 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, DVOCatFormat format, int swapFromNative); 990 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, DVOCatFormat format, int swapFromNative); 991 int StarParToFtable (FTable *ftable, StarPar *starpar, off_t Nstarpar, DVOCatFormat format, int swapFromNative); 992 int GalShapeToFtable (FTable *ftable, GalShape *galshape, off_t Ngalshape, DVOCatFormat format, int swapFromNative); 993 993 994 994 int ImageToFtable (FTable *ftable, Header *theader, DVOCatFormat format); -
branches/eam_branches/ohana.20150429/src/libdvo/src/dvo_catalog_create.c
r38331 r38348 1 1 # include <dvo.h> 2 2 # define DEBUG 0 3 4 Catalog *dvo_catalog_create_subcat (Catalog *catalog, char *ext, char *tablename); 3 5 4 6 // create a new dvo catalog file (if split, lock extra files as well?) … … 9 11 // catalog[0].lockmode 10 12 void dvo_catalog_create (SkyRegion *region, Catalog *catalog) { 11 12 int length;13 char *path, *root, *file, *line;14 time_t now;15 13 16 14 if (DEBUG) fprintf (stderr, "new catalog file: %s\n", catalog[0].filename); … … 29 27 30 28 if (catalog[0].catmode == DVO_MODE_SPLIT) { 31 path = pathname (catalog[0].filename); 32 root = filerootname (catalog[0].filename); 33 length = strlen(path) + strlen(root) + 6; 34 35 /* define measure catalog file */ 36 ALLOCATE (catalog[0].measure_catalog, Catalog, 1); 37 dvo_catalog_init (catalog[0].measure_catalog, TRUE); 38 39 /* create basic data for measure catalog file */ 40 gfits_create_header (&catalog[0].measure_catalog[0].header); 41 42 ALLOCATE (catalog[0].measure_catalog[0].filename, char, length); 43 44 sprintf (catalog[0].measure_catalog[0].filename, "%s/%s.cpm", path, root); 45 file = filebasename (catalog[0].measure_catalog[0].filename); 46 gfits_modify (&catalog[0].header, "MEASURE", "%s", 1, file); 47 free (file); 48 49 /* define missing catalog file */ 50 ALLOCATE (catalog[0].missing_catalog, Catalog, 1); 51 dvo_catalog_init (catalog[0].missing_catalog, TRUE); 52 53 /* create basic data for missing catalog file */ 54 gfits_create_header (&catalog[0].missing_catalog[0].header); 55 ALLOCATE (catalog[0].missing_catalog[0].filename, char, length); 56 sprintf (catalog[0].missing_catalog[0].filename, "%s/%s.cpn", path, root); 57 file = filebasename (catalog[0].missing_catalog[0].filename); 58 gfits_modify (&catalog[0].header, "MISSING", "%s", 1, file); 59 free (file); 60 61 /* define secfilt catalog file */ 62 ALLOCATE (catalog[0].secfilt_catalog, Catalog, 1); 63 dvo_catalog_init (catalog[0].secfilt_catalog, TRUE); 64 65 /* create basic data for secfilt catalog file */ 66 gfits_create_header (&catalog[0].secfilt_catalog[0].header); 67 ALLOCATE (catalog[0].secfilt_catalog[0].filename, char, length); 68 sprintf (catalog[0].secfilt_catalog[0].filename, "%s/%s.cps", path, root); 69 file = filebasename (catalog[0].secfilt_catalog[0].filename); 70 gfits_modify (&catalog[0].header, "SECFILT", "%s", 1, file); 71 free (file); 72 73 /* define lensing catalog file */ 74 ALLOCATE (catalog[0].lensing_catalog, Catalog, 1); 75 dvo_catalog_init (catalog[0].lensing_catalog, TRUE); 76 77 /* create basic data for lensing catalog file */ 78 gfits_create_header (&catalog[0].lensing_catalog[0].header); 79 ALLOCATE (catalog[0].lensing_catalog[0].filename, char, length); 80 sprintf (catalog[0].lensing_catalog[0].filename, "%s/%s.cpx", path, root); 81 file = filebasename (catalog[0].lensing_catalog[0].filename); 82 gfits_modify (&catalog[0].header, "LENSING", "%s", 1, file); 83 free (file); 84 85 /* define lensobj catalog file */ 86 ALLOCATE (catalog[0].lensobj_catalog, Catalog, 1); 87 dvo_catalog_init (catalog[0].lensobj_catalog, TRUE); 88 89 /* create basic data for lensobj catalog file */ 90 gfits_create_header (&catalog[0].lensobj_catalog[0].header); 91 ALLOCATE (catalog[0].lensobj_catalog[0].filename, char, length); 92 sprintf (catalog[0].lensobj_catalog[0].filename, "%s/%s.cpy", path, root); 93 file = filebasename (catalog[0].lensobj_catalog[0].filename); 94 gfits_modify (&catalog[0].header, "LENSOBJ", "%s", 1, file); 95 free (file); 96 97 /* define starpar catalog file */ 98 ALLOCATE (catalog[0].starpar_catalog, Catalog, 1); 99 dvo_catalog_init (catalog[0].starpar_catalog, TRUE); 100 101 /* create basic data for starpar catalog file */ 102 gfits_create_header (&catalog[0].starpar_catalog[0].header); 103 ALLOCATE (catalog[0].starpar_catalog[0].filename, char, length); 104 sprintf (catalog[0].starpar_catalog[0].filename, "%s/%s.cpz", path, root); 105 file = filebasename (catalog[0].starpar_catalog[0].filename); 106 gfits_modify (&catalog[0].header, "STARPAR", "%s", 1, file); 107 free (file); 108 109 /* define galshape catalog file */ 110 ALLOCATE (catalog[0].galshape_catalog, Catalog, 1); 111 dvo_catalog_init (catalog[0].galshape_catalog, TRUE); 112 113 /* create basic data for galshape catalog file */ 114 gfits_create_header (&catalog[0].galshape_catalog[0].header); 115 ALLOCATE (catalog[0].galshape_catalog[0].filename, char, length); 116 sprintf (catalog[0].galshape_catalog[0].filename, "%s/%s.cpx", path, root); 117 file = filebasename (catalog[0].galshape_catalog[0].filename); 118 gfits_modify (&catalog[0].header, "GALSHAPE", "%s", 1, file); 119 free (file); 120 121 free (path); 122 free (root); 29 catalog[0].measure_catalog = dvo_catalog_create_subcat (catalog, "cpm", "MEASURE"); 30 catalog[0].missing_catalog = dvo_catalog_create_subcat (catalog, "cpn", "MISSING"); 31 catalog[0].secfilt_catalog = dvo_catalog_create_subcat (catalog, "cps", "SECFILT"); 32 catalog[0].lensing_catalog = dvo_catalog_create_subcat (catalog, "cpx", "LENSING"); 33 catalog[0].lensobj_catalog = dvo_catalog_create_subcat (catalog, "cpy", "LENSOBJ"); 34 catalog[0].starpar_catalog = dvo_catalog_create_subcat (catalog, "cpz", "STARPAR"); 35 catalog[0].galshape_catalog = dvo_catalog_create_subcat (catalog, "cpq", "GALSHAPE"); 123 36 124 37 // lock the additional split files … … 166 79 167 80 /* write creation date in header */ 81 time_t now; 168 82 ohana_str_to_time ("now", &now); 169 line = ohana_sec_to_date (now);83 char *line = ohana_sec_to_date (now); 170 84 gfits_modify (&catalog[0].header, "DATE", "%s", 1, line); 171 85 free (line); … … 187 101 } 188 102 103 Catalog *dvo_catalog_create_subcat (Catalog *catalog, char *ext, char *tablename) { 104 105 char *path = pathname (catalog[0].filename); 106 char *root = filerootname (catalog[0].filename); 107 int length = strlen(path) + strlen(root) + 6; 108 109 Catalog *subcat; 110 111 /* define subcat catalog file */ 112 ALLOCATE (subcat, Catalog, 1); 113 dvo_catalog_init (subcat, TRUE); 114 115 /* create basic data for measure catalog file */ 116 gfits_create_header (&subcat->header); 117 118 subcat->catcompress = catalog->catcompress; 119 120 ALLOCATE (subcat->filename, char, length); 121 122 sprintf (subcat->filename, "%s/%s.%s", path, root, ext); 123 124 char *file = filebasename (subcat->filename); 125 gfits_modify (&catalog[0].header, tablename, "%s", 1, file); 126 127 free (file); 128 free (path); 129 free (root); 130 131 return subcat; 132 } 133 189 134 int dvo_catalog_set_range (Catalog *catalog) { 190 135 -
branches/eam_branches/ohana.20150429/src/libdvo/src/dvo_catalog_mef.c
r38345 r38348 105 105 return (FALSE); 106 106 } 107 catalog[0].measure = FtableToMeasure (&ftable, catalog[0].average, &catalog[0].Nmeasure, &catalog[0].catformat );107 catalog[0].measure = FtableToMeasure (&ftable, catalog[0].average, &catalog[0].Nmeasure, &catalog[0].catformat, FALSE); 108 108 if (Nmeasure != catalog[0].Nmeas_disk) { 109 109 fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nmeasure, catalog[0].Nmeas_disk); … … 163 163 /* how many entries do we expect from the secfilt table? */ 164 164 Nexpect = catalog[0].Nsecfilt * catalog[0].Naverage; 165 catalog[0].secfilt = FtableToSecFilt (&ftable, &Nitems, &catalog[0].catformat );165 catalog[0].secfilt = FtableToSecFilt (&ftable, &Nitems, &catalog[0].catformat, FALSE); 166 166 if (Nexpect != Nitems) { 167 167 fprintf (stderr, "Warning: mismatch between Nsecfilt items in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nexpect, Nitems); … … 216 216 return (FALSE); 217 217 } 218 catalog[0].lensing = FtableToLensing (&ftable, &catalog[0].Nlensing, &catalog[0].catformat );218 catalog[0].lensing = FtableToLensing (&ftable, &catalog[0].Nlensing, &catalog[0].catformat, FALSE); 219 219 if (Nlensing != catalog[0].Nlensing_disk) { 220 220 fprintf (stderr, "Warning: mismatch between Nlensing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensing, catalog[0].Nlensing_disk); … … 241 241 return (FALSE); 242 242 } 243 catalog[0].lensobj = FtableToLensobj (&ftable, &catalog[0].Nlensobj, &catalog[0].catformat );243 catalog[0].lensobj = FtableToLensobj (&ftable, &catalog[0].Nlensobj, &catalog[0].catformat, FALSE); 244 244 if (Nlensobj != catalog[0].Nlensobj_disk) { 245 245 fprintf (stderr, "Warning: mismatch between Nlensobj in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensobj, catalog[0].Nlensobj_disk); … … 266 266 return (FALSE); 267 267 } 268 catalog[0].starpar = FtableToStarPar (&ftable, &catalog[0].Nstarpar, &catalog[0].catformat );268 catalog[0].starpar = FtableToStarPar (&ftable, &catalog[0].Nstarpar, &catalog[0].catformat, FALSE); 269 269 if (Nstarpar != catalog[0].Nstarpar_disk) { 270 270 fprintf (stderr, "Warning: mismatch between Nstarpar in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nstarpar, catalog[0].Nstarpar_disk); … … 291 291 return (FALSE); 292 292 } 293 catalog[0].galshape = FtableToGalShape (&ftable, &catalog[0].Ngalshape, &catalog[0].catformat );293 catalog[0].galshape = FtableToGalShape (&ftable, &catalog[0].Ngalshape, &catalog[0].catformat, FALSE); 294 294 if (Ngalshape != catalog[0].Ngalshape_disk) { 295 295 fprintf (stderr, "Warning: mismatch between Ngalshape in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Ngalshape, catalog[0].Ngalshape_disk); … … 398 398 399 399 /* write out Measure table (convert to FITS table format) */ 400 MeasureToFtable (&ftable, catalog[0].average, catalog[0].measure, catalog[0].Nmeasure, catalog[0].catformat );400 MeasureToFtable (&ftable, catalog[0].average, catalog[0].measure, catalog[0].Nmeasure, catalog[0].catformat, TRUE); 401 401 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 402 402 fprintf (stderr, "can't write table header"); … … 425 425 /* write out SecFilt table (convert to FITS table format) */ 426 426 Nitems = catalog[0].Naverage * Nsecfilt; 427 SecFiltToFtable (&ftable, secfilt, Nitems, catalog[0].catformat );427 SecFiltToFtable (&ftable, secfilt, Nitems, catalog[0].catformat, TRUE); 428 428 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 429 429 fprintf (stderr, "can't write table header"); … … 438 438 439 439 /* write out Lensing table (convert to FITS table format) */ 440 LensingToFtable (&ftable, catalog[0].lensing, catalog[0].Nlensing, catalog[0].catformat );440 LensingToFtable (&ftable, catalog[0].lensing, catalog[0].Nlensing, catalog[0].catformat, TRUE); 441 441 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 442 442 fprintf (stderr, "can't write table header"); … … 451 451 452 452 /* write out Lensobj table (convert to FITS table format) */ 453 LensobjToFtable (&ftable, catalog[0].lensobj, catalog[0].Nlensobj, catalog[0].catformat );453 LensobjToFtable (&ftable, catalog[0].lensobj, catalog[0].Nlensobj, catalog[0].catformat, TRUE); 454 454 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 455 455 fprintf (stderr, "can't write table header"); … … 464 464 465 465 /* write out StarPar table (convert to FITS table format) */ 466 StarParToFtable (&ftable, catalog[0].starpar, catalog[0].Nstarpar, catalog[0].catformat );466 StarParToFtable (&ftable, catalog[0].starpar, catalog[0].Nstarpar, catalog[0].catformat, TRUE); 467 467 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 468 468 fprintf (stderr, "can't write table header"); … … 477 477 478 478 /* write out GalShape table (convert to FITS table format) */ 479 GalShapeToFtable (&ftable, catalog[0].galshape, catalog[0].Ngalshape, catalog[0].catformat );479 GalShapeToFtable (&ftable, catalog[0].galshape, catalog[0].Ngalshape, catalog[0].catformat, TRUE); 480 480 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 481 481 fprintf (stderr, "can't write table header"); -
branches/eam_branches/ohana.20150429/src/libdvo/src/dvo_catalog_split.c
r38346 r38348 5 5 // * empty (file is not found) 6 6 // * ok 7 8 // utility function to see if we should compress this table) 9 int output_is_compressed (int start, int Nrows, int Ntotal, DVOCatCompress catcompress) { 10 int fullWrite = (start == 0) && (Nrows == Ntotal); 11 if (fullWrite && catcompress) return TRUE; // we want to compress, so do not swap 12 return FALSE; 13 } 7 14 8 15 int dvo_catalog_secfilt_to_primary (Catalog *catalog, SecFilt **myPrimary, SecFilt **mySecfilt, int *myNsecfilt) { … … 159 166 160 167 int fullWrite = (start == 0) && (Nrows == Ntotal); 161 162 if (fullWrite && catalog->catcompress) { 168 int isCompressed = output_is_compressed (start, Nrows, Ntotal, catalog->catcompress); 169 170 if (isCompressed) { 171 fprintf (stderr, "compress %s\n", catalog->filename); 163 172 char *compressMode = dvo_catalog_compress_string (catalog->catcompress); 164 173 if (!gfits_compress_table (ftable, &cmptable, 10, compressMode)) { … … 170 179 171 180 // write the table data 172 if (!gfits_fwrite_ftable_range (catalog->f, outtable, start, Nrows, Ndisk, Ntotal)) { 173 fprintf (stderr, "can't write table data\n"); 174 return (FALSE); 181 if (fullWrite) { 182 if (!gfits_fwrite_Theader (catalog->f, outtable->header)) { 183 fprintf (stderr, "can't write table data\n"); 184 return (FALSE); 185 } 186 if (!gfits_fwrite_table (catalog->f, outtable)) { 187 fprintf (stderr, "can't write table data\n"); 188 return (FALSE); 189 } 190 } else { 191 if (!gfits_fwrite_ftable_range (catalog->f, outtable, start, Nrows, Ndisk, Ntotal)) { 192 fprintf (stderr, "can't write table data\n"); 193 return (FALSE); 194 } 175 195 } 176 196 fullsize += outtable->datasize + outtable->header->datasize; … … 224 244 free (path); 225 245 246 // inherit compression mode for this subcat; 247 subcat->catcompress = catalog->catcompress; 248 226 249 /* lock & open catalog file */ 227 250 status = dvo_catalog_lock (subcat, catalog[0].lockmode); … … 252 275 } 253 276 return (DVO_CAT_OPEN_OK); 277 } 278 279 // ftable must already exist and have a valid, loaded header 280 int gfits_fread_uncompressed (Catalog *catalog, FTable *ftable, char *nativeOrder) { 281 282 // fread_ftable_data requires the header 283 284 *nativeOrder = FALSE; 285 if (!gfits_fread_ftable_data (catalog->f, ftable, FALSE)) { 286 if (VERBOSE) fprintf (stderr, "can't read table data\n"); 287 return FALSE; 288 } 289 // NOTE: fread_ftable returns an unswapped table; uncompress swaps the bytes into native order 290 291 if (gfits_extension_is_compressed_table (ftable->header)) { 292 FTable rawtable; 293 Header rawheader; 294 gfits_init_table (&rawtable); 295 gfits_init_header (&rawheader); 296 rawtable.header = &rawheader; 297 298 // NOTE: uncompress swaps the bytes into native order 299 if (!gfits_uncompress_table (ftable, &rawtable)) { 300 if (VERBOSE) fprintf (stderr, "failed to uncompress table\n"); 301 gfits_free_table (ftable); 302 return FALSE; 303 } 304 catalog->catcompress = DVO_COMPRESS_GZIP_1; // if any table is compressed, set all to a compress state? 305 306 // free the buffers 307 gfits_free_header (ftable->header); 308 gfits_free_table (ftable); 309 310 // copies values but does not allocate new memory 311 gfits_copy_header_ptr (&rawheader, ftable->header); 312 gfits_copy_table_ptr (&rawtable, ftable); 313 *nativeOrder = TRUE; 314 } 315 return TRUE; 254 316 } 255 317 … … 266 328 off_t Nitems; 267 329 int status, Nsecfilt; 268 Header header;269 FTable ftable;270 330 SecFilt *primary; 271 331 272 /* ftable header storage for below */273 ftable.header = &header;274 ftable.buffer = NULL;275 header.buffer = NULL;276 332 primary = NULL; 277 333 status = FALSE; … … 331 387 fseeko (catalog[0].f, Nbytes, SEEK_SET); 332 388 389 /* ftable header storage for below */ 390 Header header; 391 FTable ftable; 392 gfits_init_table (&ftable); 393 gfits_init_header (&header); 394 ftable.header = &header; 395 333 396 /* read Average table header */ 334 397 if (!gfits_fread_header (catalog[0].f, &header)) { … … 337 400 } 338 401 if (catalog[0].catflags & LOAD_AVES) { 339 Header rawheader;340 FTable rawtable;341 rawtable.header = &rawheader;342 FTable *outtable = &ftable;343 402 char nativeOrder = FALSE; 344 345 /* read Average table data : format is irrelevant here */ 346 if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) { 347 if (VERBOSE) fprintf (stderr, "can't read table average data\n"); 348 return (FALSE); 349 } 350 if (gfits_extension_is_compressed_table (ftable.header)) { 351 if (!gfits_uncompress_table (&ftable, &rawtable)) { 352 if (VERBOSE) fprintf (stderr, "failed to uncompress table\n"); 353 return (FALSE); 354 } 355 gfits_free_table (&ftable); 356 outtable = &rawtable; 357 nativeOrder = TRUE; 358 catalog->catcompress = DVO_COMPRESS_GZIP_1; // if any table is compressed, set all to a compress state? 359 } 360 // NOTE: fread_ftable returns an unswapped table; uncompress swaps the bytes into native order 403 if (!gfits_fread_uncompressed (catalog, &ftable, &nativeOrder)) { 404 if (VERBOSE) fprintf (stderr, "can't read Average table\n"); 405 gfits_free_header (&header); 406 return FALSE; 407 } 361 408 362 409 /* convert the saved version of the table to the internal version. Old versions of DVO stored 363 410 * one of the average magnitudes in Average. We save this in case it is needed below. NOTE: 364 411 * primary is only used if we read in the secfilt table, otherwise it should be freed */ 365 catalog[0].average = FtableToAverage ( outtable, &Naverage, &catalog[0].catformat, &primary, nativeOrder);412 catalog[0].average = FtableToAverage (&ftable, &Naverage, &catalog[0].catformat, &primary, nativeOrder); 366 413 if (Naverage != catalog[0].Naves_disk) { 367 414 fprintf (stderr, "Warning: mismatch between Naverage in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Naverage, catalog[0].Naves_disk); 368 415 } 369 gfits_free_header (&header);370 416 catalog[0].Naverage = catalog[0].Naves_disk; 371 417 catalog[0].Naves_off = 0; … … 376 422 catalog[0].Naves_off = catalog[0].Naves_disk; 377 423 } 424 gfits_free_header (&header); 378 425 379 426 /*** Measure Table ***/ 427 gfits_init_table (&ftable); 428 gfits_init_header (&header); 429 ftable.header = &header; 380 430 if (!(catalog[0].catflags & SKIP_MEAS)) { 381 431 // unless we specify 'skip', we still need to load the … … 389 439 } 390 440 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_MEAS)) { 391 // XXX this allows an empty Measure catalog with non-empty Average catalog : is that OK?441 char nativeOrder = FALSE; 392 442 /* read Measure table data */ 393 if (!gfits_fread_ ftable_data (catalog[0].measure_catalog[0].f, &ftable, FALSE)) {443 if (!gfits_fread_uncompressed (catalog[0].measure_catalog, &ftable, &nativeOrder)) { 394 444 if (VERBOSE) fprintf (stderr, "can't read table measure data\n"); 445 gfits_free_header (&header); 395 446 return (FALSE); 396 447 } 397 448 /* convert data format to internal : returns number of row read in Nmeasure */ 398 catalog[0].measure = FtableToMeasure (&ftable, catalog[0].average, &Nmeasure, &catalog[0].catformat );449 catalog[0].measure = FtableToMeasure (&ftable, catalog[0].average, &Nmeasure, &catalog[0].catformat, nativeOrder); 399 450 if (Nmeasure != catalog[0].Nmeas_disk) { 400 451 fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nmeasure, catalog[0].Nmeas_disk); … … 419 470 420 471 /*** Missing Table ***/ 472 gfits_init_table (&ftable); 473 gfits_init_header (&header); 474 ftable.header = &header; 421 475 status = dvo_catalog_open_subcat (catalog, &catalog[0].missing_catalog, ftable.header, "MISSING", VERBOSE); 422 476 if (status == DVO_CAT_OPEN_FAIL) { … … 427 481 } 428 482 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_MISS)) { 483 char nativeOrder = FALSE; 429 484 /* read Missing table data */ 430 if (!gfits_fread_ ftable_data (catalog[0].missing_catalog[0].f, &ftable, FALSE)) {485 if (!gfits_fread_uncompressed (catalog[0].missing_catalog, &ftable, &nativeOrder)) { 431 486 if (VERBOSE) fprintf (stderr, "can't read table missing data\n"); 432 487 return (FALSE); 433 488 } 434 489 /* no conversions currently defined : this just does the byte swap */ 435 catalog[0].missing = gfits_table_get_Missing (&ftable, &Nmissing, NULL, NULL);490 catalog[0].missing = gfits_table_get_Missing (&ftable, &Nmissing, NULL, &nativeOrder); 436 491 if (!catalog[0].missing) { 437 492 fprintf (stderr, "ERROR: failed to read missing\n"); … … 453 508 454 509 /*** Secfilt Table ***/ 510 gfits_init_table (&ftable); 511 gfits_init_header (&header); 512 ftable.header = &header; 455 513 status = dvo_catalog_open_subcat (catalog, &catalog[0].secfilt_catalog, ftable.header, "SECFILT", VERBOSE); 456 514 // fprintf (stderr, "secfilt header %s : %zx\n", catalog[0].secfilt_catalog[0].filename, (size_t) catalog[0].secfilt_catalog[0].header.buffer); … … 462 520 } 463 521 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_SECF)) { 522 char nativeOrder = FALSE; 464 523 /* read secfilt table data */ 465 if (!gfits_fread_ ftable_data (catalog[0].secfilt_catalog[0].f, &ftable, FALSE)) {524 if (!gfits_fread_uncompressed (catalog[0].secfilt_catalog, &ftable, &nativeOrder)) { 466 525 if (VERBOSE) fprintf (stderr, "can't read table secfilt data\n"); 467 526 return (FALSE); 468 527 } 469 catalog[0].secfilt = FtableToSecFilt (&ftable, &Nitems, &catalog[0].catformat );528 catalog[0].secfilt = FtableToSecFilt (&ftable, &Nitems, &catalog[0].catformat, nativeOrder); 470 529 if (Nitems != catalog[0].Nsecf_disk) { 471 530 fprintf (stderr, "Warning: mismatch between Nsecfilt items in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nitems, catalog[0].Nsecf_disk); … … 493 552 494 553 /*** Lensing Table ***/ 554 gfits_init_table (&ftable); 555 gfits_init_header (&header); 556 ftable.header = &header; 495 557 if (!(catalog[0].catflags & SKIP_LENSING)) { 496 558 // unless we specify 'skip', we still need to load the Lensing table … … 505 567 } 506 568 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_LENSING)) { 569 char nativeOrder = FALSE; 507 570 // only read the Lensing table if the file actually exists 508 571 /* read Lensing table data */ 509 if (!gfits_fread_ ftable_data (catalog[0].lensing_catalog[0].f, &ftable, FALSE)) {572 if (!gfits_fread_uncompressed (catalog[0].lensing_catalog, &ftable, &nativeOrder)) { 510 573 if (VERBOSE) fprintf (stderr, "can't read table lensing data\n"); 511 574 return (FALSE); 512 575 } 513 576 /* convert data format to internal : returns number of row read in Nlensing */ 514 catalog[0].lensing = FtableToLensing (&ftable, &Nlensing, &catalog[0].catformat );577 catalog[0].lensing = FtableToLensing (&ftable, &Nlensing, &catalog[0].catformat, nativeOrder); 515 578 if (Nlensing != catalog[0].Nlensing_disk) { 516 579 fprintf (stderr, "Warning: mismatch between Nlensing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensing, catalog[0].Nlensing_disk); … … 533 596 534 597 /*** Lensobj Table ***/ 598 gfits_init_table (&ftable); 599 gfits_init_header (&header); 600 ftable.header = &header; 535 601 if (!(catalog[0].catflags & SKIP_LENSOBJ)) { 536 602 // unless we specify 'skip', we still need to load the … … 545 611 } 546 612 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_LENSOBJ)) { 613 char nativeOrder = FALSE; 547 614 // only read the Lensobj table if the file actually exists 548 615 /* read Lensobj table data */ 549 if (!gfits_fread_ ftable_data (catalog[0].lensobj_catalog[0].f, &ftable, FALSE)) {616 if (!gfits_fread_uncompressed (catalog[0].lensobj_catalog, &ftable, &nativeOrder)) { 550 617 if (VERBOSE) fprintf (stderr, "can't read table lensobj data\n"); 551 618 return (FALSE); 552 619 } 553 620 /* convert data format to internal : returns number of row read in Nlensobj */ 554 catalog[0].lensobj = FtableToLensobj (&ftable, &Nlensobj, &catalog[0].catformat );621 catalog[0].lensobj = FtableToLensobj (&ftable, &Nlensobj, &catalog[0].catformat, FALSE); 555 622 if (Nlensobj != catalog[0].Nlensobj_disk) { 556 623 fprintf (stderr, "Warning: mismatch between Nlensobj in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nlensobj, catalog[0].Nlensobj_disk); … … 573 640 574 641 /*** StarPar Table ***/ 642 gfits_init_table (&ftable); 643 gfits_init_header (&header); 644 ftable.header = &header; 575 645 if (!(catalog[0].catflags & SKIP_STARPAR)) { 576 646 // unless we specify 'skip', we still need to load the … … 585 655 } 586 656 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_STARPAR)) { 657 char nativeOrder = FALSE; 587 658 // only read the StarPar table if the file actually exists 588 659 /* read StarPar table data */ 589 if (!gfits_fread_ ftable_data (catalog[0].starpar_catalog[0].f, &ftable, FALSE)) {660 if (!gfits_fread_uncompressed (catalog[0].starpar_catalog, &ftable, &nativeOrder)) { 590 661 if (VERBOSE) fprintf (stderr, "can't read table starpar data\n"); 591 662 return (FALSE); 592 663 } 593 664 /* convert data format to internal : returns number of row read in Nstarpar */ 594 catalog[0].starpar = FtableToStarPar (&ftable, &Nstarpar, &catalog[0].catformat );665 catalog[0].starpar = FtableToStarPar (&ftable, &Nstarpar, &catalog[0].catformat, FALSE); 595 666 if (Nstarpar != catalog[0].Nstarpar_disk) { 596 667 fprintf (stderr, "Warning: mismatch between Nstarpar in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nstarpar, catalog[0].Nstarpar_disk); … … 613 684 614 685 /*** GalShape Table ***/ 686 gfits_init_table (&ftable); 687 gfits_init_header (&header); 688 ftable.header = &header; 615 689 if (!(catalog[0].catflags & SKIP_GALSHAPE)) { 616 690 // unless we specify 'skip', we still need to load the GalShape table … … 625 699 } 626 700 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_GALSHAPE)) { 701 char nativeOrder = FALSE; 627 702 // only read the GalShape table if the file actually exists 628 703 /* read GalShape table data */ 629 if (!gfits_fread_ ftable_data (catalog[0].galshape_catalog[0].f, &ftable, FALSE)) {704 if (!gfits_fread_uncompressed (catalog[0].galshape_catalog, &ftable, &nativeOrder)) { 630 705 if (VERBOSE) fprintf (stderr, "can't read table galshape data\n"); 631 706 return (FALSE); 632 707 } 633 708 /* convert data format to internal : returns number of row read in Ngalshape */ 634 catalog[0].galshape = FtableToGalShape (&ftable, &Ngalshape, &catalog[0].catformat );709 catalog[0].galshape = FtableToGalShape (&ftable, &Ngalshape, &catalog[0].catformat, FALSE); 635 710 if (Ngalshape != catalog[0].Ngalshape_disk) { 636 711 fprintf (stderr, "Warning: mismatch between Ngalshape in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Ngalshape, catalog[0].Ngalshape_disk); … … 720 795 721 796 Nexpect = catalog[0].Naverage * catalog[0].Nsecfilt; 722 catalog[0].secfilt = FtableToSecFilt (&ftable, &Nitems, &catalog[0].catformat );797 catalog[0].secfilt = FtableToSecFilt (&ftable, &Nitems, &catalog[0].catformat, FALSE); 723 798 if (Nitems != Nexpect) { 724 799 fprintf (stderr, "Warning: mismatch between Nsecfilt items in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nitems, Nexpect); … … 756 831 757 832 /* convert data format to internal : returns number of row read in Nmeasure */ 758 catalog[0].measure = FtableToMeasure (&ftable, catalog[0].average, &Nmeasure, &catalog[0].catformat );833 catalog[0].measure = FtableToMeasure (&ftable, catalog[0].average, &Nmeasure, &catalog[0].catformat, FALSE); 759 834 if (Nmeasure != Nrows) { 760 835 // XXX this condition denotes the eof has been reached; not an error or a warning … … 821 896 822 897 /* convert data format to internal : returns number of row read in Nlensing */ 823 catalog[0].lensing = FtableToLensing (&ftable, &Nlensing, &catalog[0].catformat );898 catalog[0].lensing = FtableToLensing (&ftable, &Nlensing, &catalog[0].catformat, FALSE); 824 899 if (Nlensing != Nrows) { 825 900 // XXX this condition denotes the eof has been reached; not an error or a warning … … 852 927 853 928 /* convert data format to internal : returns number of row read in Nlensobj */ 854 catalog[0].lensobj = FtableToLensobj (&ftable, &Nlensobj, &catalog[0].catformat );929 catalog[0].lensobj = FtableToLensobj (&ftable, &Nlensobj, &catalog[0].catformat, FALSE); 855 930 if (Nlensobj != Nrows) { 856 931 // XXX this condition denotes the eof has been reached; not an error or a warning … … 883 958 884 959 /* convert data format to internal : returns number of row read in Nstarpar */ 885 catalog[0].starpar = FtableToStarPar (&ftable, &Nstarpar, &catalog[0].catformat );960 catalog[0].starpar = FtableToStarPar (&ftable, &Nstarpar, &catalog[0].catformat, FALSE); 886 961 if (Nstarpar != Nrows) { 887 962 // XXX this condition denotes the eof has been reached; not an error or a warning … … 914 989 915 990 /* convert data format to internal : returns number of row read in Ngalshape */ 916 catalog[0].galshape = FtableToGalShape (&ftable, &Ngalshape, &catalog[0].catformat );991 catalog[0].galshape = FtableToGalShape (&ftable, &Ngalshape, &catalog[0].catformat, FALSE); 917 992 if (Ngalshape != Nrows) { 918 993 // XXX this condition denotes the eof has been reached; not an error or a warning … … 1003 1078 1004 1079 // if we are going to compress, we need to receive unswapped data -- 1005 // gfits_compress_table expectes a table with unswapped data values 1006 int swapFromNative = TRUE; 1007 int fullWrite = (start == 0) && (Nrows == Naves_disk_new); 1008 if (fullWrite && catalog->catcompress) { 1009 swapFromNative = FALSE; 1010 } 1080 int swapFromNative = !output_is_compressed (start, Nrows, Naves_disk_new, catalog->catcompress); 1011 1081 1012 1082 if (!AverageToFtable (&ftable, &catalog[0].average[first], Nrows, catalog[0].catformat, primary, swapFromNative)) { … … 1046 1116 assert (catalog[0].Nmeas_disk >= catalog[0].Nmeas_off); 1047 1117 1118 // if we are going to compress, we need to receive unswapped data -- 1119 int swapFromNative = !output_is_compressed (start, Nrows, Nmeas_disk_new, catalog->catcompress); 1120 1048 1121 // convert to external table format (note that the block above does not damage or free catalog.average) 1049 if (!MeasureToFtable (&ftable, catalog[0].average, &catalog[0].measure[first], Nrows, catalog[0].catformat )) {1122 if (!MeasureToFtable (&ftable, catalog[0].average, &catalog[0].measure[first], Nrows, catalog[0].catformat, swapFromNative)) { 1050 1123 fprintf (stderr, "trouble converting format\n"); 1051 1124 goto failure; … … 1069 1142 } 1070 1143 1144 // if we are going to compress, we need to receive unswapped data -- 1145 int swapFromNative = !output_is_compressed (0, catalog->Nmissing, catalog->Nmissing, catalog->catcompress); 1146 1071 1147 // convert to external table format 1072 if (!gfits_table_set_Missing (&ftable, catalog[0].missing, catalog[0].Nmissing, TRUE)) {1148 if (!gfits_table_set_Missing (&ftable, catalog[0].missing, catalog[0].Nmissing, swapFromNative)) { 1073 1149 fprintf (stderr, "trouble converting format\n"); 1074 1150 goto failure; … … 1098 1174 // XXX check these for consistency... 1099 1175 1176 // if we are going to compress, we need to receive unswapped data -- 1177 int swapFromNative = !output_is_compressed (start, Nrows, Nsecf_disk_new, catalog->catcompress); 1178 1100 1179 // convert to external table format 1101 SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat );1180 SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat, swapFromNative); 1102 1181 1103 1182 // write out SecFilt table … … 1123 1202 1124 1203 if (catalog[0].Nlensing) { 1204 // if we are going to compress, we need to receive unswapped data -- 1205 int swapFromNative = !output_is_compressed (start, Nrows, Nlensing_disk_new, catalog->catcompress); 1206 1125 1207 // convert to external table format (note that the block above does not damage or free catalog.average) 1126 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat )) {1208 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat, swapFromNative)) { 1127 1209 fprintf (stderr, "trouble converting format\n"); 1128 1210 goto failure; … … 1152 1234 1153 1235 if (catalog[0].Nlensobj) { 1236 // if we are going to compress, we need to receive unswapped data -- 1237 int swapFromNative = !output_is_compressed (start, Nrows, Nlensobj_disk_new, catalog->catcompress); 1238 1154 1239 // convert to external table format (note that the block above does not damage or free catalog.average) 1155 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat )) {1240 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat, swapFromNative)) { 1156 1241 fprintf (stderr, "trouble converting format\n"); 1157 1242 goto failure; … … 1181 1266 1182 1267 if (catalog[0].Nstarpar) { 1268 // if we are going to compress, we need to receive unswapped data -- 1269 int swapFromNative = !output_is_compressed (start, Nrows, Nstarpar_disk_new, catalog->catcompress); 1270 1183 1271 // convert to external table format (note that the block above does not damage or free catalog.average) 1184 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat )) {1272 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat, swapFromNative)) { 1185 1273 fprintf (stderr, "trouble converting format\n"); 1186 1274 goto failure; … … 1210 1298 1211 1299 if (catalog[0].Ngalshape) { 1300 // if we are going to compress, we need to receive unswapped data -- 1301 int swapFromNative = !output_is_compressed (start, Nrows, Ngalshape_disk_new, catalog->catcompress); 1302 1212 1303 // convert to external table format (note that the block above does not damage or free catalog.average) 1213 if (!GalShapeToFtable (&ftable, &catalog[0].galshape[first], Nrows, catalog[0].catformat )) {1304 if (!GalShapeToFtable (&ftable, &catalog[0].galshape[first], Nrows, catalog[0].catformat, swapFromNative)) { 1214 1305 fprintf (stderr, "trouble converting format\n"); 1215 1306 goto failure; … … 1386 1477 1387 1478 // convert to external table format 1388 if (!MeasureToFtable (&ftable, catalog[0].average, &catalog[0].measure[first], Nrows, catalog[0].catformat )) {1479 if (!MeasureToFtable (&ftable, catalog[0].average, &catalog[0].measure[first], Nrows, catalog[0].catformat, TRUE)) { 1389 1480 fprintf (stderr, "trouble converting format\n"); 1390 1481 goto failure; … … 1438 1529 1439 1530 // convert to external table format 1440 SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat );1531 SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat, TRUE); 1441 1532 1442 1533 // write out SecFilt table … … 1462 1553 1463 1554 // convert to external table format 1464 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat )) {1555 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat, TRUE)) { 1465 1556 fprintf (stderr, "trouble converting format\n"); 1466 1557 goto failure; … … 1489 1580 1490 1581 // convert to external table format 1491 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat )) {1582 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat, TRUE)) { 1492 1583 fprintf (stderr, "trouble converting format\n"); 1493 1584 goto failure; … … 1516 1607 1517 1608 // convert to external table format 1518 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat )) {1609 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat, TRUE)) { 1519 1610 fprintf (stderr, "trouble converting format\n"); 1520 1611 goto failure; … … 1543 1634 1544 1635 // convert to external table format 1545 if (!GalShapeToFtable (&ftable, &catalog[0].galshape[first], Nrows, catalog[0].catformat )) {1636 if (!GalShapeToFtable (&ftable, &catalog[0].galshape[first], Nrows, catalog[0].catformat, TRUE)) { 1546 1637 fprintf (stderr, "trouble converting format\n"); 1547 1638 goto failure; … … 1683 1774 // convert to external table format 1684 1775 // XXX does catalog.measure have averef correctly set up? 1685 if (!MeasureToFtable (&ftable, catalog[0].average, &catalog[0].measure[first], Nrows, catalog[0].catformat )) {1776 if (!MeasureToFtable (&ftable, catalog[0].average, &catalog[0].measure[first], Nrows, catalog[0].catformat, TRUE)) { 1686 1777 fprintf (stderr, "trouble converting format\n"); 1687 1778 goto failure; … … 1736 1827 1737 1828 // convert to external table format 1738 SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat );1829 SecFiltToFtable (&ftable, &secfilt[first], Nrows, catalog[0].catformat, TRUE); 1739 1830 1740 1831 // write out SecFilt table … … 1761 1852 // convert to external table format 1762 1853 // XXX does catalog.lensing have averef correctly set up? 1763 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat )) {1854 if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat, TRUE)) { 1764 1855 fprintf (stderr, "trouble converting format\n"); 1765 1856 goto failure; … … 1789 1880 // convert to external table format 1790 1881 // XXX does catalog.lensobj have averef correctly set up? 1791 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat )) {1882 if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat, TRUE)) { 1792 1883 fprintf (stderr, "trouble converting format\n"); 1793 1884 goto failure; … … 1817 1908 // convert to external table format 1818 1909 // XXX does catalog.starpar have averef correctly set up? 1819 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat )) {1910 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat, TRUE)) { 1820 1911 fprintf (stderr, "trouble converting format\n"); 1821 1912 goto failure; … … 1845 1936 // convert to external table format 1846 1937 // XXX does catalog.galshape have averef correctly set up? 1847 if (!GalShapeToFtable (&ftable, &catalog[0].galshape[first], Nrows, catalog[0].catformat )) {1938 if (!GalShapeToFtable (&ftable, &catalog[0].galshape[first], Nrows, catalog[0].catformat, TRUE)) { 1848 1939 fprintf (stderr, "trouble converting format\n"); 1849 1940 goto failure; -
branches/eam_branches/ohana.20150429/src/libdvo/src/dvo_convert.c
r38346 r38348 152 152 switch (format) { 153 153 case DVO_FORMAT_INTERNAL: { 154 gfits_table_set_Average (ftable, average, Naverage, TRUE);154 gfits_table_set_Average (ftable, average, Naverage, swapFromNative); 155 155 break; } 156 156 … … 180 180 181 181 // FtableToMeasure needs the Average since old formats stored measure.dR,dD only 182 Measure *FtableToMeasure (FTable *ftable, Average *average, off_t *Nmeasure, DVOCatFormat *format ) {182 Measure *FtableToMeasure (FTable *ftable, Average *average, off_t *Nmeasure, DVOCatFormat *format, char nativeBytes) { 183 183 184 184 Measure *measure; … … 269 269 270 270 // MeasureToFtable needs the Average since old formats stored measure.dR,dD only 271 int MeasureToFtable (FTable *ftable, Average *average, Measure *measure, off_t Nmeasure, DVOCatFormat format ) {271 int MeasureToFtable (FTable *ftable, Average *average, Measure *measure, off_t Nmeasure, DVOCatFormat format, int swapFromNative) { 272 272 273 273 # define FORMAT_CASE(FORMAT, TYPE, ABS_COORDS) \ … … 276 276 myAssert (ABS_COORDS || average, "conversion from internal needs average table"); \ 277 277 tmpMeasure = MeasureInternalTo_##TYPE (average, measure, Nmeasure); \ 278 gfits_table_set_Measure_##TYPE (ftable, tmpMeasure, Nmeasure, TRUE); \278 gfits_table_set_Measure_##TYPE (ftable, tmpMeasure, Nmeasure, swapFromNative); \ 279 279 free (tmpMeasure); \ 280 280 break; } … … 283 283 switch (format) { 284 284 case DVO_FORMAT_INTERNAL: { 285 gfits_table_set_Measure (ftable, measure, Nmeasure, TRUE);285 gfits_table_set_Measure (ftable, measure, Nmeasure, swapFromNative); 286 286 break; } 287 287 … … 310 310 /*** SecFilt / FTable conversion functions ***/ 311 311 312 SecFilt *FtableToSecFilt (FTable *ftable, off_t *Nsecfilt, DVOCatFormat *format ) {312 SecFilt *FtableToSecFilt (FTable *ftable, off_t *Nsecfilt, DVOCatFormat *format, char nativeBytes) { 313 313 314 314 SecFilt *secfilt; … … 380 380 } 381 381 382 int SecFiltToFtable (FTable *ftable, SecFilt *secfilt, off_t Nsecfilt, DVOCatFormat format ) {382 int SecFiltToFtable (FTable *ftable, SecFilt *secfilt, off_t Nsecfilt, DVOCatFormat format, int swapFromNative) { 383 383 384 384 # define FORMAT_CASE(FORMAT, TYPE) \ … … 386 386 SecFilt_##TYPE *tmpSecFilt; \ 387 387 tmpSecFilt = SecFiltInternalTo_##TYPE (secfilt, Nsecfilt); \ 388 gfits_table_set_SecFilt_##TYPE (ftable, tmpSecFilt, Nsecfilt, TRUE); \388 gfits_table_set_SecFilt_##TYPE (ftable, tmpSecFilt, Nsecfilt, swapFromNative); \ 389 389 free (tmpSecFilt); \ 390 390 break; } … … 393 393 switch (format) { 394 394 case DVO_FORMAT_INTERNAL: { 395 gfits_table_set_SecFilt (ftable, secfilt, Nsecfilt, TRUE);395 gfits_table_set_SecFilt (ftable, secfilt, Nsecfilt, swapFromNative); 396 396 break; } 397 397 … … 420 420 /*** Lensing / FTable conversion functions ***/ 421 421 422 Lensing *FtableToLensing (FTable *ftable, off_t *Nlensing, DVOCatFormat *format ) {422 Lensing *FtableToLensing (FTable *ftable, off_t *Nlensing, DVOCatFormat *format, char nativeBytes) { 423 423 424 424 Lensing *lensing; … … 520 520 521 521 // LensingToFtable needs the Average since old formats stored lensing.dR,dD only 522 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, DVOCatFormat format ) {522 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, DVOCatFormat format, int swapFromNative) { 523 523 524 524 # define FORMAT_CASE(FORMAT, TYPE) \ … … 526 526 Lensing_##TYPE *tmpLensing; \ 527 527 tmpLensing = LensingInternalTo_##TYPE (lensing, Nlensing); \ 528 gfits_table_set_Lensing_##TYPE (ftable, tmpLensing, Nlensing, TRUE); \528 gfits_table_set_Lensing_##TYPE (ftable, tmpLensing, Nlensing, swapFromNative); \ 529 529 free (tmpLensing); \ 530 530 break; } … … 533 533 switch (format) { 534 534 case DVO_FORMAT_INTERNAL: { 535 gfits_table_set_Lensing (ftable, lensing, Nlensing, TRUE);535 gfits_table_set_Lensing (ftable, lensing, Nlensing, swapFromNative); 536 536 break; } 537 537 … … 559 559 /*** Lensobj / FTable conversion functions ***/ 560 560 561 Lensobj *FtableToLensobj (FTable *ftable, off_t *Nlensobj, DVOCatFormat *format ) {561 Lensobj *FtableToLensobj (FTable *ftable, off_t *Nlensobj, DVOCatFormat *format, char nativeBytes) { 562 562 563 563 Lensobj *lensobj; … … 635 635 636 636 // LensobjToFtable needs the Average since old formats stored lensobj.dR,dD only 637 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, DVOCatFormat format ) {637 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, DVOCatFormat format, int swapFromNative) { 638 638 639 639 # define FORMAT_CASE(FORMAT, TYPE) \ … … 641 641 Lensobj_##TYPE *tmpLensobj; \ 642 642 tmpLensobj = LensobjInternalTo_##TYPE (lensobj, Nlensobj); \ 643 gfits_table_set_Lensobj_##TYPE (ftable, tmpLensobj, Nlensobj, TRUE); \643 gfits_table_set_Lensobj_##TYPE (ftable, tmpLensobj, Nlensobj, swapFromNative); \ 644 644 free (tmpLensobj); \ 645 645 break; } … … 648 648 switch (format) { 649 649 case DVO_FORMAT_INTERNAL: { 650 gfits_table_set_Lensobj (ftable, lensobj, Nlensobj, TRUE);650 gfits_table_set_Lensobj (ftable, lensobj, Nlensobj, swapFromNative); 651 651 break; } 652 652 … … 674 674 /*** StarPar / FTable conversion functions ***/ 675 675 676 StarPar *FtableToStarPar (FTable *ftable, off_t *Nstarpar, DVOCatFormat *format ) {676 StarPar *FtableToStarPar (FTable *ftable, off_t *Nstarpar, DVOCatFormat *format, char nativeBytes) { 677 677 678 678 StarPar *starpar; … … 738 738 739 739 // StarParToFtable needs the Average since old formats stored starpar.dR,dD only 740 int StarParToFtable (FTable *ftable, StarPar *starpar, off_t Nstarpar, DVOCatFormat format ) {740 int StarParToFtable (FTable *ftable, StarPar *starpar, off_t Nstarpar, DVOCatFormat format, int swapFromNative) { 741 741 742 742 # define FORMAT_CASE(FORMAT, TYPE) \ … … 744 744 StarPar_##TYPE *tmpStarPar; \ 745 745 tmpStarPar = StarParInternalTo_##TYPE (starpar, Nstarpar); \ 746 gfits_table_set_StarPar_##TYPE (ftable, tmpStarPar, Nstarpar, TRUE); \746 gfits_table_set_StarPar_##TYPE (ftable, tmpStarPar, Nstarpar, swapFromNative); \ 747 747 free (tmpStarPar); \ 748 748 break; } … … 751 751 switch (format) { 752 752 case DVO_FORMAT_INTERNAL: { 753 gfits_table_set_StarPar (ftable, starpar, Nstarpar, TRUE);753 gfits_table_set_StarPar (ftable, starpar, Nstarpar, swapFromNative); 754 754 break; } 755 755 … … 778 778 /*** GalShape / FTable conversion functions ***/ 779 779 780 GalShape *FtableToGalShape (FTable *ftable, off_t *Ngalshape, DVOCatFormat *format ) {780 GalShape *FtableToGalShape (FTable *ftable, off_t *Ngalshape, DVOCatFormat *format, char nativeBytes) { 781 781 782 782 GalShape *galshape; … … 842 842 843 843 // GalShapeToFtable needs the Average since old formats stored galshape.dR,dD only 844 int GalShapeToFtable (FTable *ftable, GalShape *galshape, off_t Ngalshape, DVOCatFormat format ) {844 int GalShapeToFtable (FTable *ftable, GalShape *galshape, off_t Ngalshape, DVOCatFormat format, int swapFromNative) { 845 845 846 846 # define FORMAT_CASE(FORMAT, TYPE) \ … … 848 848 GalShape_##TYPE *tmpGalShape; \ 849 849 tmpGalShape = GalShapeInternalTo_##TYPE (galshape, Ngalshape); \ 850 gfits_table_set_GalShape_##TYPE (ftable, tmpGalShape, Ngalshape, TRUE); \850 gfits_table_set_GalShape_##TYPE (ftable, tmpGalShape, Ngalshape, swapFromNative); \ 851 851 free (tmpGalShape); \ 852 852 break; } … … 855 855 switch (format) { 856 856 case DVO_FORMAT_INTERNAL: { 857 gfits_table_set_GalShape (ftable, galshape, Ngalshape, TRUE);857 gfits_table_set_GalShape (ftable, galshape, Ngalshape, swapFromNative); 858 858 break; } 859 859 -
branches/eam_branches/ohana.20150429/src/libfits/header/F_copy_H.c
r27435 r38348 30 30 return (TRUE); 31 31 } 32 33 int gfits_copy_header_ptr (Header *in, Header *out) { 34 35 int i; 36 37 if (!in) return FALSE; 38 if (!out) return FALSE; 39 40 out[0].simple = in[0].simple; 41 out[0].unsign = in[0].unsign; 42 out[0].extend = in[0].extend; 43 out[0].bitpix = in[0].bitpix; 44 45 out[0].Naxes = in[0].Naxes; 46 for (i = 0; i < FT_MAX_NAXES; i++) 47 out[0].Naxis[i] = in[0].Naxis[i]; 48 49 out[0].datasize = in[0].datasize; 50 51 out[0].pcount = in[0].pcount; 52 out[0].gcount = in[0].gcount; 53 out[0].bzero = in[0].bzero; 54 out[0].bscale = in[0].bscale; 55 56 out[0].buffer = in[0].buffer; 57 58 return (TRUE); 59 } -
branches/eam_branches/ohana.20150429/src/libfits/include/gfitsio.h
r38340 r38348 271 271 int gfits_uncompress_table PROTO((FTable *srctable, FTable *tgttable)); 272 272 273 // XXX EAM for testing 274 int gfits_dump_raw_table (FTable *table, char *message); 275 int gfits_dump_cmp_table (FTable *table, char *message); 276 277 273 278 #endif /* FITSIO */ -
branches/eam_branches/ohana.20150429/src/libfits/table/F_compress_T.c
r38343 r38348 137 137 ALLOCATE (zdata, char, Nzdata_alloc); 138 138 139 gfits_dump_raw_table (srctable, "cmp"); 140 139 141 // compress the data : copy into a tile, compress the tile, then add to the output table 140 142 // each tile -> 1 row of the output table … … 171 173 if (!gfits_varlength_column_finish (tgttable, &fields[i].zdef)) ESCAPE(A); 172 174 } 175 176 gfits_dump_cmp_table (tgttable, "cmp"); 173 177 174 178 free (raw); -
branches/eam_branches/ohana.20150429/src/libfits/table/F_copy_T.c
r38329 r38348 12 12 ALLOCATE (out[0].buffer, char, out[0].datasize); 13 13 memcpy (out[0].buffer, in[0].buffer, out[0].datasize); 14 return (TRUE); 15 } 16 17 /*********************** copy ftable pointers (does not copy memory) ***********************************/ 18 int gfits_copy_ftable_ptr (FTable *in, FTable *out) { 19 20 if (!in) return FALSE; 21 if (!out) return FALSE; 22 23 /* find buffer size */ 24 out[0].validsize = in[0].validsize; 25 out[0].datasize = in[0].datasize; 26 out[0].heap_start = in[0].heap_start; 27 out[0].header = in[0].header; 28 out[0].buffer = in[0].buffer; 14 29 return (TRUE); 15 30 } -
branches/eam_branches/ohana.20150429/src/libfits/table/F_uncompress_T.c
r38343 r38348 6 6 7 7 int gfits_distribute_table_data (FTable *table, char *raw, int col, int row_start, int Nrows, int rowsize); 8 9 # define VERBOSE_DUMP 0 10 11 int gfits_dump_raw_table (FTable *table, char *message) { 12 # if (VERBOSE_DUMP) 13 int i; 14 fprintf (stderr, "%s data: ", message); 15 // for (i = 0; i < table->header->Naxis[0]*table->header->Naxis[1]; i++) { 16 for (i = 0; i < 16; i++) { 17 fprintf (stderr, "0x%02hhx ", table->buffer[i]); 18 } 19 fprintf (stderr, "\n"); 20 # endif 21 return TRUE; 22 } 23 24 int gfits_dump_cmp_table (FTable *table, char *message) { 25 # if (VERBOSE_DUMP) 26 int i; 27 fprintf (stderr, "%s pntr: ", message); 28 for (i = 0; (i < 16) && (i < table->header->Naxis[0]*table->header->Naxis[1]); i++) { 29 fprintf (stderr, "0x%02hhx ", table->buffer[i]); 30 } 31 fprintf (stderr, "\n"); 32 33 fprintf (stderr, "%s data: ", message); 34 for (i = 0; (i < 16) && (i < table->header->pcount); i++) { 35 fprintf (stderr, "0x%02hhx ", table->buffer[table->heap_start + i]); 36 } 37 fprintf (stderr, "\n"); 38 # endif 39 return TRUE; 40 } 8 41 9 42 int gfits_uncompress_table (FTable *srctable, FTable *tgttable) { … … 105 138 // each tile -> 1 row of the output table 106 139 140 gfits_dump_cmp_table (srctable, "unc"); 141 107 142 off_t row; 108 143 for (row = 0; row < srcheader->Naxis[1]; row++) { … … 129 164 } 130 165 166 // int valid = (row == 0) && (i == 0); 167 131 168 off_t row_start = row*ztilelen; 132 169 // ^- first row for this tile & field … … 140 177 } 141 178 } 179 180 gfits_dump_raw_table (tgttable, "unc"); 142 181 143 182 free (raw);
Note:
See TracChangeset
for help on using the changeset viewer.
