Skip to content

Commit

Permalink
Fix benchmarks to run with older commits
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed Jun 2, 2021
1 parent 1289aa3 commit 8a19f82
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions benchmarks/ahi_hsd_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
# satpy. If not, see <http://www.gnu.org/licenses/>.
"""Benchmark satpy."""

from pyspectral.utils import download_rsr, download_luts
from pyspectral.rayleigh import check_and_download as download_luts
from pyspectral.rsr_reader import check_and_download as download_rsr


class HimawariHSD:
Expand All @@ -28,19 +29,27 @@ class HimawariHSD:

def setup_cache(self):
"""Fetch the data files."""
from satpy.demo import download_typhoon_surigae_ahi
download_typhoon_surigae_ahi(channels=[1, 2, 3, 4], segments=[4])
try:
from satpy.demo import download_typhoon_surigae_ahi
download_typhoon_surigae_ahi(channels=[1, 2, 3, 4], segments=[4])
except ImportError:
assert len(self.get_filenames()) == 4
download_rsr()
download_luts(aerosol_type='rayleigh_only')

def setup(self):
"""Set up the benchmarks."""
import satpy
from satpy.demo import download_typhoon_surigae_ahi
# This just returns the filenames, as the data already is downloaded above
self.data_files = download_typhoon_surigae_ahi(channels=[1, 2, 3, 4], segments=[4])
self.data_files = self.get_filenames()
satpy.CHUNK_SIZE = 2048

def get_filenames(self):
"""Get the data filenames manually."""
import os
import glob
base_dir = os.environ.get("SATPY_DEMO_DATA_DIR", ".")
return glob.glob(os.path.join(base_dir, "ahi_hsd/20210417_0500_random/*"))

def time_load_one_channel(self):
"""Time the loading of one channel."""
self.compute_B01()
Expand Down

0 comments on commit 8a19f82

Please sign in to comment.