Skip to content

Commit 878c108

Browse files
authored
Merge pull request #11 from gaelforget/docs
add second set of docstrings + fix previous commit bug
2 parents a0d922f + ed19923 commit 878c108

9 files changed

+140
-12
lines changed

src/gcmfaces_IO.jl

+21-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11

22
## read_bin function with full list of argument
33

4-
function read_bin(fil::String,kt,kk,prec::DataType);
4+
"""
5+
read_bin(fil::String,kt,kk,prec::DataType)
6+
7+
Read model output from binary file and convert to gcmfaces structure.
8+
"""
9+
function read_bin(fil::String,kt,kk,prec::DataType)
510

611
if ~isempty(kt);
712
error("non-empty kt option not implemented yet");
@@ -12,7 +17,7 @@ function read_bin(fil::String,kt,kk,prec::DataType);
1217
end;
1318

1419
(n1,n2)=MeshArrays.ioSize;
15-
20+
1621
if prec==Float64;
1722
reclen=8;
1823
else;
@@ -34,12 +39,22 @@ end
3439

3540
## read_bin function with reduced list of argument
3641

37-
function read_bin(fil::String,prec::DataType);
38-
read_bin(fil,[],[],prec);
42+
"""
43+
read_bin(fil,[],[],prec)
44+
45+
Read model output from binary file and convert to gcmfaces structure.
46+
"""
47+
function read_bin(fil::String,prec::DataType)
48+
read_bin(fil,[],[],prec)
3949
end
4050

4151
## read_bin function with reduced list of argument
4252

43-
function read_bin(fil::String);
44-
read_bin(fil,[],[],Float32);
53+
"""
54+
read_bin(fil::String)
55+
56+
Read model output from binary file and convert to gcmfaces structure.
57+
"""
58+
function read_bin(fil::String)
59+
read_bin(fil,[],[],Float32)
4560
end

src/gcmfaces_calc.jl

+41-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11

22
## gradient methods
33

4+
"""
5+
gradient(inFLD::gcmfaces)
6+
7+
Compute spatial derivatives.
8+
"""
49
function gradient(inFLD::gcmfaces)
510
(dFLDdx, dFLDdy)=gradient(inFLD,true)
611
return dFLDdx, dFLDdy
712
end
813

14+
"""
15+
gradient(inFLD::gcmfaces,doDIV::Bool)
16+
17+
Compute spatial derivatives with or without dividing by grid scale.
18+
"""
919
function gradient(inFLD::gcmfaces,doDIV::Bool)
1020

1121
exFLD=exchange(inFLD,1)
@@ -29,6 +39,11 @@ end
2939
return dFLDdx, dFLDdy
3040
end
3141

42+
"""
43+
gradient(inFLD::gcmfaces,iDXC::gcmfaces,iDYC::gcmfaces)
44+
45+
Compute spatial derivatives and multiply by inverse grid scale.
46+
"""
3247
function gradient(inFLD::gcmfaces,iDXC::gcmfaces,iDYC::gcmfaces)
3348

3449
exFLD=exchange(inFLD,1)
@@ -49,11 +64,21 @@ end
4964

5065
## mask methods
5166

67+
"""
68+
mask(fld::gcmfaces)
69+
70+
Call mask(fld,NaN)
71+
"""
5272
function mask(fld::gcmfaces)
5373
fldmsk=mask(fld,NaN)
5474
return fldmsk
5575
end
5676

77+
"""
78+
mask(fld::gcmfaces, val::Number)
79+
80+
Replace non finite values with val
81+
"""
5782
function mask(fld::gcmfaces, val::Number)
5883
fldmsk=similar(fld)
5984
for a=1:fld.nFaces
@@ -64,6 +89,11 @@ function mask(fld::gcmfaces, val::Number)
6489
return fldmsk
6590
end
6691

92+
"""
93+
mask(fld::gcmfaces, val::Number)
94+
95+
Replace noval instances with val
96+
"""
6797
function mask(fld::gcmfaces, val::Number, noval::Number)
6898
fldmsk=similar(fld)
6999
for a=1:fld.nFaces
@@ -76,7 +106,12 @@ end
76106

