@@ -0,0 +1,2031 @@
+import os, re%0A%0Afrom wsynphot.io.get_filter_data import (get_filter_index,%0A    get_transmission_data)%0Afrom wsynphot.config import get_data_dir%0A%0ACACHE_DIR = os.path.join(get_data_dir(), 'cached_SVO_FPS')%0Aif not os.path.exists(CACHE_DIR):%0A    os.mkdir(CACHE_DIR)%0A%0A%0Adef cache_as_votable(table, file_path):%0A    %22%22%22Caches the passed table on disk as a VOTable.%0A%0A    Parameters%0A    ----------%0A    table : astropy.table.Table%0A        Table to be cached %0A    file_path : str%0A        Path where VOTable is to be saved %0A    %22%22%22%0A    if not file_path.endswith('.vot'):%0A        file_path += '.vot'%0A%0A    dir_path = os.path.dirname(file_path)%0A    if not os.path.exists(dir_path):%0A        os.makedirs(dir_path)%0A%0A    # Write table as votable (overwrite for cases when file already exists)%0A    table.write(file_path, format='votable', overwrite=True)%0A%0A%0Adef download_filter_data(cache_dir=CACHE_DIR):%0A    %22%22%22Downloads the entire filter data (filter index and transmission data %0A    of each filter) locally on disk as cache.%0A%0A    Parameters%0A    ----------%0A    cache_dir : str, optional%0A        Path of the directory where downloaded data is to be cached %0A    %22%22%22%0A    # Get filter index and cache it%0A    index_table = get_filter_index().to_table()%0A    cache_as_votable(index_table,%0A        os.path.join(cache_dir, 'index'))%0A%0A    # Fetch filter_ids from index & iterate%0A    for filter_id in index_table%5B'filterID'%5D:%0A        filter_id = filter_id.decode(%22utf-8%22)  # convert byte string to literal%0A        %0A        # Get transmission data for a filter_id and cache it%0A        try:%0A            print(%22caching %7B0%7D ...%22.format(filter_id))%0A            facility, instrument, filter_name = re.split('/%7C%5C.', filter_id)%0A            filter_table = get_transmission_data(filter_id).to_table()%0A            cache_as_votable(filter_table,%0A                os.path.join(cache_dir, facility, instrument, filter_name))%0A        except Exception as e:%0A            print('Data for Filter ID = %7B0%7D could not be downloaded due '%0A                'to:%5Cn%7B1%7D'.format(filter_id, e))%0A

Add function to download filter data & cache it on disk