Cryptic error scripting SubframeSelector

tcpalmer

New member
Hi all -
I'm trying to automate my preprocessing and have run into a problem with the SubframeSelector process. I've got code that determines the lights and flats for multiple sessions and then automatically generates the JS code to preprocess. The approach was working fine with ImageCalibration, ImageIntegration, and CosmeticCorrection but I hit a wall with SubframeSelector.

This is on a Mac Catalina 10.15.7 using PI 1.8.8-7.

Test code is below. I thought the problem might be related to trying to set the approval/weighting expressions but it fails with or without those.

var sfs_light_S01_Ha = new SubframeSelector;
sfs_light_S01_Ha.routine = SubframeSelector.prototype.MeasureSubframes;
sfs_light_S01_Ha.subframes = [ // subframeEnabled, subframePath
[true, "/Astrophotography/TEST_GEN/Target/processing-test/Light/session-01/Ha_c_cc/S01_180sec_Ha_gain_139_offset_21_1x1__0001_c_cc.xisf"],
//...
[true, "/Astrophotography/TEST_GEN/Target/processing-test/Light/session-01/Ha_c_cc/S01_180sec_Ha_gain_139_offset_21_1x1__0010_c_cc.xisf"]
];
sfs_light_S01_Ha.fileCache = false;
sfs_light_S01_Ha.subframeScale = 1.3751;
sfs_light_S01_Ha.cameraGain = 1.0000;
sfs_light_S01_Ha.cameraResolution = SubframeSelector.prototype.Bits12;
sfs_light_S01_Ha.siteLocalMidnight = 24;
sfs_light_S01_Ha.scaleUnit = SubframeSelector.prototype.ArcSeconds;
sfs_light_S01_Ha.dataUnit = SubframeSelector.prototype.Electron;
sfs_light_S01_Ha.trimmingFactor = 0.10;
sfs_light_S01_Ha.structureLayers = 5;
sfs_light_S01_Ha.noiseLayers = 0;
sfs_light_S01_Ha.hotPixelFilterRadius = 1;
sfs_light_S01_Ha.applyHotPixelFilter = false;
sfs_light_S01_Ha.noiseReductionFilterRadius = 0;
sfs_light_S01_Ha.sensitivity = 0.1000;
sfs_light_S01_Ha.peakResponse = 0.8000;
sfs_light_S01_Ha.maxDistortion = 0.5000;
sfs_light_S01_Ha.upperLimit = 1.0000;
sfs_light_S01_Ha.backgroundExpansion = 3;
sfs_light_S01_Ha.xyStretch = 1.5000;
sfs_light_S01_Ha.psfFit = SubframeSelector.prototype.Gaussian;
sfs_light_S01_Ha.psfFitCircular = false;
sfs_light_S01_Ha.pedestal = 0;
sfs_light_S01_Ha.roiX0 = 0;
sfs_light_S01_Ha.roiY0 = 0;
sfs_light_S01_Ha.roiX1 = 0;
sfs_light_S01_Ha.roiY1 = 0;
sfs_light_S01_Ha.inputHints = "";
sfs_light_S01_Ha.outputHints = "";
sfs_light_S01_Ha.outputDirectory = "/Astrophotography/TEST_GEN/Target/processing-test/Light/session-01/Ha_c_cc_a";
sfs_light_S01_Ha.outputExtension = ".xisf";
sfs_light_S01_Ha.outputPrefix = "";
sfs_light_S01_Ha.outputPostfix = "_a";
sfs_light_S01_Ha.outputKeyword = "SSWEIGHT";
sfs_light_S01_Ha.overwriteExistingFiles = false;
sfs_light_S01_Ha.onError = SubframeSelector.prototype.Continue;
//sfs_light_S01_Ha.approvalExpression = "((15*(1-(FWHM-FWHMMin)/(FWHMMax-FWHMMin)) + 15*(1-(Eccentricity-EccentricityMin)/(EccentricityMax-EccentricityMin)) + 20*(SNRWeight-SNRWeightMin)/(SNRWeightMax-SNRWeightMin))+50)>=65";
//sfs_light_S01_Ha.weightingExpression = "(15*(1-(FWHM-FWHMMin)/(FWHMMax-FWHMMin)) + 15*(1-(Eccentricity-EccentricityMin)/(EccentricityMax-EccentricityMin)) + 20*(SNRWeight-SNRWeightMin)/(SNRWeightMax-SNRWeightMin))+50";
sfs_light_S01_Ha.approvalExpression = "";
sfs_light_S01_Ha.weightingExpression = "";
sfs_light_S01_Ha.sortProperty = SubframeSelector.prototype.Index;
sfs_light_S01_Ha.graphProperty = SubframeSelector.prototype.Weight;
//sfs_light_S01_Ha.measurements = [ measurementIndex, measurementEnabled, measurementLocked, measurementPath, measurementWeight, measurementFWHM, measurementEccentricity, measurementSNRWeight, measurementMedian, measurementMedianMeanDev, measurementNoise, measurementNoiseRatio, measurementStars, measurementStarResidual, measurementFWHMMeanDev, measurementEccentricityMeanDev, measurementStarResidualMeanDev];

