Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Floodpy_app.query_S1_data(): TypeError: Cannot compare tz-naive and tz-aware datetime-like objects #81

Closed
mazingaro opened this issue Jul 24, 2024 · 2 comments

Comments

@mazingaro
Copy link

mazingaro commented Jul 24, 2024

@kleok ,

I've opened a new ticked cause the discussion that goes in the geometry issue is continuing elsewhere and may be confusing :)

To recapitulate:
When running Floodpy_app.query_S1_data() there comes this error:
TypeError: Cannot compare tz-naive and tz-aware datetime-like objects

So, to continue the discussion from here:

The plot is Ok and the .cdsapirc is Ok. I've added this to the code of Query_Sentinel_1_products.py, so you can see the formats that are parsed:

print(query_df.head())
print(query_df.index)

Output:

<class 'datetime.datetime'>
<class 'datetime.datetime'>
                                   @odata.mediaContentType  \
beginningDateTime                                            
2023-07-04 05:11:11.651000+00:00  application/octet-stream   
2023-07-05 16:59:05.125000+00:00  application/octet-stream   
2023-07-09 05:19:23.871000+00:00  application/octet-stream   
2023-07-10 17:06:57.845000+00:00  application/octet-stream   
2023-07-10 17:07:22.845000+00:00  application/octet-stream   

                                                                    Id  \
beginningDateTime                                                        
2023-07-04 05:11:11.651000+00:00  a35fb411-5789-4ce5-b8d9-f468d7dd276f   
2023-07-05 16:59:05.125000+00:00  3ba49f42-05aa-4cf9-b5ad-2546104e87ab   
2023-07-09 05:19:23.871000+00:00  46dadcb1-446f-47da-ab82-a39e162294b7   
2023-07-10 17:06:57.845000+00:00  5edb8f38-9cc2-49d9-ab4b-21952e42cf1d   
2023-07-10 17:07:22.845000+00:00  22454991-db23-4216-8195-be7a9e07fbf6   

                                                                               Name  \
beginningDateTime                                                                     
2023-07-04 05:11:11.651000+00:00  S1A_IW_GRDH_1SDV_20230704T051111_20230704T0511...   
2023-07-05 16:59:05.125000+00:00  S1A_IW_GRDH_1SDV_20230705T165905_20230705T1659...   
2023-07-09 05:19:23.871000+00:00  S1A_IW_GRDH_1SDV_20230709T051923_20230709T0519...   
2023-07-10 17:06:57.845000+00:00  S1A_IW_GRDH_1SDV_20230710T170657_20230710T1707...   
2023-07-10 17:07:22.845000+00:00  S1A_IW_GRDH_1SDV_20230710T170722_20230710T1707...   

                                               ContentType  ContentLength  \
beginningDateTime                                                           
2023-07-04 05:11:11.651000+00:00  application/octet-stream     1776442517   
2023-07-05 16:59:05.125000+00:00  application/octet-stream     1772251838   
2023-07-09 05:19:23.871000+00:00  application/octet-stream     1777636660   
2023-07-10 17:06:57.845000+00:00  application/octet-stream     1765677503   
2023-07-10 17:07:22.845000+00:00  application/octet-stream     1766577336   

                                                OriginDate  \
beginningDateTime                                            
2023-07-04 05:11:11.651000+00:00  2023-07-04T06:03:21.575Z   
2023-07-05 16:59:05.125000+00:00  2023-07-05T17:49:26.467Z   
2023-07-09 05:19:23.871000+00:00  2023-07-09T06:12:38.712Z   
2023-07-10 17:06:57.845000+00:00  2023-07-10T17:58:58.919Z   
2023-07-10 17:07:22.845000+00:00  2023-07-10T16:07:56.405Z   

                                           PublicationDate  \
beginningDateTime                                            
2023-07-04 05:11:11.651000+00:00  2023-07-04T06:10:48.876Z   
2023-07-05 16:59:05.125000+00:00  2023-07-05T17:59:36.979Z   
2023-07-09 05:19:23.871000+00:00  2023-07-09T06:24:02.959Z   
2023-07-10 17:06:57.845000+00:00  2023-07-10T18:08:33.852Z   
2023-07-10 17:07:22.845000+00:00  2023-07-10T18:12:57.475Z   

                                          ModificationDate  Online  \
