r"""Werthmüller 201 pt Hankel filter, 2018.

    Designed with the empymod add-on ``fdesign``, see
    https://github.com/empymod/article-fdesign.

    License: `Apache License, Version 2.0,
    <http://www.apache.org/licenses/LICENSE-2.0>`_.
188068
def wer_201_2018():
    

    """

    dlf = DigitalFilter('Werthmüller 201', 'wer_201_2018')

    dlf.base = np.array([
        8.653980893285999343e-04, 9.170399868578506730e-04,
        9.717635708540675208e-04, 1.029752738345341345e-03,
        1.091202360259058363e-03, 1.156318936280037154e-03,
        1.225321288786770891e-03, 1.298441298197734088e-03,
        1.375924682198844014e-03, 1.458031821470676028e-03,
        1.545038634690233410e-03, 1.637237505747725754e-03,
        1.734938266294200121e-03, 1.838469236921894991e-03,
        1.948178330476121357e-03, 2.064434221206373505e-03,
        2.187627583685520637e-03, 2.318172405660454734e-03,
        2.456507379246002792e-03, 2.603097375137131825e-03,
        2.758435004793547123e-03, 2.923042275846299189e-03,
        3.097472346289414230e-03, 3.282311383351382318e-03,
        3.478180533293271509e-03, 3.685738008752825322e-03,
        3.905681300649099623e-03, 4.138749522080598965e-03,
        4.385725892093550113e-03, 4.647440367666977670e-03,
        4.924772432759196537e-03, 5.218654053788364042e-03,
        5.530072811478751842e-03, 5.860075219597365645e-03,
        6.209770241733286907e-03, 6.580333017937914017e-03,
        6.973008813749223544e-03, 7.389117204870794542e-03,
        7.830056511567909730e-03, 8.297308497682591086e-03,
        8.792443350058264107e-03, 9.317124955107483966e-03,
        9.873116490254248145e-03, 1.046228634904101083e-02,
        1.108661441981135046e-02, 1.174819873906770597e-02,
        1.244926254186268406e-02, 1.319216173291635694e-02,
        1.397939280356631266e-02, 1.481360122115480543e-02,
        1.569759031904567614e-02, 1.663433071714528685e-02,
        1.762697030458526201e-02, 1.867884481811322647e-02,
        1.979348905174003331e-02, 2.097464873531334692e-02,
        2.222629312193481060e-02, 2.355262832652090660e-02,
        2.495811146033087569e-02, 2.644746560896089893e-02,
        2.802569570413705746e-02, 2.969810534264444649e-02,
        3.147031460891126092e-02, 3.334827896114080786e-02,
        3.533830924445728605e-02, 3.744709289831891358e-02,
        3.968171642946591998e-02, 4.204968922592208086e-02,
        4.455896879207719985e-02, 4.721798748965116282e-02,
        5.003568087440296575e-02, 5.302151772380819111e-02,
        5.618553185661335353e-02, 5.953835585119460899e-02,
        6.309125677603129312e-02, 6.685617405236506106e-02,
        7.084575957628110043e-02, 7.507342023504076645e-02,
        7.955336296053971967e-02, 8.430064247129397115e-02,
        8.933121186338736919e-02, 9.466197622039211612e-02,
        1.003108494224146802e-01, 1.062968143451746283e-01,
        1.126399866514113390e-01, 1.193616823889895873e-01,
        1.264844896228644322e-01, 1.340323443416230609e-01,
        1.420306108936851552e-01, 1.505061672234652703e-01,
        1.594874951939309615e-01, 1.690047762990831426e-01,
        1.790899930879975566e-01, 1.897770366412597776e-01,
        2.011018204609656135e-01, 2.131024011570106513e-01,
        2.258191063352318062e-01, 2.392946701171655144e-01,
        2.535743767468323084e-01, 2.687062127671349665e-01,
        2.847410282772538936e-01, 3.017327078129410922e-01,
        3.197383514239506286e-01, 3.388184665571116749e-01,
        3.590371713898611872e-01, 3.804624102975323052e-01,
        4.031661821784713884e-01, 4.272247824042622599e-01,
        4.527190592081252185e-01, 4.797346853730769523e-01,
        5.083624461328500876e-01, 5.386985442530570767e-01,
        5.708449233178135573e-01, 6.049096103082166609e-01,
        6.410070786239048246e-01, 6.792586327676195523e-01,
        7.197928159854947161e-01, 7.627458422329327359e-01,
        8.082620539176789132e-01, 8.564944069583262376e-01,
        9.076049847882753374e-01, 9.617655430324436594e-01,
        1.019158086687097953e+00, 1.079975481742401877e+00,
        1.144422103303022853e+00, 1.212714522384784388e+00,
        1.285082233695329812e+00, 1.361768426844476521e+00,
        1.443030803575896748e+00, 1.529142443766406734e+00,
        1.620392723103028176e+00, 1.717088285521651159e+00,
        1.819554073675149652e+00, 1.928134420893808709e+00,
        2.043194208307565596e+00, 2.165120091018537973e+00,
        2.294321797444361266e+00, 2.431233506198735572e+00,
        2.576315305136151590e+00, 2.730054737463883274e+00,
        2.892968440116886253e+00, 3.065603879901345419e+00,
        3.248541193241110570e+00, 3.442395135709440002e+00,
        3.647817147897402634e+00, 3.865497544561224075e+00,
        4.096167834405143537e+00, 4.340603178295351583e+00,
        4.599624994165753655e+00, 4.874103717369282940e+00,
        5.164961725750846000e+00, 5.473176439271492555e+00,
        5.799783604600056819e+00, 6.145880775710010013e+00,
        6.512631002177978523e+00, 6.901266737578352739e+00,
        7.313093981108034214e+00, 7.749496666359123154e+00,
        8.211941311987910552e+00, 8.701981949908562441e+00,
        9.221265347572652260e+00, 9.771536541883744320e+00,
        1.035464470334362019e+01, 1.097254935013656407e+01,
        1.162732693303372145e+01, 1.232117781324618733e+01,
        1.305643365667540934e+01, 1.383556526940939513e+01,
        1.466119090079532228e+01, 1.553608504199116247e+01,
        1.646318774956322173e+01, 1.744561452546165370e+01,
        1.848666678657500739e+01, 1.958984295904654616e+01,
        2.075885023463468926e+01, 2.199761702862400270e+01,
        2.331030618115176267e+01, 2.470132894631230158e+01,
        2.617535981604930129e+01, 2.773735222865149197e+01,
        2.939255521463919862e+01, 3.114653103598043415e+01,
        3.300517387791185087e+01, 3.497472965617872376e+01,
        3.706181700625468523e+01, 3.927344952507589682e+01,
        4.161705934003131091e+01, 4.410052208441296528e+01,
        4.673218336325475519e+01, 4.952088679849771324e+01,
        5.247600374772711262e+01, 5.560746479634944706e+01,
        5.892579312903905020e+01, 6.244213989259677078e+01,
        6.616832166905808776e+01, 7.011686018497628936e+01,
        7.430102439032442874e+01, 7.873487504841911289e+01,
        8.343331198671111792e+01, 8.841212416722630962e+01,
        9.368804274491759543e+01])

    dlf.factor = np.array([1.0596741524693181])

    dlf.j0 = np.array([
        2.940900904253498815e+00, -1.601154970027019786e+01,
        3.574488144287594338e+01, -3.775710631592443178e+01,
        9.347313619702582344e+00, 1.903333998229986435e+01,
        -1.266160545445113073e+01, -1.274822633210828471e+01,
        1.499040669570122830e+01, 1.128114232815630835e+01,
        -3.141814347069891511e+01, 2.185520874118305557e+01,
        4.204688908817206361e+00, -2.039396651211594147e+01,
        1.703214350560853418e+01, -3.858035665251962953e+00,
        -5.664929771474184861e+00, 6.236013601339658763e+00,
        -8.349084962847823643e-01, -5.076648434675173682e+00,
        8.069437229646323928e+00, -7.693517618528387558e+00,
        5.264540454351635645e+00, -2.378232295562936471e+00,
        9.488986688091295696e-02, 1.211665432819921451e+00,
        -1.641788465968915700e+00, 1.505783472315168181e+00,
        -1.120376089133631847e+00, 7.202627618735454318e-01,
        -4.293308092527763353e-01, 2.880519253847271255e-01,
        -2.765909110132210857e-01, 3.540771325316399709e-01,
        -4.702415607316920432e-01, 5.886079250132733032e-01,
        -6.804407177384068639e-01, 7.365579045711867501e-01,
        -7.516232294769148448e-01, 7.332518369461620278e-01,
        -6.840940481215002089e-01, 6.145375558739786248e-01,
        -5.263752170486778459e-01, 4.305607160730071659e-01,
        -3.307504282674695872e-01, 2.429511351824290011e-01,
        -1.749591466871897039e-01, 1.456366850874822316e-01,
        -1.595894233786172844e-01, 2.280395161025021433e-01,
        -3.413711397379035062e-01, 4.950015142033588056e-01,
        -6.617826176259098414e-01, 8.243458750063681340e-01,
        -9.468449720632085009e-01, 1.012979648696065826e+00,
        -9.946084380621768029e-01, 8.932243609342348512e-01,
        -7.019325270091921753e-01, 4.480078578272302381e-01,
        -1.456381084707468188e-01, -1.604285443826692914e-01,
        4.506359421881006022e-01, -6.820827325803067165e-01,
        8.491728004462286705e-01, -9.252486609867097700e-01,
        9.260533367474167443e-01, -8.402031897556576645e-01,
        6.982570225067336045e-01, -4.946654104012083719e-01,
        2.669962789856030194e-01, -1.042528939201309117e-02,
        -2.319933928270803414e-01, 4.654858099944349514e-01,
        -6.436180173401860882e-01, 7.780252822887177011e-01,
        -8.272840865922600484e-01, 8.197748606729908794e-01,
        -7.271116816505861502e-01, 5.992292042110317629e-01,
        -4.191980233493379782e-01, 2.522483458861179417e-01,
        -8.121597742330896597e-02, -2.652177515646544220e-02,
        1.028351781199190462e-01, -8.958878867947789315e-02,
        4.230973855067972356e-02, 8.503909842995018009e-02,
        -2.142619566112575480e-01, 3.865561094837716705e-01,
        -5.104727910435372662e-01, 6.353554205789004872e-01,
        -6.678424785380696616e-01, 6.769052092946485910e-01,
        -5.740789051340543514e-01, 4.533865101372042683e-01,
        -2.311110970314779189e-01, 2.495118155831516429e-02,
        2.508326503987150513e-01, -4.617568849058834579e-01,
        7.064398492531979157e-01, -8.419497320020807862e-01,
        9.894625411708843910e-01, -1.001995584015555441e+00,
        1.027606495406535592e+00, -9.137586391106879979e-01,
        8.347545540345707726e-01, -6.273557157264747497e-01,
        4.895538883108097039e-01, -2.415916082478662963e-01,
        1.027651673270286170e-01, 1.284590129111473078e-01,
        -2.133464520148750654e-01, 3.796869867196227544e-01,
        -3.706104772018420923e-01, 4.433984947033918766e-01,
        -3.235750823461782666e-01, 2.994380356487793549e-01,
        -7.888021235143724552e-02, -1.910472056257344828e-02,
        3.043509756878240990e-01, -4.298489130677841108e-01,
        7.233655581626995401e-01, -8.161936207950235556e-01,
        1.054311731055406431e+00, -1.057859070622381603e+00,
        1.189505276805579825e+00, -1.071819355511486993e+00,
        1.077289848919564141e+00, -8.458743245226547636e-01,
        7.443908003078970603e-01, -4.461507052923350813e-01,
        2.868208498373531756e-01, 8.293917061440093941e-03,
        -1.688393814622326516e-01, 3.930003549460732160e-01,
        -5.148213607425790039e-01, 6.232961968619017412e-01,
        -6.962255871378753014e-01, 6.749680427277989780e-01,
        -7.157027353444623818e-01, 5.769543174180707945e-01,
        -6.151602424632486299e-01, 3.892025319337197864e-01,
        -4.506933666706669506e-01, 1.804687704243498336e-01,
        -2.727244303574414830e-01, 1.174346932607069939e-02,
        -1.137579568068424057e-01, -7.811421895993872488e-02,
        1.779393134675293781e-02, -8.675295089134033022e-02,
        1.335093001151206882e-01, -5.514694464669991220e-02,
        2.441624548660136784e-01, -5.518933795483266236e-02,
        3.328770195966135881e-01, -1.532145946078544430e-01,
        3.579812932040986606e-01, -3.542418291888540516e-01,
        3.138078445399646865e-01, -5.530414472417091165e-01,
        2.996207005996078809e-01, -5.735406549188309944e-01,
        4.429014477665748628e-01, -3.892397979507834505e-01,
        6.319796721730875921e-01, -3.224362675105876264e-01,
        5.280557016061210307e-01, -5.925152169592526885e-01,
        3.097933933610434454e-01, -6.161398121500974989e-01,
        5.824585099080735739e-01, -2.863603061506506120e-01,
        5.579069742591284964e-01, -5.790177379949956737e-01,
        1.778203303660013113e-01, -2.248159329174458654e-01,
        4.570279405020428731e-01, -2.082694991220853942e-01,
        -1.639463813834285966e-01, 1.219471051626438846e-01,
        1.315907246465166380e-01, -1.561922951483753763e-01,
        -9.000173966500184253e-02, 3.555651953426591794e-01,
        -4.594671107387718334e-01, 4.051183609553802301e-01,
        -2.826594312508529105e-01, 1.664628231342878961e-01,
        -8.573386548433219179e-02, 3.940897144775467459e-02,
        -1.632396319789397934e-02, 6.095399479649578345e-03,
        -2.034197210251703809e-03, 5.959585007671103435e-04,
        -1.489396688112877424e-04, 3.040429693056684047e-05,
        -4.735729642331119566e-06, 4.982902654694162416e-07,
        -2.645962918790746080e-08])

    dlf.j1 = np.array([
        -2.594301879688918743e-03, 2.339490069567079153e-02,
        -9.478827695764932559e-02, 2.269100107268227362e-01,
        -3.508900104631907935e-01, 3.515648778060092017e-01,
        -1.994483426338835574e-01, 9.293484158449249674e-03,
        8.048790331434139966e-02, -5.691508909482047296e-02,
        2.075411236619714023e-02, -5.275228907131672418e-02,
        1.348060780914397960e-01, -1.939017682982676627e-01,
        1.854125006516780250e-01, -1.238162114378456441e-01,
        5.435433909585837137e-02, -1.270327896980103649e-02,
        7.560629247467166685e-03, -2.713648547163816441e-02,
        5.383176198347366936e-02, -7.463014212375274070e-02,
        8.413254388281748986e-02, -8.280914671407160754e-02,
        7.393816085156304507e-02, -6.119942568117115594e-02,
        4.746907894866293082e-02, -3.450474036399159977e-02,
        2.313104032185092293e-02, -1.354138672902785445e-02,
        5.604638952874172256e-03, 9.486899997092870969e-04,
        -6.382314415042419746e-03, 1.091601370650388016e-02,
        -1.467479730415811347e-02, 1.771829574440562591e-02,
        -2.001990396213982823e-02, 2.152720536808908763e-02,
        -2.214634467574278301e-02, 2.181839780171816040e-02,
        -2.049006667874660528e-02, 1.819226618052163791e-02,
        -1.498058384418661862e-02, 1.101097898088004151e-02,
        -6.444381466006598655e-03, 1.527769500667217105e-03,
        3.533045890696502513e-03, -8.470577184056853060e-03,
        1.310891443998619434e-02, -1.722186749311952272e-02,
        2.071070403809925978e-02, -2.340849145682623311e-02,
        2.528895672008608583e-02, -2.620974028011485712e-02,
        2.617463680378217042e-02, -2.501974545161460978e-02,
        2.276381800709064221e-02, -1.923696679546721411e-02,
        1.454384146700743972e-02, -8.605818651281786635e-03,
        1.738844503682727928e-03, 5.947517515245405624e-03,
        -1.385885800081448037e-02, 2.171703574368676753e-02,
        -2.872814698074024550e-02, 3.461838232135941440e-02,
        -3.858941536214401807e-02, 4.060565074712448042e-02,
        -4.004001014668581715e-02, 3.725276070158690944e-02,
        -3.184536604257427045e-02, 2.462644816656397312e-02,
        -1.539955242663786951e-02, 5.437594699869644464e-03,
        5.315602443775078317e-03, -1.514798704965643165e-02,
        2.414409295479183482e-02, -3.032245442310742278e-02,
        3.416403682006976389e-02, -3.375211066545635158e-02,
        3.045425146826126819e-02, -2.272683240323554107e-02,
        1.317397219169818418e-02, -6.119848802195663844e-04,
        -1.115685958739305421e-02, 2.344848055710842955e-02,
        -3.169397030448774938e-02, 3.817520279763731567e-02,
        -3.809651169502087376e-02, 3.552394037620545952e-02,
        -2.568176960339346032e-02, 1.487169880055576841e-02,
        1.997965754252607837e-03, -1.644546122863936588e-02,
        3.480415781283187349e-02, -4.677537576184215284e-02,
        6.111820051573001178e-02, -6.590953690231306228e-02,
        7.332112878498593667e-02, -6.941405787722150500e-02,
        7.037058951810715168e-02, -5.921683716330301134e-02,
        5.655416878814193554e-02, -4.097804417398832194e-02,
        3.810136479256000241e-02, -2.058552251762190213e-02,
        2.012009960638341116e-02, -1.904932224648239053e-03,
        5.324133880430357950e-03, 1.357085636140308721e-02,
        -5.592398994521355186e-03, 2.589415408390925710e-02,
        -1.292224858788840886e-02, 3.561835458678683924e-02,
        -1.700336052804993919e-02, 4.302272543873187499e-02,
        -1.764501119714675936e-02, 4.776824187802861110e-02,
        -1.404967795338326469e-02, 4.909105531804618811e-02,
        -5.268363386320836297e-03, 4.641444115511134810e-02,
        9.124170345995139680e-03, 3.991380510079723526e-02,
        2.859680534219202416e-02, 3.073032173944831302e-02,
        5.151734601415858261e-02, 2.097520864952298614e-02,
        7.511832720419686638e-02, 1.354148686126329000e-02,
        9.576070647813632319e-02, 1.140272504589405489e-02,
        1.097360846564945647e-01, 1.641156037670641471e-02,
        1.142607074214286172e-01, 2.822722328175052836e-02,
        1.079741026261866604e-01, 4.397838549427537935e-02,
        9.072532008032478668e-02, 5.865331390992817306e-02,
        6.310580311949447185e-02, 6.592890500839264367e-02,
        2.624768245556352575e-02, 5.954092122676180737e-02,
        -1.789442088462365327e-02, 3.555984804371448149e-02,
        -6.551973841104229146e-02, -4.489823587807304991e-03,
        -1.089659607197719371e-01, -5.052377390460756346e-02,
        -1.345089168583019634e-01, -8.286532978746213862e-02,
        -1.229744228392625760e-01, -7.728334735138943368e-02,
        -5.831402820224085293e-02, -2.088719549713474385e-02,
        5.205792146829352207e-02, 6.258826423151815643e-02,
        1.537593434905694390e-01, 9.979165672991972824e-02,
        1.545936043232943868e-01, 1.442374184540378551e-02,
        1.426608350698001064e-02, -1.462978689171700042e-01,
        -1.285617304470880462e-01, -1.519560295563492092e-01,
        -4.700754607069132507e-02, 1.106161196544740571e-01,
        1.168039951766200457e-01, 2.366820009670577984e-01,
        -1.283956636561735531e-01, 1.406024618127853579e-02,
        -4.011626826391421763e-01, 2.656020926376266300e-01,
        -1.291178852844470371e-01, 5.190017993719785450e-01,
        -5.307617026829943851e-01, 2.388177316428383157e-01,
        -4.213777919843004205e-01, 7.425023205388556757e-01,
        -6.039491377476802203e-01, 2.966551251977549986e-01,
        -3.157763414193298090e-01, 5.842678377857475347e-01,
        -7.375386163194860289e-01, 6.321787190293964853e-01,
        -3.871768116388242809e-01, 1.635153404860406612e-01,
        -3.134030444480916111e-02, -2.007964312111037639e-02,
        2.747060309825222202e-02, -1.969027573928272892e-02,
        1.080160200622757964e-02, -4.917741573140644099e-03,
        1.900872502605262596e-03, -6.228037791451519409e-04,
        1.698280169898911708e-04, -3.718088395106743311e-05,
        6.139140918052498045e-06, -6.796809441105533029e-07,
        3.780807126974975489e-08])

    return dlf
