API Reference

CopernicusData.get_AWS_configFunction
function 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_objectMethod

function s3getobject(full_path::String) Get and object from a S3 bucket given its full path (s3://....)

CopernicusData.EOProducts.eoproduct_datasetMethod
eoproduct_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_eoproductMethod
open_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.YAXTreeType
YAXTree

A tree data structure for representing hierarchical data with optional data arrays.

Fields

  • name::String: The name of the node
  • path::String: The full path to this node in the tree
  • properties::Dict{String, Any}: Additional properties/metadata for the node
  • parent::Union{Nothing, YAXTree}: Reference to parent node, or nothing for root
  • children::Dict{String, YAXTree}: Dictionary of child nodes
  • data::Union{Nothing, YAXArray, YAXArrays.Datasets.Dataset}: Optional data associated with the node
CopernicusData.YAXTrees.YAXTreeMethod
YAXTree(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 node
  • parent=nothing: Optional parent node
  • data=nothing: Optional data to associate with the node

Returns

  • YAXTree: A new tree node
CopernicusData.YAXTrees.YAXTreeMethod
YAXTree(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.YAXTreeMethod
YAXTree()

Create a new empty YAXTree with default root node.

Returns

  • YAXTree: A new tree with root node named "root"
Base.getindexMethod
getindex(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 in
  • path::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.iterateMethod
Base.iterate(tree::YAXTree, state::YAXTreeIteratorState)
Base.iterateMethod
Base.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!Function
add_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 node
  • name::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!Function
add_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 node
  • path::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_subsetMethod
copy_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 from
  • varnames::Vector{T}: List of variable names to include in the copy, where T is either String or Symbol

Keyword Arguments

  • error::Bool=false: If true, raises an error if any variable in varnames is not present in the dataset
  • verbose::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_varsMethod
exclude_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 tree
  • varnames::Vector{String} or Vector{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.isomorphicMethod
isomorphic(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 compare
  • tree2::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_datatreeFunction
open_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 URL
  • driver::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_datatreeFunction
open_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 folder
  • mapping_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_datatreeMethod
open_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 URL
  • name::String="root": Name for the root node of the tree
  • archive::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_existsMethod
path_exists(tree::YAXTree, path::String)::Bool

Check if a path exists in the tree.

Arguments

  • tree::YAXTree: The tree to search in
  • path::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.pwhereMethod
pwhere(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 array
  • val1: Value to select when condition is true
  • val2: Value to select when condition is false
  • chunks: 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_varsMethod
select_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 tree
  • varnames::Vector{String} or Vector{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_treeFunction
show_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 display
  • prefix::String="": Prefix string for indentation
  • details::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_treeFunction
show_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 to
  • tree::YAXTree: The tree to display
  • prefix::String="": Prefix string for indentation
  • details::Bool=false: Whether to show detailed information about data nodes

Examples

buf = IOBuffer()
show_tree(buf, my_tree, details=true)
CopernicusData.YAXTrees.whereMethod
where(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 array
  • val1: Value to select when condition is true
  • val2: 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_subtreesMacro
macro 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