Author Topic: Is PixInsight externally scriptable?  (Read 5448 times)

Offline dmcclain

  • PixInsight Addict
  • ***
  • Posts: 117
Is PixInsight externally scriptable?
« on: 2015 November 17 10:25:01 »
I spent a fair bit of time perusing the pages here, reading the coding examples, and finding the class library descriptions. My impression, developing slowly over fragmentary information, is that PixInsight is a GUI wrapper framework around dynamic libs that can be scheduled and parameterized to perform the image processing functions.

In effect you seem to have a Unix-like paradigm operating on dynamic libs instead of executable images as the Bourne Shell would do. Presumably this is convenient because the outer GUI wrapper can maintain global information that can be used in successive operations, rather than always beginning from scratch without any saved state, as the Bourne Shell would demand. I also see the outer wrapper maintaining caches of information and swap files.

So my question is about whether one could use a higher order external scripting language to issue commands to PixInsight? Certainly I can have that higher order scripting language generate JS files for PI to execute, but I'm wondering if PI can be remotely instructed to execute those JS files? or must I manually execute them from within the PI GUI?

Just thinking about higher order possibilities here. I'd like to use what you have and make more abstract use of it, rather than going in the opposite direction and writing C++ code to extend capabilities. The applications I have in mind at the moment are more abstract ad-hoc operations over collections of image files. I find the existing batch commands useful, but somewhat restrictive.

- DM

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
Re: Is PixInsight externally scriptable?
« Reply #1 on: 2015 November 17 17:04:55 »
Yes, type "help" and "help run" in the process console for info on command line options. On Mac OS X command line to run a script is something like this

Code: [Select]
open PixInsight.app --args "-r=\"<path.js>\""

Argument passing is also possible. I think you can run and then exit with an additional "exit --force".

Thanks,
Mike


Offline dmcclain

  • PixInsight Addict
  • ***
  • Posts: 117
Re: Is PixInsight externally scriptable?
« Reply #2 on: 2015 November 17 22:45:08 »
Very cool system! One application came to mind last night as I was running some sensor linearity tests on OSC sensors (CCD and CMOS). And I found the need to split out the individual CFA channels from a series of exposures, perform a cookie cut of the central 100 x100 pixel region, and run batch statistics on all four channels, then graph the resulting curves going into saturation at different rates.

I did it by hand last night in PI, and it would have been good to control this from my higher level coordinating system from camera, through PI processing, to data gathering and plotting. I will probably be doing this several more times.

[ at least I was able to do it relatively painlessly by having PI in the toolbox! ]

- DM

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Is PixInsight externally scriptable?
« Reply #3 on: 2015 November 18 02:57:44 »
For reference, here is the current set of command line arguments recognized by the PixInsight Core application, as of version 1.8.4.1190:

**********

Usage: PixInsight [<arg_list>] [<url_list>]

<url_list>

      is a sequence <url>[ <url_list>]

<url>

      is an URL specification to an existing file. Supported file types include
      images of any installed image format, Process Set Module files (.xpsm .psm),
      script files (.js, .jsh, .scp), project files (.xosm) and plain text files
      (.txt, files with no suffix, and a number of source code file types such as
      .c, .cpp, .h, etc).

      URLs must conform to the URI specification from RFC 3986 (Uniform Resource
      Identifier: Generic Syntax). For remote URLs, the HTTP/HTTPS and FTP
      protocols are fully supported with optional user authentication.

      For local path specifications, file name templates are fully supported via
      standard * and ? wildcards.

<arg_list>

      is a sequence <arg>[ <arg_list>]

<arg>

      is a valid argument specification. Valid arguments are the following:

--startup-script=<file_path>

      <file_path> is a path specification to a local script file that will be
      executed as part of the startup procedure. By default, all executable
      scripts located on the "etc/startup" installation directory are loaded
      and executed automatically on startup, unless a script is specified with
      this argument, or the --no-startup-scripts argument is used (see below).

--no-startup-scripts

      Don't execute any startup scripts.

--no-startup-check-updates

      Don't launch the 'check for updates' background process during startup.

--no-startup-gui-messages

      Don't show error and warning messages using message boxes and other fancy
      graphical interface resources during startup.

--no-splash

      Don't show a very nice splash window during startup.

--display=[<host_name>]:<screen_number>

      Override the standard DISPLAY environment variable on X11. <screen_number>
      is a zero-based screen number valid on the specified (or default) host. Zero
      corresponds to the default primary screen. This option is ignored on OS X
      and Windows platforms.

