Skip to content

Commit

Permalink
Merge pull request #144 from revoltek/RAP-313_numpy-fixes
Browse files Browse the repository at this point in the history
Type fixes for NumPy 1.24
  • Loading branch information
gmloose authored Feb 10, 2023
2 parents 6d5ce49 + 5bf7c28 commit 64e4ad4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions bin/H5parm2parmdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,13 +549,13 @@ def makeTECparmdb(H, solset, TECsolTab, timewidths, freq, freqwidth):
# check whether this is clock or tec; if so, reshape properly to account for all freqs in the parmdb
# anyway these tables are freq-indep
if solType == "Clock":# or solType == "TEC" or solType == "RotationMeasure":
# find freq-dimensionality
# find freq-dimensionality
nfreq = freqs.shape[0]
#print val.shape
# reshape such that all freq arrays are filled properly
val = np.tile( val, np.append([nfreq], np.ones(len(val.shape),dtype=np.int) ) )
val = np.tile( val, np.append([nfreq], np.ones(len(val.shape),dtype=int) ) )
#print val.shape
weights = np.tile( weights, np.append([nfreq], np.ones(len(weights.shape),dtype=np.int) ) )
weights = np.tile( weights, np.append([nfreq], np.ones(len(weights.shape),dtype=int) ) )

flags = np.zeros(shape=weights.shape, dtype=bool)
flags[np.where(weights == 0)] = True
Expand Down
2 changes: 1 addition & 1 deletion losoto/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

# Version number
__version__ = '2.4'
__version__ = '2.4.1'

# H5parm version
__h5parmVersion__ = '1.0'
8 changes: 4 additions & 4 deletions losoto/operations/_fitClockTEC.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def getClockTECFitStation(
except np.linalg.LinAlgError:
logging.debug("Init parmaters failed t=%d st=%s flags=%d" % (itm,stationname,datatmpist.count()) + str(sol[:]))
sol[:] = [-10.,]*sol.shape[0]

#logging.debug("Getting init par for station %d:%s "%(itm,stationname)+str(sol))

#now do the real fitting
Expand All @@ -527,7 +527,7 @@ def getClockTECFitStation(
except np.linalg.LinAlgError:
logging.debug("Fit failed t=%d st=%s flags=%d" % (itm,stationname,datatmpist.count()) + str(sol[:]))
sol[:] = [-10.,]*sol.shape[0]

# calculate chi2 per station

residual = data[itm] - np.dot(A, sol)
Expand Down Expand Up @@ -632,7 +632,7 @@ def correctWraps(
lonlat = np.concatenate((lons, lats)).reshape((2, ) + lons.shape)
# refine (is it needed/helpful for LBA? the offsets seem to make sense for LBA)
myselect=np.sqrt(np.sum(lonlat**2,axis=0))>0.5


for nr_iter in range(2):
# recreate best TEC at the moment
Expand Down Expand Up @@ -740,7 +740,7 @@ def doFit(
indices = np.arange(nF)

if flagBadChannels:
mymask=np.zeros((nF), dtype=np.bool)
mymask=np.zeros((nF), dtype=bool)
for nr_iter in range(2):
rms = np.ma.std(np.ma.std(refdata, axis=0), axis=1)
freqselect = rms < flagcut * np.average(rms)
Expand Down
8 changes: 4 additions & 4 deletions losoto/operations/flagextend.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ def _flag(weights, coord, axesToExt, selection, percent=50, size=[0], maxCycles=
Flag data if surreounded by other flagged data
weights = the weights to convert into flags
percent = percent of surrounding flagged point to extend the flag
return: flags array and final rms
"""
def extendFlag(flags, percent):
#flags = flags.astype(np.int)
#flags = flags.astype(int)
if float(np.sum( flags ))/len(flags) > percent/100.:
return 1
else:
Expand Down Expand Up @@ -59,8 +59,8 @@ def percentFlagged(w):
% (removeKeys(coord, axesToExt), initPercent, percentFlagged(weights)))

outQueue.put([weights, selection])


def run( soltab, axesToExt, size, percent=50., maxCycles=3, ncpu=0 ):
"""
This operation for LoSoTo implement a extend flag procedure
Expand Down
4 changes: 2 additions & 2 deletions losoto/operations/prefactor_bandpass.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def _savitzky_golay(y, window_size, order, deriv=0, rate=1):
from math import factorial

try:
window_size = np.abs(np.int(window_size))
order = np.abs(np.int(order))
window_size = np.abs(int(window_size))
order = np.abs(int(order))
except ValueError as msg:
raise ValueError("window_size and order have to be of type int")
if window_size % 2 != 1 or window_size < 1:
Expand Down

0 comments on commit 64e4ad4

Please sign in to comment.