/*-------------------------------------------------------------------------*/ /** @file classif.h @author Y. Jung @date July 2000 @version $Revision: 1.4 $ @brief ISAAC common functions for frames classification */ /*--------------------------------------------------------------------------*/ /* $Id: classif.h,v 1.4 2001/11/28 16:31:51 yjung Exp $ $Author: yjung $ $Date: 2001/11/28 16:31:51 $ $Revision: 1.4 $ */ #ifndef _IS_UTILS_CLASSIF_H_ #define _IS_UTILS_CLASSIF_H_ /*--------------------------------------------------------------------------- Defines ---------------------------------------------------------------------------*/ #define OFFSOURCE_FILE 1 #define OFFSOURCE_HEADER 2 /*--------------------------------------------------------------------------- Function prototypes ---------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/ /** @brief Get rid of non science frames in a frame list @param frame_list frame list @param nframes nb of frames in the input frame list @param nb_clean_frames nb of frames in output list @return The new list */ /*--------------------------------------------------------------------------*/ char ** reject_non_science_frames( char ** frame_list, int nframes, int * nb_clean_frames) ; /*-------------------------------------------------------------------------*/ /** @brief Get rid of half-cycle frames in a frame list @param frame_list frame list @param nframes nb of frames in the input frame list @param nb_clean_frames nb of frames in output list @return The new list */ /*--------------------------------------------------------------------------*/ char ** reject_hc_frames( char ** frame_list, int nframes, int * nb_clean_frames) ; /*-------------------------------------------------------------------------*/ /** @brief Classification engine for spectroscopic jitter (SW + LW) @param frame_list input frames names. @param nframes Nb of frames. @param offsets_source OFFSOURCE_HEADER or OFFSOURCE_FILE @param keyword_used_for_classif keyword used for the classification. If it begins with "isaac", use isaac_get_cumoffsety(). @param offsets_sourcefile ASCII file with the offsets list @param offsets_total_list array in which a nframes offs list is written. MODIFIED. @param nb_classified_cubes nb of cubes. MODIFIED. @param cube_id int array that gives for each frame the corresp cube. MODIFIED @param status_classification ALGO_FAILED, ALGO_SKIPPED or ALGO_OK. MODIFIED. @return Classified cubes */ /*--------------------------------------------------------------------------*/ int spectro_jitter_classification( char ** frame_list, int nframes, int offsets_source, char * keyword_used_for_classif, char * offsets_sourcefile, double ** offsets_total_list, int * nb_classified_cubes, int ** cube_id, int * status_classification) ; /*-------------------------------------------------------------------------*/ /** @brief separate a frame list into nb_cubes new cubes @param in frame list @param nbframes number of frames in the list @param t_switch switch table. values from 0 to nbcubes-1 @param nb_cubes nb of cubes (ie nb of values taken by t_switch) @return newly allocated list of nb_cubes destroys the input cube after use */ /*--------------------------------------------------------------------------*/ cube_t ** spectro_jitter_framelist_to_cubes( char ** in, int nframes, int * t_switch, int nb_cubes) ; /*-------------------------------------------------------------------------*/ /** @brief Get an offset from an offsets list @param list offsets list @param nboff nb of offsets in the list @param cube_id array that identifies cubes @param cube specifies the cube @param iter specifies which offset of the cube @return the found offset */ /*--------------------------------------------------------------------------*/ double get_offset_in_list( double * list, int noff, int * cube_id, int cube, int iter) ; /*-------------------------------------------------------------------------*/ /** @brief create a list of HC frames from a list of frames @param list list of frames @param nb_frames nb of frames in list @param nb_hc nb of hc frames @param type 1 for HC1, 2 for HC2 @return list of hc frames */ /*--------------------------------------------------------------------------*/ char ** get_hc_frames( char ** list, int nb_frames, int * nb_hc, int type) ; /*-------------------------------------------------------------------------*/ /** @brief get an offset list from a list of FITS headers @param nframes number of frames @param filenames list of frames @param keyword keyword to look for ("isaac-default" for ISAAC std) @return a list of offsets ISAAC specific */ /*--------------------------------------------------------------------------*/ double * get_cumoffsety_from_fits_header( int nframes, char ** filenames, char * keyword) ; /*-------------------------------------------------------------------------*/ /** @memo get an offset list from a ascii file @param offsets_sourcefile ASCII file with the offsets list @param nframes number of input frames @param filelist list of input frame names @return a list of offsets ISAAC specific */ /*--------------------------------------------------------------------------*/ double * get_offsets_from_file( char * offsets_sourcefile, int nframes, char ** filelist) ; /*-------------------------------------------------------------------------*/ /** @brief compare the grating, the slit and the wl in input files headers @param file1 first file @param file2 second file @return -1 in error case, 0 for different settings, 1 for equal settings */ /*--------------------------------------------------------------------------*/ int compare_settings( char * file1, char * file2) ; /*-------------------------------------------------------------------------*/ /** @brief identify the activated lamps in a frames list @param lnames list of frames @return array: array[i]: 0 if no activated lamps in lnames[i], 1 if xenon lamp is activated, 2 if argon lamp is activated, 3 if both lamps are activated */ /*--------------------------------------------------------------------------*/ int * find_activated_lamps(framelist * lnames) ; /*-------------------------------------------------------------------------*/ /** @brief for each setting, look if it is a medium or low resol setting @param lnames list of file names @param nsettings number of settings @return array of nsettings chars : l or m for low or medium resolution */ /*--------------------------------------------------------------------------*/ char * get_resolutions( framelist * lnames, int nsettings) ; /*-------------------------------------------------------------------------*/ /** @brief find out in an ASCII file which file name corresponds to a master dark frame. The order number specifies, in case there are several files corresponding to the definition, which one should be returned. First file is order 1, second file is order 2, etc. @param filename name of an ASCII file @param id id @param order order number @return pointer to statically allocated char string This is highly DFS dependant Example : If the input ASCII file contains: --- begin 'input' --- /data/flat1.fits MASTER_FLAT /data/flat2.fits MASTER_FLAT /data/dark1.fits MASTER_DARK /data/dark2.fits MASTER_DARK --- end 'input' ----- Calling: isaac_get_calibframe_name("input", "MASTER_FLAT", 1) returns: "/data/flat1.fits" isaac_get_calibframe_name("input", "MASTER_FLAT", 2) returns: "/data/flat2.fits" etc. */ /*--------------------------------------------------------------------------*/ char * isaac_get_calibframe_name(char * filename, char * id, int order) ; /*-------------------------------------------------------------------------*/ /** @brief for a list of FITS frames, extract the keyword value for each frame and return as a list of doubles. @param fnames list of file names @param nfiles number of files @param keyword a FITS keyword @return list of doubles */ /*--------------------------------------------------------------------------*/ double * get_detconfig(char ** fnames, int nfiles, char * keyword) ; /*-------------------------------------------------------------------------*/ /** @brief Filter half-cycle frames out of a frame list. @param flist Framelist object to purge. @return int 0 if Ok, -1 otherwise. This function processes a framelist object to remove any half-cycle frame. These frames are only expected in long-wavelength mode and they can be detected in two ways. Either the frame type in the framelist contains the word 'half' (case-insensitive), or the frame name corresponds to a FITS file that is referenced as a half-cycle frame. */ /*--------------------------------------------------------------------------*/ int isaac_lw_filter_halfcycle(framelist ** flist) ; /*-------------------------------------------------------------------------*/ /** @brief Classifies a charmatrix of files according to a token retrieval @param in files to classify. @param colno the column number to use as an alternative to the token retrieval function @param nb_of_classes number of classes found @param funk_get_tok the token retrieval function @return array of charmatrixes classified by token, NULL if error This function is typically used to classify a group of frames in a charmatrix. Either the token has been provided in the framelist text file as column colno (!=0) or it has to be retrieved by funk_get_tok which takes a filename of the framelist as a parameter. A typical example is one of the functions isaac_get_XXX in dicbkeys.h The function returns an array of charmatrixes each having the unique token in colno (if supplied) or appended as the last column (i.e. in->lx). */ /*--------------------------------------------------------------------------*/ charmatrix ** classify_charmatrix_by_token( charmatrix * in, int colno, int * nb_of_classes, char * (*funk_get_tok)(char*)) ; /*-------------------------------------------------------------------------*/ /** @brief Classifies a list of files according to a token retrieval function. @param in files to classify. @param nfiles number of files in input @param funk_get_tok the token retrieval function @param toktab token table @param classcount the number of files for each token @param nb_of_classes the number of different tokens found. @return array of file lists classified by token, NULL if error This function is typically used to classify a group of frames in a filelist (char**). The token has to be retrieved by funk_get_tok which takes a filename of the framelist as a parameter. A typical example is one of the functions isaac_get_XXX in dicbkeys.h The function returns an array of file lists char**. The token table is similar to the file list containing the found tokens. */ /*--------------------------------------------------------------------------*/ char *** classify_charlist_by_token( char ** in, int nfiles, char *** toktab, int * nb_of_classes, int ** classcount, char * (*funk_get_tok)(char*)) ; /*-------------------------------------------------------------------------*/ /* @brief Classifies a framelist according to a token retrieval function. @param in framelist to classify. @param funk_get_tok the token retrieval function @param toktab token table @param nb_of_classes the number of different tokens found. @return array of framelists classified by token, NULL if error This function is typically used to classify a group of frames in a frameist. The token has to be retrieved by funk_get_tok which takes a filename of the framelist as a parameter. A typical example is one of the functions isaac_get_XXX in dicbkeys.h The function returns an array of framelists. The token table is a list containing the found tokens. */ /*--------------------------------------------------------------------------*/ framelist * classify_framelist_by_token( framelist* in, char *** toktab, int * nb_of_classes, char * (*funk_get_tok)(char*)) ; /*-------------------------------------------------------------------------*/ /** @brief selects files in a list of files according to a token function. @param in files to classify (freed). @param nfiles number of files in (modified) @param funk_get_tok the token retrieval function @param token the token to match by funk_get_tok() @return list of files matching token, NULL if error This function is typically used to selct frames in a filelist (char**). The token has to match what is retrieved by funk_get_tok which takes a filename of the framelist as a parameter. A typical example is one of the functions isaac_get_XXX in dicbkeys.h The function returns a file list char**. The input list is deallocated and the nfiles parameter is updated for convenience, i.e. this function is called repeatedly whith different token/funk_get_tok's. */ /*--------------------------------------------------------------------------*/ char ** select_charlist_by_token( char ** in, int * nfiles, char * token, char * (*funk_get_tok)(char*)) ; #endif