QuantumATK Forum
QuantumATK => General Questions and Answers => Topic started by: fangyongxinxi on December 13, 2012, 09:07
-
one nc file test.nc
two configurations in it, id, '111' and '222'
I wonder how to use nlread with object_id
I use
nlread('test.nc',BulkConfiguration,'222'), failed
nlread(filename='test.nc',object_id='222') failed
I know how to use nlread with list
but how to use nlread with object_id ?
Thank you~
-
You need to write the full id name, default id's are
gId000, ...
nlread(filename='test.nc',object_id='gID222')
-
kk=nlread(filename='test.nc',object_id='222')[0]
my id full name is '222',
If the above line is: kk=nlread(filename='test.nc',object_id='222')
it's bad, this line shoud add "0"
I wonder why it should follow "0", because the id is unique.
-
This is just a programming detail. Even if the object ID is unique, the return type from nlread is always a list. So, in the case of using object ID the list has one element, that's why you use the 0th element. Having a uniform return type means it's much easier to write general functions.