SolarArbiter / solarforecastarbiter-core

Core data gathering, validation, processing, and reporting package for the Solar Forecast Arbiter
https://solarforecastarbiter-core.readthedocs.io
MIT License
35 stars 21 forks source link

fetchnwp not catching empty (0 kB) .grib2 files #696

Open williamhobbs opened 3 years ago

williamhobbs commented 3 years ago

If I make too many requests to NOMADS, it will start returning 0 kB .grib2 files. In some cases, solararbiter fetchnwp does not seem to notice this and proceeds to create a .nc file that is missing data. It seems like having a way to either

  1. return a warning or error, or
  2. catch this issue, delete empty files, and re-download them,

would be helpful.

Details on an example test case are below, where I tried fetching gefs while also fetching hrrr_subhourly. The easy solution here is that I shouldn't fetch gefs while running other fetch processes, but it seems possible that this same issue could come up in unavoidable ways, e.g., after a multi-day network outage and solararbiter fetchnwp catches up all at once when the network comes back.

pi@raspberrypi:~/Downloads/sfa/hrrr_subhourly/2021/07/23/15 $ ls -l
total 32196
-rw-r--r-- 1 pi pi  705980 Jul 23 16:33 hrrr.t15z.wrfsubhf00.grib2
-rw-r--r-- 1 pi pi 2814134 Jul 23 16:33 hrrr.t15z.wrfsubhf01.grib2
-rw-r--r-- 1 pi pi 2549912 Jul 23 16:33 hrrr.t15z.wrfsubhf02.grib2
-rw-r--r-- 1 pi pi 2559698 Jul 23 16:33 hrrr.t15z.wrfsubhf03.grib2
-rw-r--r-- 1 pi pi 2628200 Jul 23 16:33 hrrr.t15z.wrfsubhf04.grib2
-rw-r--r-- 1 pi pi 2628200 Jul 23 16:33 hrrr.t15z.wrfsubhf05.grib2
-rw-r--r-- 1 pi pi 2637986 Jul 23 16:33 hrrr.t15z.wrfsubhf06.grib2
-rw-r--r-- 1 pi pi 2677130 Jul 23 16:33 hrrr.t15z.wrfsubhf07.grib2
-rw-r--r-- 1 pi pi 2784776 Jul 23 16:33 hrrr.t15z.wrfsubhf08.grib2
-rw-r--r-- 1 pi pi 2628200 Jul 23 16:33 hrrr.t15z.wrfsubhf09.grib2
-rw-r--r-- 1 pi pi 2510768 Jul 23 16:33 hrrr.t15z.wrfsubhf10.grib2
-rw-r--r-- 1 pi pi  759074 Jul 23 16:33 hrrr.t15z.wrfsubhf11.grib2
-rw-r--r-- 1 pi pi  749288 Jul 23 16:33 hrrr.t15z.wrfsubhf12.grib2
-rw-r--r-- 1 pi pi  710144 Jul 23 16:33 hrrr.t15z.wrfsubhf13.grib2
-rw-r--r-- 1 pi pi  749288 Jul 23 16:33 hrrr.t15z.wrfsubhf14.grib2
-rw-r--r-- 1 pi pi  710144 Jul 23 16:33 hrrr.t15z.wrfsubhf15.grib2
-rw-r--r-- 1 pi pi  710144 Jul 23 16:33 hrrr.t15z.wrfsubhf16.grib2
-rw-r--r-- 1 pi pi  710144 Jul 23 16:33 hrrr.t15z.wrfsubhf17.grib2
-rw-r--r-- 1 pi pi  710144 Jul 23 16:33 hrrr.t15z.wrfsubhf18.grib2
pi@raspberrypi:~/Downloads/sfa/hrrr_subhourly/2021/07/23/15 $ ls -l
total 23956
-rw-r--r-- 1 pi pi 24527266 Jul 23 16:33 hrrr_subhourly.nc
2021-07-23 16:32:58,729 INFO Fetching NWP forecasts for hrrr_subhourly
2021-07-23 16:32:59,063 INFO Getting file /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr.t15z.wrfsubhf00.grib2
2021-07-23 16:32:59,111 INFO Getting file /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr.t15z.wrfsubhf01.grib2
2021-07-23 16:32:59,165 INFO Getting file /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr.t15z.wrfsubhf02.grib2
2021-07-23 16:32:59,225 INFO Getting file /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr.t15z.wrfsubhf03.grib2
2021-07-23 16:32:59,275 INFO Getting file /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr.t15z.wrfsubhf04.grib2
2021-07-23 16:32:59,325 INFO Getting file /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr.t15z.wrfsubhf05.grib2
2021-07-23 16:32:59,377 INFO Getting file /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr.t15z.wrfsubhf06.grib2
2021-07-23 16:32:59,428 INFO Getting file /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr.t15z.wrfsubhf07.grib2
2021-07-23 16:32:59,477 INFO Getting file /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr.t15z.wrfsubhf08.grib2
2021-07-23 16:32:59,527 INFO Getting file /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr.t15z.wrfsubhf09.grib2
2021-07-23 16:32:59,575 INFO Getting file /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr.t15z.wrfsubhf10.grib2
2021-07-23 16:33:01,669 INFO Getting file /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr.t15z.wrfsubhf11.grib2
2021-07-23 16:33:01,727 INFO Getting file /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr.t15z.wrfsubhf12.grib2
2021-07-23 16:33:01,783 INFO Getting file /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr.t15z.wrfsubhf13.grib2
2021-07-23 16:33:01,835 INFO Getting file /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr.t15z.wrfsubhf14.grib2
2021-07-23 16:33:02,056 INFO Getting file /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr.t15z.wrfsubhf15.grib2
2021-07-23 16:33:03,218 INFO Getting file /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr.t15z.wrfsubhf16.grib2
2021-07-23 16:33:03,294 INFO Getting file /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr.t15z.wrfsubhf17.grib2
2021-07-23 16:33:03,434 INFO Getting file /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr.t15z.wrfsubhf18.grib2
2021-07-23 16:33:08,332 INFO Converting GRIB files to NetCDF with wgrib2 
2021-07-23 16:33:17,817 INFO Optimizing NetCDF file to save at /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr_subhourly.nc
2021-07-23 16:33:28,966 INFO Done optimizing NetCDF at /home/pi/Downloads/sfa/hrrr_subhourly/2021/07/23/15/hrrr_subhourly.nc
wholmgren commented 3 years ago

