Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

PALAO_reconstructor.h

Go to the documentation of this file.
00001 /*
00002 Arroyo - software for the simulation of electromagnetic wave propagation
00003 through turbulence and optics.
00004 
00005 Copyright (c) 2000-2004 California Institute of Technology.  Written by
00006 Dr. Matthew Britton.  For comments or questions about this software,
00007 please contact the author at mbritton@astro.caltech.edu.
00008 
00009 This program is free software; you can redistribute it and/or modify it
00010 under the terms of the GNU General Public License as  published by the
00011 Free Software Foundation; either version 2 of the License, or (at your
00012 option) any later version.
00013 
00014 This program is provided "as is" and distributed in the hope that it
00015 will be useful, but WITHOUT ANY WARRANTY; without even the implied
00016 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  In no
00017 event shall California Institute of Technology be liable to any party
00018 for direct, indirect, special, incidental or consequential damages,
00019 including lost profits, arising out of the use of this software and its
00020 documentation, even if the California Institute of Technology has been
00021 advised of the possibility of such damage.   The California Institute of
00022 Technology has no obligation to provide maintenance, support, updates,
00023 enhancements or modifications.  See the GNU General Public License for
00024 more details.
00025 
00026 You should have received a copy of the GNU General Public License along
00027 with this program; if not, write to the Free Software
00028 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00029 */
00030 
00031 #ifndef PALAO_RECONSTRUCTOR_H
00032 #define PALAO_RECONSTRUCTOR_H
00033 
00034 #include "zernike_projected_zonal_reconstructor.h"
00035 #include "arroyo_least_squares_reconstructor.h"
00036 
00037 namespace Arroyo {
00038 
00058 
00059   class PALAO_reconstructor :
00060     public zernike_projected_zonal_reconstructor,
00061     public Arroyo::pixel_array<double> {
00062 
00063     private:
00064 
00065     static const bool factory_registration;
00066 
00069     std::string unique_name() const {return(std::string("PALAO reconstructor"));};
00070 
00073     void create_dm_actuator_lookup_table() const;
00074 
00077     void create_centroid_weighting_lookup_table() const;
00078 
00079     protected:
00080 
00083     PALAO_reconstructor(){
00084       create_dm_actuator_lookup_table();
00085     };
00086 
00087     // a vector whose index corresponds to the index on the 1D array
00088     // generated by the reconstructor, and whose values correspond to
00089     // the dm actuator location index in a 17x17 square grid
00090     mutable std::vector<long> dm_actuator_lookup_table;
00091 
00092     // a vector whose index corresponds to the array of Shack Hartmann
00093     // centroids, and whose values correspond to the weight given to
00094     // the centroid in the tip tilt measurement.
00095     mutable std::vector<double> centroid_weighting_lookup_table;
00096 
00097     public:
00098 
00101     PALAO_reconstructor(const PALAO_reconstructor & palao_recon);
00102 
00105     template<typename T>
00106     PALAO_reconstructor(const arroyo_least_squares_reconstructor<T> & arroyo_recon);
00107 
00110     PALAO_reconstructor(const char * filename);
00111 
00114     PALAO_reconstructor(const Arroyo::iofits & iof);
00115 
00118     ~PALAO_reconstructor(){};
00119 
00122     PALAO_reconstructor & operator=(const PALAO_reconstructor & palao_recon);
00123 
00126     void read(const char * filename);
00127 
00130     void read(const Arroyo::iofits & iof);
00131 
00134     void write(const char * filename) const;
00135  
00138     void write(Arroyo::iofits & iof) const;
00139  
00142     void print(std::ostream & os, const char * prefix="") const;
00143 
00147     vector<long> get_centroid_axes() const;
00148 
00152     vector<long> get_actuator_axes() const;
00153 
00162     Arroyo::zernike get_zernike_modes() const;
00163 
00170     void reconstruct_zernike_residuals(const Arroyo::Shack_Hartmann_centroids & shcentroids, 
00171                                        Arroyo::zernike & znke) const;
00172 
00176     void reconstruct_zonal_residuals(const Arroyo::Shack_Hartmann_centroids & shcentroids, 
00177                                      Arroyo::pixel_array<double> & pixarr) const;
00178 
00186     void reconstruct_residuals(const Arroyo::Shack_Hartmann_centroids & shcentroids, 
00187                                Arroyo::zernike & znke, 
00188                                Arroyo::pixel_array<double> & pixarr) const;
00189   };
00190 
00191   template<typename T>
00192   PALAO_reconstructor::PALAO_reconstructor(const arroyo_least_squares_reconstructor<T> & arroyo_recon){
00193 
00194     vector<long> arroyo_axes = arroyo_recon.get_axes();
00195 
00196     if(arroyo_axes[0]!=512 || 
00197        arroyo_axes[1]!=292){
00198       cerr << "PALAO_reconstructor::PALAO_reconstructor error - mismatched axes\n";
00199       cerr << arroyo_axes[0] 
00200            << ", "
00201            << arroyo_axes[1]
00202            << endl;
00203       throw(string("PALAO_reconstructor::PALAO_reconstructor"));
00204     }
00205 
00206     vector<long> palao_axes(2,512);
00207     palao_axes[1] = 256;
00208     this->pixel_array<double>::set_axes(palao_axes);
00209     
00210     bool entire_row_zero;
00211     int row_count=-1;
00212     int npalao_rows = 243;
00213     // These conversion facs scale the arroyo recon matrix elements
00214     // to the values used at Palomar.  Actuator commands are the
00215     // product of the matrix elements times the gain, so overall
00216     // normalizations end up absorbed into the control loop gains.
00217     double ho_conversion_fac = .70201;
00218     double tt_conversion_fac = .5403125;
00219     for(int j=0; j<npalao_rows; j++){
00220       
00221       entire_row_zero = true;
00222       while(entire_row_zero){
00223         row_count++;
00224         for(int i=0; i<arroyo_axes[0]; i++){
00225           if(fabs(arroyo_recon.data(arroyo_axes[0]*row_count+i))>1e-6){
00226             entire_row_zero = false;
00227             break;
00228           }
00229         }
00230       }
00231         
00232       if(entire_row_zero==false){
00233         for(int i=0; i<arroyo_axes[0]/2; i++){
00234 
00235           if(j<npalao_rows-2){
00236             this->pixeldata[j*palao_axes[0]+2*i] = 
00237               -ho_conversion_fac*arroyo_recon.data(arroyo_axes[0]*row_count+i+arroyo_axes[0]/2);
00238             this->pixeldata[j*palao_axes[0]+2*i+1] = 
00239               ho_conversion_fac*arroyo_recon.data(arroyo_axes[0]*row_count+i);
00240           } else {
00241             this->pixeldata[j*palao_axes[0]+2*i] = 
00242               tt_conversion_fac*arroyo_recon.data(arroyo_axes[0]*row_count+i);
00243             this->pixeldata[j*palao_axes[0]+2*i+1] = 
00244               -tt_conversion_fac*arroyo_recon.data(arroyo_axes[0]*row_count+i+arroyo_axes[0]/2);
00245           }
00246 
00247         }
00248       }
00249     }
00250   };
00251 
00252 }
00253 
00254 #endif

Generated on Thu Nov 29 17:16:30 2007 for arroyo by  doxygen 1.3.9.1