Index: trunk/SophyaPI/ProgPI/fitsbtadapter.cc
===================================================================
--- trunk/SophyaPI/ProgPI/fitsbtadapter.cc	(revision 3424)
+++ trunk/SophyaPI/ProgPI/fitsbtadapter.cc	(revision 3449)
@@ -148,7 +148,8 @@
 kw = "readfits";
 usage = "readfits: Read one or all HDU's of a fits file \n" ;
-usage += "Usage: readfits FileName [num_hdu] \n";
+usage += "Usage: readfits [-nobsz] FileName [num_hdu] \n";
 usage += " num_hdu=1,..,NbHDU (uses FitsManager) \n";
-usage += "See also  scanfits writefits fitsadapt swfitstable ";
+usage += " -nobsz: Ignore HDU BSCALE/BZERO values -> BSCALE=1, BZERO=0 \n";
+usage += "See also rdfitsarr scanfits writefits fitsadapt swfitstable ";
 mpiac->RegisterCommand(kw, usage, this, hgrp); 
 
@@ -156,4 +157,13 @@
 usage = "openfits: alias for readfits \n" ;
 mpiac->RegisterCommand(kw, usage, this, hgrp); 
+
+kw = "rdfitsarr";
+usage = "rdfitsarr: Read a single IMAGE HDU of a fits file as an array \n" ;
+usage += "Usage: rdfitsarr FileName [arrType=D] [num_hdu=1] [arrName] [compd]\n";
+usage += " ArrType= I/L/F/D: Array data type (int_4, int_8, r_4, r_8)\n";
+usage += " compd : call array.CompactTrailingDimensions()\n";
+usage += "See also readfits ";
+mpiac->RegisterCommand(kw, usage, this, hgrp); 
+
 
 kw = "swfitstable";
@@ -244,17 +254,25 @@
   return 0;
 }
+
+
 else if ((kw == "readfits") || (kw == "openfits")) {
-  if(tokens.size() < 1)  {
-    cout<<"Usage: readfits FileName [num_hdu]"<<endl;
-    return 1;
-  }
-  cout << "readfits: Opening  fits file " << tokens[0];
-  FitsInOutFile fis(tokens[0], FitsInOutFile::Fits_RO);
+  if ((tokens.size()<1) || ((tokens[0]=="-nobsz")&&(tokens.size()<2)))  {
+    cout<<"Usage: readfits [-nobsz] FileName [num_hdu]"<<endl;
+    return 1;
+  }
+  int offa = 0; 
+  bool fgnobsz = false;
+  if (tokens[0] == "-nobsz") {
+    fgnobsz = true;  offa = 1;
+  }
+  cout << "readfits: Opening  fits file " << tokens[offa];
+  FitsInOutFile fis(tokens[offa], FitsInOutFile::Fits_RO);
+  if (fgnobsz) fis.SetBScaleBZero();
   int k1 = 1;
   int k2 = fis.NbHDUs();
   if (fis.CurrentHDU() > 1) k1 = k2 = fis.CurrentHDU(); 
   bool fgshdu = false;
-  if (tokens.size() > 1) {  // Numero de HDU specifie
-    k2 = k1 = atoi(tokens[1].c_str());
+  if (tokens.size() > (offa+1)) {  // Numero de HDU specifie
+    k2 = k1 = atoi(tokens[offa+1].c_str());
     fgshdu = true;
     cout << " - HDU Num " << k1 << endl;
@@ -262,5 +280,5 @@
   else cout << " - HDU's " << k1 << "-" << k2 << endl;
 
-  string bnom = omg.GetServiceObj()->FileName2Name(tokens[0]);
+  string bnom = omg.GetServiceObj()->FileName2Name(tokens[offa]);
   string nom = bnom;
   char bun[16];
@@ -292,4 +310,61 @@
   return 0;  
 }
+//-- Lecture d'un tableau depuis fits avec possibilite de specification type
+else if (kw == "rdfitsarr") {
+  if (tokens.size()<1) {  
+    cout << "Usage: rdfitsarr FileName [arrType=D] [num_hdu=1] [arrName] [compd]" << endl;
+    return 1;
+  }
+  char atype = 'D';
+  if (tokens.size()>1) atype = tokens[1][0];
+  if ((atype != 'I')&&(atype != 'L')&&(atype != 'F')&&(atype != 'D'))  atype = 'D';
+  int ihdu = 1;
+  if (tokens.size()>2)  ihdu = atoi(tokens[2].c_str());
+  cout << "rdfitsarr: Opening  fits file " << tokens[0] << " HDU=" << ihdu << endl;
+  FitsInOutFile fis(tokens[0], FitsInOutFile::Fits_RO);
+  fis.MoveAbsToHDU(ihdu);
+  string arrname = "arr";
+  if (tokens.size()>3)  arrname = tokens[3];
+  else arrname = omg.GetServiceObj()->FileName2Name(tokens[0]);
+  bool fgcompd = false;
+  if ((tokens.size()>4)&&(tokens[4]=="compd"))  fgcompd = true;
+
+  switch (atype) {
+    case 'I' : 
+      {
+      TArray<int_4> * arr = new TArray<int_4>;
+      FitsManager::Read(fis, (*arr));
+      if (fgcompd) arr->CompactTrailingDimensions();
+      omg.AddObj(arr, arrname, false);
+      }
+      break;
+    case 'L' : 
+      {
+      TArray<int_8> * arr = new TArray<int_8>;
+      FitsManager::Read(fis, (*arr));
+      if (fgcompd) arr->CompactTrailingDimensions();
+      omg.AddObj(arr, arrname, false);
+      }
+      break;
+    case 'F' : 
+      {
+      TArray<r_4> * arr = new TArray<r_4>;
+      FitsManager::Read(fis, (*arr));
+      if (fgcompd) arr->CompactTrailingDimensions();
+      omg.AddObj(arr, arrname, false);
+      }
+      break;
+    case 'D' : 
+      {
+      TArray<r_8> * arr = new TArray<r_8>;
+      FitsManager::Read(fis, (*arr));
+      if (fgcompd) arr->CompactTrailingDimensions();
+      omg.AddObj(arr, arrname, false);
+      }
+      break;
+
+  }
+}
+
  return(0);
 }
