// Compiled by ClojureScript 1.10.520 {}
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){
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,"weight","weight",-1262796205)], null));
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,"weight","weight",-1262796205)], null));
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,"weight","weight",-1262796205)], null));
var s = 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,"sunny","sunny",1448267778),new cljs.core.Keyword(null,"weight","weight",-1262796205)], null));
var total_weight = (((i + p) + f) + s);
var i_STAR_ = (i / total_weight);
var p_STAR_ = ((i + p) / total_weight);
var f_STAR_ = (((i + p) + f) / total_weight);
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_STAR_),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_STAR_,p_STAR_,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_STAR_,i_STAR_,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_STAR_,f_STAR_,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_STAR_,p_STAR_,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__27818 = cljs.core.first.call(null,cljs.core.filter.call(null,((function (i,p,f,s,total_weight,i_STAR_,p_STAR_,f_STAR_,contour){
return (function (p__27827){
var vec__27828 = p__27827;
var vec__27831 = cljs.core.nth.call(null,vec__27828,(0),null);
var low = cljs.core.nth.call(null,vec__27831,(0),null);
var vec__27834 = cljs.core.nth.call(null,vec__27828,(1),null);
var high = cljs.core.nth.call(null,vec__27834,(0),null);
return (((low <= x)) && ((x <= high)));
});})(i,p,f,s,total_weight,i_STAR_,p_STAR_,f_STAR_,contour))
,cljs.core.partition.call(null,(2),(1),contour)));
var vec__27821 = cljs.core.nth.call(null,vec__27818,(0),null);
var x1 = cljs.core.nth.call(null,vec__27821,(0),null);
var v1 = cljs.core.nth.call(null,vec__27821,(1),null);
var vec__27824 = cljs.core.nth.call(null,vec__27818,(1),null);
var x2 = cljs.core.nth.call(null,vec__27824,(0),null);
var v2 = cljs.core.nth.call(null,vec__27824,(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__27837){
var vec__27838 = p__27837;
var type = cljs.core.nth.call(null,vec__27838,(0),null);
var weight = cljs.core.nth.call(null,vec__27838,(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.clamp.call(null,(0),(1),(Math.pow(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)),1.25) + 0.1));
});
/**
 * 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__27841 = params;
var map__27841__$1 = (((((!((map__27841 == null))))?(((((map__27841.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27841.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27841):map__27841);
var x = cljs.core.get.call(null,map__27841__$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__27841__$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__27841__$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__27841__$1,new cljs.core.Keyword(null,"seed","seed",68613327));
var turbulence = cljs.core.get.call(null,map__27841__$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__27843,x1,y1){
var vec__27844 = p__27843;
var x = cljs.core.nth.call(null,vec__27844,(0),null);
var y = cljs.core.nth.call(null,vec__27844,(1),null);
var v = ((Math.sin(x) * Math.sin(y)) + (Math.sin((x / x1)) * Math.sin((y / y1))));
return ((v + (2)) / (4));
});
weathergen.model.wind_direction = (function weathergen$model$wind_direction(p__27847,v,params){
var vec__27848 = p__27847;
var x = cljs.core.nth.call(null,vec__27848,(0),null);
var y = cljs.core.nth.call(null,vec__27848,(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__27851,x_STAR_,y_STAR_){
var map__27852 = p__27851;
var map__27852__$1 = (((((!((map__27852 == null))))?(((((map__27852.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27852.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27852):map__27852);
var bounds = map__27852__$1;
var x = cljs.core.get.call(null,map__27852__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var y = cljs.core.get.call(null,map__27852__$1,new cljs.core.Keyword(null,"y","y",-1757859776));
var width = cljs.core.get.call(null,map__27852__$1,new cljs.core.Keyword(null,"width","width",-384071477));
var height = cljs.core.get.call(null,map__27852__$1,new cljs.core.Keyword(null,"height","height",1025178622));
var and__4120__auto__ = x;
if(cljs.core.truth_(and__4120__auto__)){
var and__4120__auto____$1 = y;
if(cljs.core.truth_(and__4120__auto____$1)){
var and__4120__auto____$2 = width;
if(cljs.core.truth_(and__4120__auto____$2)){
var and__4120__auto____$3 = height;
if(cljs.core.truth_(and__4120__auto____$3)){
return (((x <= x_STAR_)) && ((x_STAR_ < (x + width))) && ((y <= y_STAR_)) && ((y_STAR_ < (y + height))));
} else {
return and__4120__auto____$3;
}
} else {
return and__4120__auto____$2;
}
} else {
return and__4120__auto____$1;
}
} else {
return and__4120__auto__;
}
});
/**
 * 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__27854 = override;
var map__27854__$1 = (((((!((map__27854 == null))))?(((((map__27854.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27854.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27854):map__27854);
var begin = cljs.core.get.call(null,map__27854__$1,new cljs.core.Keyword(null,"begin","begin",-319034319));
var peak = cljs.core.get.call(null,map__27854__$1,new cljs.core.Keyword(null,"peak","peak",389096055));
var taper = cljs.core.get.call(null,map__27854__$1,new cljs.core.Keyword(null,"taper","taper",1772067478));
var end = cljs.core.get.call(null,map__27854__$1,new cljs.core.Keyword(null,"end","end",-268185958));
var animate_QMARK_ = cljs.core.get.call(null,map__27854__$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);

}
}
}
}
}
});
/**
 * Computes the weight a particular override contributes considering the
 *   time and location and other factors.
 */
weathergen.model.override_weight = (function weathergen$model$override_weight(params,override){
var map__27856 = params;
var map__27856__$1 = (((((!((map__27856 == null))))?(((((map__27856.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27856.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27856):map__27856);
var x = cljs.core.get.call(null,map__27856__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var y = cljs.core.get.call(null,map__27856__$1,new cljs.core.Keyword(null,"y","y",-1757859776));
var t = cljs.core.get.call(null,map__27856__$1,new cljs.core.Keyword(null,"t","t",-1397832519));
var weather_overrides = cljs.core.get.call(null,map__27856__$1,new cljs.core.Keyword(null,"weather-overrides","weather-overrides",-837381710));
var time = cljs.core.get.call(null,map__27856__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var map__27857 = override;
var map__27857__$1 = (((((!((map__27857 == null))))?(((((map__27857.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27857.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27857):map__27857);
var location = cljs.core.get.call(null,map__27857__$1,new cljs.core.Keyword(null,"location","location",1815599388));
var radius = cljs.core.get.call(null,map__27857__$1,new cljs.core.Keyword(null,"radius","radius",-2073122258));
var falloff = cljs.core.get.call(null,map__27857__$1,new cljs.core.Keyword(null,"falloff","falloff",-1639069456));
var strength = cljs.core.get.call(null,map__27857__$1,new cljs.core.Keyword(null,"strength","strength",-415606478));
var animate_QMARK_ = cljs.core.get.call(null,map__27857__$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));
return ((position_weight * tw) * strength);
});
weathergen.model.wind_alts = new cljs.core.PersistentVector(null, 10, 5, cljs.core.PersistentVector.EMPTY_NODE, [(0),(3000),(6000),(9000),(12000),(18000),(24000),(30000),(40000),(50000)], null);
/**
 * Returns the wind, stabilized if appropriate by a wind stability region
 */
weathergen.model.wind = (function weathergen$model$wind(p__27860,wind_adj_var,ground_wind){
var map__27861 = p__27860;
var map__27861__$1 = (((((!((map__27861 == null))))?(((((map__27861.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27861.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27861):map__27861);
var params = map__27861__$1;
var x = cljs.core.get.call(null,map__27861__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var y = cljs.core.get.call(null,map__27861__$1,new cljs.core.Keyword(null,"y","y",-1757859776));
var winds_aloft = cljs.core.get.call(null,map__27861__$1,new cljs.core.Keyword(null,"winds-aloft","winds-aloft",83956399));
var prevailing_wind = cljs.core.get.call(null,map__27861__$1,new cljs.core.Keyword(null,"prevailing-wind","prevailing-wind",-190580386));
var overrides = cljs.core.get.call(null,map__27861__$1,new cljs.core.Keyword(null,"weather-overrides","weather-overrides",-837381710));
var base_winds = cljs.core.reduce.call(null,((function (map__27861,map__27861__$1,params,x,y,winds_aloft,prevailing_wind,overrides){
return (function (m,alt){
return cljs.core.assoc.call(null,m,alt,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"speed","speed",1257663751),(new cljs.core.Keyword(null,"speed","speed",1257663751).cljs$core$IFn$_invoke$arity$1(ground_wind) + weathergen.math.interpolate.call(null,cljs.core.get_in.call(null,winds_aloft,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [alt,new cljs.core.Keyword(null,"speed","speed",1257663751),new cljs.core.Keyword(null,"from","from",1815293044)], null)),cljs.core.get_in.call(null,winds_aloft,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [alt,new cljs.core.Keyword(null,"speed","speed",1257663751),new cljs.core.Keyword(null,"to","to",192099007)], null)),wind_adj_var)),new cljs.core.Keyword(null,"heading","heading",-1312171873),cljs.core.mod.call(null,weathergen.math.interpolate.call(null,new cljs.core.Keyword(null,"heading","heading",-1312171873).cljs$core$IFn$_invoke$arity$1(ground_wind),new cljs.core.Keyword(null,"heading","heading",-1312171873).cljs$core$IFn$_invoke$arity$1(prevailing_wind),cljs.core.get_in.call(null,winds_aloft,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [alt,new cljs.core.Keyword(null,"bias","bias",-315297926)], null))),(360))], null));
});})(map__27861,map__27861__$1,params,x,y,winds_aloft,prevailing_wind,overrides))
,new cljs.core.PersistentArrayMap(null, 1, [(0),ground_wind], null),cljs.core.drop.call(null,(1),weathergen.model.wind_alts));
return cljs.core.reduce.call(null,((function (base_winds,map__27861,map__27861__$1,params,x,y,winds_aloft,prevailing_wind,overrides){
return (function (winds,override){
var alts = new cljs.core.Keyword(null,"wind-alts","wind-alts",1257047776).cljs$core$IFn$_invoke$arity$1(override);
var override_dir = cljs.core.get.call(null,override,new cljs.core.Keyword(null,"wind-dir","wind-dir",-432221184));
var override_speed = cljs.core.get.call(null,override,new cljs.core.Keyword(null,"wind-speed","wind-speed",-815617496));
var weight = weathergen.model.override_weight.call(null,params,override);
return cljs.core.reduce.call(null,((function (alts,override_dir,override_speed,weight,base_winds,map__27861,map__27861__$1,params,x,y,winds_aloft,prevailing_wind,overrides){
return (function (winds__$1,alt){
var G__27863 = winds__$1;
var G__27863__$1 = (((!((override_dir == null))))?cljs.core.update_in.call(null,G__27863,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [alt,new cljs.core.Keyword(null,"heading","heading",-1312171873)], null),((function (G__27863,alts,override_dir,override_speed,weight,base_winds,map__27861,map__27861__$1,params,x,y,winds_aloft,prevailing_wind,overrides){
return (function (heading){
return weathergen.math.nearest.call(null,cljs.core.mod.call(null,((heading * ((1) - weight)) + (weight * override_dir)),(360)),(1));
});})(G__27863,alts,override_dir,override_speed,weight,base_winds,map__27861,map__27861__$1,params,x,y,winds_aloft,prevailing_wind,overrides))
):G__27863);
if((!((override_speed == null)))){
return cljs.core.update_in.call(null,G__27863__$1,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [alt,new cljs.core.Keyword(null,"speed","speed",1257663751)], null),((function (G__27863,G__27863__$1,alts,override_dir,override_speed,weight,base_winds,map__27861,map__27861__$1,params,x,y,winds_aloft,prevailing_wind,overrides){
return (function (speed){
return ((speed * ((1) - weight)) + (weight * override_speed));
});})(G__27863,G__27863__$1,alts,override_dir,override_speed,weight,base_winds,map__27861,map__27861__$1,params,x,y,winds_aloft,prevailing_wind,overrides))
);
} else {
return G__27863__$1;
}
});})(alts,override_dir,override_speed,weight,base_winds,map__27861,map__27861__$1,params,x,y,winds_aloft,prevailing_wind,overrides))
,winds,alts);
});})(base_winds,map__27861,map__27861__$1,params,x,y,winds_aloft,prevailing_wind,overrides))
,base_winds,overrides);
});
/**
 * Computes the pressure we should use to override the weather type given the weather type
 */
weathergen.model.override_pressure = (function weathergen$model$override_pressure(params,override){
var i = cljs.core.get_in.call(null,params,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"categories","categories",178386610),new cljs.core.Keyword(null,"inclement","inclement",-550669382),new cljs.core.Keyword(null,"weight","weight",-1262796205)], null));
var p = cljs.core.get_in.call(null,params,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"categories","categories",178386610),new cljs.core.Keyword(null,"poor","poor",1462482211),new cljs.core.Keyword(null,"weight","weight",-1262796205)], null));
var f = cljs.core.get_in.call(null,params,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"categories","categories",178386610),new cljs.core.Keyword(null,"fair","fair",1684139423),new cljs.core.Keyword(null,"weight","weight",-1262796205)], null));
var s = cljs.core.get_in.call(null,params,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"categories","categories",178386610),new cljs.core.Keyword(null,"sunny","sunny",1448267778),new cljs.core.Keyword(null,"weight","weight",-1262796205)], null));
var total_weight = (((i + p) + f) + s);
var i_STAR_ = (i / total_weight);
var p_STAR_ = ((i + p) / total_weight);
var G__27864 = new cljs.core.Keyword(null,"type","type",1174270348).cljs$core$IFn$_invoke$arity$1(override);
var G__27864__$1 = (((G__27864 instanceof cljs.core.Keyword))?G__27864.fqn:null);
switch (G__27864__$1) {
case "sunny":
return (1);

break;
case "inclement":
return (0);

break;
case "poor":
return (((p / (2)) + i) / total_weight);

break;
case "fair":
return ((((f / (2)) + i) + p) / total_weight);

break;
default:
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__27864__$1)].join('')));

}
});
/**
 * Adjusts pressure value based on weather overrides, if any.
 */
weathergen.model.override = (function weathergen$model$override(params,v){
var map__27866 = params;
var map__27866__$1 = (((((!((map__27866 == null))))?(((((map__27866.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27866.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27866):map__27866);
var x = cljs.core.get.call(null,map__27866__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var y = cljs.core.get.call(null,map__27866__$1,new cljs.core.Keyword(null,"y","y",-1757859776));
var t = cljs.core.get.call(null,map__27866__$1,new cljs.core.Keyword(null,"t","t",-1397832519));
var weather_overrides = cljs.core.get.call(null,map__27866__$1,new cljs.core.Keyword(null,"weather-overrides","weather-overrides",-837381710));
var time = cljs.core.get.call(null,map__27866__$1,new cljs.core.Keyword(null,"time","time",1385887882));
return weathergen.math.clamp.call(null,0.0,1.0,cljs.core.reduce.call(null,((function (map__27866,map__27866__$1,x,y,t,weather_overrides,time){
return (function (v__$1,override){
var map__27868 = override;
var map__27868__$1 = (((((!((map__27868 == null))))?(((((map__27868.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27868.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27868):map__27868);
var location = cljs.core.get.call(null,map__27868__$1,new cljs.core.Keyword(null,"location","location",1815599388));
var radius = cljs.core.get.call(null,map__27868__$1,new cljs.core.Keyword(null,"radius","radius",-2073122258));
var falloff = cljs.core.get.call(null,map__27868__$1,new cljs.core.Keyword(null,"falloff","falloff",-1639069456));
var strength = cljs.core.get.call(null,map__27868__$1,new cljs.core.Keyword(null,"strength","strength",-415606478));
var animate_QMARK_ = cljs.core.get.call(null,map__27868__$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_ = weathergen.model.override_pressure.call(null,params,override);
return ((v_STAR_ * w) + (v__$1 * ((1) - w)));
});})(map__27866,map__27866__$1,x,y,t,weather_overrides,time))
,v,cljs.core.filter.call(null,new cljs.core.Keyword(null,"type","type",1174270348),weather_overrides)));
});
weathergen.model.override_param = (function weathergen$model$override_param(params,attr,attr_val,v,override){
var override_val = cljs.core.get.call(null,override,attr);
if((override_val == null)){
return v;
} else {
var w = weathergen.model.override_weight.call(null,params,override);
var v_STAR_ = attr_val.call(null,override_val);
return ((v_STAR_ * w) + (v * ((1) - w)));
}
});
weathergen.model.temperature = (function weathergen$model$temperature(p__27870,mixture,v){
var map__27871 = p__27870;
var map__27871__$1 = (((((!((map__27871 == null))))?(((((map__27871.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27871.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27871):map__27871);
var params = map__27871__$1;
var categories = cljs.core.get.call(null,map__27871__$1,new cljs.core.Keyword(null,"categories","categories",178386610));
var overrides = cljs.core.get.call(null,map__27871__$1,new cljs.core.Keyword(null,"weather-overrides","weather-overrides",-837381710));
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));
var init = weathergen.math.distribute.call(null,v,min,mean,max,(1));
return cljs.core.reduce.call(null,((function (mean,min,max,init,map__27871,map__27871__$1,params,categories,overrides){
return (function (v__$1,override){
return weathergen.model.override_param.call(null,params,new cljs.core.Keyword(null,"temperature","temperature",899018429),cljs.core.identity,v__$1,override);
});})(mean,min,max,init,map__27871,map__27871__$1,params,categories,overrides))
,init,overrides);
});
weathergen.model.cloud_coverages = new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"none","none",1333468478),new cljs.core.Keyword(null,"few","few",941665998),new cljs.core.Keyword(null,"scattered","scattered",-1263632526),new cljs.core.Keyword(null,"broken","broken",-1742446874),new cljs.core.Keyword(null,"overcast","overcast",-2096313755)], null);
var coverage_vals_27882 = cljs.core.zipmap.call(null,weathergen.model.cloud_coverages,new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [0.0,0.25,0.5,0.75,1.0], null));
var inverse_27883 = cljs.core.zipmap.call(null,cljs.core.vals.call(null,coverage_vals_27882),cljs.core.keys.call(null,coverage_vals_27882));
weathergen.model.cloud_coverage = ((function (coverage_vals_27882,inverse_27883){
return (function weathergen$model$cloud_coverage(p__27875,v){
var map__27876 = p__27875;
var map__27876__$1 = (((((!((map__27876 == null))))?(((((map__27876.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27876.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27876):map__27876);
var params = map__27876__$1;
var type = cljs.core.get.call(null,map__27876__$1,new cljs.core.Keyword(null,"type","type",1174270348));
var categories = cljs.core.get.call(null,map__27876__$1,new cljs.core.Keyword(null,"categories","categories",178386610));
var overrides = cljs.core.get.call(null,map__27876__$1,new cljs.core.Keyword(null,"weather-overrides","weather-overrides",-837381710));
if(cljs.core._EQ_.call(null,type,new cljs.core.Keyword(null,"sunny","sunny",1448267778))){
return new cljs.core.Keyword(null,"none","none",1333468478);
} else {
var map__27878 = cljs.core.get_in.call(null,categories,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [type,new cljs.core.Keyword(null,"low-clouds","low-clouds",-702988471),new cljs.core.Keyword(null,"coverage","coverage",1606292651)], null));
var map__27878__$1 = (((((!((map__27878 == null))))?(((((map__27878.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27878.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27878):map__27878);
var from = cljs.core.get.call(null,map__27878__$1,new cljs.core.Keyword(null,"from","from",1815293044));
var to = cljs.core.get.call(null,map__27878__$1,new cljs.core.Keyword(null,"to","to",192099007));
var from_val = (coverage_vals_27882.call(null,from) - 0.12);
var to_val = (coverage_vals_27882.call(null,to) + 0.12);
var result = weathergen.math.interpolate.call(null,from_val,to_val,v);
var v_STAR_ = weathergen.math.clamp.call(null,(function (){var G__27880 = type;
var G__27880__$1 = (((G__27880 instanceof cljs.core.Keyword))?G__27880.fqn:null);
switch (G__27880__$1) {
case "sunny":
return 0.0;

break;
case "fair":
return 0.25;

break;
case "poor":
return 0.5;

break;
case "inclement":
return 0.5;

break;
default:
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__27880__$1)].join('')));

}
})(),(function (){var G__27881 = type;
var G__27881__$1 = (((G__27881 instanceof cljs.core.Keyword))?G__27881.fqn:null);
switch (G__27881__$1) {
case "sunny":
return 0.0;

break;
case "fair":
return 0.75;

break;
case "poor":
return 1.0;

break;
case "inclement":
return 1.0;

break;
default:
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__27881__$1)].join('')));

}
})(),cljs.core.reduce.call(null,((function (map__27878,map__27878__$1,from,to,from_val,to_val,result,map__27876,map__27876__$1,params,type,categories,overrides,coverage_vals_27882,inverse_27883){
return (function (p1__27873_SHARP_,p2__27874_SHARP_){
return weathergen.model.override_param.call(null,params,new cljs.core.Keyword(null,"cloud-cover","cloud-cover",1830614752),coverage_vals_27882,p1__27873_SHARP_,p2__27874_SHARP_);
});})(map__27878,map__27878__$1,from,to,from_val,to_val,result,map__27876,map__27876__$1,params,type,categories,overrides,coverage_vals_27882,inverse_27883))
,result,overrides));
var final$ = inverse_27883.call(null,weathergen.math.nearest.call(null,v_STAR_,0.25));
if(cljs.core.truth_(final$)){
} else {
console.debug("coverage error",v_STAR_,final$);
}

return final$;
}
});})(coverage_vals_27882,inverse_27883))
;
weathergen.model.cloud_towering_QMARK_ = (function weathergen$model$cloud_towering_QMARK_(p__27887,v){
var map__27888 = p__27887;
var map__27888__$1 = (((((!((map__27888 == null))))?(((((map__27888.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27888.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27888):map__27888);
var params = map__27888__$1;
var type = cljs.core.get.call(null,map__27888__$1,new cljs.core.Keyword(null,"type","type",1174270348));
var categories = cljs.core.get.call(null,map__27888__$1,new cljs.core.Keyword(null,"categories","categories",178386610));
var overrides = cljs.core.get.call(null,map__27888__$1,new cljs.core.Keyword(null,"weather-overrides","weather-overrides",-837381710));
if(cljs.core._EQ_.call(null,type,new cljs.core.Keyword(null,"sunny","sunny",1448267778))){
return false;
} else {
var threshold = cljs.core.get_in.call(null,categories,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [type,new cljs.core.Keyword(null,"low-clouds","low-clouds",-702988471),new cljs.core.Keyword(null,"towering","towering",-44547353)], null));
var v_STAR_ = cljs.core.reduce.call(null,((function (threshold,map__27888,map__27888__$1,params,type,categories,overrides){
return (function (v__$1,override){
return weathergen.model.override_param.call(null,params,new cljs.core.Keyword(null,"towering?","towering?",2005070836),((function (threshold,map__27888,map__27888__$1,params,type,categories,overrides){
return (function (p1__27886_SHARP_){
if(cljs.core.truth_(p1__27886_SHARP_)){
return (threshold / (2));
} else {
return (((1) + threshold) / (2));
}
});})(threshold,map__27888,map__27888__$1,params,type,categories,overrides))
,v__$1,override);
});})(threshold,map__27888,map__27888__$1,params,type,categories,overrides))
,v,overrides);
return (v_STAR_ < threshold);
}
});
weathergen.model.linear_param = (function weathergen$model$linear_param(p__27890,v){
var map__27891 = p__27890;
var map__27891__$1 = (((((!((map__27891 == null))))?(((((map__27891.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27891.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27891):map__27891);
var from = cljs.core.get.call(null,map__27891__$1,new cljs.core.Keyword(null,"from","from",1815293044));
var to = cljs.core.get.call(null,map__27891__$1,new cljs.core.Keyword(null,"to","to",192099007));
return weathergen.math.interpolate.call(null,from,to,v);
});
weathergen.model.cloud_param = (function weathergen$model$cloud_param(p__27893,param,v){
var map__27894 = p__27893;
var map__27894__$1 = (((((!((map__27894 == null))))?(((((map__27894.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27894.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27894):map__27894);
var params = map__27894__$1;
var type = cljs.core.get.call(null,map__27894__$1,new cljs.core.Keyword(null,"type","type",1174270348));
var categories = cljs.core.get.call(null,map__27894__$1,new cljs.core.Keyword(null,"categories","categories",178386610));
if(cljs.core._EQ_.call(null,type,new cljs.core.Keyword(null,"sunny","sunny",1448267778))){
return (0);
} else {
return weathergen.model.linear_param.call(null,cljs.core.get_in.call(null,categories,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [type,new cljs.core.Keyword(null,"low-clouds","low-clouds",-702988471),param], null)),v);
}
});
weathergen.model.cloud_size = (function weathergen$model$cloud_size(p__27896,v){
var map__27897 = p__27896;
var map__27897__$1 = (((((!((map__27897 == null))))?(((((map__27897.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27897.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27897):map__27897);
var params = map__27897__$1;
var overrides = cljs.core.get.call(null,map__27897__$1,new cljs.core.Keyword(null,"weather-overrides","weather-overrides",-837381710));
var type = cljs.core.get.call(null,map__27897__$1,new cljs.core.Keyword(null,"type","type",1174270348));
if(cljs.core._EQ_.call(null,type,new cljs.core.Keyword(null,"sunny","sunny",1448267778))){
return (0);
} else {
return cljs.core.reduce.call(null,((function (map__27897,map__27897__$1,params,overrides,type){
return (function (v__$1,override){
return weathergen.model.override_param.call(null,params,new cljs.core.Keyword(null,"cloud-size","cloud-size",-1568256381),cljs.core.identity,v__$1,override);
});})(map__27897,map__27897__$1,params,overrides,type))
,weathergen.model.cloud_param.call(null,params,new cljs.core.Keyword(null,"size","size",1098693007),v),overrides);
}
});
weathergen.model.cloud_base = (function weathergen$model$cloud_base(p__27899,v){
var map__27900 = p__27899;
var map__27900__$1 = (((((!((map__27900 == null))))?(((((map__27900.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27900.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27900):map__27900);
var params = map__27900__$1;
var overrides = cljs.core.get.call(null,map__27900__$1,new cljs.core.Keyword(null,"weather-overrides","weather-overrides",-837381710));
var type = cljs.core.get.call(null,map__27900__$1,new cljs.core.Keyword(null,"type","type",1174270348));
if(cljs.core._EQ_.call(null,type,new cljs.core.Keyword(null,"sunny","sunny",1448267778))){
return (0);
} else {
return weathergen.math.nearest.call(null,cljs.core.reduce.call(null,((function (map__27900,map__27900__$1,params,overrides,type){
return (function (v__$1,override){
return weathergen.model.override_param.call(null,params,new cljs.core.Keyword(null,"cloud-base","cloud-base",826793857),cljs.core.identity,v__$1,override);
});})(map__27900,map__27900__$1,params,overrides,type))
,weathergen.model.cloud_param.call(null,params,new cljs.core.Keyword(null,"base","base",185279322),v),overrides),(100));
}
});
weathergen.model.visibility = (function weathergen$model$visibility(p__27902,v){
var map__27903 = p__27902;
var map__27903__$1 = (((((!((map__27903 == null))))?(((((map__27903.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27903.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27903):map__27903);
var params = map__27903__$1;
var type = cljs.core.get.call(null,map__27903__$1,new cljs.core.Keyword(null,"type","type",1174270348));
var categories = cljs.core.get.call(null,map__27903__$1,new cljs.core.Keyword(null,"categories","categories",178386610));
var mixture = cljs.core.get.call(null,map__27903__$1,new cljs.core.Keyword("weathergen.model","mixture","weathergen.model/mixture",-456301147));
var overrides = cljs.core.get.call(null,map__27903__$1,new cljs.core.Keyword(null,"weather-overrides","weather-overrides",-837381710));
return cljs.core.reduce.call(null,((function (map__27903,map__27903__$1,params,type,categories,mixture,overrides){
return (function (v__$1,override){
return weathergen.model.override_param.call(null,params,new cljs.core.Keyword(null,"visibility","visibility",1338380893),cljs.core.identity,v__$1,override);
});})(map__27903,map__27903__$1,params,type,categories,mixture,overrides))
,weathergen.model.linear_param.call(null,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"from","from",1815293044),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,"visibility","visibility",1338380893),new cljs.core.Keyword(null,"from","from",1815293044)], null)),new cljs.core.Keyword(null,"to","to",192099007),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,"visibility","visibility",1338380893),new cljs.core.Keyword(null,"to","to",192099007)], null))], null),v),overrides);
});
/**
 * x and y are in cells
 */
weathergen.model.weather = (function weathergen$model$weather(p__27905){
var map__27906 = p__27905;
var map__27906__$1 = (((((!((map__27906 == null))))?(((((map__27906.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27906.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27906):map__27906);
var params = map__27906__$1;
var wind_uniformity = cljs.core.get.call(null,map__27906__$1,new cljs.core.Keyword(null,"wind-uniformity","wind-uniformity",827531801));
var x = cljs.core.get.call(null,map__27906__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var crossfade = cljs.core.get.call(null,map__27906__$1,new cljs.core.Keyword(null,"crossfade","crossfade",-118506406));
var prevailing_wind = cljs.core.get.call(null,map__27906__$1,new cljs.core.Keyword(null,"prevailing-wind","prevailing-wind",-190580386));
var y = cljs.core.get.call(null,map__27906__$1,new cljs.core.Keyword(null,"y","y",-1757859776));
var temp_uniformity = cljs.core.get.call(null,map__27906__$1,new cljs.core.Keyword(null,"temp-uniformity","temp-uniformity",836756864));
var pressure = cljs.core.get.call(null,map__27906__$1,new cljs.core.Keyword(null,"pressure","pressure",505343747));
var time = cljs.core.get.call(null,map__27906__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var evolution = cljs.core.get.call(null,map__27906__$1,new cljs.core.Keyword(null,"evolution","evolution",944820557));
var seed = cljs.core.get.call(null,map__27906__$1,new cljs.core.Keyword(null,"seed","seed",68613327));
var feature_size = cljs.core.get.call(null,map__27906__$1,new cljs.core.Keyword(null,"feature-size","feature-size",-878734864));
var categories = cljs.core.get.call(null,map__27906__$1,new cljs.core.Keyword(null,"categories","categories",178386610));
var origin = cljs.core.get.call(null,map__27906__$1,new cljs.core.Keyword(null,"origin","origin",1037372088));
var vec__27908 = origin;
var origin_x = cljs.core.nth.call(null,vec__27908,(0),null);
var origin_y = cljs.core.nth.call(null,vec__27908,(1),null);
var x_STAR_ = ((origin_x + x) / feature_size);
var y_STAR_ = ((origin_y + y) / feature_size);
var map__27911 = time;
var map__27911__$1 = (((((!((map__27911 == null))))?(((((map__27911.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27911.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27911):map__27911);
var offset = cljs.core.get.call(null,map__27911__$1,new cljs.core.Keyword(null,"offset","offset",296498311));
var current = cljs.core.get.call(null,map__27911__$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,(3),(3)));
var wind_dir = weathergen.model.wind_direction.call(null,p,value,params_STAR_);
var pressure_t = ((t / new cljs.core.Keyword(null,"speed","speed",1257663751).cljs$core$IFn$_invoke$arity$1(pressure)) / (4));
var pressure_variance = new cljs.core.Keyword(null,"variance","variance",1132010827).cljs$core$IFn$_invoke$arity$1(pressure);
var mean_pressure = ((max_pressure + min_pressure) / (2));
var theater_min_pressure = weathergen.math.interpolate.call(null,min_pressure,(max_pressure - pressure_variance),weathergen.math.fractal_field.call(null,pressure_t,(1234),(32),seed,1.0));
var theater_max_pressure = (theater_min_pressure + pressure_variance);
var pressure__$1 = (theater_min_pressure + (pressure_variance * value));
var mixture = weathergen.model.mix.call(null,value,crossfade,categories);
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 wind_adj_var = weathergen.model.pressure_pattern.call(null,p,3.2,3.2);
var temp_var = weathergen.model.pressure_pattern.call(null,p,3.3,3.3);
var coverage_var = weathergen.math.reject_tails.call(null,0.9,weathergen.model.pressure_pattern.call(null,weathergen.math.vector_add.call(null,p,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(1000),(1000)], null)),2.5,3.5));
var weather_type = cljs.core.key.call(null,cljs.core.last.call(null,cljs.core.sort_by.call(null,cljs.core.val,mixture)));
var towering_var = weathergen.model.pressure_pattern.call(null,p,1.5,1.5);
var base_var = weathergen.model.pressure_pattern.call(null,p,3.4,3.5);
var size_var = weathergen.model.pressure_pattern.call(null,p,3.5,3.6);
var vis_var = weathergen.model.pressure_pattern.call(null,p,3.7,3.8);
var params_STAR__STAR_ = cljs.core.assoc.call(null,params_STAR_,new cljs.core.Keyword(null,"type","type",1174270348),weather_type);
return cljs.core.PersistentHashMap.fromArrays([new cljs.core.Keyword(null,"towering-var","towering-var",-1328603040),new cljs.core.Keyword(null,"pressure","pressure",505343747),new cljs.core.Keyword(null,"temp-var","temp-var",1728501704),new cljs.core.Keyword(null,"low-clouds","low-clouds",-702988471),new cljs.core.Keyword(null,"value","value",305978217),new cljs.core.Keyword(null,"coverage-var","coverage-var",1734683883),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,"visibility","visibility",1338380893),new cljs.core.Keyword(null,"temperature","temperature",899018429)],[towering_var,weathergen.math.nearest.call(null,pressure__$1,0.01),temp_var,new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"coverage","coverage",1606292651),weathergen.model.cloud_coverage.call(null,params_STAR__STAR_,coverage_var),new cljs.core.Keyword(null,"towering?","towering?",2005070836),weathergen.model.cloud_towering_QMARK_.call(null,params_STAR__STAR_,towering_var),new cljs.core.Keyword(null,"base","base",185279322),weathergen.model.cloud_base.call(null,params_STAR__STAR_,base_var),new cljs.core.Keyword(null,"size","size",1098693007),weathergen.model.cloud_size.call(null,params_STAR__STAR_,size_var)], null),value,coverage_var,weather_type,weathergen.model.wind.call(null,params_STAR_,wind_adj_var,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.visibility.call(null,cljs.core.assoc.call(null,params_STAR__STAR_,new cljs.core.Keyword("weathergen.model","mixture","weathergen.model/mixture",-456301147),mixture),vis_var),weathergen.model.temperature.call(null,params_STAR__STAR_,mixture,temp_var)]);
});
weathergen.model.weather_grid = (function weathergen$model$weather_grid(p__27913){
var map__27914 = p__27913;
var map__27914__$1 = (((((!((map__27914 == null))))?(((((map__27914.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27914.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27914):map__27914);
var params = map__27914__$1;
var map_fn = cljs.core.get.call(null,map__27914__$1,new cljs.core.Keyword(null,"map-fn","map-fn",1184112686));
var cells = cljs.core.get.call(null,map__27914__$1,new cljs.core.Keyword(null,"cells","cells",-985166822));
var origin = cljs.core.get.call(null,map__27914__$1,new cljs.core.Keyword(null,"origin","origin",1037372088));
var time = cljs.core.get.call(null,map__27914__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var map_fn__$1 = (function (){var or__4131__auto__ = map_fn;
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return cljs.core.mapv;
}
})();
return cljs.core.into.call(null,cljs.core.sorted_map.call(null),map_fn__$1.call(null,((function (map_fn__$1,map__27914,map__27914__$1,params,map_fn,cells,origin,time){
return (function (p__27916){
var vec__27917 = p__27916;
var vec__27920 = cljs.core.nth.call(null,vec__27917,(0),null);
var x = cljs.core.nth.call(null,vec__27920,(0),null);
var y = cljs.core.nth.call(null,vec__27920,(1),null);
var params__$1 = cljs.core.nth.call(null,vec__27917,(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__27914,map__27914__$1,params,map_fn,cells,origin,time))
,(function (){var iter__4523__auto__ = ((function (map_fn__$1,map__27914,map__27914__$1,params,map_fn,cells,origin,time){
return (function weathergen$model$weather_grid_$_iter__27923(s__27924){
return (new cljs.core.LazySeq(null,((function (map_fn__$1,map__27914,map__27914__$1,params,map_fn,cells,origin,time){
return (function (){
var s__27924__$1 = s__27924;
while(true){
var temp__5720__auto__ = cljs.core.seq.call(null,s__27924__$1);
if(temp__5720__auto__){
var s__27924__$2 = temp__5720__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,s__27924__$2)){
var c__4521__auto__ = cljs.core.chunk_first.call(null,s__27924__$2);
var size__4522__auto__ = cljs.core.count.call(null,c__4521__auto__);
var b__27926 = cljs.core.chunk_buffer.call(null,size__4522__auto__);
if((function (){var i__27925 = (0);
while(true){
if((i__27925 < size__4522__auto__)){
var vec__27927 = cljs.core._nth.call(null,c__4521__auto__,i__27925);
var x = cljs.core.nth.call(null,vec__27927,(0),null);
var y = cljs.core.nth.call(null,vec__27927,(1),null);
cljs.core.chunk_append.call(null,b__27926,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__27933 = (i__27925 + (1));
i__27925 = G__27933;
continue;
} else {
return true;
}
break;
}
})()){
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__27926),weathergen$model$weather_grid_$_iter__27923.call(null,cljs.core.chunk_rest.call(null,s__27924__$2)));
} else {
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__27926),null);
}
} else {
var vec__27930 = cljs.core.first.call(null,s__27924__$2);
var x = cljs.core.nth.call(null,vec__27930,(0),null);
var y = cljs.core.nth.call(null,vec__27930,(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__27923.call(null,cljs.core.rest.call(null,s__27924__$2)));
}
} else {
return null;
}
break;
}
});})(map_fn__$1,map__27914,map__27914__$1,params,map_fn,cells,origin,time))
,null,null));
});})(map_fn__$1,map__27914,map__27914__$1,params,map_fn,cells,origin,time))
;
return iter__4523__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__27934 = movement_params;
var map__27934__$1 = (((((!((map__27934 == null))))?(((((map__27934.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27934.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27934):map__27934);
var step = cljs.core.get.call(null,map__27934__$1,new cljs.core.Keyword(null,"step","step",1288888124));
var direction = cljs.core.get.call(null,map__27934__$1,new cljs.core.Keyword(null,"direction","direction",-633359395));
var map__27935 = direction;
var map__27935__$1 = (((((!((map__27935 == null))))?(((((map__27935.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27935.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27935):map__27935);
var speed = cljs.core.get.call(null,map__27935__$1,new cljs.core.Keyword(null,"speed","speed",1257663751));
var heading = cljs.core.get.call(null,map__27935__$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__27940,weather_params,movement_params,interval,steps){
var vec__27941 = p__27940;
var x = cljs.core.nth.call(null,vec__27941,(0),null);
var y = cljs.core.nth.call(null,vec__27941,(1),null);
var map__27944 = weather_params;
var map__27944__$1 = (((((!((map__27944 == null))))?(((((map__27944.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27944.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27944):map__27944);
var seed = cljs.core.get.call(null,map__27944__$1,new cljs.core.Keyword(null,"seed","seed",68613327));
var time = cljs.core.get.call(null,map__27944__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var map__27945 = time;
var map__27945__$1 = (((((!((map__27945 == null))))?(((((map__27945.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27945.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27945):map__27945);
var offset = cljs.core.get.call(null,map__27945__$1,new cljs.core.Keyword(null,"offset","offset",296498311));
var current = cljs.core.get.call(null,map__27945__$1,new cljs.core.Keyword(null,"current","current",-1088038603));
var max = cljs.core.get.call(null,map__27945__$1,new cljs.core.Keyword(null,"max","max",61366548));
var map__27946 = movement_params;
var map__27946__$1 = (((((!((map__27946 == null))))?(((((map__27946.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27946.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27946):map__27946);
var direction = cljs.core.get.call(null,map__27946__$1,new cljs.core.Keyword(null,"direction","direction",-633359395));
var step = cljs.core.get.call(null,map__27946__$1,new cljs.core.Keyword(null,"step","step",1288888124));
var map__27947 = direction;
var map__27947__$1 = (((((!((map__27947 == null))))?(((((map__27947.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27947.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27947):map__27947);
var heading = cljs.core.get.call(null,map__27947__$1,new cljs.core.Keyword(null,"heading","heading",-1312171873));
var speed = cljs.core.get.call(null,map__27947__$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__27944,map__27944__$1,seed,time,map__27945,map__27945__$1,offset,current,max,map__27946,map__27946__$1,direction,step,map__27947,map__27947__$1,heading,speed,now,max_t,vec__27941,x,y){
return (function (p1__27938_SHARP_){
return cljs.core.remove.call(null,new cljs.core.Keyword(null,"exclude-from-forecast?","exclude-from-forecast?",1182671640),p1__27938_SHARP_);
});})(map__27944,map__27944__$1,seed,time,map__27945,map__27945__$1,offset,current,max,map__27946,map__27946__$1,direction,step,map__27947,map__27947__$1,heading,speed,now,max_t,vec__27941,x,y))
);
return cljs.core.into.call(null,cljs.core.sorted_map_by.call(null,((function (map__27944,map__27944__$1,seed,time,map__27945,map__27945__$1,offset,current,max,map__27946,map__27946__$1,direction,step,map__27947,map__27947__$1,heading,speed,now,max_t,weather_params_STAR_,vec__27941,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__27944,map__27944__$1,seed,time,map__27945,map__27945__$1,offset,current,max,map__27946,map__27946__$1,direction,step,map__27947,map__27947__$1,heading,speed,now,max_t,weather_params_STAR_,vec__27941,x,y))
),(function (){var iter__4523__auto__ = ((function (map__27944,map__27944__$1,seed,time,map__27945,map__27945__$1,offset,current,max,map__27946,map__27946__$1,direction,step,map__27947,map__27947__$1,heading,speed,now,max_t,weather_params_STAR_,vec__27941,x,y){
return (function weathergen$model$forecast_$_iter__27952(s__27953){
return (new cljs.core.LazySeq(null,((function (map__27944,map__27944__$1,seed,time,map__27945,map__27945__$1,offset,current,max,map__27946,map__27946__$1,direction,step,map__27947,map__27947__$1,heading,speed,now,max_t,weather_params_STAR_,vec__27941,x,y){
return (function (){
var s__27953__$1 = s__27953;
while(true){
var temp__5720__auto__ = cljs.core.seq.call(null,s__27953__$1);
if(temp__5720__auto__){
var s__27953__$2 = temp__5720__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,s__27953__$2)){
var c__4521__auto__ = cljs.core.chunk_first.call(null,s__27953__$2);
var size__4522__auto__ = cljs.core.count.call(null,c__4521__auto__);
var b__27955 = cljs.core.chunk_buffer.call(null,size__4522__auto__);
if((function (){var i__27954 = (0);
while(true){
if((i__27954 < size__4522__auto__)){
var t = cljs.core._nth.call(null,c__4521__auto__,i__27954);
var dt = (t - now);
var vec__27956 = 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__27956,(0),null);
var dy = cljs.core.nth.call(null,vec__27956,(1),null);
var dpos = vec__27956;
cljs.core.chunk_append.call(null,b__27955,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__4131__auto__ = cljs.core._EQ_.call(null,t,now);
if(or__4131__auto__){
return or__4131__auto__;
} else {
var and__4120__auto__ = max_t;
if(cljs.core.truth_(and__4120__auto__)){
return (t <= max_t);
} else {
return and__4120__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__27962 = (i__27954 + (1));
i__27954 = G__27962;
continue;
} else {
return true;
}
break;
}
})()){
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__27955),weathergen$model$forecast_$_iter__27952.call(null,cljs.core.chunk_rest.call(null,s__27953__$2)));
} else {
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__27955),null);
}
} else {
var t = cljs.core.first.call(null,s__27953__$2);
var dt = (t - now);
var vec__27959 = 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__27959,(0),null);
var dy = cljs.core.nth.call(null,vec__27959,(1),null);
var dpos = vec__27959;
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__4131__auto__ = cljs.core._EQ_.call(null,t,now);
if(or__4131__auto__){
return or__4131__auto__;
} else {
var and__4120__auto__ = max_t;
if(cljs.core.truth_(and__4120__auto__)){
return (t <= max_t);
} else {
return and__4120__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__27952.call(null,cljs.core.rest.call(null,s__27953__$2)));
}
} else {
return null;
}
break;
}
});})(map__27944,map__27944__$1,seed,time,map__27945,map__27945__$1,offset,current,max,map__27946,map__27946__$1,direction,step,map__27947,map__27947__$1,heading,speed,now,max_t,weather_params_STAR_,vec__27941,x,y))
,null,null));
});})(map__27944,map__27944__$1,seed,time,map__27945,map__27945__$1,offset,current,max,map__27946,map__27946__$1,direction,step,map__27947,map__27947__$1,heading,speed,now,max_t,weather_params_STAR_,vec__27941,x,y))
;
return iter__4523__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__4523__auto__,map__27944,map__27944__$1,seed,time,map__27945,map__27945__$1,offset,current,max,map__27946,map__27946__$1,direction,step,map__27947,map__27947__$1,heading,speed,now,max_t,weather_params_STAR_,vec__27941,x,y){
return (function (p1__27939_SHARP_){
return (cljs.core.long$.call(null,((((p1__27939_SHARP_ + (1)) * interval) + now) / interval)) * interval);
});})(iter__4523__auto__,map__27944,map__27944__$1,seed,time,map__27945,map__27945__$1,offset,current,max,map__27946,map__27946__$1,direction,step,map__27947,map__27947__$1,heading,speed,now,max_t,weather_params_STAR_,vec__27941,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__27963 = movement_params;
var map__27963__$1 = (((((!((map__27963 == null))))?(((((map__27963.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27963.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27963):map__27963);
var evolution = cljs.core.get.call(null,map__27963__$1,new cljs.core.Keyword(null,"evolution","evolution",944820557));
var direction = cljs.core.get.call(null,map__27963__$1,new cljs.core.Keyword(null,"direction","direction",-633359395));
var map__27964 = direction;
var map__27964__$1 = (((((!((map__27964 == null))))?(((((map__27964.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27964.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27964):map__27964);
var speed = cljs.core.get.call(null,map__27964__$1,new cljs.core.Keyword(null,"speed","speed",1257663751));
var heading = cljs.core.get.call(null,map__27964__$1,new cljs.core.Keyword(null,"heading","heading",-1312171873));
var map__27965 = weather_params;
var map__27965__$1 = (((((!((map__27965 == null))))?(((((map__27965.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27965.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27965):map__27965);
var time = cljs.core.get.call(null,map__27965__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var map__27966 = time;
var map__27966__$1 = (((((!((map__27966 == null))))?(((((map__27966.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27966.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27966):map__27966);
var current = cljs.core.get.call(null,map__27966__$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 (type){
var weight = 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),type,new cljs.core.Keyword(null,"weight","weight",-1262796205)], null));
if(cljs.core._EQ_.call(null,type,new cljs.core.Keyword(null,"sunny","sunny",1448267778))){
return (weight * weight);
} else {
return weight;
}
});})(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__27971_SHARP_){
return (((p1__27971_SHARP_ / total) * pressure_span) + min_pressure);
});})(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__27972,new_revision){
var map__27973 = p__27972;
var map__27973__$1 = (((((!((map__27973 == null))))?(((((map__27973.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__27973.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__27973):map__27973);
var params = map__27973__$1;
var revision = cljs.core.get.call(null,map__27973__$1,new cljs.core.Keyword(null,"revision","revision",-1350113114));
if((revision < (8))){
throw cljs.core.ex_info.call(null,"This version of VMT cannot be used to load weather files from prior versions - file format changes in BMS 4.34 resulted in incompatibilities. You will need to ask the mission creator for a new briefing file.",new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"omit-stack-trace?","omit-stack-trace?",1080142229),true], null));
} else {
}

var G__27975 = params;
var G__27975__$1 = (((revision < (7)))?weathergen.model.upgrade_pressure_threshold.call(null,G__27975):G__27975);
return cljs.core.assoc.call(null,G__27975__$1,new cljs.core.Keyword(null,"revision","revision",-1350113114),new_revision);

});
