Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cd80a58
refac(histogram_t): rm un{used,needed} getters
rouson Oct 21, 2025
1100e4f
refac(histogram_t): store bin count, cardinality
rouson Oct 21, 2025
bc23705
refac(histogram): constructor with preset range
rouson Oct 21, 2025
7bc90cc
feat(tensor-stats): read >1 training-data files
rouson Oct 21, 2025
e3582ea
feat(tensor-stats): write 1 plot per training file
rouson Oct 22, 2025
5b352dd
feat(command-line): update flags & usage info
rouson Oct 22, 2025
98f7124
chore(tensor-stats): rm unused args, update usage
rouson Oct 22, 2025
dc4e63f
refac(tensor-stats): encapsulate command-line args
rouson Oct 22, 2025
4f00f13
chore(test): rm unnecessary preprocessing
rouson Oct 23, 2025
8cf4e72
chore(time_data_test): rm unneeded `include`
rouson Oct 23, 2025
c6bdba0
test(histogram_t): check uniform distribution
rouson Oct 25, 2025
aa05968
chore(demo/histogram): rm optional arguments
rouson Oct 27, 2025
2a264b0
refac(histogram_t): match constructor arg order
rouson Oct 27, 2025
78bbd5e
feat(demo/histogram): rm domain normalization
rouson Oct 27, 2025
4966a08
chore(histogram_s): blank space eds (indentation)
rouson Oct 27, 2025
ed7dd04
feat(histogram): default(none) locality
rouson Oct 27, 2025
bec7f65
refac(histogram): map constructor inputs to 1D
rouson Oct 27, 2025
145a75d
feat(NetCDF_variable): 1-3D histogram construction
rouson Oct 27, 2025
f7ef70b
test(histogram): construct from bracketed array(s)
rouson Oct 27, 2025
703c9c9
feat(NetCDF_var): aggregate histograms across files
rouson Oct 27, 2025
40799c0
WIP(demo/tensor-statistics): calc derivs
rouson Oct 27, 2025
ec54158
fix(NetCDF_variable_s,histogram_s): assertions
rouson Oct 27, 2025
5e16f57
fix(tensor-statistics): alloc derivs just once
rouson Oct 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ set term png size 2600, 1200
set output "input-tensor-histograms.png"
set multiplot layout 3,3
do for [name in "potential_temperature pressure qc qr qs qv temperature"] {
filename = name . ".plt"
filename = name . "-inputs.plt"
set title sprintf("Histogram for %s",name)
plot filename using 1:2 with linespoints title columnheader
}
print "\n Output-tensor histograms have been written to the graphics file 'output-tensor-histograms.png'."
print " Input-tensor histograms have been written to the graphics file 'input-tensor-histograms.png'.\n"

unset multiplot

Expand All @@ -19,4 +19,4 @@ do for [name in "dpotential_temperature_dt dqc_dt dqr_dt dqs_dt dqv_dt"] {
set title sprintf("Histogram for %s",name)
plot filename using 1:2 with linespoints title columnheader
}
print " Input-tensor histograms have been written to the graphics file 'input-tensor-histograms.png'.\n"
print "\n Output-tensor histograms have been written to the graphics file 'output-tensor-histograms.png'."
384 changes: 172 additions & 212 deletions demo/app/tensor-statistics.F90

Large diffs are not rendered by default.

33 changes: 19 additions & 14 deletions demo/src/NetCDF_variable_m.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module NetCDF_variable_m
public :: NetCDF_variable_t
public :: tensors
public :: time_derivative_t
public :: histogram

type NetCDF_variable_t(k)
integer, kind :: k = default_real
Expand All @@ -35,8 +36,6 @@ module NetCDF_variable_m
procedure, private, non_overridable :: default_real_maximum , double_precision_maximum
generic :: operator(-) => default_real_subtract , double_precision_subtract
procedure, private, non_overridable :: default_real_subtract , double_precision_subtract
generic :: histogram => default_real_histogram , double_precision_histogram
procedure, private, non_overridable :: default_real_histogram , double_precision_histogram
generic :: compare => default_real_compare , double_precision_compare
procedure, private, non_overridable :: default_real_compare , double_precision_compare
end type
Expand Down Expand Up @@ -148,13 +147,13 @@ elemental module function double_precision_rank(self) result(my_rank)

elemental module function default_real_end_step(self) result(end_step)
implicit none
class(NetCDF_variable_t), intent(inout) :: self
class(NetCDF_variable_t), intent(in) :: self
integer end_step
end function

elemental module function double_precision_end_step(self) result(end_step)
implicit none
class(NetCDF_variable_t(double_precision)), intent(inout) :: self
class(NetCDF_variable_t(double_precision)), intent(in) :: self
integer end_step
end function

Expand Down Expand Up @@ -215,32 +214,38 @@ module function tensors(NetCDF_variables, step_start, step_end, step_stride)

elemental module function default_real_end_time(self) result(end_time)
implicit none
class(NetCDF_variable_t), intent(inout) :: self
class(NetCDF_variable_t), intent(in) :: self
integer end_time
end function

elemental module function double_precision_end_time(self) result(end_time)
implicit none
class(NetCDF_variable_t), intent(inout) :: self
class(NetCDF_variable_t), intent(in) :: self
integer end_time
end function

