// 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__41972 = cljs.core.first.call(null,cljs.core.filter.call(null,((function (pressure_span,i,p,f,s,contour){
return (function (p__41981){
var vec__41982 = p__41981;
var vec__41985 = cljs.core.nth.call(null,vec__41982,(0),null);
var low = cljs.core.nth.call(null,vec__41985,(0),null);
var vec__41988 = cljs.core.nth.call(null,vec__41982,(1),null);
var high = cljs.core.nth.call(null,vec__41988,(0),null);
return ((low <= x)) && ((x <= high));
});})(pressure_span,i,p,f,s,contour))
,cljs.core.partition.call(null,(2),(1),contour)));
var vec__41975 = cljs.core.nth.call(null,vec__41972,(0),null);
var x1 = cljs.core.nth.call(null,vec__41975,(0),null);
var v1 = cljs.core.nth.call(null,vec__41975,(1),null);
var vec__41978 = cljs.core.nth.call(null,vec__41972,(1),null);
var x2 = cljs.core.nth.call(null,vec__41978,(0),null);
var v2 = cljs.core.nth.call(null,vec__41978,(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__41995){
var vec__41996 = p__41995;
var type = cljs.core.nth.call(null,vec__41996,(0),null);
var weight = cljs.core.nth.call(null,vec__41996,(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__42001 = params;
var map__42001__$1 = ((((!((map__42001 == null)))?((((map__42001.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42001.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42001):map__42001);
var x = cljs.core.get.call(null,map__42001__$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__42001__$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__42001__$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__42001__$1,new cljs.core.Keyword(null,"seed","seed",68613327));
var turbulence = cljs.core.get.call(null,map__42001__$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__42003){
var vec__42007 = p__42003;
var x = cljs.core.nth.call(null,vec__42007,(0),null);
var y = cljs.core.nth.call(null,vec__42007,(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__42010,v,params){
var vec__42014 = p__42010;
var x = cljs.core.nth.call(null,vec__42014,(0),null);
var y = cljs.core.nth.call(null,vec__42014,(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__42017,x_STAR_,y_STAR_){
var map__42020 = p__42017;
var map__42020__$1 = ((((!((map__42020 == null)))?((((map__42020.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42020.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42020):map__42020);
var bounds = map__42020__$1;
var x = cljs.core.get.call(null,map__42020__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var y = cljs.core.get.call(null,map__42020__$1,new cljs.core.Keyword(null,"y","y",-1757859776));
var width = cljs.core.get.call(null,map__42020__$1,new cljs.core.Keyword(null,"width","width",-384071477));
var height = cljs.core.get.call(null,map__42020__$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__42023,pattern_wind){
var map__42026 = p__42023;
var map__42026__$1 = ((((!((map__42026 == null)))?((((map__42026.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42026.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42026):map__42026);
var wind_stability_areas = cljs.core.get.call(null,map__42026__$1,new cljs.core.Keyword(null,"wind-stability-areas","wind-stability-areas",1732901204));
var x = cljs.core.get.call(null,map__42026__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var y = cljs.core.get.call(null,map__42026__$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__42026,map__42026__$1,wind_stability_areas,x,y){
return (function (p1__42022_SHARP_){
return weathergen.model.in_area_QMARK_.call(null,new cljs.core.Keyword(null,"bounds","bounds",1691609455).cljs$core$IFn$_invoke$arity$1(p1__42022_SHARP_),x,y);
});})(_QMARK_,map__42026,map__42026__$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__42030 = override;
var map__42030__$1 = ((((!((map__42030 == null)))?((((map__42030.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42030.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42030):map__42030);
var begin = cljs.core.get.call(null,map__42030__$1,new cljs.core.Keyword(null,"begin","begin",-319034319));
var peak = cljs.core.get.call(null,map__42030__$1,new cljs.core.Keyword(null,"peak","peak",389096055));
var taper = cljs.core.get.call(null,map__42030__$1,new cljs.core.Keyword(null,"taper","taper",1772067478));
var end = cljs.core.get.call(null,map__42030__$1,new cljs.core.Keyword(null,"end","end",-268185958));
var animate_QMARK_ = cljs.core.get.call(null,map__42030__$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__42036 = params;
var map__42036__$1 = ((((!((map__42036 == null)))?((((map__42036.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42036.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42036):map__42036);
var x = cljs.core.get.call(null,map__42036__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var y = cljs.core.get.call(null,map__42036__$1,new cljs.core.Keyword(null,"y","y",-1757859776));
var t = cljs.core.get.call(null,map__42036__$1,new cljs.core.Keyword(null,"t","t",-1397832519));
var weather_overrides = cljs.core.get.call(null,map__42036__$1,new cljs.core.Keyword(null,"weather-overrides","weather-overrides",-837381710));
var time = cljs.core.get.call(null,map__42036__$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__42036,map__42036__$1,x,y,t,weather_overrides,time,min_pressure,max_pressure,pressure_span){
return (function (v__$1,override){
var map__42038 = override;
var map__42038__$1 = ((((!((map__42038 == null)))?((((map__42038.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42038.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42038):map__42038);
var location = cljs.core.get.call(null,map__42038__$1,new cljs.core.Keyword(null,"location","location",1815599388));
var radius = cljs.core.get.call(null,map__42038__$1,new cljs.core.Keyword(null,"radius","radius",-2073122258));
var falloff = cljs.core.get.call(null,map__42038__$1,new cljs.core.Keyword(null,"falloff","falloff",-1639069456));
var strength = cljs.core.get.call(null,map__42038__$1,new cljs.core.Keyword(null,"strength","strength",-415606478));
var animate_QMARK_ = cljs.core.get.call(null,map__42038__$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__42036,map__42036__$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__42040){
var map__42048 = p__42040;
var map__42048__$1 = ((((!((map__42048 == null)))?((((map__42048.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42048.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42048):map__42048);
var params = map__42048__$1;
var wind_uniformity = cljs.core.get.call(null,map__42048__$1,new cljs.core.Keyword(null,"wind-uniformity","wind-uniformity",827531801));
var x = cljs.core.get.call(null,map__42048__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var crossfade = cljs.core.get.call(null,map__42048__$1,new cljs.core.Keyword(null,"crossfade","crossfade",-118506406));
var prevailing_wind = cljs.core.get.call(null,map__42048__$1,new cljs.core.Keyword(null,"prevailing-wind","prevailing-wind",-190580386));
var y = cljs.core.get.call(null,map__42048__$1,new cljs.core.Keyword(null,"y","y",-1757859776));
var temp_uniformity = cljs.core.get.call(null,map__42048__$1,new cljs.core.Keyword(null,"temp-uniformity","temp-uniformity",836756864));
var pressure = cljs.core.get.call(null,map__42048__$1,new cljs.core.Keyword(null,"pressure","pressure",505343747));
var time = cljs.core.get.call(null,map__42048__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var evolution = cljs.core.get.call(null,map__42048__$1,new cljs.core.Keyword(null,"evolution","evolution",944820557));
var seed = cljs.core.get.call(null,map__42048__$1,new cljs.core.Keyword(null,"seed","seed",68613327));
var feature_size = cljs.core.get.call(null,map__42048__$1,new cljs.core.Keyword(null,"feature-size","feature-size",-878734864));
var categories = cljs.core.get.call(null,map__42048__$1,new cljs.core.Keyword(null,"categories","categories",178386610));
var origin = cljs.core.get.call(null,map__42048__$1,new cljs.core.Keyword(null,"origin","origin",1037372088));
var vec__42050 = origin;
var origin_x = cljs.core.nth.call(null,vec__42050,(0),null);
var origin_y = cljs.core.nth.call(null,vec__42050,(1),null);
var x_STAR_ = ((origin_x + x) / feature_size);
var y_STAR_ = ((origin_y + y) / feature_size);
var map__42053 = time;
var map__42053__$1 = ((((!((map__42053 == null)))?((((map__42053.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42053.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42053):map__42053);
var offset = cljs.core.get.call(null,map__42053__$1,new cljs.core.Keyword(null,"offset","offset",296498311));
var current = cljs.core.get.call(null,map__42053__$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__42055){
var map__42081 = p__42055;
var map__42081__$1 = ((((!((map__42081 == null)))?((((map__42081.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42081.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42081):map__42081);
var params = map__42081__$1;
var map_fn = cljs.core.get.call(null,map__42081__$1,new cljs.core.Keyword(null,"map-fn","map-fn",1184112686));
var cells = cljs.core.get.call(null,map__42081__$1,new cljs.core.Keyword(null,"cells","cells",-985166822));
var origin = cljs.core.get.call(null,map__42081__$1,new cljs.core.Keyword(null,"origin","origin",1037372088));
var time = cljs.core.get.call(null,map__42081__$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__42081,map__42081__$1,params,map_fn,cells,origin,time){
return (function (p__42083){
var vec__42084 = p__42083;
var vec__42087 = cljs.core.nth.call(null,vec__42084,(0),null);
var x = cljs.core.nth.call(null,vec__42087,(0),null);
var y = cljs.core.nth.call(null,vec__42087,(1),null);
var params__$1 = cljs.core.nth.call(null,vec__42084,(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__42081,map__42081__$1,params,map_fn,cells,origin,time))
,(function (){var iter__24010__auto__ = ((function (map_fn__$1,map__42081,map__42081__$1,params,map_fn,cells,origin,time){
return (function weathergen$model$weather_grid_$_iter__42090(s__42091){
return (new cljs.core.LazySeq(null,((function (map_fn__$1,map__42081,map__42081__$1,params,map_fn,cells,origin,time){
return (function (){
var s__42091__$1 = s__42091;
while(true){
var temp__5278__auto__ = cljs.core.seq.call(null,s__42091__$1);
if(temp__5278__auto__){
var s__42091__$2 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,s__42091__$2)){
var c__24008__auto__ = cljs.core.chunk_first.call(null,s__42091__$2);
var size__24009__auto__ = cljs.core.count.call(null,c__24008__auto__);
var b__42093 = cljs.core.chunk_buffer.call(null,size__24009__auto__);
if((function (){var i__42092 = (0);
while(true){
if((i__42092 < size__24009__auto__)){
var vec__42100 = cljs.core._nth.call(null,c__24008__auto__,i__42092);
var x = cljs.core.nth.call(null,vec__42100,(0),null);
var y = cljs.core.nth.call(null,vec__42100,(1),null);
cljs.core.chunk_append.call(null,b__42093,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__42106 = (i__42092 + (1));
i__42092 = G__42106;
continue;
} else {
return true;
}
break;
}
})()){
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__42093),weathergen$model$weather_grid_$_iter__42090.call(null,cljs.core.chunk_rest.call(null,s__42091__$2)));
} else {
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__42093),null);
}
} else {
var vec__42103 = cljs.core.first.call(null,s__42091__$2);
var x = cljs.core.nth.call(null,vec__42103,(0),null);
var y = cljs.core.nth.call(null,vec__42103,(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__42090.call(null,cljs.core.rest.call(null,s__42091__$2)));
}
} else {
return null;
}
break;
}
});})(map_fn__$1,map__42081,map__42081__$1,params,map_fn,cells,origin,time))
,null,null));
});})(map_fn__$1,map__42081,map__42081__$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__42111 = movement_params;
var map__42111__$1 = ((((!((map__42111 == null)))?((((map__42111.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42111.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42111):map__42111);
var step = cljs.core.get.call(null,map__42111__$1,new cljs.core.Keyword(null,"step","step",1288888124));
var direction = cljs.core.get.call(null,map__42111__$1,new cljs.core.Keyword(null,"direction","direction",-633359395));
var map__42112 = direction;
var map__42112__$1 = ((((!((map__42112 == null)))?((((map__42112.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42112.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42112):map__42112);
var speed = cljs.core.get.call(null,map__42112__$1,new cljs.core.Keyword(null,"speed","speed",1257663751));
var heading = cljs.core.get.call(null,map__42112__$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__42117,weather_params,movement_params,interval,steps){
var vec__42145 = p__42117;
var x = cljs.core.nth.call(null,vec__42145,(0),null);
var y = cljs.core.nth.call(null,vec__42145,(1),null);
var map__42148 = weather_params;
var map__42148__$1 = ((((!((map__42148 == null)))?((((map__42148.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42148.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42148):map__42148);
var seed = cljs.core.get.call(null,map__42148__$1,new cljs.core.Keyword(null,"seed","seed",68613327));
var time = cljs.core.get.call(null,map__42148__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var map__42149 = time;
var map__42149__$1 = ((((!((map__42149 == null)))?((((map__42149.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42149.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42149):map__42149);
var offset = cljs.core.get.call(null,map__42149__$1,new cljs.core.Keyword(null,"offset","offset",296498311));
var current = cljs.core.get.call(null,map__42149__$1,new cljs.core.Keyword(null,"current","current",-1088038603));
var max = cljs.core.get.call(null,map__42149__$1,new cljs.core.Keyword(null,"max","max",61366548));
var map__42150 = movement_params;
var map__42150__$1 = ((((!((map__42150 == null)))?((((map__42150.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42150.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42150):map__42150);
var direction = cljs.core.get.call(null,map__42150__$1,new cljs.core.Keyword(null,"direction","direction",-633359395));
var step = cljs.core.get.call(null,map__42150__$1,new cljs.core.Keyword(null,"step","step",1288888124));
var map__42151 = direction;
var map__42151__$1 = ((((!((map__42151 == null)))?((((map__42151.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42151.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42151):map__42151);
var heading = cljs.core.get.call(null,map__42151__$1,new cljs.core.Keyword(null,"heading","heading",-1312171873));
var speed = cljs.core.get.call(null,map__42151__$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__42148,map__42148__$1,seed,time,map__42149,map__42149__$1,offset,current,max,map__42150,map__42150__$1,direction,step,map__42151,map__42151__$1,heading,speed,now,max_t,vec__42145,x,y){
return (function (p1__42115_SHARP_){
return cljs.core.remove.call(null,new cljs.core.Keyword(null,"exclude-from-forecast?","exclude-from-forecast?",1182671640),p1__42115_SHARP_);
});})(map__42148,map__42148__$1,seed,time,map__42149,map__42149__$1,offset,current,max,map__42150,map__42150__$1,direction,step,map__42151,map__42151__$1,heading,speed,now,max_t,vec__42145,x,y))
);
return cljs.core.into.call(null,cljs.core.sorted_map_by.call(null,((function (map__42148,map__42148__$1,seed,time,map__42149,map__42149__$1,offset,current,max,map__42150,map__42150__$1,direction,step,map__42151,map__42151__$1,heading,speed,now,max_t,weather_params_STAR_,vec__42145,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__42148,map__42148__$1,seed,time,map__42149,map__42149__$1,offset,current,max,map__42150,map__42150__$1,direction,step,map__42151,map__42151__$1,heading,speed,now,max_t,weather_params_STAR_,vec__42145,x,y))
),(function (){var iter__24010__auto__ = ((function (map__42148,map__42148__$1,seed,time,map__42149,map__42149__$1,offset,current,max,map__42150,map__42150__$1,direction,step,map__42151,map__42151__$1,heading,speed,now,max_t,weather_params_STAR_,vec__42145,x,y){
return (function weathergen$model$forecast_$_iter__42156(s__42157){
return (new cljs.core.LazySeq(null,((function (map__42148,map__42148__$1,seed,time,map__42149,map__42149__$1,offset,current,max,map__42150,map__42150__$1,direction,step,map__42151,map__42151__$1,heading,speed,now,max_t,weather_params_STAR_,vec__42145,x,y){
return (function (){
var s__42157__$1 = s__42157;
while(true){
var temp__5278__auto__ = cljs.core.seq.call(null,s__42157__$1);
if(temp__5278__auto__){
var s__42157__$2 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,s__42157__$2)){
var c__24008__auto__ = cljs.core.chunk_first.call(null,s__42157__$2);
var size__24009__auto__ = cljs.core.count.call(null,c__24008__auto__);
var b__42159 = cljs.core.chunk_buffer.call(null,size__24009__auto__);
if((function (){var i__42158 = (0);
while(true){
if((i__42158 < size__24009__auto__)){
var t = cljs.core._nth.call(null,c__24008__auto__,i__42158);
var dt = (t - now);
var vec__42166 = 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__42166,(0),null);
var dy = cljs.core.nth.call(null,vec__42166,(1),null);
var dpos = vec__42166;
cljs.core.chunk_append.call(null,b__42159,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__42172 = (i__42158 + (1));
i__42158 = G__42172;
continue;
} else {
return true;
}
break;
}
})()){
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__42159),weathergen$model$forecast_$_iter__42156.call(null,cljs.core.chunk_rest.call(null,s__42157__$2)));
} else {
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__42159),null);
}
} else {
var t = cljs.core.first.call(null,s__42157__$2);
var dt = (t - now);
var vec__42169 = 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__42169,(0),null);
var dy = cljs.core.nth.call(null,vec__42169,(1),null);
var dpos = vec__42169;
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__42156.call(null,cljs.core.rest.call(null,s__42157__$2)));
}
} else {
return null;
}
break;
}
});})(map__42148,map__42148__$1,seed,time,map__42149,map__42149__$1,offset,current,max,map__42150,map__42150__$1,direction,step,map__42151,map__42151__$1,heading,speed,now,max_t,weather_params_STAR_,vec__42145,x,y))
,null,null));
});})(map__42148,map__42148__$1,seed,time,map__42149,map__42149__$1,offset,current,max,map__42150,map__42150__$1,direction,step,map__42151,map__42151__$1,heading,speed,now,max_t,weather_params_STAR_,vec__42145,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__42148,map__42148__$1,seed,time,map__42149,map__42149__$1,offset,current,max,map__42150,map__42150__$1,direction,step,map__42151,map__42151__$1,heading,speed,now,max_t,weather_params_STAR_,vec__42145,x,y){
return (function (p1__42116_SHARP_){
return (cljs.core.long$.call(null,((((p1__42116_SHARP_ + (1)) * interval) + now) / interval)) * interval);
});})(iter__24010__auto__,map__42148,map__42148__$1,seed,time,map__42149,map__42149__$1,offset,current,max,map__42150,map__42150__$1,direction,step,map__42151,map__42151__$1,heading,speed,now,max_t,weather_params_STAR_,vec__42145,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__42181 = movement_params;
var map__42181__$1 = ((((!((map__42181 == null)))?((((map__42181.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42181.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42181):map__42181);
var evolution = cljs.core.get.call(null,map__42181__$1,new cljs.core.Keyword(null,"evolution","evolution",944820557));
var direction = cljs.core.get.call(null,map__42181__$1,new cljs.core.Keyword(null,"direction","direction",-633359395));
var map__42182 = direction;
var map__42182__$1 = ((((!((map__42182 == null)))?((((map__42182.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42182.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42182):map__42182);
var speed = cljs.core.get.call(null,map__42182__$1,new cljs.core.Keyword(null,"speed","speed",1257663751));
var heading = cljs.core.get.call(null,map__42182__$1,new cljs.core.Keyword(null,"heading","heading",-1312171873));
var map__42183 = weather_params;
var map__42183__$1 = ((((!((map__42183 == null)))?((((map__42183.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42183.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42183):map__42183);
var time = cljs.core.get.call(null,map__42183__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var map__42184 = time;
var map__42184__$1 = ((((!((map__42184 == null)))?((((map__42184.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42184.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42184):map__42184);
var current = cljs.core.get.call(null,map__42184__$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__42189_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__42189_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__42190_SHARP_){
return weathergen.math.nearest.call(null,(((p1__42190_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__42191,new_revision){
var map__42195 = p__42191;
var map__42195__$1 = ((((!((map__42195 == null)))?((((map__42195.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__42195.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42195):map__42195);
var params = map__42195__$1;
var revision = cljs.core.get.call(null,map__42195__$1,new cljs.core.Keyword(null,"revision","revision",-1350113114));
var G__42197 = params;
var G__42197__$1 = (((revision < (7)))?weathergen.model.upgrade_pressure_threshold.call(null,G__42197):G__42197);
return cljs.core.assoc.call(null,G__42197__$1,new cljs.core.Keyword(null,"revision","revision",-1350113114),new_revision);

});
