Skip to content

Commit

Permalink
Calculate arrival of P/S waves separately
Browse files Browse the repository at this point in the history
  • Loading branch information
bclswl0827 committed Oct 24, 2023
1 parent 4e1082e commit e530804
Show file tree
Hide file tree
Showing 38 changed files with 240 additions and 118 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.1.21p
v2.1.22p
2 changes: 1 addition & 1 deletion app/trace/ceic.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (c *CEIC) Format(latitude, longitude float64, data map[string]any) ([]Event
Magnitude: string2Float(v["M"].(string)),
}
l.Distance = getDistance(latitude, l.Latitude, longitude, l.Longitude)
l.Estimated = getEstimation(l.Distance)
l.Estimation = getEstimation(l.Distance)

list = append(list, l)
}
Expand Down
2 changes: 1 addition & 1 deletion app/trace/cwa.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (c *CWA) Format(latitude, longitude float64, data map[string]any) ([]Event,
Magnitude: v.(map[string]any)["magnitude"].(float64),
}
l.Distance = getDistance(latitude, l.Latitude, longitude, l.Longitude)
l.Estimated = getEstimation(l.Distance)
l.Estimation = getEstimation(l.Distance)

list = append(list, l)
}
Expand Down
9 changes: 7 additions & 2 deletions app/trace/estimate.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package trace

func getEstimation(distance float64) float64 {
return distance / 5.0
func getEstimation(distance float64) estimation {
pWave := distance / 6.0
sWave := distance / 3.5
return estimation{
P: pWave,
S: sWave,
}
}
2 changes: 1 addition & 1 deletion app/trace/hko.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (h *HKO) Format(latitude, longitude float64, data map[string]any) ([]Event,
Magnitude: string2Float(v["Mag"].(string)),
}
l.Distance = getDistance(latitude, l.Latitude, longitude, l.Longitude)
l.Estimated = getEstimation(l.Distance)
l.Estimation = getEstimation(l.Distance)

list = append(list, l)
}
Expand Down
2 changes: 1 addition & 1 deletion app/trace/jma.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (j *JMA) Format(latitude, longitude float64, data map[string]any) ([]Event,
Magnitude: string2Float(v["mag"].(string)),
}
l.Distance = getDistance(latitude, l.Latitude, longitude, l.Longitude)
l.Estimated = getEstimation(l.Distance)
l.Estimation = getEstimation(l.Distance)

list = append(list, l)
}
Expand Down
2 changes: 1 addition & 1 deletion app/trace/scea-b.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (s *SCEA_B) Format(latitude, longitude float64, data map[string]any) ([]Eve
Timestamp: time.UnixMilli(int64(v.(map[string]any)["shockTime"].(float64))).UnixMilli(),
}
l.Distance = getDistance(latitude, l.Latitude, longitude, l.Longitude)
l.Estimated = getEstimation(l.Distance)
l.Estimation = getEstimation(l.Distance)

list = append(list, l)
}
Expand Down
2 changes: 1 addition & 1 deletion app/trace/scea-e.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (s *SCEA_E) Format(latitude, longitude float64, data map[string]any) ([]Eve
Timestamp: time.UnixMilli(int64(v.(map[string]any)["shockTime"].(float64))).UnixMilli(),
}
l.Distance = getDistance(latitude, l.Latitude, longitude, l.Longitude)
l.Estimated = getEstimation(l.Distance)
l.Estimation = getEstimation(l.Distance)

list = append(list, l)
}
Expand Down
25 changes: 15 additions & 10 deletions app/trace/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@ type Binding struct {
Source string `form:"source" json:"source" xml:"source" binding:"required"`
}

type estimation struct {
P float64 `json:"p"`
S float64 `json:"s"`
}

type Event struct {
Verfied bool `json:"verfied"`
Timestamp int64 `json:"timestamp"`
Event string `json:"event"`
Region string `json:"region"`
Depth float64 `json:"depth"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Distance float64 `json:"distance"`
Magnitude float64 `json:"magnitude"`
Estimated float64 `json:"estimated"`
Verfied bool `json:"verfied"`
Timestamp int64 `json:"timestamp"`
Event string `json:"event"`
Region string `json:"region"`
Depth float64 `json:"depth"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Distance float64 `json:"distance"`
Magnitude float64 `json:"magnitude"`
Estimation estimation `json:"estimation"`
}

