/[escript]/trunk/doc/examples/usersguide/int_save.py
ViewVC logotype

Diff of /trunk/doc/examples/usersguide/int_save.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2676 by jfenwick, Fri Sep 4 00:13:00 2009 UTC revision 2677 by jfenwick, Tue Sep 22 00:48:00 2009 UTC
# Line 38  toobig=100 #An exception will be thrown Line 38  toobig=100 #An exception will be thrown
38    
39  #In this example we will interpolate a sine curve  #In this example we will interpolate a sine curve
40  #The values we take from the domain will range from 0 to 1 (inclusive)  #The values we take from the domain will range from 0 to 1 (inclusive)
 #Because we will actually see the maximum value in the input we need to add  
 #an extra entry to the table (so we have 1.125 sine cycles)  
41    
42  sine_table=[0, 0.70710678118654746, 1, 0.70710678118654746, 0, -0.70710678118654746, -1, -0.70710678118654746, 0, 0.70710678118654746]  sine_table=[0, 0.70710678118654746, 1, 0.70710678118654746, 0, -0.70710678118654746, -1, -0.70710678118654746, 0]
43    
44  numslices=len(sine_table)-1  numslices=len(sine_table)-1
45    
46  minval=0  minval=0
47  maxval=1.125    # The extra 0.25 is to account for the extra entry in the table  maxval=1
48    
49  step=sup(maxval-minval)/numslices   #The width of the gap between entries in the table  step=sup(maxval-minval)/numslices   #The width of the gap between entries in the table
50    
# Line 60  saveDataCSV("1d.csv", inp=x0, out=result Line 58  saveDataCSV("1d.csv", inp=x0, out=result
58    
59  #This time the sine curve will be at full height along the x (ie x0) axis.  #This time the sine curve will be at full height along the x (ie x0) axis.
60  #Its amplitude will decrease to a flat line along x1=1.1  #Its amplitude will decrease to a flat line along x1=1.1
 #Since 1.1 is larger than any value in the input we don't need to add an extra row  
 #to our table  
61    
62  #Interpolate works with numpy arrays so we'll use them  #Interpolate works with numpy arrays so we'll use them
63  #st=numpy.array(sine_table)  st=numpy.array(sine_table)
64    
65  #table=[st, 0.5*st, 0*st ]   #Note that this table is 2D  table=[st, 0.5*st, 0*st ]   #Note that this table is 2D
66    
67  ##note that we call the interpolate table method on the object  ##note that we call the interpolate table method on the object
68  ##which corresponds to the outer dimension of the table  ##which corresponds to the outer dimension of the table
 #result2=x1.interpolateTable(table, 0, 0.55, x0, minval, step, 500)  
 #saveDataCSV("2d.csv",inp0=x0, inp2=x1, out=result2)  
69    result2=x1.interpolateTable(table, 0, 0.55, x0, minval, step, 500)
70    saveDataCSV("2d.csv",inp0=x0, inp2=x1, out=result2)

Legend:
Removed from v.2676  
changed lines
  Added in v.2677

  ViewVC Help
Powered by ViewVC 1.1.26