예제 #1
0
  def test_convert(self):
    from spatialdata.geocoords.CSGeo import CSGeo
    csNAD27 = CSGeo()
    csNAD27.inventory.ellipsoid = "clrk66"
    csNAD27.inventory.datumHoriz = "NAD27"
    csNAD27.inventory.datumVert = "mean sea level"
    csNAD27._configure()
    csNAD27.initialize()

    from spatialdata.geocoords.CSGeoLocalCart import CSGeoLocalCart
    csLocal = CSGeoLocalCart()
    csLocal.inventory.originLon = -100.0
    csLocal.inventory.originLat = 39.0
    from pyre.units.length import m
    csLocal.inventory.originElev = 0.01*m
    csLocal.inventory.ellipsoid = "clrk66"
    csLocal.inventory.datumHoriz = "NAD27"
    csLocal.inventory.datumVert = "mean sea level"
    csLocal._configure()
    csLocal.initialize()

    from spatialdata.geocoords.Converter import convert
    coordsXYZ = numpy.array(lonlatNAD27ElevVals)
    convert(coordsXYZ, csLocal, csNAD27)
    xyzLocalValsT = numpy.array(coordsXYZ)

    self.assertEqual(len(xyzLocalVals.shape), len(xyzLocalValsT.shape))
    for (xyz, xyzT) in zip(numpy.reshape(xyzLocalVals,-1),
                           numpy.reshape(xyzLocalValsT, -1)):
      self.assertAlmostEqual(1.0, xyz/xyzT, 6)
        
    return
예제 #2
0
  def test_convert(self):
    from spatialdata.geocoords.CSGeo import CSGeo
    csNAD27 = CSGeo()
    csNAD27.inventory.ellipsoid = "clrk66"
    csNAD27.inventory.datumHoriz = "NAD27"
    csNAD27.inventory.datumVert = "mean sea level"
    csNAD27._configure()
    csNAD27.initialize()

    from spatialdata.geocoords.CSGeoLocalCart import CSGeoLocalCart
    csLocal = CSGeoLocalCart()
    csLocal.inventory.originLon = -100.0
    csLocal.inventory.originLat = 39.0
    from pyre.units.length import m
    csLocal.inventory.originElev = 0.01*m
    csLocal.inventory.ellipsoid = "clrk66"
    csLocal.inventory.datumHoriz = "NAD27"
    csLocal.inventory.datumVert = "mean sea level"
    csLocal._configure()
    csLocal.initialize()

    from spatialdata.geocoords.Converter import convert
    coordsXYZ = numpy.array(lonlatNAD27ElevVals)
    convert(coordsXYZ, csLocal, csNAD27)
    xyzLocalValsT = numpy.array(coordsXYZ)

    self.assertEqual(len(xyzLocalVals.shape), len(xyzLocalValsT.shape))
    for (xyz, xyzT) in zip(numpy.reshape(xyzLocalVals,-1),
                           numpy.reshape(xyzLocalValsT, -1)):
      self.assertAlmostEqual(1.0, xyz/xyzT, 6)
        
    return
예제 #3
0
 def convert(self, points):
     """
 Transform coordinates of points from one coordinate system to another.
 """
     self._initialize()
     from spatialdata.geocoords.Converter import convert
     convert(points, self.csDest, self.csSrc)
     return
예제 #4
0
 def convert(self, points):
   """
   Transform coordinates of points from one coordinate system to another.
   """
   self._initialize()
   from spatialdata.geocoords.Converter import convert
   convert(points, self.csDest, self.csSrc)
   return
예제 #5
0
    def test_cart(self):
        from spatialdata.geocoords.CSCart import CSCart
        csKm = CSCart()
        csKm.inventory.units = "km"
        csKm.inventory.spaceDim = 2
        csKm._configure()

        csM = CSCart()
        csM.inventory.units = "m"
        csM.inventory.spaceDim = 2
        csM._configure()

        from spatialdata.geocoords.Converter import convert
        xy = numpy.array(xyKm)
        convert(xy, csM, csKm)

        xyM = xyKm * 1.0e+3
        self.assertEqual(len(xyM.shape), len(xy.shape))
        for (xyE, xyT) in zip(numpy.reshape(xyM, -1), numpy.reshape(xy, -1)):
            self.assertAlmostEqual(xyE, xyT, 4)
예제 #6
0
    def test_geo(self):
        from spatialdata.geocoords.CSGeo import CSGeo
        csNAD27 = CSGeo()
        csNAD27.inventory.crsString = "EPSG:4267"
        csNAD27.inventory.spaceDim = 2
        csNAD27._configure()

        csWGS84 = CSGeo()
        csWGS84.inventory.crsString = "EPSG:4326"
        csWGS84.inventory.spaceDim = 2
        csWGS84._configure()

        from spatialdata.geocoords.Converter import convert
        lonlat = numpy.array(lonlatNAD27)
        convert(lonlat, csWGS84, csNAD27)

        self.assertEqual(len(lonlatWGS84.shape), len(lonlat.shape))
        for (ll, llT) in zip(numpy.reshape(lonlatWGS84, -1),
                             numpy.reshape(lonlat, -1)):
            self.assertAlmostEqual(ll, llT, 4)
