Skip to content
Snippets Groups Projects
Commit 255ade26 authored by Robert Butora's avatar Robert Butora
Browse files

improves error handling for pixel-cuts (vlkb imcopy)

parent 4dddc8c1
No related branches found
No related tags found
No related merge requests found
......@@ -31,9 +31,7 @@ int stream_cutout(string pathname, int extnum, string region)
{
string pixfilter{ to_cfitsio_format(bnds) };
int rc = imcopy(pathname, extnum, pixfilter, "dummy");
if(rc)
std::cout << "rc = " << rc << std::endl;
imcopy(pathname, extnum, pixfilter, "dummy");
return EXIT_SUCCESS;
}
......@@ -61,7 +59,7 @@ int fits_copy_image_section2(
int imcopy(std::string filename, int extnum, std::string pixfilter, std::string temp_root)
void imcopy(std::string filename, int extnum, std::string pixfilter, std::string temp_root)
{
LOG_trace(__func__);
......@@ -97,7 +95,7 @@ int imcopy(std::string filename, int extnum, std::string pixfilter, std::string
throw runtime_error("fits_open_file to stream failed: " + errmsg);
}
int rc = fits_copy_image_section2(fptr, newfptr, expr, &status);
fits_copy_image_section2(fptr, newfptr, expr, &status);
if (status)
{
string errmsg{fitsfiles::cfitsio_errmsg(__FILE__, __LINE__, status)};
......@@ -118,8 +116,6 @@ int imcopy(std::string filename, int extnum, std::string pixfilter, std::string
string errmsg{fitsfiles::cfitsio_errmsg(__FILE__, __LINE__, status)};
throw runtime_error("fits_close_file cut failed: " + errmsg);
}
return rc;
}
......
......@@ -3,7 +3,7 @@
#include <string>
int imcopy(std::string filename, int extnum, std::string pixfilter, std::string temp_root);
void imcopy(std::string filename, int extnum, std::string pixfilter, std::string temp_root);
int stream_cutout(std::string pathname, int extnum, std::string region);
#endif
......@@ -189,9 +189,15 @@ int cmd_imcopy(int argc, char * argv[])
int extnum = std::stoi(std::string{argv[2]});
std::string pixfilter{argv[3]};
std::string temp_root = ((argc == 5) ? argv[4] : "/tmp" );
int rc = imcopy(infilename, extnum, pixfilter, temp_root);
if(rc)
std::cout << "rc = " << rc << std::endl;
try
{
imcopy(infilename, extnum, pixfilter, temp_root);
}
catch(const std::exception & ex)
{
std::cerr << ex.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
else
......
......@@ -162,12 +162,14 @@ class CutoutImpl implements Cutout
{
/* cutout -> outputStream */
String pixFilterString = pixels_valid ? pixels : boundsString;
String[] cmdCut = new String[6];
cmdCut[0] = "/usr/local/bin/vlkb";
cmdCut[1] = "imcopy";
cmdCut[2] = absPathname;
cmdCut[3] = String.valueOf(hdunum-1);
cmdCut[4] = pixels_valid ? pixels : boundsString;
cmdCut[4] = pixFilterString;
cmdCut[5] = settings.fitsPaths.cutouts();
if(outputStream == null)
......@@ -176,6 +178,15 @@ class CutoutImpl implements Cutout
ExecCmd execCut = new ExecCmd();
execCut.doRun(outputStream, cmdCut);
LOGGER.info("execCut exitValue: " + execCut.exitValue);
boolean cut_successful = (execCut.exitValue == 0);
if(!cut_successful)
{
throw new IllegalArgumentException("cut by pixels not completed for pixels : " + pixFilterString);
}
Instant cutDone = Instant.now();
LOGGER.info("EXECTIME cutDone: " + Duration.between(start, cutDone));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment