question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Give lat/lon array a str() that doesn’t raise ValueError

See original GitHub issue

Minimal code to repro:

iss = find_satellite("ISS (ZARYA)")
ts = load.timescale()
geocentric = iss.at(ts.now())
sample_size = 100
total_mins = 200 # approximately 3 and a half hours
interval = int(total_mins / sample_size) # minutes per sample
from skyfield.api import utc
times = {"past": [], "future": []}
total_time = interval
for i in range(int(sample_size / 2)):
    times["past"].append(datetime.utcnow().replace(tzinfo=utc) - timedelta(minutes=total_time))
    times["future"].append(datetime.utcnow().replace(tzinfo=utc) + timedelta(minutes=total_time))
    total_time += interval
past = iss.at(ts.from_datetimes(times["past"]))
future = iss.at(ts.from_datetimes(times["future"]))
breakpoint()

At that breakpoint you can see the errors by:

(Pdb) wgs84.subpoint(future)
*** ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
(Pdb) wgs84.subpoint(past)
*** ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I was expecting to get back a list or multiple subpoint objects.

I just realized this is just a warning message and that the code does work as intended. So perhaps this is just a vanity thing to clean up or maybe it’s something I’ve done wrong.

Proof it works as intended:

(Pdb) future_points = wgs84.subpoint(future)
(Pdb) future_points.latitude.degrees
array([ 40.02567957,  35.19123787,  29.92500048,  24.34328505,
        18.53587237,  12.57340305,   6.51363887,   0.40644326,
        -5.7021849 , -11.76657634, -17.73789652, -23.56023409,
       -29.16582637, -34.46906677, -39.3593364 , -43.69388955,
       -47.29473674, -49.95777065, -51.48454313, -51.73715061,
       -50.6908114 , -48.44458085, -45.18084694, -41.10678884,
       -36.41257692, -31.25460376, -25.75510598, -20.00841863,
       -14.08837606,  -8.05480355,  -1.95873081,   4.15341527,
        10.23620968,  16.24176508,  22.11594664,  27.79380953,
        33.19385636,  38.21100379,  42.70909598,  46.51613832,
        49.42958409,  51.24250449,  51.79526684,  51.03345195,
        49.03122698,  45.95993831,  42.02867312,  37.43616958,
        32.34866274,  26.896893  ])

Perhaps it’s just tired eyes, but that message raised a red flag for me. I realize this may be an issue there’s not much to do on. But I thought I’d share anyways.

Greatly enjoying this library. Thanks for your work on it 😃

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
brandon-rhodescommented, Jan 15, 2021

I’m glad it’s no longer raising the exception for you! I’ll have to take a look at cartopy, thanks for linking toit.

1reaction
brandon-rhodescommented, Jan 2, 2021

Thanks for the ideas! I’ll mull them over and hopefully have my thoughts straight by sometime next week; I’ll comment here at that point.

Read more comments on GitHub >

github_iconTop Results From Across the Web

list.index() function for Python that doesn't throw exception ...
So, basically, test() will return index of the element (second parameter) within given list (first parameter), unless it has not been found ...
Read more >
Data Classes in Python 3.7+ (Guide)
In this tutorial, you will learn exactly which conveniences data classes provide. In addition to nice representations and comparisons, you'll see: How to...
Read more >
Source code for pyuvdata.fhd
Raises ------ IOError If root file directory doesn't exist. ValueError If required files are missing or multiple files for any polarization are included...
Read more >
Source Code for Package pyproj
20 21 Input coordinates can be given as python arrays, lists/tuples, ... Python 3 70 string_types = (str,) 71 72 pj_list={ 73 'aea':...
Read more >
Convert ERA5 data to WGS84 - python - GIS Stack Exchange
Dataset: if name is None: raise ValueError("I need a variable name") dataarray = dataarray[name] longitud = dataarray[xaxis].values ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found