def create_grid(self,abins=None,zbins=None):
if abins is None and zbins is None:
filenames = glob.glob(self.get_dirname()+'/%s_*.dat'%(self._prefix))
data = np.array([self.filename2params(f) for f in filenames])
if not len(data):
msg = "No isochrone files found in: %s"%self.get_dirname()
raise Exception(msg)
arange = np.unique(data[:,0])
zrange = np.unique(data[:,1])
elif abins is not None and zbins is not None:
# Age in units of Gyr
arange = np.linspace(abins[0],abins[1],abins[2]+1)
# Metallicity sampled logarithmically
zrange = np.logspace(np.log10(zbins[0]),np.log10(zbins[1]),zbins[2]+1)
else:
msg = "Must specify both `abins` and `zbins` or neither"
raise Exception(msg)
aa,zz = np.meshgrid(arange,zrange)
return aa.flatten(),zz.flatten()
评论列表
文章目录