Skip to content

Commit 57620ed

Browse files
committed
feat: init type for event and catalog
1 parent 733570a commit 57620ed

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

src/SpaceDataModel.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ using Accessors: @set
33
import Base: size,
44
import Base: push!, insert!
55

6-
export AbstractModel, AbstractProject, AbstractInstrument, AbstractProduct, AbstractDataSet
6+
export AbstractModel, AbstractProject, AbstractInstrument, AbstractProduct, AbstractDataSet, AbstractCatalog, AbstractEvent
77
export AbstractDataVariable
88
export Project, Instrument, DataSet, LDataSet, Product
9+
export Event
910
export abbr
1011

1112
name(v) = v.name
@@ -17,6 +18,7 @@ include("types.jl")
1718
include("dataset.jl")
1819
include("product.jl")
1920
include("variable.jl")
21+
include("catalog.jl")
2022
include("methods.jl")
2123

2224
end

src/catalog.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# https://spase-group.org/data/model/spase-2.7.0/spase-2_7_0_xsd.html#http___www.spase-group.org_data_schema_Spase_Catalog
2+
# Listing of events or observational notes.
3+
abstract type AbstractCatalog <: AbstractModel end
4+
abstract type AbstractEvent <: AbstractModel end
5+
6+
@kwdef struct Event <: AbstractEvent
7+
start
8+
stop
9+
metadata = Dict()
10+
end
11+
12+
(P::AbstractProduct)(e::Event) = P(e.start, e.stop)

src/methods.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,16 @@ Get the abbreviation (abbr) of a project.
66
function abbr(p::Project; lowercase=true)
77
ab = p.metadata["abbreviation"]
88
return lowercase ? Base.lowercase(ab) : ab
9-
end
9+
end
10+
11+
struct Extended{F,T} <: Function
12+
f::F
13+
left::T
14+
right::T
15+
end
16+
17+
Extended(f, margin) = Extended(f, margin, margin)
18+
19+
(t::Extended)(data, t0, t1) = t.f(data, t0 - t.left, t1 + t.right)
20+
21+
extend(p::Product, l, r=l) = @set p.transformation = Extended(func(p), l, r)

0 commit comments

Comments
 (0)