sfs_light_S01_Ha.executeGlobal()

Here's the console output:

run --execute-mode=auto "/Astrophotography/TEST_GEN/Target/processing-test/scripts/sfsTest2.js"

Processing script file: /Astrophotography/TEST_GEN/Target/processing-test/scripts/sfsTest2.js

SubframeSelector: Global context

Measuring of 10 subframes:
* Using 10 worker threads

[000] Measuring subframe 1 of 10
Loading image: w=4656 h=3520 n=1 Gray Float32

[001] Measuring subframe 2 of 10
Loading image: w=4656 h=3520 n=1 Gray Float32

...

[009] Measuring subframe 10 of 10
Loading image: w=4656 h=3520 n=1 Gray Float32

* Waiting for running tasks to terminate...


Measuring: /Astrophotography/TEST_GEN/Target/processing-test/Light/session-01/Ha_c_cc/S01_180sec_Ha_gain_139_offset_21_1x1__0009_c_cc.xisf
Image Calculations: 4.801 s
Star Detector: 3.531 s
1247 Star(s) detected
1221 PSF(s) fitted

...

Measuring: /Astrophotography/TEST_GEN/Target/processing-test/Light/session-01/Ha_c_cc/S01_180sec_Ha_gain_139_offset_21_1x1__0006_c_cc.xisf
Image Calculations: 5.691 s
Star Detector: 5.702 s
1315 Star(s) detected
1290 PSF(s) fitted

===== SubframeSelector: 10 succeeded, 0 failed, 0 skipped =====
*** Error: Unknown exception
<* failed *>

Any ideas? Is PI writing any additional error details to some log?

Thanks -
- Tom
 
My understanding is that SubframeSelector always generates an error in a script but still produces correct result. Do you get correct output, or does it fail to do that also?
 
I've gotten around this for the most part by calling launchInterface() on the instance before executeGlobal(). Since doing that, I seem to be able to get it to reliably run.

After the execution is complete, I read the measurements property to get the subframe details. However, the values you get aren't what you see in the SFS table:
  • My approval formula has not been applied even though the expression shows in the UI
  • The weight value has not been calculated even though the expression shows in the UI
  • The reported FWHM values need to divided by 1/subframeScale used
I've got code that handles all this and outputs CSV files ... but I would expect that the measurements property would reflect what you see in the table immediately after the execution so I didn't have to do it manually ...

Cheers -
- Tom
 
Integresting, I need to check my code. I have a very simple use case, I use it just to calculate weight. And I have never heard about launchInterface(), that was useful information too.

Jarmo
 
Back
Top