Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mismatch between release sites reported and locations (multiple issues) #147

Open
SimonDedman opened this issue Nov 28, 2024 · 6 comments
Open
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@SimonDedman
Copy link

1. Error mismatch release sites and locations

Error: There is a mismatch between the release sites reported and the release locations for the animals.
The following release sites were listed in the biometrics.csv file but are not part of the release sites listed in the spatial.csv file:
GNWR
Please include the missing release sites in the spatial.csv file.

I changed GNWR in the spatial file from "Hydrophone" to "Release" and now it says it's the same as StJaqs (another site).

This error is related to an earlier warning:

2. Warning deployment station not part of study's stations

Warning: The following station is listed in the deployments but is not part of the study's stations: 'StJaqs'

"StJaqs" %in% unique(deployments$Station.name) # TRUE
"StJaqs" %in% unique(spatial$Station.name) # TRUE
"StJaqs" %in% row.names(distances) # TRUE

Ideally Actel could improve the error message for StJaqs to explain it's due to release/hydrophone in spatial csv. Without that info, the user is left hunting around to try to deduce what's causing this.

Do I need to add a duplicate row for StJaqs and GNWR to be release as well as hydrophone?

Another likely related warning:

3. Warning: receivers not part of study stations

Warning: Detections from receivers 104790, 139044, 484731 are present in the data, but these receivers are not part of the study's stations. Double-check potential errors.

104790: in deployments (GNWR) & GNWR in spatial.
139044 = StJaqs, ditto.
484731 = GNWR also.

So again, could it be these are marked as release sites when they should be receivers?

Another likely related warning:

4. Warning: tag detected on receiver not listed in study area

Warning: Tag 9001-57458 was detected in one or more receivers that are not listed in the study area (receiver(s): 139044, 484731)!

StJaqs & GNWR again.

Probably NOT related but just in case. LMK and I'll make this into a separate issue.

5. Stations not present in distances matrix

Warning: Some stations and/or release sites are not present in the distances matrix. Deactivating speed calculations to avoid function failure. Stations missing: 'St.1', [...], 'St.127

Where is it (not) getting these station names from?

Five Rds files here.

Thanks bud!

@hugomflavio hugomflavio added documentation Improvements or additions to documentation enhancement New feature or request labels Dec 3, 2024
@hugomflavio
Copy link
Owner

Hi Simon! Thanks for bringing these up.

