Skip to content

Commit 40f7b0f

Browse files
Improve some doc strings (#2279)
1 parent 60212ea commit 40f7b0f

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

src/Fields/Fields.jl

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ end
314314
"""
315315
zeros(space::AbstractSpace)
316316
317-
Construct a field on `space` that is zero everywhere.
317+
Create a new field on `space` that is zero everywhere.
318318
"""
319319
function Base.zeros(::Type{FT}, space::AbstractSpace) where {FT}
320320
field = Field(FT, space)
@@ -327,7 +327,7 @@ Base.zeros(space::AbstractSpace) = zeros(Spaces.undertype(space), space)
327327
"""
328328
ones(space::AbstractSpace)
329329
330-
Construct a field on `space` that is one everywhere.
330+
Create a new field on `space` that is one everywhere.
331331
"""
332332
function Base.ones(::Type{FT}, space::AbstractSpace) where {FT}
333333
field = Field(FT, space)
@@ -348,7 +348,7 @@ end
348348
"""
349349
coordinate_field(space::AbstractSpace)
350350
351-
Construct a `Field` of the coordinates of the space.
351+
Return a pointer to the input space's coordinates `Field`.
352352
"""
353353
coordinate_field(space::AbstractSpace) =
354354
Field(Spaces.coordinates_data(space), space)
@@ -357,7 +357,7 @@ coordinate_field(field::Field) = coordinate_field(axes(field))
357357
"""
358358
local_geometry_field(space::AbstractSpace)
359359
360-
Construct a `Field` of the `LocalGeometry` of the space.
360+
Return a pointer to the input space's `LocalGeometry` `Field`.
361361
"""
362362
local_geometry_field(space::AbstractSpace) =
363363
Field(Spaces.local_geometry_data(space), space)
@@ -367,7 +367,8 @@ local_geometry_field(field::Field) = local_geometry_field(axes(field))
367367
Δz_field(field::Field)
368368
Δz_field(space::AbstractSpace)
369369
370-
A `Field` containing the `Δz` values on the same space as the given field.
370+
Return a pointer to the input space's `Field` containing the `Δz` values on the
371+
same space as the given field.
371372
"""
372373
Δz_field(field::Field) = Δz_field(axes(field))
373374
Δz_field(space::AbstractSpace) = Field(Spaces.Δz_data(space), space)
@@ -521,12 +522,29 @@ Base.@propagate_inbounds Base.setindex!(field::PointField, val) =
521522
"""
522523
set!(f::Function, field::Field, args = ())
523524
524-
Apply function `f` to populate
525-
values in field `field`. `f` must
526-
have a function signature with signature
527-
`f(::LocalGeometry[, args...])`.
528-
Additional arguments may be passed to
529-
`f` with `args`.
525+
Apply function `f` to populate values in field `field`. `f` must have a function
526+
signature with signature `f(::LocalGeometry[, args...])`. Additional arguments
527+
may be passed to `f` with `args`.
528+
529+
## Example
530+
531+
```julia
532+
using ClimaCore.Fields
533+
using ClimaCore.CommonSpaces
534+
ᶜspace = ExtrudedCubedSphereSpace(Float64;
535+
z_elem = 10,
536+
z_min = 0,
537+
z_max = 1,
538+
radius = 10,
539+
h_elem = 10,
540+
n_quad_points = 4,
541+
staggering = CellCenter(),
542+
)
543+
x = Fields.Field(Float64, ᶜspace)
544+
Fields.set!(x) do lg
545+
sin(lg.coordinates.z)
546+
end
547+
```
530548
"""
531549
function set!(f::Function, field::Field, args = ())
532550
space = axes(field)

0 commit comments

Comments
 (0)