type DataSource interface {
Expand Down
2 changes: 1 addition & 1 deletion app/trace/usgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (u *USGS) Format(latitude, longitude float64, data map[string]any) ([]Event
Magnitude: properties.(map[string]any)["mag"].(float64),
}
l.Distance = getDistance(latitude, l.Latitude, longitude, l.Longitude)
l.Estimated = getEstimation(l.Distance)
l.Estimation = getEstimation(l.Distance)

list = append(list, l)
}
Expand Down
8 changes: 4 additions & 4 deletions build/assets/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"station_settings": {
"uuid": "a373e39c-8e15-44ae-a1ad-6fb622bc49e6",
"name": "Test Station",
"latitude": 1.0,
"longitude": 1.0,
"latitude": 39.9,
"longitude": 116.3,
"altitude": 0
},
"geophone_settings": {
Expand Down Expand Up @@ -32,8 +32,8 @@
},
"serial_settings": {
"packet": 4,
"baud": 19200,
"device": "/dev/ttyUSB0"
"baud": 115200,
"device": "/dev/rfcomm0"
},
"ntpclient_settings": {
"host": "0.pool.ntp.org",
Expand Down
11 changes: 11 additions & 0 deletions config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ type miniseed struct {
LifeCycle int `json:"lifecycle"`
}

type seedlink struct {
Enable bool `json:"enable"`
Host string `json:"host"`
Port int `json:"port"`
Station string `json:"station"`
Network string `json:"network"`
Buffer string `json:"buffer"`
Size int `json:"size"`
}

type Conf struct {
Station station `json:"station_settings"`
Serial serial `json:"serial_settings"`
Expand All @@ -72,6 +82,7 @@ type Conf struct {
Archiver archiver `json:"archiver_settings"`
Server server `json:"server_settings"`
MiniSEED miniseed `json:"miniseed_settings"`
SeedLink seedlink `json:"seedlink_settings"`
}

type Args struct {
Expand Down
6 changes: 3 additions & 3 deletions feature/miniseed/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (
"github.com/fatih/color"
)

func (g *MiniSEED) OnStart(options *feature.FeatureOptions, v ...any) {
func (m *MiniSEED) OnStart(options *feature.FeatureOptions, v ...any) {
logger.Print(MODULE, text.Concat(v...), color.FgMagenta, false)
}

func (g *MiniSEED) OnStop(options *feature.FeatureOptions, v ...any) {
func (m *MiniSEED) OnStop(options *feature.FeatureOptions, v ...any) {
logger.Print(MODULE, text.Concat(v...), color.FgBlue, false)
}

func (a *MiniSEED) OnReady(options *feature.FeatureOptions, v ...any) {
func (m *MiniSEED) OnReady(options *feature.FeatureOptions, v ...any) {
logger.Print(MODULE, "1 record has been written", color.FgGreen, false)
}

Expand Down
6 changes: 3 additions & 3 deletions feature/ntpclient/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (
"github.com/fatih/color"
)

func (g *NTPClient) OnStart(options *feature.FeatureOptions, v ...any) {
func (n *NTPClient) OnStart(options *feature.FeatureOptions, v ...any) {
logger.Print(MODULE, text.Concat(v...), color.FgMagenta, false)
}

func (g *NTPClient) OnStop(options *feature.FeatureOptions, v ...any) {
func (n *NTPClient) OnStop(options *feature.FeatureOptions, v ...any) {
logger.Print(MODULE, text.Concat(v...), color.FgBlue, false)
}

func (a *NTPClient) OnReady(options *feature.FeatureOptions, v ...any) {
func (n *NTPClient) OnReady(options *feature.FeatureOptions, v ...any) {
options.Status.System.Offset = v[0].(float64)
options.Status.IsReady = true
logger.Print(MODULE, "time alignment succeed", color.FgGreen, false)
Expand Down
17 changes: 17 additions & 0 deletions feature/seedlink/callbacks.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package seedlink

import (
"github.com/bclswl0827/observer/feature"
)

func (s *SeedLink) OnStart(options *feature.FeatureOptions, v ...any) {
}

func (s *SeedLink) OnStop(options *feature.FeatureOptions, v ...any) {
}

func (s *SeedLink) OnReady(options *feature.FeatureOptions, v ...any) {
}

func (s *SeedLink) OnError(options *feature.FeatureOptions, err error) {
}
14 changes: 14 additions & 0 deletions feature/seedlink/daemon.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package seedlink

import (
"sync"

"github.com/bclswl0827/observer/feature"
)

func (s *SeedLink) Run(options *feature.FeatureOptions, waitGroup *sync.WaitGroup) {
if !options.Config.SeedLink.Enable {
s.OnStop(options, "service is disabled")
return
}
}
9 changes: 9 additions & 0 deletions feature/seedlink/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package seedlink

const MODULE string = "seedlink"

const (
RELEASE string = "SeedLink v3.1 (Observer edition) :: SLPROTO:3.1 :: Constructing Realtime Seismic Network Ambitiously."
)

type SeedLink struct{}
10 changes: 5 additions & 5 deletions frontend/dist/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"files": {
"main.css": "/static/css/main.3d547ccc.css",
"main.js": "/static/js/main.43baa15e.js",
"main.js": "/static/js/main.c4219939.js",
"static/css/278.525e2941.chunk.css": "/static/css/278.525e2941.chunk.css",
"static/js/278.f2bbf51e.chunk.js": "/static/js/278.f2bbf51e.chunk.js",
"static/js/967.89477617.chunk.js": "/static/js/967.89477617.chunk.js",
"static/js/555.a23f4689.chunk.js": "/static/js/555.a23f4689.chunk.js",
"static/js/967.8f28312d.chunk.js": "/static/js/967.8f28312d.chunk.js",
"static/js/555.c29bef82.chunk.js": "/static/js/555.c29bef82.chunk.js",
"static/js/756.f470d0ba.chunk.js": "/static/js/756.f470d0ba.chunk.js",
"static/js/886.2b35e155.chunk.js": "/static/js/886.2b35e155.chunk.js",
"static/js/377.f0e1c66a.chunk.js": "/static/js/377.f0e1c66a.chunk.js",
Expand All @@ -17,7 +17,7 @@
"static/js/979.14e4e415.chunk.js": "/static/js/979.14e4e415.chunk.js",
"static/js/822.ae40dac1.chunk.js": "/static/js/822.ae40dac1.chunk.js",
"static/js/912.2ed8ddb3.chunk.js": "/static/js/912.2ed8ddb3.chunk.js",
"static/js/730.cafd7702.chunk.js": "/static/js/730.cafd7702.chunk.js",
"static/js/730.31759149.chunk.js": "/static/js/730.31759149.chunk.js",
"static/media/gear-solid.svg": "/static/media/gear-solid.bf34f9d52ff44a67baec8a0d4220d3a3.svg",
"static/media/bug-solid.svg": "/static/media/bug-solid.7f781f9ddd35c29f11111e36602dcc87.svg",
"static/media/earth-americas-solid.svg": "/static/media/earth-americas-solid.4105ee3951f1c7ac60331fccafc17c1f.svg",
Expand Down Expand Up @@ -47,6 +47,6 @@
},
"entrypoints": [
"static/css/main.3d547ccc.css",
"static/js/main.43baa15e.js"
"static/js/main.c4219939.js"
]
}
8 changes: 5 additions & 3 deletions frontend/dist/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"modals": {
"choose_event": {
"title": "Select an Earthquake Event",
"template": "[M{{ magnitude }}] {{ event }}\nTime: {{ time }}\nDepth: {{ depth }} km\nEstimated arrival time: {{ estimated }} seconds"
"template": "[M{{ magnitude }}] {{ event }}\nTime: {{ time }}\nDepth: {{ depth }} km\nDistance: {{ distance }} km\nEstimated P-Wave Arrival: {{ p_wave }} sec\nEstimated S-Wave Arrival: {{ s_wave }} sec"
}
},
"selects": {
Expand Down Expand Up @@ -191,7 +191,7 @@
"end_time": "Select End Time"
},
"toasts": {
"time_error": "Please select the correct time range",
"duration_error": "Please select the correct time range",
"metadata_error": "An error occurred while retrieving station information. The functionality is not available.",
"is_exporting_sac": "Exporting SAC format waveforms, please wait...",
"export_sac_success": "SAC format waveform data export successful",
Expand All @@ -206,7 +206,9 @@
"fetch_waveform_success": "Historical waveform data query successful",
"fetch_waveform_error": "Historical waveform data query failed",
"copy_link_success": "Share link has copied to clipboard",
"copy_link_error": "Failed to copy share link to clipboard"
"copy_link_error": "Failed to copy share link to clipboard",
"duration_excceed": "The event duration exceeds the limit. Please manually query according to the arrival time of P/S waves at the station, or change the earthquake event",
"event_select_success": "Event selection successful.\nP-Wave arrival is about {{ p_wave }}\nS-Wave arrival is about {{ s_wave }}"
}
},
"export": {
Expand Down
24 changes: 13 additions & 11 deletions frontend/dist/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"success": {
"label": "{{ station }} 已连接",
"text": "服务器在线时长 {{ uptime }} 秒\n服务器采用架构 {{ arch }}/{{ os }}\nUUID{{ uuid }}"
"text": "服务器在线时长 {{ uptime }} 秒\n服务器采用架构 {{ arch }}/{{ os }}\nUUID {{ uuid }}"
},
"error": {
"label": "连接失败",
Expand All @@ -50,17 +50,17 @@
"areas": {
"cpu": {
"label": "CPU 使用率",
"text": "当前占用率{{ usage }}%"
"text": "当前占用率 {{ usage }}%"
},
"memory": {
"label": "内存使用率",
"text": "当前占用率{{ usage }}%"
"text": "当前占用率 {{ usage }}%"
}
},
"map": {
"area": {
"label": "测站所在位置",
"text": "经度{{ longitude }} °\n纬度{{ latitude }} °\n海拔{{ altitude }} m"
"text": "经度 {{ longitude }} °\n纬度 {{ latitude }} °\n海拔 {{ altitude }} "
}
},
"labels": {
Expand Down Expand Up @@ -108,15 +108,15 @@
"areas": {
"ehz": {
"label": "EHZ 通道波形计数",
"text": "PGA{{ pga }} gal\nPGV{{ pgv }} kine\n震度{{ intensity }}"
"text": "PGA {{ pga }} gal\nPGV {{ pgv }} kine\n震度 {{ intensity }}"
},
"ehe": {
"label": "EHE 通道波形计数",
"text": "PGA{{ pga }} gal\nPGV{{ pgv }} kine\n震度{{ intensity }}"
"text": "PGA {{ pga }} gal\nPGV {{ pgv }} kine\n震度 {{ intensity }}"
},
"ehn": {
"label": "EHN 通道波形计数",
"text": "PGA{{ pga }} gal\nPGV{{ pgv }} kine\n震度{{ intensity }}"
"text": "PGA {{ pga }} gal\nPGV {{ pgv }} kine\n震度 {{ intensity }}"
}
},
"toasts": {
Expand All @@ -128,7 +128,7 @@
"modals": {
"choose_event": {
"title": "选择一个地震事件",
"template": "[M{{ magnitude }}] {{ event }}\n震发时间 {{ time }}\n震源深度 {{ depth }} km\n预计到站 {{ estimated }} 秒"
"template": "[M{{ magnitude }}] {{ event }}\n震发时间 {{ time }}\n震源深度 {{ depth }} 公里\n震央距离 {{ distance }} 公里\nP 波到站 {{ p_wave }} 秒\nS 波到站 {{ s_wave }} 秒"
}
},
"selects": {
Expand Down Expand Up @@ -191,7 +191,7 @@
"end_time": "选择结束时间"
},
"toasts": {
"time_error": "请选择正确的时间范围",
"duration_error": "请选择正确的时间范围",
"metadata_error": "取得测站资讯时发生错误,功能无法使用",
"is_exporting_sac": "正在导出 SAC 格式波形,请稍等...",
"export_sac_success": "SAC 格式波形数据导出成功",
Expand All @@ -206,7 +206,9 @@
"fetch_waveform_success": "历史波形数据查询成功",
"fetch_waveform_error": "历史波形数据查询失败",
"copy_link_success": "分享链接已复制到剪贴板",
"copy_link_error": "分享链接复制失败"
"copy_link_error": "分享链接复制失败",
"duration_excceed": "事件时间跨度超出限制,请根据 P/S 波到达测站时间点手动进行查询,或更换地震事件",
"event_select_success": "事件选择成功\nP 波约在 {{ p_wave }} 到站\nS 波约在 {{ s_wave }} 到站"
}
},
"export": {
Expand Down Expand Up @@ -273,7 +275,7 @@
"duration_set": "历史波形默认查询范围已更改为 {{ duration }} s,页面即将刷新"
},
"contents": {
"select_scale": "当前震度标准{{ scale }}\n震度标准是用来衡量地震震度的标准,不同的标准会导致不同的震度值。",
"select_scale": "当前震度标准 {{ scale }}\n震度标准是用来衡量地震震度的标准,不同的标准会导致不同的震度值。",
"purge_cache": "应用出现问题时,可尝试重置应用偏好。\n执行重置后,浏览器中的偏好将被清理,不会对后端服务器产生影响。",
"waveform_retention": "此项设定实时波形页面的波形会保留的时间,当前 {{ retention }} s。\n以秒为单位,需要大于 0 且小于 1000,否则将会被重置为默认值 180 秒。",
"query_duration": "此项设定历史查询页面自动填写的时间范围,当前 {{ duration }} s。\n以秒为单位,需要大于 0 且小于 3600,否则将会被重置为默认值 300 秒。"
Expand Down
Loading

0 comments on commit e530804

Please sign in to comment.