Re: Writing non-string variable attributes to netcdf files

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu Jan 20 2011 - 18:16:23 MST

NCL does not write any numeric types as strings

================
    z = ispan(1,10,1)
    z@pi = 3.14159 ; float
    z@test = 123 ; integer
    z@foo = 1d3 ; double
    z@apple = 5.0 ; float

    print(z)

    ncdf = addfile("andrew.nc", "c")
    ncdf->Z = z

=================
ncdump andrew.nc
==================
netcdf andrew {
dimensions:
        ncl0 = 10 ;
variables:
        int Z(ncl0) ;
                Z:apple = 5.f ;
                Z:foo = 1000. ;
                Z:test = 123 ;
                Z:pi = 3.14159f ;
data:

  Z = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ;
}

On 1/20/11 5:35 PM, Andrew Monaghan wrote:
> Hello,
>
> I'm creating a netcdf file in which some of the variable attributes are
> real numbers (as opposed to strings), but when they are written to the
> netcdf output file with ncl, they have quotes around them. For example:
>
> Lambert_Conformal:longitude_of_central_meridian = "297." ;
>
> But what I want is (no quotes around 297):
>
> Lambert_Conformal:longitude_of_central_meridian = 297. ;
>
>
> I assume that most software can probably distinguish whether an
> attribute should be a real or a string value based on the attribute
> name, as long as its a standard cf-compliant attribute name. Therefore,
> having quotes around a real numbered attribute likely isn't an issue
> when reading the netcdf file into another piece of software. However,
> this isn't the case when reading netcdf files into ArcGIS -- it appears
> that ArcGIS requires that real-numbered attribute values not have
> quotes; otherwise any attribute with quotes is assumed to be a string
> and the data arrays are subsequently geo-located in the wrong place.
>
> Is there any way, in ncl, to write out certain attributes in netcdf
> files so that they do not have quotes around them?
>
> Thanks in advance for any insight you can provide.
>
> Sincerely,
> Andy Monaghan
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Jan 20 18:16:29 2011

This archive was generated by hypermail 2.1.8 : Tue Jan 25 2011 - 14:22:15 MST