<commit_before>import json
import os

import rasterio
from pyproj import Proj

from vistas.core.gis.extent import Extent
from vistas.core.plugins.data import RasterDataPlugin, VariableStats


class GeoTIFF(RasterDataPlugin):

    id = 'geotiff'
    name = 'GeoTIFF Data Plugin'
    description = 'Reads GeoTIFF (.tif) files'
    author = 'Conservation Biology Institute'
    version = '1.0'
    extensions = [('tif', 'GeoTIFF'), ('tiff', 'GeoTIFF')]

    data_name = None
    shape = None
    resolution = None
    extent = None

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.shape = None
        self.extent = None
        self.resolution = None
        self._nodata = None
        self._count = None
        self._stats_path = None

    def load_data(self):
        file_name = self.path.split(os.sep)[-1]
        *name, ext = file_name.split('.')
        self.data_name = '.'.join(name)
        self._stats_path = os.path.join(os.path.dirname(self.path), '{}.{}'.format(self.data_name, 'json'))

        with rasterio.open(self.path) as src:
            projection = Proj(src.crs)
            self.shape = src.shape
            self.resolution = src.res[0]
            xmin, ymin = src.xy(src.height, 0, 'ul')
            xmax, ymax = src.xy(0, src.width, 'ul')
            self.extent = Extent(xmin, ymin, xmax, ymax, projection)
            self._nodata = src.nodata
            self._count = src.count

    @staticmethod
    def _band(b):
        return b.split(' ')[-1]

    @staticmethod
    def is_valid_file(path):
        return True

    def get_data(self, variable, date=None):
        band = int(self._band(variable))
        with rasterio.open(self.path, 'r') as src:
            return src.read(band)

    @property
    def variables(self):
        return ['Band {}'.format(i) for i in range(1, self._count + 1)]<commit_msg>Remove dead code.<commit_after>import json
import os

import rasterio
from pyproj import Proj

from vistas.core.gis.extent import Extent
from vistas.core.plugins.data import RasterDataPlugin, VariableStats


class GeoTIFF(RasterDataPlugin):

    id = 'geotiff'
    name = 'GeoTIFF Data Plugin'
    description = 'Reads GeoTIFF (.tif) files'
    author = 'Conservation Biology Institute'
    version = '1.0'
    extensions = [('tif', 'GeoTIFF'), ('tiff', 'GeoTIFF')]

    data_name = None
    shape = None
    resolution = None
    extent = None

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.shape = None
        self.extent = None
        self.resolution = None
        self._nodata = None
        self._count = None

    def load_data(self):
        file_name = self.path.split(os.sep)[-1]
        *name, ext = file_name.split('.')
        self.data_name = '.'.join(name)

        with rasterio.open(self.path) as src:
            projection = Proj(src.crs)
            self.shape = src.shape
            self.resolution = src.res[0]
            xmin, ymin = src.xy(src.height, 0, 'ul')
            xmax, ymax = src.xy(0, src.width, 'ul')
            self.extent = Extent(xmin, ymin, xmax, ymax, projection)
            self._nodata = src.nodata
            self._count = src.count

    @staticmethod
    def _band(b):
        return b.split(' ')[-1]

    @staticmethod
    def is_valid_file(path):
        return True

    def get_data(self, variable, date=None):
        band = int(self._band(variable))
        with rasterio.open(self.path, 'r') as src:
            return src.read(band)

    @property
    def variables(self):
        return ['Band {}'.format(i) for i in range(1, self._count + 1)]
{'fraction_non_alphanumeric': 0.12753702687877125, 'fraction_numerical': 0.004936917169500823, 'mean_word_length': 2.2974683544303796, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4857272', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1186, 'n_words': 291}