Skip to content
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

Small tweaks #51

Merged
merged 5 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 0 additions & 68 deletions .github/workflows/dhcr.yml

This file was deleted.

54 changes: 0 additions & 54 deletions .github/workflows/ghcr.yml

This file was deleted.

3 changes: 1 addition & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ jobs:
python3 -m pip install --upgrade pip
pip3 install https://github.com/wmo-im/csv2bufr/archive/master.zip
pip3 install -r requirements.txt
pip3 install -r requirements-dev.txt
pip3 install --no-cache-dir https://github.com/wmo-im/pymetdecoder/archive/refs/tags/v0.1.1.zip
pip3 install -r requirements-dev.txt
python3 setup.py install
- name: run tests ⚙️
run: |
Expand Down
20 changes: 18 additions & 2 deletions synop2bufr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from pymetdecoder import synop
from csv2bufr import BUFRMessage

__version__ = '0.6.2'
__version__ = '0.7.0_dev'

LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -1485,12 +1485,28 @@ def transform(data: str, metadata: str, year: int,
error_msgs = []
continue

def truncate_to_twenty(name: str) -> str:
"""
Ensures the string is no longer than 20 characters,
which is the maximum length allowed for the station name
in the BUFR template.

Args:
name (str): The station or site name.

Returns:
str: This name truncated to 20 characters.
"""
LOGGER.info(f"Truncating station name {name} to 20 characters")
return name[:20]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the name is only 10 characters long? Suggest adding a check.


# parse WSI to get sections
try:
wsi_series, wsi_issuer, wsi_issue_number, wsi_local = wsi.split("-") # noqa

# get other required metadata
station_name = metadata_dict[wsi]["station_name"]
station_name = truncate_to_twenty(
metadata_dict[wsi]["station_name"])
latitude = metadata_dict[wsi]["latitude"]
longitude = metadata_dict[wsi]["longitude"]
station_height = metadata_dict[wsi]["elevation"]
Expand Down
Loading