Author Topic: 2DPlot  (Read 8616 times)

Offline hvb356

  • PixInsight Enthusiast
  • **
  • Posts: 77
2DPlot
« on: 2013 July 06 10:54:51 »
Hi,

for some reason I had to write a script, which gives a different view on how intensities are distributed on your chip. 2DPlot cuts the image in either vertical, horizontal or diagonal direction and produces a plot with a linear or logarithmic scale. The coordinates are variable and can be entered with the numeric box, trackbar or with the mouse in the image window:

https://dl.dropboxusercontent.com/u/90132063/Scripts/2DPlot.js

I tested with 01.08.00.1015 RC7 on a Win7-64 system and crashed PI with almost every selfmade  error (i.e. variable not defined or object not set). Is there anything I can do to make scripting a little more tolerant?

Regards

Hartmut Bornemann


TOA-150, ML8300, CFW2-7 w. Astronomik HaLRGB, PDF, EM-400, guiding FS-60 + ST402, ASCOM bsd. image acquisition

Offline bitli

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 513
Re: 2DPlot
« Reply #1 on: 2013 July 06 11:32:34 »
Try adding
"use strict";
as the first line of your script.
It may show a few more errors at compile time and may reduce the number of crashes of PI by 20%  ;)

Immediately add a valid parent to a GUI object when it is created (this may force creation in a specific order, but this saves quite a few crashes too).

Write Javascript that look like c++ (at least in the GUI part), it seems to work better with the GUI library (cut and paste from existing code).

Isolate the GUI part and the functions (at least for larger scripts), write some programs to execute test systematically or to exercise the GUI without executing  the actions. This may it is possible to test the code very often. I found it extremely difficult to track an error if I did a lot of changes since the last test and the only error message is PI crashing.

This helped me but YMMV.
-- bitli

Offline hvb356

  • PixInsight Enthusiast
  • **
  • Posts: 77
Re: 2DPlot
« Reply #2 on: 2013 July 07 01:13:26 »
Dear,

following your recommendation, the syntax checker immediately returned

"SyntaxError: strict mode code may not contain 'with' statements".

And as the "with ()" construct is indispensable for me, "use strict" is not an option. Somehow or other, no system shall crash by wrong handling. A good analysis of "what happened and where" is, what we can expect from modern instruments today.

Thanks

Hartmut
 
TOA-150, ML8300, CFW2-7 w. Astronomik HaLRGB, PDF, EM-400, guiding FS-60 + ST402, ASCOM bsd. image acquisition

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: 2DPlot
« Reply #3 on: 2013 July 07 13:44:09 »
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline hvb356

  • PixInsight Enthusiast
  • **
  • Posts: 77
Re: 2DPlot
« Reply #4 on: 2013 July 08 00:01:49 »
Georg,

the inability to handle programming errors limits the productive use of the embedded scripting machine. Looking for a workaround was not my intention here. I will rather inspire the team to put this case on the change list.

Hartmut Bornemann
TOA-150, ML8300, CFW2-7 w. Astronomik HaLRGB, PDF, EM-400, guiding FS-60 + ST402, ASCOM bsd. image acquisition

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: 2DPlot
« Reply #5 on: 2013 July 08 02:36:31 »
I agree that script errors should *never* crash a program. I dont agree that "with" is indispensible.
Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline hvb356

  • PixInsight Enthusiast
  • **
  • Posts: 77
Re: 2DPlot
« Reply #6 on: 2013 July 08 05:17:08 »
agree

Hartmut
TOA-150, ML8300, CFW2-7 w. Astronomik HaLRGB, PDF, EM-400, guiding FS-60 + ST402, ASCOM bsd. image acquisition

Offline hvb356

  • PixInsight Enthusiast
  • **
  • Posts: 77
Re: 2DPlot
« Reply #7 on: 2013 July 17 07:13:49 »
All,

I've just released an update with corrections in plot scaling and mouse operations. You can change pixel coordinates by +/-1 with the mouse wheel and display the the intensity at x,y with the left mouse button pressed.

Good luck

Hartmut
TOA-150, ML8300, CFW2-7 w. Astronomik HaLRGB, PDF, EM-400, guiding FS-60 + ST402, ASCOM bsd. image acquisition

Offline Solidarity

  • Member
  • *
  • Posts: 58
Re: 2DPlot
« Reply #8 on: 2013 July 18 22:10:11 »
Hi Hartmut,

thanks for the script from germany.

Regards

Karsten

Offline hvb356

  • PixInsight Enthusiast
  • **
  • Posts: 77
Re: 2DPlot
« Reply #9 on: 2013 July 18 23:24:18 »
Hi Karsten,

it's a pleasure for me.

Keep going

Hartmut
TOA-150, ML8300, CFW2-7 w. Astronomik HaLRGB, PDF, EM-400, guiding FS-60 + ST402, ASCOM bsd. image acquisition