// // code snippet for wrfvdfcreate. // { VDC vdc(VDC::NETCDF4); // Open the VDC master file for writing. Have to specify how // many compression ratios we will have // status = vdc.Initialize(masterpath, "w"); // Set up compression parameters. We will use the same ones for all // variables. Ditto for boundary periodicity // vdc.SetCompressionBlock(opt.bs, opt.wname, opt.wmode, opt.cratios()); vdc.SetPeriodicBoundary(opt.periodic); // All 3D variables have the same dimensions, named "x", "y", // and "z", plus time, "t" // vector dimnames; dimnames.push_back("x"); dimnames.push_back("y"); dimnames.push_back("z"); dimnames.push_back("t"); // Dimension lenths. // vector dimlens; dimlens.push_back(wrf.dims[0]); dimlens.push_back(wrf.dims[1]); dimlens.push_back(wrf.dims[2]); dimlens.push_back(wrf.numts); // Identify the axis for each dimension // vector axes; axes.push_back(VDC:X); axes.push_back(VDC:Y); axes.push_back(VDC:Z); axes.push_back(VDC:T); // Each dimension in the VDC has a 1D coordinate variable of the same // name. We also need to define the multi-dimensional, time varying // "ELEVATION" coordinate variable. // vector coordnames; coordnames.push_back(dimnames[0]); coordnames.push_back(dimnames[1]); coordnames.push_back("ELEVATION"); coordnames.push_back(dimnames[3]); // Define dimensions and 1D coordinate variable associated with the // dimension. The DefineDimension() method both defines a dimension // name and length, as well as a 1D coordinate variable, of the same // name, with uniform sampling. // // Here we only have 4: x, y, z, and time (t) // for (int i=0; i ele_dim_names; ele_dim_names.push_back(dim_names[0]); ele_dim_names.push_back(dim_names[1]); ele_dim_names.push_back(dim_names[3]); vdc.DefineCoordVar( coordnames[2], ele_dim_names, "meters", axes[2], VDC::FLOAT32, true ); // Finally define time coordinate variable, which in general has non // uniform sampling // vector time_dim_names; time_dim_names.push_back(dim_names[3]); vdc.DefineCoordVar( coordnames[3], time_dim_names, "seconds", axes[3], VDC::FLOAT32, false ); // Now define each of the 3D variables. We would need to do similar // thing for each 2D variable... // Again not units, but this time the variables are compressed // for (int i=0; i