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

IDEA: refactor pg_calendar() with dict? #112

Open
truth-quark opened this issue Sep 25, 2024 · 0 comments
Open

IDEA: refactor pg_calendar() with dict? #112

truth-quark opened this issue Sep 25, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@truth-quark
Copy link
Collaborator

For simplification extensibility, consider replacing this:

# Override the PP file calendar function to use Proleptic Gregorian rather than Gregorian.
# This matters for control runs with model years < 1600.
@property
def pg_calendar(self):
"""Return the calendar of the field."""
# TODO #577 What calendar to return when ibtim.ic in [0, 3]
calendar = cf_units.CALENDAR_PROLEPTIC_GREGORIAN
if self.lbtim.ic == 2:
calendar = cf_units.CALENDAR_360_DAY
elif self.lbtim.ic == 4:
calendar = cf_units.CALENDAR_365_DAY
return calendar

with a dict:

 @property 
 def pg_calendar(self): 
    cal = {2: cf_units.CALENDAR_360_DAY,
           4: cf_units.CALENDAR_365_DAY}
    return cal.get(self.lbtim.ic, cf_units.CALENDAR_PROLEPTIC_GREGORIAN)
@truth-quark truth-quark added the enhancement New feature or request label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant