Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nefrathenrici committed Oct 18, 2023
1 parent 36c57b6 commit 9559746
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
8 changes: 6 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
using Documenter
using Documenter: doctest
using CalibrateAtmos
using Base.CoreLogging
using DocumenterCitations

disable_logging(Base.CoreLogging.Info) # Hide doctest's `@info` printing
bib = CitationBibliography(joinpath(@__DIR__, "bibliography.bib"))

doctest(CalibrateAtmos; plugins = [bib])
disable_logging(Base.CoreLogging.BelowMinLevel) # Re-enable all logging

makedocs(
CitationBibliography(joinpath(@__DIR__, "bibliography.bib")),
modules = Vector{Module}(),
plugins = [bib],
modules = [CalibrateAtmos],
sitename = "CalibrateAtmos.jl",
authors = "Clima",
strict = true,
Expand Down
Empty file added docs/src/quickstart.md
Empty file.
43 changes: 34 additions & 9 deletions plot/latitude_contour_plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@ import Statistics: mean

# Adapted from contours_and_plots.jl in ClimaAtmos

function time_from_filename(file)
arr = split(basename(file), ".")
day = parse(Float64, replace(arr[1], "day" => ""))
sec = parse(Float64, arr[2])
return day * (60 * 60 * 24) + sec
end

function read_hdf5_file(file_path)
function read_diagnostics(file_path)
reader = InputOutput.HDF5Reader(
file_path,
ClimaComms.SingletonCommsContext(ClimaComms.CPUSingleThreaded()),
Expand All @@ -22,6 +15,17 @@ function read_hdf5_file(file_path)
return diagnostics
end

"""
time_from_filename(file_path)
Returns the time in seconds from the name of the given file.
"""
function time_from_filename(file_path)
arr = split(basename(file_path), ".")
day = parse(Float64, replace(arr[1], "day" => ""))
sec = parse(Float64, arr[2])
return day * (60 * 60 * 24) + sec
end

horizontal_space(diagnostics) =
Spaces.horizontal_space(axes(diagnostics.temperature))

Expand All @@ -33,6 +37,11 @@ get_column_1(diagnostics) =
isnothing(diagnostics) ? (nothing, nothing) :
column_view_diagnostics(diagnostics, ((1, 1), 1))


"""
column_view_diagnostics(diagnostics, column)
Retrieves the diagnostics from the given column.
"""
function column_view_diagnostics(diagnostics, column)
((i, j), h) = column
is_extruded_field(object) =
Expand Down Expand Up @@ -62,6 +71,10 @@ function column_view_diagnostics(diagnostics, column)
return column_zs_and_values, col_string
end

"""
column_at_coord_getter(latitude, longitude)
Retrieves the diagnostics from the column closest to the given latitude and longitude.
"""
column_at_coord_getter(latitude, longitude) =
diagnostics -> begin
isnothing(diagnostics) && return (nothing, nothing)
Expand Down Expand Up @@ -96,7 +109,7 @@ function latitude_contour_plot(
longitude = 0,
out_path = nothing,
)
diagnostics = read_hdf5_file(file_path)
diagnostics = read_diagnostics(file_path)
latitudes = -90:5:90
cols = map(latitudes) do lat
column_at_coord_getter(lat, longitude)(diagnostics)[1]
Expand All @@ -123,3 +136,15 @@ function latitude_contour_plot(
Makie.save(out_path, figure)
return nothing
end

"""
all_variables(file_path)
Returns the propertynames of the diagnostics of the given file path.
Assumes all columns have the same propertynames.
"""
function all_variables(file_path)
diagnostics = read_diagnostics(file_path)
latitude = -90
col = column_at_coord_getter(latitude, 0)(diagnostics)[1]
return propertynames(col[2])
end

0 comments on commit 9559746

Please sign in to comment.