Element84 / earth-search

Earth Search information and issue tracking
https://earth-search.aws.element84.com/v1
27 stars 2 forks source link

Sentinel-2 L1C Products with Missing Times #22

Closed J6767 closed 8 months ago

J6767 commented 9 months ago

I am running a pystac query as follows:

def pystac_query(max_items, time_range, lon, lat, max_cloud):
    client = Client.open("https://earth-search.aws.element84.com/v1")

    query = client.search(
        max_items=max_items,
        collections=['sentinel-2-l1c'],
        query={"eo:cloud_cover": {"lt": max_cloud}},
        datetime = time_range,
        intersects=dict(type="Point", coordinates=[lon, lat]),
    )
    items = query.item_collection()
    return items

Then, because some L1C products have been mislabelled as L2A, as discussed here, I run:

    for i in items:
        for a in i.assets:
            i.assets[a].href = i.assets[a].href.replace('sentinel-s2-l2a', 'sentinel-s2-l1c')

However, for some AOIs / time periods, assets have a missing time field. E.g:

['2023-01-02T00:13:58.324000000' '2023-01-22T00:13:57.571000000'
 '2023-02-11T00:13:58.205000000' '2023-02-16T00:13:56.386000000'
 '2023-03-18T00:13:57.551000000' '2023-04-17T00:13:59.100000000'
 '2023-04-22T00:14:01.694000000' '2023-05-17T00:14:00.951000000'
 '2023-05-22T00:14:04.583000000' '2023-05-27T00:14:03.146000000'
 '2023-06-01T00:14:03.403000000' '2023-06-06T00:14:03.279000000'
 '2023-06-11T00:14:04.683000000' '2023-06-16T00:14:03.863000000'
                           'NaT' '2023-07-11T00:14:04.655000000'
 '2023-07-16T00:14:04.465000000' '2023-07-26T00:14:04.611000000'
 '2023-07-31T00:14:04.992000000' '2023-08-05T00:14:04.717000000'
 '2023-08-10T00:14:05.125000000' '2023-08-15T00:14:05.157000000'
 '2023-08-20T00:14:04.700000000' '2023-08-25T00:14:05.699000000'
 '2023-08-30T00:14:04.310000000' '2023-09-04T00:14:04.949000000'
 '2023-09-09T00:14:03.771000000' '2023-09-19T00:14:03.156000000'
 '2023-09-29T00:14:02.197000000' '2023-10-19T00:14:01.849000000'
 '2023-10-24T00:13:59.719000000']

This causes an error as follows: KeyError: "cannot represent labeled-based slice indexer for coordinate 'time' with a slice over integer positions; the index is unsorted or non-unique"

Why are there assets with missing times, please? What is an appropriate fix? I have tried removing the assets with the missing times, but this creates new errors Re. AWS access. Many thanks.

gadomski commented 9 months ago

We'll need a little bit more information to look into the issue. Could you either provide:

Thanks for the report!

J6767 commented 8 months ago

Sorry for they delay, this appears to be an error with stackstac, so I will redirect. Many thanks.