Skip to content
Snippets Groups Projects
run_identify.py 1.5 KiB
Newer Older
# Usage Example
from enstools.feature.pipeline import FeaturePipeline
from enstools.feature.identification.african_easterly_waves import AEWIdentification
from enstools.feature.tracking.african_easterly_waves import AEWTracking

from enstools.feature.identification._proto_gen import african_easterly_waves_pb2
from os.path import expanduser, join
from enstools.feature.identification.african_easterly_waves.plotting import plot_timesteps_from_desc, plot_tracks_from_graph
pipeline = FeaturePipeline(african_easterly_waves_pb2, processing_mode='2d')

# init AEWIdentification strategy, can take different parameters
i_strat = AEWIdentification(wt_out_file=False, cv='cv')

pipeline.set_identification_strategy(i_strat)
Christoph Fischer's avatar
Christoph Fischer committed
pipeline.set_tracking_strategy(t_strat) # None
data_path = join(expanduser("~") + '/phd/data/aew/cv/2008cv.nc')
pipeline.set_data_path(data_path)

# execute pipeline
pipeline.execute()

od = pipeline.get_object_desc() # just the identified objects and their connections in object_desc

Christoph.Fischer's avatar
Christoph.Fischer committed
# generate the single tracks
pipeline.generate_tracks()
# out_netcdf_path = data_path + '_streamers.nc'
out_json_path = data_path[:-3] + 'aew_desc.json'
out_graph_path = data_path[:-3] + 'aew_graph.json'
out_dataset_path = data_path[:-5] + '_out.nc'
Christoph Fischer's avatar
Christoph Fischer committed
pipeline.save_result(description_type='json', dataset_path=out_dataset_path) # , description_path=out_json_path, graph_path=out_graph_path
print("Plot.")
# plot_timesteps_from_desc(od, pipeline.get_data())
plot_tracks_from_graph(od, pipeline.get_data())