示例#1
0
    def __setitem__(self, keys, arr):
        var, var_slice = parse_keys(keys)

        if var == 'meta':
            self.meta = arr
        else:
            self._set_var_array(var, arr, *var_slice)
示例#2
0
    def __getitem__(self, keys):
        ds, ds_slice = parse_keys(keys)

        if ds.lower().startswith('lat'):
            out = self._get_latitude(*ds_slice)
        elif ds.lower().startswith('lon'):
            out = self._get_longitude(*ds_slice)
        else:
            out = self._get_layer(ds, *ds_slice)

        return out
示例#3
0
    def __getitem__(self, keys):
        ds, ds_slice = parse_keys(keys)

        if ds.endswith('time_index'):
            out = self.h5.h5._get_time_index(ds_slice)
        elif ds.endswith('meta'):
            out = self.h5.h5._get_meta(ds, ds_slice)
        elif ds.endswith('coordinates'):
            out = self.h5.h5._get_coords(ds, ds_slice)
        else:
            out = self.h5._get_ds(ds, ds_slice)

        return out
示例#4
0
文件: outputs.py 项目: clhughes/reV
    def __setitem__(self, keys, arr):
        if self.writable:
            ds, ds_slice = parse_keys(keys)

            slice_test = False
            if isinstance(ds_slice, tuple):
                slice_test = ds_slice[0] == slice(None, None, None)

            if ds.endswith('meta') and slice_test:
                self._set_meta(ds, arr)
            elif ds.endswith('time_index') and slice_test:
                self._set_time_index(ds, arr)
            else:
                self._set_ds_array(ds, arr, ds_slice)
示例#5
0
文件: outputs.py 项目: clhughes/reV
    def __getitem__(self, keys):
        ds, ds_slice = parse_keys(keys)
        if ds in self.datasets:
            if ds.endswith('time_index'):
                out = self._get_time_index(ds, ds_slice)
            elif ds.endswith('meta'):
                out = self._get_meta(ds, ds_slice)
            else:
                out = self._get_ds(ds, ds_slice)
        else:
            msg = '{} is not a valid Dataset'.format(ds)
            raise HandlerKeyError(msg)

        return out
示例#6
0
    def __getitem__(self, keys):
        ds, ds_slice = parse_keys(keys)
        _, ds_name = os.path.split(ds)
        if 'SAM' in ds_name:
            site = ds_slice[0]
            if isinstance(site, (int, np.integer)):
                _, height = self._parse_name(ds_name)
                out = self.get_SAM_df(site, height)
            else:
                msg = "Can only extract SAM DataFrame for a single site"
                raise ResourceRuntimeError(msg)
        else:
            out = super().__getitem__(keys)

        return out
示例#7
0
    def __getitem__(self, keys):
        ds, ds_slice = parse_keys(keys)

        if ds.endswith('time_index'):
            out = self._get_time_index(ds, ds_slice)
        elif ds.endswith('meta'):
            out = self._get_meta(ds, ds_slice)
        elif 'SAM' in ds:
            site = ds_slice[0]
            if isinstance(site, int):
                out = self._get_SAM_df(ds, site)
            else:
                msg = "Can only extract SAM DataFrame for a single site"
                raise ResourceRuntimeError(msg)
        else:
            out = self._get_ds(ds, ds_slice)

        return out
示例#8
0
文件: resource.py 项目: NREL/rex
    def __getitem__(self, keys):
        ds, ds_slice = parse_keys(keys)
        _, ds_name = os.path.split(ds)
        if ds_name.startswith('time_index'):
            out = self._get_time_index(ds, ds_slice)
        elif ds_name.startswith('meta'):
            out = self._get_meta(ds, ds_slice)
        elif ds_name.startswith('coordinates'):
            out = self._get_coords(ds, ds_slice)
        elif 'SAM' in ds_name:
            site = ds_slice[0]
            if isinstance(site, (int, np.integer)):
                out = self.get_SAM_df(site)  # pylint: disable=E1111
            else:
                msg = "Can only extract SAM DataFrame for a single site"
                raise ResourceRuntimeError(msg)
        else:
            out = self._get_ds(ds, ds_slice)

        return out
示例#9
0
    def __getitem__(self, keys):
        var, var_slice = parse_keys(keys)

        if var == 'time_index':
            out = self.time_index
            out = out[var_slice[0]]
        elif var == 'meta':
            out = self.meta
            out = out.loc[var_slice[0]]
        elif isinstance(var, str):
            if var.startswith('mean_'):
                var = var.lstrip('mean_')
                out = self._get_var_mean(var, *var_slice)
            else:
                out = self._get_var_ts(var, *var_slice)
        elif isinstance(var, int):
            site = var
            out, _ = self._get_res_df(site)
        else:
            msg = 'Cannot interpret {}'.format(var)
            logger.error(msg)
            raise ResourceKeyError(msg)

        return out