Load spectre

modou
Posts: 17
Joined: 2017-01-05
Location: Senegal

Dear,
I would like to load several spectra in a file.When I load one spectre I use this program:
// Spectre
//-------------------------------------------------------
Macro SpectreTotal(ctrlName) : ButtonControl
String ctrlName

KillWaves/Z Wavelength,Intensity
dowindow/K Graph0
dowindow/K Table0
LoadWave/A/G
String list = waveList("*", ";", "")
String traceName
variable i
variable/G cpix,Lgond
String/G mypath=S_path
variable/G npt

traceName = StringFromList(0, list)
npt=pnt2x($traceName,numpnts($traceName)-1)+1 // N = numpnts(waveName)
Make/O/N=(npt) Wavelength=$traceName
traceName = StringFromList(1, list)
Make/O/N=(npt) Intensity=$traceName
edit Intensity,Wavelength
display /W=(10, 20, 600, 400) Intensity vs Wavelength
ModifyGraph rgb=(0,0,0)
Label left "\\u#2Intensité (u.a.)";DelayUpdate
Label bottom "\\u#2longueur d'onde (A°)"
KillWaves/Z wave0,wave1
ShowInfo
End


ChrLie
Posts: 241
Joined: 2009-01-06
Location: Switzerland

You have been asked so many times to post properly formatted code, for instructions see here:

http://www.igorexchange.com/node/3221

So, please!


HJDrescher
Posts: 274
Joined: 2015-01-20
Location: Germany

Yes! Please use properly formatted code.

I really helps us to provide help.

I am rather sure that you do not know what this code is doing. This is perfectly fine for a beginner.

    However, here is some homework:

  1. Add a comment to each line what the specific line does (Here you will learn how to code !)
  2. Post the commented code in Igor tags.
    Once you are done with that, do the following:

  1. Describe your problem in a similar way (What each line of code in YOUR program should do)
  2. Read the chapter covering loops in the online help or the manual
  3. Use the lines with similar description from your posted code to produce YOUR new code
  4. Post your NEW code (with Igor tags!)

HJ


[ last edited March 20, 2017 - 05:41 ]
xufriedman
Posts: 21
Joined: 2008-05-09
Location: United States

It is a little unclear what you are trying to do, and more context would be very helpful (what are graph0, table0, wave0, wave1? why are the loaded waves killed at the end?). If I guess right, it seems the user specifies two waves to load (wave0 = wavelength? wave1 = intensity?), then they are displayed in a graph (graph0?) and table (table0?). So, the my questions are:

  • What are the multiple waves you want to read in? Are they all in the same folder on disk?
  • Do you want to ask the user each time to specify each wave to read? Or does the user specify the folder, and your routine goes and finds them all?
  • Do you want to edit them all? Display them all? In the same graph/table? Each in its own?

You probably want to think about how you will specify the files you want to load. If you can get that in a list, then you can make a loop that goes through that list, and loads them in, appending to one graph, or displaying each in its own graph. Ditto with tables. If the files are not cleverly named so wavelength and intensity can be identified, that will be tricky to automate. Anyway, it would be helpful to explain the context better.

-Matthew


HJDrescher
Posts: 274
Joined: 2015-01-20
Location: Germany

It is a piece of code from somewhere else... Thus the "homework" ;-)
HJ


[ last edited March 22, 2017 - 14:38 ]
Posts: 1708
Joined: 2007-06-29
Location: United States

And I answered a previous, identical post, with this:
DisplayHelpTopic "Loading Waves Using Igor Procedures"

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com


Back to top