Find the right geographical file handlers for given dataset ID *dsid*.
976459
def get_right_geo_fhs(self, dsid, fhs):
        """"""
        ds_info = self.ids[dsid]
        req_geo, rem_geo = self._get_req_rem_geo(ds_info)
        desired, other = split_desired_other(fhs, req_geo, rem_geo)
        if desired:
            try:
                ds_info['dataset_groups'].remove(rem_geo)
            except ValueError:
                pass
            return desired
        else:
            return other
1160255
def get_dataset(self, key, info):
        """"""

        angles = self._get_coarse_dataset(key, info)
        if angles is None:
            return

        # Fill gaps at edges of swath
        darr = DataArray(angles, dims=['y', 'x'])
        darr = darr.bfill('x')
        darr = darr.ffill('x')
        angles = darr.data

        res = self.interpolate_angles(angles, key.resolution)

        proj = DataArray(res, dims=['y', 'x'])
        proj.attrs = info.copy()
        proj.attrs['units'] = 'degrees'
        proj.attrs['platform_name'] = self.platform_name
        return proj
1175387
def _readWMSDatasets(self, datasetCards, directory, session, spatial=False, spatialReferenceID=4236):
        
        if self.mapType in self.MAP_TYPES_SUPPORTED:
            # Get Mask Map dependency
            maskMap = session.query(RasterMapFile).\
                              filter(RasterMapFile.projectFile == self).\
                              filter(RasterMapFile.fileExtension == 'msk').\
                              one()

            for card in self.projectCards:
                if (card.name in datasetCards) and self._noneOrNumValue(card.value):
                    # Get filename from project file
                    filename = card.value.strip('"')
                    path = os.path.join(directory, filename)

                    if os.path.isfile(path):
                        wmsDatasetFile = WMSDatasetFile()
                        wmsDatasetFile.projectFile = self
                        wmsDatasetFile.read(directory=directory,
                                            filename=filename,
                                            session=session,
                                            maskMap=maskMap,
                                            spatial=spatial,
                                            spatialReferenceID=spatialReferenceID)
                    else:
                        self._readBatchOutputForFile(directory, WMSDatasetFile, filename, session, spatial,
                                                     spatialReferenceID, maskMap=maskMap)
147524
def read_geo(fid, key):
    """"""
    dsid = GEO_NAMES[key.name]
    add_epoch = False
    if "time" in key.name:
        days = fid["/L1C/" + dsid["day"]].value
        msecs = fid["/L1C/" + dsid["msec"]].value
        data = _form_datetimes(days, msecs)
        add_epoch = True
        dtype = np.float64
    else:
        data = fid["/L1C/" + dsid].value
        dtype = np.float32
    data = xr.DataArray(da.from_array(data, chunks=CHUNK_SIZE),
                        name=key.name, dims=['y', 'x']).astype(dtype)

    if add_epoch:
        data.attrs['sensing_time_epoch'] = EPOCH

    return data
1316746
def data_available(dataset_name=None):
    """"""
    try:
        from itertools import zip_longest
    except ImportError:
        from itertools import izip_longest as zip_longest
    dr = data_resources[dataset_name]
    zip_urls = (dr['files'], )
    if 'save_names' in dr: zip_urls += (dr['save_names'], )
    else: zip_urls += ([],)

    for file_list, save_list in zip_longest(*zip_urls, fillvalue=[]):
        for f, s in zip_longest(file_list, save_list, fillvalue=None):
            if s is not None: f=s # If there is a save_name given, use that one
            if not os.path.exists(os.path.join(data_path, dataset_name, f)):
                return False
    return True
426529
def _convert_dataset_files(value):
    """"""
    output = {}
    for k, v in value.items():
        inst = DatasetFile.from_jsonld(v)
        output[inst.path] = inst
    return output
261206
def _get_req_rem_geo(self, ds_info):
        """"""
        if ds_info['dataset_groups'][0].startswith('GM'):
            if self.use_tc is False:
                req_geo = 'GMODO'
                rem_geo = 'GMTCO'
            else:
                req_geo = 'GMTCO'
                rem_geo = 'GMODO'
        elif ds_info['dataset_groups'][0].startswith('GI'):
            if self.use_tc is False:
                req_geo = 'GIMGO'
                rem_geo = 'GITCO'
            else:
                req_geo = 'GITCO'
                rem_geo = 'GIMGO'
        else:
            raise ValueError('Unknown dataset group %s' % ds_info['dataset_groups'][0])
        return req_geo, rem_geo
230608
@SuppressWarnings("unchecked")
	public <T> DataSet<T> getDataSet(int id) {
		return verifyType(id, dataSets.get(id), SetType.DATA_SET);
	}
