@@ -24,11 +24,14 @@ Read a SigMF Recording
2424
2525 import sigmf
2626 handle = sigmf.fromfile(" example.sigmf" )
27- handle.read_samples() # returns all timeseries data
27+ # reading data
28+ handle.read_samples() # read all timeseries data
29+ handle[10 :50 ] # read memory slice of samples 10 through 50
30+ # accessing metadata
31+ handle.sample_rate # get sample rate attribute
2832 handle.get_global_info() # returns 'global' dictionary
2933 handle.get_captures() # returns list of 'captures' dictionaries
3034 handle.get_annotations() # returns list of all annotations
31- handle[10 :50 ] # return memory slice of samples 10 through 50
3235
3336-----------------------------------
3437Verify SigMF Integrity & Compliance
@@ -52,16 +55,16 @@ Save a Numpy array as a SigMF Recording
5255 data = np.zeros(1024 , dtype = np.complex64)
5356
5457 # write those samples to file in cf32_le
55- data.tofile(' example_cf32 .sigmf-data' )
58+ data.tofile(" example .sigmf-data" )
5659
5760 # create the metadata
5861 meta = SigMFFile(
59- data_file = ' example_cf32 .sigmf-data' , # extension is optional
62+ data_file = " example .sigmf-data" , # extension is optional
6063 global_info = {
61- SigMFFile.DATATYPE_KEY : get_data_type_str(data), # in this case, ' cf32_le'
64+ SigMFFile.DATATYPE_KEY : get_data_type_str(data), # in this case, " cf32_le"
6265 SigMFFile.SAMPLE_RATE_KEY : 48000 ,
63- SigMFFile.AUTHOR_KEY : ' jane.doe@domain.org' ,
64- SigMFFile.DESCRIPTION_KEY : ' All zero complex float32 example file.' ,
66+ SigMFFile.AUTHOR_KEY : " jane.doe@domain.org" ,
67+ SigMFFile.DESCRIPTION_KEY : " All zero complex float32 example file." ,
6568 }
6669 )
6770
@@ -75,8 +78,40 @@ Save a Numpy array as a SigMF Recording
7578 meta.add_annotation(100 , 200 , metadata = {
7679 SigMFFile.FLO_KEY : 914995000.0 ,
7780 SigMFFile.FHI_KEY : 915005000.0 ,
78- SigMFFile.COMMENT_KEY : ' example annotation' ,
81+ SigMFFile.COMMENT_KEY : " example annotation" ,
7982 })
8083
81- # check for mistakes & write to disk
82- meta.tofile(' example_cf32.sigmf-meta' ) # extension is optional
84+ # validate & write to disk
85+ meta.tofile(" example.sigmf-meta" ) # extension is optional
86+
87+ ----------------------------------
88+ Attribute Access for Global Fields
89+ ----------------------------------
90+
91+ SigMF-Python provides convenient attribute read/write access for core global
92+ metadata fields, allowing you use simple dot notation alongside the traditional
93+ method-based approach.
94+
95+ .. code-block :: python
96+
97+ import sigmf
98+
99+ # read some recording
100+ meta = sigmf.SigMFFile(" sigmf_logo" )
101+
102+ # read global metadata
103+ print (f " Sample rate: { meta.sample_rate} " )
104+ print (f " License: { meta.license} " )
105+
106+ # set global metadata
107+ meta.description = " Updated description via attribute access"
108+ meta.author = " jane.doe@domain.org"
109+
110+ # validate & write changes to disk
111+ meta.tofile(" sigmf_logo_updated" )
112+
113+ .. note ::
114+
115+ Only core **global ** fields support attribute access. Capture and annotation
116+ fields must still be accessed using the traditional ``get_captures() `` and
117+ ``get_annotations() `` methods.
0 commit comments