2727- Load data from an image file (tif, png, jpg) or a hdf file.
2828- Save a 2D array as a tif/png/jpg image or a 2D, 3D array to a hdf file.
2929- Save a plot of data points to an image.
30- - Save/load metadata to/from a text file.
30+ - Save/load metadata to/from a text/json file.
3131- Save/load python list
3232
3333"""
@@ -453,23 +453,23 @@ def save_image(file_path, mat, overwrite=True):
453453def save_plot_image (file_path , list_lines , height , width , overwrite = True ,
454454 dpi = 100 ):
455455 """
456- Save the plot of dot-centroids to an image. Useful to check if the dots
457- are arranged properly where dots on the same line having the same color.
456+ Save the plot of points to an image. Useful to check if the points are
457+ arranged properly where points on the same line having the same color.
458458
459459 Parameters
460460 ----------
461461 file_path : str
462462 Output file path.
463463 list_lines : list of array_like
464- List of 2D arrays. Each list is the coordinates of dots on a line.
464+ List of 2D arrays. Each list is the coordinates of points on a line.
465465 height : int
466466 Height of the image.
467467 width : int
468468 Width of the image.
469469 overwrite : bool, optional
470470 Overwrite the existing file if True.
471471 dpi : int, optional
472- The resolution in dots per inch.
472+ The resolution in points per inch.
473473
474474 Returns
475475 -------
@@ -529,15 +529,15 @@ def save_residual_plot(file_path, list_data, height, width, overwrite=True,
529529 file_path : str
530530 Output file path.
531531 list_data : array_like
532- 2D array. List of [residual, radius] of each dot .
532+ 2D array. List of [residual, radius] of each point .
533533 height : int
534534 Height of the output image.
535535 width : int
536536 Width of the output image.
537537 overwrite : bool, optional
538538 Overwrite the existing file if True.
539539 dpi : int, optional
540- The resolution in dots per inch.
540+ The resolution in points per inch.
541541 font_family : str, optional
542542 To set the font family
543543
@@ -659,8 +659,8 @@ def open_hdf_stream(file_path, data_shape, key_path='entry/data',
659659def save_plot_points (file_path , list_points , height , width , overwrite = True ,
660660 dpi = 100 , marker = "o" , color = "blue" ):
661661 """
662- Save the plot of dot-centroids to an image. Useful to check if the dots
663- are arranged properly where dots on the same line having the same color.
662+ Save the plot of points to an image. Useful to check if the points are
663+ arranged properly where points on the same line having the same color.
664664
665665 Parameters
666666 ----------
@@ -675,7 +675,7 @@ def save_plot_points(file_path, list_points, height, width, overwrite=True,
675675 overwrite : bool, optional
676676 Overwrite the existing file if True.
677677 dpi : int, optional
678- The resolution in dots per inch.
678+ The resolution in points per inch.
679679 marker : str
680680 Plot marker. Full list is at:
681681 https://matplotlib.org/stable/api/markers_api.html
@@ -777,11 +777,10 @@ def load_metadata_txt(file_path):
777777
778778
779779def __numpy_encoder (obj ):
780- if isinstance (obj , (np .int_ , np .intc , np .intp , np .int8 ,
781- np .int16 , np .int32 , np .int64 , np .uint8 ,
782- np .uint16 , np .uint32 , np .uint64 )):
780+ if isinstance (obj , (np .int8 , np .int16 , np .int32 , np .int64 ,
781+ np .uint8 , np .uint16 , np .uint32 , np .uint64 )):
783782 return int (obj )
784- elif isinstance (obj , (np .float_ , np . float16 , np .float32 , np .float64 )):
783+ elif isinstance (obj , (np .float16 , np .float32 , np .float64 )):
785784 return float (obj )
786785 elif isinstance (obj , (np .ndarray ,)):
787786 return obj .tolist ()
@@ -895,3 +894,24 @@ def save_python_list(file_path, python_list, overwrite=True):
895894 with open (file_path , 'wb' ) as f :
896895 pickle .dump (python_list , f )
897896 return file_path
897+
898+
899+ def find_file (path ):
900+ """
901+ Search file
902+
903+ Parameters
904+ ----------
905+ path : str
906+ Path and pattern to find files.
907+
908+ Returns
909+ -------
910+ str or list of str
911+ List of files.
912+ """
913+ path = __correct_path (path )
914+ file_paths = list (path .parent .glob (path .name ))
915+ if not file_paths :
916+ raise FileNotFoundError (f"No files found matching: { path } " )
917+ return sorted ([file .as_posix () for file in file_paths ])
0 commit comments