[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #LHC-295018]: ncgen: formatting small floats



Hello Jonny,

You don't mention which version of netCDF/netCDF utilities you are using, but 
assuming they are a modern version then you should be fine.  Both ncgen and 
ncdump are capable of using exponential format for representing extreme 
floating-point numbers.  Consider the following cdl file:

netcdf fp_test {
dimensions:
     latitude = 2 ;

variables:
     float latitude(latitude) ;

data:

     latitude = 2.5e-20, 0.00000000000000000000123456 ;

}

If I generate a netCDF file using `ncgen -b fp_test.cdl`, and then inspect the 
contents with `ncdump fp_test.nc`, I see the following:

netcdf fp_test {
dimensions:
        latitude = 3 ;
variables:
        float latitude(latitude) ;
data:

 latitude = 2.5e-20, 1.23456e-21 ;
}

I hope this helps; have a great day, let me know if any issues arise!

-Ward

> Hi.
> 
> I use a software package called IGOR Pro, which has no native netCDF
> support. So I'm writing some tools to load/create netCDF files this
> thanks to the netCDF library's and ncgen/ncdump. This generally works
> well, but I've been thinking about trying to conserve data integrity as
> much as possible during conversion to netCDF.
> 
> What I don't get a feel for is how ncgen deals with float and double
> data types. I can output number in decimal format with the correct
> number of sig figs, but if we consider the value 1.23456e-20, you need
> over 20 sig figs to represent that in decimal format in the CDL file
> (0.0000000000000000000123456). Does ncgen deal with this? Can it use
> exponential format with the "correct" number of significant figures?
> 
> Thanks
> 
> Jonny
> 
> --
> 
> =======================================================
> Dr Jonathan Crosier
> NCAS Weather Scientist
> School of Earth, Atmospheric & Environmental Sciences
> The University of Manchester
> Simon Building, Oxford Road
> Manchester
> M13 9PL
> 
> tel: +44 161 306 8398
> fax: +44 161 306 3951
> 
> 

Ticket Details
===================
Ticket ID: LHC-295018
Department: Support netCDF
Priority: Normal
Status: Closed