11from types
import coroutine
12from dataclasses
import dataclass, field
14from libc.stdlib cimport malloc, free
16cdef
import from "<mpi.h>" nogil:
17 ctypedef struct _mpi_comm_t
18 ctypedef _mpi_comm_t* MPI_Comm
19 int MPI_Comm_c2f(MPI_Comm)
20 MPI_Comm MPI_Comm_f2c(int)
21 MPI_Comm MPI_COMM_WORLD
23cdef extern
from "Python.h":
24 int Py_AtExit(void (*)())
26cdef extern
from "yac.h":
28 ctypedef long long yac_int
30 cdef const int _LOCATION_CELL
"YAC_LOCATION_CELL"
31 cdef const int _LOCATION_CORNER
"YAC_LOCATION_CORNER"
32 cdef const int _LOCATION_EDGE
"YAC_LOCATION_EDGE"
34 cdef const int _EXCHANGE_TYPE_NONE
"YAC_EXCHANGE_TYPE_NONE"
35 cdef const int _EXCHANGE_TYPE_SOURCE
"YAC_EXCHANGE_TYPE_SOURCE"
36 cdef const int _EXCHANGE_TYPE_TARGET
"YAC_EXCHANGE_TYPE_TARGET"
38 cdef const int _ACTION_NONE
"YAC_ACTION_NONE"
39 cdef const int _ACTION_REDUCTION
"YAC_ACTION_REDUCTION"
40 cdef const int _ACTION_COUPLING
"YAC_ACTION_COUPLING"
41 cdef const int _ACTION_GET_FOR_RESTART
"YAC_ACTION_GET_FOR_RESTART"
42 cdef const int _ACTION_PUT_FOR_RESTART
"YAC_ACTION_PUT_FOR_RESTART"
43 cdef const int _ACTION_OUT_OF_BOUND
"YAC_ACTION_OUT_OF_BOUND"
45 cdef const int _REDUCTION_TIME_NONE
"YAC_REDUCTION_TIME_NONE"
46 cdef const int _REDUCTION_TIME_ACCUMULATE
"YAC_REDUCTION_TIME_ACCUMULATE"
47 cdef const int _REDUCTION_TIME_AVERAGE
"YAC_REDUCTION_TIME_AVERAGE"
48 cdef const int _REDUCTION_TIME_MINIMUM
"YAC_REDUCTION_TIME_MINIMUM"
49 cdef const int _REDUCTION_TIME_MAXIMUM
"YAC_REDUCTION_TIME_MAXIMUM"
51 cdef const int _CALENDAR_NOT_SET
"YAC_CALENDAR_NOT_SET"
52 cdef const int _PROLEPTIC_GREGORIAN
"YAC_PROLEPTIC_GREGORIAN"
53 cdef const int _YEAR_OF_365_DAYS
"YAC_YEAR_OF_365_DAYS"
54 cdef const int _YEAR_OF_360_DAYS
"YAC_YEAR_OF_360_DAYS"
56 cdef const int _TIME_UNIT_MILLISECOND
"YAC_TIME_UNIT_MILLISECOND"
57 cdef const int _TIME_UNIT_SECOND
"YAC_TIME_UNIT_SECOND"
58 cdef const int _TIME_UNIT_MINUTE
"YAC_TIME_UNIT_MINUTE"
59 cdef const int _TIME_UNIT_HOUR
"YAC_TIME_UNIT_HOUR"
60 cdef const int _TIME_UNIT_DAY
"YAC_TIME_UNIT_DAY"
61 cdef const int _TIME_UNIT_MONTH
"YAC_TIME_UNIT_MONTH"
62 cdef const int _TIME_UNIT_YEAR
"YAC_TIME_UNIT_YEAR"
63 cdef const int _TIME_UNIT_ISO_FORMAT
"YAC_TIME_UNIT_ISO_FORMAT"
65 cdef const int _AVG_ARITHMETIC
"YAC_AVG_ARITHMETIC"
66 cdef const int _AVG_DIST
"YAC_AVG_DIST"
67 cdef const int _AVG_BARY
"YAC_AVG_BARY"
69 cdef const int _NCC_AVG
"YAC_NCC_AVG"
70 cdef const int _NCC_DIST
"YAC_NCC_DIST"
72 cdef const int _NNN_AVG
"YAC_NNN_AVG"
73 cdef const int _NNN_DIST
"YAC_NNN_DIST"
74 cdef const int _NNN_GAUSS
"YAC_NNN_GAUSS"
75 cdef const int _NNN_RBF
"YAC_NNN_RBF"
77 cdef const int _DNN_AVG
"YAC_DNN_AVG"
78 cdef const int _DNN_DIST
"YAC_DNN_DIST"
79 cdef const int _DNN_GAUSS
"YAC_DNN_GAUSS"
80 cdef const int _DNN_RBF
"YAC_DNN_RBF"
82 cdef const int _DNN_SEARCH_DISTANCE_FIXED
"YAC_DNN_SEARCH_DISTANCE_FIXED"
83 cdef const int _DNN_SEARCH_DISTANCE_CELL_AREA
"YAC_DNN_SEARCH_DISTANCE_CELL_AREA"
85 cdef const int _CONSERV_DESTAREA
"YAC_CONSERV_DESTAREA"
86 cdef const int _CONSERV_FRACAREA
"YAC_CONSERV_FRACAREA"
88 cdef const int _SPMAP_AVG
"YAC_SPMAP_AVG"
89 cdef const int _SPMAP_DIST
"YAC_SPMAP_DIST"
91 cdef const int _SPMAP_NONE
"YAC_SPMAP_NONE"
92 cdef const int _SPMAP_SRCAREA
"YAC_SPMAP_SRCAREA"
93 cdef const int _SPMAP_INVTGTAREA
"YAC_SPMAP_INVTGTAREA"
94 cdef const int _SPMAP_FRACAREA
"YAC_SPMAP_FRACAREA"
96 cdef const int _FILE_MISSING_ERROR
"YAC_FILE_MISSING_ERROR"
97 cdef const int _FILE_MISSING_CONT
"YAC_FILE_MISSING_CONT"
99 cdef const int _FILE_SUCCESS_STOP
"YAC_FILE_SUCCESS_STOP"
100 cdef const int _FILE_SUCCESS_CONT
"YAC_FILE_SUCCESS_CONT"
102 cdef const int _CONFIG_OUTPUT_FORMAT_YAML
"YAC_CONFIG_OUTPUT_FORMAT_YAML"
103 cdef const int _CONFIG_OUTPUT_FORMAT_JSON
"YAC_CONFIG_OUTPUT_FORMAT_JSON"
105 cdef const int _CONFIG_OUTPUT_SYNC_LOC_DEF_COMP
"YAC_CONFIG_OUTPUT_SYNC_LOC_DEF_COMP"
106 cdef const int _CONFIG_OUTPUT_SYNC_LOC_SYNC_DEF
"YAC_CONFIG_OUTPUT_SYNC_LOC_SYNC_DEF"
107 cdef const int _CONFIG_OUTPUT_SYNC_LOC_ENDDEF
"YAC_CONFIG_OUTPUT_SYNC_LOC_ENDDEF"
109 cdef const int _WGT_ON_EXISTING_ERROR
"YAC_WGT_ON_EXISTING_ERROR"
110 cdef const int _WGT_ON_EXISTING_KEEP
"YAC_WGT_ON_EXISTING_KEEP"
111 cdef const int _WGT_ON_EXISTING_OVERWRITE
"YAC_WGT_ON_EXISTING_OVERWRITE"
114 void yac_cinit_instance ( int * yac_instance_id )
115 void yac_cinit_comm (MPI_Comm comm )
116 void yac_cinit_comm_instance (MPI_Comm comm, int * yac_instance_id )
119 void yac_ccleanup_instance (int yac_instance_id)
120 void yac_cdef_comp_instance ( int yac_instance_id,
121 const char * comp_name,
123 void yac_cdef_comps_instance ( int yac_instance_id,
124 const char ** comp_names,
127 void yac_cpredef_comp_instance ( int yac_instance_id,
128 const char * comp_name,
130 void yac_cget_comp_comm ( int comp_id, MPI_Comm* comp_comm )
131 void yac_cdef_datetime_instance ( int yac_instance_id,
132 const char * start_datetime,
133 const char * end_datetime )
135 const char ** comp_names,
137 MPI_Comm * comps_comm)
138 void yac_cdef_calendar ( int calendar )
139 int yac_cget_calendar ( )
140 void yac_cenddef_instance ( int yac_instance_id )
141 int yac_cget_nbr_comps_instance ( int yac_instance_id )
142 int yac_cget_nbr_grids_instance ( int yac_instance_id )
143 int yac_cget_comp_nbr_grids_instance ( int yac_instance_id, const char* comp_name )
144 int yac_cget_nbr_fields_instance ( int yac_instance_id, const char * comp_name,
145 const char* grid_name)
146 void yac_cget_comp_names_instance ( int yac_instance_id, int nbr_comps,
147 const char ** comp_names )
148 void yac_cget_grid_names_instance ( int yac_instance_id, int nbr_grids,
149 const char ** grid_names )
150 void yac_cget_comp_grid_names_instance ( int yac_instance_id, const char* comp_name,
151 int nbr_grids, const char ** grid_names )
152 void yac_cget_field_names_instance ( int yac_instance_id, const char* comp_name,
153 const char* grid_name,
154 int nbr_fields, const char ** field_names )
155 int yac_cget_comp_id_instance ( int yac_instance_id,
156 const char* comp_name )
157 int yac_cget_grid_id ( const char* grid_name )
158 int yac_cget_points_id ( int grid_id,
160 const char* point_name )
161 int yac_cget_mask_id ( int grid_id,
163 const char* mask_name )
164 int yac_cget_field_is_defined_instance ( int yac_instance_id, const char* comp_name,
165 const char* grid_name,
166 const char* field_name )
167 int yac_cget_field_id_instance ( int yac_instance_id, const char* comp_name,
168 const char* grid_name,
169 const char * field_name )
170 const char* yac_cget_field_timestep_instance ( int yac_instance_id, const char* comp_name,
171 const char* grid_name,
172 const char * field_name )
173 int yac_cget_field_role_instance ( int yac_instance_id, const char* comp_name,
174 const char* grid_name, const char* field_name )
175 void yac_cget_field_source_instance ( int yac_instance_id, const char* tgt_comp_name,
176 const char* tgt_grid_name, const char* tgt_field_name,
177 const char** src_comp_name, const char** src_grid_name,
178 const char** src_field_name)
179 void yac_cenable_field_frac_mask_instance ( int yac_instance_id,
180 const char* comp_name,
181 const char* grid_name,
182 const char * field_name,
183 double frac_mask_fallback_value)
184 int yac_cget_field_collection_size_instance ( int yac_instance_id,
185 const char* comp_name,
186 const char* grid_name,
187 const char * field_name )
188 double yac_cget_field_frac_mask_fallback_value_instance ( int yac_instance_id,
189 const char* comp_name,
190 const char* grid_name,
191 const char * field_name )
192 void yac_cdef_component_metadata_instance ( int yac_instance_id,
193 const char* comp_name,
194 const char* metadata)
195 void yac_cdef_grid_metadata_instance ( int yac_instance_id,
196 const char* grid_name,
197 const char* metadata)
198 void yac_cdef_field_metadata_instance ( int yac_instance_id,
199 const char* comp_name,
200 const char* grid_name,
201 const char* field_name,
202 const char* metadata)
204 const char* comp_name)
206 const char* grid_name)
208 const char* comp_name,
209 const char* grid_name,
210 const char* field_name)
211 char * yac_cget_start_datetime_instance ( int yac_instance_id )
212 char * yac_cget_end_datetime_instance ( int yac_instance_id )
213 char * yac_cget_version ()
214 const char * yac_cget_mpi_handshake_group_name ()
215 void yac_cdef_grid_reg2d ( const char * grid_name,
221 void yac_cdef_points_reg2d_named ( const int grid_id,
224 const double *x_points,
225 const double *y_points,
228 void yac_cdef_grid_reg2d_rot ( const char * grid_name,
236 void yac_cdef_points_reg2d_rot_named ( const int grid_id,
239 const double *x_points,
240 const double *y_points,
245 void yac_cdef_grid_curve2d ( const char * grid_name,
251 void yac_cdef_points_curve2d_named ( const int grid_id,
254 const double *x_points,
255 const double *y_points,
258 void yac_cdef_grid_cloud ( const char * grid_name,
263 void yac_cdef_grid_unstruct ( const char * grid_name,
266 int *num_vertices_per_cell,
271 void yac_cdef_grid_unstruct_ll ( const char * grid_name,
274 int *num_vertices_per_cell,
279 void yac_cdef_grid_unstruct_edge ( const char * grid_name,
283 int *num_edges_per_cell,
289 void yac_cdef_grid_unstruct_edge_ll ( const char * grid_name,
293 int *num_edges_per_cell,
299 void yac_cdef_points_unstruct_named ( const int grid_id,
300 const int nbr_points,
302 const double *x_points,
303 const double *y_points,
306 void yac_cset_global_index_yac_int ( const yac_int * global_index,
309 void yac_cdef_field ( const char * field_name,
310 const int component_id,
311 const int * point_ids,
312 const int num_pointsets,
314 const char* timestep,
317 void yac_cdef_field_mask ( const char * field_name,
318 const int component_id,
319 const int * point_ids,
320 const int * mask_ids,
321 const int num_pointsets,
323 const char* timestep,
326 void yac_csync_def_instance ( int yac_instance_id )
327 void yac_csync_def_comps_instance ( int yac_instance_id,
328 const char ** comp_names,
332 const char * weight_file)
334 int ext_couple_config_id, int weight_file_on_existing)
340 double scale_summand)
342 int ext_couple_config_id, size_t num_src_mask_names,
343 const char * const * src_mask_names)
345 int ext_couple_config_id, const char * tgt_mask_name)
347 int ext_couple_config_id, const char * yaxt_exchanger_name)
349 int ext_couple_config_id,
351 const int * collection_indices);
353 int ext_couple_config_id, int use_raw_exchange);
356 const char * src_comp_name,
357 const char * src_grid_name,
358 const char * src_field_name,
359 const char * tgt_comp_name,
360 const char * tgt_grid_name,
361 const char * tgt_field_name,
362 const char * coupling_timestep,
363 int time_unit, int time_reduction,
364 int interp_stack_config_id,
365 int src_lag, int tgt_lag,
366 int ext_couple_config_id)
367 void yac_cget_ ( const int field_id,
368 const int collection_size,
372 void yac_cget_async_ ( const int field_id,
373 const int collection_size,
377 void yac_cput_ ( const int field_id,
378 const int collection_size,
382 void yac_cput_frac_ ( const int field_id,
383 const int collection_size,
385 double *send_frac_mask,
388 void yac_cget_raw_ ( const int field_id,
389 const int collection_size,
390 double *src_field_buffer,
393 void yac_cget_raw_async_ ( const int field_id,
394 const int collection_size,
395 double *src_field_buffer,
398 void yac_cget_raw_frac_ ( const int field_id,
399 const int collection_size,
400 double *src_field_buffer,
401 double *src_frac_mask_buffer,
404 void yac_cget_raw_frac_async_ ( const int field_id,
405 const int collection_size,
406 double *src_field_buffer,
407 double *src_frac_mask_buffer,
410 void yac_cexchange_ ( const int send_field_id,
411 const int recv_field_id,
412 const int collection_size,
418 void yac_cexchange_frac_ ( const int send_field_id,
419 const int recv_field_id,
420 const int collection_size,
422 double *send_frac_mask,
427 void yac_ctest ( int field_id, int * flag )
428 void yac_cwait ( int field_id ) nogil
430 const char* yac_cget_field_name_from_field_id ( int field_id )
431 const char* yac_cget_component_name_from_field_id ( int field_id )
432 const char* yac_cget_grid_name_from_field_id ( int field_id )
433 int yac_cget_role_from_field_id ( int field_id )
434 const char* yac_cget_timestep_from_field_id ( int field_id )
435 size_t yac_cget_grid_size ( int location, int grid_id )
436 size_t yac_cget_points_size ( int points_id )
437 int yac_cget_collection_size_from_field_id ( const int field_id )
441 int interp_stack_config_id, int reduction_type, int partial_coverage)
443 int interp_stack_config_id, int weight_type, int partial_coverage)
446 double max_search_distance,
449 int search_distance_type,
450 double search_distance,
454 double max_search_distance,
457 int interp_stack_config_id, int order, int enforced_conserv,
458 int partial_coverage, int normalisation)
460 int interp_stack_config_id, double spread_distance,
461 double max_search_distance, int weight_type, int scale_type,
462 double src_sphere_radius, char * src_filename,
463 char * src_varname, int src_min_global_id,
464 double tgt_sphere_radius, char * tgt_filename,
465 char * tgt_varname, int tgt_min_global_id)
468 int interp_stack_config_id, char * filename,
469 int on_missing_file, int on_success)
471 int interp_stack_config_id, double value)
473 int interp_stack_config_id, char * constructor_key, char * do_search_key)
475 int interp_stack_config_id, int creep_distance)
477 int * interp_stack_config_id)
479 int * interp_stack_config_id)
481 void yac_cset_core_mask ( const int * is_core,
484 void yac_cset_mask ( const int * is_valid,
486 void yac_cdef_mask_named ( const int grid_id,
487 const int nbr_points,
489 const int * is_valid,
493 ctypedef void (*yac_abort_func)(MPI_Comm comm, const char *msg,
494 const char *source, int line)
except *
498 const char * yaml_file)
501 const char * filename,
504 int include_definitions);
506 const char * gridname,
507 const char * filename);
509 const char * filename);
515 void yac_cget_raw_interp_weights_data ( const int field_id,
516 double * frac_mask_fallback_value,
517 double * scaling_factor,
518 double * scaling_summand,
519 size_t * num_fixed_values,
520 double ** fixed_values,
521 size_t ** num_tgt_per_fixed_value,
522 size_t ** tgt_idx_fixed,
523 size_t * num_wgt_tgt,
524 size_t ** wgt_tgt_idx,
525 size_t ** num_src_per_tgt,
527 size_t ** src_field_idx,
529 size_t * num_src_fields,
530 size_t ** src_field_buffer_sizes );
531 void yac_cget_raw_interp_weights_data_csr ( const int field_id,
532 double * frac_mask_fallback_value,
533 double * scaling_factor,
534 double * scaling_summand,
535 size_t * num_fixed_values,
536 double ** fixed_values,
537 size_t ** num_tgt_per_fixed_value,
538 size_t ** tgt_idx_fixed,
539 size_t ** src_indptr,
541 size_t ** src_field_idx,
543 size_t * num_src_fields,
544 size_t ** src_field_buffer_sizes );
553_logger = logging.getLogger(
"yac")
554_logger.addHandler(logging.NullHandler())
560 Refers to @ref YAC_LOCATION_CELL, @ref YAC_LOCATION_CORNER and @ref YAC_LOCATION_EDGE
562 CELL = _LOCATION_CELL
563 CORNER = _LOCATION_CORNER
564 EDGE = _LOCATION_EDGE
568 Exchange type of a field
570 Refers to @ref YAC_EXCHANGE_TYPE_NONE, @ref YAC_EXCHANGE_TYPE_SOURCE and @ref YAC_EXCHANGE_TYPE_TARGET
572 NONE = _EXCHANGE_TYPE_NONE
573 SOURCE = _EXCHANGE_TYPE_SOURCE
574 TARGET = _EXCHANGE_TYPE_TARGET
578 Refers to @ref YAC_ACTION_NONE, @ref YAC_ACTION_REDUCTION etc.
581 REDUCTION = _ACTION_REDUCTION
582 COUPLING = _ACTION_COUPLING
583 GET_FOR_RESTART = _ACTION_GET_FOR_RESTART
584 PUT_FOR_RESTART = _ACTION_PUT_FOR_RESTART
585 OUT_OF_BOUND = _ACTION_OUT_OF_BOUND
589 Reduction type for the definition of interpolations
591 Refers to @ref YAC_REDUCTION_TIME_NONE, @ref YAC_REDUCTION_TIME_ACCUMULATE etc.
593 TIME_NONE = _REDUCTION_TIME_NONE
594 TIME_ACCUMULATE = _REDUCTION_TIME_ACCUMULATE
595 TIME_AVERAGE = _REDUCTION_TIME_AVERAGE
596 TIME_MINIMUM = _REDUCTION_TIME_MINIMUM
597 TIME_MAXIMUM = _REDUCTION_TIME_MAXIMUM
601 Calendar type for use in def_calendar
603 Refers to @ref YAC_CALENDAR_NOT_SET, @ref YAC_PROLEPTIC_GREGORIAN etc.
605 CALENDAR_NOT_SET = _CALENDAR_NOT_SET
606 PROLEPTIC_GREGORIAN = _PROLEPTIC_GREGORIAN
607 YEAR_OF_365_DAYS = _YEAR_OF_365_DAYS
608 YEAR_OF_360_DAYS = _YEAR_OF_360_DAYS
612 @see yac_cdef_calendar
618 @see yac_cget_calendar
625 Refers to @ref YAC_TIME_UNIT_MILLISECOND, @ref YAC_TIME_UNIT_SECOND etc.
627 MILLISECOND = _TIME_UNIT_MILLISECOND
628 SECOND = _TIME_UNIT_SECOND
629 MINUTE = _TIME_UNIT_MINUTE
630 HOUR = _TIME_UNIT_HOUR
632 MONTH = _TIME_UNIT_MONTH
633 YEAR = _TIME_UNIT_YEAR
634 ISO_FORMAT = _TIME_UNIT_ISO_FORMAT
638 Reduction type for average interpolation
640 Refers to @ref YAC_AVG_ARITHMETIC, @ref YAC_AVG_DIST and @ref YAC_AVG_BARY
642 AVG_ARITHMETIC = _AVG_ARITHMETIC
648 Reduction type for ncc interpolation
650 Refers to @ref YAC_NCC_AVG and @ref YAC_NCC_DIST
657 Reduction type for nnn interpolation
659 Refers to @ref YAC_NNN_AVG, @ref YAC_NNN_DIST etc.
668 Reduction type for dnn interpolation
670 Refers to @ref YAC_DNN_AVG, @ref YAC_DNN_DIST, @ref YAC_DNN_GAUSS,
680 Search distance type for dnn interpolation
682 Refers to @ref YAC_DNN_SEARCH_DISTANCE_FIXED and
683 @ref YAC_DNN_SEARCH_DISTANCE_CELL_AREA
685 FIXED = _DNN_SEARCH_DISTANCE_FIXED
686 CELL_AREA = _DNN_SEARCH_DISTANCE_CELL_AREA
690 Normalization type for conservative interpolation
692 Refers to @ref YAC_CONSERV_DESTAREA and @ref YAC_CONSERV_FRACAREA
694 DESTAREA = _CONSERV_DESTAREA
695 FRACAREA = _CONSERV_FRACAREA
699 Refers to @ref YAC_SPMAP_AVG and @ref YAC_SPMAP_DIST
706 Refers to @ref YAC_SPMAP_NONE, @ref YAC_SPMAP_SRCAREA
707 @ref YAC_SPMAP_INVTGTAREA, and @ref YAC_SPMAP_FRACAREA
710 SRCAREA = _SPMAP_SRCAREA
711 INVTGTAREA = _SPMAP_INVTGTAREA
712 FRACAREA = _SPMAP_FRACAREA
716 Refers to @ref YAC_FILE_MISSING_ERROR, @ref YAC_FILE_MISSING_CONT
718 ERROR = _FILE_MISSING_ERROR
719 CONT = _FILE_MISSING_CONT
723 Refers to @ref YAC_FILE_SUCCESS_STOP, @ref YAC_FILE_SUCCESS_CONT
725 STOP = _FILE_SUCCESS_STOP
726 CONT = _FILE_SUCCESS_CONT
729 YAML = _CONFIG_OUTPUT_FORMAT_YAML
730 JSON = _CONFIG_OUTPUT_FORMAT_JSON
733 DEF_COMP = _CONFIG_OUTPUT_SYNC_LOC_DEF_COMP
734 SYNC_DEF = _CONFIG_OUTPUT_SYNC_LOC_SYNC_DEF
735 ENDDEF = _CONFIG_OUTPUT_SYNC_LOC_ENDDEF
739 Handling of existing files, if weight file is to be written
741 Refers to @ref YAC_WGT_ON_EXISTING_ERROR, @ref YAC_WGT_ON_EXISTING_KEEP and
742 @ref YAC_WGT_ON_EXISTING_OVERWRITE
744 ERROR = _WGT_ON_EXISTING_ERROR
746 KEEP = _WGT_ON_EXISTING_KEEP
747 OVERWRITE = _WGT_ON_EXISTING_OVERWRITE
757 Initializies a YAC instance and provides further functionality
759 The destructor finalizes the YAC instance by calling yac_cfinalize_instance
761 def __init__(self, comm = None, default_instance = False):
763 @see yac_cinit_instance
769 _logger.debug(
"init")
771 assert(YAC.default_instance_id_defined)
774 _logger.debug(
"init_instance")
777 from mpi4py
import MPI
778 if type(comm)
is MPI.Intracomm:
779 comm = MPI.Comm.py2f(comm)
781 _logger.debug(
"init_comm")
783 assert(YAC.default_instance_id_defined)
786 _logger.debug(
"init_comm_instance")
788 _logger.debug(f
"instance_id={instance_id}")
795 @return True if default_instance_id is defined
802 @see yac_cget_default_instance_id
804 @return Default instance if exists, None if no default instance exists
813 yac = cls.__new__(cls)
815 yac.owned_instance =
False
823 @see yac_ccleanup_instance
826 if _logger
is not None:
827 _logger.debug(f
"cleanup instance_id={self.instance_id}")
834 number of processes in this instance
843 process index in this instance
851 @see yac_cdef_comp_instance
854 _logger.debug(f
"def_comp: comp_name={comp_name}")
856 _logger.debug(f
"comp_id={comp_id}")
861 @see yac_cdef_comps_instance
863 cdef int comp_len = len(comp_names)
864 cdef const char **c_comp_names = <const char **>malloc(comp_len * sizeof(const char *))
865 cdef int *c_comp_ids = <int*>malloc(comp_len * sizeof(int))
866 _logger.debug(f
"def_comps: comp_names={comp_names}")
867 byte_comp_names = [c.encode()
for c
in comp_names]
868 for i
in range(comp_len):
869 c_comp_names[i] = byte_comp_names[i]
871 comp_list = [
Component(c_comp_ids[i])
for i
in range(comp_len) ]
874 _logger.debug(
"comp_list={comp_list}")
879 @see yac_cpredef_comp_instance
882 _logger.debug(f
"predef_comp: comp_name={comp_name}")
884 _logger.debug(
"comp_id={comp_id}")
889 @see yac_cdef_datetime_instance
891 The parameters can be given either as a string in iso8601
892 format or as datetime objects
894 Datetimes are interpreted with UTC semantics and are stored without a
895 timezone offset. If no time zone is provided, UTC is assumed.
896 Explicitly specifying UTC as `Z` or `+00:00` is allowed; using other
897 time zones than UTC is not supported and will lead to an error.
901 if(
type(start_datetime)
is datetime.datetime):
902 start_datetime = start_datetime.isoformat()
905 if start_datetime
is not None:
906 _logger.debug(f
"def_datetime start: {start_datetime}")
908 start_datetime.encode(),
912 if(
type(end_datetime)
is datetime.datetime):
913 end_datetime = end_datetime.isoformat()
916 if end_datetime
is not None:
917 _logger.debug(f
"def_datetime end: {end_datetime}")
920 end_datetime.encode())
925 @see yac_cget_start_datetime_instance (`datetime.datetime`, read-only).
928 return bytes(start).decode(
'UTF-8')
933 @see yac_cget_end_datetime_instance (`datetime.datetime`, read-only).
936 return bytes(end).decode(
'UTF-8')
940 @see yac_csync_def_instance
942 _logger.debug(
"sync_def")
947 @see yac_csync_def_comps_instance
949 _logger.debug(f
"sync_def_comps: comp_names={comp_names}")
950 cptr = [c.encode()
for c
in comp_names]
951 cdef const char ** comp_names_c_ptr = <const char **>malloc(len(comp_names) * sizeof(const char *))
952 for i
in range(len(comp_names)):
953 comp_names_c_ptr[i] = cptr[i]
955 free(comp_names_c_ptr)
958 src_comp : str, src_grid : str, src_field,
959 tgt_comp : str, tgt_grid : str, tgt_field,
960 coupling_timestep : str, timeunit : TimeUnit,
961 time_reduction : Reduction,
962 interp_stack, src_lag = 0, tgt_lag = 0,
964 weight_file_on_existing : WeightFileOnExisting =
965 WeightFileOnExisting.OVERWRITE,
966 mapping_on_source = 1,
967 scale_factor = 1.0, scale_summand = 0.0,
968 src_masks_names =
None, tgt_mask_name =
None,
969 yaxt_exchanger_name =
None,
970 collection_selection =
None,
971 use_raw_exchange =
False):
973 @see yac_cdef_couple_instance
975 cdef char * weight_file_ptr
976 if weight_file
is None:
977 weight_file_ptr = NULL
979 weight_file_bytes = weight_file.encode()
980 weight_file_ptr = weight_file_bytes
981 cdef const char ** src_mask_names_ptr = NULL
982 cdef const char * tgt_mask_name_ptr = NULL
983 cdef const char * yaxt_exchanger_name_ptr = NULL
984 cdef int couple_config_id
985 cdef const int[::1] collection_selection_view
998 if src_masks_names
is not None:
999 if type(src_masks_names)
is str:
1000 src_masks = [src_masks_names]
1001 src_masks_enc = [s.encode()
for s
in src_masks_names]
1002 src_mask_names_ptr = <const char **>malloc(len(src_masks_enc) * sizeof(char*))
1003 for i
in range(len(src_masks_enc)):
1004 src_mask_names_ptr[i] = src_masks_enc[i]
1008 free(src_mask_names_ptr)
1009 if tgt_mask_name
is not None:
1011 if yaxt_exchanger_name
is not None:
1013 if collection_selection
is not None:
1014 collection_selection_view = _np.ascontiguousarray(collection_selection, dtype=_np.intc)
1016 len(collection_selection),
1017 &collection_selection_view[0])
1019 _logger.debug(f
"def_couple {(src_comp.encode(), src_grid.encode(), src_field.encode())}, {(tgt_comp.encode(), tgt_grid.encode(), tgt_field.encode())}")
1021 src_comp.encode(), src_grid.encode(), src_field.encode(),
1022 tgt_comp.encode(), tgt_grid.encode(), tgt_field.encode(),
1023 coupling_timestep.encode(),
TimeUnit(timeunit).value,
1025 interp_stack.interp_stack_id, src_lag, tgt_lag,
1031 @see yac_cenddef_instance
1033 _logger.debug(
"enddef")
1038 @see yac_cget_comp_id_instance
1044 @see yac_cget_grid_id
1051 @see yac_cget_comp_names
1054 cdef const char **ret = <const char **>malloc(nbr_components * sizeof(const char *))
1056 comp_list = [bytes(ret[i]).decode(
'UTF-8')
for i
in range(nbr_components)]
1063 @see yac_cget_grid_names
1066 cdef const char **ret = <const char **>malloc(nbr_grids * sizeof(const char *))
1068 grid_list = [bytes(ret[i]).decode(
'UTF-8')
for i
in range(nbr_grids)]
1074 @see yac_cget_comp_grid_names
1077 cdef const char **ret = <const char **>malloc(nbr_grids * sizeof(const char *))
1079 grid_list = [bytes(ret[i]).decode(
'UTF-8')
for i
in range(nbr_grids)]
1085 @see yac_cget_field_names
1090 cdef const char **ret = <const char **>malloc(nbr_fields * sizeof(const char *))
1092 grid_name.encode(), nbr_fields, ret)
1093 field_list = [bytes(ret[i]).decode(
'UTF-8')
for i
in range(nbr_fields)]
1099 @see yac_cget_field_is_defined
1101 return yac_cget_field_is_defined_instance (self.
instance_id,
1104 field_name.encode()) != 0
1106 def get_field_id(self, comp_name : str, grid_name : str, field_name : str):
1108 @see yac_cget_field_id
1110 return yac_cget_field_id_instance (self.
instance_id,
1113 field_name.encode())
1115 def get_field(self, comp_name : str, grid_name : str, field_name : str):
1117 @see yac_cget_field_id
1122 field_name.encode()))
1126 @see yac_cget_field_timestep
1131 field_name.encode())
1132 return bytes(timestep).decode(
'UTF-8')
if timestep != NULL
else None
1136 @see yac_cget_field_role
1141 field_name.encode()))
1145 cdef const char* src_comp
1146 cdef const char* src_grid
1147 cdef const char* src_field
1151 field_name.encode(),
1155 return (bytes(src_comp).decode(
"UTF-8"),
1156 bytes(src_grid).decode(
"UTF-8"),
1157 bytes(src_field).decode(
"UTF-8"))
1161 @see yac_cget_field_collection_size
1163 @retval int the collection size, if defined for this field
1164 @retval None if no collection size is defined for this field
1170 field_name.encode())
1171 return None if collection_size == -1
else collection_size
1175 @see yac_cget_field_frac_mask_fallback_value
1180 field_name.encode())
1183 frac_mask_fallback_value : _np.float64):
1185 @see yac_cenable_field_frac_mask
1187 _logger.debug(f
"enable_field_frac_mask {(comp_name, grid_name, field_name)})")
1191 field_name.encode(),
1192 frac_mask_fallback_value)
1196 @see yac_cdef_component_metadata
1198 _logger.debug(f
"def_component_metadata comp_name={comp_name}")
1200 comp_name.encode(), metadata)
1204 @see yac_cdef_grid_metadata
1206 _logger.debug(f
"def_grid_metadata grid_name={grid_name}")
1208 grid_name.encode(), metadata)
1211 field_name : str,metadata : bytes):
1213 @see yac_cdef_field_metadata
1215 _logger.debug(
"def_field_metadata (comp_name, grid_name, field_name)="
1216 f
"{(comp_name, grid_name, field_name)}")
1218 grid_name.encode(), field_name.encode(),
1223 @see yac_cget_component_metadata
1227 return bytes(metadata).decode(
'UTF-8')
if metadata != NULL
else None
1231 @see yac_cget_grid_metadata
1235 return bytes(metadata).decode(
'UTF-8')
if metadata != NULL
else None
1239 @see yac_cget_field_metadata
1244 field_name.encode())
1245 return bytes(metadata).decode(
'UTF-8')
if metadata != NULL
else None
1249 @see yac_cget_comps_comm
1251 from mpi4py
import MPI
1253 cptr = [c.encode()
for c
in comp_names]
1254 cdef const char ** comp_names_c_ptr = <const char **>malloc(len(comp_names) * sizeof(const char *))
1255 for i
in range(len(comp_names)):
1256 comp_names_c_ptr[i] = cptr[i]
1258 free(comp_names_c_ptr)
1260 return MPI.Comm.f2py(MPI_Comm_c2f(comm))
1264 @see yac_cread_config_yaml_instance
1266 _logger.debug(f
"read_config_yaml yaml_file={yaml_file}")
1270 fileformat : ConfigOutputFormat,
1271 sync_location : ConfigOutputSyncLoc,
1272 include_definitions : bool =
False):
1274 @see yac_cset_config_output_file_instance
1279 sync_location.value,
1280 1
if include_definitions
else 0)
1284 @see yac_cset_grid_output_file_instance
1292 @see yac_cset_grids_output_file_instance
1299 @see yac_cset_coordinates_check_instance
1302 1
if check_coordinates
else 0)
1306 @see yac_cset_coordinates_mismatch_is_fatal_instance
1309 1
if mismatch_is_fatal
else 0)
1313 Stores the component_id and provides further functionality
1321 @see yac_cget_comp_comm (`MPI.Comm`, read-only)
1323 from mpi4py
import MPI
1327 return MPI.Comm.f2py(MPI_Comm_c2f(comm))
1332 number of processes in this component
1341 process index in the component
1356 Stores the grid_id and provides further functionality
1358 Base class for Reg2dGrid and UnstructuredGrid
1361 _logger.debug(f
"grid_id={grid_id}")
1366 Set global indices for grid points using yac_int type.
1367 Accepts integer arrays and automatically converts to the appropriate type.
1369 @see yac_cset_global_index_yac_int
1370 @see yac_cset_global_index
1373 cdef size_t yac_int_size
1374 cdef size_t expected_size
1375 cdef const int[::1] global_index_view32
1376 cdef const long long[::1] global_index_view64
1378 global_index_arr = _np.asarray(global_index)
1382 assert <size_t>len(global_index_arr) == expected_size, \
1383 f
"Wrong number of indices provided: expected {expected_size}, got {len(global_index_arr)}"
1387 yac_int_size = sizeof(yac_int)
1389 if yac_int_size == 4:
1391 global_index_view32 = _np.ascontiguousarray(
1392 global_index_arr, dtype=_np.int32)
1393 _logger.debug(f
"set_global_index grid_id={self.grid_id} (yac_int: 32-bit)")
1396 elif yac_int_size == 8:
1398 global_index_view64 = _np.ascontiguousarray(
1399 global_index_arr, dtype=_np.int64)
1400 _logger.debug(f
"set_global_index grid_id={self.grid_id} (yac_int: 64-bit)")
1404 raise RuntimeError(f
"Unsupported yac_int size: {yac_int_size} bytes")
1407 location : Location,
1410 @see yac_cget_points_id
1414 point_name.encode()))
1417 location : Location,
1420 @see yac_cget_mask_id
1424 mask_name.encode()))
1429 @see yac_cget_grid_size (`int`, read-only)
1431 return yac_cget_grid_size ( Location.CELL.value, self.
grid_id )
1436 @see yac_cget_grid_size (`int`, read-only)
1438 return yac_cget_grid_size ( Location.CORNER.value, self.
grid_id )
1443 @see yac_cget_grid_size (`int`, read-only)
1445 return yac_cget_grid_size ( Location.EDGE.value, self.
grid_id )
1449 @see yac_cset_core_mask
1451 cdef size_t len_is_core = len(is_core)
1453 cdef const int[::1] np_mask = _np.ascontiguousarray(is_core, dtype=_np.intc)
1454 _logger.debug(f
"set_core_mask grid_id={self.grid_id}")
1455 yac_cset_core_mask ( &np_mask[0], location.value, self.
grid_id)
1458 is_valid, name =
None):
1459 cdef int len_is_valid = len(is_valid)
1460 cdef const int[::1] np_mask = _np.ascontiguousarray(is_valid, dtype=_np.int32)
1462 cdef char* c_name = NULL
1463 if name
is not None:
1464 name_enc = name.encode()
1466 _logger.debug(f
"def_mask_named grid_id={self.grid_id}, name={name}")
1467 yac_cdef_mask_named ( self.
grid_id,
1473 return Mask(mask_id)
1477 @see yac_ccompute_grid_cell_areas
1479 if cell_areas
is None:
1481 cdef double[::1] np_cell_areas = _np.ascontiguousarray(cell_areas, dtype=_np.double)
1487 Stores the points_id and provides further functionality
1495 @see yac_cget_points_size (`int`, read-only)
1497 return yac_cget_points_size ( self.
points_id )
1503 cdef size_t len_is_valid = len(is_valid)
1504 assert len_is_valid==self.
size
1505 cdef const int[::1] np_mask = _np.ascontiguousarray(is_valid, dtype=_np.intc)
1506 _logger.debug(f
"set_mask points_id={self.points_id}")
1507 yac_cset_mask ( &np_mask[0],
1514 def __init__(self, grid_name : str, x_vertices, y_vertices,
1515 cyclic = [
False,
False], north_pole =
None):
1517 @see yac_cdef_grid_reg2d
1520 cdef const double[::1] x = _np.ascontiguousarray(x_vertices, dtype=_np.double)
1521 cdef const double[::1] y = _np.ascontiguousarray(y_vertices, dtype=_np.double)
1522 cdef int[2] cyclic_view = cyclic
1523 cdef const double[::1] n_p
1525 if north_pole
is None:
1526 _logger.debug(f
"def_grid_reg2d grid_name={grid_name}")
1528 cyclic_view, <double*>&x[0], <double*>&y[0],
1531 n_p = _np.ascontiguousarray(north_pole, dtype=_np.double)
1532 _logger.debug(f
"def_grid_reg2d_rot grid_name={grid_name}")
1534 cyclic_view, <double*>&x[0], <double*>&y[0],
1535 n_p[0], n_p[1], &grid_id)
1539 x_vertices, y_vertices, name =
None):
1541 @see yac_cdef_points_reg2d_named
1544 cdef const double[::1] x = _np.ascontiguousarray(x_vertices, dtype=_np.double)
1545 cdef const double[::1] y = _np.ascontiguousarray(y_vertices, dtype=_np.double)
1546 cdef const double[::1] n_p
1547 cdef char* c_name = NULL
1548 if name
is not None:
1549 name_enc = name.encode()
1552 _logger.debug(f
"def_points_reg2d_named grid_id={self.grid_id}, name={name}")
1554 location.value, &x[0], &y[0], c_name,
1557 n_p = _np.ascontiguousarray(self.
north_pole, dtype=_np.double)
1558 _logger.debug(f
"def_points_reg2d_rot_named grid_id={self.grid_id}, name={name}")
1560 location.value, &x[0], &y[0],
1561 n_p[0], n_p[1], c_name,
1563 _logger.debug(f
"points_id={points_id}")
1567 x_vertices, y_vertices, name =
None):
1569 @see yac_cdef_points_unstruct_named
1571 assert len(x_vertices) == len(y_vertices)
1573 cdef const double[::1] x = _np.ascontiguousarray(x_vertices, dtype=_np.double)
1574 cdef const double[::1] y = _np.ascontiguousarray(y_vertices, dtype=_np.double)
1575 cdef char* c_name = NULL
1576 if name
is not None:
1577 name_enc = name.encode()
1579 _logger.debug(f
"def_points_unstruct_named grid_id={self.grid_id}, name={name}")
1581 location.value, &x[0], &y[0], c_name,
1583 _logger.debug(f
"points_id={points_id}")
1588 A curvilinear stuctured 2d Grid
1590 def __init__(self, grid_name : str, x_vertices, y_vertices,
1591 cyclic = [
False,
False]):
1593 @see yac_cdef_grid_curve2d
1596 cdef const double[::1] x = _np.ascontiguousarray(x_vertices.flatten(), dtype=_np.double)
1597 cdef const double[::1] y = _np.ascontiguousarray(y_vertices.flatten(), dtype=_np.double)
1598 cdef int[2] cyclic_view = cyclic
1599 _logger.debug(f
"def_grid_curve2d grid_name={grid_name}")
1601 [_np.shape(x_vertices)[1], _np.shape(y_vertices)[0]],
1602 cyclic_view, <double*>&x[0], <double*>&y[0], &grid_id)
1606 x_vertices, y_vertices, name =
None):
1608 @see yac_cdef_points_curve2d_named
1610 assert x_vertices.shape == y_vertices.shape
1612 cdef const double[::1] x = _np.ascontiguousarray(x_vertices.flatten(), dtype=_np.double)
1613 cdef const double[::1] y = _np.ascontiguousarray(y_vertices.flatten(), dtype=_np.double)
1614 cdef char* c_name = NULL
1615 if name
is not None:
1616 name_enc = name.encode()
1618 _logger.debug(f
"def_points_curve2d_named grid_id={self.grid_id}, name={name}")
1621 [_np.shape(x_vertices)[1], _np.shape(x_vertices)[0]],
1622 location.value, &x[0], &y[0], c_name, &points_id)
1623 _logger.debug(f
"points_id={points_id}")
1627 x_vertices, y_vertices, name =
None):
1629 @see yac_cdef_points_unstruct_named
1631 assert len(x_vertices) == len(y_vertices)
1633 cdef const double[::1] x = _np.ascontiguousarray(x_vertices, dtype=_np.double)
1634 cdef const double[::1] y = _np.ascontiguousarray(y_vertices, dtype=_np.double)
1635 cdef char* c_name = NULL
1636 if name
is not None:
1637 name_enc = name.encode()
1639 _logger.debug(f
"def_points_unstruct_named grid_id={self.grid_id}, name={name}")
1641 location.value, &x[0], &y[0], c_name,
1643 _logger.debug(f
"points_id={points_id}")
1652 x_points, y_points, name =
None):
1654 @see yac_cdef_points_unstruct_named
1657 cdef const double[::1] x_points_view = _np.ascontiguousarray(x_points, dtype=_np.double)
1658 cdef const double[::1] y_points_view = _np.ascontiguousarray(y_points, dtype=_np.double)
1659 cdef char* c_name = NULL
1660 if name
is not None:
1661 name_enc = name.encode()
1663 _logger.debug(f
"yac_cdef_points_unstruct_named grid_id={self.grid_id}, name={name}")
1666 &x_points_view[0], &y_points_view[0], c_name, &points_id)
1667 _logger.debug(f
"points_id={points_id}")
1672 An unstuctured 2d Grid
1674 def __init__(self, grid_name : str, num_vertices_per_cell,
1675 x_vertices, y_vertices, cell_to_vertex, use_ll_edges=
False):
1677 @see yac_cdef_grid_unstruct and @see yac_cdef_grid_unstruct_ll
1680 cdef const int[::1] num_vertices_per_cell_view = _np.ascontiguousarray(num_vertices_per_cell, dtype=_np.intc)
1681 cdef const double[::1] x_vertices_view = _np.ascontiguousarray(x_vertices, dtype=_np.double)
1682 cdef const double[::1] y_vertices_view = _np.ascontiguousarray(y_vertices, dtype=_np.double)
1683 cdef const int[::1] cell_to_vertex_view = _np.ascontiguousarray(cell_to_vertex, dtype=_np.intc)
1684 assert len(num_vertices_per_cell_view) > 0, \
1685 "UnstrucuredGrid needs at least one cell. Use CloudGrid if you dont need to define cells."
1686 if not use_ll_edges:
1687 _logger.debug(f
"def_grid_unstruct grid_name={grid_name}")
1689 len(num_vertices_per_cell_view),
1690 <int*>&num_vertices_per_cell_view[0],
1691 <double*>&x_vertices_view[0],
1692 <double*>&y_vertices_view[0],
1693 <int*>&cell_to_vertex_view[0], &grid_id)
1695 _logger.debug(f
"def_grid_unstruct_ll grid_name={grid_name}")
1697 len(num_vertices_per_cell_view),
1698 <int*>&num_vertices_per_cell_view[0],
1699 <double*>&x_vertices_view[0],
1700 <double*>&y_vertices_view[0],
1701 <int*>&cell_to_vertex_view[0], &grid_id)
1706 @see yac_cdef_grid_cloud
1708 def __init__(self, grid_name : str, x_vertices, y_vertices):
1710 cdef const double[::1] x_vertices_view = _np.ascontiguousarray(x_vertices, dtype=_np.double)
1711 cdef const double[::1] y_vertices_view = _np.ascontiguousarray(y_vertices, dtype=_np.double)
1712 _logger.debug(f
"def_grid_cloud grid_name={grid_name}")
1713 yac_cdef_grid_cloud (grid_name.encode(),
1714 len(x_vertices_view),
1715 <double*>&x_vertices_view[0],
1716 <double*>&y_vertices_view[0],
1721 return super().
def_points(Location.CORNER, x_points, y_points, name)
1725 def __init__(self, grid_name : str, num_edges_per_cell,
1726 x_vertices, y_vertices, cell_to_edge, edge_to_vertex,
1727 use_ll_edges=
False):
1729 cdef const int[::1] num_edges_per_cell_view = _np.ascontiguousarray(num_edges_per_cell, dtype=_np.intc)
1730 cdef const double[::1] x_vertices_view = _np.ascontiguousarray(x_vertices, dtype=_np.double)
1731 cdef const double[::1] y_vertices_view = _np.ascontiguousarray(y_vertices, dtype=_np.double)
1732 cdef const int[::1] cell_to_edge_view = _np.ascontiguousarray(cell_to_edge, dtype=_np.intc)
1733 cdef const int[:, ::1] edge_to_vertex_view = _np.ascontiguousarray(edge_to_vertex, dtype=_np.intc)
1734 assert edge_to_vertex_view.shape[1] == 2, \
1735 "dimension 1 of edge_to_vertex must be 2"
1736 assert len(num_edges_per_cell_view) > 0, \
1737 "UnstrucuredGridEdge needs at least one cell. Use CloudGrid if you dont need to define cells."
1738 if not use_ll_edges:
1739 _logger.debug(f
"def_grid_unstruct_edge grid_name={grid_name}")
1741 len(num_edges_per_cell_view),
1742 edge_to_vertex_view.shape[0],
1743 <int*>&num_edges_per_cell_view[0],
1744 <double*>&x_vertices_view[0],
1745 <double*>&y_vertices_view[0],
1746 <int*>&cell_to_edge_view[0],
1747 <int*>&edge_to_vertex_view[0,0],
1750 _logger.debug(f
"def_grid_unstruct_edge_ll grid_name={grid_name}")
1752 len(num_edges_per_cell_view),
1753 edge_to_vertex_view.shape[0],
1754 <int*>&num_edges_per_cell_view[0],
1755 <double*>&x_vertices_view[0],
1756 <double*>&y_vertices_view[0],
1757 <int*>&cell_to_edge_view[0],
1758 <int*>&edge_to_vertex_view[0,0],
1772 def create(cls, field_name : str, comp : Component, points, collection_size,
1773 timestep : str, timeunit : TimeUnit, masks =
None):
1777 from collections.abc
import Iterable
1779 if not isinstance(points, Iterable):
1781 cdef const int[:] point_ids_array = _np.array([p.points_id
for p
in points], dtype=_np.intc)
1782 size = sum(p.size
for p
in points)
1783 cdef const int[:] mask_ids_array
1785 _logger.debug(f
"def_field field_name={field_name}, comp_id={comp.comp_id}, point_ids={[p.points_id for p in points]}")
1787 &point_ids_array[0], len(point_ids_array),
1788 collection_size, timestep.encode(),
TimeUnit(timeunit).value, &field_id)
1790 if not isinstance(masks, Iterable):
1792 mask_ids_array = _np.array([m.mask_id
for m
in masks], dtype=_np.intc)
1793 _logger.debug(f
"def_field_mask field_name={field_name}, comp_id={comp.comp_id}, point_ids={[p.points_id for p in points]}")
1795 &point_ids_array[0], &mask_ids_array[0],
1796 len(point_ids_array),
1797 collection_size, timestep.encode(),
TimeUnit(timeunit).value, &field_id)
1798 _logger.debug(f
"field_id={field_id}")
1799 return Field(field_id, size)
1807 _logger.debug(f
"test field_id={self.field_id}")
1809 _logger.debug(f
"flag={flag}")
1818 _logger.debug(f
"wait field_id={field_id}")
1820 yac_cwait ( field_id )
1825 Coroutine. Blocks until the communication is completed.
1827 while self.
test() == 0:
1830 @cython.boundscheck(False)
1831 def get(self, buf=None, asyn=False):
1833 @see yac_cget_ and variants
1835 @param[out] buf receive buffer, if `None` a numpy array of correct size is allocated
1836 @param[in] asyn if True the call returns immediately and must be completed
1837 with `test` or `wait`
1839 @returns a tuple `(data, action)`. If no data is to be received
1840 (i.e. `action` is `Action.NONE` or `Action.OUT_OF_BOUND`),
1841 `update` is called instead and `data` is `None`.
1846 if action
in (Action.NONE, Action.OUT_OF_BOUND):
1852 if buf.base
is None:
1853 _logger.warning(
"get: non-contiguous buffer passed to get. Reallocated memory.")
1854 cdef double[:,::1] buf_view = buf
1858 _logger.debug(f
"get_async_ field_id={self.field_id}")
1859 yac_cget_async_(field_id, collection_size, &buf_view[0,0], &info, &ierror)
1861 _logger.debug(f
"get_ field_id={self.field_id}")
1863 yac_cget_(field_id, collection_size, &buf_view[0,0], &info, &ierror)
1865 raise RuntimeError(
"yac_cget returned error number " + str(ierror))
1866 _logger.debug(f
"info={info}")
1871 Coroutine. Executes a get operation.
1873 @see yac_cget_async_
1875 @param[out] buf receive buffer, if `None` a numpy array of correct size is allocated
1877 buf, info = self.
get(buf, asyn=
True)
1881 @cython.boundscheck(False)
1882 def get_raw(self, buf, frac_mask=None, asyn=False):
1884 @see yac_cget_raw_ and variants
1886 @param[inout] buf receive buffer, if `None` a numpy array of correct size is allocated
1887 @param[inout] frac_mask receive buffer for frac_mask, if `None` a numpy array of correct size is allocated
1888 @param[in] asyn if True the call returns immediately and must be completed
1889 with `test` or `wait`
1891 @returns a tuple `(data, frac_mask, action)`. If no data is to be
1892 received (i.e. `action` is `Action.NONE` or
1893 `Action.OUT_OF_BOUND`), `update` is called instead and
1894 `data` and `frac_mask` are `None`.
1899 if action
in (Action.NONE, Action.OUT_OF_BOUND):
1901 return None,
None, action
1903 if buf.base
is None:
1904 _logger.warning(
"get: non-contiguous buffer passed to get_raw. Reallocated memory.")
1905 cdef double[:,::1] buf_view = buf
1906 if frac_mask
is not None:
1908 if frac_mask
is not None and frac_mask.base
is None:
1909 _logger.warning(
"get: non-contiguous frac_mask buffer passed to get_raw. Reallocated memory.")
1910 cdef double[:,::1] frac_mask_view = frac_mask
1914 if frac_mask
is not None:
1915 _logger.debug(f
"get_raw_frac_async_ field_id={self.field_id}")
1917 &frac_mask_view[0,0], &info, &ierror)
1919 _logger.debug(f
"get_raw_async_ field_id={self.field_id}")
1922 if frac_mask
is not None:
1923 _logger.debug(f
"get_raw_frac_ field_id={self.field_id}")
1926 &frac_mask_view[0,0], &info, &ierror)
1928 _logger.debug(f
"get_raw_ field_id={self.field_id}")
1930 yac_cget_raw_(field_id, collection_size, &buf_view[0,0], &info, &ierror)
1932 raise RuntimeError(
"yac_cget returned error number " + str(ierror))
1933 _logger.debug(f
"info={info}")
1934 return buf, frac_mask,
Action(info)
1936 @cython.boundscheck(False)
1937 def put(self, buf, frac_mask = None):
1944 cdef const double[:,:,::1] frac_mask_view
1947 if frac_mask
is not None:
1948 frac_mask_view = _np.ascontiguousarray(
1950 _logger.debug(f
"put_frac_ field_id={self.field_id}")
1952 yac_cput_frac_(field_id, collection_size, <double*>&buf_view[0,0,0],
1953 <double*>&frac_mask_view[0,0,0], &info, &ierror)
1955 _logger.debug(f
"put_ field_id={self.field_id}")
1957 yac_cput_(field_id, collection_size, <double*>&buf_view[0,0,0], &info, &ierror)
1959 raise RuntimeError(
"yac_cput returned error number " + str(ierror))
1960 _logger.debug(f
"info={info}")
1965 Coroutine. Executes a put operation.
1970 return self.
put(buf, frac_mask)
1976 _logger.debug(f
"update field_id={self.field_id}")
1980 @cython.boundscheck(False)
1981 def exchange(cls, send_field, recv_field, send_buf, recv_buf=None, send_frac_mask=None):
1983 @see yac_cexchange_frac_
1985 @returns a tuple `(data, send_info, recv_info)`. If no data is to be
1986 received on the recv side (i.e. `recv_info` is
1987 `Action.NONE` or `Action.OUT_OF_BOUND`), the send side is
1988 handled via `put`, `update` is called on the recv side and
1991 assert send_field.collection_size == recv_field.collection_size,
"exchange can only be used with fields of the same collection_size"
1992 cdef int collection_size = send_field.collection_size
1996 recv_action = recv_field.action
1997 if recv_action
in (Action.NONE, Action.OUT_OF_BOUND):
1999 send_action = send_field.put(send_buf, send_frac_mask)
2000 return None, send_action, recv_action
2001 cdef const double[:,:,::1] send_buf_view = _np.ascontiguousarray(send_buf.reshape(-1,collection_size,send_field.size), dtype=_np.double)
2002 cdef const double[:,:,::1] frac_mask_view
2003 if recv_buf
is None:
2004 recv_buf = _np.empty((collection_size, recv_field.size), dtype=_np.double)
2005 recv_buf = _np.ascontiguousarray(recv_buf.reshape(collection_size, recv_field.size), dtype=_np.double)
2006 cdef double[:,::1] recv_buf_view = recv_buf
2007 cdef int send_field_id = send_field.field_id
2008 cdef int recv_field_id = recv_field.field_id
2009 if send_frac_mask
is None:
2010 _logger.debug(f
"exchange_ with send_field.field_id={send_field.field_id} and recv_field.field_id={recv_field.field_id}")
2013 <double*>&send_buf_view[0,0,0],
2014 <double*>&recv_buf_view[0,0],
2015 &send_info, &recv_info, &ierror)
2017 _logger.debug(f
"exchange_frac_ with send_field.field_id={send_field.field_id} and recv_field.field_id={recv_field.field_id}")
2018 frac_mask_view = _np.ascontiguousarray(
2019 send_frac_mask.reshape(-1,collection_size,send_field.size), dtype=_np.double)
2022 <double*>&send_buf_view[0,0,0],
2023 <double*>&frac_mask_view[0,0,0],
2024 <double*>&recv_buf_view[0,0],
2025 &send_info, &recv_info, &ierror)
2027 raise RuntimeError(
"yac_cexchange_frac_ returned error number " + str(ierror))
2034 @see yac_cget_field_name_from_field_id
2036 cdef const char* field_name = yac_cget_field_name_from_field_id ( self.
field_id )
2037 return bytes(field_name).decode(
'UTF-8')
2042 @see yac_cget_grid_name_from_field_id
2044 cdef const char* grid_name = yac_cget_grid_name_from_field_id ( self.
field_id )
2045 return bytes(grid_name).decode(
'UTF-8')
2050 @see yac_cget_component_name_from_field_id
2052 cdef const char* component_name = yac_cget_component_name_from_field_id ( self.
field_id )
2053 return bytes(component_name).decode(
'UTF-8')
2058 @see yac_cget_role_from_field_id
2065 @see yac_cget_timestep_from_field_id
2067 cdef const char* timestep = yac_cget_timestep_from_field_id ( self.
field_id )
2068 return bytes(timestep).decode(
'UTF-8')
if timestep != NULL
else None
2073 @see yac_cget_collection_size_from_field_id
2080 The size of the corresponding points object
2087 @see yac_cget_field_datetime
2090 return bytes(dt).decode(
'UTF-8')
if dt != NULL
else None
2095 @see yac_cget_action
2097 Can be checked before calling `get`/`get_raw` to determine whether
2098 the next call will actually receive data. If it is `Action.NONE` or
2099 `Action.OUT_OF_BOUND`, `get`/`get_raw` will return `None` instead of
2100 data and `update` can be called instead.
2108 @see yac_cget_raw_interp_weights_data
2110 Returns a dictionary with the corresponding values
2112 cdef double frac_mask_fallback_value;
2113 cdef double scaling_factor;
2114 cdef double scaling_summand;
2115 cdef size_t num_fixed_values;
2116 cdef double * fixed_values;
2117 cdef size_t * num_tgt_per_fixed_value;
2118 cdef size_t * tgt_idx_fixed;
2119 cdef size_t num_wgt_tgt;
2120 cdef size_t * wgt_tgt_idx;
2121 cdef size_t * num_src_per_tgt;
2122 cdef double * weights;
2123 cdef size_t * src_field_idx;
2124 cdef size_t * src_idx;
2125 cdef size_t num_src_fields;
2126 cdef size_t * src_field_buffer_sizes;
2127 yac_cget_raw_interp_weights_data ( self.
field_id,
2128 &frac_mask_fallback_value,
2133 &num_tgt_per_fixed_value,
2142 &src_field_buffer_sizes );
2145 frac_mask_fallback_value=frac_mask_fallback_value,
2146 scaling_factor=scaling_factor,
2147 scaling_summand=scaling_summand)
2149 if num_fixed_values > 0:
2150 result.fixed_values = _np.array(<double[:num_fixed_values]> fixed_values)
2151 result.num_tgt_per_fixed_value = _np.array(<size_t[:num_fixed_values]> num_tgt_per_fixed_value)
2152 tgt_idx_fixed_size = _np.sum(result.num_tgt_per_fixed_value)
2153 result.tgt_idx_fixed = _np.array(<size_t[:tgt_idx_fixed_size]> tgt_idx_fixed)
2156 result.wgt_tgt_idx = _np.array(<size_t[:num_wgt_tgt]>wgt_tgt_idx)
2157 result.num_src_per_tgt = _np.array(<size_t[:num_wgt_tgt]> num_src_per_tgt)
2158 num_weights = _np.sum(result.num_src_per_tgt)
2159 result.weights = _np.array(<double[:num_weights]>weights)
2160 result.src_field_idx = _np.array(<size_t[:num_weights]> src_field_idx)
2161 result.src_idx = _np.array(<size_t[:num_weights]> src_idx)
2163 if num_src_fields > 0:
2164 result.src_field_buffer_sizes = _np.array(<size_t[:num_src_fields]> src_field_buffer_sizes)
2167 free(num_tgt_per_fixed_value);
2168 free(tgt_idx_fixed);
2170 free(num_src_per_tgt);
2172 free(src_field_idx);
2174 free(src_field_buffer_sizes);
2179 @see yac_cget_raw_interp_weights_data
2181 Returns a dictionary with the corresponding values
2183 cdef double frac_mask_fallback_value;
2184 cdef double scaling_factor;
2185 cdef double scaling_summand;
2186 cdef size_t num_fixed_values;
2187 cdef double * fixed_values;
2188 cdef size_t * num_tgt_per_fixed_value;
2189 cdef size_t * tgt_idx_fixed;
2190 cdef size_t * src_indptr;
2191 cdef double * weights;
2192 cdef size_t * src_field_idx;
2193 cdef size_t * src_idx;
2194 cdef size_t num_src_fields;
2195 cdef size_t * src_field_buffer_sizes;
2196 yac_cget_raw_interp_weights_data_csr ( self.
field_id,
2197 &frac_mask_fallback_value,
2202 &num_tgt_per_fixed_value,
2209 &src_field_buffer_sizes );
2212 frac_mask_fallback_value=frac_mask_fallback_value,
2213 scaling_factor=scaling_factor,
2214 scaling_summand=scaling_summand)
2216 if num_fixed_values > 0:
2217 result.fixed_values = _np.array(<double[:num_fixed_values]> fixed_values)
2218 result.num_tgt_per_fixed_value = _np.array(<size_t[:num_fixed_values]> num_tgt_per_fixed_value)
2219 tgt_idx_fixed_size = _np.sum(result.num_tgt_per_fixed_value)
2220 result.tgt_idx_fixed = _np.array(<size_t[:tgt_idx_fixed_size]> tgt_idx_fixed)
2222 result.src_indptr = _np.array(<size_t[:self.
sizesize + 1]> src_indptr)
2223 num_weights = result.src_indptr[-1]
2224 result.weights = _np.array(<double[:num_weights]>weights)
2225 result.src_field_idx = _np.array(<size_t[:num_weights]> src_field_idx)
2226 result.src_idx = _np.array(<size_t[:num_weights]> src_idx)
2228 if num_src_fields > 0:
2229 result.src_field_buffer_sizes = _np.array(<size_t[:num_src_fields]> src_field_buffer_sizes)
2232 free(num_tgt_per_fixed_value);
2233 free(tgt_idx_fixed);
2236 free(src_field_idx);
2238 free(src_field_buffer_sizes);
2244 frac_mask_fallback_value : float
2245 scaling_factor : float
2246 scaling_summand : float
2247 fixed_values : _np.ndarray = field(default_factory=
lambda: _np.empty(shape=[0], dtype=_np.float64))
2248 num_tgt_per_fixed_value : _np.ndarray = field(default_factory=
lambda: _np.empty(shape=[0], dtype=_np.uintp))
2249 tgt_idx_fixed : _np.ndarray = field(default_factory=
lambda: _np.empty(shape=[0], dtype=_np.uintp))
2250 wgt_tgt_idx : _np.ndarray = field(default_factory=
lambda: _np.empty(shape=[0], dtype=_np.uintp))
2251 num_src_per_tgt : _np.ndarray = field(default_factory=
lambda: _np.empty(shape=[0], dtype=_np.uintp))
2252 weights : _np.ndarray = field(default_factory=
lambda: _np.empty(shape=[0], dtype=_np.float64))
2253 src_field_idx : _np.ndarray = field(default_factory=
lambda: _np.empty(shape=[0], dtype=_np.uintp))
2254 src_idx : _np.ndarray = field(default_factory=
lambda: _np.empty(shape=[0], dtype=_np.uintp))
2255 src_field_buffer_sizes : _np.ndarray = field(default_factory=
lambda: _np.empty(shape=[0], dtype=_np.uintp))
2260 frac_mask_fallback_value : float
2261 scaling_factor : float
2262 scaling_summand : float
2263 fixed_values : _np.ndarray = field(default_factory=
lambda: _np.empty(shape=[0], dtype=_np.float64))
2264 num_tgt_per_fixed_value : _np.ndarray = field(default_factory=
lambda: _np.empty(shape=[0], dtype=_np.uintp))
2265 tgt_idx_fixed : _np.ndarray = field(default_factory=
lambda: _np.empty(shape=[0], dtype=_np.uintp))
2266 src_indptr : _np.ndarray = field(default_factory=
lambda: _np.empty(shape=[0], dtype=_np.uintp))
2267 weights : _np.ndarray = field(default_factory=
lambda: _np.empty(shape=[0], dtype=_np.float64))
2268 src_field_idx : _np.ndarray = field(default_factory=
lambda: _np.empty(shape=[0], dtype=_np.uintp))
2269 src_idx : _np.ndarray = field(default_factory=
lambda: _np.empty(shape=[0], dtype=_np.uintp))
2270 src_field_buffer_sizes : _np.ndarray = field(default_factory=
lambda: _np.empty(shape=[0], dtype=_np.uintp))
2275 @see yac_cget_interp_stack_config
2277 cdef int interp_stack_config_id
2278 _logger.debug(f
"get_interp_stack_config")
2280 _logger.debug(f
"interp_stack_config_id={interp_stack_config_id}")
2285 interp_stack = cls.__new__(cls)
2286 cdef int interp_stack_config_id
2287 _logger.debug(f
"get_interp_stack_config_from_string_yaml: interp_stack_string={interp_stack_string}")
2289 _logger.debug(f
"interp_stack_config_id_from_string_yaml={interp_stack_config_id}")
2290 interp_stack.interp_stack_id = interp_stack_config_id
2295 interp_stack = cls.__new__(cls)
2296 cdef int interp_stack_config_id
2297 _logger.debug(f
"get_interp_stack_config_from_string_json: interp_stack_string={interp_stack_string}")
2299 _logger.debug(f
"interp_stack_config_id_from_string_json={interp_stack_config_id}")
2300 interp_stack.interp_stack_id = interp_stack_config_id
2304 reduction_type : AverageReductionType = AverageReductionType.AVG_ARITHMETIC,
2305 partial_coverage : bool =
False):
2307 @see yac_cadd_interp_stack_config_average
2309 _logger.debug(f
"add_interp_stack_config_average interp_stack_id={self.interp_stack_id}")
2315 reduction_type : NCCReductionType = NCCReductionType.AVG,
2316 partial_coverage : bool =
False):
2318 @see yac_cadd_interp_stack_config_ncc
2320 _logger.debug(f
"add_interp_stack_config_ncc interp_stack_id={self.interp_stack_id}")
2326 reduction_type : NNNReductionType = NNNReductionType.AVG,
2328 max_search_distance : _np.float64 = 0.0,
2329 scale : _np.float64 = 1.0):
2331 @see yac_cadd_interp_stack_config_nnn
2333 _logger.debug(f
"add_interp_stack_config_nnn interp_stack_id={self.interp_stack_id}")
2336 n, max_search_distance, scale)
2339 reduction_type : DNNReductionType = DNNReductionType.DIST,
2340 search_distance_type : DNNSearchDistanceType = DNNSearchDistanceType.CELL_AREA,
2341 search_distance : _np.float64 = 1.0,
2342 scale : _np.float64 = 0.0):
2344 @see yac_cadd_interp_stack_config_dnn
2346 _logger.debug(f
"add_interp_stack_config_dnn interp_stack_id={self.interp_stack_id}")
2350 search_distance, scale)
2354 max_search_distance : _np.float64 = 0.0,
2355 scale : _np.float64 = 1.487973e+01):
2357 @see yac_cadd_interp_stack_config_rbf
2359 _logger.debug(f
"add_interp_stack_config_rbf interp_stack_id={self.interp_stack_id}")
2361 n, max_search_distance, scale)
2365 enforced_conserv : bool =
False,
2366 partial_coverage : bool =
False,
2367 normalisation : ConservNormalizationType = ConservNormalizationType.DESTAREA):
2369 @see yac_cadd_interp_stack_config_conservative
2371 _logger.debug(f
"add_interp_stack_config_conservative interp_stack_id={self.interp_stack_id}")
2373 order, enforced_conserv,
2378 spread_distance : _np.float64 = 0.0,
2379 max_search_distance : _np.float64 = 0.0,
2380 weight_type : SPMAPWeightType = SPMAPWeightType.AVG,
2381 scale_type : SPMAPScaleType = SPMAPScaleType.NONE,
2382 src_sphere_radius : _np.float64 = 1.0,
2383 src_filename : str =
None,
2384 src_varname : str =
None,
2385 src_min_global_id : int = 0,
2386 tgt_sphere_radius : _np.float64 = 1.0,
2387 tgt_filename : str =
None,
2388 tgt_varname : str =
None,
2389 tgt_min_global_id : int = 0):
2391 @see yac_cadd_interp_stack_config_spmap
2393 _logger.debug(f
"add_interp_stack_config_spmap interp_stack_id={self.interp_stack_id}")
2394 cdef char * src_filename_ptr
2395 if src_filename
is None:
2396 src_filename_ptr = NULL
2398 src_filename_bytes = src_filename.encode()
2399 src_filename_ptr = src_filename_bytes
2400 cdef char * src_varname_ptr
2401 if src_varname
is None:
2402 src_varname_ptr = NULL
2404 src_varname_bytes = src_varname.encode()
2405 src_varname_ptr = src_varname_bytes
2406 cdef char * tgt_filename_ptr
2407 if tgt_filename
is None:
2408 tgt_filename_ptr = NULL
2410 tgt_filename_bytes = tgt_filename.encode()
2411 tgt_filename_ptr = tgt_filename_bytes
2412 cdef char * tgt_varname_ptr
2413 if tgt_varname
is None:
2414 tgt_varname_ptr = NULL
2416 tgt_varname_bytes = tgt_varname.encode()
2417 tgt_varname_ptr = tgt_varname_bytes
2419 spread_distance, max_search_distance,
2422 src_sphere_radius, src_filename_ptr,
2423 src_varname_ptr, src_min_global_id,
2424 tgt_sphere_radius, tgt_filename_ptr,
2425 tgt_varname_ptr, tgt_min_global_id)
2429 @see yac_cadd_interp_stack_config_hcsbb
2431 _logger.debug(f
"add_interp_stack_config_hcsbb interp_stack_id={self.interp_stack_id}")
2436 on_missing_file : UserFileOnMissingFile = UserFileOnMissingFile.ERROR,
2437 on_success : UserFileOnSuccess = UserFileOnSuccess.CONT):
2439 @see yac_cadd_interp_stack_config_user_file
2441 _logger.debug(f
"add_interp_stack_config_user_file interp_stack_id={self.interp_stack_id}")
2448 def add_fixed(self, value : _np.float64 = _np.finfo(_np.double).max):
2450 @see yac_cadd_interp_stack_config_fixed
2452 _logger.debug(f
"add_interp_stack_config_fixed interp_stack_id={self.interp_stack_id}")
2456 constructor_key : str,
2457 do_search_key : str):
2459 @see yac_cadd_interp_stack_config_check
2461 _logger.debug(f
"add_interp_stack_config_check interp_stack_id={self.interp_stack_id}")
2463 constructor_key.encode(), do_search_key.encode())
2466 creep_distance : int = -1):
2468 @see yac_cadd_interp_stack_config_creep
2470 _logger.debug(f
"add_interp_stack_config_creep interp_stack_id={self.interp_stack_id}")
2476 @see yac_cfree_interp_stack_config
2478 _logger.debug(f
"free_interp_stack_config interp_stack_id={self.interp_stack_id}")
2483 @see yac_cget_version
2486 return bytes(version_str).decode(
'UTF-8')
2491 @see yac_cget_mpi_handshake_group_name
2494 return bytes(group_name).decode(
'UTF-8')
2497if Py_AtExit(yac_cfinalize) < 0:
2500 b
"could not register yac_cfinalize with Py_AtExit()",
2505cdef void yac_python_abort(MPI_Comm comm, const char* msg,
2506 const char* source, int line) noexcept
with gil:
2507 traceback.print_stack()
2514 traceback.print_tb(tb)
2516 str(value).encode(),
2517 tb.tb_frame.f_code.co_filename.encode(),
2518 tb.tb_frame.f_lineno)
2520sys.excepthook = _yac_excepthook
char const * grid_names[]
char const * component_names[]
Refers to YAC_ACTION_NONE, YAC_ACTION_REDUCTION etc.
Reduction type for average interpolation.
Calendar type for use in def_calendar.
def_points(self, x_points, y_points, name=None)
__init__(self, str grid_name, x_vertices, y_vertices)
Stores the component_id and provides further functionality.
size(self)
number of processes in this component
rank(self)
process index in the component
Normalization type for conservative interpolation.
A curvilinear stuctured 2d Grid.
__init__(self, str grid_name, x_vertices, y_vertices, cyclic=[False, False])
def_points(self, Location location, x_vertices, y_vertices, name=None)
def_points_unstruct(self, Location location, x_vertices, y_vertices, name=None)
Reduction type for dnn interpolation.
Search distance type for dnn interpolation.
Exchange type of a field.
get_raw(self, buf, frac_mask=None, asyn=False)
put_coro(self, buf, frac_mask=None)
Coroutine.
get_coro(self, buf=None)
Coroutine.
size(self)
The size of the corresponding points object.
wait_coro(self)
Coroutine.
get_raw_interp_weights_data(self)
get(self, buf=None, asyn=False)
exchange(cls, send_field, recv_field, send_buf, recv_buf=None, send_frac_mask=None)
create(cls, str field_name, Component comp, points, collection_size, str timestep, TimeUnit timeunit, masks=None)
get_raw_interp_weights_data_csr(self)
__init__(self, field_id, size=None)
put(self, buf, frac_mask=None)
Stores the grid_id and provides further functionality.
get_mask(self, Location location, str mask_name)
set_core_mask(self, is_core, Location location)
get_points(self, Location location, str point_name)
set_global_index(self, global_index, Location location)
Set global indices for grid points using yac_int type.
def_mask(self, Location location, is_valid, name=None)
compute_grid_cell_areas(self, cell_areas=None)
add_check(self, str constructor_key, str do_search_key)
add_creep(self, int creep_distance=-1)
add_user_file(self, str filename, UserFileOnMissingFile on_missing_file=UserFileOnMissingFile.ERROR, UserFileOnSuccess on_success=UserFileOnSuccess.CONT)
add_nnn(self, NNNReductionType reduction_type=NNNReductionType.AVG, int n=1, _np.float64 max_search_distance=0.0, _np.float64 scale=1.0)
add_rbf(self, int n=9, _np.float64 max_search_distance=0.0, _np.float64 scale=1.487973e+01)
add_spmap(self, _np.float64 spread_distance=0.0, _np.float64 max_search_distance=0.0, SPMAPWeightType weight_type=SPMAPWeightType.AVG, SPMAPScaleType scale_type=SPMAPScaleType.NONE, _np.float64 src_sphere_radius=1.0, str src_filename=None, str src_varname=None, int src_min_global_id=0, _np.float64 tgt_sphere_radius=1.0, str tgt_filename=None, str tgt_varname=None, int tgt_min_global_id=0)
add_ncc(self, NCCReductionType reduction_type=NCCReductionType.AVG, bool partial_coverage=False)
add_conservative(self, int order=1, bool enforced_conserv=False, bool partial_coverage=False, ConservNormalizationType normalisation=ConservNormalizationType.DESTAREA)
from_string_json(cls, str interp_stack_string)
from_string_yaml(cls, str interp_stack_string)
add_dnn(self, DNNReductionType reduction_type=DNNReductionType.DIST, DNNSearchDistanceType search_distance_type=DNNSearchDistanceType.CELL_AREA, _np.float64 search_distance=1.0, _np.float64 scale=0.0)
add_average(self, AverageReductionType reduction_type=AverageReductionType.AVG_ARITHMETIC, bool partial_coverage=False)
add_fixed(self, _np.float64 value=_np.finfo(_np.double).max)
Reduction type for ncc interpolation.
Reduction type for nnn interpolation.
Stores the points_id and provides further functionality.
__init__(self, points_id)
Reduction type for the definition of interpolations.
def_points_unstruct(self, Location location, x_vertices, y_vertices, name=None)
def_points(self, Location location, x_vertices, y_vertices, name=None)
__init__(self, str grid_name, x_vertices, y_vertices, cyclic=[False, False], north_pole=None)
Refers to YAC_SPMAP_NONE, YAC_SPMAP_SRCAREA YAC_SPMAP_INVTGTAREA, and YAC_SPMAP_FRACAREA.
Refers to YAC_SPMAP_AVG and YAC_SPMAP_DIST.
Refers to YAC_TIME_UNIT_MILLISECOND, YAC_TIME_UNIT_SECOND etc.
__init__(self, str grid_name, num_edges_per_cell, x_vertices, y_vertices, cell_to_edge, edge_to_vertex, use_ll_edges=False)
__init__(self, str grid_name, num_vertices_per_cell, x_vertices, y_vertices, cell_to_vertex, use_ll_edges=False)
Refers to YAC_FILE_MISSING_ERROR, YAC_FILE_MISSING_CONT.
Refers to YAC_FILE_SUCCESS_STOP, YAC_FILE_SUCCESS_CONT.
Handling of existing files, if weight file is to be written.
Initializies a YAC instance and provides further functionality.
set_coordinates_check(self, bool check_coordinates)
get_field_is_defined(self, str comp_name, str grid_name, str field_name)
read_config_yaml(self, str yaml_file)
get_grid(self, str grid_name)
set_coordinates_mismatch_is_fatal(self, bool mismatch_is_fatal)
default_instance_id_defined(cls)
def_comp(self, str comp_name)
sync_def_comps(self, list comp_names)
predef_comp(self, str comp_name)
def_couple(self, str src_comp, str src_grid, src_field, str tgt_comp, str tgt_grid, tgt_field, str coupling_timestep, TimeUnit timeunit, Reduction time_reduction, interp_stack, src_lag=0, tgt_lag=0, weight_file=None, WeightFileOnExisting weight_file_on_existing=WeightFileOnExisting.OVERWRITE, mapping_on_source=1, scale_factor=1.0, scale_summand=0.0, src_masks_names=None, tgt_mask_name=None, yaxt_exchanger_name=None, collection_selection=None, use_raw_exchange=False)
get_grid_metadata(self, str grid_name)
def_component_metadata(self, str comp_name, bytes metadata)
def_field_metadata(self, str comp_name, str grid_name, str field_name, bytes metadata)
def_grid_metadata(self, str grid_name, bytes metadata)
get_field_metadata(self, str comp_name, str grid_name, str field_name)
get_comps_comm(self, comp_names)
get_field_names(self, str comp_name, str grid_name)
get_field_id(self, str comp_name, str grid_name, str field_name)
def_comps(self, comp_names=[])
size(self)
number of processes in this instance
set_grid_output_file(self, str gridname, str filename)
get_component(self, str comp_name)
get_component_metadata(self, str comp_name)
def_datetime(self, start_datetime, end_datetime)
get_field_role(self, str comp_name, str grid_name, str field_name)
get_field_source(self, str comp_name, str grid_name, str field_name)
enable_field_frac_mask(self, str comp_name, str grid_name, str field_name, _np.float64 frac_mask_fallback_value)
get_comp_grid_names(self, comp_name)
rank(self)
process index in this instance
get_field_timestep(self, str comp_name, str grid_name, str field_name)
get_field(self, str comp_name, str grid_name, str field_name)
get_field_frac_mask_fallback_value(self, str comp_name, str grid_name, str field_name)
__init__(self, comm=None, default_instance=False)
set_grids_output_file(self, str filename)
get_field_collection_size(self, str comp_name, str grid_name, str field_name)
set_config_output_file(self, str filename, ConfigOutputFormat fileformat, ConfigOutputSyncLoc sync_location, bool include_definitions=False)
default_instance_id_defined
def_points(self, Location location, x_points, y_points, name=None)
__get__(self, cls, owner)
mpi_handshake_group_name()
def_calendar(Calendar calendar)
_yac_excepthook(typ, value, tb)
int yac_cget_points_id(int grid_id, int location, const char *point_name)
void yac_ccompute_grid_cell_areas(int grid_id, double *cell_areas)
void yac_cadd_interp_stack_config_ncc(int interp_stack_config_id, int weight_type, int partial_coverage)
const char * yac_cget_field_metadata_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name)
void yac_cget_instance_size_c2py(int yac_instance_id, int *size)
void yac_cset_global_index_yac_int(yac_int const *global_index, int location, int grid_id)
void yac_cpredef_comp_instance(int yac_instance_id, char const *name, int *comp_id)
char * yac_cget_start_datetime_instance(int yac_instance_id)
void yac_cdef_field_mask(char const *name, int const comp_id, int const *point_ids, int const *mask_ids, int const num_pointsets, int collection_size, const char *timestep, int time_unit, int *field_id)
void yac_cset_grid_output_file_instance(int yac_instance_id, const char *gridname, const char *filename)
void yac_cget_(int const field_id, int const collection_size, double *recv_field, int *info, int *ierr)
int yac_cget_nbr_grids_instance(int yac_instance_id)
void yac_cfree_ext_couple_config(int ext_couple_config_id)
const char * yac_cget_grid_metadata_instance(int yac_instance_id, const char *grid_name)
char * yac_cget_end_datetime_instance(int yac_instance_id)
void yac_cadd_interp_stack_config_user_file_2(int interp_stack_config_id, char const *filename, int on_missing_file, int on_succes)
void yac_cset_ext_couple_config_tgt_mask_name(int ext_couple_config_id, char const *tgt_mask_name)
void yac_cdef_grid_curve2d(const char *grid_name, int nbr_vertices[2], int cyclic[2], double *x_vertices, double *y_vertices, int *grid_id)
void yac_cget_grid_names_instance(int yac_instance_id, int nbr_grids, const char **grid_names)
void yac_cset_ext_couple_config_scale_factor(int ext_couple_config_id, double scale_factor)
void yac_cset_ext_couple_config_weight_file_on_existing(int ext_couple_config_id, int weight_file_on_existing)
void yac_cadd_interp_stack_config_creep(int interp_stack_config_id, int creep_distance)
void yac_cput_frac_(int const field_id, int const collection_size, double *send_field, double *send_frac_mask, int *info, int *ierr)
void yac_cget_comp_rank_c2py(int comp_id, int *rank)
void yac_cdef_points_curve2d_named(int const grid_id, int const *nbr_points, int const located, double const *x_points, double const *y_points, char const *name, int *point_id)
void yac_cset_grids_output_file_instance(int yac_instance_id, const char *filename)
void yac_cget_comp_size_c2py(int comp_id, int *size)
int yac_cget_comp_nbr_grids_instance(int yac_instance_id, const char *comp_name)
void yac_cdef_grid_unstruct_ll(const char *grid_name, int nbr_vertices, int nbr_cells, int *num_vertices_per_cell, double *x_vertices, double *y_vertices, int *cell_to_vertex, int *grid_id)
void yac_cdef_points_reg2d_rot_named(int const grid_id, int const *nbr_points, int const located, double const *x_points, double const *y_points, double x_north_pole, double y_north_pole, char const *name, int *point_id)
void yac_csync_def_instance(int yac_instance_id)
void yac_cget_interp_stack_config_from_string_json(char const *interp_stack_config, int *interp_stack_config_id)
void yac_cdef_grid_reg2d_rot(const char *grid_name, int nbr_vertices[2], int cyclic[2], double *x_vertices, double *y_vertices, double x_north_pole, double y_north_pole, int *grid_id)
void yac_cget_raw_(int const field_id, int const collection_size, double *src_field_buffer, int *info, int *ierr)
void yac_cfinalize()
Finalises YAC.
void yac_cadd_interp_stack_config_check(int interp_stack_config_id, char const *constructor_key, char const *do_search_key)
void yac_cenddef_instance(int yac_instance_id)
void yac_cset_ext_couple_config_src_mask_names(int ext_couple_config_id, size_t num_src_mask_names, char const *const *src_mask_names)
void yac_cget_raw_async_(int const field_id, int const collection_size, double *src_field_buffer, int *info, int *ierr)
int yac_cget_nbr_comps_instance(int yac_instance_id)
void yac_cdef_points_unstruct_named(int const grid_id, int const nbr_points, int const located, double const *x_points, double const *y_points, char const *name, int *point_id)
int yac_cget_nbr_fields_instance(int yac_instance_id, const char *comp_name, const char *grid_name)
void yac_cset_coordinates_mismatch_is_fatal_instance(int yac_instance_id, int is_fatal)
void yac_cget_ext_couple_config(int *ext_couple_config_id)
const char * yac_cget_mpi_handshake_group_name(void)
Retrieve the MPI handshake group name used by YAC.
void yac_cdef_grid_unstruct_edge(const char *grid_name, int nbr_vertices, int nbr_cells, int nbr_edges, int *num_edges_per_cell, double *x_vertices, double *y_vertices, int *cell_to_edge, int *edge_to_vertex, int *grid_id)
void yac_cdef_points_reg2d_named(int const grid_id, int const *nbr_points, int const located, double const *x_points, double const *y_points, char const *name, int *point_id)
void yac_cdef_grid_metadata_instance(int yac_instance_id, const char *grid_name, const char *metadata)
void yac_cset_ext_couple_config_weight_file(int ext_couple_config_id, char const *weight_file)
const char * yac_cget_component_metadata_instance(int yac_instance_id, const char *comp_name)
void yac_cread_config_yaml_instance(int yac_instance_id, const char *yaml_filename)
void yac_cset_ext_couple_config_yaxt_exchanger_name(int ext_couple_config_id, char const *yaxt_exchanger_name)
const char * yac_cget_field_timestep_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name)
void yac_cset_ext_couple_config_scale_summand(int ext_couple_config_id, double scale_summand)
void yac_cget_comp_comm(int comp_id, MPI_Comm *comp_comm)
const char * yac_cget_field_datetime(int field_id)
void yac_cdef_comp_instance(int yac_instance_id, char const *comp_name, int *comp_id)
void yac_cupdate(int field_id)
void yac_cget_action(int field_id, int *action)
void yac_cexchange_(int const send_field_id, int const recv_field_id, int const collection_size, double *send_field, double *recv_field, int *send_info, int *recv_info, int *ierr)
int yac_cget_collection_size_from_field_id(int field_id)
void yac_cdef_grid_reg2d(const char *grid_name, int nbr_vertices[2], int cyclic[2], double *x_vertices, double *y_vertices, int *grid_id)
int yac_cget_comp_id_instance(int yac_instance_id, const char *comp_name)
int yac_cdefault_instance_defined(void)
void yac_cdef_couple_custom_instance(int yac_instance_id, char const *src_comp_name, char const *src_grid_name, char const *src_field_name, char const *tgt_comp_name, char const *tgt_grid_name, char const *tgt_field_name, char const *coupling_timestep, int time_unit, int time_reduction, int interp_stack_config_id, int src_lag, int tgt_lag, int ext_couple_config_id)
void yac_cset_ext_couple_config_use_raw_exchange(int ext_couple_config_id, int use_raw_exchange)
int yac_cget_grid_id(const char *grid_name)
void yac_cset_config_output_file_instance(int yac_instance_id, const char *filename, int fileformat, int sync_location, int include_definitions)
void yac_cinit_comm_instance(MPI_Comm comm, int *yac_instance_id)
void yac_cget_instance_rank_c2py(int yac_instance_id, int *rank)
void yac_cenable_field_frac_mask_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name, double frac_mask_fallback_value)
void yac_cget_interp_stack_config_from_string_yaml(char const *interp_stack_config, int *interp_stack_config_id)
void yac_cadd_interp_stack_config_conservative(int interp_stack_config_id, int order, int enforced_conserv, int partial_coverage, int normalisation)
void yac_cdef_grid_unstruct(const char *grid_name, int nbr_vertices, int nbr_cells, int *num_vertices_per_cell, double *x_vertices, double *y_vertices, int *cell_to_vertex, int *grid_id)
char * yac_cget_version(void)
int yac_cget_default_instance_id()
void yac_cexchange_frac_(int const send_field_id, int const recv_field_id, int const collection_size, double *send_field, double *send_frac_mask, double *recv_field, int *send_info, int *recv_info, int *ierr)
void yac_cdef_component_metadata_instance(int yac_instance_id, const char *comp_name, const char *metadata)
void yac_cdef_calendar(int calendar)
void yac_cget_raw_frac_async_(int const field_id, int const collection_size, double *src_field_buffer, double *src_frac_mask_buffer, int *info, int *ierr)
void yac_cset_coordinates_check_instance(int yac_instance_id, int apply_check)
void yac_cadd_interp_stack_config_rbf(int interp_stack_config_id, size_t n, double max_search_distance, double scale)
int yac_cget_mask_id(int grid_id, int location, const char *mask_name)
void yac_cget_raw_frac_(int const field_id, int const collection_size, double *src_field_buffer, double *src_frac_mask_buffer, int *info, int *ierr)
void yac_cput_(int const field_id, int const collection_size, double *send_field, int *info, int *ierr)
void yac_cget_comp_grid_names_instance(int yac_instance_id, const char *comp_name, int nbr_grids, const char **grid_names)
void yac_cget_async_(int const field_id, int const collection_size, double *recv_field, int *info, int *ierr)
void yac_cadd_interp_stack_config_hcsbb(int interp_stack_config_id)
void yac_cget_comps_comm_instance(int yac_instance_id, char const **comp_names, int num_comps, MPI_Comm *comps_comm)
void yac_cadd_interp_stack_config_fixed(int interp_stack_config_id, double value)
double yac_cget_field_frac_mask_fallback_value_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name)
void yac_cget_field_source_instance(int yac_instance_id, const char *tgt_comp_name, const char *tgt_grid_name, const char *tgt_field_name, const char **src_comp_name, const char **src_grid_name, const char **src_field_name)
void yac_cadd_interp_stack_config_spmap(int interp_stack_config_id, double spread_distance, double max_search_distance, int weight_type, int scale_type, double src_sphere_radius, char const *src_filename, char const *src_varname, int src_min_global_id, double tgt_sphere_radius, char const *tgt_filename, char const *tgt_varname, int tgt_min_global_id)
void yac_cdef_grid_unstruct_edge_ll(const char *grid_name, int nbr_vertices, int nbr_cells, int nbr_edges, int *num_edges_per_cell, double *x_vertices, double *y_vertices, int *cell_to_edge, int *edge_to_vertex, int *grid_id)
void yac_cset_ext_couple_config_mapping_side(int ext_couple_config_id, int mapping_side)
void yac_ccleanup_instance(int yac_instance_id)
Clean-up a YAC instance (see Restarting YAC)
int yac_cget_field_collection_size_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name)
void yac_cfree_interp_stack_config(int interp_stack_config_id)
void yac_cadd_interp_stack_config_nnn(int interp_stack_config_id, int type, size_t n, double max_search_distance, double scale)
size_t yac_cget_grid_size(int located, int grid_id)
void yac_cinit_instance(int *yac_instance_id)
void yac_cget_interp_stack_config(int *interp_stack_config_id)
void yac_cset_ext_couple_config_collection_selection(int ext_couple_config_id, int collection_size, int const *collection_indices)
void yac_cadd_interp_stack_config_average(int interp_stack_config_id, int reduction_type, int partial_coverage)
void yac_cdef_field(char const *name, int const comp_id, int const *point_ids, int const num_pointsets, int collection_size, const char *timestep, int time_unit, int *field_id)
void yac_csync_def_comps_instance(int yac_instance_id, char const **comp_names, int num_comp_names)
void yac_cdef_field_metadata_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name, const char *metadata)
void yac_cadd_interp_stack_config_dnn(int interp_stack_config_id, int weight_type, int search_distance_type, double search_distance, double scale)
void yac_cget_field_names_instance(int yac_instance_id, const char *comp_name, const char *grid_name, int nbr_fields, const char **field_names)
void yac_cdef_comps_instance(int yac_instance_id, char const **comp_names, int num_comps, int *comp_ids)
void yac_cget_comp_names_instance(int yac_instance_id, int nbr_comps, const char **comp_names)
void yac_cinit_comm(MPI_Comm comm)
yac_abort_func yac_get_abort_handler(void)
void yac_set_abort_handler(yac_abort_func custom_abort)