// Compiled by ClojureScript 1.9.562 {}
goog.provide('weathergen.model');
goog.require('cljs.core');
goog.require('weathergen.time');
goog.require('weathergen.math');
goog.require('org.craigandera.weathergen.pattern_space');
weathergen.model.mmhg__GT_inhg = (function weathergen$model$mmhg__GT_inhg(mmhg){
return ((((mmhg - (950)) / (110)) * 3.25) + 28.05);
});
weathergen.model.inhg__GT_mmhg = (function weathergen$model$inhg__GT_mmhg(inhg){
return ((((inhg - 28.05) / 3.25) * (110)) + (950));
});
weathergen.model.types = new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"inclement","inclement",-550669382),new cljs.core.Keyword(null,"poor","poor",1462482211),new cljs.core.Keyword(null,"fair","fair",1684139423),new cljs.core.Keyword(null,"sunny","sunny",1448267778)], null);
weathergen.model.mix = (function weathergen$model$mix(x,fade,type_params,min_pressure,max_pressure){
var pressure_span = (max_pressure - min_pressure);
var i = ((cljs.core.get_in.call(null,type_params,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"inclement","inclement",-550669382),new cljs.core.Keyword(null,"pressure","pressure",505343747)], null)) - min_pressure) / pressure_span);
var p = ((cljs.core.get_in.call(null,type_params,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"poor","poor",1462482211),new cljs.core.Keyword(null,"pressure","pressure",505343747)], null)) - min_pressure) / pressure_span);
var f = ((cljs.core.get_in.call(null,type_params,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"fair","fair",1684139423),new cljs.core.Keyword(null,"pressure","pressure",505343747)], null)) - min_pressure) / pressure_span);
var s = (1);
var contour = new cljs.core.PersistentVector(null, 8, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(0),new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [(1),(0),(0),(0)], null)], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(((1) - fade) * i),new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [(1),(0),(0),(0)], null)], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [weathergen.math.interpolate.call(null,i,p,fade),new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [(0),(1),(0),(0)], null)], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [weathergen.math.interpolate.call(null,p,i,fade),new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [(0),(1),(0),(0)], null)], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [weathergen.math.interpolate.call(null,p,f,fade),new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [(0),(0),(1),(0)], null)], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [weathergen.math.interpolate.call(null,f,p,fade),new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [(0),(0),(1),(0)], null)], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [((1) - fade),new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [(0),(0),(0),(1)], null)], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(1),new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [(0),(0),(0),(1)], null)], null)], null);
var vec__33340 = cljs.core.first.call(null,cljs.core.filter.call(null,((function (pressure_span,i,p,f,s,contour){
return (function (p__33349){
var vec__33350 = p__33349;
var vec__33353 = cljs.core.nth.call(null,vec__33350,(0),null);
var low = cljs.core.nth.call(null,vec__33353,(0),null);
var vec__33356 = cljs.core.nth.call(null,vec__33350,(1),null);
var high = cljs.core.nth.call(null,vec__33356,(0),null);
return ((low <= x)) && ((x <= high));
});})(pressure_span,i,p,f,s,contour))
,cljs.core.partition.call(null,(2),(1),contour)));
var vec__33343 = cljs.core.nth.call(null,vec__33340,(0),null);
var x1 = cljs.core.nth.call(null,vec__33343,(0),null);
var v1 = cljs.core.nth.call(null,vec__33343,(1),null);
var vec__33346 = cljs.core.nth.call(null,vec__33340,(1),null);
var x2 = cljs.core.nth.call(null,vec__33346,(0),null);
var v2 = cljs.core.nth.call(null,vec__33346,(1),null);
return cljs.core.zipmap.call(null,weathergen.model.types,weathergen.math.vector_interpolate.call(null,v1,v2,x,x1,x2));
});
weathergen.model.mix_on = (function weathergen$model$mix_on(categories,mixture,path){
return cljs.core.reduce.call(null,cljs.core._PLUS_,cljs.core.mapv.call(null,(function (p__33363){
var vec__33364 = p__33363;
var type = cljs.core.nth.call(null,vec__33364,(0),null);
var weight = cljs.core.nth.call(null,vec__33364,(1),null);
return (cljs.core.get_in.call(null,cljs.core.get.call(null,categories,type),path) * weight);
}),mixture));
});
weathergen.model.smoothed_noise_field = (function weathergen$model$smoothed_noise_field(x,y,t,seed,zoom){
var t_STAR_ = cljs.core.long$.call(null,Math.floor((t + seed)));
return weathergen.math.interpolate.call(null,weathergen.math.fractal_field.call(null,x,y,zoom,(t_STAR_ + 0.01),(1)),weathergen.math.fractal_field.call(null,x,y,zoom,(t_STAR_ + 1.01),(1)),cljs.core.mod.call(null,weathergen.math.frac.call(null,t),1.0));
});
/**
 * Returns the perturbed coordinates of a point given:
 * 
 * x, y, t - coordinates of sample position in pattern space.
 * seed    - PNRG seed
 * t-power - Strength of turbulence factor
 * t-size  - Spatial size of turbulence field
 */
