-
Notifications
You must be signed in to change notification settings - Fork 29
Add SKILL.md for AI agents #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
haroldfabla2-hue
wants to merge
1
commit into
sigmf:main
Choose a base branch
from
haroldfabla2-hue:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| # SKILL.md - SigMF Python | ||
|
|
||
| ## Description | ||
| SigMF Python library skill for AI agents to work with Signal Metadata Format recordings. This skill enables AI agents to read, write, and process RF time series data using the SigMF standard. | ||
|
|
||
| ## Use Cases | ||
| - Reading and analyzing RF signal recordings | ||
| - Converting between different RF data formats | ||
| - Processing and validating SigMF metadata | ||
| - Creating automated RF signal analysis workflows | ||
| - Generating reports from RF signal data | ||
|
|
||
| ## Setup | ||
| ```python | ||
| import sigmf | ||
| ``` | ||
|
|
||
| ## Core Operations | ||
|
|
||
| ### Read SigMF Recordings | ||
| ```python | ||
| # Read SigMF recording | ||
| meta = sigmf.fromfile("recording.sigmf-meta") | ||
| samples = meta[0:1024] # Get first 1024 samples | ||
| sample_rate = meta.sample_rate # Get sample rate | ||
|
|
||
| # Read other formats as SigMF | ||
| meta = sigmf.fromfile("recording.wav") # WAV files | ||
| meta = sigmf.fromfile("recording.cdif") # BLUE/Platinum files | ||
| meta = sigmf.fromfile("recording.xml") # Signal Hound Spike files | ||
| ``` | ||
|
|
||
| ### Signal Analysis | ||
| ```python | ||
| # Basic signal properties | ||
| sample_rate = meta.sample_rate | ||
| center_freq = meta.core:frequency | ||
| datetime = meta.core:datetime | ||
| annotation = meta.annotations[0] if meta.annotations else None | ||
|
|
||
| # Process signal data | ||
| samples = meta.read_samples(start_index=0, count=1024) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think slicing the signal is simpler. Like |
||
| ``` | ||
|
|
||
| ### Format Conversion | ||
| ```python | ||
| # Convert between RF formats | ||
| # WAV to SigMF | ||
| sigmf.fromfile("input.wav").tofile("output.sigmf-meta") | ||
|
|
||
| # CDIF to SigMF | ||
| sigmf.fromfile("input.cdif").tofile("output.sigmf-meta") | ||
|
|
||
| # Signal Hound to SigMF | ||
| sigmf.fromfile("input.xml").tofile("output.sigmf-meta") | ||
| ``` | ||
|
|
||
| ### Metadata Operations | ||
| ```python | ||
| # Access metadata | ||
| global_fields = meta.global_fields | ||
| global_keys = list(meta.global_fields.keys()) | ||
|
|
||
| # Validate SigMF files | ||
| sigmf.validate.validate_file("recording.sigmf-meta") | ||
| ``` | ||
|
|
||
| ## Advanced Features | ||
|
|
||
| ### Signal Generation | ||
| ```python | ||
| # Generate test signals | ||
| from sigmf import siggen | ||
|
|
||
| # Create sine wave | ||
| samples = siggen.sinewave(frequency=1e6, sample_rate=10e6, duration=1.0) | ||
|
|
||
| # Create noise | ||
| samples = siggen.white_noise(sample_rate=10e6, num_samples=1024) | ||
| ``` | ||
|
|
||
| ### Archive Operations | ||
| ```python | ||
| # Handle SigMF archives | ||
| archive = sigmf.Archive("archive.sigmf-meta") | ||
| archive.add_file("recording1.sigmf-meta") | ||
| archive.add_file("recording2.sigmf-meta") | ||
| archive.write("combined.sigmf-meta") | ||
| ``` | ||
|
|
||
| ## Best Practices | ||
| 1. Always validate SigMF files before processing | ||
| 2. Use appropriate sample rates for your analysis | ||
| 3. Include proper metadata annotations | ||
| 4. Handle large files in chunks when memory is constrained | ||
| 5. Use proper units for frequency (Hz) and time (seconds) | ||
|
|
||
| ## Common Tasks | ||
|
|
||
| ### RF Signal Analysis Workflow | ||
| ```python | ||
| def analyze_rf_signal(file_path): | ||
| """Complete RF signal analysis workflow""" | ||
| # Load signal | ||
| meta = sigmf.fromfile(file_path) | ||
|
|
||
| # Get basic properties | ||
| sample_rate = meta.sample_rate | ||
| center_freq = meta.core.get('frequency', 0) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not valid |
||
|
|
||
| # Read samples | ||
| samples = meta.read_samples(count=1024) | ||
|
|
||
| # Basic analysis | ||
| max_amplitude = max(abs(samples)) | ||
| avg_amplitude = sum(abs(samples)) / len(samples) | ||
|
|
||
| return { | ||
| 'sample_rate': sample_rate, | ||
| 'center_frequency': center_freq, | ||
| 'max_amplitude': max_amplitude, | ||
| 'avg_amplitude': avg_amplitude | ||
| } | ||
| ``` | ||
|
|
||
| ### Batch Processing | ||
| ```python | ||
| def batch_convert_rf_files(input_dir, output_dir, input_format='wav'): | ||
| """Convert multiple RF files to SigMF format""" | ||
| import glob | ||
|
|
||
| pattern = f"{input_dir}/*.{input_format}" | ||
| for input_file in glob.glob(pattern): | ||
| output_file = input_file.replace(input_format, 'sigmf-meta') | ||
| meta = sigmf.fromfile(input_file) | ||
| meta.tofile(output_file) | ||
| print(f"Converted {input_file} to {output_file}") | ||
| ``` | ||
|
|
||
| ## Error Handling | ||
| ```python | ||
| try: | ||
| meta = sigmf.fromfile("signal.sigmf-meta") | ||
| samples = meta.read_samples() | ||
| except sigmf.SigMFError as e: | ||
| print(f"SigMF error: {e}") | ||
| except FileNotFoundError: | ||
| print("File not found") | ||
| except Exception as e: | ||
| print(f"Unexpected error: {e}") | ||
| ``` | ||
|
|
||
| ## References | ||
| - [SigMF Specification](https://sigmf.org/) | ||
| - [SigMF Python Documentation](https://sigmf.readthedocs.io/) | ||
| - [Signal Metadata Format](https://github.com/sigmf/SigMF) | ||
|
|
||
| ## Notes | ||
| - Compatible with Python 3.7-3.14 | ||
| - Licensed under GNU Lesser GPL v3 | ||
| - Supports various RF recording formats | ||
| - Includes validation and conversion utilities | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything in here needs to be tested. This is invalid python syntax.
If a file had a center frequency for a capture, you would access it with
meta.get_capture_info(0).get(sigmf.SigMFFile.FREQUENCY_KEY)or maybe there is a simpler way. Capture frequency isn't a required key.