-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #604 from jbusecke/jbusecke_calendar_parser
Calendar parsing
- Loading branch information
Showing
5 changed files
with
55 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from parcels.tools.converters import TimeConverter, _get_cftime_datetimes | ||
import cftime | ||
import numpy as np | ||
|
||
|
||
def test_TimeConverter(): | ||
cf_datetime_names = _get_cftime_datetimes() | ||
for cf_datetime in cf_datetime_names: | ||
date = getattr(cftime, cf_datetime)(1990, 1, 1) | ||
assert TimeConverter(date).calendar == date.calendar | ||
assert TimeConverter(None).calendar is None | ||
date_datetime64 = np.datetime64('2001-01-01T12:00') | ||
assert TimeConverter(date_datetime64).calendar == "np_datetime64" |
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,10 @@ | ||
from parcels.particlefile import _set_calendar | ||
from parcels.tools.converters import _get_cftime_calendars, _get_cftime_datetimes | ||
import cftime | ||
|
||
|
||
def test_set_calendar(): | ||
for calendar_name, cf_datetime in zip(_get_cftime_calendars(), _get_cftime_datetimes()): | ||
date = getattr(cftime, cf_datetime)(1990, 1, 1) | ||
assert _set_calendar(date.calendar) == date.calendar | ||
assert _set_calendar('np_datetime64') == 'standard' |