Skip to content

adding new pickers

Mike Brady edited this page Mar 5, 2020 · 2 revisions

Adding a new air-snow/snow-ice layer picking function:

All picker functions are stored under the algorithms subdirectory.

The general ideas are:

  • One module per usergroup (i.e. The GSFC_NK.py file contains pickers designed and implemented by NASA Goddard contributors)
  • Many pickers can exist per module
  • Each picker reads a single trace of SnowRadar data (i.e. 1D numpy array of floats) and returns 2 index values (for air-snow and snow-ice interface locations, respectively) which correspond to the input trace.

To add a new picker for a new group, here are some steps to follow:

1. Create a new .py file under algorithms subdirectory

mygroup.py

2. Add your picker code to this .py file as a function, for example:

def my_picker(trace, arg1, arg2, ... argN, kwarg1, kwarg2, ... kwargN):
    ...code...

3. Update the __init__.py file inside the algorithms subdirectory to allow your function to be imported:

from .mygroup import my_picker

4. Update the layerpicking.py file to allow your picker to be selected. For example:

from pySnowRadar.algorithms import GSFC_NK, NSIDC, Wavelet_TN, my_picker

...

    elif choice == 'mypicker':
        try:
            airsnow_layer, snowice_layer = my_picker(
                data, arg1, arg2, *kwargs
            )
        except KeyError:
            raise Exception('Missing or invalid parameters supplied for My_Picker picker')