/[escript]/trunk/downunder/py_src/datasources.py
ViewVC logotype

Diff of /trunk/downunder/py_src/datasources.py

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

revision 3956 by caltinay, Wed Sep 5 04:57:43 2012 UTC revision 3957 by caltinay, Wed Sep 5 23:49:23 2012 UTC
# Line 23  __all__ = ['DataSource','UBCDataSource', Line 23  __all__ = ['DataSource','UBCDataSource',
23    
24  import logging  import logging
25  import numpy as np  import numpy as np
 import pyproj  
26  from esys.escript import *  from esys.escript import *
27  from esys.escript.linearPDEs import *  from esys.escript.linearPDEs import *
28  import esys.escript.unitsSI as U  import esys.escript.unitsSI as U
# Line 33  try: Line 32  try:
32  except:  except:
33      pass      pass
34    
35  def LatLonToUTM(lon, lat, wkt_string):  def LatLonToUTM(lon, lat, wkt_string=None):
36        """
37        Converts one or more longitude,latitude pairs to the corresponding x,y
38        coordinates in the Universal Transverse Mercator projection.
39        If wkt_string is not given or invalid or the gdal module is not available
40        to convert the string, then the input values are assumed to be given in the
41        Clarke 1866 projection.
42        """
43    
44        # not really optimal: if pyproj is not installed we return the input
45        # values without modification.
46        try:
47            import pyproj
48        except:
49            print("Warning, pyproj not available. Domain extents will be wrong")
50            return lon,lat
51    
52        # determine UTM zone from the input data
53      zone=int(np.median((np.floor((np.array(lon) + 180)/6) + 1) % 60))      zone=int(np.median((np.floor((np.array(lon) + 180)/6) + 1) % 60))
54      try:      try:
55          import osgeo.osr          import osgeo.osr

Legend:
Removed from v.3956  
changed lines
  Added in v.3957

  ViewVC Help
Powered by ViewVC 1.1.26