Dear Forum,
I am a little confused about how to properly use the nlread function.
I have done a major calculation on a quite big system (120 atoms) which took days on my computer :), but I would like to redo the DOS and transmission.
I got this example of how to load the "device configuration" from the .nc file that was saved to along the way
device_configuration = nlread('file.nc', DeviceConfiguration)[-1]
I am not quite sure why the object type/name is DeviceConfiguration. Where can I see a list of suitable names usable for nlread?
I would expect it to be 'device_configuration' since that is how it got saved in the original script (the standard when doing the script out the the Script Generator), or otherwise 'Device Configuration' as shown in the the VNL window when clicking on my .nc file.
Otherwise, I can refer to the object handle eg. 'gID000', right?
Lastly I do not know what the [-1] means. I learned that nlread gets a list (array?) and so you need to specify the element that you want to use, but how can that be [-1] ? In the VNL window I have two objects, 'Device Configuration' and 'Density of States' (the one I wish to redo). I would expect that the device configuration would be [ 0 ] and DOS would be [1]. Is this correct/wrong?
Thank you a lot!
Kaspar
Negative index, yes this is very standard Python.
As for nlread, it's fairly transparent: any class you can nlsave, can be nlread. So that's all the Analysis stuff you see in the Script Generator, basically, and configurations of course, plus a few more exotic things.
But there is nlinspect. You can do this on a NC file:
from NL.IO.NLSaveUtilities import nlinspect
nlinspect("file.nc")
and you might see something like
array([['Bandstructure', 'gID001'],
['Bandstructure', 'gID004'],
['BulkConfiguration', 'gID000'],
['BulkConfiguration', 'gID003'],
['MullikenPopulation', 'gID002'],
['MullikenPopulation', 'gID005']],
dtype='|S18')
Then you know what's in the file. You can also do
from NL.IO.NLSaveUtilities import nlinspect
file_objects = nlinspect("file.nc")
# Make a data dictionary from the NC file
data_dict = {}
for file_object in file_objects:
object_type = file_object[0]
id = file_object[1]
data_dict[id] = { 'data' : nlread("file.nc", object_id=id)[0], 'type' : object_type}
# Print data dictionary
data_dict
This might produce something like
{'gID000': {'data': <NL.CommonConcepts.Configurations.BulkConfiguration.BulkConfiguration object at 0x000000000D845C18>,
'type': 'BulkConfiguration'},
'gID001': {'data': <NL.Analysis.Bandstructure.Bandstructure object at 0x000000000DB6ED68>,
'type': 'Bandstructure'},
'gID002': {'data': <NL.Analysis.MullikenPopulation.MullikenPopulation object at 0x000000000DB6E3C8>,
'type': 'MullikenPopulation'},
'gID003': {'data': <NL.CommonConcepts.Configurations.BulkConfiguration.BulkConfiguration object at 0x000000000DB6EDD8>,
'type': 'BulkConfiguration'},
'gID004': {'data': <NL.Analysis.Bandstructure.Bandstructure object at 0x000000000DB6EC88>,
'type': 'Bandstructure'},
'gID005': {'data': <NL.Analysis.MullikenPopulation.MullikenPopulation object at 0x000000000DB6EEB8>,
'type': 'MullikenPopulation'}}
which could be useful to keep track of objects etc.