How to run netcdf.defVarFill for a variable defined as 'float'
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I am using Matlab 7.14.0.739 (R2012a) and I need to create forcing data for my model in NetCDF that should look something like this:
variables:
float T2D(Time, south_north, west_east) ;
T2D:layer_top = 0.f ;
T2D:layer_bottom = 0.1f ;
T2D:units = "K" ;
T2D:_FillValue = -1.e+36f ;
The NetCDF file is created like this:
ncid = netcdf.create(filenc,'NETCDF4');
... and this is how I am currently writing my Matlab script:
% Surface temperature
varid_t2d = netcdf.defVar(ncid,'T2D','float',dimid_west_east,dimid_south_north,dimid_Time]);
netcdf.putAtt(ncid,varid_t2d,'layer_top',0);
netcdf.putAtt(ncid,varid_t2d,'layer_bottom',0.1);
netcdf.putAtt(ncid,varid_t2d,'units','K');
netcdf.defVarFill(ncid,varid_t2d,false,-1.e+36);
This is the error message I get when running it:
Error using netcdflib
The fill value datatype class 'double' does not match the netCDF datatype for T2D.
Error in netcdf.defVarFill (line 32)
netcdflib('defVarFill',ncid,varid,noFillMode,fillvalue);
Error in noah2d_text_to_netcdf (line 164)
netcdf.defVarFill(ncid,varid_t2d,false,-1.e+36);
If I change "netcdf.defVar" line to 'double':
varid_t2d = netcdf.defVar(ncid,'T2D','double',...)]
the script runs fine!
Is there a way I can run "netcdf.defVarFill" for a variable which is originally defined as 'float'?
Thanks
0 Commenti
Risposta accettata
John
il 13 Ago 2012
If your netCDF variable is single precision, then your fill value must also be given as single precision, so
netcdf.defVarFill(ncid,varid_t2d,false,single(-1e+36));
Più risposte (0)
Vedere anche
Categorie
Scopri di più su NetCDF in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!