Skip to content

Commit

Permalink
Update the list of supported models
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb committed Sep 14, 2024
1 parent 49247e5 commit 11c73b1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
4 changes: 4 additions & 0 deletions libs/windy-sounding/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions libs/windy-sounding/src/components/favorites.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
35 changes: 24 additions & 11 deletions libs/windy-sounding/src/util/utils.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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).
*
Expand Down

0 comments on commit 11c73b1

Please sign in to comment.