🏷️ Custom filename on download#

By default, Herbie uses files original name when it is download, but it is possible to give the file a custom name.

[1]:
from herbie.core import Herbie
[2]:
H = Herbie("2021-01-01", model="hrrr", product="sfc", fxx=6)
βœ… Found β”Š model=hrrr β”Š product=sfc β”Š 2021-Jan-01 00:00 UTC F06 β”Š GRIB2 @ aws β”Š IDX @ aws
[3]:
H.get_localFileName
[3]:
'hrrr.t00z.wrfsfcf06.grib2'
[4]:
H.get_localFilePath()
[4]:
PosixPath('/home/blaylock/data/hrrr/20210101/hrrr.t00z.wrfsfcf06.grib2')
[7]:
H.LOCALFILE = "custom_name.grib2"
[8]:
H.get_localFilePath()
[8]:
PosixPath('/home/blaylock/data/hrrr/20210101/custom_name.grib2')
[9]:
H.download()
πŸ‘¨πŸ»β€πŸ­ Created directory: [/home/blaylock/data/hrrr/20210101]
[9]:
PosixPath('/home/blaylock/data/hrrr/20210101/custom_name.grib2')

It may be more useful to give the file a more descriptive name based on the file’s attributes

[15]:
H = Herbie("2021-01-01", model="hrrr", product="sfc", fxx=6)
H.LOCALFILE = f"model_{H.model.upper()}_{H.date:%Y%m%d%H}_F{H.fxx:02d}_valid_{H.valid_date:%Y%m%d%H}.grib2"
H.download(verbose=True)
βœ… Found β”Š model=hrrr β”Š product=sfc β”Š 2021-Jan-01 00:00 UTC F06 β”Š GRIB2 @ aws β”Š IDX @ aws
βœ… Success! Downloaded HRRR from aws                 
        src: https://noaa-hrrr-bdp-pds.s3.amazonaws.com/hrrr.20210101/conus/hrrr.t00z.wrfsfcf06.grib2
        dst: /home/blaylock/data/hrrr/20210101/model_HRRR_2021010100_F06_valid_2021010106.grib2
[15]:
PosixPath('/home/blaylock/data/hrrr/20210101/model_HRRR_2021010100_F06_valid_2021010106.grib2')
[16]:
H = Herbie("2021-01-01", model="hrrr", product="sfc", fxx=6)
H.LOCALFILE = f"model_{H.model.upper()}_{H.date:%Y%m%d%H}_F{H.fxx:02d}_valid_{H.valid_date:%Y%m%d%H}.grib2"
H.download("TMP:2 m", verbose=True)
βœ… Found β”Š model=hrrr β”Š product=sfc β”Š 2021-Jan-01 00:00 UTC F06 β”Š GRIB2 @ aws β”Š IDX @ aws
πŸ“‡ Download subset: β–Œβ–ŒHerbie HRRR model sfc product initialized 2021-Jan-01 00:00 UTC F06 β”Š source=aws
 cURL from https://noaa-hrrr-bdp-pds.s3.amazonaws.com/hrrr.20210101/conus/hrrr.t00z.wrfsfcf06.grib2
Found 1 grib messages.
Download subset group 1
  71  :TMP:2 m above ground:6 hour fcst
curl -s --range 48792552-50016187 "https://noaa-hrrr-bdp-pds.s3.amazonaws.com/hrrr.20210101/conus/hrrr.t00z.wrfsfcf06.grib2" > "/home/blaylock/data/hrrr/20210101/subset_abb2fd54__model_HRRR_2021010100_F06_valid_2021010106.grib2"
πŸ’Ύ Saved the subset to /home/blaylock/data/hrrr/20210101/subset_abb2fd54__model_HRRR_2021010100_F06_valid_2021010106.grib2
[16]:
PosixPath('/home/blaylock/data/hrrr/20210101/subset_abb2fd54__model_HRRR_2021010100_F06_valid_2021010106.grib2')