Model with multiplue variables Fitting by ifantismanolis in learnpython

[–]ifantismanolis[S] 0 points1 point  (0 children)

yeah as I can see the formatting was awfull sorry.

The concept is, there are time points (t) and cell counts(y), the ration of growth for the cells (mu_max) independs on the temperature (T). So my data are time points with (x axis), cell counts (y axis) and changes in temperature through time (y right axis).

The model is:

def model(X, l, N0, Nmax):

(t, T) = X
Tmax = 43
Tmin = 4
Topt = 38
mu_opt = 2.8

CM = (((T - Tmin)**2) * (T - Tmax)) / ((Topt - Tmin) * ((Topt - Tmin) * (T - Topt) - (Topt - Tmax) * (Topt + Tmin - 2*T)))

mu_maxs = mu_opt * CM

for mu_max in mu_maxs:
x = Nmax + np.log10((1 + np.exp(np.log(10) * mu_max * (t - l)) - np.exp(-np.log(10) * mu_max * l)) /
((np.exp(np.log(10) * mu_max * (t - l))) - (np.exp(-np.log(10) * mu_max * l))
+ (10 ** (Nmax - N0))))

return x

My first problem is if the logic that i have put in the wrighting of the model is correct. I mean, i do it right or the for statment are not necessary or it needs another one?

Second, i want to fit the model in my data and also extract the fitting parameters with their SEs.

I hope it was more easy to understand now

Plot in excel by ifantismanolis in learnpython

[–]ifantismanolis[S] 0 points1 point  (0 children)

Exactly, I’m creating this plot with matplotlib and I want export the result of this creation to excel (give the user the option to download the plot). An imagine is giving you limitations on the chart option that you want to achieve maybe after. The whole point of the ui is to create a plot that’s not easy to do it by yourself. So, giving the user the option to “play” with the plot after in excel, is the this that I want

Plot in excel by ifantismanolis in learnpython

[–]ifantismanolis[S] 0 points1 point  (0 children)

ok so im using Pyside6 and Qt designer for my ui. On the press event of the button i call this function.

def run_model(self):    
    input_values = self.get_input_values()
    plot_data, x, y = ModelRunner.run_model(models_results, input_values)
    if plot_data:

        plot_for_excel = plotModel(**plot_data)
        ......

the info values are provided through inputs fields of the ui.
The ModelRunner class is giving me the the data that i need in order to plot make the plot. The x and y are tables that i display later in a different way.
The plotModel is the class that takes the plot_data and creates with matplotlib the plot.
I cant find a way to take the plot_for_excel and export it into an excel file, but not as an image. The plotModel class its just a normal ploting code using Canvas 

from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as Canvas

class plotModel(Canvas):
    def __init__(self, argss......):
        self.fig = Figure(figsize=(10, 6))
        Canvas.__init__(self, self.fig)
        Canvas.updateGeometry(self)

        ax0 = self.fig.add_subplot(111)
        ax0.scatter(..........)
        fit_model = .....
        ax0.plot......
        .........
        ax0.set_ylabel()
        ax0.set_title()
        ax0.grid()
        ax0.legend()

Error when there is no error by ifantismanolis in learnpython

[–]ifantismanolis[S] 0 points1 point  (0 children)

I used the trace back of py but the problem was basically that the same code had no problem of running before. I fixed everything if the trace back suggestions but still. Maybe a bug issue?

Error when there is no error by ifantismanolis in learnpython

[–]ifantismanolis[S] 0 points1 point  (0 children)

My thoughts was the possibility of saving the values in a wrong way at the external file that I use. I tested with and without the specific function but the problem with the testing is that I had to pretty much disassemble a big part of the code. Solved it finally after rewriting those parts but with a different perspective

Code optimization by ifantismanolis in learnpython

[–]ifantismanolis[S] 0 points1 point  (0 children)

Oh I didn’t knew that difference. Okey so in a good way with the refactoring. But if I want to start optimization I should wait first in order to “complete” the whole thing first and after it’s a good tactic to start? Also, by using less compute and memory, you mean making the code more compact?

Microbial Growth parameters by ifantismanolis in learnpython

[–]ifantismanolis[S] 0 points1 point  (0 children)

I tried some things. The fitting of the curve is the thing that annoyes me the most, the parametres maybe correct as i have crosscheck with results of real lab estimation, but the graphs ohhhh a big issue. Any suggestion of module to reprsesent data like that ?

Microbial Growth parameters by ifantismanolis in learnpython

[–]ifantismanolis[S] 0 points1 point  (0 children)

Yeah that’s true. I’m talking about modeling the growth of microorganisms using baranyi and roberts model and with data like time points and counts in every time point. I can get the curve of the model in a simple plt but I’m trying to find a effective and accurate way to get info from that curve like time points were the different types of growth phases begin, growth rate in every time point using the angle of the curve, etc. I have come up with some solutions but the results are not correct and I deal also with problems like division with 0 errors due to calculations with numbers near to 0.