diff --git a/libs/windy-sounding/CHANGELOG.md b/libs/windy-sounding/CHANGELOG.md index 1c5abb97..b959e6a9 100644 --- a/libs/windy-sounding/CHANGELOG.md +++ b/libs/windy-sounding/CHANGELOG.md @@ -1,5 +1,9 @@ # Release history +## 4.1.7 - Sep 14, 2024 + +- Update the list of supported models to exclude AROME-HD + ## 4.1.6 - Aug 26, 2024 - Fix the required update check diff --git a/libs/windy-sounding/src/components/favorites.tsx b/libs/windy-sounding/src/components/favorites.tsx index b7b95c2f..76c37900 100644 --- a/libs/windy-sounding/src/components/favorites.tsx +++ b/libs/windy-sounding/src/components/favorites.tsx @@ -2,7 +2,7 @@ import type { Fav, LatLon } from '@windy/interfaces'; import { useState } from 'preact/hooks'; import { round } from '../util/math'; -import { getFavLabel, latLon2Str, SUPPORTED_MODEL_PREFIXES } from '../util/utils'; +import { getFavLabel, latLon2Str, isSupportedModelName } from '../util/utils'; const windyModels = W.models; @@ -38,7 +38,7 @@ export function Favorites({ favorites, location, isMobile, onSelected, modelName if (isMobile) { const models: string[] = windyModels .getAllPointProducts(location) - .filter((model: string) => SUPPORTED_MODEL_PREFIXES.some((prefix) => model.startsWith(prefix))) + .filter((model: string) => isSupportedModelName(model)) .sort(); const { lat, lon } = location; diff --git a/libs/windy-sounding/src/util/utils.ts b/libs/windy-sounding/src/util/utils.ts index 0d93416c..35b62c1e 100644 --- a/libs/windy-sounding/src/util/utils.ts +++ b/libs/windy-sounding/src/util/utils.ts @@ -1,16 +1,16 @@ import type { Fav } from '@windy/interfaces'; // Some models do not have the required parameters for soundings (i.e. surface only) -export const SUPPORTED_MODEL_PREFIXES = [ - 'ecmwf', - 'gfs', - 'nam', - 'icon', - 'hrrr', - 'ukv', - 'arome', - 'czeAladin', - 'canHrdps', +const SUPPORTED_MODELS = [ + /^ecmwf$/, + /^gfs$/, + /^nam/, + /^icon/, + /^hrrr/, + /^ukv$/, + /^arome\w+/, // "arome" is unsupported + /^czeAladin$/, + /^canHrdps$/, ]; export const DEFAULT_MODEL = 'ecmwf'; @@ -40,9 +40,22 @@ export function formatTimestamp(ts: number) { * Some models only include surface data and can not be used for soundings. */ export function getSupportedModelName(windyModelName: string): string { - return SUPPORTED_MODEL_PREFIXES.some((prefix) => windyModelName.startsWith(prefix)) ? windyModelName : DEFAULT_MODEL; + return isSupportedModelName(windyModelName) ? windyModelName : DEFAULT_MODEL; } +/** + * Checks if a Windy model name is supported for soundings. + * + * Some models only include surface data and can not be used for soundings. + * + * @param windyModelName - The Windy model name to check. + * @returns True if the model is supported, false otherwise. + */ +export function isSupportedModelName(windyModelName: string): boolean { + return SUPPORTED_MODELS.some((prefix) => prefix.test(windyModelName)); +} + + /** * Returns a code from a location (lat, lon). *