diff options
author | Aaron LI <aly@aaronly.me> | 2017-11-03 13:25:42 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2017-11-03 13:25:42 +0800 |
commit | aeb268cdc60b210484f9b31f7bf72accf690f047 (patch) | |
tree | b8cb2cdb35cb4781ff0f3e4c06b99e4779be70a2 | |
parent | eb2fdf35f276a88158ed2620c28cb3ae7cc4e272 (diff) | |
download | atoolbox-aeb268cdc60b210484f9b31f7bf72accf690f047.tar.bz2 |
Deprecate np.int, np.float
See: https://github.com/numpy/numpy/pull/6103
-rwxr-xr-x | astro/calc_psd.py | 2 | ||||
-rwxr-xr-x | astro/fits/fitscube.py | 2 | ||||
-rwxr-xr-x | astro/ps2d.py | 12 | ||||
-rwxr-xr-x | astro/spectrum/crosstalk_deprojection.py | 4 |
4 files changed, 9 insertions, 11 deletions
diff --git a/astro/calc_psd.py b/astro/calc_psd.py index 50344aa..da5465f 100755 --- a/astro/calc_psd.py +++ b/astro/calc_psd.py @@ -38,7 +38,7 @@ class PSD: spectral density (i.e., 1D radial power spectrum). """ def __init__(self, image, pixel=(1.0, "pixel"), step=None): - self.image = np.array(image, dtype=np.float) + self.image = np.array(image, dtype=float) self.shape = self.image.shape if self.shape[0] != self.shape[1]: raise ValueError("input image is not square!") diff --git a/astro/fits/fitscube.py b/astro/fits/fitscube.py index 2c9a4fc..7c30783 100755 --- a/astro/fits/fitscube.py +++ b/astro/fits/fitscube.py @@ -165,7 +165,7 @@ class FITSCube: """ nslice = self.nslice wcs = self.wcs - pix = np.zeros(shape=(nslice, 3), dtype=np.int) + pix = np.zeros(shape=(nslice, 3), dtype=int) pix[:, 2] = np.arange(nslice) world = wcs.wcs_pix2world(pix, 0) return world[:, 2] diff --git a/astro/ps2d.py b/astro/ps2d.py index 777d592..ce81b5e 100755 --- a/astro/ps2d.py +++ b/astro/ps2d.py @@ -69,7 +69,7 @@ def freq2z(freq): def get_frequencies(wcs, nfreq): - pix = np.zeros(shape=(nfreq, 3), dtype=np.int) + pix = np.zeros(shape=(nfreq, 3), dtype=int) pix[:, -1] = np.arange(nfreq) world = wcs.wcs_pix2world(pix, 0) freqMHz = world[:, -1] / 1e6 @@ -88,7 +88,7 @@ class PS2D: def __init__(self, cube, pixelsize, frequencies, window_name=None, window_width="extended", unit="???"): logger.info("Initializing PS2D instance ...") - self.cube = cube + self.cube = np.array(cube, dtype=float) self.pixelsize = pixelsize # [arcsec] self.unit = unit logger.info("Loaded data cube: %dx%d (cells) * %d (channels)" % @@ -157,12 +157,10 @@ class PS2D: """ if self.window is not None: logger.info("Applying window along frequency axis ...") - cube2 = self.cube * self.window[:, np.newaxis, np.newaxis] - else: - cube2 = self.cube.astype(np.float) + self.cube *= self.window[:, np.newaxis, np.newaxis] logger.info("Calculating 3D FFT ...") - cubefft = fftpack.fftshift(fftpack.fftn(cube2)) + cubefft = fftpack.fftshift(fftpack.fftn(self.cube)) logger.info("Calculating 3D PS ...") ps3d = np.abs(cubefft) ** 2 # [K^2] @@ -190,7 +188,7 @@ class PS2D: p_z = np.abs(np.arange(self.Nz) - ic_z) mx, my = np.meshgrid(p_xy, p_xy) rho, phi = self.cart2pol(mx, my) - rho = np.around(rho).astype(np.int) + rho = np.around(rho).astype(int) logger.info("Cylindrically averaging 3D power spectrum ...") for r in range(n_k_perp): diff --git a/astro/spectrum/crosstalk_deprojection.py b/astro/spectrum/crosstalk_deprojection.py index b08a66a..263cb15 100755 --- a/astro/spectrum/crosstalk_deprojection.py +++ b/astro/spectrum/crosstalk_deprojection.py @@ -1015,7 +1015,7 @@ class SpectrumSet(Spectrum): # {{{ """ neg_counts = self.spec_data < 0 N = len(neg_counts) - neg_channels = np.arange(N, dtype=np.int)[neg_counts] + neg_channels = np.arange(N, dtype=int)[neg_counts] if len(neg_channels) > 0: print("WARNING: %d channels have NEGATIVE counts" % \ len(neg_channels), file=sys.stderr) @@ -1038,7 +1038,7 @@ class SpectrumSet(Spectrum): # {{{ self.spec_data[ch] = 0 # update negative channels indices neg_counts = self.spec_data < 0 - neg_channels = np.arange(N, dtype=np.int)[neg_counts] + neg_channels = np.arange(N, dtype=int)[neg_counts] if i > 0: print("FIXED!", file=sys.stderr) # record history |