Instrument PipelineControl SW DRS Common Library for Image

Instrument PipelineControl SW DRS Common Library for Image

Instrument PipelineControl SW DRS Common Library for Image Processing (CLIP) Csar Enrique Garca Dab, Mario Kiekebusch and Stewart McLay Instrument Control Systems Seminar, 20th - 24th October 2014, Overview Problem More complex Instruments Need for Quicklook procedures Data Reduction Software (DRS) normally includes these routines for quality control Instrument Control Systems Seminar, 20th - 24th October 2014, Overview Definition and Goals

CLIP was introduced as the new standard online image processing tool for the VLT Instrumentation Software during the VLT2009 release cycle Goals To provide an image processing toolkit, flexible and well integrated with the INS SW To share the same image processing algorithms whenever possible between INS SW and pipeline DRS To implement some specialized image processing routines which are generally required during the instrument acquisition process. Instrument Control Systems Seminar, 20th - 24th October 2014, Overview Package Image Processing Library

C++ VLTSW Library rtdc Image Acquisition Simulator clipvTcl Real Time Display clipv Tcl VLTSW Library clipm extending CPL clipias

Template modules xxclipv, xxclipm Instrument Control Systems Seminar, 20th - 24th October 2014, Image Processing Library Goals 1. 2. 3. Covers common image processing needs, for example Centroiding of point-like sources Detection and characterisation of diversely shaped objects such as images of mask pinholes and slits Image alignment Corss-correlation Serve as temporary development platform (until routines are accepted and included in CPL) Provides flexibility by separating DFS and INS SW development cycles

Intended for instrumentation use only Instrument Control Systems Seminar, 20th - 24th October 2014, Image Processing Library Functions Image Analysis Mathematics Linear Regression Full bad pixel support Background Estimation Point-Source Centroiding Fitting Barycentre Alignment Cross-correlation Transformation Aperture Characterisation Variously shaped objects Automatic region of interest Optimised results Statistics in- & outside Random Number Generation Gaussian

Poisson 2d-pattern Pattern Alignment Different degrees of freedom Transformation Interface Instrument Control Systems Seminar, 20th - 24th October 2014, ANSI-C Error Message History CPL Objects in Memory C++ VLTSW Library Features Main Features: Direct access of images from shared memory C++ wrappers for some CPL objects Automatic initialization and cleaning up of CPL Verbose and logging facilities Byte swapping and data conversion. VLTSW standard error handling

Instrument Control Systems Seminar, 20th - 24th October 2014, C++ VLTSW Library Shared Memory Client Mode Server Mode Register Acq. Process Create/ Write Shared Memory Image Events: Size of the image Data type Shared memory ID Last event flag Notify RTD Server Register/ Notify

Notify Read Notify Clipv Client Clipv Server Instrument Control Systems Seminar, 20th - 24th October 2014, Write RTD App. Read Shared Memory Create/ Remove C++ VLTSW Library Example // Initialize the connection to the RTD server registering // as the CCS process name and attaching to the image events

// generated by the acquisition process. clipvRTD_EVT_RECV *rtdEvtRecv; rtdEvtRecv = new clipvRTD_EVT_RECV(ccsGetMyNameInt(), ngcoptb); rtdEvtRecv->Attach(); // Receives the image event and store it in the internal // structure. rtdEvtRecv->ReceiveImageInfo(); More examples in the test directory of module clipv Instrument Control Systems Seminar, 20th - 24th October 2014, Tcl VLTSW Library Functions TCL Commands: General Purpose, e.g. verbose, version, subcommands, etc. RTD Image Events, e.g. rtd_attach, rtd_detach, rtd_image_wait, etc. Image Basic Operations, e.g. image_add_scalar, image_add, etc. Image Statistics, e.g. image_get_min, image_get_mean, etc.

Image Processing Recipes, e.g. image_center_gauss, image_slit, etc. More than 40 Tcl Wrappers in total More wrappers for CPL functions can be added on demand Others Services Image Store Keep images in memory across different exposures. Store from different Instrument Controlimages Systems Seminar, 20 - 24 October 2014, sources: file and shared th th Real Time Display Display image in real-time Like a normal RTD Display superimposed

