Author Topic: How to del the data in nc file  (Read 12458 times)

0 Members and 1 Guest are viewing this topic.

Offline eastnobil

  • Regular QuantumATK user
  • **
  • Posts: 19
  • Reputation: 0
    • View Profile
How to del the data in nc file
« on: June 7, 2010, 11:41 »
With the ATK SE 2010.02 manual, the commond of 'nlread','nlsave'and 'nlprint' is for operating the relevant ATK files. But the wrong datas or unnecessary data like the trasmission spectrum,Molecular energy spectrum etc. will be deleted for reducing the storage space of nc file or easily dealing with a series of data after finishing ATK running. What can I do for that operation?

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5574
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: How to del the data in nc file
« Reply #1 on: June 7, 2010, 11:56 »
This is currently not possible directly. You can of course always read all the data you want to save from one file and write to a new one.

It's a nice feature request, to be able to delete the data sets easily. We will make a note of it!
« Last Edit: June 7, 2010, 11:58 by Anders Blom »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5574
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: How to del the data in nc file
« Reply #2 on: June 7, 2010, 13:54 »
Here is an (unsupported) script that should help you
Code: python
from NanoLanguage import *
from NL.IO.NLSaveUtilities import nlinspect
import tempfile

def nlremove(input_filename,output_filename,id_to_remove):
    if input_filename==output_filename:
        print 'Input and output NC files must be different'
        print 'Exiting'
        return
    file_contents = nlinspect(input_filename)
    print "Contents of ", input_filename
    print "ID\tObject"
    print "----------------------"
    for ix in range(len(file_contents)):
        print file_contents[ix][1],'\t',file_contents[ix][0]
    print
    all_objects = nlread(input_filename)
    for ix in range(len(file_contents)):
        if file_contents[ix][1]!=id_to_remove:
            print 'Writing object with ID %s to %s' % (file_contents[ix][1],output_filename)
            nlsave(output_filename,all_objects[ix],object_id=file_contents[ix][1])
        else:
            print 'Skipping object with ID %s' % (file_contents[ix][1])

in_filename = 'gaas.nc'
out_filename = 'gaas_.nc'
ID_to_remove = 'gID1'

nlremove(in_filename,out_filename,ID_to_remove)
« Last Edit: June 7, 2010, 13:56 by Anders Blom »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5574
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: How to del the data in nc file
« Reply #3 on: June 7, 2010, 14:02 »
Note, however, that the transmission spectrum etc take up very little space in the file. If your NC file contains a "configuration" with a converged calculation, the configuration itself is most likely the absolutely largest part of the NC file, and you probably don't want to remove the configuration... Of course, 3D grids do occupy a lot of space so those would make sense to remove (if you really don't need them any more!).