def _get_filename(self): """Get the rsr filname from platform and instrument names, and download if not available. """ self.filename = expanduser( os.path.join(self.rsr_dir, 'rsr_{0}_{1}.h5'.format(self.instrument, self.platform_name))) LOG.debug('Filename: %s', str(self.filename)) if not os.path.exists(self.filename) or not os.path.isfile(self.filename): LOG.warning("No rsr file %s on disk", self.filename) if self._rsr_data_version_uptodate: LOG.info("RSR data up to date, so seems there is no support for this platform and sensor") else: # Try download from the internet! if self.do_download: LOG.info("Will download from internet...") download_rsr() if self._get_rsr_data_version() == RSR_DATA_VERSION: self._rsr_data_version_uptodate = True if not self._rsr_data_version_uptodate: LOG.warning("rsr data may not be up to date: %s", self.filename) if self.do_download: LOG.info("Will download from internet...") download_rsr()
def check_and_download(**kwargs): """Do a check for the version and attempt downloading only if needed.""" dry_run = kwargs.get('dry_run', False) dest_dir = kwargs.get('dest_dir', None) rsr = RSRDataBaseClass() if rsr.rsr_data_version_uptodate: LOG.info("RSR data already the latest!") else: if dest_dir: download_rsr(dest_dir=dest_dir, dry_run=dry_run) else: download_rsr(dry_run=dry_run)
def check_and_download(**kwargs): """Do a check for the version and attempt downloading only if needed""" dry_run = kwargs.get('dry_run', False) dest_dir = kwargs.get('dest_dir', None) rsr = RSRDataBaseClass() if rsr.rsr_data_version_uptodate: LOG.info("RSR data already the latest!") else: if dest_dir: download_rsr(dest_dir=dest_dir, dry_run=dry_run) else: download_rsr(dry_run=dry_run)
def __init__(self, platform_name, instrument): self.platform_name = platform_name self.instrument = instrument self.filename = None self.rsr = {} self.description = "Unknown" self.band_names = None self.unit = '1e-6 m' self.si_scale = 1e-6 # How to scale the wavelengths to become SI unit self._wavespace = WAVL conf = get_config() options = {} for option, value in conf.items('general', raw=True): options[option] = value # Try fix instrument naming instr = INSTRUMENTS.get(platform_name, instrument) if instr != instrument: instrument = instr LOG.warning("Inconsistent instrument/satellite input - " + "instrument set to %s", instrument) instrument = instrument.replace('/', '') rsr_dir = options['rsr_dir'] self.filename = expanduser(os.path.join(rsr_dir, 'rsr_%s_%s.h5' % (instrument, platform_name))) LOG.debug('Filename: %s', str(self.filename)) if not os.path.exists(self.filename) or not os.path.isfile(self.filename): # Try download from the internet! LOG.warning("No rsr file %s on disk", self.filename) if 'download_from_internet' in options and options['download_from_internet'] == 'True': LOG.info("Will download from internet...") download_rsr() if not os.path.exists(self.filename) or not os.path.isfile(self.filename): raise IOError('pyspectral RSR file does not exist! Filename = ' + str(self.filename) + '\nFiles matching instrument and satellite platform' + ': ' + str(glob(os.path.join(rsr_dir, '*%s*%s*.h5' % (instrument, platform_name))))) self.load()
def _get_filename(self): """Get the rsr filname from platform and instrument names, and download if not available. """ self.filename = expanduser( os.path.join( self.rsr_dir, 'rsr_{0}_{1}.h5'.format(self.instrument, self.platform_name))) LOG.debug('Filename: %s', str(self.filename)) if not os.path.exists(self.filename) or not os.path.isfile( self.filename): # Try download from the internet! LOG.warning("No rsr file %s on disk", self.filename) if self.do_download: LOG.info("Will download from internet...") download_rsr()
import argparse from pyspectral.utils import download_rsr from pyspectral.utils import logging_on, logging_off if __name__ == "__main__": parser = argparse.ArgumentParser( description='Download relative spectral response data in hdf5') parser.add_argument("-o", "--destination", help=("Destination path where to store the files"), default=None, type=str) parser.add_argument( "-d", '--dry_run', help=("Dry run - no action"), action='store_true', default=False) parser.add_argument( "-v", '--verbose', help=("Turn logging on"), action='store_true') args = parser.parse_args() dest_dir = args.destination verbose = args.verbose dry_run = args.dry_run if verbose: logging_on(logging.DEBUG) else: logging_off() if dest_dir: download_rsr(dest_dir=dest_dir, dry_run=dry_run) else: download_rsr(dry_run=dry_run)
def download_pyspectral_luts(): print("Downloading lookup tables used by pyspectral...") from pyspectral.utils import download_luts, download_rsr download_luts() download_rsr() return True
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]) download_rsr() download_luts(aerosol_type='rayleigh_only')
#!/usr/bin/env python # -*- coding: utf-8 -*- # I waive copyright and related rights in the this work worldwide # through the CC0 1.0 Universal public domain dedication. # https://creativecommons.org/publicdomain/zero/1.0/legalcode # Author(s): # Tom Parker <*****@*****.**> """ Retrieve luts """ import pyspectral.utils as utils utils.download_luts() utils.download_rsr()