Skip to content

Commit

Permalink
SIRENA update (v.8.0.2)
Browse files Browse the repository at this point in the history
- Add a progress bar when running 'teslib' and 'tesrecons'
  (libsixt/initSIRENA.c)
  • Loading branch information
bcobo committed Nov 8, 2023
1 parent 938813b commit 16797d6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 47 deletions.
70 changes: 25 additions & 45 deletions libsixt/initSIRENA.c
Expand Up @@ -405,7 +405,6 @@ int getSamplingrate_trigreclength (char* inputFile, struct Parameters par, doubl
{
// Error status.
int status=EXIT_SUCCESS;

char firstcharAux = inputFile[0];
char firstchar[2] = {firstcharAux , '\0'};

Expand Down Expand Up @@ -621,44 +620,27 @@ int callSIRENA_Filei(char* inputFile, SixtStdKeywords* keywords, ReconstructInit
allocateTesRecord(record,*trig_reclength,record_file->delta_t,0,&status);
if (status != EXIT_SUCCESS) return(EXIT_FAILURE);

// Iterate of records and run SIRENA
/*fitsfile *fptr;
//if (fits_open_file(&fptr, inputFile, READONLY, &status)) {
// fits_report_error(stderr, status);
// return status;
//}
fits_open_file(&fptr, inputFile, READONLY, &status);
// Iteration of records and running SIRENA
// Read numrecords (NAXIS2) to simulate a progress bar
fitsfile *fptr;
if (fits_open_file(&fptr, inputFile, READONLY, &status)) {
SIXT_ERROR("Cannot open the input FITS file to read the number of records (NAXIS2)(in 'callSIRENA_Filei' function).");
return status;
}
fits_movnam_hdu(fptr, ANY_HDU,"TESRECORDS", 0, &status);
//if (status != EXIT_SUCCESS) return(EXIT_FAILURE);
if (status != EXIT_SUCCESS)
{
status = EXIT_SUCCESS;
fits_movnam_hdu(fptr, ANY_HDU,"RECORDS", 0, &status);
if (status != EXIT_SUCCESS)
{
SIXT_ERROR("Cannot find the TESRECORDS (or RECORDS) HDU in the input FITS file to read the number of records (NAXIS2)(in 'callSIRENA_Filei' function).");
return status;
}
}
int numrecords;
fits_read_key(fptr, TINT, "NAXIS2", &numrecords, NULL, &status);
fits_close_file(fptr, &status);
//printf("%s","Paso5\n");
//printf("%s %d %s","NAXIS2=",numrecords,"\n");
//printf("%s","Paso6\n");
//int i;
//int total=numrecords;
// for (i = 0; i <= total; i++) {
// float progress = (float)i / total;
// int bar_width = 50;
// printf("Simulating |");
// int pos = bar_width * progress;
// for (int j = 0; j < bar_width; j++) {
// if (j < pos)
// printf("=");
// else if (j == pos)
// printf(">");
// else
// printf(" ");
// }
// printf("| %.2f%%\r", progress * 100);
// fflush(stdout);
// usleep(100000); // Sleep for a short time to simulate progress
//}
//printf("\n");*/

fits_movnam_hdu(outfile->fptr, ANY_HDU,"EVENTS", 0, &status);
if (status != EXIT_SUCCESS) return(EXIT_FAILURE);
Expand All @@ -670,11 +652,11 @@ int callSIRENA_Filei(char* inputFile, SixtStdKeywords* keywords, ReconstructInit
if (status != EXIT_SUCCESS) return(EXIT_FAILURE);
while(getNextRecord(record_file,record,&lastRecord,&startRecordGroup,&status))
{
/*float progress = (float)nrecord / numrecords;
// Progress bar
float progress = (float)nrecord / (numrecords-1);
int bar_width = 50;
printf("Simulating |");
int pos = bar_width * progress;
printf("Simulating |");
for (int j = 0; j < bar_width; j++) {
if (j < pos)
printf("=");
Expand All @@ -683,15 +665,13 @@ int callSIRENA_Filei(char* inputFile, SixtStdKeywords* keywords, ReconstructInit
else
printf(" ");
}
printf("| %.2f%%\r", progress * 100);
fflush(stdout);
usleep(100000); // Sleep for a short time to simulate progress
if (nrecord == numrecords-1)
{
printf("| %.2f%%\r", progress * 100);
fflush(stdout);
usleep(100000); // Sleep for a short time to simulate progress
printf("\n");
}*/
printf("\n"); // New line after ending "Simulating...."
}

nrecord = nrecord + 1;
/*if(nrecord < 5887)
Expand Down
4 changes: 2 additions & 2 deletions libsixt/versionSIRENA.h
Expand Up @@ -22,11 +22,11 @@
// CANTABRIA (CSIC-UC) with funding from the Spanish Ministry of Science and
// Innovation (MICINN)
//
// DATE: 2023/11/06, 12:19:50
// DATE: 2023/11/08, 14:14:31

#ifndef SIRENA_VERSION_H
#define SIRENA_VERSION_H

#define SIRENA_VERSION "8.0.1"
#define SIRENA_VERSION "8.0.2"

#endif

0 comments on commit 16797d6

Please sign in to comment.