Пример #1
0
 def _add_time_to_xAxis(self,
                        path,
                        var='Time',
                        data=[]):  # help function to add_to_x_axis
     timePath = findCorrespondingTime(path)
     time_data = combineYMDHMwithSec(timePath)
     self.add_to_x_axis(path, 'Time', time_data)
Пример #2
0
    def plot_var_time(path, var, fig):
        #retrive time data and if not possible just return
        axis = []
        data = []

        timePath = findCorrespondingTime(path)
        if timePath is "":
            return
        time_data = []
        time = combineYMDHMwithSec(timePath)
        for t in time:
            time_data.append(t)
        #retive y-axis data
        y = getDataFromVar(path, var)

        #Create plot
        axis.append(fig.add_subplot(1, 1, 1))
        axis[0].set_title(
            header_info_to_plot(path) + "\n " + "Plot " + name(var) +
            " versus Time ")
        if len(time_data) == len(y):
            #axis[0].xticks(rotation= 80)
            axis[0].plot(time_data, y)
            axis[0].set_xlabel('Time')
            axis[0].set_ylabel(name(var) + unit(var))
            #axis[0].set_xticklabels(axis[0].get_xticklabels(), rotation=80)
            data.append(pd.Series(y, index=time_data))
        else:
            raise ValueError('Time and data do not have same length')
        return axis, data
Пример #3
0
def header_plot(path):
    #get date of session
    timePath = findCorrespondingTime(path)
    if timePath != '':
        time = combineYMDHMwithSec(timePath)
        date = time[1].date()
        station = get_var_content_S1("Station", path) # Station is name of data that one seeks.
        return ( station + "   " + str(date) )
    else:
        return ('')
Пример #4
0
def checkIfTimeAvailable(paths, vars):
    c = 0
    for path in paths:
        timePath = findCorrespondingTime(path)
        if timePath is "":
            return False
        time_data = combineYMDHMwithSec(timePath)
        y = get_data_to_plot(path, vars[c])
        if len(time_data) != len(y[0]):
            return False
        c += 1
    return True
Пример #5
0
 def tableFunctionGeneral(self,paths,vars):
     self.data_reset()
     timePath = findCorrespondingTime(paths[0].strip())
     if os.path.isfile(timePath):
         time =  combineYMDHMwithSec(timePath)
         self.data[Tablefunction.time_key] = time
     c = 0
     for path in paths:
         y = get_data_to_table(path, vars[c])
         if len(y) == 1 :
             self.data[name(vars[c])] = y[0]
         else:
             for i in range(len(y)):
                 y[i]= np.squeeze(np.asarray(y[i])) # to convert matrix to array if needed
                 self.data[name(vars[c])+'#'+ str(i+1)] = y[i]
         c = c + 1
     return self.data
Пример #6
0
    def plot_two_var_time(paths, vars, fig):

        # Define return arrays'
        axis = []
        data = []

        #try to retrive time data, if can not just return
        timePath = findCorrespondingTime(paths[0])
        time = combineYMDHMwithSec(timePath)
        time_data = []
        i = 0
        for t in time:
            time_data.append(t)
        # retriv y-axis data
        y1 = getDataFromVar(paths[0], vars[0])
        y2 = getDataFromVar(paths[1], vars[1])

        if len(time) == len(y1) and len(time) == len(y2):
            axis.append(fig.add_subplot(1, 1, 1))
            #ax1 = fig.add_subplot(1,1,1)
            color = 'tab:red'
            axis[0].set_xlabel('Time H:M:S')
            axis[0].set_ylabel(name(vars[0]) + unit(paths[0], vars[0]))
            axis[0].plot(time_data, y1, color=color)
            #plt.xticks( rotation= 80 )
            axis[0].tick_params(axis=vars[0], labelcolor=color)
            axis.append(axis[0].twinx(
            ))  # instantiate a second y-axis that shares the same x-axis
            color = 'tab:blue'
            axis[1].plot(time_data, y2, color=color)
            axis[1].set_ylabel(name(vars[1]) + unit(paths[1], vars[1]))
            axis[1].tick_params(axis=vars[1], labelcolor=color)
            plt.title(
                header_info_to_plot(paths[0]) + "\nPlot " + name(vars[0]) +
                "and " + name(vars[1]) + " over time ")
            data.append(pd.Series(y1, index=time_data))
            data.append(pd.Series(y2, index=time_data))
            return axis, data
        else:
            print("Dimensions do not agree")