How to use the siphon.catalog.CaseInsensitiveStr function in siphon

To help you get started, we’ve selected a few siphon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Unidata / siphon / siphon / catalog.py View on Github external
Return an Python object capable of communicating with the server using the particular
        service. For instance, for 'HTTPServer' this is a file-like object capable of
        HTTP communication; for OPENDAP this is a netCDF4 dataset.

        Parameters
        ----------
        service : str
            The name of the service for accessing the dataset

        Returns
        -------
            An instance appropriate for communicating using ``service``.

        """
        service = CaseInsensitiveStr(service)
        if service == 'CdmRemote':
            if use_xarray:
                from .cdmr.xarray_support import CDMRemoteStore
                try:
                    import xarray as xr
                    provider = lambda url: xr.open_dataset(CDMRemoteStore(url))  # noqa: E731
                except ImportError:
                    raise ImportError('CdmRemote access needs xarray to be installed.')
            else:
                from .cdmr import Dataset as CDMRDataset
                provider = CDMRDataset
        elif service == 'OPENDAP':
            if use_xarray:
                try:
                    import xarray as xr
                    provider = xr.open_dataset
github Unidata / siphon / siphon / catalog.py View on Github external
An object for holding Datasets obtained from a THREDDS Client Catalog.

    Attributes
    ----------
    name : str
        The name of the :class:`Dataset` element
    url_path : str
        url to the accessible dataset
    access_urls : CaseInsensitiveDict[str, str]
        A dictionary of access urls whose keywords are the access service
        types defined in the catalog (for example, "OPENDAP", "NetcdfSubset",
        "WMS", etc.

    """

    ncss_service_names = (CaseInsensitiveStr('NetcdfSubset'),
                          CaseInsensitiveStr('NetcdfServer'))

    def __init__(self, element_node, catalog_url=''):
        """Initialize the Dataset object.

        Parameters
        ----------
        element_node : :class:`~xml.etree.ElementTree.Element`
            An :class:`~xml.etree.ElementTree.Element` representing a Dataset node
        catalog_url : str
            The top level server url

        """
        self.name = element_node.attrib['name']
        self.id = element_node.attrib.get('ID', None)
        self.url_path = element_node.attrib.get('urlPath', None)
github Unidata / siphon / siphon / catalog.py View on Github external
Parameters
        ----------
        service : str, optional
            The name of the service to use for access to the dataset, either
            'CdmRemote' or 'OPENDAP'. Defaults to 'CdmRemote'.

        Returns
        -------
        Dataset
            Object for netCDF4-like access to the dataset

        """
        if service is None:
            service = 'CdmRemote' if 'CdmRemote' in self.access_urls else 'OPENDAP'

        if service not in (CaseInsensitiveStr('CdmRemote'), CaseInsensitiveStr('OPENDAP')):
            raise ValueError(service + ' is not a valid service for remote_access')

        return self.access_with_service(service, use_xarray)
github Unidata / siphon / siphon / catalog.py View on Github external
def __setitem__(self, key, value):
        """Set value with lowercase ``key``."""
        super(CaseInsensitiveDict, self).__setitem__(CaseInsensitiveStr(key), value)
github eWaterCycle / jupyterlab_thredds / jupyterlab_thredds / crawler.py View on Github external
# if so, these datasets need to be processed specially when making
                # access_urls
                if previous_dataset and self.datasets[previous_dataset].access_element_info:
                    self.ds_with_access_elements_to_process.append(previous_dataset)

                previous_dataset = current_dataset

            elif tag_type == 'access':
                self.datasets[current_dataset].add_access_element_info(child)
            elif tag_type == 'catalogRef':
                self._process_catalog_ref(child)
            elif (tag_type == 'metadata') or (tag_type == ''):
                self._process_metadata(child, tag_type)
            elif tag_type == 'service':
                if CaseInsensitiveStr(child.attrib['serviceType']) \
                        != CaseInsensitiveStr('Compound'):
                    # we do not want to process single services if they
                    # are already contained within a compound service, so
                    # we need to skip over those cases.
                    if service_skip_count >= service_skip:
                        self.services.append(SimpleService(child))
                        service_skip = 0
                        service_skip_count = 0
                    else:
                        service_skip_count += 1
                else:
                    self.services.append(CompoundService(child))
                    service_skip = self.services[-1].number_of_subservices
                    service_skip_count = 0

        self._process_datasets()
github Unidata / siphon / siphon / catalog.py View on Github external
# if so, these datasets need to be processed specially when making
                    # access_urls
                    if self.datasets[previous_dataset].access_element_info:
                        self.ds_with_access_elements_to_process.append(previous_dataset)

                previous_dataset = current_dataset

            elif tag_type == 'access':
                self.datasets[current_dataset].add_access_element_info(child)
            elif tag_type == 'catalogRef':
                self._process_catalog_ref(child)
            elif (tag_type == 'metadata') or (tag_type == ''):
                self._process_metadata(child, tag_type)
            elif tag_type == 'service':
                if CaseInsensitiveStr(child.attrib['serviceType'])\
                        != CaseInsensitiveStr('Compound'):
                    # we do not want to process single services if they
                    # are already contained within a compound service, so
                    # we need to skip over those cases.
                    if service_skip_count >= service_skip:
                        self.services.append(SimpleService(child))
                        service_skip = 0
                        service_skip_count = 0
                    else:
                        service_skip_count += 1
                else:
                    self.services.append(CompoundService(child))
                    service_skip = self.services[-1].number_of_subservices
                    service_skip_count = 0

        self._process_datasets()
github Unidata / siphon / siphon / catalog.py View on Github external
def __getitem__(self, key):
        """Return value from case-insensitive lookup of ``key``."""
        return super(CaseInsensitiveDict, self).__getitem__(CaseInsensitiveStr(key))
github Unidata / siphon / siphon / catalog.py View on Github external
def pop(self, key, *args, **kwargs):
        """Remove and return the value associated with case-insensitive ``key``."""
        return super(CaseInsensitiveDict, self).pop(CaseInsensitiveStr(key))