at.tuwien.ifs.somtoolbox.output
Class SOMLibMapOutputter

java.lang.Object
  extended by at.tuwien.ifs.somtoolbox.output.SOMLibMapOutputter
Direct Known Subclasses:
GrowingCellStructuresMapOutputter

public class SOMLibMapOutputter
extends Object

Gathers methods to write trained maps in the SOMLib file format

Version:
$Id: SOMLibMapOutputter.java 3981 2010-12-16 17:32:27Z mayer $
Author:
Michael Dittenbach

Nested Class Summary
(package private) static class SOMLibMapOutputter.DataWinnerMappingThread
           
 
Constructor Summary
SOMLibMapOutputter()
           
 
Method Summary
protected static String getDataWinnerMappingFileName(String fDir, String fName, String idString, boolean gzipped)
           
protected static String getMapDescriptionFileName(String fDir, String fName, String idString, boolean gzipped)
           
protected static String getUnitDescriptionFileName(String fDir, String fName, String idString, boolean gzipped)
           
protected static String getWeightVectorFileName(String fDir, String fName, String idString, boolean gzipped)
           
private static BufferedWriter openAndWriteUnitFileHeader(String fDir, String fName, String id, int xSize, int ySize, int zSize, Layer.GridLayout gridLayout, Layer.GridTopology gridTopology, boolean gzipped)
           
static void write(GHSOM ghsom, String fDir, String fName, boolean gzipped, SOMProperties somProps, FileProperties fileProps)
           
static void write(GrowingSOM gsom, String fDir, String fName, boolean gzipped, SOMProperties somProps, FileProperties fileProps)
          Writes a SOM (or SOM-like) structure to SOMLib format.
static void writeDataWinnerMappingFile(GHSOM ghsom, InputData data, int numWinners, String fDir, String fName, boolean gzipped)
           
static void writeDataWinnerMappingFile(GrowingSOM gsom, InputData data, int numWinners, String fDir, String fName, boolean gzipped)
           
static void writeDataWinnerMappingFile(SOMLibDataWinnerMapping dwm, String fDir, String fName, boolean gzip)
           
static void writeMapDescriptionFile(GrowingSOM topLevelMap, String fDir, String fName, SOMProperties somProps, FileProperties fileProps)
           
static void writeMapDescriptionFile(int xSize, int ySize, int zSize, int dim, int numVectors, String fDir, String fName)
          Simple SOMLib Map description file writer, if you don't have a GrowingSOM object at hand, e.g.
private static void writeMappedVectors(BufferedWriter bw, String[] datalabels, double[] dataDistances)
           
static void writeUnitDescriptionFile(GrowingSOM gsom, String fDir, String fName, boolean gzipped)
          Writes the Unit Description File.
static void writeUnitDescriptionFile(int xdim, int ydim, Layer.GridLayout gridLayout, Layer.GridTopology gridTopology, String fDir, String fName, boolean gzipped)
          Method to write a unit description file of an empty map.
static void writeUnitDescriptionFile(String[][][] labels, Layer.GridLayout gridLayout, Layer.GridTopology gridTopology, String fDir, String fName, boolean gzipped)
           
private static void writeUnitInfoBegin(String fName, BufferedWriter bw, int j, int i, int k, int zSize)
           
static void writeWeightVectorFile(double[][][][] weights, Layer.GridLayout gridLayout, Layer.GridTopology gridTopology, String fDir, String fName, boolean gzipped)
          Writes the Weight Vector File from given weight values, used e.g.
static void writeWeightVectorFile(GrowingSOM gsom, String fDir, String fName, boolean gzipped, String... extraHeaders)
          Writes the Weight Vector File.
protected static BufferedWriter writeWeightVectorFileHeader(String fDir, String fName, boolean gzipped, int xDim, int yDim, int zDim, Layer.GridLayout gridLayout, Layer.GridTopology gridTopology, int vecDim, String idString, String... extraHeaders)
          Writes the header part of the weight vector file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SOMLibMapOutputter

public SOMLibMapOutputter()
Method Detail

write

public static void write(GrowingSOM gsom,
                         String fDir,
                         String fName,
                         boolean gzipped,
                         SOMProperties somProps,
                         FileProperties fileProps)
                  throws IOException
Writes a SOM (or SOM-like) structure to SOMLib format. Usually writes a Map Description File, Weight Vector File and Unit Description File.

Parameters:
gsom - The growing SOM to be written.
fDir - Directory where to write the files to.
fName - Filename without suffix. Usually the name of the training run.
gzipped - Determines whether the written files should be gzipped or not. A ".gz" suffix is automatically appended.
Throws:
IOException

write

public static void write(GHSOM ghsom,
                         String fDir,
                         String fName,
                         boolean gzipped,
                         SOMProperties somProps,
                         FileProperties fileProps)
                  throws IOException
Throws:
IOException

writeWeightVectorFile

public static void writeWeightVectorFile(GrowingSOM gsom,
                                         String fDir,
                                         String fName,
                                         boolean gzipped,
                                         String... extraHeaders)
                                  throws IOException
Writes the Weight Vector File.

