|
| 1 | +# Usage Guide |
| 2 | + |
| 3 | +This guide provides detailed examples of how to use `HAPIClient.jl` to access heliophysics data from HAPI servers. |
| 4 | + |
| 5 | +## Basic Usage |
| 6 | + |
| 7 | +### Listing Available Servers |
| 8 | + |
| 9 | +Start by exploring what HAPI servers are available: |
| 10 | + |
| 11 | +```@example usage |
| 12 | +using HAPIClient |
| 13 | +
|
| 14 | +# List all available HAPI servers |
| 15 | +servers = hapi() |
| 16 | +``` |
| 17 | + |
| 18 | +### Getting Dataset Catalogs |
| 19 | + |
| 20 | +Once you know which servers are available, you can browse their catalogs: |
| 21 | + |
| 22 | +```@example usage |
| 23 | +# Get catalog of available datasets from CDAWeb |
| 24 | +catalog = hapi(CDAWeb) |
| 25 | +``` |
| 26 | + |
| 27 | +### Dataset Information |
| 28 | + |
| 29 | +Get detailed information about parameters in a specific dataset: |
| 30 | + |
| 31 | +```@example usage |
| 32 | +dataset = "AC_H0_MFI" |
| 33 | +params = hapi(CDAWeb, dataset) |
| 34 | +``` |
| 35 | + |
| 36 | +## Data Retrieval and Access |
| 37 | + |
| 38 | +### Basic Data Download |
| 39 | + |
| 40 | +Retrieve data for specific parameters within a time range: |
| 41 | + |
| 42 | +```@example usage |
| 43 | +using Dates |
| 44 | +
|
| 45 | +dataset = "AC_H0_MFI" |
| 46 | +parameters = "Magnitude,BGSEc" |
| 47 | +start_time = DateTime(2001, 1, 1, 5, 0, 0) |
| 48 | +end_time = DateTime(2001, 1, 1, 6, 0, 0) |
| 49 | +
|
| 50 | +# Retrieve the data |
| 51 | +data = hapi(CDAWeb, dataset, parameters, start_time, end_time) |
| 52 | +``` |
| 53 | + |
| 54 | +### Alternative Path Format |
| 55 | + |
| 56 | +You can also use a path-like format for data retrieval: |
| 57 | + |
| 58 | +```julia |
| 59 | +# Alternative method using path format |
| 60 | +data = get_data("CDAWeb/AC_H0_MFI/Magnitude,BGSEc", start_time, end_time) |
| 61 | +``` |
| 62 | + |
| 63 | +### Accessing Retrieved Data |
| 64 | + |
| 65 | +Once you have retrieved data, you can access individual variables: |
| 66 | + |
| 67 | +```@example usage |
| 68 | +Magnitude = data.Magnitude # or data[1] if you know the order (same as `parameters` order) |
| 69 | +BGSEc = data.BGSEc # or data[2] |
| 70 | +var = data[2] |
| 71 | +``` |
| 72 | + |
| 73 | +Retrieve the values |
| 74 | + |
| 75 | +```@example usage |
| 76 | +values = parent(var) |
| 77 | +``` |
| 78 | + |
| 79 | +Retrieve the timestamps |
| 80 | + |
| 81 | +```@example usage |
| 82 | +timestamps = times(var) |
| 83 | +``` |
| 84 | + |
| 85 | +Retrieve the metadata |
| 86 | + |
| 87 | +```@example usage |
| 88 | +metadata = meta(var) |
| 89 | +``` |
| 90 | + |
| 91 | +## Working with Different Servers |
| 92 | + |
| 93 | +### CSA Example |
| 94 | + |
| 95 | +```julia |
| 96 | +# Example with CSA (Cluster Science Archive) server |
| 97 | +csa_dataset = "C4_CP_FGM_FULL" |
| 98 | +csa_parameters = "B_vec_xyz_gse,B_mag" |
| 99 | +csa_start = DateTime(2001, 6, 11, 0, 0, 0) |
| 100 | +csa_end = DateTime(2001, 6, 11, 0, 1, 0) |
| 101 | +csa_data = hapi(CSA, csa_dataset, csa_parameters, csa_start, csa_end) |
| 102 | +``` |
| 103 | + |
| 104 | +## Data Analysis |
| 105 | + |
| 106 | +The retrieved data integrates well with Julia's ecosystem: |
| 107 | + |
| 108 | +```@example usage |
| 109 | +using CairoMakie |
| 110 | +
|
| 111 | +f = Figure() |
| 112 | +for (i, var) in enumerate(data) |
| 113 | + m = meta(var) |
| 114 | + ax = Axis(f[i,1]; xlabel="Time", ylabel=m["name"], title=m["description"]) |
| 115 | + t = times(var) |
| 116 | + for c in eachcol(var) |
| 117 | + lines!(t, c) |
| 118 | + end |
| 119 | + i != length(data) && hidexdecorations!(; grid=false) |
| 120 | +end |
| 121 | +f |
| 122 | +``` |
| 123 | + |
| 124 | +For advanced visualization capabilities, `HAPIClient.jl` works well with the `SPEDAS.jl` ecosystem. See the [SPEDAS.jl quickstart guide](https://JuliaSpacePhysics.github.io/SPEDAS.jl/dev/tutorials/getting-started/) for detailed visualization examples. |
0 commit comments