blaylockbk / Herbie

Download numerical weather prediction datasets (HRRR, RAP, GFS, IFS, etc.) from NOMADS, NODD partners (Amazon, Google, Microsoft), ECMWF open data, and the University of Utah Pando Archive System.
https://herbie.readthedocs.io/
MIT License
507 stars 75 forks source link

GEFS reforecast has different scheme on every Wednesday #377

Open juanqiu1 opened 3 weeks ago

juanqiu1 commented 3 weeks ago

On every Wednesday, GEFS reforecast dataset has different ensemble size and forecast length, and URLs are slightly different from other dates.

I made a small change to corresponding functions, as below

class gefs_reforecast:

    ........

    def template(self):
        self.DESCRIPTION = "Global Ensemble Forecast System (GEFS)"
        self.DETAILS = {
            "aws": "https://registry.opendata.aws/noaa-gefs-reforecast/",
        }
        self.PRODUCTS = {
            "GEFSv12/reforecast": "reforecasts for 2000-2019",
        }

        if self.date.weekday() == 2:
            # GEFS reforecast has extended ensemble on every Wednesday
            max_member_size = 10
            max_fxx = "Days:10-35"
        else:
            max_member_size = 4
            max_fxx = "Days:10-16"

        # Adjust "member" argument
        # - Member 0 is the control member
        # - Members 1-4 are the perturbation members
        if self.member == 0:
            member = f"c{self.member:02d}"
        elif self.member > 0 and self.member < max_member_size:
            member = f"p{self.member:02d}"
        else:
            raise ValueError(f"GEFS 'member' must be within range of [0 - {max_member_size}].")

        # Adjust "fxx" argument (given in hours)
        # This is used to define the directory to enter rather than the filename.
        if self.fxx <= 240:
            fxx = "Days:1-10"
        else:
            fxx = max_fxx

This change at least satisfies this call

H = Herbie("2000-01-05", model="gefs_reforecast", fxx=34 * 24, member=9, variable_level="ugrd_hgt")

However, I didn't test it thoroughly and I am not in a comfortable situation I could send a PR in. Could you kindly review and consider adopting this change?

Best,

blaylockbk commented 3 weeks ago

Thanks for bringing this to my attention and the code. I created a new branch for this and get this in when I have time.

juanqiu1 commented 3 weeks ago

My bad, this line should have <=

self.member > 0 and self.member < max_member_size: