Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
33aa141
Export int1d into python
rmjarvis Sep 28, 2012
23fa3a6
Export int1d into python take 2
rmjarvis Sep 28, 2012
ec58e89
fix typo
rmjarvis Sep 29, 2012
8fb8fdb
Make a python layer version of int1d to call the C++ version. Also a…
rmjarvis Sep 30, 2012
ff57043
Remove diagnostic print statements.
rmjarvis Oct 1, 2012
cb5db03
please check: fixed rel_err/abs_err typo in int1d docstring
barnabytprowe Oct 1, 2012
832ee1e
added info to the int1d docstrings to describe how to specify infinit…
barnabytprowe Oct 2, 2012
cdaa738
added test_integ.py... currently contains four tests, one easy on fin…
barnabytprowe Oct 2, 2012
1b1e2e9
added test_integ to run_all_tests properly
barnabytprowe Oct 2, 2012
ae664bd
fixed error in err_msg for sin(x^2)*exp(-|x|) finite interval tests
barnabytprowe Oct 2, 2012
0245a5a
backed out allclose in favour of assert_almost_equal
barnabytprowe Oct 2, 2012
cb4147f
added inverse root integration tests
barnabytprowe Oct 2, 2012
9538740
changed limits in sin(x^2) * exp(-|x|) test to match Mike's comments …
barnabytprowe Oct 2, 2012
5ca5864
Merge branch 'master' into #288
barnabytprowe Oct 2, 2012
c7a0460
added an example to docstring for integ.py
rmandelb Oct 3, 2012
f404c50
added integ to int1d example
rmandelb Oct 3, 2012
64ba7a0
Make errors from integrator pass c++/python boundary correctly
rmjarvis Oct 3, 2012
4b871a5
Test python exception when integrator fails
rmjarvis Oct 3, 2012
2176034
Add c++ test suite for integ
rmjarvis Oct 3, 2012
53701b9
Add normal timing output to test_integ.py
rmjarvis Oct 3, 2012
001be44
Remove ostringstream from the code that builds the IntFailure messages
rmjarvis Oct 3, 2012
7d62f38
Merge branch 'master' into #288
rmjarvis Oct 3, 2012
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
5 changes: 0 additions & 5 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,12 @@ The GalSim package also requires
functionality, and can be omitted if users are happy to use JSON-style
config parsing or prefer to write python scripts directly.

* Optional dependency: the scientific Python module SciPy
(http://www.scipy.org). SciPy is only required for generation of
shears due to an NFW halo.

These should installed onto your Python system so that they can be imported by:

>>> import numpy
>>> import pyfits
>>> import yaml [ if using the galsim_yaml executable or otherwise plan to
parse .yaml configuration files ]
>>> import scipy [ if generating shears according to an NFW halo ]

within Python. You can test this by loading up the Python interpreter for the
version of Python you will be using with the GalSim toolkit. This is usually
Expand Down
1 change: 1 addition & 0 deletions galsim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
from psfcorr import *
from io import *
from . import lensing
from . import integ
36 changes: 36 additions & 0 deletions galsim/integ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""@file integ.py
A Python layer version of the C++ int1d function in galim::integ
"""

from . import _galsim

def int1d(func, min, max, rel_err=1.e-6, abs_err=1.e-12):
"""Integrate a 1-dimensional function from min to max.

Example usage:

>>> def func(x): return x**2
>>> galsim.integ.int1d(func, 0, 1)
0.33333333333333337
>>> galsim.integ.int1d(func, 0, 2)
2.666666666666667
>>> galsim.integ.int1d(func, -1, 1)
0.66666666666666674

@param func The function to be integrated. y = func(x) should be valid.
@param min The lower end of the integration bounds (anything < -1.e10 is treated as
negative infinity).
@param max The upper end of the integration bounds (anything > 1.e10 is treated as positive
infinity).
@param rel_err The desired relative error (default `rel_err = 1.e-6`)
@param abs_err The desired absolute error (default `abs_err = 1.e-12`)
"""
min = float(min)
max = float(max)
rel_err = float(rel_err)
abs_err = float(abs_err)
success, result = _galsim.PyInt1d(func,min,max,rel_err,abs_err)
if success:
return result
else:
raise RuntimeError(result)
5 changes: 2 additions & 3 deletions galsim/lensing.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,8 @@ def Da(self, z, z_ref=0):
raise ValueError("Redshift z must not be negative")
if z < z_ref:
raise ValueError("Redshift z must not be smaller than the reference redshift")
# TODO: We don't want to depend on scipy, so need to move this down to c++.
from scipy.integrate import quad
d = quad(self.__angKernel, z_ref+1, z+1)[0]

d = galsim.integ.int1d(self.__angKernel, z_ref+1, z+1)
# check for curvature
rk = (abs(self.omega_c))**0.5
if (rk*d > 0.01):
Expand Down
Loading