graphics. Ovals, Lines, Rectangles Crosses Text User interaction. Pickup Object Get Rectangle Instrument Control Systems Seminar, 20th - 24th October 2014, Image Acquisition Simulator Commands: SETUP, START, STOP. Modes: BIAS, SKY and FILE Supported sky objects: Gaussian star

Supported star parameters: pos, sigma, maxflux and gaussian norm. shell> msgSend clipiasControl_IR SETUP -function CIAS.MODE SKY CIAS.SKY.STAR.NUM 3 CIAS.SKY.STAR1.POSX 300 CIAS.SKY.STAR1.POSY 512 CIAS.SKY.STAR1.MAXFLUX 5000 CIAS.SKY.STAR1.SIGMAX 6 CIAS.SKY.STAR2.POSX 200 CIAS.SKY.STAR2.POSY 100 CIAS.SKY.STAR3.POSX 700 CIAS.SKY.STAR3.POSY 700 CIAS.SKY.STAR3.SIGMAX 8 shell> msgSend clipiasControl_IR START Instrument Control Systems Seminar, 20th - 24th October 2014, Image Acquisition Simulator Configuration CIAS.DET1.CAM CIAS.DET1.TYPE CIAS.DET1.WIDTH CIAS.DET1.HEIGHT CIAS.DET1.DATATYPE CIAS.DET1.MINBIAS CIAS.DET1.MAXBIAS CIAS.DET1.DELAY "IR"; "2"; 1024; 1024; -32;

116; 129; 500; Instrument Control Systems Seminar, 20th - 24th October 2014, # # # # # # # # Detector camera name VISIBLE=1 and INFRARED=2 Detector width Detector height FLOAT=-32 SHORT=16 Detector minimum bias Detector maximum bias Detector exposure delay Template Library Interface Instrument Templates (updated version of tpl)

Asynchronous exposure wait New class: tplCLIP New set of classes to create graphics in the Real Time Display New concept for instrument acquisition. Template TPL Tcl Command 1: C++ Class Image Processing Routine 2: 3: 4: 5: 6: 7: 8: 9:

10: Instrument Control Systems Seminar, 20th - 24th October 2014, CPL Template Library Interface Example # object declaration tplCLIP clip # Attach to the image events from camera clip Attach ngcopt set expId [obs Setup "-function $funcSetup"] # start the exposure obs Start [ngcopt Subsystem] $expId set cmdId [obs WaitAsync $expId "-detId [ngcopt Subsystem]"] # Wait until image is shared memory clip Wait 20000 ngcopt # Compute mean value from shared memory tplLog "Image MeanLevel: [clip MeanLevel ngcopt] # Check the reply from asynchronous wait obs RecvReply $cmdId Instrument Control Systems Seminar, 20th - 24th October 2014, Extendibility Requirements and Templates Requirements to be served: instrument specific needs:

control software-only image processing tasks, and/or shared functions for pipeline and control software Template modules: Interface Templates (C++ and Tcl) Image Processing Library Template Instrument Control Systems Seminar, 20th - 24th October 2014, Extendibility Image Processing Development Strategy Consortium ESO Repositories Observatory SVN Pipeline World

INS World DRL Developer INS Developer Pipeline DRL Pipeline Responsible clipm DFS CLIP Responsible clipv (Wrappers) Instrument Control Systems Seminar, 20th - 24th October 2014, Pipeline Integration INS / RTD Integration

