读取gr2中的数据
public static void main(String[] args){
int[] origin = {0,0,0};
int[] size = {1,430,516};
Array data = getDataFromNC(filepath,str,origin,size)
float[][][] data1 = (float[][][]) data.copyToNDJavaArray();
}
private static Array getDataFromNC(String filepath,String varname,int[] origin,int[] size){
try{
int len1 = origin.length;
int len2 = size.length;
if(len1>0 && len2>0 && (len1==len2)){
NetcdfFile ncfile = null;
Array data = null;
try{
ncfile = NetcdfFile.open(filepath);
Variable v = ncfile.findVariable(varname);
if(null == v)return null;
try{
data = v.read(origin,size);
return data;
}catch(IOException ioe){
ioe.printStackTrace();
}
}catch(IOException ioe){
ioe.printStackTrace();
}finally{
if(null!=ncfile)try{
ncfile.close();
}catch(IOException ioe){
ioe.printStackTrace();
}
}
}else{
System.out.println("输入的参数不合法");
}
}catch(Exception e){
e.printStackTrace();
}
return null;
}