I see the source of the confusion. Essentially, you have two stations in the same place with the same name; one is a hydrophone station, the other is a release station (in actel terms). actel is not being very helpful by not checking that there is a hydrophone station with the name of the release site stated in the biometrics; in which case it could give a more useful error message (instructing the user to duplicate the line so there's a "hydrophone" and a "release" station).

It would probably also be helpful to call it "release stations" instead of "release sites" in your point 1.

Warning 2 could be improved by saying "study's hydrophone stations" instead of just "study's stations".

Warning 3 could be improved to say that the receivers were deployed at hydrophone stations that are not listed in the spatial input.

For both warnings, it could check if those station names exist as release stations, and provide an extra line with more guidance (essentially telling the user to make two identical stations, one for the hydrophone and another for the release).

Warning 4 is a consequence of the above.

The last is a separate issue. This distances matrix is not correctly formatted for actel. How was it made?

Thanks!

@SimonDedman
Copy link
Author

SimonDedman commented Dec 3, 2024

Cheers for the reply bud. Ongoing fixing attempts:

1/2/3/4

Station log / spatial: GNWR & St Jaques changed to hydrophone. Deep ledge & Jupiter are release only.

Error: The following release sites were listed in the biometrics.csv file but are not part of the release sites listed in the spatial.csv file: GNWR. Please include the missing release sites in the spatial.csv file.

GNWR is in spatial.csv, it's a release site but also a hydrophone. I added another row in spatial.csv to duplicate GNWR and mark it as Release, given the existing row was Hydrophone, and that seemed to solve issue 1.

Kinda: the dupe is then propagated to distances so needs to be removed there and elsewhere.

Error: The 'Station.name' column in the spatial input must not have duplicated values. Stations appearing more than once: GNWR

So: not sure how to proceed. Duplicate station to be both release and hydrophone in spatial.csv fixes the mismatch between release sites and locations, but causes a station.name dupe.

5. Stations not present in distances matrix

This distances matrix is not correctly formatted for actel. How was it made?

install.packages("gbm.auto")
library(gbm.auto)
gbm.auto::gbm.basemap(bounds = c(min(spatial$Longitude),
                                 max(spatial$Longitude),
                                 min(spatial$Latitude),
                                 max(spatial$Latitude)),
                      savedir = file.path(loadloc, "actel", "NOAAcoastlines"),
                      getzip = file.path(loadloc, "actel", "NOAAcoastlines"),
                      extrabounds = FALSE)
# install.packages("gdistance")
base.raster <- actel::shapeToRaster(shape = file.path(loadloc, "actel", "NOAAcoastlines", "CroppedMap", "Crop_Map.shp"),
                                    size = 0.01, # of the raster pixels in metres (or possibly 100km's)
                                    spatial = spatial, # " character string specifying the path to a spatial.csv file or a spatial data frame
                                    coord.x = "Longitude", # names of the columns containing the x and y coordinates
                                    coord.y = "Latitude",
                                    buffer = NULL) # request an expansion of the shapefile limits
t.layer <- actel::transitionLayer(base.raster, directions = 16)
distances <- actel::distancesMatrix(
  t.layer = t.layer,
  starters = spatial,
  targets = spatial,
  coord.x = "Longitude",
  coord.y = "Latitude",
  # id.col = "Station.name",
  actel = FALSE
)
# Colnames & rownames don't match due to Xs, remove GNWR dupe & rename:
duperowremove <- max(which(spatial$Station.name == "GNWR"), na.rm = TRUE)
distances <- distances[-duperowremove,] # remove column
distances <- distances[,-duperowremove] # remove row
colnames(distances) <- unique(spatial$Station.name)
rownames(distances) <- unique(spatial$Station.name)

@hugomflavio
Copy link
Owner

For the duplicate: could you simply change the names slightly? I'll look into being able to have hydrophones and releases with the same name; I'm not sure if that would break anything or not.

For the distances: the actel = false argument is the issue. @dsmith-unbc what is the status on the distanceMatrix updates you were working on? I think they would solve this by letting Simon use the starter argument while actel = true. If there's something I should be doing on that front and I forgot, let me know 😄

@SimonDedman
Copy link
Author

Error: The following release sites were listed in the biometrics.csv file but are not part of the release sites listed in the spatial.csv file: GNWR. Please include the missing release sites in the spatial.csv file.

Ok, have now changed the name of the hydrophone in spatial.csv

Warning: The following station is listed in the deployments but is not part of the study's stations: 'GNWR'
Discarding deployments at unknown stations.
Error: The following station is listed in the spatial file but no receivers were ever deployed there: 'GNWRhy'

Edited name in Deployments: SOLVED, after much wrangling.

Ok it's now running. For the hydrophone/releases issue, what if you added the ability for users to tag Type=Both in the spatial file, and then have actel deal with this in the backend?

Distances

where are the "St.1" station names coming from? Until this point it seems like everything is contained in the 5 files, but St.1 isn't anywhere...

@dsmith-unbc
Copy link
Collaborator

Hi @hugomflavio , thanks for the reminder.

I should be able to get the distanceMatrix updated code pushed by Friday.

I don't think there is anything you need to do, I just need to find more time in my days 😩 .

Cheers,

@SimonDedman
Copy link
Author

Solved by manually creating duplicate rows in releases to account for sharks being released at locations with hydrophones. Leaving this open for the documentation actionables. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants