34 #include "fitshandle.h" 35 #include "share_utils.h" 36 #include "string_utils.h" 42 unsigned int healpix_repcount (tsize npix)
44 if (npix<1024)
return 1;
45 if ((npix%1024)==0)
return 1024;
46 return isqrt (npix/12);
49 bool is_iau (
const fitshandle &inp)
51 if (!inp.key_present(
"POLCCONV"))
return false;
52 string polcconv=inp.get_key<
string>(
"POLCCONV");
53 planck_assert((polcconv==
"COSMO")||(polcconv==
"IAU"),
"bad POLCCONV keyword");
54 return (polcconv==
"IAU");
63 inp.read_entire_column (colnum, myarr);
64 int64 nside = inp.get_key<
int>(
"NSIDE");
65 planck_assert (int64(myarr.size())==12*nside*nside,
66 string(
"mismatch between number of map pixels (" 67 +dataToString(myarr.size())+
") and Nside ("+dataToString(nside)+
")"));
68 map.
Set (myarr, string2HealpixScheme(inp.get_key<
string>(
"ORDERING")));
79 (fitshandle &inp,
int colnum)
87 (fitshandle &inp,
int colnum);
89 (fitshandle &inp,
int colnum);
91 (fitshandle &inp,
int colnum);
94 (
const string &filename,
Healpix_Map<T> &map,
int colnum,
int hdunum)
98 inp.goto_hdu (hdunum);
110 (
const string &filename,
int colnum,
int hdunum)
118 (
const string &filename,
int colnum,
int hdunum);
120 (
const string &filename,
int colnum,
int hdunum);
122 (
const string &filename,
int colnum,
int hdunum);
128 int64 nside = inp.get_key<
int>(
"NSIDE");
130 = string2HealpixScheme(inp.get_key<
string>(
"ORDERING"));
134 planck_assert (multiequal(int64(mapT.
Npix()),inp.nelems(1),inp.nelems(2),
135 inp.nelems(3)),
"mismatch between number of map pixels and Nside");
136 chunkMaker cm(mapT.
Npix(),inp.efficientChunkSize(1));
138 while(cm.getNext(offset,ppix))
140 inp.read_column_raw(1,&mapT[offset],ppix,offset);
141 inp.read_column_raw(2,&mapQ[offset],ppix,offset);
142 inp.read_column_raw(3,&mapU[offset],ppix,offset);
145 for (
int i=0; i<mapU.
Npix(); ++i)
162 inp.goto_hdu(hdunum);
174 (fitshandle &out,
const Healpix_Base &base, PDT datatype,
175 const arr<string> &colname)
177 vector<fitscolumn> cols;
178 int repcount = healpix_repcount (base.
Npix());
179 for (tsize m=0; m<colname.size(); ++m)
180 cols.push_back (fitscolumn (colname[m],
"unknown",repcount, datatype));
181 out.insert_bintab(cols);
182 out.set_key (
"PIXTYPE",
string(
"HEALPIX"),
"HEALPIX pixelisation");
183 string ordering = (base.
Scheme()==
RING) ?
"RING" :
"NESTED";
184 out.set_key (
"ORDERING",ordering,
185 "Pixel ordering scheme, either RING or NESTED");
186 out.set_key (
"NSIDE",base.
Nside(),
"Resolution parameter for HEALPIX");
187 out.set_key (
"FIRSTPIX",0,
"First pixel # (0 based)");
188 out.set_key (
"LASTPIX",base.
Npix()-1,
"Last pixel # (0 based)");
189 out.set_key (
"INDXSCHM",
string(
"IMPLICIT"),
190 "Indexing: IMPLICIT or EXPLICIT");
196 arr<string> colname(1);
197 colname[0] =
"TEMPERATURE";
199 out.write_column(1,map.
Map());
214 arr<string> colname(3);
215 colname[0] =
"TEMPERATURE";
216 colname[1] =
"Q_POLARISATION";
217 colname[2] =
"U_POLARISATION";
219 out.set_key (
"POLCCONV",
string(
"COSMO"));
220 chunkMaker cm(mapT.
Npix(),out.efficientChunkSize(1));
222 while(cm.getNext(offset,ppix))
224 out.write_column_raw(1,&mapT[offset],ppix,offset);
225 out.write_column_raw(2,&mapQ[offset],ppix,offset);
226 out.write_column_raw(3,&mapU[offset],ppix,offset);
void SetNside(int nside, Healpix_Ordering_Scheme scheme)
void Set(arr< T > &data, Healpix_Ordering_Scheme scheme)
void read_Healpix_map_from_fits(fitshandle &inp, Healpix_Map< T > &map, int colnum)
Healpix_Ordering_Scheme Scheme() const
void write_Healpix_map_to_fits(fitshandle &out, const Healpix_Map< T > &map, PDT datatype)
void prepare_Healpix_fitsmap(fitshandle &out, const Healpix_Base &base, PDT datatype, const arr< std::string > &colname)
const arr< T > & Map() const