@@ -294,7 +294,8 @@ def _parse_result(self, response, *, verbose=False):
294
294
295
295
def get_species_table (self , * , catfile = 'partfunc.cat' , use_cached = True ,
296
296
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 ):
298
299
"""
299
300
A directory of the catalog is found in a file called 'catdir.cat.'
300
301
@@ -304,6 +305,15 @@ def get_species_table(self, *, catfile='partfunc.cat', use_cached=True,
304
305
----------
305
306
catfile : str, name of file, default 'catdir.cat'
306
307
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.
307
317
308
318
Returns
309
319
-------
@@ -316,7 +326,7 @@ def get_species_table(self, *, catfile='partfunc.cat', use_cached=True,
316
326
317
327
"""
318
328
319
- if use_cached :
329
+ if use_cached and not write_new_species_cache :
320
330
try :
321
331
result = ascii .read (data_path (catfile ), format = 'fixed_width' , delimiter = '|' )
322
332
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,
332
342
else :
333
343
result = retrieve_catfile (catfile_url )
334
344
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 )
337
348
338
349
merged = table .join (result , result2 , keys = ['tag' ])
339
350
if not all (merged ['#lines' ] == merged ['# lines' ]):
0 commit comments