Thanks all for your suggestions. As you can probably tell I am quite green when it comes to working with data in anything other than Excel files! Fortunately I am coming along faster than I thought I would.
Ansley, your suggestion to work this from the Matlab side of things seems to be the winner. Here's what I ended up doing:
>> missing = netcdf.getatt(ncid, varid, 'missing_value')
missing =
-1.0000e+34
>> variable = netcdf.getvar(ncid, varid) ;
>> variable( variable == missing ) = NaN ;
Totally easy... Once it's all figured out!
Also, Ned, thanks for the heads up about ncgen. I'm sure I'll get some use out of that down the road.
Sam Rabin Graduate student Princeton University Ecology & Evolutionary Biology
On Jun 21, 2011, at 12:14 PM, Ansley Manke wrote:
Hi -
I don't know matlab, but I find it hard to imagine that it couldn't
handle netCDF files that have some other missing-data flag. Aren't
there tools within Matlab and its NetCDF handling code to do
something with the missing-data flag in the netCDF file?
A quick Google search turned up this, which seems to have some
commands to do this. Look for "Replace Missing Numbers (if
necessary)"
http://www.mathworks.com/matlabcentral/fileexchange/26644-reading-and-animating-a-netcdf-file-of-sea-surface-temperature/content/NetCDF_and_SeaSurfaceTemperatureFiles/read_sst.m
On 6/21/2011 7:03 AM, Sam Rabin wrote:
Thanks folks! I will give this a try. My backup plan
is to export the data as an ASCII file, then use a text editor to
find-and-replace all missing values with NaN, then just import
that into MatLab.
And yes, of course it turns out I do have missing(). I
must have misinterpreted the output I got when I used the
command incorrectly.
Thanks again,
Sam
Rabin
Graduate student
Princeton University
Ecology & Evolutionary Biology
On Jun 20, 2011, at 8:16 PM, Ryo Furue wrote:
Hi,
| > Hello! I am trying to analyze a NetCDF file in
MatLab, and
| > I would like to change all "missing" values in
the dataset
| > to NaN for compatibility. This would probably be
trivial
| > if the missing()
[. . .]
| Perhaps somebody can
| tell us whether the NCO operators will let you do
this.
It seems to me that you may be able to trick ncap2 into
doing that. I say this because I don't see a legitimate
way to generate a NaN in the ncap2 language. If ncap2
passes values to its math backend without checking,
things like "sqrt(-1.0)" and "0.0/0.0" may generate
NaNs.
I haven't tested this idea.
Regards,
Ryo
|