beginningDateTime                                                    
2023-07-04 05:11:11.651000+00:00  2023-07-04T06:11:03.504Z    True   
2023-07-05 16:59:05.125000+00:00  2023-07-05T18:04:00.551Z    True   
2023-07-09 05:19:23.871000+00:00  2023-07-09T06:30:45.535Z    True   
2023-07-10 17:06:57.845000+00:00  2023-07-10T18:08:50.294Z    True   
2023-07-10 17:07:22.845000+00:00  2023-07-10T18:13:13.899Z    True   

                                 EvictionDate  ...  \
beginningDateTime                              ...   
2023-07-04 05:11:11.651000+00:00               ...   
2023-07-05 16:59:05.125000+00:00               ...   
2023-07-09 05:19:23.871000+00:00               ...   
2023-07-10 17:06:57.845000+00:00               ...   
2023-07-10 17:07:22.845000+00:00               ...   

                                                                        ContentDate  \
beginningDateTime                                                                     
2023-07-04 05:11:11.651000+00:00  {'Start': '2023-07-04T05:11:11.651Z', 'End': '...   
2023-07-05 16:59:05.125000+00:00  {'Start': '2023-07-05T16:59:05.125Z', 'End': '...   
2023-07-09 05:19:23.871000+00:00  {'Start': '2023-07-09T05:19:23.871Z', 'End': '...   
2023-07-10 17:06:57.845000+00:00  {'Start': '2023-07-10T17:06:57.845Z', 'End': '...   
2023-07-10 17:07:22.845000+00:00  {'Start': '2023-07-10T17:07:22.845Z', 'End': '...   

                                                                          Footprint  \
beginningDateTime                                                                     
2023-07-04 05:11:11.651000+00:00  geography'SRID=4326;POLYGON ((15.885898 44.570...   
2023-07-05 16:59:05.125000+00:00  geography'SRID=4326;POLYGON ((12.004252 45.222...   
2023-07-09 05:19:23.871000+00:00  geography'SRID=4326;POLYGON ((13.87602 44.6898...   
2023-07-10 17:06:57.845000+00:00  geography'SRID=4326;POLYGON ((10.31477 43.9351...   
2023-07-10 17:07:22.845000+00:00  geography'SRID=4326;POLYGON ((9.496206 46.9349...   

                                                                       GeoFootprint  \
beginningDateTime                                                                     
2023-07-04 05:11:11.651000+00:00  {'type': 'Polygon', 'coordinates': [[[15.88589...   
2023-07-05 16:59:05.125000+00:00  {'type': 'Polygon', 'coordinates': [[[12.00425...   
2023-07-09 05:19:23.871000+00:00  {'type': 'Polygon', 'coordinates': [[[13.87602...   
2023-07-10 17:06:57.845000+00:00  {'type': 'Polygon', 'coordinates': [[[10.31477...   
2023-07-10 17:07:22.845000+00:00  {'type': 'Polygon', 'coordinates': [[[9.496206...   

                                                                         Attributes  \
beginningDateTime                                                                     
2023-07-04 05:11:11.651000+00:00  [{'@odata.type': '#OData.CSC.StringAttribute',...   
2023-07-05 16:59:05.125000+00:00  [{'@odata.type': '#OData.CSC.StringAttribute',...   
2023-07-09 05:19:23.871000+00:00  [{'@odata.type': '#OData.CSC.StringAttribute',...   
2023-07-10 17:06:57.845000+00:00  [{'@odata.type': '#OData.CSC.StringAttribute',...   
2023-07-10 17:07:22.845000+00:00  [{'@odata.type': '#OData.CSC.StringAttribute',...   

                                 sliceNumber orbitDirection  processorVersion  \
beginningDateTime                                                               
2023-07-04 05:11:11.651000+00:00          20     DESCENDING            003.61   
2023-07-05 16:59:05.125000+00:00          11      ASCENDING            003.61   
2023-07-09 05:19:23.871000+00:00          20     DESCENDING            003.61   
2023-07-10 17:06:57.845000+00:00          10      ASCENDING            003.61   
2023-07-10 17:07:22.845000+00:00          11      ASCENDING            003.61   

                                 relativeOrbitNumber platformSerialIdentifier  \
beginningDateTime                                                               
2023-07-04 05:11:11.651000+00:00                  22                        A   
2023-07-05 16:59:05.125000+00:00                  44                        A   
2023-07-09 05:19:23.871000+00:00                  95                        A   
2023-07-10 17:06:57.845000+00:00                 117                        A   
2023-07-10 17:07:22.845000+00:00                 117                        A   

                                         beginningDateTime  
beginningDateTime                                           
2023-07-04 05:11:11.651000+00:00  2023-07-04T05:11:11.651Z  
2023-07-05 16:59:05.125000+00:00  2023-07-05T16:59:05.125Z  
2023-07-09 05:19:23.871000+00:00  2023-07-09T05:19:23.871Z  
2023-07-10 17:06:57.845000+00:00  2023-07-10T17:06:57.845Z  
2023-07-10 17:07:22.845000+00:00  2023-07-10T17:07:22.845Z  

[5 rows x 22 columns]
DatetimeIndex(['2023-07-04 05:11:11.651000+00:00',
               '2023-07-05 16:59:05.125000+00:00',
               '2023-07-09 05:19:23.871000+00:00',
               '2023-07-10 17:06:57.845000+00:00',
               '2023-07-10 17:07:22.845000+00:00',
               '2023-07-16 05:11:12.614000+00:00',
               '2023-07-17 16:59:06.007000+00:00',
               '2023-07-21 05:19:24.419000+00:00',
               '2023-07-22 17:06:58.512000+00:00',
               '2023-07-22 17:07:23.511000+00:00',
               '2023-07-28 05:11:13.147000+00:00',
               '2023-07-29 16:59:06.631000+00:00',
               '2023-08-02 05:19:24.848000+00:00',
               '2023-08-03 17:06:59.681000+00:00',
               '2023-08-03 17:07:24.681000+00:00',
               '2023-08-09 05:11:13.195000+00:00',
               '2023-08-10 16:59:06.548000+00:00',
               '2023-08-14 05:19:25.607000+00:00',
               '2023-08-15 17:06:59.681000+00:00',
               '2023-08-15 17:07:24.680000+00:00',
               '2023-08-21 05:11:14.215000+00:00',
               '2023-08-22 16:59:07.780000+00:00',
               '2023-08-26 05:19:26.539000+00:00',
               '2023-08-27 17:07:00.546000+00:00',
               '2023-08-27 17:07:25.546000+00:00',
               '2023-09-02 05:11:15.257000+00:00',
               '2023-09-03 16:59:08.728000+00:00',
               '2023-09-07 05:19:26.988000+00:00',
               '2023-09-08 17:07:01.075000+00:00',
               '2023-09-08 17:07:26.075000+00:00'],
              dtype='datetime64[ns, UTC]', name='beginningDateTime', freq=None)

and it finishes with the same error:
TypeError: Cannot compare tz-naive and tz-aware datetime-like objects

In this part of the code you can see that there are 2 date types: one with the timezone indication (right) and one without (left). Could this be the cause?

                                         beginningDateTime  
beginningDateTime                                           
2023-07-04 05:11:11.651000+00:00  2023-07-04T05:11:11.651Z 
2023-07-05 16:59:05.125000+00:00  2023-07-05T16:59:05.125Z  
2023-07-09 05:19:23.871000+00:00  2023-07-09T05:19:23.871Z  
2023-07-10 17:06:57.845000+00:00  2023-07-10T17:06:57.845Z  
2023-07-10 17:07:22.845000+00:00  2023-07-10T17:07:22.845Z  

BTW, I use SNAP 10 (I'ts written SNAP 9.0+).

kleok added a commit that referenced this issue Jul 26, 2024
kleok added a commit that referenced this issue Jul 26, 2024
#81 convert timeindex to tz-naive
@kleok
Copy link
Owner

kleok commented Jul 26, 2024

Dear @mazingaro,
I pushed some changes regarding the report issue.
Could you please verify that it works for you too?

@kleok kleok closed this as completed Aug 6, 2024
@mazingaro
Copy link
Author

@kleok , I apologize for not checking yet your changes, but I am absent from my computer. You marked it as completed, but I can check this anyway when back. Thank you!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants