def writeSOM(self, som): """ This method writes the L{SOM.SOM} information to the output file. The C{SOM.SOM} carries only one C{SOM.SO} that has a 2-dimensional spectrum contained in it. @param som: The object to have its information written to file. @type som: L{SOM.SOM} """ self.writeXValues(som) self.writeData(som[0]) dst_utils.write_spec_header(self.__file, self.__epoch, som, comments=self.__comments)
def writeSOM(self, som, **kwargs): """ This method writes the L{SOM.SOM} information to the output file. @param som: The object to have its information written to file. @type som: L{SOM.SOM} @param kwargs: A list of keyword arguments that the method accepts: @keyword extra_som: Parameter to provide another L{SOM.SOM} containing information that should be written to the file. @type extra_som: L{SOM.SOM} @exception RuntimeError: Is raised if the current C{SOM.SOM} and the extra C{SOM.SOM} have incompatible data types. """ self.__data_type = som.getDataSetType() try: extra_som = kwargs["extra_som"] except KeyError: extra_som = None if extra_som is not None and \ self.__data_type != extra_som.getDataSetType(): raise RuntimeError("The SOMs are not the same data type: "\ +"%s, extra_som=%s" % (self._data_type, extra_som.getDataSetType())) dst_utils.write_spec_header(self.__file, self.__epoch, som, comments=self.__comments) (format_str, names) = self.__formatDataInfo(som, extra_som) self.__axes_and_units = format_str % names self.__counter = 1 if extra_som is None: for so in som: self.writeData(so) else: import itertools for so_tuple in itertools.izip(som, extra_som): self.writeData(so_tuple[0], so_tuple[1])
def writeSOM(self, som): """ This method writes the L{SOM.SOM} information to the output file. @param som: The object to have its information written to file. @type som: L{SOM.SOM} """ # Adding a key that will make this a different format print >> self.__file, "#I" dst_utils.write_spec_header(self.__file, self.__epoch, som) if self.__comments is not None: for comment in self.__comments: print >> self.__file, "#C", comment print >> self.__file, \ "#L Pixel ID %s (%s) Error (%s)" % (self.__tag, self.__units, self.__units) for so in som: self.writeData(so)