Parameters:
gsom - The growing SOM to be written.
fDir - Directory where to write the file to.
fName - fName Filename without suffix. Usually the name of the training run.
gzipped - Determines whether the written files should be gzipped or not. A ".gz" suffix is automatically appended.
Throws:
IOException

writeWeightVectorFile

public static void writeWeightVectorFile(double[][][][] weights,
                                         Layer.GridLayout gridLayout,
                                         Layer.GridTopology gridTopology,
                                         String fDir,
                                         String fName,
                                         boolean gzipped)
                                  throws IOException
Writes the Weight Vector File from given weight values, used e.g. when interpolating a SOM.

Throws:
IOException

writeWeightVectorFileHeader

protected static BufferedWriter writeWeightVectorFileHeader(String fDir,
                                                            String fName,
                                                            boolean gzipped,
                                                            int xDim,
                                                            int yDim,
                                                            int zDim,
                                                            Layer.GridLayout gridLayout,
                                                            Layer.GridTopology gridTopology,
                                                            int vecDim,
                                                            String idString,
                                                            String... extraHeaders)
                                                     throws IOException,
                                                            FileNotFoundException
Writes the header part of the weight vector file.

Throws:
IOException
FileNotFoundException

openAndWriteUnitFileHeader

private static BufferedWriter openAndWriteUnitFileHeader(String fDir,
                                                         String fName,
                                                         String id,
                                                         int xSize,
                                                         int ySize,
                                                         int zSize,
                                                         Layer.GridLayout gridLayout,
                                                         Layer.GridTopology gridTopology,
                                                         boolean gzipped)
                                                  throws IOException
Throws:
IOException

writeUnitDescriptionFile

public static void writeUnitDescriptionFile(GrowingSOM gsom,
                                            String fDir,
                                            String fName,
                                            boolean gzipped)
                                     throws IOException
Writes the Unit Description File.

Parameters:
gsom - The growing SOM to be written.
fDir - Directory where to write the file to.
fName - fName Filename without suffix. Usually the name of the training run.
gzipped - Determines whether the written files should be gzipped or not. A ".gz" suffix is automatically appended.
Throws:
IOException

writeUnitInfoBegin

private static void writeUnitInfoBegin(String fName,
                                       BufferedWriter bw,
                                       int j,
                                       int i,
                                       int k,
                                       int zSize)
                                throws IOException
Throws:
IOException

writeMappedVectors

private static void writeMappedVectors(BufferedWriter bw,
                                       String[] datalabels,
                                       double[] dataDistances)
                                throws IOException
Throws:
IOException

writeUnitDescriptionFile

public static void writeUnitDescriptionFile(int xdim,
                                            int ydim,
                                            Layer.GridLayout gridLayout,
                                            Layer.GridTopology gridTopology,
                                            String fDir,
                                            String fName,
                                            boolean gzipped)
                                     throws IOException
Method to write a unit description file of an empty map.

Throws:
IOException

writeUnitDescriptionFile

public static void writeUnitDescriptionFile(String[][][] labels,
                                            Layer.GridLayout gridLayout,
                                            Layer.GridTopology gridTopology,
                                            String fDir,
                                            String fName,
                                            boolean gzipped)
                                     throws IOException
Throws:
IOException

writeMapDescriptionFile

public static void writeMapDescriptionFile(GrowingSOM topLevelMap,
                                           String fDir,
                                           String fName,
                                           SOMProperties somProps,
                                           FileProperties fileProps)
                                    throws IOException
Throws:
IOException

writeMapDescriptionFile

public static void writeMapDescriptionFile(int xSize,
                                           int ySize,
                                           int zSize,
                                           int dim,
                                           int numVectors,
                                           String fDir,
                                           String fName)
                                    throws IOException
Simple SOMLib Map description file writer, if you don't have a GrowingSOM object at hand, e.g. when converting maps.

Throws:
IOException

writeDataWinnerMappingFile

public static void writeDataWinnerMappingFile(GHSOM ghsom,
                                              InputData data,
                                              int numWinners,
                                              String fDir,
                                              String fName,
                                              boolean gzipped)
                                       throws IOException
Throws:
IOException

writeDataWinnerMappingFile

public static void writeDataWinnerMappingFile(GrowingSOM gsom,
                                              InputData data,
                                              int numWinners,
                                              String fDir,
                                              String fName,
                                              boolean gzipped)
                                       throws IOException
Throws:
IOException

writeDataWinnerMappingFile

public static void writeDataWinnerMappingFile(SOMLibDataWinnerMapping dwm,
                                              String fDir,
                                              String fName,
                                              boolean gzip)
                                       throws IOException
Throws:
IOException

getUnitDescriptionFileName

protected static String getUnitDescriptionFileName(String fDir,
                                                   String fName,
                                                   String idString,
                                                   boolean gzipped)

getWeightVectorFileName

protected static String getWeightVectorFileName(String fDir,
                                                String fName,
                                                String idString,
                                                boolean gzipped)

getDataWinnerMappingFileName

protected static String getDataWinnerMappingFileName(String fDir,
                                                     String fName,
                                                     String idString,
                                                     boolean gzipped)

getMapDescriptionFileName

protected static String getMapDescriptionFileName(String fDir,
                                                  String fName,
                                                  String idString,
                                                  boolean gzipped)