diff --git a/Project.toml b/Project.toml index 8eae46e..925201e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PALEOboxes" uuid = "804b410e-d900-4b2a-9ecd-f5a06d4c1fd4" authors = ["Stuart Daines "] -version = "0.18.3" +version = "0.18.4" [deps] BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" diff --git a/src/VariableReaction.jl b/src/VariableReaction.jl index 76b6e16..71cfd0d 100644 --- a/src/VariableReaction.jl +++ b/src/VariableReaction.jl @@ -65,9 +65,9 @@ end ################################################## """ - CreateVariableReaction(var_type, linklocal_namestr, units, description; - attributes=Tuple(), link_namestr=linklocal_namestr) - -> VariableReaction{T} + CreateVariableReaction(T, localname => link_namestr, units, description; attributes=Tuple()) -> VariableReaction{T} + CreateVariableReaction(T, linklocal_namestr, units, description; attributes=Tuple()) -> VariableReaction{T} + [deprecated] CreateVariableReaction(T, localname, units, description; link_namestr, attributes=Tuple()) -> VariableReaction{T} Create a [`VariableReaction`](@ref). @@ -76,19 +76,30 @@ Not called directly: use short names `VarProp`, `VarDep`, `VarContrib`, `VarTarg # Arguments - `var_type::VariableType`: one of `VT_ReactProperty`, `VT_ReactDependency`, `VT_ReactContributor`, `VT_ReactTarget` -- `linklocal_namestr::AbstractString`: either - - `localname`, or - - `.[linkreq_subdomain.]localname` (which is parsed by [`parse_variablereaction_namestr`](@ref) - to define the requested linking to `Domain` Variable). +- `localname::AbstractString`: Reaction-local Variable name +- `link_namestr::AbstractString`: `.[linkreq_subdomain.]linkreq_name`. Parsed by [`parse_variablereaction_namestr`](@ref) + to define the requested linking to `Domain` Variable. +- `linklocal_namestr::AbstractString`: `.[linkreq_subdomain.]localname`. Convenience form to define both `localname` + and requested linking to Domain Variable, for the common case where `linkreq_name == localname`. - `units::AbstractString`: units ("" if not applicable) - `description::AbstractString`: text describing the variable # Keywords - `attributes::Tuple(:attrb1name=>attrb1value, :attrb2name=>attrb2value, ...)`: variable attributes, see [`StandardAttributes`](@ref), [`set_attribute!`](@ref), [`get_attribute`](@ref) -- `link_namestr::AbstractString`: parsed by [`parse_variablereaction_namestr`](@ref) - to define requested linking to `Domain` Variable. Only required to specify a requested link name where `linkreq_name` - is different from `localname`. If supplied, `linklocal_namestr` must then be just `localname`. """ +function CreateVariableReaction end + +CreateVariableReaction( + var_type::VariableType, + localname_linkname::Pair{<:AbstractString, <:AbstractString}, + units::AbstractString, + description::AbstractString; + attributes::Tuple{Vararg{Pair}}=(), # (:atrb1=>value1, :atrb2=>value2) +) = CreateVariableReaction( + var_type, first(localname_linkname), units, description; + link_namestr=last(localname_linkname), attributes=attributes +) + function CreateVariableReaction( var_type::VariableType, linklocal_namestr::AbstractString, diff --git a/src/reactioncatalog/Fluxes.jl b/src/reactioncatalog/Fluxes.jl index ebbe593..d25922b 100644 --- a/src/reactioncatalog/Fluxes.jl +++ b/src/reactioncatalog/Fluxes.jl @@ -127,8 +127,7 @@ function _FluxVars( push!( variables, varctorfn( - localname, "mol yr-1", "$description $fluxname", - link_namestr=link_namestr, + localname=>link_namestr, "mol yr-1", "$description $fluxname", attributes=attributes ) ) @@ -321,8 +320,7 @@ function PB.register_dynamic_methods!(rj::ReactionFluxTransfer, model::PB.Model) input_attrb = Tuple(atnm=>PB.get_attribute(input_var, atnm) for atnm in (:field_data, :data_dims, :space)) push!(var_inputs, - PB.VarDep("input_"*fluxname, "mol yr-1", "flux input", - link_namestr=input_namestr, + PB.VarDep("input_"*fluxname => input_namestr, "mol yr-1", "flux input", attributes=input_attrb, ) ) @@ -333,8 +331,7 @@ function PB.register_dynamic_methods!(rj::ReactionFluxTransfer, model::PB.Model) replace(output_var_patternname, "\$fluxname\$" => fluxname) )*")" push!(var_outputs, - PB.VarContrib("output_"*fluxname, "mol yr-1", "flux output", - link_namestr=output_namestr, + PB.VarContrib("output_"*fluxname => output_namestr, "mol yr-1", "flux output", attributes=input_attrb, ) ) diff --git a/src/reactioncatalog/VariableStats.jl b/src/reactioncatalog/VariableStats.jl index f9faf96..b083542 100644 --- a/src/reactioncatalog/VariableStats.jl +++ b/src/reactioncatalog/VariableStats.jl @@ -71,7 +71,7 @@ function PB.register_methods!(rj::ReactionSum) # mark all vars_to_add as optional to help diagnose config errors # default :field_data=>PB.UndefinedData to allow Variable to link to any data type (this is checked later) push!(vars_to_add, - PB.VarDep(localname, "", "", link_namestr="("*varname*")") + PB.VarDep(localname => "("*varname*")", "", "") ) end