ai2cm / pace

Implementation of the FV3GFS / SHiELD atmospheric model in Python
https://ai2cm.github.io/pace/
Apache License 2.0
37 stars 12 forks source link

DaCe cannot parse quantity.transpose #389

Closed elynnwu closed 1 year ago

elynnwu commented 1 year ago

For select checkpoints, we do quantity.transpose to match with data on disk. However, DaCe cannot parse transpose.

VERBOSE: Failed to parse the following program:
def transpose(self, target_dims: Sequence[Union[str, Iterable[str]]]) -> 'Quantity':
    'Change the dimension order of this Quantity.\n\n    If you know you are working with cell-centered variables, you can do:\n\n    >>> from pace.util import X_DIM, Y_DIM, Z_DIM\n    >>> transposed_quantity = quantity.transpose([X_DIM, Y_DIM, Z_DIM])\n\n    To support re-ordering without checking whether quantities are on\n    cell centers or interfaces, the API supports giving a list of dimension names\n    for dimensions. For example, to re-order to X-Y-Z dimensions regardless of the\n    grid the variable is on, one could do:\n\n    >>> from pace.util import X_DIMS, Y_DIMS, Z_DIMS\n    >>> transposed_quantity = quantity.transpose([X_DIMS, Y_DIMS, Z_DIMS])\n\n    Args:\n        target_dims: a list of output dimensions. Instead of a single dimension\n            name, an iterable of dimensions can be used instead for any entries.\n            For example, you may want to use pace.util.X_DIMS to place an\n            x-dimension without knowing whether it is on cell centers or interfaces.\n\n    Returns:\n        transposed: Quantity with the requested output dimension order\n\n    Raises:\n        ValueError: if any of the target dimensions do not exist on this Quantity,\n            or if this Quantity contains multiple values from an iterable entry\n    '
    target_dims = <dace.frontend.python.parser.DaceProgram object at 0x15544cac7bb0>(target_dims, ('x', 'y', 'z_interface'))
    transpose_order = [self_dims_index(dim) for dim in target_dims]
    transposed = Quantity_0(<dace.frontend.python.parser.DaceProgram object at 0x15544cf872e0>(__g_self_data, transpose_order), dims=<dace.frontend.python.parser.DaceProgram object at 0x15544529c040>(('x', 'y', 'z_interface'), transpose_order), units='ln(Pa)', origin=<dace.frontend.python.parser.DaceProgram object at 0x15544cbce820>((3, 3, 0), transpose_order), extent=<dace.frontend.python.parser.DaceProgram object at 0x155447383910>((12, 12, 80), transpose_order), gt4py_backend='dace:gpu')
    transposed._attrs = self._attrs
    return transposed