def create_geosetup():
    s = GeoSetup()

    #Create two GeoPoints for source and instrument
    source = GeoPoint(37.751005, 14.993435, name="source")
    camera = GeoPoint(37.73122, 15.1129, name="cam")

    # Add the two GeoPoints to the GeoSetup
    s.add_geo_points(source, camera)
    s.set_borders_from_points()

    # Create plume vector anchored at source pointing south with horizontal
    # orientation (elevation angle 0)
    plume = GeoVector3D(azimuth=180,
                        dist_hor=s.magnitude,
                        elevation=0,
                        anchor=source,
                        name="plume")
    # Create viewing direction vector anchored at instrument pointing west
    # at elevation angle of 8deg
    view_dir = GeoVector3D(azimuth=270,
                           dist_hor=s.magnitude,
                           elevation=8,
                           anchor=camera,
                           name="cam_view")

    # Add the two GeoVectors to the GeoSetup class
    s.add_geo_vectors(plume, view_dir)
    return s
def find_viewing_direction(meas_geometry, draw_result=True):
    """Correct viewing direction using location of Etna SE crater.

    Defines location of Etna SE crater within images (is plotted into current
    plume onband image of dataset) and uses its geo location to retrieve the
    camera viewing direction

    :param meas_geometry: :class:`MeasGeometry` object

    """
    # Position of SE crater in the image (x, y)
    se_crater_img_pos = [806, 736]

    # Geographic position of SE crater (extracted from Google Earth)
    # The GeoPoint object (geonum library) automatically retrieves the altitude
    # using SRTM data
    se_crater = GeoPoint(37.747757, 15.002643, name="SE crater")

    print("Retrieved altitude SE crater (SRTM): %s" % se_crater.altitude)

    # The following method finds the camera viewing direction based on the
    # position of the south east crater.
    new_elev, new_azim, _, basemap =\
        meas_geometry.find_viewing_direction(pix_x=se_crater_img_pos[0],
                                             pix_y=se_crater_img_pos[1],
                                             # for uncertainty estimate
                                             pix_pos_err=100,
                                             geo_point=se_crater,
                                             draw_result=draw_result,
                                             update=True)  # overwrite settings

    print("Updated camera azimuth and elevation in MeasGeometry, new values: "
          "elev = %.1f, azim = %.1f" % (new_elev, new_azim))

    return meas_geometry, basemap
def calc_vector(targ_sentance, base_pos):
    """
    :param targ_sentance:
        #targ_sentance[3] - Lat
        #targ_sentance[4] - Lon
        #targ_sentance[5] - Alt
    :param base_pos:
    :return:
    """
    try:
        if 45 <= int(targ_sentance[3]
                     ) <= 70:  # is Lat is a reasonable number, for Europe.
            # extract the position (lat,lon alt and name)
            targ_pos = [
                float(targ_sentance[3]),
                float(targ_sentance[4]),
                float(targ_sentance[5]), targ_sentance[0]
            ]

        targ = GeoPoint(targ_pos[0], targ_pos[1], targ_pos[2], targ_pos[3])

        base = GeoPoint(base_pos[0], base_pos[1], base_pos[2], base_pos[3])

        connection_vector = targ - base

        #print('=====Received at: ',datetime.datetime.now(),'===================')
        print('Target: ', targ_pos[3], ' , lat/lon : ', targ_pos[0], ' / ',
              targ_pos[1], 'Alt : ', targ_pos[2])
        #print('\n')
        print('connection_vector', connection_vector)

        GeonumDistance = connection_vector.magnitude
        #GeonumDistance = float("{0:.4f}".format(GeonumDistance))

        #print("Geonum:", GeonumDistance, "km")
        print("--")
        return connection_vector

    except Exception as e:
        print('error in calc_vector\n')
        print(e)
        pass
Exemple #4
0
def test_diffvector():
    p1 = GeoPoint(lat=37.751005,
                  lon=14.993435,
                  altitude=3264.0,
                  auto_topo_access=False)
    p2 = GeoPoint(37.765755,
                  15.016696,
                  altitude=2820.0,
                  auto_topo_access=False)
    connection_vector = p2 - p1

    assert connection_vector.anchor is p1

    actual = [
        connection_vector.azimuth, connection_vector.elevation,
        connection_vector.magnitude
    ]

    npt.assert_allclose(
        actual=actual,
        desired=[51.378677249653983, -9.6064174085658465, 2.6606074796318557],
        rtol=1e-7)