--opengl=<impl>

      Forces the use of a particular OpenGL implementation. This option can be
      useful to troubleshoot OpenGL problems, especially on Windows platforms.
      The <impl> argument value must be one of:

      raster         Use pure raster surfaces on top-level windows. This option
                     effectively disables the use of OpenGL in the PixInsight core
                     application.

      software       Force the use of a software-based OpenGL 2.1 implementation
                     on Windows. This option has no effect on other platforms.

      ES             Force the use of an OpenGL ES 2.0 or higher implementation
                     distributed with the core application on Windows. This option
                     has no effect on other platforms.

      desktop        Force the use of desktop OpenGL, even if the host graphics
                     driver/adapter has been blacklisted, or if the host graphics
                     hardware is known to cause problems.

-n[=<slot>] | --new-instance[=<slot>]

      Create a new instance of the PixInsight Core application. If specified as
      a positive integer, <slot> is an application slot in the [1,256] range. If
      no slot is specified, the new instance will try to run in the first free
      slot available.

-y[=<slot>] | --yield[=<slot>]

      Yield execution to an already running instance of the PixInsight Core
      application. <slot> is an optional application slot with the same meaning
      as for the -n option. Execution is always yielded by default if neither -n
      nor -y are specified, and there are one or more running (and alive)
      application instances.

--enumerate-instances

      Write a report of all the running and crashed application instances (to
      stdout on UNIX/Linux platforms, to a message box on Windows), including
      process identifiers (PIDs), then exit.

--terminate-instance=<slot>

      Unconditionally terminates a running application instance at the specified
      <slot>, and exits.

      ** Warning ** The application will be forced to exit immediately, even if
      there are running processes or scripts. No modified data will be saved and
      no settings will be stored. Running process won't have any chance to perform
      cleanup operations or save working parameters.

-m=<file_path> | --module=<file_path>

      <file_path> is a local path specification to a PixInsight module that
      will be installed upon startup. This argument can be used multiple
      times to define a set of modules that will be installed in the order
      they appear on the command line.

-s=<file_path> | --script=<file_path>

      <file_path> is a local path specification to a script that will be featured
      (if the script provides valid feature preprocessor directives) upon startup.
      This argument can be used multiple times to define a ser of scripts that
      will be featured in the order they appear on the command line.

-r=<file_path> | --run=<file_path>

      <file_path> is a local path specification to a script file that will be
      loaded and executed just after the startup procedure. This argument can
      be used multiple times to define an ordered set of scripts that will be
      executed after the startup script.

--force-exit

      After running all scripts specified with -r arguments, exit the application
      unconditionally.

      ** Warning ** No modified data will be saved if this option is specified.

--backup-conf

      Write a backup copy of the current PixInsight configuration file on the
      user's home directory. The backup file is generated prior to any reset of
      configuration settings.

--reset-all

      Force a reset of all configuration settings. This includes all user-defined
      preferences, pixel readout options, color management settings, and global
      RGBWS parameters.

--reset-color-management

      Reset color management settings to default values.

--reset-preferences

      Reset all user preferences to default settings.

--reset-readout-options

      Reset pixel readout options to default settings.

--reset-RGBWS

      Reset global RGB Working Space parameters to default values.

--reset-printer

      Reset the global printer object to default settings.

--without-printer

      Do not initialize the global printer object. Currently this option is
      enabled by default on OS X and Windows.

--with-printer

      Initialize the global printer object (inverse option to --without-printer).

--default-modules

      Reset the set of installed modules to the default standard set. After
      scanning the bin installation directory looking for valid PixInsight
      modules, the core application will try to install all modules found.
      Other modules that could have previously been installed will be discarded.

--default-scripts

      Reset the set of featured scripts. After scanning the src/scripts
      installation directory looking for scripts, the core application will
      create entries for all valid scripts found under the Script menu. Other
      scripts that could have previously been featured will be discarded.

--default-favorites

      Reset the Favorite Processes category to the factory-default set, which is
      version-dependent. The previous selection is lost.

--no-modules

      Do not install any modules. Any modules installed during this session will
      be discarded. The core application will install the current set of modules
      the next time it is executed without this argument.

--no-scripts

      Do not feature any scripts. Any scripts featured during this session will
      be discarded. The core application will load the current collection of
      featured scripts the next time it is executed without this argument.

--uninstall

      Run the PixInsight core application in uninstall mode. This is a special
      execution mode reserved to erase all PixInsight configuration settings
      for the current user. A modal dialog box asks for confirmation before
      actually erasing all settings. The uninstall mode can also be triggered
      by running the core application with the Ctrl key pressed.

--print-environment

      Writes the names and values of all environment variables (to stdout on
      UNIX/Linux platforms, to a message box on Windows).

--r[+|-]

      Enable/disable recursive directory search for wildcard local file
      specifications. Each occurrence of this argument applies to local file
      items following it on the command line.

--help

      Display this help text and exit.

**********
Juan Conejero
PixInsight Development Team
http://pixinsight.com/