Merge ../libgpiv-omp into fft-omp
[libgpiv.git] / lib / postpar.c
blob715ac9f397bb419a6938b73943d96373b8c7b56f
1 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 c-style: "K&R" -*- */
3 /*
4 libgpiv - library for Particle Image Velocimetry
6 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
7 Gerber van der Graaf
9 This file is part of libgpiv.
10 Libgpiv is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
13 any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software Foundation,
22 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 -----------------------------------------------------------------------
27 FILENAME: postpar.c
28 LIBRARY: libgpiv
31 EXTERNAL FUNCTIONS:
32 gpiv_post_read_parameters
33 gpiv_post_default_parameters
34 gpiv_post_get_parameters_from_resources
36 gpiv_post_parameters_set
37 gpiv_post_check_parameters_read
38 gpiv_post_fprint_parameters
39 gpiv_post_fread_hdf_parameters
40 gpiv_post_fwrite_hdf_parameters
42 LAST MODIFICATION DATE: $Id: post_par.c,v 1.8 2008-05-05 14:38:42 gerber Exp $
43 ------------------------------------------------------------------- */
45 #include <gpiv.h>
49 * Default values and keys of GpivPostPar
51 const gfloat POSTPAR_DEFAULT__SET_DX = 0.0; /**< Default parameter for set_dx of __GpivPostPar */
52 const gfloat POSTPAR_DEFAULT__SET_DY = 0.0; /**< Default parameter for set_dx of __GpivPostPar */
53 const gfloat POSTPAR_DEFAULT__Z_OFF_DX = 0.0; /**< Default parameter for z_off_dx of __GpivPostPar */
54 const gfloat POSTPAR_DEFAULT__Z_OFF_DY = 0.0; /**< Default parameter for z_off_dy of __GpivPostPar */
56 enum {
57 POSTPAR_DEFAULT__OPERATOR_MANIPIV = 0, /**< Default parameter for operator_manipiv of __GpivPostPar */
58 POSTPAR_DEFAULT__SET = 1, /**< Default parameter for set of __GpivPostPar */
59 POSTPAR_DEFAULT__SUBTRACT = 0, /**< Default parameter for subtract of __GpivPostPar */
60 POSTPAR_DEFAULT__DIFF_TYPE = 2, /**< Default parameter for diff_type of __GpivPostPar */
61 POSTPAR_DEFAULT__OPERATOR_VORSTRA = 0, /**< Default parameter for operator_vorstra of __GpivPostPar */
62 POSTPAR_DEFAULT__SCALE_TYPE = 0 /**< Default parameter for scale_type of __GpivPostPar */
66 const gchar *POSTPAR_KEY__OPERATOR_MANIPIV = "Operator_manipiv"; /**< Key for operator_manipiv of __GpivPostPar */
67 const gchar *POSTPAR_KEY__SET = "Set"; /**< Key for set of __GpivPostPar */
68 const gchar *POSTPAR_KEY__SET_DX = "Set_dx"; /**< Key for set_dx of __GpivPostPar */
69 const gchar *POSTPAR_KEY__SET_DY = "Set_dy"; /**< Key for set_dx of __GpivPostPar */
70 const gchar *POSTPAR_KEY__SUBTRACT = "Subtract"; /**< Key for subtract of __GpivPostPar */
71 const gchar *POSTPAR_KEY__Z_OFF_DX = "Zoff_dx"; /**< Key for z_off_dx of __GpivPostPar */
72 const gchar *POSTPAR_KEY__Z_OFF_DY = "Zoff_dy"; /**< Key for z_off_dy of __GpivPostPar */
73 const gchar *POSTPAR_KEY__DIFF_TYPE = "Differential_type"; /**< Key for diff_type of __GpivPostPar */
74 const gchar *POSTPAR_KEY__OPERATOR_VORSTRA = "Operator_vorstra"; /**< Key for operator_vorstra of __GpivPostPar */
75 const gchar *POSTPAR_KEY__SCALE_TYPE = "Scale_type"; /**< Key for scale_type of __GpivPostPar */
78 /*
79 * Prototypes local functions
82 static void
83 obtain_postpar_fromline (gchar line[],
84 GpivPostPar *post_par,
85 const gboolean verbose
88 static herr_t
89 attr_info (hid_t loc_id,
90 const gchar *name,
91 GpivPostPar *post_par
95 * Public functions
98 void
99 gpiv_post_parameters_set (GpivPostPar *post_par,
100 const gboolean flag
102 /*-----------------------------------------------------------------------------
103 * Set flag for post_par __set */
105 post_par->operator_manipiv__set = flag;
106 post_par->set__set = flag;
107 post_par->set_dx__set = flag;
108 post_par->set_dy__set = flag;
109 post_par->subtract__set = flag;
110 post_par->z_off_dx__set = flag;
111 post_par->z_off_dy__set = flag;
112 post_par->diff_type__set = flag;
113 post_par->operator_vorstra__set = flag;
114 post_par->scale_type__set = flag;
119 void
120 gpiv_post_default_parameters (GpivPostPar *post_par_default,
121 const gboolean force
123 /*-----------------------------------------------------------------------------
124 * Default parameter values
127 if (!post_par_default->operator_manipiv__set || force)
128 post_par_default->operator_manipiv =
129 POSTPAR_DEFAULT__OPERATOR_MANIPIV;
130 if (!post_par_default->set__set || force)
131 post_par_default->set = POSTPAR_DEFAULT__SET;
132 if (!post_par_default->set_dx__set || force)
133 post_par_default->set_dx = POSTPAR_DEFAULT__SET_DX;
134 if (!post_par_default->set_dy__set || force)
135 post_par_default->set_dy = POSTPAR_DEFAULT__SET_DY;
136 if (!post_par_default->subtract__set || force)
137 post_par_default->subtract = POSTPAR_DEFAULT__SUBTRACT;
138 if (!post_par_default->z_off_dx__set || force)
139 post_par_default->z_off_dx = POSTPAR_DEFAULT__Z_OFF_DX;
140 if (!post_par_default->z_off_dy__set || force)
141 post_par_default->z_off_dy = POSTPAR_DEFAULT__Z_OFF_DY;
142 if (!post_par_default->diff_type__set || force)
143 post_par_default->diff_type = POSTPAR_DEFAULT__DIFF_TYPE;
144 if (!post_par_default->operator_vorstra__set || force)
145 post_par_default->operator_vorstra =
146 POSTPAR_DEFAULT__OPERATOR_VORSTRA;
147 if (!post_par_default->scale_type__set || force)
148 post_par_default->scale_type = POSTPAR_DEFAULT__SCALE_TYPE;
150 gpiv_post_parameters_set(post_par_default, TRUE);
155 GpivPostPar *
156 gpiv_post_get_parameters_from_resources (const gchar *localrc,
157 const gboolean verbose
159 /*-----------------------------------------------------------------------------
160 * DESCRIPTION:
161 * Reads pos-processing parameters from system-wide gpiv.conf and $HOME/.gpivrc
162 *---------------------------------------------------------------------------*/
164 GpivPostPar *post_par = g_new0 (GpivPostPar, 1);
167 gpiv_post_parameters_set (post_par, FALSE);
168 gpiv_scan_parameter (GPIV_POSTPAR_KEY, localrc, post_par, verbose);
169 gpiv_scan_resourcefiles (GPIV_POSTPAR_KEY, post_par, verbose);
172 return post_par;
177 void
178 gpiv_post_read_parameters (FILE *fp,
179 GpivPostPar *post_par,
180 const gboolean verbose
182 /*-----------------------------------------------------------------------------
183 * DESCRIPTION:
184 * Read all parameters for PIV post processing
185 * if not defined by command line keys
187 * PROTOTYPE LOCATATION:
188 * post.h
190 * INPUTS:
192 * OUTPUTS:
194 * RETURNS:
195 *---------------------------------------------------------------------------*/
197 gchar line[GPIV_MAX_CHARS], par_name[GPIV_MAX_CHARS];
200 if (fp == stdin || fp == NULL) {
201 while (gets (line) != NULL) {
202 obtain_postpar_fromline (line, post_par, verbose);
204 } else {
205 while (fgets(line, GPIV_MAX_CHARS, fp) != NULL) {
206 obtain_postpar_fromline (line, post_par, verbose);
211 return;
216 gchar *
217 gpiv_post_check_parameters_read (GpivPostPar *post_par,
218 const GpivPostPar *post_par_default
220 /*-----------------------------------------------------------------------------
221 * DESCRIPTION:
222 * Check out if all parameters have been read
223 * Returns: NULL on success or *err_msg on failure
225 * PROTOTYPE LOCATATION:
226 * post.h
228 * INPUTS:
230 * OUTPUTS:
232 * RETURNS:
233 *---------------------------------------------------------------------------*/
235 gchar * err_msg = NULL;
239 * Parameters for manipiv
241 if (post_par->operator_manipiv__set == FALSE) {
242 post_par->operator_manipiv__set = TRUE;
243 if (post_par_default == NULL) {
244 err_msg = "Using default from libgpiv: ";
245 post_par->operator_manipiv = POSTPAR_DEFAULT__OPERATOR_MANIPIV;
246 } else {
247 err_msg = "Using default: ";
248 post_par->operator_manipiv = post_par_default->operator_manipiv;
250 gpiv_warning("%s\n%s.%s %d",
251 err_msg,
252 GPIV_POSTPAR_KEY,
253 POSTPAR_KEY__OPERATOR_MANIPIV,
254 post_par->operator_manipiv);
258 if (post_par->set__set == FALSE) {
259 post_par->set__set = TRUE;
260 if (post_par_default == NULL) {
261 err_msg = "Using default from libgpiv: ";
262 post_par->set = POSTPAR_DEFAULT__SET;
263 } else {
264 err_msg = "Using default: ";
265 post_par->set = post_par_default->set;
267 gpiv_warning("%s\n%s.%s %d",
268 err_msg,
269 GPIV_POSTPAR_KEY,
270 POSTPAR_KEY__SET,
271 post_par->set);
275 if (post_par->set_dx__set == FALSE) {
276 post_par->set_dx__set = TRUE;
277 if (post_par_default == NULL) {
278 err_msg = "Using default from libgpiv: ";
279 post_par->set_dx = POSTPAR_DEFAULT__SET_DX;
280 } else {
281 err_msg = "Using default: ";
282 post_par->set_dx = post_par_default->set_dx;
284 gpiv_warning("%s\n%s.%s %f",
285 err_msg,
286 GPIV_POSTPAR_KEY,
287 POSTPAR_KEY__SET_DX,
288 post_par->set_dx);
292 if (post_par->set_dy__set == FALSE) {
293 post_par->set_dy__set = TRUE;
294 if (post_par_default == NULL) {
295 err_msg = "Using default from libgpiv: ";
296 post_par->set_dy = POSTPAR_DEFAULT__SET_DY;
297 } else {
298 err_msg = "Using default: ";
299 post_par->set_dy = post_par_default->set_dy;
301 gpiv_warning("%s\n%s.%s %f",
302 err_msg,
303 GPIV_POSTPAR_KEY,
304 POSTPAR_KEY__SET_DY,
305 post_par->set_dy);
310 * Parameters of s-avg
312 if (post_par->subtract__set == FALSE) {
313 post_par->subtract__set = TRUE;
314 if (post_par_default == NULL) {
315 err_msg = "Using default from libgpiv: ";
316 post_par->subtract = POSTPAR_DEFAULT__SUBTRACT;
317 } else {
318 err_msg = "Using default: ";
319 post_par->subtract = post_par_default->subtract;
321 gpiv_warning("%s\n%s.%s %d",
322 err_msg,
323 GPIV_POSTPAR_KEY,
324 POSTPAR_KEY__SUBTRACT,
325 post_par->subtract);
328 if (post_par->z_off_dx__set == FALSE) {
329 post_par->z_off_dx__set = TRUE;
330 if (post_par_default == NULL) {
331 err_msg = "Using default from libgpiv: ";
332 post_par->z_off_dx = POSTPAR_DEFAULT__Z_OFF_DX;
333 } else {
334 err_msg = "Using default: ";
335 post_par->z_off_dx = post_par_default->z_off_dx;
337 gpiv_warning("%s\n%s.%s %f",
338 err_msg,
339 GPIV_POSTPAR_KEY,
340 POSTPAR_KEY__Z_OFF_DX,
341 post_par->z_off_dx);
344 if (post_par->z_off_dy__set == FALSE) {
345 post_par->z_off_dy__set = TRUE;
346 if (post_par_default == NULL) {
347 err_msg = "Using default from libgpiv: ";
348 post_par->z_off_dy = POSTPAR_DEFAULT__Z_OFF_DY;
349 } else {
350 err_msg = "Using default: ";
351 post_par->z_off_dy = post_par_default->z_off_dy;
353 gpiv_warning("%s\n%s.%s %f",
354 err_msg,
355 GPIV_POSTPAR_KEY,
356 POSTPAR_KEY__Z_OFF_DY,
357 post_par->z_off_dy);
362 * Parameters for vorstra
364 if (post_par->diff_type__set == FALSE) {
365 post_par->diff_type__set = TRUE;
366 if (post_par_default == NULL) {
367 err_msg = "Using default from libgpiv: ";
368 post_par->diff_type = POSTPAR_DEFAULT__DIFF_TYPE;
369 } else {
370 err_msg = "Using default: ";
371 post_par->diff_type = post_par_default->diff_type;
373 gpiv_warning("%s\n%s.%s %d",
374 err_msg,
375 GPIV_POSTPAR_KEY,
376 POSTPAR_KEY__DIFF_TYPE,
377 post_par->diff_type);
380 if (post_par->operator_vorstra__set == FALSE) {
381 post_par->operator_vorstra__set = TRUE;
382 if (post_par_default == NULL) {
383 err_msg = "Using default from libgpiv: ";
384 post_par->operator_vorstra =
385 POSTPAR_DEFAULT__OPERATOR_VORSTRA;
386 } else {
387 err_msg = "Using default: ";
388 post_par->operator_vorstra = post_par_default->operator_vorstra;
390 gpiv_warning("%s\n%s.%s %d",
391 err_msg,
392 GPIV_POSTPAR_KEY,
393 POSTPAR_KEY__OPERATOR_VORSTRA,
394 post_par->operator_vorstra);
398 * Parameters for scale
400 if (post_par->scale_type__set == FALSE) {
401 post_par->scale_type__set = TRUE;
402 if (post_par_default == NULL) {
403 err_msg = "Using default from libgpiv: ";
404 post_par->scale_type = POSTPAR_DEFAULT__SCALE_TYPE;
405 } else {
406 err_msg = "Using default: ";
407 post_par->scale_type = post_par_default->scale_type;
409 gpiv_warning("%s\n%s.%s %d",
410 err_msg,
411 GPIV_POSTPAR_KEY,
412 POSTPAR_KEY__SCALE_TYPE,
413 post_par->scale_type);
417 return err_msg;
422 void
423 gpiv_post_print_parameters (FILE *fp,
424 const GpivPostPar *post_par
426 /*-----------------------------------------------------------------------------
427 * DESCRIPTION:
428 * Prints parameters to fp
430 * PROTOTYPE LOCATATION:
431 * post.h
433 * INPUTS:
435 * OUTPUTS:
437 * RETURNS:
438 *---------------------------------------------------------------------------*/
440 if (fp == stdout || fp == NULL) fp = stdout;
442 * Parameters for manipiv
444 if (post_par->operator_manipiv__set)
445 fprintf(fp,"%s.%s %d\n",
446 GPIV_POSTPAR_KEY,
447 POSTPAR_KEY__OPERATOR_MANIPIV,
448 post_par->operator_manipiv);
450 if (post_par->set__set)
451 fprintf(fp,"%s.%s %d\n",
452 GPIV_POSTPAR_KEY,
453 POSTPAR_KEY__SET,
454 post_par->set);
456 if (post_par->set_dx__set)
457 fprintf(fp,"%s.%s %f\n",
458 GPIV_POSTPAR_KEY,
459 POSTPAR_KEY__SET_DX,
460 post_par->set_dx);
462 if (post_par->set_dy__set)
463 fprintf(fp,"%s.%s %f\n",
464 GPIV_POSTPAR_KEY,
465 POSTPAR_KEY__SET_DY,
466 post_par->set_dy);
469 * Parameters of s-avg
471 if (post_par->subtract__set)
472 fprintf(fp,"%s.%s %d\n",
473 GPIV_POSTPAR_KEY,
474 POSTPAR_KEY__SUBTRACT,
475 post_par->subtract);
477 if (post_par->z_off_dx__set)
478 fprintf(fp,"%s.%s %f\n",
479 GPIV_POSTPAR_KEY,
480 POSTPAR_KEY__Z_OFF_DX,
481 post_par->z_off_dx);
483 if (post_par->z_off_dy__set)
484 fprintf(fp,"%s.%s %f\n",
485 GPIV_POSTPAR_KEY,
486 POSTPAR_KEY__Z_OFF_DY,
487 post_par->z_off_dy);
490 * Parameters for vorstra
492 if (post_par->operator_vorstra__set)
493 fprintf(fp, "%s.%s %d\n",
494 GPIV_POSTPAR_KEY,
495 POSTPAR_KEY__OPERATOR_VORSTRA,
496 post_par->operator_vorstra);
498 if (post_par->diff_type__set)
499 fprintf(fp, "%s.%s %d\n",
500 GPIV_POSTPAR_KEY,
501 POSTPAR_KEY__DIFF_TYPE,
502 post_par->diff_type);
505 * Parameter for scale
507 if (post_par->scale_type__set)
508 fprintf(fp, "%s.%s %d\n",
509 GPIV_POSTPAR_KEY,
510 POSTPAR_KEY__SCALE_TYPE,
511 post_par->scale_type);
514 fprintf(fp, "\n");
520 GpivPostPar *
521 gpiv_post_fread_hdf5_parameters (const gchar *fname
523 /* ---------------------------------------------------------------------------
524 * DESCRIPTION:
525 * Reads post parameters from hdf5 data file
527 * PROTOTYPE LOCATATION:
528 * post.h
530 * INPUTS:
531 * group_id: hdf group identity
533 * OUTPUTS:
534 * piv_post_par: parameter structure
536 * RETURNS:
537 * NULL on success or *err_msg on failure
538 *-------------------------------------------------------------------------- */
540 GpivPostPar *post_par = g_new0 (GpivPostPar, 1);
541 gchar *err_msg = NULL;
542 int i;
544 * HDF declarations
546 hid_t file_id, group_id, attribute_id;
547 herr_t status;
550 if ((i = H5Fis_hdf5(fname)) == 0) {
551 err_msg = "gpiv_post_fread_hdf5_parameters: not an hdf5 file";
552 gpiv_warning("%s", err_msg);
553 return NULL;
555 file_id = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT);
557 group_id = H5Gopen (file_id, "PIV", H5P_DEFAULT);
558 /* H5Aiterate (group_id, NULL, (H5A_operator_t)attr_info, post_par); */
559 H5Aiterate (group_id, H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, 0,
560 (H5A_operator_t)attr_info, post_par);
561 status = H5Gclose (group_id);
563 group_id = H5Gopen (file_id, "SCALARS", H5P_DEFAULT);
564 /* H5Aiterate(group_id, NULL, (H5A_operator_t)attr_info, post_par); */
565 H5Aiterate (group_id, H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, 0,
566 (H5A_operator_t)attr_info, post_par);
567 status = H5Gclose (group_id);
569 status = H5Fclose(file_id);
572 return post_par;
577 gchar *
578 gpiv_post_fwrite_hdf5_parameters (const gchar *fname,
579 const GpivPostPar *post_par
581 /*----------------------------------------------------------------------------
582 * DESCRIPTION:
583 * Writes post parameters to an existing hdf5 data file
585 * PROTOTYPE LOCATATION:
586 * post.h
588 * INPUTS:
589 * group_id: hdf group identity
590 * post_par: parameter structure
592 * OUTPUTS:
594 * RETURNS:
595 * NULL on success or *err_msg on failure
596 *-------------------------------------------------------------------------- */
598 gchar *err_msg = NULL;
599 int i;
601 * HDF declarations
603 hid_t file_id, dataspace_id, group_id, attribute_id;
604 hsize_t dims[1];
605 herr_t status;
607 if ((i = H5Fis_hdf5(fname)) == 0) {
608 err_msg = "gpiv_post_fwrite_hdf5_parameters: not an hdf5 file";
609 gpiv_warning("%s", err_msg);
610 return err_msg;
612 file_id = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT);
613 group_id = H5Gopen (file_id, "PIV", H5P_DEFAULT);
617 dims[0] = 1;
618 dataspace_id = H5Screate_simple(1, dims, NULL);
621 * Parameters of manipiv
623 if (post_par->operator_manipiv__set) {
624 attribute_id = H5Acreate(group_id,
625 POSTPAR_KEY__OPERATOR_MANIPIV,
626 H5T_NATIVE_INT,
627 dataspace_id, H5P_DEFAULT, H5P_DEFAULT);
628 status = H5Awrite(attribute_id, H5T_NATIVE_INT,
629 &post_par->operator_manipiv);
630 status = H5Aclose(attribute_id);
634 * parameters of s-avg
636 if (post_par->subtract__set) {
637 attribute_id = H5Acreate(group_id,
638 POSTPAR_KEY__SUBTRACT,
639 H5T_NATIVE_INT,
640 dataspace_id, H5P_DEFAULT, H5P_DEFAULT);
641 status = H5Awrite(attribute_id, H5T_NATIVE_INT,
642 &post_par->subtract);
643 status = H5Aclose(attribute_id);
647 if (post_par->z_off_dx__set) {
648 attribute_id = H5Acreate(group_id,
649 POSTPAR_KEY__Z_OFF_DX,
650 H5T_NATIVE_FLOAT,
651 dataspace_id, H5P_DEFAULT, H5P_DEFAULT);
652 status = H5Awrite(attribute_id, H5T_NATIVE_FLOAT,
653 &post_par->z_off_dx);
654 status = H5Aclose(attribute_id);
657 if (post_par->z_off_dy__set) {
658 attribute_id = H5Acreate(group_id,
659 POSTPAR_KEY__Z_OFF_DY,
660 H5T_NATIVE_FLOAT,
661 dataspace_id, H5P_DEFAULT, H5P_DEFAULT);
662 status = H5Awrite(attribute_id, H5T_NATIVE_FLOAT,
663 &post_par->z_off_dy);
664 status = H5Aclose(attribute_id);
667 status = H5Gclose (group_id);
670 * Parameters of vorstra
672 group_id = H5Gopen (file_id, "SCALARS", H5P_DEFAULT);
674 if (post_par->diff_type__set) {
675 attribute_id = H5Acreate(group_id,
676 POSTPAR_KEY__DIFF_TYPE,
677 H5T_NATIVE_INT,
678 dataspace_id, H5P_DEFAULT, H5P_DEFAULT);
679 status = H5Awrite(attribute_id, H5T_NATIVE_INT,
680 &post_par->diff_type);
681 status = H5Aclose(attribute_id);
684 if (post_par->operator_vorstra__set) {
685 attribute_id = H5Acreate(group_id,
686 POSTPAR_KEY__OPERATOR_VORSTRA,
687 H5T_NATIVE_INT,
688 dataspace_id, H5P_DEFAULT, H5P_DEFAULT);
689 status = H5Awrite(attribute_id, H5T_NATIVE_INT,
690 &post_par->operator_vorstra);
691 status = H5Aclose(attribute_id);
696 * Parameters of scale
698 if (post_par->scale_type__set) {
699 attribute_id = H5Acreate(group_id,
700 POSTPAR_KEY__SCALE_TYPE,
701 H5T_NATIVE_INT,
702 dataspace_id, H5P_DEFAULT, H5P_DEFAULT);
703 status = H5Awrite(attribute_id, H5T_NATIVE_INT,
704 &post_par->scale_type);
705 status = H5Aclose(attribute_id);
708 status = H5Sclose(dataspace_id);
709 status = H5Gclose (group_id);
710 status = H5Fclose(file_id);
711 return err_msg;
716 * Local functions
719 static void
720 obtain_postpar_fromline (gchar line[],
721 GpivPostPar *post_par,
722 const gboolean verbose
724 /*-----------------------------------------------------------------------------
725 * Scans a line to get a member of GpivPostPar
728 char par_name[GPIV_MAX_CHARS];
731 if (line[0] != '#' && line[0] != '\n' && line[0] != ' '
732 && line[0] != '\t') {
733 sscanf(line,"%s",par_name);
736 * Parameters for manipulating PIV data
738 if (post_par->operator_manipiv__set == FALSE) {
739 post_par->operator_manipiv__set =
740 gpiv_scan_iph (GPIV_POSTPAR_KEY,
741 POSTPAR_KEY__OPERATOR_MANIPIV, TRUE,
742 line, par_name, (int *) &post_par->operator_manipiv,
743 verbose, NULL);
746 if (post_par->set__set == FALSE) {
747 post_par->set__set =
748 gpiv_scan_iph (GPIV_POSTPAR_KEY,
749 POSTPAR_KEY__SET, TRUE,
750 line, par_name, &post_par->set,
751 verbose, NULL);
754 if (post_par->set_dx__set == FALSE) {
755 post_par->set_dx__set =
756 gpiv_scan_fph (GPIV_POSTPAR_KEY,
757 POSTPAR_KEY__SET_DX, TRUE,
758 line, par_name, &post_par->set_dx,
759 verbose, NULL);
762 if (post_par->set_dy__set == FALSE) {
763 post_par->set_dy__set =
764 gpiv_scan_fph (GPIV_POSTPAR_KEY,
765 POSTPAR_KEY__SET_DY, TRUE,
766 line, par_name, &post_par->set_dy,
767 verbose, NULL);
771 * Parameters for s-avg
773 if (post_par->subtract__set == FALSE) {
774 post_par->subtract__set =
775 gpiv_scan_iph (GPIV_POSTPAR_KEY,
776 POSTPAR_KEY__SUBTRACT, TRUE,
777 line,par_name, &post_par->subtract,
778 verbose, NULL);
781 if (post_par->z_off_dx__set == FALSE) {
782 post_par->z_off_dx__set =
783 gpiv_scan_fph (GPIV_POSTPAR_KEY,
784 POSTPAR_KEY__Z_OFF_DX, TRUE,
785 line, par_name, &post_par->z_off_dx,
786 verbose, NULL);
789 if (post_par->z_off_dy__set == FALSE) {
790 post_par->z_off_dy__set =
791 gpiv_scan_fph (GPIV_POSTPAR_KEY,
792 POSTPAR_KEY__Z_OFF_DY, TRUE,
793 line, par_name, &post_par->z_off_dy,
794 verbose, NULL);
798 * Parameters for vorticity and strain
800 if (post_par->diff_type__set == FALSE) {
801 post_par->diff_type__set =
802 gpiv_scan_iph (GPIV_POSTPAR_KEY,
803 POSTPAR_KEY__DIFF_TYPE, TRUE,
804 line, par_name, (int *) &post_par->diff_type,
805 verbose, NULL);
808 if (post_par->operator_vorstra__set == FALSE) {
809 post_par->operator_vorstra__set =
810 gpiv_scan_iph (GPIV_POSTPAR_KEY,
811 POSTPAR_KEY__OPERATOR_VORSTRA, TRUE,
812 line, par_name, (int *) &post_par->operator_vorstra,
813 verbose, NULL);
817 * Parameters for scaling PIV data.
819 if (post_par->scale_type__set == FALSE) {
820 post_par->scale_type__set =
821 gpiv_scan_iph (GPIV_POSTPAR_KEY,
822 POSTPAR_KEY__SCALE_TYPE, TRUE,
823 line, par_name, (int *) &post_par->scale_type,
824 verbose, NULL);
830 return;
835 static herr_t
836 attr_info (hid_t loc_id,
837 const gchar *name,
838 GpivPostPar *post_par
840 /*-----------------------------------------------------------------------------
841 * DESCRIPTION:
842 * Operator function.
844 * PROTOTYPE LOCATATION:
845 * post.h
847 * INPUTS:
849 * OUTPUTS:
851 * RETURNS:
852 *---------------------------------------------------------------------------*/
854 hid_t attribute_id, atype;
855 herr_t status;
860 * Parameters of manipiv
862 if (strcmp(name, POSTPAR_KEY__OPERATOR_MANIPIV) == 0) {
863 attribute_id = H5Aopen_name(loc_id, name);
864 status = H5Aread(attribute_id, H5T_NATIVE_INT,
865 &post_par->operator_manipiv);
866 status = H5Aclose(attribute_id);
867 post_par->operator_manipiv__set = TRUE;
872 * Global variables and parameters of s-avg
874 if (strcmp(name, POSTPAR_KEY__SUBTRACT) == 0) {
875 attribute_id = H5Aopen_name(loc_id, name);
876 status = H5Aread(attribute_id, H5T_NATIVE_INT,
877 &post_par->subtract);
878 status = H5Aclose(attribute_id);
879 post_par->subtract__set = TRUE;
882 if (strcmp(name, POSTPAR_KEY__Z_OFF_DX) == 0) {
883 attribute_id = H5Aopen_name(loc_id, name);
884 status = H5Aread(attribute_id, H5T_NATIVE_FLOAT,
885 &post_par->z_off_dx);
886 status = H5Aclose(attribute_id);
887 post_par->z_off_dx__set = TRUE;
891 if (strcmp(name, POSTPAR_KEY__Z_OFF_DY) == 0) {
892 attribute_id = H5Aopen_name(loc_id, name);
893 status = H5Aread(attribute_id, H5T_NATIVE_FLOAT,
894 &post_par->z_off_dy);
895 status = H5Aclose(attribute_id);
896 post_par->z_off_dy__set = TRUE;
901 * Parameters of vorstra
903 if (strcmp(name, POSTPAR_KEY__DIFF_TYPE) == 0) {
904 attribute_id = H5Aopen_name(loc_id, name);
905 status = H5Aread(attribute_id, H5T_NATIVE_INT,
906 &post_par->diff_type);
907 status = H5Aclose(attribute_id);
908 post_par->diff_type__set = TRUE;
912 if (strcmp(name, POSTPAR_KEY__OPERATOR_VORSTRA) == 0) {
913 attribute_id = H5Aopen_name(loc_id, name);
914 status = H5Aread(attribute_id, H5T_NATIVE_INT,
915 &post_par->operator_vorstra);
916 status = H5Aclose(attribute_id);
917 post_par->operator_vorstra__set = TRUE;
921 * Parameters of scale
923 if (strcmp(name, POSTPAR_KEY__SCALE_TYPE) == 0) {
924 attribute_id = H5Aopen_name(loc_id, name);
925 status = H5Aread(attribute_id, H5T_NATIVE_INT,
926 &post_par->scale_type);
927 status = H5Aclose(attribute_id);
928 post_par->scale_type__set = TRUE;
931 return 0;