weathergen.model.perturb = (function weathergen$model$perturb(params){
var map__33369 = params;
var map__33369__$1 = ((((!((map__33369 == null)))?((((map__33369.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33369.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33369):map__33369);
var x = cljs.core.get.call(null,map__33369__$1,new cljs.core.Keyword("org.craigandera.weathergen.pattern-space","x","org.craigandera.weathergen.pattern-space/x",441833243));
var y = cljs.core.get.call(null,map__33369__$1,new cljs.core.Keyword("org.craigandera.weathergen.pattern-space","y","org.craigandera.weathergen.pattern-space/y",-176904590));
var t = cljs.core.get.call(null,map__33369__$1,new cljs.core.Keyword("org.craigandera.weathergen.pattern-space","t","org.craigandera.weathergen.pattern-space/t",1253598919));
var seed = cljs.core.get.call(null,map__33369__$1,new cljs.core.Keyword(null,"seed","seed",68613327));
var turbulence = cljs.core.get.call(null,map__33369__$1,new cljs.core.Keyword(null,"turbulence","turbulence",-915506410));
var t_power = new cljs.core.Keyword(null,"power","power",-937852079).cljs$core$IFn$_invoke$arity$1(turbulence);
var t_size = new cljs.core.Keyword(null,"size","size",1098693007).cljs$core$IFn$_invoke$arity$1(turbulence);
var x_STAR_ = (x / t_size);
var y_STAR_ = (y / t_size);
var x_turbulence = weathergen.model.smoothed_noise_field.call(null,x_STAR_,y_STAR_,t,seed,(32));
var y_turbulence = weathergen.model.smoothed_noise_field.call(null,x_STAR_,y_STAR_,(t + (16)),seed,(32));
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [((t_power * x_turbulence) + x),((t_power * y_turbulence) + y)], null);
});
weathergen.model.pressure_pattern = (function weathergen$model$pressure_pattern(p__33371){
var vec__33375 = p__33371;
var x = cljs.core.nth.call(null,vec__33375,(0),null);
var y = cljs.core.nth.call(null,vec__33375,(1),null);
var v = ((Math.sin(x) * Math.sin(y)) + (Math.sin((x / (3))) * Math.sin((y / (3)))));
return ((v + (2)) / (4));
});
weathergen.model.wind_direction = (function weathergen$model$wind_direction(p__33378,v,params){
var vec__33382 = p__33378;
var x = cljs.core.nth.call(null,vec__33382,(0),null);
var y = cljs.core.nth.call(null,vec__33382,(1),null);
var h = cljs.core.get_in.call(null,params,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"prevailing-wind","prevailing-wind",-190580386),new cljs.core.Keyword(null,"heading","heading",-1312171873)], null));
var w0 = weathergen.math.rotate.call(null,(90),weathergen.math.normalize.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [((Math.cos(x) * Math.sin(y)) + (((1.0 / (3)) * Math.cos((x / (3)))) * Math.sin((y / (3))))),((Math.sin(x) * Math.cos(y)) + (((1.0 / (3)) * Math.sin((x / (3)))) * Math.cos((y / (3)))))], null)));
var w1 = weathergen.math.rotate.call(null,h,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(0),(1)], null));
var c = Math.abs((v - 0.5));
return weathergen.math.normalize.call(null,weathergen.math.vector_interpolate.call(null,w1,w0,c,(0),0.5));
});
weathergen.model.wind_speed = (function weathergen$model$wind_speed(categories,mixture,v){
var mean = weathergen.model.mix_on.call(null,categories,mixture,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"wind","wind",-527553074),new cljs.core.Keyword(null,"mean","mean",-1359234715)], null));
var min = weathergen.model.mix_on.call(null,categories,mixture,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"wind","wind",-527553074),new cljs.core.Keyword(null,"min","min",444991522)], null));
var max = weathergen.model.mix_on.call(null,categories,mixture,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"wind","wind",-527553074),new cljs.core.Keyword(null,"max","max",61366548)], null));
return weathergen.math.distribute.call(null,v,min,mean,max,(1));
});
/**
 * Return true if x*,y* is within the bounds of area.
 */
