In working with other observed lightning data, I often have a time range of interest of a few seconds corresponding to a lightning flash, and I want to find it in GLM data. When querying goes2go with GOES.timerange for this short window, I get an error due to an empty data frame of GLM files being returned.
A workaround is to pad the times with the duration of a GLM file, but it would be useful if this condition were handled automatically.
It is also difficult to know that a short time range is the problem, since the error message percolates up from the threading library. So, a simpler fix would be to detect that no files are returned by the initial timerange query and raise a more meaningful error.
This code reproduces the error:
from goes2go import GOES
import pandas as pd
from pathlib import Path
glm_data_dir = Path('./GLM/')
glm_data_dir.mkdir(parents=True, exist_ok=True)
first_time, last_time = pd.Timestamp('2025-06-03 02:16:26.493570'), pd.Timestamp('2025-06-03 02:16:31.493580')
GLM19 = GOES(satellite=19, product="GLM-L2-LCFA")
glm19_df = GLM19.timerange(first_time, last_time, save_dir=str(glm_data_dir.absolute()), verbose=False)
And here is the resulting error, which complains about the number of thread workers. The error is because because no GLM files were returned in the file list data frame, so the code in data.py asks for zero threads and then crashes.
ValueError Traceback (most recent call last)
Cell In[6], line 7
4 first_time, last_time = pd.Timestamp('2025-06-03 02:16:26.493570'), pd.Timestamp('2025-06-03 02:16:31.493580')
6 GLM19 = GOES(satellite=19, product="GLM-L2-LCFA")
----> 7 glm19_df = GLM19.timerange(first_time, last_time, save_dir=str(glm_data_dir.absolute()), verbose=False)
File ~/miniconda3/envs/leelma/lib/python3.10/site-packages/goes2go/NEW.py:219, in GOES.timerange(self, start, end, recent, **kwargs)
208 def timerange(self, start=None, end=None, recent=None, **kwargs):
209 """Get GOES data for a time range.
210
211 Parameters
(...)
217 get the most recent files for the past hour.
218 """
--> 219 return goes_timerange(
220 start,
221 end,
222 recent,
223 satellite=self.satellite,
224 product=self.product,
225 domain=self.domain,
226 bands=self.bands,
227 **kwargs,
228 )
File ~/miniconda3/envs/leelma/lib/python3.10/site-packages/goes2go/data.py:428, in goes_timerange(start, end, recent, satellite, product, domain, return_as, download, overwrite, save_dir, max_cpus, bands, s3_refresh, ignore_missing, verbose)
425 df = _goes_file_df(satellite, product, start, end, bands=bands, refresh=s3_refresh, ignore_missing=ignore_missing)
427 if download:
--> 428 _download(df, save_dir=save_dir, overwrite=overwrite, verbose=verbose)
430 if return_as == "filelist":
431 df.attrs["filePath"] = save_dir
File ~/miniconda3/envs/leelma/lib/python3.10/site-packages/goes2go/data.py:216, in _download(df, save_dir, overwrite, max_threads, verbose)
213 tasks = len(df)
214 threads = min(tasks, max_threads)
--> 216 with ThreadPoolExecutor(threads) as exe:
217 futures = [exe.submit(do_download, src) for src in df.file]
219 # nothing is returned in the list
File ~/miniconda3/envs/leelma/lib/python3.10/concurrent/futures/thread.py:144, in ThreadPoolExecutor.__init__(self, max_workers, thread_name_prefix, initializer, initargs)
142 max_workers = min(32, (os.cpu_count() or 1) + 4)
143 if max_workers <= 0:
--> 144 raise ValueError("max_workers must be greater than 0")
146 if initializer is not None and not callable(initializer):
147 raise TypeError("initializer must be a callable")
ValueError: max_workers must be greater than 0
In working with other observed lightning data, I often have a time range of interest of a few seconds corresponding to a lightning flash, and I want to find it in GLM data. When querying goes2go with
GOES.timerangefor this short window, I get an error due to an empty data frame of GLM files being returned.A workaround is to pad the times with the duration of a GLM file, but it would be useful if this condition were handled automatically.
It is also difficult to know that a short time range is the problem, since the error message percolates up from the threading library. So, a simpler fix would be to detect that no files are returned by the initial timerange query and raise a more meaningful error.
This code reproduces the error:
And here is the resulting error, which complains about the number of thread workers. The error is because because no GLM files were returned in the file list data frame, so the code in data.py asks for zero threads and then crashes.