Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

How best to handle the default (Earth) radius constant

Aberta
#941 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
48/100
Tipo de issue
Refatoração
Clareza
Razoavelmente clara
Status de atividade
Pouca atividade
Stack de tecnologia
python
Domínio
data

Direção de pesquisa

Comece por cf/constants.py e mixin/fielddomain.py; depois, inspecione o valor padrão do raio em cf.relative_vorticity e a convenção existente de Field.cell_area. Rastreie outras referências ao raio que usem o valor do raio da Terra e compare sua nomenclatura e seus valores padrão. Está concluído quando o valor padrão estiver centralizado e as referências afetadas oferecerem suporte consistente ao comportamento descrito para o raio da Terra.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

code tidy enhancement question

Throughout the codebase we often perform calculations using a value for the radius of a sphere. This can usually be assumed to be the Earth's because the relevant calculations concern the Earth's surface - but there may also be applications to extra-planetary atmospheres and oceans etc. so when referencing/naming the radius generally we should keep that wider scope in mind so as to not to possibly put off those wanting to do calculations for other planets.

During code review for #910 we decided to have a think about how best to handle the Earth radius default as a value that has a default to sensible precision (we use 6371229.0 meters generally), including as hard-coded at present as:

  • in mixin/fielddomain.py as a float constant (potnetially not ideal as a float as technically that can vary very slightly by floating point precision, as a separate concern);
  • a radius kwarg value default for cf.relative_vorticity.

See thread in https://github.com/NCAS-CMS/cf-python/pull/910#discussion_r2967106221 for original discussion points.

Suggestion

I suggest that:

  • we add earth_radius[_value] to the constants module as an integer value 6371229 and import there where necessary. The canonical units for it are already defined there:

    https://github.com/NCAS-CMS/cf-python/blob/8c760f82ed119cdda0ad041bc9deec49f3bc15d4/cf/constants.py#L18

    so it is nice to have it close to those as an additional benefit;

  • we change any radius reference to make sure it doesn't reference the 'Earth' in the name explicitly, but take our default Earth radius as default (the average user will be considering the Earth and surely in most cases not need to tweak the value from default precision);

  • for any functions that use the default Earth radius, consult that constant - notably where there's a corresponding keyword argument radius take 'earth' as a string default to mean 'use the default earth value', as we presently do for many methods such as Field.cell_area.

Linguagem predominante
Python
Estrelas
151
Forks
23
Merge médio
1d 2h
PRs com merge (30d)
1

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de NCAS-CMS/cf-python

Todas as issues de NCAS-CMS/cf-python

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.