Esempio n. 1
0
def aggregate_cmd(main_arguments):
    """
    Main routine for handling calls to the aggregation command.

    :param main_arguments: The command line arguments (minus the aggregate command)
    """
    import cis.exceptions as ex
    from cis.data_io.gridded_data import GriddedDataList

    if len(main_arguments.datagroups) > 1:
        __error_occurred("Aggregation can only be performed on one data group")
    input_group = main_arguments.datagroups[0]

    data = DataReader().read_single_datagroup(input_group)

    if isinstance(data, GriddedDataList):
        logging.warning("The aggregate command is deprecated for GriddedData and will not be supported in future "
                        "versions of CIS. Please use 'collapse' instead.")
        if any(v is not None for v in main_arguments.grid.values()):
            raise ex.InvalidCommandLineOptionError("Grid specifications are not supported for Gridded aggregation.")
        output = data.collapsed(list(main_arguments.grid.keys()), how=input_group.get("kernel", ''))
    else:
        output = data.aggregate(how=input_group.get("kernel", ''), **main_arguments.grid)

    output.save_data(main_arguments.output)
Esempio n. 2
0
def aggregate_cmd(main_arguments):
    """
    Main routine for handling calls to the aggregation command.

    :param main_arguments: The command line arguments (minus the aggregate command)
    """
    import cis.exceptions as ex
    from cis.data_io.gridded_data import GriddedDataList

    if len(main_arguments.datagroups) > 1:
        __error_occurred("Aggregation can only be performed on one data group")
    input_group = main_arguments.datagroups[0]

    data = DataReader().read_single_datagroup(input_group)

    if isinstance(data, GriddedDataList):
        logging.warning(
            "The aggregate command is deprecated for GriddedData and will not be supported in future "
            "versions of CIS. Please use 'collapse' instead.")
        if any(v is not None for v in main_arguments.grid.values()):
            raise ex.InvalidCommandLineOptionError(
                "Grid specifications are not supported for Gridded aggregation."
            )
        output = data.collapsed(list(main_arguments.grid.keys()),
                                how=input_group.get("kernel", ''))
    else:
        output = data.aggregate(how=input_group.get("kernel", ''),
                                **main_arguments.grid)

    output.save_data(main_arguments.output)
Esempio n. 3
0
def collapse_cmd(main_arguments):
    """
    Main routine for handling calls to the collapse command.

    :param main_arguments: The command line arguments (minus the collapse command)
    """
    from cis.data_io.ungridded_data import UngriddedDataList

    if len(main_arguments.datagroups) > 1:
        __error_occurred("Collapse can only be performed on one data group")
    input_group = main_arguments.datagroups[0]

    data = DataReader().read_single_datagroup(input_group)

    if isinstance(data, UngriddedDataList):
        logging.error("The collapse command can only be performed on gridded data. "
                      "Please use 'aggregate' instead.")

    output = data.collapsed(main_arguments.dimensions, how=input_group.get("kernel", ''))

    output.save_data(main_arguments.output)
Esempio n. 4
0
def collapse_cmd(main_arguments):
    """
    Main routine for handling calls to the collapse command.

    :param main_arguments: The command line arguments (minus the collapse command)
    """
    from cis.data_io.ungridded_data import UngriddedDataList

    if len(main_arguments.datagroups) > 1:
        __error_occurred("Collapse can only be performed on one data group")
    input_group = main_arguments.datagroups[0]

    data = DataReader().read_single_datagroup(input_group)

    if isinstance(data, UngriddedDataList):
        logging.error(
            "The collapse command can only be performed on gridded data. "
            "Please use 'aggregate' instead.")

    output = data.collapsed(main_arguments.dimensions,
                            how=input_group.get("kernel", ''))

    output.save_data(main_arguments.output)