Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add outfile option to calc_datacube #646

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading