Merge 'dev' into 'eto'

This commit is contained in:
Matthew Oslan
2019-06-30 16:33:54 -04:00
13 changed files with 181 additions and 80 deletions

View File

@@ -1,13 +1,13 @@
import * as moment from "moment-timezone";
import { GeoCoordinates, WateringData, WeatherData } from "../../types";
import { GeoCoordinates, WeatherData, ZimmermanWateringData } from "../../types";
import { httpJSONRequest } from "../weather";
import { WeatherProvider } from "./WeatherProvider";
import { approximateSolarRadiation, CloudCoverInfo, EToData } from "../adjustmentMethods/EToAdjustmentMethod";
export default class DarkSkyWeatherProvider extends WeatherProvider {
public async getWateringData( coordinates: GeoCoordinates ): Promise< WateringData > {
public async getWateringData( coordinates: GeoCoordinates ): Promise< ZimmermanWateringData > {
// The Unix timestamp of 24 hours ago.
const yesterdayTimestamp: number = moment().subtract( 1, "day" ).unix();
const todayTimestamp: number = moment().unix();
@@ -48,9 +48,16 @@ export default class DarkSkyWeatherProvider extends WeatherProvider {
const totals = { temp: 0, humidity: 0, precip: 0 };
for ( const sample of samples ) {
/*
* If temperature or humidity is missing from a sample, the total will become NaN. This is intended since
* calculateWateringScale will treat NaN as a missing value and temperature/humidity can't be accurately
* calculated when data is missing from some samples (since they follow diurnal cycles and will be
* significantly skewed if data is missing for several consecutive hours).
*/
totals.temp += sample.temperature;
totals.humidity += sample.humidity;
totals.precip += sample.precipIntensity
// This field may be missing from the response if it is snowing.
totals.precip += sample.precipIntensity || 0;
}
return {