Skip to main content

Package SHEF Parser

A python based package to parse SHEF files and optionally load them into various data stores. It also provides functionality for generating SHEF text from various data stores.

Parsing and loading can be performed by using module in python or through command line. Generating SHEF text from a data store is currenly limited to using the module in python.

See User Guide at https://shef-processing.readthedocs.io/en/latest/

See API Documentation at https://hydrologicengineeringcenter.github.io/shef-parser/index.html

Install

pip install shef-parser

Loading via command line

#CWMS CDA loader will load for all offices
shefParser -i input_filename --loader cda[$API_ROOT][$API_KEY]
# optional office scoping for transform lookup
shefParser -i input_filename --loader cda[$API_ROOT][$API_KEY][MVP]
shefParser -i input_filename --loader cda[$API_ROOT][$API_KEY][MVP,LRL,SWG]
#HEC-DSS loader
shefParser -i input_filename --loader dss[<dss_file>][<sensors_file>][<parameters_file>]

Loading via module

#CWMS CDA loader
import os
from shef import shef_parser

cda_url: str = os.getenv("CDA_API_ROOT")
cda_api_key: str = os.getenv("CDA_API_KEY")

shef_parser.parse(
    input_name=input_filename,
    loader_spec=f"cda[{cda_url}][{cda_api_key}]",
)
#HEC-DSS loader
from shef import shef_parser

dss_filename: str = "/path/to/dss_file"
sensors_filename: str = "/path/to/sensors_file"
parameters_filename: str = "/path/to/parameters_file"

shef_parser.parse(
    input_name=input_filename,
    loader_spec=f"dss[{dss_filename}][{sensors_filename}][{parameters_filename}]",
)

Generating SHEF Text

Exporting via command line

#CWMS CDA loader
#et and st can be either ISO date formate 2026-02-01T11:00:00 or use HEC time T, T-1D, T-5Hr, 02Feb2026, ect...)
#either timeseries group ID can be used or the -tsids parameter with a list of timeseries ids ("tsid1,tsid2,...")
shefParser export -a api_root -o office -f filename.shef -st start_time -et end_time -tsg <Timesereis Group ID> 

shefParser export -a api_root -o MVP -f filename.shef -st T-2D -et T -tsg KEYS
#CWMS CDA loader
import os
from datetime import datetime, timedelta
from shef import shef_parser

cda_url: str = os.getenv("CDA_API_ROOT")
office_id: str = os.getenv("CDA_OFFICE_ID")
tsids: list[str] = [
    ...
]

export_file="/path/to/output_file"
shef_parser.export(
            api_root=cda_url,
            office=office_id,
            export_file=export_file,
            timeseries_ids=tsids,
            start_time=datetime.now(),
            end_time=datetime.now() - timedelta(days=1),
        )
#HEC-DSS loader
from datetime import datetime, timedelta
from shef.exporters import DssExporter

dss_filename: str = "/path_to_dss_file"
sensors_filename: str = "/path/to/sensors_file"
parameters_filename: str = "/path/to/parameters_file"
pathnames: list[str] = [
    ...
]

exporter = DssExporter(
    dss_filename,
    sensors_filename,
    parameters_filename
)
exporter.start_time = datetime.now() - timedelta(days=1)
exporter.end_time = datetime.now()
with open("/path/to/output_file", "w") as f:
    exporter.set_output(f)
    for (pathname in pathnames):
        exporter.export(pathname)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shef_parser-1.11.0.tar.gz (75.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shef_parser-1.11.0-py3-none-any.whl (82.5 kB view details)

Uploaded Python 3

File details

Details for the file shef_parser-1.11.0.tar.gz.

File metadata

  • Download URL: shef_parser-1.11.0.tar.gz
  • Upload date:
  • Size: 75.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for shef_parser-1.11.0.tar.gz
Algorithm Hash digest
SHA256 eef004e4850c13b87105a9010845f3b2de3017faba14a9b23afd0c30820d4604
MD5 fcc12095535421e428ee6a619103add2
BLAKE2b-256 303be00ead5c9c4ef93903549029b3c2f0e7e2ba2269ffca1a0fce1ef6896da7

See more details on using hashes here.

Provenance

The following attestation bundles were made for shef_parser-1.11.0.tar.gz:

Publisher: pypi-deploy.yml on HydrologicEngineeringCenter/SHEF_processing

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file shef_parser-1.11.0-py3-none-any.whl.

File metadata

  • Download URL: shef_parser-1.11.0-py3-none-any.whl
  • Upload date:
  • Size: 82.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for shef_parser-1.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c3059ad6dd27a62fcaf328bfec35e5be4b637bdc60b4f525b5c5ec1887617564
MD5 de8565895712a7f538f39a90577cfe58
BLAKE2b-256 628b635f44e90c5e61aaa17ea8b9a5c13dcd584c74589c37bf18b1ff5c3cfc6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for shef_parser-1.11.0-py3-none-any.whl:

Publisher: pypi-deploy.yml on HydrologicEngineeringCenter/SHEF_processing

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.11.0 This release

2 files

1.10.0

2 files

1.9.0

2 files

1.7.2

2 files

1.7.0

2 files

1.6.2

2 files

1.6.1

2 files

1.5.3

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page