- Timestamp:
- Jun 27, 2018, 3:31:55 PM (8 years ago)
- Location:
- branches/czw_branch/20170908
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippToPsps/jython/stackbatch.py (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20170908
- Property svn:mergeinfo changed
-
branches/czw_branch/20170908/ippToPsps/jython/stackbatch.py
r39764 r40483 307 307 308 308 # zp correction should comes from DVO (unless image is not in DVO) 309 zpImage = self.scratchDb.getImageZeroPoint(stackID) 310 311 if (zpImage == "NULL"): 312 zpImage = zp 309 (zpImagePSF, zpImageAPER) = self.scratchDb.getStackZeroPoint(stackID) 310 311 # zp is the value in the header, zpImage includes the McalPSF value from DVO 312 if (zpImagePSF == "NULL"): zpImagePSF = zp 313 if (zpImageAPER == "NULL"): zpImageAPER = zpImagePSF 313 314 314 315 detectionThreshold = "NULL" 315 if (magref != "NULL") and (zpImage != "NULL") and (expTime != "NULL"):316 detectionThreshold = magref + zpImage + 2.5 * math.log10(expTime)316 if (magref != "NULL") and (zpImagePSF != "NULL") and (expTime != "NULL"): 317 detectionThreshold = magref + zpImagePSF + 2.5 * math.log10(expTime) 317 318 318 319 # insert stack metadata into table … … 340 341 # sqlLine.group("psfFwhm_max", fwhm_maj_uq) 341 342 sqlLine.group("astroScat", astroscat) 342 sqlLine.group("photoZero", zpImage) 343 sqlLine.group("photoZero", zpImagePSF) 344 sqlLine.group("photoZeroAperture", zpImageAPER) 343 345 sqlLine.group("photoScat", zpErr) 344 346 sqlLine.group("nAstroRef", header['NASTRO']) … … 429 431 sqlLine.group("a."+filter+"Epoch", str(stackEpoch)) 430 432 431 sqlLine.group("a."+filter+"PSFMag", "b.Mpsf") 433 # the Mag values below are set in dvopsps/insert_detections_dvopsps_catalog.c using either zpPSF (PSFMag) or zpAPER (KronMag, ApMag) 434 sqlLine.group("a."+filter+"PSFMag", "b.Mpsf") 432 435 sqlLine.group("a."+filter+"PSFMagErr", "b.dMpsf") 433 436 sqlLine.group("a."+filter+"KronMag", "b.Mkron") … … 440 443 441 444 sqlLine.group("a."+filter+"infoFlag3", "b.flags") 445 sqlLine.group("a."+filter+"infoFlag4", "b.filtflags") 442 446 sql = sqlLine.makeEquals("WHERE a.objID = b.objID AND a." + filter + "ippDetectID = b.ippDetectID AND b.imageID = " + str(imageID)) 443 447 … … 557 561 sqlLine = sqlUtility("UPDATE " + tablename + " AS a, " + self.scratchDb.dvoDetectionTable + " as b SET") 558 562 sqlLine.group("a."+filter+"expTime", "b.expTime") 559 sqlLine.group("a."+filter+"zp", "b.zp") 560 sqlLine.group("a."+filter+"PSFFlux", "a."+filter+"PSFFlux * b.zpFactor") 561 sqlLine.group("a."+filter+"PSFFluxErr", "a."+filter+"PSFFluxErr * b.zpFactor") 562 sqlLine.group("a."+filter+"ApFlux", "a."+filter+"ApFlux * b.zpFactor") 563 sqlLine.group("a."+filter+"ApFluxErr", "a."+filter+"ApFluxErr * b.zpFactor") 564 sqlLine.group("a."+filter+"KronFlux", "a."+filter+"KronFlux * b.zpFactor") 565 sqlLine.group("a."+filter+"KronFluxErr", "a."+filter+"KronFluxErr * b.zpFactor") 566 567 sqlLine.group("a."+filter+"sky", "a."+filter+"sky * b.zpFactor") 568 sqlLine.group("a."+filter+"skyErr", "a."+filter+"skyErr * b.zpFactor") 563 sqlLine.group("a."+filter+"zp", "b.zpPSF") 564 sqlLine.group("a."+filter+"zpAPER", "b.zpAPER") 565 sqlLine.group("a."+filter+"PSFFlux", "a."+filter+"PSFFlux * b.zpFactorPSF") 566 sqlLine.group("a."+filter+"PSFFluxErr", "a."+filter+"PSFFluxErr * b.zpFactorPSF") 567 sqlLine.group("a."+filter+"ApFlux", "a."+filter+"ApFlux * b.zpFactorAPER") 568 sqlLine.group("a."+filter+"ApFluxErr", "a."+filter+"ApFluxErr * b.zpFactorAPER") 569 sqlLine.group("a."+filter+"KronFlux", "a."+filter+"KronFlux * b.zpFactorAPER") 570 sqlLine.group("a."+filter+"KronFluxErr", "a."+filter+"KronFluxErr * b.zpFactorAPER") 571 572 sqlLine.group("a."+filter+"sky", "a."+filter+"sky * b.zpFactorAPER") 573 sqlLine.group("a."+filter+"skyErr", "a."+filter+"skyErr * b.zpFactorAPER") 569 574 570 575 # where should these go? … … 700 705 imageID = self.imageIDs[filter] 701 706 self.logger.infoPair("selecting imageID", imageID) 707 708 # NOTE: for model magnitudes, we use zpPSF not zpAPER since they are PSF-matched 709 # (maybe that is the wrong solution?) 702 710 703 711 # model calibrated magnitude = instrumental magnitude + 2.5*log10(exptime) + ZP (added below from dvoDetectionTable) … … 765 773 sqlLine = sqlUtility("UPDATE " + tablename + " AS a, " + self.scratchDb.dvoDetectionTable + " as b SET") 766 774 767 sqlLine.group("a." + filter + model + "Mag", "a." + filter + model + "Mag + b.zp ")775 sqlLine.group("a." + filter + model + "Mag", "a." + filter + model + "Mag + b.zpPSF") 768 776 769 777 sql = sqlLine.makeEquals("WHERE a.objID = b.objID AND a." + filter + "ippDetectID = b.ippDetectID AND b.imageID = " + str(imageID)) … … 884 892 # PETRO_MAG is instrumental + 2.5log(exptime) + FPA.ZP 885 893 # we want to apply the DVO zero point, so remove FPA.ZP: 886 ## XXX is this statement true: is FPA.ZP + 2.5log(exptime) applied to PETRO_MAG?887 894 888 895 hdrZP = str(self.zpImage[filter]) … … 897 904 sqlLine.group("a."+filter+"haveData", "'1'") 898 905 899 sqlLine.group("a." + filter + "petMag", "b.PETRO_MAG - " + hdrZP) 906 sqlLine.group("a." + filter + "petMag", "b.PETRO_MAG - " + hdrZP) # note that this is **subtracting** the hdrZP (zpAPER is added in below) 900 907 sqlLine.group("a." + filter + "petMagErr", "1.0 / b.PETRO_MAG_ERR") # still inverted? (yes) 901 908 … … 913 920 # modify petMag to apply the zero point 914 921 sqlLine = sqlUtility("UPDATE " + tablename + " AS a, " + self.scratchDb.dvoDetectionTable + " as b SET") 915 sqlLine.group("a." + filter + "petMag", "a." + filter + "petMag + b.zp ")922 sqlLine.group("a." + filter + "petMag", "a." + filter + "petMag + b.zpAPER") 916 923 sql = sqlLine.makeEquals("WHERE a.objID = b.objID AND a." + filter + "ippDetectID = b.ippDetectID AND b.imageID = " + str(imageID)) 917 924 … … 1019 1026 # care of this, but does not? 1020 1027 1021 sqlLine = sqlUtility("UPDATE " + tablename + " SET") 1022 for radius in [1, 2, 3, 4, 5, 6, 7, 8, 9]: 1023 if radius < minRadius: continue 1024 if radius > maxRadius: continue 1025 pspsRadius = radius + 2 1026 sqlLine.group(filter + prefix + "flxR" + str(pspsRadius), "-999") 1027 sqlLine.group(filter + prefix + "flxR" + str(pspsRadius) + "Err", "-999") 1028 sqlLine.group(filter + prefix + "flxR" + str(pspsRadius) + "Std", "-999") 1029 sqlLine.group(filter + prefix + "flxR" + str(pspsRadius) + "Fill", "-999") 1030 1031 sql = sqlLine.makeEquals("") 1032 1033 try: self.scratchDb.execute(sql) 1034 except: 1035 self.logger.errorPair('failed sql',sql) 1036 raise 1028 # chopping this out to see if it still works 1029 1030 #sqlLine = sqlUtility("UPDATE " + tablename + " SET") 1031 #for radius in [1, 2, 3, 4, 5, 6, 7, 8, 9]: 1032 # if radius < minRadius: continue 1033 # if radius > maxRadius: continue 1034 # pspsRadius = radius + 2 1035 # sqlLine.group(filter + prefix + "flxR" + str(pspsRadius), "-999") 1036 # sqlLine.group(filter + prefix + "flxR" + str(pspsRadius) + "Err", "-999") 1037 # sqlLine.group(filter + prefix + "flxR" + str(pspsRadius) + "Std", "-999") 1038 # sqlLine.group(filter + prefix + "flxR" + str(pspsRadius) + "Fill", "-999")# 1039 1040 #sql = sqlLine.makeEquals("") 1041 1042 # try: self.scratchDb.execute(sql) 1043 # except: 1044 # self.logger.errorPair('failed sql',sql) 1045 # raise 1037 1046 1038 1047 # set the flux values from the cmf file … … 1110 1119 pspsNum = str(int(number) + 2) 1111 1120 field = filter + prefix + "flxR" + pspsNum 1112 sqlLine.group(field, field + " * b.zpFactor ")1113 sqlLine.group(field + "Err", field + "err" + " * b.zpFactor ")1114 sqlLine.group(field + "Std", field + "Std" + " * b.zpFactor ")1121 sqlLine.group(field, field + " * b.zpFactorAPER") 1122 sqlLine.group(field + "Err", field + "err" + " * b.zpFactorAPER") 1123 sqlLine.group(field + "Std", field + "Std" + " * b.zpFactorAPER") 1115 1124 1116 1125 sql = sqlLine.makeEquals("WHERE a.objID = b.objID AND a." + filter + "ippDetectID = b.ippDetectID AND b.imageID = " + str(imageID)) … … 1120 1129 self.logger.infoPair("failed sql",sql) 1121 1130 raise 1131 1122 1132 ''' 1123 1133 Populates the StackToImage table
Note:
See TracChangeset
for help on using the changeset viewer.
