This guide is for developers who want to understand, modify, or extend the Community GSF Toolkit.
mb-community-toolkit/
├── tools/ # Command-line tools
│ ├── gsf-info.py
│ ├── gsf-verify.py
│ ├── gsf-repair.py
│ └── gsf-timecheck.py
├── profiles/ # JSON validation profiles
│ ├── xyz.json
│ ├── singlebeam.json
│ └── multibeam.json
├── docs/ # Documentation
├── data/ # Sample/test data files
└── requirements.txt # Python dependencies
- Python 3.7+
- pip
- Git
-
Clone the repository:
git clone https://github.com/your-org/community-gsf-toolkit.git cd community-gsf-toolkit -
Install dependencies:
pip install -r requirements.txt
No git submodules are required; the reader implementation is bundled in
readers/base. -
(Optional) Install in development mode if creating a package structure
- GSF Reader: Uses the bundled
readers/baseimplementation to read GSF data - Profile System: JSON-based validation profiles define required records and subrecords
- Command Tools: Standalone scripts for specific operations
readers/base: bundled GSF reader implementationnumpy: Numerical operations for array processing
Each script is a standalone command-line tool:
gsf-info.py: File inspection and information extractiongsf-verify.py: Profile-based validationgsf-repair.py: File repair and compliance fixinggsf-timecheck.py: Time ordering verification
JSON files defining validation rules:
- Record types and IDs
- Required header fields
- Required subrecords
- Constraints and encoding recommendations
- Create a new script in
tools/ - Follow existing patterns for:
- Argument parsing
- File I/O
- Error handling
- Add documentation
- Update this guide
- Create JSON file in
profiles/ - Define required records and subrecords
- Specify constraints and encoding recommendations
- Test with
gsf-verify.py
Reading GSF Files:
from readers.base import GSFREADER, SWATH_BATHYMETRY
reader = GSFREADER("file.gsf")
while reader.moreData():
nbytes, recid, dg = reader.readDatagram()
# Process datagramProfile Loading:
import json
with open("profile.json", 'r') as f:
profile = json.load(f)['profile']Install test dependencies:
pip install -e ".[dev]"Run all tests:
pytestRun specific test file:
pytest tests/test_utils.pyRun with verbose output:
pytest -vThe tests/ directory contains:
test_utils.py- Tests for utility functionstest_gsf_verify.py- Tests for profile loading and validationtest_gsf_repair.py- Tests for repair functionalityconftest.py- Shared pytest fixtures
- Create test files following the pattern
test_*.py - Use pytest fixtures from
conftest.pywhen available - Follow existing test structure and naming conventions
- See
tests/README.mdfor more details
Test with sample GSF files in data/ directory:
python tools/gsf-verify.py profiles/xyz.json data/sample.gsf- Use provided sample files
- Ensure no sensitive data in test files
- Add new test cases as needed
- Follow PEP 8
- Use type hints where appropriate
- Add docstrings to functions
- Keep functions focused and modular
(To be documented when package structure is established)
- Import errors: Run tools from the repository root so
readers/baseis importable - File format errors: Verify GSF file integrity
- Profile validation: Check JSON syntax and structure
- Use
--pingHeaderVerboseingsf-info.pyfor detailed inspection - Check raw file structure with hex dump if needed
- Validate profile JSON syntax separately
See CONTRIBUTING.md for contribution guidelines.
- GSF Format Specification (to be linked)
- pygsf Documentation (to be linked)
- Community Resources (to be established)
Note: This is an initial placeholder. Detailed developer documentation including API references, architecture diagrams, and advanced topics will be added as the project evolves.