~fluidity-core/fluidity/sea-ice-branch

« back to all changes in this revision

Viewing changes to tools/radial_scale.py

  • Committer: Simon Mouradian
  • Date: 2012-10-19 10:35:59 UTC
  • mfrom: (3520.32.371 fluidity)
  • Revision ID: simon.mouradian06@imperial.ac.uk-20121019103559-y36qa47phc69q8sc
mergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
2
 
3
 
from pylab import *
 
3
from math import sqrt, acos, atan, sin, cos
4
4
import argparse
5
5
import vtktools
6
6
 
19
19
 
20
20
R_geoid = 6.37101e+06
21
21
 
22
 
for vtu in range(size(args.input_vtu)):
 
22
for vtu in range(len(args.input_vtu)):
23
23
    vtu_name=args.input_vtu[vtu]
24
24
    output_filename=args.output_prefix+vtu_name
25
25
    vtu_object= vtktools.vtu(vtu_name)
29
29
    for i in range(npoints):
30
30
        (x,y,z) = vtu_object.ugrid.GetPoint(i)
31
31
        radius = sqrt( x**2 + y**2 + z**2 )
32
 
        theta = arccos(z/radius)
33
 
        phi = arctan(y/x)
 
32
        theta = acos(z/radius)
 
33
        phi = atan(y/x)
34
34
        new_radius= R_geoid - (R_geoid - radius)*scale_factor
35
35
        new_x=new_radius*sin(theta)*cos(phi)
36
36
        new_y=new_radius*sin(theta)*sin(phi)