weathergen.model.in_area_QMARK_ = (function weathergen$model$in_area_QMARK_(p__33385,x_STAR_,y_STAR_){
var map__33388 = p__33385;
var map__33388__$1 = ((((!((map__33388 == null)))?((((map__33388.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33388.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33388):map__33388);
var bounds = map__33388__$1;
var x = cljs.core.get.call(null,map__33388__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var y = cljs.core.get.call(null,map__33388__$1,new cljs.core.Keyword(null,"y","y",-1757859776));
var width = cljs.core.get.call(null,map__33388__$1,new cljs.core.Keyword(null,"width","width",-384071477));
var height = cljs.core.get.call(null,map__33388__$1,new cljs.core.Keyword(null,"height","height",1025178622));
var and__23136__auto__ = x;
if(cljs.core.truth_(and__23136__auto__)){
var and__23136__auto____$1 = y;
if(cljs.core.truth_(and__23136__auto____$1)){
var and__23136__auto____$2 = width;
if(cljs.core.truth_(and__23136__auto____$2)){
var and__23136__auto____$3 = height;
if(cljs.core.truth_(and__23136__auto____$3)){
return ((x <= x_STAR_)) && ((x_STAR_ < (x + width))) && ((y <= y_STAR_)) && ((y_STAR_ < (y + height)));
} else {
return and__23136__auto____$3;
}
} else {
return and__23136__auto____$2;
}
} else {
return and__23136__auto____$1;
}
} else {
return and__23136__auto__;
}
});
/**
 * Returns the wind, stabilized if appropriate by a wind stability region
 */
weathergen.model.stabilize_wind = (function weathergen$model$stabilize_wind(p__33391,pattern_wind){
var map__33394 = p__33391;
var map__33394__$1 = ((((!((map__33394 == null)))?((((map__33394.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33394.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33394):map__33394);
var wind_stability_areas = cljs.core.get.call(null,map__33394__$1,new cljs.core.Keyword(null,"wind-stability-areas","wind-stability-areas",1732901204));
var x = cljs.core.get.call(null,map__33394__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var y = cljs.core.get.call(null,map__33394__$1,new cljs.core.Keyword(null,"y","y",-1757859776));
var _QMARK_ = wind_stability_areas;
var _QMARK___$1 = cljs.core.filter.call(null,((function (_QMARK_,map__33394,map__33394__$1,wind_stability_areas,x,y){
return (function (p1__33390_SHARP_){
return weathergen.model.in_area_QMARK_.call(null,new cljs.core.Keyword(null,"bounds","bounds",1691609455).cljs$core$IFn$_invoke$arity$1(p1__33390_SHARP_),x,y);
});})(_QMARK_,map__33394,map__33394__$1,wind_stability_areas,x,y))
,_QMARK_);
var _QMARK___$2 = cljs.core.first.call(null,_QMARK___$1);
var _QMARK___$3 = new cljs.core.Keyword(null,"wind","wind",-527553074).cljs$core$IFn$_invoke$arity$1(_QMARK___$2);
var or__23148__auto__ = _QMARK___$3;
if(cljs.core.truth_(or__23148__auto__)){
return or__23148__auto__;
} else {
return pattern_wind;
}
});
weathergen.model.temperature = (function weathergen$model$temperature(categories,mixture,v){
var mean = weathergen.model.mix_on.call(null,categories,mixture,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"temp","temp",1791541284),new cljs.core.Keyword(null,"mean","mean",-1359234715)], null));
var min = weathergen.model.mix_on.call(null,categories,mixture,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"temp","temp",1791541284),new cljs.core.Keyword(null,"min","min",444991522)], null));
var max = weathergen.model.mix_on.call(null,categories,mixture,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"temp","temp",1791541284),new cljs.core.Keyword(null,"max","max",61366548)], null));
return weathergen.math.distribute.call(null,v,min,mean,max,(1));
});
/**
 * Given a weather override and a time, determine how much of the
 *   override we should blend in based on the time.
 */
weathergen.model.time_weight = (function weathergen$model$time_weight(override,current_time){
var map__33398 = override;
var map__33398__$1 = ((((!((map__33398 == null)))?((((map__33398.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33398.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33398):map__33398);
var begin = cljs.core.get.call(null,map__33398__$1,new cljs.core.Keyword(null,"begin","begin",-319034319));
var peak = cljs.core.get.call(null,map__33398__$1,new cljs.core.Keyword(null,"peak","peak",389096055));
var taper = cljs.core.get.call(null,map__33398__$1,new cljs.core.Keyword(null,"taper","taper",1772067478));
var end = cljs.core.get.call(null,map__33398__$1,new cljs.core.Keyword(null,"end","end",-268185958));
var animate_QMARK_ = cljs.core.get.call(null,map__33398__$1,new cljs.core.Keyword(null,"animate?","animate?",-1559039739));
var bm = weathergen.time.campaign_time__GT_minutes.call(null,begin);
var pm = weathergen.time.campaign_time__GT_minutes.call(null,peak);
var tm = weathergen.time.campaign_time__GT_minutes.call(null,taper);
var em = weathergen.time.campaign_time__GT_minutes.call(null,end);
var t = weathergen.time.campaign_time__GT_minutes.call(null,current_time);
if(cljs.core.not.call(null,animate_QMARK_)){
return (1);
} else {
if((em < t)){
return (0);
} else {
if((tm < t)){
return ((1) - ((t - tm) / (em - tm)));
} else {
if((pm < t)){
return (1);
} else {
if((bm < t)){
return ((t - bm) / (pm - bm));
} else {
return (0);

}
}
}
}
}
});
/**
 * Adjusts pressure value based on weather overrides, if any.
 */
weathergen.model.override = (function weathergen$model$override(params,v){
var map__33404 = params;
var map__33404__$1 = ((((!((map__33404 == null)))?((((map__33404.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33404.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33404):map__33404);
var x = cljs.core.get.call(null,map__33404__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var y = cljs.core.get.call(null,map__33404__$1,new cljs.core.Keyword(null,"y","y",-1757859776));
var t = cljs.core.get.call(null,map__33404__$1,new cljs.core.Keyword(null,"t","t",-1397832519));
var weather_overrides = cljs.core.get.call(null,map__33404__$1,new cljs.core.Keyword(null,"weather-overrides","weather-overrides",-837381710));
var time = cljs.core.get.call(null,map__33404__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var min_pressure = new cljs.core.Keyword(null,"min","min",444991522).cljs$core$IFn$_invoke$arity$1(new cljs.core.Keyword(null,"pressure","pressure",505343747).cljs$core$IFn$_invoke$arity$1(params));
var max_pressure = new cljs.core.Keyword(null,"max","max",61366548).cljs$core$IFn$_invoke$arity$1(new cljs.core.Keyword(null,"pressure","pressure",505343747).cljs$core$IFn$_invoke$arity$1(params));
var pressure_span = (max_pressure - min_pressure);
return weathergen.math.clamp.call(null,0.0,1.0,cljs.core.reduce.call(null,((function (map__33404,map__33404__$1,x,y,t,weather_overrides,time,min_pressure,max_pressure,pressure_span){
return (function (v__$1,override){
var map__33406 = override;
var map__33406__$1 = ((((!((map__33406 == null)))?((((map__33406.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33406.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33406):map__33406);
var location = cljs.core.get.call(null,map__33406__$1,new cljs.core.Keyword(null,"location","location",1815599388));
var radius = cljs.core.get.call(null,map__33406__$1,new cljs.core.Keyword(null,"radius","radius",-2073122258));
var falloff = cljs.core.get.call(null,map__33406__$1,new cljs.core.Keyword(null,"falloff","falloff",-1639069456));
var strength = cljs.core.get.call(null,map__33406__$1,new cljs.core.Keyword(null,"strength","strength",-415606478));
var animate_QMARK_ = cljs.core.get.call(null,map__33406__$1,new cljs.core.Keyword(null,"animate?","animate?",-1559039739));
var locx = new cljs.core.Keyword(null,"x","x",2099068185).cljs$core$IFn$_invoke$arity$1(location);
var locy = new cljs.core.Keyword(null,"y","y",-1757859776).cljs$core$IFn$_invoke$arity$1(location);
var dx = (locx - x);
var dy = (locy - y);
var d2 = ((dx * dx) + (dy * dy));
var r2 = (radius * radius);
var fr = falloff;
var f2 = (fr * fr);
var position_weight = (((d2 < f2))?(1):(((d2 < r2))?((1) - ((Math.sqrt(d2) - fr) / (radius - falloff))):(0)
));
var tw = weathergen.model.time_weight.call(null,override,new cljs.core.Keyword(null,"current","current",-1088038603).cljs$core$IFn$_invoke$arity$1(time));
var w = ((position_weight * tw) * strength);
var v_STAR_ = ((new cljs.core.Keyword(null,"pressure","pressure",505343747).cljs$core$IFn$_invoke$arity$1(override) - min_pressure) / pressure_span);
return ((v_STAR_ * w) + (v__$1 * ((1) - w)));
});})(map__33404,map__33404__$1,x,y,t,weather_overrides,time,min_pressure,max_pressure,pressure_span))
,v,weather_overrides));
});
/**
 * x and y are in cells
 */
weathergen.model.weather = (function weathergen$model$weather(p__33408){
var map__33416 = p__33408;
var map__33416__$1 = ((((!((map__33416 == null)))?((((map__33416.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33416.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33416):map__33416);
var params = map__33416__$1;
var wind_uniformity = cljs.core.get.call(null,map__33416__$1,new cljs.core.Keyword(null,"wind-uniformity","wind-uniformity",827531801));
var x = cljs.core.get.call(null,map__33416__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var crossfade = cljs.core.get.call(null,map__33416__$1,new cljs.core.Keyword(null,"crossfade","crossfade",-118506406));
var prevailing_wind = cljs.core.get.call(null,map__33416__$1,new cljs.core.Keyword(null,"prevailing-wind","prevailing-wind",-190580386));
var y = cljs.core.get.call(null,map__33416__$1,new cljs.core.Keyword(null,"y","y",-1757859776));
var temp_uniformity = cljs.core.get.call(null,map__33416__$1,new cljs.core.Keyword(null,"temp-uniformity","temp-uniformity",836756864));
var pressure = cljs.core.get.call(null,map__33416__$1,new cljs.core.Keyword(null,"pressure","pressure",505343747));
var time = cljs.core.get.call(null,map__33416__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var evolution = cljs.core.get.call(null,map__33416__$1,new cljs.core.Keyword(null,"evolution","evolution",944820557));
var seed = cljs.core.get.call(null,map__33416__$1,new cljs.core.Keyword(null,"seed","seed",68613327));
var feature_size = cljs.core.get.call(null,map__33416__$1,new cljs.core.Keyword(null,"feature-size","feature-size",-878734864));
var categories = cljs.core.get.call(null,map__33416__$1,new cljs.core.Keyword(null,"categories","categories",178386610));
var origin = cljs.core.get.call(null,map__33416__$1,new cljs.core.Keyword(null,"origin","origin",1037372088));
var vec__33418 = origin;
var origin_x = cljs.core.nth.call(null,vec__33418,(0),null);
var origin_y = cljs.core.nth.call(null,vec__33418,(1),null);
var x_STAR_ = ((origin_x + x) / feature_size);
var y_STAR_ = ((origin_y + y) / feature_size);
var map__33421 = time;
var map__33421__$1 = ((((!((map__33421 == null)))?((((map__33421.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33421.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33421):map__33421);
var offset = cljs.core.get.call(null,map__33421__$1,new cljs.core.Keyword(null,"offset","offset",296498311));
var current = cljs.core.get.call(null,map__33421__$1,new cljs.core.Keyword(null,"current","current",-1088038603));
var t = (offset + weathergen.time.campaign_time__GT_minutes.call(null,current));
var t_STAR_ = ((t / evolution) / (10));
var max_pressure = new cljs.core.Keyword(null,"max","max",61366548).cljs$core$IFn$_invoke$arity$1(pressure);
var min_pressure = new cljs.core.Keyword(null,"min","min",444991522).cljs$core$IFn$_invoke$arity$1(pressure);
var params_STAR_ = cljs.core.assoc.call(null,params,new cljs.core.Keyword("org.craigandera.weathergen.pattern-space","x","org.craigandera.weathergen.pattern-space/x",441833243),x_STAR_,new cljs.core.Keyword("org.craigandera.weathergen.pattern-space","y","org.craigandera.weathergen.pattern-space/y",-176904590),y_STAR_,new cljs.core.Keyword("org.craigandera.weathergen.pattern-space","t","org.craigandera.weathergen.pattern-space/t",1253598919),t_STAR_);
var p = weathergen.model.perturb.call(null,params_STAR_);
var value = weathergen.model.override.call(null,params,weathergen.model.pressure_pattern.call(null,p));
var wind_dir = weathergen.model.wind_direction.call(null,p,value,params_STAR_);
var pressure__$1 = weathergen.math.clamp.call(null,min_pressure,max_pressure,(min_pressure + ((max_pressure - min_pressure) * value)));
var mixture = weathergen.model.mix.call(null,value,crossfade,categories,min_pressure,max_pressure);
var wind_var = weathergen.math.reject_tails.call(null,wind_uniformity,weathergen.model.smoothed_noise_field.call(null,(x_STAR_ * feature_size),(y_STAR_ * feature_size),t_STAR_,(seed + (17)),(32)));
var temp_var = weathergen.math.reject_tails.call(null,temp_uniformity,weathergen.model.smoothed_noise_field.call(null,(x_STAR_ * feature_size),(y_STAR_ * feature_size),t_STAR_,(seed + (18)),(32)));
return cljs.core.PersistentHashMap.fromArrays([new cljs.core.Keyword(null,"pressure","pressure",505343747),new cljs.core.Keyword(null,"value","value",305978217),new cljs.core.Keyword(null,"type","type",1174270348),new cljs.core.Keyword(null,"wind","wind",-527553074),new cljs.core.Keyword(null,"mixture","mixture",-739485872),new cljs.core.Keyword(null,"wind-var","wind-var",-996728908),new cljs.core.Keyword(null,"wind-vec","wind-vec",-1062133259),new cljs.core.Keyword(null,"p","p",151049309),new cljs.core.Keyword(null,"temperature","temperature",899018429)],[weathergen.math.nearest.call(null,pressure__$1,0.01),value,cljs.core.key.call(null,cljs.core.last.call(null,cljs.core.sort_by.call(null,cljs.core.val,mixture))),weathergen.model.stabilize_wind.call(null,params_STAR_,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"heading","heading",-1312171873),weathergen.math.heading.call(null,wind_dir),new cljs.core.Keyword(null,"speed","speed",1257663751),weathergen.model.wind_speed.call(null,categories,mixture,wind_var)], null)),mixture,wind_var,wind_dir,p,weathergen.model.temperature.call(null,categories,mixture,temp_var)]);
});
weathergen.model.weather_grid = (function weathergen$model$weather_grid(p__33423){
var map__33449 = p__33423;
var map__33449__$1 = ((((!((map__33449 == null)))?((((map__33449.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33449.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33449):map__33449);
var params = map__33449__$1;
var map_fn = cljs.core.get.call(null,map__33449__$1,new cljs.core.Keyword(null,"map-fn","map-fn",1184112686));
var cells = cljs.core.get.call(null,map__33449__$1,new cljs.core.Keyword(null,"cells","cells",-985166822));
var origin = cljs.core.get.call(null,map__33449__$1,new cljs.core.Keyword(null,"origin","origin",1037372088));
var time = cljs.core.get.call(null,map__33449__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var map_fn__$1 = (function (){var or__23148__auto__ = map_fn;
if(cljs.core.truth_(or__23148__auto__)){
return or__23148__auto__;
} else {
return cljs.core.map;
}
})();
return cljs.core.into.call(null,cljs.core.sorted_map.call(null),map_fn__$1.call(null,((function (map_fn__$1,map__33449,map__33449__$1,params,map_fn,cells,origin,time){
return (function (p__33451){
var vec__33452 = p__33451;
var vec__33455 = cljs.core.nth.call(null,vec__33452,(0),null);
var x = cljs.core.nth.call(null,vec__33455,(0),null);
var y = cljs.core.nth.call(null,vec__33455,(1),null);
var params__$1 = cljs.core.nth.call(null,vec__33452,(1),null);
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [x,y], null),weathergen.model.weather.call(null,params__$1)], null);
});})(map_fn__$1,map__33449,map__33449__$1,params,map_fn,cells,origin,time))
,(function (){var iter__24010__auto__ = ((function (map_fn__$1,map__33449,map__33449__$1,params,map_fn,cells,origin,time){
return (function weathergen$model$weather_grid_$_iter__33458(s__33459){
return (new cljs.core.LazySeq(null,((function (map_fn__$1,map__33449,map__33449__$1,params,map_fn,cells,origin,time){
return (function (){
var s__33459__$1 = s__33459;
while(true){
var temp__5278__auto__ = cljs.core.seq.call(null,s__33459__$1);
if(temp__5278__auto__){
var s__33459__$2 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,s__33459__$2)){
var c__24008__auto__ = cljs.core.chunk_first.call(null,s__33459__$2);
var size__24009__auto__ = cljs.core.count.call(null,c__24008__auto__);
var b__33461 = cljs.core.chunk_buffer.call(null,size__24009__auto__);
if((function (){var i__33460 = (0);
while(true){
if((i__33460 < size__24009__auto__)){
var vec__33468 = cljs.core._nth.call(null,c__24008__auto__,i__33460);
var x = cljs.core.nth.call(null,vec__33468,(0),null);
var y = cljs.core.nth.call(null,vec__33468,(1),null);
cljs.core.chunk_append.call(null,b__33461,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [x,y], null),cljs.core.assoc.call(null,params,new cljs.core.Keyword(null,"x","x",2099068185),x,new cljs.core.Keyword(null,"y","y",-1757859776),y)], null));

var G__33474 = (i__33460 + (1));
i__33460 = G__33474;
continue;
} else {
return true;
}
break;
}
})()){
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__33461),weathergen$model$weather_grid_$_iter__33458.call(null,cljs.core.chunk_rest.call(null,s__33459__$2)));
} else {
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__33461),null);
}
} else {
var vec__33471 = cljs.core.first.call(null,s__33459__$2);
var x = cljs.core.nth.call(null,vec__33471,(0),null);
var y = cljs.core.nth.call(null,vec__33471,(1),null);
return cljs.core.cons.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [x,y], null),cljs.core.assoc.call(null,params,new cljs.core.Keyword(null,"x","x",2099068185),x,new cljs.core.Keyword(null,"y","y",-1757859776),y)], null),weathergen$model$weather_grid_$_iter__33458.call(null,cljs.core.rest.call(null,s__33459__$2)));
}
} else {
return null;
}
break;
}
});})(map_fn__$1,map__33449,map__33449__$1,params,map_fn,cells,origin,time))
,null,null));
});})(map_fn__$1,map__33449,map__33449__$1,params,map_fn,cells,origin,time))
;
return iter__24010__auto__.call(null,cells);
})()));
});
/**
 * Returns an updated weather-params that has been moved in time and
 *   space according to movement-params by `steps`.
 */
weathergen.model.step = (function weathergen$model$step(weather_params,movement_params,steps){
var map__33479 = movement_params;
var map__33479__$1 = ((((!((map__33479 == null)))?((((map__33479.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33479.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33479):map__33479);
var step = cljs.core.get.call(null,map__33479__$1,new cljs.core.Keyword(null,"step","step",1288888124));
var direction = cljs.core.get.call(null,map__33479__$1,new cljs.core.Keyword(null,"direction","direction",-633359395));
var map__33480 = direction;
var map__33480__$1 = ((((!((map__33480 == null)))?((((map__33480.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33480.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33480):map__33480);
var speed = cljs.core.get.call(null,map__33480__$1,new cljs.core.Keyword(null,"speed","speed",1257663751));
var heading = cljs.core.get.call(null,map__33480__$1,new cljs.core.Keyword(null,"heading","heading",-1312171873));
var delta_t = (steps * step);
return cljs.core.update.call(null,cljs.core.update_in.call(null,weather_params,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"time","time",1385887882),new cljs.core.Keyword(null,"current","current",-1088038603)], null),weathergen.time.add_minutes,delta_t),new cljs.core.Keyword(null,"origin","origin",1037372088),weathergen.math.vector_add,weathergen.math.scale.call(null,(delta_t * ((speed / (60)) / (9))),weathergen.math.rotate.call(null,(- heading),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(0),(1)], null))));
});
/**
 * Return a map, keyed by time, with the weather forecast for the
 *   given location. First forecast is for start time from weather
 *   params, with `steps` forecasts in total. Step size is as specified
 *   by movement params.
 */
weathergen.model.forecast = (function weathergen$model$forecast(p__33485,weather_params,movement_params,interval,steps){
var vec__33513 = p__33485;
var x = cljs.core.nth.call(null,vec__33513,(0),null);
var y = cljs.core.nth.call(null,vec__33513,(1),null);
var map__33516 = weather_params;
var map__33516__$1 = ((((!((map__33516 == null)))?((((map__33516.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33516.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33516):map__33516);
var seed = cljs.core.get.call(null,map__33516__$1,new cljs.core.Keyword(null,"seed","seed",68613327));
var time = cljs.core.get.call(null,map__33516__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var map__33517 = time;
var map__33517__$1 = ((((!((map__33517 == null)))?((((map__33517.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33517.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33517):map__33517);
var offset = cljs.core.get.call(null,map__33517__$1,new cljs.core.Keyword(null,"offset","offset",296498311));
var current = cljs.core.get.call(null,map__33517__$1,new cljs.core.Keyword(null,"current","current",-1088038603));
var max = cljs.core.get.call(null,map__33517__$1,new cljs.core.Keyword(null,"max","max",61366548));
var map__33518 = movement_params;
var map__33518__$1 = ((((!((map__33518 == null)))?((((map__33518.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33518.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33518):map__33518);
var direction = cljs.core.get.call(null,map__33518__$1,new cljs.core.Keyword(null,"direction","direction",-633359395));
var step = cljs.core.get.call(null,map__33518__$1,new cljs.core.Keyword(null,"step","step",1288888124));
var map__33519 = direction;
var map__33519__$1 = ((((!((map__33519 == null)))?((((map__33519.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33519.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33519):map__33519);
var heading = cljs.core.get.call(null,map__33519__$1,new cljs.core.Keyword(null,"heading","heading",-1312171873));
var speed = cljs.core.get.call(null,map__33519__$1,new cljs.core.Keyword(null,"speed","speed",1257663751));
var now = weathergen.time.campaign_time__GT_minutes.call(null,current);
var max_t = (cljs.core.truth_(max)?weathergen.time.campaign_time__GT_minutes.call(null,max):null);
var weather_params_STAR_ = cljs.core.update.call(null,weather_params,new cljs.core.Keyword(null,"weather-overrides","weather-overrides",-837381710),((function (map__33516,map__33516__$1,seed,time,map__33517,map__33517__$1,offset,current,max,map__33518,map__33518__$1,direction,step,map__33519,map__33519__$1,heading,speed,now,max_t,vec__33513,x,y){
return (function (p1__33483_SHARP_){
return cljs.core.remove.call(null,new cljs.core.Keyword(null,"exclude-from-forecast?","exclude-from-forecast?",1182671640),p1__33483_SHARP_);
});})(map__33516,map__33516__$1,seed,time,map__33517,map__33517__$1,offset,current,max,map__33518,map__33518__$1,direction,step,map__33519,map__33519__$1,heading,speed,now,max_t,vec__33513,x,y))
);
return cljs.core.into.call(null,cljs.core.sorted_map_by.call(null,((function (map__33516,map__33516__$1,seed,time,map__33517,map__33517__$1,offset,current,max,map__33518,map__33518__$1,direction,step,map__33519,map__33519__$1,heading,speed,now,max_t,weather_params_STAR_,vec__33513,x,y){
return (function (a,b){
return cljs.core.compare.call(null,weathergen.time.campaign_time__GT_minutes.call(null,a),weathergen.time.campaign_time__GT_minutes.call(null,b));
});})(map__33516,map__33516__$1,seed,time,map__33517,map__33517__$1,offset,current,max,map__33518,map__33518__$1,direction,step,map__33519,map__33519__$1,heading,speed,now,max_t,weather_params_STAR_,vec__33513,x,y))
),(function (){var iter__24010__auto__ = ((function (map__33516,map__33516__$1,seed,time,map__33517,map__33517__$1,offset,current,max,map__33518,map__33518__$1,direction,step,map__33519,map__33519__$1,heading,speed,now,max_t,weather_params_STAR_,vec__33513,x,y){
return (function weathergen$model$forecast_$_iter__33524(s__33525){
return (new cljs.core.LazySeq(null,((function (map__33516,map__33516__$1,seed,time,map__33517,map__33517__$1,offset,current,max,map__33518,map__33518__$1,direction,step,map__33519,map__33519__$1,heading,speed,now,max_t,weather_params_STAR_,vec__33513,x,y){
return (function (){
var s__33525__$1 = s__33525;
while(true){
var temp__5278__auto__ = cljs.core.seq.call(null,s__33525__$1);
if(temp__5278__auto__){
var s__33525__$2 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,s__33525__$2)){
var c__24008__auto__ = cljs.core.chunk_first.call(null,s__33525__$2);
var size__24009__auto__ = cljs.core.count.call(null,c__24008__auto__);
var b__33527 = cljs.core.chunk_buffer.call(null,size__24009__auto__);
if((function (){var i__33526 = (0);
while(true){
if((i__33526 < size__24009__auto__)){
var t = cljs.core._nth.call(null,c__24008__auto__,i__33526);
var dt = (t - now);
var vec__33534 = weathergen.math.scale.call(null,(dt * ((speed / (60)) / (9))),weathergen.math.rotate.call(null,(- heading),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(0),(1)], null)));
var dx = cljs.core.nth.call(null,vec__33534,(0),null);
var dy = cljs.core.nth.call(null,vec__33534,(1),null);
var dpos = vec__33534;
cljs.core.chunk_append.call(null,b__33527,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [weathergen.time.minutes__GT_campaign_time.call(null,t),weathergen.model.weather.call(null,cljs.core.update.call(null,cljs.core.assoc_in.call(null,cljs.core.assoc_in.call(null,cljs.core.assoc.call(null,(cljs.core.truth_((function (){var or__23148__auto__ = cljs.core._EQ_.call(null,t,now);
if(or__23148__auto__){
return or__23148__auto__;
} else {
var and__23136__auto__ = max_t;
if(cljs.core.truth_(and__23136__auto__)){
return (t <= max_t);
} else {
return and__23136__auto__;
}
}
})())?weather_params:weather_params_STAR_),new cljs.core.Keyword(null,"x","x",2099068185),x,new cljs.core.Keyword(null,"y","y",-1757859776),y),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"time","time",1385887882),new cljs.core.Keyword(null,"current","current",-1088038603)], null),weathergen.time.minutes__GT_campaign_time.call(null,t)),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"time","time",1385887882),new cljs.core.Keyword(null,"offset","offset",296498311)], null),(offset - dt)),new cljs.core.Keyword(null,"origin","origin",1037372088),weathergen.math.vector_add,dpos))], null));

var G__33540 = (i__33526 + (1));
i__33526 = G__33540;
continue;
} else {
return true;
}
break;
}
})()){
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__33527),weathergen$model$forecast_$_iter__33524.call(null,cljs.core.chunk_rest.call(null,s__33525__$2)));
} else {
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__33527),null);
}
} else {
var t = cljs.core.first.call(null,s__33525__$2);
var dt = (t - now);
var vec__33537 = weathergen.math.scale.call(null,(dt * ((speed / (60)) / (9))),weathergen.math.rotate.call(null,(- heading),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(0),(1)], null)));
var dx = cljs.core.nth.call(null,vec__33537,(0),null);
var dy = cljs.core.nth.call(null,vec__33537,(1),null);
var dpos = vec__33537;
return cljs.core.cons.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [weathergen.time.minutes__GT_campaign_time.call(null,t),weathergen.model.weather.call(null,cljs.core.update.call(null,cljs.core.assoc_in.call(null,cljs.core.assoc_in.call(null,cljs.core.assoc.call(null,(cljs.core.truth_((function (){var or__23148__auto__ = cljs.core._EQ_.call(null,t,now);
if(or__23148__auto__){
return or__23148__auto__;
} else {
var and__23136__auto__ = max_t;
if(cljs.core.truth_(and__23136__auto__)){
return (t <= max_t);
} else {
return and__23136__auto__;
}
}
})())?weather_params:weather_params_STAR_),new cljs.core.Keyword(null,"x","x",2099068185),x,new cljs.core.Keyword(null,"y","y",-1757859776),y),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"time","time",1385887882),new cljs.core.Keyword(null,"current","current",-1088038603)], null),weathergen.time.minutes__GT_campaign_time.call(null,t)),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"time","time",1385887882),new cljs.core.Keyword(null,"offset","offset",296498311)], null),(offset - dt)),new cljs.core.Keyword(null,"origin","origin",1037372088),weathergen.math.vector_add,dpos))], null),weathergen$model$forecast_$_iter__33524.call(null,cljs.core.rest.call(null,s__33525__$2)));
}
} else {
return null;
}
break;
}
});})(map__33516,map__33516__$1,seed,time,map__33517,map__33517__$1,offset,current,max,map__33518,map__33518__$1,direction,step,map__33519,map__33519__$1,heading,speed,now,max_t,weather_params_STAR_,vec__33513,x,y))
,null,null));
});})(map__33516,map__33516__$1,seed,time,map__33517,map__33517__$1,offset,current,max,map__33518,map__33518__$1,direction,step,map__33519,map__33519__$1,heading,speed,now,max_t,weather_params_STAR_,vec__33513,x,y))
;
return iter__24010__auto__.call(null,cljs.core.into.call(null,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [now], null),cljs.core.map.call(null,((function (iter__24010__auto__,map__33516,map__33516__$1,seed,time,map__33517,map__33517__$1,offset,current,max,map__33518,map__33518__$1,direction,step,map__33519,map__33519__$1,heading,speed,now,max_t,weather_params_STAR_,vec__33513,x,y){
return (function (p1__33484_SHARP_){
return (cljs.core.long$.call(null,((((p1__33484_SHARP_ + (1)) * interval) + now) / interval)) * interval);
});})(iter__24010__auto__,map__33516,map__33516__$1,seed,time,map__33517,map__33517__$1,offset,current,max,map__33518,map__33518__$1,direction,step,map__33519,map__33519__$1,heading,speed,now,max_t,weather_params_STAR_,vec__33513,x,y))
,cljs.core.range.call(null,steps))));
})());
});
/**
 * Return a new weather params that has been moved to the specified
 *   time. Weather changes.
 */
weathergen.model.jump_to_time = (function weathergen$model$jump_to_time(weather_params,movement_params,t){
var map__33549 = movement_params;
var map__33549__$1 = ((((!((map__33549 == null)))?((((map__33549.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33549.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33549):map__33549);
var evolution = cljs.core.get.call(null,map__33549__$1,new cljs.core.Keyword(null,"evolution","evolution",944820557));
var direction = cljs.core.get.call(null,map__33549__$1,new cljs.core.Keyword(null,"direction","direction",-633359395));
var map__33550 = direction;
var map__33550__$1 = ((((!((map__33550 == null)))?((((map__33550.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33550.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33550):map__33550);
var speed = cljs.core.get.call(null,map__33550__$1,new cljs.core.Keyword(null,"speed","speed",1257663751));
var heading = cljs.core.get.call(null,map__33550__$1,new cljs.core.Keyword(null,"heading","heading",-1312171873));
var map__33551 = weather_params;
var map__33551__$1 = ((((!((map__33551 == null)))?((((map__33551.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33551.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33551):map__33551);
var time = cljs.core.get.call(null,map__33551__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var map__33552 = time;
var map__33552__$1 = ((((!((map__33552 == null)))?((((map__33552.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33552.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33552):map__33552);
var current = cljs.core.get.call(null,map__33552__$1,new cljs.core.Keyword(null,"current","current",-1088038603));
var delta_t = (weathergen.time.campaign_time__GT_minutes.call(null,t) - weathergen.time.campaign_time__GT_minutes.call(null,current));
var new$ = cljs.core.assoc_in.call(null,cljs.core.update.call(null,weather_params,new cljs.core.Keyword(null,"origin","origin",1037372088),weathergen.math.vector_add,weathergen.math.scale.call(null,(delta_t * ((speed / (60)) / (9))),weathergen.math.rotate.call(null,(- heading),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(0),(1)], null)))),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"time","time",1385887882),new cljs.core.Keyword(null,"current","current",-1088038603)], null),t);
cljs.core.println.call(null,new cljs.core.Keyword(null,"new","new",-2085437848),new$);

return new$;
});
/**
 * Adjust the time coordinate so that the current time is adjusted to
 *   match the provided time without changing the location in weather
 *   space.
 */
weathergen.model.set_time = (function weathergen$model$set_time(weather_params,time){
var offset = cljs.core.get_in.call(null,weather_params,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"time","time",1385887882),new cljs.core.Keyword(null,"offset","offset",296498311)], null));
var current_time = cljs.core.get_in.call(null,weather_params,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"time","time",1385887882),new cljs.core.Keyword(null,"current","current",-1088038603)], null));
var delta = (weathergen.time.campaign_time__GT_minutes.call(null,current_time) - weathergen.time.campaign_time__GT_minutes.call(null,time));
return cljs.core.assoc_in.call(null,cljs.core.update_in.call(null,weather_params,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"time","time",1385887882),new cljs.core.Keyword(null,"offset","offset",296498311)], null),cljs.core._PLUS_,delta),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"time","time",1385887882),new cljs.core.Keyword(null,"current","current",-1088038603)], null),time);
});
/**
 * Performs the upgrade from the weight-based thresholds to explicit
 *   pressure thresholds.
 */
weathergen.model.upgrade_pressure_threshold = (function weathergen$model$upgrade_pressure_threshold(params){
var min_pressure = cljs.core.get_in.call(null,params,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"weather-params","weather-params",-259271365),new cljs.core.Keyword(null,"pressure","pressure",505343747),new cljs.core.Keyword(null,"min","min",444991522)], null));
var max_pressure = cljs.core.get_in.call(null,params,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"weather-params","weather-params",-259271365),new cljs.core.Keyword(null,"pressure","pressure",505343747),new cljs.core.Keyword(null,"max","max",61366548)], null));
var pressure_span = (max_pressure - min_pressure);
var normalize = ((function (min_pressure,max_pressure,pressure_span){
return (function (relative){
return (min_pressure + (relative * pressure_span));
});})(min_pressure,max_pressure,pressure_span))
;
var cumulative = cljs.core.reductions.call(null,cljs.core._PLUS_,cljs.core.map.call(null,((function (min_pressure,max_pressure,pressure_span,normalize){
return (function (p1__33557_SHARP_){
return cljs.core.get_in.call(null,params,new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"weather-params","weather-params",-259271365),new cljs.core.Keyword(null,"categories","categories",178386610),p1__33557_SHARP_,new cljs.core.Keyword(null,"weight","weight",-1262796205)], null));
});})(min_pressure,max_pressure,pressure_span,normalize))
,weathergen.model.types));
var total = cljs.core.last.call(null,cumulative);
var thresholds = cljs.core.zipmap.call(null,weathergen.model.types,cljs.core.map.call(null,((function (min_pressure,max_pressure,pressure_span,normalize,cumulative,total){
return (function (p1__33558_SHARP_){
return weathergen.math.nearest.call(null,(((p1__33558_SHARP_ / total) * pressure_span) + min_pressure),0.01);
});})(min_pressure,max_pressure,pressure_span,normalize,cumulative,total))
,cumulative));
return cljs.core.reduce.call(null,((function (min_pressure,max_pressure,pressure_span,normalize,cumulative,total,thresholds){
return (function (params__$1,type){
return cljs.core.assoc_in.call(null,params__$1,new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"weather-params","weather-params",-259271365),new cljs.core.Keyword(null,"categories","categories",178386610),type,new cljs.core.Keyword(null,"pressure","pressure",505343747)], null),thresholds.call(null,type));
});})(min_pressure,max_pressure,pressure_span,normalize,cumulative,total,thresholds))
,params,weathergen.model.types);
});
weathergen.model.upgrade = (function weathergen$model$upgrade(p__33559,new_revision){
var map__33563 = p__33559;
var map__33563__$1 = ((((!((map__33563 == null)))?((((map__33563.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__33563.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__33563):map__33563);
var params = map__33563__$1;
var revision = cljs.core.get.call(null,map__33563__$1,new cljs.core.Keyword(null,"revision","revision",-1350113114));
var G__33565 = params;
var G__33565__$1 = (((revision < (7)))?weathergen.model.upgrade_pressure_threshold.call(null,G__33565):G__33565);
return cljs.core.assoc.call(null,G__33565__$1,new cljs.core.Keyword(null,"revision","revision",-1350113114),new_revision);

});
