mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
datetime support for DimArray
This commit is contained in:
parent
b482eac053
commit
366ead6ab4
@ -76,7 +76,7 @@ public class Dimension {
|
||||
* @param dimType Dimension type
|
||||
*/
|
||||
public Dimension(DimensionType dimType) {
|
||||
this(dimType.toString(), 1, dimType);
|
||||
this(dimType.toString().toLowerCase(), 1, dimType);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -639,13 +639,28 @@ public class Dimension {
|
||||
dim.setDimId(this.dimId);
|
||||
dim.setUnit(this.unit);
|
||||
dim.setStagger(this.stagger);
|
||||
Array values = Array.factory(this.dimValue.getDataType(), new int[]{(int) index.getSize()});
|
||||
IndexIterator iter = index.getIndexIterator();
|
||||
IndexIterator iterV = values.getIndexIterator();
|
||||
while (iter.hasNext()) {
|
||||
iterV.setObjectNext(this.dimValue.getObject(iter.getIntNext()));
|
||||
if (index.getDataType() == DataType.BOOLEAN) {
|
||||
int n = ArrayMath.sum(index).intValue();
|
||||
Array values = Array.factory(this.dimValue.getDataType(), new int[]{n});
|
||||
IndexIterator iter = index.getIndexIterator();
|
||||
IndexIterator iterV = values.getIndexIterator();
|
||||
int i = 0;
|
||||
while (iter.hasNext()) {
|
||||
if (iter.getBooleanNext()) {
|
||||
iterV.setObjectNext(this.dimValue.getObject(i));
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
dim.setDimValue(values);
|
||||
} else {
|
||||
Array values = Array.factory(this.dimValue.getDataType(), new int[]{(int) index.getSize()});
|
||||
IndexIterator iter = index.getIndexIterator();
|
||||
IndexIterator iterV = values.getIndexIterator();
|
||||
while (iter.hasNext()) {
|
||||
iterV.setObjectNext(this.dimValue.getObject(iter.getIntNext()));
|
||||
}
|
||||
dim.setDimValue(values);
|
||||
}
|
||||
dim.setDimValue(values);
|
||||
|
||||
return dim;
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
package org.meteoinfo.data.meteodata;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Formatter;
|
||||
import java.util.List;
|
||||
import org.meteoinfo.ndarray.Array;
|
||||
@ -141,6 +142,20 @@ public class Attribute {
|
||||
this.isUnsigned = isUnsigned;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a scalar datetime-valued Attribute.
|
||||
*
|
||||
* @param name name of Attribute
|
||||
* @param val value of Attribute
|
||||
*/
|
||||
public Attribute(String name, LocalDateTime val) {
|
||||
this(name);
|
||||
|
||||
Array vala = Array.factory(DataType.DATE, new int[]{1});
|
||||
vala.setDate(0, val);
|
||||
setValues(vala);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a String-valued Attribute.
|
||||
*
|
||||
@ -473,8 +488,13 @@ public class Attribute {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
Formatter f = new Formatter();
|
||||
writeCDL(f);
|
||||
return f.toString();
|
||||
switch (this.dataType) {
|
||||
case DATE:
|
||||
return this.name + " = " + this.values.toString();
|
||||
default:
|
||||
Formatter f = new Formatter();
|
||||
writeCDL(f);
|
||||
return f.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,9 +20,11 @@ import java.time.Period;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.errorprone.annotations.Var;
|
||||
import org.meteoinfo.common.util.JDateUtil;
|
||||
import org.meteoinfo.data.dimarray.DimArray;
|
||||
import org.meteoinfo.data.dimarray.DimensionType;
|
||||
import org.meteoinfo.data.meteodata.netcdf.NCUtil;
|
||||
import org.meteoinfo.ndarray.*;
|
||||
import org.meteoinfo.data.dimarray.Dimension;
|
||||
import org.meteoinfo.ndarray.math.ArrayMath;
|
||||
@ -40,6 +42,7 @@ import org.meteoinfo.projection.ProjectionInfo;
|
||||
|
||||
protected String fileName;
|
||||
protected List<Variable> variables = new ArrayList<>();
|
||||
protected List<Variable> coordinates = new ArrayList<>();
|
||||
protected List<Dimension> dimensions = new ArrayList<>();
|
||||
protected List<Attribute> attributes = new ArrayList<>();
|
||||
protected Dimension tDim = null;
|
||||
@ -110,6 +113,37 @@ import org.meteoinfo.projection.ProjectionInfo;
|
||||
return vars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data variables - excluding coordinate variables
|
||||
* @return Data variables
|
||||
*/
|
||||
public List<Variable> getDataVariables() {
|
||||
List<Variable> dataVariables = new ArrayList<>();
|
||||
for (Variable variable : this.variables) {
|
||||
if (!variable.isDimVar()) {
|
||||
dataVariables.add(variable);
|
||||
}
|
||||
}
|
||||
|
||||
return dataVariables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get coordinate variables
|
||||
* @return Coordinate variables
|
||||
*/
|
||||
public List<Variable> getCoordinates() {
|
||||
return this.coordinates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set coordinate variables
|
||||
* @param value Coordinate variables
|
||||
*/
|
||||
public void setCoordinates(List<Variable> value) {
|
||||
this.coordinates = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dimensions
|
||||
*
|
||||
@ -137,6 +171,29 @@ import org.meteoinfo.projection.ProjectionInfo;
|
||||
return variables.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data variable number
|
||||
* @return Data variable number
|
||||
*/
|
||||
public int getDataVariableNum() {
|
||||
int i = 0;
|
||||
for (Variable var : variables) {
|
||||
if (!var.isDimVar()) {
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get coordinate variable number
|
||||
* @return Coordinate variable number
|
||||
*/
|
||||
public int getCoordinateNum() {
|
||||
return this.coordinates.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get variable names
|
||||
*
|
||||
@ -151,6 +208,20 @@ import org.meteoinfo.projection.ProjectionInfo;
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get coordinate names
|
||||
*
|
||||
* @return Coordinate names
|
||||
*/
|
||||
public List<String> getCoordinateNames() {
|
||||
List<String> names = new ArrayList<>();
|
||||
for (Variable var : coordinates) {
|
||||
names.add(var.getName());
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get times
|
||||
*
|
||||
@ -404,6 +475,30 @@ import org.meteoinfo.projection.ProjectionInfo;
|
||||
yReverse = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get x coordinate variable name
|
||||
* @return X coordinate variable name
|
||||
*/
|
||||
public String getXCoordVariableName() {
|
||||
if (this.projInfo.isLonLat()) {
|
||||
return "lon";
|
||||
} else {
|
||||
return "x";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get y coordinate variable name
|
||||
* @return Y coordinate variable name
|
||||
*/
|
||||
public String getYCoordVariableName() {
|
||||
if (this.projInfo.isLonLat()) {
|
||||
return "lat";
|
||||
} else {
|
||||
return "y";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if is global data
|
||||
*
|
||||
@ -503,14 +598,13 @@ import org.meteoinfo.projection.ProjectionInfo;
|
||||
*/
|
||||
public String generateInfoText() {
|
||||
String dataInfo;
|
||||
int i, j;
|
||||
Attribute aAttS;
|
||||
dataInfo = "File Name: " + this.getFileName();
|
||||
//dataInfo += System.getProperty("line.separator") + "File type: " + _fileTypeStr + " (" + _fileTypeId + ")";
|
||||
dataInfo += System.getProperty("line.separator") + "Dimensions: " + dimensions.size();
|
||||
for (i = 0; i < dimensions.size(); i++) {
|
||||
dataInfo += System.getProperty("line.separator") + "\t" + dimensions.get(i).getShortName() + " = "
|
||||
+ String.valueOf(dimensions.get(i).getLength()) + ";";
|
||||
for (Dimension dimension : dimensions) {
|
||||
dataInfo += System.getProperty("line.separator") + "\t" + dimension.getShortName() + " = "
|
||||
+ String.valueOf(dimension.getLength()) + ";";
|
||||
}
|
||||
|
||||
Dimension xdim = this.getXDimension();
|
||||
@ -527,29 +621,43 @@ import org.meteoinfo.projection.ProjectionInfo;
|
||||
}
|
||||
|
||||
dataInfo += System.getProperty("line.separator") + "Global Attributes: ";
|
||||
for (i = 0; i < this.attributes.size(); i++) {
|
||||
aAttS = this.attributes.get(i);
|
||||
dataInfo += System.getProperty("line.separator") + "\t: " + aAttS.toString();
|
||||
for (Attribute attribute : attributes) {
|
||||
dataInfo += System.getProperty("line.separator") + "\t: " + attribute.toString();
|
||||
}
|
||||
|
||||
dataInfo += System.getProperty("line.separator") + "Variations: " + variables.size();
|
||||
for (i = 0; i < variables.size(); i++) {
|
||||
dataInfo += System.getProperty("line.separator") + "\t" + variables.get(i).getDataType().toString()
|
||||
+ " " + variables.get(i).getShortName() + "(";
|
||||
List<Dimension> dims = variables.get(i).getDimensions();
|
||||
for (j = 0; j < dims.size(); j++) {
|
||||
dataInfo += dims.get(j).getShortName() + ",";
|
||||
List<Variable> dataVariables = this.getDataVariables();
|
||||
dataInfo += System.getProperty("line.separator") + "Data Variables: " + dataVariables.size();
|
||||
for (Variable variable : dataVariables) {
|
||||
dataInfo += System.getProperty("line.separator") + "\t" + variable.getDataType().toString()
|
||||
+ " " + variable.getShortName() + "(";
|
||||
for (Dimension dim : variable.getDimensions()) {
|
||||
dataInfo += dim.getShortName() + ",";
|
||||
}
|
||||
dataInfo = dataInfo.substring(0, dataInfo.length() - 1);
|
||||
dataInfo += ");";
|
||||
List<Attribute> atts = variables.get(i).getAttributes();
|
||||
for (j = 0; j < atts.size(); j++) {
|
||||
List<Attribute> atts = variable.getAttributes();
|
||||
for (int j = 0; j < atts.size(); j++) {
|
||||
aAttS = atts.get(j);
|
||||
dataInfo += System.getProperty("line.separator") + "\t" + "\t" + variables.get(i).getShortName()
|
||||
dataInfo += System.getProperty("line.separator") + "\t" + "\t" + variable.getShortName()
|
||||
+ ": " + aAttS.toString();
|
||||
}
|
||||
}
|
||||
|
||||
dataInfo += System.getProperty("line.separator") + "Coordinates: " + coordinates.size();
|
||||
for (Variable coord : coordinates) {
|
||||
dataInfo += System.getProperty("line.separator") + "\t" + coord.getDataType().toString()
|
||||
+ " " + coord.getShortName() + "(";
|
||||
for (Dimension dim : coord.getDimensions()) {
|
||||
dataInfo += dim.getShortName() + ",";
|
||||
}
|
||||
dataInfo = dataInfo.substring(0, dataInfo.length() - 1);
|
||||
dataInfo += ");";
|
||||
for (Attribute attr : coord.getAttributes()) {
|
||||
dataInfo += System.getProperty("line.separator") + "\t" + "\t" + coord.getShortName()
|
||||
+ ": " + attr.toString();
|
||||
}
|
||||
}
|
||||
|
||||
for (Dimension dim : dimensions) {
|
||||
if (dim.isUnlimited()) {
|
||||
dataInfo += System.getProperty("line.separator") + "Unlimited dimension: " + dim.getShortName();
|
||||
@ -565,7 +673,23 @@ import org.meteoinfo.projection.ProjectionInfo;
|
||||
* @param varName Variable name
|
||||
* @return Array
|
||||
*/
|
||||
public abstract Array read(String varName);
|
||||
public Array read(String varName) {
|
||||
Variable var = this.getVariable(varName);
|
||||
if (var != null) {
|
||||
if (var.hasCachedData()) {
|
||||
return var.cachedData.copy();
|
||||
}
|
||||
}
|
||||
|
||||
return realRead(varName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read array data
|
||||
* @param varName Variable name
|
||||
* @return Array
|
||||
*/
|
||||
public abstract Array realRead(String varName);
|
||||
|
||||
/**
|
||||
* Read dimension array data
|
||||
@ -593,7 +717,63 @@ import org.meteoinfo.projection.ProjectionInfo;
|
||||
* @param stride Stride array
|
||||
* @return Array
|
||||
*/
|
||||
public abstract Array read(String varName, int[] origin, int[] size, int[] stride);
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
Variable var = this.getVariable(varName);
|
||||
if (var == null) {
|
||||
System.out.println("The variable is not exist: " + varName);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (var.hasCachedData()) {
|
||||
boolean negStride = false;
|
||||
for (int s : stride) {
|
||||
if (s < 0) {
|
||||
negStride = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<Integer> flips = new ArrayList<>();
|
||||
if (negStride) {
|
||||
int[] pStride = new int[stride.length];
|
||||
for (int i = 0; i < stride.length; i++) {
|
||||
pStride[i] = Math.abs(stride[i]);
|
||||
if (stride[i] < 0) {
|
||||
flips.add(i);
|
||||
}
|
||||
}
|
||||
stride = pStride;
|
||||
}
|
||||
Section section = null;
|
||||
try {
|
||||
section = new Section(origin, size, stride);
|
||||
Array r = var.getCachedData().section(section.getRanges()).copy();
|
||||
if (negStride) {
|
||||
for (int i : flips) {
|
||||
r = r.flip(i);
|
||||
}
|
||||
Array data = Array.factory(r.getDataType(), r.getShape());
|
||||
MAMath.copy(data, r);
|
||||
return data;
|
||||
}
|
||||
return r;
|
||||
} catch (InvalidRangeException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
return realRead(varName, origin, size, stride);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read array data
|
||||
*
|
||||
* @param varName Variable name
|
||||
* @param origin Origin array
|
||||
* @param size Size array
|
||||
* @param stride Stride array
|
||||
* @return Array
|
||||
*/
|
||||
public abstract Array realRead(String varName, int[] origin, int[] size, int[] stride);
|
||||
|
||||
/**
|
||||
* Read dimension array data
|
||||
@ -652,24 +832,19 @@ import org.meteoinfo.projection.ProjectionInfo;
|
||||
* @return The variable
|
||||
*/
|
||||
public Variable getVariable(String varName) {
|
||||
Variable v = null;
|
||||
for (Variable var : variables) {
|
||||
if (var.getName().equalsIgnoreCase(varName)) {
|
||||
v = var;
|
||||
break;
|
||||
return var;
|
||||
}
|
||||
}
|
||||
|
||||
if (v == null) {
|
||||
for (Variable var : variables) {
|
||||
if (var.getShortName().equalsIgnoreCase(varName)) {
|
||||
v = var;
|
||||
break;
|
||||
}
|
||||
for (Variable var : variables) {
|
||||
if (var.getShortName().equalsIgnoreCase(varName)) {
|
||||
return var;
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -711,6 +886,15 @@ import org.meteoinfo.projection.ProjectionInfo;
|
||||
this.variables.add(var);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a coordinate variable
|
||||
* @param var Coordinate variable
|
||||
*/
|
||||
public void addCoordinate(Variable var) {
|
||||
this.coordinates.add(var);
|
||||
this.variables.add(var);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a dimension
|
||||
*
|
||||
|
||||
@ -40,6 +40,7 @@ import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.meteoinfo.data.meteodata.radar.RadarDataUtil;
|
||||
import org.meteoinfo.ndarray.IndexIterator;
|
||||
import org.meteoinfo.ndarray.math.ArrayMath;
|
||||
import org.meteoinfo.projection.ProjectionInfo;
|
||||
import java.util.List;
|
||||
@ -802,7 +803,7 @@ public class MeteoDataInfo {
|
||||
}
|
||||
|
||||
/**
|
||||
* Open GRIB data by predifined version - for mixed GRIB-1 and GRIB-2 data file.
|
||||
* Open GRIB data by predefined version - for mixed GRIB-1 and GRIB-2 data file.
|
||||
*
|
||||
* @param fileName File path
|
||||
* @param version GRIB data version: 1 or 2.
|
||||
@ -1067,7 +1068,26 @@ public class MeteoDataInfo {
|
||||
nranges.add((Range)ranges.get(i));
|
||||
branges.add(new Range(0, ((Range)ranges.get(i)).length() - 1, 1));
|
||||
} else {
|
||||
List<Integer> list = (List<Integer>)ranges.get(i);
|
||||
List<Integer> list;
|
||||
if (ranges.get(i) instanceof Array) {
|
||||
list = new ArrayList<>();
|
||||
Array array = ((Array) ranges.get(i));
|
||||
IndexIterator iter = array.getIndexIterator();
|
||||
if (array.getDataType().isBoolean()) {
|
||||
int idx = 0;
|
||||
while (iter.hasNext()) {
|
||||
if (iter.getBooleanNext())
|
||||
list.add(idx);
|
||||
idx += 1;
|
||||
}
|
||||
} else {
|
||||
while (iter.hasNext()) {
|
||||
list.add(iter.getIntNext());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
list = (List<Integer>) ranges.get(i);
|
||||
}
|
||||
int min = list.get(0);
|
||||
int max = min;
|
||||
if (list.size() > 1){
|
||||
|
||||
@ -69,6 +69,19 @@ public class Variable {
|
||||
description = "null";
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param name Variable name
|
||||
*/
|
||||
public Variable(String name) {
|
||||
this.name = name;
|
||||
this.shortName = name;
|
||||
this.dataType = DataType.FLOAT;
|
||||
levels = new ArrayList<>();
|
||||
units = "null";
|
||||
description = "null";
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -629,6 +642,7 @@ public class Variable {
|
||||
*/
|
||||
public void setCachedData(Array value) {
|
||||
this.cachedData = value;
|
||||
this.dataType = value.getDataType();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -54,25 +54,14 @@ import java.util.logging.Logger;
|
||||
public class ARLDataInfo extends DataInfo implements IGridDataInfo {
|
||||
|
||||
// <editor-fold desc="Variables">
|
||||
//private FileStream _fs = null;
|
||||
//private BinaryWriter _bw = null;
|
||||
/// <summary>
|
||||
/// Is Lat/Lon
|
||||
/// </summary>
|
||||
public Boolean isLatLon;
|
||||
/// <summary>
|
||||
/// Projection info
|
||||
/// </summary>
|
||||
//public ProjectionInfo projInfo;
|
||||
/// <summary>
|
||||
/// Data head
|
||||
/// </summary>
|
||||
public DataHead dataHead;
|
||||
// /// <summary>
|
||||
// /// Time list
|
||||
// /// </summary>
|
||||
// public List<Date> times;
|
||||
/// <summary>
|
||||
/// Record length
|
||||
/// </summary>
|
||||
public long recLen;
|
||||
@ -85,11 +74,6 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
|
||||
/// Variable list
|
||||
/// </summary>
|
||||
public List<List<String>> LevelVarList;
|
||||
// /// <summary>
|
||||
// /// Variables
|
||||
// /// </summary>
|
||||
// public List<Variable> Variables = new ArrayList<Variable>();
|
||||
/// <summary>
|
||||
/// Level number
|
||||
/// </summary>
|
||||
public int levelNum;
|
||||
@ -98,10 +82,6 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
|
||||
/// </summary>
|
||||
public List<Double> levels;
|
||||
///// <summary>
|
||||
///// Variable-levle list
|
||||
///// </summary>
|
||||
//public List<ARLVAR> varLevList;
|
||||
/// <summary>
|
||||
/// Undefine data
|
||||
/// </summary>
|
||||
public double missingValue;
|
||||
@ -117,7 +97,6 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
|
||||
/// Is global
|
||||
/// </summary>
|
||||
public boolean isGlobal;
|
||||
//private DataOutputStream _bw = null;
|
||||
private RandomAccessFile _bw = null;
|
||||
private long indexRecPos = 0;
|
||||
// </editor-fold>
|
||||
@ -399,10 +378,12 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
|
||||
}
|
||||
|
||||
Dimension xDim = new Dimension(DimensionType.X);
|
||||
xDim.setName(this.getXCoordVariableName());
|
||||
xDim.setValues(X);
|
||||
this.setXDimension(xDim);
|
||||
this.addDimension(xDim);
|
||||
Dimension yDim = new Dimension(DimensionType.Y);
|
||||
yDim.setName(this.getYCoordVariableName());
|
||||
yDim.setValues(Y);
|
||||
this.setYDimension(yDim);
|
||||
this.addDimension(yDim);
|
||||
@ -440,35 +421,12 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
|
||||
br.seek(br.getFilePointer() - 50 - 108);
|
||||
|
||||
aTime = LocalDateTime.of(year, aDL.getMonth(), aDL.getDay(), aDL.getHour(), dh.MN, 0);
|
||||
/*if (aTime.equals(oldTime)) {
|
||||
sameTimeNum += 1;
|
||||
}*/
|
||||
times.add(aTime);
|
||||
timeNum += 1;
|
||||
} while (true);
|
||||
|
||||
br.close();
|
||||
|
||||
/*//Update times
|
||||
if (sameTimeNum > 1) {
|
||||
int minutes = 60 / sameTimeNum;
|
||||
int idx = 0;
|
||||
List<LocalDateTime> newTimes = new ArrayList<>();
|
||||
LocalDateTime baseTime = times.get(0);
|
||||
for (LocalDateTime time : times) {
|
||||
if (time.equals(baseTime)) {
|
||||
if (idx > 0)
|
||||
time = baseTime.plusMinutes(minutes * idx);
|
||||
idx += 1;
|
||||
} else {
|
||||
baseTime = time;
|
||||
idx = 1;
|
||||
}
|
||||
newTimes.add(time);
|
||||
}
|
||||
times = newTimes;
|
||||
}*/
|
||||
|
||||
//Set dimensions
|
||||
Array values = Array.factory(DataType.DATE, new int[]{times.size()});
|
||||
IndexIterator iter = values.getIndexIterator();
|
||||
@ -476,6 +434,7 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
|
||||
iter.setDateNext(t);
|
||||
}
|
||||
Dimension tDim = new Dimension(DimensionType.T);
|
||||
tDim.setName("time");
|
||||
tDim.setDimValue(values);
|
||||
this.setTimeDimension(tDim);
|
||||
this.addDimension(tDim);
|
||||
@ -524,7 +483,7 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
|
||||
}
|
||||
if (zDim == null){
|
||||
zDim = new Dimension(DimensionType.Z);
|
||||
zDim.setName("Z_" + String.valueOf(len));
|
||||
zDim.setName("z_" + String.valueOf(len));
|
||||
zDim.setValues(var.getLevels());
|
||||
zdims.add(zDim);
|
||||
this.addDimension(zDim);
|
||||
@ -534,8 +493,24 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
|
||||
var.setDimension(this.getYDimension());
|
||||
var.setDimension(this.getXDimension());
|
||||
}
|
||||
this.setTimes(times);
|
||||
this.setVariables(variables);
|
||||
|
||||
//Add coordinate variables
|
||||
Variable var;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
switch (dim.getDimType()) {
|
||||
case T:
|
||||
case X:
|
||||
case Y:
|
||||
case Z:
|
||||
var = new Variable(dim.getName());
|
||||
var.setDimVar(true);
|
||||
var.setCachedData(dim.getDimValue());
|
||||
var.addDimension(dim);
|
||||
this.addCoordinate(var);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(ARLDataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@ -749,7 +724,7 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName) {
|
||||
public Array realRead(String varName) {
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -761,7 +736,7 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -776,7 +751,7 @@ public class ARLDataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
Variable var = this.getVariable(varName);
|
||||
Section section = new Section(origin, size, stride);
|
||||
|
||||
@ -129,12 +129,12 @@ public class ASCIIGridDataInfo extends DataInfo implements IGridDataInfo {
|
||||
this.addAttribute(new Attribute("data_format", "ASCII grid data"));
|
||||
|
||||
Dimension xDim = new Dimension(DimensionType.X);
|
||||
xDim.setShortName("X");
|
||||
xDim.setShortName("x");
|
||||
xDim.setValues(X);
|
||||
this.setXDimension(xDim);
|
||||
this.addDimension(xDim);
|
||||
Dimension yDim = new Dimension(DimensionType.Y);
|
||||
yDim.setShortName("Y");
|
||||
yDim.setShortName("y");
|
||||
yDim.setValues(Y);
|
||||
this.setYDimension(yDim);
|
||||
this.addDimension(yDim);
|
||||
@ -155,6 +155,21 @@ public class ASCIIGridDataInfo extends DataInfo implements IGridDataInfo {
|
||||
variables.add(aVar);
|
||||
this.setVariables(variables);
|
||||
|
||||
//Add coordinate variables
|
||||
Variable var;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
switch (dim.getDimType()) {
|
||||
case X:
|
||||
case Y:
|
||||
var = new Variable(dim.getName());
|
||||
var.setDimVar(true);
|
||||
var.setCachedData(dim.getDimValue());
|
||||
var.addDimension(dim);
|
||||
this.addCoordinate(var);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sr.close();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(ASCIIGridDataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
@ -178,7 +193,7 @@ public class ASCIIGridDataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName) {
|
||||
public Array realRead(String varName) {
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -190,7 +205,7 @@ public class ASCIIGridDataInfo extends DataInfo implements IGridDataInfo {
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -205,7 +220,7 @@ public class ASCIIGridDataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
Section section = new Section(origin, size, stride);
|
||||
Array dataArray = Array.factory(this.dataType, section.getShape());
|
||||
|
||||
@ -139,7 +139,7 @@ import org.mozilla.universalchardet.UniversalDetector;
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName){
|
||||
public Array realRead(String varName){
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ import org.mozilla.universalchardet.UniversalDetector;
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -121,6 +121,21 @@ import org.meteoinfo.data.meteodata.Attribute;
|
||||
variables.add(aVar);
|
||||
this.setVariables(variables);
|
||||
|
||||
//Add coordinate variables
|
||||
Variable var;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
switch (dim.getDimType()) {
|
||||
case X:
|
||||
case Y:
|
||||
var = new Variable(dim.getName());
|
||||
var.setDimVar(true);
|
||||
var.setCachedData(dim.getDimValue());
|
||||
var.addDimension(dim);
|
||||
this.addCoordinate(var);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sr.close();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(SurferGridDataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
@ -161,7 +176,7 @@ import org.meteoinfo.data.meteodata.Attribute;
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName){
|
||||
public Array realRead(String varName){
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -173,7 +188,7 @@ import org.meteoinfo.data.meteodata.Attribute;
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -188,7 +203,7 @@ import org.meteoinfo.data.meteodata.Attribute;
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
Section section = new Section(origin, size, stride);
|
||||
Array dataArray = Array.factory(DataType.FLOAT, section.getShape());
|
||||
|
||||
@ -395,6 +395,16 @@ public class AWXDataInfo extends DataInfo implements IGridDataInfo, IStationData
|
||||
FieldList.addAll(VarList);
|
||||
break;
|
||||
}
|
||||
|
||||
//Add coordinate variables
|
||||
Variable variable;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
variable = new Variable(dim.getName());
|
||||
variable.setDimVar(true);
|
||||
variable.setCachedData(dim.getDimValue());
|
||||
variable.addDimension(dim);
|
||||
this.addCoordinate(variable);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(AWXDataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@ -538,12 +548,12 @@ public class AWXDataInfo extends DataInfo implements IGridDataInfo, IStationData
|
||||
}
|
||||
|
||||
Dimension xdim = new Dimension(DimensionType.X);
|
||||
xdim.setShortName("X");
|
||||
xdim.setShortName(this.getXCoordVariableName());
|
||||
xdim.setValues(x);
|
||||
this.setXDimension(xdim);
|
||||
this.addDimension(xdim);
|
||||
Dimension ydim = new Dimension(DimensionType.Y);
|
||||
ydim.setShortName("Y");
|
||||
ydim.setShortName(this.getYCoordVariableName());
|
||||
ydim.setValues(y);
|
||||
this.setYDimension(ydim);
|
||||
this.addDimension(ydim);
|
||||
@ -571,12 +581,12 @@ public class AWXDataInfo extends DataInfo implements IGridDataInfo, IStationData
|
||||
y[i] = _lrLatitude + yDelt * i;
|
||||
}
|
||||
Dimension xdim = new Dimension(DimensionType.X);
|
||||
xdim.setShortName("X");
|
||||
xdim.setShortName(this.getXCoordVariableName());
|
||||
xdim.setValues(x);
|
||||
this.setXDimension(xdim);
|
||||
this.addDimension(xdim);
|
||||
Dimension ydim = new Dimension(DimensionType.Y);
|
||||
ydim.setShortName("Y");
|
||||
ydim.setShortName(this.getYCoordVariableName());
|
||||
ydim.setValues(y);
|
||||
this.setYDimension(ydim);
|
||||
this.addDimension(ydim);
|
||||
@ -599,7 +609,7 @@ public class AWXDataInfo extends DataInfo implements IGridDataInfo, IStationData
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName) {
|
||||
public Array realRead(String varName) {
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -611,13 +621,13 @@ public class AWXDataInfo extends DataInfo implements IGridDataInfo, IStationData
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
if (this._productType == 4){
|
||||
Array dataArray = this.read_4(varName);
|
||||
|
||||
@ -220,6 +220,16 @@ import org.meteoinfo.ndarray.math.ArrayMath;
|
||||
variables.add(aVar);
|
||||
}
|
||||
this.setVariables(variables);
|
||||
|
||||
//Add coordinate variables
|
||||
Variable variable;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
variable = new Variable(dim.getName());
|
||||
variable.setDimVar(true);
|
||||
variable.setCachedData(dim.getDimValue());
|
||||
variable.addDimension(dim);
|
||||
this.addCoordinate(variable);
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(BILDataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (IOException ex) {
|
||||
@ -263,7 +273,7 @@ import org.meteoinfo.ndarray.math.ArrayMath;
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName){
|
||||
public Array realRead(String varName){
|
||||
return readArray_bil(varName);
|
||||
}
|
||||
|
||||
@ -277,7 +287,7 @@ import org.meteoinfo.ndarray.math.ArrayMath;
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
Section section = new Section(origin, size, stride);
|
||||
Variable var = this.getVariable(varName);
|
||||
|
||||
@ -67,14 +67,19 @@ import org.meteoinfo.data.meteodata.Attribute;
|
||||
|
||||
geoTiff = new GeoTiff(fileName);
|
||||
geoTiff.read();
|
||||
|
||||
this.setProjectionInfo(geoTiff.readProj());
|
||||
|
||||
List<double[]> xy = geoTiff.readXY();
|
||||
double[] X = xy.get(0);
|
||||
double[] Y = xy.get(1);
|
||||
Dimension xDim = new Dimension(DimensionType.X);
|
||||
xDim.setName(this.getXCoordVariableName());
|
||||
xDim.setValues(X);
|
||||
this.setXDimension(xDim);
|
||||
this.addDimension(xDim);
|
||||
Dimension yDim = new Dimension(DimensionType.Y);
|
||||
yDim.setName(this.getYCoordVariableName());
|
||||
yDim.setValues(Y);
|
||||
yDim.setReverse(true);
|
||||
this.setYDimension(yDim);
|
||||
@ -83,6 +88,7 @@ import org.meteoinfo.data.meteodata.Attribute;
|
||||
Dimension bDim = null;
|
||||
if (this.bandNum > 1){
|
||||
bDim = new Dimension(DimensionType.OTHER);
|
||||
bDim.setName("band");
|
||||
bDim.setValues(new double[this.bandNum]);
|
||||
this.addDimension(bDim);
|
||||
}
|
||||
@ -98,7 +104,15 @@ import org.meteoinfo.data.meteodata.Attribute;
|
||||
variables.add(aVar);
|
||||
this.setVariables(variables);
|
||||
|
||||
this.setProjectionInfo(geoTiff.readProj());
|
||||
//Add coordinate variables
|
||||
Variable variable;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
variable = new Variable(dim.getName());
|
||||
variable.setDimVar(true);
|
||||
variable.setCachedData(dim.getDimValue());
|
||||
variable.addDimension(dim);
|
||||
this.addCoordinate(variable);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(GeoTiffDataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@ -128,7 +142,7 @@ import org.meteoinfo.data.meteodata.Attribute;
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName){
|
||||
public Array realRead(String varName){
|
||||
Array r = null;
|
||||
try {
|
||||
r = this.geoTiff.readArray();
|
||||
@ -149,7 +163,7 @@ import org.meteoinfo.data.meteodata.Attribute;
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
Section section = new Section(origin, size, stride);
|
||||
int rangeIdx = 0;
|
||||
|
||||
@ -590,7 +590,7 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
|
||||
isGlobal = true;
|
||||
}
|
||||
Dimension xDim = new Dimension(DimensionType.X);
|
||||
xDim.setShortName("X");
|
||||
xDim.setName(this.getXCoordVariableName());
|
||||
xDim.setUnit("degree east");
|
||||
xDim.setValues(values);
|
||||
this.setXDimension(xDim);
|
||||
@ -637,7 +637,7 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
|
||||
Collections.reverse(values);
|
||||
|
||||
Dimension yDim = new Dimension(DimensionType.Y);
|
||||
yDim.setShortName("Y");
|
||||
yDim.setShortName(this.getYCoordVariableName());
|
||||
yDim.setUnit("degree north");
|
||||
yDim.setValues(values);
|
||||
this.setYDimension(yDim);
|
||||
@ -702,7 +702,7 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
|
||||
unit = "m";
|
||||
}
|
||||
zDim = new Dimension(DimensionType.Z);
|
||||
zDim.setShortName("Z");
|
||||
zDim.setShortName("z");
|
||||
zDim.setUnit(unit);
|
||||
zDim.setValues(values);
|
||||
this.setZDimension(zDim);
|
||||
@ -819,7 +819,7 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
|
||||
iter.setDateNext(t);
|
||||
}
|
||||
Dimension tDim = new Dimension(DimensionType.T);
|
||||
tDim.setShortName("T");
|
||||
tDim.setShortName("time");
|
||||
tDim.setDimValue(tArray);
|
||||
this.setTimeDimension(tDim);
|
||||
this.addDimension(tDim);
|
||||
@ -850,7 +850,7 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
|
||||
tArray.setDate(i, t);
|
||||
}
|
||||
Dimension tDim = new Dimension(DimensionType.T);
|
||||
tDim.setShortName("T");
|
||||
tDim.setShortName("time");
|
||||
tDim.setDimValue(tArray);
|
||||
this.setTimeDimension(tDim);
|
||||
this.addDimension(tDim);
|
||||
@ -877,6 +877,7 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
|
||||
this.ensNames.add(dataArray[3 + i]);
|
||||
}
|
||||
eDim = new Dimension(DimensionType.E);
|
||||
eDim.setName("ensemble");
|
||||
eDim.setLength(eNum);
|
||||
this.addDimension(eDim);
|
||||
Variable evar = new Variable();
|
||||
@ -900,10 +901,7 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
|
||||
aVar.setName(dataArray[0]);
|
||||
aVar.setDataType(DataType.FLOAT);
|
||||
int lNum = Integer.parseInt(dataArray[1]);
|
||||
//aVar.setLevelNum(Integer.parseInt(dataArray[1]));
|
||||
aVar.setUnits(dataArray[2]);
|
||||
//attr = new Attribute("units", dataArray[2]);
|
||||
//aVar.addAttribute(attr);
|
||||
if (dataArray.length > 3) {
|
||||
int idx = aLine.indexOf(dataArray[3]);
|
||||
String desc = aLine.substring(idx);
|
||||
@ -935,7 +933,7 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
|
||||
}
|
||||
}
|
||||
Dimension dim = new Dimension(DimensionType.Z);
|
||||
dim.setShortName("Z_" + String.valueOf(lNum));
|
||||
dim.setName("z_" + String.valueOf(lNum));
|
||||
dim.setUnit(zDim.getUnit());
|
||||
dim.setValues(levs);
|
||||
aVar.setDimension(dim);
|
||||
@ -964,9 +962,25 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
|
||||
}
|
||||
|
||||
} while (aLine != null);
|
||||
|
||||
sr.close();
|
||||
|
||||
//Add coordinate variables
|
||||
Variable var;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
switch (dim.getDimType()) {
|
||||
case T:
|
||||
case X:
|
||||
case Y:
|
||||
case Z:
|
||||
var = new Variable(dim.getName());
|
||||
var.setDimVar(true);
|
||||
var.setCachedData(dim.getDimValue());
|
||||
var.addDimension(dim);
|
||||
this.addCoordinate(var);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isNotPath && !this.OPTIONS.template) {
|
||||
errorStr = "The data file is not exist!" + System.getProperty("line.separator") + DSET;
|
||||
System.out.println(errorStr);
|
||||
@ -1343,7 +1357,7 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName) {
|
||||
public Array realRead(String varName) {
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -1355,7 +1369,7 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -1370,7 +1384,7 @@ public class GrADSDataInfo extends DataInfo implements IGridDataInfo, IStationDa
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
Variable var = this.getVariable(varName);
|
||||
Section section = new Section(origin, size, stride);
|
||||
|
||||
@ -446,7 +446,7 @@ public class GRIB2DataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName){
|
||||
public Array realRead(String varName){
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -460,7 +460,7 @@ public class GRIB2DataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -228,7 +228,7 @@ public class HYSPLITConcDataInfo extends DataInfo implements IGridDataInfo {
|
||||
start += 4;
|
||||
}
|
||||
Dimension zDim = new Dimension(DimensionType.Z);
|
||||
zDim.setShortName("level");
|
||||
zDim.setName("z");
|
||||
zDim.setValues(heights);
|
||||
this.setZDimension(zDim);
|
||||
this.addDimension(zDim);
|
||||
@ -349,7 +349,7 @@ public class HYSPLITConcDataInfo extends DataInfo implements IGridDataInfo {
|
||||
iter.setDateNext(t);
|
||||
}
|
||||
Dimension tDim = new Dimension(DimensionType.T);
|
||||
tDim.setShortName("time");
|
||||
tDim.setName("time");
|
||||
tDim.setDimValue(tArray);
|
||||
this.setTimeDimension(tDim);
|
||||
this.addDimension(tDim);
|
||||
@ -362,6 +362,23 @@ public class HYSPLITConcDataInfo extends DataInfo implements IGridDataInfo {
|
||||
}
|
||||
this.setVariables(variables);
|
||||
|
||||
//Add coordinate variables
|
||||
Variable variable;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
switch (dim.getDimType()) {
|
||||
case X:
|
||||
case Y:
|
||||
case Z:
|
||||
case T:
|
||||
variable = new Variable(dim.getName());
|
||||
variable.setDimVar(true);
|
||||
variable.setCachedData(dim.getDimValue());
|
||||
variable.addDimension(dim);
|
||||
this.addCoordinate(variable);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(ASCIIGridDataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
@ -384,7 +401,7 @@ public class HYSPLITConcDataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName){
|
||||
public Array realRead(String varName){
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -396,7 +413,7 @@ public class HYSPLITConcDataInfo extends DataInfo implements IGridDataInfo {
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -411,7 +428,7 @@ public class HYSPLITConcDataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
Variable var = this.getVariable(varName);
|
||||
Section section = new Section(origin, size, stride);
|
||||
@ -478,7 +495,7 @@ public class HYSPLITConcDataInfo extends DataInfo implements IGridDataInfo {
|
||||
br.skipBytes(nBytes);
|
||||
|
||||
//Record #5
|
||||
nBytes = 12 + this.getVariableNum() * 4;
|
||||
nBytes = 12 + this.getDataVariableNum() * 4;
|
||||
br.skipBytes(nBytes);
|
||||
|
||||
//Record Data
|
||||
@ -492,7 +509,7 @@ public class HYSPLITConcDataInfo extends DataInfo implements IGridDataInfo {
|
||||
for (t = 0; t < this.getTimeNum(); t++) {
|
||||
br.skipBytes(64);
|
||||
|
||||
for (i = 0; i < this.getVariableNum(); i++) {
|
||||
for (i = 0; i < this.getDataVariableNum(); i++) {
|
||||
for (j = 0; j < this.getZDimension().getLength(); j++) {
|
||||
if (t == timeIdx && i == varIdx && j == levelIdx) {
|
||||
if (br.getFilePointer() + 28 > br.length()) {
|
||||
@ -637,7 +654,7 @@ public class HYSPLITConcDataInfo extends DataInfo implements IGridDataInfo {
|
||||
br.skipBytes(nBytes);
|
||||
|
||||
//Record #5
|
||||
nBytes = 12 + this.getVariableNum() * 4;
|
||||
nBytes = 12 + this.getDataVariableNum() * 4;
|
||||
br.skipBytes(nBytes);
|
||||
|
||||
//Record Data
|
||||
@ -648,7 +665,7 @@ public class HYSPLITConcDataInfo extends DataInfo implements IGridDataInfo {
|
||||
for (t = 0; t < this.getTimeNum(); t++) {
|
||||
br.skipBytes(64);
|
||||
|
||||
for (i = 0; i < this.getVariableNum(); i++) {
|
||||
for (i = 0; i < this.getDataVariableNum(); i++) {
|
||||
for (j = 0; j < this.getZDimension().getLength(); j++) {
|
||||
if (t == timeIdx && i == varIdx && j == levelIdx) {
|
||||
if (br.getFilePointer() + 28 > br.length()) {
|
||||
|
||||
@ -133,26 +133,32 @@ public class HYSPLITPartDataInfo extends DataInfo implements IStationDataInfo {
|
||||
var.addAttribute(new Attribute("time_index", i));
|
||||
switch (varName.toLowerCase()) {
|
||||
case "lon":
|
||||
var.setDimVar(true);
|
||||
var.addAttribute("long_name", "longitude");
|
||||
var.addAttribute("units", "degrees_east");
|
||||
break;
|
||||
case "lat":
|
||||
var.setDimVar(true);
|
||||
var.addAttribute("long_name", "latitude");
|
||||
var.addAttribute("units", "degrees_north");
|
||||
break;
|
||||
case "height":
|
||||
var.setDimVar(true);
|
||||
var.addAttribute("long_name", "height above ground");
|
||||
var.addAttribute("units", "meter");
|
||||
break;
|
||||
case "sigma_h":
|
||||
var.setDimVar(true);
|
||||
var.addAttribute("long_name", "horizontal puff size");
|
||||
var.addAttribute("units", "meter");
|
||||
break;
|
||||
case "vel_w":
|
||||
var.setDimVar(true);
|
||||
var.addAttribute("long_name", "current value for the turbulent velocity in the vertical");
|
||||
var.addAttribute("units", "m/s");
|
||||
break;
|
||||
case "vel_v":
|
||||
var.setDimVar(true);
|
||||
var.addAttribute("long_name", "current value for the turbulent velocity in the horizontal");
|
||||
var.addAttribute("units", "m/s");
|
||||
break;
|
||||
@ -218,7 +224,7 @@ public class HYSPLITPartDataInfo extends DataInfo implements IStationDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName){
|
||||
public Array realRead(String varName){
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -230,7 +236,7 @@ public class HYSPLITPartDataInfo extends DataInfo implements IStationDataInfo {
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -245,7 +251,7 @@ public class HYSPLITPartDataInfo extends DataInfo implements IStationDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
Variable var = this.getVariable(varName);
|
||||
int timeIdx = (int)var.findAttribute("time_index").getNumericValue();
|
||||
|
||||
@ -311,12 +311,12 @@ public class HYSPLITTrajDataInfo extends DataInfo implements ITrajDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName) {
|
||||
public Array realRead(String varName) {
|
||||
int[] origin = new int[]{0, 0};
|
||||
int[] size = new int[]{this.trajNum, this.endPointNum};
|
||||
int[] stride = new int[]{1, 1};
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -331,7 +331,7 @@ public class HYSPLITTrajDataInfo extends DataInfo implements ITrajDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
DataColumn col = this.dataTables.get(0).findColumn(varName);
|
||||
DataType dtype = DataType.FLOAT;
|
||||
|
||||
@ -96,7 +96,7 @@ public class MatLabDataInfo extends DataInfo implements IGridDataInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array read(String varName) {
|
||||
public Array realRead(String varName) {
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -108,13 +108,13 @@ public class MatLabDataInfo extends DataInfo implements IGridDataInfo {
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
Variable variable = this.getVariable(varName);
|
||||
return variable.getCachedData().section(origin, size, stride).copy();
|
||||
|
||||
@ -229,7 +229,7 @@ public class METARDataInfo extends DataInfo implements IStationDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName) {
|
||||
public Array realRead(String varName) {
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -241,7 +241,7 @@ public class METARDataInfo extends DataInfo implements IStationDataInfo {
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -256,7 +256,7 @@ public class METARDataInfo extends DataInfo implements IStationDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -125,16 +125,15 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
|
||||
this.numVariation = DataConvert.bytes2Short(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
LocalDateTime dt = LocalDateTime.of(year, month, day, hour, 0);
|
||||
|
||||
this.addAttribute(new Attribute("time", dt));
|
||||
this.addAttribute(new Attribute("level", level));
|
||||
|
||||
Dimension tDim = new Dimension(DimensionType.T);
|
||||
tDim.setName("time");
|
||||
tDim.setValue(dt);
|
||||
this.setTimeDimension(tDim);
|
||||
this.addDimension(tDim);
|
||||
Dimension zDim = new Dimension(DimensionType.Z);
|
||||
zDim.setName("level");
|
||||
zDim.setValues(new float[]{level});
|
||||
this.setZDimension(zDim);
|
||||
this.addDimension(zDim);
|
||||
//this.addDimension(tDim);
|
||||
Dimension stDim = new Dimension(DimensionType.OTHER);
|
||||
stDim.setName("station");
|
||||
float[] values = new float[numStation];
|
||||
@ -154,8 +153,6 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
|
||||
var.setName(varName);
|
||||
var.setStation(false);
|
||||
var.setDataType(DataType.STRING);
|
||||
var.setDimension(tDim);
|
||||
var.setDimension(zDim);
|
||||
var.setDimension(stDim);
|
||||
var.addAttribute("name", varName);
|
||||
this.addVariable(var);
|
||||
@ -165,8 +162,6 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
|
||||
var.setName(varName);
|
||||
var.setStation(true);
|
||||
var.setDataType(DataType.FLOAT);
|
||||
var.setDimension(tDim);
|
||||
var.setDimension(zDim);
|
||||
var.setDimension(stDim);
|
||||
var.addAttribute("name", varName);
|
||||
this.addVariable(var);
|
||||
@ -176,8 +171,6 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
|
||||
var.setName(varName);
|
||||
var.setStation(true);
|
||||
var.setDataType(DataType.FLOAT);
|
||||
var.setDimension(tDim);
|
||||
var.setDimension(zDim);
|
||||
var.setDimension(stDim);
|
||||
var.addAttribute("name", varName);
|
||||
this.variableNames.add(varName);
|
||||
@ -192,8 +185,6 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
|
||||
var.setName(varName);
|
||||
var.setStation(true);
|
||||
var.setDataType(this.dataTypeMap.get(dataTypeId));
|
||||
var.setDimension(tDim);
|
||||
var.setDimension(zDim);
|
||||
var.setDimension(stDim);
|
||||
var.addAttribute("name", varName);
|
||||
this.addVariable(var);
|
||||
@ -256,16 +247,14 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
|
||||
br.skipBytes(97);
|
||||
|
||||
dt = LocalDateTime.of(year, month, day, hour, 0);
|
||||
|
||||
this.addAttribute(new Attribute("time", dt));
|
||||
this.addAttribute(new Attribute("level", level));
|
||||
|
||||
tDim = new Dimension(DimensionType.T);
|
||||
tDim.setName("time");
|
||||
tDim.setValue(dt);
|
||||
this.setTimeDimension(tDim);
|
||||
this.addDimension(tDim);
|
||||
zDim = new Dimension(DimensionType.Z);
|
||||
zDim.setName("level");
|
||||
zDim.setValues(new float[]{level});
|
||||
this.setZDimension(zDim);
|
||||
this.addDimension(zDim);
|
||||
Dimension yDim = new Dimension(DimensionType.Y);
|
||||
if (deltaLat < 0) {
|
||||
this.yReverse = true;
|
||||
@ -296,8 +285,6 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
|
||||
var = new Variable();
|
||||
var.setName(this.element);
|
||||
var.setDataType(DataType.FLOAT);
|
||||
var.setDimension(tDim);
|
||||
var.setDimension(zDim);
|
||||
var.setDimension(yDim);
|
||||
var.setDimension(xDim);
|
||||
this.addVariable(var);
|
||||
@ -308,8 +295,6 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
|
||||
var = new Variable();
|
||||
var.setName(vName);
|
||||
var.setDataType(DataType.FLOAT);
|
||||
var.setDimension(tDim);
|
||||
var.setDimension(zDim);
|
||||
var.setDimension(yDim);
|
||||
var.setDimension(xDim);
|
||||
this.addVariable(var);
|
||||
@ -322,8 +307,6 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
|
||||
var.setName("WindSpeed");
|
||||
var.setDataType(DataType.FLOAT);
|
||||
var.setUnits("m/s");
|
||||
var.setDimension(tDim);
|
||||
var.setDimension(zDim);
|
||||
var.setDimension(yDim);
|
||||
var.setDimension(xDim);
|
||||
this.addVariable(var);
|
||||
@ -332,8 +315,6 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
|
||||
var.setName("WindDirection");
|
||||
var.setDataType(DataType.FLOAT);
|
||||
var.setUnits("degree");
|
||||
var.setDimension(tDim);
|
||||
var.setDimension(zDim);
|
||||
var.setDimension(yDim);
|
||||
var.setDimension(xDim);
|
||||
this.addVariable(var);
|
||||
@ -344,9 +325,18 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
|
||||
this.addAttribute(new Attribute("model_name", modelName));
|
||||
break;
|
||||
}
|
||||
this.addAttribute(new Attribute("level", level));
|
||||
this.addAttribute(new Attribute("description", description));
|
||||
|
||||
//Add coordinate variables
|
||||
Variable variable;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
variable = new Variable(dim.getName());
|
||||
variable.setDimVar(true);
|
||||
variable.setCachedData(dim.getDimValue());
|
||||
variable.addDimension(dim);
|
||||
this.addCoordinate(variable);
|
||||
}
|
||||
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(MDFSDataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
@ -472,7 +462,7 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array read(String varName) {
|
||||
public Array realRead(String varName) {
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -484,7 +474,7 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -520,13 +510,13 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
Section section = new Section(origin, size, stride);
|
||||
Variable variable = this.getVariable(varName);
|
||||
Array dataArray = Array.factory(variable.getDataType(), section.getShape());
|
||||
IndexIterator ii = dataArray.getIndexIterator();
|
||||
int rangeIdx = 2;
|
||||
int rangeIdx = 0;
|
||||
switch (this.type) {
|
||||
case 1:
|
||||
case 2:
|
||||
|
||||
@ -164,22 +164,20 @@ public class MICAPS11DataInfo extends DataInfo implements IGridDataInfo {
|
||||
}
|
||||
|
||||
this.addAttribute(new Attribute("data_format", "MICAPS 11"));
|
||||
this.addAttribute(new Attribute("time", time));
|
||||
this.addAttribute(new Attribute("level", _level));
|
||||
|
||||
Dimension tdim = new Dimension(DimensionType.T);
|
||||
tdim.setShortName("time");
|
||||
tdim.setValue(time);
|
||||
this.setTimeDimension(tdim);
|
||||
this.addDimension(tdim);
|
||||
Dimension zdim = new Dimension(DimensionType.Z);
|
||||
zdim.setShortName("level");
|
||||
zdim.setValues(new double[]{_level});
|
||||
this.addDimension(zdim);
|
||||
Dimension ydim = new Dimension(DimensionType.Y);
|
||||
ydim.setShortName("lat");
|
||||
ydim.setShortName(this.getYCoordVariableName());
|
||||
ydim.setValues(_yArray);
|
||||
this.setYDimension(ydim);
|
||||
this.addDimension(ydim);
|
||||
Dimension xdim = new Dimension(DimensionType.X);
|
||||
xdim.setShortName("lon");
|
||||
xdim.setShortName(this.getXCoordVariableName());
|
||||
xdim.setValues(_xArray);
|
||||
this.setXDimension(xdim);
|
||||
this.addDimension(xdim);
|
||||
@ -192,13 +190,21 @@ public class MICAPS11DataInfo extends DataInfo implements IGridDataInfo {
|
||||
Variable var = new Variable();
|
||||
var.setName(varName);
|
||||
var.setStation(true);
|
||||
var.setDimension(tdim);
|
||||
var.setDimension(zdim);
|
||||
var.setDimension(ydim);
|
||||
var.setDimension(xdim);
|
||||
variables.add(var);
|
||||
}
|
||||
this.setVariables(variables);
|
||||
|
||||
//Add coordinate variables
|
||||
Variable variable;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
variable = new Variable(dim.getName());
|
||||
variable.setDimVar(true);
|
||||
variable.setCachedData(dim.getDimValue());
|
||||
variable.addDimension(dim);
|
||||
this.addCoordinate(variable);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(MICAPS4DataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@ -231,7 +237,7 @@ public class MICAPS11DataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName){
|
||||
public Array realRead(String varName){
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -243,7 +249,7 @@ public class MICAPS11DataInfo extends DataInfo implements IGridDataInfo {
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -258,11 +264,11 @@ public class MICAPS11DataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
Section section = new Section(origin, size, stride);
|
||||
Array dataArray = Array.factory(DataType.FLOAT, section.getShape());
|
||||
int rangeIdx = 2;
|
||||
int rangeIdx = 0;
|
||||
Range yRange = section.getRange(rangeIdx++);
|
||||
Range xRange = section.getRange(rangeIdx);
|
||||
IndexIterator ii = dataArray.getIndexIterator();
|
||||
|
||||
@ -94,6 +94,9 @@ public class MICAPS120DataInfo extends DataInfo implements IStationDataInfo {
|
||||
DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyyMMddHH");
|
||||
LocalDateTime time = LocalDateTime.parse(dateStr, format);
|
||||
|
||||
this.addAttribute(new Attribute("data_format", "MICAPS 120"));
|
||||
this.addAttribute(new Attribute("time", time));
|
||||
|
||||
//Set dimension and variables
|
||||
Dimension tdim = new Dimension(DimensionType.T);
|
||||
tdim.setValue(time);
|
||||
@ -122,11 +125,11 @@ public class MICAPS120DataInfo extends DataInfo implements IStationDataInfo {
|
||||
|
||||
Dimension stdim = new Dimension(DimensionType.OTHER);
|
||||
stdim.setShortName("station");
|
||||
double[] values = new double[stNum];
|
||||
Array stations = Array.factory(DataType.INT, new int[]{stNum});
|
||||
for (int i = 0; i < stNum; i++){
|
||||
values[i] = i;
|
||||
stations.setInt(i, i);
|
||||
}
|
||||
stdim.setValues(values);
|
||||
stdim.setDimValue(stations);
|
||||
this.addDimension(stdim);
|
||||
List<Variable> variables = new ArrayList<>();
|
||||
for (String vName : this._fieldList) {
|
||||
@ -142,6 +145,16 @@ public class MICAPS120DataInfo extends DataInfo implements IStationDataInfo {
|
||||
variables.add(var);
|
||||
}
|
||||
this.setVariables(variables);
|
||||
|
||||
//Add coordinate variables
|
||||
Variable variable;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
variable = new Variable(dim.getName());
|
||||
variable.setDimVar(true);
|
||||
variable.setCachedData(dim.getDimValue());
|
||||
variable.addDimension(dim);
|
||||
this.addCoordinate(variable);
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(MICAPS120DataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
@ -185,7 +198,7 @@ public class MICAPS120DataInfo extends DataInfo implements IStationDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName){
|
||||
public Array realRead(String varName){
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -197,7 +210,7 @@ public class MICAPS120DataInfo extends DataInfo implements IStationDataInfo {
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -212,7 +225,7 @@ public class MICAPS120DataInfo extends DataInfo implements IStationDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
int varIdx = this._fieldList.indexOf(varName);
|
||||
if (varIdx < 0)
|
||||
return null;
|
||||
|
||||
@ -212,10 +212,12 @@ public class MICAPS131DataInfo extends DataInfo implements IGridDataInfo {
|
||||
}
|
||||
br.close();
|
||||
|
||||
this.addAttribute(new Attribute("data_format", "MICAPS 131"));
|
||||
this.addAttribute(new Attribute("time", time));
|
||||
|
||||
Dimension tdim = new Dimension(DimensionType.T);
|
||||
tdim.setValue(time);
|
||||
this.setTimeDimension(tdim);
|
||||
this.addDimension(tdim);
|
||||
Dimension zdim = new Dimension(DimensionType.Z);
|
||||
double[] zValues = new double[zNum];
|
||||
for (int i = 0; i < zNum; i++) {
|
||||
@ -243,12 +245,21 @@ public class MICAPS131DataInfo extends DataInfo implements IGridDataInfo {
|
||||
|
||||
Variable var = new Variable();
|
||||
var.setName("var");
|
||||
var.setDimension(tdim);
|
||||
var.setDimension(zdim);
|
||||
var.setDimension(ydim);
|
||||
var.setDimension(xdim);
|
||||
var.addAttribute("data_name", dataName);
|
||||
this.addVariable(var);
|
||||
|
||||
//Add coordinate variables
|
||||
Variable variable;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
variable = new Variable(dim.getName());
|
||||
variable.setDimVar(true);
|
||||
variable.setCachedData(dim.getDimValue());
|
||||
variable.addDimension(dim);
|
||||
this.addCoordinate(variable);
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(MICAPS131DataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (IOException ex) {
|
||||
@ -273,7 +284,7 @@ public class MICAPS131DataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName) {
|
||||
public Array realRead(String varName) {
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -285,7 +296,7 @@ public class MICAPS131DataInfo extends DataInfo implements IGridDataInfo {
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -300,12 +311,12 @@ public class MICAPS131DataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
Variable var = this.getVariable(varName);
|
||||
Section section = new Section(origin, size, stride);
|
||||
Array dataArray = Array.factory(DataType.FLOAT, section.getShape());
|
||||
int rangeIdx = 1;
|
||||
int rangeIdx = 0;
|
||||
|
||||
Range levRange = var.getLevelNum() > 0 ? section
|
||||
.getRange(rangeIdx++)
|
||||
|
||||
@ -135,25 +135,38 @@ public class MICAPS13DataInfo extends DataInfo implements IGridDataInfo {
|
||||
Object[] coords = this.calCoordinate(_lon_LB, _lat_LB, _lon_Center, _lat_Center, _xNum, _yNum);
|
||||
br.close();
|
||||
|
||||
this.addAttribute(new Attribute("data_format", "MICAPS 13"));
|
||||
this.addAttribute(new Attribute("time", _time));
|
||||
|
||||
Dimension tdim = new Dimension(DimensionType.T);
|
||||
tdim.setValue(_time);
|
||||
this.setTimeDimension(tdim);
|
||||
this.addDimension(tdim);
|
||||
Dimension ydim = new Dimension(DimensionType.Y);
|
||||
ydim.setName(this.getYCoordVariableName());
|
||||
ydim.setValues((double[]) coords[1]);
|
||||
this.addDimension(ydim);
|
||||
this.setYDimension(ydim);
|
||||
Dimension xdim = new Dimension(DimensionType.X);
|
||||
xdim.setName(this.getXCoordVariableName());
|
||||
xdim.setValues((double[]) coords[0]);
|
||||
this.addDimension(xdim);
|
||||
this.setXDimension(xdim);
|
||||
|
||||
Variable var = new Variable();
|
||||
var.setName("var");
|
||||
var.setDimension(tdim);
|
||||
var.setDimension(ydim);
|
||||
var.setDimension(xdim);
|
||||
this.addVariable(var);
|
||||
|
||||
//Add coordinate variables
|
||||
Variable variable;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
variable = new Variable(dim.getName());
|
||||
variable.setDimVar(true);
|
||||
variable.setCachedData(dim.getDimValue());
|
||||
variable.addDimension(dim);
|
||||
this.addCoordinate(variable);
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(MICAPS13DataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (IOException ex) {
|
||||
@ -315,7 +328,7 @@ public class MICAPS13DataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName){
|
||||
public Array realRead(String varName){
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -327,7 +340,7 @@ public class MICAPS13DataInfo extends DataInfo implements IGridDataInfo {
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -342,11 +355,11 @@ public class MICAPS13DataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
Section section = new Section(origin, size, stride);
|
||||
Array dataArray = Array.factory(DataType.INT, section.getShape());
|
||||
int rangeIdx = 1;
|
||||
int rangeIdx = 0;
|
||||
Range yRange = section.getRange(rangeIdx++);
|
||||
Range xRange = section.getRange(rangeIdx);
|
||||
IndexIterator ii = dataArray.getIndexIterator();
|
||||
|
||||
@ -19,6 +19,7 @@ import org.meteoinfo.common.util.JDateUtil;
|
||||
import org.meteoinfo.data.StationData;
|
||||
import org.meteoinfo.data.dimarray.DimArray;
|
||||
import org.meteoinfo.data.meteodata.DataInfo;
|
||||
import org.meteoinfo.ndarray.IndexIterator;
|
||||
import org.meteoinfo.ndarray.math.ArrayMath;
|
||||
import org.meteoinfo.data.dimarray.Dimension;
|
||||
import org.meteoinfo.data.dimarray.DimensionType;
|
||||
@ -122,11 +123,12 @@ public class MICAPS1DataInfo extends DataInfo implements IStationDataInfo {
|
||||
}
|
||||
LocalDateTime time = LocalDateTime.of(year, Integer.parseInt(dataArray[1]),
|
||||
Integer.parseInt(dataArray[2]), Integer.parseInt(dataArray[3]), 0, 0);
|
||||
this.addAttribute(new Attribute("time", time));
|
||||
Dimension tdim = new Dimension(DimensionType.T);
|
||||
tdim.setName("time");
|
||||
tdim.setValue(time);
|
||||
this.setTimeDimension(tdim);
|
||||
this.addDimension(tdim);
|
||||
//this.addDimension(tdim);
|
||||
|
||||
if (dataArray.length >= 5)
|
||||
_stNum = Integer.parseInt(dataArray[4]);
|
||||
@ -143,10 +145,8 @@ public class MICAPS1DataInfo extends DataInfo implements IStationDataInfo {
|
||||
Dimension stdim = new Dimension(DimensionType.OTHER);
|
||||
stdim.setShortName("station");
|
||||
double[] values = new double[_stNum];
|
||||
for (int i = 0; i < _stNum; i++) {
|
||||
values[i] = i;
|
||||
}
|
||||
stdim.setValues(values);
|
||||
Array stations = this.readStid();
|
||||
stdim.setDimValue(stations);
|
||||
this.addDimension(stdim);
|
||||
List<Variable> variables = new ArrayList<>();
|
||||
for (String vName : _fieldList) {
|
||||
@ -169,12 +169,22 @@ public class MICAPS1DataInfo extends DataInfo implements IStationDataInfo {
|
||||
}
|
||||
var.setDataType(dt);
|
||||
var.setStation(true);
|
||||
var.setDimension(tdim);
|
||||
//var.setDimension(tdim);
|
||||
var.setDimension(stdim);
|
||||
variables.add(var);
|
||||
}
|
||||
this.setVariables(variables);
|
||||
|
||||
//Add coordinate variables
|
||||
Variable variable;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
variable = new Variable(dim.getName());
|
||||
variable.setDimVar(true);
|
||||
variable.setCachedData(dim.getDimValue());
|
||||
variable.addDimension(dim);
|
||||
this.addCoordinate(variable);
|
||||
}
|
||||
|
||||
//Read data
|
||||
dataNum = 0;
|
||||
do {
|
||||
@ -322,6 +332,69 @@ public class MICAPS1DataInfo extends DataInfo implements IStationDataInfo {
|
||||
}
|
||||
}
|
||||
|
||||
private Array readStid() {
|
||||
BufferedReader sr = null;
|
||||
try {
|
||||
sr = new BufferedReader(new InputStreamReader(new FileInputStream(this.getFileName()), "gbk"));
|
||||
String aLine;
|
||||
String[] dataArray;
|
||||
Array data = Array.factory(DataType.STRING, new int[]{this._stNum});
|
||||
IndexIterator iter = data.getIndexIterator();
|
||||
|
||||
//Read file head
|
||||
sr.readLine();
|
||||
aLine = sr.readLine().trim();
|
||||
if (aLine.isEmpty()) {
|
||||
sr.readLine();
|
||||
}
|
||||
|
||||
//Read data
|
||||
do {
|
||||
aLine = sr.readLine();
|
||||
if (aLine == null) {
|
||||
break;
|
||||
}
|
||||
aLine = aLine.trim();
|
||||
if (aLine.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
dataArray = aLine.split("\\s+");
|
||||
if (iter.hasNext()) {
|
||||
iter.setStringNext(dataArray[0]);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
for (int n = 0; n <= 10; n++) {
|
||||
if (dataArray.length < 24) {
|
||||
aLine = sr.readLine();
|
||||
if (aLine == null) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (aLine != null);
|
||||
|
||||
return data;
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(MICAPS1DataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return null;
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(MICAPS1DataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return null;
|
||||
} finally {
|
||||
try {
|
||||
if (sr != null) {
|
||||
sr.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(MICAPS1DataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get global attributes
|
||||
*
|
||||
@ -350,7 +423,7 @@ public class MICAPS1DataInfo extends DataInfo implements IStationDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName) {
|
||||
public Array realRead(String varName) {
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -362,7 +435,7 @@ public class MICAPS1DataInfo extends DataInfo implements IStationDataInfo {
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -377,7 +450,7 @@ public class MICAPS1DataInfo extends DataInfo implements IStationDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
int varIdx = this._fieldList.indexOf(varName);
|
||||
if (varIdx < 0) {
|
||||
return null;
|
||||
@ -398,7 +471,7 @@ public class MICAPS1DataInfo extends DataInfo implements IStationDataInfo {
|
||||
dt = DataType.INT;
|
||||
break;
|
||||
}
|
||||
int[] shape = new int[]{1, this._stNum};
|
||||
int[] shape = new int[]{this._stNum};
|
||||
Array r = Array.factory(dt, shape);
|
||||
int i;
|
||||
float v;
|
||||
|
||||
@ -121,13 +121,14 @@ public class MICAPS2DataInfo extends DataInfo implements IStationDataInfo {
|
||||
}
|
||||
_dataList.add(dataList);
|
||||
}
|
||||
|
||||
|
||||
this.addAttribute(new Attribute("data_format", "MICAPS 2"));
|
||||
this.addAttribute(new Attribute("time", time));
|
||||
this.addAttribute(new Attribute("level", level));
|
||||
|
||||
Dimension tdim = new Dimension(DimensionType.T);
|
||||
tdim.setValue(time);
|
||||
this.setTimeDimension(tdim);
|
||||
Dimension zdim = new Dimension(DimensionType.Z);
|
||||
zdim.setValues(new double[]{level});
|
||||
this.setZDimension(zdim);
|
||||
Dimension stdim = new Dimension(DimensionType.OTHER);
|
||||
stdim.setShortName("station");
|
||||
double[] values = new double[stNum];
|
||||
@ -141,12 +142,20 @@ public class MICAPS2DataInfo extends DataInfo implements IStationDataInfo {
|
||||
Variable var = new Variable();
|
||||
var.setName(vName);
|
||||
var.setStation(true);
|
||||
//var.setDimension(tdim);
|
||||
//var.setDimension(zdim);
|
||||
var.setDimension(stdim);
|
||||
variables.add(var);
|
||||
}
|
||||
this.setVariables(variables);
|
||||
|
||||
//Add coordinate variables
|
||||
Variable variable;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
variable = new Variable(dim.getName());
|
||||
variable.setDimVar(true);
|
||||
variable.setCachedData(dim.getDimValue());
|
||||
variable.addDimension(dim);
|
||||
this.addCoordinate(variable);
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(MICAPS3DataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
@ -189,7 +198,7 @@ public class MICAPS2DataInfo extends DataInfo implements IStationDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName){
|
||||
public Array realRead(String varName){
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -201,7 +210,7 @@ public class MICAPS2DataInfo extends DataInfo implements IStationDataInfo {
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -216,7 +225,7 @@ public class MICAPS2DataInfo extends DataInfo implements IStationDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
int varIdx = this._fieldList.indexOf(varName);
|
||||
if (varIdx < 0) {
|
||||
return null;
|
||||
|
||||
@ -145,6 +145,9 @@ public class MICAPS3DataInfo extends DataInfo implements IStationDataInfo {
|
||||
_dataList.add(aData);
|
||||
}
|
||||
|
||||
this.addAttribute(new Attribute("time", time));
|
||||
this.addAttribute(new Attribute("level", level));
|
||||
|
||||
stNum = _dataList.size();
|
||||
Dimension stdim = new Dimension(DimensionType.OTHER);
|
||||
stdim.setShortName("station");
|
||||
@ -157,9 +160,6 @@ public class MICAPS3DataInfo extends DataInfo implements IStationDataInfo {
|
||||
Dimension tdim = new Dimension(DimensionType.T);
|
||||
tdim.setValue(time);
|
||||
this.setTimeDimension(tdim);
|
||||
Dimension zdim = new Dimension(DimensionType.Z);
|
||||
zdim.setValues(new double[]{level});
|
||||
this.setZDimension(zdim);
|
||||
List<Variable> variables = new ArrayList<>();
|
||||
for (String vName : this._fieldList) {
|
||||
Variable var = new Variable();
|
||||
@ -167,12 +167,20 @@ public class MICAPS3DataInfo extends DataInfo implements IStationDataInfo {
|
||||
if (vName.equals("Stid"))
|
||||
var.setDataType(DataType.STRING);
|
||||
var.setStation(true);
|
||||
//var.setDimension(tdim);
|
||||
//var.setDimension(zdim);
|
||||
var.setDimension(stdim);
|
||||
variables.add(var);
|
||||
}
|
||||
this.setVariables(variables);
|
||||
|
||||
//Add coordinate variables
|
||||
Variable variable;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
variable = new Variable(dim.getName());
|
||||
variable.setDimVar(true);
|
||||
variable.setCachedData(dim.getDimValue());
|
||||
variable.addDimension(dim);
|
||||
this.addCoordinate(variable);
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(MICAPS3DataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
@ -215,7 +223,7 @@ public class MICAPS3DataInfo extends DataInfo implements IStationDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName){
|
||||
public Array realRead(String varName){
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -227,7 +235,7 @@ public class MICAPS3DataInfo extends DataInfo implements IStationDataInfo {
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -242,7 +250,7 @@ public class MICAPS3DataInfo extends DataInfo implements IStationDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
int varIdx = this._fieldList.indexOf(varName);
|
||||
if (varIdx < 0) {
|
||||
return null;
|
||||
|
||||
@ -180,17 +180,19 @@ public class MICAPS4DataInfo extends DataInfo implements IGridDataInfo {
|
||||
}
|
||||
|
||||
this.addAttribute(new Attribute("data_format", "MICAPS 4"));
|
||||
this.addAttribute(new Attribute("time", time));
|
||||
this.addAttribute(new Attribute("level", _level));
|
||||
|
||||
Dimension tdim = new Dimension(DimensionType.T);
|
||||
tdim.setName("time");
|
||||
tdim.setValue(time);
|
||||
this.setTimeDimension(tdim);
|
||||
this.addDimension(tdim);
|
||||
Dimension zdim = new Dimension(DimensionType.Z);
|
||||
zdim.setValues(new double[]{_level});
|
||||
this.addDimension(zdim);
|
||||
Dimension xdim = new Dimension(DimensionType.X);
|
||||
xdim.setName(this.getXCoordVariableName());
|
||||
xdim.setValues(_xArray);
|
||||
this.setXDimension(xdim);
|
||||
Dimension ydim = new Dimension(DimensionType.Y);
|
||||
ydim.setName(this.getYCoordVariableName());
|
||||
ydim.setValues(_yArray);
|
||||
this.setYDimension(ydim);
|
||||
this.addDimension(ydim);
|
||||
@ -200,12 +202,20 @@ public class MICAPS4DataInfo extends DataInfo implements IGridDataInfo {
|
||||
Variable var = new Variable();
|
||||
var.setName("var");
|
||||
var.setDataType(DataType.FLOAT);
|
||||
var.setDimension(tdim);
|
||||
var.setDimension(zdim);
|
||||
var.setDimension(ydim);
|
||||
var.setDimension(xdim);
|
||||
variables.add(var);
|
||||
this.setVariables(variables);
|
||||
|
||||
//Add coordinate variables
|
||||
Variable variable;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
variable = new Variable(dim.getName());
|
||||
variable.setDimVar(true);
|
||||
variable.setCachedData(dim.getDimValue());
|
||||
variable.addDimension(dim);
|
||||
this.addCoordinate(variable);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(MICAPS4DataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@ -238,7 +248,7 @@ public class MICAPS4DataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName){
|
||||
public Array realRead(String varName){
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -250,7 +260,7 @@ public class MICAPS4DataInfo extends DataInfo implements IGridDataInfo {
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -265,11 +275,11 @@ public class MICAPS4DataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
Section section = new Section(origin, size, stride);
|
||||
Array dataArray = Array.factory(DataType.FLOAT, section.getShape());
|
||||
int rangeIdx = 2;
|
||||
int rangeIdx = 0;
|
||||
Range yRange = section.getRange(rangeIdx++);
|
||||
Range xRange = section.getRange(rangeIdx);
|
||||
IndexIterator ii = dataArray.getIndexIterator();
|
||||
|
||||
@ -262,12 +262,12 @@
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName) {
|
||||
public Array realRead(String varName) {
|
||||
int[] origin = new int[]{0, 0};
|
||||
int[] size = new int[]{this.trajNum, this.pointNum};
|
||||
int[] stride = new int[]{1, 1};
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -282,7 +282,7 @@
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
DataColumn col = this.dataTables.get(0).findColumn(varName);
|
||||
DataType dtype = col.getDataType();
|
||||
|
||||
@ -352,6 +352,23 @@ public class MM5DataInfo extends DataInfo implements IGridDataInfo {
|
||||
|
||||
this.setVariables(variables);
|
||||
|
||||
//Add coordinate variables
|
||||
Variable variable;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
switch (dim.getDimType()) {
|
||||
case X:
|
||||
case Y:
|
||||
case Z:
|
||||
case T:
|
||||
variable = new Variable(dim.getName());
|
||||
variable.setDimVar(true);
|
||||
variable.setCachedData(dim.getDimValue());
|
||||
variable.addDimension(dim);
|
||||
this.addCoordinate(variable);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
br.close();
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(MM5DataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
@ -675,7 +692,7 @@ public class MM5DataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName) {
|
||||
public Array realRead(String varName) {
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -687,7 +704,7 @@ public class MM5DataInfo extends DataInfo implements IGridDataInfo {
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -702,7 +719,7 @@ public class MM5DataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
Variable var = this.getVariable(varName);
|
||||
Section section = new Section(origin, size, stride);
|
||||
|
||||
@ -136,6 +136,23 @@ public class MM5IMDataInfo extends DataInfo implements IGridDataInfo {
|
||||
|
||||
this.setVariables(variables);
|
||||
|
||||
//Add coordinate variables
|
||||
Variable variable;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
switch (dim.getDimType()) {
|
||||
case X:
|
||||
case Y:
|
||||
case Z:
|
||||
case T:
|
||||
variable = new Variable(dim.getName());
|
||||
variable.setDimVar(true);
|
||||
variable.setCachedData(dim.getDimValue());
|
||||
variable.addDimension(dim);
|
||||
this.addCoordinate(variable);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(MM5IMDataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
@ -239,7 +256,7 @@ public class MM5IMDataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName){
|
||||
public Array realRead(String varName){
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -251,7 +268,7 @@ public class MM5IMDataInfo extends DataInfo implements IGridDataInfo {
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -266,7 +283,7 @@ public class MM5IMDataInfo extends DataInfo implements IGridDataInfo {
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -158,7 +158,7 @@ public class NCUtil {
|
||||
* @param ncVar Netcdf variable
|
||||
* @return MeteoThink variable
|
||||
*/
|
||||
public static Variable convertVariable(ucar.nc2.Variable ncVar) {
|
||||
public static Variable convertVariable(ucar.nc2.Variable ncVar) throws IOException {
|
||||
Variable var = new Variable();
|
||||
var.setName(ncVar.getFullName());
|
||||
var.setShortName(ncVar.getShortName());
|
||||
@ -170,6 +170,10 @@ public class NCUtil {
|
||||
var.addAttribute(convertAttribute(ncAttr));
|
||||
}
|
||||
var.setUnits(ncVar.getUnitsString());
|
||||
var.setDimVar(ncVar.isCoordinateVariable());
|
||||
if (ncVar.hasCachedData()) {
|
||||
var.setCachedData(convertArray(ncVar.read()));
|
||||
}
|
||||
|
||||
return var;
|
||||
}
|
||||
|
||||
@ -75,7 +75,6 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
|
||||
private boolean keepOpen = false;
|
||||
private List<ucar.nc2.Variable> ncVariables = new ArrayList<>();
|
||||
private List<ucar.nc2.Dimension> ncDimensions = new ArrayList<>();
|
||||
private List<Dimension> dimensions = new ArrayList<>();
|
||||
private List<ucar.nc2.Attribute> ncAttributes = new ArrayList<>();
|
||||
private ucar.nc2.Variable xVar = null;
|
||||
private ucar.nc2.Variable yVar = null;
|
||||
@ -334,17 +333,9 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
|
||||
//Get projection
|
||||
this.getProjection();
|
||||
|
||||
//Get dimensions values
|
||||
getDimensionValues(ncfile);
|
||||
|
||||
//Get variables
|
||||
List<Variable> vars = new ArrayList<>();
|
||||
//List<Dimension> coorDims = new ArrayList<Dimension>();
|
||||
for (ucar.nc2.Variable var : ncVariables) {
|
||||
Variable nvar = NCUtil.convertVariable(var);
|
||||
//nvar.setName(var.getShortName());
|
||||
//nvar.setCoorVar(var.isCoordinateVariable());
|
||||
nvar.setDimVar(var.getRank() <= 1);
|
||||
if (isSWATH || isPROFILE) {
|
||||
nvar.setStation(true);
|
||||
}
|
||||
@ -363,18 +354,16 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
|
||||
}
|
||||
}
|
||||
|
||||
//nvar.setAttributes(var.getAttributes());
|
||||
/*double[] packData = this.getPackData(var);
|
||||
nvar.setAddOffset(packData[0]);
|
||||
nvar.setScaleFactor(packData[1]);
|
||||
nvar.setFillValue(packData[2]);*/
|
||||
|
||||
vars.add(nvar);
|
||||
if (nvar.isDimVar()) {
|
||||
this.addCoordinate(nvar);
|
||||
} else {
|
||||
this.addVariable(nvar);
|
||||
}
|
||||
}
|
||||
this.setVariables(vars);
|
||||
|
||||
//
|
||||
//getVariableLevels();
|
||||
//Get dimensions values
|
||||
getDimensionValues(ncfile);
|
||||
|
||||
} catch (IOException | ParseException ex) {
|
||||
Logger.getLogger(NetCDFDataInfo.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} finally {
|
||||
@ -1094,15 +1083,15 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
|
||||
ucar.nc2.Variable var = this.findNCVariable("Pressure");
|
||||
if (var != null) {
|
||||
Array darray = NCUtil.convertArray(var.read());
|
||||
int n = (int) darray.getSize();
|
||||
double[] values = new double[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
values[i] = darray.getDouble(i);
|
||||
}
|
||||
Dimension zDim = this.findDimension(var.getDimension(0).getShortName());
|
||||
zDim.setDimType(DimensionType.Z);
|
||||
zDim.setValues(values);
|
||||
zDim.setDimValue(darray);
|
||||
this.setZDimension(zDim);
|
||||
|
||||
Variable variable = this.getVariable("Pressure");
|
||||
if (variable != null) {
|
||||
variable.setCachedData(darray);
|
||||
}
|
||||
} else {
|
||||
//var = this.getNCVariable("")
|
||||
}
|
||||
@ -1116,6 +1105,11 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
|
||||
tDim.setDimType(DimensionType.T);
|
||||
tDim.setDimValue(times);
|
||||
this.setTimeDimension(tDim);
|
||||
|
||||
Variable variable = this.getVariable("Time");
|
||||
if (variable != null) {
|
||||
variable.setCachedData(darray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1140,6 +1134,7 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
|
||||
DimensionType dimType = getDimType(var);
|
||||
dim.setDimType(dimType);
|
||||
Array values = NCUtil.convertArray(var.read());
|
||||
Variable miVar = this.getVariable(var.getFullName());
|
||||
if (values.getSize() > 1) {
|
||||
if (values.getDouble(0) > values.getDouble(1)) {
|
||||
switch (dimType) {
|
||||
@ -1219,6 +1214,10 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
|
||||
dim.setValues((double[]) ArrayUtil.copyToNDJavaArray_Double(values));
|
||||
break;
|
||||
}
|
||||
|
||||
if (miVar != null) {
|
||||
miVar.setCachedData(dim.getDimValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1323,6 +1322,16 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
|
||||
yDim.setValues(Y);
|
||||
this.setYDimension(yDim);
|
||||
}
|
||||
|
||||
//Add coordinate variables
|
||||
Variable variable;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
variable = new Variable(dim.getName());
|
||||
variable.setDimVar(true);
|
||||
variable.setCachedData(dim.getDimValue());
|
||||
variable.addDimension(dim);
|
||||
this.addCoordinate(variable);
|
||||
}
|
||||
}
|
||||
|
||||
private void getDimValues_WRF(NetcdfFile ncfile) throws ParseException, IOException {
|
||||
@ -1576,6 +1585,16 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Add coordinate variables
|
||||
Variable variable;
|
||||
for (Dimension dim : this.dimensions) {
|
||||
variable = new Variable(dim.getName());
|
||||
variable.setDimVar(true);
|
||||
variable.setCachedData(dim.getDimValue());
|
||||
variable.addDimension(dim);
|
||||
this.addCoordinate(variable);
|
||||
}
|
||||
}
|
||||
|
||||
private int getDimensionLength(String dimName) {
|
||||
@ -1899,7 +1918,7 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
|
||||
return sTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
/*@Override
|
||||
public String generateInfoText() {
|
||||
String dataInfo;
|
||||
int i, j;
|
||||
@ -1957,7 +1976,7 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
|
||||
}
|
||||
|
||||
return dataInfo;
|
||||
}
|
||||
}*/
|
||||
|
||||
private int getTrueVarIndex(int varIdx) {
|
||||
int tVarIdx = varIdx;
|
||||
@ -3049,7 +3068,7 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName) {
|
||||
public Array realRead(String varName) {
|
||||
return read(varName, true);
|
||||
}
|
||||
|
||||
@ -3125,7 +3144,7 @@ public class NetCDFDataInfo extends DataInfo implements IGridDataInfo, IStationD
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
return read(varName, origin, size, stride, true);
|
||||
}
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ public class NumpyDataInfo extends DataInfo implements IGridDataInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array read(String varName) {
|
||||
public Array realRead(String varName) {
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -56,13 +56,13 @@ public class NumpyDataInfo extends DataInfo implements IGridDataInfo {
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
Variable variable = this.getVariable(varName);
|
||||
return variable.getCachedData().section(origin, size, stride).copy();
|
||||
|
||||
@ -341,7 +341,7 @@ public abstract class BaseRadarDataInfo extends DataInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array read(String varName) {
|
||||
public Array realRead(String varName) {
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -353,20 +353,16 @@ public abstract class BaseRadarDataInfo extends DataInfo {
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
try {
|
||||
Variable variable = this.getVariable(varName);
|
||||
Section section = new Section(origin, size, stride);
|
||||
if (variable.hasCachedData()) {
|
||||
return variable.getCachedData().section(section.getRanges()).copy();
|
||||
}
|
||||
|
||||
RadialRecord record = this.recordMap.get(varName);
|
||||
Array dataArray = Array.factory(DataType.FLOAT, section.getShape());
|
||||
Range zRange = section.getRange(0);
|
||||
|
||||
@ -309,7 +309,7 @@ import org.meteoinfo.data.meteodata.Attribute;
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName){
|
||||
public Array realRead(String varName){
|
||||
Variable var = this.getVariable(varName);
|
||||
int n = var.getDimNumber();
|
||||
int[] origin = new int[n];
|
||||
@ -321,7 +321,7 @@ import org.meteoinfo.data.meteodata.Attribute;
|
||||
stride[i] = 1;
|
||||
}
|
||||
|
||||
Array r = read(varName, origin, size, stride);
|
||||
Array r = realRead(varName, origin, size, stride);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -336,7 +336,7 @@ import org.meteoinfo.data.meteodata.Attribute;
|
||||
* @return Array data
|
||||
*/
|
||||
@Override
|
||||
public Array read(String varName, int[] origin, int[] size, int[] stride) {
|
||||
public Array realRead(String varName, int[] origin, int[] size, int[] stride) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -1,30 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\animation">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\binary"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\common_math\stats">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\geotiff"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\grib"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\hdf"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\json"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\matlab"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\micaps"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\radar"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\plot"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\grads"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe\series"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\calc"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\wrf"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\netcdf"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\animation"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\grads"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\dataframe"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\traj"/>
|
||||
<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\stats"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\dataframe\dataframe_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\animation\magic_2.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\common_math\stats\ttest_ind_precipitation_anomaly_2.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\netcdf\sht_coords.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\common_math\stats\ttest_ind_precipitation_anomaly_1.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\dataframe\dataframe_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\animation\magic_2.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\common_math\stats\ttest_ind_precipitation_anomaly_2.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\netcdf\sht_coords.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\common_math\stats\ttest_ind_precipitation_anomaly_1.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
@ -32,5 +34,5 @@
|
||||
</Font>
|
||||
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
||||
<Figure DoubleBuffering="true"/>
|
||||
<Startup MainFormLocation="-6,-6" MainFormSize="1292,764"/>
|
||||
<Startup MainFormLocation="-6,0" MainFormSize="1312,794"/>
|
||||
</MeteoInfo>
|
||||
|
||||
17
meteoinfo-lab/pylib/mipylib/dataset/core/_attributes.py
Normal file
17
meteoinfo-lab/pylib/mipylib/dataset/core/_attributes.py
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
|
||||
class Attributes(OrderedDict):
|
||||
|
||||
def __init__(self, **kw):
|
||||
super(OrderedDict, self).__init__(**kw)
|
||||
|
||||
def __getattr__(self, key):
|
||||
try:
|
||||
return self[key]
|
||||
except KeyError:
|
||||
raise AttributeError("Has no attribute '{}'".format(key))
|
||||
|
||||
def __setattr__(self, key, value):
|
||||
self[key] = value
|
||||
26
meteoinfo-lab/pylib/mipylib/dataset/core/_coordinates.py
Normal file
26
meteoinfo-lab/pylib/mipylib/dataset/core/_coordinates.py
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
from pylib.mipylib import DimArray
|
||||
|
||||
|
||||
class Coordinate(DimArray):
|
||||
|
||||
@property
|
||||
def dim(self):
|
||||
return self.dims[0]
|
||||
|
||||
|
||||
class Coordinates(OrderedDict):
|
||||
|
||||
def __init__(self, **kw):
|
||||
super(OrderedDict, self).__init__(**kw)
|
||||
|
||||
def __getattr__(self, key):
|
||||
try:
|
||||
return self[key]
|
||||
except KeyError:
|
||||
raise AttributeError("Has no coordinates '{}'".format(key))
|
||||
|
||||
def __setattr__(self, key, value):
|
||||
self[key] = value
|
||||
17
meteoinfo-lab/pylib/mipylib/dataset/core/_dimensions.py
Normal file
17
meteoinfo-lab/pylib/mipylib/dataset/core/_dimensions.py
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
|
||||
class Dimensions(OrderedDict):
|
||||
|
||||
def __init__(self, **kw):
|
||||
super(OrderedDict, self).__init__(**kw)
|
||||
|
||||
def __getattr__(self, key):
|
||||
try:
|
||||
return self[key]
|
||||
except KeyError:
|
||||
raise AttributeError("Has no dimension '{}'".format(key))
|
||||
|
||||
def __setattr__(self, key, value):
|
||||
self[key] = value
|
||||
117
meteoinfo-lab/pylib/mipylib/dataset/core/dataarray.py
Normal file
117
meteoinfo-lab/pylib/mipylib/dataset/core/dataarray.py
Normal file
@ -0,0 +1,117 @@
|
||||
import mipylib.numeric as np
|
||||
from .variable import Variable
|
||||
|
||||
|
||||
class DataArray(np.NDArray):
|
||||
"""N-dimensional array with labeled coordinates and dimensions.
|
||||
|
||||
DataArray provides a wrapper around numpy ndarrays that uses
|
||||
labeled dimensions and coordinates to support metadata aware
|
||||
operations. The API is similar to that for the pandas Series or
|
||||
DataFrame, but DataArray objects can have any number of dimensions,
|
||||
and their contents have fixed data types.
|
||||
|
||||
Additional features over raw numpy arrays:
|
||||
|
||||
- Apply operations over dimensions by name: ``x.sum('time')``.
|
||||
- Select or assign values by integer location (like numpy):
|
||||
``x[:10]`` or by label (like pandas): ``x.loc['2014-01-01']`` or
|
||||
``x.sel(time='2014-01-01')``.
|
||||
- Mathematical operations (e.g., ``x - y``) vectorize across
|
||||
multiple dimensions (known in numpy as "broadcasting") based on
|
||||
dimension names, regardless of their original order.
|
||||
- Keep track of arbitrary metadata in the form of a Python
|
||||
dictionary: ``x.attrs``
|
||||
- Convert to a pandas Series: ``x.to_series()``.
|
||||
|
||||
Getting items from or doing mathematical operations with a
|
||||
DataArray always returns another DataArray.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
data : array_like
|
||||
Values for this array. Must be an ``ndarray``, ndarray
|
||||
like, or castable to an ``ndarray``. If a self-described xarray
|
||||
or pandas object, attempts are made to use this array's
|
||||
metadata to fill in other unspecified arguments. A view of the
|
||||
array's data is used instead of a copy if possible.
|
||||
coords : sequence or dict of array_like or :py:class:`~Coordinates`, optional
|
||||
Coordinates (tick labels) to use for indexing along each
|
||||
dimension. The following notations are accepted:
|
||||
|
||||
- mapping {dimension name: array-like}
|
||||
- sequence of tuples that are valid arguments for
|
||||
``xarray.Variable()``
|
||||
- (dims, data)
|
||||
- (dims, data, attrs)
|
||||
- (dims, data, attrs, encoding)
|
||||
|
||||
Additionally, it is possible to define a coord whose name
|
||||
does not match the dimension name, or a coord based on multiple
|
||||
dimensions, with one of the following notations:
|
||||
|
||||
- mapping {coord name: DataArray}
|
||||
- mapping {coord name: Variable}
|
||||
- mapping {coord name: (dimension name, array-like)}
|
||||
- mapping {coord name: (tuple of dimension names, array-like)}
|
||||
|
||||
Alternatively, a :py:class:`~Coordinates` object may be used in
|
||||
order to explicitly pass indexes (e.g., a multi-index or any custom
|
||||
Xarray index) or to bypass the creation of a default index for any
|
||||
:term:`Dimension coordinate` included in that object.
|
||||
dims : Hashable or sequence of Hashable, optional
|
||||
Name(s) of the data dimension(s). Must be either a Hashable
|
||||
(only for 1D data) or a sequence of Hashables with length equal
|
||||
to the number of dimensions. If this argument is omitted,
|
||||
dimension names are taken from ``coords`` (if possible) and
|
||||
otherwise default to ``['dim_0', ... 'dim_n']``.
|
||||
name : str or None, optional
|
||||
Name of this array.
|
||||
attrs : dict_like or None, optional
|
||||
Attributes to assign to the new instance. By default, an empty
|
||||
attribute dictionary is initialized.
|
||||
"""
|
||||
|
||||
def __init__(self, data, coords=None, dims=None, name=None, attrs=None):
|
||||
self._variable = Variable(dims, data, attrs)
|
||||
self._coords = coords
|
||||
self._dims = dims
|
||||
self._name = name
|
||||
self._attrs = attrs
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""The name of this array."""
|
||||
return self._name
|
||||
|
||||
@name.setter
|
||||
def name(self, value):
|
||||
self._name = value
|
||||
|
||||
@property
|
||||
def variable(self):
|
||||
"""Low level interface to the Variable object for this DataArray."""
|
||||
return self._variable
|
||||
|
||||
@property
|
||||
def dtype(self):
|
||||
"""
|
||||
Data-type of the array’s elements.
|
||||
|
||||
See Also
|
||||
--------
|
||||
ndarray.dtype
|
||||
numpy.dtype
|
||||
"""
|
||||
return self.variable.dtype
|
||||
|
||||
@property
|
||||
def shape(self):
|
||||
"""
|
||||
Tuple of array dimensions.
|
||||
|
||||
See Also
|
||||
--------
|
||||
ndarray.shape
|
||||
"""
|
||||
return self.variable.shape
|
||||
30
meteoinfo-lab/pylib/mipylib/dataset/core/variable.py
Normal file
30
meteoinfo-lab/pylib/mipylib/dataset/core/variable.py
Normal file
@ -0,0 +1,30 @@
|
||||
import mipylib.numeric as np
|
||||
|
||||
|
||||
class Variable(np.NDArray):
|
||||
|
||||
def __init__(self, dims, data, attrs=None):
|
||||
super(Variable, self).__init__(data)
|
||||
|
||||
self._dims = dims
|
||||
self._data = data
|
||||
self._attrs = attrs
|
||||
|
||||
@property
|
||||
def data(self):
|
||||
return self._data
|
||||
|
||||
@data.setter
|
||||
def data(self, data):
|
||||
self._data = np.asarray(data)
|
||||
|
||||
@property
|
||||
def dims(self):
|
||||
return self._dims
|
||||
|
||||
@property
|
||||
def attrs(self):
|
||||
return self._attrs
|
||||
|
||||
def load(self):
|
||||
pass
|
||||
@ -1,5 +1,7 @@
|
||||
|
||||
from dimarray import dimension, DimArray, dim_array
|
||||
from .dimarray import DimArray, dim_array
|
||||
from ._dimensions import dimension
|
||||
from .accessor_dt import DateTimeAccessor
|
||||
|
||||
|
||||
__all__ = ['dim_array','dimension','DimArray']
|
||||
__all__ = ['dim_array','dimension','DimArray','DateTimeAccessor']
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
from pylib.mipylib import DimArray
|
||||
|
||||
|
||||
class Coordinate(DimArray):
|
||||
|
||||
@property
|
||||
def dim(self):
|
||||
return self.dims[0]
|
||||
|
||||
|
||||
class Coordinates(OrderedDict):
|
||||
|
||||
def __init__(self, **kw):
|
||||
super(OrderedDict, self).__init__(**kw)
|
||||
|
||||
def __getattr__(self, key):
|
||||
try:
|
||||
return self[key]
|
||||
except KeyError:
|
||||
raise AttributeError("Has no coordinates '{}'".format(key))
|
||||
|
||||
def __setattr__(self, key, value):
|
||||
self[key] = value
|
||||
45
meteoinfo-lab/pylib/mipylib/dataset/dataarray/_dimensions.py
Normal file
45
meteoinfo-lab/pylib/mipylib/dataset/dataarray/_dimensions.py
Normal file
@ -0,0 +1,45 @@
|
||||
|
||||
from org.meteoinfo.data.dimarray import Dimension, DimensionType
|
||||
from collections import OrderedDict
|
||||
import mipylib.numeric as np
|
||||
|
||||
|
||||
def dimension(value, name='null', type=None):
|
||||
"""
|
||||
Create a new Dimension.
|
||||
|
||||
:param value: (*array_like*) Dimension value.
|
||||
:param name: (*string*) Dimension name.
|
||||
:param type: (*string*) Dimension type ['X' | 'Y' | 'Z' | 'T'].
|
||||
"""
|
||||
value = np.asarray(value)
|
||||
|
||||
dtype = DimensionType.OTHER
|
||||
if not type is None:
|
||||
if type.upper() == 'X':
|
||||
dtype = DimensionType.X
|
||||
elif type.upper() == 'Y':
|
||||
dtype = DimensionType.Y
|
||||
elif type.upper() == 'Z':
|
||||
dtype = DimensionType.Z
|
||||
elif type.upper() == 'T':
|
||||
dtype = DimensionType.T
|
||||
dim = Dimension(dtype)
|
||||
dim.setDimValue(value._array)
|
||||
dim.setShortName(name)
|
||||
return dim
|
||||
|
||||
|
||||
class Dimensions(OrderedDict):
|
||||
|
||||
def __init__(self, **kw):
|
||||
super(OrderedDict, self).__init__(**kw)
|
||||
|
||||
def __getattr__(self, key):
|
||||
try:
|
||||
return self[key]
|
||||
except KeyError:
|
||||
raise AttributeError("Has no dimension '{}'".format(key))
|
||||
|
||||
def __setattr__(self, key, value):
|
||||
self[key] = value
|
||||
51
meteoinfo-lab/pylib/mipylib/dataset/dataarray/accessor_dt.py
Normal file
51
meteoinfo-lab/pylib/mipylib/dataset/dataarray/accessor_dt.py
Normal file
@ -0,0 +1,51 @@
|
||||
import mipylib.numeric as np
|
||||
|
||||
class DateTimeAccessor(object):
|
||||
"""Access datetime fields for DimArrays with datetime-like dtypes.
|
||||
|
||||
Fields can be accessed through the `.dt` attribute
|
||||
for applicable DimArrays.
|
||||
"""
|
||||
|
||||
def __init__(self, data):
|
||||
"""
|
||||
Init.
|
||||
:param data: NDArray with datetime data type.
|
||||
"""
|
||||
self._data = np.asarray(data)
|
||||
|
||||
@property
|
||||
def year(self):
|
||||
"""The year of the datetime"""
|
||||
r = self._data._array.getYears()
|
||||
return np.NDArray(r)
|
||||
|
||||
@property
|
||||
def month(self):
|
||||
"""The month of the datetime"""
|
||||
r = self._data._array.getMonths()
|
||||
return np.NDArray(r)
|
||||
|
||||
@property
|
||||
def day(self):
|
||||
"""The day of the datetime"""
|
||||
r = self._data._array.getDays()
|
||||
return np.NDArray(r)
|
||||
|
||||
@property
|
||||
def hour(self):
|
||||
"""The hour of the datetime"""
|
||||
r = self._data._array.getHours()
|
||||
return np.NDArray(r)
|
||||
|
||||
@property
|
||||
def minute(self):
|
||||
"""The minute of the datetime"""
|
||||
r = self._data._array.getMinutes()
|
||||
return np.NDArray(r)
|
||||
|
||||
@property
|
||||
def second(self):
|
||||
"""The second of the datetime"""
|
||||
r = self._data._array.getSeconds()
|
||||
return np.NDArray(r)
|
||||
Binary file not shown.
@ -12,40 +12,19 @@ from org.meteoinfo.common import ResampleMethods
|
||||
from org.meteoinfo.common import PointD
|
||||
from org.meteoinfo.ndarray import Array, Range, MAMath, DataType
|
||||
from org.meteoinfo.data.dimarray import Dimension, DimensionType
|
||||
from mipylib.numeric.core._ndarray import NDArray
|
||||
from java.lang import Double
|
||||
from java.util import ArrayList
|
||||
|
||||
import math
|
||||
import datetime
|
||||
import numbers
|
||||
import mipylib.miutil as miutil
|
||||
from java.lang import Double
|
||||
from java.util import ArrayList
|
||||
import mipylib.numeric as np
|
||||
from mipylib.numeric.core._ndarray import NDArray
|
||||
from .accessor_dt import DateTimeAccessor
|
||||
|
||||
nan = Double.NaN
|
||||
|
||||
def dimension(value, name='null', type=None):
|
||||
"""
|
||||
Create a new Dimension.
|
||||
|
||||
:param value: (*array_like*) Dimension value.
|
||||
:param name: (*string*) Dimension name.
|
||||
:param type: (*string*) Dimension type ['X' | 'Y' | 'Z' | 'T'].
|
||||
"""
|
||||
if isinstance(value, NDArray):
|
||||
value = value.aslist()
|
||||
dtype = DimensionType.OTHER
|
||||
if not type is None:
|
||||
if type.upper() == 'X':
|
||||
dtype = DimensionType.X
|
||||
elif type.upper() == 'Y':
|
||||
dtype = DimensionType.Y
|
||||
elif type.upper() == 'Z':
|
||||
dtype = DimensionType.Z
|
||||
elif type.upper() == 'T':
|
||||
dtype = DimensionType.T
|
||||
dim = Dimension(dtype)
|
||||
dim.setDimValues(value)
|
||||
dim.setShortName(name)
|
||||
return dim
|
||||
|
||||
# Dimension array
|
||||
class DimArray(NDArray):
|
||||
@ -68,7 +47,6 @@ class DimArray(NDArray):
|
||||
|
||||
self.proj = proj
|
||||
|
||||
|
||||
def __getitem__(self, indices):
|
||||
if not isinstance(indices, tuple):
|
||||
indices = [indices]
|
||||
@ -336,6 +314,14 @@ class DimArray(NDArray):
|
||||
:param value: NDArray object
|
||||
"""
|
||||
self._array = value._array
|
||||
|
||||
@property
|
||||
def dt(self):
|
||||
a = self.array
|
||||
if a.dtype == np.dtype.datetime:
|
||||
return DateTimeAccessor(a)
|
||||
else:
|
||||
return None
|
||||
|
||||
def member_names(self):
|
||||
"""
|
||||
|
||||
Binary file not shown.
@ -34,6 +34,7 @@ class DimDataFile(object):
|
||||
self.access = access
|
||||
self.ncfile = ncfile
|
||||
self._variables = []
|
||||
self._coordinates = []
|
||||
if not dataset is None:
|
||||
self.filename = dataset.getFileName()
|
||||
self.nvar = dataset.getDataInfo().getVariableNum()
|
||||
@ -44,9 +45,12 @@ class DimDataFile(object):
|
||||
dim_var = DimVariable.factory(v, self)
|
||||
self._variables.append(dim_var)
|
||||
setattr(self, dim_var.name, dim_var)
|
||||
if dim_var._coordinate:
|
||||
self._coordinates.append(dim_var)
|
||||
|
||||
self.arldata = arldata
|
||||
self.bufrdata = bufrdata
|
||||
|
||||
|
||||
def __getitem__(self, key):
|
||||
if isinstance(key, basestring):
|
||||
@ -186,6 +190,25 @@ class DimDataFile(object):
|
||||
Get all variable names.
|
||||
"""
|
||||
return self.dataset.getDataInfo().getVariableNames()
|
||||
|
||||
@property
|
||||
def data_vars(self):
|
||||
"""Get data variables"""
|
||||
vars = []
|
||||
for var in self._variables:
|
||||
if not var._coordinate:
|
||||
vars.append(var)
|
||||
return vars
|
||||
|
||||
@property
|
||||
def coordinates(self):
|
||||
"""Get all coordinates"""
|
||||
return self._coordinates
|
||||
|
||||
@property
|
||||
def coordnames(self):
|
||||
"""Get all coordinate names"""
|
||||
return self.dataset.getDataInfo().getCoordinateNames()
|
||||
|
||||
def read(self, varname, origin=None, size=None, stride=None):
|
||||
"""
|
||||
|
||||
Binary file not shown.
@ -18,6 +18,7 @@ from org.meteoinfo.ndarray import DataType
|
||||
|
||||
import mipylib.numeric as np
|
||||
from .dataarray import DimArray
|
||||
from .dataarray import DateTimeAccessor
|
||||
import mipylib.miutil as miutil
|
||||
import datetime
|
||||
import numbers
|
||||
@ -42,18 +43,21 @@ class DimVariable(object):
|
||||
self._variable = variable
|
||||
self.dataset = dataset
|
||||
self.ncvariable = ncvariable
|
||||
self._coordinate = False
|
||||
if not variable is None:
|
||||
self._name = variable.getName()
|
||||
self.dtype = np.dtype.fromjava(variable.getDataType())
|
||||
self.dims = variable.getDimensions()
|
||||
self.ndim = variable.getDimNumber()
|
||||
self.attributes = variable.getAttributes()
|
||||
self._coordinate = variable.isDimVar()
|
||||
elif not ncvariable is None:
|
||||
self._name = ncvariable.getFullName()
|
||||
self.dtype = ncvariable.getDataType()
|
||||
self.dims = ncvariable.getDimensions()
|
||||
self.ndim = len(self.dims)
|
||||
self.attributes = list(ncvariable.getAttributes())
|
||||
self._coordinate = ncvariable.isCoordinateVariable()
|
||||
else:
|
||||
self._name = None
|
||||
self.dtype = None
|
||||
@ -271,6 +275,10 @@ class DimVariable(object):
|
||||
tlist.append(idx)
|
||||
ranges.append(tlist)
|
||||
k = tlist
|
||||
elif isinstance(k, np.NDArray):
|
||||
onlyrange = False
|
||||
isrange = False
|
||||
ranges.append(k._array)
|
||||
elif isinstance(k, basestring):
|
||||
dim = self._variable.getDimension(i)
|
||||
kvalues = k.split(':')
|
||||
@ -317,7 +325,12 @@ class DimVariable(object):
|
||||
rr = Range(sidx, eidx, abs(step))
|
||||
ranges.append(rr)
|
||||
else:
|
||||
if len(k) > 1:
|
||||
if isinstance(k, np.NDArray):
|
||||
dim = self._variable.getDimension(i)
|
||||
dim = dim.extract(k._array)
|
||||
#dim.setReverse(False)
|
||||
dims.append(dim)
|
||||
elif len(k) > 1:
|
||||
dim = self._variable.getDimension(i)
|
||||
dim = dim.extract(k)
|
||||
#dim.setReverse(False)
|
||||
@ -351,6 +364,19 @@ class DimVariable(object):
|
||||
"""
|
||||
return np.array(self.dataset.read(self.name))
|
||||
|
||||
@property
|
||||
def values(self):
|
||||
"""Read data array"""
|
||||
return np.array(self.dataset.read(self.name))
|
||||
|
||||
@property
|
||||
def dt(self):
|
||||
"""date time accessor"""
|
||||
if self._variable.hasCachedData() and self.dtype == np.dtype.datetime:
|
||||
return DateTimeAccessor(self._variable.getCachedData())
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_pack_paras(self):
|
||||
"""
|
||||
Get pack parameters.
|
||||
@ -602,7 +628,9 @@ class StructureVariable(DimVariable):
|
||||
self._ncvar = self._ncfile.findVariable(self.name)
|
||||
self._variables = []
|
||||
for var in self._ncvar.getVariables():
|
||||
self._variables.append(MemberVariable.factory(NCUtil.convertVariable(var), dataset, self))
|
||||
mvar = MemberVariable.factory(NCUtil.convertVariable(var), dataset, self)
|
||||
self._variables.append(mvar)
|
||||
setattr(self, mvar.short_name, mvar)
|
||||
|
||||
def __getitem__(self, key):
|
||||
if isinstance(key, basestring):
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="config.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Temp\image"/>
|
||||
<Path OpenPath="D:\Temp\grads"/>
|
||||
<Font>
|
||||
<TextFont FontName="YaHei Consolas Hybrid" FontSize="14"/>
|
||||
<LegendFont FontName="宋体" FontSize="12"/>
|
||||
|
||||
@ -173,6 +173,96 @@ public class ArrayDate extends Array {
|
||||
return storage[i.currentElement()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ArrayInt for years of all data
|
||||
* @return Years array
|
||||
*/
|
||||
public Array getYears() {
|
||||
Array r = Array.factory(DataType.INT, this.getShape());
|
||||
IndexIterator iter = this.getIndexIterator();
|
||||
IndexIterator rIter = r.getIndexIterator();
|
||||
while (iter.hasNext()) {
|
||||
rIter.setIntNext(iter.getDateNext().getYear());
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ArrayInt for months of all data
|
||||
* @return Months array
|
||||
*/
|
||||
public Array getMonths() {
|
||||
Array r = Array.factory(DataType.INT, this.getShape());
|
||||
IndexIterator iter = this.getIndexIterator();
|
||||
IndexIterator rIter = r.getIndexIterator();
|
||||
while (iter.hasNext()) {
|
||||
rIter.setIntNext(iter.getDateNext().getMonthValue());
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ArrayInt for days of all data
|
||||
* @return Days array
|
||||
*/
|
||||
public Array getDays() {
|
||||
Array r = Array.factory(DataType.INT, this.getShape());
|
||||
IndexIterator iter = this.getIndexIterator();
|
||||
IndexIterator rIter = r.getIndexIterator();
|
||||
while (iter.hasNext()) {
|
||||
rIter.setIntNext(iter.getDateNext().getDayOfMonth());
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ArrayInt for hours of all data
|
||||
* @return Hours array
|
||||
*/
|
||||
public Array getHours() {
|
||||
Array r = Array.factory(DataType.INT, this.getShape());
|
||||
IndexIterator iter = this.getIndexIterator();
|
||||
IndexIterator rIter = r.getIndexIterator();
|
||||
while (iter.hasNext()) {
|
||||
rIter.setIntNext(iter.getDateNext().getHour());
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ArrayInt for minutes of all data
|
||||
* @return Minutes array
|
||||
*/
|
||||
public Array getMinutes() {
|
||||
Array r = Array.factory(DataType.INT, this.getShape());
|
||||
IndexIterator iter = this.getIndexIterator();
|
||||
IndexIterator rIter = r.getIndexIterator();
|
||||
while (iter.hasNext()) {
|
||||
rIter.setIntNext(iter.getDateNext().getMinute());
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ArrayInt for seconds of all data
|
||||
* @return Seconds array
|
||||
*/
|
||||
public Array getSeconds() {
|
||||
Array r = Array.factory(DataType.INT, this.getShape());
|
||||
IndexIterator iter = this.getIndexIterator();
|
||||
IndexIterator rIter = r.getIndexIterator();
|
||||
while (iter.hasNext()) {
|
||||
rIter.setIntNext(iter.getDateNext().getSecond());
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the value at the specified index.
|
||||
* @param i
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user