# Path: imas_utility/idsinstance.py
# class ImasObject:
#     def __init__(self, shot, run, user, machine):
#         assert isinstance(shot, int)
#         self.shot = shot
# 
#         assert isinstance(run, int)
#         self.run = run
# 
#         if user is None:
#             self.user = os.getenv('USER')
#             self.local_data_base = False
#         else:
#             assert isinstance(user, str)
#             self.user = user
#             self.local_data_base = True
# 
#         if machine is None:
#             self.machine = 'iter'
#         else:
#             assert isinstance(machine, str)
#             self.machine = machine
# 
#         self.build_imas_pointer()
# 
#     def build_imas_pointer(self):
#         try:
#             if self.local_data_base is True:
#                 self.imas_pointer = pyual.Client(self.shot, self.run, user=self.user, machine=self.machine)
#             else:
#                 self.imas_pointer = pyual.Client(self.shot, self.run)
#         except:
#             raise IdsLoadError('IDS for shot ' + str(self.shot) + ', @ run ' + str(self.run) +
#                                ' could not be found. Check input, local idsdb and common idsdb')
# 
# Path: utility/exceptions.py
# class IdsInstanceLoadError(Exception):
#     def __init__(self, *args, **kwargs):
#         pass
# 
#     @staticmethod
#     def __new__(*args, **kwargs):
#         """ Create and return a new object.  See help(type) for accurate signature. """
#         pass
# 
# Path: utility/exceptions.py
# class IdsAttributeLoadError(Exception):
#     def __init__(self, *args, **kwargs):
#         pass
# 
#     @staticmethod
#     def __new__(*args, **kwargs):
#         """ Create and return a new object.  See help(type) for accurate signature. """
#         pass


from imas_utility.idsinstance import ImasObject
from utility.exceptions import IdsInstanceLoadError
from utility.exceptions import IdsAttributeLoadError
import numpy as np

    def load_profiles_from_ids(self, source):
        self.source = source
        try:
            self.profiles = self.imas_pointer.get(self.source)
        except:
            raise IdsInstanceLoadError('No ' + self.source + ' IDS was found for shot: '
                                       + str(self.shot) + ' at run ' + str(self.run))

    def get_grid_in_rho_tor_norm(self, time):
        time_index = self.get_time_index(time)
        try:
            return self.profiles.profiles_1d[time_index].grid.rho_tor_norm
        except:
            raise IdsAttributeLoadError('There is no available rho tor norm based grid for Shot:' +
                                        str(self.shot) + ' at Run: ' + str(self.run) + ' in ' + self.source + ' IDS.')

    def get_grid_in_psi(self, time):
        time_index = self.get_time_index(time)
        try:
            return self.profiles.profiles_1d[time_index].grid.psi
        except:
            raise IdsAttributeLoadError('There is no available psi based grid for Shot:' +
                                        str(self.shot) + ' at Run: ' + str(self.run) + ' in ' + self.source + ' IDS.')

    def get_grid_in_rho_tor(self, time):
        time_index = self.get_time_index(time)
        try:
            return self.profiles.profiles_1d[time_index].grid.rho_tor
        except:

# Path: imas_utility/idsinstance.py
# class ImasObject:
#     def __init__(self, shot, run, user, machine):
#         assert isinstance(shot, int)
#         self.shot = shot
# 
#         assert isinstance(run, int)
#         self.run = run
# 
#         if user is None:
#             self.user = os.getenv('USER')
#             self.local_data_base = False
#         else:
#             assert isinstance(user, str)
#             self.user = user
#             self.local_data_base = True
# 
#         if machine is None:
#             self.machine = 'iter'
#         else:
#             assert isinstance(machine, str)
#             self.machine = machine
# 
#         self.build_imas_pointer()
# 
#     def build_imas_pointer(self):
#         try:
#             if self.local_data_base is True:
#                 self.imas_pointer = pyual.Client(self.shot, self.run, user=self.user, machine=self.machine)
#             else:
#                 self.imas_pointer = pyual.Client(self.shot, self.run)
#         except:
#             raise IdsLoadError('IDS for shot ' + str(self.shot) + ', @ run ' + str(self.run) +
#                                ' could not be found. Check input, local idsdb and common idsdb')
# 
# Path: utility/exceptions.py
# class IdsInstanceLoadError(Exception):
#     def __init__(self, *args, **kwargs):
#         pass
# 
#     @staticmethod
#     def __new__(*args, **kwargs):
#         """ Create and return a new object.  See help(type) for accurate signature. """
#         pass
# 
# Path: utility/exceptions.py
# class IdsAttributeLoadError(Exception):
#     def __init__(self, *args, **kwargs):
#         pass
# 
#     @staticmethod
#     def __new__(*args, **kwargs):
#         """ Create and return a new object.  See help(type) for accurate signature. """
#         pass


# Path: imas_utility/idsprofiles.py
from imas_utility.idsinstance import ImasObject
from utility.exceptions import IdsInstanceLoadError
from utility.exceptions import IdsAttributeLoadError
import numpy as np


    def load_profiles_from_ids(self, source):
        self.source = source
        try:
            self.profiles = self.imas_pointer.get(self.source)
        except:
            raise IdsInstanceLoadError('No ' + self.source + ' IDS was found for shot: '
                                       + str(self.shot) + ' at run ' + str(self.run))

    def get_grid_in_rho_tor_norm(self, time):
        time_index = self.get_time_index(time)
        try:
            return self.profiles.profiles_1d[time_index].grid.rho_tor_norm
        except:
            raise IdsAttributeLoadError('There is no available rho tor norm based grid for Shot:' +
                                        str(self.shot) + ' at Run: ' + str(self.run) + ' in ' + self.source + ' IDS.')

    def get_grid_in_psi(self, time):
        time_index = self.get_time_index(time)
        try:
            return self.profiles.profiles_1d[time_index].grid.psi
        except:
            raise IdsAttributeLoadError('There is no available psi based grid for Shot:' +
                                        str(self.shot) + ' at Run: ' + str(self.run) + ' in ' + self.source + ' IDS.')

    def get_grid_in_rho_tor(self, time):
        time_index = self.get_time_index(time)
        try:
            return self.profiles.profiles_1d[time_index].grid.rho_tor
        except:

            raise IdsAttributeLoadError('There is no available rho tor based grid for Shot:' +