Skip to content

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

@wgwz

Description

@wgwz

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions