JuliaClimate / JuliaClimate/ClimateBase.jl

Re-write `temporal_sampling` to directly return the period

Open
#96 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

breaking clarity enhancement temporal
Dominant language
Julia
Stars
38
Forks
3
PR merge metrics
No merged PRs in 30d

Description

In the source code at the moment we have temporal_sampling and tsamp2period. The first returns a symbol, the other an actual period type like Month(1). However, in the code the period type is what we actually use, when we use it. The symbol is used only to make decisions on if clauses. But because there is a unique and invertible mapping between the sampling symbol and the period type, we could just be using the period type instead.

This means that we only need one function temporal_sampling that directly returns the period of sampling, with numbers, e.g., Month(3) is the "seasonal" period.

This generalization means that we probably don't have to write so many different clauses of code for different types of averaging. I guess then weekly averaging would come naturally from a period if Day(7), and seasonal comes from Month(3).

I guess we could leave the inverse transform from period type to symbol/string for convenience.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate temporal_sampling and tsamp2period, then inspect their callers to understand where sampling symbols and period values are used. Done means temporal_sampling directly returns period values such as Month(3), callers no longer require the separate symbol for decisions, and an inverse period-to-symbol or string transform remains only if needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.