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

cutout for vlkb: implements nullValuesCount when using 'vlkb' exec

parent 109736d3
No related branches found
No related tags found
No related merge requests found
...@@ -19,7 +19,7 @@ public interface Cutout ...@@ -19,7 +19,7 @@ public interface Cutout
public CutResult doFile(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol, public CutResult doFile(String relPathname, int hdunum, Pos pos, Band band, Time time, Pol pol,
boolean countNullValues, FitsCard[] extraCards) boolean countNullValues, FitsCard[] extraCards)
throws IOException, InterruptedException; throws IOException, InterruptedException;
;
} }
...@@ -47,14 +47,6 @@ class CutoutImpl implements Cutout ...@@ -47,14 +47,6 @@ class CutoutImpl implements Cutout
this.settings = settings; this.settings = settings;
} }
/*
public DatasetsImpl(Settings settings, Subsurvey[] subsurveys)
{
LOGGER.info("trace DatasetsImpl(settings, subsurveys)");
this.settings = settings;
this.subsurveys = subsurveys;
}
*/
private String genRegionForVlkbOverlapCmd(Pos pos, Band band) private String genRegionForVlkbOverlapCmd(Pos pos, Band band)
{ {
...@@ -182,6 +174,55 @@ class CutoutImpl implements Cutout ...@@ -182,6 +174,55 @@ class CutoutImpl implements Cutout
} }
private NullValueCount doCountNullValues(String absPathname, int hdunum)
throws IOException, InterruptedException
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
if(bos == null)
throw new AssertionError("byte output stream for bounds was not created, is null");
String[] cmdBounds = new String[3];
cmdBounds[0] = "/usr/local/bin/vlkb";
cmdBounds[1] = "nullvals";
cmdBounds[2] = absPathname;
ExecCmd exec = new ExecCmd();
exec.doRun(bos, cmdBounds);
LOGGER.info("exec NullVals exitValue: " + exec.exitValue);
bos.close();
boolean hasResult = (exec.exitValue == 0);
if(hasResult)
{
String nullValsString = new String(bos.toByteArray());
LOGGER.info("vlkb nullvals: " + nullValsString);
if((nullValsString != null) && nullValsString.trim().isEmpty())
{
throw new AssertionError("'vlkb nullvals' returned empty string");
}
// parse result: '<fill-ratio> <nullvals-count> <tot-count>'
String[] splitStr = nullValsString.trim().split("\\s+");
if(splitStr.length != 3) throw new AssertionError("'vlkb nullvals' did not return 3 numbers but: " + nullValsString);
NullValueCount nvc = new NullValueCount();
nvc.percent = Double.parseDouble(splitStr[0]);
nvc.nullCount = Long.parseLong(splitStr[1]);
nvc.totalCount = Long.parseLong(splitStr[2]);
return nvc;
}
else
{
throw new AssertionError("'vlkb nullvals' exited without results for: " + absPathname);
}
}
public CutResult doFile(String relPathname, int hdunum, public CutResult doFile(String relPathname, int hdunum,
Pos pos, Band band, Time time, Pol pol, Pos pos, Band band, Time time, Pol pol,
boolean countNullValues, FitsCard[] extraCards) boolean countNullValues, FitsCard[] extraCards)
...@@ -210,7 +251,12 @@ class CutoutImpl implements Cutout ...@@ -210,7 +251,12 @@ class CutoutImpl implements Cutout
if(countNullValues) if(countNullValues)
{ {
LOGGER.info("NullValuesCount not implemented when used with Cutout::doStream()"); cutResult.nullValueCount = doCountNullValues(absSubimgPathname, 1);
}
if(extraCards == null || (extraCards.length < 1))
{
LOGGER.info("Adding extraCards to cut-file not implemented when using 'vlkb' exec (implemented in engine vlkbd/AMQP)");
} }
} }
else else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment