This page can't be edited.

Rain filtering

From $1

    Table of contents
    to the older version or return to version archive.

    Combined revision comparison

    Comparing version 19:24, 15 Mar 2012 by beth with version 13:39, 10 Aug 2015 by Admin.

    2015 Aug 10: code changed to assess number of blips based on existing filtering, not just unfiltered patch count.

    ...

    num.blips.cutoff <- 500
    
    drop.crowded.scans <- function(x) {
       if (sumlength(x) > num.blips.cutoff) ## if there are at least num.blips.cutoff blipspatches
         return (rep(FALSE, length(x))) ## return a FALSE for each patch, filtering it out
       else
         return(NULL) ## otherwise, don't do any further filtering; could also return x with the same effect
    }
    
    ## now add the function to the PATCH_STATS hook, which calls it every scan
    ## right before anything is done with the blips
    rss.add.hook("PATCH_STATS", "norain", drop.crowded.scans, read.only=FALSE)
    

    ...

    The function drop.crowded.scans() examines the number of blipspatches (namely sumlength(x)), and if this is larger than the cutoff, the function returns an all FALSE vector, which means no patches are accepted as blips.  Otherwise, the function returns NULL to indicate it does not want to change the status of any blips.

    ...

    num.blips.cutoff <- 500
    
    ## increase default printing precision so timestamps are output with a single decimal digit
    options(digits=11)
    
    ## add a hook function to open a rainscans file when the blipmovie is opened (using the same base name)
    rss.add.hook("START_SOURCE", function(...)  {
        rain.scans.file <<- file(paste(RSS$source$file.basename, ".rainscans.csv", sep=""), "w")
        cat ("timestamp,ts.string\n", file=rain.scans.file)    
        })
    
    plot.title.date.format <- "%Y %b %d %H:%M:%OS1" ## copy of GUI$plot.title.date.format so it works in batch mode too
    
    drop.crowded.scans <- function(x) {
       if (sumlength(x) > num.blips.cutoff) {
         ## if we're really processing this scan (not just browsing through the blipmovie)
         ## then write timestamp in two formats
         if (RSS$play.state >= RSS$PS$PLAYING && !RSS$previewing)
            cat (RSS$scan.info$timestamp, ",", format(structure(RSS$scan.info$timestamp, class="POSIXct"), plot.title.date.format), "\n", sep="", file=rain.scans.file)
         return (rep(FALSE, length(x)))
       } else {
         return(NULL)
       }
    }
    
    rss.add.hook("PATCH_STATS", "norain", drop.crowded.scans, read.only=FALSE)

    ...

    Version from 19:24, 15 Mar 2012

    This revision modified by beth (Ban)

    ...

    num.blips.cutoff <- 500
    
    drop.crowded.scans <- function(x) {
       if (length(x) > num.blips.cutoff) ## if there are at least num.blips.cutoff patches
         return (rep(FALSE, length(x))) ## return a FALSE for each patch, filtering it out
       else
         return(NULL) ## otherwise, don't do any further filtering; could also return x with the same effect
    }
    
    ## now add the function to the PATCH_STATS hook, which calls it every scan
    ## right before anything is done with the blips
    rss.add.hook("PATCH_STATS", "norain", drop.crowded.scans, read.only=FALSE)
    

    ...

    The function drop.crowded.scans() examines the number of patches (namely length(x)), and if this is larger than the cutoff, the function returns an all FALSE vector, which means no patches are accepted as blips.  Otherwise, the function returns NULL to indicate it does not want to change the status of any blips.

    ...

    num.blips.cutoff <- 500
    
    ## increase default printing precision so timestamps are output with a single decimal digit
    options(digits=11)
    
    ## add a hook function to open a rainscans file when the blipmovie is opened (using the same base name)
    rss.add.hook("START_SOURCE", function(...)  {
        rain.scans.file <<- file(paste(RSS$source$file.basename, ".rainscans.csv", sep=""), "w")
        cat ("timestamp,ts.string\n", file=rain.scans.file)    
        })
    
    plot.title.date.format <- "%Y %b %d %H:%M:%OS1" ## copy of GUI$plot.title.date.format so it works in batch mode too
    
    drop.crowded.scans <- function(x) {
       if (length(x) > num.blips.cutoff) {
         ## if we're really processing this scan (not just browsing through the blipmovie)
         ## then write timestamp in two formats
         if (RSS$play.state >= RSS$PS$PLAYING && !RSS$previewing)
            cat (RSS$scan.info$timestamp, ",", format(structure(RSS$scan.info$timestamp, class="POSIXct"), plot.title.date.format), "\n", sep="", file=rain.scans.file)
         return (rep(FALSE, length(x)))
       } else {
         return(NULL)
       }
    }
    
    rss.add.hook("PATCH_STATS", "norain", drop.crowded.scans, read.only=FALSE)

    ...

    Current version

    This revision modified by Admin (Ban)

    2015 Aug 10: code changed to assess number of blips based on existing filtering, not just unfiltered patch count.

    ...

    num.blips.cutoff <- 500
    
    drop.crowded.scans <- function(x) {
       if (sum(x) > num.blips.cutoff) ## if there are at least num.blips.cutoff blips
         return (rep(FALSE, length(x))) ## return a FALSE for each patch, filtering it out
       else
         return(NULL) ## otherwise, don't do any further filtering; could also return x with the same effect
    }
    
    ## now add the function to the PATCH_STATS hook, which calls it every scan
    ## right before anything is done with the blips
    rss.add.hook("PATCH_STATS", "norain", drop.crowded.scans, read.only=FALSE)
    

    ...

    The function drop.crowded.scans() examines the number of blips (namely sum(x)), and if this is larger than the cutoff, the function returns an all FALSE vector, which means no patches are accepted as blips.  Otherwise, the function returns NULL to indicate it does not want to change the status of any blips.

    ...

    num.blips.cutoff <- 500
    
    ## increase default printing precision so timestamps are output with a single decimal digit
    options(digits=11)
    
    ## add a hook function to open a rainscans file when the blipmovie is opened (using the same base name)
    rss.add.hook("START_SOURCE", function(...)  {
        rain.scans.file <<- file(paste(RSS$source$file.basename, ".rainscans.csv", sep=""), "w")
        cat ("timestamp,ts.string\n", file=rain.scans.file)    
        })
    
    plot.title.date.format <- "%Y %b %d %H:%M:%OS1" ## copy of GUI$plot.title.date.format so it works in batch mode too
    
    drop.crowded.scans <- function(x) {
       if (sum(x) > num.blips.cutoff) {
         ## if we're really processing this scan (not just browsing through the blipmovie)
         ## then write timestamp in two formats
         if (RSS$play.state >= RSS$PS$PLAYING && !RSS$previewing)
            cat (RSS$scan.info$timestamp, ",", format(structure(RSS$scan.info$timestamp, class="POSIXct"), plot.title.date.format), "\n", sep="", file=rain.scans.file)
         return (rep(FALSE, length(x)))
       } else {
         return(NULL)
       }
    }
    
    rss.add.hook("PATCH_STATS", "norain", drop.crowded.scans, read.only=FALSE)

    ...


     
    Powered by MindTouch Core