Author Topic: javascript: adding files to imageintergration.images array.  (Read 334 times)

Offline Dvelledge

  • Newcomer
  • Posts: 4
    • View Profile
I have a very stupid question but i seems to be having a challenge.  I have a list of files.  These are bias files.  Simple array of type string of paths to a number of bias files which i want to automate the intergration of.  I am having trouble adding the files along with the other items that shoudl go into the array of images for Image Intergration.  I have tried about 20 different ways.  Some seem to work but when i try and look at what is in the array images it says undefined.   thanks for your support

here is my latest attempt at the probelm.

var biasII = new ImageIntegration;

//enabled, path, drizzlePath, localNormalizationDataPath


for (let i=0;i<bias_filelist.length;++i)
{
                     biasII.images.push({ enabled:                      true,
                                                     path:                         bias_filelist.path,
                                                     drizzlePath:                  "",
                                                     localNormalizationDataPath:   ""});
                      console.writeln("added: "+bias_filelist.path+ "      to     "+ biasII.images.path);
}

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 6621
    • View Profile
    • http://pixinsight.com/
Re: javascript: adding files to imageintergration.images array.
« Reply #1 on: 2019 February 27 23:50:07 »
Hi Don,

Table parameters of external processes must be specified as plain arrays, not as structured objects. For your example this should work:

Code: [Select]
for ( let i = 0; i < bias_filelist.length; ++i )
   biasII.images.push( [true, bias_filelist[i].path, "", ""] );

although this is much more efficient:

Code: [Select]
let images = [];
for ( let i = 0; i < bias_filelist.length; ++i )
   images.push( [true, bias_filelist[i].path, "", ""] );
biasII.images = images;

In this example I assume that your bias_filelist is an array of objects, each of which has a path property of String type.

A useful trick is clicking the Edit Instance Source Code tool button on a tool's interface (blue empty square button). This opens a code editor window where you can edit the JavaScript representation of the tool's current process instance. Here you can copy fragments of code and inspect it to learn how parameters have to be specified in your scripts.

Let me know if it works.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Dvelledge

  • Newcomer
  • Posts: 4
    • View Profile
Re: javascript: adding files to imageintergration.images array.
« Reply #2 on: 2019 February 28 07:17:41 »
Thank You very much Juan,

As always your responses are on point and very helpful.  The source code tool is extremely helpful.  You can tell pixinsight was build by an excellent architect.

Don. 




Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 6621
    • View Profile
    • http://pixinsight.com/
Re: javascript: adding files to imageintergration.images array.
« Reply #3 on: 2019 February 28 09:18:10 »
Thank you Don. Glad to be of help. Let me know if I can assist you further.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/