Skip to content

Commit

Permalink
Fixed np.float issue by changing to np.float64
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Clark committed Jul 13, 2023
1 parent 9334d22 commit 763e4c3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion pyCHX/Create_Report.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class create_pdf_report( object ):

def __init__( self, data_dir, uid, out_dir=None, filename=None, load=True, user=None,
report_type='saxs',md=None, res_h5_filename=None ):
from datetime import datetime
self.data_dir = data_dir
self.uid = uid
self.md = md
Expand Down Expand Up @@ -1638,7 +1639,7 @@ def recursively_save_dict_contents_to_group( h5file, path, dic):
if not isinstance(key, str):
raise ValueError("dict keys must be strings to save to hdf5")
# save strings, numpy.int64, and numpy.float64 types
if isinstance(item, (np.int64, np.float64, str, np.float, float, np.float32,int)):
if isinstance(item, (np.int64, np.float64, str, float, np.float32,int)): # removed depreciated np.float LW @06/11/2023
#print( 'here' )
h5file[path + key] = item
if not h5file[path + key].value == item:
Expand Down
8 changes: 4 additions & 4 deletions pyCHX/chx_compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def read_compressed_eigerdata( mask, filename, beg, end,
CAL = True
if CAL:
FD = Multifile( filename, beg, end)
imgsum = np.zeros( FD.end- FD.beg, dtype= np.float )
avg_img = np.zeros( [FD.md['ncols'], FD.md['nrows'] ] , dtype= np.float )
imgsum = np.zeros( FD.end- FD.beg, dtype= np.float64 )
avg_img = np.zeros( [FD.md['ncols'], FD.md['nrows'] ] , dtype= np.float64 )
imgsum, bad_frame_list_ = get_each_frame_intensityc( FD, sampling = 1,
bad_pixel_threshold=bad_pixel_threshold, bad_pixel_low_threshold=bad_pixel_low_threshold,
hot_pixel_threshold=hot_pixel_threshold, plot_ = False,
Expand Down Expand Up @@ -345,7 +345,7 @@ def segment_compress_eigerdata( images, mask, md, filename,

Nimg_ = len( images)
M,N = images[0].shape
avg_img = np.zeros( [M,N], dtype= np.float )
avg_img = np.zeros( [M,N], dtype= np.float64 )
Nopix = float( avg_img.size )
n=0
good_count = 0
Expand Down Expand Up @@ -531,7 +531,7 @@ def init_compress_eigerdata( images, mask, md, filename,
fp.write( Header)

Nimg_ = len( images)
avg_img = np.zeros_like( images[0], dtype= np.float )
avg_img = np.zeros_like( images[0], dtype= np.float64 )
Nopix = float( avg_img.size )
n=0
good_count = 0
Expand Down
8 changes: 4 additions & 4 deletions pyCHX/chx_correlationc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,14 +1283,14 @@ def get_data(self ):
Return: 2-D array, shape as (len(images), len(pixellist))
'''

data_array = np.zeros([ self.length,len(self.pixelist)], dtype=np.float)
data_array = np.zeros([ self.length,len(self.pixelist)], dtype=np.float64) # changed dtype = np.float (depreciated) to dtype = np.float64 LW @06112023
#fra_pix = np.zeros_like( pixelist, dtype=np.float64)
timg = np.zeros( self.FD.md['ncols'] * self.FD.md['nrows'] , dtype=np.int32 )
timg[self.pixelist] = np.arange( 1, len(self.pixelist) + 1 )

if self.norm_inten is not None:
#Mean_Int_Qind = np.array( self.qind.copy(), dtype=np.float)
Mean_Int_Qind = np.ones( len( self.qind), dtype = np.float)
Mean_Int_Qind = np.ones( len( self.qind), dtype = np.float64) # changed dtype = np.float (depreciated) to dtype = np.float64 LW @06112023
noqs = len(np.unique( self.qind ))
nopr = np.bincount(self.qind-1)
noprs = np.concatenate( [ np.array([0]), np.cumsum(nopr) ] )
Expand Down Expand Up @@ -1393,14 +1393,14 @@ def get_data(self ):
Return: 2-D array, shape as (len(images), len(pixellist))
'''

data_array = np.zeros([ self.length,len(self.pixelist)], dtype=np.float)
data_array = np.zeros([ self.length,len(self.pixelist)], dtype=np.float64)
#fra_pix = np.zeros_like( pixelist, dtype=np.float64)
timg = np.zeros( self.FD.md['ncols'] * self.FD.md['nrows'] , dtype=np.int32 )
timg[self.pixelist] = np.arange( 1, len(self.pixelist) + 1 )

if self.mean_int_sets is not None:
#Mean_Int_Qind = np.array( self.qind.copy(), dtype=np.float)
Mean_Int_Qind = np.ones( len( self.qind), dtype = np.float)
Mean_Int_Qind = np.ones( len( self.qind), dtype = np.float64)
noqs = len(np.unique( self.qind ))
nopr = np.bincount(self.qind-1)
noprs = np.concatenate( [ np.array([0]), np.cumsum(nopr) ] )
Expand Down
4 changes: 2 additions & 2 deletions pyCHX/xpcs_timepixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def init_compress_timepix_data( pos, t, binstep, filename, mask=None,
css = np.cumsum(cs)
imgsum = np.zeros( N )
good_count = 0
avg_img = np.zeros( [ md['sy'], md['sx'] ], dtype= np.float )
avg_img = np.zeros( [ md['sy'], md['sx'] ], dtype= np.float64 ) # changed depreciated np.float to np.float64 LW @06/11/2023

for i in tqdm( range(0,N) ):
if i ==0:
Expand Down Expand Up @@ -337,7 +337,7 @@ def init_compress_timepix_data_light_duty( pos, t, binstep, filename, mask=None
imgsum = np.zeros( N-1 )
print('There are %s frames to be compressed...'%(N-1))
good_count = 0
avg_img = np.zeros( [ md['sy'], md['sx'] ], dtype= np.float )
avg_img = np.zeros( [ md['sy'], md['sx'] ], dtype= np.float64 ) # changed depreciated np.float to np.float64 LW @06/11/2023
for i in tqdm( range(N-1) ):
ind1 = np.argmin( np.abs( tx[i] - t) )
ind2 = np.argmin( np.abs( tx[i+1] - t ) )
Expand Down

0 comments on commit 763e4c3

Please sign in to comment.