Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ params = hapi(CDAWeb, dataset)

# Retrieve data for specific parameters within a time range
parameters = "Magnitude,BGSEc"
start_time = DateTime(2001, 1, 1, 5, 0, 0)
end_time = DateTime(2001, 1, 1, 6, 0, 0)
data = hapi(CDAWeb, dataset, parameters, start_time, end_time)
tmin = DateTime(2001, 1, 1, 5, 0, 0)
tmax = DateTime(2001, 1, 1, 6, 0, 0)
data = hapi(CDAWeb, dataset, parameters, tmin, tmax)

# Alternative method using path format
data = get_data("CDAWeb/AC_H0_MFI/Magnitude,BGSEc", start_time, end_time)
data = get_data("CDAWeb/AC_H0_MFI/Magnitude,BGSEc", tmin, tmax)

# Access the data
Magnitude = data[1]
Expand Down
36 changes: 25 additions & 11 deletions docs/src/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,24 @@ using Dates

dataset = "AC_H0_MFI"
parameters = "Magnitude,BGSEc"
start_time = DateTime(2001, 1, 1, 5, 0, 0)
end_time = DateTime(2001, 1, 1, 6, 0, 0)
tmin = DateTime(2001, 1, 1, 5, 0, 0)
tmax = DateTime(2001, 1, 1, 6, 0, 0)

# Retrieve the data
data = hapi(CDAWeb, dataset, parameters, start_time, end_time)
data = hapi(CDAWeb, dataset, parameters, tmin, tmax)
```

### Alternative Path Format

You can also use a path-like format for data retrieval:
You can also use a path-like format for data retrieval. The path format is `"server/dataset/parameter"`, where datasets may contain slashes:

```julia
# Alternative method using path format
data = get_data("CDAWeb/AC_H0_MFI/Magnitude,BGSEc", start_time, end_time)
data = get_data("CDAWeb/AC_H0_MFI/Magnitude,BGSEc", tmin, tmax)
```

!!! note
This path format cannot handle cases where both the dataset and parameter contain slashes (e.g., dataset=`abc/123` and parameter=`p1/v1`). In such cases, use the `hapi()` function directly.

### Accessing Retrieved Data

Once you have retrieved data, you can access individual variables:
Expand Down Expand Up @@ -94,11 +96,23 @@ metadata = meta(var)

```julia
# Example with CSA (Cluster Science Archive) server
csa_dataset = "C4_CP_FGM_FULL"
csa_parameters = "B_vec_xyz_gse,B_mag"
csa_start = DateTime(2001, 6, 11, 0, 0, 0)
csa_end = DateTime(2001, 6, 11, 0, 1, 0)
csa_data = hapi(CSA, csa_dataset, csa_parameters, csa_start, csa_end)
dataset = "C4_CP_FGM_FULL"
parameters = "B_vec_xyz_gse,B_mag"
tmin = DateTime(2001, 6, 11, 0, 0, 0)
tmax = DateTime(2001, 6, 11, 0, 1, 0)
data = hapi(CSA, dataset, parameters, tmin, tmax)
```

### INTERMAGNET Example

```julia
# Example with INTERMAGNET server (datasets with slashes in names)
dataset = "aae/definitive/PT1M/xyzf"
parameters = "Field_Vector"
tmin = DateTime(2001, 6, 11, 0, 0, 0)
tmax = DateTime(2001, 6, 11, 0, 1, 0)
data = hapi(INTERMAGNET, dataset, parameters, tmin, tmax)
data = get_data("INTERMAGNET/aae/definitive/PT1M/xyzf/Field_Vector", tmin, tmax)
```

## Data Analysis
Expand Down
12 changes: 7 additions & 5 deletions src/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ end
Get data and metadata using a `path` in the format "server/dataset/parameter".
"""
function get_data(path, tmin, tmax; kwargs...)
# Split path into components
# Split path into components - handle datasets with slashes
parts = split(path, "/")
length(parts) != 3 && throw(ArgumentError("Path must be in format 'server/dataset/parameter'"))
server_id, dataset, parameters = parts
server = Server(server_id)
length(parts) < 3 && throw(ArgumentError("Path must be in format 'server/dataset/parameter'"))

# First part is server, last part is parameter, everything in between is dataset
server = Server(parts[1])
parameters = parts[end]
dataset = join(parts[2:(end - 1)], "/")

# Call the main get_data function
return get_data(server, dataset, parameters, tmin, tmax; kwargs...)
end

Expand Down
11 changes: 11 additions & 0 deletions test/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ end
@test_nowarn hapi(server, dataset, parameters, tmin, tmax)
end

@testitem "INTERMAGNET" begin
server = INTERMAGNET
dataset = "aae/definitive/PT1M/xyzf"
parameters = "Field_Vector"
start = "2001-06-11T00:00:00"
stop = "2001-06-11T00:01:00"

@test_nowarn hapi(server, dataset, parameters, start, stop)
@test_nowarn get_data("INTERMAGNET/aae/definitive/PT1M/xyzf/Field_Vector", start, stop)
end

@testitem "CDAWeb" begin
server = CDAWeb
dataset = "AC_H0_MFI"
Expand Down
Loading