Re: a coordinate made up from an array of strings

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Tue Jun 08 2010 - 12:25:46 MDT

Hi Mark,

Besides the fact that coordinate arrays must be monotonic (enforced by
NCL, but only a convention that can be violated in NetCDF), the NetCDF
API (prior to the full NetCDF 4 API) does not have an actual "string"
type. It has arrays of characters. You can store an array of strings
as a variable in NetCDF using a 2-D array of characters with the 2nd
dimension set to the length of the longest string, being careful to
ensure that the empty bytes past the length of the shorter strings are
set to the NULL byte '\0'. However, NetCDF restricts attributes to no
more than a single dimension array. Therefore it is not possible to
store an array of strings as an attribute unless you flatten them into
a 1d array that you will need to unpack when reading.
  -dave

On Jun 8, 2010, at 5:49 AM, Dennis Shea wrote:

> Mark
>
> By (Unidata/netCDF) definition, a coordinate array
> must be a monotonically {in/de}creasing one-dimensional array.
>
> D
>
> On 6/8/10 1:30 AM, mark collier wrote:
>> Hi,
>> I'm wondering why I cannot write out a coordinate which is made up
>> from an array of strings like in the following?
>>
>> load "/home/599/mac599/marsland/all_scripts.ncl"
>>
>> begin
>>
>> txtlabel =
>> (/"bering_strait","denmark_strait","canadian_archipelago"/)
>>
>> time = (/1.0,2.0,3.0/)
>>
>> transports=new((/dimsizes(time),dimsizes(txtlabel)/),float)
>>
>> transports!0 = "time"
>> transports!1 = "transport"
>>
>> transports&time = time
>> transports&transport = txtlabel
>>
>> output = addfile("test_coo.nc","c")
>> output->transports=transports
>>
>> end
>>
>> Regards,
>> Mark.
>> _______________________________________________
>> 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

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jun 8 12:25:51 2010

This archive was generated by hypermail 2.1.8 : Thu Jun 24 2010 - 14:10:27 MDT