1238127
function convolute2DI(ftSignal, ftFilter, ftRows, ftCols) {
    var re, im;
    for (var iRow = 0; iRow < ftRows / 2; iRow++) {
        for (var iCol = 0; iCol < ftCols; iCol++) {
            //
            re = ftSignal[(iRow * 2) * ftCols + iCol]
                * ftFilter[(iRow * 2) * ftCols + iCol]
                - ftSignal[(iRow * 2 + 1) * ftCols + iCol]
                * ftFilter[(iRow * 2 + 1) * ftCols + iCol];
            im = ftSignal[(iRow * 2) * ftCols + iCol]
                * ftFilter[(iRow * 2 + 1) * ftCols + iCol]
                + ftSignal[(iRow * 2 + 1) * ftCols + iCol]
                * ftFilter[(iRow * 2) * ftCols + iCol];
            //
            ftSignal[(iRow * 2) * ftCols + iCol] = re;
            ftSignal[(iRow * 2 + 1) * ftCols + iCol] = im;
        }
    }
}
647727
public static void hessianBorder(GrayF32 integral, int skip , int size ,
									 GrayF32 intensity)
	{
		final int w = intensity.width;
		final int h = intensity.height;

		// get convolution kernels for the second order derivatives
		IntegralKernel kerXX = DerivativeIntegralImage.kernelDerivXX(size,null);
		IntegralKernel kerYY = DerivativeIntegralImage.kernelDerivYY(size,null);
		IntegralKernel kerXY = DerivativeIntegralImage.kernelDerivXY(size,null);

		int radiusFeature = size/2;
		final int borderOrig = radiusFeature+ 1 + (skip-(radiusFeature+1)%skip);
		final int border = borderOrig/skip;

		float norm = 1.0f/(size*size);

		BoofConcurrency.loopFor(0, h, y -> {
			int yy = y * skip;
			for (int x = 0; x < border; x++) {
				int xx = x * skip;
				computeHessian(integral, intensity, kerXX, kerYY, kerXY, norm, y, yy, x, xx);
			}
			for (int x = w - border; x < w; x++) {
				int xx = x * skip;
				computeHessian(integral, intensity, kerXX, kerYY, kerXY, norm, y, yy, x, xx);
			}
		});

		BoofConcurrency.loopFor(border, w-border, x -> {
			int xx = x*skip;

			for( int y = 0; y < border; y++ ) {
				int yy = y*skip;
				computeHessian(integral, intensity, kerXX, kerYY, kerXY, norm, y, yy, x, xx);
			}
			for( int y = h-border; y < h; y++ ) {
				int yy = y*skip;
				computeHessian(integral, intensity, kerXX, kerYY, kerXY, norm, y, yy, x, xx);
			}
		});
	}
