> For the complete documentation index, see [llms.txt](https://exolabs-ch.gitbook.io/cosmos/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://exolabs-ch.gitbook.io/cosmos/raw-data-access-1.md).

# Raw Data Access

{% hint style="info" %}
The authentication system for raw data access on AWS S3 is independent of the COSMOS service authentication!
{% endhint %}

## Authentication

The authentication system for raw data access on AWS S3 is independent of the COSMOS service authentication! The download of raw data can be done from within a browser or programmatically. Only folders a respective user has granted access to can be accessed.&#x20;

The AWS S3 credentials contain a selection of:

* Username
* Password
* Access key ID&#x20;
* Secret access key&#x20;
* Account ID

## Browser Access

To access data in a browser, the specific folder link a respective user has granted access to needs to be provided by ExoLabs. To successfully login, the IAM User Account ID, IAM Username and the password are needed.&#x20;

## Programmatic Access

AWS provides tools for S3 access, mainly boto3 for Python and the AWS Command Line Interface (CLI). AWS CLI needs to be configured before usage.

### AWS CLI

```bash
❯ aws configure
AWS Access Key ID [None]: 
AWS Secret Access Key [None]: 
Default region name [None]: eu-central-1
Default output format [None]: 
```

```
aws s3 sync s3://exolabs-swiss-project/alps Downloads/ --exclude "*" --include "2023-02-08*" --dryrun
```

{% embed url="<https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html>" %}

### AWS BOTO3

```python
import boto3
from os import path as op
from datetime import datetime

#   AWS Credentials
access_key = 'foo'
secret = 'bar'

#   Configuration
bucket = 'exolabs-swiss-project'
roi = 'alps'
product_type = 'SWE'
timestamp = '000'
doi = '8. February 2024'

# Convert Date
doi = datetime.strptime(doi, '%d. %B %Y').strftime('%Y-%m-%d')

# Download
selection = op.join(roi, doi, f'{doi}+{timestamp}_{roi}_{product_type}_product.tif')
download_to = op.basename(selection)
if not op.isfile(download_to):
    session = boto3.Session(
        aws_access_key_id=access_key,
        aws_secret_access_key=secret,
        region_name='eu-central-1'
    )
    s3 = session.client('s3')
    s3.download_file(bucket, selection, download_to)
    print(download_to)

```

Descriptions for the available data can be found here:

{% content-ref url="/pages/-MQWPdF8CYbuKw8kuXGI" %}
[Raw Data Listing](/cosmos/raw-data-listing.md)
{% endcontent-ref %}
