/*--------------------------------------------------------------------------- File name : lwjit_ini.c Author : N. Devillard Created on : July 2000 Description : lwjit ini file handling ---------------------------------------------------------------------------*/ /* $Id: lwjit_ini.c,v 1.8 2001/07/03 14:35:38 ndevilla Exp $ $Author: ndevilla $ $Date: 2001/07/03 14:35:38 $ $Revision: 1.8 $ */ /*--------------------------------------------------------------------------- Includes ---------------------------------------------------------------------------*/ #include #include #include #include #include #include "eclipse.h" #include "isaacp_lib.h" #include "lwjit_ini.h" /*---------------------------------------------------------------------------- Functions private to this module ---------------------------------------------------------------------------*/ static void parse_section_frames(dictionary*,lwjit_bb* , int*); static void parse_section_cosmetics( dictionary *,lwjit_bb *, int *); static void parse_section_saa( dictionary *, lwjit_bb *, int *); static void parse_section_output( dictionary *, lwjit_bb* , int *); static void parse_section_postproc(dictionary*, lwjit_bb*, int*); static void generate_input_section(FILE * , char * ); static void generate_output_section(FILE * , char * ); static void generate_calibration_section(FILE *, char * ); static void generate_saa_section(FILE * ); /*--------------------------------------------------------------------------- Function codes ---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /** @name lwjit_ini_generate() @memo Generate a default ini file for lwjitter. @param ini_name filename of the file to generate @param name_i Input name. @param name_o Output name. @param name_c Calibration name. @return 0 if Ok, anything else otherwise @doc Generates a default ini file for the lwjitter command. */ /*---------------------------------------------------------------------------*/ int lwjit_ini_generate( char * ini_name, char * name_i, char * name_o, char * name_c ) { FILE * ini_file ; if (file_exists(ini_name)) e_warning("overwriting file [%s]", ini_name); if ((ini_file = fopen(ini_name, "w")) == NULL) { e_error("cannot create file [%s]", ini_name); return -1 ; } fprintf(ini_file, "#\n" "# Configuration file for Long Wavelength Jitter\n" "# %s\n" "#\n", create_timestamp()); fprintf(ini_file, "#\n\n[Eclipse]\n") ; fprintf(ini_file, "VersionNumber = %s\n\n", get_eclipse_version()) ; fprintf(ini_file, "#\n" "# Please check out the following pages regularly for updates:\n" "#\n" "# Infrared jitter imaging data reduction algorithms\n" "# http://www.eso.org/projects/dfs/papers/jitter99/\n" "#\n" "# Frequently Asked Questions about eclipse,\n" "# has a dedicated section for the 'lwjitter' command.\n" "# http://www.eso.org/eclipse/faq\n" "#\n" "# eclipse main WWW site:\n" "# http://www.eso.org/eclipse\n" "#\n" "# This is an adaptation of the original (short wavelength) jitter \n" "# for the long wavelength. Please read the 'long wavelength jitter\n" "# imaging data reduction algorithms' paper for a description of the \n" "# differences. \n"); fprintf(ini_file, "# ----- A note about output names since version 3.3\n" "#\n" "# All files created by 'lwjitter' will be named according to the\n" "# following convention:\n" "# basename_type.fits or basename_type.ascii\n" "# where basename is declared in the [Output]:BaseName section\n" "# and type depends on what kind of data are contained in the file.\n" "#\n" "# The following output files are possible (if requested):\n" "#\n" "# * basename.fits is the final output file\n" "# * basename_off.ascii are offset measurements\n" "\n\n\n") ; fprintf(ini_file, "# A note about FITS keywords since version 3.5\n" "# Either provide the name of a FITS keyword when\n" "# requested, or provide the string 'isaac-default'\n" "# that means that 'lwjitter' should try to look for the\n" "# information with ISAAC conventions.\n" "#\n" "# The 'lwjitter' code knows about all current and past\n" "# conventions for ISAAC keywords and will try to find\n" "# the corresponding value no matter what the file version\n" "# is.\n" "# Example: in the first six months, ISAAC produces the\n" "# RA information in a keyword named 'RA' but later in a keyword\n" "# named 'ISAACRA'. If you indicate 'isaac-default', lwjitter will\n" "# first look for a valid keyword named 'RA' and if it does not\n" "# find it, will look for 'ISAACRA'.\n" "# If getting the information requires some more complex search\n" "# in the header, it will be implemented in the code itself.\n\n\n"); generate_input_section(ini_file, name_i); generate_calibration_section(ini_file, name_c); generate_saa_section(ini_file); fprintf(ini_file, "\n" "# ----- Optional post-processing features\n" "#\n" "# ProduceStatusReport produces an ASCII file describing the status\n" "# of the algorithm at the end of the process. There is information\n" "# about how well each part of the algorithm performed, and all\n" "# possible intermediate information such as detected objects for\n" "# cross-correlation, the offsets which were used, sky background\n" "# measurements, etc.\n" "# The name of this report file is 'basename'_status.ascii, where\n" "# 'basename' is declared in the [Output]:Basename section.\n" "\n" "[PostProcessing]\n" "Activate = yes ; if not set none of the following occurs\n" "ProduceStatusReport = yes ; to produce global status report\n" "\n" "# Included as 'post-processing' is the ability to start\n" "# an image viewer to see the results when 'lwjitter' has\n" "# finished working. Specify the command-line to start it,\n" "# %%s being the name of the output file\n" "\n" "StartViewer = no ; to launch a viewer when finished\n" "StartCommand = \"saoimage -fits %%s\" ;\n" "#\n" "# Examples:\n" "#\n" "# StartCommand = \"saoimage -fits %%s\" ;\n" "# StartCommand = \"rtd %%s\" ;\n" "# StartCommand = \"xv %%s\" ;\n" "#\n" "\n" "\n") ; generate_output_section(ini_file, name_o); fprintf(ini_file, "\n\n" "# ----- end of file\n" "#\n") ; fclose(ini_file) ; return 0 ; } /* * --------------- generate_input_section */ static void generate_input_section(FILE * ini_file, char * name_i) { fprintf(ini_file, "# ----- Input files\n" "#\n" "# Input image file names are stored in a separate ASCII text file.\n" "# This text file is a frame list containing\n" "# the image file name in first column and optionally a frame type\n" "# in the second column. The frame type is a string used for rejection\n" "# of half-cycle frames. If the frame type contains 'half'\n" "# (case insensitive) the frame is rejected from the input batch.\n" "#\n" "# Example:\n" "# file1 INT\n" "# file2 HALF-CYCLE1\n" "# file3 HALF-CYCLE2\n" "# file4 INT\n" "# file5 HALF-CYCLE1\n" "# file6 HALF-CYCLE2\n" "# In this example, frames 2, 3, 5 and 6 are rejected (half-cycle).\n" "# Frames 1 and 4 are kept, they are expected to be an AB pair.\n" "#\n" "# Provide one file name per line, no comments allowed.\n" "\n" "[Frames]\n" "FileList = %s ; contains the list of frames to process\n" "\n\n", name_i); return ; } /* * --------------- generate_output_section */ static void generate_output_section(FILE * ini_file, char * name_o) { fprintf(ini_file, "\n\n" "# ----- Saving the output\n" "#\n" "# The final result base name is declared here\n" "# NB: if averaging was not activated, the result is a FITS cube\n" "# i.e. a single 3-d file (NAXIS3>1)\n" "# if averaging was activated, a single image is produced (no NAXIS3)\n" "\n" "[Output]\n" "BaseName = %s;\n" "\n\n", name_o); return ; } /* * --------------- generate_calibration_section */ static void generate_calibration_section(FILE * ini_file, char * name_c) { fprintf(ini_file, "\n\n" "# ----- Flatfield/Bad pixels\n" "#\n" "# Flat-field division and bad pixel replacement\n" "# can be activated here. Provide a file name containing the correct\n" "# calibration data in each case.\n" "# If you do not provide these files, specify 'none' as filename\n" "\n" "[CalibrationData]\n" "FlatField = none; name of the flatfield file\n" "BadPixelMap = none;\n" "\n\n"); return ; } /* * --------------- generate_saa_section */ static void generate_saa_section(FILE * ini_file) { fprintf(ini_file, "\n\n" "# -------------------- Shift and add\n" "#\n" "# Shift and add is separated into the following sections:\n" "# -> 4. object acquisition (detection or file read)\n" "# -> 5. offset detection/estimation\n" "# -> 6. plane shifts\n" "# -> 7. averaging\n" "#\n" "# You can deactivate shift and add (all 4 sections) by saying 'no'\n" "# to 'ApplyShiftAndAdd' here.\n" "\n" "[ShiftAndAdd]\n" "ApplyShiftAndAdd = yes ; activate shift and add\n" "\n\n") ; fprintf(ini_file, "\n\n\n" "# ----- SAA/Object acquisition\n" "#\n" "# Objects must be acquired if you want 'lwjitter' to compute offsets\n" "# between frames, i.e. you provide first estimates through the\n" "# FITS headers or an ASCII file, and ask for refining, or you\n" "# request an automatic offset computation.\n" "# Objects to work on can either be detected by 'lwjitter' itself or\n" "# user-provided. Indicate if the source is 'auto' or 'file'.\n" "\n" "[ObjectAcquisition]\n" "Source = auto ; auto/file\n\n\n" "# The following specifies automatic acquisition parameters.\n" "[DetPeak]\n" "Threshold = 2.0 ; peak detection sigma threshold\n" "MinDetectPoints = 1 ; min # of peaks to detect\n" "MaxDetectPoints = 10 ; max # of peaks to detect\n" "OutputObjects = yes ; dump objects to separate file\n" "\n\n\n" "# You can also provide your own objects through an ASCII file.\n" "# The objects are mandatorily in the first input frame.\n" "# The file format is as usual: lines starting with a hash are\n" "# comments, object positions are given as couples X Y alone on each\n" "# line. Blank lines are ignored. Example:\n" "# --- begin objects.in ---\n" "# 128 256\n" "# 285 384\n" "# 33 12\n" "# --- end objects.in ---\n" "\n" "[UserObjects]\n" "FileName = objects.in ; name of the input object file\n" "\n\n"); fprintf(ini_file, "# ----- SAA/Offset detection and estimation\n" "#\n" "# First estimate offsets can be provided, they either come from\n" "# the FITS headers -- in that case specify the keywords containing\n" "# the offset information --- or from an ASCII file -- in that case\n" "# provide the name of the file containing the offsets, you can get\n" "# more help about this feature by running 'lwjitter --offset'.\n" "#\n" "# You can set the input estimates to 'automatic', which is equivalent\n" "# to setting initial estimates to (0,0) for all planes. The search\n" "# zone is then bigger. Beware that computation time can reach very\n" "# quickly enormous amounts!\n" "#\n" "# For both 'header' and 'file' inputs, you can choose to refine the\n" "# first estimates through cross-correlation techniques (recommended)\n" "# or you can trust your inputs blindly.\n" "#\n" "# Notice that if you request 'header' or 'file' offset inputs but\n" "# an error occurs (e.g. the specified keywords do not exist or they are\n" "# not numerical values, etc.), the program will switch to automatic mode\n" "# so better set the values in 'Automatic' carefully.\n" "#\n" "# The offsets finally found will be saved to the global status report\n" "# if this has been activated, they can also be saved to their own\n" "# output ASCII file if activated here. Default output name for an offset\n" "# file is 'basename'_off.ascii.\n" "\n" "[Offsets]\n" "Input = header ; header/file/auto\n" "OffsetFileOutput = yes ; dump used offsets to separate file\n" "\n" "[HeaderOffsets]\n" "# Either specify isaac-default to get ISAAC's default keywords\n" "# or provide the true name directly, e.g. HIERARCH ESO SEQ CUMOFFSETX.\n" "XOffsetKeyword = isaac-default ;\n" "YOffsetKeyword = isaac-default ;\n" "\n" "Refine = yes ; activate header offset refining\n" "SearchSizeX = 10 ; search halfsize (int)\n" "SearchSizeY = 10 ; search halfsize (int)\n" "MeasureSizeX = 25 ; measure halfsize (int)\n" "MeasureSizeY = 25 ; measure halfsize (int)\n" "\n" "[FileOffsets]\n" "InputFileName = offsets.in ;\n" "Refine = yes ; activate file offset refining\n" "SearchSizeX = 10 ; search halfsize (int)\n" "SearchSizeY = 10 ; search halfsize (int)\n" "MeasureSizeX = 25 ; measure halfsize (int)\n" "MeasureSizeY = 25 ; measure halfsize (int)\n" "\n" "[AutomaticOffsets]\n" "SearchSizeX = 280 ; search halfsize (int)\n" "SearchSizeY = 280 ; search halfsize (int)\n" "MeasureSizeX = 25 ; measure halfsize (int)\n" "MeasureSizeY = 25 ; measure halfsize (int)\n" "\n\n") ; fprintf(ini_file, "\n\n\n" "# ----- SAA/Plane registration\n" "#\n" "# Activate here subpixel shifts if you want to get sharp images,\n" "# but it means interpolation thus noise smoothing. You might prefer\n" "# integer pixel registration but this will produce aliasing in the\n" "# output image.\n" "#\n" "# The interpolation kernel for subpixel shifts is one of:\n" "#\n" "# sinc sin(x)/x\n" "# sinc2 square sinc\n" "# lanczos Lanczos2 window\n" "# hamming Hamming window\n" "# hann Hahn window\n" "# tanh Hyperbolic tangent (default)\n" "#\n" "# Please refer to the algorithmic documentation for more\n" "# information about interpolation kernels. If you do not know\n" "# what to set, use the default (tanh).\n" "#\n" "\n" "[Registration]\n" "SubPixelShifts = yes ; activate subpixel shifts\n" "InterpKernel = tanh ;\n" "\n\n") ; fprintf(ini_file, "\n\n" "# ----- SAA/Plane averaging (3d average)\n" "#\n" "# Choose between straight linear, median, or filtered 3d average.\n" "# The recommended method is 'filtered', set up the high and low\n" "# thresholds according to where you expect to find outliers.\n" "# Default is 5%% low and 5%% high.\n" "\n" "[FrameAverage]\n" "AverageOutput = yes ; activate average of the output\n" "AverageType = filtered ; filtered/median/linear\n" "FilteredLow = 0.05 ; double percentage in [0..1]\n" "FilteredHigh = 0.05 ; double percentage in [0..1]\n\n\n" "#\n" "# -------------------- end of shift and add section\n" "#\n\n\n") ; return ; } /*---------------------------------------------------------------------------*/ /** @name lwjit_ini_parse() @memo Parse an ini file and return an allocated blackboard. @param name Filename of ini file to parse. @return 1 allocated blackboard structure @doc The returned blackboard must be freed in the end using lwjit_bb_destroy(). This function returns NULL in case of parsing error. */ /*---------------------------------------------------------------------------*/ lwjit_bb * lwjit_ini_parse(char * ini_name) { lwjit_bb *bb ; dictionary *d ; int status; /* Find out if named file really exists */ if (!file_exists(ini_name)) { e_error("cannot find ini file [%s]", ini_name); return NULL ; } /* Load ini file into dictionary */ d = iniparser_load(ini_name); /* Create blackboard structure */ bb = lwjit_bb_create() ; /* Parse symbolic table and fill up blackboard structure */ parse_section_frames (d, bb, &status); parse_section_cosmetics (d, bb, &status); parse_section_saa (d, bb, &status); parse_section_postproc (d, bb, &status); parse_section_output (d, bb, &status); iniparser_freedict(d); return bb ; } /* * --------------- parse_section_frames */ static void parse_section_frames( dictionary * sym, lwjit_bb * bb, int * status) { char * listname ; listname = iniparser_getstr(sym, "frames:filelist"); if (is_ascii_list(listname)!=1) { e_error("file [%s] is not an ASCII list: aborting", listname); (*status)++ ; return ; } strcpy(bb->frames_filelist, listname); return ; } /* * --------------- parse_section_cosmetics */ static void parse_section_cosmetics( dictionary * sym, lwjit_bb * bb, int * status) { char * cval ; cval = iniparser_getstr(sym, "calibrationdata:flatfield") ; if (cval!=NULL) { if (strcmp(cval, "none")) { bb->flatfield_division = 1 ; strcpy(bb->flatfield_filename, cval); } } cval = iniparser_getstr(sym, "calibrationdata:badpixelmap") ; if (cval!=NULL) { if (strcmp(cval, "none")) { bb->badpixels_replacement = 1 ; strcpy(bb->badpixels_filename, cval); } } return ; } /* * --------------- parse_section_saa */ static void parse_section_saa( dictionary * sym, lwjit_bb * bb, int * status) { int ival ; double dval ; char * cval ; if (iniparser_getboolean(sym, "shiftandadd:applyshiftandadd", 1)==0) { /* Shift and add not requested: zero all parameters */ bb->saa_apply = 0 ; return ; } /* Shift and add activated */ bb->saa_apply = 1 ; /* Source acquisition from? */ cval = iniparser_getstr(sym, "objectacquisition:source") ; if (cval==NULL) { /* Nothing specified: switch to automatic */ e_warning("no source specified for object acquisition"); e_warning("switching to automatic finder"); bb->objacq_source = OBJACQ_AUTO ; } else { if (!strcmp(cval, "auto")) { /* Automatic mode */ bb->objacq_source = OBJACQ_AUTO ; } else if (!strcmp(cval, "file")) { /* User provided list of objects */ bb->objacq_source = OBJACQ_FILE ; } else { /* Invalid specified source */ e_error("invalid object source: [%s]", cval); e_error("in [ObjectAcquisition]:Source"); (*status)++ ; return ; } } /* Need to output objects to separate file? */ if (iniparser_getboolean(sym, "detpeak:outputobjects", 0)==1) { bb->detpeak_outputobjs = 1 ; } switch (bb->objacq_source) { case OBJACQ_AUTO: /* Find out threshold for detection */ dval = iniparser_getdouble(sym, "detpeak:threshold", -1.0); if (dval<0.0) { /* Invalid threshold: exit */ e_error("[DetPeak]:Threshold: invalid threshold [%g]", dval); (*status)++ ; return ; } bb->detpeak_threshold = dval ; /* Find out min and max detect points */ ival = iniparser_getint(sym, "detpeak:mindetectpoints", -1); if (ival<0) { e_warning("illegal or no value for [DetPeak]:MinDetectPoints"); e_warning("using MinDetectPoints=1"); ival = 1 ; } bb->detpeak_mindetpoints = ival ; ival = iniparser_getint(sym, "detpeak:maxdetectpoints", -1); if (ival<0) { e_warning("illegal or no value for [DetPeak]:MaxDetectPoints"); e_warning("using MaxDetectPoints=1"); ival = 1 ; } bb->detpeak_maxdetpoints = ival ; break ; case OBJACQ_FILE: /* Find out file name to read objects from */ cval = iniparser_getstr(sym, "userobjects:filename"); if (cval==NULL) { e_error("[UserObjects]:Filename does not exist"); e_error("user-defined list of objects requested"); e_error("but no input file was specified"); (*status)++ ; return ; } strcpy(bb->objacq_filename, cval); if (file_exists(bb->objacq_filename)!=1) { e_error("in [UserObjects]:Filename"); e_error("file [%s] does not exist", bb->objacq_filename); (*status)++ ; } break ; default: /* Should never reach here */ e_error("internal error in parsing ini file"); e_error("while in source acquisition"); (*status)++ ; return ; } /* Where are offsets acquired from? */ cval = iniparser_getstr(sym, "offsets:input") ; if (cval==NULL) { e_error("specify a value for [Offsets]:Input"); (*status)++ ; return ; } if (!strcmp(cval, "header")) { bb->off_input = OFFSIN_HEADER ; } else if (!strcmp(cval, "file")) { bb->off_input = OFFSIN_FILE ; } else if (!strcmp(cval, "auto")) { bb->off_input = OFFSIN_AUTO ; } else { e_error("[Offsets]:Input has illegal value [%s]", cval); e_error("should be 'header', 'file' or 'auto'"); (*status)++; return ; } /* Need to output offsets to separate file? */ if (iniparser_getboolean(sym, "offsets:offsetfileoutput", 0)==1) bb->off_fileoutput = 1 ; switch (bb->off_input) { case OFFSIN_HEADER: /* Get X offset keyword */ cval = iniparser_getstr(sym, "headeroffsets:xoffsetkeyword"); if (cval==NULL) { e_error("[Offsets]:Input specifies header offsets"); e_error("but cannot find [HeaderOffsets]:XOffsetKeyword"); (*status)++ ; return ; } strcpy(bb->off_hdr_xkey, cval); /* Get Y offset keyword */ cval = iniparser_getstr(sym, "headeroffsets:yoffsetkeyword"); if (cval==NULL) { e_error("[Offsets]:Input specifies header offsets"); e_error("but cannot find [HeaderOffsets]:YOffsetKeyword"); (*status)++ ; return ; } strcpy(bb->off_hdr_ykey, cval); /* Refine flag */ if (iniparser_getboolean(sym,"headeroffsets:refine",0)==0) { bb->off_hdr_refine = 0 ; } else { /* Refining activated */ bb->off_hdr_refine = 1 ; /* Get search size in X */ ival = iniparser_getint(sym,"headeroffsets:searchsizex",-1); if (ival<0) { e_error("missing [HeaderOffsets]:SearchSizeX"); (*status)++; } bb->off_hdr_sx = ival ; /* Get search size in Y */ ival = iniparser_getint(sym,"headeroffsets:searchsizey",-1); if (ival<0) { e_error("missing [HeaderOffsets]:SearchSizeY"); (*status)++; } bb->off_hdr_sy = ival ; /* Get measure size in X */ ival = iniparser_getint(sym,"headeroffsets:measuresizex",-1); if (ival<0) { e_error("missing [HeaderOffsets]:MeasureSizeX"); (*status)++; } bb->off_hdr_hx = ival ; /* Get measure size in Y */ ival = iniparser_getint(sym,"headeroffsets:measuresizey",-1); if (ival<0) { e_error("missing [HeaderOffsets]:MeasureSizeY"); (*status)++; } bb->off_hdr_hy = ival ; } break ; case OFFSIN_FILE: cval = iniparser_getstr(sym, "fileoffsets:inputfilename"); if (cval==NULL) { e_error("[Offsets]:Input specifies File offsets"); e_error("but cannot find [FileOffsets]:InputFileName"); (*status)++ ; return ; } strcpy(bb->off_file_name, cval); /* Refine flag */ if (iniparser_getboolean(sym,"fileoffsets:refine",0)==0) { bb->off_file_refine = 0 ; } else { /* Refining activated */ bb->off_file_refine = 1 ; /* Get search size in X */ ival = iniparser_getint(sym,"fileoffsets:searchsizex",-1); if (ival<0) { e_error("missing [FileOffsets]:SearchSizeX"); (*status)++; } bb->off_file_sx = ival ; /* Get search size in Y */ ival = iniparser_getint(sym,"fileoffsets:searchsizey",-1); if (ival<0) { e_error("missing [FileOffsets]:SearchSizeY"); (*status)++; } bb->off_file_sy = ival ; /* Get measure size in X */ ival = iniparser_getint(sym,"fileoffsets:measuresizex",-1); if (ival<0) { e_error("missing [FileOffsets]:MeasureSizeX"); (*status)++; } bb->off_file_hx = ival ; /* Get measure size in Y */ ival = iniparser_getint(sym,"fileoffsets:measuresizey",-1); if (ival<0) { e_error("missing [FileOffsets]:MeasureSizeY"); (*status)++; } bb->off_file_hy = ival ; } break ; case OFFSIN_AUTO: /* Get search size in X */ ival = iniparser_getint(sym,"automaticoffsets:searchsizex",-1); if (ival<0) { e_error("missing [AutomaticOffsets]:SearchSizeX"); (*status)++; } bb->off_auto_sx = ival ; /* Get search size in Y */ ival = iniparser_getint(sym,"automaticoffsets:searchsizey",-1); if (ival<0) { e_error("missing [AutomaticOffsets]:SearchSizeY"); (*status)++; } bb->off_auto_sy = ival ; /* Get measure size in X */ ival = iniparser_getint(sym,"automaticoffsets:measuresizex",-1); if (ival<0) { e_error("missing [AutomaticOffsets]:MeasureSizeX"); (*status)++; } bb->off_auto_hx = ival ; /* Get measure size in Y */ ival = iniparser_getint(sym,"automaticoffsets:measuresizey",-1); if (ival<0) { e_error("missing [AutomaticOffsets]:MeasureSizeY"); (*status)++; } bb->off_auto_hy = ival ; break ; default: e_error("internal error during ini file parsing"); e_error("while in offset configuration reading"); (*status)++ ; return ; } /* Automatic offsets are read in any case */ /* Get search size in X */ ival = iniparser_getint(sym,"automaticoffsets:searchsizex",-1); if (ival<0) { e_warning("missing [AutomaticOffsets]:SearchSizeX"); e_warning("using default"); } bb->off_auto_sx = ival ; /* Get search size in Y */ ival = iniparser_getint(sym,"automaticoffsets:searchsizey",-1); if (ival<0) { e_warning("missing [AutomaticOffsets]:SearchSizeY"); e_warning("using default"); } bb->off_auto_sy = ival ; /* Get measure size in X */ ival = iniparser_getint(sym,"automaticoffsets:measuresizex",-1); if (ival<0) { e_warning("missing [AutomaticOffsets]:MeasureSizeX"); e_warning("using default"); } bb->off_auto_hx = ival ; /* Get measure size in Y */ ival = iniparser_getint(sym,"automaticoffsets:measuresizey",-1); if (ival<0) { e_warning("missing [AutomaticOffsets]:MeasureSizeY"); e_warning("using default"); } bb->off_auto_hy = ival ; /* Plane registration */ if (iniparser_getboolean(sym, "registration:subpixelshifts", 1)==1) { bb->reg_subpix = 1 ; cval = iniparser_getstr(sym, "registration:interpkernel"); if (cval!=NULL) { strcpy(bb->reg_kernel, cval); } else { strcpy(bb->reg_kernel, "default"); } } else { bb->reg_subpix = 0 ; } /* 3d average */ if (iniparser_getboolean(sym, "frameaverage:averageoutput", 1)==1) { bb->avg3d_active = 1 ; cval = iniparser_getstr(sym, "frameaverage:averagetype") ; if (cval == NULL) { e_warning("3d average requested but no method specified"); e_warning("using median 3d average"); bb->avg3d_type = AVG3D_MEDIAN ; } else if (!strcmp(cval, "linear")) { bb->avg3d_type = AVG3D_LINEAR ; } else if (!strcmp(cval, "median")) { bb->avg3d_type = AVG3D_MEDIAN ; } else if (!strcmp(cval, "filtered")) { bb->avg3d_type = AVG3D_FILTERED ; dval = iniparser_getdouble(sym,"frameaverage:filteredlow",0.00); bb->avg3d_filt_lo = dval ; dval = iniparser_getdouble(sym,"frameaverage:filteredhigh",0.00); bb->avg3d_filt_hi = dval ; } else { e_error("in [FrameAverage]:AverageType"); e_error("undefined 3d average [%s]", cval); (*status)++; return ; } } else bb->avg3d_active = 0 ; return ; } /* * --------------- parse_section_postproc */ static void parse_section_postproc( dictionary * sym, lwjit_bb * bb, int * status) { char * cval ; if (iniparser_getboolean(sym, "postprocessing:activate", 0)==0) { bb->postproc_active = 0 ; return ; } bb->postproc_active = 1 ; if (iniparser_getboolean(sym,"postprocessing:startviewer",0)==1) { bb->postproc_startviewer = 1 ; cval = iniparser_getstr(sym, "postprocessing:startcommand") ; if (cval == NULL) { e_error("viewer start requested but no viewer provided"); bb->postproc_startviewer = 0 ; (*status)++ ; } else strcpy(bb->postproc_viewer, cval); } if (iniparser_getboolean(sym,"postprocessing:producestatusreport",1)==1) bb->postproc_statusreport = 1 ; return ; } /* * --------------- parse_section_output */ static void parse_section_output( dictionary * sym, lwjit_bb * bb, int * status) { char *cval=NULL ; /* Output section is optional, cannot trigger errors */ cval = iniparser_getstr(sym, "output:basename") ; if (cval==NULL) { e_warning("default output base name used: [lwjit_result]"); strcpy(bb->output_basename, "lwjit_result"); } else { strcpy(bb->output_basename, cval); } return ; }