62578
def bandpass(ts, low_hz, high_hz, order=3):
    """"""
    orig_ndim = ts.ndim
    if ts.ndim is 1:
        ts = ts[:, np.newaxis]
    channels = ts.shape[1]
    fs = (len(ts) - 1.0) / (ts.tspan[-1] - ts.tspan[0])
    nyq = 0.5 * fs
    low = low_hz/nyq
    high = high_hz/nyq
    b, a = signal.butter(order, [low, high], btype='band')
    if not np.all(np.abs(np.roots(a)) < 1.0):
        raise ValueError('Filter will not be stable with these values.')
    dtype = ts.dtype
    output = np.zeros((len(ts), channels), dtype)
    for i in range(channels):
        output[:, i] = signal.filtfilt(b, a, ts[:, i])
    if orig_ndim is 1:
        output = output[:, 0]
    return Timeseries(output, ts.tspan, labels=ts.labels)
413888
def maskedFilter(arr, mask, ksize=30, fill_mask=True,
                 fn='median'):
    '''
    
    '''

    if fill_mask:
        mask1 = mask
        out = arr
    else:
        mask1 = ~mask
        out = np.full_like(arr, fill_value=np.nan)
    mask2 = ~mask

    if fn == 'mean':
        _calcMean(arr, mask1, mask2, out, ksize // 2)
    else:
        buff = np.empty(shape=(ksize * ksize), dtype=arr.dtype)
        _calcMedian(arr, mask1, mask2, out, ksize // 2, buff)
    return out
412147
function SepiaFilter()
{
    core.AbstractFilter.call(this,
        // vertex shader
        null,
        // fragment shader
        fs.readFileSync(__dirname + '/sepia.frag', 'utf8'),
        // custom uniforms
        {
            sepia: { type: '1f', value: 1 }
        }
    );
}
349748
def gauss_blur( sigma, max_error = 1.0 / 0x100 )
      filter_type = DFLOAT.align typecode
      filter = Sequence[ *Array.gauss_blur_filter( sigma, max_error / dimension ) ].
        to_type filter_type
      ( dimension - 1 ).downto( 0 ).inject self do |retval,i|
        retval.convolve filter
      end
    end
325333
public static <T extends ImageBase<T>> BlurStorageFilter<T> gaussian(ImageType<T> type , double sigma , int radius ) {
		return new BlurStorageFilter<>("gaussian", type, sigma, radius);
	}
770082
function filterCoeffs(f_c) {
  if (f_c > 0.5) {  // we can't lowpass above the nyquist frequency...
    f_c = 0.5;
  }
  var wct = Math.sqrt(2) * Math.PI * f_c;
  var e = Math.exp(-wct);
  var c = e * Math.cos(wct);
  var gain = (1 - 2*c + e*e) / 2;
  return [gain, 2*c, -e*e];
}
1242754
def savgol_filter(x, window_length, polyorder, deriv=0, delta=1.0, axis=-1, mode='interp', cval=0.0):
    '''
    
    '''
    # linearly interpolate missing values before filtering
    x = np.ma.masked_invalid(pd.Series(x).interpolate())

    try:
        # start filtering from the first non-zero value since these won't be addressed by
        # the interpolation above
        ind = np.isfinite(x).nonzero()[0][0]
        x[ind:] = signal.savgol_filter(x[ind:], window_length, polyorder, deriv,
                                       delta, axis, mode, cval)
    except IndexError:
        pass
    return np.ma.masked_invalid(x)
1109396
def _get_struct_bevelfilter(self):
        """"""
        obj = _make_object("BevelFilter")
        obj.ShadowColor = self._get_struct_rgba()
        obj.HighlightColor = self._get_struct_rgba()
        obj.BlurX = unpack_fixed16(self._src)
        obj.BlurY = unpack_fixed16(self._src)
        obj.Angle = unpack_fixed16(self._src)
        obj.Distance = unpack_fixed16(self._src)
        obj.Strength = unpack_fixed8(self._src)
        bc = BitConsumer(self._src)
        obj.InnerShadow = bc.u_get(1)
        obj.Knockout = bc.u_get(1)
        obj.CompositeSource = bc.u_get(1)
        obj.OnTop = bc.u_get(1)
        obj.Passes = bc.u_get(4)
        return obj
1366201
def _twofilter_smoothing_ON2(self, t, ti, info, phi, lwinfo):
        
        sp, sw = 0., 0.
        upb = lwinfo.max() + self.wgt[t].lw.max()
        if hasattr(self.model, 'upper_bound_trans'):
            upb += self.model.upper_bound_trans(t + 1)
        # Loop over n, to avoid having in memory a NxN matrix
        for n in range(self.N):
            omegan = np.exp(lwinfo + self.wgt[t].lw[n] - upb
                            + self.model.logpt(t + 1, self.X[t][n],
                                               info.hist.X[ti]))
            sp += np.sum(omegan * phi(self.X[t][n], info.hist.X[ti]))
            sw += np.sum(omegan)
        return sp / sw
225037
function addSwigFilters() {

    /**
     * Zero padding function.
     * Used as both a filter and internally here.
     *
     * @param input
     * @param length
     * @returns {string}
     */
    function zeropad(input, length) {
      input = input + ''; // Ensure input is a string.
      length = length || 2; // Ensure a length is set.
      return input.length >= length ? input : new Array(length - input.length + 1).join('0') + input;
    }

    /**
     * Add a very simple range filter that handles integers with step = 1.
     *
     * @return []
     */
    swig.setFilter('range', function(start, stop, step) {
      var range = [];
      for(var i = start; i <= stop; i += step) {
        range.push(i);
      }
      return range;
    });

    /**
     * Convert a string in hh:mm format to the number of seconds after midnight it represents.
     *
     * @return in
     */
    swig.setFilter('hhmm_to_seconds', function(hhmm) {
      var parts = hhmm.split(':');
      return parts[0] * 60 * 60 + parts[1] * 60;
    });

    /**
     *
     */
    swig.setFilter('seconds_to_hhmm', function(seconds) {
      var date = new Date(seconds * 1000);
      return zeropad(date.getUTCHours()) + ':' + zeropad(date.getUTCMinutes());
    });

    /**
     * Add a filter to zero-pad the input to the given length (default 2).
     */
    swig.setFilter('zeropad', zeropad);

  }
260134
def _calculate_filter(n, spacing, shift, fI, r_def, reim, name):
    """

    # Base :: For this n/spacing/shift
    base = np.exp(spacing*(np.arange(n)-n//2) + shift)

    # r :: Start/end is defined by base AND r_def[0]/r_def[1]
    #      Overdetermined system if r_def[2] > 1
    r = np.logspace(np.log10(1/np.max(base)) - r_def[0],
                    np.log10(1/np.min(base)) + r_def[1], r_def[2]*n)

    # k :: Get required k-values (matrix of shape (r.size, base.size))
    k = base/r[:, None]

    # Create filter instance
    dlf = DigitalFilter(name.split('.')[0])
    dlf.base = base
    dlf.factor = np.around(np.average(base[1:]/base[:-1]), 15)

    # Loop over transforms
    for f in fI:
        # Calculate lhs and rhs for inversion
        lhs = reim(f.lhs(k))
        rhs = reim(f.rhs(r)*r)

        # Calculate filter values: Solve lhs*J=rhs using linalg.qr.
        # If factoring fails (qr) or if matrix is singular or square (solve) it
        # will raise a LinAlgError. Error is ignored and zeros are returned
        # instead.
        try:
            qq, rr = np.linalg.qr(lhs)
            J = np.linalg.solve(rr, rhs.dot(qq))
        except np.linalg.LinAlgError:
            J = np.zeros((base.size,))

        setattr(dlf, f.name, J)

    return dlf
847403
def _lmder1_freudenstein_roth():
    """"""

    def func(params, vec):
        vec[0] = -13 + params[0] + ((5 - params[1]) * params[1] - 2) * params[1]
        vec[1] = -29 + params[0] + ((1 + params[1]) * params[1] - 14) * params[1]

    def jac(params, jac):
        jac[0] = 1
        jac[1,0] = params[1] * (10 - 3 * params[1]) - 2
        jac[1,1] = params[1] * (2 + 3 * params[1]) - 14

    guess = np.asfarray([0.5, -2])

    _lmder1_driver(2, func, jac, guess,
                   0.200124960962e+02, 0.699887517585e+01,
                   [0.114124844655e+02, -0.896827913732e+00])
    _lmder1_driver(2, func, jac, guess * 10,
                   0.124328339489e+05, 0.699887517449e+01,
                   [0.114130046615e+02, -0.896796038686e+00])
    _lmder1_driver(2, func, jac, guess * 100,
                   0.11426454595762e+08, 0.699887517243e+01,
                   [0.114127817858e+02, -0.896805107492e+00])
1296908
def filter(self, s, method='exact', order=None):
        
        if self._modulation_first:
            return super(Modulation, self).filter(s, method='exact')
        else:
            # The dot product with each modulated kernel is equivalent to the
            # GFT, as for the localization and the IGFT.
            y = np.empty((self.G.n_vertices, self.G.n_vertices))
            for i in range(self.G.n_vertices):
                x = s * self._kernels.localize(i)
                y[i] = np.sqrt(self.G.n_vertices) * self.G.gft(x)
            return y
1354018
def _jmomentsurfaceIntegrand(vz,vR,vT,R,z,df,sigmaR1,gamma,sigmaz1,n,m,o): #pragma: no cover because this is too slow; a warning is shown
    """"""
    return df(R,vR*sigmaR1,vT*sigmaR1*gamma,z,vz*sigmaz1,use_physical=False,
              func= (lambda x,y,z: x**n*y**m*z**o))