Skip to content

Improve PIT tag query at dams #24

@KevinSee

Description

@KevinSee

Based on a suggestion from @tbuehrens, the queryPITtagObs function could be expanded to include more sites (currently only works for Lower Granite). It might be improved by focusing on adult PIT tag detections only, which would involve changing some code from pitall_obs_de to pitadult_obs_de. Here's Thomas's suggested function:

get_unique_adult_dam_observations<-function(years, 
                                            species, #Chinook, Steelhead, Coho, Sockeye
                                            run, #1= spring, 2=summer, 3=fall, 4=winter 5=unknown, Null=all
                                            rear, #W or H or Null = all
                                            dam #B2A = BON
                                            ){
  spp_code = tibble(spp_nm = c('Chinook', 'Coho', 'Steelhead', 'Sockeye'),
                  spp_code = 1:4)  %>%
  filter(spp_nm %in% species) %>%
  pull(spp_code)
  
  results<-tibble()
  baseurl<-"https://www.cbr.washington.edu/dart/cs/php/rpt/pitall_obs_de.php?sc=1&queryName=pitadult_obs_de&outputFormat=csv&year="
  for(y in years){
    for(s in spp_code){
      fullurl=paste0(baseurl,y,"&proj=",dam,"&species=",s,"&run=",run,"&rear_type=",rear,"&span=no&startdate=1%2F1&enddate=12%2F31&syear=",y,"&eyear=",y,"&reltype=alpha&relloc=251&summary=no")
    dat<-readr::read_csv(fullurl)%>%
      filter(!is.na(`Tag ID`))
    results <- bind_rows(results, dat)
    }
  }
  return(results)
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions