Commit 42dd4f83 authored by Yannick Roehlly's avatar Yannick Roehlly

Save M2005 spec_table to a file

Instead of putting the M2005 spec_table in the database, save it to
a file with This is necessary for the high resolution
models that don't fit into the database.
parent 1280b243
......@@ -83,7 +83,6 @@ class _M2005(BASE):
time_grid = Column(PickleType)
wavelength_grid = Column(PickleType)
info_table = Column(PickleType)
spec_table = Column(PickleType)
def __init__(self, ssp):
self.imf = ssp.imf
......@@ -91,7 +90,6 @@ class _M2005(BASE):
self.time_grid = ssp.time_grid
self.wavelength_grid = ssp.wavelength_grid
self.info_table = ssp.info_table
self.spec_table = ssp.spec_table
class _BC03(BASE):
......@@ -329,6 +327,10 @@ class Database(object):
# Save the spec_table to a file
filename = "m2005_%s_%s.npy" % (ssp.imf, ssp.metallicity)
filepath = pkg_resources.resource_filename(__name__, filename), ssp_m2005.spec_table)
except exc.IntegrityError:
raise DatabaseInsertError('The SSP is already in the base.')
......@@ -362,9 +364,13 @@ class Database(object):
.filter(_M2005.metallicity == metallicity)\
if result:
# Load the spec_table from file
filename = "m2005_%s_%s.npy" % (result.imf, result.metallicity)
filepath = pkg_resources.resource_filename(__name__, filename)
spec_table = np.load(filepath)
return M2005(result.imf, result.metallicity, result.time_grid,
result.wavelength_grid, result.info_table,
raise DatabaseLookupError(
"The M2005 SSP for imf <{0}> and metallicity <{1}> is not in "
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment