Skip to content

Commit

Permalink
Fix SAC file waveform lag issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bclswl0827 committed Dec 16, 2023
1 parent 39826cf commit 0b9335e
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 35 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Starting from v2.2.5, all notable changes to this project will be documented in this file.

## v2.2.6 (2023-12-16)

- Fixed SAC file waveform lag issue caused by sample rate calculation

## v2.2.5 (2023-12-12)

- Migrating to [anyshake/observer](https://github.com/anyshake/observer)
Expand Down
90 changes: 78 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,36 @@
[![Latest Release](https://img.shields.io/github/release/anyshake/observer.svg?style=flat-square)](https://github.com/anyshake/observer/releases/latest)
[![Go Report Card](https://goreportcard.com/badge/github.com/anyshake/observer?style=flat-square)](https://goreportcard.com/report/github.com/anyshake/observer)

AnyShake Observer use serial port to read & parse seismic data from [AnyShake Explorer](https://github.com/anyshake/explorer), also provides a web-based easy-to-use UI for monitoring and exporting seismic data (Support SAC & MiniSEED format)
## Overview

AnyShake Observer is written in Go, which means it can easily port to a variety of OS and CPU architectures, even embedded Linux devices, AnyShake Observer also supports PostgreSQL, MariaDB (MySQL), SQLite, and SQL Server as seismic data archiving engines.
AnyShake Observer is an open-source, cross-platform software that can be used to monitor, archive, and export seismic data from [AnyShake Explorer](https://github.com/anyshake/explorer) via serial port. It provides a user-friendly web-based interface to visualize and analyze the seismic data. For more professional users, it supports exporting the data to SAC or MiniSEED format for further analysis.

## Features

TO BE DONE

## Install
This software is written in Go and TypeScript, which means it can easily port to a variety of OS and CPU architectures, even embedded Linux devices, AnyShake Observer also supports PostgreSQL, MariaDB (MySQL), SQLite, and SQL Server as seismic data archiving engines. We're currently trying to integrate the SEEDLink server on this software (Using pure Go implementation).

TO BE DONE
As of the release of the software documentation, AnyShake has successfully captured more than 40 earthquake events, the furthest captured earthquake event is [M 7.1 - 180 km NNE of Gili Air, Indonesia](https://earthquake.usgs.gov/earthquakes/eventpage/us7000krjx/executive), approximately 4,210 km, by the station located in Chongqing, China.

## Configuration
## Documentation

TO BE DONE
Please visit [anyshake.org/docs/intro](https://anyshake.org/docs/intro) for quick start guide and more information.

## Contributing
## Features

TO BE DONE
- User-friendly web-based interface
- Mobile / Tablet friendly interface
- Query seismic waveform by time range
- Query seismic waveform by known event
- Link to share the seismic waveform
- Real-time seismic waveform display
- Swagger generated API documentation
- Support multiple database engines
- Support multiple languages, detected by browser
- Multiple seismic intensity standards, default to JMA
- Cross-platform, runs on Linux, Windows, macOS
- Ability to export data to SAC or MiniSEED format
- AnyShake Explorer data checksum verification
- Auto reset AnyShake Explorer on error
- Flexible channel packet read length
- Variable serial port baud rate

## Preview

Expand All @@ -35,6 +46,61 @@ TO BE DONE
![Preview - Export](https://raw.githubusercontent.com/anyshake/logotype/master/preview_export.gif)
![Preview - Settings](https://raw.githubusercontent.com/anyshake/logotype/master/preview_setting.gif)

## Credits

AnyShake Observer is designed and developed by [@bclswl0827](https://github.com/bclswl0827), test work is done by [@TenkyuChimata](https://github.com/TenkyuChimata).

Thanks to the following tools and libraries, AnyShake Observer is made possible!

### Backend

- [github.com/PuerkitoBio/goquery](https://github.com/PuerkitoBio/goquery)
- [github.com/bclswl0827/go-serial](https://github.com/bclswl0827/go-serial)
- [github.com/bclswl0827/sacio](https://github.com/bclswl0827/sacio)
- [github.com/beevik/ntp](https://github.com/beevik/ntp)
- [github.com/common-nighthawk/go-figure](https://github.com/common-nighthawk/go-figure)
- [github.com/gin-contrib/gzip](https://github.com/gin-contrib/gzip)
- [github.com/gin-gonic/gin](https://github.com/gin-gonic/gin)
- [github.com/gorilla/websocket](https://github.com/gorilla/websocket)
- [github.com/juju/ratelimit](https://github.com/juju/ratelimit)
- [github.com/mackerelio/go-osstat](https://github.com/mackerelio/go-osstat)
- [github.com/sbabiv/xml2map](https://github.com/sbabiv/xml2map)
- [github.com/shirou/gopsutil](https://github.com/shirou/gopsutil)
- [github.com/swaggo/files](https://github.com/swaggo/files)
- [github.com/swaggo/swag](https://github.com/swaggo/swag)
- [github.com/wille/osutil](https://github.com/wille/osutil)
- [gorm.io/driver/mysql](https://github.com/go-gorm/mysql)
- [gorm.io/driver/postgres](https://github.com/go-gorm/postgres)
- [gorm.io/driver/sqlite](https://github.com/go-gorm/sqlite)
- [gorm.io/driver/sqlserver](https://github.com/go-gorm/sqlserver)
- [gorm.io/gorm](https://gorm.io/)

### Frontend

- [axios](https://axios-http.com/)
- [date-fns](https://date-fns.org/)
- [highcharts](https://www.highcharts.com/)
- [i18next](https://www.i18next.com/)
- [i18next-browser-languagedetector](https://github.com/i18next/i18next-browser-languageDetector)
- [i18next-http-backend](https://github.com/i18next/i18next-http-backend)
- [js-file-download](https://github.com/kennethjiang/js-file-download)
- [leaflet](https://leafletjs.com/)
- [mui](https://mui.com/)
- [react](https://reactjs.org/)
- [react-dom](https://reactjs.org/)
- [react-hot-toast](https://react-hot-toast.com/)
- [react-i18next](https://react.i18next.com/)
- [react-leaflet](https://react-leaflet.js.org/)
- [react-polling](https://github.com/vivek12345/react-polling)
- [react-redux](https://react-redux.js.org/)
- [react-router-dom](https://reactrouter.com/)
- [react-scripts](https://github.com/facebook/create-react-app/tree/main/packages/react-scripts)
- [redux](https://react-redux.js.org/)
- [redux-persist](https://github.com/rt2zz/redux-persist)
- [seisplotjs](https://github.com/crotwell/seisplotjs)
- [tailwindcss](https://tailwindcss.com/)
- [typescript](https://www.typescriptlang.org/)

## License

[The MIT License (MIT)](https://raw.githubusercontent.com/anyshake/observer/master/LICENSE)
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.2.5p
v2.2.6p
2 changes: 1 addition & 1 deletion app/history/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (h *History) RegisterModule(rg *gin.RouterGroup, options *app.ServerOptions

switch binding.Format {
case "json":
response.Message(c, "The specified waveform data was successfully filtered", data)
response.Message(c, "The waveform data was successfully filtered", data)
return
case "sac":
fileName, dataBytes, err := getSACBytes(data, binding.Channel, options)
Expand Down
23 changes: 13 additions & 10 deletions app/history/sample.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,31 @@ import (

func getSampleRate(data []publisher.Geophone, channel string) (int, error) {
var (
length = 0
lastTime = time.UnixMilli(data[0].TS)
sampleRateSum float64
lastTime = time.UnixMilli(data[0].TS)
)

for _, v := range data {
currentTime := time.UnixMilli(v.TS)
if duration.Difference(currentTime, lastTime) > THRESHOLD {
for i := 1; i < len(data); i++ {
var (
currentTime = time.UnixMilli(data[i].TS)
timeDiff = duration.Difference(currentTime, lastTime)
)
if timeDiff > THRESHOLD {
err := fmt.Errorf("uneven gaps between the data")
return 0, err
}

switch channel {
case "EHZ":
length += len(v.EHZ)
sampleRateSum += float64(len(data[i].EHZ)) / timeDiff.Seconds()
case "EHE":
length += len(v.EHE)
sampleRateSum += float64(len(data[i].EHE)) / timeDiff.Seconds()
case "EHN":
length += len(v.EHN)
sampleRateSum += float64(len(data[i].EHN)) / timeDiff.Seconds()
}

lastTime = time.UnixMilli(v.TS)
lastTime = currentTime
}

return length / len(data), nil
return int(sampleRateSum) / len(data), nil
}
4 changes: 2 additions & 2 deletions build/assets/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}
},
"adc_settings": {
"resolution": 32,
"resolution": 27,
"fullscale": 5.0
},
"serial_settings": {
Expand All @@ -39,7 +39,7 @@
"interval": 5
},
"archiver_settings": {
"enable": false,
"enable": true,
"engine": "postgresql",
"host": "127.0.0.1",
"port": 5432,
Expand Down
4 changes: 2 additions & 2 deletions frontend/dist/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"files": {
"main.css": "/static/css/main.3d547ccc.css",
"main.js": "/static/js/main.a6508a5a.js",
"main.js": "/static/js/main.e17ea804.js",
"static/css/290.525e2941.chunk.css": "/static/css/290.525e2941.chunk.css",
"static/js/290.2f73e962.chunk.js": "/static/js/290.2f73e962.chunk.js",
"static/js/78.90c012c7.chunk.js": "/static/js/78.90c012c7.chunk.js",
Expand Down Expand Up @@ -47,6 +47,6 @@
},
"entrypoints": [
"static/css/main.3d547ccc.css",
"static/js/main.a6508a5a.js"
"static/js/main.e17ea804.js"
]
}
2 changes: 1 addition & 1 deletion frontend/dist/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/><link rel="icon" href="/favicon.ico"/><link rel="manifest" href="/manifest.json"/><script defer="defer" src="/static/js/main.a6508a5a.js"></script><link href="/static/css/main.3d547ccc.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
<!doctype html><html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/><link rel="icon" href="/favicon.ico"/><link rel="manifest" href="/manifest.json"/><script defer="defer" src="/static/js/main.e17ea804.js"></script><link href="/static/css/main.3d547ccc.css" rel="stylesheet"></head><body><div id="root"></div></body></html>

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions frontend/src/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
REACT_APP_VERSION=v2.2.5p
REACT_APP_RELEASE=44af8a25-20231212145520
REACT_APP_VERSION=v2.2.6p
REACT_APP_RELEASE=39826cfe-20231216182920
1 change: 0 additions & 1 deletion frontend/src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion frontend/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@types/leaflet": "^1.9.6",
"@types/react-transition-group": "^4.4.7",
"@types/redux-persist": "^4.3.1",
"tailwindcss": "^3.3.3"
}
Expand Down

0 comments on commit 0b9335e

Please sign in to comment.