# Julia suitable language for operational weather analysis?

**URL:** https://discourse.julialang.org/t/julia-suitable-language-for-operational-weather-analysis/66401
**Category:** New to Julia
**Tags:** question
**Created:** [August 14, 2021, 7:50pm UTC](https://discourse.julialang.org/t/julia-suitable-language-for-operational-weather-analysis/66401 "2021-08-14T19:50:44Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![Dieter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dieter/32/29860_2.png) [@Dieter](https://discourse.julialang.org/u/Dieter)
#### Post date: [August 14, 2021, 7:50pm UTC](https://discourse.julialang.org/t/julia-suitable-language-for-operational-weather-analysis/66401/1 "2021-08-14T19:50:44Z")

</div>

Hello community,

I have programmed Matlab from 1997 up to now and now I think about changing to Julia (skipping Python). Working at a private weather company in Austria, I have created a lot of Matlab programmes which are analyzing the weather on an operational basis scheduled by crontabs on an 10 minute up to an hourly basis.

I have heard that Julia is fast in the REPL mode after a first run, but it seems, that Julia code is very slow when executed from the command line (julia …jl) because every new call is equivalent to the first call in REPL. But if Julia code is called by crontab/cronjob, the fast usage from REPL mode is not possible.

Is there generally a way to either call Julia code in REPL every 10 minutes/ 1 hour or to call Julia programmes from command line (with cronjob) in that fast way Julia is known for?

If yes, a change from Matlab to Julia would be a good way, but if Julia is only fast when used in REPL mode, it would unfortunately not be.

Best regards,  
Dieter

---

<div class="post-metadata">

### Author: ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)
#### Post date: [August 14, 2021, 7:57pm UTC](https://discourse.julialang.org/t/julia-suitable-language-for-operational-weather-analysis/66401/2 "2021-08-14T19:57:33Z")

</div>

You may want to look at  
[https://github.com/dmolina/DaemonMode.jl](https://github.com/dmolina/DaemonMode.jl)

The “slow” at the first call is a bit overemphasized. It is just, that at the first call the code is compiled and this compilation time is sometimes annoying long and of course sums up if you start again often, e.g. during development (there is [https://github.com/timholy/Revise.jl](https://github.com/timholy/Revise.jl) for the development issue).  
But not in any cases this compilation is a problem. E.g. if the process itself just runs long enough the compilation at the beginning just doesn’t matter.

So, I would encourage you just to try it out and if you run into such issues there are already some solutions or workarounds.

By the way, the issue has a name, it’s TTFP (time to first plot). You may search for it to find more discussions.

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [August 14, 2021, 8:27pm UTC](https://discourse.julialang.org/t/julia-suitable-language-for-operational-weather-analysis/66401/3 "2021-08-14T20:27:50Z")

</div>

> [@Dieter](#):
>
> an 10 minute up to an hourly basis.

Edit: I misunderstood, but the message is still valid, depending on how long the task itself takes.

The JIT just means that the first time a function is called, it will take a bit longer due to compilation. Thus making running `julia blah.jl` every few seconds not worth it[1].

Just like your MATLAB probably always run in the background (you don’t cold start MATLAB every time you run the analysis right?), you can use DaemonMode mentioned above.

[1]: it also means this is not a good way to develop a script, check out [Home · Revise.jl](https://timholy.github.io/Revise.jl/stable/#Usage-example-1)

---

<div class="post-metadata">

### Author: ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)
#### Post date: [August 14, 2021, 8:30pm UTC](https://discourse.julialang.org/t/julia-suitable-language-for-operational-weather-analysis/66401/4 "2021-08-14T20:30:21Z")

</div>

> [@jling](#):
>
> But if you’re running for O(10 minutes)~O(hour), it’s definitely an negligible overhead almost always.

I think he meant he’s running the script every 10 minutes or every hour, not that it takes that long to run.

For “production” usage, I think PackageCompiler is pretty good to bring down startup latency, possibly bundled up in a docker container if you are using docker already.

---

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [August 14, 2021, 8:37pm UTC](https://discourse.julialang.org/t/julia-suitable-language-for-operational-weather-analysis/66401/5 "2021-08-14T20:37:54Z")

</div>

How long does your program run for? e.g. 1ms, 1s, 1min, 1hr?

---

<div class="post-metadata">

### Author: ![Eben60](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eben60/32/13475_2.png) [@Eben60](https://discourse.julialang.org/u/Eben60)
#### Post date: [August 14, 2021, 9:27pm UTC](https://discourse.julialang.org/t/julia-suitable-language-for-operational-weather-analysis/66401/6 "2021-08-14T21:27:01Z")

</div>

There are ways to reduce compilation time or to avoid compilation each time you are running your program - DaemonMode.jl is one of them. Still, if you aim is just to run your script every 10 min and the total compile+run time ist less than that - than just start it from cron job and that’s it.

You are going to spend some time learning Julia, and getting around the TTFP issue shouldn’t probably be your fist priority.

---

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [August 14, 2021, 9:44pm UTC](https://discourse.julialang.org/t/julia-suitable-language-for-operational-weather-analysis/66401/7 "2021-08-14T21:44:40Z")

</div>

Just adding that, for example, a script I have that loads large packages as DifferentialEquations, Plots, Catalyst, runs the simulations and produce plots takes 50s overall. And this is the worst case I have experienced up to now. It may we’ll be that startup and running your script doesn’t take more than a few seconds. Thus, this should be a primary concern if you needed to run the script repeatedly in the sub-second time scale.

---

<div class="post-metadata">

### Author: ![Dieter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dieter/32/29860_2.png) [@Dieter](https://discourse.julialang.org/u/Dieter)
#### Post date: [August 14, 2021, 10:08pm UTC](https://discourse.julialang.org/t/julia-suitable-language-for-operational-weather-analysis/66401/8 "2021-08-14T22:08:37Z")

</div>

In Matlab the compiled stand alone script takes ~10 minutes. 30% of the time is spend by creating large sparse matrices and solving the corresponding system of linear equations.

---

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [August 14, 2021, 10:15pm UTC](https://discourse.julialang.org/t/julia-suitable-language-for-operational-weather-analysis/66401/9 "2021-08-14T22:15:54Z")

</div>

Is it okay for your application if the Julia package loading adds an extra 5-90 seconds?

---

<div class="post-metadata">

### Author: ![Dieter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dieter/32/29860_2.png) [@Dieter](https://discourse.julialang.org/u/Dieter)
#### Post date: [August 14, 2021, 10:26pm UTC](https://discourse.julialang.org/t/julia-suitable-language-for-operational-weather-analysis/66401/10 "2021-08-14T22:26:40Z")

</div>

Thanks for your reply and hints.  
After creating Matlab programs for operational purpose they are compiled to stand alone executables and called by cronjobs (without needing Matlab in background).  
If running “julia blah.jl” is only some percent slower as in REPL mode (second call) there will not be a problem.

---

<div class="post-metadata">

### Author: ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)
#### Post date: [August 14, 2021, 10:37pm UTC](https://discourse.julialang.org/t/julia-suitable-language-for-operational-weather-analysis/66401/11 "2021-08-14T22:37:35Z")

</div>

The other option is to instead of running cron jobs, just have Julia run continuously and it just starts up a new fit every 10 mins. (not talking about DaemonMode, just write your script so that it looks like)

```julia
while true
   #... do some stuff
   sleeptime = nexttime - time()
   sleep(sleeptime)
end

```

---

<div class="post-metadata">

### Author: ![Dieter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dieter/32/29860_2.png) [@Dieter](https://discourse.julialang.org/u/Dieter)
#### Post date: [August 14, 2021, 10:40pm UTC](https://discourse.julialang.org/t/julia-suitable-language-for-operational-weather-analysis/66401/12 "2021-08-14T22:40:11Z")

</div>

Good idea, if there is no temporal overlap (if run takes e.g. 12 minutes and the function should be called every 10 minutes)

---

<div class="post-metadata">

### Author: ![Dieter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dieter/32/29860_2.png) [@Dieter](https://discourse.julialang.org/u/Dieter)
#### Post date: [August 14, 2021, 10:43pm UTC](https://discourse.julialang.org/t/julia-suitable-language-for-operational-weather-analysis/66401/13 "2021-08-14T22:43:16Z")

</div>

If the time saving potential compared to Matlab is much larger than these 5-90 seconds I suppose yes

---

<div class="post-metadata">

### Author: ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)
#### Post date: [August 14, 2021, 11:27pm UTC](https://discourse.julialang.org/t/julia-suitable-language-for-operational-weather-analysis/66401/14 "2021-08-14T23:27:44Z")

</div>

> [@Dieter](#):
>
> there is no temporal overlap

```julia
while true
   Threads.@spawn domodel()
   nexttime = calcnexttime()
   sleep(nexttime - time())
end

```

On Julia 1.7+ spawning a thread/task will make sure your model spawns off right away, and will run on an available thread. If you have many cores, you can be running overlapping runs provided they don’t fall too far behind (like if you need to run light calculations every 10 mins and then a detailed calculation every hour)

---

<div class="post-metadata">

### Author: ![colintbowers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/colintbowers/32/8033_2.png) [@colintbowers](https://discourse.julialang.org/u/colintbowers)
#### Post date: [August 15, 2021, 11:17pm UTC](https://discourse.julialang.org/t/julia-suitable-language-for-operational-weather-analysis/66401/15 "2021-08-15T23:17:50Z")

</div>

Just thought I’d add that I run a live trading program from Julia doing exactly this and have never had a problem, and that program has to hit certain time points exactly for specific bits of code, like opening and closing auctions, etc. So it is definitely a feasible solution.

---

<div class="post-metadata">

### Author: ![0xDBFB7](https://avatars.discourse-cdn.com/v4/letter/0/53a042/32.png) [@0xDBFB7](https://discourse.julialang.org/u/0xDBFB7)
#### Post date: [August 18, 2021, 7:15pm UTC](https://discourse.julialang.org/t/julia-suitable-language-for-operational-weather-analysis/66401/16 "2021-08-18T19:15:17Z")

</div>

I really want to emphasize how superb PackageCompiler is now. I, too, am new to julia, and I thought the ~20s startup time was going to be a dealbreaker, but creating a custom sysimage with all the packages I use has reduced it to ~1s without pre-warming the REPL.

```julia
create_sysimage([:Plots,:ModelingToolkit,:OrdinaryDiffEq];
        precompile_execution_file="my_fancy_cronjob.jl", replace_default=true)

```

This case, where specific code is being run repeatedly, would seem to be an ideal use-case for a PC sysimage.

The cost is that making modifications to the code may be slower, but if you’re already compiling matlab code then there shouldn’t be a significant loss here.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [August 18, 2021, 8:11pm UTC](https://discourse.julialang.org/t/julia-suitable-language-for-operational-weather-analysis/66401/17 "2021-08-18T20:11:56Z")

</div>

And see [https://github.com/SciML/DifferentialEquations.jl/issues/786](https://github.com/SciML/DifferentialEquations.jl/issues/786) . We’re just starting to take compile times very seriously. The OrdinaryDiffEq ones have dropped dramatically. ModelingToolkit needs a pass. And also, we could probably use another pass at Plots.jl.
