mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
bugfix for MICAPS MDFS type 11 wind direction data reading
This commit is contained in:
parent
acd9c29262
commit
1305d889ed
@ -312,6 +312,7 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
|
||||
var = new Variable();
|
||||
var.setName("WindSpeed");
|
||||
var.setDataType(DataType.FLOAT);
|
||||
var.setUnits("m/s");
|
||||
var.setDimension(tDim);
|
||||
var.setDimension(zDim);
|
||||
var.setDimension(yDim);
|
||||
@ -321,6 +322,7 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
|
||||
var = new Variable();
|
||||
var.setName("WindDirection");
|
||||
var.setDataType(DataType.FLOAT);
|
||||
var.setUnits("degree");
|
||||
var.setDimension(tDim);
|
||||
var.setDimension(zDim);
|
||||
var.setDimension(yDim);
|
||||
@ -491,15 +493,32 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
|
||||
int index;
|
||||
byte[] bytes = new byte[4];
|
||||
float v;
|
||||
for (int y = yRange.first(); y <= yRange.last(); y += yRange.stride()) {
|
||||
for (int x = xRange.first(); x <= xRange.last(); x += xRange.stride()) {
|
||||
if (this.yReverse)
|
||||
index = (numLat - y - 1) * xNum + x;
|
||||
else
|
||||
index = y * xNum + x;
|
||||
System.arraycopy(dataBytes, index * 4, bytes, 0, 4);
|
||||
v = DataConvert.bytes2Float(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
ii.setFloatNext(v);
|
||||
if (this.type == 11 && varName.equals("WindDirection")) {
|
||||
for (int y = yRange.first(); y <= yRange.last(); y += yRange.stride()) {
|
||||
for (int x = xRange.first(); x <= xRange.last(); x += xRange.stride()) {
|
||||
if (this.yReverse)
|
||||
index = (numLat - y - 1) * xNum + x;
|
||||
else
|
||||
index = y * xNum + x;
|
||||
System.arraycopy(dataBytes, index * 4, bytes, 0, 4);
|
||||
v = DataConvert.bytes2Float(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
v = 360 - (v + 90);
|
||||
if (v < 0)
|
||||
v = v + 360;
|
||||
ii.setFloatNext(v);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int y = yRange.first(); y <= yRange.last(); y += yRange.stride()) {
|
||||
for (int x = xRange.first(); x <= xRange.last(); x += xRange.stride()) {
|
||||
if (this.yReverse)
|
||||
index = (numLat - y - 1) * xNum + x;
|
||||
else
|
||||
index = y * xNum + x;
|
||||
System.arraycopy(dataBytes, index * 4, bytes, 0, 4);
|
||||
v = DataConvert.bytes2Float(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
ii.setFloatNext(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -538,14 +557,32 @@ public class MDFSDataInfo extends DataInfo implements IGridDataInfo, IStationDat
|
||||
double[][] data = new double[numLat][numLon];
|
||||
int index;
|
||||
byte[] bytes = new byte[4];
|
||||
for (int i = 0; i < numLat; i++) {
|
||||
for (int j = 0; j < numLon; j++) {
|
||||
if (this.yReverse)
|
||||
index = (numLat - i - 1) * numLon + j;
|
||||
else
|
||||
index = i * numLon + j;
|
||||
System.arraycopy(dataBytes, index * 4, bytes, 0, 4);
|
||||
data[i][j] = DataConvert.bytes2Float(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
if (this.type == 11 && varName.equals("WindDirection")) {
|
||||
float wd;
|
||||
for (int i = 0; i < numLat; i++) {
|
||||
for (int j = 0; j < numLon; j++) {
|
||||
if (this.yReverse)
|
||||
index = (numLat - i - 1) * numLon + j;
|
||||
else
|
||||
index = i * numLon + j;
|
||||
System.arraycopy(dataBytes, index * 4, bytes, 0, 4);
|
||||
wd = DataConvert.bytes2Float(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
wd = 360 - (wd + 90);
|
||||
if (wd < 0)
|
||||
wd = wd + 360;
|
||||
data[i][j] = wd;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < numLat; i++) {
|
||||
for (int j = 0; j < numLon; j++) {
|
||||
if (this.yReverse)
|
||||
index = (numLat - i - 1) * numLon + j;
|
||||
else
|
||||
index = i * numLon + j;
|
||||
System.arraycopy(dataBytes, index * 4, bytes, 0, 4);
|
||||
data[i][j] = DataConvert.bytes2Float(bytes, ByteOrder.LITTLE_ENDIAN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -21,14 +21,12 @@
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\map\projection\aea_proj.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\map\projection\lcc_proj_tickline.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\micaps\mdfs_6.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\micaps\mdfs_dataframe_type12.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\micaps\mdfs_type11.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\map\projection\aea_proj.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\map\projection\lcc_proj_tickline.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\micaps\mdfs_6.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\micaps\mdfs_dataframe_type12.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\micaps\mdfs_type11.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="config.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Temp\grads"/>
|
||||
<Path OpenPath="D:\Temp\micaps\mdfs"/>
|
||||
<Font>
|
||||
<TextFont FontName="YaHei Consolas Hybrid" FontSize="14"/>
|
||||
<LegendFont FontName="宋体" FontSize="12"/>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user