# Path: turbulence_diagnostics/inputs.py
# class Inputs:
# class Inputs1:
# class Profiles:
#     def __init__(self, filename='/marconi_work/eufus_gw/work/g2bszond/renate-od.git/trunk/'
#                                 'data/Profiles/SOL_profiles/EAST_412.h5', time_index=0):
#     def interpolate_profile(self, profile):
#     def __init__(self, filename, time_index):
#     def get_grid(self):
#     def get_density_2d(self,time_index):
#     def get_electron_temperature_2d(self, time_index):
#     def get_ion_temperature_2d(self, time_index):
#     def calculate_new_r_axis(self):
# 
# Path: crm_solver/coefficientmatrix.py
# class CoefficientMatrix:
#     def __init__(self, beamlet_param, beamlet_profiles, plasma_components, atomic_db):
#     def interpolate_rates(self, atomic_db, plasma_components):
#     def assemble_matrix(self, atomic_db, plasma_components):
#     def interpolate_electron_impact_trans(self, from_level, to_level, atomic_db):
#     def interpolate_ion_impact_trans(self, ion, from_level, to_level, atomic_db):
#     def interpolate_electron_impact_loss(self, from_level, atomic_db):
#     def interpolate_ion_impact_loss(self, ion, from_level, atomic_db):
#     def fetch_neutral_impact_loss(self, neutral, from_level, atomic_db):
#     def fetch_neutral_impact_trans(self, neutral, from_level, to_level, atomic_db):
#     def assemble_electron_impact_population_loss_terms(self, from_level, to_level, atomic_db):
#     def assemble_neutral_impact_population_loss_terms(self, neutral, from_level, to_level, atomic_db):
#     def assemble_ion_impact_population_loss_terms(self, ion, from_level, to_level, atomic_db):
#     def assemble_electron_impact_population_gain_terms(self, from_level, to_level):
#     def assemble_neutral_impact_population_gain_terms(self, neutral, from_level, to_level):
#     def assemble_ion_impact_population_gain_terms(self, ion, from_level, to_level):
#     def assemble_spontaneous_population_loss_terms(self, from_level, to_level, atomic_db):
#     def assemble_spontaneous_population_gain_terms(self, from_level, to_level, atomic_db):
#     def apply_electron_density(self, step):
#     def apply_ion_density(self, ion, step):
#     def apply_photons(self, step):
#     def apply_neutral_density(self, neutral, step):
# 
# Path: crm_solver/ode.py
# class Ode:
#     def __init__(self, coeff_matrix, init_condition):
#         self.coeff_matrix = coeff_matrix
#         self.init_condition = init_condition
#         self.__validate_parameters()
# 
#     def __validate_parameters(self):
#         self.__validate(self.coeff_matrix)
#         self.__validate(self.init_condition)
#         self.__validate_matrix(self.coeff_matrix)
# 
#     @staticmethod
#     def __validate(parameter):
#         if parameter is None:
#             raise ValueError('Try to define Ode class with null matrix.')
# 
#     def __validate_matrix(self, parameter):
#         if self.__is_not_square(parameter):
#             raise ValueError("The matrix must be squared")
# 
#     @staticmethod
#     def __is_not_square(matrix):
#         matrix_temp1 = matrix.shape[0]
#         if matrix.ndim > 1:
#             matrix_temp2 = matrix.shape[1]
#         else:
#             matrix_temp2 = 0
#         return matrix_temp1 != matrix_temp2
# 
#     def calculate_numerical_solution(self, steps):
#         return odeint(func=self.set_derivative_vector, y0=self.init_condition, t=steps, args=(self.coeff_matrix, steps))
# 
#     def calculate_analytical_solution(self, steps):
#         eigenvalues, eigenvectors = numpy.linalg.eig(self.coeff_matrix)
#         if self.init_condition.size == 1:
#             return self.__calculate_analytical_solution_1d(steps, eigenvalues)
#         else:
#             return self.__calculate_analytical_solution_else(steps, eigenvalues, eigenvectors)
# 
#     def __calculate_analytical_solution_else(self, steps, eigenvalues, eigenvectors):
#         analytical_solution = numpy.zeros((steps.size, self.init_condition.size))
#         temporal_constant = numpy.dot(numpy.dot(numpy.linalg.inv(eigenvectors), self.init_condition), eigenvectors)
#         for step in range(steps.size):
#             analytical_solution[step, :] = self.calculate_exp_solution(temporal_constant, eigenvalues, steps[step])
#         return analytical_solution
# 
#     def __calculate_analytical_solution_1d(self, steps, eigenvalues):
#         analytical_solution = numpy.zeros(steps.size)
#         for step in range(steps.size):
#             analytical_solution[step] = self.calculate_exp_solution(self.init_condition, eigenvalues, steps[step])
#         return analytical_solution
# 
#     @staticmethod
#     def set_derivative_vector(variable_vector, actual_position, coeff_matrix, steps):
#         if coeff_matrix.ndim == 3:
#             interp_coeff_matrix = interp1d(steps, coeff_matrix, axis=2, fill_value='extrapolate')
#             return numpy.dot(variable_vector, interp_coeff_matrix(actual_position))
#         elif coeff_matrix.ndim == 2:
#             return numpy.dot(variable_vector, coeff_matrix)
#         else:
#             raise ValueError('Rate Coefficient Matrix of dimensions: ' + str(coeff_matrix.ndim) + ' is not supported')
# 
#     @staticmethod
#     def calculate_exp_solution(init, coefficient, variable):
#         return init * numpy.exp(coefficient * variable)


