GithubHelp home page GithubHelp logo

pbrod / nvector Goto Github PK

View Code? Open in Web Editor NEW
56.0 56.0 7.0 710 KB

Nvector is a suite of tools written in Python to solve geographical position calculations.

License: Other

Python 100.00%
distance-calculation geodesy geography great-circle n-vector wgs84

nvector's People

Contributors

garyvdm avatar pbrod avatar quantifiedcode-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nvector's Issues

latlon_deg property gives different types for linux vs windows

This might not be a nvector code problem, but a numpy issue. But I thought I would mention it anyway.

I have the following code:

ecef = [[ 1782029.5702637 ]
[-5958967.13026865]
[ 1407960.53954478]]

ell = nv.FrameE(name='WGS84')
p_EB_E = ell.ECEFvector(ecef)
pnt = p_EB_E.to_geo_point()
lon, lat, z = pnt.latlon_deg
print(lon, lat)
print(type(lat))

With Windows, I get the following output:
[12.83821967] [-73.35070153]
<class 'numpy.ndarray'>

with linux, I get this:
12.838219667803369 -73.35070153096443
<class 'numpy.float64'>

Any idea why one returns single element array vs a floating point?

Suggestion: make `Cartopy` and opt-in dependency

As of 0.7.7, Cartopy is a required dependency of nvector. This is sometimes problematic since Cartopy does not provide ready-built wheels on pypi, thus requiring every user to have a proper build environment (including a build of GEOS) to do pip install nvector.

My suggestion would be to put the plotting part of nvector as a an optional dependency so that users can do pip install nvector to get the core functionality or pip install nvector[plots] (or similar) to also require Cartopy (and perhaps matplotlib).

Right now, the "easy way out" for me is to do: pip install "nvector<=0.7.6"

`GeoPath.intersect` should return `GeoPoint`

The intersect method on GeoPath objects claims to return an instance of GeoPoint, which seems like the desired behavior (at least, that is what I want it to return too). However it returns an instance of Nvector.

From the last line of the intersect method...

return frame.Nvector(normal_c, z=depth)

KeyError: 'point' in __repr__ of Pvector

Python 3.9.2
nvector 0.7.7

Following Example 1:

import numpy as np
import nvector as nv
wgs84 = nv.FrameE(name='WGS84')
pointA = wgs84.GeoPoint(latitude=1, longitude=2, z=3, degrees=True)
pointB = wgs84.GeoPoint(latitude=4, longitude=5, z=6, degrees=True)
p_AB_N = pointA.delta_to(pointB)
print(p_AB_N)

