---
title: "Introduction to ET0MassModels"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Introduction to ET0MassModels}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 7,
  fig.height = 5
)
```

## Overview

The `ET0MassModels` package provides 10 mass transfer-based empirical models for
estimating daily reference evapotranspiration (ET0). The FAO Penman-Monteith
method is included as the standard reference against which the mass transfer-based
models are compared and evaluated.

Mass transfer-based models estimate evaporation from the vapor pressure deficit
and wind speed, making them suitable where humidity and wind data are available
but radiation data are limited.

### Mass Transfer-Based Models

| # | Model | Function | Primary Inputs |
|---|-------|----------|----------------|
| 1 | Dalton (1802) | `et0_dalton()` | Tmin, Tmax, RH, u |
| 2 | Trabert (1896) | `et0_trabert()` | Tmin, Tmax, RH, u |
| 3 | Meyer (1926) | `et0_meyer()` | Tmin, Tmax, RH, u |
| 4 | Rohwer (1931) | `et0_rohwer()` | Tmin, Tmax, RH, u |
| 5 | Penman (1948) | `et0_penman()` | Tmin, Tmax, RH, u |
| 6 | Albrecht (1950) | `et0_albrecht()` | Tmin, Tmax, RH, u |
| 7 | WMO (1966) | `et0_wmo()` | Tmin, Tmax, RH, u |
| 8 | Brockamp-Wenner (1963) | `et0_brockamp_wenner()` | Tmin, Tmax, RH, u |
| 9 | Romanenko (1961) | `et0_romanenko()` | Tmean, Tmin, Tmax, RH |
| 10 | Mahringer (1970) | `et0_mahringer()` | Tmin, Tmax, RH, u |

## Quick Start

### Loading the Package and Data

```{r load}
library(ET0MassModels)
data(jhansi_weather)
head(jhansi_weather)
```

### Computing ET0 for a Single Day

```{r single-day}
# FAO Penman-Monteith (reference)
et0_fao_pm(Tmin = 15, Tmax = 35, RH_morning = 90, RH_evening = 40,
           u2 = 1.5, n = 9, J = 172, lat = 25.43, z = 216)

# Dalton (linear wind function)
et0_dalton(Tmin = 15, Tmax = 35, RH_morning = 90, RH_evening = 40, u = 1.5)

# Romanenko (temperature and humidity based)
et0_romanenko(Tmean = 25, Tmin = 15, Tmax = 35,
              RH_morning = 90, RH_evening = 40)
```

### Computing All 10 Mass Transfer-Based Models at Once

```{r all-models}
result <- et0_mass_all(
  Tmin       = jhansi_weather$Tmin[1:5],
  Tmax       = jhansi_weather$Tmax[1:5],
  RH_morning = jhansi_weather$RH_morning[1:5],
  RH_evening = jhansi_weather$RH_evening[1:5],
  u2         = jhansi_weather$WS[1:5],
  n          = jhansi_weather$SSH[1:5],
  J          = jhansi_weather$J[1:5],
  lat        = 25.43,
  z          = 216
)
round(result, 2)
```

## Evaluating Model Performance Against FAO-PM

```{r evaluation}
full_result <- et0_mass_all(
  Tmin       = jhansi_weather$Tmin,
  Tmax       = jhansi_weather$Tmax,
  RH_morning = jhansi_weather$RH_morning,
  RH_evening = jhansi_weather$RH_evening,
  u2         = jhansi_weather$WS,
  n          = jhansi_weather$SSH,
  J          = jhansi_weather$J,
  lat        = 25.43,
  z          = 216
)

obs   <- full_result$FAO_PM
preds <- full_result[, c("Dalton", "Meyer", "WMO", "Mahringer")]
metrics <- evaluate_models(obs, preds)
print(metrics)
```

## Visualization

### Scatter Plot

```{r scatter, fig.width=6, fig.height=6}
plot_scatter(obs, preds,
             main = "Mass Transfer-Based Models vs FAO-PM")
```

### Taylor Diagram

```{r taylor, fig.width=7, fig.height=7}
plot_taylor(obs, preds,
            main = "Taylor Diagram - Mass Transfer-Based Models")
```

## References

- Allen, R.G., Pereira, L.S., Raes, D., & Smith, M. (1998). Crop
  evapotranspiration: Guidelines for computing crop water requirements.
  FAO Irrigation and Drainage Paper No. 56.
- Satpute, A.N., Barman, S., Singh, A.K., Ghosh, A., & Gupta, G. (2026).
  A multi-scale evaluation of 30 empirical models for reference
  evapotranspiration estimation in a data-scarce semi-arid region:
  A case study of Jhansi, India.
  *Journal of Hydrology: Regional Studies*.
  https://doi.org/10.1016/j.ejrh.2026.103925
