Simple-Track 2.0.7__tar.gz → 2.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. {simple_track-2.0.7 → simple_track-2.2.0}/PKG-INFO +77 -53
  2. {simple_track-2.0.7 → simple_track-2.2.0}/README.md +76 -52
  3. {simple_track-2.0.7 → simple_track-2.2.0}/pyproject.toml +1 -1
  4. {simple_track-2.0.7 → simple_track-2.2.0}/src/Simple_Track.egg-info/PKG-INFO +77 -53
  5. {simple_track-2.0.7 → simple_track-2.2.0}/src/Simple_Track.egg-info/SOURCES.txt +2 -0
  6. simple_track-2.2.0/src/run_simple_track.py +61 -0
  7. {simple_track-2.0.7 → simple_track-2.2.0}/src/simpletrack/feature.py +121 -3
  8. {simple_track-2.0.7 → simple_track-2.2.0}/src/simpletrack/flow_solver.py +70 -23
  9. {simple_track-2.0.7 → simple_track-2.2.0}/src/simpletrack/frame.py +13 -6
  10. {simple_track-2.0.7 → simple_track-2.2.0}/src/simpletrack/frame_tracker.py +6 -0
  11. {simple_track-2.0.7 → simple_track-2.2.0}/src/simpletrack/load.py +91 -74
  12. {simple_track-2.0.7 → simple_track-2.2.0}/src/simpletrack/track.py +72 -51
  13. simple_track-2.2.0/tests/test_cli.py +245 -0
  14. {simple_track-2.0.7 → simple_track-2.2.0}/tests/test_feature.py +129 -0
  15. {simple_track-2.0.7 → simple_track-2.2.0}/tests/test_flow_solver.py +40 -0
  16. {simple_track-2.0.7 → simple_track-2.2.0}/tests/test_frame.py +4 -9
  17. {simple_track-2.0.7 → simple_track-2.2.0}/tests/test_frame_tracker.py +13 -11
  18. simple_track-2.2.0/tests/test_load.py +100 -0
  19. simple_track-2.2.0/tests/test_mwe_output.py +376 -0
  20. {simple_track-2.0.7 → simple_track-2.2.0}/tests/test_simple_track_and_load.py +3 -34
  21. simple_track-2.0.7/src/run_simple_track.py +0 -22
  22. simple_track-2.0.7/tests/test_mwe_output.py +0 -118
  23. {simple_track-2.0.7 → simple_track-2.2.0}/LICENSE +0 -0
  24. {simple_track-2.0.7 → simple_track-2.2.0}/setup.cfg +0 -0
  25. {simple_track-2.0.7 → simple_track-2.2.0}/src/Simple_Track.egg-info/dependency_links.txt +0 -0
  26. {simple_track-2.0.7 → simple_track-2.2.0}/src/Simple_Track.egg-info/entry_points.txt +0 -0
  27. {simple_track-2.0.7 → simple_track-2.2.0}/src/Simple_Track.egg-info/requires.txt +0 -0
  28. {simple_track-2.0.7 → simple_track-2.2.0}/src/Simple_Track.egg-info/top_level.txt +0 -0
  29. {simple_track-2.0.7 → simple_track-2.2.0}/src/simpletrack/__init__.py +0 -0
  30. {simple_track-2.0.7 → simple_track-2.2.0}/src/simpletrack/exceptions.py +0 -0
  31. {simple_track-2.0.7 → simple_track-2.2.0}/src/simpletrack/frame_output.py +0 -0
  32. {simple_track-2.0.7 → simple_track-2.2.0}/src/simpletrack/utils.py +0 -0
  33. {simple_track-2.0.7 → simple_track-2.2.0}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Simple-Track
3
- Version: 2.0.7
3
+ Version: 2.2.0
4
4
  Summary: Threshold-based object tracking algorithm for 2D data
5
5
  Author-email: Adam Gainford <adam.gainford@reading.ac.uk>, Thorwald Stein <t.h.m.stein@reading.ac.uk>
6
6
  License-Expression: MPL-2.0
@@ -23,13 +23,13 @@ Dynamic: license-file
23
23
  # Simple-Track
24
24
 
25
25
  <p align="center">
26
- <img src="docs/anim_feature.gif" alt="Feature field from Simple-Track" width="400"/>
27
- <img src="docs/anim_lifetime.gif" alt="Lifetime field from Simple-Track" width="400"/>
26
+ <img src="docs/animations/anim_feature.gif" alt="Feature field from Simple-Track" width="400"/>
27
+ <img src="docs/animations/anim_lifetime.gif" alt="Lifetime field from Simple-Track" width="400"/>
28
28
  </p>
