@@ -294,7 +294,8 @@ def _parse_result(self, response, *, verbose=False):
294294
295295 def get_species_table (self , * , catfile = 'partfunc.cat' , use_cached = True ,
296296 catfile_url = conf .catfile_url ,
297- catfile2 = 'catdir.cat' , catfile_url2 = conf .catfile_url2 ):
297+ catfile2 = 'catdir.cat' , catfile_url2 = conf .catfile_url2 ,
298+ write_new_species_cache = False ):
298299 """
299300 A directory of the catalog is found in a file called 'catdir.cat.'
300301
@@ -304,6 +305,15 @@ def get_species_table(self, *, catfile='partfunc.cat', use_cached=True,
304305 ----------
305306 catfile : str, name of file, default 'catdir.cat'
306307 The catalog file, installed locally along with the package
308+ use_cached : bool, optional
309+ If True, use the cached file if it exists. If False, download the
310+ file from the CDMS server and save it to the cache if
311+ ``write_new_species_cache`` is set.
312+ write_new_species_cache : bool, optional
313+ *Overrides ``use_cached=True``*.
314+ If True, write the species data table files to the CDMS data
315+ directory. Use this option if you need to update the index from
316+ CDMS; this should be set to False for testing.
307317
308318 Returns
309319 -------
@@ -316,7 +326,7 @@ def get_species_table(self, *, catfile='partfunc.cat', use_cached=True,
316326
317327 """
318328
319- if use_cached :
329+ if use_cached and not write_new_species_cache :
320330 try :
321331 result = ascii .read (data_path (catfile ), format = 'fixed_width' , delimiter = '|' )
322332 result2 = ascii .read (data_path (catfile2 ), format = 'fixed_width' , delimiter = '|' )
@@ -332,8 +342,9 @@ def get_species_table(self, *, catfile='partfunc.cat', use_cached=True,
332342 else :
333343 result = retrieve_catfile (catfile_url )
334344 result2 = retrieve_catfile2 (catfile_url2 )
335- result .write (data_path (catfile ), format = 'ascii.fixed_width' , delimiter = '|' , overwrite = True )
336- result2 .write (data_path (catfile2 ), format = 'ascii.fixed_width' , delimiter = '|' , overwrite = True )
345+ if write_new_species_cache :
346+ result .write (data_path (catfile ), format = 'ascii.fixed_width' , delimiter = '|' , overwrite = True )
347+ result2 .write (data_path (catfile2 ), format = 'ascii.fixed_width' , delimiter = '|' , overwrite = True )
337348
338349 merged = table .join (result , result2 , keys = ['tag' ])
339350 if not all (merged ['#lines' ] == merged ['# lines' ]):
0 commit comments