R/plot-MYZ.R

Defines functions dts_lines_Z_fracs dts_plot_Z_fracs dts_lines_YZ_fracs dts_plot_YZ_fracs dts_lines_YZ dts_plot_YZ dts_lines_M dts_plot_M

Documented in dts_lines_M dts_lines_YZ dts_lines_YZ_fracs dts_lines_Z_fracs dts_plot_M dts_plot_YZ dts_plot_YZ_fracs dts_plot_Z_fracs

#' Plot adult mosquito population density
#'
#' @param pars a list that defines an `ramp.dts` model (*e.g.*,  generated by `dts_setup()`)
#' @param s the vector species index
#' @param clrs a vector of colors
#' @param llty an integer (or integers) to set the `lty` for plotting
#' @param stable a logical: set to FALSE for `orbits` and TRUE for `stable_orbits`
#' @param add_axes a logical: plot axes only if TRUE
#'
#' @export
dts_plot_M = function(pars, s=1, clrs="darkblue", llty=1, stable=FALSE, add_axes=TRUE){
  vars=with(pars$outputs,if(stable==TRUE){stable_orbits}else{orbits})

  if(add_axes == TRUE) with(vars$MYZ[[s]],
                            plot(time, 0*time, type = "n", ylim = range(0,max(M)),
                                 ylab = "Mosquito Density", xlab = "Time"))

  dts_lines_M(vars$MYZ[[s]], pars, clrs, llty)
}

#' Add lines for adult mosquito population density
#'
#' @param MYZ a list the output of `ramp.dts::parse_deout()`
#' @param pars a list that defines an `ramp.dts` model (*e.g.*,  generated by `dts_setup()`)
#' @param clrs a vector of colors
#' @param llty an integer (or integers) to set the `lty` for plotting
#'
#' @export
dts_lines_M = function(MYZ, pars, clrs="darkblue", llty=1){
  with(MYZ,{
   if(pars$nPatches==1) lines(time, M, col=clrs[1], lty = llty[1])
   if(pars$nPatches>1){
      if (length(clrs)==1) clrs=rep(clrs, pars$nPatches)
      if (length(llty)==1) llty=rep(llty, pars$nPatches)
      for(i in 1:pars$nPatches){
        lines(time, M[,i], col=clrs[i], lty = llty[i])
      }
    }
})}

#' Plot the density of infected and infective mosquitoes
#'
#' @param pars a list that defines an `ramp.dts` model (*e.g.*,  generated by `dts_setup()`)
#' @param s the vector species index
#' @param Yclrs a vector of colors for infected mosquitoes
#' @param Zclrs a vector of colors for infective mosquitoes
#' @param llty an integer (or integers) to set the `lty` for plotting
#' @param stable set to FALSE for `orbits` and TRUE for `stable_orbits`
#' @param add_axes to plot axes only if TRUE
#'
#' @export
dts_plot_YZ = function(pars, s=1, Yclrs = "purple", Zclrs="darkred", llty=1, stable=FALSE, add_axes=TRUE){
  vars=with(pars$outputs,if(stable==TRUE){stable_orbits}else{orbits})

  if(add_axes == TRUE)
    with(vars$MYZ[[s]],
         plot(time, 0*time, type = "n", ylim = range(0,max(Y,Z)),
              ylab = "Mosquito Density", xlab = "Time"))

  dts_lines_YZ(vars$MYZ[[s]], pars, Yclrs, Zclrs, llty)
}

#' Add lines for the density of infected and infective mosquitoes
#'
#' @param MYZ a list the output of `ramp.dts::parse_deout()`
#' @param pars a list that defines an `ramp.dts` model (*e.g.*,  generated by `dts_setup()`)
#' @param Yclrs a vector of colors
#' @param Zclrs a vector of colors
#' @param llty an integer (or integers) to set the `lty` for plotting
#'
#' @export
dts_lines_YZ = function(MYZ, pars, Yclrs="purple", Zclrs = "darkred", llty=1){
  with(MYZ,{
    if(pars$nPatches==1){
      lines(time, Y, col=Yclrs[1], lty = llty[1])
      lines(time, Z, col=Zclrs[1], lty = llty[1])
    }
    if(pars$nPatches>1){
      if (length(Yclrs)==1) Yclrs=rep(Yclrs, pars$nPatches)
      if (length(Zclrs)==1) Zclrs=rep(Zclrs, pars$nPatches)
      if (length(llty)==1) llty=rep(llty, pars$nPatches)

      for(i in 1:pars$nPatches){
        lines(time, Y[,i], col=Yclrs[i], lty = llty[i])
        lines(time, Z[,i], col=Zclrs[i], lty = llty[i])
      }
    }
})}

