Author Topic: Batch MergeCFA  (Read 5239 times)

Offline moscow

  • Newcomer
  • Posts: 17
Batch MergeCFA
« on: 2016 May 11 12:58:20 »
Hi all.

First of all thanks for GREAT pixInsight with PJSR inside.
Second... thanks to NKV (Nikolay) for SplitCFA / MergeCFA processes.

I'm good enought web-programmer with good javascript knowledge, but noob in PJSR. Just wrote test script for try to automate mergecfa process. This is just a test fragment, not whole scrpt, like BatchDebayer, sure.

Code: [Select]
var cfa0 = ImageWindow.open('/ASTRO/M57/newton-f4.6-qhy8l/cfa/2016-04-29-M57-001-15m_CFA0_c_cc.fit');
var cfa1 = ImageWindow.open('/ASTRO/M57/newton-f4.6-qhy8l/cfa/2016-04-29-M57-001-15m_CFA1_c_cc.fit');
var cfa2 = ImageWindow.open('/ASTRO/M57/newton-f4.6-qhy8l/cfa/2016-04-29-M57-001-15m_CFA2_c_cc.fit');
var cfa3 = ImageWindow.open('/ASTRO/M57/newton-f4.6-qhy8l/cfa/2016-04-29-M57-001-15m_CFA3_c_cc.fit');

/*
var out = new ImageWindow(
   cfa0[0].mainView.image.width * 2,
   cfa0[0].mainView.image.height * 2,
   1,
   cfa0[0].bitsPerSample,
   cfa0[0].isFloatSample, false, "");
*/

console.writeln(cfa0[0].mainView.id);

var merge = new MergeCFA;
merge.sourceCFAImage0 = cfa0[0].mainView.id;
merge.sourceCFAImage1 = cfa1[0].mainView.id;
merge.sourceCFAImage2 = cfa2[0].mainView.id;
merge.sourceCFAImage3 = cfa3[0].mainView.id;

merge.executeGlobal();

//out.saveAs('/ASTRO/a.fit', false, false, true, false);

cfa0[0].forceClose();
cfa1[0].forceClose();
cfa2[0].forceClose();
cfa3[0].forceClose();

Have questions:
1. cant start mergeCFA process. It tell me: Source image #0 not set.
2. have pix debug abilities like google chrome console?
3. how I can catch image object from mergecfa working in global context to save it?

Thanks in advance :)

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
Re: Batch MergeCFA
« Reply #1 on: 2016 May 11 15:29:19 »
1) Problem reproduced, don't know why this is not working, the parameters appear to be "read-only", maybe a bug:

Code: [Select]
var merge = new MergeCFA;
merge.sourceCFAImage0 = cfa0[0].mainView.id;
merge.sourceCFAImage1 = cfa1[0].mainView.id;
merge.sourceCFAImage2 = cfa2[0].mainView.id;
merge.sourceCFAImage3 = cfa3[0].mainView.id;

console.writeln("merge.sourceCFAImage0: ", merge.sourceCFAImage0); // returns empty string???
console.writeln("merge.sourceCFAImage1: ", merge.sourceCFAImage1); // returns empty string???
console.writeln("merge.sourceCFAImage2: ", merge.sourceCFAImage2); // returns empty string???
console.writeln("merge.sourceCFAImage3: ", merge.sourceCFAImage3); // returns empty string???

2) I believe no. I use console.writeln() and console.flush().

3) Some processes (eg PixelMath) let you set a newImageId. Others like NewImage and MergeCFA don't. For the latter, immediately after execution, you can try ImageWindow.activeWindow.mainView.image.

Regards,
Mike


Offline moscow

  • Newcomer
  • Posts: 17
Re: Batch MergeCFA
« Reply #2 on: 2016 May 12 00:05:30 »
Thanks a lot for fast reply.
Will ask Nikolay for help, so...

Perhaps someone can help me with PixelMath expressions to merge four images into one CFA? Didnt understand PM yet :(

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Batch MergeCFA
« Reply #3 on: 2016 May 12 06:51:57 »
The MergeCFA process was broken. I have just released an update with a new version of the SplitCFA module, where this bug (along with some others) is now fixed. Your script now works perfectly. Thank you for detecting this problem.

Quote
2. have pix debug abilities like google chrome console?

Nope. This has been something I've been wanting to do for a long time, but it is a lot of complex and delicate work. The fact that each version of the SpiderMonkey engine changes almost everything does not help either.

Quote
3. how I can catch image object from mergecfa working in global context to save it?

In the new version I've released today, I've added a read-only output parameter to MergeCFA, namely outputViewId, which stores the identifier of the last generated image. Example:

Code: [Select]
let cfa0 = ImageWindow.open( "/path/to/CFA_image0.xisf" );
let cfa1 = ImageWindow.open( "/path/to/CFA_image1.xisf" );
let cfa2 = ImageWindow.open( "/path/to/CFA_image2.xisf" );
let cfa3 = ImageWindow.open( "/path/to/CFA_image3.xisf" );

let merge = new MergeCFA;
merge.sourceCFAImage0 = cfa0[0].mainView.id;
merge.sourceCFAImage1 = cfa1[0].mainView.id;
merge.sourceCFAImage2 = cfa2[0].mainView.id;
merge.sourceCFAImage3 = cfa3[0].mainView.id;
merge.executeGlobal();

let result = ImageWindow.windowById( merge.outputViewId );
result.saveAs( "/path/to/output_image.xisf", false/*queryOptions*/, false/*allowMessages*/, true/*strict*/, false/*verifyOverwrite*/ );
result.forceClose();

cfa0[0].forceClose();
cfa1[0].forceClose();
cfa2[0].forceClose();
cfa3[0].forceClose();
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline moscow

  • Newcomer
  • Posts: 17
Re: Batch MergeCFA
« Reply #4 on: 2016 May 12 07:21:31 »
Oh... so quick update!
Thanks a lot!