# Fnotching


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

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

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

### calc_indices_from_index

``` python

def calc_indices_from_index(
    n, # Length of condensed matrix
    c, # Index of the distance value of interest
): # Coordinate pair of the 2 indices that were used to calculate distance
at index c of the condensed distance matrix.

```

*calculate source indices from condensed distance matrix.*

The `pdist` function returns its measurements in a (01, 02, 03, 12, 13…)
fashion and this function can be used to get out the original
coordinates of the 2 inputs.

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

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

### remove_opposing_fans

``` python

def remove_opposing_fans(
    fans, # Fan marking data
    eps:int=20
): # Data with opposing fans removed.

```

*Find fans that have opposite orientation and remove lower voted one.*

First check if any fans are close enough to be fnotched (same criteria
as blotch-fan fnotching), then check if any of those have opposite
orientation. Delete the one with lower votes. If number of votes is
equal, take a random choice.

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

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

### get_clusters_in_path

``` python

def get_clusters_in_path(
    path, # Path in where to search for L1A csv files.
): # List with 2 pd.DataFrames

```

*Find csv files in path and combine into DataFrame.*

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

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

### get_id_from_path

``` python

def get_id_from_path(
    path
):

```

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

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

### data_to_centers

``` python

def data_to_centers(
    df, # Dataframe with either fan or blotch marking data. It probes itself
which one it is by looking at if distances and radii are defined.
    kind, scope:str='hirise'
):

```

*Convert a dataframe with marking data to an array of center coords.*

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

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

### fnotch_image_ids

``` python

def fnotch_image_ids(
    obsid, # Observation ID for which the clustering and fnotching is performed.
    eps:int=20, # The maximum distance in pixels to consider for fnotching, by default 20.
    savedir:NoneType=None, # Directory where the results will be saved, by default None.
    scope:str='hirise', # Coordinate scope of the calculation, by default "hirise".
):

```

*Cluster each image_id for an obsid separately and perform fnotching.*

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

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

### write_l1c

``` python

def write_l1c(
    kind, # P4 marking kind
    slashed, # The remaining fnotch data after applying the cut
    pm, # The PathManager for the current image_id
):

```

*Write the L1C for marking `kind`.*

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

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

### apply_cut_obsid

``` python

def apply_cut_obsid(
    obsid, cut:float=0.5, savedir:NoneType=None
):

```

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

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

### apply_cut

``` python

def apply_cut(
    obsid, # HiRISE obsid, i.e. P4 `image_name`
    cut:float=0.5, # Value where to cut the vote_ratio of the fnotches.
    savedir:NoneType=None
):

```

*Loop over all image_id paths for an obsid and apply cut to fnotches.*