gives

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/f380cedric/.local/lib/python3.9/site-packages/nvector/objects.py", line 138, in __repr__
    params = fmt.join(['{}={!r}'.format(name, dict_params[name])
  File "/home/f380cedric/.local/lib/python3.9/site-packages/nvector/objects.py", line 138, in <listcomp>
    params = fmt.join(['{}={!r}'.format(name, dict_params[name])
  File "/home/f380cedric/.local/lib/python3.9/site-packages/nvector/objects.py", line 138, in __repr__
    params = fmt.join(['{}={!r}'.format(name, dict_params[name])
  File "/home/f380cedric/.local/lib/python3.9/site-packages/nvector/objects.py", line 138, in <listcomp>
    params = fmt.join(['{}={!r}'.format(name, dict_params[name])
KeyError: 'point'

It goes like this: Pvector.__dict__["frame"] → FrameN.__dict__["point"]. FrameN._NAMES gives "point" while dict_params only contains key nvector.

Example not working

Hi,

Using the latest version 0.7.5 the below example fails:

wgs84 = nv.FrameE(name='WGS84')
point1 = wgs84.GeoPoint(latitude=88, longitude=0, degrees=True)
point2 = wgs84.GeoPoint(latitude=89, longitude=-170, degrees=True)
s_12, _azi1, _azi2 = point1.distance_and_azimuth(point2)
p_12_E = point2.to_ecef_vector() - point1.to_ecef_vector()
d_12 = p_12_E.length[0]
msg = 'Ellipsoidal and Euclidean distance = {:5.2f} km, {:5.2f} km'
msg.format(s_12 / 1000, d_12 / 1000)

The error given is:

Attribute Error: 'list' object has no attribute 'T'

The example works correctly with version 0.7.4

path.positionA not always on path when using the exact method

Hello,

First of all, thank you for making this package opensource. It is very useful to me.
I came across the following issue:
on_path when method='exact' will not return consistently True on the positionA of a path.
Below is an illustrating example. Having had a quick look at the code under the hood, it may be the checking the difference of azimuth is not meaningful when point_a==point

import nvector as nv
import numpy as np

wgs84 = nv.FrameE(name='WGS84')
pointA = wgs84.GeoPoint(latitude=81, longitude=0, degrees=True)
pointB = wgs84.GeoPoint(latitude=80, longitude=0, degrees=True)
path = nv.GeoPath(pointA, pointB)
print(np.allclose(path.on_path(path.positionA, method='exact'), True))

wgs84 = nv.FrameE(name='WGS84')
pointA = wgs84.GeoPoint(latitude=79, longitude=0, degrees=True)
pointB = wgs84.GeoPoint(latitude=80, longitude=0, degrees=True)
path = nv.GeoPath(pointA, pointB)
print(np.allclose(path.on_path(path.positionA, method='exact'), True))

nvector.version == 0.7.4

test for test_n_E_and_wa2R_EL seems incorrect

I have run the same test as in test_n_E_and_wa2R_EL using the reference Matlab implementation (using Octave) and the result is not the one used as Python test

        R_EL1 = [[0, 1.0, 0],
                 [1.0, 0, 0],
                 [0, 0, -1.0]]

but rather

>> n_E_and_wa2R_EL([0 0 1]', wander_azimuth = (pi / 2))
ans =

  -6.1230e-17  -1.0000e+00   6.1230e-17
  -1.0000e+00   6.1230e-17  -7.4983e-33
   3.7492e-33  -6.1230e-17  -1.0000e+00

HTH

Find GeoPosition from GeoPosition and cartesian vector

Hi,

I'm using this code for calculating the cartesian vector from "origin" to "target":
` wgs84 = nv.FrameE(name='WGS84')
origin = wgs84.GeoPoint(latitude=latitudeOrigin, longitude=longitudeOrigin, z=altitudeOrigin, degrees=False)
target = wgs84.GeoPoint(latitude=latitudeTarget, longitude=longitudeTarget, z=altitudeTarget, degrees=False)

    p_AB_N = origin.delta_to(target)
    x, y, z = p_AB_N.pvector.ravel()

`

Now, how can I reverse this operation? I have an origin and a cartesian vector and like to find the vector position as a GeoPosition (in my example "target").

In Pseudo-Code:
target = origin.to_geo_position(np.r_[x,y,z].reshape((-1, 1)))

Thank you,
Manfred

Conda-forge

Would appreciate install availability with conda-forge. It's a little more stable with a conda environment than pypi. Thanks.

new version with updated Sphinx

Hello, thanks for this great library! Would it be possible to release a new package on PyPi with documentation built using Sphinx>=3.0.4? The newer version uses an updated version of jQuery (3.5) that addresses a security vulnerability.

Inconsistent return types in GeoPath.track_distance

Hi, and thanks for this really nice concept and library. The paper is really interesting!

I ran into an inconsistency of return types from the GeoPath.track_distance-method:

  • GeoPath.track_distance(method='great_circle') returns a single-element array
  • GeoPath.track_distance(method='euclidian') returns a single-element array
  • GeoPath.track_distance(method='exact') returns a scalar

From my point of view I would prefer it to consistently return scalars, that makes the most sense to me.

Cross track distance ill conditioned

Hi,

I was doing some quick experimentation with nvector, and found this calculation of the cross-track distance on the great circle.

nvector/src/nvector/_core.py

Lines 1140 to 1143 in bf1cf5e

def _great_circle_cross_track_distance(sin_theta, radius=1):
return np.arcsin(sin_theta) * radius
# ill conditioned for small angles:
# return (np.arccos(-sin_theta) - np.pi / 2) * radius

The arccos function is inaccurate for small angles, as mentioned in the comment. When this function is called from cross_track_distance however, it is taken between the cross product of the n-vectors describing the path (c^E) and the position B. For small cross-track errors, shouldn't the expression with arccos be the most accurate (since arcsin is inaccurate at -pi/2 and pi/2)?

  • Øystein

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.