hafs-community / hafs_graphics

Generate HAFS Graphics
1 stars 6 forks source link

plot_tempanomaly_hgt_wind.py uses lower-case stormModel so it doesn't find the grib files #15

Closed SamuelTrahanNOAA closed 43 minutes ago

SamuelTrahanNOAA commented 5 hours ago

This code in feature/hafs.v2.0.1 causes the plot_tempanomaly_hgt_wind.py to produce the wrong GRIB2 filename. For example, instead of HFSA it gets hfsa:

fname = conf['stormID'].lower()+'.'+conf['ymdh']+'.'+conf['stormModel'].lower()+'.'+conf['stormDomain']+'.atm.'+conf['fhhh']+'.grb2'

It should use upper-case stormModel instead:

fname = conf['stormID'].lower()+'.'+conf['ymdh']+'.'+conf['stormModel'].upper()+'.'+conf['stormDomain']+'.atm.'+conf['fhhh']+'.grb2'

Or no case correction:

fname = conf['stormID'].lower()+'.'+conf['ymdh']+'.'+conf['stormModel']+'.'+conf['stormDomain']+'.atm.'+conf['fhhh']+'.grb2'

Here's the error I get:

Parse the config file: plot_atmos.yml:
{'stormModel': 'HRFS', 'stormName': 'THIRTEEN', 'stormID': '13L', 'stormBasin': 'AL', 'stormDomain': 'storm', 'ymdh': '2023090512', 'fhhh': 'f000', 'standardLayer': 200, 'COMhafs': '/work2/noaa/wrfruc/strahan/scrub/hafs-rrfs-coupled-01/com/2023090512/13L
', 'cartopyDataDir': '/work/noaa/hwrf/noscrub/local/share/cartopy', 'stormNumber': '13', 'initTime': Timestamp('2023-09-05 12:00:00'), 'fhour': 0, 'fcstTime': Timedelta('0 days 00:00:00'), 'validTime': Timestamp('2023-09-05 12:00:00')}
grib2file: /work2/noaa/wrfruc/strahan/scrub/hafs-rrfs-coupled-01/com/2023090512/13L/13l.2023090512.hrfs.storm.atm.f000.grb2
Traceback (most recent call last):
  File "/work2/noaa/wrfruc/strahan/scrub/hafs-rrfs-coupled-01/2023090512/13L/emc_graphics/THIRTEEN13L/2023090512.storm.tempanomaly_hgt_wind_200_f000/./plot_tempanomaly_hgt_wind.py", line 40, in <module>
    grb = grib2io.open(grib2file,mode='r')
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work2/noaa/hwrf/maristiz/miniconda3/envs/WCOSS2_env/lib/python3.11/site-packages/grib2io/_grib2io.py", line 129, in __init__
    self._filehandle = builtins.open(filename, mode=mode)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/work2/noaa/wrfruc/strahan/scrub/hafs-rrfs-coupled-01/com/2023090512/13L/13l.2023090512.hrfs.storm.atm.f000.grb2'

That directory may be scrubbed by the time you look at it. The correct filename is:

Only the capitalization of HRFS is different.

SamuelTrahanNOAA commented 3 hours ago

Apparently there are a few more of those lower() vs. upper() mismatches.

Perhaps the hafs scripts changed grib2 filenames between v2 final and v2.0.1? My branch is based on v2 final.

SamuelTrahanNOAA commented 2 hours ago

I think this is due to version incompatibility (v2 final vs v2.0.1), so I'm closing the PR until I can get feedback from other developers.

Please let me know in this issue why you think it may be happening.

SamuelTrahanNOAA commented 43 minutes ago

This bug was caused by setting config.RUN to a string with capital letters. It must be lower-case.