IO

A lot of I/O related tasks are handled internally in the step class polaris.Step. Some of the lower level functions can be called directly if need be.

Download

You can download files more directly if you need to using polaris.io.download(), though we recommend using polaris.Step.add_input_file() whenever possible because it is more flexible and takes care of more of the details of symlinking the local file and adding it as an input to the step. No current tasks use download() directly, but an example might look like this:

import os
from polaris.io import symlink, download

def setup(self):
    config = self.config
    step_dir = self.work_dir
    database_root = self.config.get('paths', 'database_root')
    download_path = os.path.join(database_root, 'mpas-ocean',
                                 'bathymetry_database')

    remote_filename = \
        'BedMachineAntarctica_and_GEBCO_2019_0.05_degree.200128.nc'
    local_filename = 'topography.nc'

    download(
        url=f'https://web.lcrc.anl.gov/public/e3sm/mpas_standalonedata/'
            f'mpas-ocean/bathymetry_database/{remote_filename}',
        config=config, dest_path=download_path)

    symlink(os.path.join(download_path, remote_filename),
            os.path.join(step_dir, local_filename))

In this example, the remote file BedMachineAntarctica_and_GEBCO_2019_0.05_degree.200128.nc gets downloaded into the bathymetry database (if it’s not already there). Then, we create a local symlink called topography.nc to the file in the bathymetry database.