Example #1
0
 def insert_mapping(self):
     logger.info("save annotatedVOTable in %s", self.output_path)
     with open(self.output_path, 'w') as output_votable:
         with open(self.raw_votable_path, 'r') as raw_votable:
             for line in raw_votable:
                 output_votable.write(line)
                 if line.startswith("<VOTABLE") is True:
                     output_votable.write(self._get_mapping())
    def __init__(self, mango_path, component_path):
        '''
        Constructor
        '''
        self.mango_path = mango_path
        self.component_path = component_path
        self.position_path = os.path.join(component_path,
                                          "mango.MJD.mapping.xml")
        logger.info("read  component %s", self.position_path)
        self.appender = ParameterAppender(PARAM_TABLE_MAPPING.POSITION,
                                          self.mango_path, self.position_path)

        #self.appender.add_globals()
        self.appender.add_param_parameter()
    def __init__(self, output_mapping_path, component_path):
        '''
        Constructor
        :param output_mapping_path: Output file with just the mapping block
        :type output_mapping_path: string
        :param component_path: Directory with all the mapping components
        :type component_path: string
        '''
        self.output_mapping_path = output_mapping_path
        self.component_path = component_path
        # get the mapping component attached to this appender
        self.position_path = os.path.join(
            component_path, "mango.LonLatSkyPosition.mapping.xml")
        logger.info("read  component %s", self.position_path)

        # Build the appender instance
        # The appender is in charge of all operations modifying the mapping component
        # to build an XML block ready to be inserted to the mapping
        self.appender = ParameterAppender(PARAM_TABLE_MAPPING.POSITION,
                                          self.output_mapping_path,
                                          self.position_path)
    def build_annotations(self):
        # set the source identifier mapping
        # This is the only mandatory source parameter
        appender = IdentifierAppender(self.mango_path)
        appender.append_measure(self.mapping_config)
        appender.save(self.output_mapping_path)

        # Iterate upon all the parameters to be instanciated
        # The is one appender class for each parameter class
        for measure in self.mapping_config["parameters"]:
            appender = None

            if measure["measure"] == "LonLatSkyPosition":
                logger.info("Position found")
                #FAIT
                appender = LonLatPositionAppender(self.output_mapping_path,
                                                  self.component_path)
            elif measure["measure"] == "Position":
                logger.info("Status found")
                #FAIT
                appender = PositionAppender(self.output_mapping_path,
                                            self.component_path)
            elif measure["measure"] == "ProperMotion":
                logger.info("Status found")
                #FAIT
                appender = ProperMotionAppender(self.output_mapping_path,
                                                self.component_path)
            elif measure["measure"] == "status":
                logger.info("Status found")
                #appender = StatusAppender(self.output_mapping_path, self.component_path)
            elif measure["measure"] == "Photometry":
                logger.info("Photometry found")
                #FAIT
                appender = PhotometryAppender(self.output_mapping_path,
                                              self.component_path)
            elif measure["measure"] == "GenericMeasure":
                logger.info("GenericMeasure found")
                #FAIT
                appender = GenericAppender(self.output_mapping_path,
                                           self.component_path)
            elif measure["measure"] == "HardnessRatio":
                logger.info("GenericMeasure found")
                # FAIT
                appender = HardnessRatioAppender(self.output_mapping_path,
                                                 self.component_path)
            elif measure["measure"] == "DetectionFlag":
                logger.info("DetectionFlag found")
                appender = DetectionFlagAppender(self.output_mapping_path,
                                                 self.component_path)
            elif measure["measure"] == "MJD":
                logger.info("MJD found")
                #appender = MJDAppender(self.output_mapping_path, self.component_path)

            if appender is not None:
                # Build the mapping block for the current measure
                appender.append_measure(measure)
                # Save the file with just the mapping block
                appender.save(self.output_mapping_path)

        # Insert the mapping block in the head of the VOTable
        merger = VOTableMerger(self.raw_votable_path, self.output_mapping_path,
                               self.annot_votable_path)
        merger.insert_mapping()