[ncl-talk] new variables from rows

Rashed Mahmood rashidcomsis at gmail.com
Sun Jul 23 04:51:22 MDT 2017


Hi Damjan,
The attached script would read variable names, units and data from the
file, and write in a netcdf file. It still needs to specify number of
header lines, and the line numbers for variable names and units.

Since the variable and unit names in the text files has double quotes, I
had to add a "tric" using two do loops to get rid of double quotes from
individual strings (lines:22-36, Perhaps there is some proper way for it
which I am not aware of).

The script seems to work fine, I think!. Attached are input,output and the
script files.

hope that helps,
Rashed

Date: Fri, 21 Jul 2017 16:50:07 +0200
From: Damjan Jeli? <damjan.jelic at fmf.uni-lj.si>
Subject: [ncl-talk] new variables from rows
To: ncl-talk at ucar.edu
Message-ID: <81b23a5fb192458c543a235e55871440 at fmf.uni-lj.si>
Content-Type: text/plain; charset="utf-8"

Dear NCL support,

i have txt files (attached) containing 35 different variables which im
trying to save in netcdf format. current problem is that i need to
specify every variable on its own and it is not elegant (attached) and
later on it will be problem since columns will be rearranged in random
order from time to time.
Can it be done somehow like this:
.data=asciiread(...
....
variable_5 = (str_get_field(data(1::),5,","))
print(variable_5(0)); which is variable name of column 5
print(variable_5(0))=variable_5(3:end)

or in written form:
i load data, ignore first row,
read data by columns
use first row as new variable name
use second row tu set units
skip 3. row and use all the rest as data.

Kind regards,
Damjan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170723/85efb30c/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: text_example_DJelic.ncl
Type: application/octet-stream
Size: 2610 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170723/85efb30c/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: text_file_Damjan_Jelic
Type: application/octet-stream
Size: 9515 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170723/85efb30c/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_file.nc
Type: application/x-netcdf
Size: 8296 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170723/85efb30c/attachment.nc 


More information about the ncl-talk mailing list