Example #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
Example #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
Example #3
0
  def test_initialize(self):
    from spatialdata.geocoords.CSGeoLocalCart import CSGeoLocalCart
    cs = CSGeoLocalCart()
    cs.inventory.originLon = -120.0
    cs.inventory.originLat = 38.4
    from pyre.units.length import m
    cs.inventory.originElev = 12.0*m
    cs.inventory.ellipsoid = "clrk66"
    cs.inventory.datumHoriz = "NAD27"
    cs.inventory.datumVert = "mean sea level"
    cs.inventory.units = "km"
    cs._configure()
    cs.initialize()

    self.assertEqual("clrk66", cs.ellipsoid())
    self.assertEqual("NAD27", cs.datumHoriz())
    self.assertEqual("mean sea level", cs.datumVert())
    self.assertEqual(True, cs.isGeocentric())
    self.assertEqual(1.0e+3, cs.toMeters())
    self.assertEqual(3, cs.spaceDim())

    (lon, lat, elev) = cs.origin()
    self.assertAlmostEqual(-120.0, lon, 6)
    self.assertAlmostEqual(38.4, lat, 6)
    self.assertAlmostEqual(12.0, elev, 6)

    return
Example #4
0
  def test_main(self):
    """
    Test main().
    """
    filename = "in.txt"

    from spatialdata.utils.PointsStream import PointsStream
    s = PointsStream()
    s.inventory.filename = filename
    s.inventory.numFormat = "%20.8e"
    s._configure()
    
    s.write(lonlatNAD27ElevVals)

    from spatialdata.geocoords.CSGeo import CSGeo
    csNAD27 = CSGeo()
    csNAD27.inventory.ellipsoid = "clrk66"
    csNAD27.inventory.datumHoriz = "NAD27"
    csNAD27.inventory.datumVert = "mean sea level"
    csNAD27._configure()

    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()

    from spatialdata.utils.ChangeCoordSys import ChangeCoordSys
    converter = ChangeCoordSys()
    converter.inventory.csDest = csLocal
    converter.inventory.csSrc = csNAD27
    converter._configure()

    from spatialdata.utils.ConvertApp import ConvertApp
    reader = PointsStream()
    reader.inventory.filename = filename
    reader.inventory.numFormat = "%20.8e"
    reader._configure()

    writer = PointsStream()
    writer.inventory.filename = "out.txt"
    writer.inventory.numFormat = "%20.8e"
    writer._configure()

    app = ConvertApp()
    app.inventory.reader = reader
    app.inventory.writer = writer
    app.inventory.converter = converter
    app._configure()

    app.main()

    points = writer.read()
    self.assertEqual(len(xyzLocalVals.shape), len(points.shape))
    for dE,d in zip(xyzLocalVals.shape, points.shape):
      self.assertEqual(dE, d)
    for vE,v in zip(numpy.reshape(xyzLocalVals, -1),
                    numpy.reshape(points, -1)):
      self.assertAlmostEqual(1.0, vE/v, 6)
    return
Example #5
0
    def test_main(self):
        """
    Test main().
    """
        filename = "in.txt"

        from spatialdata.utils.PointsStream import PointsStream
        s = PointsStream()
        s.inventory.filename = filename
        s.inventory.numFormat = "%20.8e"
        s._configure()

        s.write(lonlatNAD27ElevVals)

        from spatialdata.geocoords.CSGeo import CSGeo
        csNAD27 = CSGeo()
        csNAD27.inventory.ellipsoid = "clrk66"
        csNAD27.inventory.datumHoriz = "NAD27"
        csNAD27.inventory.datumVert = "mean sea level"
        csNAD27._configure()

        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()

        from spatialdata.utils.ChangeCoordSys import ChangeCoordSys
        converter = ChangeCoordSys()
        converter.inventory.csDest = csLocal
        converter.inventory.csSrc = csNAD27
        converter._configure()

        from spatialdata.utils.ConvertApp import ConvertApp
        reader = PointsStream()
        reader.inventory.filename = filename
        reader.inventory.numFormat = "%20.8e"
        reader._configure()

        writer = PointsStream()
        writer.inventory.filename = "out.txt"
        writer.inventory.numFormat = "%20.8e"
        writer._configure()

        app = ConvertApp()
        app.inventory.reader = reader
        app.inventory.writer = writer
        app.inventory.converter = converter
        app._configure()

        app.main()

        points = writer.read()
        self.assertEqual(len(xyzLocalVals.shape), len(points.shape))
        for dE, d in zip(xyzLocalVals.shape, points.shape):
            self.assertEqual(dE, d)
        for vE, v in zip(numpy.reshape(xyzLocalVals, -1),
                         numpy.reshape(points, -1)):
            self.assertAlmostEqual(1.0, vE / v, 6)
        return
Example #6
0
    def test_initialize(self):
        from spatialdata.geocoords.CSGeoLocalCart import CSGeoLocalCart
        cs = CSGeoLocalCart()
        cs.inventory.originLon = -120.0
        cs.inventory.originLat = 38.4
        from pyre.units.length import m
        cs.inventory.originElev = 12.0 * m
        cs.inventory.ellipsoid = "clrk66"
        cs.inventory.datumHoriz = "NAD27"
        cs.inventory.datumVert = "mean sea level"
        cs.inventory.units = "km"
        cs._configure()
        cs.initialize()

        self.assertEqual("clrk66", cs.ellipsoid())
        self.assertEqual("NAD27", cs.datumHoriz())
        self.assertEqual("mean sea level", cs.datumVert())
        self.assertEqual(True, cs.isGeocentric())
        self.assertEqual(1.0e+3, cs.toMeters())
        self.assertEqual(3, cs.spaceDim())

        (lon, lat, elev) = cs.origin()
        self.assertAlmostEqual(-120.0, lon, 6)
        self.assertAlmostEqual(38.4, lat, 6)
        self.assertAlmostEqual(12.0, elev, 6)

        return