56 while(cm.getNext(offset,ppix))
61 for (
tsize i=0; i<ppix; ++i)
63 int l =
isqrt(index[i]-1);
64 int m = index[i] - l*l - l - 1;
71 void get_almsize(
const string &filename,
int &lmax,
int &mmax,
int hdunum)
85 for (
int hdu=2; hdu<=4; ++hdu)
89 if (tlmax>lmax) lmax=tlmax;
90 if (tmmax>mmax) mmax=tmmax;
101 alms.Set(lmax, mmax);
103 int max_index = lmax*lmax + lmax + mmax + 1;
106 while(cm.getNext(offset,ppix))
114 for (
tsize i=0; i<ppix; ++i)
116 if (index[i]>max_index)
continue;
118 int l =
isqrt(index[i]-1);
119 int m = index[i] - l*l - l - 1;
122 if ((l<=lmax) && (m<=mmax))
123 alms(l,m) = xcomplex<T> (re[i], im[i]);
129 Alm<xcomplex<double> > &alms,
int lmax,
int mmax);
131 Alm<xcomplex<float> > &alms,
int lmax,
int mmax);
135 (
const string &filename,
Alm<xcomplex<T> >&alms,
int lmax,
int mmax,
145 Alm<xcomplex<double> > &alms,
int lmax,
int mmax,
int hdunum);
147 Alm<xcomplex<float> > &alms,
int lmax,
int mmax,
int hdunum);
154 vector<fitscolumn> cols;
155 cols.push_back (
fitscolumn(
"index",
"l*l+l+m+1",1,PLANCK_INT32));
156 cols.push_back (
fitscolumn(
"real",
"unknown",1,datatype));
157 cols.push_back (
fitscolumn(
"imag",
"unknown",1,datatype));
162 int lm=alms.Lmax(), mm=alms.Mmax();
163 int n_alms = ((mmax+1)*(mmax+2))/2 + (mmax+1)*(lmax-mmax);
168 while(cm.getNext(offset,ppix))
172 for (
tsize i=0; i<ppix; ++i)
174 index[i] = l*l + l + m + 1;
175 if ((l<=lm) && (m<=mm))
176 { re[i] = alms(l,m).real(); im[i] = alms(l,m).imag(); }
178 { re[i] = 0; im[i] = 0; }
180 if ((m>l) || (m>mmax)) { ++l; m=0; }
186 out.
set_key(
"MAX-LPOL",lmax,
"highest l in the table");
187 out.
set_key(
"MAX-MPOL",mmax,
"highest m in the table");
191 (
fitshandle &out,
const Alm<xcomplex<double> > &alms,
int lmax,
192 int mmax,
PDT datatype);
194 (
fitshandle &out,
const Alm<xcomplex<float> > &alms,
int lmax,
195 int mmax,
PDT datatype);
202 vector<fitscolumn> cols;
203 cols.push_back (
fitscolumn(
"index",
"l*l+l+m+1",1,PLANCK_INT32));
204 cols.push_back (
fitscolumn(
"real",
"unknown",1,datatype));
205 cols.push_back (
fitscolumn(
"imag",
"unknown",1,datatype));
211 for (
int m=0; m<=mmax; ++m)
212 for (
int l=m; l<=lmax; ++l)
213 if (norm(alms(l,m))>0) ++n_alms;
216 int real_lmax=0, real_mmax=0;
219 while(cm.getNext(offset,ppix))
223 for (
tsize i=0; i<ppix; ++i)
225 while (norm(alms(l,m))==0)
228 if ((m>l) || (m>mmax)) { ++l; m=0; }
230 index[i] = l*l + l + m + 1;
231 re[i] = alms(l,m).real();
232 im[i] = alms(l,m).imag();
233 if (l>real_lmax) real_lmax=l;
234 if (m>real_mmax) real_mmax=m;
236 if ((m>l) || (m>mmax)) { ++l; m=0; }
242 out.
set_key(
"MAX-LPOL",real_lmax,
"highest l in the table");
243 out.
set_key(
"MAX-MPOL",real_mmax,
"highest m in the table");
247 (
fitshandle &out,
const Alm<xcomplex<double> > &alms,
int lmax,
248 int mmax,
PDT datatype);
250 (
fitshandle &out,
const Alm<xcomplex<float> > &alms,
int lmax,
251 int mmax,
PDT datatype);
void write_Alm_to_fits(fitshandle &out, const Alm< xcomplex< T > > &alms, int lmax, int mmax, PDT datatype)
T1 safe_cast(const T2 &arg)
int64 nelems(int i) const
void get_key(const std::string &name, T &value) const
void open(const std::string &fname)
int64 efficientChunkSize(int i) const
void read_Alm_from_fits(fitshandle &inp, Alm< xcomplex< T > > &alms, int lmax, int mmax)
void insert_bintab(const std::vector< fitscolumn > &cols, const std::string &extname="xtension")
void get_almsize_pol(const std::string &filename, int &lmax, int &mmax)
void write_column(int colnum, const arr< T > &data, int64 offset=0)
void set_key(const std::string &name, const T &value, const std::string &comment="")
void read_column(int colnum, arr< T > &data, int64 offset=0) const
void get_almsize(fitshandle &inp, int &lmax, int &mmax)
#define planck_assert(testval, msg)
bool key_present(const std::string &name) const
void write_compressed_Alm_to_fits(fitshandle &out, const Alm< xcomplex< T > > &alms, int lmax, int mmax, PDT datatype)