public float[] _reassignData(ucar.ma2.Array sourceData, ucar.ma2.Array xData, ucar.ma2.Array yData, java.util.List attList, float delVal, double j, double k, double lat0, double lon0, double dx, double dy, int xPosition, int yPosition) { try { int resCount = 0; ucar.ma2.Index xIndex = xData.getIndex(); ucar.ma2.Index yIndex = yData.getIndex(); ucar.ma2.Index resIndex = sourceData.getIndex(); int[] resShape = resIndex.getShape(); List <double> xCoorList = new List <double>(); for (int xLayerCount = 0; xLayerCount < j; xLayerCount++) { double lon = lon0 + xLayerCount * dx; xCoorList.Add(lon); } List <double> yCoorList = new List <double>(); for (int yLayerCount = 0; yLayerCount < k; yLayerCount++) { double lat = lat0 + yLayerCount * dy; yCoorList.Add(lat); } //get indexes and values from nc file if (resShape.Length > 1) { _ncIndexes = _generateNCIndexes(sourceData, xData, yData, xIndex, yIndex, resShape, xPosition, yPosition, attList, xCoorList, yCoorList); } else { _ncIndexes = _generateNCIndexes1D(sourceData, xData, yData, xIndex, yIndex, resShape, xPosition, yPosition, attList, xCoorList, yCoorList); } //assign values to dfs2 grid List <DataIndex> matchedIndex = new List <DataIndex>(); float[] resfloat = new float[(int)j * (int)k]; for (int i = 0; i < resfloat.Length; i++) { resfloat[i] = delVal; } int resCountNC = 0; for (int i = 0; i < _ncIndexes.Count; i++) { List <int> xCounts = new List <int>(); for (int a = 0; a < _ncIndexes[i].lonFromDfs.Count; a++) { int xCount = xCoorList.FindIndex(x => x == _ncIndexes[i].lonFromDfs[a]); xCounts.Add(xCount); } List <int> yCounts = new List <int>(); for (int a = 0; a < _ncIndexes[i].latFromDfs.Count; a++) { int yCount = yCoorList.FindIndex(x => x == _ncIndexes[i].latFromDfs[a]); yCounts.Add(yCount); } for (int y = 0; y < yCounts.Count; y++) { for (int x = 0; x < xCounts.Count; x++) { resCountNC = (xCounts[x]) + (yCounts[y]) * (xCoorList.Count); if (resCountNC >= resfloat.Length || resCountNC < 0) { throw new Exception("out of bounds - " + resCountNC.ToString() + " + >= array size of " + resfloat.Length.ToString()); } resfloat[resCountNC] = (float)_ncIndexes[i].data; } } } return(resfloat); } catch (Exception ex) { throw new Exception("_reassignData Error: " + ex.Message); } }