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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Python
 How to save a fit parameter
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

GuyLaser

Netherlands
3 Posts

Posted - 05/18/2024 :  4:52:56 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello,

I need help to save a fit parameter. I have a graph with inverse lorentzian fit and I need to extract the xc parameter(see picture)

I have used Code Builder with the following code:



# 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'

# 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('lorentz')
model.set_data(wks, 0, 1)
model.fit()

r, c = model.report(True)
wReport=op.find_sheet('w', r)
wReport.activate()



GHof

ChaoC

USA
174 Posts

Posted - 05/20/2024 :  09:52:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

You can use result() to create a dictionary of report table values.
https://docs.originlab.com/originpro/classoriginpro_1_1analysis_1_1NLFit.html#a4cce13ba6479d9c4abc4604fec3c1550

E.g.

xc=model.result()["xc"]

Best,
Chao
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000