001    package org.wdssii.polarmerger;
002    
003    /**
004     * Maintains a list of weights for each grid point
005     * 
006     * @author lakshman
007     * 
008     */
009    public abstract class AbstractWeightedObservationMerger implements
010                    ObservationMerger {
011    
012            protected float[][][] weights = null;
013    
014            public void init(float[][][] values) {
015                    if (weights == null || weights.length != values.length
016                                    || weights[0].length != values[0].length
017                                    || weights[0][0].length != values[0][0].length) {
018    
019                            weights = new float[values.length][values[0].length][values[0][0].length];
020                    }
021                    
022                    for (int i = 0; i < weights.length; ++i) {
023                            for (int j = 0; j < weights[0].length; ++j) {
024                                    for (int k = 0; k < weights[0][0].length; ++k) {
025                                            weights[i][j][k] = 0;
026                                    }
027                            }
028                    }
029    
030                    // the initial values are all zero. Just assert one ...
031                    assert (Math.abs(values[0][0][0] - 0.0f) < 0.001f);
032                    assert (Math.abs(weights[0][0][0] - 0.0f) < 0.001f);
033            }
034    
035    }