示例#1
0
文件: cis_main.py 项目: cedadev/cis
def stats_cmd(main_arguments):
    """
    Main routine for handling calls to the statistics command.

    :param main_arguments: The command line arguments (minus the stats command)
    """
    from cis.stats import StatsAnalyzer
    from cis.data_io.gridded_data import GriddedDataList
    data_reader = DataReader()
    data_list = data_reader.read_datagroups(main_arguments.datagroups)
    analyzer = StatsAnalyzer(*data_list)
    results = analyzer.analyze()
    header = "RESULTS OF STATISTICAL COMPARISON:"
    note = "Compared all points which have non-missing values in both variables"
    header_length = max(len(header), len(note))
    print(header_length * '=')
    print(header)
    print(header_length * '-')
    print(note)
    print(header_length * '=')
    for result in results:
        print(result.pprint())
    if main_arguments.output:
        cubes = GriddedDataList([result.as_cube() for result in results])
        variables = []
        filenames = []
        for datagroup in main_arguments.datagroups:
            variables.extend(datagroup['variables'])
            filenames.extend(datagroup['filenames'])
        history = "Statistical comparison performed using CIS version " + __version__ + \
                  "\n variables: " + str(variables) + \
                  "\n from files: " + str(set(filenames))
        cubes.add_history(history)
        cubes.save_data(main_arguments.output)
示例#2
0
def stats_cmd(main_arguments):
    """
    Main routine for handling calls to the statistics command.

    :param main_arguments: The command line arguments (minus the stats command)
    """
    from cis.stats import StatsAnalyzer
    from cis.data_io.gridded_data import GriddedDataList
    data_reader = DataReader()
    data_list = data_reader.read_datagroups(main_arguments.datagroups)
    analyzer = StatsAnalyzer(*data_list)
    results = analyzer.analyze()
    header = "RESULTS OF STATISTICAL COMPARISON:"
    note = "Compared all points which have non-missing values in both variables"
    header_length = max(len(header), len(note))
    print(header_length * '=')
    print(header)
    print(header_length * '-')
    print(note)
    print(header_length * '=')
    for result in results:
        print(result.pprint())
    if main_arguments.output:
        cubes = GriddedDataList([result.as_cube() for result in results])
        variables = []
        filenames = []
        for datagroup in main_arguments.datagroups:
            variables.extend(datagroup['variables'])
            filenames.extend(datagroup['filenames'])
        history = "Statistical comparison performed using CIS version " + __version__ + \
                  "\n variables: " + str(variables) + \
                  "\n from files: " + str(set(filenames))
        cubes.add_history(history)
        cubes.save_data(main_arguments.output)
示例#3
0
 def test_gridded_list_write_no_time_has_no_unlimited_dimension(self):
     data = GriddedDataList([make_from_cube(make_mock_cube())])
     data[0].var_name = 'rain'
     data.save_data(tmp_file)
     self.d = Dataset(tmp_file)
     for d in self.d.dimensions.values():
         assert not d.isunlimited()
示例#4
0
 def test_gridded_list_write_time_as_unlimited_dimension(self):
     data = GriddedDataList(
         [make_from_cube(make_mock_cube(time_dim_length=7))])
     data[0].var_name = 'rain'
     data.save_data(tmp_file)
     self.d = Dataset(tmp_file)
     assert self.d.dimensions['time'].isunlimited()
示例#5
0
 def test_gridded_list_write_no_time_has_no_unlimited_dimension(self):
     data = GriddedDataList([make_from_cube(make_mock_cube())])
     data[0].var_name = 'rain'
     data.save_data(tmp_file)
     self.d = Dataset(tmp_file)
     for d in self.d.dimensions.values():
         assert not d.isunlimited()
示例#6
0
 def test_gridded_list_write_time_as_unlimited_dimension(self):
     data = GriddedDataList([make_from_cube(make_mock_cube(time_dim_length=7))])
     data[0].var_name = 'rain'
     data.save_data(tmp_file)
     self.d = Dataset(tmp_file)
     assert self.d.dimensions['time'].isunlimited()