aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2018-02-02 13:31:30 +0800
committerAaron LI <aly@aaronly.me>2018-02-02 13:31:30 +0800
commit1f2758286769fec0bcff2be3457fe243035269a2 (patch)
tree34c1cce9d3526d6eef4816aa786c29166959101e /fg21sim
parent2b8dda20b1737794c82ab29a0221e3ffe96cd26c (diff)
downloadfg21sim-1f2758286769fec0bcff2be3457fe243035269a2.tar.bz2
Numba: disable/restrict the Numba JIT usage; needs refactor -> Cython ...
Diffstat (limited to 'fg21sim')
-rw-r--r--fg21sim/utils/grid.py37
-rw-r--r--fg21sim/utils/transform.py14
-rw-r--r--fg21sim/webui/handlers/console.py4
3 files changed, 29 insertions, 26 deletions
diff --git a/fg21sim/utils/grid.py b/fg21sim/utils/grid.py
index cf97045..abca9ce 100644
--- a/fg21sim/utils/grid.py
+++ b/fg21sim/utils/grid.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2016-2017 Weitian LI <weitian@aaronly.me>
+# Copyright (c) 2016-2018 Weitian LI <weitian@aaronly.me>
# MIT license
"""
@@ -7,14 +7,15 @@ Grid utilities.
import numpy as np
-import numba as nb
+# import numba as nb
+from scipy import ndimage
from .draw import ellipse
-from .transform import rotate_center
+# from .transform import rotate_center
from .healpix import ang2pix_ring
-@nb.jit(nopython=True)
+# @nb.jit(nopython=True)
def _wrap_longitudes(lon):
"""Wrap the longitudes for values that beyond the valid range [0, 360)"""
lon[lon < 0] += 360
@@ -22,7 +23,7 @@ def _wrap_longitudes(lon):
return lon
-@nb.jit(nopython=True)
+# @nb.jit(nopython=True)
def _wrap_latitudes(lat):
"""Wrap the latitudes for values that beyond the valid range [-90, 90]"""
lat[lat < -90] = -lat[lat < -90] - 180
@@ -30,11 +31,11 @@ def _wrap_latitudes(lat):
return lat
-@nb.jit(nb.types.UniTuple(nb.float64[:, :], 2)(
- nb.types.UniTuple(nb.float64, 2),
- nb.types.UniTuple(nb.float64, 2),
- nb.float64),
- nopython=True)
+# @nb.jit(nb.types.UniTuple(nb.float64[:, :], 2)(
+# nb.types.UniTuple(nb.float64, 2),
+# nb.types.UniTuple(nb.float64, 2),
+# nb.float64),
+# nopython=True)
def make_coordinate_grid(center, size, resolution):
"""
Make a rectangular, Cartesian coordinate grid.
@@ -116,8 +117,9 @@ def make_ellipse(center, radii, rotation):
for ri, ci in zip(rr, cc):
gridmap[ri, ci] = 1.0
# Rotate the ellipse about the grid center
- gridmap = rotate_center(gridmap, angle=rotation, interp=True,
- reshape=False, fill_value=0.0)
+ # gridmap = rotate_center(gridmap, angle=rotation, interp=True,
+ # reshape=False, fill_value=0.0)
+ gridmap = ndimage.rotate(gridmap, angle=rotation, reshape=False, order=1)
return gridmap
@@ -172,14 +174,15 @@ def make_grid_ellipse(center, size, resolution, rotation=0.0):
for ri, ci in zip(rr, cc):
gridmap[ri, ci] = 1.0
# Rotate the ellipse about the grid center
- gridmap = rotate_center(gridmap, angle=rotation, interp=True,
- reshape=False, fill_value=0.0)
+ # gridmap = rotate_center(gridmap, angle=rotation, interp=True,
+ # reshape=False, fill_value=0.0)
+ gridmap = ndimage.rotate(gridmap, angle=rotation, reshape=False, order=1)
return (lon, lat, gridmap)
-@nb.jit(nb.types.Tuple((nb.int64[:], nb.float64[:]))(
- nb.types.UniTuple(nb.float64[:, :], 3), nb.int64),
- nopython=True)
+# @nb.jit(nb.types.Tuple((nb.int64[:], nb.float64[:]))(
+# nb.types.UniTuple(nb.float64[:, :], 3), nb.int64),
+# nopython=True)
def map_grid_to_healpix(grid, nside):
"""
Map the filled coordinate grid to the HEALPix map (RING ordering).
diff --git a/fg21sim/utils/transform.py b/fg21sim/utils/transform.py
index 66f0d29..c59d660 100644
--- a/fg21sim/utils/transform.py
+++ b/fg21sim/utils/transform.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2016-2017 Weitian LI <weitian@aaronly.me>
+# Copyright (c) 2016-2018 Weitian LI <weitian@aaronly.me>
# MIT license
"""
@@ -17,15 +17,15 @@ References
import numpy as np
-import numba as nb
+# import numba as nb
from scipy import ndimage
-@nb.jit([nb.float64[:, :](nb.int64[:, :], nb.float64, nb.boolean,
- nb.boolean, nb.float64),
- nb.float64[:, :](nb.float64[:, :], nb.float64, nb.boolean,
- nb.boolean, nb.float64)],
- nopython=True)
+# @nb.jit([nb.float64[:, :](nb.int64[:, :], nb.float64, nb.boolean,
+# nb.boolean, nb.float64),
+# nb.float64[:, :](nb.float64[:, :], nb.float64, nb.boolean,
+# nb.boolean, nb.float64)],
+# nopython=True)
def rotate_center(imgin, angle, interp=True, reshape=True, fill_value=0.0):
"""
Rotate the input image (only gray-scale image currently supported)
diff --git a/fg21sim/webui/handlers/console.py b/fg21sim/webui/handlers/console.py
index fece851..caf69e3 100644
--- a/fg21sim/webui/handlers/console.py
+++ b/fg21sim/webui/handlers/console.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2016 Weitian LI <liweitianux@live.com>
+# Copyright (c) 2016,2018 Weitian LI <weitian@aaronly.me>
# MIT license
"""
@@ -174,7 +174,7 @@ class ConsoleAJAXHandler(BaseRequestHandler):
logger.info("Checking the configurations ...")
self.configs.check_all()
#
- logger.info("Importing modules + Numba JIT, waiting ...")
+ logger.info("Importing modules, waiting ...")
from ...foregrounds import Foregrounds
#
fg = Foregrounds(self.configs)