- 积分
- 1486
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-10-27
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2013-8-6 13:23:38
|
显示全部楼层
MeteoInfo 发表于 2013-8-4 21:17
极坐标至少要知道极点在哪里、每个点的极径和极角。极点可能是Global Attribute里的Latitude和Longitude, ...
王老师,我试着用你meteoinfo下面的netcdf.dll自己读取那个雷达的极坐标nc数据然后进行二次开发显示这类数据,但是在读取的过程中遇到了一些问题,想请教王老师帮忙解答一下····这是C#引用netcdf.dll库函数的说明:
public static class NetCDFInterop
{
[DllImport("netcdf.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int nc_open(string path, CreateMode omode, out int ncidp);
[DllImport("netcdf.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int nc_close(int ncidp);
[DllImport("netcdf.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int nc_inq_varid(int ncid, string nvars, out int varid);
[DllImport("netcdf.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int nc_get_var_double(int ncid, int varid, double[,] ip);
[DllImport("netcdf.dll", CallingConvention = CallingConvention.Cdecl )]
public static extern int nc_get_var_float(int ncid, int varid, float[,] ip);
[DllImport("netcdf.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int nc_inq(int ncid, out int ndims, out int nvars, out int ngatts, out int unlimdimid);
[DllImport("netcdf.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int nc_inq_dim(int ncid, int dimid, string name, out int length);
[DllImport("netcdf.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int nc_inq_dimname(int ncid, int dimid, StringBuilder name);
[DllImport("netcdf.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int nc_inq_dimid(int ncid, string name, out int dimid);
[DllImport("netcdf.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int nc_inq_dimlen(int ncid, int dimid, out int length);
[DllImport("netcdf.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int nc_inq_ndims(int ncid, out int ndims);
[DllImport("netcdf.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int nc_inq_nvars(int ncid, out int nvars);
[DllImport("netcdf.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int nc_inq_varname(int ncid, int varid, StringBuilder name);
[DllImport("netcdf.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int nc_inq_varndims(int ncid, int varid, out int ndims);
[DllImport("netcdf.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int nc_inq_vardimid(int ncid, int varid, int[] dimids);
[DllImport("netcdf.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int nc_inq_var_fill(int ncid, int varid, out int no_fill, out object fill_value);
public enum CreateMode : int
{
NC_NOWRITE = 0,
/// read & write
NC_WRITE = 0x0001,
NC_CLOBBER = 0,
/// Don't destroy existing file on create
NC_NOCLOBBER = 0x0004,
/// argument to ncsetfill to clear NC_NOFILL
NC_FILL = 0,
/// Don't fill data section an records
NC_NOFILL = 0x0100,
/// Use locking if available
NC_LOCK = 0x0400,
/// Share updates, limit cacheing
NC_SHARE = 0x0800,
NC_64BIT_OFFSET = 0x0200,
/// Enforce strict netcdf-3 rules
NC_CLASSIC = 0x0100,
/// causes netCDF to create a HDF5/NetCDF-4 file
NC_NETCDF4 = 0x1000
}
然后我用以下代码读取数据:
int i;
string path = "radar.nc";
NetCDFInterop.nc_open(path,NetCDFInterop.CreateMode.NC_NOWRITE,out i);
int ndims_in, nvars_in, ngatts_in, unlimdimid_in;
NetCDFInterop.nc_inq(i, out ndims_in, out nvars_in, out ngatts_in, out unlimdimid_in);
int azimuth_varid, gate_varid, filtered_Intensity_varid;
NetCDFInterop.nc_inq_varid(i, "Azimuth",out azimuth_varid);
NetCDFInterop.nc_inq_varid(i, "GateWidth",out gate_varid);
NetCDFInterop.nc_inq_varid(i, "Filtered_Intensity(Horizontal)", out filtered_Intensity_varid);
double[,] azimuth_in=new double[865,1];
double[,] gate_in=new double[480,1];
float [,] ppidata=new float[865,480];
NetCDFInterop.nc_get_var_double(i,azimuth_varid,azimuth_in);
NetCDFInterop.nc_get_var_double(i, gate_varid, gate_in);
NetCDFInterop.nc_get_var_float(i, filtered_Intensity_varid, ppidata);
但是读到红色代码这个地方的时候就报错了,提示的是ppidata无法获取局部变量或参数,索引超出了数组界限,读不出ppidata数据呢,王老师在您开发这个过程中这个问题是怎么解决的呢?希望王老师教教学生····嘿嘿
这是上次传的数据
radar.nc
(1.6 MB, 下载次数: 1)
|
|