PSFEstimationwithCPSO
|
00001 /* 00002 * FitsManager.hpp 00003 * 00004 * Created on: 09/09/2012 00005 * Author: Peter Frank Perroni (pfperroni@inf.ufpr.br) 00006 */ 00007 00008 #ifndef FITSMANAGER_HPP_ 00009 #define FITSMANAGER_HPP_ 00010 00011 #include <dirent.h> 00012 #include <iostream> 00013 #include <string.h> 00014 #include <vector> 00015 #include <fitsio.h> 00016 #include "config.hpp" 00017 #include "util.hpp" 00018 00019 using namespace std; 00020 00025 typedef struct{ 00026 int sequence; 00027 string *img_filename; 00028 double *image; 00029 double *object; 00030 WORD *coefs; 00031 WORD *psf_generated; 00032 WORD *psf_inverted; 00033 WORD *phase_generated; 00034 WORD *conobj; 00035 WORD *img_diff; 00036 } fits_result; 00037 00041 struct fits_ptr{ 00042 fitsfile *fptr; 00043 long first_elem; 00044 }; 00045 00049 struct fits_out_buffer{ 00050 double *buffer; 00051 int pos; 00052 }; 00053 00057 struct word_out_buffer{ 00058 WORD *buffer; 00059 int pos; 00060 }; 00061 00077 class FitsManager{ 00078 static int buffer_size; 00082 static omp_lock_t mutex; 00083 00084 double *object; 00085 fits_result **buffer; 00086 fits_out_buffer psfinv_buffer, psf_buffer, phase_buffer, conobj_buffer, imgdiff_buffer; 00087 word_out_buffer coefs_buffer; 00088 int fits_size, seq_read, seq_write; 00089 int n_zernikes, img_size, fft_size, img_area, phase_area; 00090 char *path_in; 00091 char *path_out; 00092 string *image_filename; 00093 vector<fits_result*> awaiting_buffer; 00094 vector<fits_result*> available_buffer; 00095 vector<string*> files; 00096 fits_ptr fptr_in, fptr_out_psf, fptr_out_psfinv, fptr_out_phase, fptr_out_conobj, fptr_out_imgdiff; 00097 00098 bool multi_files, saved; 00099 00100 void startup(int _n_zernikes, int _img_area, int _size_fft, char *obj_filepath); 00101 00102 void readFitsFile(char* filename, double* image, int size); 00103 00104 void readFitsFile(char* filename, fits_ptr *fptr, bool closeFits, double* image, int size); 00105 00106 int fitsSize(char* filename); 00107 00108 void save_coefs(char *file_name, WORD *coefs, int n_rows, int n_coefs); 00109 00110 void holdData(fits_result *result); 00111 00112 void printerror(int status); 00113 00114 void listFolder(char *folder, vector<string*> &files, const char *extension); 00115 00116 void getFileName(char *fullPath, char *fileName); 00117 00118 bool isFolder(char *folder); 00119 00120 void getFileExtension(char *fullPath, char *fileExtension); 00121 00122 public: 00123 FitsManager(int _n_zernikes, int _img_area, int _size_fft, char *obj_filename, char *_path_in, char *_path_out); 00124 00125 ~FitsManager(); 00126 00127 static void startup(int _bufer_size); 00128 00129 void writeFitsFile(char* filename, WORD* array, int sx, int sy); 00130 00131 void writeFitsFile(char* filename, fits_ptr *ptr, bool closeFits, double* array, int sx, int sy, int sz); 00132 00133 fits_result* nextImage(); 00134 00135 void saveImage(fits_result *result); 00136 00137 double *getObject(); 00138 00139 int size(); 00140 }; 00141 00142 #endif /* FITSMANAGER_HPP_ */