hovmoller {stxplore}R Documentation

Computes the data structure for the Hovmoller plots

Description

This function creates the data structure for Hovmoller plots for either latitude or longitude. This function can take either a stars object or a dataframe. Input arguments differ for each case. The function autoplot can plot this object.

Usage

hovmoller(x, lat_or_lon = "lat", xlen = NULL, ...)

## S3 method for class 'data.frame'
hovmoller(
  x,
  lat_or_lon = "lat",
  xlen = NULL,
  lat_or_lon_col,
  t_col,
  z_col,
  ...
)

## S3 method for class 'stars'
hovmoller(x, lat_or_lon = "lat", xlen = NULL, ...)

## S3 method for class 'hovmoller'
autoplot(
  object,
  ylab = "Day",
  xlab = NULL,
  title = "",
  palette = "Spectral",
  legend_title = "z",
  ...
)

Arguments

x

A stars object or a dataframe. Arguments differ according to the input type.

lat_or_lon

Needs to be either lat or lon. lat plots the latitudinal Hovmoller plat, while lon plots the longitudinal Hovmoller plot.

xlen

The length of the xaxis for latitude/longitude.

...

Other arguments currently ignored.

lat_or_lon_col

For dataframes: the column or the column name corresponding to the latitude/longitude.

t_col

For dataframes: the time column. Time must be a set of discrete integer values.

z_col

For dataframes: the The quantity of interest that will be plotted. Eg. temperature.

object

For autoplot: the output of the function ‘hovmoller’.

ylab

The y label.

xlab

The x label.

title

The graph title.

palette

The color palette. Default is Spectral.

legend_title

The title for the legend.

Value

An object of hovmoller class containing the original data and the Hovmoller data.

Examples

# dataframe examples
library(dplyr)
data(NOAA_df_1990)
Tmax <- filter(NOAA_df_1990,
  proc == "Tmax" &
  month %in% 5:9 &
  year == 1993 &
  id < 4000)
Tmax$t <- Tmax$julian - min(Tmax$julian) + 1
hov <- hovmoller(lat_or_lon = "lat",
          x = Tmax,
          lat_or_lon_col = 'lat',
          t_col = 't',
          z_col = 'z')
autoplot(hov)

# stars examples
library(stars)
prec_file = system.file("nc/test_stageiv_xyt.nc", package = "stars")
prec <- read_ncdf(prec_file)
prec2 <- prec %>% slice(time, 1:5)
hov <- hovmoller(prec2)
hov

[Package stxplore version 0.1.0 Index]