@@ -95,9 +95,9 @@ MRS::MRS(bool verbose)
9595
9696// Destructor
9797MRS::~MRS (){
98- mr_initialized=False;
99- nb_procs=0 ;
100- Verbose=False;
98+ mr_initialized=False;
99+ nb_procs=0 ;
100+ Verbose=False;
101101}
102102
103103// int MRS::get_lmax(int & Lmax, int Nside, float ZeroPadding)
@@ -122,7 +122,7 @@ void MRS::alloc(int Nside, int Nscale, int LmaxIn, int ALM_iter, bool Verb)
122122 float ZeroPadding=0 .;
123123 int LM=LmaxIn;
124124 int Lmax = mrs_get_lmax (LM, Nside, ZeroPadding);
125- cout << " ALLOC: " << Nside << " " << Nscale << " " << LmaxIn << " " << ALM_iter << endl;
125+ // cout << "ALLOC: " << Nside << " " << Nscale << " " << LmaxIn << " " << ALM_iter << endl;
126126 WT.wt_alloc (Nside, Nscale, Lmax, nested); // DEF_MRS_ORDERING);
127127 WT.ALM_iter = ALM_iter;
128128 if (Verb) Verbose=Verb;
@@ -133,14 +133,11 @@ void MRS::alloc(int Nside, int Nscale, int LmaxIn, int ALM_iter, bool Verb)
133133py::array_t <float > MRS::uwt (py::array_t <float >& arr, int Ns)
134134{
135135 Verbose=True;
136- cout << " Input arr.ndim() = " << arr.ndim () << " " << arr.shape (0 ) << endl;
136+ // cout << "Input arr.ndim() = " << arr.ndim() << " " << arr.shape(0) << endl;
137137 if (arr.ndim () != 1 )
138138 throw std::runtime_error (" Input should be 1-D NumPy array" );
139139
140-
141- cout << " OK" << endl;
142- exit (-1 );
143-
140+ // cout << "OK" << endl;
144141
145142 auto buffer = arr.request ();
146143 float *pointer = (float *) buffer.ptr ;
@@ -156,7 +153,7 @@ py::array_t<float> MRS::uwt(py::array_t<float>& arr, int Ns)
156153 throw std::runtime_error (" Input map has not expected nside." );
157154 }
158155
159- cout << " alloc ok. Nside = " << Nside << " " << Ns << " , Npix = " << Npix << endl;
156+ // cout << "alloc ok. Nside = " << Nside << " " << Ns << ", Npix = " << Npix << endl;
160157
161158 // Copy the numpy array into a healpix map
162159 Hdmap Map;
@@ -168,27 +165,28 @@ py::array_t<float> MRS::uwt(py::array_t<float>& arr, int Ns)
168165
169166 // Wavelet transform
170167 WT.transform (Map);
171- cout << " transform ok. " << endl;
168+ // cout << "transform ok. " << endl;
172169
173170 // Recopy to numpy array
174- auto arr1 = py::array_t <float >(Npix* WT.nscale ());
171+ auto arr1 = py::array_t <float >({ WT.nscale (), Npix} );
175172 auto buf1 = arr1.request ();
176- pointer = (float *) buf1.ptr ;
173+ pointer = static_cast <float *>(buf1.ptr );
174+
177175 for (int s=0 ; s < WT.nscale (); s++)
178176 for (int i=0 ; i<Npix; i++)
179177 {
180178 pointer[i + s * Npix] = WT.WTTrans (i,s);
181179 }
182- cout << " copy ok. Npix =" << Npix << endl;
180+ // cout << "copy ok. Npix =" << Npix << endl;
183181
184- arr1.resize ({WT.nscale (), Npix});
185- cout << " resize dim = " << arr1.ndim () << " " << arr1.shape (1 )<< " " << arr1.shape (0 ) << endl;
186182 return arr1;
187183
188184}
189185
190186py::array_t <float > MRS::get_tabnorm ()
191187{
188+ int n = WT.TabNorm .nx ();
189+ if (n <= 0 ) throw std::runtime_error (" TabNorm has invalid size" );
192190 auto arr1 = py::array_t <float >(WT.TabNorm .nx ());
193191 auto buf1 = arr1.request ();
194192 float *pointer = (float *) buf1.ptr ;
0 commit comments