Author Topic: How to use 'nlread' with 'object_id'  (Read 3126 times)

0 Members and 1 Guest are viewing this topic.

Offline fangyongxinxi

  • QuantumATK Guru
  • ****
  • Posts: 143
  • Reputation: 0
    • View Profile
How to use 'nlread' with 'object_id'
« 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~

Offline kstokbro

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 392
  • Reputation: 13
    • View Profile
    • QuantumWise
Re: How to use 'nlread' with 'object_id'
« Reply #1 on: December 13, 2012, 14:52 »
You need to write the full id name, default id's are
gId000, ...
nlread(filename='test.nc',object_id='gID222')

Offline fangyongxinxi

  • QuantumATK Guru
  • ****
  • Posts: 143
  • Reputation: 0
    • View Profile
Re: How to use 'nlread' with 'object_id'
« Reply #2 on: December 13, 2012, 15:23 »
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.
« Last Edit: December 13, 2012, 15:26 by fangyongxinxi »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: How to use 'nlread' with 'object_id'
« Reply #3 on: December 13, 2012, 16:41 »
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.