Skip to content

Commit 409eb90

Browse files
committed
Merge branch 'master' into #642
2 parents 53b9e1c + b1505df commit 409eb90

File tree

6 files changed

+61
-62
lines changed

6 files changed

+61
-62
lines changed

CHANGELOG.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ API Changes
2727
issue, and we can add them back. (#218)
2828
- Made all returned matrices consistently use numpy.array, rather than
2929
numpy.matrix. We had been inconsistent with which type different functions
30-
returned, so now all matrices are numpy.arrays. If you rely on the
30+
returned, so now all matrices are numpy.arrays. If you rely on the
3131
numpy.matrix behavior, you should recast with numpy.asmatrix(M). (#218)
32-
- Deprecated CorrelatedNoise.calculateCovarianceMatrix, since it is not used
32+
- Deprecated CorrelatedNoise.calculateCovarianceMatrix, since it is not used
3333
anywhere, and we think no one really has a need for it. (#630)
3434
- Officially deprecated the methods and functions that had been described as
35-
having been removed or changed to a different name. In fact, many of them
35+
having been removed or changed to a different name. In fact, many of them
3636
had been still valid, but no longer documented. This was intentional to
3737
allow people time to change their code. Now these methods are officially
3838
deprecated and will emit a warning message if used. (#643)
@@ -48,14 +48,14 @@ New Features
4848

4949
- Made all GalSim objects picklable unless they use fundamentally unpicklable
5050
things such as lambda expressions. Also gave objects better str and repr
51-
representations (str(obj) should be descriptive, but relatively succinct,
51+
representations (str(obj) should be descriptive, but relatively succinct,
5252
and repr(obj) should be unambiguous). Also made __eq__, __ne__, and __hash__
5353
work better. (#218)
5454
- Added ability to set the zeropoint of a bandpass on construction. (Only
5555
a numeric value; more complicated calculations still need to use the method
5656
`bandpass.withZeropoint()`.) (#218)
5757
- Added ability to set the redshift of an SED on construction. (#218)
58-
- Updated CorrelatedNoise to work with images that have a non-trivial WCS.
58+
- Updated CorrelatedNoise to work with images that have a non-trivial WCS.
5959
(#501)
6060
- Added new methods of the image class to simulate detector effects:
6161
inter-pixel capacitance (#555) and image quantization (#558).
@@ -79,7 +79,7 @@ New Features
7979
rendering process compared to brute force evaluation for chromatic objects
8080
with basic properties that are wavelength-dependent. (#618)
8181
- Added new `ChromaticAiry` and `ChromaticOpticalPSF` classes for representing
82-
optical PSFs. These new classes allow the diffraction effects and (in the
82+
optical PSFs. These new classes allow the diffraction effects and (in the
8383
latter case) aberrations to be wavelength-dependent. (#618)
8484
- Enable initializing a DES_PSFEx object using a pyfits HDU directly instead
8585
of a filename. (#626)
@@ -100,7 +100,7 @@ Bug Fixes and Improvements
100100
- Fixed a bug in UncorrelatedNoise where the variance was set incorrectly.
101101
(#630)
102102
- Changed the implementation of drawing Box and Pixel profiles in real space
103-
(i.e. without being convolved by anything) to actually draw the surface
103+
(i.e. without being convolved by anything) to actually draw the surface
104104
brightness at the center of each pixel. This is what all other profiles do,
105105
but had not been what a Box or Pixel did. (#639)
106106
- Fixed a bug where InterpolatedImage and Box profiles were not correctly
@@ -116,4 +116,3 @@ Updates to config options
116116
- Added Spergel type. (#616)
117117
- Added lam, diam, scale_units options to Airy and OpticalPSF types. (#618)
118118
- Added TopHat type. (#639)
119-

galsim/chromatic.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def drawImage(self, bandpass, image=None, integrator='trapezoidal', **kwargs):
212212
213213
The task of drawImage() in a chromatic context is to integrate a chromatic surface
214214
brightness profile multiplied by the throughput of `bandpass`, over the wavelength interval
215-
indicated by `bandpass`.
215+
indicated by `bandpass`.
216216
217217
Several integrators are available in galsim.integ to do this integration when using the
218218
first method (non-interpolated integration). By default,
@@ -520,8 +520,8 @@ def shear(self, *args, **kwargs):
520520
the appropriate change in area, either use shear() with magnify(), or use lens(), which
521521
combines both operations.
522522
523-
Note that, while gravitational shear is monochromatic, the shear method may be used for
524-
many other use cases including some which may be wavelength-dependent, such as
523+
Note that, while gravitational shear is monochromatic, the shear method may be used for
524+
many other use cases including some which may be wavelength-dependent, such as
525525
intrinsic galaxy shape, telescope dilation, atmospheric PSF shape, etc. Thus, the
526526
shear argument is allowed to be a function of wavelength like other transformations.
527527
@@ -566,7 +566,7 @@ def lens(self, g1, g2, mu):
566566
567567
While gravitational lensing is achromatic, we do allow the parameters `g1`, `g2`, and `mu`
568568
to be callable functions to be parallel to all the other transformations of chromatic
569-
objects. In this case, the functions should take the wavelength in nanometers as the
569+
objects. In this case, the functions should take the wavelength in nanometers as the
570570
argument, and the return values are the corresponding value at that wavelength.
571571
572572
@param g1 First component of lensing (reduced) shear to apply to the object.
@@ -721,7 +721,7 @@ class InterpolatedChromaticObject(ChromaticObject):
721721
Any ChromaticObject can be used, although the interpolation procedure is most effective
722722
for non-separable objects, which can sometimes be very slow to render.
723723
724-
Normally, you would not create an InterpolatedChromaticObject directly. It is the
724+
Normally, you would not create an InterpolatedChromaticObject directly. It is the
725725
return type from `chrom_obj.interpolate()`. See the description of that function
726726
for more details.
727727
@@ -739,7 +739,7 @@ class InterpolatedChromaticObject(ChromaticObject):
739739
whichever wavelength has the highest Nyquist frequency.
740740
`oversample_fac`>1 results in higher accuracy but costlier
741741
pre-computations (more memory and time). [default: 1]
742-
"""
742+
"""
743743
def __init__(self, obj, waves, oversample_fac=1.0):
744744

745745
self.separable = obj.separable
@@ -926,7 +926,7 @@ def drawImage(self, bandpass, image=None, integrator='trapezoidal', **kwargs):
926926
images at the specified wavelengths.
927927
928928
This integration will take place using interpolation between stored images that were
929-
setup when the object was constructed. (See interpolate() for more details.)
929+
setup when the object was constructed. (See interpolate() for more details.)
930930
931931
@param bandpass A Bandpass object representing the filter against which to
932932
integrate.
@@ -1110,7 +1110,7 @@ def drawImage(self, bandpass, image=None, integrator='trapezoidal', **kwargs):
11101110
@returns the drawn Image.
11111111
"""
11121112
return self.build_obj().drawImage(bandpass, image, integrator, **kwargs)
1113-
1113+
11141114

11151115
class Chromatic(ChromaticObject):
11161116
"""Construct chromatic versions of galsim GSObjects.
@@ -1191,7 +1191,7 @@ class ChromaticTransformation(ChromaticObject):
11911191
Typically, you do not need to construct a ChromaticTransformation object explicitly.
11921192
This is the type returned by the various transformation methods of ChromaticObject such as
11931193
shear(), rotate(), shift(), transform(), etc. All the various transformations can be described
1194-
as a combination of transform() and shift(), which are described by (dudx,dudy,dvdx,dvdy) and
1194+
as a combination of transform() and shift(), which are described by (dudx,dudy,dvdx,dvdy) and
11951195
(dx,dy) respectively.
11961196
11971197
@param obj The object to be transformed.
@@ -1230,7 +1230,7 @@ def __init__(self, obj, jac=np.identity(2), offset=(0,0), flux_ratio=1., gsparam
12301230
self._jac = jac
12311231
self._offset = offset
12321232
self._flux_ratio = flux_ratio
1233-
1233+
12341234
elif isinstance(obj, ChromaticTransformation):
12351235
self.original = obj.original
12361236
if hasattr(jac, '__call__'):
@@ -2014,7 +2014,7 @@ class ChromaticOpticalPSF(ChromaticObject):
20142014
[default: galsim.arcsec]
20152015
@param **kwargs Any other keyword arguments to be passed to OpticalPSF, for example,
20162016
related to struts, obscuration, oversampling, etc. See OpticalPSF
2017-
docstring for a complete list of options.
2017+
docstring for a complete list of options.
20182018
"""
20192019
def __init__(self, lam, diam=None, lam_over_diam=None, aberrations=None,
20202020
scale_unit=galsim.arcsec, **kwargs):

galsim/utilities.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ def roll2d(image, (iroll, jroll)):
3535
def kxky(array_shape=(256, 256)):
3636
"""Return the tuple `(kx, ky)` corresponding to the DFT of a unit integer-sampled array of input
3737
shape.
38-
38+
3939
Uses the SBProfile conventions for Fourier space, so `k` varies in approximate range (-pi, pi].
4040
Uses the most common DFT element ordering conventions (and those of FFTW), so that `(0, 0)`
4141
array element corresponds to `(kx, ky) = (0, 0)`.
4242
4343
See also the docstring for np.fftfreq, which uses the same DFT convention, and is called here,
4444
but misses a factor of pi.
45-
45+
4646
Adopts NumPy array index ordering so that the trailing axis corresponds to `kx`, rather than the
4747
leading axis as would be expected in IDL/Fortran. See docstring for numpy.meshgrid which also
4848
uses this convention.
@@ -112,7 +112,7 @@ def parse_pos_args(args, kwargs, name1, name2, integer=False, others=[]):
112112
f(name1=x, name2=y)
113113
114114
If the inputs must be integers, set `integer=True`.
115-
If there are other args/kwargs to parse after these, then their names should be
115+
If there are other args/kwargs to parse after these, then their names should be
116116
be given as the parameter `others`, which are passed back in a tuple after the position.
117117
"""
118118
def canindex(arg):
@@ -174,13 +174,13 @@ class SimpleGenerator:
174174
"""
175175
def __init__(self, obj): self._obj = obj
176176
def __call__(self): return self._obj
177-
177+
178178
class AttributeDict(object):
179179
"""Dictionary class that allows for easy initialization and refs to key values via attributes.
180180
181181
NOTE: Modified a little from Jim's bot.git AttributeDict class so that tab completion now works
182182
in ipython since attributes are actually added to __dict__.
183-
183+
184184
HOWEVER this means the __dict__ attribute has been redefined to be a collections.defaultdict()
185185
so that Jim's previous default attribute behaviour is also replicated.
186186
"""
@@ -258,7 +258,7 @@ def _convertPositions(pos, units, func):
258258
np.array([pos.y], dtype='float') ]
259259

260260
# Check for list of PositionD or PositionI:
261-
# The only other options allow pos[0], so if this is invalid, an exception
261+
# The only other options allow pos[0], so if this is invalid, an exception
262262
# will be raised:
263263
elif isinstance(pos[0],galsim.PositionD) or isinstance(pos[0],galsim.PositionI):
264264
pos = [ np.array([p.x for p in pos], dtype='float'),
@@ -297,7 +297,7 @@ def _convertPositions(pos, units, func):
297297

298298
def thin_tabulated_values(x, f, rel_err=1.e-4, preserve_range=False):
299299
"""
300-
Remove items from a set of tabulated f(x) values so that the error in the integral is still
300+
Remove items from a set of tabulated f(x) values so that the error in the integral is still
301301
accurate to a given relative accuracy.
302302
303303
The input `x,f` values can be lists, NumPy arrays, or really anything that can be converted
@@ -308,7 +308,7 @@ def thin_tabulated_values(x, f, rel_err=1.e-4, preserve_range=False):
308308
@param rel_err The maximum relative error to allow in the integral from the removal.
309309
[default: 1.e-4]
310310
@param preserve_range Should the original range of `x` be preserved? (True) Or should the ends
311-
be trimmed to include only the region where the integral is
311+
be trimmed to include only the region where the integral is
312312
significant? (False) [default: False]
313313
314314
@returns a tuple of lists `(x_new, y_new)` with the thinned tabulation.
@@ -417,4 +417,3 @@ def _gammafn(x):
417417
0.00000000000000122678, -0.00000000000000011813, 0.00000000000000000119,
418418
0.00000000000000000141, -0.00000000000000000023, 0.00000000000000000002
419419
)
420-

galsim/wfirst/wfirst_psfs.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ def getPSF(SCAs=None, approximate_struts=False, n_waves=None, extra_aberrations=
202202
pupil_plane_im=galsim.wfirst.pupil_plane_file,
203203
oversampling=1.2, pad_factor=2.)
204204
if n_waves is not None:
205-
PSF.setupInterpolation(waves=np.linspace(blue_limit, red_limit, n_waves),
206-
oversample_fac=1.5)
205+
PSF = PSF.interpolate(waves=np.linspace(blue_limit, red_limit, n_waves),
206+
oversample_fac=1.5)
207207
else:
208208
tmp_aberrations = use_aberrations * zemax_wavelength / wavelength_nm
209209
if approximate_struts:
@@ -279,7 +279,8 @@ def storePSFImages(PSF_dict, filename, bandpass_list=None, clobber=False):
279279
SCA_index_list = []
280280
for SCA in PSF_dict.keys():
281281
PSF = PSF_dict[SCA]
282-
if not isinstance(PSF, galsim.ChromaticOpticalPSF):
282+
if not isinstance(PSF, galsim.ChromaticOpticalPSF) and \
283+
not isinstance(PSF, galsim.InterpolatedChromaticObject):
283284
raise RuntimeError("Error, PSFs are not ChromaticOpticalPSFs.")
284285
star = galsim.Gaussian(sigma=1.e-8, flux=1.)
285286

tests/test_chromatic.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ def test_chromatic_flux():
533533
err_msg="Drawn ChromaticConvolve flux (interpolated) doesn't match analytic prediction")
534534
# As an aside, check for appropriate tests of 'integrator' argument.
535535
try:
536-
np.testing.assert_raises(TypeError, final_int.drawImage, bandpass,
536+
np.testing.assert_raises(TypeError, final_int.drawImage, bandpass,
537537
integrator='midp') # minor misspelling
538538
np.testing.assert_raises(TypeError, final_int.drawImage, bandpass,
539539
integrator=galsim.integ.midpt)
@@ -741,7 +741,7 @@ def test_ChromaticObject_expand():
741741
np.testing.assert_almost_equal(myy / (sigma/pixel_scale)**2, 1.0, decimal=4)
742742
np.testing.assert_almost_equal(mxy / (sigma/pixel_scale)**2, 0, decimal=4)
743743

744-
# First a very simple case with no actual wavelength dependence, but using the
744+
# First a very simple case with no actual wavelength dependence, but using the
745745
# functional syntax.
746746
gal1 = galsim.ChromaticObject(gal).expand(lambda w: 1.2)
747747
# Use a simple bandpass so we can do the integral below analytically
@@ -863,7 +863,7 @@ def test_ChromaticObject_rotate():
863863
np.testing.assert_almost_equal(myy / (sigma/pixel_scale)**2, (1-0.3)/fact, decimal=4)
864864
np.testing.assert_almost_equal(mxy / (sigma/pixel_scale)**2, 0, decimal=4)
865865

866-
# First a very simple case with no actual wavelength dependence, but using the
866+
# First a very simple case with no actual wavelength dependence, but using the
867867
# functional syntax.
868868
gal1 = galsim.ChromaticObject(gal).rotate(lambda w: 0.4 * galsim.radians)
869869
bp = galsim.Bandpass(lambda w: 1. - 0.12*(w-600)**2/100**2, 500, 700)
@@ -963,7 +963,7 @@ def test_ChromaticObject_shear():
963963
np.testing.assert_almost_equal(myy / (sigma/pixel_scale)**2, 1.0, decimal=4)
964964
np.testing.assert_almost_equal(mxy / (sigma/pixel_scale)**2, 0.0, decimal=4)
965965

966-
# First a very simple case with no actual wavelength dependence, but using the
966+
# First a very simple case with no actual wavelength dependence, but using the
967967
# functional syntax.
968968
gal1 = galsim.ChromaticObject(gal).shear(lambda w: galsim.Shear(e1=0.23, e2=0.13))
969969
bp = galsim.Bandpass(lambda w: 1. - 0.12*(w-600)**2/100**2, 500, 700)
@@ -1519,7 +1519,7 @@ def test_ChromaticOpticalPSF():
15191519
t1 = time.time()
15201520

15211521
# For ChromaticOpticalPSF, exact evaluation is too slow for routine unit tests. So, for
1522-
# this unit test, we use an interpolated version only. The tests of
1522+
# this unit test, we use an interpolated version only. The tests of
15231523
# ChromaticObject in the previous unit test should be enough to ensure that exact
15241524
# and interpolated evaluation match in general (given reasonable settings).
15251525

@@ -1547,7 +1547,7 @@ def test_ChromaticOpticalPSF():
15471547
# obscuration = 0.18
15481548
# nstruts = 2
15491549
# scale = 0.02
1550-
#
1550+
#
15511551
# psf = galsim.ChromaticOpticalPSF(lam=lam, diam=diam, aberrations=aberrations,
15521552
# obscuration=obscuration, nstruts=nstruts)
15531553
# obj = galsim.Convolve(psf, star)
@@ -1643,7 +1643,7 @@ def test_ChromaticAiry():
16431643
# diam = 3.1 # meters
16441644
# obscuration = 0.11
16451645
# scale = 0.02
1646-
#
1646+
#
16471647
# psf = galsim.ChromaticAiry(lam=lam, diam=diam, obscuration=obscuration)
16481648
# obj = galsim.Convolve(psf, star)
16491649
# im_r = obj.drawImage(bandpass, scale=scale)

0 commit comments

Comments
 (0)