17 #ifndef __VISAOIMUTILS_H__
18 #define __VISAOIMUTILS_H__
30 #define INT_2BYTES short
94 template <
class dataT>
int visao_fits_create_img( fitsfile *fptr,
int naxis,
long *naxes,
int *status);
95 template <
class dataT>
int visao_fits_write_subset(fitsfile *fptr,
long *fpixel,
long *lpixel,
96 dataT *array,
int *status);
104 int write_visao_raw(
const char * name_base,
sharedimS *sim,
visao_imheader * head,
bool aohead=
true,
bool visaohead=
true);
107 int write_visao_fits_aosys_header(fitsfile * outfptr,
visao_imheader * head);
108 int write_visao_fits_visao_header(fitsfile * outfptr,
visao_imheader * head);
115 long naxes[2], lpix[2],fpix[2];
116 char hfld[81], tmp[30], datestr[80];
117 struct tm *dateobs_tm;
121 fits_get_system_time(datestr, &timeref, &status);
126 if ( !fits_create_file(&outfptr, foutname, &status) )
131 if(!visao_fits_create_img<dataT>(outfptr,2, naxes, &status))
137 visao_fits_write_subset<dataT>(outfptr,fpix, lpix, im, &status);
140 for(i=0;i<81;i++) hfld[i] =
' ';
141 fits_update_key(outfptr, TSTRING,
"DATE", (
void *)datestr,
"Date this file was written YYYY-mm-dd", &status);
144 fits_update_key(outfptr, TSTRING,
"ORIGIN", (
void *)head->origin.c_str(),0, &status);
145 fits_update_key(outfptr, TSTRING,
"TELESCOP", (
void *)head->telescop.c_str(),0, &status);
146 fits_update_key(outfptr, TSTRING,
"INSTRUME", (
void *)head->instrume.c_str(),0, &status);
148 dateobs_tm = gmtime(&head->dateobs.tv_sec);
149 strftime(tmp, 30,
"%Y-%m-%dT%H:%M:%S", dateobs_tm);
150 sprintf(datestr,
"%s.%06u", tmp, (
unsigned) head->dateobs.tv_usec);
152 fits_update_key(outfptr, TSTRING,
"DATE-OBS", (
void *)datestr,
"Date of obs. YYYY-mm-ddTHH:MM:SS", &status);
154 if(head->frameNo > -1) fits_update_key(outfptr, TLONG,
"FRAMENO", (
void *)&head->frameNo,
"Camera frame counter", &status);
156 if(aohead) status = write_visao_fits_aosys_header(outfptr, head);
157 if(visaohead) status = write_visao_fits_visao_header(outfptr, head);
162 fits_close_file(outfptr, &status);
166 if (status) fits_report_error(stderr, status);
184 head->dateobs.tv_sec = sim->frame_time.tv_sec;
185 head->dateobs.tv_usec = sim->frame_time.tv_usec;
186 head->timestamp_dma.tv_sec = sim->frame_time_dma.tv_sec;
187 head->timestamp_dma.tv_usec = sim->frame_time_dma.tv_usec;
189 head->frameNo = sim->frameNo;
192 return write_visao_fits<dataT>(fname.c_str(), sim->nx, sim->ny, sim->imdata, head, aohead, visaohead);
196 int get_fits_im(
unsigned char *im,
long hduno,
long *fpix,
long *lpix, fitsfile **fptr,
const char *fname);
198 int get_fits_im(
float *im,
long hduno,
long *fpix,
long *lpix, fitsfile **fptr,
const char *fname);
200 int get_fits_im(
double *im,
long hduno,
long *fpix,
long *lpix, fitsfile **fptr,
const char *fname);
202 #endif //__VISAOIMUTILS_H__
int write_visao_fits(const char *foutname, int nx, int ny, dataT *im, visao_imheader *head, bool aohead, bool visaohead)
Write a fits file.
Declarations for the VisAO status information structures.
int get_visao_filename(char *buffer, struct timeval *tv)
Writes the standard visao unique filename for a timeval to the buffer.
VisAO software utilitites, declarations.
Declarations for the shared image circular buffer.