File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
src/binding/python/openpmd_api Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 11import openpmd_api as pmd
2- import openpmd_api .scipp as pmdsc
3- import scipp as sc
42
53
64def main ():
75 series = pmd .Series ("../samples/git-sample/data%T.h5" , pmd .Access .read_only )
86
7+ try :
8+ scipp_loader = series .to_scipp ()
9+ import plopp
10+ except ImportError :
11+ print ("Need to install scipp and plopp to run this example." )
12+ return
13+ import openpmd_api .scipp as pmdsc
14+ import scipp as sc
915 time = 65 * sc .Unit ("fs" )
10- scipp_loader = series . to_scipp ()
16+
1117 print (scipp_loader .iterations )
1218 Ex = scipp_loader .get_field ("E" , "x" , time = time )
1319 print (Ex )
Original file line number Diff line number Diff line change 11def series_to_scipp (series ):
22
3- import scipp
3+ # lazy import
4+ try :
5+ import scipp
6+ found_scipp = True
7+ except ImportError as original_error :
8+ found_scipp = False
9+ original_error_string = f"{ original_error } "
10+
11+ if not found_scipp :
12+ raise ImportError (f"Scipp NOT found. Install scipp for Scipp support. Original error: { original_error_string } " )
413
514 from .scipp import DataLoader
615
You can’t perform that action at this time.
0 commit comments