# Usage Example

from enstools.feature.pipeline import FeaturePipeline
from enstools.feature.identification.template import IdentificationTemplate
from enstools.feature.tracking.template_object_compare import TrackingCompareTemplate
from enstools.feature.tracking.template import TrackingTemplate
from enstools.feature.identification._proto_gen import template_pb2
from os.path import expanduser

# set the pb_reference to the compiled pb2.py file (see proto_gen directory)
pipeline = FeaturePipeline(template_pb2, processing_mode='2d')

# change this to an identification technique that actually does something: existing one or implement your own
i_strat = IdentificationTemplate(some_parameter='foo') # set the Identification strategy
t_strat = TrackingCompareTemplate() # set the tracking strategy

pipeline.set_identification_strategy(i_strat)
pipeline.set_tracking_strategy(t_strat) # or None as argument if no tracking

path = expanduser("~") + '/phd/data/tracked/feature/enstools_feature_test.nc' #  ERA5/vietnam/t0_glob.nc' #  set data path(s) here
pipeline.set_data_path(path)

# execute pipeline
pipeline.execute()
# or separated...
# pipeline.execute_identification()
# pipeline.execute_tracking()

# generate the single tracks
pipeline.generate_tracks()

out_json_path = path[:-3] + '_desc.json'
out_graph_path = path[:-3] + '_graph.json'

od = pipeline.get_object_desc() # identified objects, and graph-structure if tracking done

pipeline.save_result(description_type='json', description_path=out_json_path) # dataset_path=...