Extendibility Image Processing Adding New Functions(1) cpl_image *xxclipm_something(cpl_image double *img_in, some_param) { cpl_image *img_out = NULL; XXCLIPM_TRY { XXCLIPM_TRY_CHECK_AUTOMSG(img_in != NULL, CPL_ERROR_NULL_INPUT); XXCLIPM_TRY_CHECK_AUTOMSG(some_param > 1.5, CPL_ERROR_ILLEGAL_INPUT); /* do some processing here */ XXCLIPM_TRY_CHECK_ERROR_STATE(); } XXCLIPM_CATCH { cpl_image_delete(img_out); /* clean up if error happened */ img_out = NULL; }

return img_out; } Instrument Control Systems Seminar, 20th - 24th October 2014, Extendibility Image Processing Adding New Functions(2) cpl_error_code xxclipm_something(cpl_image double *img_in, *out_value) { cpl_image *img_tmp = NULL; XXCLIPM_TRY { XXCLIPM_TRY_CHECK_AUTOMSG(img_in != NULL, CPL_ERROR_NULL_INPUT); XXCLIPM_TRY_CHECK_AUTOMSG(out_value != NULL, CPL_ERROR_NULL_INPUT); /* do some processing here */ } XXCLIPM_CATCH

{ if (out_param != NULL) *out_param = -1; } cpl_image_delete(img_tmp); /* delete temporary stuff in any case */ return XXCLIPM_ERROR_GET_NEW_SINCE_TRY(); } Instrument Control Systems Seminar, 20th - 24th October 2014, Extendibility TCL Implementation Steps Retrieve template module from SVN archive $ svn checkout --username http://svnhq1.hq.eso.org/p1/trunk/INS/Templates/xxclipv Compile template module to make sure that everything is fine before to start customization $ cd xxclipv/src; make clean all Create the instrument specific module from the CLIP template $ clipvCreate Instrument Control Systems Seminar, 20th - 24th October 2014,

Extendibility TCL Parameter Handling Predefined classes for main built-in types: int, double, logical and string Class for handling the list of parameters objects clipvTCL_ARG_STR par_mode('m', "mode", "alignment mode", "SHIFT", "SHIFT SHIFT_ROBUST UNIT EQUAL FREE", clipvTCL_ARG::OPTIONAL_ARG| clipvTCL_ARG::MANDATORY_VAL_ARG)); parameter parameter parameter parameter Parameter parameter option alias description default value range flags

(one character) (string) (string) (value of the same type) (list of allowed values) (valid class flag) Instrument Control Systems Seminar, 20th - 24th October 2014, Extendibility TCL Adding New Commands // Declare the command in the constructor NewSubCmd(string("image_app"), this, &xxclipvTCL_APP::CmdApp); vltINT32 xxclipvTCL_APP::CmdApp(int argc, char *argv[]) { clipvLOG_3(("xxclipvTCL_APP::CmdApp - begin")); // defining subcommand parameters clipvTCL_LINE_ARG tclArg(&par_file, &par_scalar, NULL); // parsing subcommand parameters if (tclArg.ParseArgs(_interp, argc, argv) != TCL_OK){ clipvTCL_ERR_RETURN(tclArg.Usage(tclArg.GetStrError())); } // adding image processing here clipvLOG_3(("xxclipvTCL_APP::CmdApp - end")); return(TclSetResult("XXXX sample command executed !")); } Instrument Control Systems Seminar, 20th - 24th October 2014, Status and Outlook

Status CLIP was originally released with VLTSW 2009 VLTSW 2014 includes CPL version 6.3.1 VLTSW 2015 targeted to upgrade to CPL version 6.6 Instruments using CLIP CRIRES: Calculate the position and intensity of light spots during calibration. HAWKI: Automatically insert mosaic gap into raw image. Allows users to correctly apply offsets across different detectors. KMOS: Spatial image reconstruction and alignment.

MATISSE: Fringe detection, instrument alignment and determining internal OPD. MUSE: Slow guiding systems and image reconstruction. PACMAN: Fast dual fringe viewer (16 frames/sec). SPHERE: Quick look and image processing (flux, polarisation, centering). XSHOOTER: Active flexure compensation by measuring the cross- Instrument Control Systems Seminar, 20th - 24th October 2014, Examples KMOS Image Reconstruction KMOS spectrograph image data was reconstructed into a spatial image that could be used to analyse and verify the telescope pointing position Instrument Control Systems Seminar, 20th - 24th October 2014,

The End Questions Instrument Control Systems Seminar, 20th - 24th October 2014,

Recently Viewed Presentations