<commit_before># Copyright (c) 2017, Vienna University of Technology (TU Wien),
# Department of Geodesy and Geoinformation (GEO).
# All rights reserved.
#
# All information contained herein is, and remains the property of Vienna
# University of Technology (TU Wien), Department of Geodesy and Geoinformation
# (GEO). The intellectual and technical concepts contained herein are
# proprietary to Vienna University of Technology (TU Wien), Department of
# Geodesy and Geoinformation (GEO). Dissemination of this information or
# reproduction of this material is forbidden unless prior written permission
# is obtained from Vienna University of Technology (TU Wien), Department of
# Geodesy and Geoinformation (GEO).

'''
Module for reading CGLOPS SWI TS products
'''

import pynetcf.time_series as netcdf_dataset
import pygeogrids.netcdf as netcdf

import os
import numpy as np


class SWI_TS(netcdf_dataset.GriddedNcOrthoMultiTs):

    """
    SWI TS reader for timeseries data from CGLOPS

    Parameters
    ----------
    data_path: string
        path to the netCDF files
    parameters: list
        list of parameters to read from netCDF file
    dt: string, optional
        datetime in the filenames of the cells
    version: string, optional
        version number of the files
    grid_fname: string, optional
        filename + path of the grid netCDF file,
        default is the standard grid file (c_gls_SWI-STATIC-DGG_201501010000_GLOBE_ASCAT_V3.0.1.nc)
        in the same folder as the data
    read_bulk: boolean, optional
        if set to true then a complete 5x5 degree cell will be read at once
        providing speedup if the complete data is needed.
    fname_template: string, optional
        Filename template. Has to have two slots for {dt} and {version} and a
        slot for the cell number that is available for further formatting.
        Because of this the cell number location has to be written as '{{:04d}}'.
        The has to be without the .nc ending since this is added during reading.
    """

    def __init__(self, data_path, parameters=['SWI_001', 'SWI_005', 'SWI_010',
                                              'SWI_015', 'SWI_020', 'SWI_040',
                                              'SWI_060', 'SWI_100', 'SSF'],
                 dt='201612310000', version='3.0.1',
                 grid_fname=None, read_bulk=True,
                 fname_template='c_gls_SWI-TS_{dt}_C{{:04d}}_ASCAT_V{version}'):

        if grid_fname is None:
            grid_fname = os.path.join(
                data_path, 'c_gls_SWI-STATIC-DGG_201501010000_GLOBE_ASCAT_V3.0.1.nc')
        grid = netcdf.load_grid(grid_fname, location_var_name='location_id')

        scale_factors = {'SWI_001': 0.5,
                         'SWI_005': 0.5,
                         'SWI_010': 0.5,
                         'SWI_015': 0.5,
                         'SWI_020': 0.5,
                         'SWI_040': 0.5,
                         'SWI_060': 0.5,
                         'SWI_100': 0.5,
                         'SSF': 1}

        dtypes = {'SWI_001': np.uint8,
                  'SWI_005': np.uint8,<commit_msg>Initialize CGLS SWI TS grid only with land points.<commit_after># Copyright (c) 2017, Vienna University of Technology (TU Wien),
# Department of Geodesy and Geoinformation (GEO).
# All rights reserved.
#
# All information contained herein is, and remains the property of Vienna
# University of Technology (TU Wien), Department of Geodesy and Geoinformation
# (GEO). The intellectual and technical concepts contained herein are
# proprietary to Vienna University of Technology (TU Wien), Department of
# Geodesy and Geoinformation (GEO). Dissemination of this information or
# reproduction of this material is forbidden unless prior written permission
# is obtained from Vienna University of Technology (TU Wien), Department of
# Geodesy and Geoinformation (GEO).

'''
Module for reading CGLOPS SWI TS products
'''

import pynetcf.time_series as netcdf_dataset
import pygeogrids.netcdf as netcdf

import os
import numpy as np


class SWI_TS(netcdf_dataset.GriddedNcOrthoMultiTs):

    """
    SWI TS reader for timeseries data from CGLOPS

    Parameters
    ----------
    data_path: string
        path to the netCDF files
    parameters: list
        list of parameters to read from netCDF file
    dt: string, optional
        datetime in the filenames of the cells
    version: string, optional
        version number of the files
    grid_fname: string, optional
        filename + path of the grid netCDF file,
        default is the standard grid file (c_gls_SWI-STATIC-DGG_201501010000_GLOBE_ASCAT_V3.0.1.nc)
        in the same folder as the data
    read_bulk: boolean, optional
        if set to true then a complete 5x5 degree cell will be read at once
        providing speedup if the complete data is needed.
    fname_template: string, optional
        Filename template. Has to have two slots for {dt} and {version} and a
        slot for the cell number that is available for further formatting.
        Because of this the cell number location has to be written as '{{:04d}}'.
        The has to be without the .nc ending since this is added during reading.
    """

    def __init__(self, data_path, parameters=['SWI_001', 'SWI_005', 'SWI_010',
                                              'SWI_015', 'SWI_020', 'SWI_040',
                                              'SWI_060', 'SWI_100', 'SSF'],
                 dt='201612310000', version='3.0.1',
                 grid_fname=None, read_bulk=True,
                 fname_template='c_gls_SWI-TS_{dt}_C{{:04d}}_ASCAT_V{version}'):

        if grid_fname is None:
            grid_fname = os.path.join(
                data_path, 'c_gls_SWI-STATIC-DGG_201501010000_GLOBE_ASCAT_V3.0.1.nc')
        grid = netcdf.load_grid(grid_fname, location_var_name='location_id',
                                subset_flag='land_flag')

        scale_factors = {'SWI_001': 0.5,
                         'SWI_005': 0.5,
                         'SWI_010': 0.5,
                         'SWI_015': 0.5,
                         'SWI_020': 0.5,
                         'SWI_040': 0.5,
                         'SWI_060': 0.5,
                         'SWI_100': 0.5,
                         'SSF': 1}

        dtypes = {'SWI_001': np.uint8,
                  'SWI_005': np.uint8,
{'fraction_non_alphanumeric': 0.07980558168704924, 'fraction_numerical': 0.04013797428661022, 'mean_word_length': 2.2039176293319938, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3569347', 'n_tokens_mistral': 2051, 'n_tokens_neox': 1811, 'n_words': 640}