| Title: | Migration Traffic Rate Calculation Package for 'Birdscan MR1' Radars |
|---|---|
| Description: | Extract data from 'Birdscan MR1' 'SQL' vertical-looking radar databases, filter, and process them to Migration Traffic Rates (# objects per hour and km) or density (# objects per km3) of, for example birds, and insects. Object classifications in the 'Birdscan MR1' databases are based on the dataset of Haest et al. (2021) <doi:10.5281/zenodo.5734960>). Migration Traffic Rates and densities can be calculated separately for different height bins (with a height resolution of choice) as well as over time periods of choice (e.g., 1/2 hour, 1 hour, 1 day, day/night, the full time period of observation, and anything in between). Two plotting functions are also included to explore the data in the 'SQL' databases and the resulting Migration Traffic Rate results. For details on the Migration Traffic Rate calculation procedures, see Schmid et al. (2019) <doi:10.1111/ecog.04025>. |
| Authors: | Birgen Haest [aut, cre] (ORCID: <https://orcid.org/0000-0002-8739-6460>), Fabian Hertner [aut], Baptiste Schmid [ctb] (ORCID: <https://orcid.org/0000-0002-7736-7527>), Peter Desmet [ctb] (ORCID: <https://orcid.org/0000-0002-8442-8025>), Bart Kranstauber [ctb] (ORCID: <https://orcid.org/0000-0001-8303-780X>), Damiano Preatoni [ctb] (ORCID: <https://orcid.org/0000-0001-8760-1316>), Johannes De Groeve [ctb] (ORCID: <https://orcid.org/0000-0002-1274-3237>), Felix Liechti [ctb] (ORCID: <https://orcid.org/0000-0001-9473-0837>), Swiss Ornithological Institute [cph] (ROR: <https://ror.org/03mcsbr76>), Swiss Birdradar Solution AG [cph] (https://swiss-birdradar.com) |
| Maintainer: | Birgen Haest <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.3.0.9038 |
| Built: | 2026-12-02 14:32:31 UTC |
| Source: | https://github.com/birdscancommunity/birdscanr |
addDayNightInfoPerEcho() adds three columns
‘dayOrNight’, ”dayOrCrepOrNight' and ‘dateSunset’ to the echo data. This
allows the user to filter echo data easily by “day” and “night”, or "day",
"crepuscular", and "night".
addDayNightInfoPerEcho( echoData, sunriseSunset, sunOrCivil = "civil", crepuscule = "nauticalSolar" )addDayNightInfoPerEcho( echoData, sunriseSunset, sunOrCivil = "civil", crepuscule = "nauticalSolar" )
echoData |
dataframe with the echo data from the data list created with
|
sunriseSunset |
dataframe with sunrise/sunset and civil twilight times
created with |
sunOrCivil |
optional character variable, Set to “sun” to use sunrise/sunset times or to “civil” to use civil twilight times to group echoes into day/night. Default is "civil". |
crepuscule |
optional character variable, Set to “nauticalSolar” to use the time between nautical dusk/dawn and sunrise/sunset times to define the crepuscular period, or to "nauticalCivil" to use the time between nautical and civil dusk/dawn to define the crepuscular period, or to "civilSolar" to use the time between civil dusk/dawn and sunrise/sunset times to define the crepuscular period. Default is "nauticalSolar". |
data frame with thre columns added, i.e. 'dayOrNight', 'dayOrCrepOrNight', and 'dateSunset'.
Fabian Hertner, Birgen Haest
Other manipulation functions:
computeDensity(),
computeMTR(),
convertTimeZone(),
createVPTS(),
filterSpeedFeature37(),
mergeVisibilityAndManualBlindTimes(),
reclassToBats(),
twilight()
# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) # Add day/night info to echo data # =========================================================================== echoData = addDayNightInfoPerEcho( echoData = dbData$echoData, sunriseSunset = dbData$sunriseSunset, sunOrCivil = "civil" )# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) # Add day/night info to echo data # =========================================================================== echoData = addDayNightInfoPerEcho( echoData = dbData$echoData, sunriseSunset = dbData$sunriseSunset, sunOrCivil = "civil" )
addZenodoRelatedIdentifiers() adds related identifiers to the
metadata of a Zenodo record, e.g. an IsPartOf link from a campaign data
package to the owner collection it belongs to, or a HasPart link from a
collection to a campaign. Related identifiers that the record already has are
not added twice; existing ones are kept.
Only the metadata are changed: the files, the DOI and the version of the record stay the same, so no new version is needed. The latest version of the record is updated, whichever version's DOI (or the concept DOI) is given.
For a published record, the function opens an edit of the record and
updates its metadata. With publish = FALSE (default), the edit stays
open: check it on Zenodo and publish it there (or discard it). With
publish = TRUE, the edit is published directly. If the record already
has the related identifiers in an open edit (e.g. added earlier with
publish = FALSE), publish = TRUE publishes that edit.
For an unpublished draft, the metadata of the draft are updated. The
draft is never published, also not with publish = TRUE.
addZenodoRelatedIdentifiers( doi, relatedIdentifiers, token = NULL, sandbox = FALSE, publish = FALSE )addZenodoRelatedIdentifiers( doi, relatedIdentifiers, token = NULL, sandbox = FALSE, publish = FALSE )
doi |
DOI (e.g. |
relatedIdentifiers |
related identifiers to add: a list of lists, each
with |
token |
Zenodo personal access token with the scopes |
sandbox |
logical. If |
publish |
logical. If |
A list, invisibly, with id (Zenodo record ID), url (link to the
record on Zenodo), added (number of related identifiers added) and
published (logical, whether the edit was published).
Birgen Haest
Other write file functions:
checkDataPackageMetadata(),
compileData(),
createCollectionMetadataTemplate(),
createDataPackage(),
createDataPackageMetadataTemplate(),
editDataPackageMetadata(),
linkCollectionMembers(),
saveMTR(),
savePlotToFile(),
uploadCollectionToZenodo(),
uploadDataPackageToZenodo(),
validateDataPackage()
## Not run: # Link a campaign data package to its owner collection (Zenodo sandbox) # =========================================================================== addZenodoRelatedIdentifiers( doi = "https://doi.org/10.5281/zenodo.1234567", relatedIdentifiers = list(list( relationType = "IsPartOf", relatedIdentifier = "https://doi.org/10.5281/zenodo.7654321" )), sandbox = TRUE ) ## End(Not run)## Not run: # Link a campaign data package to its owner collection (Zenodo sandbox) # =========================================================================== addZenodoRelatedIdentifiers( doi = "https://doi.org/10.5281/zenodo.1234567", relatedIdentifiers = list(list( relationType = "IsPartOf", relatedIdentifier = "https://doi.org/10.5281/zenodo.7654321" )), sandbox = TRUE ) ## End(Not run)
A complete data extract from a Birdscan MR1 weather radar, as returned by
extractDbData(). Collected at Sempach, Switzerland (47.13°N, 8.19°E)
on September 24–25, 2024. Load with:
readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR"))
A named list as returned by extractDbData(), with components:
data.frame with one row per detected echo
data.frame with protocol/collection intervals
data.frame with radar site metadata
data.frame with automatic visibility/blind times
data.frame with raw time-bin table from the database
character vector of classification labels
character vector of bat classification labels
data.frame with RF feature metadata
data.frame with radarTimeZone and targetTimeZone
data.frame with class probabilities
data.frame with bat class probabilities
data.frame with sunrise/sunset and civil twilight times
Other sample data:
classAbbreviations,
loadManualBlindTimes(),
manualBlindTimes
dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" ))dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" ))
checkDataPackageMetadata() checks a metadata file (or list)
before it is used, and lists all problems at once: the metadata of a data
package (see createDataPackageMetadataTemplate() and createDataPackage())
or, if it has a collectionID, of a collection (see
createCollectionMetadataTemplate() and uploadCollectionToZenodo()).
These are the same checks that createDataPackage() and
uploadCollectionToZenodo() run before they start.
checkDataPackageMetadata(metadata)checkDataPackageMetadata(metadata)
metadata |
path to a YAML file, or a named list with the same structure. |
A character vector with the problems found (empty if none), invisibly. The problems are also shown as message.
Birgen Haest
Other write file functions:
addZenodoRelatedIdentifiers(),
compileData(),
createCollectionMetadataTemplate(),
createDataPackage(),
createDataPackageMetadataTemplate(),
editDataPackageMetadata(),
linkCollectionMembers(),
saveMTR(),
savePlotToFile(),
uploadCollectionToZenodo(),
uploadDataPackageToZenodo(),
validateDataPackage()
# Check the example metadata template # =========================================================================== checkDataPackageMetadata(system.file("extdata", "dataPackage", "metadataTemplate.yaml", package = "birdscanR" ))# Check the example metadata template # =========================================================================== checkDataPackageMetadata(system.file("extdata", "dataPackage", "metadataTemplate.yaml", package = "birdscanR" ))
citeDataPackages() gives the references to cite for the MR1
data packages used in a study, following the citation rule of the BirdScan
MR1 community:
up to 3 data packages: cite each data package;
more than 3 data packages: cite their owner collections (e.g. the collection of the Swiss Ornithological Institute);
more than 3 owner collections: cite the community collection of the BirdScan MR1 community.
The collections are found through the IsPartOf links of the Zenodo
records (see uploadCollectionToZenodo()). Packages that are not in an
owner collection (or owner collections not in a community collection) are
cited themselves, with a warning. Data packages are cited in the version
that was used; collections in their latest version.
The references are built from the Zenodo metadata: creators, year of publication, title, version, publisher (Zenodo) and DOI.
citeDataPackages(x, sandbox = FALSE, token = NULL)citeDataPackages(x, sandbox = FALSE, token = NULL)
x |
The data packages used: a data package or a list of data packages
(read with |
sandbox |
logical. Are the records on the Zenodo sandbox
(https://sandbox.zenodo.org)? Only used for DOIs and packages without
Zenodo information ( |
token |
Zenodo personal access token. Not needed for public records.
Default is the environment variable |
A data frame of class mr1dpCitation, with one row per reference
and the columns level ("package", "owner collection" or
"community collection"), doi, title, text (plain-text reference)
and bibtex (BibTeX entry). Printing it shows the references as text; use
utils::toBibtex() to get the BibTeX entries.
Birgen Haest
Other read file functions:
getManualVisibilityTable(),
mergeDataPackages(),
readDataPackageFromZenodo()
## Not run: # Read data packages from Zenodo and cite them # =========================================================================== dataPackages = readDataPackageFromZenodo( doi = c("10.5281/zenodo.1234567", "10.5281/zenodo.2345678"), merge = FALSE ) references = citeDataPackages(dataPackages) references # BibTeX entries for a reference manager # =========================================================================== writeLines(toBibtex(references), "references.bib") ## End(Not run)## Not run: # Read data packages from Zenodo and cite them # =========================================================================== dataPackages = readDataPackageFromZenodo( doi = c("10.5281/zenodo.1234567", "10.5281/zenodo.2345678"), merge = FALSE ) references = citeDataPackages(dataPackages) references # BibTeX entries for a reference manager # =========================================================================== writeLines(toBibtex(references), "references.bib") ## End(Not run)
Table to allow for easy abbreviations of the standard classes of the Birdscan MR1.
data(classAbbreviations)data(classAbbreviations)
An object of class data.frame.
Other sample data:
CH_Sempach_2024_SEP24_25_DataExtract,
loadManualBlindTimes(),
manualBlindTimes
data(classAbbreviations)data(classAbbreviations)
compileData() filters database-extracts and
save metadata used to compute MTR computeMTR(). It takes the output from
extractDbData() and trunks the needed dataset to the restricted settings,
e.g. time frame, pulse type.
compileData( echoData = NULL, protocolData = NULL, blindTimesData = NULL, sunriseSunsetData = NULL, radarSiteData = NULL, dbName = NULL, pulseTypeSelection = NULL, rotationSelection = NULL, timeRangeTargetTZ = NULL, targetTimeZone = "Etc/GMT0", classSelection = NULL, classProbCutOff = NULL, altitudeRange_AGL = NULL, echoValidator = FALSE, filePath = NULL, tagOutputFile = c(NULL, NULL), saveCSV = FALSE )compileData( echoData = NULL, protocolData = NULL, blindTimesData = NULL, sunriseSunsetData = NULL, radarSiteData = NULL, dbName = NULL, pulseTypeSelection = NULL, rotationSelection = NULL, timeRangeTargetTZ = NULL, targetTimeZone = "Etc/GMT0", classSelection = NULL, classProbCutOff = NULL, altitudeRange_AGL = NULL, echoValidator = FALSE, filePath = NULL, tagOutputFile = c(NULL, NULL), saveCSV = FALSE )
echoData |
dataframe with the echo data from the data list created with
|
protocolData |
dataframe with the protocol data from the data list created
with |
blindTimesData |
dataframe with the manual blind times created by
|
sunriseSunsetData |
dataframe with sunrise/sunset, and civil and
nautical dawn/dusk. Computed with |
radarSiteData |
dataframe/vector with the database site table. |
dbName |
Name of the database. Can be a useful meta data. |
pulseTypeSelection |
character vector with the pulse types which should
be included in the subset. Options: |
rotationSelection |
numeric vector to select the operation modes with and/or without antenna rotation. Options: 0, 1. (0 = no rotation, 1 = rotation). Default is NULL: no filtering applied based on rotation mode. |
timeRangeTargetTZ |
Character vector of length 2, with start and end of time range, formatted as "%Y-%m-%d %H:%M". Echoes outside the time range will be excluded. |
targetTimeZone |
"Etc/GMT0" String specifying the target time zone. Default is "Etc/GMT0". |
classSelection |
character string vector with the classes that should be included. |
classProbCutOff |
numeric cutoff value for class probabilities. Echoes with a lower class probability will be excluded. |
altitudeRange_AGL |
numeric vector of length 2 with start and end of the altitude range. Echoes outside the altitude range will be excluded. |
echoValidator |
logical, If set to FALSE - default -, no additional filters is applied; if set to TRUE, echoes labelled by the echo validator as "non-bio scatterer" will be excluded. |
filePath |
If given, the data-list is saved as RDS. |
tagOutputFile |
Vector of two elements for prefix & suffix to file name, given |
saveCSV |
if true, save tables as CSV in a folder nested in |
Returns filtered data table - echo, protocol, blindTimes, sunriseSunset,
radarSite - and necessary parameters as input for computeMTR().
Baptiste Schmid, Fabian Hertner, Birgen Haest
Other write file functions:
addZenodoRelatedIdentifiers(),
checkDataPackageMetadata(),
createCollectionMetadataTemplate(),
createDataPackage(),
createDataPackageMetadataTemplate(),
editDataPackageMetadata(),
linkCollectionMembers(),
saveMTR(),
savePlotToFile(),
uploadCollectionToZenodo(),
uploadDataPackageToZenodo(),
validateDataPackage()
This function will estimate the density (expressed as #objects / km3) based on the observations in your database. Note that this function only works properly on Birdscan MR1 database versions >= 1.7.0.4 as the variable feature37.speed is required for the density calculation.
computeDensity( dbName, echoes, classSelection, altitudeRange, altitudeBinSize, timeRange, timeBinDuration_sec, timeZone, sunriseSunset, sunOrCivil = "civil", crepuscule = "nauticalSolar", protocolData, visibilityData, manualBlindTimes = NULL, saveBlindTimes = FALSE, blindTimesOutputDir = getwd(), blindTimeAsMtrZero = NULL, propObsTimeCutoff = 0, computePerDayNight = FALSE, computePerDayCrepusculeNight = FALSE, computeAltitudeDistribution = TRUE, blindTimes = NULL, dataPackage = NULL, campaignID = NULL )computeDensity( dbName, echoes, classSelection, altitudeRange, altitudeBinSize, timeRange, timeBinDuration_sec, timeZone, sunriseSunset, sunOrCivil = "civil", crepuscule = "nauticalSolar", protocolData, visibilityData, manualBlindTimes = NULL, saveBlindTimes = FALSE, blindTimesOutputDir = getwd(), blindTimeAsMtrZero = NULL, propObsTimeCutoff = 0, computePerDayNight = FALSE, computePerDayCrepusculeNight = FALSE, computeAltitudeDistribution = TRUE, blindTimes = NULL, dataPackage = NULL, campaignID = NULL )
dbName |
Character string, containing the name of the database you are processing |
echoes |
dataframe with the echo data from the data list created with
|
classSelection |
character string vector with all classes which should be used to calculate the density. The density and number of Echoes will be calculated for each class as well as for all classes together. |
altitudeRange |
numeric vector of length 2 with the start and end of the altitude range in meter a.g.l. |
altitudeBinSize |
numeric, size of the altitude bins in meter. |
timeRange |
Character vector of length 2, with start and end of time range, formatted as "%Y-%m-%d %H:%M" |
timeBinDuration_sec |
duration of timeBins in seconds (numeric). for values <= 0 a duration of 1 hour will be set |
timeZone |
time zone in which the time bins should be created as string, e.g. "Etc/GMT0" |
sunriseSunset |
dataframe with sunrise/sunset, and civil and nautical
dawn/dusk. Computed with |
sunOrCivil |
sunrise/sunset or civil dawn/dusk used to split day and night. Supported values: "sun" or "civil". Default: "civil" |
crepuscule |
optional character variable, Set to “nauticalSolar” to use the time between nautical dusk/dawn and sunrise/sunset times to define the crepuscular period, or to "nauticalCivil" to use the time between nautical and civil dusk/dawn to define the crepuscular period, or to "civilSolar" to use the time between civil dusk/dawn and sunrise/sunset times to define the crepuscular period. Default is "nauticalSolar". |
protocolData |
dataframe with the protocol data from the data list
created by |
visibilityData |
dataframe with the visibility data from the data list
created by |
manualBlindTimes |
dataframe with the manual blind times created by the
function |
saveBlindTimes |
Logical, determines whether to save the blind times to a file. Default: False. |
blindTimesOutputDir |
Character string containing the path to save the blind times to. Default: 'your-working-directory' |
blindTimeAsMtrZero |
character string vector with the blind time types which should be treated as observation time with MTR zero. |
propObsTimeCutoff |
numeric between 0 and 1. Time bins with a proportional
observation time smaller than |
computePerDayNight |
logical, TRUE: density is computed per day and night. The time bins of each day and night will be combined and the mean density is computed for each day and night. The spread (first and third Quartile) for each day and night are also computed. The spread is dependent on the chosen time bin duration/amount of time bins; When FALSE: density is computed for each time bin. This option computes the density for each time bin defined in the time bin dataframe. The time bins that were split due to sunrise/sunset during the time bin will be combined to one bin. |
computePerDayCrepusculeNight |
logical, TRUE: density is computed per crepusculeMorning, day, crepusculeEvening, and night. The time bins of each of these diel phases will be combined and the mean density is computed for each phase. The spread (first and third Quartile) for each phase is also computed. The spread is dependent on the chosen time bin duration/amount of time bins; When FALSE: density is computed for each time bin. This option computes the density for each time bin defined in the time bin dataframe. The time bins that were split due to sunrise/sunset during the time bin will be combined to one bin. Default = FALSE. |
computeAltitudeDistribution |
logical, TRUE: compute the mean height and altitude distribution of density for the pre-defined quantiles 0.05, 0.25, 0.5, 0.75, 0.95 |
blindTimes |
optional. Data frame with blind times that were already
merged (columns |
dataPackage |
optional. An MR1 data package (see |
campaignID |
optional. With a merged |
Density (for a merged dataPackage: a named list with the
result of each campaign)
Birgen Haest, Fabian Hertner, Baptiste Schmid
Other manipulation functions:
addDayNightInfoPerEcho(),
computeMTR(),
convertTimeZone(),
createVPTS(),
filterSpeedFeature37(),
mergeVisibilityAndManualBlindTimes(),
reclassToBats(),
twilight()
# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) dbName = "CH_Sempach_2024_SEP24_25" targetTimeZone = "Etc/GMT0" timeRangeData = c("2024-09-24 00:00", "2024-09-25 23:59") # Set manual blind times to NULL (no manual blind times) # =========================================================================== cManualBlindTimes = NULL # Compute density # =========================================================================== classSelection.density = c("passerine_type") densityData = computeDensity( dbName = dbName, echoes = dbData$echoData, classSelection = classSelection.density, altitudeRange = c(25, 1025), altitudeBinSize = 50, timeRange = timeRangeData, timeBinDuration_sec = 1800, timeZone = targetTimeZone, sunriseSunset = dbData$sunriseSunset, sunOrCivil = "civil", crepuscule = "nauticalSolar", protocolData = dbData$protocolData, visibilityData = dbData$visibilityData, manualBlindTimes = cManualBlindTimes, saveBlindTimes = FALSE, blindTimesOutputDir = getwd(), blindTimeAsMtrZero = NULL, propObsTimeCutoff = 0, computePerDayNight = FALSE, computePerDayCrepusculeNight = FALSE, computeAltitudeDistribution = TRUE )# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) dbName = "CH_Sempach_2024_SEP24_25" targetTimeZone = "Etc/GMT0" timeRangeData = c("2024-09-24 00:00", "2024-09-25 23:59") # Set manual blind times to NULL (no manual blind times) # =========================================================================== cManualBlindTimes = NULL # Compute density # =========================================================================== classSelection.density = c("passerine_type") densityData = computeDensity( dbName = dbName, echoes = dbData$echoData, classSelection = classSelection.density, altitudeRange = c(25, 1025), altitudeBinSize = 50, timeRange = timeRangeData, timeBinDuration_sec = 1800, timeZone = targetTimeZone, sunriseSunset = dbData$sunriseSunset, sunOrCivil = "civil", crepuscule = "nauticalSolar", protocolData = dbData$protocolData, visibilityData = dbData$visibilityData, manualBlindTimes = cManualBlindTimes, saveBlindTimes = FALSE, blindTimesOutputDir = getwd(), blindTimeAsMtrZero = NULL, propObsTimeCutoff = 0, computePerDayNight = FALSE, computePerDayCrepusculeNight = FALSE, computeAltitudeDistribution = TRUE )
This function will estimate the Activity / Migration Traffic Rates (MTR, expressed as #objects / km / hour) based on the observations in your database.
computeMTR( dbName, echoes, classSelection, altitudeRange, altitudeBinSize, timeRange, timeBinDuration_sec, timeZone, sunriseSunset, sunOrCivil = "civil", crepuscule = "nauticalSolar", protocolData, visibilityData, manualBlindTimes = NULL, saveBlindTimes = FALSE, blindTimesOutputDir = getwd(), blindTimeAsMtrZero = NULL, propObsTimeCutoff = 0, computePerDayNight = FALSE, computePerDayCrepusculeNight = FALSE, computeAltitudeDistribution = TRUE, blindTimes = NULL, dataPackage = NULL, campaignID = NULL )computeMTR( dbName, echoes, classSelection, altitudeRange, altitudeBinSize, timeRange, timeBinDuration_sec, timeZone, sunriseSunset, sunOrCivil = "civil", crepuscule = "nauticalSolar", protocolData, visibilityData, manualBlindTimes = NULL, saveBlindTimes = FALSE, blindTimesOutputDir = getwd(), blindTimeAsMtrZero = NULL, propObsTimeCutoff = 0, computePerDayNight = FALSE, computePerDayCrepusculeNight = FALSE, computeAltitudeDistribution = TRUE, blindTimes = NULL, dataPackage = NULL, campaignID = NULL )
dbName |
Character string, containing the name of the database you are processing |
echoes |
dataframe with the echo data from the data list created by
|
classSelection |
character string vector with all classes which should be used to calculate the MTR. The MTR and number of Echoes will be calculated for each class as well as for all classes together. |
altitudeRange |
numeric vector of length 2 with the start and end of the altitude range in meter a.g.l. |
altitudeBinSize |
numeric, size of the altitude bins in meter. |
timeRange |
Character vector of length 2, with start and end of time range, formatted as "%Y-%m-%d %H:%M" |
timeBinDuration_sec |
duration of timeBins in seconds (numeric). for values <= 0 a duration of 1 hour will be set |
timeZone |
time zone in which the time bins should be created as string, e.g. "Etc/GMT0" |
sunriseSunset |
dataframe with sunrise/sunset, and civil and nautical
dawn/dusk. Computed with |
sunOrCivil |
sunrise/sunset or civil dawn/dusk used to split day and night. Supported values: "sun" or "civil". Default: "civil" |
crepuscule |
optional character variable, Set to “nauticalSolar” to use the time between nautical dusk/dawn and sunrise/sunset times to define the crepuscular period, or to "nauticalCivil" to use the time between nautical and civil dusk/dawn to define the crepuscular period, or to "civilSolar" to use the time between civil dusk/dawn and sunrise/sunset times to define the crepuscular period. Default is "nauticalSolar". |
protocolData |
|
visibilityData |
dataframe with the visibility data from the data list
created by |
manualBlindTimes |
dataframe with the manual blind times created by the
function |
saveBlindTimes |
Logical, determines whether to save the blind times to a file. Default: False. |
blindTimesOutputDir |
Character string containing the path to save the blind times to. Default: 'your-working-directory' |
blindTimeAsMtrZero |
character string vector with the blind time types which should be treated as observation time with MTR zero. |
propObsTimeCutoff |
numeric between 0 and 1. Time bins with a proportional
observation time smaller than |
computePerDayNight |
logical, TRUE: MTR is computed per day and night. The time bins of each day and night will be combined and the mean MTR is computed for each day and night. The spread (first and third Quartile) for each day and night are also computed. The spread is dependent on the chosen time bin duration/amount of time bins; When FALSE: MTR is computed for each time bin. This option computes the MTR for each time bin defined in the time bin dataframe. The time bins that were split due to sunrise/sunset during the time bin will be combined to one bin. |
computePerDayCrepusculeNight |
logical, TRUE: MTR is computed per crepusculeMorning, day, crepusculeEvening, and night. The time bins of each of these diel phases will be combined and the mean MTR is computed for each phase. The spread (first and third Quartile) for each phase is also computed. The spread is dependent on the chosen time bin duration/amount of time bins; When FALSE: MTR is computed for each time bin. This option computes the MTR for each time bin defined in the time bin dataframe. The time bins that were split due to sunrise/sunset during the time bin will be combined to one bin. Default = FALSE. |
computeAltitudeDistribution |
logical, TRUE: compute the mean height and altitude distribution of MTR for the pre-defined quantiles 0.05, 0.25, 0.5, 0.75, 0.95 |
blindTimes |
optional. Data frame with blind times that were already
merged (columns |
dataPackage |
optional. An MR1 data package (see |
campaignID |
optional. With a merged |
Migration Traffic Rates (for a merged dataPackage: a named list with the
result of each campaign)
Fabian Hertner, Baptiste Schmid, Birgen Haest
Other manipulation functions:
addDayNightInfoPerEcho(),
computeDensity(),
convertTimeZone(),
createVPTS(),
filterSpeedFeature37(),
mergeVisibilityAndManualBlindTimes(),
reclassToBats(),
twilight()
# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) dbName = "CH_Sempach_2024_SEP24_25" targetTimeZone = "Etc/GMT0" timeRangeData = c("2024-09-24 00:00", "2024-09-25 23:59") # Set manual blind times to NULL (no manual blind times) # =========================================================================== cManualBlindTimes = NULL # Compute migration traffic rate # =========================================================================== classSelection.mtr = c("passerine_type") mtrData = computeMTR( dbName = dbName, echoes = dbData$echoData, classSelection = classSelection.mtr, altitudeRange = c(25, 1025), altitudeBinSize = 50, timeRange = timeRangeData, timeBinDuration_sec = 1800, timeZone = targetTimeZone, sunriseSunset = dbData$sunriseSunset, sunOrCivil = "civil", crepuscule = "nauticalSolar", protocolData = dbData$protocolData, visibilityData = dbData$visibilityData, manualBlindTimes = cManualBlindTimes, saveBlindTimes = FALSE, blindTimesOutputDir = getwd(), blindTimeAsMtrZero = NULL, propObsTimeCutoff = 0, computePerDayNight = FALSE, computePerDayCrepusculeNight = FALSE, computeAltitudeDistribution = TRUE )# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) dbName = "CH_Sempach_2024_SEP24_25" targetTimeZone = "Etc/GMT0" timeRangeData = c("2024-09-24 00:00", "2024-09-25 23:59") # Set manual blind times to NULL (no manual blind times) # =========================================================================== cManualBlindTimes = NULL # Compute migration traffic rate # =========================================================================== classSelection.mtr = c("passerine_type") mtrData = computeMTR( dbName = dbName, echoes = dbData$echoData, classSelection = classSelection.mtr, altitudeRange = c(25, 1025), altitudeBinSize = 50, timeRange = timeRangeData, timeBinDuration_sec = 1800, timeZone = targetTimeZone, sunriseSunset = dbData$sunriseSunset, sunOrCivil = "civil", crepuscule = "nauticalSolar", protocolData = dbData$protocolData, visibilityData = dbData$visibilityData, manualBlindTimes = cManualBlindTimes, saveBlindTimes = FALSE, blindTimesOutputDir = getwd(), blindTimeAsMtrZero = NULL, propObsTimeCutoff = 0, computePerDayNight = FALSE, computePerDayCrepusculeNight = FALSE, computeAltitudeDistribution = TRUE )
Converts timestamps from radar time zone to an user-defined time zone
convertTimeZone( data = NULL, colNames = "", originTZ = "Etc/GMT0", targetTZ = "Etc/GMT0" )convertTimeZone( data = NULL, colNames = "", originTZ = "Etc/GMT0", targetTZ = "Etc/GMT0" )
data |
a data frame containing BirdScan data |
colNames |
a character vector containing valid column names, as present
in |
originTZ |
character, the time zone name of data to be converted (default is "etc/GMT0") |
targetTZ |
character, the time zone name to convert data into (default is "etc/GMT0") |
a data frame identical to data, any columns declared in colNames
will have their name changed with a suffix (_originTZ or _targetTZ) added.
Fabian Hertner, Birgen Haest
Other manipulation functions:
addDayNightInfoPerEcho(),
computeDensity(),
computeMTR(),
createVPTS(),
filterSpeedFeature37(),
mergeVisibilityAndManualBlindTimes(),
reclassToBats(),
twilight()
# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) # Add day/night info to echo data # =========================================================================== echoData = convertTimeZone( data = dbData$echoData, colNames = c("time_stamp"), originTZ = "Etc/GMT0", targetTZ = "Etc/GMT-2" )# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) # Add day/night info to echo data # =========================================================================== echoData = convertTimeZone( data = dbData$echoData, colNames = c("time_stamp"), originTZ = "Etc/GMT0", targetTZ = "Etc/GMT-2" )
createCollectionMetadataTemplate() writes a commented YAML
template with the metadata of a collection of MR1 records on Zenodo:
collection ID, level (owner or community), title, description, version,
owner, licence, keywords, contributors, members (DOIs of the records in the
collection), related identifiers and suggested citation. Fill in the
template and pass its path to the metadata argument of
uploadCollectionToZenodo().
createCollectionMetadataTemplate(filePath, overwrite = FALSE)createCollectionMetadataTemplate(filePath, overwrite = FALSE)
filePath |
Path of the YAML file to write. |
overwrite |
logical. If |
The path of the written file, invisibly.
Birgen Haest
Other write file functions:
addZenodoRelatedIdentifiers(),
checkDataPackageMetadata(),
compileData(),
createDataPackage(),
createDataPackageMetadataTemplate(),
editDataPackageMetadata(),
linkCollectionMembers(),
saveMTR(),
savePlotToFile(),
uploadCollectionToZenodo(),
uploadDataPackageToZenodo(),
validateDataPackage()
# Write the collection metadata template # =========================================================================== metadataFile = file.path(tempdir(), "SOI_BirdScanMR1_collection.yaml") createCollectionMetadataTemplate(filePath = metadataFile, overwrite = TRUE)# Write the collection metadata template # =========================================================================== metadataFile = file.path(tempdir(), "SOI_BirdScanMR1_collection.yaml") createCollectionMetadataTemplate(filePath = metadataFile, overwrite = TRUE)
createDataPackage() compiles data from extractDbData() into
a standardised MR1 data package for one radar campaign, following the
Frictionless Data Package standard. Time range,
pulse type, rotation, echo class, class probability, altitude and echo
validator filters are applied with filterProtocolData() and
filterEchoData().
The package contains five tabular resources: echo_data, protocol_data,
blind_times, sunrise_sunset and site_data. Each resource has a Table
Schema with field types, descriptions, units, and primary and foreign keys.
echo_data contains all echo columns, except those that are obsolete or
redundant: mtr_factor_old, statistical_classification_old,
classification_id and sphere_dia (old classification, outdated since
BirdScan v1.6), feature15.polRatio and feature16.absPolarisation
(outdated since BirdScan v1.6), feature3.speed (superseded by
feature37.speed), time_string (same as time_stamp_originTZ), and
time_bin and altitude_bin (refer to radar database tables that are not
part of the package).
The package-level metadata (title, description, owner, licence, embargo,
contributors with ORCID and DataCite roles, related identifiers, suggested
citation) are read from metadata. Spatial and temporal coverage, the
applied filters and the provenance (database, birdscanR and classifier
versions) are added automatically.
When outputDirPath is provided, the package is written to
outputDirPath/<campaignID>/ as datapackage.json plus one compressed CSV
file per resource, ready for a Zenodo deposit.
createDataPackage( dbExtract, metadata, manualBlindTimes = NULL, dbName = NULL, pulseTypeSelection = NULL, rotationSelection = NULL, timeRangeTargetTZ = NULL, classSelection = NULL, classProbCutOff = NULL, altitudeRange = NULL, echoValidator = FALSE, outputDirPath = NULL, saveAsRDS = FALSE )createDataPackage( dbExtract, metadata, manualBlindTimes = NULL, dbName = NULL, pulseTypeSelection = NULL, rotationSelection = NULL, timeRangeTargetTZ = NULL, classSelection = NULL, classProbCutOff = NULL, altitudeRange = NULL, echoValidator = FALSE, outputDirPath = NULL, saveAsRDS = FALSE )
dbExtract |
named list with the database tables extracted by
|
metadata |
path to a YAML file, or a named list with the same structure,
with the package-level metadata. Use |
manualBlindTimes |
data frame with the manual blind times created by
|
dbName |
Name of the database. Stored in the package provenance.
Default is |
pulseTypeSelection |
character vector with the pulse types which should
be included in the subset. Options: |
rotationSelection |
numeric vector to select the operation modes with
and/or without antenna rotation. Options: 0, 1. (0 = no rotation,
1 = rotation). Default is |
timeRangeTargetTZ |
Character vector of length 2, with start and end of
time range, formatted as |
classSelection |
character string vector with the classes that should be
included. Default is |
classProbCutOff |
numeric cutoff value for class probabilities. Echoes
with a lower class probability will be excluded. Default is |
altitudeRange |
numeric vector of length 2 with start and end of the
altitude range in metres a.g.l. Echoes outside the altitude range will be
excluded. Default is |
echoValidator |
logical. If set to |
outputDirPath |
Directory where the data package is written, in a
subdirectory named after the |
saveAsRDS |
logical. If |
A Frictionless Data Package object (class mr1dp and
datapackage), i.e. a list with the package-level metadata and the
resources echo_data, protocol_data, blind_times, sunrise_sunset and
site_data. Read a resource as a data frame with
frictionless::read_resource().
Baptiste Schmid, Fabian Hertner, Birgen Haest
Other write file functions:
addZenodoRelatedIdentifiers(),
checkDataPackageMetadata(),
compileData(),
createCollectionMetadataTemplate(),
createDataPackageMetadataTemplate(),
editDataPackageMetadata(),
linkCollectionMembers(),
saveMTR(),
savePlotToFile(),
uploadCollectionToZenodo(),
uploadDataPackageToZenodo(),
validateDataPackage()
# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) dbName = "CH_Sempach_2024_SEP24_25" timeRangeTargetTZ = c("2024-09-24 00:00", "2024-09-25 23:59") mainOutputDir = tempdir() # Set manual blind times to NULL (no manual blind times) # =========================================================================== cManualBlindTimes = NULL # Write the package metadata template (fill it in for a real campaign) # =========================================================================== metadataFile = file.path(mainOutputDir, "CH_Sempach_2024_metadata.yaml") createDataPackageMetadataTemplate(filePath = metadataFile, overwrite = TRUE) # Create MR1 data package # =========================================================================== dataPackage = createDataPackage( dbExtract = dbData, metadata = metadataFile, manualBlindTimes = cManualBlindTimes, dbName = dbName, timeRangeTargetTZ = timeRangeTargetTZ, pulseTypeSelection = "S", outputDirPath = mainOutputDir ) # Read a resource of the data package # =========================================================================== echoData = frictionless::read_resource(dataPackage, "echo_data")# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) dbName = "CH_Sempach_2024_SEP24_25" timeRangeTargetTZ = c("2024-09-24 00:00", "2024-09-25 23:59") mainOutputDir = tempdir() # Set manual blind times to NULL (no manual blind times) # =========================================================================== cManualBlindTimes = NULL # Write the package metadata template (fill it in for a real campaign) # =========================================================================== metadataFile = file.path(mainOutputDir, "CH_Sempach_2024_metadata.yaml") createDataPackageMetadataTemplate(filePath = metadataFile, overwrite = TRUE) # Create MR1 data package # =========================================================================== dataPackage = createDataPackage( dbExtract = dbData, metadata = metadataFile, manualBlindTimes = cManualBlindTimes, dbName = dbName, timeRangeTargetTZ = timeRangeTargetTZ, pulseTypeSelection = "S", outputDirPath = mainOutputDir ) # Read a resource of the data package # =========================================================================== echoData = frictionless::read_resource(dataPackage, "echo_data")
createDataPackageMetadataTemplate() writes a commented YAML
template with the package-level metadata of an MR1 data package: campaign ID,
title, description, version, owner, licence, embargo, keywords, contributors
(with ORCID, affiliation, DataCite roles and embargo request type), related
identifiers and suggested citation. Fill in the template and pass its path to
the metadata argument of createDataPackage(), and check it first with
checkDataPackageMetadata(). To fill in the metadata in a form instead of
a text editor, use editDataPackageMetadata().
Without dbExtract, the template contains example values for the Sempach
test dataset. With dbExtract, the values that can be derived from the data
are filled in: campaign ID (<countryCode>_<site name>_<year(s)>), title
and description (site name and the period of the echo data) and owner (the
customer of the site). The example contributor is removed, so the
contributors must be filled in before the metadata pass the checks.
createDataPackageMetadataTemplate( filePath, dbExtract = NULL, countryCode = NULL, overwrite = FALSE )createDataPackageMetadataTemplate( filePath, dbExtract = NULL, countryCode = NULL, overwrite = FALSE )
filePath |
Path of the YAML file to write. |
dbExtract |
optional. Named list with the database tables extracted by
|
countryCode |
optional. Two-letter ISO country code of the site (e.g.
|
overwrite |
logical. If |
The path of the written file, invisibly.
Birgen Haest
Other write file functions:
addZenodoRelatedIdentifiers(),
checkDataPackageMetadata(),
compileData(),
createCollectionMetadataTemplate(),
createDataPackage(),
editDataPackageMetadata(),
linkCollectionMembers(),
saveMTR(),
savePlotToFile(),
uploadCollectionToZenodo(),
uploadDataPackageToZenodo(),
validateDataPackage()
# Write the metadata template # =========================================================================== metadataFile = file.path(tempdir(), "CH_Sempach_2024_metadata.yaml") createDataPackageMetadataTemplate(filePath = metadataFile, overwrite = TRUE) # Write a template filled in from the data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) createDataPackageMetadataTemplate( filePath = metadataFile, dbExtract = dbData, countryCode = "CH", overwrite = TRUE ) # Fill in the contributors, then check the file checkDataPackageMetadata(metadataFile)# Write the metadata template # =========================================================================== metadataFile = file.path(tempdir(), "CH_Sempach_2024_metadata.yaml") createDataPackageMetadataTemplate(filePath = metadataFile, overwrite = TRUE) # Write a template filled in from the data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) createDataPackageMetadataTemplate( filePath = metadataFile, dbExtract = dbData, countryCode = "CH", overwrite = TRUE ) # Fill in the contributors, then check the file checkDataPackageMetadata(metadataFile)
Create a list by segmenting the input time range into regular periods for plots.
createTimeRangeForPlot( startDate = NULL, endDate = NULL, periodLength = 7, returnAsList = TRUE )createTimeRangeForPlot( startDate = NULL, endDate = NULL, periodLength = 7, returnAsList = TRUE )
startDate |
Per default, the first element of the input setting |
endDate |
Per default, the second element of the input setting 'timeRangeData“ |
periodLength |
Duration in days of each period |
returnAsList |
TRUE per default, otherwise as data.frame. |
A list of time periods
Baptiste Schmid, Birgen Haest
Other plot functions:
plotExploration(),
plotLongitudinalMTR()
## Not run: # Set server, database, and other input settings # =========================================================================== # Example with seven days time window timeRangeData <- c("2024-01-01", "2024-02-15") timeRangePlot <- createTimeRangePlot(timeRangeData[1], timeRangeData[2], 7) print(timeRangePlot) ## End(Not run)## Not run: # Set server, database, and other input settings # =========================================================================== # Example with seven days time window timeRangeData <- c("2024-01-01", "2024-02-15") timeRangePlot <- createTimeRangePlot(timeRangeData[1], timeRangeData[2], 7) print(timeRangePlot) ## End(Not run)
This function creates VPTS CSV output files in line with the ALOFT data standard, described here. Note that this function only works on Birdscan MR1 database versions >= 1.7.0.4 as the variable feature37.speed is required for the density calculation.
createVPTS( dbName, outputDir, echoes, classSelection = c("passerine_type", "wader_type", "swift_type", "large_bird", "unid_bird", "bird_flock"), altitudeRange = c(50, 1500), altitudeBinSize = 50, timeRange, timeBinDuration_sec = 900, timeZone = "Etc/GMT0", protocolData, visibilityData, siteData, sunriseSunset, manualBlindTimes = NULL, saveBlindTimes = FALSE, blindTimesOutputDir = getwd(), blindTimeAsMtrZero = NULL, propObsTimeCutoff = 0.2, blindTimes = NULL, dataPackage = NULL, campaignID = NULL )createVPTS( dbName, outputDir, echoes, classSelection = c("passerine_type", "wader_type", "swift_type", "large_bird", "unid_bird", "bird_flock"), altitudeRange = c(50, 1500), altitudeBinSize = 50, timeRange, timeBinDuration_sec = 900, timeZone = "Etc/GMT0", protocolData, visibilityData, siteData, sunriseSunset, manualBlindTimes = NULL, saveBlindTimes = FALSE, blindTimesOutputDir = getwd(), blindTimeAsMtrZero = NULL, propObsTimeCutoff = 0.2, blindTimes = NULL, dataPackage = NULL, campaignID = NULL )
dbName |
Character string, containing the name of the database you are processing |
outputDir |
Character variable indicating where you want the VPTS
files to be stored. The function will create a subdirectory called "vpts"
within the specified |
echoes |
dataframe with the echo data from the data list created with
|
classSelection |
character string vector with all classes which should be used to calculate the density. The density and number of Echoes will be calculated for each class as well as for all classes together. |
altitudeRange |
numeric vector of length 2 with the start and end of the altitude range in meter a.g.l. |
altitudeBinSize |
numeric, size of the altitude bins in meter. |
timeRange |
Character vector of length 2, with start and end of time range, formatted as "%Y-%m-%d %H:%M" |
timeBinDuration_sec |
duration of timeBins in seconds (numeric). for values <= 0 a duration of 1 hour will be set |
timeZone |
time zone in which the time bins should be created as string, e.g. "Etc/GMT0" |
protocolData |
dataframe with the protocol data from the data list
created by |
visibilityData |
dataframe with the visibility data from the data list
created by |
siteData |
A data frame holding the site table, as extracted with
|
sunriseSunset |
dataframe with sunrise/sunset, and civil and nautical
dawn/dusk. Computed with |
manualBlindTimes |
dataframe with the manual blind times created by the
function |
saveBlindTimes |
Logical, determines whether to save the blind times to a file. Default: False. |
blindTimesOutputDir |
Character string containing the path to save the blind times to. Default: 'your-working-directory' |
blindTimeAsMtrZero |
character string vector with the blind time types which should be treated as observation time with MTR zero. |
propObsTimeCutoff |
numeric between 0 and 1. Time bins with a proportional
observation time smaller than |
blindTimes |
optional. Data frame with blind times that were already
merged (columns |
dataPackage |
optional. An MR1 data package (see |
campaignID |
optional. With a merged |
File path to the created VPTS CSV file (for a merged dataPackage:
a named list with the file of each campaign).
Birgen Haest
Other manipulation functions:
addDayNightInfoPerEcho(),
computeDensity(),
computeMTR(),
convertTimeZone(),
filterSpeedFeature37(),
mergeVisibilityAndManualBlindTimes(),
reclassToBats(),
twilight()
# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) dbName = "CH_Sempach_2024_SEP24_25" mainOutputDir = tempdir() targetTimeZone = "Etc/GMT0" timeRangeData = c("2024-09-24 00:00", "2024-09-25 23:59") # Set manual blind times to NULL (no manual blind times) # =========================================================================== cManualBlindTimes = NULL # Create vpts files # =========================================================================== vptsDir = createVPTS( dbName = dbName, outputDir = mainOutputDir, echoes = dbData$echoData, altitudeRange = c(25, 1025), altitudeBinSize = 50, timeRange = timeRangeData, timeBinDuration_sec = 1800, timeZone = targetTimeZone, protocolData = dbData$protocolData, visibilityData = dbData$visibilityData, siteData = dbData$siteData, sunriseSunset = dbData$sunriseSunset, manualBlindTimes = cManualBlindTimes, saveBlindTimes = FALSE, blindTimesOutputDir = mainOutputDir, blindTimeAsMtrZero = NULL, propObsTimeCutoff = 0.2 )# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) dbName = "CH_Sempach_2024_SEP24_25" mainOutputDir = tempdir() targetTimeZone = "Etc/GMT0" timeRangeData = c("2024-09-24 00:00", "2024-09-25 23:59") # Set manual blind times to NULL (no manual blind times) # =========================================================================== cManualBlindTimes = NULL # Create vpts files # =========================================================================== vptsDir = createVPTS( dbName = dbName, outputDir = mainOutputDir, echoes = dbData$echoData, altitudeRange = c(25, 1025), altitudeBinSize = 50, timeRange = timeRangeData, timeBinDuration_sec = 1800, timeZone = targetTimeZone, protocolData = dbData$protocolData, visibilityData = dbData$visibilityData, siteData = dbData$siteData, sunriseSunset = dbData$sunriseSunset, manualBlindTimes = cManualBlindTimes, saveBlindTimes = FALSE, blindTimesOutputDir = mainOutputDir, blindTimeAsMtrZero = NULL, propObsTimeCutoff = 0.2 )
Connects to a Birdscan SQL database, be it a Microsoft SQL or postgreSQL database3
dbConnectBirdscanSQL( dbDriverChar = "SQL Server", dbServer = NULL, dbName = NULL, dbUser = NULL, dbPwd = NULL, dbPort = 5432 )dbConnectBirdscanSQL( dbDriverChar = "SQL Server", dbServer = NULL, dbName = NULL, dbUser = NULL, dbPwd = NULL, dbPort = 5432 )
dbDriverChar |
'SQL Server' The name of the driver. Should be either 'SQL Server' or 'PostgreSQL'. |
dbServer |
NULL The name of the SQL Server. For a 'PostgreSQL' this can be a the host address or the internal IP. |
dbName |
NULL The name of the SQL database |
dbUser |
NULL The username of the SQL server |
dbPwd |
NULL The password for the user name |
dbPort |
5432 The dbPort parameter specifies the TCP/IP port number on which the PostgreSQL server is listening for connections (default is 5432) |
A database connection to your target database
Birgen Haest
Other read SQL database functions:
QUERY(),
extractDbData(),
getBatClassification(),
getCollectionTable(),
getEchoFeatures(),
getEchoValidationTable(),
getProtocolTable(),
getRadarTable(),
getRfClassification(),
getSiteTable(),
getTimeBinsTable(),
getVisibilityTable()
## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) ## End(Not run)## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) ## End(Not run)
editDataPackageMetadata() opens a form in the web browser to
fill in (or correct) the metadata of an MR1 data package, as an alternative
to editing the YAML file in a text editor. The form shows what is still
missing or wrong while you type (the same checks as
checkDataPackageMetadata()), and saves the metadata as YAML file, ready for
createDataPackage(). Metadata with problems can be saved too, to continue
later.
The form runs on your own computer: nothing is sent over the internet. It
needs the package shiny; if it is not installed, you are asked whether to
install it.
The form starts from:
the metadata in filePath, if that file exists;
otherwise, the values derived from dbExtract (see
createDataPackageMetadataTemplate()), if given;
otherwise, an empty form with the default licence, version and keywords.
Related identifiers cannot be edited in the form; those in the file (or the default link to birdscanR) are kept.
editDataPackageMetadata( filePath, dbExtract = NULL, countryCode = NULL, launch.browser = TRUE )editDataPackageMetadata( filePath, dbExtract = NULL, countryCode = NULL, launch.browser = TRUE )
filePath |
Path of the YAML file with the metadata. If it exists, its metadata are loaded into the form; saving overwrites it. |
dbExtract |
optional. Named list with the database tables extracted by
|
countryCode |
optional. Two-letter ISO country code of the site (e.g.
|
launch.browser |
logical. Open the form in the web browser (default),
or, if |
The path of the saved YAML file, invisibly, when the form is closed
with "Save and close"; NULL if it is closed without saving.
Birgen Haest
Other write file functions:
addZenodoRelatedIdentifiers(),
checkDataPackageMetadata(),
compileData(),
createCollectionMetadataTemplate(),
createDataPackage(),
createDataPackageMetadataTemplate(),
linkCollectionMembers(),
saveMTR(),
savePlotToFile(),
uploadCollectionToZenodo(),
uploadDataPackageToZenodo(),
validateDataPackage()
## Not run: # Fill in the metadata of a campaign in a form # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) metadataFile = editDataPackageMetadata( filePath = "CH_Sempach_2024_metadata.yaml", dbExtract = dbData, countryCode = "CH" ) ## End(Not run)## Not run: # Fill in the metadata of a campaign in a form # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) metadataFile = editDataPackageMetadata( filePath = "CH_Sempach_2024_metadata.yaml", dbExtract = dbData, countryCode = "CH" ) ## End(Not run)
Load the data from the database or file and save it to file
extractDbData( dbDriverChar = "SQL Server", dbServer = NULL, dbName = NULL, dbUser = NULL, dbPwd = NULL, dbPort = 5432, saveDbToFile = FALSE, dbDataDir = NULL, radarTimeZone = NULL, targetTimeZone = "Etc/GMT0", timeInterval = NULL, listOfRfFeaturesToExtract = NULL, siteLocation = NULL, sunOrCivil = "civil", crepuscule = "nauticalSolar" )extractDbData( dbDriverChar = "SQL Server", dbServer = NULL, dbName = NULL, dbUser = NULL, dbPwd = NULL, dbPort = 5432, saveDbToFile = FALSE, dbDataDir = NULL, radarTimeZone = NULL, targetTimeZone = "Etc/GMT0", timeInterval = NULL, listOfRfFeaturesToExtract = NULL, siteLocation = NULL, sunOrCivil = "civil", crepuscule = "nauticalSolar" )
dbDriverChar |
'SQL Server' The name of the driver. Should be either 'SQL Server' or 'PostgreSQL'. |
dbServer |
NULL The name of the SQL Server. For a 'PostgreSQL' this can be a the host address or the internal IP. |
dbName |
NULL The name of the SQL database |
dbUser |
NULL The username of the SQL server |
dbPwd |
NULL The password for the user name |
dbPort |
5432 The dbPort parameter specifies the TCP/IP port number on which the PostgreSQL server is listening for connections (default is 5432) |
saveDbToFile |
FALSE Set to TRUE if you want to save the extracted database data to an rds file. The output filename is automatically set to dbName_DataExtract.rds |
dbDataDir |
NULL The path to the output directory where to store the extracted dataset. If the directory does not exist, it will be created. |
radarTimeZone |
NULL String specifying the radar time zone. Default is NULL: extract the time zone from the site table of the 'SQL' database. |
targetTimeZone |
"Etc/GMT0" String specifying the target time zone. Default is "Etc/GMT0". |
timeInterval |
NULL An optional vector of timestamps (either as |
listOfRfFeaturesToExtract |
Either NULL (i.e., don't extract any of the rf features), "all" (i.e., extract all rf features) or a vector of the feature numbers to extract. Default is NULL. |
siteLocation |
Geographic location of the radar measurements in decimal format: c(Latitude, Longitude) |
sunOrCivil |
optional character variable, Set to “sun” to use sunrise/sunset times or to “civil” to use civil twilight times to group echoes into day/night. Default is "civil". |
crepuscule |
optional character variable, Set to “nauticalSolar” to use the time between nautical dusk/dawn and sunrise/sunset times to define the crepuscular period, or to "nauticalCivil" to use the time between nautical and civil dusk/dawn to define the crepuscular period, or to "civilSolar" to use the time between civil dusk/dawn and sunrise/sunset times to define the crepuscular period. Default is "nauticalSolar". |
a list of R objects with data extracted from the Database: 'echoData', 'protocolData', 'siteData', 'visibilityData', 'timeBinData', 'rfFeatures', 'availableClasses', 'availableBatClasses', 'classProbabilitiesAndMtrFactors', 'batProbabilitiesAndMtrFactors'
Fabian Hertner, Birgen Haest
Other read SQL database functions:
QUERY(),
dbConnectBirdscanSQL(),
getBatClassification(),
getCollectionTable(),
getEchoFeatures(),
getEchoValidationTable(),
getProtocolTable(),
getRadarTable(),
getRfClassification(),
getSiteTable(),
getTimeBinsTable(),
getVisibilityTable()
## Not run: # Set server, database, and other input settings # =========================================================================== dbDriverChar = "SQL Server" # Set either "SQL Server" or "PostgreSQL" dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database mainOutputDir = file.path(".", "results") radarTimeZone = "Etc/GMT0" targetTimeZone = "Etc/GMT0" listOfRfFeaturesToExtract = c(167, 168) siteLocation = c(47.494427, 8.716432) sunOrCivil = "civil" # Get data # =========================================================================== dbData = extractDbData( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, saveDbToFile = TRUE, dbDataDir = mainOutputDir, radarTimeZone = radarTimeZone, targetTimeZone = targetTimeZone, listOfRfFeaturesToExtract = listOfRfFeaturesToExtract, siteLocation = siteLocation, sunOrCivil = sunOrCivil, crepuscule = "nauticalSolar" ) ## End(Not run)## Not run: # Set server, database, and other input settings # =========================================================================== dbDriverChar = "SQL Server" # Set either "SQL Server" or "PostgreSQL" dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database mainOutputDir = file.path(".", "results") radarTimeZone = "Etc/GMT0" targetTimeZone = "Etc/GMT0" listOfRfFeaturesToExtract = c(167, 168) siteLocation = c(47.494427, 8.716432) sunOrCivil = "civil" # Get data # =========================================================================== dbData = extractDbData( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, saveDbToFile = TRUE, dbDataDir = mainOutputDir, radarTimeZone = radarTimeZone, targetTimeZone = targetTimeZone, listOfRfFeaturesToExtract = listOfRfFeaturesToExtract, siteLocation = siteLocation, sunOrCivil = sunOrCivil, crepuscule = "nauticalSolar" ) ## End(Not run)
With filterData() both the echo and protocol data can be
filtered based on several parameters. Give either the whole database extract
(dbExtract), or the echo and protocol data (echoData, protocolData).
filterData( echoData = NULL, protocolData = NULL, pulseTypeSelection = NULL, rotationSelection = NULL, timeRangeTargetTZ = NULL, targetTimeZone = "Etc/GMT0", classSelection = NULL, classProbCutOff = NULL, altitudeRange_AGL = NULL, manualBlindTimes = NULL, echoValidator = FALSE, dbExtract = NULL )filterData( echoData = NULL, protocolData = NULL, pulseTypeSelection = NULL, rotationSelection = NULL, timeRangeTargetTZ = NULL, targetTimeZone = "Etc/GMT0", classSelection = NULL, classProbCutOff = NULL, altitudeRange_AGL = NULL, manualBlindTimes = NULL, echoValidator = FALSE, dbExtract = NULL )
echoData |
|
protocolData |
|
pulseTypeSelection |
character vector with the pulse types which should be included in the subset. Options: “S”, “M”, “L” (short-, medium-, long-pulse). Default is NULL: no filtering applied based on pulseType. |
rotationSelection |
numeric vector to select the operation modes with and/or without antenna rotation. Options: 0, 1. (0 = no rotation, 1 = rotation). Default is NULL: no filtering applied based on rotation mode. |
timeRangeTargetTZ |
Character vector of length 2, with start and end of time range, formatted as "%Y-%m-%d %H:%M". Echoes outside the time range will be excluded. |
targetTimeZone |
"Etc/GMT0" String specifying the target time zone.
Default is "Etc/GMT0", or with |
classSelection |
character string vector with the classes that should be included. |
classProbCutOff |
numeric cutoff value for class probabilities. Echoes with a lower class probability will be excluded. |
altitudeRange_AGL |
numeric vector of length 2 with start and end of the altitude range. Echoes outside the altitude range will be excluded. |
manualBlindTimes |
dataframe with the manual blind times created by the
function |
echoValidator |
logical, if set to TRUE, echoes labelled by the echo validator as “non-bio scatterer” will be excluded. If set to FALSE, all echoes are included. |
dbExtract |
named list with the database tables extracted by
|
With dbExtract: the extract with the filtered echoData and
protocolData; the other tables are kept as they are. Without: a list with
the filtered echoData and protocolData, in the same format as provided.
Both contain filtersApplied, a list with the filter settings of each
filtering step (one element per call of filterData(); filtering a
filtered extract again adds a step). createDataPackage() stores them in
the package metadata.
Birgen Haest
Other filter functions:
filterEchoData(),
filterProtocolData()
# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) # Set input settings for filtering of the data # =========================================================================== pulseLengthSelection = "S" rotationSelection = 1 timeRangeData = c("2024-09-24 00:00", "2024-09-25 23:59") targetTimeZone = "Etc/GMT0" classSelection = c( "passerine_type", "wader_type", "swift_type", "large_bird", "unid_bird", "bird_flock" ) classProbCutoff = NULL altitudeRange = c(50, 1000) cManualBlindTimes = NULL useEchoValidator = FALSE # Filter the data # =========================================================================== filteredData = filterData( dbExtract = dbData, pulseTypeSelection = pulseLengthSelection, rotationSelection = rotationSelection, timeRangeTargetTZ = timeRangeData, targetTimeZone = targetTimeZone, classSelection = classSelection, classProbCutOff = classProbCutoff, altitudeRange_AGL = altitudeRange, manualBlindTimes = cManualBlindTimes, echoValidator = useEchoValidator ) filteredData$filtersApplied # Or filter only the echo and protocol data # =========================================================================== filteredTables = filterData( echoData = dbData$echoData, protocolData = dbData$protocolData, classSelection = classSelection, altitudeRange_AGL = altitudeRange )# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) # Set input settings for filtering of the data # =========================================================================== pulseLengthSelection = "S" rotationSelection = 1 timeRangeData = c("2024-09-24 00:00", "2024-09-25 23:59") targetTimeZone = "Etc/GMT0" classSelection = c( "passerine_type", "wader_type", "swift_type", "large_bird", "unid_bird", "bird_flock" ) classProbCutoff = NULL altitudeRange = c(50, 1000) cManualBlindTimes = NULL useEchoValidator = FALSE # Filter the data # =========================================================================== filteredData = filterData( dbExtract = dbData, pulseTypeSelection = pulseLengthSelection, rotationSelection = rotationSelection, timeRangeTargetTZ = timeRangeData, targetTimeZone = targetTimeZone, classSelection = classSelection, classProbCutOff = classProbCutoff, altitudeRange_AGL = altitudeRange, manualBlindTimes = cManualBlindTimes, echoValidator = useEchoValidator ) filteredData$filtersApplied # Or filter only the echo and protocol data # =========================================================================== filteredTables = filterData( echoData = dbData$echoData, protocolData = dbData$protocolData, classSelection = classSelection, altitudeRange_AGL = altitudeRange )
With filterEchoData() the echo data can be
filtered by several parameters. The function returns the filtered echo data.
filterEchoData( echoData = NULL, timeRangeTargetTZ = NULL, targetTimeZone = "Etc/GMT0", protocolData = NULL, classSelection = NULL, classProbCutOff = NULL, altitudeRange_AGL = NULL, manualBlindTimes = NULL, echoValidator = FALSE )filterEchoData( echoData = NULL, timeRangeTargetTZ = NULL, targetTimeZone = "Etc/GMT0", protocolData = NULL, classSelection = NULL, classProbCutOff = NULL, altitudeRange_AGL = NULL, manualBlindTimes = NULL, echoValidator = FALSE )
echoData |
|
timeRangeTargetTZ |
Character vector of length 2, with start and end of time range, formatted as "%Y-%m-%d %H:%M". Echoes outside the time range will be excluded. |
targetTimeZone |
"Etc/GMT0" String specifying the target time zone. Default is "Etc/GMT0". |
protocolData |
|
classSelection |
character string vector with the classes that should be included. |
classProbCutOff |
numeric cutoff value for class probabilities. Echoes with a lower class probability will be excluded. |
altitudeRange_AGL |
numeric vector of length 2 with start and end of the altitude range. Echoes outside the altitude range will be excluded. |
manualBlindTimes |
dataframe with the manual blind times created by the
function |
echoValidator |
logical, if set to TRUE, echoes labelled by the echo validator as “non-bio scatterer” will be excluded. If set to FALSE, all echoes are included. |
returns the filtered echo data in the same format as provided in the
parameter echoData.
Fabian Hertner, Birgen Haest
Other filter functions:
filterData(),
filterProtocolData()
# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) # Set input settings for filtering of the data # =========================================================================== timeRangeData = c("2024-09-24 00:00", "2024-09-25 23:59") targetTimeZone = "Etc/GMT0" classSelection = c( "passerine_type", "wader_type", "swift_type", "large_bird", "unid_bird", "bird_flock" ) classProbCutoff = NULL altitudeRange = c(50, 1000) cManualBlindTimes = NULL useEchoValidator = FALSE # Filter the echo data # =========================================================================== filteredEchoData = filterEchoData( echoData = dbData$echoData, timeRangeTargetTZ = timeRangeData, targetTimeZone = targetTimeZone, protocolData = dbData$protocolData, classSelection = classSelection, classProbCutOff = classProbCutoff, altitudeRange_AGL = altitudeRange, manualBlindTimes = cManualBlindTimes, echoValidator = useEchoValidator )# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) # Set input settings for filtering of the data # =========================================================================== timeRangeData = c("2024-09-24 00:00", "2024-09-25 23:59") targetTimeZone = "Etc/GMT0" classSelection = c( "passerine_type", "wader_type", "swift_type", "large_bird", "unid_bird", "bird_flock" ) classProbCutoff = NULL altitudeRange = c(50, 1000) cManualBlindTimes = NULL useEchoValidator = FALSE # Filter the echo data # =========================================================================== filteredEchoData = filterEchoData( echoData = dbData$echoData, timeRangeTargetTZ = timeRangeData, targetTimeZone = targetTimeZone, protocolData = dbData$protocolData, classSelection = classSelection, classProbCutOff = classProbCutoff, altitudeRange_AGL = altitudeRange, manualBlindTimes = cManualBlindTimes, echoValidator = useEchoValidator )
With filterProtocolData() the protocol data
can be filtered by the operation mode (pulse-type and antenna rotation). The
function returns the filtered subset of the protocol data which can later be
used to filter the echoes based on the operation mode/protocol
filterProtocolData( protocolData = NULL, pulseTypeSelection = NULL, rotationSelection = NULL )filterProtocolData( protocolData = NULL, pulseTypeSelection = NULL, rotationSelection = NULL )
protocolData |
|
pulseTypeSelection |
character vector with the pulse types which should be included in the subset. Options: “S”, “M”, “L” (short-, medium-, long-pulse). Default is NULL: no filtering applied based on pulseType. |
rotationSelection |
numeric vector to select the operation modes with and/or without antenna rotation. Options: 0, 1. (0 = no rotation, 1 = rotation). Default is NULL: no filtering applied based on rotation mode. |
returns the filtered protocol data in the same format as provided in
the parameter protocolData.
Fabian Hertner, Birgen Haest
Other filter functions:
filterData(),
filterEchoData()
# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) # Set input settings for filtering of the data # =========================================================================== pulseLengthSelection = "S" rotationSelection = 1 # Filter the protocol data # =========================================================================== filteredProtocolData = filterProtocolData( protocolData = dbData$protocolData, pulseTypeSelection = pulseLengthSelection, rotationSelection = rotationSelection )# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) # Set input settings for filtering of the data # =========================================================================== pulseLengthSelection = "S" rotationSelection = 1 # Filter the protocol data # =========================================================================== filteredProtocolData = filterProtocolData( protocolData = dbData$protocolData, pulseTypeSelection = pulseLengthSelection, rotationSelection = rotationSelection )
Filter outliers in Speed feature (collection.feature37)
filterSpeedFeature37(echoData = NULL, minEchoDuration = 5)filterSpeedFeature37(echoData = NULL, minEchoDuration = 5)
echoData |
valid echodata |
minEchoDuration |
minimum duration of a echo to allow speed feature |
echoData with the filtered speed feature 37
Fabian Hertner, [email protected]; Birgen Haest, [email protected]
Other manipulation functions:
addDayNightInfoPerEcho(),
computeDensity(),
computeMTR(),
convertTimeZone(),
createVPTS(),
mergeVisibilityAndManualBlindTimes(),
reclassToBats(),
twilight()
# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) # Filter speed feature 37 # =========================================================================== minEchoDuration = 5 dbData$echoData = filterSpeedFeature37( echoData = dbData$echoData, minEchoDuration = minEchoDuration )# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) # Filter speed feature 37 # =========================================================================== minEchoDuration = 5 dbData$echoData = filterSpeedFeature37( echoData = dbData$echoData, minEchoDuration = minEchoDuration )
Gets the 'rfClasses' table from a 'Birdscan MR1' 'SQL' database
getBatClassification(dbConnection, dbDriverChar)getBatClassification(dbConnection, dbDriverChar)
dbConnection |
A valid database connection. |
dbDriverChar |
This was the name of the driver, and is now automatically detected, therefore it should be omitted into the future. |
A list containing three variables: (1) batClassificationTable: The 'batClassification' database table; (2) classProbabilitiesAndMtrFactors: A dataframe containing the classification probabilities for all classes for each object; and (3) availableClasses: the classes used for the classification of the objects.
Fabian Hertner, Birgen Haest
Other read SQL database functions:
QUERY(),
dbConnectBirdscanSQL(),
extractDbData(),
getCollectionTable(),
getEchoFeatures(),
getEchoValidationTable(),
getProtocolTable(),
getRadarTable(),
getRfClassification(),
getSiteTable(),
getTimeBinsTable(),
getVisibilityTable()
## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) batClassification = getBatClassification(dbConnection) ## End(Not run)## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) batClassification = getBatClassification(dbConnection) ## End(Not run)
Load collection from 'Birdscan MR1' 'SQL' database.
getCollectionTable(dbConnection, dbDriverChar, timeInterval = NULL)getCollectionTable(dbConnection, dbDriverChar, timeInterval = NULL)
dbConnection |
A valid database connection. |
dbDriverChar |
This was the name of the driver, and is now automatically detected, therefore it should be omitted into the future. |
timeInterval |
Null An optional vector of timestamps (either as |
A dataframe with the collection table
Fabian Hertner, Birgen Haest, Bart Kranstauber
Other read SQL database functions:
QUERY(),
dbConnectBirdscanSQL(),
extractDbData(),
getBatClassification(),
getEchoFeatures(),
getEchoValidationTable(),
getProtocolTable(),
getRadarTable(),
getRfClassification(),
getSiteTable(),
getTimeBinsTable(),
getVisibilityTable()
## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) collectionTable = getCollectionTable(dbConnection) ## End(Not run)## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) collectionTable = getCollectionTable(dbConnection) ## End(Not run)
Load echo rffeature map from 'Birdscan MR1' 'SQL' database.
getEchoFeatures( dbConnection, dbDriverChar, listOfRfFeaturesToExtract, echoIDRange = NULL )getEchoFeatures( dbConnection, dbDriverChar, listOfRfFeaturesToExtract, echoIDRange = NULL )
dbConnection |
A valid database connection. |
dbDriverChar |
This was the name of the driver, and is now automatically detected, therefore it should be omitted into the future. |
listOfRfFeaturesToExtract |
Either NULL (i.e., don't extract any of the rf features), "all" (i.e., extract all rf features) or a vector of the feature numbers to extract. Default is NULL. Feature IDs can be found in the 'rfFeatures' table in the sql database. |
echoIDRange |
NULL A two-element vector of integers to subset the rf feature extraction to a range of echoIDs. Default is to extract for all echoes. |
A list of the features extracted
Fabian Hertner, Birgen Haest
Other read SQL database functions:
QUERY(),
dbConnectBirdscanSQL(),
extractDbData(),
getBatClassification(),
getCollectionTable(),
getEchoValidationTable(),
getProtocolTable(),
getRadarTable(),
getRfClassification(),
getSiteTable(),
getTimeBinsTable(),
getVisibilityTable()
## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) # Set list of Rf features you also want to extract # Vector with RF features to extract. Feature IDs can be found in the # 'rfFeatures' table in the sql database. # Example: Get wing beat frequency and credibility: c(167, 168) # Set to NULL to not extract any. # Set to "all" to extract all features. # =========================================================================== listOfRfFeaturesToExtract = c(167, 168) echoFeatures = getEchoFeatures( dbConnection, listOfRfFeaturesToExtract ) ## End(Not run)## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) # Set list of Rf features you also want to extract # Vector with RF features to extract. Feature IDs can be found in the # 'rfFeatures' table in the sql database. # Example: Get wing beat frequency and credibility: c(167, 168) # Set to NULL to not extract any. # Set to "all" to extract all features. # =========================================================================== listOfRfFeaturesToExtract = c(167, 168) echoFeatures = getEchoFeatures( dbConnection, listOfRfFeaturesToExtract ) ## End(Not run)
Gets the echoValidationTable from an already connected database.
getEchoValidationTable(dbConnection, dbDriverChar)getEchoValidationTable(dbConnection, dbDriverChar)
dbConnection |
A valid database connection. |
dbDriverChar |
This was the name of the driver, and is now automatically detected, therefore it should be omitted into the future. |
A dataframe called echovalidationTable
Fabian Hertner, Birgen Haest
Other read SQL database functions:
QUERY(),
dbConnectBirdscanSQL(),
extractDbData(),
getBatClassification(),
getCollectionTable(),
getEchoFeatures(),
getProtocolTable(),
getRadarTable(),
getRfClassification(),
getSiteTable(),
getTimeBinsTable(),
getVisibilityTable()
## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) echovalidationTable = getEchoValidationTable(dbConnection) ## End(Not run)## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) echovalidationTable = getEchoValidationTable(dbConnection) ## End(Not run)
Load visibility table from an already connected 'Birdscan MR1' 'SQL' database.
getManualVisibilityTable(dbConnection, dbDriverChar)getManualVisibilityTable(dbConnection, dbDriverChar)
dbConnection |
A valid database connection. |
dbDriverChar |
This was the name of the driver, and is now automatically detected, therefore it should be omitted into the future. |
A data.frame with the manual visibility table.
Baptiste Schmid, Birgen Haest
Other read file functions:
citeDataPackages(),
mergeDataPackages(),
readDataPackageFromZenodo()
## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) manualVisibilityTable = getManualVisibilityTable(dbConnection) ## End(Not run)## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) manualVisibilityTable = getManualVisibilityTable(dbConnection) ## End(Not run)
Load protocol table from an already connected 'Birdscan MR1' 'SQL' database.
getProtocolTable(dbConnection, dbDriverChar)getProtocolTable(dbConnection, dbDriverChar)
dbConnection |
A valid database connection. |
dbDriverChar |
This was the name of the driver, and is now automatically detected, therefore it should be omitted into the future. |
A dataframe with the protocol table
Fabian Hertner, Birgen Haest
Other read SQL database functions:
QUERY(),
dbConnectBirdscanSQL(),
extractDbData(),
getBatClassification(),
getCollectionTable(),
getEchoFeatures(),
getEchoValidationTable(),
getRadarTable(),
getRfClassification(),
getSiteTable(),
getTimeBinsTable(),
getVisibilityTable()
## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) protocolTable = getProtocolTable(dbConnection) ## End(Not run)## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) protocolTable = getProtocolTable(dbConnection) ## End(Not run)
Get the Radar table from an already connected DB and rename the columns appropriately.
getRadarTable(dbConnection, dbDriverChar)getRadarTable(dbConnection, dbDriverChar)
dbConnection |
A valid database connection. |
dbDriverChar |
This was the name of the driver, and is now automatically detected, therefore it should be omitted into the future. |
the radar table as a data frame
Fabian Hertner, Birgen Haest
Other read SQL database functions:
QUERY(),
dbConnectBirdscanSQL(),
extractDbData(),
getBatClassification(),
getCollectionTable(),
getEchoFeatures(),
getEchoValidationTable(),
getProtocolTable(),
getRfClassification(),
getSiteTable(),
getTimeBinsTable(),
getVisibilityTable()
## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) radarTable = getRadarTable(dbConnection) ## End(Not run)## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) radarTable = getRadarTable(dbConnection) ## End(Not run)
Gets the 'rfClasses' table from a 'Birdscan MR1' 'SQL' database.
getRfClassification(dbConnection, dbDriverChar)getRfClassification(dbConnection, dbDriverChar)
dbConnection |
A valid database connection. |
dbDriverChar |
This was the name of the driver, and is now automatically detected, therefore it should be omitted into the future. |
A list containing three variables: (1) rfclassificationTable: The 'rfClassification' database table; (2) classProbabilitiesAndMtrFactors: A dataframe containing the classification probabilities for all classes for each object; and (3) availableClasses: the classes used for the classification of the objects.
Fabian Hertner, Birgen Haest
Other read SQL database functions:
QUERY(),
dbConnectBirdscanSQL(),
extractDbData(),
getBatClassification(),
getCollectionTable(),
getEchoFeatures(),
getEchoValidationTable(),
getProtocolTable(),
getRadarTable(),
getSiteTable(),
getTimeBinsTable(),
getVisibilityTable()
## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) rfClassification = getRfClassification(dbConnection) ## End(Not run)## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) rfClassification = getRfClassification(dbConnection) ## End(Not run)
Load site table from an already connected 'Birdscan MR1' 'SQL' database.
getSiteTable(dbConnection, dbDriverChar)getSiteTable(dbConnection, dbDriverChar)
dbConnection |
A valid database connection. |
dbDriverChar |
This was the name of the driver, and is now automatically detected, therefore it should be omitted into the future. |
A data.frame with the site table
Fabian Hertner, Birgen Haest
Other read SQL database functions:
QUERY(),
dbConnectBirdscanSQL(),
extractDbData(),
getBatClassification(),
getCollectionTable(),
getEchoFeatures(),
getEchoValidationTable(),
getProtocolTable(),
getRadarTable(),
getRfClassification(),
getTimeBinsTable(),
getVisibilityTable()
## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) siteTable <- getSiteTable(dbConnection) ## End(Not run)## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) siteTable <- getSiteTable(dbConnection) ## End(Not run)
Load time bins table from an already connected 'Birdscan MR1' 'SQL' database.
getTimeBinsTable(dbConnection, dbDriverChar)getTimeBinsTable(dbConnection, dbDriverChar)
dbConnection |
A valid database connection. |
dbDriverChar |
This was the name of the driver, and is now automatically detected, therefore it should be omitted into the future. |
A dataframe with the time bins table
Fabian Hertner, Birgen Haest
Other read SQL database functions:
QUERY(),
dbConnectBirdscanSQL(),
extractDbData(),
getBatClassification(),
getCollectionTable(),
getEchoFeatures(),
getEchoValidationTable(),
getProtocolTable(),
getRadarTable(),
getRfClassification(),
getSiteTable(),
getVisibilityTable()
## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) timeBinsTable = getTimeBinsTable(dbConnection) ## End(Not run)## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) timeBinsTable = getTimeBinsTable(dbConnection) ## End(Not run)
Load visibility table from an already connected 'Birdscan MR1' 'SQL' database.
getVisibilityTable(dbConnection, dbDriverChar)getVisibilityTable(dbConnection, dbDriverChar)
dbConnection |
A valid database connection. |
dbDriverChar |
This was the name of the driver, and is now automatically detected, therefore it should be omitted into the future. |
A data.frame with the visibility table.
Fabian Hertner, Birgen Haest
Other read SQL database functions:
QUERY(),
dbConnectBirdscanSQL(),
extractDbData(),
getBatClassification(),
getCollectionTable(),
getEchoFeatures(),
getEchoValidationTable(),
getProtocolTable(),
getRadarTable(),
getRfClassification(),
getSiteTable(),
getTimeBinsTable()
## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) visibilityTable = getVisibilityTable(dbConnection) ## End(Not run)## Not run: # Set server and database settings # ========================================================================== # Using and Microsoft SQL database # ======================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set to "SQL Server" # Using a PostgreSQL # ======================================================================== dbServer = "cloud.birdradar.com" # Set the name or IP of your postgreSQL dbName = "db_Name" # Set the name of your database dbDriverChar = "PostgreSQL" # Set to "PostgreSQL" # Open the connection with the database # ========================================================================== dbConnection = dbConnectBirdscanSQL( dbDriverChar = dbDriverChar, dbServer = dbServer, dbName = dbName, ) visibilityTable = getVisibilityTable(dbConnection) ## End(Not run)
linkCollectionMembers() adds an IsPartOf link to the
concept DOI of a collection record (see uploadCollectionToZenodo()) to each
member of the collection, i.e. to each Zenodo record the collection links to
with HasPart. Members that already have the link are left unchanged.
Use it after publishing a collection, with publish = TRUE, to publish the
links that uploadCollectionToZenodo() added to the members, or to link the
members of an existing collection. Links can only be added to records of
your own Zenodo account; members that cannot be linked are reported in a
warning.
linkCollectionMembers(doi, token = NULL, sandbox = FALSE, publish = FALSE)linkCollectionMembers(doi, token = NULL, sandbox = FALSE, publish = FALSE)
doi |
DOI (e.g. |
token |
Zenodo personal access token with the scopes |
sandbox |
logical. If |
publish |
logical. If |
A data frame, invisibly, with per member: member (Zenodo record
ID), added (number of links added), published (logical) and error
(error message, or NA).
Birgen Haest
Other write file functions:
addZenodoRelatedIdentifiers(),
checkDataPackageMetadata(),
compileData(),
createCollectionMetadataTemplate(),
createDataPackage(),
createDataPackageMetadataTemplate(),
editDataPackageMetadata(),
saveMTR(),
savePlotToFile(),
uploadCollectionToZenodo(),
uploadDataPackageToZenodo(),
validateDataPackage()
## Not run: # Publish the IsPartOf links of the members of a published collection # =========================================================================== linkCollectionMembers( doi = "https://doi.org/10.5281/zenodo.7654321", publish = TRUE ) ## End(Not run)## Not run: # Publish the IsPartOf links of the members of a published collection # =========================================================================== linkCollectionMembers( doi = "https://doi.org/10.5281/zenodo.7654321", publish = TRUE ) ## End(Not run)
Load manual blind times from csv file.
For the MTR computation the times when the radar was blind have to be known.
The radar itself can be blind in case of a protocol change (block time at the
beginning of each protocol, usually 60s) or due to rain/snow or clutter
(nearby objects, leaves or similar on radome, etc.). These times are stored
in the visibility table or in the time_bins table in relation to the time
bins duration (5min). To be flexible and not fixed to the 5 min time bins
created by the radar, the visibility table is used in this script. In
addition to the radar blind times, manual blind times can be defined. Manual
blind times have to be defined in a csv file and are loaded with
loadManualBlindTimes(). An example dataset is available by running:
data(manualBlindTimes)
write.table(manualBlindTimes, file = 'the output file destination', sep = ",", row.names = FALSE, col.names = FALSE)
The file path is defined as a global variable ‘manualBlindTimesFile’. A
custom file and filepath can be used instead. The manual blind times have to
be entered with 3 columns:
start time 'yyyy-mm-dd hh:mm:ss', stop time 'yyyy-MM-dd hh:mm:ss', type.
Example: 2024-09-24 05:00:00,2024-09-24 07:03:30,rain 2024-09-25 15:20:00,2024-09-25 15:34:00,clutter Manual blind time types can be chosen freely. When computing observation times, it can be decided if some of the defined manual blind time types should be treated as observed time with MTR zero or as blind time (e.g. rain). If no file is present or the file is empty, no manual blind times will be computed.
loadManualBlindTimes(filePath, blindTimesTZ, targetTZ)loadManualBlindTimes(filePath, blindTimesTZ, targetTZ)
filePath |
character string, absolute filepath of the manual blind time file |
blindTimesTZ |
time zone of the blind times |
targetTZ |
target time zone of the blind times |
A dataframe with the manual blind times
Fabian Hertner, Birgen Haest
Other sample data:
CH_Sempach_2024_SEP24_25_DataExtract,
classAbbreviations,
manualBlindTimes
# Load manual blind time example data from birdscanR package # =========================================================================== data(manualBlindTimes) # Save example manual blind times to a temporary file # =========================================================================== tmpFile = tempfile(fileext = ".csv") write.table(manualBlindTimes, file = tmpFile, sep = ",", row.names = FALSE, col.names = FALSE ) # Read the manual blind times from file # =========================================================================== manualBlindTimes.new = loadManualBlindTimes( filePath = tmpFile, blindTimesTZ = "Etc/GMT0", targetTZ = "Etc/GMT0" )# Load manual blind time example data from birdscanR package # =========================================================================== data(manualBlindTimes) # Save example manual blind times to a temporary file # =========================================================================== tmpFile = tempfile(fileext = ".csv") write.table(manualBlindTimes, file = tmpFile, sep = ",", row.names = FALSE, col.names = FALSE ) # Read the manual blind times from file # =========================================================================== manualBlindTimes.new = loadManualBlindTimes( filePath = tmpFile, blindTimesTZ = "Etc/GMT0", targetTZ = "Etc/GMT0" )
To create your own manual blind times file, just copy this file, and adjust.
The example blind times (rain, a technical outage and clutter) fall within
the period of the sample data extract
CH_Sempach_2024_SEP24_25_DataExtract.rds (24-25 September 2024), so they
can be used together in examples.
data(manualBlindTimes)data(manualBlindTimes)
A data.frame with one row per blind time and three character
columns without header names: start and stop of the blind time (format
"%Y-%m-%d %H:%M:%S"), and the type of blind time. Write it to a csv file
without row and column names, and load it with loadManualBlindTimes().
Other sample data:
CH_Sempach_2024_SEP24_25_DataExtract,
classAbbreviations,
loadManualBlindTimes()
data(manualBlindTimes)data(manualBlindTimes)
mergeDataPackages() merges MR1 data packages of several
campaigns, e.g. read with readDataPackageFromZenodo() or created with
createDataPackage(), into one data package. Each resource (echo_data,
protocol_data, blind_times, sunrise_sunset, site_data) holds the
rows of all campaigns, with the campaign in the first column, campaignID.
IDs such as echo and protocolID are only unique within a campaign, so
they are kept as they are, and the primary and foreign keys of the merged
package include campaignID. Columns that are missing in some packages are
filled with NA.
The merged package keeps the metadata of each campaign in the property
mr1dp:campaigns (title, version, DOI, owner, licences, embargo, period,
site, suggested citation and Zenodo information), and lists the packages as
sources. Contributors, licences and keywords are combined; contributors
with the same ORCID (or name) are listed once. Use citeDataPackages() to
cite the merged data.
A merged package is meant for analysis, not for publication:
validateDataPackage() checks packages of single campaigns. Write it to disk
with frictionless::write_package() if needed.
mergeDataPackages(packages)mergeDataPackages(packages)
packages |
list of MR1 data packages (class |
A data package (class mr1dp and datapackage) with the merged
resources as data frames. Read a resource with
frictionless::read_resource().
Birgen Haest
Other read file functions:
citeDataPackages(),
getManualVisibilityTable(),
readDataPackageFromZenodo()
# Create two data packages of the example data (two days, as if they were # two campaigns) # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) metadata = yaml::read_yaml(system.file("extdata", "dataPackage", "metadataTemplate.yaml", package = "birdscanR" )) day1 = createDataPackage(dbData, metadata = utils::modifyList(metadata, list(campaignID = "CH_Sempach_2024_day1")), timeRangeTargetTZ = c("2024-09-24 00:00", "2024-09-24 23:59") ) day2 = createDataPackage(dbData, metadata = utils::modifyList(metadata, list(campaignID = "CH_Sempach_2024_day2")), timeRangeTargetTZ = c("2024-09-25 00:00", "2024-09-25 23:59") ) # Merge them # =========================================================================== merged = mergeDataPackages(list(day1, day2)) echoData = frictionless::read_resource(merged, "echo_data") table(echoData$campaignID)# Create two data packages of the example data (two days, as if they were # two campaigns) # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) metadata = yaml::read_yaml(system.file("extdata", "dataPackage", "metadataTemplate.yaml", package = "birdscanR" )) day1 = createDataPackage(dbData, metadata = utils::modifyList(metadata, list(campaignID = "CH_Sempach_2024_day1")), timeRangeTargetTZ = c("2024-09-24 00:00", "2024-09-24 23:59") ) day2 = createDataPackage(dbData, metadata = utils::modifyList(metadata, list(campaignID = "CH_Sempach_2024_day2")), timeRangeTargetTZ = c("2024-09-25 00:00", "2024-09-25 23:59") ) # Merge them # =========================================================================== merged = mergeDataPackages(list(day1, day2)) echoData = frictionless::read_resource(merged, "echo_data") table(echoData$campaignID)
Function to merge manual blind times with blind times from
visibility table. For further processing the radar (visibility) and manual
blind times have to be merged with
mergeVisibilityAndManualBlindTimes(). This function will add a blind time
type to the radar/visibility blind times. Blind times during the block time
(usually 60s) at the beginning of each protocol are given the type
'protocolChange', the rest of the radar blind times are given the type
“visibility”. After that the visibility and manual blind times will be
merged. In case manual blind times and radar blind times are overlapping,
radar blind times with type “visibility” will be overwritten, but not radar
blind times with type “protocolChange”.
mergeVisibilityAndManualBlindTimes( visibilityData, manualBlindTimes = NULL, protocolData )mergeVisibilityAndManualBlindTimes( visibilityData, manualBlindTimes = NULL, protocolData )
visibilityData |
dataframe with the visibility data from the data list
created by |
manualBlindTimes |
dataframe with the manual blind times created by the function ‘loadManualBlindTimes’. |
protocolData |
dataframe with the protocol data from the data list
created by |
dataframe with overall blind times
Fabian Hertner, Birgen Haest, Baptiste Schmid
Other manipulation functions:
addDayNightInfoPerEcho(),
computeDensity(),
computeMTR(),
convertTimeZone(),
createVPTS(),
filterSpeedFeature37(),
reclassToBats(),
twilight()
# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) # Get manual blind times # =========================================================================== data(manualBlindTimes) tmpFile = tempfile(fileext = ".csv") write.table(manualBlindTimes, file = tmpFile, sep = ",", row.names = FALSE, col.names = FALSE ) cManualBlindTimes = loadManualBlindTimes( filePath = tmpFile, blindTimesTZ = "Etc/GMT0", targetTZ = "Etc/GMT0" ) # Merge manual and automatic blind times # =========================================================================== blindTimes = mergeVisibilityAndManualBlindTimes( visibilityData = dbData$visibilityData, manualBlindTimes = cManualBlindTimes, protocolData = dbData$protocolData )# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) # Get manual blind times # =========================================================================== data(manualBlindTimes) tmpFile = tempfile(fileext = ".csv") write.table(manualBlindTimes, file = tmpFile, sep = ",", row.names = FALSE, col.names = FALSE ) cManualBlindTimes = loadManualBlindTimes( filePath = tmpFile, blindTimesTZ = "Etc/GMT0", targetTZ = "Etc/GMT0" ) # Merge manual and automatic blind times # =========================================================================== blindTimes = mergeVisibilityAndManualBlindTimes( visibilityData = dbData$visibilityData, manualBlindTimes = cManualBlindTimes, protocolData = dbData$protocolData )
This function creates a time series plot showing all of the observed echoes at their respective altitudes. These plots are helpful to roughly visually explore your data (and for example spot oddities).
plotExploration( echoData = NULL, timeRange = NULL, targetTimeZone = "Etc/GMT0", manualBlindTimes = NULL, visibilityData = NULL, protocolData = NULL, sunriseSunset = NULL, maxAltitude = NULL, filePath = NULL )plotExploration( echoData = NULL, timeRange = NULL, targetTimeZone = "Etc/GMT0", manualBlindTimes = NULL, visibilityData = NULL, protocolData = NULL, sunriseSunset = NULL, maxAltitude = NULL, filePath = NULL )
echoData |
dataframe with the echo data from the data list created by
|
timeRange |
optional list of string vectors length 2, start and end time of the time ranges that should be plotted. The date/time format is “yyyy-MM-dd hh:mm”. If not set, all echo data is plotted in one plot. Note: Too long time-ranges may produce an error if the created image is too large and the function can’t allocate the file. |
targetTimeZone |
"Etc/GMT0" String specifying the target time zone. Default is "Etc/GMT0". |
manualBlindTimes |
optional dataframe with the manual blind times
created by |
visibilityData |
optional dataframe with the visibility data created by
|
protocolData |
optional dataframe with the protocol data used to filter
the echoes, created by |
sunriseSunset |
optional dataframe with sunrise/sunset, civil, and nautical
twilight times created by |
maxAltitude |
optional numeric, fixes the maximum value of the y-Scale of the plot to the given value. If negative or not set, the y-Scale is auto-scaled. |
filePath |
character string, path of the directory where the plot
should be saved. |
png files stored in the directory specified in 'filePath'
Fabian Hertner, Birgen Haest
Other plot functions:
createTimeRangeForPlot(),
plotLongitudinalMTR()
# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) # Set manual blind times to NULL (no manual blind times) # =========================================================================== cManualBlindTimes = NULL # Make Plot # =========================================================================== timeRangePlot = list( c("2024-09-24 00:00", "2024-09-24 23:59"), c("2024-09-25 00:00", "2024-09-25 23:59") ) plotExploration( echoData = dbData$echoData, timeRange = timeRangePlot, targetTimeZone = "Etc/GMT0", manualBlindTimes = cManualBlindTimes, visibilityData = dbData$visibilityData, protocolData = dbData$protocolData, sunriseSunset = dbData$sunriseSunset, maxAltitude = -1, filePath = tempdir() )# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) # Set manual blind times to NULL (no manual blind times) # =========================================================================== cManualBlindTimes = NULL # Make Plot # =========================================================================== timeRangePlot = list( c("2024-09-24 00:00", "2024-09-24 23:59"), c("2024-09-25 00:00", "2024-09-25 23:59") ) plotExploration( echoData = dbData$echoData, timeRange = timeRangePlot, targetTimeZone = "Etc/GMT0", manualBlindTimes = cManualBlindTimes, visibilityData = dbData$visibilityData, protocolData = dbData$protocolData, sunriseSunset = dbData$sunriseSunset, maxAltitude = -1, filePath = tempdir() )
Plots a time series of MTR values as a bar plot. For each bar the spread (first and third Quartile) is shown as error bars as well as the numbers of echoes. Periods with no observation are indicated with grey, negative bars.
plotLongitudinalMTR( mtr, maxMTR, timeRange = NULL, targetTimeZone = "Etc/GMT0", plotClass = "allClasses", propObsTimeCutoff = 0.2, plotSpread = TRUE, filePath = NULL )plotLongitudinalMTR( mtr, maxMTR, timeRange = NULL, targetTimeZone = "Etc/GMT0", plotClass = "allClasses", propObsTimeCutoff = 0.2, plotSpread = TRUE, filePath = NULL )
mtr |
data frame with MTR values created by |
maxMTR |
optional numeric variable, fixes the maximum value of the y-Scale of the plot to the given value. If negative or not set, the y-Scale is auto-scaled. |
timeRange |
optional list of string vectors length 2, start and end time of the time ranges that should be plotted. The date/time format is “yyyy-MM-dd hh:mm”. |
targetTimeZone |
"Etc/GMT0" String specifying the target time zone. Default is "Etc/GMT0". |
plotClass |
character string with the class of which the MTR data should be plotted. If not set or set to “allClasses”, MTR of all classes will be plotted. |
propObsTimeCutoff |
numeric between 0 and 1. If the MTR is computed per day and night, time bins with a proportional observation time smaller than propObsTimeCutoff are ignored when combining the time bins. If the MTR is computed for each time bin, the parameter is ignored. |
plotSpread |
logical, choose if the spread (first and third quartile) should be plotted. |
filePath |
character string, path of the directory where the plot
should be saved. |
png files stored in the directory specified with 'filePath'
Fabian Hertner, Birgen Haest
Other plot functions:
createTimeRangeForPlot(),
plotExploration()
# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) dbName = "CH_Sempach_2024_SEP24_25" targetTimeZone = "Etc/GMT0" timeRangeData = c("2024-09-24 00:00", "2024-09-25 23:59") # Set manual blind times to NULL (no manual blind times) # =========================================================================== cManualBlindTimes = NULL # Compute migration traffic rate # =========================================================================== classSelection.mtr = c("passerine_type") mtrData = computeMTR( dbName = dbName, echoes = dbData$echoData, classSelection = classSelection.mtr, altitudeRange = c(25, 1025), altitudeBinSize = 50, timeRange = timeRangeData, timeBinDuration_sec = 1800, timeZone = targetTimeZone, sunriseSunset = dbData$sunriseSunset, sunOrCivil = "civil", protocolData = dbData$protocolData, visibilityData = dbData$visibilityData, manualBlindTimes = cManualBlindTimes, saveBlindTimes = FALSE, blindTimesOutputDir = getwd(), blindTimeAsMtrZero = NULL, propObsTimeCutoff = 0, computePerDayNight = FALSE, computeAltitudeDistribution = TRUE ) # Make Plot # =========================================================================== timeRangePlot = list( c("2024-09-24 00:00", "2024-09-24 23:59"), c("2024-09-25 00:00", "2024-09-25 23:59") ) plotLongitudinalMTR( mtr = mtrData, maxMTR = -1, timeRange = timeRangePlot, targetTimeZone = "Etc/GMT0", plotClass = "allClasses", propObsTimeCutoff = 0.2, plotSpread = TRUE, filePath = tempdir() )# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) dbName = "CH_Sempach_2024_SEP24_25" targetTimeZone = "Etc/GMT0" timeRangeData = c("2024-09-24 00:00", "2024-09-25 23:59") # Set manual blind times to NULL (no manual blind times) # =========================================================================== cManualBlindTimes = NULL # Compute migration traffic rate # =========================================================================== classSelection.mtr = c("passerine_type") mtrData = computeMTR( dbName = dbName, echoes = dbData$echoData, classSelection = classSelection.mtr, altitudeRange = c(25, 1025), altitudeBinSize = 50, timeRange = timeRangeData, timeBinDuration_sec = 1800, timeZone = targetTimeZone, sunriseSunset = dbData$sunriseSunset, sunOrCivil = "civil", protocolData = dbData$protocolData, visibilityData = dbData$visibilityData, manualBlindTimes = cManualBlindTimes, saveBlindTimes = FALSE, blindTimesOutputDir = getwd(), blindTimeAsMtrZero = NULL, propObsTimeCutoff = 0, computePerDayNight = FALSE, computeAltitudeDistribution = TRUE ) # Make Plot # =========================================================================== timeRangePlot = list( c("2024-09-24 00:00", "2024-09-24 23:59"), c("2024-09-25 00:00", "2024-09-25 23:59") ) plotLongitudinalMTR( mtr = mtrData, maxMTR = -1, timeRange = timeRangePlot, targetTimeZone = "Etc/GMT0", plotClass = "allClasses", propObsTimeCutoff = 0.2, plotSpread = TRUE, filePath = tempdir() )
Run an 'SQL' query on an already connected database.
QUERY(dbConnection, dbDriverChar, query, as.is = FALSE)QUERY(dbConnection, dbDriverChar, query, as.is = FALSE)
dbConnection |
A valid database connection. |
dbDriverChar |
This was the name of the driver, and is now automatically detected, therefore it should be omitted into the future. |
query |
an 'SQL' string with your query |
as.is |
If TRUE, leaves data as it is |
the result of the query
Fabian Hertner, Birgen Haest
Other read SQL database functions:
dbConnectBirdscanSQL(),
extractDbData(),
getBatClassification(),
getCollectionTable(),
getEchoFeatures(),
getEchoValidationTable(),
getProtocolTable(),
getRadarTable(),
getRfClassification(),
getSiteTable(),
getTimeBinsTable(),
getVisibilityTable()
## Not run: # Set server and database settings # =========================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set either "SQL Server" or "PostgreSQL" # Open the connection with the database # =========================================================================== dsn = paste0( "driver=", dbDriverChar, ";server=", dbServer, ";database=", dbName, ";uid=", rstudioapi::askForPassword("Database user"), ";pwd=", rstudioapi::askForPassword("Database password") ) dbConnection = RODBC::odbcDriverConnect(dsn) QUERY( dbConnection = dbConnection, query = "Select * From collection order by row asc" ) ## End(Not run)## Not run: # Set server and database settings # =========================================================================== dbServer = "MACHINE\\SERVERNAME" # Set the name of your SQL server dbName = "db_Name" # Set the name of your database dbDriverChar = "SQL Server" # Set either "SQL Server" or "PostgreSQL" # Open the connection with the database # =========================================================================== dsn = paste0( "driver=", dbDriverChar, ";server=", dbServer, ";database=", dbName, ";uid=", rstudioapi::askForPassword("Database user"), ";pwd=", rstudioapi::askForPassword("Database password") ) dbConnection = RODBC::odbcDriverConnect(dsn) QUERY( dbConnection = dbConnection, query = "Select * From collection order by row asc" ) ## End(Not run)
readDataPackageFromZenodo() downloads one or more MR1 data
packages from Zenodo and reads them as Frictionless
Data Packages, as created by createDataPackage(). Give the DOI of:
a data package (campaign). A version DOI reads that version; the concept DOI reads the latest version;
a collection (see uploadCollectionToZenodo()): all its members are
read, i.e. the latest version of each campaign of an owner collection, or
of each campaign of each owner collection of the community collection.
The files are downloaded to outputDirPath, in one folder per Zenodo
record. Files that were already downloaded (same checksum) are not
downloaded again. Each package gets the property mr1dp:zenodo, with the
DOI, concept DOI, version and the collections (isPartOf) of its Zenodo
record. citeDataPackages() uses these to cite the data.
With several packages, merge = TRUE (default) merges them into one data
package with mergeDataPackages(); merge = FALSE returns a list of
separate packages.
Data files under embargo cannot be downloaded, except by the owner of the record (with their token). These records are skipped with a warning that shows the end of the embargo and the contact person(s) for data requests.
readDataPackageFromZenodo( doi, outputDirPath = file.path(tempdir(), "birdscanR_zenodo"), merge = TRUE, sandbox = FALSE, token = NULL, overwrite = FALSE )readDataPackageFromZenodo( doi, outputDirPath = file.path(tempdir(), "birdscanR_zenodo"), merge = TRUE, sandbox = FALSE, token = NULL, overwrite = FALSE )
doi |
Character vector with the DOIs (e.g.
|
outputDirPath |
Directory to download the files to. Default is a
folder |
merge |
logical. If |
sandbox |
logical. If |
token |
Zenodo personal access token, only needed to download files of
your own records under embargo. Default is the environment variable
|
overwrite |
logical. If |
One data package (class mr1dp and datapackage) if one package
is read or merge = TRUE; otherwise a named list of data packages. Read a
resource as a data frame with frictionless::read_resource().
Birgen Haest
Other read file functions:
citeDataPackages(),
getManualVisibilityTable(),
mergeDataPackages()
## Not run: # Read a data package from Zenodo # =========================================================================== dataPackage = readDataPackageFromZenodo( doi = "https://doi.org/10.5281/zenodo.1234567", outputDirPath = file.path(".", "zenodo") ) echoData = frictionless::read_resource(dataPackage, "echo_data") # Read all campaigns of a collection, as separate packages # =========================================================================== dataPackages = readDataPackageFromZenodo( doi = "https://doi.org/10.5281/zenodo.7654321", merge = FALSE ) # Cite the data # =========================================================================== citeDataPackages(dataPackages) ## End(Not run)## Not run: # Read a data package from Zenodo # =========================================================================== dataPackage = readDataPackageFromZenodo( doi = "https://doi.org/10.5281/zenodo.1234567", outputDirPath = file.path(".", "zenodo") ) echoData = frictionless::read_resource(dataPackage, "echo_data") # Read all campaigns of a collection, as separate packages # =========================================================================== dataPackages = readDataPackageFromZenodo( doi = "https://doi.org/10.5281/zenodo.7654321", merge = FALSE ) # Cite the data # =========================================================================== citeDataPackages(dataPackages) ## End(Not run)
Reclassifies echoes based on bat classification.
reclassToBats( echoData = NULL, batProbabilitiesAndMtrFactors = NULL, reclassToBatCutoff = -1 )reclassToBats( echoData = NULL, batProbabilitiesAndMtrFactors = NULL, reclassToBatCutoff = -1 )
echoData |
echodata dataframe, output from extractDbData |
batProbabilitiesAndMtrFactors |
probabilities of bat classification, output from extractDbData' |
reclassToBatCutoff |
Threshold (0..1), classification of echoes with bat probability higher than reclassToBatCutoff will be set to 'bat' |
echoData dataframe
Fabian Hertner
Other manipulation functions:
addDayNightInfoPerEcho(),
computeDensity(),
computeMTR(),
convertTimeZone(),
createVPTS(),
filterSpeedFeature37(),
mergeVisibilityAndManualBlindTimes(),
twilight()
# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) # Reclass To Bats # =========================================================================== dbData$echoData = reclassToBats( echoData = dbData$echoData, batProbabilitiesAndMtrFactors = dbData$batProbabilitiesAndMtrFactors, reclassToBatCutoff = 0.5 )# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) # Reclass To Bats # =========================================================================== dbData$echoData = reclassToBats( echoData = dbData$echoData, batProbabilitiesAndMtrFactors = dbData$batProbabilitiesAndMtrFactors, reclassToBatCutoff = 0.5 )
Saves MTR data to a .rds file in the directory filepath.
If the directory is not existing it will be created if possible.
saveMTR( mtr, filepath, fileName = NULL, fileNamePrefix = NULL, dbName = NULL, rotSelection = NULL, pulseTypeSelection = NULL, classAbbreviations = NULL )saveMTR( mtr, filepath, fileName = NULL, fileNamePrefix = NULL, dbName = NULL, rotSelection = NULL, pulseTypeSelection = NULL, classAbbreviations = NULL )
mtr |
dataframe with MTR values created by |
filepath |
character string, path of the directory. If the directory does not exist it will be created if possible. |
fileName |
Filename (string) for the file. If not set, the filename will be built using the input of the variables 'filenamePrefix', 'dbName', 'classAbbreviations', and other info in the 'mtr' data. If set, overrides the automatic filename creation. |
fileNamePrefix |
prefix of the filename (string). If not set, "mtr" is used. Different information about the MTR data will be appended to the filename. |
dbName |
character string, name of the database. Used to create the filename, if 'fileName' is not provided. |
rotSelection |
numeric vector, rotation selection which was used to filter protocols. Used to create the filename, if 'fileName' is not provided. If not set, the rotation selection will not be appended to the filename. |
pulseTypeSelection |
character vector, pulse type selection which was used to filter protocols. Used to create the filename, if 'fileName' is not provided. If not set, the pulse type selection will not be appended to the filename. |
classAbbreviations |
Two-column dataframe with character first column named 'class' and character second 'abbr', containing the full names of the classes and their abbreviations to use in the output filename. Default = NULL, meaning the abbreviations will be used that are stored in the package; See data(classAbbreviations). Used to create the filename, if 'fileName' is not provided. |
No return value, used to save MTR to file.
Fabian Hertner, Birgen Haest
Other write file functions:
addZenodoRelatedIdentifiers(),
checkDataPackageMetadata(),
compileData(),
createCollectionMetadataTemplate(),
createDataPackage(),
createDataPackageMetadataTemplate(),
editDataPackageMetadata(),
linkCollectionMembers(),
savePlotToFile(),
uploadCollectionToZenodo(),
uploadDataPackageToZenodo(),
validateDataPackage()
# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) dbName = "CH_Sempach_2024_SEP24_25" mainOutputDir = tempdir() targetTimeZone = "Etc/GMT0" timeRangeData = c("2024-09-24 00:00", "2024-09-25 23:59") # Set manual blind times to NULL (no manual blind times) # =========================================================================== cManualBlindTimes = NULL # Compute migration traffic rate # =========================================================================== classSelection.mtr = c("passerine_type") mtrData = computeMTR( dbName = dbName, echoes = dbData$echoData, classSelection = classSelection.mtr, altitudeRange = c(25, 1025), altitudeBinSize = 50, timeRange = timeRangeData, timeBinDuration_sec = 1800, timeZone = targetTimeZone, sunriseSunset = dbData$sunriseSunset, sunOrCivil = "civil", protocolData = dbData$protocolData, visibilityData = dbData$visibilityData, manualBlindTimes = cManualBlindTimes, saveBlindTimes = FALSE, blindTimesOutputDir = mainOutputDir, blindTimeAsMtrZero = NULL, propObsTimeCutoff = 0, computePerDayNight = FALSE, computeAltitudeDistribution = TRUE ) # Save the MTR data to file # =========================================================================== saveMTR( mtr = mtrData, filepath = mainOutputDir, dbName = dbName )# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) dbName = "CH_Sempach_2024_SEP24_25" mainOutputDir = tempdir() targetTimeZone = "Etc/GMT0" timeRangeData = c("2024-09-24 00:00", "2024-09-25 23:59") # Set manual blind times to NULL (no manual blind times) # =========================================================================== cManualBlindTimes = NULL # Compute migration traffic rate # =========================================================================== classSelection.mtr = c("passerine_type") mtrData = computeMTR( dbName = dbName, echoes = dbData$echoData, classSelection = classSelection.mtr, altitudeRange = c(25, 1025), altitudeBinSize = 50, timeRange = timeRangeData, timeBinDuration_sec = 1800, timeZone = targetTimeZone, sunriseSunset = dbData$sunriseSunset, sunOrCivil = "civil", protocolData = dbData$protocolData, visibilityData = dbData$visibilityData, manualBlindTimes = cManualBlindTimes, saveBlindTimes = FALSE, blindTimesOutputDir = mainOutputDir, blindTimeAsMtrZero = NULL, propObsTimeCutoff = 0, computePerDayNight = FALSE, computeAltitudeDistribution = TRUE ) # Save the MTR data to file # =========================================================================== saveMTR( mtr = mtrData, filepath = mainOutputDir, dbName = dbName )
Saves created plots as .png.
savePlotToFile( plot = NULL, filePath = NULL, plotType = NULL, plotWidth_mm = NULL, plotHeight_mm = NULL, timeRange = NULL, classSelection = NULL, altitudeRange = NULL, classAbbreviations = NULL )savePlotToFile( plot = NULL, filePath = NULL, plotType = NULL, plotWidth_mm = NULL, plotHeight_mm = NULL, timeRange = NULL, classSelection = NULL, altitudeRange = NULL, classAbbreviations = NULL )
plot |
'ggplot' plot to be saved |
filePath |
character string, path of the directory, e.g. "your-project-directory/Data/MTR". If the directory does not exist it will be created if possible. |
plotType |
character string, name/description of the plot, used to create the filename. If not set, the pulse type selection will not be appended to the filename |
plotWidth_mm |
numeric, width of the plot in mm. If not set, the size of the png will be set automatically. |
plotHeight_mm |
numeric, height of the plot in mm. If not set, the size of the png will be set automatically. |
timeRange |
POSIXct vector of size 2, time range of the plot, used to create the filename. If not set, the pulse type selection will not be appended to the filename |
classSelection |
character string vector, classes that were used to create the plot, used to create the filename. If not set, the pulse type selection will not be appended to the filename |
altitudeRange |
numeric vector of size 2, altitude range used to create the plot, used to create the filename. If not set, the pulse type selection will not be appended to the filename |
classAbbreviations |
Two-column dataframe with character first column named 'class' and character second 'abbr', containing the full names of the classes and their abbreviations to use in the output filename. Default = NULL, meaning the abbreviations will be used that are stored in the package; See data(classAbbreviations). |
No return value, used to save plots to file.
Fabian Hertner, Birgen Haest
Other write file functions:
addZenodoRelatedIdentifiers(),
checkDataPackageMetadata(),
compileData(),
createCollectionMetadataTemplate(),
createDataPackage(),
createDataPackageMetadataTemplate(),
editDataPackageMetadata(),
linkCollectionMembers(),
saveMTR(),
uploadCollectionToZenodo(),
uploadDataPackageToZenodo(),
validateDataPackage()
# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) mainOutputDir = tempdir() # Set manual blind times to NULL (no manual blind times) # =========================================================================== cManualBlindTimes = NULL # Make Plot # =========================================================================== timeRangePlot = list( c("2024-09-24 00:00", "2024-09-24 23:59"), c("2024-09-25 00:00", "2024-09-25 23:59") ) cPlot = plotExploration( echoData = dbData$echoData, timeRange = timeRangePlot, targetTimeZone = "Etc/GMT0", manualBlindTimes = cManualBlindTimes, visibilityData = dbData$visibilityData, protocolData = dbData$protocolData, sunriseSunset = dbData$sunriseSunset, maxAltitude = -1, filePath = mainOutputDir ) # Save plot # =========================================================================== savePlotToFile( plot = cPlot, filePath = mainOutputDir, plotType = "S", plotWidth_mm = 400, plotHeight_mm = 200 )# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) mainOutputDir = tempdir() # Set manual blind times to NULL (no manual blind times) # =========================================================================== cManualBlindTimes = NULL # Make Plot # =========================================================================== timeRangePlot = list( c("2024-09-24 00:00", "2024-09-24 23:59"), c("2024-09-25 00:00", "2024-09-25 23:59") ) cPlot = plotExploration( echoData = dbData$echoData, timeRange = timeRangePlot, targetTimeZone = "Etc/GMT0", manualBlindTimes = cManualBlindTimes, visibilityData = dbData$visibilityData, protocolData = dbData$protocolData, sunriseSunset = dbData$sunriseSunset, maxAltitude = -1, filePath = mainOutputDir ) # Save plot # =========================================================================== savePlotToFile( plot = cPlot, filePath = mainOutputDir, plotType = "S", plotWidth_mm = 400, plotHeight_mm = 200 )
Get the time of nautical (sun at 12 degrees below horizon), civil (sun at 6 degrees below horizon) and solar (sun at 0 degrees below horizon) dawn and dusk for each day over a given time range.
twilight(timeRange, latLon, crs_datum = "WGS84", timeZone)twilight(timeRange, latLon, crs_datum = "WGS84", timeZone)
timeRange |
A two-element character vector with elements of the form %Y-%m-%d defining the start and end of the timerange for which you want to get the twilight information. |
latLon |
A list of X, Y coordinates |
crs_datum |
The coordinate reference system and datum of the X, Y coordinates. Default = "WGS84. |
timeZone |
The time zone of the area of interest |
A data frame with the results
Fabian Hertner, Birgen Haest
Other manipulation functions:
addDayNightInfoPerEcho(),
computeDensity(),
computeMTR(),
convertTimeZone(),
createVPTS(),
filterSpeedFeature37(),
mergeVisibilityAndManualBlindTimes(),
reclassToBats()
sunriseSunset = twilight( timeRange = c("2024-09-24 00:00", "2024-09-25 23:59"), latLon = c(47.12764, 8.192569), timeZone = "Etc/GMT0" )sunriseSunset = twilight( timeRange = c("2024-09-24 00:00", "2024-09-25 23:59"), latLon = c(47.12764, 8.192569), timeZone = "Etc/GMT0" )
uploadCollectionToZenodo() creates a collection record on
Zenodo as a draft: a record with its own DOI that
groups published Zenodo records, so that they can be cited together. There
are two levels of collections:
an owner collection groups the MR1 data packages (campaigns) of one owner, e.g. all campaigns of the Swiss Ornithological Institute;
the community collection groups the owner collections of the BirdScan MR1 community.
The collection is described in a YAML file, see
createCollectionMetadataTemplate(). The collection record:
links to each member with a HasPart related identifier. The links point
to the concept DOI of the member, so they stay valid when a member gets a
new version;
holds the file members.csv, with per member the concept DOI, the DOI,
record ID, title, version and publication date of its latest version, its
period and its Zenodo link, at the time of the upload;
gets the period (Collected) of its members.
With linkMembers = TRUE (default), an IsPartOf link to the concept DOI
of the collection is added to each member, with
addZenodoRelatedIdentifiers(). These edits of the members are not
published, because the collection itself is a draft: first check and
publish the collection on Zenodo, then publish the edits of the members with
linkCollectionMembers() and publish = TRUE (or on Zenodo). Links can
only be added to records of your own Zenodo account; members that cannot be
linked are reported in a warning.
New versions. To add or remove members, add them to the members of the
metadata file, increase version, and set id to the DOI of the published
collection. The upload then creates a new version of the collection record.
The HasPart links follow the new list of members; other related
identifiers of the previous version are kept.
uploadCollectionToZenodo( metadata, token = NULL, sandbox = FALSE, community = "birdscanmr1community", newVersion = NULL, linkMembers = TRUE )uploadCollectionToZenodo( metadata, token = NULL, sandbox = FALSE, community = "birdscanmr1community", newVersion = NULL, linkMembers = TRUE )
metadata |
Path to the YAML file with the collection metadata (see
|
token |
Zenodo personal access token with the scopes |
sandbox |
logical. If |
community |
Identifier of the Zenodo community the record is submitted
to when it is published. Default is |
newVersion |
logical or |
linkMembers |
logical. If |
A list, invisibly, with id (Zenodo record ID of the draft), doi
(reserved DOI), conceptDoi (concept DOI of the collection), url (link to
the draft on Zenodo), members (data frame, the content of members.csv),
links (data frame with the result of linking each member, or NULL) and
newVersion (logical).
Birgen Haest
Other write file functions:
addZenodoRelatedIdentifiers(),
checkDataPackageMetadata(),
compileData(),
createCollectionMetadataTemplate(),
createDataPackage(),
createDataPackageMetadataTemplate(),
editDataPackageMetadata(),
linkCollectionMembers(),
saveMTR(),
savePlotToFile(),
uploadDataPackageToZenodo(),
validateDataPackage()
## Not run: # Describe the collection: fill in the template, with the DOIs of the # published campaign records as members # =========================================================================== metadataFile = file.path(".", "SOI_BirdScanMR1_collection.yaml") createCollectionMetadataTemplate(filePath = metadataFile) # Upload the collection as draft to the Zenodo sandbox # =========================================================================== draft = uploadCollectionToZenodo( metadata = metadataFile, sandbox = TRUE, community = NULL ) draft$members # After publishing the collection on Zenodo: publish the IsPartOf links of # the members # =========================================================================== linkCollectionMembers(doi = draft$doi, sandbox = TRUE, publish = TRUE) ## End(Not run)## Not run: # Describe the collection: fill in the template, with the DOIs of the # published campaign records as members # =========================================================================== metadataFile = file.path(".", "SOI_BirdScanMR1_collection.yaml") createCollectionMetadataTemplate(filePath = metadataFile) # Upload the collection as draft to the Zenodo sandbox # =========================================================================== draft = uploadCollectionToZenodo( metadata = metadataFile, sandbox = TRUE, community = NULL ) draft$members # After publishing the collection on Zenodo: publish the IsPartOf links of # the members # =========================================================================== linkCollectionMembers(doi = draft$doi, sandbox = TRUE, publish = TRUE) ## End(Not run)
uploadDataPackageToZenodo() uploads an MR1 data package,
written to disk by createDataPackage(), to Zenodo as
a draft record: either a new record, or a new version of an existing
record. The function never publishes the record: check the draft on Zenodo
and publish it there.
The package is first checked with validateDataPackage(); an invalid
package is not uploaded. The Zenodo metadata are taken from
datapackage.json:
title, description, version, keywords and related identifiers;
creators: all contributors, with ORCID and affiliation;
contributors: each contributor with each of their roles, and the owner as rights holder;
licence, and the embargo: if the embargo date is in the future, the record
is embargoed (metadata public, files restricted until that date),
otherwise open;
location of the site, and the period of the data (Collected);
the suggested citation, and the contact person(s) for data requests during the embargo, in the description and notes.
A DOI is reserved for the record. It is written as id in the local
datapackage.json (and in the suggested citation) before the files are
uploaded, so the published package carries its own DOI.
New versions. When the data of a published campaign are corrected,
create the package again with a higher version, and with the DOI of the
published record as id in the metadata file. The upload then creates a new
version of that record (with a new DOI) instead of a new record. All versions
share the concept DOI of the record. The files of the previous version are
replaced, and the related identifiers of the previous version that are not
in the package (e.g. IsPartOf links to collections, see
addZenodoRelatedIdentifiers()) are kept.
uploadDataPackageToZenodo( packageDir, token = NULL, sandbox = FALSE, community = "birdscanmr1community", addDoi = TRUE, newVersion = NULL )uploadDataPackageToZenodo( packageDir, token = NULL, sandbox = FALSE, community = "birdscanmr1community", addDoi = TRUE, newVersion = NULL )
packageDir |
Directory of the data package, i.e. the folder with
|
token |
Zenodo personal access token with the scopes |
sandbox |
logical. If |
community |
Identifier of the Zenodo community the record is submitted
to when it is published. Default is |
addDoi |
logical. If |
newVersion |
logical or |
A list, invisibly, with id (Zenodo record ID of the draft), doi
(reserved DOI), url (link to the draft on Zenodo), files (names of the
uploaded files) and newVersion (logical).
Birgen Haest
Other write file functions:
addZenodoRelatedIdentifiers(),
checkDataPackageMetadata(),
compileData(),
createCollectionMetadataTemplate(),
createDataPackage(),
createDataPackageMetadataTemplate(),
editDataPackageMetadata(),
linkCollectionMembers(),
saveMTR(),
savePlotToFile(),
uploadCollectionToZenodo(),
validateDataPackage()
## Not run: # Create the data package (see createDataPackage()) # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) mainOutputDir = file.path(".", "results") metadataFile = file.path(mainOutputDir, "CH_Sempach_2024_metadata.yaml") createDataPackageMetadataTemplate(filePath = metadataFile, overwrite = TRUE) createDataPackage( dbExtract = dbData, metadata = metadataFile, outputDirPath = mainOutputDir ) # Upload the data package as draft to the Zenodo sandbox # =========================================================================== # The token is read from the environment variable ZENODO_SANDBOX_TOKEN, e.g. # set in your .Renviron file draft = uploadDataPackageToZenodo( packageDir = file.path(mainOutputDir, "CH_Sempach_2024"), sandbox = TRUE, community = NULL ) draft$url ## End(Not run)## Not run: # Create the data package (see createDataPackage()) # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) mainOutputDir = file.path(".", "results") metadataFile = file.path(mainOutputDir, "CH_Sempach_2024_metadata.yaml") createDataPackageMetadataTemplate(filePath = metadataFile, overwrite = TRUE) createDataPackage( dbExtract = dbData, metadata = metadataFile, outputDirPath = mainOutputDir ) # Upload the data package as draft to the Zenodo sandbox # =========================================================================== # The token is read from the environment variable ZENODO_SANDBOX_TOKEN, e.g. # set in your .Renviron file draft = uploadDataPackageToZenodo( packageDir = file.path(mainOutputDir, "CH_Sempach_2024"), sandbox = TRUE, community = NULL ) draft$url ## End(Not run)
validateDataPackage() checks whether an MR1 data package,
created by createDataPackage(), is complete and consistent before it is
published, e.g. on Zenodo. It checks:
the package structure (Frictionless Data Package) and the package-level
metadata (the same checks as in createDataPackage(), plus the
properties that createDataPackage() adds automatically);
that all five resources (echo_data, protocol_data, blind_times,
sunrise_sunset, site_data) are present, can be read, and contain
the required columns;
that the column names and types match the Table Schema of each resource, and that every column has a description;
that primary keys are unique and not missing, and that foreign keys
(e.g. protocolID of the echoes) refer to existing rows;
that the content is plausible: start times before stop times, echoes within their measurement period and within the temporal coverage, and site coordinates equal to the spatial coverage.
Problems that make the package unusable or inconsistent are reported as errors; problems that do not, e.g. a column without description, as warnings. A package is valid when there are no errors.
validateDataPackage(package)validateDataPackage(package)
package |
MR1 data package object returned by |
An object of class mr1dpValidation: a list with valid (logical,
TRUE if no errors were found) and issues (data frame with the columns
level ("error" or "warning"), resource, field and message).
Printing it gives a summary of the issues.
Birgen Haest
Other write file functions:
addZenodoRelatedIdentifiers(),
checkDataPackageMetadata(),
compileData(),
createCollectionMetadataTemplate(),
createDataPackage(),
createDataPackageMetadataTemplate(),
editDataPackageMetadata(),
linkCollectionMembers(),
saveMTR(),
savePlotToFile(),
uploadCollectionToZenodo(),
uploadDataPackageToZenodo()
# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) mainOutputDir = tempdir() # Write the package metadata template (fill it in for a real campaign) # =========================================================================== metadataFile = file.path(mainOutputDir, "CH_Sempach_2024_metadata.yaml") createDataPackageMetadataTemplate(filePath = metadataFile, overwrite = TRUE) # Create MR1 data package # =========================================================================== dataPackage = createDataPackage( dbExtract = dbData, metadata = metadataFile, pulseTypeSelection = "S", outputDirPath = mainOutputDir ) # Validate the data package object # =========================================================================== validateDataPackage(dataPackage) # Validate the data package files on disk # =========================================================================== validation = validateDataPackage(file.path(mainOutputDir, "CH_Sempach_2024")) validation$valid# Load example data # =========================================================================== dbData = readRDS(system.file("extdata", "CH_Sempach_2024_SEP24_25_DataExtract.rds", package = "birdscanR" )) mainOutputDir = tempdir() # Write the package metadata template (fill it in for a real campaign) # =========================================================================== metadataFile = file.path(mainOutputDir, "CH_Sempach_2024_metadata.yaml") createDataPackageMetadataTemplate(filePath = metadataFile, overwrite = TRUE) # Create MR1 data package # =========================================================================== dataPackage = createDataPackage( dbExtract = dbData, metadata = metadataFile, pulseTypeSelection = "S", outputDirPath = mainOutputDir ) # Validate the data package object # =========================================================================== validateDataPackage(dataPackage) # Validate the data package files on disk # =========================================================================== validation = validateDataPackage(file.path(mainOutputDir, "CH_Sempach_2024")) validation$valid