This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Leo, > i'm using matlab R2008a and netcdf toolbox to read and translate data > from netcdf files from one format to another. Difference is that > dimension names and variable names and data formats are different > (double, float). For example, my original file format is as follow > (with ncdump): dimensions: > > Radial = UNLIMITED ; // (637 currently) > Gate = 426 ; > variables: > double Azimuth(Radial) ; > Azimuth:Units = "Degrees" ; > double Elevation(Radial) ; > Elevation:Units = "Degrees" ; > and destination format should be: > dimensions: > time = 401 ; > range = 250 ; > variables: > float range(range) ; > range:units = "km" ; > range:long_name = "Range from antenna to the centre of each range gate" ; > float time(time) ; > time:units = "hours since 2000-08-18 00:00:00 +00:00" ; > time:long_name = "Decimal hours from midnight UTC to the middle of each ray" ; > time:axis = "T" ; > float azim(time) ; > azim:units = "degrees" ; > azim:long_name = "Azimuth of the end of the ray clockwise from due north" ; > > etc. I can read dimensions of the original file with > > a=NC_origin('Radial'); > > but the result is an ncdim object <79x1 ncdim> of this form: > > a = > > NetCDF_Dimension: 'Radial' > itsLength: 79 > > so i can't just copy it to new netcdf file, i need somehow get the > value of 'itsLength' as a number (i'm getting an error: '??? Undefined > function or method 'finite' for input arguments of type 'ncdim'. Error > in ==> ncdim.ncdim at 70 if ~finite(theDimsize), theDimsize = 0; > end'). Is there a way to read ncdim object and access its parts > (NetCDF_Dimension,itsLength) as a string and number ? Sorry, this is a question that requires some MATLAB expertise, and we don't have that at Unidata. We develop and maintain the netCDF library, but the MATLAB interfaces have been developed by others. In particular, there is a new MATLAB interface to netCDF in R2008b: http://mexcdf.sourceforge.net/ but evidently you don't have that version yet. As stated on the web page above, the netCDF Toolbox is unsupported, and I've been unable to find a mailing list appropriate for your question. > Or there is a simpler way to rtanslate dimensions and variables from > one format to another? If you have relatively small files, you can use ncdump to get a CDL file, edit the types and names in the resulting CDL file using a text editor, then use the ncgen utility to convert the edited CDL file to a binary netCDF file. Another possibility, short of writing a program in one of the language interfaces available for netCDF data (C, Fortran, Java, Perl, Python, Ruby) is to see if a utility program such as ncks from the NetCDF Operators package(NCO) can do what you want: http://www.unidata.ucar.edu/software/netcdf/software.html#NCO Sorry we can't be of more help ... --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: ZXL-616448 Department: Support netCDF Priority: Normal Status: Closed