TUW-GEO / ascat

Read and visualize data from the Advanced Scatterometer (ASCAT) on-board the series of Metop satellites
https://ascat.readthedocs.io/
MIT License
23 stars 16 forks source link

unsupported operand type(s) for /: 'str' and 'str' #55

Closed diegormsouza closed 8 months ago

diegormsouza commented 8 months ago

Hi!

I was using the following code without any problems until v2.1.1:

# download a sample of the Root Zone Soil Moisture Profile Index (Metop/ASCAT)
# note: after creating the H-SAF account it takes about 30 minutes to be able to use it.

import datetime                                                            # basic date and time types
from ascat.download.interface import hsaf_download # download data from the hsaf server

credentials = {'user': my_user, 'password': my_password}           # user and password
local_path = '/content/samples/'                                                 # where we want to store the data
remote_path = '/h26/h26_cur_mon_nc/'                                      # FTP server folder
start_date = datetime.datetime(2024, 1, 1)                                  # start date
end_date = datetime.datetime(2024, 1, 2)                                   # end date

hsaf_download(credentials, remote_path, local_path, start_date, end_date, limit=1) # download the file(s)

Now when I use the same code I get the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[<ipython-input-6-b17892317e70>](https://localhost:8080/#) in <cell line: 13>()
     11 end_date = datetime.datetime(2024, 1, 2)                                           # end date
     12 
---> 13 hsaf_download(credentials, remote_path, local_path, start_date, end_date, limit=1) # download the file(s)

1 frames
[/usr/local/lib/python3.10/dist-packages/ascat/download/connectors.py](https://localhost:8080/#) in download(self, remote_path, local_path, start_date, end_date, limit, overwrite)
    339         for daily_files in self.files(remote_path, start_date, end_date):
    340             for file_remote in daily_files:
--> 341                 file_local = local_path / file_remote
    342                 local_file_list.append(file_local)
    343                 download_url_list.append(file_remote)

TypeError: unsupported operand type(s) for /: 'str' and 'str'

Any hints? Tested the same code again with v2.1.1 and it works well!

sebhahn commented 8 months ago

yes, the local_path needs to be a Path object

from pathlib import Path

local_path = Path("/path/to/folder")

I'll add a check here in the doenload function

sebhahn commented 8 months ago

a new version (v2.3.1) has been released that should fix this problem