520 cout <<
" *" << ClassName() <<
"::LoadHeaderInfo* Could not open " <<
fFilenameFilter << endl;
528 fits_get_hdu_num(
fInput,&hdunum);
533 fits_get_hdu_type(
fInput,&hdutype,&status);
538 cout <<
" *" << ClassName() <<
"::LoadHeaderInfo* Could not retrieve the HDU type." << endl;
539 fits_close_file(
fInput,&status);
550 fits_get_hdrspace(
fInput,&nkeys,&morekeys,&status);
555 cout <<
" *" << ClassName() <<
"::LoadHeaderInfo* Could not retrieve the HDU header space." << endl;
556 fits_close_file(
fInput,&status);
567 char keyname[FLEN_KEYWORD+1];
568 char keyvalue[FLEN_VALUE+1];
569 char comment[FLEN_COMMENT+1];
571 for (Int_t i=1; i<=nkeys; i++)
573 fits_read_keyn(
fInput,i,keyname,keyvalue,comment,&status);
578 cout <<
" *" << ClassName() <<
"::LoadHeaderInfo* Could not retrieve info of HDU key record "<< i << endl;
579 fits_close_file(
fInput,&status);
609 fits_get_num_rows(
fInput,&nrows,&status);
614 cout <<
" *" << ClassName() <<
"::LoadHeaderInfo* Could not retrieve number of table rows." << endl;
615 fits_close_file(
fInput,&status);
624 fits_get_num_cols(
fInput,&ncols,&status);
629 cout <<
" *" << ClassName() <<
"::LoadHeaderInfo* Could not retrieve number of table columns." << endl;
630 fits_close_file(
fInput,&status);
646 fits_get_colname(
fInput,CASEINSEN,(
char*)
"*",colname,&jcol,&status);
648 if (status==COL_NOT_FOUND)
651 cout <<
" *" << ClassName() <<
"::LoadHeaderInfo* Could not find any table column." << endl;
652 fits_close_file(
fInput,&status);
658 if (jcol>0 && jcol<=ncols)
fColumnNames[jcol-1]=colname;
660 while (status==COL_NOT_UNIQUE)
662 fits_get_colname(
fInput,CASEINSEN,(
char*)
"*",colname,&jcol,&status);
663 if (jcol>0 && jcol<=ncols)
fColumnNames[jcol-1]=colname;
665 if (status && status!=COL_NOT_FOUND)
668 cout <<
" *" << ClassName() <<
"::LoadHeaderInfo* Could not retrieve name of table column " << jcol << endl;
669 fits_close_file(
fInput,&status);
682 fits_get_coltype(
fInput,jcol,&typecode,&repeat,&width,&status);
687 cout <<
" *" << ClassName() <<
"::LoadHeaderInfo* Could not retrieve data type of table column " << jcol << endl;
688 fits_close_file(
fInput,&status);
696 if (typecode==TSTRING) dim=Int_t(repeat/width);
701 if (typecode==TSTRING)
706 else if (typecode==TLOGICAL)
711 else if (typecode==TCOMPLEX || typecode==TDBLCOMPLEX)
730 fits_get_img_dim(
fInput,&ndims,&status);
735 cout <<
" *" << ClassName() <<
"::LoadHeaderInfo* Could not retrieve the number of dimensions of the Image." << endl;
736 fits_close_file(
fInput,&status);
750 long* dimsizes=
new long[ndims];
751 fits_get_img_size(
fInput,ndims,dimsizes,&status);
756 cout <<
" *" << ClassName() <<
"::LoadHeaderInfo* Could not retrieve the sizes of the dimensions of the Image." << endl;
757 fits_close_file(
fInput,&status);
765 fSizes=
new TArrayI(ndims);
766 for (Int_t i= 0; i<ndims; i++)
768 fSizes->SetAt(dimsizes[i],i);
913 fits_open_file(&fp,
fFilename.Data(),READONLY,&status);
917 cout <<
" *" << ClassName() <<
"::GetHDUCount* Could not open file : " <<
fFilename << endl;
918 fits_close_file(fp,&status);
923 fits_get_num_hdus(fp,&n,&status);
927 cout <<
" *" << ClassName() <<
"::GetHDUCount* Could not read the number of HDUs" << endl;
928 fits_close_file(fp,&status);
935 fits_close_file(fp,&status);
1096 long long rownum=row;
1100 fits_read_descript(
fInput,colnum,rownum,&repeat,&offset,&status);
1111 if (dim<=0)
return 0;
1116 double* array=
new double[dim];
1120 bool* barray=
new bool[dim];
1122 fits_read_col(
fInput,TLOGICAL,col,row,1,dim,&bnulval,barray,&anynul,&status);
1123 for (Int_t i=0; i<dim; i++)
1125 array[i]=double(barray[i]);
1131 fits_read_col(
fInput,TDOUBLE,col,row,1,dim,&nulval,array,&anynul,&status);
1137 cout <<
" *" << ClassName() <<
"::GetTableCell* Could not retrieve data type of table cell ["
1138 << row <<
"," << col <<
"]." << endl;
1139 fits_close_file(
fInput,&status);
1147 for (Int_t i=0; i<dim; i++)
1149 arr.SetAt(array[i],i);
1283 if (!arr) arr=
new TString[1];
1293 long long rownum=row;
1297 fits_read_descript(
fInput,colnum,rownum,&repeat,&offset,&status);
1308 if (dim<=0)
return 0;
1313 fits_get_col_display_width(
fInput,col,&dispwidth,&status);
1318 cout <<
" *" << ClassName() <<
"::GetTableCell* Could not retrieve string width of table cell ["
1319 << row <<
"," << col <<
"]." << endl;
1320 fits_close_file(
fInput,&status);
1325 if (dispwidth<=0) dispwidth=1;
1328 char* nulval=(
char*)
"";
1330 char** array=
new char*[dim];
1331 for (Int_t i=0; i<dim; i++)
1333 array[i]=
new char[dispwidth+1];
1335 fits_read_col(
fInput,TSTRING,col,row,1,dim,nulval,array,&anynul,&status);
1340 cout <<
" *" << ClassName() <<
"::GetTableCell* Could not retrieve string of table cell ["
1341 << row <<
"," << col <<
"]." << endl;
1342 fits_close_file(
fInput,&status);
1350 arr=
new TString[dim];
1351 for (Int_t j=0; j<dim; j++)
1952 TString title=
"Histogram of layer ";
1954 his.SetTitle(title.Data());
1959 if (!npix)
return 0;
1961 Int_t nrows=m.GetNrows();
1962 Int_t ncols=m.GetNcols();
1965 his.SetBins(ncols+1,0,ncols,nrows+1,0,nrows);
1969 for (Int_t icol=0; icol<ncols; icol++)
1971 for (Int_t irow=0; irow<nrows; irow++)
1974 his.SetBinContent(icol+1,irow+1,val);
2018 Int_t ndims=
fSizes->GetSize();
2020 if (ndims<1 || ifirst.GetSize()<ndims || ilast.GetSize()<ndims || incr.GetSize()<ndims)
return 0;
2023 long* fpixel=
new long[ndims];
2024 long* lpixel=
new long[ndims];
2025 long* inc=
new long[ndims];
2026 long long npixels=1;
2032 for (Int_t i=0; i<ndims; i++)
2034 istart=ifirst.At(i);
2038 if (istart<1 || iend<1 || istep<1 || iend<istart)
2041 cout <<
" *" << ClassName() <<
"::GetImageArray* Inconsistent ifirst, ilast or incr input array(s)." << endl;
2042 fits_close_file(
fInput,&status);
2053 if (iend>istart) npixels*=1+(iend-istart)/istep;
2056 if (!npixels) npixels=1;
2057 double* pixels=
new double[npixels];
2062 fits_read_subset(
fInput,TDOUBLE,fpixel,lpixel,inc,(
void*)&nulval,(
void*)pixels,&anynul,&status);
2067 cout <<
" *" << ClassName() <<
"::GetImageArray* Could not read pixel data." << endl;
2068 fits_close_file(
fInput,&status);
2080 for (
long long i=0; i<npixels; i++)
2086 UInt_t npix=npixels;
2126 if (ndims<1 || ifirst.GetSize()<ndims)
return 0;
2129 for (Int_t i=1; i<=ndims; i++)
2134 if (npix>nmax)
return 0;
2137 long* fpixel=
new long[ndims];
2141 for (Int_t i=0; i<ndims; i++)
2143 istart=ifirst.At(i);
2148 cout <<
" *" << ClassName() <<
"::GetImageArray* Inconsistent ifirst input array." << endl;
2149 fits_close_file(
fInput,&status);
2158 long long npixels=npix;
2159 double* pixels=
new double[npixels];
2163 fits_read_pix(
fInput,TDOUBLE,fpixel,npixels,(
void*)&nulval,(
void*)pixels,&anynul,&status);
2168 cout <<
" *" << ClassName() <<
"::GetImageArray* Could not read pixel data." << endl;
2169 fits_close_file(
fInput,&status);
2179 for (
long long i=0; i<npixels; i++)
2185 UInt_t nread=npixels;
2219 cout <<
" *" << ClassName() <<
"::ListTable* This is not a table HDU." << endl;
2225 cout <<
" *" << ClassName() <<
"::ListTable* Invalid argument : width=" << width << endl;
2233 if (rstart<=0 || rstart>
fNrows || rend<=0 || rend>
fNrows ||
2236 cout <<
" *" << ClassName() <<
"::ListTable* Invalid input rstart=" << rstart <<
" rend=" << rend
2237 <<
" cstart=" << cstart <<
" cend=" << cend << endl;
2248 cout <<
" *" << ClassName() <<
"::ListTable* Table column description for col=["
2249 << cstart <<
"," << cend <<
"] (name width is " << width <<
" characters)."<< endl;
2252 for (Int_t i=cstart; i<=cend; i++)
2264 name=name.Strip(name.kBoth,
' ');
2267 cout <<
" " << name <<
" : " << type;
2268 if (type.Contains(
"ARRAY")) cout <<
"[" <<
fColumnLayers[i-1] <<
"]";
2278 cout <<
" *" << ClassName() <<
"::ListTable* Table contents for row=[" << rstart <<
"," << rend <<
"] and"
2279 <<
" col=[" << cstart <<
"," << cend <<
"] (column width is " << width <<
" characters)."<< endl;
2283 if (width<7) width=7;
2287 for (Int_t col=cstart; col<=cend; col++)
2290 str=str.Strip(str.kBoth,
' ');
2292 if (col==cstart) cout <<
" ";
2293 printf(
"%s| ",str.Data());
2297 if (nchars>0) nchars--;
2308 for (Int_t row=rstart; row<=rend; row++)
2310 for (Int_t col=cstart; col<=cend; col++)
2312 if (col==cstart) cout <<
" ";
2316 if (!ndim) str=
"---";
2317 str=str.Strip(str.kBoth,
' ');
2319 printf(
"%s",str.Data());
2328 printf(
"%-*.*g",width,prec,val);
2332 printf(
"%s",str.Data());
2380 fits_open_file(&fp,
fFilename.Data(),READONLY,&status);
2384 cout <<
" *" << ClassName() <<
"::ListFileHeader* Could not open file : " <<
fFilename << endl;
2385 fits_close_file(fp,&status);
2392 cout <<
" *" << ClassName() <<
"::ListFileHeader* Short summary of the FITS file header information" << endl;
2396 cout <<
" *" << ClassName() <<
"::ListFileHeader* Full FITS file header information" << endl;
2402 fits_get_num_hdus(fp,&nhdus,&status);
2406 cout <<
" *" << ClassName() <<
"::ListFileHeader* Could not read the number of HDUs" << endl;
2407 fits_close_file(fp,&status);
2411 cout <<
" Total number of HDUs : " << nhdus << endl;
2417 char keyname[FLEN_KEYWORD+1];
2418 char keyvalue[FLEN_VALUE+1];
2419 char comment[FLEN_COMMENT+1];
2422 TString* keynames=0;
2423 TString* keyvalues=0;
2424 TString* comments=0;
2425 for (Int_t jhdu=1; jhdu<=nhdus; jhdu++)
2428 fits_get_hdu_type(fp,&hdutype,&status);
2432 cout <<
" *" << ClassName() <<
"::ListFileHeader* Could not read the type of HDU ["<< (jhdu-1) <<
"]" << endl;
2433 fits_close_file(fp,&status);
2438 if (hdutype==IMAGE_HDU) exttype=
"IMAGE";
2439 if (hdutype==ASCII_TBL) exttype=
"ASCII-TABLE";
2440 if (hdutype==BINARY_TBL) exttype=
"BINARY-TABLE";
2443 fits_get_hdrspace(fp,&nkeys,&morekeys,&status);
2447 cout <<
" *" << ClassName() <<
"::ListFileHeader* Could not read the header space of HDU ["<< (jhdu-1) <<
"]" << endl;
2448 fits_close_file(fp,&status);
2452 keynames=
new TString[nkeys];
2453 keyvalues=
new TString[nkeys];
2454 comments=
new TString[nkeys];
2458 for (Int_t i=1; i<=nkeys; i++)
2460 fits_read_keyn(fp,i,keyname,keyvalue,comment,&status);
2464 cout <<
" *" << ClassName() <<
"::ListFileHeader* Could not read key number " << i <<
" of HDU ["<< (jhdu-1) <<
"]" << endl;
2465 fits_close_file(fp,&status);
2466 if (keynames)
delete[] keynames;
2467 if (keyvalues)
delete[] keyvalues;
2468 if (comments)
delete[] comments;
2472 keynames[i-1]=keyname;
2473 keyvalues[i-1]=keyvalue;
2474 comments[i-1]=comment;
2477 if (keynames[i-1]==
"EXTNAME")
2479 extname=keyvalues[i-1];
2480 extname.ReplaceAll(
"'",
"");
2481 extname=extname.Strip(extname.kBoth,
' ');
2482 extname.Prepend(
"[");
2488 cout <<
" [" << (jhdu-1) <<
"] " << exttype <<
" " << extname << endl;
2493 for (Int_t i=0; i<nkeys; i++)
2495 printf(
" %-8s = %-s",keynames[i].Data(),keyvalues[i].Data());
2496 if (comments[i].Length()>0) printf(
" / %-s",comments[i].Data());
2502 if (keynames)
delete[] keynames;
2503 if (keyvalues)
delete[] keyvalues;
2504 if (comments)
delete[] comments;
2509 fits_movrel_hdu(fp,1,&hdutype,&status);
2513 cout <<
" *" << ClassName() <<
"::ListFileHeader* Could not move to HDU [" << jhdu <<
"]" << endl;
2514 fits_close_file(fp,&status);
2521 fits_close_file(fp,&status);
2613 UInt_t npix=arr.GetSize();
2620 for (UInt_t i=0; i<npix; i++)
2631 if (val<minval) minval=val;
2632 if (val>maxval) maxval=val;
2635 Double_t range=maxval-minval;
2637 if (range>0) fact=max/range;
2639 for (UInt_t i=0; i<npix; i++)
2648 val=fact*(val-minval);