29
29
 
30
30
  Simple-Track is a data-agnostic, threshold-based feature tracking algorithm for 2D data.
31
31
 
32
- Features are tracked between consecutive frames of data by projecting feature fields onto common timeframes and matching between them based on the degree of overlap. Matched features retain the same identification between all tracked fields, while new features are assigned a unique label. Comprehensive information about feature merging, splitting, accretion, initiation and dissipation is compiled using Simple-Track.
32
+ Features are tracked between consecutive frames of data by projecting feature fields onto common timeframes and matching between them based on the degree of overlap. Matched features retain the same identification between all tracked fields, while new features are assigned a unique label. Simple-Track compiles comprehensive information about feature merging, splitting, accretion, initiation and dissipation with an easy to use interface.
33
33
 
34
34
  # Installation
35
35
 
@@ -45,6 +45,8 @@ Coming soon to uv
45
45
 
46
46
  # User Guide
47
47
 
48
+ This section describes the main methods of running Simple-Track. More details can be found [in the docs](docs/user_guide.md)
49
+
48
50
  ## Input Requirements
49
51
  While Simple-Track is designed to accept a wide range of input data, certain requirements must be met for the tool to function as intended:
50
52
 
@@ -54,8 +56,6 @@ While Simple-Track is designed to accept a wide range of input data, certain req
54
56
 
55
57
  * The time between frames should be sufficiently short such that features can be reasonably expected to persist between frames. This is not a strict requirement since the tool includes an artificial advection step that projects data onto a common time, but it is likely that longer time steps will lead to more errors in feature matching and therefore less accurate tracking statistics.
56
58
 
57
- * It is currently a requirement that the timestep between frames is fixed, although future updates may relax this requirement.
58
-
59
59
  ## Running Simple-Track
60
60
 
61
61
  Simple-Track can be run in two ways:
@@ -67,37 +67,35 @@ Simple-Track can be run in two ways:
67
67
  simpletrack my_config.yaml
68
68
  ```
69
69
 
70
- * The `my_config.yaml` file contains the parameters for running Simple-Track. The necessary parameters for running Simple-Track from the command line are shown below:
70
+ * The `my_config.yaml` file contains the parameters for running Simple-Track. The required parameters are shown below:
71
71
 
72
72
  ```yaml
73
73
  INPUT:
