[1790] | 1 | #input_file = 'wool_100m.txt' |
---|
| 2 | #output_file = 'wool_100m_fer.txt' |
---|
| 3 | #variable = 'wool_100m' |
---|
| 4 | #journal_file = 'wool_100m.jnl' |
---|
| 5 | #journal_file = 'Port_Kembla_10m.jnl' |
---|
| 6 | #variable = 'Port_Kembla_10m' |
---|
| 7 | #input_file = 'Port_Kembla_10m.txt' |
---|
| 8 | #output_file = 'Port_Kembla_10m_fer.txt' |
---|
| 9 | #input_file = 'Botany_Bay_10m.txt' |
---|
| 10 | #output_file = 'Botany_Bay_fer_10m.txt' |
---|
| 11 | #variable = 'Botany_Bay_10m' |
---|
| 12 | #journal_file = 'Botany_Bay_10m.jnl' |
---|
| 13 | |
---|
| 14 | #input_file = 'Botany_Bay_100m.txt' |
---|
| 15 | #output_file = 'Botany_Bay_fer_100m.txt' |
---|
| 16 | #variable = 'Botany_Bay_100m' |
---|
| 17 | #journal_file = 'Botany_Bay_100m.jnl' |
---|
| 18 | |
---|
| 19 | #input_file = 'Botany_Bay_200m.txt' |
---|
| 20 | #output_file = 'Botany_Bay_fer_200m.txt' |
---|
| 21 | #variable = 'Botany_Bay_200m' |
---|
| 22 | #journal_file = 'Botany_Bay_200m.jnl' |
---|
| 23 | |
---|
| 24 | input_file = 'wool_200m.txt' |
---|
| 25 | output_file = 'wool_200m_fer.txt' |
---|
| 26 | variable = 'wool_200m' |
---|
| 27 | journal_file = 'wool_200m.jnl' |
---|
| 28 | |
---|
| 29 | #input_file = 'aus_coast_most_smooth.txt' |
---|
| 30 | #output_file = 'aus_coast_fer_smooth.txt' |
---|
| 31 | |
---|
| 32 | in_file = open(input_file,'r') |
---|
| 33 | print 'reading header' |
---|
| 34 | nx_ny_str = in_file.readline() |
---|
| 35 | nx_str,ny_str = nx_ny_str.split() |
---|
| 36 | nx = int(nx_str) |
---|
| 37 | ny = int(ny_str) |
---|
| 38 | h1_list=[] |
---|
| 39 | for i in range(nx): |
---|
| 40 | h1_list.append(in_file.readline()) |
---|
| 41 | |
---|
| 42 | x_min = float(h1_list[0]) |
---|
| 43 | x_max = float(h1_list[-1]) |
---|
| 44 | x_inc = (x_max-x_min)*1.0000001/float(nx-1) |
---|
| 45 | |
---|
| 46 | h2_list=[] |
---|
| 47 | for j in range(ny): |
---|
| 48 | h2_list.append(in_file.readline()) |
---|
| 49 | |
---|
| 50 | y_min = float(h2_list[-1]) |
---|
| 51 | y_max = float(h2_list[0]) |
---|
| 52 | y_inc = (y_max-y_min)*1.00000001/float(ny-1) |
---|
| 53 | |
---|
| 54 | print 'reading depths' |
---|
| 55 | in_depth_list = in_file.readlines() |
---|
| 56 | in_file.close() |
---|
| 57 | |
---|
| 58 | out_depth_list = [] |
---|
| 59 | |
---|
| 60 | for j in range(ny): |
---|
| 61 | out_depth_list.append('') |
---|
| 62 | |
---|
| 63 | print 'processing depths' |
---|
| 64 | k=1 |
---|
| 65 | for in_line in in_depth_list: |
---|
| 66 | for string in in_line.split(): |
---|
| 67 | #j = k/nx |
---|
| 68 | out_depth_list[(k-1)/nx]=out_depth_list[(k-1)/nx]+('%s '%string) |
---|
| 69 | if k-(k/nx)*nx ==0: |
---|
| 70 | out_depth_list[(k-1)/nx]=out_depth_list[(k-1)/nx]+'\n' |
---|
| 71 | if k==nx*ny: |
---|
| 72 | break |
---|
| 73 | k+=1 |
---|
| 74 | |
---|
| 75 | in_file.close() |
---|
| 76 | |
---|
| 77 | out_depth_list.reverse() |
---|
| 78 | |
---|
| 79 | depth_list = out_depth_list |
---|
| 80 | |
---|
| 81 | print 'writing results' |
---|
| 82 | out_file = open(output_file,'w') |
---|
| 83 | |
---|
| 84 | for line in depth_list: |
---|
| 85 | out_file.write(line) |
---|
| 86 | |
---|
| 87 | out_file.close() |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | jnl_file = open(journal_file,'w') |
---|
| 91 | |
---|
| 92 | jnl_file.write('DEFINE AXIS/X=%10.10fe:%10.10fe:%10.10f/unit=degree xlong\n'%(x_min,x_max,x_inc)) |
---|
| 93 | jnl_file.write('DEFINE AXIS/Y=%10.10fn:%10.10fn:%10.10f/unit=degree ylat\n'%(y_min,y_max,y_inc)) |
---|
| 94 | jnl_file.write('DEFINE GRID/x=xlong/y=ylat Pacific\n') |
---|
| 95 | jnl_file.write('FILE/VARIABLES=%s/COLUMNS=%i/GRID=Pacific %s\n'%(variable,nx,output_file)) |
---|
| 96 | jnl_file.write('shade/pal=land_sea/lev=(-60,60,1) -1*%s\n'%variable) |
---|
| 97 | jnl_file.close() |
---|
| 98 | |
---|
| 99 | |
---|