Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://doi.org/10.5281/zenodo.14318846
17 December 2024, 12:45:03 UTC
  • Code
  • Branches (0)
  • Releases (1)
  • Visits
    • Branches
    • Releases
      • 1
      • 1
    • c8b2287
    • /
    • combining-hmm-and-ssf-code
    • /
    • scripts
    • /
    • 03 - filter for max nsd above 40.R
    Raw File Download

    To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
    Select below a type of object currently browsed in order to display its associated SWHID and permalink.

    • content
    • directory
    • snapshot
    • release
    origin badgecontent badge
    swh:1:cnt:33fc015caced6000006ddcdba2ca737b4254c272
    origin badgedirectory badge
    swh:1:dir:30ac199afd3b1d7a0d0bdca02408cfa6e4b4363a
    origin badgesnapshot badge
    swh:1:snp:05a2af42b588522ca08f036c1f785d8457dcf25e
    origin badgerelease badge
    swh:1:rel:aa35d9e39d94cbf3f73362c2c2b5cd04c355e955

    This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
    Select below a type of object currently browsed in order to generate citations for them.

    • content
    • directory
    • snapshot
    • release
    Generate software citation in BibTex format (requires biblatex-software package)
    Generating citation ...
    Generate software citation in BibTex format (requires biblatex-software package)
    Generating citation ...
    Generate software citation in BibTex format (requires biblatex-software package)
    Generating citation ...
    Generate software citation in BibTex format (requires biblatex-software package)
    Generating citation ...
    03 - filter for max nsd above 40.R
    #
    #
    #currently set to only add tod and filter for date/min spm
    #
    #
    rm(list=ls())
    
    #packages
    library(dplyr)
    library(ggplot2)
    library(sp)
    library(maptools)
    
    #file list
    file_list <- list.files("data/find ladder/SSF data with tod filtered for migration and min spm over 2/",full.names=T)
    #keep only tracks where max_nsd >40
    
    
    #get list of Good track ids and fish
    
    #need to do filtering in track_straightness as well to get Same Tracks
    
    for(p in 1:length(file_list)){ 
      data <-  read.csv(file_list[[p]])
      
      id <- data$fish_id[1]
      
      data$t1_ <- as.POSIXct(data$t1_)
      data$t2_ <- as.POSIXct(data$t2_)
      
    
      
      if(length(data$fish_id)>1){
        
        #calculate nsd
        
        X <- split(data, list(data$fish_id,data$track),drop=T)
        
        for (d in 1:length(X)) { #ok getting errors as assuming levels for all parts of track
          track <- X[[d]]   
          #save starting coord
          start <- track[1,c("x1_","y1_")] #start coords
          track$nsd <- with(track, sqrt((x2_ - start[[1]])^2 + (y2_ - start[[2]])^2))
          
          if(d==1){
            data_filt <- track
          } else{
            data_filt <- rbind(data_filt,track)
          }
          
        }
        
        #now summarise nsd per track
        
        sum_nsd <- data_filt %>% group_by(track) %>% summarise(max_nsd=max(nsd))
        
        
        #now filter to remove tracks nsd<40
        
        tracks_max40 <- sum_nsd %>% filter(max_nsd>=40)
        
        #now filter data
        
        dat_filt <- data %>% filter(track %in% unique(tracks_max40$track))
        
        write.csv(dat_filt_final,
                  paste0("data/find ladder/FINAL final SSF dataframes - filtered - decision tree/",id,".csv"),
                  row.names = F)
      } else{
        print(paste0("fish id ",id," no data post date filtering"))
      }
      
    }
    
    

    back to top

    Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
    The source code of Software Heritage itself is available on our development forge.
    The source code files archived by Software Heritage are available under their own copyright and licenses.
    Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API