00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef MUSE_UTILS_H
00023 #define MUSE_UTILS_H
00024
00025
00026
00027
00028 #include <cpl.h>
00029 #include <math.h>
00030
00031 #include "muse_dfs.h"
00032 #include "muse_image.h"
00033 #include "muse_pixtable.h"
00034 #include "muse_processing.h"
00035
00036
00037
00038 #ifndef FILENAME_MAX
00039 # error FILENAME_MAX undefined!
00040 #endif
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #define UNUSED_ARGUMENT(arg) (void)(arg)
00051 #define UNUSED_ARGUMENTS(arg1,arg2) UNUSED_ARGUMENT(arg1),UNUSED_ARGUMENT(arg2);
00052
00053
00054 #if !HAVE_ISFINITE
00055 #if HAVE_ISNAN && HAVE_ISINF
00056 #define isfinite(x) (!isnan(x) && !isinf(x))
00057 #else
00058 #define isfinite(x) ((x != nan) && (x != -nan) && (x != inf) && (x != -inf))
00059 #endif
00060 #endif
00061
00062
00063 #if !HAVE_ISNORMAL
00064 #if HAVE_ISNAN && HAVE_ISINF
00065 #define isnormal(x) (!isnan(x) && !isinf(x) && (x != 0.))
00066 #else
00067 #define isnormal(x) ((x != nan) && (x != -nan) && (x != inf) && (x != -inf) \
00068 && (x != 0.) && (x != -0.))
00069 #endif
00070 #endif
00071
00072
00073 #if !HAVE_DRAND48
00074
00075 #define drand48() ((double)(rand()) / RAND_MAX)
00076 #endif
00077
00081
00082
00083 #define MUSE_ERROR_READ_DATA CPL_ERROR_EOL+1
00084 #define MUSE_ERROR_READ_DQ CPL_ERROR_EOL+2
00085 #define MUSE_ERROR_READ_STAT CPL_ERROR_EOL+3
00086
00087 #define MUSE_ERROR_SLICE_LEFT_MISSING CPL_ERROR_EOL+4
00088 #define MUSE_ERROR_SLICE_RIGHT_MISSING CPL_ERROR_EOL+5
00089 #define MUSE_ERROR_SLICE_EDGE_MISSING CPL_ERROR_EOL+6
00090
00091 #define MUSE_ERROR_CHIP_NOT_LIVE CPL_ERROR_EOL+10
00092
00093
00094
00095
00096
00097
00101
00102 typedef enum {
00103 MUSE_UTILS_CENTROID_NORMAL = 0,
00104 MUSE_UTILS_CENTROID_MEAN,
00105 MUSE_UTILS_CENTROID_MEDIAN
00106 } muse_utils_centroid_type;
00107
00110
00111
00112
00113 const char *muse_get_license(void);
00114
00115 unsigned char muse_utils_get_ifu(const cpl_propertylist *);
00116 int muse_utils_get_extension_for_ifu(const char *, unsigned char);
00117
00118 cpl_frameset *muse_frameset_find(const cpl_frameset *, const char *, unsigned char, cpl_boolean);
00119 cpl_frameset *muse_frameset_find_tags(const cpl_frameset *, const cpl_array *, unsigned char, cpl_boolean);
00120 cpl_frameset *muse_frameset_check_raw(const cpl_frameset *, const cpl_array *, unsigned char);
00121 cpl_frameset *muse_frameset_sort_raw_other(const cpl_frameset *, int, const char *, cpl_boolean);
00122 cpl_frame *muse_frameset_find_master(const cpl_frameset *, const char *, unsigned char);
00123 cpl_error_code muse_utils_frameset_merge_frames(cpl_frameset *, cpl_boolean);
00124
00125 cpl_table *muse_table_load(muse_processing *, const char *, unsigned char);
00126 cpl_propertylist *muse_propertylist_load(muse_processing *, const char *);
00127 cpl_table *muse_table_load_filter(muse_processing *, const char *);
00128
00129 char *muse_utils_header_get_lamp_names(cpl_propertylist *, char);
00130 cpl_array *muse_utils_header_get_lamp_numbers(cpl_propertylist *);
00131 cpl_image *muse_utils_image_fit_polynomial(const cpl_image *, unsigned short, unsigned short);
00132 cpl_error_code muse_utils_image_get_centroid_window(cpl_image *, int, int, int, int, double *, double *, muse_utils_centroid_type);
00133 cpl_error_code muse_utils_get_centroid(const cpl_matrix *, const cpl_vector *, const cpl_vector *, double *, double *, muse_utils_centroid_type);
00134 cpl_error_code muse_utils_fit_multigauss_1d(const cpl_vector *, const cpl_bivector *, cpl_vector *, double *, cpl_vector *, cpl_vector *, double *, double *, cpl_matrix **);
00135 cpl_error_code muse_utils_fit_moffat_2d(const cpl_matrix *, const cpl_vector *, const cpl_vector *, cpl_array *, cpl_array *, const cpl_array *, double *, double *);
00136 cpl_polynomial *muse_utils_iterate_fit_polynomial(cpl_matrix *, cpl_vector *, cpl_vector *, cpl_table *, const unsigned int, const double, double *, double *);
00137 double muse_utils_pixtable_fit_line_gaussian(muse_pixtable *, double, double, double, float, float, unsigned char, cpl_array *, cpl_array *);
00138 cpl_matrix *muse_matrix_new_gaussian_2d(int, int, double);
00139
00140 cpl_error_code muse_utils_copy_modified_header(cpl_propertylist *, cpl_propertylist *, const char *, const char *);
00141 cpl_error_code muse_utils_set_hduclass(cpl_propertylist *, const char *, const char *, const char *, const char *);
00142
00143 void muse_utils_memory_dump(const char *);
00144
00145 muse_image *muse_fov_load(const char *aFilename);
00146 cpl_image *muse_convolve_image(const cpl_image *aImage, const cpl_matrix *aKernel);
00147
00148
00149 #endif