Commit fde32660 by Maude Le Jeune

### alm ok

parent 33cab6cf
 ... ... @@ -24,5 +24,8 @@ import map from spherelib_map import regress, fastfill, cat2mask, apodize_mask from spherelib_alm import _alm2cov from fitsfunc2 import * from bin import * from alm import * from utils import *
 """ spherical harmonic coefficients computations. """ # Copyright (C) 2009 APC CNRS Universite Paris Diderot # # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see http://www.gnu.org/licenses/gpl.html from pylab import * import utils import spherelib_alm import bin def alm2cov (list_alm): """ Compute second order statistics of spherical harmonic coefficients. Parameters ---------- list_alm : list of alm array of same size. Returns ------- 3D array representing symetric covariance matrices vector of number of modes used to compute each matrix. """ nin = len(list_alm) nalm = len(list_alm[0]) almtab = zeros((nin, nalm)) for i in range(nin): almtab[i,:] = list_alm[i] lmax = int(round((sqrt(1+8*nalm)-3) / 2) ) ncross = nin*(nin+1)/2 covtab = zeros((ncross, lmax+1)) spherelib_alm._alm2cov (almtab, covtab) cov = zeros((nin, nin, lmax+1)) for ell in range(lmax+1): cov[:,:,ell] = utils.vec2mat(covtab[:,ell]) nmode = bin.get_nmode(bin.uniformbin (0, lmax, 1)) return cov, nmode
 """ second order statistics computations. """ # Copyright (C) 2009 APC CNRS Universite Paris Diderot # # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see http://www.gnu.org/licenses/gpl.html def unbeamcov (cov, beams, max_inv=10000): """ """ pass
 ... ... @@ -37,21 +37,29 @@ def write_alm (filename, alm): filename : string. FITS file name. alm : complex array, shape(1, (lmax+1)(lmax+2)/2) """ lmax = int(round(((sqrt(1+8*size(alm))-3)/2))) ##Building index Ind = zeros(size(alm)) lmax = int(round(((sqrt(1+8*size(alm))-3)/2))) nalm = size(alm) idx = zeros(size(alm), dtype="int32") start = 0 for l in range(lmax+1): stop = start + l Ind[start:stop+1] = arange(l*l+l+1,(l+1)*(l+1)+1) idx[start:stop+1] = arange(l*l+l+1,(l+1)*(l+1)+1) start = stop +1 cols = [pyfits.Column(name='index', format='J', array=array(Ind))] cols.append(pyfits.Column(name='real', format='E', array=array(real(alm)))) cols.append(pyfits.Column(name='imaginary', format='E', array=array(imag(alm)))) l = floor(sqrt(idx-1)).astype(long) m = idx - l**2 - l - 1 lmax = l.max() mmax = m.max() i = hp.Alm.getidx(lmax,l,m) almr = alm.real[i] almi = alm.imag[i] cols = [pyfits.Column(name='index', format='J', array=idx)] cols.append(pyfits.Column(name='real', format='D', array=almr)) cols.append(pyfits.Column(name='imaginary', format='D', array=almi)) cols = pyfits.ColDefs(cols) tbhdu = pyfits.new_table(cols) ... ...
 """ Healpix map computations. """ # Copyright (C) 2009 APC CNRS Universite Paris Diderot # # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see http://www.gnu.org/licenses/gpl.html def rien(): return 0
 // Copyright (C) 2009 APC CNRS Universite Paris Diderot // // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, see http://www.gnu.org/licenses/gpl.html #include "xcomplex.h" #include "alm.h" #include "powspec.h" #include "alm_powspec_tools.h" #include "alm_healpix_tools.h" #include "healpix_base.h" #include "healpix_map.h" #include "MapExt.h" #include "AlmExt.h" #include "PowSpecExt.h" #include "CovMat.h" #include "Python.h" #include #define dcomplex std::double void _alm2cov(npy_cdouble *tabalm, int nbin, int nalm, double* cov, int ncross, int nell) { int ncross2 = nbin*(nbin+1)/2; if (ncross != ncross2) PyErr_Format(PyExc_ValueError,"Arrays of different lengths (%d %d)",ncross, ncross2); int nalm2 = (nell)*(nell+1)/2; if (nalm != nalm2) PyErr_Format(PyExc_ValueError,"Arrays of different lengths (%d %d)",nalm, nalm2); int lmax = nell-1; int mmax = lmax; int j=0; AlmExt Alm[nbin]; for (int m=0; m< nbin; m++){ arr< xcomplex > arralm (nalm); for( int i = 0; i < nalm; i++ ){ arralm[i]=xcomplex(tabalm[j].real, tabalm[j].imag); j++;} Alm[m].Set(arralm, lmax, mmax); } CovMat CovMat; CovMat.FromAlm (Alm, nbin); arr2 Mat = CovMat.getCovMat(); j = 0; for (int m=0; m< ncross; m++){ for( int i = 0; i < nell; i++ ) { cov[j] = Mat[m][i]; j++;} } }