Differences

This shows you the differences between two versions of the page.

Link to this comparison view

documentation:language_reference:objects:spectra:functions:clone [2016/09/25 23:23] – created Maurits W. Haverkortdocumentation:language_reference:objects:spectra:functions:clone [2016/10/10 09:41] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====== Clone ======
  
 +###
 +Creates a copy of the spectrum. The input //G1 = G2// creates two pointers to the same object. Changing //G1// will change //G2//. //G1=Spectra.Clone(G2)// will create two different objects.
 +###
 +
 +===== Example =====
 +
 +###
 +The following example creates a clone of //G// and stores this in the variable //GClone//. Next it sets //G2// equal to //G//. Shifting //G2// will also lead to a shift in //G//. //GClone// is independent of //G//.
 +###
 +
 +==== Input ====
 +<code Quanty Example.Quanty>
 +dofile("definitions.Quanty")
 +
 +GClone = Spectra.Clone(G)
 +G2 = G
 +G2.Shift(0.5)
 +
 +G.Print({{"file","Spectra.dat"}})
 +G2.Print({{"file","Spectra2.dat"}})
 +GClone.Print({{"file","Spectra.Clone.dat"}})
 +
 +gnuplotScript = gnuplotHead .. [[
 +set output "Spectra.Clone.ps"
 +plot "Spectra.dat"  using 1:(-$3+8) title 'G' with lines ls  1,\
 +     "Spectra2.dat"  using 1:(-$3+4) title 'G2' with lines ls  2,\
 +     "Spectra.Clone.dat"  using 1:(-$3) title 'Gclone' with lines ls  3
 +]]
 +
 +file = io.open("Spectra.Clone.gnuplot", "w")
 +file:write(gnuplotScript)
 +file:close()
 +
 +os.execute("gnuplot Spectra.Clone.gnuplot")
 +os.execute("convert -density 1024 Spectra.Clone.ps -resize 1024 Spectra.Clone.png")
 +</code>
 +
 +==== Result ====
 +The resulting picture is:
 +{{:documentation:language_reference:objects:spectra:functions:spectra.clone.png?nolink |}}
 +
 +===== Available functions =====
 +{{indexmenu>.#1}}
Print/export