74
- path: /path_to_folder_containing_data
75
- loader: LoaderName # See next section
74
+ path: /path_to_folder_containing_data/*.data
75
+ loader: /path_to_file_containing_function|function_name # See next section
76
76
  FEATURE:
77
77
  threshold: 1 # Threshold used for defining a feature
78
- under_threshold: false # Whether features are defined above or below the threshold
79
78
  ```
80
79
 
81
80
  * Other parameters, such as `experiment_name`, `output_path` and `save_data`, along with more technical options, can also be set in this config file. See [All Simple-Track Parameters](#all-simple-track-parameters) for a full list.
82
81
 
83
- * A valid `Loader` object is required for pre-processing input data before tracking. See [Loading Data](#loading-data) for more information.
82
+ * A valid loader function is required for pre-processing input data before tracking. See [Loading Data](#loading-data) for more information.
84
83
 
85
84
  * Any number of config files can be provided as additional arguments, Simple-Track will iterate over each one in turn.
86
85
 
87
86
  ### 2. Importing Simple-Track to a python file
88
- * Simple-Track can be run by importing the `Tracker` class from `track.py` or directly from the `simpletrack` module. The config can be input either using a path to a yaml file, or by passing a dict when instantiating the object:
87
+ * Simple-Track can be run by importing the `Tracker` class from the `simpletrack` module. A config can be input either using a path to a yaml file, or by passing a dict when instantiating the object:
89
88
 
90
89
  ```python
91
90
  from simpletrack import Tracker
92
91
 
93
92
  my_config = {
94
93
  INPUT: {
95
- path: "/path_to_folder_containing_data",
96
- loader: "LoaderName" # See next section
94
+ path: "/path_to_folder_containing_data/*.data",
95
+ loader: "/path_to_file_containing_function|function_name" # See next section
97
96
  },
98
97
  FEATURE: {
99
98
  threshold: 1, # Threshold used for defining a feature
100
- under_threshold: False # Whether features are defined above or below the threshold
101
99
  }
102
100
  }
103
101
 
@@ -108,64 +106,89 @@ Simple-Track can be run in two ways:
108
106
  ```
109
107
  * Other parameters, such as `experiment_name`, `output_path` and `save_data`, along with more technical options, can also be set in this config. See [All Simple-Track Parameters](#all-simple-track-parameters) for a full list.
110
108
 
111
- * If `loader` is included as a config input, a valid `Loader` object is used for pre-processing input data before tracking. Alternatively, valid pre-processed data may be passed to the `Tracker.run()` method, bypassing the use of the `Loader` class, and eliminating the need for the `INPUT` config section. See [Loading Data](#loading-data) for more information.
109
+ * If `loader` is included as a config input, the specified function is used for pre-processing input data before tracking. Alternatively, valid pre-processed data may be passed to the `Tracker.run()` method, bypassing the use of a separate function, and eliminating the need for the `INPUT` config section. See [Loading Data](#loading-data) for more information.
112
110
 
113
111
  * `Tracker.run()` returns a `Timeline` object which is used to store all tracking and feature data. This can be inspected and analysed beyond the [outputs](#outputs) that are saved as part of standard operation.
114
112
 
115
113
  ## Loading Data
116
114
 
117
- For Simple-Track to operate effectively, each input must consist of two sets of data:
115
+ Each Simple-Track input must contain two sets of data:
118
116
 
119
117
  1. A `datetime` object specifying the time that the data is valid for
120
118
  2. A `numpy.array` object containing the data to track
121
119
 
122
- There are two methods of providing these data pairs to Simple-Track:
120
+ There are three methods of providing these data pairs to Simple-Track:
121
+
122
+ ### 1. Loading through config options
123
+ * Simple-Track will load all data matching the structure given in `"INPUT": "path"` config section. This input supports wildcard matching (i.e., using `"./path_to_data/*.data"` would load all files with the `.data` suffix).
123
124
 
124
- ### 1. Using a Loader object
125
- * Since Simple-Track is a data-agnostic tool, there may be any number of bespoke tools for loading and pre-processing data before it is suitable for tracking. This functionality can be contained in a custom `Loader` class that will perform these actions before passing the compatible data (and time) to the main processing methods.
125
+ * Each file contains one input to Simple-Track ([see here](docs/inputs.md#extra-loading-parameters) for more information)
126
126
 
127
- * A custom `Loader` object should be defined in the `load.py` file and should inherit from the `BaseLoader` object, which
128
- will perform additional checks to ensure the loaded data is in the correct format. An example of a loader class is shown in the code snippet below:
127
+ * Since Simple-Track is a data-agnostic tool, there may be any number of bespoke tools for loading and pre-processing data before it is suitable for tracking. This functionality can be contained in a custom loader function that will perform these actions before passing the compatible data to the main processing workflow.
128
+
129
+ * An example of a custom loader function is shown below:
129
130
 
130
131
  ```python
131
- class ChilboltonLoader(BaseLoader):
132
- def __init__(self):
133
- super().__init__()
132
+ def user_definable_load(self, filename):
133
+ import iris # Import any required libraries here
134
134
 
135
- def user_definable_load(self, filename):
136
- import iris # Import any required libraries here
135
+ # Get 2D data from input file as a numpy array
136
+ cube = iris.load_cube(filename, "precipitation_flux")
137
+ data = cube.data
137
138
 
138
- # Get 2D data from input file as a numpy array
139
- cube = iris.load_cube(filename, "precipitation_flux")
140
- data = cube.data
139
+ # Additional data pre-processing can be performed here too!
141
140
 
142
- # Additional data pre-processing can be performed here too!
141
+ # Get time from input file, in datetime format
142
+ tcoord = cube.coord("time")
143
+ time = tcoord.units.num2pydate(tcoord.points)[0]
143
144
 
144
- # Get time from input file, in datetime format
145
- tcoord = cube.coord("time")
146
- time = tcoord.units.num2pydate(tcoord.points)[0]
145
+ # Method must return a tuple of
146
+ # (datetime.datetime, numpy.NDArray), where the
147
+ # first element is the time the data is valid for
148
+ # and second element is the 2D array of data to be tracked
149
+ return time, data
150
+ ```
147
151
 
148
- # Method must return a tuple of
149
- # (datetime.datetime, numpy.NDArray, ), where the
150
- # first element is the time the data is valid for
151
- # and second element is the 2D array of data to be tracked
152
- return time, data
152
+ * This loader function is then specified in the `"INPUT": "loader"` config using the `./path_to_file.py|func_name` format. So in this case, the config option would be `./path_to_file.py|user_definable_load`.
153
+
154
+ * Loading via the config can be used whether Simple-Track is being run [from the command line](#1-running-simple-track-from-the-command-line) or [from a python file](#2-importing-simple-track-to-a-python-file).
155
+
156
+ ### 2. Loading through the Command Line
157
+ * The same `"INPUT"` config sections mentioned above can also be input [from the command line](#1-running-simple-track-from-the-command-line)
158
+
159
+ ```
160
+ simpletrack my_config.yaml -i /path_to_folder/*.data -l ./path_to_file.py|func_name
153
161
  ```
154
162
 
155
- * This loader class must then be added to the `available_loaders` dict in the `get_loader` function of `load.py`, where the key for this loader is used to specify the loader in the config file. This structure allows users to easily define their own loading procedures for their specific datasets, while still being able to use the core functionality of Simple-Track without modification.
163
+ * Each file contains one input to Simple-Track ([see here](docs/inputs.md#extra-loading-parameters) for more information)
156
164
 
157
- * A Loader object can be used whether Simple-Track is being run [from the command line](#1-running-simple-track-from-the-command-line) or [from a python file](#2-importing-simple-track-to-a-python-file).
165
+ ### 3. Passing a dict directly to Tracker.run()
166
+ * If SimpleTrack is being run [from a python file](#2-importing-simple-track-to-a-python-file) and a suitable set of data has already been loaded, this data can be passed directly to `Tracker.run()` as a `dict`, with the `datetime` object as the key and a `numpy.array` object as the value. For example:
158
167
 
159
- * The list of filenames which will be iteratively loaded using a custom `Loader` object can be obtained and input in multiple ways:
160
- * If running Simple-Track [from the command line](#1-running-simple-track-from-the-command-line), the code will find all files in the config `[INPUT][path]` directory matching a given extension defined in `Tracker.get_filenames_from_input_path()`
161
- * If running Simple-Track [from a python file](#2-importing-simple-track-to-a-python-file), a list of filenames can be passed to `Tracker.run()`. Alternatively, if no filenames are passed to this method, the code will find all files in the config `[INPUT][path]` directory matching a given extension defined in `Tracker.get_filenames_from_input_path()`
168
+ ```python
169
+ import datetime as dt
170
+ import numpy as np
171
+ from simpletrack import Tracker
172
+
173
+ time1 = dt.datetime(year=2000, month=1, day=1, hour=10, minute=5)
174
+ time2 = time1 + dt.timedelta(minutes=5)
175
+
176
+ data1 = np.array(...)
177
+ data2 = np.array(...)
162
178
 
163
- ### 2. Passing a dict directly to Tracker.run()
164
- * If SimpleTrack is being run [from a python file](#2-importing-simple-track-to-a-python-file) and a suitable set of data has already been loaded, this data can be passed directly to `Tracker.run()` as a `dict`, with the `datetime` object as the key and a `numpy.array` object as the value
179
+ st_input = {
180
+ time1: data1,
181
+ time2: data2,
182
+ }
183
+
184
+ my_config = {...}
185
+
186
+ Tracker(my_config).run(st_input)
187
+ ```
165
188
 
166
189
  * Any number of time:data pairs can be passed to `Tracker.run()` and the code will iterate over the ordered dict.
167
190
 
168
- * Passing data into `Tracker.run()` via this method will bypass any `Loader` or `[INPUT][path]` inputs specified in the corresponding config file.
191
+ * Passing data into `Tracker.run()` via this method will bypass any `"INPUT":"loader"` or `"INPUT":"path"` inputs specified in the corresponding config file.
169
192
 
170
193
 
171
194
  # Outputs
@@ -193,13 +216,14 @@ It it also possible to perform further analysis of tracking statistics using the
193
216
  Alternatively, the data that is output by Simple-Track can be read back in to a `Timeline` object using the `LoadOutput` class in `frame_output.py`. This object only requires a path to the stored Simple-Track data. The `LoadOutput.load_to_timeline()` method will return a `Timeline` object containing all of the loaded data in the same data structures that Simple-Track stores its data. (Note: this does not currently load the raw input data back into the system, and therefore some methods such as `Frame.identify_features()` will not work. This data can be added manually to the `Frame.raw_field` attribute).
194
217
 
195
218
  # All Simple-Track Parameters
196
- A complete list of parameters and their default values are given below:
219
+ A complete list of parameters and their default values are given below. For a more thorough explanation of each parameter, refer to the docs.
197
220
 
198
221
  ```yaml
199
222
  INPUT:
200
- path: ./path_to_input_data
201
- loader: MyLoader # Custom loader class name
202
- file_type: .nc # File extension to search for when compiling files to load and iterate over
223
+ path: ./path_to_input_data/*.data
224
+ loader: /path_to_file_containing_function|function_name
225
+ iterate_over_array: False # Whether to iterate a single array or multiple files
226
+ iterating_dim: 0 # If iterate_over_array flag is enabled, this sets the dimension to iterate over
203
227
 
204
228
  OUTPUT:
205
229
  path: ./output
@@ -213,7 +237,7 @@ FEATURE:
213
237
  min_size: 4 # Minimum size of feature to be tracked (in pixels)
214
238
 
215
239
  FLOW_SOLVER:
216
- overlap_threshold: 0.6 # Minimum fraction of overlap between features for use in flow_solver
240
+ overlap_threshold: 0.3 # Minimum fraction of overlap between features for use in flow_solver
217
241
  subdomain_size: 100 # Size in pixels of individual squares to run fft for (dy, dx) displacement. Must divide (y,x) lengths of the array. Defaults to domain size / 5
218
242
  min_fractional_coverage: 0.01 # Minimum fractional cover of objects required for fft to obtain (dy, dx) displacement
219
243
  subdomain_tolerance: 3.0 # Maximum difference in displacement values between adjacent squares (to remove spurious values)
@@ -221,6 +245,6 @@ FLOW_SOLVER:
221
245
 
222
246
  TRACKING:
223
247
  overlap_nbhood: 5 # Radius of halo in pixels for orphan storms - big halo assumes storms may spawn "children" at a distance multiple pixels away
224
- overlap_threshold: 0.6 # Minimum fraction of overlap
248
+ overlap_threshold: 0.3 # Minimum fraction of overlap
225
249
  retain_lifetime_on_split: True # If a child Feature splits from its parent feature, this determines whether the child Feature should carry over the lifetime from the parent or whether its lifetime should be set to 1
226
250
  ```
@@ -1,13 +1,13 @@
1
1
  # Simple-Track
2
2
 
3
3
  <p align="center">
4
- <img src="docs/anim_feature.gif" alt="Feature field from Simple-Track" width="400"/>
5
- <img src="docs/anim_lifetime.gif" alt="Lifetime field from Simple-Track" width="400"/>
4
+ <img src="docs/animations/anim_feature.gif" alt="Feature field from Simple-Track" width="400"/>
5
+ <img src="docs/animations/anim_lifetime.gif" alt="Lifetime field from Simple-Track" width="400"/>
6
6
  </p>
7
7
 
8
8
  Simple-Track is a data-agnostic, threshold-based feature tracking algorithm for 2D data.
9
9
 
10
- Features are tracked between consecutive frames of data by projecting feature fields onto common timeframes and matching between them based on the degree of overlap. Matched features retain the same identification between all tracked fields, while new features are assigned a unique label. Comprehensive information about feature merging, splitting, accretion, initiation and dissipation is compiled using Simple-Track.
10
+ Features are tracked between consecutive frames of data by projecting feature fields onto common timeframes and matching between them based on the degree of overlap. Matched features retain the same identification between all tracked fields, while new features are assigned a unique label. Simple-Track compiles comprehensive information about feature merging, splitting, accretion, initiation and dissipation with an easy to use interface.
11
11
 
12
12
  # Installation
13
13
 
@@ -23,6 +23,8 @@ Coming soon to uv
23
23
 
24
24
  # User Guide
25
25
 
26
+ This section describes the main methods of running Simple-Track. More details can be found [in the docs](docs/user_guide.md)
27
+
26
28
  ## Input Requirements
27
29
  While Simple-Track is designed to accept a wide range of input data, certain requirements must be met for the tool to function as intended:
28
30
 
@@ -32,8 +34,6 @@ While Simple-Track is designed to accept a wide range of input data, certain req
32
34
 
33
35
  * The time between frames should be sufficiently short such that features can be reasonably expected to persist between frames. This is not a strict requirement since the tool includes an artificial advection step that projects data onto a common time, but it is likely that longer time steps will lead to more errors in feature matching and therefore less accurate tracking statistics.
34
36
 
35
- * It is currently a requirement that the timestep between frames is fixed, although future updates may relax this requirement.
36
-
37
37
  ## Running Simple-Track
38
38
 
39
39
  Simple-Track can be run in two ways:
@@ -45,37 +45,35 @@ Simple-Track can be run in two ways:
45
45
  simpletrack my_config.yaml
46
46
  ```
47
47
 
48
- * The `my_config.yaml` file contains the parameters for running Simple-Track. The necessary parameters for running Simple-Track from the command line are shown below:
48
+ * The `my_config.yaml` file contains the parameters for running Simple-Track. The required parameters are shown below:
49
49
 
50
50
  ```yaml
51
51
  INPUT:
52
- path: /path_to_folder_containing_data
53
- loader: LoaderName # See next section
52
+ path: /path_to_folder_containing_data/*.data
53
+ loader: /path_to_file_containing_function|function_name # See next section
54
54
  FEATURE:
55
55
  threshold: 1 # Threshold used for defining a feature
56
- under_threshold: false # Whether features are defined above or below the threshold
57
56
  ```
58
57
 
59
58
  * Other parameters, such as `experiment_name`, `output_path` and `save_data`, along with more technical options, can also be set in this config file. See [All Simple-Track Parameters](#all-simple-track-parameters) for a full list.
60
59
 
61
- * A valid `Loader` object is required for pre-processing input data before tracking. See [Loading Data](#loading-data) for more information.
60
+ * A valid loader function is required for pre-processing input data before tracking. See [Loading Data](#loading-data) for more information.
62
61
 
63
62
  * Any number of config files can be provided as additional arguments, Simple-Track will iterate over each one in turn.
64
63
 
65
64
  ### 2. Importing Simple-Track to a python file
66
- * Simple-Track can be run by importing the `Tracker` class from `track.py` or directly from the `simpletrack` module. The config can be input either using a path to a yaml file, or by passing a dict when instantiating the object:
65
+ * Simple-Track can be run by importing the `Tracker` class from the `simpletrack` module. A config can be input either using a path to a yaml file, or by passing a dict when instantiating the object:
67
66
 
68
67
  ```python
69
68
  from simpletrack import Tracker
70
69
 
71
70
  my_config = {
72
71
  INPUT: {
73
- path: "/path_to_folder_containing_data",
74
- loader: "LoaderName" # See next section
72
+ path: "/path_to_folder_containing_data/*.data",
73
+ loader: "/path_to_file_containing_function|function_name" # See next section
75
74
  },
76
75
  FEATURE: {
77
76
  threshold: 1, # Threshold used for defining a feature
78
- under_threshold: False # Whether features are defined above or below the threshold
79
77
  }
80
78
  }
81
79
 
@@ -86,64 +84,89 @@ Simple-Track can be run in two ways:
86
84
  ```
87
85
  * Other parameters, such as `experiment_name`, `output_path` and `save_data`, along with more technical options, can also be set in this config. See [All Simple-Track Parameters](#all-simple-track-parameters) for a full list.
88
86
 
89
- * If `loader` is included as a config input, a valid `Loader` object is used for pre-processing input data before tracking. Alternatively, valid pre-processed data may be passed to the `Tracker.run()` method, bypassing the use of the `Loader` class, and eliminating the need for the `INPUT` config section. See [Loading Data](#loading-data) for more information.
87
+ * If `loader` is included as a config input, the specified function is used for pre-processing input data before tracking. Alternatively, valid pre-processed data may be passed to the `Tracker.run()` method, bypassing the use of a separate function, and eliminating the need for the `INPUT` config section. See [Loading Data](#loading-data) for more information.
90
88
 
91
89
  * `Tracker.run()` returns a `Timeline` object which is used to store all tracking and feature data. This can be inspected and analysed beyond the [outputs](#outputs) that are saved as part of standard operation.
92
90
 
93
91
  ## Loading Data
94
92
 
95
- For Simple-Track to operate effectively, each input must consist of two sets of data:
93
+ Each Simple-Track input must contain two sets of data:
96
94
 
97
95
  1. A `datetime` object specifying the time that the data is valid for
98
96
  2. A `numpy.array` object containing the data to track
99
97
 
100
- There are two methods of providing these data pairs to Simple-Track:
98
+ There are three methods of providing these data pairs to Simple-Track:
99
+
100
+ ### 1. Loading through config options
101
+ * Simple-Track will load all data matching the structure given in `"INPUT": "path"` config section. This input supports wildcard matching (i.e., using `"./path_to_data/*.data"` would load all files with the `.data` suffix).
101
102
 
102
- ### 1. Using a Loader object
103
- * Since Simple-Track is a data-agnostic tool, there may be any number of bespoke tools for loading and pre-processing data before it is suitable for tracking. This functionality can be contained in a custom `Loader` class that will perform these actions before passing the compatible data (and time) to the main processing methods.
103
+ * Each file contains one input to Simple-Track ([see here](docs/inputs.md#extra-loading-parameters) for more information)
104
104
 
105
- * A custom `Loader` object should be defined in the `load.py` file and should inherit from the `BaseLoader` object, which
106
- will perform additional checks to ensure the loaded data is in the correct format. An example of a loader class is shown in the code snippet below:
105
+ * Since Simple-Track is a data-agnostic tool, there may be any number of bespoke tools for loading and pre-processing data before it is suitable for tracking. This functionality can be contained in a custom loader function that will perform these actions before passing the compatible data to the main processing workflow.
106
+
107
+ * An example of a custom loader function is shown below:
107
108
 
108
109
  ```python
109
- class ChilboltonLoader(BaseLoader):
110
- def __init__(self):
111
- super().__init__()
110
+ def user_definable_load(self, filename):
111
+ import iris # Import any required libraries here
112
112
 
113
- def user_definable_load(self, filename):
114
- import iris # Import any required libraries here
113
+ # Get 2D data from input file as a numpy array
114
+ cube = iris.load_cube(filename, "precipitation_flux")
115
+ data = cube.data
115
116
 
116
- # Get 2D data from input file as a numpy array
117
- cube = iris.load_cube(filename, "precipitation_flux")
118
- data = cube.data
117
+ # Additional data pre-processing can be performed here too!
119
118
 
120
- # Additional data pre-processing can be performed here too!
119
+ # Get time from input file, in datetime format
120
+ tcoord = cube.coord("time")
121
+ time = tcoord.units.num2pydate(tcoord.points)[0]
121
122
 
122
- # Get time from input file, in datetime format
123
- tcoord = cube.coord("time")
124
- time = tcoord.units.num2pydate(tcoord.points)[0]
123
+ # Method must return a tuple of
124
+ # (datetime.datetime, numpy.NDArray), where the
125
+ # first element is the time the data is valid for
126
+ # and second element is the 2D array of data to be tracked
127
+ return time, data
128
+ ```
125
129
 
126
- # Method must return a tuple of
127
- # (datetime.datetime, numpy.NDArray, ), where the
128
- # first element is the time the data is valid for
129
- # and second element is the 2D array of data to be tracked
130
- return time, data
130
+ * This loader function is then specified in the `"INPUT": "loader"` config using the `./path_to_file.py|func_name` format. So in this case, the config option would be `./path_to_file.py|user_definable_load`.
131
+
132
+ * Loading via the config can be used whether Simple-Track is being run [from the command line](#1-running-simple-track-from-the-command-line) or [from a python file](#2-importing-simple-track-to-a-python-file).
133
+
134
+ ### 2. Loading through the Command Line
135
+ * The same `"INPUT"` config sections mentioned above can also be input [from the command line](#1-running-simple-track-from-the-command-line)
136
+
137
+ ```
138
+ simpletrack my_config.yaml -i /path_to_folder/*.data -l ./path_to_file.py|func_name
131
139
  ```
132
140
 
133
- * This loader class must then be added to the `available_loaders` dict in the `get_loader` function of `load.py`, where the key for this loader is used to specify the loader in the config file. This structure allows users to easily define their own loading procedures for their specific datasets, while still being able to use the core functionality of Simple-Track without modification.
141
+ * Each file contains one input to Simple-Track ([see here](docs/inputs.md#extra-loading-parameters) for more information)
134
142
 
135
- * A Loader object can be used whether Simple-Track is being run [from the command line](#1-running-simple-track-from-the-command-line) or [from a python file](#2-importing-simple-track-to-a-python-file).
143
+ ### 3. Passing a dict directly to Tracker.run()
144
+ * If SimpleTrack is being run [from a python file](#2-importing-simple-track-to-a-python-file) and a suitable set of data has already been loaded, this data can be passed directly to `Tracker.run()` as a `dict`, with the `datetime` object as the key and a `numpy.array` object as the value. For example:
136
145
 
137
- * The list of filenames which will be iteratively loaded using a custom `Loader` object can be obtained and input in multiple ways:
138
- * If running Simple-Track [from the command line](#1-running-simple-track-from-the-command-line), the code will find all files in the config `[INPUT][path]` directory matching a given extension defined in `Tracker.get_filenames_from_input_path()`
139
- * If running Simple-Track [from a python file](#2-importing-simple-track-to-a-python-file), a list of filenames can be passed to `Tracker.run()`. Alternatively, if no filenames are passed to this method, the code will find all files in the config `[INPUT][path]` directory matching a given extension defined in `Tracker.get_filenames_from_input_path()`
146
+ ```python
147
+ import datetime as dt
148
+ import numpy as np
149
+ from simpletrack import Tracker
150
+
151
+ time1 = dt.datetime(year=2000, month=1, day=1, hour=10, minute=5)
152
+ time2 = time1 + dt.timedelta(minutes=5)
153
+
154
+ data1 = np.array(...)
155
+ data2 = np.array(...)
140
156
 
141
- ### 2. Passing a dict directly to Tracker.run()
142
- * If SimpleTrack is being run [from a python file](#2-importing-simple-track-to-a-python-file) and a suitable set of data has already been loaded, this data can be passed directly to `Tracker.run()` as a `dict`, with the `datetime` object as the key and a `numpy.array` object as the value
157
+ st_input = {
158
+ time1: data1,
159
+ time2: data2,
160
+ }
161
+
162
+ my_config = {...}
163
+
164
+ Tracker(my_config).run(st_input)
165
+ ```
143
166
 
144
167
  * Any number of time:data pairs can be passed to `Tracker.run()` and the code will iterate over the ordered dict.
145
168
 
146
- * Passing data into `Tracker.run()` via this method will bypass any `Loader` or `[INPUT][path]` inputs specified in the corresponding config file.
169
+ * Passing data into `Tracker.run()` via this method will bypass any `"INPUT":"loader"` or `"INPUT":"path"` inputs specified in the corresponding config file.
147
170
 
148
171
 
149
172
  # Outputs
@@ -171,13 +194,14 @@ It it also possible to perform further analysis of tracking statistics using the
171
194
  Alternatively, the data that is output by Simple-Track can be read back in to a `Timeline` object using the `LoadOutput` class in `frame_output.py`. This object only requires a path to the stored Simple-Track data. The `LoadOutput.load_to_timeline()` method will return a `Timeline` object containing all of the loaded data in the same data structures that Simple-Track stores its data. (Note: this does not currently load the raw input data back into the system, and therefore some methods such as `Frame.identify_features()` will not work. This data can be added manually to the `Frame.raw_field` attribute).
172
195
 
173
196
  # All Simple-Track Parameters
174
- A complete list of parameters and their default values are given below:
197
+ A complete list of parameters and their default values are given below. For a more thorough explanation of each parameter, refer to the docs.
175
198
 
176
199
  ```yaml
177
200
  INPUT:
178
- path: ./path_to_input_data
179
- loader: MyLoader # Custom loader class name
180
- file_type: .nc # File extension to search for when compiling files to load and iterate over
201
+ path: ./path_to_input_data/*.data
202
+ loader: /path_to_file_containing_function|function_name
203
+ iterate_over_array: False # Whether to iterate a single array or multiple files
204
+ iterating_dim: 0 # If iterate_over_array flag is enabled, this sets the dimension to iterate over
181
205
 
182
206
  OUTPUT:
183
207
  path: ./output
@@ -191,7 +215,7 @@ FEATURE:
191
215
  min_size: 4 # Minimum size of feature to be tracked (in pixels)
192
216
 
193
217
  FLOW_SOLVER:
194
- overlap_threshold: 0.6 # Minimum fraction of overlap between features for use in flow_solver
218
+ overlap_threshold: 0.3 # Minimum fraction of overlap between features for use in flow_solver
195
219
  subdomain_size: 100 # Size in pixels of individual squares to run fft for (dy, dx) displacement. Must divide (y,x) lengths of the array. Defaults to domain size / 5
196
220
  min_fractional_coverage: 0.01 # Minimum fractional cover of objects required for fft to obtain (dy, dx) displacement
197
221
  subdomain_tolerance: 3.0 # Maximum difference in displacement values between adjacent squares (to remove spurious values)
@@ -199,6 +223,6 @@ FLOW_SOLVER:
199
223
 
200
224
  TRACKING:
201
225
  overlap_nbhood: 5 # Radius of halo in pixels for orphan storms - big halo assumes storms may spawn "children" at a distance multiple pixels away
202
- overlap_threshold: 0.6 # Minimum fraction of overlap
226
+ overlap_threshold: 0.3 # Minimum fraction of overlap
203
227
  retain_lifetime_on_split: True # If a child Feature splits from its parent feature, this determines whether the child Feature should carry over the lifetime from the parent or whether its lifetime should be set to 1
204
228
  ```
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "Simple-Track"
7
- version = "2.0.7"
7
+ version = "2.2.0"
8
8
  authors = [
9
9
  { name="Adam Gainford", email="adam.gainford@reading.ac.uk" },
10
10
  { name="Thorwald Stein", email="t.h.m.stein@reading.ac.uk"}