// 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__29071 = cljs.core.first.call(null,cljs.core.filter.call(null,((function (pressure_span,i,p,f,s,contour){
return (function (p__29080){
var vec__29081 = p__29080;
var vec__29084 = cljs.core.nth.call(null,vec__29081,(0),null);
var low = cljs.core.nth.call(null,vec__29084,(0),null);
var vec__29087 = cljs.core.nth.call(null,vec__29081,(1),null);
var high = cljs.core.nth.call(null,vec__29087,(0),null);
return ((low <= x)) && ((x <= high));
});})(pressure_span,i,p,f,s,contour))
,cljs.core.partition.call(null,(2),(1),contour)));
var vec__29074 = cljs.core.nth.call(null,vec__29071,(0),null);
var x1 = cljs.core.nth.call(null,vec__29074,(0),null);
var v1 = cljs.core.nth.call(null,vec__29074,(1),null);
var vec__29077 = cljs.core.nth.call(null,vec__29071,(1),null);
var x2 = cljs.core.nth.call(null,vec__29077,(0),null);
var v2 = cljs.core.nth.call(null,vec__29077,(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__29094){
var vec__29095 = p__29094;
var type = cljs.core.nth.call(null,vec__29095,(0),null);
var weight = cljs.core.nth.call(null,vec__29095,(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__29100 = params;
var map__29100__$1 = ((((!((map__29100 == null)))?((((map__29100.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29100.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29100):map__29100);
var x = cljs.core.get.call(null,map__29100__$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__29100__$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__29100__$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__29100__$1,new cljs.core.Keyword(null,"seed","seed",68613327));
var turbulence = cljs.core.get.call(null,map__29100__$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__29102){
var vec__29106 = p__29102;
var x = cljs.core.nth.call(null,vec__29106,(0),null);
var y = cljs.core.nth.call(null,vec__29106,(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__29109,v,params){
var vec__29113 = p__29109;
var x = cljs.core.nth.call(null,vec__29113,(0),null);
var y = cljs.core.nth.call(null,vec__29113,(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__29116,x_STAR_,y_STAR_){
var map__29119 = p__29116;
var map__29119__$1 = ((((!((map__29119 == null)))?((((map__29119.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29119.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29119):map__29119);
var bounds = map__29119__$1;
var x = cljs.core.get.call(null,map__29119__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var y = cljs.core.get.call(null,map__29119__$1,new cljs.core.Keyword(null,"y","y",-1757859776));
var width = cljs.core.get.call(null,map__29119__$1,new cljs.core.Keyword(null,"width","width",-384071477));
var height = cljs.core.get.call(null,map__29119__$1,new cljs.core.Keyword(null,"height","height",1025178622));
var and__23326__auto__ = x;
if(cljs.core.truth_(and__23326__auto__)){
var and__23326__auto____$1 = y;
if(cljs.core.truth_(and__23326__auto____$1)){
var and__23326__auto____$2 = width;
if(cljs.core.truth_(and__23326__auto____$2)){
var and__23326__auto____$3 = height;
if(cljs.core.truth_(and__23326__auto____$3)){
return ((x <= x_STAR_)) && ((x_STAR_ < (x + width))) && ((y <= y_STAR_)) && ((y_STAR_ < (y + height)));
} else {
return and__23326__auto____$3;
}
} else {
return and__23326__auto____$2;
}
} else {
return and__23326__auto____$1;
}
} else {
return and__23326__auto__;
}
});
/**
 * Returns the wind, stabilized if appropriate by a wind stability region
 */
weathergen.model.stabilize_wind = (function weathergen$model$stabilize_wind(p__29122,pattern_wind){
var map__29125 = p__29122;
var map__29125__$1 = ((((!((map__29125 == null)))?((((map__29125.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29125.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29125):map__29125);
var wind_stability_areas = cljs.core.get.call(null,map__29125__$1,new cljs.core.Keyword(null,"wind-stability-areas","wind-stability-areas",1732901204));
var x = cljs.core.get.call(null,map__29125__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var y = cljs.core.get.call(null,map__29125__$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__29125,map__29125__$1,wind_stability_areas,x,y){
return (function (p1__29121_SHARP_){
return weathergen.model.in_area_QMARK_.call(null,new cljs.core.Keyword(null,"bounds","bounds",1691609455).cljs$core$IFn$_invoke$arity$1(p1__29121_SHARP_),x,y);
});})(_QMARK_,map__29125,map__29125__$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__23338__auto__ = _QMARK___$3;
if(cljs.core.truth_(or__23338__auto__)){
return or__23338__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__29129 = override;
var map__29129__$1 = ((((!((map__29129 == null)))?((((map__29129.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29129.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29129):map__29129);
var begin = cljs.core.get.call(null,map__29129__$1,new cljs.core.Keyword(null,"begin","begin",-319034319));
var peak = cljs.core.get.call(null,map__29129__$1,new cljs.core.Keyword(null,"peak","peak",389096055));
var taper = cljs.core.get.call(null,map__29129__$1,new cljs.core.Keyword(null,"taper","taper",1772067478));
var end = cljs.core.get.call(null,map__29129__$1,new cljs.core.Keyword(null,"end","end",-268185958));
var animate_QMARK_ = cljs.core.get.call(null,map__29129__$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__29135 = params;
var map__29135__$1 = ((((!((map__29135 == null)))?((((map__29135.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29135.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29135):map__29135);
var x = cljs.core.get.call(null,map__29135__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var y = cljs.core.get.call(null,map__29135__$1,new cljs.core.Keyword(null,"y","y",-1757859776));
var t = cljs.core.get.call(null,map__29135__$1,new cljs.core.Keyword(null,"t","t",-1397832519));
var weather_overrides = cljs.core.get.call(null,map__29135__$1,new cljs.core.Keyword(null,"weather-overrides","weather-overrides",-837381710));
var time = cljs.core.get.call(null,map__29135__$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__29135,map__29135__$1,x,y,t,weather_overrides,time,min_pressure,max_pressure,pressure_span){
return (function (v__$1,override){
var map__29137 = override;
var map__29137__$1 = ((((!((map__29137 == null)))?((((map__29137.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29137.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29137):map__29137);
var location = cljs.core.get.call(null,map__29137__$1,new cljs.core.Keyword(null,"location","location",1815599388));
var radius = cljs.core.get.call(null,map__29137__$1,new cljs.core.Keyword(null,"radius","radius",-2073122258));
var falloff = cljs.core.get.call(null,map__29137__$1,new cljs.core.Keyword(null,"falloff","falloff",-1639069456));
var strength = cljs.core.get.call(null,map__29137__$1,new cljs.core.Keyword(null,"strength","strength",-415606478));
var animate_QMARK_ = cljs.core.get.call(null,map__29137__$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__29135,map__29135__$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__29139){
var map__29147 = p__29139;
var map__29147__$1 = ((((!((map__29147 == null)))?((((map__29147.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29147.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29147):map__29147);
var params = map__29147__$1;
var wind_uniformity = cljs.core.get.call(null,map__29147__$1,new cljs.core.Keyword(null,"wind-uniformity","wind-uniformity",827531801));
var x = cljs.core.get.call(null,map__29147__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var crossfade = cljs.core.get.call(null,map__29147__$1,new cljs.core.Keyword(null,"crossfade","crossfade",-118506406));
var prevailing_wind = cljs.core.get.call(null,map__29147__$1,new cljs.core.Keyword(null,"prevailing-wind","prevailing-wind",-190580386));
var y = cljs.core.get.call(null,map__29147__$1,new cljs.core.Keyword(null,"y","y",-1757859776));
var temp_uniformity = cljs.core.get.call(null,map__29147__$1,new cljs.core.Keyword(null,"temp-uniformity","temp-uniformity",836756864));
var pressure = cljs.core.get.call(null,map__29147__$1,new cljs.core.Keyword(null,"pressure","pressure",505343747));
var time = cljs.core.get.call(null,map__29147__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var evolution = cljs.core.get.call(null,map__29147__$1,new cljs.core.Keyword(null,"evolution","evolution",944820557));
var seed = cljs.core.get.call(null,map__29147__$1,new cljs.core.Keyword(null,"seed","seed",68613327));
var feature_size = cljs.core.get.call(null,map__29147__$1,new cljs.core.Keyword(null,"feature-size","feature-size",-878734864));
var categories = cljs.core.get.call(null,map__29147__$1,new cljs.core.Keyword(null,"categories","categories",178386610));
var origin = cljs.core.get.call(null,map__29147__$1,new cljs.core.Keyword(null,"origin","origin",1037372088));
var vec__29149 = origin;
var origin_x = cljs.core.nth.call(null,vec__29149,(0),null);
var origin_y = cljs.core.nth.call(null,vec__29149,(1),null);
var x_STAR_ = ((origin_x + x) / feature_size);
var y_STAR_ = ((origin_y + y) / feature_size);
var map__29152 = time;
var map__29152__$1 = ((((!((map__29152 == null)))?((((map__29152.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29152.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29152):map__29152);
var offset = cljs.core.get.call(null,map__29152__$1,new cljs.core.Keyword(null,"offset","offset",296498311));
var current = cljs.core.get.call(null,map__29152__$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__29154){
var map__29180 = p__29154;
var map__29180__$1 = ((((!((map__29180 == null)))?((((map__29180.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29180.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29180):map__29180);
var params = map__29180__$1;
var map_fn = cljs.core.get.call(null,map__29180__$1,new cljs.core.Keyword(null,"map-fn","map-fn",1184112686));
var cells = cljs.core.get.call(null,map__29180__$1,new cljs.core.Keyword(null,"cells","cells",-985166822));
var origin = cljs.core.get.call(null,map__29180__$1,new cljs.core.Keyword(null,"origin","origin",1037372088));
var time = cljs.core.get.call(null,map__29180__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var map_fn__$1 = (function (){var or__23338__auto__ = map_fn;
if(cljs.core.truth_(or__23338__auto__)){
return or__23338__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__29180,map__29180__$1,params,map_fn,cells,origin,time){
return (function (p__29182){
var vec__29183 = p__29182;
var vec__29186 = cljs.core.nth.call(null,vec__29183,(0),null);
var x = cljs.core.nth.call(null,vec__29186,(0),null);
var y = cljs.core.nth.call(null,vec__29186,(1),null);
var params__$1 = cljs.core.nth.call(null,vec__29183,(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__29180,map__29180__$1,params,map_fn,cells,origin,time))
,(function (){var iter__24200__auto__ = ((function (map_fn__$1,map__29180,map__29180__$1,params,map_fn,cells,origin,time){
return (function weathergen$model$weather_grid_$_iter__29189(s__29190){
return (new cljs.core.LazySeq(null,((function (map_fn__$1,map__29180,map__29180__$1,params,map_fn,cells,origin,time){
return (function (){
var s__29190__$1 = s__29190;
while(true){
var temp__5278__auto__ = cljs.core.seq.call(null,s__29190__$1);
if(temp__5278__auto__){
var s__29190__$2 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,s__29190__$2)){
var c__24198__auto__ = cljs.core.chunk_first.call(null,s__29190__$2);
var size__24199__auto__ = cljs.core.count.call(null,c__24198__auto__);
var b__29192 = cljs.core.chunk_buffer.call(null,size__24199__auto__);
if((function (){var i__29191 = (0);
while(true){
if((i__29191 < size__24199__auto__)){
var vec__29199 = cljs.core._nth.call(null,c__24198__auto__,i__29191);
var x = cljs.core.nth.call(null,vec__29199,(0),null);
var y = cljs.core.nth.call(null,vec__29199,(1),null);
cljs.core.chunk_append.call(null,b__29192,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__29205 = (i__29191 + (1));
i__29191 = G__29205;
continue;
} else {
return true;
}
break;
}
})()){
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__29192),weathergen$model$weather_grid_$_iter__29189.call(null,cljs.core.chunk_rest.call(null,s__29190__$2)));
} else {
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__29192),null);
}
} else {
var vec__29202 = cljs.core.first.call(null,s__29190__$2);
var x = cljs.core.nth.call(null,vec__29202,(0),null);
var y = cljs.core.nth.call(null,vec__29202,(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__29189.call(null,cljs.core.rest.call(null,s__29190__$2)));
}
} else {
return null;
}
break;
}
});})(map_fn__$1,map__29180,map__29180__$1,params,map_fn,cells,origin,time))
,null,null));
});})(map_fn__$1,map__29180,map__29180__$1,params,map_fn,cells,origin,time))
;
return iter__24200__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__29210 = movement_params;
var map__29210__$1 = ((((!((map__29210 == null)))?((((map__29210.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29210.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29210):map__29210);
var step = cljs.core.get.call(null,map__29210__$1,new cljs.core.Keyword(null,"step","step",1288888124));
var direction = cljs.core.get.call(null,map__29210__$1,new cljs.core.Keyword(null,"direction","direction",-633359395));
var map__29211 = direction;
var map__29211__$1 = ((((!((map__29211 == null)))?((((map__29211.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29211.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29211):map__29211);
var speed = cljs.core.get.call(null,map__29211__$1,new cljs.core.Keyword(null,"speed","speed",1257663751));
var heading = cljs.core.get.call(null,map__29211__$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__29216,weather_params,movement_params,interval,steps){
var vec__29244 = p__29216;
var x = cljs.core.nth.call(null,vec__29244,(0),null);
var y = cljs.core.nth.call(null,vec__29244,(1),null);
var map__29247 = weather_params;
var map__29247__$1 = ((((!((map__29247 == null)))?((((map__29247.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29247.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29247):map__29247);
var seed = cljs.core.get.call(null,map__29247__$1,new cljs.core.Keyword(null,"seed","seed",68613327));
var time = cljs.core.get.call(null,map__29247__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var map__29248 = time;
var map__29248__$1 = ((((!((map__29248 == null)))?((((map__29248.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29248.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29248):map__29248);
var offset = cljs.core.get.call(null,map__29248__$1,new cljs.core.Keyword(null,"offset","offset",296498311));
var current = cljs.core.get.call(null,map__29248__$1,new cljs.core.Keyword(null,"current","current",-1088038603));
var max = cljs.core.get.call(null,map__29248__$1,new cljs.core.Keyword(null,"max","max",61366548));
var map__29249 = movement_params;
var map__29249__$1 = ((((!((map__29249 == null)))?((((map__29249.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29249.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29249):map__29249);
var direction = cljs.core.get.call(null,map__29249__$1,new cljs.core.Keyword(null,"direction","direction",-633359395));
var step = cljs.core.get.call(null,map__29249__$1,new cljs.core.Keyword(null,"step","step",1288888124));
var map__29250 = direction;
var map__29250__$1 = ((((!((map__29250 == null)))?((((map__29250.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29250.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29250):map__29250);
var heading = cljs.core.get.call(null,map__29250__$1,new cljs.core.Keyword(null,"heading","heading",-1312171873));
var speed = cljs.core.get.call(null,map__29250__$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__29247,map__29247__$1,seed,time,map__29248,map__29248__$1,offset,current,max,map__29249,map__29249__$1,direction,step,map__29250,map__29250__$1,heading,speed,now,max_t,vec__29244,x,y){
return (function (p1__29214_SHARP_){
return cljs.core.remove.call(null,new cljs.core.Keyword(null,"exclude-from-forecast?","exclude-from-forecast?",1182671640),p1__29214_SHARP_);
});})(map__29247,map__29247__$1,seed,time,map__29248,map__29248__$1,offset,current,max,map__29249,map__29249__$1,direction,step,map__29250,map__29250__$1,heading,speed,now,max_t,vec__29244,x,y))
);
return cljs.core.into.call(null,cljs.core.sorted_map_by.call(null,((function (map__29247,map__29247__$1,seed,time,map__29248,map__29248__$1,offset,current,max,map__29249,map__29249__$1,direction,step,map__29250,map__29250__$1,heading,speed,now,max_t,weather_params_STAR_,vec__29244,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__29247,map__29247__$1,seed,time,map__29248,map__29248__$1,offset,current,max,map__29249,map__29249__$1,direction,step,map__29250,map__29250__$1,heading,speed,now,max_t,weather_params_STAR_,vec__29244,x,y))
),(function (){var iter__24200__auto__ = ((function (map__29247,map__29247__$1,seed,time,map__29248,map__29248__$1,offset,current,max,map__29249,map__29249__$1,direction,step,map__29250,map__29250__$1,heading,speed,now,max_t,weather_params_STAR_,vec__29244,x,y){
return (function weathergen$model$forecast_$_iter__29255(s__29256){
return (new cljs.core.LazySeq(null,((function (map__29247,map__29247__$1,seed,time,map__29248,map__29248__$1,offset,current,max,map__29249,map__29249__$1,direction,step,map__29250,map__29250__$1,heading,speed,now,max_t,weather_params_STAR_,vec__29244,x,y){
return (function (){
var s__29256__$1 = s__29256;
while(true){
var temp__5278__auto__ = cljs.core.seq.call(null,s__29256__$1);
if(temp__5278__auto__){
var s__29256__$2 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,s__29256__$2)){
var c__24198__auto__ = cljs.core.chunk_first.call(null,s__29256__$2);
var size__24199__auto__ = cljs.core.count.call(null,c__24198__auto__);
var b__29258 = cljs.core.chunk_buffer.call(null,size__24199__auto__);
if((function (){var i__29257 = (0);
while(true){
if((i__29257 < size__24199__auto__)){
var t = cljs.core._nth.call(null,c__24198__auto__,i__29257);
var dt = (t - now);
var vec__29265 = 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__29265,(0),null);
var dy = cljs.core.nth.call(null,vec__29265,(1),null);
var dpos = vec__29265;
cljs.core.chunk_append.call(null,b__29258,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__23338__auto__ = cljs.core._EQ_.call(null,t,now);
if(or__23338__auto__){
return or__23338__auto__;
} else {
var and__23326__auto__ = max_t;
if(cljs.core.truth_(and__23326__auto__)){
return (t <= max_t);
} else {
return and__23326__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__29271 = (i__29257 + (1));
i__29257 = G__29271;
continue;
} else {
return true;
}
break;
}
})()){
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__29258),weathergen$model$forecast_$_iter__29255.call(null,cljs.core.chunk_rest.call(null,s__29256__$2)));
} else {
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__29258),null);
}
} else {
var t = cljs.core.first.call(null,s__29256__$2);
var dt = (t - now);
var vec__29268 = 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__29268,(0),null);
var dy = cljs.core.nth.call(null,vec__29268,(1),null);
var dpos = vec__29268;
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__23338__auto__ = cljs.core._EQ_.call(null,t,now);
if(or__23338__auto__){
return or__23338__auto__;
} else {
var and__23326__auto__ = max_t;
if(cljs.core.truth_(and__23326__auto__)){
return (t <= max_t);
} else {
return and__23326__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__29255.call(null,cljs.core.rest.call(null,s__29256__$2)));
}
} else {
return null;
}
break;
}
});})(map__29247,map__29247__$1,seed,time,map__29248,map__29248__$1,offset,current,max,map__29249,map__29249__$1,direction,step,map__29250,map__29250__$1,heading,speed,now,max_t,weather_params_STAR_,vec__29244,x,y))
,null,null));
});})(map__29247,map__29247__$1,seed,time,map__29248,map__29248__$1,offset,current,max,map__29249,map__29249__$1,direction,step,map__29250,map__29250__$1,heading,speed,now,max_t,weather_params_STAR_,vec__29244,x,y))
;
return iter__24200__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__24200__auto__,map__29247,map__29247__$1,seed,time,map__29248,map__29248__$1,offset,current,max,map__29249,map__29249__$1,direction,step,map__29250,map__29250__$1,heading,speed,now,max_t,weather_params_STAR_,vec__29244,x,y){
return (function (p1__29215_SHARP_){
return (cljs.core.long$.call(null,((((p1__29215_SHARP_ + (1)) * interval) + now) / interval)) * interval);
});})(iter__24200__auto__,map__29247,map__29247__$1,seed,time,map__29248,map__29248__$1,offset,current,max,map__29249,map__29249__$1,direction,step,map__29250,map__29250__$1,heading,speed,now,max_t,weather_params_STAR_,vec__29244,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__29280 = movement_params;
var map__29280__$1 = ((((!((map__29280 == null)))?((((map__29280.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29280.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29280):map__29280);
var evolution = cljs.core.get.call(null,map__29280__$1,new cljs.core.Keyword(null,"evolution","evolution",944820557));
var direction = cljs.core.get.call(null,map__29280__$1,new cljs.core.Keyword(null,"direction","direction",-633359395));
var map__29281 = direction;
var map__29281__$1 = ((((!((map__29281 == null)))?((((map__29281.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29281.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29281):map__29281);
var speed = cljs.core.get.call(null,map__29281__$1,new cljs.core.Keyword(null,"speed","speed",1257663751));
var heading = cljs.core.get.call(null,map__29281__$1,new cljs.core.Keyword(null,"heading","heading",-1312171873));
var map__29282 = weather_params;
var map__29282__$1 = ((((!((map__29282 == null)))?((((map__29282.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29282.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29282):map__29282);
var time = cljs.core.get.call(null,map__29282__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var map__29283 = time;
var map__29283__$1 = ((((!((map__29283 == null)))?((((map__29283.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29283.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29283):map__29283);
var current = cljs.core.get.call(null,map__29283__$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__29288_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__29288_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__29289_SHARP_){
return weathergen.math.nearest.call(null,(((p1__29289_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__29290,new_revision){
var map__29294 = p__29290;
var map__29294__$1 = ((((!((map__29294 == null)))?((((map__29294.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__29294.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__29294):map__29294);
var params = map__29294__$1;
var revision = cljs.core.get.call(null,map__29294__$1,new cljs.core.Keyword(null,"revision","revision",-1350113114));
var G__29296 = params;
var G__29296__$1 = (((revision < (7)))?weathergen.model.upgrade_pressure_threshold.call(null,G__29296):G__29296);
return cljs.core.assoc.call(null,G__29296__$1,new cljs.core.Keyword(null,"revision","revision",-1350113114),new_revision);

});
