NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
I have written a preliminary version of a matlab/fan interface. The two utilities, nc2mat and mat2nc, are mex-file analogs to the fan utilities nc2text and text2nc. I would like to submit it for inclusion in the netcdf contrib library if there is interest. These utilities supplement the capabilities of the existing mexcdf in much the same way that fan supplements the netcdf library. These utilities are still quite crude, but they seem to work for me. For the most part, I simply wrote a mex file interface to nc2text and text2nc, so they should have the same capabilities and limitations of the fan utilities. Of course, these are preliminary versions, so they have additional limitations imposed on them due to a lack of time and programming skill on my part. The read utility, nc2mat, is fairly complete---it is the one I use most often. It was also the simple to write since both fan and matlab store data internally as double precision elements. There are some enhancements that I would like to make to nc2mat. Primarily I would like to modify how the internal fan function replaces bad data (missing values, values < valid_min, values > valid_max). I would like to replace these with NaN, -Inf, +Inf, but I do not know how to get the representations of them in C code. I guess I could try nan = 0./0.; minf = -1./0.; pinf = 1./0., but that is not appealing to me. Any suggestions? I hope that there is a common IEEE arithmetic way to do this, but I am pretty sure that it will be system dependent. (I am using a sun with the Solaris operating system.) For completeness (and as a programming exercise for myself) I also wrote a write utility, mat2nc, which may need further improvement before it will be very useful to matlab users. Part of the problem is a limitation in my implementation, and part of it is a limitation in the underlying fan utilities. For instance one cannot use the fan utility text2nc to do the following: echo '[1 2 3; 4 5 6]' | text2nc 't.nc newVariable' This makes more sense in the context of matlab where one might want to write new data to a netCDF file; i.e., x = [1 2 3; 4 5 6]; mat2nc('t.nc newVariable', x); But this is almost an ill-defined case, as netCDF is not really aimed at such dynamic creation of data. Of course, in matlab I can use the mexcdf utility. The issue brings up a generic netCDF question on what is a good convention for creating arbitrary dimensions. For instance, if I have a 5 by 10 matrix, netCDF requires that I have a dimension of length five, and a dimension of length ten before I can store the matrix. I know one can do this, (by having dimensions d5 = 5, d10 = 10), but what is a good way to do it? Is there a netCDF convention for it? Thanks and let me know if there is interest in nc2mat and mat2nc. Phil ------------------------------------------------------------------ Philip W. Miller pwmiller@xxxxxxxxxxxxxxx Lockheed Martin/GES, MS 137-232 199 Borton Landing Rd PO Box 1027 Moorestown, NJ 08057-0927 voice: (609) 722-6979 fax: (609) 231-5100 ------------------------------------------------------------------
netcdfgroup
archives: