// 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__43799 = cljs.core.first.call(null,cljs.core.filter.call(null,((function (pressure_span,i,p,f,s,contour){
return (function (p__43808){
var vec__43809 = p__43808;
var vec__43812 = cljs.core.nth.call(null,vec__43809,(0),null);
var low = cljs.core.nth.call(null,vec__43812,(0),null);
var vec__43815 = cljs.core.nth.call(null,vec__43809,(1),null);
var high = cljs.core.nth.call(null,vec__43815,(0),null);
return ((low <= x)) && ((x <= high));
});})(pressure_span,i,p,f,s,contour))
,cljs.core.partition.call(null,(2),(1),contour)));
var vec__43802 = cljs.core.nth.call(null,vec__43799,(0),null);
var x1 = cljs.core.nth.call(null,vec__43802,(0),null);
var v1 = cljs.core.nth.call(null,vec__43802,(1),null);
var vec__43805 = cljs.core.nth.call(null,vec__43799,(1),null);
var x2 = cljs.core.nth.call(null,vec__43805,(0),null);
var v2 = cljs.core.nth.call(null,vec__43805,(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__43822){
var vec__43823 = p__43822;
var type = cljs.core.nth.call(null,vec__43823,(0),null);
var weight = cljs.core.nth.call(null,vec__43823,(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__43828 = params;
var map__43828__$1 = ((((!((map__43828 == null)))?((((map__43828.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__43828.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__43828):map__43828);
var x = cljs.core.get.call(null,map__43828__$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__43828__$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__43828__$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__43828__$1,new cljs.core.Keyword(null,"seed","seed",68613327));
var turbulence = cljs.core.get.call(null,map__43828__$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__43830){
var vec__43834 = p__43830;
var x = cljs.core.nth.call(null,vec__43834,(0),null);
var y = cljs.core.nth.call(null,vec__43834,(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__43837,v,params){
var vec__43841 = p__43837;
var x = cljs.core.nth.call(null,vec__43841,(0),null);
var y = cljs.core.nth.call(null,vec__43841,(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__43844,x_STAR_,y_STAR_){
var map__43847 = p__43844;
var map__43847__$1 = ((((!((map__43847 == null)))?((((map__43847.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__43847.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__43847):map__43847);
var bounds = map__43847__$1;
var x = cljs.core.get.call(null,map__43847__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var y = cljs.core.get.call(null,map__43847__$1,new cljs.core.Keyword(null,"y","y",-1757859776));
var width = cljs.core.get.call(null,map__43847__$1,new cljs.core.Keyword(null,"width","width",-384071477));
var height = cljs.core.get.call(null,map__43847__$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__43850,pattern_wind){
var map__43853 = p__43850;
var map__43853__$1 = ((((!((map__43853 == null)))?((((map__43853.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__43853.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__43853):map__43853);
var wind_stability_areas = cljs.core.get.call(null,map__43853__$1,new cljs.core.Keyword(null,"wind-stability-areas","wind-stability-areas",1732901204));
var x = cljs.core.get.call(null,map__43853__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var y = cljs.core.get.call(null,map__43853__$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__43853,map__43853__$1,wind_stability_areas,x,y){
return (function (p1__43849_SHARP_){
return weathergen.model.in_area_QMARK_.call(null,new cljs.core.Keyword(null,"bounds","bounds",1691609455).cljs$core$IFn$_invoke$arity$1(p1__43849_SHARP_),x,y);
});})(_QMARK_,map__43853,map__43853__$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__43857 = override;
var map__43857__$1 = ((((!((map__43857 == null)))?((((map__43857.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__43857.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__43857):map__43857);
var begin = cljs.core.get.call(null,map__43857__$1,new cljs.core.Keyword(null,"begin","begin",-319034319));
var peak = cljs.core.get.call(null,map__43857__$1,new cljs.core.Keyword(null,"peak","peak",389096055));
var taper = cljs.core.get.call(null,map__43857__$1,new cljs.core.Keyword(null,"taper","taper",1772067478));
var end = cljs.core.get.call(null,map__43857__$1,new cljs.core.Keyword(null,"end","end",-268185958));
var animate_QMARK_ = cljs.core.get.call(null,map__43857__$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__43863 = params;
var map__43863__$1 = ((((!((map__43863 == null)))?((((map__43863.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__43863.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__43863):map__43863);
var x = cljs.core.get.call(null,map__43863__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var y = cljs.core.get.call(null,map__43863__$1,new cljs.core.Keyword(null,"y","y",-1757859776));
var t = cljs.core.get.call(null,map__43863__$1,new cljs.core.Keyword(null,"t","t",-1397832519));
var weather_overrides = cljs.core.get.call(null,map__43863__$1,new cljs.core.Keyword(null,"weather-overrides","weather-overrides",-837381710));
var time = cljs.core.get.call(null,map__43863__$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__43863,map__43863__$1,x,y,t,weather_overrides,time,min_pressure,max_pressure,pressure_span){
return (function (v__$1,override){
var map__43865 = override;
var map__43865__$1 = ((((!((map__43865 == null)))?((((map__43865.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__43865.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__43865):map__43865);
var location = cljs.core.get.call(null,map__43865__$1,new cljs.core.Keyword(null,"location","location",1815599388));
var radius = cljs.core.get.call(null,map__43865__$1,new cljs.core.Keyword(null,"radius","radius",-2073122258));
var falloff = cljs.core.get.call(null,map__43865__$1,new cljs.core.Keyword(null,"falloff","falloff",-1639069456));
var strength = cljs.core.get.call(null,map__43865__$1,new cljs.core.Keyword(null,"strength","strength",-415606478));
var animate_QMARK_ = cljs.core.get.call(null,map__43865__$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__43863,map__43863__$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__43867){
var map__43875 = p__43867;
var map__43875__$1 = ((((!((map__43875 == null)))?((((map__43875.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__43875.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__43875):map__43875);
var params = map__43875__$1;
var wind_uniformity = cljs.core.get.call(null,map__43875__$1,new cljs.core.Keyword(null,"wind-uniformity","wind-uniformity",827531801));
var x = cljs.core.get.call(null,map__43875__$1,new cljs.core.Keyword(null,"x","x",2099068185));
var crossfade = cljs.core.get.call(null,map__43875__$1,new cljs.core.Keyword(null,"crossfade","crossfade",-118506406));
var prevailing_wind = cljs.core.get.call(null,map__43875__$1,new cljs.core.Keyword(null,"prevailing-wind","prevailing-wind",-190580386));
var y = cljs.core.get.call(null,map__43875__$1,new cljs.core.Keyword(null,"y","y",-1757859776));
var temp_uniformity = cljs.core.get.call(null,map__43875__$1,new cljs.core.Keyword(null,"temp-uniformity","temp-uniformity",836756864));
var pressure = cljs.core.get.call(null,map__43875__$1,new cljs.core.Keyword(null,"pressure","pressure",505343747));
var time = cljs.core.get.call(null,map__43875__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var evolution = cljs.core.get.call(null,map__43875__$1,new cljs.core.Keyword(null,"evolution","evolution",944820557));
var seed = cljs.core.get.call(null,map__43875__$1,new cljs.core.Keyword(null,"seed","seed",68613327));
var feature_size = cljs.core.get.call(null,map__43875__$1,new cljs.core.Keyword(null,"feature-size","feature-size",-878734864));
var categories = cljs.core.get.call(null,map__43875__$1,new cljs.core.Keyword(null,"categories","categories",178386610));
var origin = cljs.core.get.call(null,map__43875__$1,new cljs.core.Keyword(null,"origin","origin",1037372088));
var vec__43877 = origin;
var origin_x = cljs.core.nth.call(null,vec__43877,(0),null);
var origin_y = cljs.core.nth.call(null,vec__43877,(1),null);
var x_STAR_ = ((origin_x + x) / feature_size);
var y_STAR_ = ((origin_y + y) / feature_size);
var map__43880 = time;
var map__43880__$1 = ((((!((map__43880 == null)))?((((map__43880.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__43880.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__43880):map__43880);
var offset = cljs.core.get.call(null,map__43880__$1,new cljs.core.Keyword(null,"offset","offset",296498311));
var current = cljs.core.get.call(null,map__43880__$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__43882){
var map__43908 = p__43882;
var map__43908__$1 = ((((!((map__43908 == null)))?((((map__43908.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__43908.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__43908):map__43908);
var params = map__43908__$1;
var map_fn = cljs.core.get.call(null,map__43908__$1,new cljs.core.Keyword(null,"map-fn","map-fn",1184112686));
var cells = cljs.core.get.call(null,map__43908__$1,new cljs.core.Keyword(null,"cells","cells",-985166822));
var origin = cljs.core.get.call(null,map__43908__$1,new cljs.core.Keyword(null,"origin","origin",1037372088));
var time = cljs.core.get.call(null,map__43908__$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__43908,map__43908__$1,params,map_fn,cells,origin,time){
return (function (p__43910){
var vec__43911 = p__43910;
var vec__43914 = cljs.core.nth.call(null,vec__43911,(0),null);
var x = cljs.core.nth.call(null,vec__43914,(0),null);
var y = cljs.core.nth.call(null,vec__43914,(1),null);
var params__$1 = cljs.core.nth.call(null,vec__43911,(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__43908,map__43908__$1,params,map_fn,cells,origin,time))
,(function (){var iter__24200__auto__ = ((function (map_fn__$1,map__43908,map__43908__$1,params,map_fn,cells,origin,time){
return (function weathergen$model$weather_grid_$_iter__43917(s__43918){
return (new cljs.core.LazySeq(null,((function (map_fn__$1,map__43908,map__43908__$1,params,map_fn,cells,origin,time){
return (function (){
var s__43918__$1 = s__43918;
while(true){
var temp__5278__auto__ = cljs.core.seq.call(null,s__43918__$1);
if(temp__5278__auto__){
var s__43918__$2 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,s__43918__$2)){
var c__24198__auto__ = cljs.core.chunk_first.call(null,s__43918__$2);
var size__24199__auto__ = cljs.core.count.call(null,c__24198__auto__);
var b__43920 = cljs.core.chunk_buffer.call(null,size__24199__auto__);
if((function (){var i__43919 = (0);
while(true){
if((i__43919 < size__24199__auto__)){
var vec__43927 = cljs.core._nth.call(null,c__24198__auto__,i__43919);
var x = cljs.core.nth.call(null,vec__43927,(0),null);
var y = cljs.core.nth.call(null,vec__43927,(1),null);
cljs.core.chunk_append.call(null,b__43920,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__43933 = (i__43919 + (1));
i__43919 = G__43933;
continue;
} else {
return true;
}
break;
}
})()){
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__43920),weathergen$model$weather_grid_$_iter__43917.call(null,cljs.core.chunk_rest.call(null,s__43918__$2)));
} else {
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__43920),null);
}
} else {
var vec__43930 = cljs.core.first.call(null,s__43918__$2);
var x = cljs.core.nth.call(null,vec__43930,(0),null);
var y = cljs.core.nth.call(null,vec__43930,(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__43917.call(null,cljs.core.rest.call(null,s__43918__$2)));
}
} else {
return null;
}
break;
}
});})(map_fn__$1,map__43908,map__43908__$1,params,map_fn,cells,origin,time))
,null,null));
});})(map_fn__$1,map__43908,map__43908__$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__43938 = movement_params;
var map__43938__$1 = ((((!((map__43938 == null)))?((((map__43938.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__43938.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__43938):map__43938);
var step = cljs.core.get.call(null,map__43938__$1,new cljs.core.Keyword(null,"step","step",1288888124));
var direction = cljs.core.get.call(null,map__43938__$1,new cljs.core.Keyword(null,"direction","direction",-633359395));
var map__43939 = direction;
var map__43939__$1 = ((((!((map__43939 == null)))?((((map__43939.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__43939.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__43939):map__43939);
var speed = cljs.core.get.call(null,map__43939__$1,new cljs.core.Keyword(null,"speed","speed",1257663751));
var heading = cljs.core.get.call(null,map__43939__$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__43944,weather_params,movement_params,interval,steps){
var vec__43972 = p__43944;
var x = cljs.core.nth.call(null,vec__43972,(0),null);
var y = cljs.core.nth.call(null,vec__43972,(1),null);
var map__43975 = weather_params;
var map__43975__$1 = ((((!((map__43975 == null)))?((((map__43975.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__43975.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__43975):map__43975);
var seed = cljs.core.get.call(null,map__43975__$1,new cljs.core.Keyword(null,"seed","seed",68613327));
var time = cljs.core.get.call(null,map__43975__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var map__43976 = time;
var map__43976__$1 = ((((!((map__43976 == null)))?((((map__43976.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__43976.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__43976):map__43976);
var offset = cljs.core.get.call(null,map__43976__$1,new cljs.core.Keyword(null,"offset","offset",296498311));
var current = cljs.core.get.call(null,map__43976__$1,new cljs.core.Keyword(null,"current","current",-1088038603));
var max = cljs.core.get.call(null,map__43976__$1,new cljs.core.Keyword(null,"max","max",61366548));
var map__43977 = movement_params;
var map__43977__$1 = ((((!((map__43977 == null)))?((((map__43977.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__43977.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__43977):map__43977);
var direction = cljs.core.get.call(null,map__43977__$1,new cljs.core.Keyword(null,"direction","direction",-633359395));
var step = cljs.core.get.call(null,map__43977__$1,new cljs.core.Keyword(null,"step","step",1288888124));
var map__43978 = direction;
var map__43978__$1 = ((((!((map__43978 == null)))?((((map__43978.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__43978.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__43978):map__43978);
var heading = cljs.core.get.call(null,map__43978__$1,new cljs.core.Keyword(null,"heading","heading",-1312171873));
var speed = cljs.core.get.call(null,map__43978__$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__43975,map__43975__$1,seed,time,map__43976,map__43976__$1,offset,current,max,map__43977,map__43977__$1,direction,step,map__43978,map__43978__$1,heading,speed,now,max_t,vec__43972,x,y){
return (function (p1__43942_SHARP_){
return cljs.core.remove.call(null,new cljs.core.Keyword(null,"exclude-from-forecast?","exclude-from-forecast?",1182671640),p1__43942_SHARP_);
});})(map__43975,map__43975__$1,seed,time,map__43976,map__43976__$1,offset,current,max,map__43977,map__43977__$1,direction,step,map__43978,map__43978__$1,heading,speed,now,max_t,vec__43972,x,y))
);
return cljs.core.into.call(null,cljs.core.sorted_map_by.call(null,((function (map__43975,map__43975__$1,seed,time,map__43976,map__43976__$1,offset,current,max,map__43977,map__43977__$1,direction,step,map__43978,map__43978__$1,heading,speed,now,max_t,weather_params_STAR_,vec__43972,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__43975,map__43975__$1,seed,time,map__43976,map__43976__$1,offset,current,max,map__43977,map__43977__$1,direction,step,map__43978,map__43978__$1,heading,speed,now,max_t,weather_params_STAR_,vec__43972,x,y))
),(function (){var iter__24200__auto__ = ((function (map__43975,map__43975__$1,seed,time,map__43976,map__43976__$1,offset,current,max,map__43977,map__43977__$1,direction,step,map__43978,map__43978__$1,heading,speed,now,max_t,weather_params_STAR_,vec__43972,x,y){
return (function weathergen$model$forecast_$_iter__43983(s__43984){
return (new cljs.core.LazySeq(null,((function (map__43975,map__43975__$1,seed,time,map__43976,map__43976__$1,offset,current,max,map__43977,map__43977__$1,direction,step,map__43978,map__43978__$1,heading,speed,now,max_t,weather_params_STAR_,vec__43972,x,y){
return (function (){
var s__43984__$1 = s__43984;
while(true){
var temp__5278__auto__ = cljs.core.seq.call(null,s__43984__$1);
if(temp__5278__auto__){
var s__43984__$2 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,s__43984__$2)){
var c__24198__auto__ = cljs.core.chunk_first.call(null,s__43984__$2);
var size__24199__auto__ = cljs.core.count.call(null,c__24198__auto__);
var b__43986 = cljs.core.chunk_buffer.call(null,size__24199__auto__);
if((function (){var i__43985 = (0);
while(true){
if((i__43985 < size__24199__auto__)){
var t = cljs.core._nth.call(null,c__24198__auto__,i__43985);
var dt = (t - now);
var vec__43993 = 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__43993,(0),null);
var dy = cljs.core.nth.call(null,vec__43993,(1),null);
var dpos = vec__43993;
cljs.core.chunk_append.call(null,b__43986,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__43999 = (i__43985 + (1));
i__43985 = G__43999;
continue;
} else {
return true;
}
break;
}
})()){
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__43986),weathergen$model$forecast_$_iter__43983.call(null,cljs.core.chunk_rest.call(null,s__43984__$2)));
} else {
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__43986),null);
}
} else {
var t = cljs.core.first.call(null,s__43984__$2);
var dt = (t - now);
var vec__43996 = 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__43996,(0),null);
var dy = cljs.core.nth.call(null,vec__43996,(1),null);
var dpos = vec__43996;
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__43983.call(null,cljs.core.rest.call(null,s__43984__$2)));
}
} else {
return null;
}
break;
}
});})(map__43975,map__43975__$1,seed,time,map__43976,map__43976__$1,offset,current,max,map__43977,map__43977__$1,direction,step,map__43978,map__43978__$1,heading,speed,now,max_t,weather_params_STAR_,vec__43972,x,y))
,null,null));
});})(map__43975,map__43975__$1,seed,time,map__43976,map__43976__$1,offset,current,max,map__43977,map__43977__$1,direction,step,map__43978,map__43978__$1,heading,speed,now,max_t,weather_params_STAR_,vec__43972,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__43975,map__43975__$1,seed,time,map__43976,map__43976__$1,offset,current,max,map__43977,map__43977__$1,direction,step,map__43978,map__43978__$1,heading,speed,now,max_t,weather_params_STAR_,vec__43972,x,y){
return (function (p1__43943_SHARP_){
return (cljs.core.long$.call(null,((((p1__43943_SHARP_ + (1)) * interval) + now) / interval)) * interval);
});})(iter__24200__auto__,map__43975,map__43975__$1,seed,time,map__43976,map__43976__$1,offset,current,max,map__43977,map__43977__$1,direction,step,map__43978,map__43978__$1,heading,speed,now,max_t,weather_params_STAR_,vec__43972,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__44008 = movement_params;
var map__44008__$1 = ((((!((map__44008 == null)))?((((map__44008.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__44008.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__44008):map__44008);
var evolution = cljs.core.get.call(null,map__44008__$1,new cljs.core.Keyword(null,"evolution","evolution",944820557));
var direction = cljs.core.get.call(null,map__44008__$1,new cljs.core.Keyword(null,"direction","direction",-633359395));
var map__44009 = direction;
var map__44009__$1 = ((((!((map__44009 == null)))?((((map__44009.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__44009.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__44009):map__44009);
var speed = cljs.core.get.call(null,map__44009__$1,new cljs.core.Keyword(null,"speed","speed",1257663751));
var heading = cljs.core.get.call(null,map__44009__$1,new cljs.core.Keyword(null,"heading","heading",-1312171873));
var map__44010 = weather_params;
var map__44010__$1 = ((((!((map__44010 == null)))?((((map__44010.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__44010.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__44010):map__44010);
var time = cljs.core.get.call(null,map__44010__$1,new cljs.core.Keyword(null,"time","time",1385887882));
var map__44011 = time;
var map__44011__$1 = ((((!((map__44011 == null)))?((((map__44011.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__44011.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__44011):map__44011);
var current = cljs.core.get.call(null,map__44011__$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__44016_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__44016_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__44017_SHARP_){
return weathergen.math.nearest.call(null,(((p1__44017_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__44018,new_revision){
var map__44022 = p__44018;
var map__44022__$1 = ((((!((map__44022 == null)))?((((map__44022.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__44022.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__44022):map__44022);
var params = map__44022__$1;
var revision = cljs.core.get.call(null,map__44022__$1,new cljs.core.Keyword(null,"revision","revision",-1350113114));
var G__44024 = params;
var G__44024__$1 = (((revision < (7)))?weathergen.model.upgrade_pressure_threshold.call(null,G__44024):G__44024);
return cljs.core.assoc.call(null,G__44024__$1,new cljs.core.Keyword(null,"revision","revision",-1350113114),new_revision);

});
