Esempio n. 1
0
    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
Esempio n. 2
0
                    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(
                    'function xmlEndConfig encountered a problem')
                raise Exception(err)

            # mark up the data
            try:
                xmlUtil.xmlData(catfile,
                                xmlCatalogName,
                                excludeList=self.excludeList)
                self.logfile.write('XML catalog written for ' +
                                   os.path.basename(catfile))
            except Exception, err:
                self.errorList.append((self.modName, str(err)))