MI - Fimex
interpolation.h
Go to the documentation of this file.
1 /*
2  * Fimex
3  *
4  * (C) Copyright 2008, met.no
5  *
6  * Project Info: https://wiki.met.no/fimex/start
7  *
8  * This library is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or
11  * (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  * License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21  * USA.
22  */
23 
24 #ifndef INTERPOLATION_H_
25 #define INTERPOLATION_H_
26 
31 #include "fimex/deprecated.h"
32 #include "fimex/mifi_constants.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
44 extern int mifi_string_to_interpolation_method(const char* stringMethod);
45 
46 
71 extern int mifi_interpolate_f(int method,
72  const char* proj_input, const float* infield, const double* in_x_axis, const double* in_y_axis,
73  const int in_x_axis_type, const int in_y_axis_type, const int ix, const int iy, const int iz,
74  const char* proj_output, float* outfield, const double* out_x_axis, const double* out_y_axis,
75  const int out_x_axis_type, const int out_y_axis_type, const int ox, const int oy);
76 
83 extern int mifi_interpolate_d(int method,
84  char* proj_input, double* infield, double* in_x_axis, double* in_y_axis,
85  int in_x_axis_type, int in_y_axis_type, int ix, int iy, int iz,
86  char* proj_output, double* outfield, double* out_x_axis, double* out_y_axis,
87  int out_x_axis_type, int out_y_axis_type, int ox, int oy);
88 
124 extern int mifi_vector_reproject_values_f(int method,
125  const char* proj_input,
126  const char* proj_output,
127  float* u_out, float* v_out,
128  const double* out_x_axis, const double* out_y_axis,
129  int out_x_axis_type, int out_y_axis_type,
130  int ox, int oy, int oz);
142 extern int mifi_vector_reproject_values_by_matrix_f(int method,
143  const double* matrix,
144  float* u_out, float* v_out,
145  int ox, int oy, int oz);
146 
158 extern int mifi_vector_reproject_direction_by_matrix_f(int method,
159  const double* matrix,
160  float* angle_out, // angle in radian
161  int ox, int oy, int oz);
162 
177 extern int mifi_get_vector_reproject_matrix(const char* proj_input,
178  const char* proj_output,
179  const double* out_x_axis, const double* out_y_axis,
180  int out_x_axis_type, int out_y_axis_type,
181  int ox, int oy,
182  double* matrix);
183 
197 int mifi_get_vector_reproject_matrix_field(const char* proj_input,
198  const char* proj_output,
199  const double* in_x_field, const double* in_y_field, // both ox*oy
200  int ox, int oy,
201  double* matrix);
202 
203 
216 int mifi_get_vector_reproject_matrix_points(const char* proj_input,
217  const char* proj_output,
218  int inputIsMetric,
219  const double* out_x_points, const double* out_y_points, // both size on, must be in m or rad
220  int on,
221  double* matrix
222  );
231 extern int mifi_get_values_f(const float* infield, float* outfield, const double x, const double y, const int ix, const int iy, const int iz);
232 
241 extern int mifi_get_values_weak_extrapol_f(const float* infield, float* outfield, const double x, const double y, const int ix, const int iy, const int iz);
242 
251 extern int mifi_get_values_no_extrapol_f(const float* infield, float* outfield, const double x, const double y, const int ix, const int iy, const int iz);
252 
274 extern int mifi_get_values_bilinear_f(const float* infield, float* outvalues, const double x, const double y, const int ix, const int iy, const int iz);
275 
276 
291 extern int mifi_get_values_bicubic_f(const float* infield, float* outvalues, const double x, const double y, const int ix, const int iy, const int iz);
292 
305 extern int mifi_get_values_nearest_f(const float* infieldA, const float* infieldB, float* outfield, const size_t n, const double a, const double b, const double x);
306 
323 extern int mifi_get_values_linear_f(const float* infieldA, const float* infieldB, float* outfield, const size_t n, const double a, const double b, const double x);
335 extern int mifi_get_values_linear_weak_extrapol_f(const float* infieldA, const float* infieldB, float* outfield, const size_t n, const double a, const double b, const double x);
347 extern int mifi_get_values_linear_no_extrapol_f(const float* infieldA, const float* infieldB, float* outfield, const size_t n, const double a, const double b, const double x);
359 extern int mifi_get_values_linear_const_extrapol_f(const float* infieldA, const float* infieldB, float* outfield, const size_t n, const double a, const double b, const double x);
363 extern int mifi_get_values_linear_d(const double* infieldA, const double* infieldB, double* outfield, const size_t n, const double a, const double b, const double x);
364 
381 extern int mifi_get_values_log_f(const float* infieldA, const float* infieldB, float* outfield, const size_t n, const double a, const double b, const double x);
400 extern int mifi_get_values_log_log_f(const float* infieldA, const float* infieldB, float* outfield, const size_t n, const double a, const double b, const double x);
401 
415 extern int mifi_points2position(double* points, const int n, const double* axis, const int num, const int axis_type);
416 
417 
423 static inline int mifi_3d_array_position(int x, int y, int z, int ix, int iy, int iz) {
424  (void)iz; // suppress compiler warning
425  return (z*iy + y)*ix + x;
426 }
427 
428 
429 
443 int mifi_project_values(const char* proj_input, const char* proj_output, double* in_out_x_vals, double* in_out_y_vals, const int num);
444 
461 extern int mifi_project_axes(const char* proj_input, const char* proj_output, const double* in_x_axis, const double* in_y_axis, const int ix, const int iy, double* out_xproj_axis, double* out_yproj_axis);
462 
463 
483 extern int mifi_fill2d_f(size_t nx, size_t ny, float* field, float relaxCrit, float corrEff, size_t maxLoop, size_t* nChanged);
484 
505 extern int mifi_creepfill2d_f(size_t nx, size_t ny, float* field, unsigned short repeat, char setWeight, size_t* nChanged);
506 
528 extern int mifi_creepfillval2d_f(size_t nx, size_t ny, float* field, float defaultVal, unsigned short repeat, char setWeight, size_t* nChanged);
529 
530 
542 int mifi_griddistance(size_t nx, size_t ny, const double* lonVals, const double* latVals, float* gridDistX, float* gridDistY);
543 
564 size_t mifi_compute_vertical_velocity(size_t nx, size_t ny, size_t nz, double dx, double dy, const float* gridDistX, const float* gridDistY, const double* ap, const double* b,
565  const float* zs, const float* ps, const float* u, const float* v, const float* t,
566  float* w);
567 
568 
579 extern size_t mifi_bad2nanf(float* posPtr, float* endPtr, float badVal);
588 extern size_t mifi_nanf2bad(float* posPtr, float* endPtr, float badVal);
589 
599 extern MIFI_DEPRECATED(int mifi_isnanf(float val));
609 extern MIFI_DEPRECATED(int mifi_isnand(double val));
610 
611 
612 
613 
614 #ifdef __cplusplus
615 }
616 #endif
617 
618 
619 #endif /*INTERPOLATION_H_*/
int mifi_string_to_interpolation_method(const char *stringMethod)
int mifi_project_axes(const char *proj_input, const char *proj_output, const double *in_x_axis, const double *in_y_axis, const int ix, const int iy, double *out_xproj_axis, double *out_yproj_axis)
project axes so that the projetion (x,y) => (x_proj), (y_proj) can be expressed as x_proj(x...
int mifi_creepfillval2d_f(size_t nx, size_t ny, float *field, float defaultVal, unsigned short repeat, char setWeight, size_t *nChanged)
Method to fill undefined values in a 2d field in stable time.
static int mifi_3d_array_position(int x, int y, int z, int ix, int iy, int iz)
Definition: interpolation.h:423
int mifi_vector_reproject_direction_by_matrix_f(int method, const double *matrix, float *angle_out, int ox, int oy, int oz)
int mifi_get_values_linear_d(const double *infieldA, const double *infieldB, double *outfield, const size_t n, const double a, const double b, const double x)
int mifi_points2position(double *points, const int n, const double *axis, const int num, const int axis_type)
find position in array of position in projection
int mifi_get_vector_reproject_matrix(const char *proj_input, const char *proj_output, const double *out_x_axis, const double *out_y_axis, int out_x_axis_type, int out_y_axis_type, int ox, int oy, double *matrix)
size_t mifi_compute_vertical_velocity(size_t nx, size_t ny, size_t nz, double dx, double dy, const float *gridDistX, const float *gridDistY, const double *ap, const double *b, const float *zs, const float *ps, const float *u, const float *v, const float *t, float *w)
int mifi_fill2d_f(size_t nx, size_t ny, float *field, float relaxCrit, float corrEff, size_t maxLoop, size_t *nChanged)
Method to fill undefined values in a 2d field.
int mifi_get_values_log_f(const float *infieldA, const float *infieldB, float *outfield, const size_t n, const double a, const double b, const double x)
int mifi_get_values_linear_weak_extrapol_f(const float *infieldA, const float *infieldB, float *outfield, const size_t n, const double a, const double b, const double x)
int mifi_vector_reproject_values_f(int method, const char *proj_input, const char *proj_output, float *u_out, float *v_out, const double *out_x_axis, const double *out_y_axis, int out_x_axis_type, int out_y_axis_type, int ox, int oy, int oz)
interpolate the vector values
int mifi_get_values_bicubic_f(const float *infield, float *outvalues, const double x, const double y, const int ix, const int iy, const int iz)
not implemented yet
size_t mifi_bad2nanf(float *posPtr, float *endPtr, float badVal)
int mifi_get_values_linear_no_extrapol_f(const float *infieldA, const float *infieldB, float *outfield, const size_t n, const double a, const double b, const double x)
int mifi_vector_reproject_values_by_matrix_f(int method, const double *matrix, float *u_out, float *v_out, int ox, int oy, int oz)
int mifi_get_values_bilinear_f(const float *infield, float *outvalues, const double x, const double y, const int ix, const int iy, const int iz)
int mifi_project_values(const char *proj_input, const char *proj_output, double *in_out_x_vals, double *in_out_y_vals, const int num)
project values so that the projetion (x,y) => (x_proj), (y_proj) can be expressed as x_proj(x...
int mifi_interpolate_d(int method, char *proj_input, double *infield, double *in_x_axis, double *in_y_axis, int in_x_axis_type, int in_y_axis_type, int ix, int iy, int iz, char *proj_output, double *outfield, double *out_x_axis, double *out_y_axis, int out_x_axis_type, int out_y_axis_type, int ox, int oy)
not implemented yet
size_t mifi_nanf2bad(float *posPtr, float *endPtr, float badVal)
int mifi_get_values_linear_const_extrapol_f(const float *infieldA, const float *infieldB, float *outfield, const size_t n, const double a, const double b, const double x)
int mifi_get_vector_reproject_matrix_points(const char *proj_input, const char *proj_output, int inputIsMetric, const double *out_x_points, const double *out_y_points, int on, double *matrix)
int mifi_griddistance(size_t nx, size_t ny, const double *lonVals, const double *latVals, float *gridDistX, float *gridDistY)
int mifi_get_values_nearest_f(const float *infieldA, const float *infieldB, float *outfield, const size_t n, const double a, const double b, const double x)
int mifi_interpolate_f(int method, const char *proj_input, const float *infield, const double *in_x_axis, const double *in_y_axis, const int in_x_axis_type, const int in_y_axis_type, const int ix, const int iy, const int iz, const char *proj_output, float *outfield, const double *out_x_axis, const double *out_y_axis, const int out_x_axis_type, const int out_y_axis_type, const int ox, const int oy)
int mifi_get_values_weak_extrapol_f(const float *infield, float *outfield, const double x, const double y, const int ix, const int iy, const int iz)
int mifi_get_values_log_log_f(const float *infieldA, const float *infieldB, float *outfield, const size_t n, const double a, const double b, const double x)
int mifi_get_values_f(const float *infield, float *outfield, const double x, const double y, const int ix, const int iy, const int iz)
MIFI_DEPRECATED(int mifi_isnanf(float val))
int mifi_get_values_linear_f(const float *infieldA, const float *infieldB, float *outfield, const size_t n, const double a, const double b, const double x)
int mifi_get_vector_reproject_matrix_field(const char *proj_input, const char *proj_output, const double *in_x_field, const double *in_y_field, int ox, int oy, double *matrix)
int mifi_creepfill2d_f(size_t nx, size_t ny, float *field, unsigned short repeat, char setWeight, size_t *nChanged)
Method to fill undefined values in a 2d field in stable time.
int mifi_get_values_no_extrapol_f(const float *infield, float *outfield, const double x, const double y, const int ix, const int iy, const int iz)