00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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
00088
00089
00090 mutable std::vector<long> dm_actuator_lookup_table;
00091
00092
00093
00094
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
00214
00215
00216
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