SWOT-community / SWOT-Hydrology

Hydrology-relevant tutorials and resources for the Surface Water and Ocean Topography (SWOT) Mission
https://swot-community.github.io/SWOT-galleries/hydrology/hydrology.html
MIT License
9 stars 2 forks source link

eodag configuration #3

Open mn5hk opened 1 week ago

mn5hk commented 1 week ago

Hi @msimeon-cnes,

Thank you for the training session at 30YPRA event. I am currently struggling with getting my eodag configuration setup in the right way.

Would it be possible to share a template for the eodag yml file to access the hydroweb-next portal?

Thank you, Amin

msimeon-cnes commented 1 week ago

Hi @mn5hk , you can generate a configuration file by running this command a first time to create a configuration file

import eodag
dag = eodag.EODataAccessGateway()

You should have a file created in ~/.config/eodag/eodag.yaml.

You can also find attached the default configuration file. eodag.zip

I hope this will resolved your problem !

Mathilde

mn5hk commented 1 week ago

Hi @msimeon-cnes, thanks for the support. The line dag = eodag.EODataAccessGateway() is not working for me currently. I suspect, that is an issue with my conda environment.

Upon trying to create a new conda environment from the env_swot-training.yml, I receive the following package not found errors:

Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  - hydro-db-connector==1.8.0=py_3
  - hydro-db-api==1.8.0=py_0
  - hydro-data-downloader==1.8.0=py_0
  - cross_spectral==2024.1.0=py310h76be34b_3
  - casys==0.12=pypy_0

I have currently manually removed the packages not found and created a new conda environment. However, my initial error still persists..

Sharing the error on running the dag = eodag.EODataAccessGateway() line below:

ReaderError: unacceptable character #x0080: special characters are not allowed
  in "/home/anaconda3/envs/swot-ypra/lib/python3.10/site-packages/eodag/resources/product_types.yml", position 40894

I will try to execute the code in a different machine to see if it is my machine-specific issue.

Thanks a lot for the support once again, Amin

msimeon-cnes commented 1 week ago

Thanks for the feedback. Indeed, those packages are not necessary, You can remove them from the environment file. It updated the file on github. Your error suggest that you have issue with the encoding of your file. Are you working on windows, linux or mac ? 1) Check the encoding of your file with file /home/anaconda3/envs/swot-ypra/lib/python3.10/site-packages/eodag/resources/product_types.yml should return file /home/anaconda3/envs/swot-ypra/lib/python3.10/site-packages/eodag/resources/product_types.yml: Unicode text, UTF-8 text 2) Open product_types.yaml with a code editor and look for a special character a the position (line 929). Try to remove it to see if this solves it. On my file, it correspond to the "–" of (CNR – Rome, Italy) of S3_OLCI_L4BALTIC which seems suspicious

S3_OLCI_L4BALTIC:
  abstract: |
    Baltic Sea Surface Ocean Colour Plankton from Sentinel-3 OLCI L4 monthly observations
    For the Baltic Sea Ocean Satellite Observations, the Italian National Research Council (CNR – Rome, Italy), is
mn5hk commented 1 week ago

Hi, sharing my file here. I might have replaced a few symbols such as mu or degrees symbol. But it still shows me some errors.

I am working on a linux machine.

Thanks for the support. product_types.zip

msimeon-cnes commented 1 week ago

Your file corresponds to mine excepted the few replaced symbols. I'm not able to reproduce the bug.

Could you try to remove the "–" of (CNR – Rome, Italy) (line 929) of S3_OLCI_L4BALTIC configuration which seems suspicious ?

S3_OLCI_L4BALTIC: abstract: | Baltic Sea Surface Ocean Colour Plankton from Sentinel-3 OLCI L4 monthly observations For the Baltic Sea Ocean Satellite Observations, the Italian National Research Council (CNR – Rome, Italy)

mn5hk commented 1 week ago

Hi I have now implemented the solution. The code below helped.

Thanks a lot for the support. Will try to go through some of the tutorials :)

Best, Amin

# clean_yml.py
import re

def clean_file(input_path, output_path):
    with open(input_path, 'r', encoding='utf-8') as file:
        content = file.read()

    # Remove characters with ASCII values outside the printable range
    cleaned_content = re.sub(r'[^\x00-\x7F]+', '', content)

    with open(output_path, 'w', encoding='utf-8') as file:
        file.write(cleaned_content)

# Update with your file paths
input_file = 'path/oldfinename.yml'
output_file = 'path/product_types.yml'

clean_file(input_file, output_file)
msimeon-cnes commented 1 week ago

Thank you, I opened an issue directly at eodag project here : https://github.com/CS-SI/eodag/issues/1317