DynamicGravitySystems / DGP

Dynamic Gravity Processor
http://dgp.readthedocs.io/en/develop/
Apache License 2.0
7 stars 4 forks source link

Future of transforms #72

Open cbertinato opened 6 years ago

cbertinato commented 6 years ago

There are two major objectives that I would like to work toward with respect to transforms: 1) a more declarative syntax for transform graphs and the functions that implement the nodes; 2) caching or containerization of processing 'runs' with different parameters.

The intention of the first is to make transform graphs much less unwieldy and more efficient space-wise. My vision is something along the lines of this prototype:

class ExampleGraph(TransformGraph):
    inputs = ('trajectory', 'gravity', 'begin_static', 'end_static')
    graph = {
        ('gravity', 'trajectory'): (align_frames(item='r'), 'gravity', 'trajectory'),
        ('eotvos', 'accel'): (eotvos_correction, 'trajectory'),
        'lat_corr': (latitude_correction, 'trajectory'),
        'fac': (free_air_correction, 'trajectory'),
        'total_corr': (sum, ['eotvos', 'accel', 'lat_corr', 'fac']),
        'corrected_grav': (sum, 'total_corr', demux('gravity', 'gravity')),
        'filtered_grav': (lp_filter(fs=10), 'corrected_grav')
    }

This is slightly cleaner than the current implementation and there are likely use-cases that I haven't thought of that would require some changes here, but it is a step closer to what I would this to look like.

Defining a node would pull from an earlier implementation of transform graphs that we had done:

@transformgraph
def detrend(begin_static, end_static, data_in):
    if hasattr(grav, 'index'):
        length = len(data_in.index)
    else:
        length = len(data_in)

    trend = np.linspace(begin, end, num=length)
    if hasattr(data_in, 'sub'):
        trend = pd.Series(trend, index=data_in.index)
        result = data_in.sub(trend, axis=0)
    else:
        result = data_in - trend
    return result

The intention of the second is to enable a user to compare results when processing with different graph nodes or different parameters. For example, one might want to assess how different filter cut-off frequencies affect the free air anomaly. This too recalls some of the things we had done much earlier on with transform chains. Ideas on how this should look still need to be sketched out.