Skip to content

Commit

Permalink
Merge pull request #58 from gaelforget/v0p2p20
Browse files Browse the repository at this point in the history
V0p2p20
  • Loading branch information
gaelforget authored Aug 18, 2021
2 parents 2e747bb + 8232ffc commit e7f65bb
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 17 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: CI
on:
pull_request:
branches:
- master
push:
branches:
- master
tags: '*'
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.6' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'.
- '1' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia.
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1'
- run: |
julia --project=docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- run: julia --project=docs docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
GKSwstype: "100" # https://discourse.julialang.org/t/generation-of-documentation-fails-qt-qpa-xcb-could-not-connect-to-display/60988
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1

3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name = "MeshArrays"
uuid = "cb8c808f-1acf-59a3-9d2b-6e38d009f683"
authors = ["gaelforget <[email protected]>"]
version = "0.2.19"
version = "0.2.20"

[deps]
CatViews = "81a5f4ea-a946-549a-aa7e-2a7f63a27d31"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
NearestNeighbors = "b8a86587-4115-5ab1-83bc-aa920d37bbce"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# MeshArrays.jl


[![Travis Build Status](https://travis-ci.com/juliaclimate/MeshArrays.jl.svg?branch=master)](https://travis-ci.com/juliaclimate/MeshArrays.jl)
[![CI](https://github.com/juliaclimate/MeshArrays.jl/actions/workflows/ci.yml/badge.svg)](https://github.com/juliaclimate/MeshArrays.jl/actions/workflows/ci.yml)
[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliaclimate.github.io/MeshArrays.jl/stable)
[![](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliaclimate.github.io/MeshArrays.jl/dev)
[![codecov](https://codecov.io/gh/juliaclimate/MeshArrays.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/juliaclimate/MeshArrays.jl)
Expand Down
16 changes: 8 additions & 8 deletions src/Grids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function simple_periodic_domain(np::Integer,nq=missing)
list_p=(pc,pg,pc,pg,pc,pu,pv,pg,pu,pv,pv,pu,pc,fill(0.5,3),[0.,0.5,0.5],[0.5,0.,0.5])
for ii=1:length(list_n);
tmp1=fill(1.,np,nq*nFaces);
m=varmeta(list_u[ii],list_p[ii],list_n[ii],list_n[ii]);
m=varmeta(list_u[ii],list_p[ii],missing,list_n[ii],list_n[ii]);
tmp1=γ.read(tmp1,MeshArray(γ,Float64;meta=m));
tmp2=Symbol(list_n[ii]);
@eval (($tmp2) = ($tmp1))
Expand Down Expand Up @@ -164,7 +164,7 @@ function GridLoad(γ::gcmgrid)
end

for ii=1:length(list_n)
m=varmeta(list_u[ii],list_p[ii],list_n[ii],list_n[ii])
m=varmeta(list_u[ii],list_p[ii],missing,list_n[ii],list_n[ii])
tmp1=γ.read(joinpath.path,list_n[ii]*".data"),MeshArray(γ,γ.ioPrec;meta=m))
tmp2=Symbol(list_n[ii])
@eval (($tmp2) = ($tmp1))
Expand Down Expand Up @@ -196,7 +196,7 @@ function GridLoad(γ::gcmgrid)
list_p=(fill(0.5,3),[0.,0.5,0.5],[0.5,0.,0.5])
n3=length(Γ["RC"])
for ii=1:length(list_n)
m=varmeta(list_u[ii],list_p[ii],list_n[ii],list_n[ii]);
m=varmeta(list_u[ii],list_p[ii],missing,list_n[ii],list_n[ii]);
tmp1=γ.read(joinpath.path,list_n[ii]*".data"),MeshArray(γ,γ.ioPrec,n3;meta=m))
tmp2=Symbol(list_n[ii])
@eval (($tmp2) = ($tmp1))
Expand Down Expand Up @@ -247,7 +247,7 @@ function GridOfOnes(grTp,nF,nP)
list_p=(pc,pg,pc,pg,pc,pu,pv,pg,pu,pv,pv,pu,pc,fill(0.5,3),[0.,0.5,0.5],[0.5,0.,0.5])

for ii=1:length(list_n);
tmp1=fill(1.,nP,nP*nF); m=varmeta(list_u[ii],list_p[ii],list_n[ii],list_n[ii]);
tmp1=fill(1.,nP,nP*nF); m=varmeta(list_u[ii],list_p[ii],missing,list_n[ii],list_n[ii]);
tmp1=γ.read(tmp1,MeshArray(γ,Float64;meta=m));
tmp2=Symbol(list_n[ii]);
@eval (($tmp2) = ($tmp1))
Expand Down Expand Up @@ -343,10 +343,10 @@ function GridAddWS!(Γ::Dict)
uX=XC.meta.unit
uY=YC.meta.unit

XW=MeshArrays.gcmarray(XC.grid,eltype(XC);meta=varmeta(uX,[0.,0.5],"XW","XW"))
YW=MeshArrays.gcmarray(XC.grid,eltype(XC);meta=varmeta(uY,[0.,0.5],"YW","YW"))
XS=MeshArrays.gcmarray(XC.grid,eltype(XC);meta=varmeta(uX,[0.5,0.],"XS","XS"))
YS=MeshArrays.gcmarray(XC.grid,eltype(XC);meta=varmeta(uY,[0.5,0.],"YS","YS"))
XW=MeshArrays.gcmarray(XC.grid,eltype(XC);meta=varmeta(uX,[0.,0.5],missing,"XW","XW"))
YW=MeshArrays.gcmarray(XC.grid,eltype(XC);meta=varmeta(uY,[0.,0.5],missing,"YW","YW"))
XS=MeshArrays.gcmarray(XC.grid,eltype(XC);meta=varmeta(uX,[0.5,0.],missing,"XS","XS"))
YS=MeshArrays.gcmarray(XC.grid,eltype(XC);meta=varmeta(uY,[0.5,0.],missing,"YS","YS"))

for ff=1:nFaces
tmp1=XC[ff][1:end-2,2:end-1]
Expand Down
17 changes: 17 additions & 0 deletions src/Type_gcmarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ gcmarray(grid::gcmgrid)
gcmarray(grid::gcmgrid,::Type{T})
gcmarray(grid::gcmgrid,::Type{T},n3::Int)
gcmarray(grid::gcmgrid,::Type{T},n3::Int,n4::Int)
gcmarray(A::Array{T,N};meta::varmeta=defaultmeta)
```
"""
struct gcmarray{T, N, AT} <: AbstractMeshArray{T, N}
Expand All @@ -30,6 +32,21 @@ struct gcmarray{T, N, AT} <: AbstractMeshArray{T, N}
version::String
end

function gcmarray(A::Array{T,N};
meta::varmeta=defaultmeta) where {T, N}
s=size(A)[1:2]
fs=Array{NTuple{2, Int},1}(undef,1)
fs[1]=s
ios=[s[1] s[2]]
γ=gcmgrid("","PeriodicDomain",1, fs, ios, T, read, write)
if N==2
B=γ.read(A,gcmarray(γ,T;meta=meta));
else
B=γ.read(A,gcmarray(γ,T,size(A)[3];meta=meta));
end
B
end

function gcmarray(grid::gcmgrid,f::OuterArray{InnerArray{T,2},N};
meta::varmeta=defaultmeta) where {T, N}
gcmarray{T,N,InnerArray{T,2}}(grid,meta,f,grid.fSize,collect(1:grid.nFaces),thisversion)
Expand Down
14 changes: 8 additions & 6 deletions src/Types.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

using Unitful
using Unitful, Dates

"""
AbstractMeshArray{T, N}
Expand Down Expand Up @@ -36,28 +36,30 @@ end
varmeta
varmeta data structure. By default, `unit` is `1.0` (non-dimensional), `position`
is `fill(0.5,3)` (cell center), and `name` / `long_name` is unknown.
is `fill(0.5,3)` (cell center), time is missing, and `name` / `long_name` is unknown.
Available constructors:
```
varmeta(unit::Union{Unitful.AbstractQuantity,Number},position::Array{Float64,1},
name::String,long_name::String)
varmeta(unit::Union{Unitful.Units,Number,Missing},position::Array{Float64,1},
time::Union{DateTime,Missing,Array{DateTime,1}},name::String,long_name::String)
```
And:
```defaultmeta = varmeta(1.0,fill(0.5,3),"unknown","unknown")```
```defaultmeta = varmeta(missing,fill(0.5,3),missing,"unknown","unknown")```
"""
struct varmeta
unit::Union{Unitful.Units,Number,Missing}
position::Array{Float64,1}
time::Union{DateTime,Missing,Array{DateTime,1}}
name::String
long_name::String
#time? format?
end

defaultmeta = varmeta(missing,fill(0.5,3),"unknown","unknown")
defaultmeta = varmeta(missing,fill(0.5,3),missing,"unknown","unknown")

## concrete types and MeshArray alias:

Expand Down

0 comments on commit e7f65bb

Please sign in to comment.