Changeset 3449 in Sophya for trunk/SophyaPI/ProgPI
- Timestamp:
- Jan 31, 2008, 7:20:00 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/ProgPI/fitsbtadapter.cc
r3424 r3449 148 148 kw = "readfits"; 149 149 usage = "readfits: Read one or all HDU's of a fits file \n" ; 150 usage += "Usage: readfits FileName [num_hdu] \n";150 usage += "Usage: readfits [-nobsz] FileName [num_hdu] \n"; 151 151 usage += " num_hdu=1,..,NbHDU (uses FitsManager) \n"; 152 usage += "See also scanfits writefits fitsadapt swfitstable "; 152 usage += " -nobsz: Ignore HDU BSCALE/BZERO values -> BSCALE=1, BZERO=0 \n"; 153 usage += "See also rdfitsarr scanfits writefits fitsadapt swfitstable "; 153 154 mpiac->RegisterCommand(kw, usage, this, hgrp); 154 155 … … 156 157 usage = "openfits: alias for readfits \n" ; 157 158 mpiac->RegisterCommand(kw, usage, this, hgrp); 159 160 kw = "rdfitsarr"; 161 usage = "rdfitsarr: Read a single IMAGE HDU of a fits file as an array \n" ; 162 usage += "Usage: rdfitsarr FileName [arrType=D] [num_hdu=1] [arrName] [compd]\n"; 163 usage += " ArrType= I/L/F/D: Array data type (int_4, int_8, r_4, r_8)\n"; 164 usage += " compd : call array.CompactTrailingDimensions()\n"; 165 usage += "See also readfits "; 166 mpiac->RegisterCommand(kw, usage, this, hgrp); 167 158 168 159 169 kw = "swfitstable"; … … 244 254 return 0; 245 255 } 256 257 246 258 else if ((kw == "readfits") || (kw == "openfits")) { 247 if(tokens.size() < 1) { 248 cout<<"Usage: readfits FileName [num_hdu]"<<endl; 249 return 1; 250 } 251 cout << "readfits: Opening fits file " << tokens[0]; 252 FitsInOutFile fis(tokens[0], FitsInOutFile::Fits_RO); 259 if ((tokens.size()<1) || ((tokens[0]=="-nobsz")&&(tokens.size()<2))) { 260 cout<<"Usage: readfits [-nobsz] FileName [num_hdu]"<<endl; 261 return 1; 262 } 263 int offa = 0; 264 bool fgnobsz = false; 265 if (tokens[0] == "-nobsz") { 266 fgnobsz = true; offa = 1; 267 } 268 cout << "readfits: Opening fits file " << tokens[offa]; 269 FitsInOutFile fis(tokens[offa], FitsInOutFile::Fits_RO); 270 if (fgnobsz) fis.SetBScaleBZero(); 253 271 int k1 = 1; 254 272 int k2 = fis.NbHDUs(); 255 273 if (fis.CurrentHDU() > 1) k1 = k2 = fis.CurrentHDU(); 256 274 bool fgshdu = false; 257 if (tokens.size() > 1) { // Numero de HDU specifie258 k2 = k1 = atoi(tokens[ 1].c_str());275 if (tokens.size() > (offa+1)) { // Numero de HDU specifie 276 k2 = k1 = atoi(tokens[offa+1].c_str()); 259 277 fgshdu = true; 260 278 cout << " - HDU Num " << k1 << endl; … … 262 280 else cout << " - HDU's " << k1 << "-" << k2 << endl; 263 281 264 string bnom = omg.GetServiceObj()->FileName2Name(tokens[ 0]);282 string bnom = omg.GetServiceObj()->FileName2Name(tokens[offa]); 265 283 string nom = bnom; 266 284 char bun[16]; … … 292 310 return 0; 293 311 } 312 //-- Lecture d'un tableau depuis fits avec possibilite de specification type 313 else if (kw == "rdfitsarr") { 314 if (tokens.size()<1) { 315 cout << "Usage: rdfitsarr FileName [arrType=D] [num_hdu=1] [arrName] [compd]" << endl; 316 return 1; 317 } 318 char atype = 'D'; 319 if (tokens.size()>1) atype = tokens[1][0]; 320 if ((atype != 'I')&&(atype != 'L')&&(atype != 'F')&&(atype != 'D')) atype = 'D'; 321 int ihdu = 1; 322 if (tokens.size()>2) ihdu = atoi(tokens[2].c_str()); 323 cout << "rdfitsarr: Opening fits file " << tokens[0] << " HDU=" << ihdu << endl; 324 FitsInOutFile fis(tokens[0], FitsInOutFile::Fits_RO); 325 fis.MoveAbsToHDU(ihdu); 326 string arrname = "arr"; 327 if (tokens.size()>3) arrname = tokens[3]; 328 else arrname = omg.GetServiceObj()->FileName2Name(tokens[0]); 329 bool fgcompd = false; 330 if ((tokens.size()>4)&&(tokens[4]=="compd")) fgcompd = true; 331 332 switch (atype) { 333 case 'I' : 334 { 335 TArray<int_4> * arr = new TArray<int_4>; 336 FitsManager::Read(fis, (*arr)); 337 if (fgcompd) arr->CompactTrailingDimensions(); 338 omg.AddObj(arr, arrname, false); 339 } 340 break; 341 case 'L' : 342 { 343 TArray<int_8> * arr = new TArray<int_8>; 344 FitsManager::Read(fis, (*arr)); 345 if (fgcompd) arr->CompactTrailingDimensions(); 346 omg.AddObj(arr, arrname, false); 347 } 348 break; 349 case 'F' : 350 { 351 TArray<r_4> * arr = new TArray<r_4>; 352 FitsManager::Read(fis, (*arr)); 353 if (fgcompd) arr->CompactTrailingDimensions(); 354 omg.AddObj(arr, arrname, false); 355 } 356 break; 357 case 'D' : 358 { 359 TArray<r_8> * arr = new TArray<r_8>; 360 FitsManager::Read(fis, (*arr)); 361 if (fgcompd) arr->CompactTrailingDimensions(); 362 omg.AddObj(arr, arrname, false); 363 } 364 break; 365 366 } 367 } 368 294 369 return(0); 295 370 }
Note:
See TracChangeset
for help on using the changeset viewer.