0

我已经从noaa 网站下载了这个文件

使用 netcdfAll 我可以看到变量元数据

[int GaussLatLon_Projection;
  :grid_mapping_name = "latitude_longitude";
  :earth_radius = 6371229.0; // double
, float lat(lat=576);
  :units = "degrees_north";
, float lon(lon=1152);
  :units = "degrees_east";
, double reftime(reftime=124);
  :units = "Hour since 1979-01-01T00:00:00Z";
  :standard_name = "forecast_reference_time";
  :long_name = "GRIB reference time";
  :calendar = "proleptic_gregorian";
, double time(reftime=124, time=6);
  :units = "Hour since 1979-01-01T00:00:00Z";
  :standard_name = "time";
  :long_name = "GRIB forecast or observation time";
  :calendar = "proleptic_gregorian";
  :bounds = "time_bounds";
, double time_bounds(reftime=124, time=6, 2);
  :units = "Hour since 1979-01-01T00:00:00Z";
  :long_name = "bounds for time";
, float Precipitation_rate_surface_Mixed_intervals_Average(reftime=124, time=6, lat=576, lon=1152);
  :long_name = "Precipitation rate (Mixed_intervals Average) @ Ground or water surface";
  :units = "kg.m-2.s-1";
  :abbreviation = "PRATE";
  :missing_value = NaNf; // float
  :grid_mapping = "GaussLatLon_Projection";
  :coordinates = "reftime time lat lon ";
  :Grib_Statistical_Interval_Type = "Average";
  :Grib_Variable_Id = "VAR_0-1-7_L1_Imixed_S0";
  :Grib2_Parameter = 0, 1, 7; // int
  :Grib2_Parameter_Discipline = "Meteorological products";
  :Grib2_Parameter_Category = "Moisture";
  :Grib2_Parameter_Name = "Precipitation rate";
  :Grib2_Level_Type = 1; // int
  :Grib2_Level_Desc = "Ground or water surface";
  :Grib2_Generating_Process_Type = "Forecast";
]

我知道测量时间是 6 小时参考时间的组合reftime,每小时偏移量由time. 如果我在 Panoply(或在 python 中使用 pygrib)打开 grib 文件,我可以看到测量时间如下

1979-01-01T00:00:00Z - 1979-01-01T00:00:00Z
1979-01-01T00:00:00Z - 1979-01-01T00:01:00Z
1979-01-01T00:00:00Z - 1979-01-01T00:02:00Z
1979-01-01T00:00:00Z - 1979-01-01T00:03:00Z
1979-01-01T00:00:00Z - 1979-01-01T00:04:00Z
1979-01-01T00:00:00Z - 1979-01-01T00:05:00Z
1979-01-01T00:00:00Z - 1979-01-01T00:06:00Z
1979-01-01T00:06:00Z - 1979-01-01T00:06:00Z
...

Panoply 和 pygrib 似乎显示了参考时间和预测时间。但是,如果我使用 netcdfAll 读取 Java 文件(请参阅底部的代码),我看不到重复的时间戳。我大概只看到预测时间,因为 netcdfAll 正在过滤掉参考测量值。那是对的吗?

根据 Noaa 时间序列参考,应忽略 f00 参考时间。那么 netcdfAll 过滤掉参考时间测量值有关系吗? https://www.ncdc.noaa.gov/sites/default/files/attachments/CFSR-Hourly-Timeseries.pdf

NetcdfFile ncfile = NetcdfFile.open(filename);

System.out.println(ncfile.getVariables().toString());

String varName = "Precipitation_rate_surface_Mixed_intervals_Average";
String latName = "lat";
String lonName = "lon";
String timeName = "time";
String reftimeName = "reftime";
String time_boundsName = "time_bounds";

Variable prate = ncfile.findVariable(varName);
if (null == prate) {
    System.out.println("variable does not exist: "+varName);
    return null;
}

Variable lat = ncfile.findVariable(latName);
Variable lon = ncfile.findVariable(lonName);
Variable time = ncfile.findVariable(timeName);
Variable reftime = ncfile.findVariable(reftimeName);
Variable time_bounds = ncfile.findVariable(time_boundsName);

ZonedDateTime basetime = ZonedDateTime.parse("1979-01-01T00:00:00Z");

try {
        // reftime + time = hours since 1979-01-01T00:00:00Z
        int index_lat = 0;
        int index_lon = 0;

        int[] shape = vars.prate.getShape();

        Array data_timeAll = vars.time.read(); // "reftime, hrs since ref (0-6)"
        Array data_timeboundsAll = vars.time.read(); // "reftime, hrs since ref (0-6)"

        // loop reftime
        for(int index_reftime = 0; index_reftime < shape[0]; index_reftime++) {

        // loop time 
            for(int index_time = 0; index_time < shape[1]; index_time++) {
                // reftime(124), time(6), lat(576), lon(1152)
                Array data = vars.prate.read(
                index_reftime + "," +
                index_time + ", 0, 0");

                Array data_lat = vars.lat.read("0");
                Array data_lon = vars.lon.read("0");
                Array data_time = vars.time.read(
                index_reftime + "," + index_time); // "reftime, hrs since ref (0-6)"
                Array data_reftime = vars.reftime.read(Integer.toString(index_reftime));

                System.out.println("----------------");
                System.out.println(index_reftime + "," + index_time);

                NCdumpW.printArray(data.reduce(), "prate", System.out, null);
                NCdumpW.printArray(data_reftime.reduce(), "reftime", System.out, null);

                Integer val_reftime = data_reftime.getInt(data_reftime.getIndex().set(0));
                System.out.println(basetime.plusHours(val_reftime).toString());
                System.out.println(basetime.plusHours(val_reftime+index_time).toString());


                System.out.println(data_timeAll.getDouble(data_timeAll.getIndex().set(index_reftime,index_time)));
                System.out.println(basetime.plusHours(data_timeAll.getInt(data_timeAll.getIndex().set(index_reftime,index_time))).toString());

                System.out.println("=>");
                System.out.println(data_timeboundsAll.shapeToString());
                System.out.println(data_timeboundsAll.getDouble(data_timeAll.getIndex().set(index_reftime,index_time)));
                System.out.println(basetime.plusHours(data_timeboundsAll.getInt(data_timeboundsAll.getIndex().set(index_reftime,index_time))).toString());
            }
        }

} finally {
    if (null != vars.ncfile) try {
        vars.ncfile.close();
    } catch (IOException ioe) {
        System.out.println(ioe);
    }
}

    Variable lat = ncfile.findVariable(latName);
    Variable lon = ncfile.findVariable(lonName);
    Variable time = ncfile.findVariable(timeName);
    Variable reftime = ncfile.findVariable(reftimeName);
    Variable time_bounds = ncfile.findVariable(time_boundsName);
4

0 回答 0