當前位置: 首頁>>代碼示例>>Python>>正文


Python xarray.__version__方法代碼示例

本文整理匯總了Python中xarray.__version__方法的典型用法代碼示例。如果您正苦於以下問題:Python xarray.__version__方法的具體用法?Python xarray.__version__怎麽用?Python xarray.__version__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在xarray的用法示例。


在下文中一共展示了xarray.__version__方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: write_index

# 需要導入模塊: import xarray [as 別名]
# 或者: from xarray import __version__ [as 別名]
def write_index():
    """This is to write the docs for the index automatically."""

    here = os.path.dirname(__file__)
    filename = os.path.join(here, '_generated', 'version_text.txt')

    try:
        os.makedirs(os.path.dirname(filename))
    except FileExistsError:
        pass

    text = text_version if '+' not in oggm.__version__ else text_dev

    with open(filename, 'w') as f:
        f.write(text) 
開發者ID:OGGM,項目名稱:oggm,代碼行數:17,代碼來源:conf.py

示例2: _get_versions

# 需要導入模塊: import xarray [as 別名]
# 或者: from xarray import __version__ [as 別名]
def _get_versions(requirements=True):
    if requirements:
        import matplotlib as mpl
        import xarray as xr
        import pandas as pd
        import numpy as np
        return {'version': __version__,
                'requirements': {'matplotlib': mpl.__version__,
                                 'xarray': xr.__version__,
                                 'pandas': pd.__version__,
                                 'numpy': np.__version__,
                                 'python': ' '.join(sys.version.splitlines())}}
    else:
        return {'version': __version__} 
開發者ID:psyplot,項目名稱:psyplot,代碼行數:16,代碼來源:__init__.py

示例3: _add_path_to_ds

# 需要導入模塊: import xarray [as 別名]
# 或者: from xarray import __version__ [as 別名]
def _add_path_to_ds(self, ds):
        """Adding path info to a coord for a particular file
        """
        import xarray as xr
        XARRAY_VERSION = LooseVersion(xr.__version__)
        if not (XARRAY_VERSION > '0.11.1'):
            raise ImportError("Your version of xarray is '{}'. "
                "The insurance that source path is available on output of "
                "open_dataset was added in 0.11.2, so "
                "pattern urlpaths are not supported.".format(XARRAY_VERSION))

        var = next(var for var in ds)
        new_coords = reverse_format(self.pattern, ds[var].encoding['source'])
        return ds.assign_coords(**new_coords) 
開發者ID:intake,項目名稱:intake-xarray,代碼行數:16,代碼來源:netcdf.py

示例4: old_xarray

# 需要導入模塊: import xarray [as 別名]
# 或者: from xarray import __version__ [as 別名]
def old_xarray():
    import xarray as xr
    version = xr.__version__
    try:
        xr.__version__ = "0.1"
        yield
    finally:
        xr.__version__ = version 
開發者ID:intake,項目名稱:intake-xarray,代碼行數:10,代碼來源:test_intake_xarray.py

示例5: resolve_name

# 需要導入模塊: import xarray [as 別名]
# 或者: from xarray import __version__ [as 別名]
def resolve_name(self, modname, parents, path, base):
        if modname is None:
            if path:
                mod_cls = path.rstrip(".")
            else:
                mod_cls = None
                # if documenting a class-level object without path,
                # there must be a current class, either from a parent
                # auto directive ...
                mod_cls = self.env.temp_data.get("autodoc:class")
                # ... or from a class directive
                if mod_cls is None:
                    mod_cls = self.env.temp_data.get("py:class")
                # ... if still None, there's no way to know
                if mod_cls is None:
                    return None, []
            # HACK: this is added in comparison to ClassLevelDocumenter
            # mod_cls still exists of class.accessor, so an extra
            # rpartition is needed
            modname, accessor = rpartition(mod_cls, ".")
            modname, cls = rpartition(modname, ".")
            parents = [cls, accessor]
            # if the module name is still missing, get it like above
            if not modname:
                modname = self.env.temp_data.get("autodoc:module")
            if not modname:
                if sphinx.__version__ > "1.3":
                    modname = self.env.ref_context.get("py:module")
                else:
                    modname = self.env.temp_data.get("py:module")
            # ... else, it stays None, which means invalid
        return modname, parents + [base] 
