Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #2897 > unrolled thread

loop issues

Started bys0198362 <adrian.h.hill@gmail.com>
First post2015-05-10 02:40 -0700
Last post2015-05-10 02:40 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.graphics.apps.gnuplot


Contents

  loop issues s0198362 <adrian.h.hill@gmail.com> - 2015-05-10 02:40 -0700

#2897 — loop issues

Froms0198362 <adrian.h.hill@gmail.com>
Date2015-05-10 02:40 -0700
Subjectloop issues
Message-ID<8a34ca12-c290-46d7-9065-d40beb4b8d04@googlegroups.com>
Hi, I am trying to simplify a script of mine.  Currently I evaluate a series of data sets over a specific xrange for the max value.  I then output the max value in each data set to a txt file, which will be plotted later.  This is then repeated over various different x-ranges.

I currently have a long script where I have to reset things and change output titles to make it work correctly.  I am now trying to simplify the script but can't seem to get it to work.  I have attached the relevant parts of the scripts below.  If anyone has tips on how to get my simple one to work I would be very thankful.

I realise it may be confusing, so please do ask for clarification if needed.

Thanks

Adrian

####  This works, but is long and cumbersome ###################################

list = system('dir /b *.xy')
FILES = words(list)
FILE(i) = word(list,i)
#Creates a temporary list of all files in the directory with extension .xy 

#### 332 ####

set xrange [12.8:12.9]
set yrange [*:*]

do for [i=1:FILES:1] {
	stats FILE(i) every ::2301::2341 u 2 name 'evaluateA'
	scan_number =FILE(i)
	maximumA = evaluateA_max

	if (i==1){
	set print '332_intensity.txt'
	} else {
	set print '332_intensity.txt' append
	}
	print scan_number[16:21] , ' ', maximumA
	unset print
}

reset
clear

#### 051####

set xrange [12.36:12.48]
set yrange [*:*]

do for [i=1:FILES:1] {
	stats FILE(i) every ::2301::2341 u 2 name 'evaluateB'
	scan_number =FILE(i)
	maximumB = evaluateB_max

	if (i==1){
	set print '051_intensity.txt'
	} else {
	set print '051_intensity.txt' append
	}
	print scan_number[16:21] , ' ', maximumB
	unset print
}

reset
clear

################################################################################



####  My attemped simplification ###############################################


list = system('dir /b *.xy')
FILES = words(list)
FILE(i) = word(list,i)
#Creates a temporary list of all files in the directory with extension .xy 

stth = "12.80 12.36 12.57 12.70 12.90" # start tth
etth = "12.90 12.48 12.67 12.80 13.08" # end tth
bragg = "332 051 151 303 133"				# index
#two-theta ranges and index of interest

do for [j=1:words(stth):1] {
	set xrange [word(stth,j):word(etth,j)]
	show xrange
	set yrange [*:*]


	do for [i=1:FILES:1] {
		stats FILE(i) every ::2301::2341 u 2 name 'evaluate'
		scan_number =FILE(i)
		maximum = evaluate_max

		#print word(bragg,j)

		if (i==1){
			set print word(bragg,j)"_Intensity.txt"
		} else {
			set print word(bragg,j)"_Intensity.txt" append
		}

		print scan_number[16:21] , ' ', maximum
	}
}


################################################################################

[toc] | [standalone]


Back to top | Article view | comp.graphics.apps.gnuplot


csiph-web