Exemple #1
0
def test_ocgis_average():
    v1 = TESTDATA['cmip3_tasmin_sresa2_da_nc'][6:]
    v2 = TESTDATA['cmip3_tasmax_sresa2_da_nc'][6:]

    rd1 = RequestDataset(v1)
    rd2 = RequestDataset(v2)

    ops = OcgOperations([rd1, rd2],
                        calc=[{
                            'func': 'average',
                            'name': 'tas',
                            'kwds': {
                                'v1': 'tasmin',
                                'v2': 'tasmax'
                            }
                        }])
    ret = ops.execute()
    t = ret.get_element()['tas'][0, :, :].get_value()

    t1 = rd1.get_field()['tasmin'][0, :, :].get_value()
    t2 = rd2.get_field()['tasmax'][0, :, :].get_value()
    aaae(np.mean([t1, t2], axis=0), t)
Exemple #2
0
    def test_system_parallel_write(self):
        if MPI_RANK == 0:
            in_path = self.get_path_to_template_csv()
            out_path = self.get_temporary_file_path('foo_out.csv')
        else:
            in_path, out_path = [None] * 2

        in_path = MPI_COMM.bcast(in_path)
        out_path = MPI_COMM.bcast(out_path)

        rd = RequestDataset(in_path)
        list(rd.metadata['dimensions'].values())[0]['dist'] = True
        field = rd.get_field()

        with vm.scoped_by_emptyable('vc.write', field):
            if not vm.is_null:
                field.write(out_path, driver=DriverCSV)

        if MPI_RANK == 0:
            self.assertCSVFilesEqual(in_path, out_path)