def find_view_dir(geom):
    """Perform a correction of the viewing direction using crater in img.

    :param MeasGeometry geom: measurement geometry
    :param str which_crater: use either "ne" (northeast) or "se" (south east)
    :return: - MeasGeometry, corrected geometry
    """
    # Use position of NE crater in image
    posx, posy = 1051, 605  # pixel position of NE crate in image
    # Geo location of NE crater (info from Google Earth)
    ne_crater = GeoPoint(37.754788, 14.996673, 3287, name="NE crater")

    geom.find_viewing_direction(pix_x=posx, pix_y=posy, pix_pos_err=100,
                                geo_point=ne_crater, draw_result=True)
    return geom
def test_ElevationProfile():
    
    lat_taranaki = -39.296571
    lon_observer = 173.9224
    
    obs = GeoPoint(lat_taranaki, lon_observer)
    
    npt.assert_almost_equal(obs.altitude, 324)
    
    prof = obs.get_elevation_profile(azimuth=90, dist_hor=50)
    
    prof_nans = obs.get_elevation_profile(azimuth=45, dist_hor=50)
    prof2 = obs.get_elevation_profile(azimuth=45, dist_hor=50,
                                      order=1)
    
    npt.assert_array_equal([len(prof.dists), len(prof.profile),
                            np.sum(np.isnan(prof_nans.profile))],
                            [10092,10092,10263])
    npt.assert_array_almost_equal([prof.profile.max(), prof.profile.min(), 
                                   prof.profile.mean(), prof.profile.std(),
                                   prof.dists.max(),
                                   prof2.profile.max(), prof2.profile.min()],
                                  [2482.598405, 176.008484, 583.012202,  
                                   486.57815, 50.033677, 1005.208932, 0.])
    def get_altitude_srtm(self):
        """Try load camera altitude based on lon, lat and SRTM topo data.

        Note
        ----
        Requires :mod:`geonum` package to be installed and :attr:`lon` and
        :attr:`lat` to be set.

        """
        try:
            from geonum import GeoPoint
            lon, lat = float(self.lon), float(self.lat)
            self.altitude = GeoPoint(lat, lon).altitude
        except Exception as e:
            warn("Failed to automatically access local topography altitude"
                 " at camera position using SRTM data: %s" % repr(e))
Exemple #8
0
def viewing_direction(geometry):
    """Find viewing direction of camera based on MeasGeometry."""
    from geonum import GeoPoint
    # Position of SE crater in the image (x, y)
    se_crater_img_pos = [720, 570]  # [806, 736] (changed on 12/5/19)
    # Geographic position of SE crater (extracted from Google Earth)
    # The GeoPoint object (geonum library) automatically retrieves the altitude
    # using SRTM data
    se_crater = GeoPoint(37.747757, 15.002643, altitude=3103.0)

    # The following method finds the camera viewing direction based on the
    # position of the south east crater.
    new_elev, new_azim, _, basemap =\
        geometry.find_viewing_direction(
            pix_x=se_crater_img_pos[0],
            pix_y=se_crater_img_pos[1],
            pix_pos_err=100,  # for uncertainty estimate
            geo_point=se_crater,
            draw_result=False,
            update=True)  # overwrite old settings
    return geometry
"""geonum example script 1

Introduction into the geonum base classes GeoPoint and GeoVector3D
"""

from geonum import GeoPoint
from SETTINGS import OPTPARSE
from numpy import testing as npt
from matplotlib.pyplot import show
### Create 2 GeoPoint objects

# Summit region of Mt. Etna
p1 = GeoPoint(lat=37.751005, lon=14.993435, altitude=3264.0, name="Etna")

# Position of volcanological observatory of Mt. Etna
p2 = GeoPoint(37.765755, 15.016696, name="Observatory")

# Print info (string represenation of both points")
print(("Point1: %s, point 2: %s" % (p1, p2)))

# Get and print the connection vector of both points
connection_vector = p2 - p1

print(connection_vector)

# Import script options
(options, args) = OPTPARSE.parse_args()

# If applicable, do some tests. This is done only if TESTMODE is active:
# testmode can be activated globally (see SETTINGS.py) or can also be
# activated from the command line when executing the script using the
Exemple #10
0
def test_GeoPoint():
    """Test basic arithmetic operations on GeoPoints."""
    p = GeoPoint(lat=0, lon=0, auto_topo_access=False)
    assert p.latitude == 0
    assert p.longitude == 0