Skip to content

Commit 2988ec5

Browse files
authored
Merge pull request #3598 from gulfofmaine/current-obs-only
Only show observations by default on current conditions
2 parents 3cfab47 + b631b93 commit 2988ec5

3 files changed

Lines changed: 117 additions & 1 deletion

File tree

src/Features/ERDDAP/utils/currentConditionsTimeseries.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,11 @@ describe("currentConditionsTimeseries", () => {
3939

4040
expect(timeSeriesVariables).toStrictEqual(["barometric_pressure", "visibility"])
4141
})
42+
43+
it("Should not show a forecasted time series", () => {
44+
const { timeSeries } = currentConditionsTimeseries(platform, laterThan)
45+
const timeSeriesVariables = timeSeries.map((ts) => ts.variable)
46+
47+
expect(timeSeriesVariables).toStrictEqual(["barometric_pressure", "visibility"])
48+
})
4249
})

src/Features/ERDDAP/utils/currentConditionsTimeseries.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import { conditions } from "./conditions"
22
import { PlatformFeature, PlatformTimeSeries } from "../types"
33
import { pickWindTimeSeries } from "./wind"
44

5+
/// Filter to current observation time series for specified data types
56
export function filterTimeSeries(timeSeries: PlatformTimeSeries[], dataTypes: string[], laterThan: Date) {
67
let filterTimeSeries: PlatformTimeSeries[] = []
78

89
dataTypes.forEach((dataType) => {
910
const matchStandard = timeSeries.filter((reading) => dataType === reading.data_type.standard_name) // match any that are the current data type
10-
const matchTime = matchStandard.filter((reading) => (reading.time ? laterThan < new Date(reading.time) : false)) // that have data in the last day
11+
const matchObservation = matchStandard.filter((reading) => reading.type === "Observation") // that are observations
12+
const matchTime = matchObservation.filter((reading) => (reading.time ? laterThan < new Date(reading.time) : false)) // that have data in the last day
1113
const matchDepth = matchTime.filter((reading) => (reading.depth ? reading.depth < 2 : true)) // are near-surface
1214
matchDepth.forEach((ts) => filterTimeSeries.push(ts))
1315
})

src/stories/platform.ts

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const platform_base: PlatformFeature = {
3333
loadStartTimes: [],
3434
loading: false,
3535
highlighted: "No",
36+
type: "Observation",
3637
readings: [
3738
{
3839
reading: 4.55,
@@ -151,6 +152,7 @@ const platform_base: PlatformFeature = {
151152
loading: false,
152153
readings: [],
153154
highlighted: "No",
155+
type: "Observation",
154156
},
155157
{
156158
value: 33.9589462280273,
@@ -175,6 +177,7 @@ const platform_base: PlatformFeature = {
175177
loading: false,
176178
readings: [],
177179
highlighted: "No",
180+
type: "Observation",
178181
},
179182
{
180183
value: 9.89000034332275,
@@ -199,6 +202,7 @@ const platform_base: PlatformFeature = {
199202
loading: false,
200203
readings: [],
201204
highlighted: "No",
205+
type: "Observation",
202206
},
203207
{
204208
value: 25.5368404388428,
@@ -223,6 +227,7 @@ const platform_base: PlatformFeature = {
223227
loading: false,
224228
readings: [],
225229
highlighted: "No",
230+
type: "Observation",
226231
},
227232
{
228233
value: 32.5026893615723,
@@ -247,6 +252,7 @@ const platform_base: PlatformFeature = {
247252
loading: false,
248253
readings: [],
249254
highlighted: "No",
255+
type: "Observation",
250256
},
251257
{
252258
value: 6.34700012207031,
@@ -271,6 +277,7 @@ const platform_base: PlatformFeature = {
271277
loading: false,
272278
readings: [],
273279
highlighted: "No",
280+
type: "Observation",
274281
},
275282
{
276283
value: 25.2565860748291,
@@ -295,6 +302,7 @@ const platform_base: PlatformFeature = {
295302
loading: false,
296303
readings: [],
297304
highlighted: "No",
305+
type: "Observation",
298306
},
299307
{
300308
value: 31.966287612915,
@@ -319,6 +327,7 @@ const platform_base: PlatformFeature = {
319327
loading: false,
320328
readings: [],
321329
highlighted: "No",
330+
type: "Observation",
322331
},
323332
{
324333
value: 30.9360008239746,
@@ -343,6 +352,7 @@ const platform_base: PlatformFeature = {
343352
loading: false,
344353
readings: [],
345354
highlighted: "No",
355+
type: "Observation",
346356
},
347357
{
348358
value: 32.4659996032715,
@@ -367,6 +377,7 @@ const platform_base: PlatformFeature = {
367377
loading: false,
368378
readings: [],
369379
highlighted: "No",
380+
type: "Observation",
370381
},
371382
{
372383
value: 37.0120010375977,
@@ -391,6 +402,7 @@ const platform_base: PlatformFeature = {
391402
loading: false,
392403
readings: [],
393404
highlighted: "No",
405+
type: "Observation",
394406
},
395407
{
396408
value: 290.853210449219,
@@ -414,6 +426,7 @@ const platform_base: PlatformFeature = {
414426
loading: false,
415427
readings: [],
416428
highlighted: "No",
429+
type: "Observation",
417430
},
418431
{
419432
value: 1.39300000667572,
@@ -436,6 +449,7 @@ const platform_base: PlatformFeature = {
436449
loadStartTimes: [],
437450
loading: false,
438451
highlighted: "Before",
452+
type: "Observation",
439453
readings: [
440454
{
441455
reading: 2.85,
@@ -553,6 +567,7 @@ const platform_base: PlatformFeature = {
553567
loading: false,
554568
readings: [],
555569
highlighted: "No",
570+
type: "Observation",
556571
},
557572
{
558573
value: 5.13100004196167,
@@ -576,6 +591,7 @@ const platform_base: PlatformFeature = {
576591
loadStartTimes: [new Date("2020-01-28T14:18:01.570Z")],
577592
loading: false,
578593
highlighted: "After",
594+
type: "Observation",
579595
readings: [
580596
{
581597
reading: 5.92,
@@ -1936,6 +1952,7 @@ const platform_base: PlatformFeature = {
19361952
loadStartTimes: ["2020-01-28T14:18:01.570Z"],
19371953
loading: false,
19381954
highlighted: "After",
1955+
type: "Observation",
19391956
readings: [
19401957
{
19411958
reading: 5,
@@ -2620,6 +2637,7 @@ const platform_base: PlatformFeature = {
26202637
loadStartTimes: ["2020-01-28T14:18:01.570Z"],
26212638
loading: false,
26222639
highlighted: "Before",
2640+
type: "Observation",
26232641
readings: [
26242642
{
26252643
reading: 0.696,
@@ -6648,6 +6666,7 @@ const platform_base: PlatformFeature = {
66486666
loadStartTimes: ["2020-01-28T14:18:01.570Z"],
66496667
loading: false,
66506668
highlighted: "No",
6669+
type: "Observation",
66516670
readings: [
66526671
{
66536672
reading: 2977.7466,
@@ -10674,6 +10693,7 @@ const platform_base: PlatformFeature = {
1067410693
loadStartTimes: ["2020-01-28T14:18:01.570Z"],
1067510694
loading: false,
1067610695
highlighted: "No",
10696+
type: "Observation",
1067710697
readings: [
1067810698
{
1067910699
reading: 355.92,
@@ -14700,6 +14720,7 @@ const platform_base: PlatformFeature = {
1470014720
loadStartTimes: ["2020-01-28T14:18:01.570Z"],
1470114721
loading: false,
1470214722
highlighted: "No",
14723+
type: "Observation",
1470314724
readings: [
1470414725
{
1470514726
reading: 8.46,
@@ -18728,6 +18749,7 @@ const platform_base: PlatformFeature = {
1872818749
loadStartTimes: ["2020-01-28T14:18:01.570Z"],
1872918750
loading: false,
1873018751
highlighted: "No",
18752+
type: "Observation",
1873118753
readings: [
1873218754
{
1873318755
reading: 1004.6906,
@@ -22754,6 +22776,7 @@ const platform_base: PlatformFeature = {
2275422776
loading: false,
2275522777
readings: [],
2275622778
highlighted: "No",
22779+
type: "Observation",
2275722780
},
2275822781
{
2275922782
value: 3.33200001716614,
@@ -22774,6 +22797,7 @@ const platform_base: PlatformFeature = {
2277422797
loadStartTimes: ["2020-01-28T14:20:13.209Z"],
2277522798
loading: false,
2277622799
highlighted: "No",
22800+
type: "Observation",
2277722801
readings: [
2277822802
{
2277922803
reading: 10.31,
@@ -26777,6 +26801,89 @@ const platform_base: PlatformFeature = {
2677726801
},
2677826802
],
2677926803
},
26804+
{
26805+
value: -0.97644,
26806+
time: "2025-07-22T21:00:00Z",
26807+
depth: null,
26808+
data_type: {
26809+
standard_name: "sea_surface_height_above_geopotential_datum",
26810+
short_name: "Sea Surface Height",
26811+
long_name: "Sea surface height above geopotential datum (NAVD 88)",
26812+
units: "Meters",
26813+
},
26814+
server: "https://data.neracoos.org/erddap/",
26815+
variable: "navd_88_meters",
26816+
constraints: {
26817+
"site_id=": "SCTM3",
26818+
},
26819+
dataset: "NWS_Hydromet_BOX",
26820+
dataset_public_name: "NWS HydroMet Forecast",
26821+
start_time: "2025-04-16T16:36:14.973619Z",
26822+
cors_proxy_url: "/api/servers/9/proxy/",
26823+
datum_offsets: {},
26824+
flood_levels: [],
26825+
highlighted: "No",
26826+
type: "Forecast",
26827+
readings: [],
26828+
extrema: false,
26829+
extrema_values: {
26830+
max: {
26831+
time: "2025-07-23T02:00:00+00:00",
26832+
value: 1.6448400000000003,
26833+
},
26834+
min: {
26835+
time: "2025-07-24T09:00:00+00:00",
26836+
value: -1.76892,
26837+
},
26838+
tides: [
26839+
{
26840+
tide: "high",
26841+
time: "2025-07-23T02:00:00+00:00",
26842+
value: 1.6448400000000003,
26843+
},
26844+
{
26845+
tide: "low",
26846+
time: "2025-07-23T08:00:00+00:00",
26847+
value: -1.647,
26848+
},
26849+
{
26850+
tide: "high",
26851+
time: "2025-07-23T15:00:00+00:00",
26852+
value: 1.0352400000000002,
26853+
},
26854+
{
26855+
tide: "low",
26856+
time: "2025-07-23T21:00:00+00:00",
26857+
value: -1.3422,
26858+
},
26859+
{
26860+
tide: "high",
26861+
time: "2025-07-24T03:00:00+00:00",
26862+
value: 1.58388,
26863+
},
26864+
{
26865+
tide: "low",
26866+
time: "2025-07-24T09:00:00+00:00",
26867+
value: -1.76892,
26868+
},
26869+
{
26870+
tide: "high",
26871+
time: "2025-07-24T16:00:00+00:00",
26872+
value: 1.0352400000000002,
26873+
},
26874+
{
26875+
tide: "low",
26876+
time: "2025-07-24T21:00:00+00:00",
26877+
value: -1.40316,
26878+
},
26879+
{
26880+
tide: "high",
26881+
time: "2025-07-25T04:00:00+00:00",
26882+
value: 1.5534,
26883+
},
26884+
],
26885+
},
26886+
},
2678026887
],
2678126888
attribution: [
2678226889
{

0 commit comments

Comments
 (0)