# Pipeline IO


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

------------------------------------------------------------------------

<a
href="https://github.com/michaelaye/p4tools/blob/main/p4tools/production/io.py#L96"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_ground_projection_root

``` python

def get_ground_projection_root(
    
)->Path | None:

```

------------------------------------------------------------------------

<a
href="https://github.com/michaelaye/p4tools/blob/main/p4tools/production/io.py#L84"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_data_root

``` python

def get_data_root(
    
)->Path | None:

```

------------------------------------------------------------------------

<a
href="https://github.com/michaelaye/p4tools/blob/main/p4tools/production/io.py#L61"
target="_blank" style="float:right; font-size:smaller">source</a>

### set_database_path

``` python

def set_database_path(
    dbfolder, # Path to where planet4 will store clustering results by default.
)->None:

```

*Use to write the database path into the config.*

------------------------------------------------------------------------

<a
href="https://github.com/michaelaye/p4tools/blob/main/p4tools/production/io.py#L40"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_config

``` python

def get_config(
    
)->ConfigParser | None: # Dictionary with the content of the configpath file, or None if config
file does not exist.

```

*Read the configfile and return config dict.*

------------------------------------------------------------------------

<a
href="https://github.com/michaelaye/p4tools/blob/main/p4tools/production/io.py#L210"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_random_tile

``` python

def get_random_tile(
    db:str | None=None, # Path to Parquet database. Resolved from config if *None*.
    tolerance:float=0.5, # Fractional tolerance around the mean (default 0.5 = within 50%).
)->dict: # Keys: ``image_id``, ``image_name``, ``markings``, ``avg``.

```

*Pick a random tile with a near-average marking count.*

------------------------------------------------------------------------

<a
href="https://github.com/michaelaye/p4tools/blob/main/p4tools/production/io.py#L144"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_db_stats

``` python

def get_db_stats(
    db:str | None=None, # Path to Parquet database. Resolved from config if *None*.
    top:int=10, # Number of top tiles/obsids to include.
)->dict: # Keys: ``n_markings``, ``n_tiles``, ``n_obsids``,
``avg_per_tile``, ``avg_per_obsid``,
``type_counts`` (dict), ``top_tiles`` (DataFrame),
``top_obsids`` (DataFrame).

```

*Compute summary statistics for a raw Planet Four database.*

------------------------------------------------------------------------

<a
href="https://github.com/michaelaye/p4tools/blob/main/p4tools/production/io.py#L113"
target="_blank" style="float:right; font-size:smaller">source</a>

### resolve_dbname

``` python

def resolve_dbname(
    db:str | None=None, # Explicit path to the Parquet database.  If *None*, the path is read
from ``[planet4_db] dbname`` in the config file.
)->str: # Resolved database path.

```

*Resolve the database path from an explicit argument or the config
file.*

------------------------------------------------------------------------

<a
href="https://github.com/michaelaye/p4tools/blob/main/p4tools/production/io.py#L245"
target="_blank" style="float:right; font-size:smaller">source</a>

### check_and_pad_id

``` python

def check_and_pad_id(
    imgid, # The ID of the individual image.
)->str | None: # The padded image ID if it was provided, otherwise None.

```

*Checks the Image ID and pads it if necessary.*

------------------------------------------------------------------------

<a
href="https://github.com/michaelaye/p4tools/blob/main/p4tools/production/io.py#L266"
target="_blank" style="float:right; font-size:smaller">source</a>

### PathManager

``` python

def PathManager(
    id_:str='', datapath:str='clustering', suffix:str='.csv', obsid:str='', cut:float=0.5, extra_path:str=''
):

```

*Manage file paths and folders related to the analysis pipeline.*

Level definitions: \* L0 : Raw output of Planet Four \* L1A : Clustering
of Blotches and Fans on their own \* L1B : Clustered blotches and fans
combined into final fans, final blotches, and fnotches that need to have
a cut applied for the decision between fans or blotches. \* L1C :
Derived database where a cut has been applied for fnotches to become
either fan or blotch.

------------------------------------------------------------------------

<a
href="https://github.com/michaelaye/p4tools/blob/main/p4tools/production/io.py#L541"
target="_blank" style="float:right; font-size:smaller">source</a>

### DBManager

``` python

def DBManager(
    dbname:NoneType=None, # Filename of database file to use.
    obsid:NoneType=None
):

```

*Access class for database activities.*

Provides easy access to often used data items.
