'''[wiki:GraspExtrasSoftware fitspipe]''' A streaming FITS image server. This server is often run on TCP port 9999 and currently supports 16 bit 2D FITS image data (and corresponding headers.) It is best suited for "video" style applications when an external client, possibly on another host, needs to process or display live images from a "feed" within the server. External clients need only be able to read (concatenated) FITS format from stdin. The receiver client '''fitspipe-get''' handles the network communication with fitspipe server. The tools '''fitspipe-get''', '''fitspipe-put''', and several other tools which can process this streaming video format are documented below on this page. {{{ % fitspipe -h }}} Currently produces the following help summary: {{{ Network FITS Video Stream Server v2.01 (svn 5372, Feb 03 2012) usage: fitspipe [daemon=false] Listens on port for fitspipe network clients. Clients can either "put" images into particular feed, or "get" images from one. Protocol is handled by fitspipe-put and fitspipe-get respectively. By default, fitspipe becomes a background process. This can be prevented by adding "daemon=false". There are no other options for the server. Make sure your firewall protects "port" adequately. }}} Typing "help" on the socket of a running fitspipe produces: {{{ help + fitspipe v2.01 Feb 03 2012 (compiled Feb 03 2012) commands: + - Same as "put feed=default" + version - Show fitspipe server version + put feed= - To submit a FITS file + get feed= [frame=] - To retrieve a FITS frame + list or ls - List available feeds + composite compenable= [compgeom=wxh compfeeds=] + - Set up composite of multiple feeds + shutdown - Make this server exit + exit or quit or q - Close the connection . OK }}} === Starting the Service === The "fitspipe" service is started at boot time from rc.local. Typically, the rc.local script of a host offering fitspipe service will include a single line: {{{ fitspipe 9999 }}} By default the server becomes a daemon/background process after the listening socket is open. === Creating Feeds === Feeds are created when a data provider produces the first frame. In the future, we intend to implement a way to create feeds with nothing in them to ease startup problems resulting from not being able to start "fitspipe-get" to get video from a feed until the first frame has arrived. === Putting Frames In (fitspipe-put) === Only 2D (NAXIS3=1), Basic FITS (no extensions), at 16 bits per pixel is accepted. The simplest form of a client which produces frames for the "default" feed would be one which makes a socket connection to port 9999 (or whichever port the server is using) and writes an entire FITS file on the socket. The server knows this method is being used when the conversation begins with "SIMPLE=T". The client may leave the connection open and send the next frame when it is ready in the same manner. Normally, the client used for this purpose is the program '''fitspipe-put'''. This client uses a more complete version of the protocol which sends a "put feed=" on a single line before each FITS frame. The feedname, host, and port can be specified on the '''fitspipe-put''' command line, as in this example: {{{ grasp_vidgrab ... | fitspipe-put localhost:9999/default }}} Or the equivalent: {{{ grasp_vidgrab ... | fitspipe-put server=localhost port=9999 feed=default }}} The feed name can be any identifier (avoid spaces though) and grasp_vidgrab can be replaced by anything which produces concatenated FITS on its stdout. === Getting Frames Out (fitspipe-get) === Once a "feed" exists, the '''fitspipe-get''' tool is used to handle making a socket connection to the fitspipe server and converting the stream of FITS images something which can be read from stdout (just as the original output of grasp_vidgrab, but it doesn't have to be on the same host as grasp_vidgrab. Also, multiple clients can register to receive the video. In this way, fitspipe plus fitspipe-get can function as a tee, and way of distributing FITS data to different hosts. The '''fitspipe-get''' tool takes the same parameters as '''fitspipe-put''' plus an additional parameter called '''fullheader=true|false''' which is described below {{{ fitspipe-get server=localhost port=9999 feed=default | ... }}} When used together with the '''fitspipe-put''' example from above, this produces the same result that reading the standard output of grasp_vidgrab in the original example would have. In other words, a simple process which only knows how to produce FITS files on its output has been tunneled through the network. ==== fitspipe-get fullheader=true ==== By default, the '''fitspipe''' server sends a minimal, abbreviated header with each video frame. This is fine when the connection is being used, for example, to display the images for the user with a graphical display program such as '''zimfits.''' For other connections which may want a complete set of metadata and time stamps in each video frame header, the server should be send a command like "get feed=default fullheader=true" to enable this extra information. The "fullheader=true" command line option to '''fitspipe-get''' does this. === Viewing the Frames === Another unsupported "extra" provided with the STARGRASP software is an X-Window system utility called '''zimfits.''' Zimfits requires an X-Display and can read back-to-back basic FITS images on its standard input and display them in a window. It can read from grasp_vidgrab or fitspipe-get. To display with fitspipe-get, use the following syntax: {{{ fitspipe-get server=localhost port=9999 feed=default | zimfits }}} Essentially, put '''zimfits''' in for the '''...''' in the fitspipe-get example above. Try '''zimfits -h''' for more information on its command line options: {{{ --help Display command line options -if F Read from file F instead of stdin -box NXxNY[:X0,Y0] Read only a subarray from a file centered at X0,Y0 -fzoom N Zoom/pan via prebinned files, start at extension .rN at 2^N bin -binx A Bin factor in x (default 1) -biny A Bin factor in y (default 1) -anax A Anamorphic display magnification factor in x (default 1) -anay A Anamorphic display magnification factor in y (default 1) -dt T Delay at least T sec between frames -xflip Flip images in x -yflip Flip images in y -rot R Rotate images by 90 deg CCW (R=+1) or CW (R=-1) -nstat N Size of statistics box (default 32) -stat X Start running statistics X -follow Follow PSF if persistent stats (default 1) -nofollow Do not follow PSF if persistent stats (default 1) -eofquit Quit upon EOF on input -novideo Suppress X video display (but do stats if requested) -pkbord N Border to ignore for PSF search (default 30) -psfwhm F Smoothing to apply for PSF search (default 0.0) -leak N Leaky average number of previous frames to subtract (default 0) -auto N Autoscale or not? (0/1, default 1) -z0 Z Set stretch threshold to Z -z1 Z Set stretch saturation to Z -slin S Stretch non-linearity: S = 0/1/2/3 for lin/log/sqrt/rtlog (0) -ignore N Ignore pixels valued N for autoscaling (0) -fmt N 0/1 for human/program stats output (0) -passthru Copy all input to stdout -v V Set verbosity level to V (default 0) }}} and mouse input and keystrokes accepted in the running window: {{{ left_mouse Zoom out by a factor of 2 mid_mouse Pan to center on mouse location right_mouse Zoom in by a factor of 2 @ Recenter and restore 1:1 zoom ! Recenter and restore 1:1 zoom # zoom in by x64 and print data values on pixels $ Toggle between sampling and averaging when zoomed out (space) Pause the display of FITS images , Single step to the next FITS image - Set the stretch threshold at this pixel value + Set the stretch saturation at this pixel value a Toggle autoscale on and off s Report on statistics in a box at mouse location S Persistent report on statistics in previous box b-b Report on statistics in a box defined by two b's B-B Persistent report on statistics in previous box x Report on psf statistics at mouse location X Persistent report on psf statistics at previous location p Report on JT psf statistics at mouse location P Persistent report on JT psf statistics at previous location j Auto-detect a star and report on JT psf statistics J Persistent version of 'j' o Auto-detect a star and report on donut psf statistics O Persistent version of 'o' m Auto-detect a star and provide psf moments M Persistent version of 'm' ? Create the command menu window q Quit }}}