Python you let me down

Personally, I’m very disappointed about the some Python community people/projects. It’s been years that PEP 3000(the year was 2006) came up, but we need to wait years until Python 3.11(the year was 2022) to get real performance improvements? Why people keep using Python and spending lots of time to add typing which doesn’t have run time check instead of rewriting codes in Go to get huge speed up while enjoying static language’s safe static type? ...

 · 2 min · 236 words · ringsaturn

Thought on Python's DataFrame

Note ...

 · 2 min · 254 words · ringsaturn

History of package tzf

Introduces the evolution of tzf, from the initial implementation in Go, to the later Python extension, and finally to the current Rust implementation with a PyO3 wrapper.

 · 4 min · 1875 words · ringsaturn

How to look up GPS location belongs to which administration?

This is English version of 《彩云天气地理查询优化(2): 行政区划查询》. With some minor changes. In ColorfulClouds App and ColorfulClouds Weather API, we could get current GPS location’s weather alert information, such as “Gale Blue Alert”. Different countries and regions have different rules for issuing alerts. In China, it is issued according to the administrative division level, and the smallest is the county-level administrative division. Therefore, in the implementation, it is necessary to convert the GPS location into the administrative division level information, and then find the relevant alert information. ...

 · 3 min · 1310 words · ringsaturn

Caiyun Weather Geo Query Optimization (1): Meteorological Station Data Query

This article is reproduced from “Caiyun Weather Geo Query Optimization: The nearest N points” Let’s start from a real-world scenario: How to find the K nearest national observation stations to the 768 Creative Industry Park in Haidian District, Beijing? The simplest approach is to iterate over all candidate stations, compute the distance between each station and the 768 park, and then pick the K smallest distances. The code is straightforward. But the problem is it is slow. ...

 · 4 min · 744 words · ringsaturn

Deploy Hugo pages via GitHub Actions

 · 1 min · 124 words · ringsaturn

Geographic aggregation using the map tile index

When dealing with large amounts of scattered data, sometimes we need to provide a read-only query API to visualize on a map. When the amount of data is too large, say millions, it is not appropriate to return it all to the front end for processing on the browser. Some aggregation should be completed within the back-end service to return the aggregated search to the front end. Here’s how to do this with the MongoDB + tile index in Go. ...

 · 2 min · 369 words · ringsaturn

Computing AQI in Go

I write a package named aqi. Install: 1 go install github.com/ringsaturn/aqi For China’s HJ633-2012 standar: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 package main import ( "fmt" "github.com/ringsaturn/aqi" "github.com/ringsaturn/aqi/mep" ) func main() { algo := &mep.Algo{} inputs := []*aqi.Var{ { P: aqi.Pollutant_PM2_5_1H, Value: 16, }, { P: aqi.Pollutant_PM10_1H, Value: 88, }, { P: aqi.Pollutant_CO_1H, Value: 0.2, }, { P: aqi.Pollutant_SO2_1H, Value: 3, }, { P: aqi.Pollutant_NO2_1H, Value: 11, }, { P: aqi.Pollutant_O3_1H, Value: 75, }, } aqi, primaryPollutant, err := algo.Calc(inputs...) if err != nil { panic(err) } levelDesc, err := algo.AQIToDesc(aqi) if err != nil { panic(err) } fmt.Printf("aqi=%v as level=%v with primary pollutant as %v\n", aqi, levelDesc, primaryPollutant) } Output: ...

 · 1 min · 306 words · ringsaturn

Add Mathjax to Hugo

Code copy&paste from Ataias Pereira Reis’s PR adityatelange/hugo-PaperMod#140 with some modifed on toggle option. Creat two files under layouts/partials/. Create math.html: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 <script> MathJax = { tex: { inlineMath: [["$", "$"], ["\\(", "\\)"]], displayMath: [["$$", "$$"]], processEscapes: true, processEnvironments: true, tags: "ams", }, options: { skipHtmlTags: [ "script", "noscript", "style", "textarea", "pre", ], }, startup: { ready: () => { MathJax.startup.defaultReady(); // Fix <code> tags after MathJax finishes running const all = MathJax.typesetPromise(); all.then(() => { document.querySelectorAll(".MathJax").forEach( (el) => { el.parentNode.className += " has-jax"; }, ); }); }, }, }; </script> <script id="MathJax-script" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js" ></script> Create extend_head.html: ...

 ·  · 1 min · 181 words · ringsaturn