open-aviation / pyopensky

The Python interface for OpenSky database
https://open-aviation.github.io/pyopensky/
GNU Lesser General Public License v3.0
48 stars 11 forks source link

Unexpected behaviour trino.history start/stop params #64

Closed quinten-goens closed 6 months ago

quinten-goens commented 6 months ago

Hi!

I ran into a mismatch between requested timeframe and received timeframe using trino.history(). When I run the following code:

from pyopensky.trino import Trino
from datetime import datetime, timedelta
import pandas as pd

# Initialize Trino
trino = Trino()

# Bounding box around LSZH
bounds = (3.4981903989707055, 44.04369159096895, 13.597921601029295, 50.87242040903105)

# Timeframe
start = datetime(2024, 1, 1, 0, 0, 0)
stop =  datetime(2024, 1, 1, 1, 0, 0) 

statevectors = trino.history(start=start, stop=stop, bounds=bounds)

print(f"Minimum time: {statevectors.time.min()}")
print(f"Maximum time: {statevectors.time.max()}")

I get the output:

Minimum time: 2024-01-01 00:00:01+00:00
Maximum time: 2024-01-01 00:35:08+00:00

However, when I input

start = datetime(2024, 1, 1, 0, 0, 0)
stop =  datetime(2024, 1, 1, 1, 0, 1) 

I get the output

Minimum time: 2024-01-01 00:00:01+00:00
Maximum time: 2024-01-01 01:00:01+00:00

Any idea what's happening? Simultaneously I get this warning

/home/cdsw/.local/lib/python3.9/site-packages/pyopensky/trino.py:571: FutureWarning: 'H' is deprecated and will be removed in a future version, please use 'h' instead.
  StateVectorsData4.hour >= start_ts.floor("1H"),
/home/cdsw/.local/lib/python3.9/site-packages/pyopensky/trino.py:572: FutureWarning: 'H' is deprecated and will be removed in a future version, please use 'h' instead.
  StateVectorsData4.hour < stop_ts.ceil("1H"),

In the attachment my pip freeze with my current versions (some might be outdated because I work in a 'managed' environment).

requirements (1).txt

Thank you for any help you may provide!

xoolive commented 6 months ago

Hi Quinten, I think I encountered/fixed an issue which could be related to yours. Could you try to upgrade with the latest commit version and confirm/infirm whether the issue is still there? If it is still here I will try to run/fix your code later.

quinten-goens commented 6 months ago

Hi @xoolive,

I tried out my reprex with the latest commit pyopensky @ git+https://github.com/open-aviation/pyopensky.git@19cef3debbd7cbc908d6e1880fa79f6f8631dffb and the issue persists. I get an identical output. I did note that there's no more FutureWarning.

This is the full output I get:

EXECUTE IMMEDIATE not available for trino.opensky-network.org:443; defaulting to legacy prepared statements (TrinoUserError(type=USER_ERROR, name=SYNTAX_ERROR, message="line 1:19: mismatched input ''SELECT 1''. Expecting: 'USING', <EOF>", query_id=20240319_112857_00370_s65nj))
FINISHED: : 100% [00:19, 5.05%/s]
DOWNLOAD: 53.2klines [00:01, 49.0klines/s]
Minimum time: 2024-01-01 00:00:01+00:00
Maximum time: 2024-01-01 00:35:08+00:00

Thanks for looking into this!

xoolive commented 6 months ago

image

I think it looks like just what is in base at this point :man_shrugging: A big gap between 2024-01-01 00:35:08+00:00 and 2024-01-01 01:00:01+00:00