388933
def check_dataset_format(ds_format):
    
    if ds_format.lower() not in DATASET_FORMATS.keys():
        raise ValueError(
            "dataset_format is expected to be one of %s. '%s' is not valid"
            % (", ".join(DATASET_FORMATS.keys()), ds_format)
        )
1365785
def dataset_list_files(self, dataset):
        
        if dataset is None:
            raise ValueError('A dataset must be specified')
        if '/' in dataset:
            self.validate_dataset_string(dataset)
            dataset_urls = dataset.split('/')
            owner_slug = dataset_urls[0]
            dataset_slug = dataset_urls[1]
        else:
            owner_slug = self.get_config_value(self.CONFIG_NAME_USER)
            dataset_slug = dataset
        dataset_list_files_result = self.process_response(
            self.datasets_list_files_with_http_info(
                owner_slug=owner_slug, dataset_slug=dataset_slug))
        return ListFilesResult(dataset_list_files_result)
26670
def loaded_dataset_ids(self):
        """"""
        return set(ds_id for scene in self.scenes for ds_id in scene.keys())
810202
def get_srid(queryset):
    """"""
    try:
        srid = list(six.viewvalues(queryset.query.annotations))[0].srid
    except (AttributeError, IndexError):
        srid = None
    return srid or geo_field(queryset).srid
1137972
def handle_uploaded_files(uploaded_files):
    """"""
    if uploaded_files:
        uploaded_files = json.loads(uploaded_files)[0]
        _id = uploaded_files.get('id')
        # Strip extension from filename
        _filename = os.path.splitext(uploaded_files.get('filename'))[0]

        # Create a dataset
        dataset = g.client.Dataset.get_or_create_by_full_path('~/' + _filename)

        # Import the file into the dataset
        g.client.DatasetImport.create(
            dataset_id=dataset.id,
            object_id=_id
        )

        # Wait until activity is completed
        dataset.activity(follow=True)

        SELECTED_COLS = ['col_a', 'col_b', 'col_c']
        query = dataset.query(fields=SELECTED_COLS)

        return html.Div(
            dt.DataTable(
                id='data-table',
                rows=list(query),
                columns=SELECTED_COLS
            )
        )
743569
def retrieve_file_handles_of_same_dataset(self, **args):
        '''
        
        '''
        mandatory_args = ['drs_id', 'version_number', 'data_node', 'prefix']
        esgfpid.utils.check_presence_of_mandatory_args(args, mandatory_args)
        self.__reset_error_messages()

        # Try plan A
        file_handles = None
        try:
            file_handles = self.__strategy1(args) # can raise SolrError or SolrSwitchedOff, but can't return None
        except esgfpid.exceptions.SolrError as e:
            self.__error_messages.append('Error during first query: '+e.message)

        if file_handles is not None and len(file_handles)>0:
            LOGGER.debug('Retrieved file handles from solr in first query.')
            return file_handles

        # Try plan B
        try:
            file_handles = self.__strategy2(args) # can raise SolrError or SolrSwitchedOff, but can't return None
        except esgfpid.exceptions.SolrError as e:
            self.__error_messages.append('Error during second query: '+e.message)
            msg = '/n'.join(self.__error_messages)
            raise esgfpid.exceptions.SolrError('Failure in both queries. Messages:\n'+msg)

        return file_handles
221644
def datasets_directory(path)
      Dataset::Resolver.default = Dataset::DirectoryResolver.new(path)
      Dataset::ContextClassMethods.datasets_database_dump_path = File.join(path, '/tmp/dataset')
    end
105451
def gcs_dataset_info_files(dataset_dir):
  """"""
  prefix = posixpath.join(GCS_DATASET_INFO_DIR, dataset_dir, "")
  # Filter for this dataset
  filenames = [el for el in gcs_files(prefix_filter=prefix)
               if el.startswith(prefix) and len(el) > len(prefix)]
  return filenames
1109652
def choose_raw_dataset(currently=""):
    """"""
    folder = os.path.join(get_project_root(), "raw-datasets")
    files = [os.path.join(folder, name) for name in os.listdir(folder)
             if name.endswith(".pickle")]
    default = -1
    for i, filename in enumerate(files):
        if os.path.basename(currently) == os.path.basename(filename):
            default = i
        if i != default:
            print("[%i]\t%s" % (i, os.path.basename(filename)))
        else:
            print("\033[1m[%i]\033[0m\t%s" % (i, os.path.basename(filename)))
    i = input_int_default("Choose a dataset by number: ", default)
    return files[i]