Is there a way to write out a spectralcube to a file with mycube.write() such that it will overwrite an existing file with the same name? I.e. something that replicates the overwrite=True or clobber=True keywords in most CASA tasks? This would be very useful for cases where I'm creating large numbers of files at once and find that my script breaks in the middle. I've looked but can't find anything in the documentation that suggests this is currently possible with cube.write().
(I know I can solve this problem by adding an if os.path.exists('myfilename.fits'): os.system('rm -rf myfilename.fits') to the script, and this is what I'm currently doing, but I'd rather not have to do this every time - a built-in "yes, please overwrite the file for me, thank you" would be a nice improvement.)
Is there a way to write out a spectralcube to a file with
mycube.write()
such that it will overwrite an existing file with the same name? I.e. something that replicates theoverwrite=True
orclobber=True
keywords in most CASA tasks? This would be very useful for cases where I'm creating large numbers of files at once and find that my script breaks in the middle. I've looked but can't find anything in the documentation that suggests this is currently possible with cube.write().(I know I can solve this problem by adding an
if os.path.exists('myfilename.fits'): os.system('rm -rf myfilename.fits')
to the script, and this is what I'm currently doing, but I'd rather not have to do this every time - a built-in "yes, please overwrite the file for me, thank you" would be a nice improvement.)