#' Plot the fraction of infected and infective mosquitoes
#'
#' @param pars a list that defines an `ramp.dts` model (*e.g.*,  generated by `dts_setup()`)
#' @param s the vector species index
#' @param Yclrs a vector of colors for infected mosquitoes
#' @param Zclrs a vector of colors for infective mosquitoes
#' @param llty an integer (or integers) to set the `lty` for plotting
#' @param stable a logical, set to FALSE for `orbits` and TRUE for `stable_orbits`
#' @param add_axes a logical to plot axes only if TRUE
#'
#' @export
dts_plot_YZ_fracs = function(pars, s=1, Yclrs = "purple", Zclrs = "darkred", llty=1, stable=FALSE, add_axes=TRUE){
  vars=with(pars$outputs,if(stable==TRUE){stable_orbits}else{orbits})

  if(add_axes == TRUE)
    with(vars$MYZ[[s]],
         plot(time, 0*time, type = "n", ylim = range(0,1),
              ylab = "Fraction Infected", xlab = "Time"))

  dts_lines_YZ_fracs(vars$MYZ[[s]], pars, Yclrs, Zclrs, llty)
}

#' Add lines for the fraction of infected and infective mosquitoes
#'
#' @param MYZ a list the output of `ramp.dts::parse_deout()`
#' @param pars a list that defines an `ramp.dts` model (*e.g.*,  generated by `dts_setup()`)
#' @param Yclrs a vector of colors for infected mosquitoes
#' @param Zclrs a vector of colors for infective mosquitoes
#' @param llty an integer (or integers) to set the `lty` for plotting
#'
#' @export
dts_lines_YZ_fracs = function(MYZ, pars, Yclrs="purple", Zclrs="darkred", llty=1){
  with(MYZ,{
    if(pars$nPatches==1) {
      lines(time, y, col=Yclrs, lty = llty[1])
      lines(time, z, col=Zclrs, lty = llty[1])
    }
    if(pars$nPatches>1){
      if (length(Yclrs)==1) Yclrs=rep(Yclrs, pars$nPatches)
      if (length(Zclrs)==1) Zclrs=rep(Zclrs, pars$nPatches)
      if (length(llty)==1) llty=rep(llty, pars$nPatches)

      for(i in 1:pars$nPatches){
        lines(time, y[,i], col=Yclrs[i], lty = llty[i])
        lines(time, z[,i], col=Zclrs[i], lty = llty[i])
      }
    }
})}


#' Plot the fraction of infected and infective mosquitoes
#'
#' @param pars a list that defines an `ramp.dts` model (*e.g.*,  generated by `dts_setup()`)
#' @param s the vector species index
#' @param Zclrs a vector of colors for infective mosquitoes
#' @param llty an integer (or integers) to set the `lty` for plotting
#' @param stable a logical, set to FALSE for `orbits` and TRUE for `stable_orbits`
#' @param add_axes a logical to plot axes only if TRUE
#'
#' @export
dts_plot_Z_fracs = function(pars, s=1, Zclrs = "darkred", llty=1, stable=FALSE, add_axes=TRUE){
  vars=with(pars$outputs,if(stable==TRUE){stable_orbits}else{orbits})

  if(add_axes == TRUE)
    with(vars$MZ[[s]],
         plot(time, 0*time, type = "n", ylim = range(0,vars$MZ[[s]]$z),
              ylab = "Fraction Infected", xlab = "Time"))

  dts_lines_Z_fracs(vars$MZ[[s]], pars,  Zclrs, llty)
}

#' Add lines for the fraction of infected and infective mosquitoes
#'
#' @param MZ a list the output of `ramp.dts::parse_deout()`
#' @param pars a list that defines an `ramp.dts` model (*e.g.*,  generated by `dts_setup()`)
#' @param Zclrs a vector of colors for infective mosquitoes
#' @param llty an integer (or integers) to set the `lty` for plotting
#'
#' @export
dts_lines_Z_fracs = function(MZ, pars, Zclrs="darkred", llty=1){
  with(MZ,{
    if(pars$nPatches==1) {
      lines(time, z, col=Zclrs, lty = llty[1])
    }
    if(pars$nPatches>1){
      if (length(Zclrs)==1) Zclrs=rep(Zclrs, pars$nPatches)
      if (length(llty)==1) llty=rep(llty, pars$nPatches)

      for(i in 1:pars$nPatches){
        lines(time, z[,i], col=Zclrs[i], lty = llty[i])
      }
    }
  })}
dd-harp/MicroMoB documentation built on June 6, 2024, 4:43 p.m.