Actually, if I may rewrite some sections of your code -
> > example of (1):
> > ---------------------------------------------------------
> > #this part of the program reads the file basin.out (the data we want to
> > analyze) and changes its contents to the array arr_xy
> > #layout of basin.out:
> > #1 -950.00 10.00 200 > this line contains start, interval and
> > number of x values;
> > # 0.000000E+00 > remainder is a column of y values
> > # -1.931787E-07
> > # -5.713295E-07
> > # -9.322559E-07
> > # -1.071361E-06
> > # -7.801342E-07
> > # .....
So to clarify the first line has 4 values? Are they likely to be
separated by whitespace characters other than space? If not, then you
could just use a = firstline.split(" ") instead of
> > p = re.compile(r'\s+')
> > list = p.split(firstline)
>start = int(float(list[1]))
> interval = int(float(list[2]))
> n = int(float(list[3]))
list[1] is a string, so if I'm not missing something, start =
int(list[1]) will do just fine.
>>arr_x = range(start, stop, interval) #the calculated x-values are stored
> > in 1D array arr_x (note, fake array, is really a list)
> >
> > #the list of calculated x values, together with the y values in the
> > cobra_xy_file have to be put in an array: arr_xy
> > #first define the new array:
> > arr_xy = []
> >
> > #then fill the array with the x and y values:
> > for i in range(0, len(arr_x)):
> > sub_arr_xy = []
> > sub_arr_xy.append(arr_x[i])
> > sub_arr_xy.append(float(cobra_xy_file.readline()))
> > arr_xy.append(sub_arr_xy)
arr_xy=[]
for i in range(start, stop, interval):
sub_arr_xy = []
sub_arr_xy.append(i)
sub_arr_xy.append(float(cobra_xy_file.readline() ) )
arr_xy.append(sub_arr_xy)
Should do the same thing.
Good luck,
Liam Clarke
--
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor