Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gbrammer/eazy-py
Browse files Browse the repository at this point in the history
  • Loading branch information
gbrammer committed Jun 26, 2024
2 parents a8744b1 + 4bca169 commit e524d3f
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
22 changes: 11 additions & 11 deletions eazy/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def __init__(self, name=None, wave=None, throughput=None, bp=None, photon_counte

# pysynphot Bandpass
if bp is not None:
self.wave = np.cast[np.double](bp.wave)
self._throughput = np.cast[np.double](bp.throughput)
self.wave = np.asarray(bp.wave, dtype=np.double)
self._throughput = np.asarray(bp.throughput, dtype=np.double)
self.name = bp.name

# Set throughput accounting for photon_counter
Expand Down Expand Up @@ -291,30 +291,30 @@ def __init__(self, file='FILTER.RES.latest', path='./'):
if len(wave) > 0:
# Make filter from lines already read in
new_filter = FilterDefinition(name=header,
wave=np.cast[float](wave),
throughput=np.cast[float](trans))
wave=np.asarray(wave,dtype=float),
throughput=np.asarray(trans,dtype=float))
# new_filter.name = header
# new_filter.wave = np.cast[float](wave)
# new_filter.throughput = np.cast[float](trans)
# new_filter.wave = np.asarray(wave,dtype=float)
# new_filter.throughput = np.asarray(trans,dtype=float)
filters.append(new_filter)

# Initialize filter
header = ' '.join(line.split()[1:])
wave = []
trans = []
else:
lspl = np.cast[float](line.split())
lspl = np.asarray(line.split(),dtype=float)
wave.append(lspl[1])
trans.append(lspl[2])

# last one
# new_filter = FilterDefinition()
# new_filter.name = header
# new_filter.wave = np.cast[float](wave)
# new_filter.throughput = np.cast[float](trans)
# new_filter.wave = np.asarray(wave,dtype=float)
# new_filter.throughput = np.asarray(trans,dtype=float)
new_filter = FilterDefinition(name=header,
wave=np.cast[float](wave),
throughput=np.cast[float](trans))
wave=np.asarray(wave,dtype=float),
throughput=np.asarray(trans,dtype=float))

filters.append(new_filter)

Expand Down
8 changes: 4 additions & 4 deletions eazy/photoz.py
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ def read_prior(zgrid=None, prior_file='templates/prior_F160W_TAO.dat', prior_flo
prior_raw = np.loadtxt(prior_file)
prior_header = open(prior_file).readline()

prior_mags = np.cast[float](prior_header.split()[2:])
prior_mags = np.asarray(prior_header.split()[2:],dtype=float)
NZ = len(zgrid)
prior_data = np.zeros((NZ, len(prior_mags)))

Expand Down Expand Up @@ -1290,7 +1290,7 @@ def set_prior(self, verbose=True):
# prior_raw = np.loadtxt(self.param['PRIOR_FILE'])
# prior_header = open(self.param['PRIOR_FILE']).readline()
#
# self.prior_mags = np.cast[float](prior_header.split()[2:])
# self.prior_mags = np.asarray(prior_header.split()[2:],dtype=float)
# self.prior_data = np.zeros((self.NZ, len(self.prior_mags)))
#
# for i in range(self.prior_data.shape[1]):
Expand Down Expand Up @@ -5212,8 +5212,8 @@ def apply_spatial_offset(self, f_ix, bin2d, xycols=None):
ex = np.arange(nx)
ey = np.arange(ny)

ix = np.cast[int](np.interp(xc, bin2d.x_edge, ex))
iy = np.cast[int](np.interp(yc, bin2d.y_edge, ey))
ix = np.asarray(np.interp(xc, bin2d.x_edge, ex),dtype=int)
iy = np.asarray(np.interp(yc, bin2d.y_edge, ey),dtype=int)

corr = bin2d.statistic[ix, iy]
corr[~np.isfinite(corr)] = 1
Expand Down
2 changes: 1 addition & 1 deletion eazy/sps.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ def izmet(self):
NZ = len(self.zlegend)
logzsol = self.params['logzsol']
zi = np.interp(logzsol, np.log10(self.zlegend/0.019), np.arange(NZ))
return np.clip(np.cast[int](np.round(zi)), 0, NZ-1)
return np.clip(np.asarray(np.round(zi),dtype=int), 0, NZ-1)

@property
def fsps_ages(self):
Expand Down
4 changes: 2 additions & 2 deletions eazy/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,8 @@ def __init__(self, file=None, name=None, arrays=None, sp=None, meta={}, to_angst

if sp is not None:
# Prospector
self.wave = np.cast[float](sp.wave)
self.flux = np.cast[float](sp.flux)
self.wave = np.asarray(sp.wave,dtype=float)
self.flux = np.asarray(sp.flux,dtype=float)
# already fnu
self.flux *= utils.CLIGHT*1.e10 / self.wave**2

Expand Down
4 changes: 2 additions & 2 deletions eazy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1138,8 +1138,8 @@ def draw_random(self, N=10):
Draw random sets of parameters from the chain
"""
#ok_walk = self.sampler.acceptance_fraction > min_acceptance
iwalk = np.cast[int](np.random.rand(N)*self.nwalkers)
istep = self.nburn + np.cast[int](np.random.rand(N)*(self.nstep-self.nburn))
iwalk = np.asarray(np.random.rand(N)*self.nwalkers,dtype=int)
istep = self.nburn + np.asarray(np.random.rand(N)*(self.nstep-self.nburn),dtype=int)
draw = self.chain[iwalk, istep, :]
return draw

Expand Down
2 changes: 1 addition & 1 deletion eazy/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ def parse_id_input(id_input):
if len(inp_split) == 1:
return int(inp_split[0]), None

ra, dec = np.cast[float](inp_split)
ra, dec = np.asarray(inp_split, dtype=float)

cosd = np.cos(self.df['dec']/180*np.pi)
dx = (self.df['ra'] - ra)*cosd
Expand Down
2 changes: 1 addition & 1 deletion scripts/nmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def build_matrices():

##############
## Build NMF matrix
izbest = np.cast[int](np.round(np.interp(self.zbest, self.tempfilt.zgrid, np.arange(self.NZ))))
izbest = np.asarray(np.round(np.interp(self.zbest, self.tempfilt.zgrid, np.arange(self.NZ))),dtype=int)

NOBJ = len(idx)
data = np.zeros((NOBJ, self.NFILT, self.NZ))
Expand Down
8 changes: 4 additions & 4 deletions scripts/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def go():
Lj = Ltot[:,2]

lines = open('templates/uvista_nmf/spectra_kc13_12_tweak.param').readlines()
MLv_template = np.cast[float]([line.split()[3] for line in lines if ('MLv' in line) & (line.startswith('# '))])
SFRv_template = np.cast[float]([line.split()[5] for line in lines if ('MLv' in line) & (line.startswith('# '))])
MLv_template = np.asarray([line.split()[3] for line in lines if ('MLv' in line) & (line.startswith('# '))],dtype=float)
SFRv_template = np.asarray([line.split()[5] for line in lines if ('MLv' in line) & (line.startswith('# '))],dtype=float)

irest = 1 # V
#irest = 2 # J
Expand All @@ -103,8 +103,8 @@ def go():

# These are masses
lines = open(self.param['TEMPLATES_FILE']).readlines()
MLv_template = np.cast[float]([line.split()[4] for line in lines if line.startswith('# ')])
SFRv_template = np.cast[float]([line.split()[5] for line in lines if line.startswith('# ')])
MLv_template = np.asarray([line.split()[4] for line in lines if line.startswith('# ')],dtype=float)
SFRv_template = np.asarray([line.split()[5] for line in lines if line.startswith('# ')],dtype=float)

MLv_template /= Lvt
SFRv_template /= Lvt
Expand Down

0 comments on commit e524d3f

Please sign in to comment.