elemental module function default_real_histogram(self, num_bins, raw) result(histogram)
end interface

interface histogram

module function default_real_histogram(variables, num_bins) result(aggregate)
implicit none
class(NetCDF_variable_t), intent(inout) :: self
class(NetCDF_variable_t), intent(in), target :: variables(:)
integer, intent(in) :: num_bins
logical, intent(in) :: raw
type(histogram_t) histogram
type(histogram_t) aggregate
end function

elemental module function double_precision_histogram(self, num_bins, raw) result(histogram)
module function double_precision_histogram(variables, num_bins) result(aggregate)
implicit none
class(NetCDF_variable_t(double_precision)), intent(inout) :: self
class(NetCDF_variable_t(double_precision)), intent(in) :: variables
integer, intent(in) :: num_bins
logical, intent(in) :: raw
type(histogram_t) histogram
type(histogram_t) aggregate
end function

end interface

interface

module subroutine default_real_compare(self, values)
implicit none
class(NetCDF_variable_t), intent(in) :: self
Expand Down
17 changes: 13 additions & 4 deletions demo/src/NetCDF_variable_s.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
submodule(NetCDF_variable_m) NetCDF_variable_s
use ieee_arithmetic, only : ieee_is_nan
use kind_parameters_m, only : default_real
use julienne_m, only : call_julienne_assert_, operator(.equalsExpected.)
use julienne_m, only : &
call_julienne_assert_ &
,operator(.all.) &
,operator(.equalsExpected.)
use default_m, only : default_or_present_value
implicit none

Expand Down Expand Up @@ -66,16 +69,22 @@
end procedure

module procedure default_real_histogram
select case(self%rank())

integer v

call_julienne_assert(.all. (variables(1)%rank() .equalsExpected. variables%rank()))
call_julienne_assert(.all. (variables(1)%name_ .equalsExpected. [(variables(v)%name_, v = 1, size(variables))]))

select case(variables(1)%rank())
case (4)
histogram = histogram_t(self%values_4D_ , self%name_, num_bins, raw)
aggregate = histogram_t([(variables(v)%values_4D_, v = 1, size(variables))], variables(1)%name_, num_bins)
case default
error stop 'NetCDF_variable_s(default_real_histogram): unsupported rank'
end select
end procedure

module procedure double_precision_histogram
error stop 'NetCDF_variable_s(double_precision_histogram): unsupported rank'
error stop 'NetCDF_variable_s(double_precision_histogram): unsupported kind'
end procedure

module procedure default_real_copy
Expand Down
58 changes: 18 additions & 40 deletions demo/src/histogram_m.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,30 @@ module histogram_m
!! encapsulate the primary data associated with histograms
private
character(len=:), allocatable :: variable_name_
real unmapped_min_, unmapped_max_
real, allocatable :: bin_frequency_(:), bin_value_(:)
real variable_min_, variable_max_
real, allocatable :: bin_value_(:)
integer, allocatable :: bin_count_(:)
contains
procedure variable_name
procedure unmapped_range
procedure unmapped_min
procedure unmapped_max
procedure num_bins
procedure bin_value
procedure bin_frequency
procedure bin_count
end type

interface histogram_t

pure module function construct(v, variable_name, num_bins, raw) result(histogram)
module function construct(v, variable_name, num_bins) result(histogram)
implicit none
real, intent(in) :: v(:,:,:,:)
real, intent(in) :: v(:)
character(len=*), intent(in) :: variable_name
integer, intent(in) :: num_bins
type(histogram_t) histogram
end function

pure module function construct_in_range(v, variable_name, num_bins, v_min, v_max) result(histogram)
implicit none
real, intent(in) :: v(:), v_min, v_max
character(len=*), intent(in) :: variable_name
integer, intent(in) :: num_bins
logical, intent(in) :: raw
type(histogram_t) histogram
end function

Expand All @@ -55,49 +59,23 @@ pure module function to_common_file(histograms) result(file)

interface

pure module function num_bins(self) result(bins)
implicit none
class(histogram_t), intent(in) :: self
integer bins
end function

pure module function variable_name(self) result(name)
implicit none
class(histogram_t), intent(in) :: self
character(len=:), allocatable :: name
end function

pure module function unmapped_range(self) result(raw_range)
implicit none
class(histogram_t), intent(in) :: self
integer, parameter :: num_end_points = 2
real raw_range(num_end_points)
end function

elemental module function unmapped_min(self) result(range_minimum)
implicit none
class(histogram_t), intent(in) :: self
real range_minimum
end function

elemental module function unmapped_max(self) result(range_maximum)
implicit none
class(histogram_t), intent(in) :: self
real range_maximum
end function

elemental module function bin_value(self, bin) result(v)
pure module function bin_frequency(self, bin) result(frequency)
implicit none
class(histogram_t), intent(in) :: self
integer, intent(in) :: bin
real v
real frequency
end function

pure module function bin_frequency(self, bin) result(frequency)
pure module function bin_count(self) result(counts)
implicit none
class(histogram_t), intent(in) :: self
integer, intent(in) :: bin
real frequency
integer, allocatable :: counts(:)
end function

end interface
Expand Down
Loading