Skip to content

Commit

Permalink
add outfile option to calc_datacube. Fixes https://github.com/spacete…
Browse files Browse the repository at this point in the history
  • Loading branch information
mperrin committed Dec 10, 2024
1 parent b058985 commit 20c136e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion poppy/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def calc_psf(self, outfile=None, source=None, nlambda=None, monochromatic=None,
else:
return result

def calc_datacube(self, wavelengths, progressbar=False, *args, **kwargs):
def calc_datacube(self, wavelengths, progressbar=False, outfile=None, overwrite=True, *args, **kwargs):
"""Calculate a spectral datacube of PSFs
Parameters
Expand All @@ -311,7 +311,12 @@ def calc_datacube(self, wavelengths, progressbar=False, *args, **kwargs):
while iterating over wavelengths. Note, this requires the
optional dependency package 'tqdm', which is not included as
a requirement.
outfile : string
Filename to write. If None, then result is returned as an HDUList
overwrite : bool
overwrite output FITS file if it already exists?
Additional parameters are passed through to calc_datacube
"""

# Allow up to 10,000 wavelength slices. The number matters because FITS
Expand Down Expand Up @@ -355,6 +360,11 @@ def wavelength_as_meters(wavelength):
cube[ext].header.add_history(h)

cube[0].header['NWAVES'] = nwavelengths
if outfile is not None:
cube[0].header["FILENAME"] = (os.path.basename(outfile), "Name of this file")
cube.writeto(outfile, overwrite=overwrite)
poppy_core._log.info("Saved result to " + outfile)

return cube

def _calc_psf_format_output(self, result, options):
Expand Down

0 comments on commit 20c136e

Please sign in to comment.