File: harp.h.in

package info (click to toggle)
harp 1.5%2Bdata-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 54,032 kB
  • sloc: xml: 286,510; ansic: 143,710; yacc: 1,910; python: 913; makefile: 600; lex: 574; sh: 69
file content (617 lines) | stat: -rw-r--r-- 29,330 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
/*
* Copyright (C) 2015-2018 S[&]T, The Netherlands.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
*    this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
*    contributors may be used to endorse or promote products derived from
*    this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef HARP_H
#define HARP_H

#include <stdarg.h>

/** \file */

/* *INDENT-OFF* */
#ifdef __cplusplus
extern "C"
{
#endif
/* *INDENT-ON* */

#if defined(WIN32) && defined(LIBHARPDLL)
#ifdef LIBHARPDLL_EXPORTS
#define LIBHARP_API __declspec(dllexport)
#else
#define LIBHARP_API __declspec(dllimport)
#endif
#else
#define LIBHARP_API
#endif

#ifndef HARP_CONFIG_H

/* These are the 'configure' defines that we need to export.
 * However, we need to assume that the user of harp.h may also be defining
 * some of these values himself. In order to prevent double definitions each
 * define below is encapsulated by a #ifndef - #endif block.
 */

#ifndef HAVE_INTTYPES_H
#undef HAVE_INTTYPES_H
#endif
#ifndef HAVE_STDINT_H
#undef HAVE_STDINT_H
#endif
#ifndef HAVE_SYS_TYPES_H
#undef HAVE_SYS_TYPES_H
#endif

#ifndef int8_t
#undef int8_t
#endif
#ifndef int16_t
#undef int16_t
#endif
#ifndef int32_t
#undef int32_t
#endif
#ifndef int64_t
#undef int64_t
#endif

#ifndef uint8_t
#undef uint8_t
#endif
#ifndef uint16_t
#undef uint16_t
#endif
#ifndef uint32_t
#undef uint32_t
#endif
#ifndef uint64_t
#undef uint64_t
#endif

#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#else
#ifdef HAVE_STDINT_H
#include <stdint.h>
#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#endif
#endif

#endif /* HARP_CONFIG_H */

/* *CFFI-ON* */

LIBHARP_API extern const char *libharp_version;

/** Maximum number of dimensions of a multidimensional array. */
#define HARP_MAX_NUM_DIMS       (8)

LIBHARP_API extern int harp_errno;

#define HARP_SUCCESS                                           (0)
#define HARP_ERROR_OUT_OF_MEMORY                              (-1)

#define HARP_ERROR_HDF4                                     (-100)
#define HARP_ERROR_NO_HDF4_SUPPORT                          (-101)
#define HARP_ERROR_HDF5                                     (-102)
#define HARP_ERROR_NO_HDF5_SUPPORT                          (-103)
#define HARP_ERROR_NETCDF                                   (-104)
#define HARP_ERROR_CODA                                     (-105)

#define HARP_ERROR_FILE_NOT_FOUND                           (-200)
#define HARP_ERROR_FILE_OPEN                                (-201)
#define HARP_ERROR_FILE_CLOSE                               (-202)
#define HARP_ERROR_FILE_READ                                (-203)
#define HARP_ERROR_FILE_WRITE                               (-204)

#define HARP_ERROR_INVALID_ARGUMENT                         (-300)
#define HARP_ERROR_INVALID_INDEX                            (-301)
#define HARP_ERROR_INVALID_NAME                             (-302)
#define HARP_ERROR_INVALID_FORMAT                           (-303)
#define HARP_ERROR_INVALID_DATETIME                         (-304)
#define HARP_ERROR_INVALID_TYPE                             (-305)
#define HARP_ERROR_INVALID_PRODUCT                          (-306)
#define HARP_ERROR_INVALID_VARIABLE                         (-307)
#define HARP_ERROR_ARRAY_NUM_DIMS_MISMATCH                  (-308)
#define HARP_ERROR_ARRAY_OUT_OF_BOUNDS                      (-309)
#define HARP_ERROR_VARIABLE_NOT_FOUND                       (-310)

#define HARP_ERROR_UNIT_CONVERSION                          (-400)

#define HARP_ERROR_OPERATION                                (-500)
#define HARP_ERROR_OPERATION_SYNTAX                         (-501)

#define HARP_ERROR_IMPORT                                   (-600)
#define HARP_ERROR_EXPORT                                   (-601)

#define HARP_ERROR_INGESTION                                (-700)
#define HARP_ERROR_INGESTION_OPTION_SYNTAX                  (-701)
#define HARP_ERROR_INVALID_INGESTION_OPTION                 (-702)
#define HARP_ERROR_INVALID_INGESTION_OPTION_VALUE           (-703)

#define HARP_ERROR_UNSUPPORTED_PRODUCT                      (-800)

#define HARP_ERROR_NO_DATA                                  (-900)

/* *CFFI-OFF* */

/** Default units used in HARP */
#define HARP_UNIT_ACCELERATION "m/s2"
#define HARP_UNIT_AEROSOL_EXTINCTION "1/m"
#define HARP_UNIT_AEROSOL_EXTINCTION_SQUARED "(1/m)2"
#define HARP_UNIT_ANGLE "degree"
#define HARP_UNIT_AREA "m2"
#define HARP_UNIT_COLUMN_MASS_DENSITY "kg/m2"
#define HARP_UNIT_COLUMN_MASS_DENSITY_SQUARED "(kg/m2)2"
#define HARP_UNIT_COLUMN_NUMBER_DENSITY "molec/m2"
#define HARP_UNIT_COLUMN_NUMBER_DENSITY_SQUARED "(molec/m2)2"
#define HARP_UNIT_DATETIME "s since 2000-01-01"
#define HARP_UNIT_DIMENSIONLESS ""
#define HARP_UNIT_FREQUENCY "Hz"
#define HARP_UNIT_GEOPOTENTIAL "m2/s2"
#define HARP_UNIT_IRRADIANCE "W/m2"
#define HARP_UNIT_LATITUDE "degree_north"
#define HARP_UNIT_LENGTH "m"
#define HARP_UNIT_LONGITUDE "degree_east"
#define HARP_UNIT_MASS_DENSITY "kg/m3"
#define HARP_UNIT_MASS_MIXING_RATIO "kg/kg"
#define HARP_UNIT_MASS_MIXING_RATIO_SQUARED "(kg/kg)2"
#define HARP_UNIT_MOLAR_MASS "g/mol"
#define HARP_UNIT_NUMBER_DENSITY "molec/m3"
#define HARP_UNIT_NUMBER_DENSITY_SQUARED "(molec/m3)2"
#define HARP_UNIT_PERCENT "%"
#define HARP_UNIT_PRESSURE "Pa"
#define HARP_UNIT_RADIANCE "W/(sr m2)"
#define HARP_UNIT_SPEED "m/s"
#define HARP_UNIT_TEMPERATURE "K"
#define HARP_UNIT_TIME "s"
#define HARP_UNIT_VOLUME_MIXING_RATIO "ppv"
#define HARP_UNIT_VOLUME_MIXING_RATIO_SQUARED "(ppv)2"
#define HARP_UNIT_WAVELENGTH "m"
#define HARP_UNIT_WAVENUMBER "1/m"

/* *CFFI-ON* */

/** \addtogroup harp_general
 * @{
 */

enum harp_data_type_enum
{
    harp_type_int8,     /**< BYTE */
    harp_type_int16,    /**< INTEGER */
    harp_type_int32,    /**< LONG */
    harp_type_float,    /**< FLOAT */
    harp_type_double,   /**< DOUBLE */
    harp_type_string    /**< STRING */
};
typedef enum harp_data_type_enum harp_data_type;

#define HARP_NUM_DATA_TYPES (6)

union harp_scalar_union
{
    int8_t int8_data;
    int16_t int16_data;
    int32_t int32_data;
    float float_data;
    double double_data;
};
typedef union harp_scalar_union harp_scalar;

union harp_array_union
{
    int8_t *int8_data;
    int16_t *int16_data;
    int32_t *int32_data;
    float *float_data;
    double *double_data;
    char **string_data;
    void *ptr;
};
typedef union harp_array_union harp_array;

enum harp_dimension_type_enum
{
    harp_dimension_independent = -1,
    harp_dimension_time,
    harp_dimension_latitude,
    harp_dimension_longitude,
    harp_dimension_vertical,
    harp_dimension_spectral
};
typedef enum harp_dimension_type_enum harp_dimension_type;

#define HARP_NUM_DIM_TYPES  (5)

/** @} */

/** \addtogroup harp_variable
 * @{
 */

/** HARP Variable struct */
struct harp_variable_struct
{
    char *name; /**< name of variable */
    harp_data_type data_type; /**< storage type of the data */
    int num_dimensions; /**< number of array dimensions */
    harp_dimension_type dimension_type[HARP_MAX_NUM_DIMS]; /**< type of each of the array dimensions */
    long dimension[HARP_MAX_NUM_DIMS];  /**< length of each of the array dimensions */
    long num_elements;  /**< total number of elements (equals product of array dimensions) */
    harp_array data;    /**< array data of the variable */
    /* special attributes - the harp_scalar attributes are only valid if data_type != harp_type_string */
    char *description;  /**< corresponds to netCDF long_name */
    char *unit; /**< corresponds to netCDF units */
    harp_scalar valid_min;      /**< corresponds to netCDF valid_min or valid_range[0] */
    harp_scalar valid_max;      /**< corresponds to netCDF valid_max or valid_range[1] */
    int num_enum_values;        /**< number of enumeration values (which map to values 0..N-1 in 'data') */
    char **enum_name;           /**< name of each enumeration value */
};

/** HARP Variable typedef */
typedef struct harp_variable_struct harp_variable;

/** @} */

/** \addtogroup harp_product
 * @{
 */

/** HARP Product struct */
struct harp_product_struct
{
    long dimension[HARP_NUM_DIM_TYPES]; /**< length of each dimension (0 for unused dimensions) */
    int num_variables;  /**< number of variables in this product */
    harp_variable **variable;   /**< pointers to the variables */
    char *source_product; /**< identifier of the product the HARP product originates from */
    char *history;  /**< value for the 'history' global attribute */
};

/** HARP Product typedef */
typedef struct harp_product_struct harp_product;

/** @} */

/** \addtogroup harp_product_metadata
 * @{
 */

/** HARP Product Metadata struct */
struct harp_product_metadata_struct
{
    char *filename;
    double datetime_start;
    double datetime_stop;
    long dimension[HARP_NUM_DIM_TYPES];
    char *source_product;
};

/** HARP Product Metadata typedef */
typedef struct harp_product_metadata_struct harp_product_metadata;

/** @} */

/** \addtogroup harp_dataset
 * @{
 */

/** HARP Dataset struct */
struct harp_dataset_struct
{
    struct hashtable_struct *product_to_index;  /* maps source_product names to indices */
    char **source_product;      /* set of source products - every source appears only once */
    long *sorted_index; /* indices of products sorted by source_product name */
    long num_products;
    harp_product_metadata **metadata;   /* stores metadata for source in source_product */
};

/** HARP Dataset typedef */
typedef struct harp_dataset_struct harp_dataset;

/** @} */

/** \addtogroup harp_collocation
 * @{
 */

/** Entry for a single matched pair for a collocation between a dataset A and dataset B */
struct harp_collocation_pair_struct
{
    long collocation_index;
    long product_index_a;       /* index into dataset_a of associated collocation result */
    long sample_index_a;
    long product_index_b;       /* index into dataset_b of associated collocation result */
    long sample_index_b;
    int num_differences;
    double *difference;
};

typedef struct harp_collocation_pair_struct harp_collocation_pair;

/** HARP Collocation result */
struct harp_collocation_result_struct
{
    harp_dataset *dataset_a;
    harp_dataset *dataset_b;
    int num_differences;
    char **difference_variable_name;
    char **difference_unit;
    long num_pairs;
    harp_collocation_pair **pair;
};
typedef struct harp_collocation_result_struct harp_collocation_result;

/** @} */


/* General */
LIBHARP_API int harp_init(void);
LIBHARP_API void harp_done(void);

LIBHARP_API int harp_isfinite(double x);
LIBHARP_API int harp_isnan(double x);
LIBHARP_API double harp_nan(void);
LIBHARP_API int harp_isinf(double x);
LIBHARP_API int harp_isplusinf(double x);
LIBHARP_API int harp_ismininf(double x);
LIBHARP_API double harp_plusinf(void);
LIBHARP_API double harp_mininf(void);

LIBHARP_API void harp_str64(int64_t a, char *s);
LIBHARP_API void harp_str64u(uint64_t a, char *s);

LIBHARP_API const char *harp_basename(const char *path);

LIBHARP_API long harp_get_size_for_type(harp_data_type data_type);

LIBHARP_API harp_scalar harp_get_fill_value_for_type(harp_data_type data_type);
LIBHARP_API harp_scalar harp_get_valid_min_for_type(harp_data_type data_type);
LIBHARP_API harp_scalar harp_get_valid_max_for_type(harp_data_type data_type);
LIBHARP_API int harp_is_fill_value_for_type(harp_data_type data_type, harp_scalar value);
LIBHARP_API int harp_is_valid_min_for_type(harp_data_type data_type, harp_scalar value);
LIBHARP_API int harp_is_valid_max_for_type(harp_data_type data_type, harp_scalar value);

LIBHARP_API const char *harp_get_data_type_name(harp_data_type data_type);
LIBHARP_API const char *harp_get_dimension_type_name(harp_dimension_type dimension_type);

LIBHARP_API int harp_parse_dimension_type(const char *str, harp_dimension_type *dimension_type);

LIBHARP_API int harp_set_coda_definition_path(const char *path);
LIBHARP_API int harp_set_coda_definition_path_conditional(const char *file, const char *searchpath,
                                                          const char *relative_location);
LIBHARP_API int harp_set_udunits2_xml_path(const char *path);
LIBHARP_API int harp_set_udunits2_xml_path_conditional(const char *file, const char *searchpath,
                                                       const char *relative_location);

LIBHARP_API int harp_set_option_enable_aux_afgl86(int enable);
LIBHARP_API int harp_get_option_enable_aux_afgl86(void);
LIBHARP_API int harp_set_option_enable_aux_usstd76(int enable);
LIBHARP_API int harp_get_option_enable_aux_usstd76(void);
LIBHARP_API int harp_set_option_hdf5_compression(int level);
LIBHARP_API int harp_get_option_hdf5_compression(void);
LIBHARP_API int harp_set_option_regrid_out_of_bounds(int method);
LIBHARP_API int harp_get_option_regrid_out_of_bounds(void);

LIBHARP_API int harp_convert_unit(const char *from_unit, const char *to_unit, long num_values, double *value);

/* Generated documentation */
LIBHARP_API int harp_doc_list_conversions(const harp_product *product, const char *variable_name,
                                          int (*print) (const char *, ...));
LIBHARP_API int harp_doc_export_ingestion_definitions(const char *path);

/* Geometry */
LIBHARP_API int harp_geometry_get_point_distance(double latitude_a, double longitude_a, double latitude_b,
                                                 double longitude_b, double *distance);
LIBHARP_API int harp_geometry_get_area(int num_vertices, double *latitude_bounds, double *longitude_bounds,
                                       double *area);
LIBHARP_API int harp_geometry_has_point_in_area(double latitude_point, double longitude_point, int num_vertices,
                                                double *latitude_bounds, double *longitude_bounds, int *in_area);
LIBHARP_API int harp_geometry_has_area_overlap(int num_vertices_a, double *latitude_bounds_a,
                                               double *longitude_bounds_a, int num_vertices_b,
                                               double *latitude_bounds_b, double *longitude_bounds_b, int *has_overlap,
                                               double *fraction);

/* Error */
LIBHARP_API void harp_set_error(int err, const char *message, ...);
LIBHARP_API void harp_add_error_message(const char *message, ...);
LIBHARP_API const char *harp_errno_to_string(int err);
LIBHARP_API int harp_report_warning(const char *message, ...);

/* *CFFI-OFF* */
LIBHARP_API int harp_get_warning_handler(int (**print) (const char *, va_list ap));
LIBHARP_API int harp_set_warning_handler(int (*print) (const char *, va_list ap));

/* *CFFI-ON* */

/* Variables */
LIBHARP_API int harp_variable_new(const char *name, harp_data_type data_type, int num_dimensions,
                                  const harp_dimension_type *dimension_type, const long *dimension,
                                  harp_variable **new_variable);
LIBHARP_API void harp_variable_delete(harp_variable *variable);
LIBHARP_API int harp_variable_copy(const harp_variable *variable, harp_variable **new_variable);
LIBHARP_API int harp_variable_copy_attributes(const harp_variable *variable, harp_variable *target_variable);
LIBHARP_API int harp_variable_append(harp_variable *variable, const harp_variable *other_variable);
LIBHARP_API int harp_variable_rename(harp_variable *variable, const char *name);
LIBHARP_API int harp_variable_set_description(harp_variable *variable, const char *description);
LIBHARP_API int harp_variable_set_unit(harp_variable *variable, const char *unit);
LIBHARP_API int harp_variable_set_enumeration_values(harp_variable *variable, int num_enum_values,
                                                     const char **enum_name);
LIBHARP_API int harp_variable_set_string_data_element(harp_variable *variable, long index, const char *str);
LIBHARP_API int harp_variable_convert_data_type(harp_variable *variable, harp_data_type target_data_type);
LIBHARP_API int harp_variable_convert_unit(harp_variable *variable, const char *target_unit);
LIBHARP_API int harp_variable_has_dimension_type(const harp_variable *variable, harp_dimension_type dimension_type);
LIBHARP_API int harp_variable_has_dimension_types(const harp_variable *variable, int num_dimensions,
                                                  const harp_dimension_type *dimension_type);
LIBHARP_API int harp_variable_has_unit(const harp_variable *variable, const char *unit);
LIBHARP_API int harp_variable_verify(const harp_variable *variable);
LIBHARP_API void harp_variable_print(harp_variable *variable, int show_attributes, int (*print) (const char *, ...));
LIBHARP_API void harp_variable_print_data(harp_variable *variable, int (*print) (const char *, ...));

LIBHARP_API int harp_variable_smooth_vertical(harp_variable *variable, harp_variable *vertical_axis,
                                              harp_variable *averaging_kernel, harp_variable *apriori);

/* Product */
LIBHARP_API int harp_product_new(harp_product **new_product);
LIBHARP_API void harp_product_delete(harp_product *product);
LIBHARP_API int harp_product_copy(const harp_product *product, harp_product **new_product);
LIBHARP_API int harp_product_append(harp_product *product, harp_product *other_product);
LIBHARP_API int harp_product_set_source_product(harp_product *product, const char *product_path);
LIBHARP_API int harp_product_set_history(harp_product *product, const char *history);
LIBHARP_API int harp_product_add_variable(harp_product *product, harp_variable *variable);
LIBHARP_API int harp_product_detach_variable(harp_product *product, const harp_variable *variable);
LIBHARP_API int harp_product_remove_variable(harp_product *product, harp_variable *variable);
LIBHARP_API int harp_product_remove_variable_by_name(harp_product *product, const char *name);
LIBHARP_API int harp_product_replace_variable(harp_product *product, harp_variable *variable);
LIBHARP_API int harp_product_is_empty(const harp_product *product);
LIBHARP_API int harp_product_has_variable(const harp_product *product, const char *name);
LIBHARP_API int harp_product_get_variable_by_name(const harp_product *product, const char *name,
                                                  harp_variable **variable);
LIBHARP_API int harp_product_get_variable_index_by_name(const harp_product *product, const char *name, int *index);
LIBHARP_API int harp_product_get_derived_variable(const harp_product *product, const char *name,
                                                  const harp_data_type *data_type, const char *unit, int num_dimensions,
                                                  const harp_dimension_type *dimension_type, harp_variable **variable);
LIBHARP_API int harp_product_add_derived_variable(harp_product *product, const char *name,
                                                  const harp_data_type *data_type, const char *unit, int num_dimensions,
                                                  const harp_dimension_type *dimension_type);
LIBHARP_API int harp_product_update_history(harp_product *product, const char *executable, int argc, char *argv[]);
LIBHARP_API int harp_product_verify(const harp_product *product);
LIBHARP_API int harp_product_execute_operations(harp_product *product, const char *operations);
LIBHARP_API void harp_product_print(const harp_product *product, int show_attributes, int show_data,
                                    int (*print) (const char *, ...));
LIBHARP_API int harp_product_get_metadata(harp_product *product, harp_product_metadata **new_metadata);

LIBHARP_API int harp_product_flatten_dimension(harp_product *product, harp_dimension_type dimension_name);
LIBHARP_API int harp_product_sort(harp_product *product, const char *variable_name);
LIBHARP_API int harp_product_bin(harp_product *product, long num_bins, long num_elements, long *bin_index);
LIBHARP_API int harp_product_bin_spatial(harp_product *product, long num_time_bins, long num_time_elements,
                                         long *time_bin_index, long num_latitude_edges, double *latitude_edges,
                                         long num_longitude_edges, double *longitude_edges);
LIBHARP_API int harp_product_regrid_with_axis_variable(harp_product *product, harp_variable *target_grid,
                                                       harp_variable *target_bounds);
LIBHARP_API int harp_product_regrid_with_collocated_product(harp_product *product, harp_dimension_type dimension_type,
                                                            const char *axis_name, const char *axis_unit,
                                                            const harp_product *collocated_product);
LIBHARP_API int harp_product_regrid_with_collocated_dataset(harp_product *product, harp_dimension_type dimension_type,
                                                            const char *axis_name, const char *axis_unit,
                                                            harp_collocation_result *collocation_result);
LIBHARP_API int harp_product_smooth_vertical_with_collocated_product(harp_product *product, int num_smooth_variables,
                                                                     const char **smooth_variables,
                                                                     const char *vertical_axis,
                                                                     const char *vertical_unit,
                                                                     const harp_product *collocated_product);
LIBHARP_API int harp_product_smooth_vertical_with_collocated_dataset(harp_product *product, int num_smooth_variables,
                                                                     const char **smooth_variables,
                                                                     const char *vertical_axis,
                                                                     const char *vertical_unit,
                                                                     const harp_collocation_result *collocation_result);
LIBHARP_API int harp_product_get_smoothed_column(harp_product *product, const char *name, const char *unit,
                                                 harp_variable *vertical_grid, harp_variable *vertical_bounds,
                                                 harp_variable *column_avk, harp_variable *apriori,
                                                 harp_variable **variable);
LIBHARP_API int harp_product_get_smoothed_column_using_collocated_product(harp_product *product, const char *name,
                                                                          const char *unit, int num_dimensions,
                                                                          const harp_dimension_type *dimension_type,
                                                                          const char *vertical_axis,
                                                                          const char *vertical_unit,
                                                                          const harp_product *collocated_product,
                                                                          harp_variable **variable);
LIBHARP_API int harp_product_get_smoothed_column_using_collocated_dataset(harp_product *product, const char *name,
                                                                          const char *unit, int num_dimensions,
                                                                          const harp_dimension_type *dimension_type,
                                                                          const char *vertical_axis,
                                                                          const char *vertical_unit,
                                                                          const harp_collocation_result
                                                                          *collocation_result,
                                                                          harp_variable **variable);

/* Product Metadata */
LIBHARP_API int harp_import_product_metadata(const char *filenames, const char *options,
                                             harp_product_metadata **metadata);
LIBHARP_API int harp_product_metadata_new(harp_product_metadata **new_metadata);
LIBHARP_API void harp_product_metadata_delete(harp_product_metadata *metadata);
LIBHARP_API void harp_product_metadata_print(harp_product_metadata *metadata, int (*print) (const char *, ...));

/* Dataset */
LIBHARP_API int harp_dataset_import(harp_dataset *dataset, const char *path, const char *options);
LIBHARP_API int harp_dataset_new(harp_dataset **dataset);
LIBHARP_API void harp_dataset_delete(harp_dataset *dataset);
LIBHARP_API void harp_dataset_print(harp_dataset *dataset, int (*print) (const char *, ...));
LIBHARP_API int harp_dataset_get_index_from_source_product(harp_dataset *dataset, const char *source_product,
                                                           long *index);
LIBHARP_API int harp_dataset_has_product(harp_dataset *dataset, const char *source_product);
LIBHARP_API int harp_dataset_add_product(harp_dataset *dataset, const char *source_product,
                                         harp_product_metadata *metadata);

/* Import */
LIBHARP_API int harp_import(const char *filename, const char *operations, const char *options, harp_product **product);
LIBHARP_API int harp_import_test(const char *filename, int (*print) (const char *, ...));

/* Export */
LIBHARP_API int harp_export(const char *filename, const char *format, const harp_product *product);

/* Collocation result functions */
LIBHARP_API int harp_collocation_result_new(harp_collocation_result **new_collocation_result, int num_differences,
                                            const char **difference_variable_name, const char **difference_unit);
LIBHARP_API void harp_collocation_result_delete(harp_collocation_result *collocation_result);
LIBHARP_API int harp_collocation_result_sort_by_a(harp_collocation_result *collocation_result);
LIBHARP_API int harp_collocation_result_sort_by_b(harp_collocation_result *collocation_result);
LIBHARP_API int harp_collocation_result_sort_by_collocation_index(harp_collocation_result *collocation_result);
LIBHARP_API int harp_collocation_result_filter_for_source_product_a(harp_collocation_result *collocation_result,
                                                                    const char *source_product);
LIBHARP_API int harp_collocation_result_filter_for_source_product_b(harp_collocation_result *collocation_result,
                                                                    const char *source_product);
LIBHARP_API int harp_collocation_result_filter_for_collocation_indices(harp_collocation_result *collocation_result,
                                                                       long num_indices, int32_t *collocation_index);
LIBHARP_API int harp_collocation_result_add_pair(harp_collocation_result *collocation_result, long collocation_index,
                                                 const char *source_product_a, long index_a,
                                                 const char *source_product_b, long index_b, int num_differences,
                                                 const double *difference);
LIBHARP_API int harp_collocation_result_remove_pair_at_index(harp_collocation_result *collocation_result, long index);
LIBHARP_API int harp_collocation_result_read(const char *collocation_result_filename,
                                             harp_collocation_result **new_collocation_result);
LIBHARP_API int harp_collocation_result_write(const char *collocation_result_filename,
                                              harp_collocation_result *collocation_result);
LIBHARP_API void harp_collocation_result_swap_datasets(harp_collocation_result *collocation_result);

/* *CFFI-OFF* */

/* *INDENT-OFF* */
#ifdef __cplusplus
}
#endif
/* *INDENT-ON* */

#endif