-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix deprecation in nafc metqa parser * Add-convert-input-table (#103) * add input_table input to configuration * add another onset timestamp format * use ruff for linter testing (#106) * update dependancies * update action * run all ruff tests and report any failure right after * fix nafc ruff check issues * fix seabird imports * add input-path-list (#108) * add os path separator compatibility to both cli and configuration * add test_version module * fix version to 0.6.0 * add button to readme * Add onset.xlsx format parser (#110) * move daylight saving check to a checks module, add ambiguous input and timezone to both xlsx and csv outputs * match onset parsers ambiguous_timestamp * add makefile * improve daylight saving check and add onset.csv tests * fix batch tests to ignore onset files with daylight saving issue * fix nerc get_platform_vocabulary with the latest changes to nerc api * add star_oddi.DAT test file and fix timestamp parsing * move back test_parsers.py to tests/ * fix test_file_registry.csv to ignore files with daylight saving issue * fix daylight_saving_issue test * make pme wiper compatible with pme parser (#113) * add some pme wiper test data * add pressure attributes to pme parser * deprecate pme.minidot_* parsers to pme.* * capture all header metadata from both wiper and minidot data * fix new warning with star_oddi parser dayfirst missing input * specify dayfirst for star_oddi sensors format
- Loading branch information
1 parent
3fce6b2
commit 1edf61d
Showing
22 changed files
with
840 additions
and
79 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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,4 @@ | ||
lint: | ||
ruff format . | ||
ruff check --fix --select I . | ||
ruff check --fix . |
This file contains 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
This file contains 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,51 @@ | ||
import pandas as pd | ||
from loguru import logger | ||
from pytz.exceptions import AmbiguousTimeError | ||
|
||
|
||
def check_daylight_saving( | ||
time: pd.Series, ambiguous: str = "raise", fix_log_level: str = "info" | ||
): | ||
"""Check if daylight saving issue is present in the time series | ||
Args: | ||
time (pd.Series): time series | ||
ambiguous (str, optional): Similar to pandas.Series.tz_localize. | ||
options: | ||
- "raise": raise when we encounter ambiguous dates (default) | ||
- else: warn when we encounter ambiguous dates. | ||
fix_log_level (str, optional): Log level to use when fixing the issue. | ||
Returns: | ||
bool: True if daylight saving issue is present | ||
pd.Series: time series with daylight saving issue fixed | ||
""" | ||
# Test daylight saving issue | ||
dt = time.diff() | ||
sampling_interval = dt.median() | ||
dst_fall = -pd.Timedelta("1h") + sampling_interval | ||
dst_spring = pd.Timedelta("1h") + sampling_interval | ||
|
||
error_message = [] | ||
if any(dt == dst_fall): | ||
error_message += [ | ||
f"Time gaps (={dst_fall}) for sampling interval of {sampling_interval} " | ||
"suggest a Fall daylight saving issue is present" | ||
] | ||
if any(dt == dst_spring): | ||
error_message += [ | ||
f"Time gaps (={dst_spring}) for sampling interval of {sampling_interval} " | ||
"suggest a Spring daylight saving issue is present" | ||
] | ||
|
||
# Handle errors based on ambiguous | ||
if not error_message: | ||
pass | ||
elif ambiguous == "raise" and error_message: | ||
error_message += [ | ||
"To fix this issue, set ambiguous='warn' or provide " | ||
"a local timezone (e.g. 'Canada/Pacific')" | ||
] | ||
raise AmbiguousTimeError("\n".join(error_message)) | ||
else: | ||
logger.warning("\n".join(error_message)) |
This file contains 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
Oops, something went wrong.