Author Topic: How to beging with scripts  (Read 6360 times)

Offline Astrocava

  • PixInsight Addict
  • ***
  • Posts: 180
    • Astrocava.com
How to beging with scripts
« on: 2009 May 04 02:39:14 »
Hi all!

I'm thinking about writing my first script in PI, but I don't know how to begin with. I want to do that (I think) is a easy task:

- Detect hot pixels
- Substitute hot pixel value with a interpolation of adjacent pixels. I like to do this in images taken with monochrome cameras (we use adjacents pixels to interpolate) and in images with Bayer matrix (we should use values from pixels two pixels away).

I think this will be possible in 1.5, but want to start to write scripts.

Need a initial push  :P

Sergio
Moonfish ED80 over a Meade LX200GPS 8"

Offline Niall Saunders

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1456
  • We have cookies? Where ?
Re: How to beging with scripts
« Reply #1 on: 2009 May 04 03:33:28 »
Hi Sergio,

My recommendation - based on my own experience - is to have a DETAILED look at all of the sample scripts that came with your installation of PixInsight.

Print them out, or load them into a word processor. Break them down into manageable chunks. Try to understand all of the main 'program blocks'. Then break these 'bolcks' down into smaller and smaller sections until you can follow the entire program flow.

If you are working 'on-screen', then the method I used was to load a sample script, and then to immediately save it again with a different name. This meant that I could freely 'edit' the copy of the original, adding line breaks and comments as I saw fit.

If you also look at all the many examples, you will hopefully find one that has a 'framework' that might serve as the foundation for your script. Start with that one, and break it down so that you have the 'skeleton' of the code, onto which you will hand all of your specific routines. Obviously, you may need to take sections of code from other scripts - both in the sample directory, AND from those you find here on the Forum. And, most obviously, you are going to have to ask for help, here on the Forum, when nothing else works  :(

Finally, on the right-hand-side (usually) of the script editing window you should have a list of objects available to you, in two categories : "Core Java Script Objects" and "External Objects". The first category ('Core') has a full list of all the processes that you may need to get your program running. The second ('External') categore is a list of all the PixInsight 'clever stuff' - which can be immensely useful, because - if you can see a way to use one of these INSTEAD of a process that you have to code in JavaScript, then you get an execution speed that is orders of magnitude faster than the same process coded in JS.

And, finally, finally, if you DO get a script going, remember to share it here - but, MOST IMPORTANTLY, take the time to add LOTS OF COMMENTS, so that others (and I specifically include MYSELF in that group  ;D ) can understand YOUR code and maybe, as a result, can figure out how to resolve their own coding problems.

And, finally, finally, finally, remember that 'Juan is your friend' - he is the brains behind the JSR engine (and his 24/7 telephone contact number is available for a 6-digit fee, payable to an offshore bank account  ::) )

Best of luck,
Cheers,
Niall Saunders
Clinterty Observatories
Aberdeen, UK

Altair Astro GSO 10" f/8 Ritchey Chrétien CF OTA on EQ8 mount with homebrew 3D Balance and Pier
Moonfish ED80 APO & Celestron Omni XLT 120
QHY10 CCD & QHY5L-II Colour
9mm TS-OAG and Meade DSI-IIC

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: How to beging with scripts
« Reply #2 on: 2009 May 05 00:48:55 »
Hi Sergio,

I'm glad you've decided to start with JavaScript programming on PixInsight. Welcome! :)

It seems crazy at first, but it isn't as difficult as it seems. It's just a matter of patience, as everything.

Little to add to Niall's recommendations; I wholeheartedly adhere to all he's said. Oh, that final note about a fee isn't true. It's actually five-digit and I can send you an invoice  ;D  >:D
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Astrocava

  • PixInsight Addict
  • ***
  • Posts: 180
    • Astrocava.com
Re: How to beging with scripts
« Reply #3 on: 2009 May 05 15:36:35 »
Thanks, Niall. I have begun to study the sample scripts. Soon  I will have some questions, sure. :P

Sergio
Moonfish ED80 over a Meade LX200GPS 8"