Skip to content

Commit

Permalink
Use astropy clobber parameter to overwrite files
Browse files Browse the repository at this point in the history
This replaces (where implemented) a manual check, but this uses
astropy's built in functionality to perform this.
  • Loading branch information
simonrw committed Jul 23, 2015
1 parent 5019924 commit fa74674
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions bin/pipeflat.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
def render_total_file(data, fname, nfiles):
hdu = pyfits.PrimaryHDU(data)
hdu.header.set('nfiles', nfiles)
if os.path.exists(fname):
print('file %s already exists, removing file' % fname)
os.remove(fname)
hdu.writeto(fname)
hdu.writeto(fname, clobber=True)


inlist = str(sys.argv[1])
Expand Down Expand Up @@ -98,7 +95,7 @@ def reducer():
phdu.header['mjd'] = mjd
command = 'rm -f '+outname
os.system(command)
phdu.writeto(outname)
phdu.writeto(outname, clobber=True)
tfile = outdir+'processed.dat'
f = open(tfile, 'a')
f.write(outname)
Expand All @@ -119,21 +116,18 @@ def reducer():
print(np.size(wholestd))

outname = outdir+'std.fits'
pyfits.PrimaryHDU(wholestd).writeto(outname)
pyfits.PrimaryHDU(wholestd).writeto(outname, clobber=True)
print('std done')
variance = 1/(wholestd*wholestd)

outname = outdir+'variance.fits'
pyfits.PrimaryHDU(variance).writeto(outname)
pyfits.PrimaryHDU(variance).writeto(outname, clobber=True)
print('var done')
flat = np.median(datamatrix, axis = 0)


outname = outdir+flatname
if os.path.exists(outname):
print('file %s already exists, removing file' % outname)
os.remove(outname)
pyfits.PrimaryHDU(flat).writeto(outname)
pyfits.PrimaryHDU(flat).writeto(outname, clobber=True)
print('flat done')

render_total_file(flat_total, totalname, nflat_files)
Expand Down

0 comments on commit fa74674

Please sign in to comment.