Extracting frequencies and S/N from all opened spectra

29 views
Skip to first unread message

Lee, Woonghee

unread,
Oct 16, 2020, 1:35:32 PM10/16/20
to nmr-s...@googlegroups.com

Hello-

 

Upon a request from one of users, I am giving a simple example python code that you can simply click “Load Modules…” button and select from Python shell “py” window. Basically, it generates .csv files in the same directory of the save files with assignment, frequencies, data height and signal-to-noise. You can easily customize as per your needs.

 

Woonghee

 

CODE:

 

import os

import sparky

s = sparky.session_list[0]

proj = s.project

spec_list = proj.spectrum_list()

for spec in spec_list:

  peak_list = spec.peak_list()

  csv_path = spec.save_path + '.csv'

  data = 'Assignment,'

  for i in range(spec.dimension):

    temp = 'w' + str(i+1) + ','

    data += temp

  data += 'Data Height,Signal-to-noise\n'

  for peak in peak_list:

    data += peak.assignment

    data += ','

    # Uncomment if ppm value is wanted. Header should be in line, too.

    #for i in range(spec.dimension):

    #  data += str(peak.frequency[i])

    #  data += ','

    for i in range(spec.dimension):

      data += str(peak.frequency[i] * spec.hz_per_ppm[i])

      data += ','

    data += str(peak.data_height)

    data += ','

    data += str(peak.data_height / spec.noise)

    data += '\n'

  f = open(csv_path, 'w')

  f.write(data)

  f.close()

 

   

 

 

--

Woonghee Lee, I.E.I.P., M.S., Ph.D.

 

Assistant Professor

Department of Chemistry

University of Colorado Denver

1151 Arapahoe St. (Science Bldg.) Rm 4128A

Denver, CO 80217-3364, USA

woongh...@ucdenver.edu

https://sites.google.com/view/wlee-group 

https://clas.ucdenver.edu/chemistry/woonghee-lee

 

Shipping/Mailing Address:

Woonghee Lee

1201 5th St. UCD CHEM-194

P.O. Box 173364 (USPS)

Denver, CO 80204, USA

 

extract_freq_s2n_sparky.py
Reply all
Reply to author
Forward
0 new messages