API Reference
CopernicusData.get_AWS_config
— Functionfunction get_AWS_config(profile::String="default")
Generate and AWS config given a profile name. To get the credentials, the function follows the priority as: 1- get aws config and credentials file as INI files in default path: ~/.aws 2- use environement varialbes (AWSSECRETACCESSKEY, AWSACCESSKEYID, ...)
CopernicusData.s3_get_object
— Methodfunction s3getobject(full_path::String) Get and object from a S3 bucket given its full path (s3://....)
CopernicusData.EOProducts.eoproduct_dataset
— Methodeoproduct_dataset(path::String)::Dict{String, Dataset}
Open a Copernicus product returns a Dict{String,Dataset} containing all the Variables stored in the product
Examples
julia> d = open_eoproduct("S3SLSLST_20191227T124111_0179_A109_T921.zarr")
CopernicusData.EOProducts.open_eoproduct
— Methodopen_eoproduct(path::String)
Open a Copernicus Zarr product returns a Dict{String,ZArray} containing all the Variables stored in the product
Examples
julia> d = open_eoproduct("S3SLSLST_20191227T124111_0179_A109_T921.zarr")
CopernicusData.YAXTrees.YAXTree
— TypeYAXTree
A tree data structure for representing hierarchical data with optional data arrays.
Fields
name::String
: The name of the nodepath::String
: The full path to this node in the treeproperties::Dict{String, Any}
: Additional properties/metadata for the nodeparent::Union{Nothing, YAXTree}
: Reference to parent node, or nothing for rootchildren::Dict{String, YAXTree}
: Dictionary of child nodesdata::Union{Nothing, YAXArray, YAXArrays.Datasets.Dataset}
: Optional data associated with the node
CopernicusData.YAXTrees.YAXTree
— MethodYAXTree(name::String; parent=nothing, data=nothing)
Create a new YAXTree node with the specified name and optional parent and data.
Arguments
name::String
: The name of the nodeparent=nothing
: Optional parent nodedata=nothing
: Optional data to associate with the node
Returns
YAXTree
: A new tree node
CopernicusData.YAXTrees.YAXTree
— MethodYAXTree(zgroup::ZGroup)
Create a YAXTree from a Zarr group structure.
Arguments
zgroup::ZGroup
: The Zarr group to convert to a tree
Returns
YAXTree
: A new tree representing the Zarr group hierarchy
CopernicusData.YAXTrees.YAXTree
— MethodYAXTree()
Create a new empty YAXTree with default root node.
Returns
YAXTree
: A new tree with root node named "root"
Base.getindex
— Methodgetindex(tree::YAXTree, path::String)::YAXTree
Access a node in the tree using a path string, where path components are separated by "/".
Arguments
tree::YAXTree
: The tree to search inpath::String
: Path to the desired node, components separated by "/"
Returns
YAXTree
: The node at the specified path
Throws
KeyError
: If any component of the path does not exist in the tree
Examples
node = tree["data/temperature/daily"] # Get node at path "data/temperature/daily"
Base.iterate
— MethodBase.iterate(tree::YAXTree, state::YAXTreeIteratorState)
Base.iterate
— MethodBase.iterate(tree::YAXTree)
Creates an iterator that traverses the YAXTree
in a depth-first, pre-order fashion.
This iterator yields each node in the tree, ensuring that no node is visited twice, even if children share the same name. The path of each node is used as a unique identifier.
Examples
# Assuming a YAXTree 'my_tree' is defined:
for node in my_tree
println(node.name, " at path ", node.path)
end
CopernicusData.YAXTrees.add_children!
— Functionadd_children!(tree::YAXTree, name::Union{String,Symbol}, data::Union{Nothing, YAXArray, YAXArrays.Datasets.Dataset}=nothing)
Add a child node to the tree with the given name and optional data.
Arguments
tree::YAXTree
: The parent tree nodename::Union{String,Symbol}
: Name of the new child node (must not contain '/')data::Union{Nothing, YAXArray, YAXArrays.Datasets.Dataset}=nothing
: Optional data to associate with the node
Throws
ArgumentError
: If the name contains '/' or if a child with the same name already exists
Examples
add_children!(tree, "temperature", temperature_data)
add_children!(tree, :pressure) # Add empty node
CopernicusData.YAXTrees.add_children_full_path!
— Functionadd_children_full_path!(tree::YAXTree, path::String, data::Union{Nothing, YAXArray, YAXArrays.Datasets.Dataset}=nothing)
Add nodes to the tree following a full path, creating intermediate nodes as needed.
Arguments
tree::YAXTree
: The root tree nodepath::String
: Full path of nodes to create, components separated by "/"data::Union{Nothing, YAXArray, YAXArrays.Datasets.Dataset}=nothing
: Optional data to associate with the leaf node
Examples
# Creates nodes "data", "temperature", and "daily" if they don't exist
add_children_full_path!(tree, "data/temperature/daily", temp_data)
CopernicusData.YAXTrees.copy_subset
— Methodcopy_subset(x::YAXArrays.Datasets.Dataset, varnames::Vector{T}; error::Bool=false, verbose::Bool=true)::YAXArrays.Datasets.Dataset
Create a copy of a dataset containing only the specified variables.
Arguments
x::YAXArrays.Datasets.Dataset
: The source dataset to copy fromvarnames::Vector{T}
: List of variable names to include in the copy, whereT
is eitherString
orSymbol
Keyword Arguments
error::Bool=false
: If true, raises an error if any variable invarnames
is not present in the datasetverbose::Bool=true
: If true, logs warnings for variables that are not found in the dataset
Returns
YAXArrays.Datasets.Dataset
: A new dataset containing only the specified variables
Examples
new_dataset = copy_subset(original_dataset, ["temperature", "pressure"])
# or
new_dataset = copy_subset(original_dataset, [:temperature, :pressure])
CopernicusData.YAXTrees.exclude_vars
— Methodexclude_vars(tree::YAXTree, varnames::Vector{T}; drop::Bool=false)::YAXTree where T <: Union{String,Symbol}
Create a new YAXTree excluding the specified variables.
Arguments
tree::YAXTree
: The source treevarnames::Vector{String}
orVector{Symbol}
: List of variable names to exclude
Keyword Arguments
drop::Bool=false
: If true, remove nodes that do not contain any of the specified variables.
If false, keep nodes even with empty dataset, to preserve the tree structure
Returns
YAXTree
: A new tree excluding the specified variables
Examples
new_tree = exclude_vars(tree, ["temperature", "pressure"])
# or
new_tree = exclude_vars(tree, [:temperature, :pressure])
CopernicusData.YAXTrees.isomorphic
— Methodisomorphic(tree1::YAXTree, tree2::YAXTree)::Bool
Check if two YAXTree structures are isomorphic. Two YAXTree
are isomorphic if they have the exact same tree structure and if the data contained in equivalent node is the same type (YAXArrays.YAXArray
or YAXArrays.Datasets.Dataset
) and have the same variables and same dimensions.
Arguments
tree1::YAXTree
: The first tree to comparetree2::YAXTree
: The second tree to compare
Returns
Bool
:true
if the trees are isomorphic,false
otherwise
Examples
isomorphic(tree1, tree2) # Returns true if both trees have the same structure and data
CopernicusData.YAXTrees.open_datatree
— Functionopen_datatree(path::String, driver::Union{Nothing,Symbol}=nothing; name::String="root", mapping::Union{Nothing, String}=nothing)::YAXTree
Open a data product and create a YAXTree representation of its structure. The driver is automatically detected from the file extension or can be specified manually.
Arguments
path::String
: Path to the data product, can be local file/directory or S3 URLdriver::Union{Nothing,Symbol}=nothing
: Optional driver specification. Supported values::zarr
: For Zarr format files/directories:sen3
: For Sentinel-3 SEN3 format:json
: For JSON files
name::String="root"
: Name for the root node of the tree
Returns
YAXTree
: A tree representation of the data product structure
Throws
Exception
: If the file doesn't exist or the driver is not supported
Examples
# Auto-detect driver from extension
dt = open_datatree("S03SLSLST_20191227T124111_0179_A109_T921.zarr")
# Explicitly specify driver
dt = open_datatree("data.SEN3", :sen3)
# Open from S3
dt = open_datatree("s3://bucket/path/data.zarr")
CopernicusData.YAXTrees.open_sen3_datatree
— Functionopen_sen3_datatree(path::String, mapping_file::String)::YAXTree
Open a Sentinel-3 SEN3 product folder and create a YAXTree representation based on a mapping file.
Arguments
path::String
: Path to the SEN3 product foldermapping_file::String
: Path to the JSON mapping file that defines how to organize the data
Returns
YAXTree
: A tree representation of the Sentinel-3 data structure
Throws
Exception
: If the folder doesn't exist or can't be opened
CopernicusData.YAXTrees.open_zarr_datatree
— Methodopen_zarr_datatree(path::String; name::String="root", archive::Bool=false)::YAXTree
Open a Zarr format file/directory and create a YAXTree representation. Supports both local and S3 paths, and optionally handles ZIP archives containing Zarr data.
Arguments
path::String
: Path to Zarr file/directory, can be local or S3 URLname::String="root"
: Name for the root node of the treearchive::Bool=false
: Set to true if path points to a ZIP archive containing Zarr data
Returns
YAXTree
: A tree representation of the Zarr data structure
Throws
Exception
: If the file/directory doesn't exist
Examples
# Open local Zarr directory
tree = open_zarr_datatree("data.zarr")
# Open Zarr from ZIP archive
tree = open_zarr_datatree("data.zarr.zip", archive=true)
# Open from S3
tree = open_zarr_datatree("s3://bucket/data.zarr")
CopernicusData.YAXTrees.path_exists
— Methodpath_exists(tree::YAXTree, path::String)::Bool
Check if a path exists in the tree.
Arguments
tree::YAXTree
: The tree to search inpath::String
: Path to check, components separated by "/"
Returns
Bool
: true if path exists, false otherwise
Examples
if is_path_exists(tree, "data/temperature/daily")
node = tree["data/temperature/daily"]
end
CopernicusData.YAXTrees.pwhere
— Methodpwhere(cond::YAXArray{Bool}, val1, val2, chunks)
Parallel version of where
that operates on chunked arrays for improved performance with large datasets.
Arguments
cond::YAXArray{Bool}
: Boolean condition arrayval1
: Value to select when condition is trueval2
: Value to select when condition is falsechunks
: Chunk specification for parallel processing
Returns
YAXArray
: Chunked array where each element is val1 where cond is true, val2 otherwise
Examples
# Process large array in parallel chunks
result = pwhere(large_condition, a, b, (1000, 1000))
CopernicusData.YAXTrees.select_vars
— Methodselect_vars(tree::YAXTree, varnames::Vector{T})::YAXTree where T <: Union{String,Symbol}
Create a new YAXTree containing only the specified variables.
Arguments
tree::YAXTree
: The source treevarnames::Vector{String}
orVector{Symbol}
: List of variable names to select
Keyword Arguments
exclusive::Bool=false
: If true, only include the specified variables and remove all others.
In the case when a node has only variable different from the specified ones, the node is removed. If false, keep only the specified variables from nodes which contains all or some of them, but do not affect nodes that do not contain any of the specified variables.
Returns
YAXTree
: A new tree containing only the selected variables
Examples
new_tree = select_vars(tree, ["temperature", "pressure"])
# or
new_tree = select_vars(tree, [:temperature, :pressure])
CopernicusData.YAXTrees.show_tree
— Functionshow_tree(tree::YAXTree, prefix::String = ""; details::Bool=false)
Display a tree structure in a hierarchical format with optional detailed information.
Arguments
tree::YAXTree
: The tree to displayprefix::String=""
: Prefix string for indentationdetails::Bool=false
: Whether to show detailed information about data nodes
Examples
show_tree(my_tree) # Basic display
show_tree(my_tree, details=true) # Show with data details
CopernicusData.YAXTrees.show_tree
— Functionshow_tree(io::IO, tree::YAXTree, prefix::String = ""; details::Bool = false)
Display a tree structure to an IO stream in a hierarchical format with optional detailed information.
Arguments
io::IO
: The IO stream to write totree::YAXTree
: The tree to displayprefix::String=""
: Prefix string for indentationdetails::Bool=false
: Whether to show detailed information about data nodes
Examples
buf = IOBuffer()
show_tree(buf, my_tree, details=true)
CopernicusData.YAXTrees.where
— Methodwhere(cond::YAXArray{Bool}, val1, val2)::YAXArray
Element-wise conditional selection between two values based on a boolean condition array.
Arguments
cond::YAXArray{Bool}
: Boolean condition arrayval1
: Value to select when condition is trueval2
: Value to select when condition is false
Returns
YAXArray
: Array where each element is val1 where cond is true, val2 otherwise
Examples
# Create array with values from a where condition is true, b otherwise
result = where(condition_array, a, b)
CopernicusData.YAXTrees.@map_over_subtrees
— Macromacro map_over_subtrees(func, tree)
Map a function func
over all the nodes of a YAXTree structure which contains a YAXArray or YAXArrays.Datasets.Dataset
Examples
# Assuming a YAXTree 'my_tree' is defined:
f(tree::YAXTree) = @show tree.name
YAXTrees.@map_over_subtrees f my_tree