Author Topic: how to remove objects from nc file?  (Read 3544 times)

0 Members and 1 Guest are viewing this topic.

Offline esp

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 318
  • Country: us
  • Reputation: 3
    • View Profile
    • University of Minnesota
how to remove objects from nc file?
« on: November 11, 2012, 00:36 »
i have run some simulations and saved some transmission objects there at specific biases .. now i want to run again and use the density calculation, but i need to remove the old transmission objects before i create new ones .. i could overwrite them, but for various reasons i would rather delete them from the file, then continue .. how can i do that? note i want to remove a specific object, not everything ...

Offline Nordland

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 812
  • Reputation: 18
    • View Profile
Re: how to remove objects from nc file?
« Reply #1 on: November 11, 2012, 14:12 »
I would make as seperate script that copies everyone from one file to another - except for the things you want deleted.

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5429
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Re: how to remove objects from nc file?
« Reply #2 on: November 11, 2012, 19:22 »
The reason it's necessary to do it this way is that the NC file is first of all a binary file, so you can't just cut out a segment. Second, the file is comparable to, say, a ZIP file, i.e. a container for many objects. Also for a ZIP file you would have to rewrite the file in order to remove a file contained in it.

I wrote a script for this for myself a while back, it's attached here in an updated form.

NOTE: Originally the idea was to implement this function with a single filename as argument, and make a tempfile with the new contents and then overwrite the original file. This is how nlsave() works, actually. It was however decided to play it safe, and let the user remove the original file and rename the new file, as desired.

SEE WARNING BELOW ABOUT USING THIS SCRIPT! Unless you really have to, don't use it, at least not until an update has been published.
« Last Edit: November 14, 2012, 22:22 by Anders Blom »

Offline esp

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 318
  • Country: us
  • Reputation: 3
    • View Profile
    • University of Minnesota
Re: how to remove objects from nc file?
« Reply #3 on: November 11, 2012, 19:23 »
Great thank you!

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5429
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Re: how to remove objects from nc file?
« Reply #4 on: November 14, 2012, 22:21 »
I need to issue a WARNING about my script above. Due to a minor bug in 12.2, using it may corrupt the NEW NC file. The OLD one is always perfectly safe, but if the NC file contains objects with IDs of the type "gID001" etc (i.e. the auto-generated IDs), it may destroy the NEW NC file if you later attempt to append another object to it.

If your NC file only contains "custom" object IDs, which you made yourself, you are fine. We are working on a solution, to make it safer. I will also try to think of a solution by which the nlremove function separates autogenerated and custom IDs, and make it safe this way. But for now I advise caution while using this script. At the very least keep a backup copy of the original NC file (I realize that perhaps voids the purpose of this whole exercise, but better safe than sorry, right!).

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5429
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Re: how to remove objects from nc file?
« Reply #5 on: November 23, 2012, 15:50 »
The problem mentioned above should be fixed in 12.8.