예제 #1
0
    def setUp(self):
        self.full_evaluation = Evaluation(
            _create_fake_dataset('Ref'),
            [_create_fake_dataset('T1'), _create_fake_dataset('T2')],
            [metrics.TemporalStdDev(), metrics.Bias(), metrics.Bias()]
        )

        self.unary_evaluation = Evaluation(
            None,
            [_create_fake_dataset('T1'), _create_fake_dataset('T2')],
            [metrics.TemporalStdDev()]
        )
예제 #2
0
 def setUp(self):
     self.temporal_std_dev = metrics.TemporalStdDev()
     # Initialize target dataset
     self.target_lat = np.array([10, 12, 14, 16, 18])
     self.target_lon = np.array([100, 102, 104, 106, 108])
     self.target_time = np.array(
         [dt.datetime(2000, x, 1) for x in range(1, 13)])
     flat_array = np.array(range(300))
     self.target_value = flat_array.reshape(12, 5, 5)
     self.target_variable = 'prec'
     self.target_dataset = Dataset(self.target_lat, self.target_lon,
                                   self.target_time, self.target_value,
                                   self.target_variable)
예제 #3
0
urllib.urlretrieve(FILE_LEADER + FILE_1, FILE_1)
""" Step 1: Load Local NetCDF File into OCW Dataset Objects """
print "Loading %s into an OCW Dataset Object" % (FILE_1, )
# 'tasmax' is variable name of values
knmi_dataset = local.load_file(FILE_1, "tasmax")

print "KNMI_Dataset.values shape: (times, lats, lons) - %s \n" % (
    knmi_dataset.values.shape, )

# Acessing latittudes and longitudes of netCDF file
lats = knmi_dataset.lats
lons = knmi_dataset.lons
""" Step 2:  Build a Metric to use for Evaluation - Temporal STD for this example """
# You can build your own metrics, but OCW also ships with some common metrics
print "Setting up a Temporal STD metric to use for evaluation"
std = metrics.TemporalStdDev()
""" Step 3: Create an Evaluation Object using Datasets and our Metric """
# The Evaluation Class Signature is:
# Evaluation(reference, targets, metrics, subregions=None)
# Evaluation can take in multiple targets and metrics, so we need to convert
# our examples into Python lists.  Evaluation will iterate over the lists
print "Making the Evaluation definition"
# Temporal STD Metric gets one target dataset then reference dataset should be None
std_evaluation = evaluation.Evaluation(None, [knmi_dataset], [std])
print "Executing the Evaluation using the object's run() method"
std_evaluation.run()
""" Step 4: Make a Plot from the Evaluation.results """
# The Evaluation.results are a set of nested lists to support many different
# possible Evaluation scenarios.
#
# The Evaluation results docs say:
예제 #4
0
    def setUpClass(self):
        self.lats = np.array([10, 12, 14, 16, 18])
        self.lons = np.array([100, 102, 104, 106, 108])
        self.times = np.array([dt.datetime(2000, x, 1) for x in range(1, 13)])
        flat_array = np.array(range(300))
        self.values = flat_array.reshape(12, 5, 5)
        self.variable = 'var'
        self.units = 'units'
        self.name = 'name'

        self.local_origin = {
            'source': 'local',
            'path': '/a/fake/path.nc',
            'lat_name': 'a lat name',
            'lon_name': 'a lon name',
            'time_name': 'a time name',
            'elevation_index': 2
        }

        self.rcmed_origin = {
            'source': 'rcmed',
            'dataset_id': 4,
            'parameter_id': 14
        }

        self.esgf_origin = {
            'source': 'esgf',
            'dataset_id': 'esgf dataset id',
            'variable': 'var'
        }

        self.dap_origin = {
            'source': 'dap',
            'url': 'a fake url',
        }

        self.local_ds = Dataset(self.lats,
                                self.lons,
                                self.times,
                                self.values,
                                variable=self.variable,
                                units=self.units,
                                name=self.name,
                                origin=self.local_origin)

        self.rcmed_ds = Dataset(self.lats,
                                self.lons,
                                self.times,
                                self.values,
                                variable=self.variable,
                                units=self.units,
                                name=self.name,
                                origin=self.rcmed_origin)

        self.esgf_ds = Dataset(self.lats,
                               self.lons,
                               self.times,
                               self.values,
                               variable=self.variable,
                               units=self.units,
                               name=self.name,
                               origin=self.esgf_origin)

        self.dap_ds = Dataset(self.lats,
                              self.lons,
                              self.times,
                              self.values,
                              variable=self.variable,
                              units=self.units,
                              name=self.name,
                              origin=self.dap_origin)

        self.subregions = [
            Bounds(lat_min=-10, lat_max=10, lon_min=-20, lon_max=20),
            Bounds(lat_min=-5, lat_max=5, lon_min=-15, lon_max=15)
        ]

        self.evaluation = Evaluation(
            self.local_ds, [self.rcmed_ds, self.esgf_ds, self.dap_ds],
            [metrics.Bias(), metrics.TemporalStdDev()],
            subregions=self.subregions)
예제 #5
0
    def setUpClass(self):
        self.bias = metrics.Bias()
        self.tmp_std_dev = metrics.TemporalStdDev()
        loaded_metrics = [self.bias, self.tmp_std_dev]

        self.evaluation = Evaluation(None, [], loaded_metrics)