from turbulence_diagnostics import inputs
from crm_solver import coefficientmatrix
from crm_solver.ode import Ode
import matplotlib.pyplot
import h5py
import os
import numpy


class Solve:
    def __init__(self):
        self.time_index = 0
        return

    @staticmethod
    def change_in_time():

# Path: turbulence_diagnostics/inputs.py
# class Inputs:
# class Inputs1:
# class Profiles:
#     def __init__(self, filename='/marconi_work/eufus_gw/work/g2bszond/renate-od.git/trunk/'
#                                 'data/Profiles/SOL_profiles/EAST_412.h5', time_index=0):
#     def interpolate_profile(self, profile):
#     def __init__(self, filename, time_index):
#     def get_grid(self):
#     def get_density_2d(self,time_index):
#     def get_electron_temperature_2d(self, time_index):
#     def get_ion_temperature_2d(self, time_index):
#     def calculate_new_r_axis(self):
# 
# Path: crm_solver/coefficientmatrix.py
# class CoefficientMatrix:
#     def __init__(self, beamlet_param, beamlet_profiles, plasma_components, atomic_db):
#     def interpolate_rates(self, atomic_db, plasma_components):
#     def assemble_matrix(self, atomic_db, plasma_components):
#     def interpolate_electron_impact_trans(self, from_level, to_level, atomic_db):
#     def interpolate_ion_impact_trans(self, ion, from_level, to_level, atomic_db):
#     def interpolate_electron_impact_loss(self, from_level, atomic_db):
#     def interpolate_ion_impact_loss(self, ion, from_level, atomic_db):
#     def fetch_neutral_impact_loss(self, neutral, from_level, atomic_db):
#     def fetch_neutral_impact_trans(self, neutral, from_level, to_level, atomic_db):
#     def assemble_electron_impact_population_loss_terms(self, from_level, to_level, atomic_db):
#     def assemble_neutral_impact_population_loss_terms(self, neutral, from_level, to_level, atomic_db):
#     def assemble_ion_impact_population_loss_terms(self, ion, from_level, to_level, atomic_db):
#     def assemble_electron_impact_population_gain_terms(self, from_level, to_level):
#     def assemble_neutral_impact_population_gain_terms(self, neutral, from_level, to_level):
#     def assemble_ion_impact_population_gain_terms(self, ion, from_level, to_level):
#     def assemble_spontaneous_population_loss_terms(self, from_level, to_level, atomic_db):
#     def assemble_spontaneous_population_gain_terms(self, from_level, to_level, atomic_db):
#     def apply_electron_density(self, step):
#     def apply_ion_density(self, ion, step):
#     def apply_photons(self, step):
#     def apply_neutral_density(self, neutral, step):
# 
# Path: crm_solver/ode.py
# class Ode:
#     def __init__(self, coeff_matrix, init_condition):
#         self.coeff_matrix = coeff_matrix
#         self.init_condition = init_condition
#         self.__validate_parameters()
# 
#     def __validate_parameters(self):
#         self.__validate(self.coeff_matrix)
#         self.__validate(self.init_condition)
#         self.__validate_matrix(self.coeff_matrix)
# 
#     @staticmethod
#     def __validate(parameter):
#         if parameter is None:
#             raise ValueError('Try to define Ode class with null matrix.')
# 
#     def __validate_matrix(self, parameter):
#         if self.__is_not_square(parameter):
#             raise ValueError("The matrix must be squared")
# 
#     @staticmethod
#     def __is_not_square(matrix):
#         matrix_temp1 = matrix.shape[0]
#         if matrix.ndim > 1:
#             matrix_temp2 = matrix.shape[1]
#         else:
#             matrix_temp2 = 0
#         return matrix_temp1 != matrix_temp2
# 
#     def calculate_numerical_solution(self, steps):
#         return odeint(func=self.set_derivative_vector, y0=self.init_condition, t=steps, args=(self.coeff_matrix, steps))
# 
#     def calculate_analytical_solution(self, steps):
#         eigenvalues, eigenvectors = numpy.linalg.eig(self.coeff_matrix)
#         if self.init_condition.size == 1:
#             return self.__calculate_analytical_solution_1d(steps, eigenvalues)
#         else:
#             return self.__calculate_analytical_solution_else(steps, eigenvalues, eigenvectors)
# 
#     def __calculate_analytical_solution_else(self, steps, eigenvalues, eigenvectors):
#         analytical_solution = numpy.zeros((steps.size, self.init_condition.size))
#         temporal_constant = numpy.dot(numpy.dot(numpy.linalg.inv(eigenvectors), self.init_condition), eigenvectors)
#         for step in range(steps.size):
#             analytical_solution[step, :] = self.calculate_exp_solution(temporal_constant, eigenvalues, steps[step])
#         return analytical_solution
# 
#     def __calculate_analytical_solution_1d(self, steps, eigenvalues):
#         analytical_solution = numpy.zeros(steps.size)
#         for step in range(steps.size):
#             analytical_solution[step] = self.calculate_exp_solution(self.init_condition, eigenvalues, steps[step])
#         return analytical_solution
# 
#     @staticmethod
#     def set_derivative_vector(variable_vector, actual_position, coeff_matrix, steps):
#         if coeff_matrix.ndim == 3:
#             interp_coeff_matrix = interp1d(steps, coeff_matrix, axis=2, fill_value='extrapolate')
#             return numpy.dot(variable_vector, interp_coeff_matrix(actual_position))
#         elif coeff_matrix.ndim == 2:
#             return numpy.dot(variable_vector, coeff_matrix)
#         else:
#             raise ValueError('Rate Coefficient Matrix of dimensions: ' + str(coeff_matrix.ndim) + ' is not supported')
# 
#     @staticmethod
#     def calculate_exp_solution(init, coefficient, variable):
#         return init * numpy.exp(coefficient * variable)


# Path: turbulence_diagnostics/solve.py
from turbulence_diagnostics import inputs
from crm_solver import coefficientmatrix
from crm_solver.ode import Ode
import matplotlib.pyplot
import h5py
import os
import numpy



class Solve:
    def __init__(self):
        self.time_index = 0
        return

    @staticmethod
    def change_in_time():

        inp = inputs.Inputs()