also related: https://github.com/SolarArbiter/solarforecastarbiter-core/issues/680 #674

williamhobbs commented 2 years ago

Adding a note here in case it is useful to someone: I've found that when I need to catch up on fetching NWP files (e.g., when my SD card fills up and I don't notice for a few days and I have to clean things up and get re-started), adding a 120 second pause between fetchnwp --once commands for HRRR subhourly files seems to work well at avoiding NOMADS rate limiting.

In Raspberry PI OS terminal, I run something like: x=45; for ((n=0; n < (x / 2); n++)); do solararbiter${IFS}fetchnwp${IFS}-v${IFS}--once${IFS}/home/pi/Downloads/sfa${IFS}hrrr_subhourly; sleep 120; done

This repeats the command solararbiter fetchnwp -v --once /home/pi/Downloads/sfa hrrr_subhourly 45 times, pausing 120 seconds between each run (to try to avoid NOAA download rate limits). The ${IFS} adds necessary spaces to the command.

This typically returns 19 .grib2 files, so it may be that about 10 files per minute is below the threshold for getting limited.

Edit: I'm not sure what the "x / 2" was for. The command should have been: x=45; for ((n=0; n < x; n++)); do solararbiter${IFS}fetchnwp${IFS}-v${IFS}--once${IFS}/home/pi/Downloads/sfa${IFS}hrrr_subhourly; sleep 120; done

williamhobbs commented 2 years ago

An additional scenario has come up where this could be useful: following NOMADS outages. On 2022-08-15, portions of NOMADS were down for about 6 hours. Estimated time to full repair was approximately 48 hours.