Simple-Track 2.0.7__tar.gz → 2.1.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.1.0}/PKG-INFO +79 -53
  2. {simple_track-2.0.7 → simple_track-2.1.0}/README.md +78 -52
  3. {simple_track-2.0.7 → simple_track-2.1.0}/pyproject.toml +1 -1
  4. {simple_track-2.0.7 → simple_track-2.1.0}/src/Simple_Track.egg-info/PKG-INFO +79 -53
  5. {simple_track-2.0.7 → simple_track-2.1.0}/src/Simple_Track.egg-info/SOURCES.txt +2 -0
  6. simple_track-2.1.0/src/run_simple_track.py +61 -0
  7. {simple_track-2.0.7 → simple_track-2.1.0}/src/simpletrack/feature.py +121 -3
  8. {simple_track-2.0.7 → simple_track-2.1.0}/src/simpletrack/frame.py +1 -1
  9. {simple_track-2.0.7 → simple_track-2.1.0}/src/simpletrack/frame_tracker.py +6 -0
  10. {simple_track-2.0.7 → simple_track-2.1.0}/src/simpletrack/load.py +100 -74
  11. {simple_track-2.0.7 → simple_track-2.1.0}/src/simpletrack/track.py +72 -51
  12. simple_track-2.1.0/tests/test_cli.py +245 -0
  13. {simple_track-2.0.7 → simple_track-2.1.0}/tests/test_feature.py +129 -0
  14. {simple_track-2.0.7 → simple_track-2.1.0}/tests/test_frame_tracker.py +13 -11
  15. simple_track-2.1.0/tests/test_load.py +100 -0
  16. simple_track-2.1.0/tests/test_mwe_output.py +355 -0
  17. {simple_track-2.0.7 → simple_track-2.1.0}/tests/test_simple_track_and_load.py +3 -34
  18. simple_track-2.0.7/src/run_simple_track.py +0 -22
  19. simple_track-2.0.7/tests/test_mwe_output.py +0 -118
  20. {simple_track-2.0.7 → simple_track-2.1.0}/LICENSE +0 -0
  21. {simple_track-2.0.7 → simple_track-2.1.0}/setup.cfg +0 -0
  22. {simple_track-2.0.7 → simple_track-2.1.0}/src/Simple_Track.egg-info/dependency_links.txt +0 -0
  23. {simple_track-2.0.7 → simple_track-2.1.0}/src/Simple_Track.egg-info/entry_points.txt +0 -0
  24. {simple_track-2.0.7 → simple_track-2.1.0}/src/Simple_Track.egg-info/requires.txt +0 -0
  25. {simple_track-2.0.7 → simple_track-2.1.0}/src/Simple_Track.egg-info/top_level.txt +0 -0
  26. {simple_track-2.0.7 → simple_track-2.1.0}/src/simpletrack/__init__.py +0 -0
  27. {simple_track-2.0.7 → simple_track-2.1.0}/src/simpletrack/exceptions.py +0 -0
  28. {simple_track-2.0.7 → simple_track-2.1.0}/src/simpletrack/flow_solver.py +0 -0
  29. {simple_track-2.0.7 → simple_track-2.1.0}/src/simpletrack/frame_output.py +0 -0
  30. {simple_track-2.0.7 → simple_track-2.1.0}/src/simpletrack/utils.py +0 -0
  31. {simple_track-2.0.7 → simple_track-2.1.0}/tests/test_flow_solver.py +0 -0
  32. {simple_track-2.0.7 → simple_track-2.1.0}/tests/test_frame.py +0 -0
  33. {simple_track-2.0.7 → simple_track-2.1.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.1.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,17 +45,19 @@ 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
 
51
53
  * The input data must be gridded and contain a consistent spatial domain and resolution between frames.
52
54
 
55
+ * The input grid must be evenly shaped (this will be relaxed in the future)
56
+
53
57
  * The features of interest must be defined by a threshold value, and these features must translate as a result of a spatially consistent background flow.
54
58
 
55
59
  * 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
60
 
57
- * It is currently a requirement that the timestep between frames is fixed, although future updates may relax this requirement.
58
-
59
61
  ## Running Simple-Track
60
62
 
61
63
  Simple-Track can be run in two ways:
@@ -67,37 +69,35 @@ Simple-Track can be run in two ways:
67
69
  simpletrack my_config.yaml
68
70
  ```
69
71
 
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:
72
+ * The `my_config.yaml` file contains the parameters for running Simple-Track. The required parameters are shown below:
71
73
 
72
74
  ```yaml
73
75
  INPUT:
74
- path: /path_to_folder_containing_data
75
- loader: LoaderName # See next section
76
+ path: /path_to_folder_containing_data/*.data
77
+ loader: /path_to_file_containing_function|function_name # See next section
76
78
  FEATURE:
77
79
  threshold: 1 # Threshold used for defining a feature
78
- under_threshold: false # Whether features are defined above or below the threshold
79
80
  ```
80
81
 
81
82
  * 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
83
 
83
- * A valid `Loader` object is required for pre-processing input data before tracking. See [Loading Data](#loading-data) for more information.
84
+ * A valid loader function is required for pre-processing input data before tracking. See [Loading Data](#loading-data) for more information.
84
85
 
85
86
  * Any number of config files can be provided as additional arguments, Simple-Track will iterate over each one in turn.
86
87
 
87
88
  ### 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:
89
+ * 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
90
 
90
91
  ```python
91
92
  from simpletrack import Tracker
92
93
 
93
94
  my_config = {
94
95
  INPUT: {
95
- path: "/path_to_folder_containing_data",
96
- loader: "LoaderName" # See next section
96
+ path: "/path_to_folder_containing_data/*.data",
97
+ loader: "/path_to_file_containing_function|function_name" # See next section
97
98
  },
98
99
  FEATURE: {
99
100
  threshold: 1, # Threshold used for defining a feature
100
- under_threshold: False # Whether features are defined above or below the threshold
101
101
  }
102
102
  }
103
103
 
@@ -108,64 +108,89 @@ Simple-Track can be run in two ways:
108
108
  ```
109
109
  * 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
110
 
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.
111
+ * 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
112
 
113
113
  * `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
114
 
115
115
  ## Loading Data
116
116
 
117
- For Simple-Track to operate effectively, each input must consist of two sets of data:
117
+ Each Simple-Track input must contain two sets of data:
118
118
 
119
119
  1. A `datetime` object specifying the time that the data is valid for
120
120
  2. A `numpy.array` object containing the data to track
121
121
 
122
- There are two methods of providing these data pairs to Simple-Track:
122
+ There are three methods of providing these data pairs to Simple-Track:
123
+
124
+ ### 1. Loading through config options
125
+ * 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).
126
+
127
+ * Each file contains one input to Simple-Track ([see here](docs/inputs.md#extra-loading-parameters) for more information)
123
128
 
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.
129
+ * 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.
126
130
 
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:
131
+ * An example of a custom loader function is shown below:
129
132
 
130
133
  ```python
131
- class ChilboltonLoader(BaseLoader):
132
- def __init__(self):
133
- super().__init__()
134
+ def user_definable_load(self, filename):
135
+ import iris # Import any required libraries here
134
136
 
135
- def user_definable_load(self, filename):
136
- import iris # Import any required libraries here
137
+ # Get 2D data from input file as a numpy array
138
+ cube = iris.load_cube(filename, "precipitation_flux")
139
+ data = cube.data
140
+
141
+ # Additional data pre-processing can be performed here too!
142
+
143
+ # Get time from input file, in datetime format
144
+ tcoord = cube.coord("time")
145
+ time = tcoord.units.num2pydate(tcoord.points)[0]
146
+
147
+ # Method must return a tuple of
148
+ # (datetime.datetime, numpy.NDArray), where the
149
+ # first element is the time the data is valid for
150
+ # and second element is the 2D array of data to be tracked
151
+ return time, data
152
+ ```
137
153
 
138
- # Get 2D data from input file as a numpy array
139
- cube = iris.load_cube(filename, "precipitation_flux")
140
- data = cube.data
154
+ * 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`.
141
155
 
142
- # Additional data pre-processing can be performed here too!
156
+ * 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).
143
157
 
144
- # Get time from input file, in datetime format
145
- tcoord = cube.coord("time")
146
- time = tcoord.units.num2pydate(tcoord.points)[0]
158
+ ### 2. Loading through the Command Line
159
+ * The same `"INPUT"` config sections mentioned above can also be input [from the command line](#1-running-simple-track-from-the-command-line)
147
160
 
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
153
161
  ```
162
+ simpletrack my_config.yaml -i /path_to_folder/*.data -l ./path_to_file.py|func_name
163
+ ```
164
+
165
+ * Each file contains one input to Simple-Track ([see here](docs/inputs.md#extra-loading-parameters) for more information)
166
+
167
+ ### 3. Passing a dict directly to Tracker.run()
168
+ * 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:
154
169
 
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.
170
+ ```python
171
+ import datetime as dt
172
+ import numpy as np
173
+ from simpletrack import Tracker
156
174
 
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).
175
+ time1 = dt.datetime(year=2000, month=1, day=1, hour=10, minute=5)
176
+ time2 = time1 + dt.timedelta(minutes=5)
158
177
 
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()`
178
+ data1 = np.array(...)
179
+ data2 = np.array(...)
162
180
 
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
181
+ st_input = {
182
+ time1: data1,
183
+ time2: data2,
184
+ }
185
+
186
+ my_config = {...}
187
+
188
+ Tracker(my_config).run(st_input)
189
+ ```
165
190
 
166
191
  * Any number of time:data pairs can be passed to `Tracker.run()` and the code will iterate over the ordered dict.
167
192
 
168
- * Passing data into `Tracker.run()` via this method will bypass any `Loader` or `[INPUT][path]` inputs specified in the corresponding config file.
193
+ * Passing data into `Tracker.run()` via this method will bypass any `"INPUT":"loader"` or `"INPUT":"path"` inputs specified in the corresponding config file.
169
194
 
170
195
 
171
196
  # Outputs
@@ -193,13 +218,14 @@ It it also possible to perform further analysis of tracking statistics using the
193
218
  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
219
 
195
220
  # All Simple-Track Parameters
196
- A complete list of parameters and their default values are given below:
221
+ 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
222
 
198
223
  ```yaml
199
224
  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
225
+ path: ./path_to_input_data/*.data
226
+ loader: /path_to_file_containing_function|function_name
227
+ iterate_over_array: False # Whether to iterate a single array or multiple files
228
+ iterating_dim: 0 # If iterate_over_array flag is enabled, this sets the dimension to iterate over
203
229
 
204
230
  OUTPUT:
205
231
  path: ./output
@@ -213,7 +239,7 @@ FEATURE:
213
239
  min_size: 4 # Minimum size of feature to be tracked (in pixels)
214
240
 
215
241
  FLOW_SOLVER:
216
- overlap_threshold: 0.6 # Minimum fraction of overlap between features for use in flow_solver
242
+ overlap_threshold: 0.3 # Minimum fraction of overlap between features for use in flow_solver
217
243
  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
244
  min_fractional_coverage: 0.01 # Minimum fractional cover of objects required for fft to obtain (dy, dx) displacement
219
245
  subdomain_tolerance: 3.0 # Maximum difference in displacement values between adjacent squares (to remove spurious values)
@@ -221,6 +247,6 @@ FLOW_SOLVER:
221
247
 
222
248
  TRACKING:
223
249
  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
250
+ overlap_threshold: 0.3 # Minimum fraction of overlap
225
251
  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
252
  ```
@@ -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,17 +23,19 @@ 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
 
29
31
  * The input data must be gridded and contain a consistent spatial domain and resolution between frames.
30
32
 
33
+ * The input grid must be evenly shaped (this will be relaxed in the future)
34
+
31
35
  * The features of interest must be defined by a threshold value, and these features must translate as a result of a spatially consistent background flow.
32
36
 
33
37
  * 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
38
 
35
- * It is currently a requirement that the timestep between frames is fixed, although future updates may relax this requirement.
36
-
37
39
  ## Running Simple-Track
38
40
 
39
41
  Simple-Track can be run in two ways:
@@ -45,37 +47,35 @@ Simple-Track can be run in two ways:
45
47
  simpletrack my_config.yaml
46
48
  ```
47
49
 
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:
50
+ * The `my_config.yaml` file contains the parameters for running Simple-Track. The required parameters are shown below:
49
51
 
50
52
  ```yaml
51
53
  INPUT:
52
- path: /path_to_folder_containing_data
53
- loader: LoaderName # See next section
54
+ path: /path_to_folder_containing_data/*.data
55
+ loader: /path_to_file_containing_function|function_name # See next section
54
56
  FEATURE:
55
57
  threshold: 1 # Threshold used for defining a feature
56
- under_threshold: false # Whether features are defined above or below the threshold
57
58
  ```
58
59
 
59
60
  * 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
61
 
61
- * A valid `Loader` object is required for pre-processing input data before tracking. See [Loading Data](#loading-data) for more information.
62
+ * A valid loader function is required for pre-processing input data before tracking. See [Loading Data](#loading-data) for more information.
62
63
 
63
64
  * Any number of config files can be provided as additional arguments, Simple-Track will iterate over each one in turn.
64
65
 
65
66
  ### 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:
67
+ * 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
68
 
68
69
  ```python
69
70
  from simpletrack import Tracker
70
71
 
71
72
  my_config = {
72
73
  INPUT: {
73
- path: "/path_to_folder_containing_data",
74
- 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
75
76
  },
76
77
  FEATURE: {
77
78
  threshold: 1, # Threshold used for defining a feature
78
- under_threshold: False # Whether features are defined above or below the threshold
79
79
  }
80
80
  }
81
81
 
@@ -86,64 +86,89 @@ Simple-Track can be run in two ways:
86
86
  ```
87
87
  * 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
88
 
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.
89
+ * 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
90
 
91
91
  * `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
92
 
93
93
  ## Loading Data
94
94
 
95
- For Simple-Track to operate effectively, each input must consist of two sets of data:
95
+ Each Simple-Track input must contain two sets of data:
96
96
 
97
97
  1. A `datetime` object specifying the time that the data is valid for
98
98
  2. A `numpy.array` object containing the data to track
99
99
 
100
- There are two methods of providing these data pairs to Simple-Track:
100
+ There are three methods of providing these data pairs to Simple-Track:
101
+
102
+ ### 1. Loading through config options
103
+ * 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).
104
+
105
+ * Each file contains one input to Simple-Track ([see here](docs/inputs.md#extra-loading-parameters) for more information)
101
106
 
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.
107
+ * 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.
104
108
 
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:
109
+ * An example of a custom loader function is shown below:
107
110
 
108
111
  ```python
109
- class ChilboltonLoader(BaseLoader):
110
- def __init__(self):
111
- super().__init__()
112
+ def user_definable_load(self, filename):
113
+ import iris # Import any required libraries here
112
114
 
113
- def user_definable_load(self, filename):
114
- import iris # Import any required libraries here
115
+ # Get 2D data from input file as a numpy array
116
+ cube = iris.load_cube(filename, "precipitation_flux")
117
+ data = cube.data
118
+
119
+ # Additional data pre-processing can be performed here too!
120
+
121
+ # Get time from input file, in datetime format
122
+ tcoord = cube.coord("time")
123
+ time = tcoord.units.num2pydate(tcoord.points)[0]
124
+
125
+ # Method must return a tuple of
126
+ # (datetime.datetime, numpy.NDArray), where the
127
+ # first element is the time the data is valid for
128
+ # and second element is the 2D array of data to be tracked
129
+ return time, data
130
+ ```
115
131
 
116
- # Get 2D data from input file as a numpy array
117
- cube = iris.load_cube(filename, "precipitation_flux")
118
- data = cube.data
132
+ * 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`.
119
133
 
120
- # Additional data pre-processing can be performed here too!
134
+ * 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).
121
135
 
122
- # Get time from input file, in datetime format
123
- tcoord = cube.coord("time")
124
- time = tcoord.units.num2pydate(tcoord.points)[0]
136
+ ### 2. Loading through the Command Line
137
+ * The same `"INPUT"` config sections mentioned above can also be input [from the command line](#1-running-simple-track-from-the-command-line)
125
138
 
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
131
139
  ```
140
+ simpletrack my_config.yaml -i /path_to_folder/*.data -l ./path_to_file.py|func_name
141
+ ```
142
+
143
+ * Each file contains one input to Simple-Track ([see here](docs/inputs.md#extra-loading-parameters) for more information)
144
+
145
+ ### 3. Passing a dict directly to Tracker.run()
146
+ * 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:
132
147
 
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.
148
+ ```python
149
+ import datetime as dt
150
+ import numpy as np
151
+ from simpletrack import Tracker
134
152
 
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).
153
+ time1 = dt.datetime(year=2000, month=1, day=1, hour=10, minute=5)
154
+ time2 = time1 + dt.timedelta(minutes=5)
136
155
 
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()`
156
+ data1 = np.array(...)
157
+ data2 = np.array(...)
140
158
 
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
159
+ st_input = {
160
+ time1: data1,
161
+ time2: data2,
162
+ }
163
+
164
+ my_config = {...}
165
+
166
+ Tracker(my_config).run(st_input)
167
+ ```
143
168
 
144
169
  * Any number of time:data pairs can be passed to `Tracker.run()` and the code will iterate over the ordered dict.
145
170
 
146
- * Passing data into `Tracker.run()` via this method will bypass any `Loader` or `[INPUT][path]` inputs specified in the corresponding config file.
171
+ * Passing data into `Tracker.run()` via this method will bypass any `"INPUT":"loader"` or `"INPUT":"path"` inputs specified in the corresponding config file.
147
172
 
148
173
 
149
174
  # Outputs
@@ -171,13 +196,14 @@ It it also possible to perform further analysis of tracking statistics using the
171
196
  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
197
 
173
198
  # All Simple-Track Parameters
174
- A complete list of parameters and their default values are given below:
199
+ 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
200
 
176
201
  ```yaml
177
202
  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
203
+ path: ./path_to_input_data/*.data
204
+ loader: /path_to_file_containing_function|function_name
205
+ iterate_over_array: False # Whether to iterate a single array or multiple files
206
+ iterating_dim: 0 # If iterate_over_array flag is enabled, this sets the dimension to iterate over
181
207
 
182
208
  OUTPUT:
183
209
  path: ./output
@@ -191,7 +217,7 @@ FEATURE:
191
217
  min_size: 4 # Minimum size of feature to be tracked (in pixels)
192
218
 
193
219
  FLOW_SOLVER:
194
- overlap_threshold: 0.6 # Minimum fraction of overlap between features for use in flow_solver
220
+ overlap_threshold: 0.3 # Minimum fraction of overlap between features for use in flow_solver
195
221
  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
222
  min_fractional_coverage: 0.01 # Minimum fractional cover of objects required for fft to obtain (dy, dx) displacement
197
223
  subdomain_tolerance: 3.0 # Maximum difference in displacement values between adjacent squares (to remove spurious values)
@@ -199,6 +225,6 @@ FLOW_SOLVER:
199
225
 
200
226
  TRACKING:
201
227
  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
228
+ overlap_threshold: 0.3 # Minimum fraction of overlap
203
229
  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
230
  ```
@@ -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.1.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"}