The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Python
 Extract minimum of column fit data

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
GuyLaser Posted - 06/04/2024 : 03:52:43 AM
Hi,

I have another question about fitting. I have fit data with a polynomial function. Now I need to know how to get the minimum y value with the corresponding x value of the fit data. I have shown my code below, it is about the bold code at the bottom where things go wrong.
I did not succeed in getting the first 2 columns out of the FitNLCurve1 worksheet.



import originpro as op
import csv
import numpy as np
import time
import pandas as pd



#dont pay attention to this
n = 1

lijst_xc = np.zeros((n,2))
print(lijst_xc)



for i in range(n):
    time.sleep(1)
    # Create a new worksheet
    wks = op.new_sheet()

    # Specify the path to the CSV file
    #csv_file_path = 'C:\\Users\\PC-043012\\Desktop\\GuySimon\\test.csv'
    
    csv_file_path = f'C:\\Users\\PC-043012\\Desktop\\GuySimon\\sd\\sd_dpbs_2\\{str(i+1)}.csv'

    # Load only the 4th and 5th columns from the CSV file into the worksheet
    def load_csv_data(csv_file_path):
        x_values = []
        y_values = []
        with open(csv_file_path, 'r') as file:
            csvreader = csv.reader(file)
            for row in csvreader:
                # Extract the 4th and 5th columns and convert them to float
                x_value = float(row[3])  # Assuming the 4th column index is 3 (0-indexed)
                y_value = float(row[4])  # Assuming the 5th column index is 4 (0-indexed)
                # Add the values to the lists
                x_values.append(x_value)
                y_values.append(y_value)
        # Add the accumulated values to the worksheet
        wks.from_list(0, x_values, 'X')
        wks.from_list(1, y_values, 'Y')

    # Load data from the CSV file
    load_csv_data(csv_file_path)
    
    model = op.NLFit('Poly')
   
    model.set_data(wks, 0, 1)
    model.fit()

    
    r, c = model.report(True)
    wReport=op.find_sheet('w', r)
    wReport.activate()
    
    sheet = op.find_sheet('w', '[Boo5]FitNLCurve1')



Thank you in advance!

GHof
1   L A T E S T    R E P L I E S    (Newest First)
GuyLaser Posted - 06/04/2024 : 04:02:41 AM
Hi I fixed it!

GHof

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000