bugfix for surface griddata interpolation

This commit is contained in:
wyq 2022-04-16 12:36:16 +08:00
parent 792307b8cf
commit a796e5fbc4
27 changed files with 512 additions and 219 deletions

View File

@ -29,12 +29,16 @@ public class DimArray {
this.dimensions = new ArrayList<>(); this.dimensions = new ArrayList<>();
} }
/**
* Constructor
* @param array The array
*/
public DimArray(Array array) { public DimArray(Array array) {
this.array = array; this.array = array;
this.dimensions = new ArrayList<>(); this.dimensions = new ArrayList<>();
int[] shape = array.getShape(); int[] shape = array.getShape();
for (int s : shape) { for (int s : shape) {
this.dimensions.add(new Dimension(s));
} }
} }
@ -136,7 +140,89 @@ public class DimArray {
public double getDimValue(int dimIdx, int vIdx) { public double getDimValue(int dimIdx, int vIdx) {
return this.dimensions.get(dimIdx).getDimValue(vIdx); return this.dimensions.get(dimIdx).getDimValue(vIdx);
} }
/**
* Get stagger dimension
* @return Stagger dimension
*/
public Dimension getStaggerDim() {
for (Dimension dim : this.dimensions) {
if (dim.isStagger()) {
return dim;
}
}
return null;
}
/**
* Get stagger dimension index
* @return Stagger dimension index
*/
public int getStaggerDimIndex() {
int i = 0;
for (Dimension dim : this.dimensions) {
if (dim.isStagger()) {
return i;
}
i += 1;
}
return -1;
}
/**
* Get X dimension
* @return X dimension
*/
public Dimension getXDimension() {
for (Dimension dim : this.dimensions) {
if (dim.getDimType() == DimensionType.X) {
return dim;
}
}
return null;
}
/**
* Get Y dimension
* @return Y dimension
*/
public Dimension getYDimension() {
for (Dimension dim : this.dimensions) {
if (dim.getDimType() == DimensionType.Y) {
return dim;
}
}
return null;
}
/**
* Get Z dimension
* @return Z dimension
*/
public Dimension getZDimension() {
for (Dimension dim : this.dimensions) {
if (dim.getDimType() == DimensionType.Z) {
return dim;
}
}
return null;
}
/**
* Get time dimension
* @return Time dimension
*/
public Dimension getTDimension() {
for (Dimension dim : this.dimensions) {
if (dim.getDimType() == DimensionType.T) {
return dim;
}
}
return null;
}
/** /**
* Section * Section
* @param origin Origin * @param origin Origin

View File

@ -40,6 +40,7 @@ public class Dimension {
private boolean shared = true; private boolean shared = true;
private boolean reverse = false; private boolean reverse = false;
private String unit = "null"; private String unit = "null";
private boolean stagger = false;
/** /**
* Constructor * Constructor
@ -48,6 +49,14 @@ public class Dimension {
this("null", 1); this("null", 1);
} }
/**
* Constructor
* @param len Length
*/
public Dimension(int len) {
this("null", len);
}
/** /**
* Constructor * Constructor
* *
@ -79,7 +88,7 @@ public class Dimension {
public Dimension(String name, Array dimValue, DimensionType dimType) { public Dimension(String name, Array dimValue, DimensionType dimType) {
this.name = name; this.name = name;
this.dimType = dimType; this.dimType = dimType;
this.dimValue = dimValue; this.dimValue = dimValue.copyIfView();
} }
/** /**
@ -118,6 +127,19 @@ public class Dimension {
this.dimType = dimType; this.dimType = dimType;
dimValue = ArrayUtil.arrayRange1(min, len, delta); dimValue = ArrayUtil.arrayRange1(min, len, delta);
} }
/**
* Constructor
* @param dimension Other dimension
*/
public Dimension(Dimension dimension) {
this.name = dimension.getName();
this.dimId = dimension.getDimId();
this.unit = dimension.getUnit();
this.dimType = dimension.getDimType();
this.stagger = dimension.isStagger();
this.unlimited = dimension.isUnlimited();
}
// </editor-fold> // </editor-fold>
// <editor-fold desc="Get Set Methods"> // <editor-fold desc="Get Set Methods">
/** /**
@ -206,7 +228,7 @@ public class Dimension {
* @param value Dimension values * @param value Dimension values
*/ */
public void setDimValue(Array value) { public void setDimValue(Array value) {
this.dimValue = value; this.dimValue = value.copyIfView();
} }
/** /**
@ -325,6 +347,22 @@ public class Dimension {
public void setUnit(String value) { public void setUnit(String value) {
this.unit = value; this.unit = value;
} }
/**
* Get whether is stagger dimension
* @return Whether is stagger dimension
*/
public boolean isStagger() {
return this.stagger;
}
/**
* Set whether is stagger dimension
* @param value Whether is stagger dimension
*/
public void setStagger(boolean value) {
this.stagger = value;
}
// </editor-fold> // </editor-fold>
// <editor-fold desc="Methods"> // <editor-fold desc="Methods">
@ -474,46 +512,38 @@ public class Dimension {
* @return Extracted dimension * @return Extracted dimension
*/ */
public Dimension extract(int first, int last, int stride) { public Dimension extract(int first, int last, int stride) {
/*int n = (last - first) / stride + 1; int n = (last - first) / stride + 1;
Dimension dim = new Dimension(this.getShortName(), n, this.dimType); Dimension dim = new Dimension(this.getShortName(), n, this.dimType);
dim.setDimId(this.dimId); dim.setDimId(this.dimId);
dim.setUnit(this.unit); dim.setUnit(this.unit);
//dim.setReverse(this.reverse); //dim.setReverse(this.reverse);
if (this.dimValue.size() > last) { if (this.dimValue.getSize() > last) {
List<Double> values = new ArrayList<>(); List<Double> values = new ArrayList<>();
if (first <= last) { if (first <= last) {
if (stride > 0) { if (stride > 0) {
for (int i = first; i <= last; i += stride) { for (int i = first; i <= last; i += stride) {
values.add(this.dimValue.get(i)); values.add(this.dimValue.getDouble(i));
} }
} else { } else {
for (int i = last; i >= first; i += stride) { for (int i = last; i >= first; i += stride) {
values.add(this.dimValue.get(i)); values.add(this.dimValue.getDouble(i));
} }
} }
} else { } else {
if (stride > 0) { if (stride > 0) {
for (int i = last; i <= first; i += stride) { for (int i = last; i <= first; i += stride) {
values.add(this.dimValue.get(i)); values.add(this.dimValue.getDouble(i));
} }
} else { } else {
for (int i = first; i >= last; i += stride) { for (int i = first; i >= last; i += stride) {
values.add(this.dimValue.get(i)); values.add(this.dimValue.getDouble(i));
} }
} }
} }
dim.setValues(values); dim.setValues(values);
} }
return dim;*/ return dim;
try {
Range range = new Range(first, last, stride);
return extract(range);
} catch (InvalidRangeException e) {
e.printStackTrace();
return null;
}
} }
/** /**
@ -586,17 +616,16 @@ public class Dimension {
* @return Index * @return Index
*/ */
public int getValueIndex(double v) { public int getValueIndex(double v) {
return ArrayUtil.getDimIndex(this.dimValue, v); int idx = Arrays.asList(this.dimValue).indexOf(v);
/*int idx = this.dimValue.indexOf(v);
if (idx < 0) { if (idx < 0) {
idx = this.getLength() - 1; idx = this.getLength() - 1;
if (getDeltaValue() > 0) { if (getDeltaValue() > 0) {
for (int i = 0; i < this.getLength(); i++) { for (int i = 0; i < this.getLength(); i++) {
if (v <= this.dimValue.get(i)) { if (v <= this.dimValue.getDouble(i)) {
if (i == 0) if (i == 0)
idx = 0; idx = 0;
else { else {
if (this.dimValue.get(i) - v > v - this.dimValue.get(i - 1)) if (this.dimValue.getDouble(i) - v > v - this.dimValue.getDouble(i - 1))
idx = i - 1; idx = i - 1;
else else
idx = i; idx = i;
@ -606,11 +635,11 @@ public class Dimension {
} }
} else { } else {
for (int i = 0; i < this.getLength(); i++) { for (int i = 0; i < this.getLength(); i++) {
if (v >= this.dimValue.get(i)) { if (v >= this.dimValue.getDouble(i)) {
if (i == 0) if (i == 0)
idx = 0; idx = 0;
else { else {
if (this.dimValue.get(i - 1) - v > v - this.dimValue.get(i)) if (this.dimValue.getDouble(i - 1) - v > v - this.dimValue.getDouble(i))
idx = i; idx = i;
else else
idx = i - 1; idx = i - 1;
@ -621,11 +650,7 @@ public class Dimension {
} }
} }
*//*if (this.reverse) { return idx;
idx = this.getLength() - idx - 1;
}*//*
return idx;*/
} }
/** /**
@ -648,6 +673,8 @@ public class Dimension {
sb.append("Size: ").append(String.valueOf(this.getLength())); sb.append("Size: ").append(String.valueOf(this.getLength()));
sb.append("\n"); sb.append("\n");
sb.append("Delta: ").append(String.valueOf(this.getDeltaValue())); sb.append("Delta: ").append(String.valueOf(this.getDeltaValue()));
sb.append("\n");
sb.append("Unit: ").append(this.unit);
return sb.toString(); return sb.toString();
} }

View File

@ -20,8 +20,10 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.meteoinfo.common.util.JDateUtil; import org.meteoinfo.common.util.JDateUtil;
import org.meteoinfo.data.dimarray.DimArray;
import org.meteoinfo.ndarray.Array; import org.meteoinfo.ndarray.Array;
import org.meteoinfo.data.dimarray.Dimension; import org.meteoinfo.data.dimarray.Dimension;
import org.meteoinfo.ndarray.InvalidRangeException;
import org.meteoinfo.projection.KnownCoordinateSystems; import org.meteoinfo.projection.KnownCoordinateSystems;
import org.meteoinfo.projection.ProjectionInfo; import org.meteoinfo.projection.ProjectionInfo;
@ -520,6 +522,23 @@ import org.meteoinfo.projection.ProjectionInfo;
*/ */
public abstract Array read(String varName); public abstract Array read(String varName);
/**
* Read dimension array data
* @param varName Variable name
* @return Dimension array
*/
public DimArray readDimArray(String varName) {
Variable variable = this.getVariable(varName);
if (variable == null) {
System.out.println("The variable is not exist: " + varName);
return null;
}
Array array = read(varName);
return new DimArray(array, variable.getDimensions());
}
/** /**
* Read array data * Read array data
* *
@ -531,6 +550,32 @@ import org.meteoinfo.projection.ProjectionInfo;
*/ */
public abstract Array read(String varName, int[] origin, int[] size, int[] stride); public abstract Array read(String varName, int[] origin, int[] size, int[] stride);
/**
* Read dimension array data
*
* @param varName Variable name
* @param origin Origin array
* @param size Size array
* @param stride Stride array
* @return Dimension array
*/
public DimArray readDimArray(String varName, int[] origin, int[] size, int[] stride) {
Variable variable = this.getVariable(varName);
if (variable == null) {
System.out.println("The variable is not exist: " + varName);
return null;
}
Array array = read(varName, origin, size, stride);
try {
List<Dimension> dimensions = variable.sectionDimensions(origin, size, stride);
return new DimArray(array, dimensions);
} catch (InvalidRangeException e) {
e.printStackTrace();
return new DimArray(array);
}
}
/** /**
* Get global attributes * Get global attributes
* @return Global attributes * @return Global attributes

View File

@ -14,6 +14,7 @@
package org.meteoinfo.data.meteodata; package org.meteoinfo.data.meteodata;
import org.meteoinfo.common.util.JDateUtil; import org.meteoinfo.common.util.JDateUtil;
import org.meteoinfo.data.dimarray.DimArray;
import org.meteoinfo.data.dimarray.DimensionType; import org.meteoinfo.data.dimarray.DimensionType;
import org.meteoinfo.data.dimarray.Dimension; import org.meteoinfo.data.dimarray.Dimension;
@ -21,9 +22,7 @@ import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.meteoinfo.ndarray.DataType; import org.meteoinfo.ndarray.*;
import org.meteoinfo.ndarray.Range;
import org.meteoinfo.ndarray.Section;
/** /**
* *
@ -31,9 +30,6 @@ import org.meteoinfo.ndarray.Section;
*/ */
public class Variable { public class Variable {
// <editor-fold desc="Variables"> // <editor-fold desc="Variables">
/// <summary>
/// Parameter number
/// </summary>
public int Number; public int Number;
private String name; private String name;
@ -42,21 +38,17 @@ public class Variable {
protected int[] shape = new int[0]; protected int[] shape = new int[0];
protected List<Dimension> dimensions = new ArrayList<>(); protected List<Dimension> dimensions = new ArrayList<>();
protected List<Attribute> attributes = new ArrayList<>(); protected List<Attribute> attributes = new ArrayList<>();
private int _levelType; private int levelType;
private List<Double> _levels; private List<Double> levels;
private String units; private String units;
private String _description; private String description;
//private List<Dimension> _dimensions = new ArrayList<>(); private String hdfPath;
private String _hdfPath; private boolean isStation = false;
private boolean _isStation = false; private boolean isSwath = false;
private boolean _isSwath = false; private int varId;
//private NetCDF4.NcType _ncType;
//private List<Attribute> _attributes = new ArrayList<>();
//private int _attNumber;
private int _varId;
private boolean dimVar = false; private boolean dimVar = false;
private List<Integer> _levelIdxs = new ArrayList<>(); private List<Integer> levelIdxs = new ArrayList<>();
private List<Integer> _varInLevelIdxs = new ArrayList<>(); private List<Integer> varInLevelIdxs = new ArrayList<>();
private double fill_value = -9999.0; private double fill_value = -9999.0;
private double scale_factor = 1; private double scale_factor = 1;
private double add_offset = 0; private double add_offset = 0;
@ -70,9 +62,9 @@ public class Variable {
this.name = "null"; this.name = "null";
this.shortName = null; this.shortName = null;
this.dataType = DataType.FLOAT; this.dataType = DataType.FLOAT;
_levels = new ArrayList<>(); levels = new ArrayList<>();
units = "null"; units = "null";
_description = "null"; description = "null";
} }
/** /**
@ -87,8 +79,8 @@ public class Variable {
Number = aNum; Number = aNum;
this.name = aName; this.name = aName;
this.units = aUnit; this.units = aUnit;
_description = aDesc; description = aDesc;
_levels = new ArrayList<>(); levels = new ArrayList<>();
} }
// </editor-fold> // </editor-fold>
@ -218,7 +210,7 @@ public class Variable {
* @return Level type * @return Level type
*/ */
public int getLevelType() { public int getLevelType() {
return _levelType; return levelType;
} }
/** /**
@ -227,7 +219,7 @@ public class Variable {
* @param value Level type * @param value Level type
*/ */
public void setLevelType(int value) { public void setLevelType(int value) {
_levelType = value; levelType = value;
} }
/** /**
@ -239,7 +231,7 @@ public class Variable {
//return _levels; //return _levels;
Dimension zDim = this.getZDimension(); Dimension zDim = this.getZDimension();
if (zDim == null) { if (zDim == null) {
return _levels; return levels;
} else { } else {
return zDim.getDimValueList(); return zDim.getDimValueList();
} }
@ -251,7 +243,7 @@ public class Variable {
* @param value Levels * @param value Levels
*/ */
public void setLevels(List<Double> value) { public void setLevels(List<Double> value) {
_levels = value; levels = value;
this.updateZDimension(); this.updateZDimension();
} }
@ -279,7 +271,7 @@ public class Variable {
* @return Description * @return Description
*/ */
public String getDescription() { public String getDescription() {
return _description; return description;
} }
/** /**
@ -288,7 +280,7 @@ public class Variable {
* @param value Description * @param value Description
*/ */
public void setDescription(String value) { public void setDescription(String value) {
_description = value; description = value;
} }
/** /**
@ -321,7 +313,7 @@ public class Variable {
* @return HDF path * @return HDF path
*/ */
public String getHDFPath() { public String getHDFPath() {
return _hdfPath; return hdfPath;
} }
/** /**
@ -330,7 +322,7 @@ public class Variable {
* @param value HDF path * @param value HDF path
*/ */
public void setHDFPath(String value) { public void setHDFPath(String value) {
_hdfPath = value; hdfPath = value;
} }
/** /**
@ -425,7 +417,7 @@ public class Variable {
* @return Boolean * @return Boolean
*/ */
public boolean isStation() { public boolean isStation() {
return _isStation; return isStation;
} }
/** /**
@ -434,7 +426,7 @@ public class Variable {
* @param value Boolean * @param value Boolean
*/ */
public void setStation(boolean value) { public void setStation(boolean value) {
_isStation = value; isStation = value;
} }
/** /**
@ -443,7 +435,7 @@ public class Variable {
* @return Boolean * @return Boolean
*/ */
public boolean isSwath() { public boolean isSwath() {
return _isSwath; return isSwath;
} }
/** /**
@ -452,7 +444,7 @@ public class Variable {
* @param value Boolean * @param value Boolean
*/ */
public void setSwath(boolean value) { public void setSwath(boolean value) {
_isSwath = value; isSwath = value;
} }
/** /**
@ -461,7 +453,7 @@ public class Variable {
* @return Boolean * @return Boolean
*/ */
public boolean isPlottable() { public boolean isPlottable() {
if (_isStation) { if (isStation) {
return true; return true;
} }
if (this.getXDimension() == null) { if (this.getXDimension() == null) {
@ -489,7 +481,7 @@ public class Variable {
* @return Variable identifer * @return Variable identifer
*/ */
public int getVarId() { public int getVarId() {
return _varId; return varId;
} }
/** /**
@ -498,7 +490,7 @@ public class Variable {
* @param value Variable identifer * @param value Variable identifer
*/ */
public void setVarId(int value) { public void setVarId(int value) {
_varId = value; varId = value;
} }
/** /**
@ -525,7 +517,7 @@ public class Variable {
* @return Level index list * @return Level index list
*/ */
public List<Integer> getLevelIdxs() { public List<Integer> getLevelIdxs() {
return _levelIdxs; return levelIdxs;
} }
/** /**
@ -534,7 +526,7 @@ public class Variable {
* @param value Level index list * @param value Level index list
*/ */
public void setLevelIdxs(List<Integer> value) { public void setLevelIdxs(List<Integer> value) {
_levelIdxs = value; levelIdxs = value;
} }
/** /**
@ -543,7 +535,7 @@ public class Variable {
* @return Variable index * @return Variable index
*/ */
public List<Integer> getVarInLevelIdxs() { public List<Integer> getVarInLevelIdxs() {
return _varInLevelIdxs; return varInLevelIdxs;
} }
/** /**
@ -552,7 +544,7 @@ public class Variable {
* @param value Variable index * @param value Variable index
*/ */
public void setVarInLevelIdxs(List<Integer> value) { public void setVarInLevelIdxs(List<Integer> value) {
_varInLevelIdxs = value; varInLevelIdxs = value;
} }
/** /**
@ -651,15 +643,13 @@ public class Variable {
aPar.setName(this.getName()); aPar.setName(this.getName());
aPar.setShortName(this.getShortName()); aPar.setShortName(this.getShortName());
aPar.setUnits(units); aPar.setUnits(units);
aPar.setDescription(_description); aPar.setDescription(description);
aPar.setLevelType(_levelType); aPar.setLevelType(levelType);
//aPar.getAttributes().addAll(_attributes);
aPar.getDimensions().addAll(this.getDimensions()); aPar.getDimensions().addAll(this.getDimensions());
aPar.setDimVar(dimVar); aPar.setDimVar(dimVar);
aPar.getLevels().addAll(_levels); aPar.getLevels().addAll(levels);
//aPar.NCType = _ncType; aPar.setVarId(varId);
aPar.setVarId(_varId);
return aPar; return aPar;
} }
@ -677,7 +667,7 @@ public class Variable {
if (Number != aVar.Number) { if (Number != aVar.Number) {
return false; return false;
} }
if (!_description.equals(aVar.getDescription())) { if (!description.equals(aVar.getDescription())) {
return false; return false;
} }
if (!units.equals(aVar.getUnits())) { if (!units.equals(aVar.getUnits())) {
@ -700,13 +690,13 @@ public class Variable {
if (Number != aVar.Number) { if (Number != aVar.Number) {
return false; return false;
} }
if (!_description.equals(aVar.getDescription())) { if (!description.equals(aVar.getDescription())) {
return false; return false;
} }
if (!units.equals(aVar.getUnits())) { if (!units.equals(aVar.getUnits())) {
return false; return false;
} }
if (_levelType != aVar.getLevelType()) { if (levelType != aVar.getLevelType()) {
return false; return false;
} }
@ -719,8 +709,8 @@ public class Variable {
* @param levelValue Level value * @param levelValue Level value
*/ */
public void addLevel(double levelValue) { public void addLevel(double levelValue) {
if (!_levels.contains(levelValue)) { if (!levels.contains(levelValue)) {
_levels.add(levelValue); levels.add(levelValue);
} }
} }
@ -1221,13 +1211,35 @@ public class Variable {
* Update z dimension from levels * Update z dimension from levels
*/ */
public void updateZDimension() { public void updateZDimension() {
if (_levels.size() > 0) { if (levels.size() > 0) {
Dimension zdim = new Dimension("null", 0, DimensionType.Z); Dimension zdim = new Dimension("null", 0, DimensionType.Z);
zdim.setValues(_levels); zdim.setValues(levels);
this.setZDimension(zdim); this.setZDimension(zdim);
} }
} }
/**
* Section dimensions
* @param origin Origin
* @param size Size
* @param stride Stride
* @return Section result dimensions
* @throws InvalidRangeException
*/
public List<Dimension> sectionDimensions(int[] origin, int[] size, int[] stride) throws InvalidRangeException {
Section section = new Section(origin, size, stride);
List<Dimension> dims = new ArrayList<>();
for (int i = 0; i < section.getRank(); i++) {
Range range = section.getRange(i);
if (range.length() > 1) {
Dimension dim = this.dimensions.get(i).extract(range);
dims.add(dim);
}
}
return dims;
}
/** /**
* To string * To string
* @return String * @return String

View File

@ -6,6 +6,7 @@ import org.meteoinfo.common.util.JDateUtil;
import org.meteoinfo.data.GridArray; import org.meteoinfo.data.GridArray;
import org.meteoinfo.data.GridData; import org.meteoinfo.data.GridData;
import org.meteoinfo.data.StationData; import org.meteoinfo.data.StationData;
import org.meteoinfo.data.dimarray.DimArray;
import org.meteoinfo.data.dimarray.Dimension; import org.meteoinfo.data.dimarray.Dimension;
import org.meteoinfo.data.dimarray.DimensionType; import org.meteoinfo.data.dimarray.DimensionType;
import org.meteoinfo.dataframe.Column; import org.meteoinfo.dataframe.Column;
@ -509,6 +510,16 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
} }
} }
@Override
public DimArray readDimArray(String varName) {
return null;
}
@Override
public DimArray readDimArray(String varName, int[] origin, int[] size, int[] stride) {
return null;
}
@Override @Override
public List<Attribute> getGlobalAttributes() { public List<Attribute> getGlobalAttributes() {
return null; return null;

View File

@ -17,6 +17,7 @@ import org.meteoinfo.common.Extent;
import org.meteoinfo.common.MIMath; import org.meteoinfo.common.MIMath;
import org.meteoinfo.common.util.JDateUtil; import org.meteoinfo.common.util.JDateUtil;
import org.meteoinfo.data.StationData; import org.meteoinfo.data.StationData;
import org.meteoinfo.data.dimarray.DimArray;
import org.meteoinfo.data.meteodata.DataInfo; import org.meteoinfo.data.meteodata.DataInfo;
import org.meteoinfo.ndarray.math.ArrayMath; import org.meteoinfo.ndarray.math.ArrayMath;
import org.meteoinfo.data.dimarray.Dimension; import org.meteoinfo.data.dimarray.Dimension;

View File

@ -22,6 +22,7 @@ import java.util.logging.Logger;
import org.meteoinfo.common.Extent; import org.meteoinfo.common.Extent;
import org.meteoinfo.common.util.JDateUtil; import org.meteoinfo.common.util.JDateUtil;
import org.meteoinfo.data.StationData; import org.meteoinfo.data.StationData;
import org.meteoinfo.data.dimarray.DimArray;
import org.meteoinfo.data.meteodata.DataInfo; import org.meteoinfo.data.meteodata.DataInfo;
import org.meteoinfo.data.dimarray.Dimension; import org.meteoinfo.data.dimarray.Dimension;
import org.meteoinfo.data.dimarray.DimensionType; import org.meteoinfo.data.dimarray.DimensionType;

View File

@ -16,6 +16,7 @@ package org.meteoinfo.data.meteodata.micaps;
import org.meteoinfo.common.Extent; import org.meteoinfo.common.Extent;
import org.meteoinfo.common.util.JDateUtil; import org.meteoinfo.common.util.JDateUtil;
import org.meteoinfo.data.StationData; import org.meteoinfo.data.StationData;
import org.meteoinfo.data.dimarray.DimArray;
import org.meteoinfo.data.meteodata.DataInfo; import org.meteoinfo.data.meteodata.DataInfo;
import org.meteoinfo.data.dimarray.Dimension; import org.meteoinfo.data.dimarray.Dimension;
import org.meteoinfo.data.dimarray.DimensionType; import org.meteoinfo.data.dimarray.DimensionType;

View File

@ -16,6 +16,7 @@ package org.meteoinfo.data.meteodata.micaps;
import org.meteoinfo.common.MIMath; import org.meteoinfo.common.MIMath;
import org.meteoinfo.common.util.JDateUtil; import org.meteoinfo.common.util.JDateUtil;
import org.meteoinfo.data.GridData; import org.meteoinfo.data.GridData;
import org.meteoinfo.data.dimarray.DimArray;
import org.meteoinfo.data.meteodata.DataInfo; import org.meteoinfo.data.meteodata.DataInfo;
import org.meteoinfo.data.dimarray.Dimension; import org.meteoinfo.data.dimarray.Dimension;
import org.meteoinfo.data.dimarray.DimensionType; import org.meteoinfo.data.dimarray.DimensionType;

View File

@ -23,6 +23,7 @@ import org.meteoinfo.common.DataConvert;
import org.meteoinfo.common.util.JDateUtil; import org.meteoinfo.common.util.JDateUtil;
import org.meteoinfo.data.GridArray; import org.meteoinfo.data.GridArray;
import org.meteoinfo.data.GridData; import org.meteoinfo.data.GridData;
import org.meteoinfo.data.dimarray.DimArray;
import org.meteoinfo.data.meteodata.DataInfo; import org.meteoinfo.data.meteodata.DataInfo;
import org.meteoinfo.data.dimarray.Dimension; import org.meteoinfo.data.dimarray.Dimension;
import org.meteoinfo.data.dimarray.DimensionType; import org.meteoinfo.data.dimarray.DimensionType;

View File

@ -22,6 +22,7 @@ import org.meteoinfo.common.util.GlobalUtil;
import org.meteoinfo.common.util.JDateUtil; import org.meteoinfo.common.util.JDateUtil;
import org.meteoinfo.data.GridArray; import org.meteoinfo.data.GridArray;
import org.meteoinfo.data.GridData; import org.meteoinfo.data.GridData;
import org.meteoinfo.data.dimarray.DimArray;
import org.meteoinfo.data.meteodata.DataInfo; import org.meteoinfo.data.meteodata.DataInfo;
import org.meteoinfo.data.dimarray.Dimension; import org.meteoinfo.data.dimarray.Dimension;
import org.meteoinfo.data.dimarray.DimensionType; import org.meteoinfo.data.dimarray.DimensionType;

View File

@ -18,6 +18,7 @@ import org.meteoinfo.common.MIMath;
import org.meteoinfo.common.util.JDateUtil; import org.meteoinfo.common.util.JDateUtil;
import org.meteoinfo.data.GridData; import org.meteoinfo.data.GridData;
import org.meteoinfo.data.StationData; import org.meteoinfo.data.StationData;
import org.meteoinfo.data.dimarray.DimArray;
import org.meteoinfo.data.meteodata.DataInfo; import org.meteoinfo.data.meteodata.DataInfo;
import org.meteoinfo.ndarray.math.ArrayMath; import org.meteoinfo.ndarray.math.ArrayMath;
import org.meteoinfo.ndarray.math.ArrayUtil; import org.meteoinfo.ndarray.math.ArrayUtil;
@ -1453,6 +1454,7 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
Dimension ysdim = findDimension("south_north_stag"); Dimension ysdim = findDimension("south_north_stag");
if (xsdim != null && ysdim != null) { if (xsdim != null && ysdim != null) {
xsdim.setDimType(DimensionType.X); xsdim.setDimType(DimensionType.X);
xsdim.setStagger(true);
double[] nX = new double[xNum + 1]; double[] nX = new double[xNum + 1];
double norgX = orgX - dx * 0.5; double norgX = orgX - dx * 0.5;
for (i = 0; i <= xNum; i++) { for (i = 0; i <= xNum; i++) {
@ -1461,6 +1463,7 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
xsdim.setValues(nX); xsdim.setValues(nX);
ysdim.setDimType(DimensionType.Y); ysdim.setDimType(DimensionType.Y);
ysdim.setStagger(true);
double[] nY = new double[yNum + 1]; double[] nY = new double[yNum + 1];
double norgY = orgY - dx * 0.5; double norgY = orgY - dx * 0.5;
for (i = 0; i <= yNum; i++) { for (i = 0; i <= yNum; i++) {
@ -1497,6 +1500,7 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
} }
} }
zDim.setDimType(DimensionType.Z); zDim.setDimType(DimensionType.Z);
zDim.setStagger(true);
//zDim.setDimName(_levelVar.getShortName()); //zDim.setDimName(_levelVar.getShortName());
zDim.setValues(levels); zDim.setValues(levels);
zDim.setUnit("eta"); zDim.setUnit("eta");

View File

@ -17,6 +17,7 @@ import org.meteoinfo.common.Extent;
import org.meteoinfo.common.MIMath; import org.meteoinfo.common.MIMath;
import org.meteoinfo.common.util.JDateUtil; import org.meteoinfo.common.util.JDateUtil;
import org.meteoinfo.data.StationData; import org.meteoinfo.data.StationData;
import org.meteoinfo.data.dimarray.DimArray;
import org.meteoinfo.data.meteodata.DataInfo; import org.meteoinfo.data.meteodata.DataInfo;
import org.meteoinfo.data.dimarray.Dimension; import org.meteoinfo.data.dimarray.Dimension;
import org.meteoinfo.data.dimarray.DimensionType; import org.meteoinfo.data.dimarray.DimensionType;
@ -340,6 +341,16 @@ import org.meteoinfo.data.meteodata.Attribute;
public Array read(String varName, int[] origin, int[] size, int[] stride) { public Array read(String varName, int[] origin, int[] size, int[] stride) {
return null; return null;
} }
@Override
public DimArray readDimArray(String varName) {
return null;
}
@Override
public DimArray readDimArray(String varName, int[] origin, int[] size, int[] stride) {
return null;
}
@Override @Override
public StationData getStationData(int timeIdx, String varName, int levelIdx) { public StationData getStationData(int timeIdx, String varName, int levelIdx) {

View File

@ -0,0 +1,92 @@
package org.meteoinfo.data.meteodata.util;
import org.meteoinfo.data.dimarray.DimArray;
import org.meteoinfo.data.dimarray.Dimension;
import org.meteoinfo.data.meteodata.DataInfo;
import org.meteoinfo.ndarray.Array;
import org.meteoinfo.ndarray.DataType;
import org.meteoinfo.ndarray.InvalidRangeException;
import org.meteoinfo.ndarray.Range;
import org.meteoinfo.ndarray.math.ArrayMath;
import java.util.ArrayList;
import java.util.List;
public class WRFUtil {
/**
* Un-Stagger a dimension array
* @param array The dimension array
* @param axis The axis
* @return Un-Staggered dimension array
*/
public static DimArray deStagger(DimArray array, int axis) {
try {
Dimension sDim = array.getDimension(axis);
Range range1 = new Range(0, sDim.getLength() - 2);
Range range2 = new Range(1, sDim.getLength() - 1);
Array sDimValue = sDim.getDimValue();
Array sDimValue1 = Array.factory(DataType.DOUBLE, new int[]{sDim.getLength()});
for (int i = 0; i < sDimValue1.getSize(); i++) {
sDimValue1.setDouble(i, 0.5 * (sDimValue.getDouble(i) + sDimValue.getDouble(i + 1)));
}
Dimension sDim1 = new Dimension(sDim);
sDim1.setDimValue(sDimValue1);
sDim1.setStagger(false);
List<Range> rangeList1 = new ArrayList<>();
List<Range> rangeList2 = new ArrayList<>();
List<Dimension> dimensions = new ArrayList<>();
for (int i = 0; i < array.getDimensions().size(); i++) {
if (i == axis) {
rangeList1.add(range1);
rangeList2.add(range2);
dimensions.add(sDim1);
} else {
Dimension dimension = array.getDimension(i);
rangeList1.add(new Range(dimension.getLength()));
rangeList2.add(new Range(dimension.getLength()));
dimensions.add(dimension);
}
}
Array array1 = array.getArray().section(rangeList1);
Array array2 = array.getArray().section(rangeList2);
Array r = ArrayMath.mul(ArrayMath.add(array1, array2), 0.5);
return new DimArray(r, dimensions);
} catch (InvalidRangeException e) {
e.printStackTrace();
return array;
}
}
/**
* Un-Stagger a dimension array
* @param array The dimension array
* @return Un-Staggered dimension array
*/
public static DimArray deStagger(DimArray array) {
int idx = array.getStaggerDimIndex();
if (idx >= 0) {
return deStagger(array, idx);
} else {
System.out.println("The dimension array has no stagger dimension!");
return array;
}
}
/**
* Get geopotential height array - meter
* @param dataInfo The WRF data info
* @return Geopotential height
*/
public static DimArray getGPM(DataInfo dataInfo) {
DimArray ph = dataInfo.readDimArray("PH");
ph = deStagger(ph);
DimArray phb = dataInfo.readDimArray("PHB");
phb = deStagger(phb);
DimArray hgt = dataInfo.readDimArray("HGT");
Array gpm = ArrayMath.sub(ArrayMath.div(ArrayMath.add(ph.getArray(), phb.getArray()), 9.81), hgt.getArray());
return new DimArray(gpm, ph.getDimensions());
}
}

View File

@ -2672,4 +2672,101 @@ public class GeoComputation {
} }
// </editor-fold> // </editor-fold>
// <editor-fold desc="Interpolation">
/**
* Interpolate with surface method
*
* @param x_s scatter X array
* @param y_s scatter Y array
* @param a scatter value array
* @param X x coordinate
* @param Y y coordinate
* @return grid data
*/
public static Array interpolation_Surface(Array x_s, Array y_s, Array a, Array X, Array Y) {
x_s = x_s.copyIfView();
y_s = y_s.copyIfView();
a = a.copyIfView();
X = X.copyIfView();
Y = Y.copyIfView();
int rowNum, colNum, xn, yn;
int[] shape = x_s.getShape();
colNum = shape[1];
rowNum = shape[0];
xn = (int) X.getSize();
yn = (int) Y.getSize();
Array r = Array.factory(DataType.DOUBLE, new int[]{yn, xn});
for (int i = 0; i < r.getSize(); i++) {
r.setDouble(i, Double.NaN);
}
double x, y;
double v, xll, xtl, xtr, xlr, yll, ytl, ytr, ylr;
double dX = X.getDouble(1) - X.getDouble(0);
double dY = Y.getDouble(1) - Y.getDouble(0);
int minxi, maxxi, minyi, maxyi;
for (int i = 0; i < rowNum - 1; i++) {
for (int j = 0; j < colNum - 1; j++) {
v = a.getDouble(i * colNum + j);
if (Double.isNaN(v)) {
continue;
}
xll = x_s.getDouble(i * colNum + j);
xtl = x_s.getDouble((i + 1) * colNum + j);
xtr = x_s.getDouble((i + 1) * colNum + j + 1);
xlr = x_s.getDouble(i * colNum + j + 1);
yll = y_s.getDouble(i * colNum + j);
ytl = y_s.getDouble((i + 1) * colNum + j);
ytr = y_s.getDouble((i + 1) * colNum + j + 1);
ylr = y_s.getDouble(i * colNum + j + 1);
if (Double.isNaN(xll) || Double.isNaN(xtl) || Double.isNaN(xtr) || Double.isNaN(xlr)
|| Double.isNaN(yll) || Double.isNaN(ytl) || Double.isNaN(ytr) || Double.isNaN(ylr)) {
continue;
}
PolygonShape ps = new PolygonShape();
List<PointD> points = new ArrayList<>();
points.add(new PointD(xll, yll));
points.add(new PointD(xtl, ytl));
points.add(new PointD(xtr, ytr));
points.add(new PointD(xlr, ylr));
points.add((PointD) points.get(0).clone());
ps.setPoints(points);
minxi = (int) ((ps.getExtent().minX - X.getDouble(0)) / dX);
maxxi = (int) ((ps.getExtent().maxX - X.getDouble(0)) / dX);
minyi = (int) ((ps.getExtent().minY - Y.getDouble(0)) / dY);
maxyi = (int) ((ps.getExtent().maxY - Y.getDouble(0)) / dY);
maxxi += 1;
maxyi += 1;
if (maxxi < 0 || minxi >= xn) {
continue;
}
if (maxyi < 0 || minyi >= yn) {
continue;
}
if (minxi < 0) {
minxi = 0;
}
if (maxxi >= xn) {
maxxi = xn - 1;
}
if (maxyi >= yn) {
maxyi = yn - 1;
}
for (int m = minyi; m <= maxyi; m++) {
y = Y.getDouble(m);
for (int n = minxi; n <= maxxi; n++) {
x = X.getDouble(n);
if (GeoComputation.pointInPolygon(ps, x, y)) {
r.setDouble(m * xn + n, v);
}
}
}
}
}
return r;
}
// </editor-fold>
} }

View File

@ -1,32 +1,32 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<MeteoInfo File="milconfig.xml" Type="configurefile"> <MeteoInfo File="milconfig.xml" Type="configurefile">
<Path OpenPath="D:\Working\MIScript\Jython\mis\meteo\calc"> <Path OpenPath="D:\Working\MIScript\Jython\mis\satellite\smap">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\grads"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\dataconvert"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\others"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\linalg"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\LaSW"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\fitting"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\ascii"/>
<RecentFolder Folder="D:\Temp\working\acidrain"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\interpolate"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\interpolate"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\wrf"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\calc"/> <RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\calc"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\LaSW"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\wrf"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\subplot"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\hdf"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\smap"/>
</Path> </Path>
<File> <File>
<OpenedFiles> <OpenedFiles>
<OpenedFile File="D:\Working\MIScript\Jython\mis\LaSW\typhoon_map_volume.py"/> <OpenedFile File="D:\Working\MIScript\Jython\mis\LaSW\typhoon_map_volume.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\meteo\wrf\wrf_destagger_1.py"/> <OpenedFile File="D:\Working\MIScript\Jython\mis\meteo\wrf\wrf_eta2height.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\meteo\calc\isentropic_analysis.py"/> <OpenedFile File="D:\Working\MIScript\Jython\mis\satellite\smap\pro_SMAP_L4_with_MI.py"/>
</OpenedFiles> </OpenedFiles>
<RecentFiles> <RecentFiles>
<RecentFile File="D:\Working\MIScript\Jython\mis\LaSW\typhoon_map_volume.py"/> <RecentFile File="D:\Working\MIScript\Jython\mis\LaSW\typhoon_map_volume.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\meteo\wrf\wrf_destagger_1.py"/> <RecentFile File="D:\Working\MIScript\Jython\mis\meteo\wrf\wrf_eta2height.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\meteo\calc\isentropic_analysis.py"/> <RecentFile File="D:\Working\MIScript\Jython\mis\satellite\smap\pro_SMAP_L4_with_MI.py"/>
</RecentFiles> </RecentFiles>
</File> </File>
<Font> <Font>
@ -34,5 +34,5 @@
</Font> </Font>
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/> <LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
<Figure DoubleBuffering="true"/> <Figure DoubleBuffering="true"/>
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/> <Startup MainFormLocation="-7,0" MainFormSize="1435,830"/>
</MeteoInfo> </MeteoInfo>

View File

@ -15,8 +15,8 @@ __all__ = [
] ]
def destagger(var, stagger_dim): def destagger(var, stagger_dim):
''' """
Return the variable on the unstaggered grid. Return the variable data array on the unstaggered grid.
This function destaggers the variable by taking the average of the This function destaggers the variable by taking the average of the
values located on either side of the grid box. values located on either side of the grid box.
@ -26,8 +26,8 @@ def destagger(var, stagger_dim):
Negative values can be used to choose dimensions referenced Negative values can be used to choose dimensions referenced
from the right hand side (-1 is the rightmost dimension). from the right hand side (-1 is the rightmost dimension).
:returns: (*array*) The destaggered variable. :returns: (*array*) The destaggered variable data array.
''' """
var_shape = var.shape var_shape = var.shape
num_dims = var.ndim num_dims = var.ndim
stagger_dim_size = var_shape[stagger_dim] stagger_dim_size = var_shape[stagger_dim]

View File

@ -9,7 +9,7 @@
from org.meteoinfo.math.interpolate import InterpUtil, RectLinearInterpolator, RectNearestInterpolator, \ from org.meteoinfo.math.interpolate import InterpUtil, RectLinearInterpolator, RectNearestInterpolator, \
RectNearestInterpolator3D, RectLinearInterpolator3D RectNearestInterpolator3D, RectLinearInterpolator3D
from org.meteoinfo.ndarray.math import ArrayUtil from org.meteoinfo.ndarray.math import ArrayUtil
from org.meteoinfo.geometry.geoprocess import GeometryUtil from org.meteoinfo.geometry.geoprocess import GeometryUtil, GeoComputation
from ..core import NDArray from ..core import NDArray
from ..core import numeric as np from ..core import numeric as np
@ -513,7 +513,7 @@ def griddata(points, values, xi=None, **kwargs):
r = InterpUtil.interpolation_Inside_Count(x_s.aslist(), y_s.aslist(), values, x_g.aslist(), y_g.aslist(), True, centerpoint) r = InterpUtil.interpolation_Inside_Count(x_s.aslist(), y_s.aslist(), values, x_g.aslist(), y_g.aslist(), True, centerpoint)
return NDArray(r[0]), x_g, y_g, NDArray(r[1]) return NDArray(r[0]), x_g, y_g, NDArray(r[1])
elif method == 'surface': elif method == 'surface':
r = InterpUtil.interpolation_Surface(x_s.asarray(), y_s.asarray(), values, x_g.asarray(), y_g.asarray()) r = GeoComputation.interpolation_Surface(x_s.asarray(), y_s.asarray(), values, x_g.asarray(), y_g.asarray())
elif method == 'kriging': elif method == 'kriging':
beta = kwargs.pop('beta', 1.5) beta = kwargs.pop('beta', 1.5)
r = InterpUtil.gridDataKriging(x_s.asarray(), y_s.asarray(), values, x_g.asarray(), y_g.asarray(), beta) r = InterpUtil.gridDataKriging(x_s.asarray(), y_s.asarray(), values, x_g.asarray(), y_g.asarray(), beta)

View File

@ -631,16 +631,13 @@ class Figure(ChartPanel):
y -= hspace y -= hspace
for j in range(ncols): for j in range(ncols):
if axestype == '3d': if axestype == '3d':
ax = Axes3D() ax = Axes3D(**kwargs)
self.__set_axes3d(ax, **kwargs)
elif axestype == 'map': elif axestype == 'map':
ax = MapAxes() ax = MapAxes(**kwargs)
self.__set_axesm(ax, **kwargs)
elif axestype == 'polar': elif axestype == 'polar':
ax = PolarAxes() ax = PolarAxes(**kwargs)
else: else:
ax = Axes(**kwargs) ax = Axes(**kwargs)
#self.__set_axes(ax, **kwargs)
ax.axes.isSubPlot = True ax.axes.isSubPlot = True
if not iswspace and not ishspace: if not iswspace and not ishspace:
x = left + w * j x = left + w * j

View File

@ -952,7 +952,7 @@ public class FrmMeteoData extends javax.swing.JDialog {
this.jComboBox_Level.setSelectedIndex(0); this.jComboBox_Level.setSelectedIndex(0);
} else { } else {
for (i = 0; i < ldim.getLength(); i++) { for (i = 0; i < ldim.getLength(); i++) {
this.jComboBox_Level.addItem(String.valueOf(ldim.getDimValue().get(i))); this.jComboBox_Level.addItem(String.valueOf(ldim.getDimValue().getDouble(i)));
} }
if (this.jComboBox_Level.getItemCount() > _meteoDataInfo.getLevelIndex()) { if (this.jComboBox_Level.getItemCount() > _meteoDataInfo.getLevelIndex()) {
this.jComboBox_Level.setSelectedIndex(_meteoDataInfo.getLevelIndex()); this.jComboBox_Level.setSelectedIndex(_meteoDataInfo.getLevelIndex());
@ -965,7 +965,7 @@ public class FrmMeteoData extends javax.swing.JDialog {
} else { } else {
DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel(); DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel();
for (i = 0; i < var.getZDimension().getLength(); i++) { for (i = 0; i < var.getZDimension().getLength(); i++) {
comboBoxModel.addElement(String.valueOf(var.getZDimension().getDimValue().get(i))); comboBoxModel.addElement(String.valueOf(var.getZDimension().getDimValue().getDouble(i)));
} }
this.jComboBox_Level.setModel(comboBoxModel); this.jComboBox_Level.setModel(comboBoxModel);
if (this.jComboBox_Level.getItemCount() > _meteoDataInfo.getLevelIndex()) { if (this.jComboBox_Level.getItemCount() > _meteoDataInfo.getLevelIndex()) {

View File

@ -1079,7 +1079,7 @@ public class FrmOneDim extends javax.swing.JFrame {
this.jComboBox_Level1.setSelectedIndex(0); this.jComboBox_Level1.setSelectedIndex(0);
} else { } else {
for (i = 0; i < var.getLevelNum(); i++) { for (i = 0; i < var.getLevelNum(); i++) {
this.jComboBox_Level1.addItem(String.valueOf(zDim.getDimValue().get(i))); this.jComboBox_Level1.addItem(String.valueOf(zDim.getDimValue().getDouble(i)));
} }
if ((levelIdx > -1) && (this.jComboBox_Level1.getItemCount() > levelIdx)) { if ((levelIdx > -1) && (this.jComboBox_Level1.getItemCount() > levelIdx)) {
this.jComboBox_Level1.setSelectedIndex(levelIdx); this.jComboBox_Level1.setSelectedIndex(levelIdx);
@ -1103,13 +1103,13 @@ public class FrmOneDim extends javax.swing.JFrame {
//Set lon/lat //Set lon/lat
this.jComboBox_Lon1.removeAllItems(); this.jComboBox_Lon1.removeAllItems();
for (i = 0; i < (_meteoDataInfo.getDataInfo()).getXDimension().getLength(); i++) { for (i = 0; i < (_meteoDataInfo.getDataInfo()).getXDimension().getLength(); i++) {
this.jComboBox_Lon1.addItem(String.valueOf((_meteoDataInfo.getDataInfo()).getXDimension().getDimValue().get(i))); this.jComboBox_Lon1.addItem(String.valueOf((_meteoDataInfo.getDataInfo()).getXDimension().getDimValue().getDouble(i)));
} }
this.jComboBox_Lon1.setSelectedIndex(0); this.jComboBox_Lon1.setSelectedIndex(0);
this.jComboBox_Lat1.removeAllItems(); this.jComboBox_Lat1.removeAllItems();
for (i = 0; i < (_meteoDataInfo.getDataInfo()).getYDimension().getLength(); i++) { for (i = 0; i < (_meteoDataInfo.getDataInfo()).getYDimension().getLength(); i++) {
this.jComboBox_Lat1.addItem(String.valueOf((_meteoDataInfo.getDataInfo()).getYDimension().getDimValue().get(i))); this.jComboBox_Lat1.addItem(String.valueOf((_meteoDataInfo.getDataInfo()).getYDimension().getDimValue().getDouble(i)));
} }
this.jComboBox_Lat1.setSelectedIndex(0); this.jComboBox_Lat1.setSelectedIndex(0);

View File

@ -1514,7 +1514,7 @@ public class FrmSectionPlot extends javax.swing.JFrame {
this.jComboBox_Level1.setSelectedIndex(0); this.jComboBox_Level1.setSelectedIndex(0);
} else { } else {
for (i = 0; i < var.getLevelNum(); i++) { for (i = 0; i < var.getLevelNum(); i++) {
this.jComboBox_Level1.addItem(String.valueOf(zDim.getDimValue().get(i))); this.jComboBox_Level1.addItem(String.valueOf(zDim.getDimValue().getDouble(i)));
} }
if ((levelIdx > -1) && (this.jComboBox_Level1.getItemCount() > levelIdx)) { if ((levelIdx > -1) && (this.jComboBox_Level1.getItemCount() > levelIdx)) {
this.jComboBox_Level1.setSelectedIndex(levelIdx); this.jComboBox_Level1.setSelectedIndex(levelIdx);
@ -1538,13 +1538,13 @@ public class FrmSectionPlot extends javax.swing.JFrame {
//Set lon/lat //Set lon/lat
this.jComboBox_Lon1.removeAllItems(); this.jComboBox_Lon1.removeAllItems();
for (i = 0; i < (_meteoDataInfo.getDataInfo()).getXDimension().getLength(); i++) { for (i = 0; i < (_meteoDataInfo.getDataInfo()).getXDimension().getLength(); i++) {
this.jComboBox_Lon1.addItem(String.valueOf((_meteoDataInfo.getDataInfo()).getXDimension().getDimValue().get(i))); this.jComboBox_Lon1.addItem(String.valueOf((_meteoDataInfo.getDataInfo()).getXDimension().getDimValue().getDouble(i)));
} }
this.jComboBox_Lon1.setSelectedIndex(0); this.jComboBox_Lon1.setSelectedIndex(0);
this.jComboBox_Lat1.removeAllItems(); this.jComboBox_Lat1.removeAllItems();
for (i = 0; i < (_meteoDataInfo.getDataInfo()).getYDimension().getLength(); i++) { for (i = 0; i < (_meteoDataInfo.getDataInfo()).getYDimension().getLength(); i++) {
this.jComboBox_Lat1.addItem(String.valueOf((_meteoDataInfo.getDataInfo()).getYDimension().getDimValue().get(i))); this.jComboBox_Lat1.addItem(String.valueOf((_meteoDataInfo.getDataInfo()).getYDimension().getDimValue().getDouble(i)));
} }
this.jComboBox_Lat1.setSelectedIndex(0); this.jComboBox_Lat1.setSelectedIndex(0);

View File

@ -1708,101 +1708,6 @@ public class InterpUtil {
return rdata; return rdata;
} }
// /**
// * Interpolate with surface method
// *
// * @param x_s scatter X array
// * @param y_s scatter Y array
// * @param a scatter value array
// * @param X x coordinate
// * @param Y y coordinate
// * @return grid data
// */
// public static Array interpolation_Surface(Array x_s, Array y_s, Array a, Array X, Array Y) {
// x_s = x_s.copyIfView();
// y_s = y_s.copyIfView();
// a = a.copyIfView();
// X = X.copyIfView();
// Y = Y.copyIfView();
//
// int rowNum, colNum, xn, yn;
// int[] shape = x_s.getShape();
// colNum = shape[1];
// rowNum = shape[0];
// xn = (int) X.getSize();
// yn = (int) Y.getSize();
// Array r = Array.factory(DataType.DOUBLE, new int[]{yn, xn});
// for (int i = 0; i < r.getSize(); i++) {
// r.setDouble(i, Double.NaN);
// }
//
// double x, y;
// double v, xll, xtl, xtr, xlr, yll, ytl, ytr, ylr;
// double dX = X.getDouble(1) - X.getDouble(0);
// double dY = Y.getDouble(1) - Y.getDouble(0);
// int minxi, maxxi, minyi, maxyi;
// for (int i = 0; i < rowNum - 1; i++) {
// for (int j = 0; j < colNum - 1; j++) {
// v = a.getDouble(i * colNum + j);
// if (Double.isNaN(v)) {
// continue;
// }
// xll = x_s.getDouble(i * colNum + j);
// xtl = x_s.getDouble((i + 1) * colNum + j);
// xtr = x_s.getDouble((i + 1) * colNum + j + 1);
// xlr = x_s.getDouble(i * colNum + j + 1);
// yll = y_s.getDouble(i * colNum + j);
// ytl = y_s.getDouble((i + 1) * colNum + j);
// ytr = y_s.getDouble((i + 1) * colNum + j + 1);
// ylr = y_s.getDouble(i * colNum + j + 1);
// if (Double.isNaN(xll) || Double.isNaN(xtl) || Double.isNaN(xtr) || Double.isNaN(xlr)
// || Double.isNaN(yll) || Double.isNaN(ytl) || Double.isNaN(ytr) || Double.isNaN(ylr)) {
// continue;
// }
// PolygonShape ps = new PolygonShape();
// List<PointD> points = new ArrayList<>();
// points.add(new PointD(xll, yll));
// points.add(new PointD(xtl, ytl));
// points.add(new PointD(xtr, ytr));
// points.add(new PointD(xlr, ylr));
// points.add((PointD) points.get(0).clone());
// ps.setPoints(points);
// minxi = (int) ((ps.getExtent().minX - X.getDouble(0)) / dX);
// maxxi = (int) ((ps.getExtent().maxX - X.getDouble(0)) / dX);
// minyi = (int) ((ps.getExtent().minY - Y.getDouble(0)) / dY);
// maxyi = (int) ((ps.getExtent().maxY - Y.getDouble(0)) / dY);
// maxxi += 1;
// maxyi += 1;
// if (maxxi < 0 || minxi >= xn) {
// continue;
// }
// if (maxyi < 0 || minyi >= yn) {
// continue;
// }
// if (minxi < 0) {
// minxi = 0;
// }
// if (maxxi >= xn) {
// maxxi = xn - 1;
// }
// if (maxyi >= yn) {
// maxyi = yn - 1;
// }
// for (int m = minyi; m <= maxyi; m++) {
// y = Y.getDouble(m);
// for (int n = minxi; n <= maxxi; n++) {
// x = X.getDouble(n);
// if (GeoComputation.pointInPolygon(ps, x, y)) {
// r.setDouble(m * xn + n, v);
// }
// }
// }
// }
// }
//
// return r;
// }
/** /**
* Interpolation with IDW radius method * Interpolation with IDW radius method
* *

View File

@ -99,7 +99,7 @@ public final class Range {
/** /**
* Create a range starting at zero, with unit stride. * Create a range starting at zero, with unit stride.
* *
* @param length number of elements in the Rnage * @param length number of elements in the Range
*/ */
public Range(int length) { public Range(int length) {
this.name = null; this.name = null;