77107
## convergence methods
78108

79-
function convergence(uFLD::gcmfaces,vFLD::gcmfaces);
109+
"""
110+
convergence(uFLD::gcmfaces,vFLD::gcmfaces)
111+
112+
Compute convergence of a vector field
113+
"""
114+
function convergence(uFLD::gcmfaces,vFLD::gcmfaces)
80115

81116
#important note:
82117
# Normally uFLD, vFLD should not contain any NaN;
@@ -100,6 +135,11 @@ end
100135

101136
## smooth function
102137

138+
"""
139+
smooth(FLD::gcmfaces,DXCsm::gcmfaces,DYCsm::gcmfaces)
140+
141+
Smooth out scales below threshold
142+
"""
103143
function smooth(FLD::gcmfaces,DXCsm::gcmfaces,DYCsm::gcmfaces)
104144

105145
#important note:

src/gcmfaces_convert.jl

+21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11

22
## convert2array method:
33

4+
"""
5+
convert2array(fld::gcmfaces)
6+
7+
Convert gcmfaces to array
8+
"""
49
function convert2array(fld::gcmfaces)
510

611
if fld.grTopo=="llc";
@@ -23,6 +28,12 @@ return arr;
2328
end
2429

2530
## convert2array ##
31+
32+
"""
33+
convert2array(fld::Array{T,N}) where {T,N}
34+
35+
Convert array to gcmfaces
36+
"""
2637
function convert2array(fld::Array{T,N}) where {T,N}
2738

2839
grTopo=MeshArrays.grTopo;
@@ -58,6 +69,11 @@ end
5869

5970
## convert2gcmfaces method:
6071

72+
"""
73+
convert2gcmfaces(fld::gcmfaces)
74+
75+
Convert mitgcm output to gcmfaces
76+
"""
6177
function convert2gcmfaces(fld::gcmfaces)
6278

6379
grTopo=MeshArrays.grTopo;
@@ -90,6 +106,11 @@ end
90106

91107
## convert2gcmfaces ##
92108

109+
"""
110+
convert2gcmfaces(fld::Array)
111+
112+
Convert gcmfaces to mitgcm output
113+
"""
93114
function convert2gcmfaces(fld::Array)
94115

95116
grTopo=MeshArrays.grTopo;

src/gcmfaces_demo.jl

+10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
# (Rini,Rend,DXCsm,DYCsm)=demo2();
1111
# @time Rend=smooth(Rini,DXCsm,DYCsm);
1212

13+
"""
14+
demo1(gridChoice)
15+
16+
Demo overloaded arithmetic, exchange, GCMGridLoad, gradient, etc.
17+
"""
1318
function demo1(gridChoice)
1419

1520
GCMGridSpec(gridChoice)
@@ -48,6 +53,11 @@ end
4853

4954
##
5055

56+
"""
57+
demo2()
58+
59+
Demo at higher level using smooth()
60+
"""
5161
function demo2()
5262

5363
#Pre-requisite:

src/gcmfaces_exch.jl

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

55
## User Front Ends
66

7+
"""
8+
exchange(fld::gcmfaces)
9+
10+
Exchange / transfer data between neighbor arrays. Other methods are
11+
12+
exchange(fld::gcmfaces,N::Integer)
13+
exchange(u::gcmfaces,v::gcmfaces)
14+
exchange(u::gcmfaces,v::gcmfaces,N::Integer)
15+
"""
716
function exchange(fld::gcmfaces)
817
FLD=exch_T_N(fld,1);
918
end

src/gcmfaces_grids.jl

+19
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ GCMGridSpec() = GCMGridSpec("LLC90")
55

66
## GCMGridSpec function with gridName argument:
77

8+
"""
9+
GCMGridSpec(gridName)
10+
11+
Set global variables in the module scope for grDir, nFaces, grTopo, ioSize,
12+
facesSize, ioPrec using hard-coded values for LLC90, CS32, LL360 (for now).
13+
"""
814
function GCMGridSpec(gridName)
915

