Christine Smit - 2014-04-09

Cool. Thanks! I searched through the ncap2 documentation, but didn’t find the type() function. I knew that it had to be there somewhere.

Christine

From: henryb@hush.com [mailto:henryb@hush.com]
Sent: Wednesday, April 09, 2014 4:15 AM
To: Smit, Christine E. (GSFC-610.2)[TELOPHASE CORP]
Subject: Fwd: [nco:discussion] Feature request: direct type specification in ncap2

----- Forwarded message from "henry Butowsky" hmb@users.sf.net<mailto:hmb@users.sf.net> -----
Date: Mon, 07 Apr 2014 19:46:07 +0000
Subject: [nco:discussion] Feature request: direct type specification in ncap2
To: "[nco:discussion] " 9829@discussion.nco.p.re.sf.net<mailto:9829@discussion.nco.p.re.sf.net>

Hi Christine,
some of the functionality you want is already present

the function type() returns an integer indicating the type
e.g

ncap2 -v -O -s 'four=4.0; mtype=four.type();print(mtype);' in.nc foo.nc

The values it returns are defined as defined as ram variables:

BYTE, CHAR, SHORT, INT FLOAT DOUBLE

UBYTE USHORT UINT INT64 UINT64

In addition there are the convert to types:
netcdf3:
float(),double(),long(),int, short()
netcdf4:
ushort(), uint(),uint64(), ubyte(),byte(),char()

e.g

ncap2 -v -O -s 'four=4.0;fouri=four.int(); print(fouri);' in.nc foo.nc

also there is the convert() function but at the moment it crashing out:
I shall look at this this week and get it fixed

ncap2 -v -O -s 'four=4.0;fourf=four.convert(__FLOAT); print(fourf);' in.nc foo.nc

You can use the constants in an if statement e.g:

/******

four=4.0;

if( four.type() == __DOUBLE )

print(" iam a double\n")

/******/

Ill text on the forum when I get convert() working

...Henry


Feature request: direct type specification in ncap2https://sourceforge.net/p/nco/discussion/9829/thread/b2f023ca/?limit=25#e70b


Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/nco/discussion/9829/

To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/