예제 #7
0
    def preinitialize(self, problem):
        """Do mimimal initialization.
        """
        OutputSoln.preinitialize(self, problem)

        stationNames, stationCoords = self.reader.read()

        # Convert to mesh coordinate system
        from spatialdata.geocoords.Converter import convert
        convert(stationCoords,
                problem.mesh().getCoordSys(), self.reader.coordsys)

        # Nondimensionalize
        stationCoords /= problem.normalizer.lengthScale.value

        ModuleOutputSolnPoints.setPoints(self, stationCoords, stationNames)

        identifier = self.aliases[-1]
        self.writer.setFilename(problem.defaults.outputDir,
                                problem.defaults.simName, identifier)
        return
예제 #8
0
  def initialize(self, mesh, normalizer):
    """
    Initialize output manager.
    """
    logEvent = "%sinit" % self._loggingPrefix
    self._eventLogger.eventBegin(logEvent)    

    OutputManager.initialize(self, normalizer)

    # Read points
    self.stations,points = self.reader.read()
    
    # Convert to mesh coordinate system
    from spatialdata.geocoords.Converter import convert
    convert(points, mesh.coordsys(), self.coordsys)

    ModuleOutputSolnPoints.setupInterpolator(self, mesh, points, normalizer)
    self.mesh = ModuleOutputSolnPoints.pointsMesh(self)

    self._eventLogger.eventEnd(logEvent)
    return
예제 #9
0
  def _genSpatialDB(self, f):
    """
    Computes dislocations/displacements from Euler pole and writes to
    spatial DB.
    """

    # Get lat/lon values corresponding to UTM points.
    self.srcCoordSys.initialize()
    self.destCoordSys.initialize()

    from spatialdata.geocoords.Converter import convert
    pointsLL = numpy.array(self.pointsUTM,
                           dtype=numpy.float64).reshape(self.numPoints,
                                                  self.spaceDim)
    convert(pointsLL, self.destCoordSys, self.srcCoordSys)

    normalsArr = numpy.array(self.normals,
                             dtype=numpy.float64).reshape(self.numPoints,
                                                    self.spaceDim)
    
    iCount = 0
    velocity = [0.0, 0.0, 0.0]
    for point in range(self.numPoints):
      inRange = self._testRange(self.pointsUTM[iCount:iCount+3])
      if inRange:
        velocity = self._euler2Velocity(pointsLL[point])
        if self.bcType == 'dislocation':
          vlocal = self._localTrans(velocity, normalsArr[point])
          velocity = self.bcScale * vlocal
      else:
        velocity[0] = self.bcScale * self.defaultValues[0]
        velocity[1] = self.bcScale * self.defaultValues[1]
        velocity[2] = self.bcScale * self.defaultValues[2]
      for dim in range(self.spaceDim):
        f.write(' %.12e' % self.pointsUTM[iCount + dim])
      for dim in range(self.spaceDim):
        f.write(' %.12e' % velocity[dim])
      f.write('\n')
      iCount += 3
    return
예제 #10
0
  def _genSpatialDB(self, f):
    """
    Computes dislocations/displacements from Euler pole and writes to
    spatial DB.
    """

    # Get lat/lon values corresponding to UTM points.
    self.srcCoordSys.initialize()
    self.destCoordSys.initialize()

    from spatialdata.geocoords.Converter import convert
    pointsLL = numpy.array(self.pointsUTM,
                           dtype=numpy.float64).reshape(self.numPoints,
                                                  self.spaceDim)
    convert(pointsLL, self.destCoordSys, self.srcCoordSys)

    normalsArr = numpy.array(self.normals,
                             dtype=numpy.float64).reshape(self.numPoints,
                                                    self.spaceDim)
    
    iCount = 0
    velocity = [0.0, 0.0, 0.0]
    for point in range(self.numPoints):
      inRange = self._testRange(self.pointsUTM[iCount:iCount+3])
      if inRange:
        velocity = self._euler2Velocity(pointsLL[point])
        if self.bcType == 'dislocation':
          vlocal = self._localTrans(velocity, normalsArr[point])
          velocity = self.bcScale * vlocal
      else:
        velocity[0] = self.bcScale * self.defaultValues[0]
        velocity[1] = self.bcScale * self.defaultValues[1]
        velocity[2] = self.bcScale * self.defaultValues[2]
      for dim in range(self.spaceDim):
        f.write(' %.12e' % self.pointsUTM[iCount + dim])
      for dim in range(self.spaceDim):
        f.write(' %.12e' % velocity[dim])
      f.write('\n')
      iCount += 3
    return
예제 #11
0
    def initialize(self, mesh, normalizer):
        """
        Initialize output manager.
        """
        logEvent = "%sinit" % self._loggingPrefix
        self._eventLogger.eventBegin(logEvent)

        OutputManager.initialize(self, normalizer)

        # Read points
        stations, points = self.reader.read()

        # Convert to mesh coordinate system
        from spatialdata.geocoords.Converter import convert
        convert(points, mesh.coordsys(), self.coordsys)

        ModuleOutputSolnPoints.setupInterpolator(self, mesh, points, stations,
                                                 normalizer)
        self.mesh = ModuleOutputSolnPoints.pointsMesh(self)

        self._eventLogger.eventEnd(logEvent)
        return
예제 #12
0
def geoToMesh(xyz):
    """Convert coordinates from geographic coordinates to mesh coordinates.
    """
    from spatialdata.geocoords.Converter import convert
    convert(xyz, cs_mesh(), cs_geo3D())
    return
예제 #13
0
파일: coordsys.py 프로젝트: xiaoxiz/pylith
def geoToMesh(xyz):
    """Convert coordinates from geographic coordinates to mesh coordinates.
    """
    from spatialdata.geocoords.Converter import convert
    convert(xyz, cs_mesh(), cs_geo3D())
    return