1016
global grDir, nFaces, grTopo, ioSize, facesSize, ioPrec;
@@ -40,6 +46,14 @@ end
4046

4147
## GCMGridLoad function
4248

49+
"""
50+
GCMGridLoad()
51+
52+
Loads grid variables from files located in grDir set by GCMGridSpec.
53+
54+
Grid variables are XC, XG, YC, YG, RAC, RAZ, DXC, DXG, DYC, DYG, hFacC,
55+
hFacS, hFacW, Depth based on the MITgcm naming convention.
56+
"""
4357
function GCMGridLoad()
4458

4559
global XC, XG, YC, YG, RAC, RAZ, DXC, DXG, DYC, DYG, hFacC, hFacS, hFacW, Depth;
@@ -55,6 +69,11 @@ function GCMGridLoad()
5569

5670
end
5771

72+
"""
73+
GCMGridOnes(grTp,nF,nP)
74+
75+
Define all-1 grid variables instead of using GCMGridSpec & GCMGridLoad.
76+
"""
5877
function GCMGridOnes(grTp,nF,nP)
5978

6079
global grDir, nFaces, grTopo, ioSize, facesSize, ioPrec;

src/gcmfaces_nctiles.jl

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ export read_nctiles
1010
# Depth=read_nctiles(fileName,"Depth")
1111
# hFacC=read_nctiles(fileName,"hFacC")
1212

13-
function read_nctiles(fileName,fldName);
13+
"""
14+
read_nctiles(fileName,fldName)
15+
16+
Read model output from Netcdf / NCTiles file and convert to gcmfaces structure.
17+
"""
18+
function read_nctiles(fileName,fldName)
1419

1520
if ~(MeshArrays.grTopo=="llc");
1621
error("non-llc cases not implemented yet");

src/gcmfaces_plot.jl

+10
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,22 @@ export qwckplot
1010
# qwckplot(MeshArrays.Depth)
1111
# qwckplot(MeshArrays.Depth,"Ocean Bottom Depth")
1212

13+
"""
14+
qwckplot(fld::gcmfaces)
15+
16+
Call qwckplot(fld::gcmfaces,ttl::String) with current date for title
17+
"""
1318
function qwckplot(fld::gcmfaces)
1419
tmp1=Dates.now()
1520
tmp1=Dates.format(tmp1, "yyyy-mm-dd HH:MM:SS")
1621
qwckplot(fld,"Plotted at time "*tmp1)
1722
end
1823

24+
"""
25+
qwckplot(fld::gcmfaces,ttl::String)
26+
27+
Plot input using convert2array and heatmap + add title
28+
"""
1929
function qwckplot(fld::gcmfaces,ttl::String)
2030
arr=convert2array(fld)
2131
arr=permutedims(arr,[2 1])

src/gcmfaces_type.jl

+3-4
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ end
3535
## additional constructors for gcmfaces
3636

3737
"""
38-
gcmfaces(nFaces::Int,grTopo::String,::Type{T},
39-
fSize::Array{NTuple{N, Int}},
38+
gcmfaces(nFaces::Int,grTopo::String,::Type{T},fSize::Array{NTuple{N, Int}},
4039
aSize::NTuple{N,Int}) where {T,N}
4140
4241
gcmfaces constructor.
@@ -152,7 +151,7 @@ end
152151
153152
fsize convenience function.
154153
"""
155-
function fsize(A::AbstractGcmfaces{T, N},i::Int) where {T,N}
154+
function fsize(A::AbstractGcmfaces{T, N}) where {T,N}
156155
fs=Array{NTuple{N, Int}}(undef,A.nFaces)
157156
for i=1:A.nFaces
158157
fs[i]=size(A.f[i]);
@@ -161,7 +160,7 @@ function fsize(A::AbstractGcmfaces{T, N},i::Int) where {T,N}
161160
end
162161

163162
"""
164-
fsize(A::AbstractGcmfaces{T, N}) where {T,N}
163+
fsize(A::AbstractGcmfaces{T, N},i::Int) where {T,N}
165164
166165
fsize convenience function.
167166
"""

0 commit comments

Comments
 (0)