Author Topic: Extending the automation of the batch preprocessing script  (Read 2506 times)

Offline Srgilbert69

  • Newcomer
  • Posts: 6
Hi All, relatively new to pixinsight and have been trying to develop a workflow for pre-processing. Mainly based on this tutorial https://www.lightvortexastronomy.com/tutorial-pre-processing-calibrating-and-stacking-images-in-pixinsight.html

If I take a 6 panel mosaic in narrow band I find myself doing the same set of actions 18+ times and am hoping to automate most of them.

Have recently started to look at the scripting options available and look at extending the batch preprocessing script to cover more of the process described in the tutorial. Have made some progress but am struggling with a few things. Basically I use the filenaming convention of sequence generator pro to split my files into the panel they belong to and teh filter used after calibration the process with take all files using filenames such as B33-1_120sec_1x1_HA_frame2.fit and will group on files matching up to the _frame[xx].fit

           var vImageSets = new Array;
           for (var tt=0; tt < images.length; tt++)
            {
                var filePath = images;
                var vPos = filePath.indexOf("_frame") - 1;
               if (vPos > 0)
               {
                 var vSub = filePath.substr(1, vPos);
                 var vFound = false;
                 for (var j = 0; j < vImageSets.length; j++)
                 {
                    if (vImageSets[j] == vSub)
                    {
                      vFound = true;
                      break;
                    }
                 }
                 if (!vFound)
                 {
                    vImageSets.push(vSub);
                    console.writeln("New Group = *", vSub);
                 }
               }

This works well and then my plane is to weight each of these groups of files individually, then Align, normalize, integrate and drizzle integrate each group into a final preprocessed image. (will save me hours :) )

I have the weighing process working on screen, it loads the groups of images and weights them according to the formula and display this weight on screen. My problem is I cant seem to work out how to then save the weight out into the output of the subframeselector script. it saves the files ok but the SSWEIGHT property is always 0 even though on the screen it shows correctly

            var SFS = new SubframeSelector;
            var selectedDir = this.outputDirectory + "/weighted";
            if ( !this.frameGroups.filter.isEmpty() )
               selectedDir += '/' + this.frameGroups.cleanFilterName();
            selectedDir = File.existingDirectory( selectedDir );

            SFS.subframes = workingimages.enableTargetFrames( 2 );
            console.writeln("Subframe count *", SFS.subframes.length);

            SFS.cameraGain = 0.12;
            SFS.subframeScale = 0.28;
            SFS.cameraResolution = 2;
            SFS.siteLocalMidnight = 14;
            SFS.structureLayers = 8;
            SFS.noiseLayers = 2;
            SFS.inputHints = this.inputHints();
            SFS.outputHints = this.outputHints();
            SFS.outputDirectory = selectedDir;
            SFS.appovalExpression = "FWHM < 6.5 && Eccentricity <= 0.75";
            SFS.weightingExpression = "(15*(1-(FWHM-FWHMMin)/(FWHMMax-FWHMMin)) + 15*(1-(Eccentricity-EccentricityMin)/(EccentricityMax-EccentricityMin)) + 20*(SNRWeight-SNRWeightMin)/(SNRWeightMax-SNRWeightMin))+50";
            SFS.outputKeyword = "SSWEIGHT";
            SFS.outputPostfix = "_a";
            SFS.routine = 0;
            SFS.sortProperty = 0;
            SFS.outputExtension            = ".xisf";
            SFS.outputPrefix               = "";
            SFS.outputPostfix              = "_a";
            SFS.overwriteExistingFiles     = true;

            if ( !SFS.executeGlobal() )
               throw new Error( "Error weighting light frames." );

            SFS.routine = 1;
            SFS.sortProperty = 0;

            if ( !SFS.executeGlobal() )
               throw new Error( "Error saving weighting light frames." );

            var vmax = 0.00000000000000000;
            var workingimages = new Array;
            for (var y=0; y<SFS.measurements.length; y++)
            {
                console.writeln("Weighting  order *", SFS.measurements[y]);
                console.writeln("Weighting  order *", SFS.measurements[y][3]);
                console.writeln("Weighting  order *", SFS.measurements[y][7]);  // use this to determine what you want to base your reference image on for aligning and normalization

               var filePath = String(SFS.measurements[y][3]);
               console.writeln("Filepath *", filePath);
               var ccFilePath = SFS.outputDirectory + '/'
                              + File.extractName( filePath )
                              + "_a" + ".xisf";


                workingimages.push(ccFilePath);


              if (SFS.measurements[y][7] > vmax)
              {
                vmax = SFS.measurements[y][7];
                this.actualReferenceImage = ccFilePath;
                console.writeln("Actual reference image *", ccFilePath);
              }
            }

Also is there documentation somewhere explaining the output (or input) params relating to certain objects. For example the subframeselector has a property measurements SFS.measurements which is declared as an array. Outputting it to the console I can see it is an array of objects, but am not sure what the object is so am just treating it as a 2 dimensional array and picking oput the values I want, but assume there is a better way.

The next thing I couldn't see how to do was related to the Imageintegration objec. I could see how to load up the source files but not how to load drizzle or normalization files into the script. Was hoping there was a way to automate all of this.

Sorry for the long winded post and hopefully I am just missing the point somewhere and these are simple issues to resolve.

Thanks in advance for any advice.

Cheers

Shane