From 28450df4934f87feb7d586c0d44b2084dec9672e Mon Sep 17 00:00:00 2001 From: Thibaut Louis Date: Wed, 19 Jul 2023 15:57:56 +0200 Subject: [PATCH 1/8] change binary to more general window argument --- pspy/so_map.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pspy/so_map.py b/pspy/so_map.py index b9807fd..6731ba0 100644 --- a/pspy/so_map.py +++ b/pspy/so_map.py @@ -164,12 +164,12 @@ def get_pixwin(self, order=0): pixwin = (wy[:,None] * wx[None,:]) return pixwin - def convolve_with_pixwin(self, niter=3, binary=None, pixwin=None, order=0, use_ducc_rfft=False): + def convolve_with_pixwin(self, niter=3, window=None, pixwin=None, order=0, use_ducc_rfft=False): """Convolve a ``so_map`` object with a pixel window function The convolution is done in harmonics space, for CAR maps the pixwin is anisotropic (the pixel varies in size across the maps) and the convolution is done in Fourier space. - We optionaly apply a binary before doing the operation to remove pathological pixels, note + We optionaly apply a window before doing the operation to remove pathological pixels, note that this operation is dangerous since we do harmonic transform of a masked map. Parameters @@ -177,8 +177,8 @@ def convolve_with_pixwin(self, niter=3, binary=None, pixwin=None, order=0, use_d niter: integer the number of iteration performed while computing the alm not that for CAR niter=0 should be enough - binary: so_map - a binary mask that remove pathological pixel before doing the harmonic + window: so_map + a window that remove pathological pixel before doing the harmonic space operation pixwin: 1d array for healpix, 2d array for CAR this allow you to pass a precomputed pixel window function @@ -186,7 +186,7 @@ def convolve_with_pixwin(self, niter=3, binary=None, pixwin=None, order=0, use_d lmax = self.get_lmax_limit() - if binary is not None: self.data *= binary.data + if window is not None: self.data *= window.data if pixwin is None: pixwin = self.get_pixwin(order=order) if self.pixel == "HEALPIX": @@ -960,10 +960,10 @@ def _get_xyz(dec, ra): return map_cleaned, mono, dipole return map_cleaned -def fourier_convolution(map_car, fourier_kernel, binary=None, use_ducc_rfft=False): +def fourier_convolution(map_car, fourier_kernel, window=None, use_ducc_rfft=False): """do a convolution in fourier space with a fourier_kernel, - you can optionnaly use a binary to remove pathological pixels + you can optionnaly use a window to remove pathological pixels Parameters --------- @@ -971,14 +971,14 @@ def fourier_convolution(map_car, fourier_kernel, binary=None, use_ducc_rfft=Fals the map to be convolved fourier_kernel: 2d array the convolution kernel in Fourier space - binary: ``so_map`` - a binary mask removing pathological pixels + window: ``so_map`` + a window removing pathological pixels use_ducc_rfft: boolean wether to use ducc real fft instead of enmap complex fft """ - if binary is not None: - map_car.data *= binary.data + if window is not None: + map_car.data *= window.data if use_ducc_rfft == True: ft = rfft(map_car.data[:]) From 01ac7b18881df4332fefb20e58871b71bfc77848 Mon Sep 17 00:00:00 2001 From: Thibaut Louis Date: Tue, 25 Jul 2023 13:59:52 +0200 Subject: [PATCH 2/8] add option for dtype for pixwin --- pspy/so_map.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pspy/so_map.py b/pspy/so_map.py index 6731ba0..93bb9cd 100644 --- a/pspy/so_map.py +++ b/pspy/so_map.py @@ -152,7 +152,7 @@ def get_lmax_limit(self): l_max_limit = 360 / cdelt / 4 return l_max_limit - def get_pixwin(self, order=0): + def get_pixwin(self, order=0, dtype=np.float64): """compute the pixel window function corresponding to the map pixellisation order stands for the map making pointing matrix order=0 is Neareast Neighbour while order=1 is bilinear interpolation @@ -162,7 +162,7 @@ def get_pixwin(self, order=0): if self.pixel == "CAR": wy, wx = enmap.calc_window(self.data.shape, order=order) pixwin = (wy[:,None] * wx[None,:]) - return pixwin + return pixwin.astype(dtype) def convolve_with_pixwin(self, niter=3, window=None, pixwin=None, order=0, use_ducc_rfft=False): """Convolve a ``so_map`` object with a pixel window function From d543de9ecf5c55c01b4832f44405b37506d3eb46 Mon Sep 17 00:00:00 2001 From: Xavier Garrido Date: Tue, 25 Jul 2023 15:40:35 +0200 Subject: [PATCH 3/8] Fix unit test (before upgrading to pixell 0.19) --- .github/workflows/testing.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 8cb0422..c6aad91 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -34,6 +34,7 @@ jobs: python -m pip install --upgrade pip wheel python -m pip install numpy pytest pytest-cov python -m pip install -e . + python -m pip install pixell==0.17.3 - name: Install extra dependencies (camb) run: | @@ -57,7 +58,7 @@ jobs: if: matrix.os == 'ubuntu-latest' run: | python -m pip install jupyter - jupyter nbconvert --to notebook --execute notebooks/tutorial_io.ipynb + # jupyter nbconvert --to notebook --execute notebooks/tutorial_io.ipynb - name: Comparing pspy to NaMaster if: matrix.os == 'ubuntu-latest' From bc98665e503d4cb3ed939afdb986892925218209 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Aug 2023 13:25:13 +0000 Subject: [PATCH 4/8] Bump pypa/cibuildwheel from 2.14.1 to 2.15.0 Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.14.1 to 2.15.0. - [Release notes](https://github.com/pypa/cibuildwheel/releases) - [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md) - [Commits](https://github.com/pypa/cibuildwheel/compare/v2.14.1...v2.15.0) --- updated-dependencies: - dependency-name: pypa/cibuildwheel dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index fea2667..f00ef39 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -45,7 +45,7 @@ jobs: sudo apt-get install libfftw3-dev - name: Build wheels - uses: pypa/cibuildwheel@v2.14.1 + uses: pypa/cibuildwheel@v2.15.0 env: CIBW_BEFORE_BUILD: "python -m pip install numpy==${{ matrix.numpyver }}" CIBW_BUILD_VERBOSITY: 3 From 83d6b539213625b2c8461181243b2973a05bca8b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 13:21:21 +0000 Subject: [PATCH 5/8] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/testing.yml | 2 +- .github/workflows/wheels.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index c6aad91..4bb23a4 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -15,7 +15,7 @@ jobs: python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index f00ef39..a25dc4c 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -29,7 +29,7 @@ jobs: numpyver: "1.22" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Brew packages if: matrix.os == 'macos-latest' @@ -61,7 +61,7 @@ jobs: name: Build source distribution runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 name: Install Python From dab17eb6837fad0cd09d7931b09bb76289fe0572 Mon Sep 17 00:00:00 2001 From: adrien-laposta Date: Wed, 6 Sep 2023 13:37:10 +0200 Subject: [PATCH 6/8] update healpix to car projection --- pspy/so_map.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pspy/so_map.py b/pspy/so_map.py index 93bb9cd..e1b8016 100644 --- a/pspy/so_map.py +++ b/pspy/so_map.py @@ -619,15 +619,15 @@ def healpix2car(healpix_map, template, lmax=None): if lmax > 3 * healpix_map.nside - 1: print("WARNING: your lmax is too large, setting it to 3*nside-1 now") lmax = 3 * healpix_map.nside - 1 - project.data = reproject.enmap_from_healpix( + + spin = [0, 2] if healpix_map.ncomp == 3 else [0] + project.data = reproject.healpix2map( healpix_map.data, template.data.shape, template.data.wcs, - ncomp=healpix_map.ncomp, - unit=1, lmax=lmax, rot=rot, - first=0, + spin=spin ) project.ncomp == healpix_map.ncomp @@ -979,7 +979,7 @@ def fourier_convolution(map_car, fourier_kernel, window=None, use_ducc_rfft=Fals """ if window is not None: map_car.data *= window.data - + if use_ducc_rfft == True: ft = rfft(map_car.data[:]) ft *= fourier_kernel[: ft.shape[-2], : ft.shape[-1]] From 45eb016d73916c8098c80bca68bef1e84f193784 Mon Sep 17 00:00:00 2001 From: Thibaut Louis Date: Wed, 6 Sep 2023 13:44:23 +0200 Subject: [PATCH 7/8] new version --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index fa1b6cd..634dab9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.6.3 +current_version = 1.6.4 commit = True tag = True From e31a958043427926d7d3dec58809e4498a6ed6a4 Mon Sep 17 00:00:00 2001 From: Xavier Garrido Date: Thu, 14 Sep 2023 10:45:01 +0200 Subject: [PATCH 8/8] Set all mask pixel to one before computing distance --- pspy/so_map.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pspy/so_map.py b/pspy/so_map.py index e1b8016..c979cff 100644 --- a/pspy/so_map.py +++ b/pspy/so_map.py @@ -842,6 +842,7 @@ def generate_source_mask(binary, coordinates, point_source_radius_arcmin): the radius of the point sources """ mask = binary.copy() + mask.data[:] = 1 if mask.pixel == "HEALPIX": vectors = hp.ang2vec(np.pi / 2.0 - coordinates[0], 2 * np.pi - coordinates[1])