@@ -3,7 +3,7 @@ import { mkdir, readFile, writeFile } from 'fs/promises'
33import { createWriteStream } from 'fs'
44import { join } from 'path'
55import { findStation } from 'neaps'
6- import db from '@neaps/tide-database'
6+ import { stations as db } from '@neaps/tide-database'
77import createFetch from 'make-fetch-happen'
88
99process . env . TZ = 'UTC'
@@ -16,7 +16,7 @@ const fetch = createFetch.defaults({
1616} )
1717
1818const stations = db
19- . filter ( ( station ) => station . source . source_url . includes ( 'noaa.gov' ) )
19+ . filter ( ( station ) => station . source . url . includes ( 'noaa.gov' ) )
2020 . map ( ( station ) => station . source . id )
2121
2222// Create a directory for test cache
@@ -36,6 +36,7 @@ interface Stat {
3636 p95_abs_dt_min : number
3737 mean_dt_min : number
3838 mae_dh_m : number
39+ mean_dh_m : number
3940 rmse_dh_m : number
4041 bias_dh_m : number
4142 p95_abs_dh_m : number
@@ -163,6 +164,7 @@ for (const id of stations) {
163164 // Height metrics (meters) at matched events
164165 const absDh = dhMeters . map ( ( v ) => Math . abs ( v ) )
165166 const mae_dh_m = mean ( absDh )
167+ const mean_dh_m = mean ( dhMeters )
166168 const rmse_dh_m = Math . sqrt (
167169 dhMeters . reduce ( ( a , b ) => a + b * b , 0 ) / dhMeters . length
168170 )
@@ -183,6 +185,7 @@ for (const id of stations) {
183185 p95_abs_dt_min,
184186 mean_dt_min,
185187 mae_dh_m,
188+ mean_dh_m,
186189 rmse_dh_m,
187190 bias_dh_m,
188191 p95_abs_dh_m
@@ -193,7 +196,7 @@ for (const id of stations) {
193196// Write stats to file for later analysis
194197const summary = createWriteStream ( join ( __dirname , 'noaa.csv' ) )
195198summary . write (
196- 'station,type,start_utc,end_utc,events_noaa,events_model,matched,missed,extra,med_abs_dt_min,p95_abs_dt_min,mean_dt_min,mae_dh_m,rmse_dh_m,bias_dh_m,p95_abs_dh_m\n'
199+ 'station,type,start_utc,end_utc,events_noaa,events_model,matched,missed,extra,med_abs_dt_min,p95_abs_dt_min,mean_dt_min,mae_dh_m,mean_dh_m, rmse_dh_m,bias_dh_m,p95_abs_dh_m\n'
197200)
198201
199202stats . forEach ( ( s ) => {
@@ -212,6 +215,7 @@ stats.forEach((s) => {
212215 s . p95_abs_dt_min . toFixed ( 2 ) ,
213216 s . mean_dt_min . toFixed ( 2 ) ,
214217 s . mae_dh_m . toFixed ( 4 ) ,
218+ s . mean_dh_m . toFixed ( 4 ) ,
215219 s . rmse_dh_m . toFixed ( 4 ) ,
216220 s . bias_dh_m . toFixed ( 4 ) ,
217221 s . p95_abs_dh_m . toFixed ( 4 )
0 commit comments