diff --git a/poppy/dms.py b/poppy/dms.py index a2d8e9bc..6b7a6c10 100644 --- a/poppy/dms.py +++ b/poppy/dms.py @@ -21,7 +21,7 @@ import numexpr as ne __all__ = ['ContinuousDeformableMirror', 'HexSegmentedDeformableMirror', 'CircularSegmentedDeformableMirror', - 'WedgeSegmentedDeformableMirror'] + 'KeystoneSegmentedDeformableMirror'] # noinspection PyUnresolvedReferences @@ -851,7 +851,7 @@ def __init__(self, rings=1, segment_radius=1.0 * u.m, gap=0.01 * u.m, # note, must inherit first from SegmentedDeformableMirror to get correct method resolution order -class WedgeSegmentedDeformableMirror(SegmentedDeformableMirror, optics.WedgeSegmentedCircularAperture): +class KeystoneSegmentedDeformableMirror(SegmentedDeformableMirror, optics.KeystoneSegmentedCircularAperture): """ Circularly segmented DM. Each actuator is controllable in piston, tip, and tilt (and any zernike term) Parameters @@ -873,9 +873,9 @@ class WedgeSegmentedDeformableMirror(SegmentedDeformableMirror, optics.WedgeSegm def __init__(self, name='WedgeSegDM', radius=1.0 * u.m, rings=1, nsections=4, gap_radii=None, gap=0.01 * u.m, include_factor_of_two=False, **kwargs): #FIXME ? using grey pixel does not work. something in the geometry module generate a true divide error - optics.WedgeSegmentedCircularAperture.__init__(self, name=name, radius=radius, rings=rings, - nsections=nsections, gap_radii=gap_radii, - gap=gap, **kwargs) + optics.KeystoneSegmentedCircularAperture.__init__(self, name=name, radius=radius, rings=rings, + nsections=nsections, gap_radii=gap_radii, + gap=gap, **kwargs) SegmentedDeformableMirror.__init__(self, rings=rings, include_factor_of_two=include_factor_of_two) @@ -884,4 +884,4 @@ def _setup_arrays(self, npix, pixelscale, wave=None): # edges of segments. This approach results in the DM segment maps covering the segment gaps better, to # accomodate 'gray' pixels in the transmission map super()._setup_arrays(npix, pixelscale, wave=wave) - self._transmission = optics.WedgeSegmentedCircularAperture.get_transmission(self, wave) + self._transmission = optics.KeystoneSegmentedCircularAperture.get_transmission(self, wave) diff --git a/poppy/instrument.py b/poppy/instrument.py index fbfeac4f..c1b38c7a 100644 --- a/poppy/instrument.py +++ b/poppy/instrument.py @@ -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 @@ -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 @@ -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): diff --git a/poppy/optics.py b/poppy/optics.py index ced19749..97864a35 100644 --- a/poppy/optics.py +++ b/poppy/optics.py @@ -24,7 +24,8 @@ 'BandLimitedCoron', 'BandLimitedCoronagraph', 'IdealFQPM', 'CircularPhaseMask', 'RectangularFieldStop', 'SquareFieldStop', 'AnnularFieldStop', 'HexagonFieldStop', 'CircularOcculter', 'BarOcculter', 'FQPM_FFT_aligner', 'CircularAperture', - 'HexagonAperture', 'MultiHexagonAperture', 'NgonAperture', 'MultiCircularAperture', 'WedgeSegmentedCircularAperture', 'RectangleAperture', + 'HexagonAperture', 'MultiHexagonAperture', 'NgonAperture', 'MultiCircularAperture', + 'KeystoneSegmentedCircularAperture', 'RectangleAperture', 'SquareAperture', 'SecondaryObscuration', 'LetterFAperture', 'AsymmetricSecondaryObscuration', 'ThinLens', 'GaussianAperture', 'KnifeEdge', 'TiltOpticalPathDifference', 'CompoundAnalyticOptic', 'fixed_sampling_optic'] @@ -1588,7 +1589,7 @@ def _one_aperture(self, wave, index, value=1): return self.transmission -class WedgeSegmentedCircularAperture(MultiSegmentAperture, CircularAperture): +class KeystoneSegmentedCircularAperture(MultiSegmentAperture, CircularAperture): @utils.quantity_input(radius=u.meter, gap=u.meter) def __init__(self, name=None, radius=1.0 * u.meter, rings=2, nsections=4, gap_radii=None, gap=0.01 * u.meter, diff --git a/poppy/tests/test_dms.py b/poppy/tests/test_dms.py index a971965d..2b3b62ed 100644 --- a/poppy/tests/test_dms.py +++ b/poppy/tests/test_dms.py @@ -201,7 +201,7 @@ def test_basic_wedge_dm(): """ A simple test for the circularly segmented deformable mirror code - can we move actuators, and does adding nonzero WFE result in decreased Strehl?""" - dm = dms.WedgeSegmentedDeformableMirror(rings=2, nsections=[1,6]) + dm = dms.KeystoneSegmentedDeformableMirror(rings=2, nsections=[1, 6]) osys = poppy_core.OpticalSystem(npix=256) osys.add_pupil(dm) diff --git a/poppy/tests/test_optics.py b/poppy/tests/test_optics.py index 3c32a568..ff105179 100644 --- a/poppy/tests/test_optics.py +++ b/poppy/tests/test_optics.py @@ -392,10 +392,10 @@ def test_NgonAperture(display=False): def test_WedgeSegmentedCircularAperture(plot=False): - """ test WedgeSegmentedCircularAperture """ + """ test KeystoneSegmentedCircularAperture """ ap_circ = optics.CircularAperture() - ap_wedge = optics.WedgeSegmentedCircularAperture(rings=3, nsections=[1, 6, 8]) + ap_wedge = optics.KeystoneSegmentedCircularAperture(rings=3, nsections=[1, 6, 8]) wave1 = poppy_core.Wavefront(npix=256, diam=2, wavelength=1e-6) # 10x10 meter square wave2 = poppy_core.Wavefront(npix=256, diam=2, wavelength=1e-6) # 10x10 meter square