<commit_before>#solarnmf_observations.py

#<NAME>
#2 April 2015

#Import needed modules
import numpy as np
from scipy.ndimage.interpolation import rotate

class MakeData(object):
    """Class for constructing data, either simulation or observational, for use in NMF or BSS methods
    """

    def __init__(self,toption,input_type,**kwargs):
        """Constructor for MakeData class"""

        #Set observation matrix type
        self.toption = toption
        self.input_type = input_type

        self.psi = 1.0e-16
        self.ngrid_y = 10
        self.ngrid_x = 10
        self.noise_level = 0.05

        #Check timeseries options
        if self.input_type == 'timeseries':
            if 'angle' not in kwargs:
                self.angle = 0
                print "angle not specified. Setting angle to ",self.angle
            else:
                self.angle = kwargs['angle']

        #Check simulation and data options
        if self.toption == 'simulation':
            if 'nx' not in kwargs:
                self.nx = 50
                print "nx not specified. Setting nx to ",self.nx
            else:
                self.nx = kwargs['nx']

            if 'ny' not in kwargs:
                self.ny = 50
                print "ny not specified. Setting ny to ",self.ny
            else:
                self.ny = kwargs['ny']

            if 'p' not in kwargs:
                self.p = 5
                print "p not specified. Setting p to ",self.p
            else:
                self.p = kwargs['p']

            self.grid_y = int(self.ny/self.ngrid_y)
            self.grid_x = int(self.nx/self.ngrid_x)
            self.sigma_y = float(self.grid_y/2.0)
            self.sigma_x = float(self.grid_x/2.0)

        elif self.toption == 'data':
            if 'file' not in kwargs:
                raise ValueError("'file' needs to be specified in kwargs by either a path or a variable in order to load data.")
            else:
                self.file = kwargs['file']
        else:
            raise ValueError("Unknown observation option. Use either 'simulation' or 'data'.")


    def make_t_matrix(self):
        """Construct matrix or timeseries to factorize"""

        if self.toption == 'simulation':
            #Call the make gaussians function
            target,T = self.make_gaussians()
            T[np.where(T<self.psi)] = self.psi

            if self.input_type == 'matrix':
                return target,T

            else:
                Tmat = self.ts_to_mat(T)
                return target,T,Tmat

        else:

            if type(self.filename) is str:<commit_msg>Switch from 'filename' to 'file'<commit_after>#solarnmf_observations.py

#<NAME>
#2 April 2015

#Import needed modules
import numpy as np
from scipy.ndimage.interpolation import rotate

class MakeData(object):
    """Class for constructing data, either simulation or observational, for use in NMF or BSS methods
    """

    def __init__(self,toption,input_type,**kwargs):
        """Constructor for MakeData class"""

        #Set observation matrix type
        self.toption = toption
        self.input_type = input_type

        self.psi = 1.0e-16
        self.ngrid_y = 10
        self.ngrid_x = 10
        self.noise_level = 0.05

        #Check timeseries options
        if self.input_type == 'timeseries':
            if 'angle' not in kwargs:
                self.angle = 0
                print "angle not specified. Setting angle to ",self.angle
            else:
                self.angle = kwargs['angle']

        #Check simulation and data options
        if self.toption == 'simulation':
            if 'nx' not in kwargs:
                self.nx = 50
                print "nx not specified. Setting nx to ",self.nx
            else:
                self.nx = kwargs['nx']

            if 'ny' not in kwargs:
                self.ny = 50
                print "ny not specified. Setting ny to ",self.ny
            else:
                self.ny = kwargs['ny']

            if 'p' not in kwargs:
                self.p = 5
                print "p not specified. Setting p to ",self.p
            else:
                self.p = kwargs['p']

            self.grid_y = int(self.ny/self.ngrid_y)
            self.grid_x = int(self.nx/self.ngrid_x)
            self.sigma_y = float(self.grid_y/2.0)
            self.sigma_x = float(self.grid_x/2.0)

        elif self.toption == 'data':
            if 'file' not in kwargs:
                raise ValueError("'file' needs to be specified in kwargs by either a path or a variable in order to load data.")
            else:
                self.file = kwargs['file']
        else:
            raise ValueError("Unknown observation option. Use either 'simulation' or 'data'.")


    def make_t_matrix(self):
        """Construct matrix or timeseries to factorize"""

        if self.toption == 'simulation':
            #Call the make gaussians function
            target,T = self.make_gaussians()
            T[np.where(T<self.psi)] = self.psi

            if self.input_type == 'matrix':
                return target,T

            else:
                Tmat = self.ts_to_mat(T)
                return target,T,Tmat

        else:

            if type(self.file) is str:
{'fraction_non_alphanumeric': 0.09442223491338284, 'fraction_numerical': 0.009899105273177233, 'mean_word_length': 1.6048587010411501, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '5596801', 'n_tokens_mistral': 1547, 'n_tokens_neox': 1462, 'n_words': 453}