開發者ID:benbovy,項目名稱:xarray-simlab,代碼行數:34,代碼來源:conf.py

示例6: open_odim

# 需要導入模塊: import xarray [as 別名]
# 或者: from xarray import __version__ [as 別名]
def open_odim(paths, loader="netcdf4", **kwargs):
    """Open multiple ODIM files as a XRadVolume structure.

    Parameters
    ----------
    paths : str or sequence
        Either a filename or string glob in the form `'path/to/my/files/*.h5'`
        or an explicit list of files to open.

    loader : {'netcdf4', 'h5py', 'h5netcdf'}
        Loader used for accessing file metadata, defaults to 'netcdf4'.

    kwargs : optional
        Additional arguments passed on to :py:class:`wradlib.io.XRadSweep`.
    """
    if (loader == "h5netcdf") & (
        LooseVersion(h5netcdf.__version__) < LooseVersion("0.8.0")
    ):
        warnings.warn(
            f"WRADLIB: 'h5netcdf>=0.8.0' needed to perform this "
            f"operation. 'h5netcdf={h5netcdf.__version__} "
            f"available.",
            UserWarning,
        )

    if isinstance(paths, str):
        paths = glob.glob(paths)
    else:
        paths = np.array(paths).flatten().tolist()

    if loader not in ["netcdf4", "h5netcdf", "h5py"]:
        raise ValueError("wradlib: Unkown loader: {}".format(loader))

    sweeps = []
    [
        sweeps.extend(_open_odim_sweep(f, loader, **kwargs))
        for f in tqdm(paths, desc="Open", unit=" Files", leave=None)
    ]
    angles = collect_by_angle(sweeps)
    for i in tqdm(range(len(angles)), desc="Collecting", unit=" Angles", leave=None):
        angles[i] = collect_by_time(angles[i])
    angles.sort(key=lambda x: x[0].time)
    for f in angles:
        f._parent = angles
    angles._ncfile = angles[0].ncfile
    angles._ncpath = "/"
    return angles 
開發者ID:wradlib,項目名稱:wradlib,代碼行數:49,代碼來源:xarray.py

示例7: _mask_3D

# 需要導入模塊: import xarray [as 別名]
# 或者: from xarray import __version__ [as 別名]
def _mask_3D(
    outlines,
    regions_is_180,
    numbers,
    lon_or_obj,
    lat=None,
    drop=True,
    lon_name="lon",
    lat_name="lat",
    method=None,
    wrap_lon=None,
):

    mask = _mask(
        outlines=outlines,
        regions_is_180=regions_is_180,
        numbers=numbers,
        lon_or_obj=lon_or_obj,
        lat=lat,
        lon_name=lon_name,
        lat_name=lat_name,
        method=method,
        wrap_lon=wrap_lon,
    )

    isnan = np.isnan(mask.values)

    if drop:
        numbers = np.unique(mask.values[~isnan])
        numbers = numbers.astype(np.int)

    # if no regions are found return a 0 x lat x lon mask
    if len(numbers) == 0:
        mask = mask.expand_dims("region", axis=0).sel(region=slice(0, 0))
        msg = (
            "No gridpoint belongs to any region. Returning an empty mask"
            " with shape {}".format(mask.shape)
        )
        warnings.warn(msg, UserWarning, stacklevel=3)
        return mask

    mask_3D = list()
    for num in numbers:
        mask_3D.append(mask == num)

    from distutils.version import LooseVersion

    # "override" is faster but was only introduced in version 0.13.0 of xarray
    compat = "override" if LooseVersion(xr.__version__) >= "0.13.0" else "equals"

    mask_3D = xr.concat(mask_3D, dim="region", compat=compat, coords="minimal")

    mask_3D = mask_3D.assign_coords(region=("region", numbers))

    if np.all(isnan):
        msg = "No gridpoint belongs to any region. Returning an all-False mask."
        warnings.warn(msg, UserWarning, stacklevel=3)

    return mask_3D 
開發者ID:mathause,項目名稱:regionmask,代碼行數:61,代碼來源:mask.py


注:本文中的xarray.__version__方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。