对于我的脑筋急转弯,我已经在文档和邮件列表档案中搜索了一段时间,并且很难将处理此聚合所需的步骤放在一起。
CFSR 1 小时数据文件数据来自这里:http ://rda.ucar.edu/datasets/ds094.0/
cdas_20161215_0000_f00000_G4.grib2
cdas_20161215_0000_f00100_G4
cdas_20161215_0000_f00200_G4
cdas_20161215_0000_f00300_G4
etc...
每小时文件声明了 2 个时间维度,一个设置了边界,另一个没有设置。
cdas_20161215_0000_f00300_G4.grib2
double time(time=1);
:units = "Hour since 2016-12-15T00:00:00Z";
:standard_name = "time";
:long_name = "GRIB forecast or observation time";
:calendar = "proleptic_gregorian";
:bounds = "time_bounds";
double time_bounds(time=1, 2);
:units = "Hour since 2016-12-15T00:00:00Z";
:long_name = "bounds for time";
double time1(time1=1);
:units = "Hour since 2016-12-15T00:00:00Z";
:standard_name = "time";
:long_name = "GRIB forecast or observation time";
:calendar = "proleptic_gregorian";
问题是,当我逐步创建每个数据集时,不同的每小时文件会将名称交换为 2 个时间维度名称。因此AggregationExisting
无法找到某些文件的维度名称“时间”,例如在 0300 文件中的 u-component_of_wind_isobaric 变量上,因为它被声明为 time1。
我正在调用的代码:
List<String> variableNames = Arrays.asList("u-component_of_wind_isobaric","u-component_of_wind_height_above_ground","v-component_of_wind_isobaric","v-component_of_wind_height_above_ground","Pressure_reduced_to_MSL_msl","Geopotential_height_isobaric");
NetcdfDataset netcdfDataset = new NetcdfDataset();
//here i'm trying to aggregate on a dimension called 'time'
AggregationExisting aggregationExisting = new AggregationExisting(netcdfDataset, "time", null);
aggregationExisting.addDatasetScan(null,
"/cfsr-gribs/201612/",
"G4.grib2",
null,
null,
NetcdfDataset.getDefaultEnhanceMode(),
"false",
null);
aggregationExisting.persistWrite();
aggregationExisting.finish(new CancelTaskImpl());
GridDataset gridDataset = new GridDataset(netcdfDataset);
writer.setRedefineMode(true);
CFGridWriter2.writeFile(gridDataset, variableNames, gridDataset.getBoundingBox(), null, 1, null, null, 1, true, writer);
时间维度名称问题在 2 个文件中说明:
//cdas_20161215_0000_f00300_G4.grib2
float u-component_of_wind_isobaric(time1=1, isobaric3=37, lat=361, lon=720);
:long_name = "u-component of wind @ Isobaric surface";
:units = "m/s";
:abbreviation = "UGRD";
:missing_value = NaNf; // float
:grid_mapping = "LatLon_Projection";
:coordinates = "reftime time1 isobaric3 lat lon ";
:Grib_Variable_Id = "VAR_0-2-2_L100";
:Grib2_Parameter = 0, 2, 2; // int
:Grib2_Parameter_Discipline = "Meteorological products";
:Grib2_Parameter_Category = "Momentum";
:Grib2_Parameter_Name = "u-component of wind";
:Grib2_Level_Type = "Isobaric surface";
:Grib2_Generating_Process_Type = "Forecast";
//cdas_20161215_0000_f00200_G4.grib2
float u-component_of_wind_isobaric(time=1, isobaric3=37, lat=361, lon=720);
:long_name = "u-component of wind @ Isobaric surface";
:units = "m/s";
:abbreviation = "UGRD";
:missing_value = NaNf; // float
:grid_mapping = "LatLon_Projection";
:coordinates = "reftime time isobaric3 lat lon ";
:Grib_Variable_Id = "VAR_0-2-2_L100";
:Grib2_Parameter = 0, 2, 2; // int
:Grib2_Parameter_Discipline = "Meteorological products";
:Grib2_Parameter_Category = "Momentum";
:Grib2_Parameter_Name = "u-component of wind";
:Grib2_Level_Type = "Isobaric surface";
:Grib2_Generating_Process_Type = "Forecast";
这是我第一次使用 NetCDF 库,所以我正在购买一些预处理工具来合并这些具有这种怪癖的数据集。例如,我可以将所有变量移动到同一时间维度并重命名吗?即使是指向我错过的示例的链接也会有所帮助。否则我猜我会考虑手动删除尺寸并使用 readDataSlice() 手动将数据复制到新的合并文件中。