Skip to content

New invest not detected by Herbie #473

@beuraieon-a

Description

@beuraieon-a

I am trying to use Herbie to visualize HAFS forecast for a new invest in the Western North Pacific, Invest 93w. I checked NOMADS and saw that HAFS-A forecast for Invest 93w is already present for the 2025-09-30 00:00 UTC run.
Image
But when I run my script, it returns:

=== Checking forecast hour 000 ===
⚠️ Could not process fxx=0: 'NoneType' object has no attribute 'title'

When I enter Storms().id_to_name, Invest 93w is not in the list:

{'24w': 'ragasa',
 '25w': 'neoguri',
 '09l': 'imelda',
 '14e': 'narda',
 '08l': 'humberto',
 '26w': 'bualoi'}

Here is a snippet of my script:

import os
import pytz
import datetime
from herbie import Herbie
from herbie.models.hafs import Storms
import numpy as np
import xarray as xr
import metpy.calc as mpcalc
from metpy.units import units
import matplotlib.pyplot as plt
from matplotlib.colorbar import ColorbarBase
from matplotlib.colors import Normalize
import matplotlib.colors as mcolors
import cartopy.crs as ccrs
from cartopy.io.shapereader import Reader
from cartopy.feature import ShapelyFeature
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER

###################
#### FUNCTIONS ####
###################

def read_rgb_file(rgb_file_path):
    with open(rgb_file_path, 'r') as open_file:
        rgb_lines = open_file.readlines()

    converted_colors = []
    for rgb_line in rgb_lines:
        # Split the line into components
        rgb_components = rgb_line.split()

        # Convert the RGB values to the range 0-1 and add to the list
        r, g, b = [int(c) / 255 for c in rgb_components[1:4]]
        converted_colors.append((r, g, b))

    return converted_colors

#####################################
#### MAIN PROGRAM IMPLEMENTATION ####
#####################################

# Preparing the colormap
color_file_path = 'C:/Users/Brian/Desktop/MDRRMO/Python scripts/cmap/windbeaufort_kmh_ver2.rgb'
wind_colors = read_rgb_file(color_file_path)
wind_colormap = mcolors.ListedColormap(wind_colors)

# Preparing file path to shapefile of Philippine coastline
PH_shapefile_province = 'C:/Users/Brian/Desktop/MDRRMO/Python scripts/map/gadm41_PHL_1.shp' # For provinces
guiuan_longitudes = [125.61172110216, 125.969435919155, 125.969435919155,
                     125.61172110216, 125.61172110216]
guiuan_latitudes = [10.6876240519150, 10.6876240519150, 11.0861620846742,
                    11.0861620846742, 10.6876240519150]

# Define run and storm
run = '2025-09-30T00:00'
storm = '93w'
save_dir = 'C:/Users/Brian/Desktop/HAFS'

# Forecast hours you want
forecast_hours = range(0, 97, 3)   # every 3h from 0 to 96

for fxx in forecast_hours:
    print(f"\n=== Checking forecast hour {fxx:03d} ===")

    try:
        # Initialize Herbie objects
        H_storm = Herbie(run, model='hafsa', product='storm.atm',
                         storm=storm, fxx=fxx, save_dir=save_dir)
        H_parent = Herbie(run, model='hafsa', product='parent.atm',
                          storm=storm, fxx=fxx, save_dir=save_dir)
        
        Storms().id_to_name
        
        # Check if files exist
        storm_exists = H_storm.grib is not None
        parent_exists = H_parent.grib is not None
        
        if not storm_exists and not parent_exists:
            print(f"❌ No storm.atm or parent.atm data for fxx={fxx}")
            continue
        elif storm_exists and not parent_exists:
            print(f"⚠️ Storm data present, parent missing for fxx={fxx}")
        elif parent_exists and not storm_exists:
            print(f"⚠️ Parent data present, storm missing for fxx={fxx}")
        else:
            print(f"✅ Data available for both storm.atm and parent.atm at fxx={fxx}")
        
        # Load variables only if both are available
        if storm_exists:
            mslp = H_storm.xarray('PRMSL')
            u10_storm = H_storm.xarray('UGRD')[0]
            v10_storm = H_storm.xarray('VGRD')[0]
            rainrate_storm = H_storm.xarray('PRATE') * 3600
        
        if parent_exists:
            u10_parent = H_parent.xarray('UGRD')[0]['u10'].sel(
                latitude=slice(7.5, 14.5), longitude=slice(121.5, 130.5))
            v10_parent = H_parent.xarray('VGRD')[0]['v10'].sel(
                latitude=slice(7.5, 14.5), longitude=slice(121.5, 130.5))
            ds_gust = H_parent.xarray('GUST').sel(
                latitude=slice(7.5, 14.5), longitude=slice(121.5, 130.5))
            ds_rainrate_parent = H_parent.xarray('PRATE').sel(
                latitude=slice(7.5, 14.5), longitude=slice(121.5, 130.5)) * 3600
            ds_rainaccum = H_parent.xarray('APCP').sel(
                latitude=slice(7.5, 14.5), longitude=slice(121.5, 130.5))
            ds_precipwater = H_parent.xarray('PWAT').sel(
                latitude=slice(7.5, 14.5), longitude=slice(121.5, 130.5))
            
            # Data visualization here
            
    except Exception as e:
        print(f"⚠️ Could not process fxx={fxx}: {e}")
    
    break

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions