def writeXml(self): """ writeXml calls the xmlUtil catalog functions on a list of source catalogs produced by SExtractor of the observation object and also calls the markupImage function (xmlUtil) on the segmentation images produced by SExtractor. New requirements for the markup now mean the pipeline has to include the filter name in the catalog tag of the xml file. filterName func returns the _useful_ filter name, i.e. the one that is not clear. This is now part of the argument list that goes to the xmlStartCat function. A new requirement has been placed upon this writeXml method to allow certain fields of a catalog file to be excluded from the xml markup. This is done to avoid redundant fields for the same objects being sent to the SDA. See Bugzilla bug #1436. """ self.logfile.write( 'Generating the XML catalog(s) from SExtractor output.') lcount = 0 for catfile in self.catalogList: base = string.split(catfile, '.')[0] # the following is done to just get the filter name out of the # corresponding image. dir, file = os.path.split(catfile) image = os.path.splitext(file)[0] + '.fits' fullfile = os.path.join(self.obsFits, image) if self.excludeList: self.logfile.write( "N.B. The following fields are being excluded from the xml output of " + file + ":") for field in self.excludeList: self.logfile.write(field) xmlCatalogName = base + '.xml' pardict = pUtil.readInParFile(self.inParFileList[lcount]) xmlUtil.xmlStartCat(xmlCatalogName, self.obsName, imgfile=fullfile) try: xmlUtil.xmlStartConfig(xmlCatalogName) except Exception, err: self.errorList.append((self.modName, str(err))) self.logfile.write( 'function xmlStartConfig encountered a problem.') raise Exception(err) try: xmlUtil.xmlPars(pardict, xmlCatalogName) self.logfile.write( 'Input Paramaters prepended to xml catalog file.') except Exception, err: self.errorList.append((self.modName, str(err))) self.logfile.write('function xmlPars encountered a problem.') raise Exception(err)
def writeXml(self): """ writeXmlCatalog marks source catalogs with the pipeline protocol markup. Writes the .xml file into the catalogs dir of the observation object. """ self.logfile.write('Generating the XML catalog for BPZ output.') base = string.split(self.bpzCat, '.')[0] xmlCatalogName = base + '.xml' xmlUtil.xmlStartCat(xmlCatalogName, self.obsName) pardict = self._bpzpars(self.bpzCat) xmlUtil.xmlStartConfig(xmlCatalogName) try: xmlUtil.xmlPars(pardict, xmlCatalogName) self.logfile.write( 'Input Paramaters prepended to xml catalog file.') except Exception, err: self.logfile.write('function xmlPars encountered a problem.') self.errorList.append((self.modName, str(err))) raise Exception, err
def writeXml(self): """ writeXml marks the multicolor catalog with the pipeline protocol markup. A new requirement has been placed upon this writeXml method to allow certain fields of the catalog file to be excluded from the xml markup. This is done to avoid redundant fields for the same objects being sent to the SDA. See Bugzilla bug #1436. New functionality in this method now has each filter producing it's own photometry catalog. This functionality is implement via the excludeList which allows the method to select different fields to be excluded from the catalog markup. This method now uses the columnPopList to remove a filter from the list of filters, i.e. the APER_CORR, MAG_BPZ and MAGERR_BPZ of that filter will not be excluded. The filter is then re-inserted into the list and iterates to the next filter. See Bugzilla bug #1599. The aperture correction specified in bug # 2708, is now part of both the multicolor and xml catalogs. The field is included in the markup as the new final magnitudes being sent to bpz, _APER_CORR _MAG_BPZ _MAGERR_BPZ """ self.logfile.write( "Generating the XML catalogs from the multicolor catalog.") self.logfile.write( "N.B. The following fields are being excluded from the xml output: " ) if self.excludeList: for field in self.excludeList: self.logfile.write(field) self.columnsPopList = self.filterNames.keys() for current_filter in self.filterNames.keys(): i = self.columnsPopList.index(current_filter) self.columnsPopList.remove(current_filter) xmlCatalogName = os.path.join(self.obsCats, current_filter + '_photometry.xml') imgfile = os.path.join(self.obsFits, self.filterNames[current_filter]) xmlUtil.xmlStartCat(xmlCatalogName, self.obsName, imgfile=imgfile) xmlUtil.xmlStartConfig(xmlCatalogName) xmlUtil.xmlPars(self.filterPars[current_filter], xmlCatalogName) xmlUtil.xmlEndConfig(xmlCatalogName) self.logfile.write( 'Input Paramaters prepended to xml photometry catalog file.') newXList = [] newXList.extend(self.excludeList) # Append the current filter fields below to the exclude list for the markup. # Only the aperture correction and the bpz mag and err go into the xml catalog. # See Bugzilla bug # 2708. newXList.append(current_filter + "_MAG_ISO") newXList.append(current_filter + "_MAGERR_ISO") newXList.append(current_filter + "_MAGCORR_ISO") newXList.append(current_filter + "_MAGERRCORR_ISO") for item in self.columnsPopList: newXList.append(item + "_MAG_ISO") newXList.append(item + "_MAGERR_ISO") newXList.append(item + "_MAGCORR_ISO") newXList.append(item + "_MAGERRCORR_ISO") newXList.append(item + "_APER_CORR") newXList.append(item + "_MAG_BPZ") newXList.append(item + "_MAGERR_BPZ") self.columnsPopList.insert(i, current_filter) xmlUtil.xmlColorData(self.colorcat, xmlCatalogName, newXList) self.logfile.write("XML catalog written: " + current_filter + '_photometry.xml') xmlUtil.xmlEndCat(xmlCatalogName) self.outputList[os.path.basename(xmlCatalogName)] = [ os.path.basename(self.colorcat) ] return
extParDict = {} extParDict["EBV"] = self.eBV extParDict["EBV_Error"] = self.eBV_error extParDict["Extinction_Hcons_Flag"] = self.dqList[0] extParDict["Extinction_Asteroid_Flag"] = self.dqList[1] extParDict["Extinction_Glitch_Flag"] = self.dqList[2] extParDict["Extinction_Source_Flag"] = self.dqList[3] extParDict["EXtinction_NoList_Flag"] = self.dqList[4] extParDict["Extinction_BigObj_Flag"] = self.dqList[5] extParDict["Extinction_NoIRAS_Flag"] = self.dqList[6] extParDict["Extinction"] = self.filterCorrections[image][0] extParDict["Extinction_Error"] = self.filterCorrections[image][ 1] # and send this to the xmlPars function try: xmlUtil.xmlPars(extParDict, xmlCatalogName) self.logfile.write( 'Extinction Correction Paramaters prepended to xml catalog file.' ) except Exception, err: self.errorList.append((self.modName, str(err))) self.logfile.write( 'function xmlPars encountered a problem with extinction parameters' ) raise Exception(err) try: xmlUtil.xmlEndConfig(xmlCatalogName) except Exception, err: self.errorList.append((self.modName, str(err))) self.logfile.write(