- Timestamp:
- Dec 12, 2017, 1:17:02 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/stackbatch.py (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/stackbatch.py
r40215 r40281 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") … … 557 560 sqlLine = sqlUtility("UPDATE " + tablename + " AS a, " + self.scratchDb.dvoDetectionTable + " as b SET") 558 561 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") 562 sqlLine.group("a."+filter+"zp", "b.zpPSF") 563 sqlLine.group("a."+filter+"zpAPER", "b.zpAPER") 564 sqlLine.group("a."+filter+"PSFFlux", "a."+filter+"PSFFlux * b.zpFactorPSF") 565 sqlLine.group("a."+filter+"PSFFluxErr", "a."+filter+"PSFFluxErr * b.zpFactorPSF") 566 sqlLine.group("a."+filter+"ApFlux", "a."+filter+"ApFlux * b.zpFactorAPER") 567 sqlLine.group("a."+filter+"ApFluxErr", "a."+filter+"ApFluxErr * b.zpFactorAPER") 568 sqlLine.group("a."+filter+"KronFlux", "a."+filter+"KronFlux * b.zpFactorAPER") 569 sqlLine.group("a."+filter+"KronFluxErr", "a."+filter+"KronFluxErr * b.zpFactorAPER") 570 571 sqlLine.group("a."+filter+"sky", "a."+filter+"sky * b.zpFactorAPER") 572 sqlLine.group("a."+filter+"skyErr", "a."+filter+"skyErr * b.zpFactorAPER") 569 573 570 574 # where should these go? … … 700 704 imageID = self.imageIDs[filter] 701 705 self.logger.infoPair("selecting imageID", imageID) 706 707 # NOTE: for model magnitudes, we use zpPSF not zpAPER since they are PSF-matched 708 # (maybe that is the wrong solution?) 702 709 703 710 # model calibrated magnitude = instrumental magnitude + 2.5*log10(exptime) + ZP (added below from dvoDetectionTable) … … 765 772 sqlLine = sqlUtility("UPDATE " + tablename + " AS a, " + self.scratchDb.dvoDetectionTable + " as b SET") 766 773 767 sqlLine.group("a." + filter + model + "Mag", "a." + filter + model + "Mag + b.zp ")774 sqlLine.group("a." + filter + model + "Mag", "a." + filter + model + "Mag + b.zpPSF") 768 775 769 776 sql = sqlLine.makeEquals("WHERE a.objID = b.objID AND a." + filter + "ippDetectID = b.ippDetectID AND b.imageID = " + str(imageID)) … … 884 891 # PETRO_MAG is instrumental + 2.5log(exptime) + FPA.ZP 885 892 # 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 893 888 894 hdrZP = str(self.zpImage[filter]) … … 897 903 sqlLine.group("a."+filter+"haveData", "'1'") 898 904 899 sqlLine.group("a." + filter + "petMag", "b.PETRO_MAG - " + hdrZP) 905 sqlLine.group("a." + filter + "petMag", "b.PETRO_MAG - " + hdrZP) # note that this is **subtracting** the hdrZP (zpAPER is added in below) 900 906 sqlLine.group("a." + filter + "petMagErr", "1.0 / b.PETRO_MAG_ERR") # still inverted? (yes) 901 907 … … 913 919 # modify petMag to apply the zero point 914 920 sqlLine = sqlUtility("UPDATE " + tablename + " AS a, " + self.scratchDb.dvoDetectionTable + " as b SET") 915 sqlLine.group("a." + filter + "petMag", "a." + filter + "petMag + b.zp ")921 sqlLine.group("a." + filter + "petMag", "a." + filter + "petMag + b.zpAPER") 916 922 sql = sqlLine.makeEquals("WHERE a.objID = b.objID AND a." + filter + "ippDetectID = b.ippDetectID AND b.imageID = " + str(imageID)) 917 923 … … 1019 1025 # care of this, but does not? 1020 1026 1021 #chopping this out to see if it still works1027 # chopping this out to see if it still works 1022 1028 1023 1029 #sqlLine = sqlUtility("UPDATE " + tablename + " SET") … … 1032 1038 1033 1039 #sql = sqlLine.makeEquals("") 1034 1035 # try: self.scratchDb.execute(sql)1036 # except:1037 # self.logger.errorPair('failed sql',sql)1038 # raise1040 1041 # try: self.scratchDb.execute(sql) 1042 # except: 1043 # self.logger.errorPair('failed sql',sql) 1044 # raise 1039 1045 1040 1046 # set the flux values from the cmf file … … 1112 1118 pspsNum = str(int(number) + 2) 1113 1119 field = filter + prefix + "flxR" + pspsNum 1114 sqlLine.group(field, field + " * b.zpFactor ")1115 sqlLine.group(field + "Err", field + "err" + " * b.zpFactor ")1116 sqlLine.group(field + "Std", field + "Std" + " * b.zpFactor ")1120 sqlLine.group(field, field + " * b.zpFactorAPER") 1121 sqlLine.group(field + "Err", field + "err" + " * b.zpFactorAPER") 1122 sqlLine.group(field + "Std", field + "Std" + " * b.zpFactorAPER") 1117 1123 1118 1124 sql = sqlLine.makeEquals("WHERE a.objID = b.objID AND a." + filter + "ippDetectID = b.ippDetectID AND b.imageID = " + str(imageID)) … … 1122 1128 self.logger.infoPair("failed sql",sql) 1123 1129 raise 1130 1124 1131 ''' 1125 1132 Populates the StackToImage table
Note:
See TracChangeset
for help on using the changeset viewer.
