Reference
Here you will find the reference for all available functions in wiutils. Each function has its signature, a short explanation of its purpose and a description of both its arguments and return values.
Note
You will see that functions are divided into submodules (e.g. reading or filtering). For convenience, you can execute all the functions without accessing their submodules. For example, instead of executing wiutils.filtering.remove_duplicates() you can just execute wiutils.remove_duplicates.
wiutils.darwincore
Functions to create different core and extension tables following the Darwin Core (DwC) standard from a Wildlife Insights data.
create_dwc_archive(cameras, deployments, images, projects, remove_duplicate_kws=None)
Creates a Darwin Core Archive consisting of four different cores and extensions: Event, Occurrence, Measurement or Facts and Simple Multimedia.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cameras |
DataFrame
|
Dataframe with the bundle's cameras. |
required |
deployments |
DataFrame
|
Dataframe with the bundle's deployments. |
required |
images |
DataFrame
|
Dataframe with the bundle's cameras. |
required |
projects |
DataFrame
|
Dataframe with the bundle's projects. |
required |
remove_duplicate_kws |
dict
|
Keyword arguments passed to the wiutils.remove_duplicate function. Used for the creation of the Occurrence Core. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Darwin Core Event dataframe. |
DataFrame
|
Darwin Core Occurrence dataframe. |
DataFrame
|
Darwin Core Measurement or Facts dataframe. |
DataFrame
|
Darwin Core Simple Multimedia dataframe. |
Source code in wiutils/darwincore.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
create_dwc_event(deployments, projects)
Creates a Darwin Core Event dataframe from deployments and projects information. See https://rs.gbif.org/core/dwc_event_2022-02-02.xml for more information about this core.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployments |
DataFrame
|
Dataframe with the bundle's deployments. |
required |
projects |
DataFrame
|
Dataframe with the bundle's projects. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Darwin Core Event dataframe. |
Source code in wiutils/darwincore.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
create_dwc_measurement(deployments, cameras)
Creates a Darwin Core Measurement or Facts dataframe from cameras and deployments information. See https://rs.gbif.org/extension/dwc/measurements_or_facts_2022-02-02.xml for more information about this extension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployments |
DataFrame
|
Dataframe with the bundle's deployments. |
required |
cameras |
DataFrame
|
Dataframe with the bundle's cameras. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Darwin Core Measurement or Facts dataframe. |
Source code in wiutils/darwincore.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
create_dwc_multimedia(images, deployments)
Creates a Darwin Core Simple Multimedia dataframe from images and deployments information. See https://rs.gbif.org/extension/gbif/1.0/multimedia.xml for more information about this extension. The result includes information from all the bundle's images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images |
DataFrame
|
Dataframe with the bundle's images. |
required |
deployments |
DataFrame
|
Dataframe with the bundle's deployments. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Darwin Core Simple Multimedia dataframe. |
Source code in wiutils/darwincore.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
create_dwc_occurrence(images, deployments, projects, remove_duplicate_kws=None)
Creates a Darwin Core Occurrence dataframe from images, deployments and projects information. See https://rs.gbif.org/core/dwc_occurrence_2022-02-02.xml for more information about this core. The result includes only wildlife records (i.e. unidentified and duplicate images are removed).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images |
DataFrame
|
Dataframe with the bundle's images. |
required |
deployments |
DataFrame
|
Dataframe with the bundle's deployments. |
required |
projects |
DataFrame
|
Dataframe with the bundle's projects. |
required |
remove_duplicate_kws |
dict
|
Keyword arguments passed to the wiutils.remove_duplicate function. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Darwin Core Occurrence dataframe. |
Source code in wiutils/darwincore.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
wiutils.extraction
Functions for extracting information from WI tables.
get_date_ranges(images=None, deployments=None, source='both', compute_delta=False, pivot=False)
Gets deployment date ranges using information from either images, deployments or both.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images |
DataFrame
|
DataFrame with the project's images. |
None
|
deployments |
DataFrame
|
DataFrame with the project's deployments. |
None
|
source |
bool
|
Source to plot date ranges from: Values can be:
|
'both'
|
compute_delta |
bool
|
Whether to compute the delta (in days) between the start and end dates. |
False
|
pivot |
bool
|
Whether to pivot (reshape from long to wide format) the resulting DataFrame. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with date ranges. |
Source code in wiutils/extraction.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
get_lowest_taxon(images, return_rank=False)
Gets the lowest identified taxa and ranks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images |
DataFrame
|
DataFrame with the project's images. |
required |
return_rank |
bool
|
Whether to return the lowest identified ranks. |
False
|
Returns:
| Type | Description |
|---|---|
Series
|
Lowest identified taxon for each image. |
Series
|
Lowest identified rank for each image. |
Source code in wiutils/extraction.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
get_scientific_name(images, keep_genus=False, add_qualifier=False)
Gets the scientific name of each image by concatenating their respective genus and specific epithet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images |
DataFrame
|
DataFrame with the project's images. |
required |
keep_genus |
bool
|
Whether to keep the genus as the scientific name in images where only the genus was identified. If False, the scientific name for those cases will be emtpy. |
False
|
add_qualifier |
bool
|
Whether to add an open nomenclature qualifier (sp.) to the scientific name of those cases where only the genus was identified. Only has effect if keep_genus is True. |
False
|
Returns:
| Type | Description |
|---|---|
Series
|
Series with the corresponding scientific names. |
Source code in wiutils/extraction.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
wiutils.filtering
Functions to filter WI images based on different conditions.
remove_domestic(images, broad=False, reset_index=False)
Removes images where the identification corresponds to a domestic species. See wiutils/_domestic.py for a list of the species considered as domestic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images |
DataFrame
|
DataFrame with the project's images. |
required |
broad |
bool
|
Whether to use a broader strategy when removing domestic species. A broader strategy takes the genera from the list of domestic species and removes the images where the genus identification is in that list. Otherwise, the scientific name for each image is extracted and the images where the scientific name is in the list of domestic species are removed. |
False
|
reset_index |
bool
|
Whether to reset the index of the resulting DataFrame. If True, the index will be numeric from 0 to the length of the result. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Copy of images with removed domestic species. |
Source code in wiutils/filtering.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
remove_duplicates(images, interval=30, unit='minutes', reset_index=False)
Removes duplicate records (images) from the same taxon in the same deployment given a time interval.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images |
DataFrame
|
DataFrame with the project's images. |
required |
interval |
int
|
Time interval (for a specific time unit). |
30
|
unit |
str
|
Time unit. Possible values are:
|
'minutes'
|
reset_index |
bool
|
Whether to reset the index of the resulting DataFrame. If True, the index will be numeric from 0 to the length of the result. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Copy of images with removed duplicates. |
Source code in wiutils/filtering.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
remove_inconsistent_dates(images, deployments, reset_index=False)
Removes images where the timestamp is outside the date range of the corresponding deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images |
DataFrame
|
DataFrame with the project's images. |
required |
deployments |
pd.DataFrame
|
DataFrame with the project's deployments. |
required |
reset_index |
bool
|
Whether to reset the index of the resulting DataFrame. If True, the index will be numeric from 0 to the length of the result. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Images DataFrame with removed inconsistent images. |
Source code in wiutils/filtering.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
remove_unidentified(images, rank='genus', reset_index=False)
Removes unidentified (up to a specific taxonomic rank) images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images |
DataFrame
|
DataFrame with the project's images. |
required |
rank |
str
|
Taxonomic rank for which images that do not have an identification will be removed. Possible values are:
For example, if rank is 'family', all images where the family (and therefore the inferior ranks - genus and epithet -) were not identified will be removed. |
'genus'
|
reset_index |
bool
|
Whether to reset the index of the resulting DataFrame. If True, the index will be numeric from 0 to the length of the result. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Images DataFrame with removed unidentified images. |
Source code in wiutils/filtering.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
wiutils.preprocessing
Functions to preprocess information before uploading it to WI.
change_image_timestamp(image_path, output_path, timestamp=None, offset=None)
Changes an image's associated timestamp metadata for a new timestamp. This can be a new arbitrary timestamp or a computed new timestamp from an offset and the original timestamp.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_path |
str or Path
|
Relative or absolute path of the image to resample. |
required |
output_path |
str or Path
|
Relative or absolute path of the output image. |
required |
timestamp |
str, datetime.datetime or pd.Timestamp
|
New timestamp to write to the image's metadata. |
None
|
offset |
DateOffset or Timedelta
|
Offset or Timedelta to add to (if positive) or subtract from (if negative) the original image's timestamp. This argument only has effect when no timestamp is specified. |
None
|
Returns:
| Type | Description |
|---|---|
None
|
Source code in wiutils/preprocessing.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
convert_video_to_images(video_path, output_path, timestamp=None, image_format='jpeg', offset=None)
Converts a video to images with an associated timestamp.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video_path |
str or Path
|
Relative or absolute path of the video to convert. |
required |
output_path |
str or Path
|
Relative or absolute path of the folder to save the images to. If the folder does not exist, it will be created. |
required |
timestamp |
str, datetime.datetime or pd.Timestamp
|
Timestamp of the beginning of the video. If no timestamp is provided, it will be automatically extracted from the metadata. |
None
|
image_format |
str
|
Image format of the output images. Possible values are:
|
'jpeg'
|
offset |
int
|
Offset (in seconds) to convert frames to images. For example, if offset is 1, the output images will correspond to 1 second-separated frames of the video. If offset is None, all the frames in the video will be converted to images. |
None
|
Returns:
| Type | Description |
|---|---|
None
|
Source code in wiutils/preprocessing.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
reduce_image_size(image_path, output_path, factor=0.9, method=1)
Reduces image file size by resampling using a given factor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_path |
str or Path
|
Relative or absolute path of the image to resample. |
required |
output_path |
str or Path
|
Relative or absolute path of the output image. |
required |
factor |
float
|
Resampling factor. |
0.9
|
method |
int
|
Image resizing method used by PIL. Possible values are:
|
1
|
Returns:
| Type | Description |
|---|---|
None
|
Source code in wiutils/preprocessing.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
wiutils.plotting
Functions to plot information from the images and deployments tables.
plot_activity_hours(images, names, kind='kde', polar=False, hist_kws=None, kde_kws=None, polar_kws=None)
Plots the activity hours of one or multiple taxa by grouping all observations into a 24-hour range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images |
DataFrame
|
DataFrame with the project's images. |
required |
names |
list, str or Series
|
List of names to plot activity hours for. |
required |
kind |
str
|
Type of plot. Values can be:
|
'kde'
|
polar |
bool
|
Whether to use a polar (i.e. circular projection) for the plot. If polar is True, kind must be one of 'area' or 'hist'. Otherwise it must be one of 'hist' or 'kde'. |
False
|
hist_kws |
dict
|
Keyword arguments passed to the seaborn.histplot() function. Only has effect if kind is 'hist' and polar is False. |
None
|
kde_kws |
dict
|
Keyword arguments passed to the seaborn.kde() function. Only has effect if kind is 'kde'. |
None
|
polar_kws |
dict
|
Keyword arguments passed to a local function when polar is True, regardless of kind. Possible arguments are:
|
None
|
Returns:
| Type | Description |
|---|---|
Axes
|
Plot axes. |
Source code in wiutils/plotting.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
plot_date_ranges(images=None, deployments=None, source='both', **kwargs)
Plots deployment date ranges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images |
DataFrame
|
DataFrame with the project's images. |
None
|
deployments |
DataFrame
|
DataFrame with the project's deployments. |
None
|
source |
bool
|
Source to plot date ranges from: Values can be:
|
'both'
|
kwargs Keyword arguments passed to the sns.relplot() function.
Returns:
| Type | Description |
|---|---|
Axes
|
Plot axes. |
Source code in wiutils/plotting.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
plot_detection_history(images, deployments, name, mask=False, compute_detection_history_kws=None, heatmap_kws=None)
Plots detection history matrix for a given species.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images |
DataFrame
|
DataFrame with the project's images. |
required |
deployments |
DataFrame
|
DataFrame with the project's deployments. |
required |
name |
str
|
Scientific name of the species to plot the detection history for. |
required |
mask |
bool
|
Whether to mask cells where cameras were not functioning. If True, those cells won't be displayed. Otherwise, they will be displayed as zero. |
False
|
compute_detection_history_kws |
dict
|
Keyword arguments for the wiutils.compute_detection_history() function. |
None
|
heatmap_kws |
dict
|
Keyword arguments for the seaborn.heatmap() function. |
None
|
Returns:
| Type | Description |
|---|---|
Axes
|
Plot axes. |
Source code in wiutils/plotting.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | |
wiutils.reading
Functions to read information from WI projects.
load_demo(name)
Loads the cameras, deployments, images and projects tables from a demo dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Demo dataset name. Can be one of:
|
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Demo cameras dataframe |
DataFrame
|
Demo deployments dataframe |
DataFrame
|
Demo images dataframe |
DataFrame
|
Demo projects dataframe |
Source code in wiutils/reading.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
read_bundle(path)
Reads the cameras, deployments, images and projects tables from a specific Wildlife Insights project bundle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path |
str or Path
|
Absolute or relative path of the project bundle. Can be a folder with all the respective csv files inside or a zip file. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Bundle cameras dataframe |
DataFrame
|
Bundle deployments dataframe |
DataFrame
|
Bundle images dataframe |
DataFrame
|
Bundle projects dataframe |
Source code in wiutils/reading.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
read_cameras(path, **kwargs)
Reads the cameras' table from a specific Wildlife Insights project bundle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path |
str or Path
|
Absolute or relative path of the project bundle. Can be a folder with all the respective csv files inside or a zip file. |
required |
kwargs |
Keyword arguments passed to the pd.read_csv function. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Bundle cameras dataframe |
Source code in wiutils/reading.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
read_deployments(path, **kwargs)
Reads the deployments' table from a specific Wildlife Insights project bundle. Start and end column values are automatically parsed as dates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path |
str or Path
|
Absolute or relative path of the project bundle. Can be a folder with all the respective csv files inside or a zip file. |
required |
kwargs |
Keyword arguments passed to the pd.read_csv function. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Bundle deployments dataframe |
Source code in wiutils/reading.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
read_images(path, **kwargs)
Reads the images' table from a specific Wildlife Insights project bundle. Timestamp column values are automatically parsed as dates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path |
str or Path
|
Absolute or relative path of the project bundle. Can be a folder with all the respective csv files inside or a zip file. |
required |
kwargs |
Keyword arguments passed to the pd.read_csv function. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Bundle images dataframe |
Source code in wiutils/reading.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
read_projects(path, **kwargs)
Reads projects table from a specific Wildlife Insights project bundle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path |
str or Path
|
Absolute or relative path of the project bundle. Can be a folder with all the respective csv files inside or a zip file. |
required |
kwargs |
Keyword arguments passed to the pd.read_csv function. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Bundle projects dataframe |
Source code in wiutils/reading.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
wiutils.summarizing
Functions to create new tables or modify existing ones from WI data.
compute_count_summary(images, deployments=None, groupby='deployment', add_records_by_class=False, add_taxa_by_class=False, remove_unidentified_kws=None, remove_duplicates_kws=None)
Computes a summary of images, records and taxa count by deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images |
DataFrame
|
DataFrame with the project's images. |
required |
deployments |
DataFrame
|
DataFrame with the project's deployments. Must be passed only if groupby is 'location'. |
None
|
groupby |
str
|
Level to group results by. Can be one of:
|
'deployment'
|
add_records_by_class |
bool
|
Whether to add number of independent records (i.e. number of individuals after duplicate image removal). |
False
|
add_taxa_by_class |
bool
|
Whether to add number of unique taxa. |
False
|
remove_unidentified_kws |
dict
|
Keyword arguments for the wiutils.remove_unidentified function. |
None
|
remove_duplicates_kws |
dict
|
Keyword arguments for the wiutils.remove_duplicates function. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Summary of images, records and species count by deployment. |
Source code in wiutils/summarizing.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
compute_detection(images, deployments=None, groupby='deployment', compute_abundance=True, pivot=False)
Computes the detection (in terms of abundance or presence) of each taxon by deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images |
DataFrame
|
DataFrame with the project's images. |
required |
deployments |
DataFrame
|
DataFrame with the project's deployments. Must be passed only if groupby is 'location'. |
None
|
groupby |
str
|
Level to group results by. Can be one of:
|
'deployment'
|
compute_abundance |
bool
|
Whether to compute the abundance for each deployment. If False, returns presence/absence for the deployments. |
True
|
pivot |
bool
|
Whether to pivot (reshape from long to wide format) the resulting DataFrame. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with the detection of each species by deployment. |
Source code in wiutils/summarizing.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
compute_detection_history(images, deployments, date_range='deployments', days=1, compute_abundance=True, pivot=False)
Computes the detection history (in terms of abundance or presence) by taxon and deployment, grouping observations into specific days-long intervals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images |
DataFrame
|
DataFrame with the project's images. |
required |
deployments |
DataFrame
|
DataFrame with the project's deployments. |
required |
date_range |
str
|
Table to compute the date range from. Possible values are:
|
'deployments'
|
days |
int
|
Days interval to group observations into. |
1
|
compute_abundance |
bool
|
Whether to compute the abundance for each interval. If False, returns presence/absence for the intervals. |
True
|
pivot |
bool
|
Whether to pivot (reshape from long to wide format) the resulting DataFrame. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Detection history. |
Source code in wiutils/summarizing.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
compute_general_count(images, deployments=None, groupby='deployment', add_taxonomy=False, rank='class')
Computes the general abundance and number of deployments for each taxon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images |
DataFrame
|
DataFrame with the project's images. |
required |
deployments |
DataFrame
|
DataFrame with the project's deployments. Must be passed only if groupby is 'location'. |
None
|
groupby |
str
|
Level to group results by. Can be one of:
|
'deployment'
|
add_taxonomy |
bool
|
Whether to add the superior taxonomy of the species to the result. |
False
|
rank |
str
|
Upper taxonomic rank to extract classification for. Possible values are:
|
'class'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with abundance and number of deployments by species. |
Source code in wiutils/summarizing.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | |
compute_hill_numbers(images, deployments=None, groupby='deployment', q_values=(0, 1, 2), pivot=False)
Computes the Hill numbers of order q (also called effective number of species) by site for some given values of q.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images |
DataFrame
|
DataFrame with the project's images. |
required |
deployments |
DataFrame
|
DataFrame with the project's deployments. Must be passed only if groupby is 'location'. |
None
|
groupby |
str
|
Level to group results by. Can be one of:
|
'deployment'
|
q_values |
int, list, tuple or array
|
Value(s) of q to compute Hill numbers for. |
(0, 1, 2)
|
pivot |
bool
|
Whether to pivot (reshape from long to wide format) the resulting DataFrame. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Computed Hill numbers by deployment. |
Source code in wiutils/summarizing.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | |