Skip to content

Conversation

@lochbika
Copy link

@lochbika lochbika commented Apr 20, 2023

This error only appears when using precipitation input and tsMatrix as input format.
The following code

# Load data for Tampa, lat=37.6475N, elevation=402.6 m. a.s.l.
# Data consists on monthly values since January 1980
data(wichita)
attach(wichita)
names(wichita)

# tsMatrix input (data from several stations)
# Replicating Wichita data twice to simulate data at two locations.
tmin <- cbind(TMIN, TMIN + 1.5)
tmax <- cbind(TMAX, TMAX + 1.5)
tmin <- ts(tmin, start=c(2000, 1), frequency = 12)
tmax <- ts(tmax, start=c(2000, 1), frequency = 12)
precip <- ts(matrix(runif(prod(dim(tmax)), min=0, max=23), ncol=2), start=c(2000, 1), frequency = 12)
lat <- c(37.6475, 35.000)
har <- hargreaves(tmin, tmax, lat = lat, Pre=precip, na.rm = TRUE)

give this error:

Error in `*.default`(0.0013 * 0.408 * Ra * (Tmean + 17), ab^0.76) :
non-conformable arrays

I fixed it by replacing Pre with Rs (see diff)
Rs is created inside the function with conformable array dimenstions

```
Error in `*.default`(0.0013 * 0.408 * Ra * (Tmean + 17), ab^0.76) :
non-conformable arrays
```

Use Rs instead. Rs is created inside the function with conformable array dimenstions
@sbegueria
Copy link
Owner

Have a look at this. This an option that hasn't been tested: matrix input, using pre option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants