Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readcubedata, read data into memory #457

Merged
merged 3 commits into from
Oct 23, 2024
Merged
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
35 changes: 34 additions & 1 deletion docs/src/UserGuide/read.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,37 @@ using Downloads: download

path = download("https://github.com/yeesian/ArchGDALDatasets/raw/307f8f0e584a39a050c042849004e6a2bd674f99/gdalworkshop/world.tif", "world.tif")
ds = open_dataset(path)
````
````

## Load data into memory

For datasets or variables that could fit in RAM, you might want to load them completely into memory. This can be done using the `readcubedata` function. As an example, let's use the NetCDF workflow; the same should be true for other cases.

### readcubedata

:::tabs

== single variable

```@example read_netcdf
readcubedata(ds.tos)
```

== with the `:` operator

```@example read_netcdf
ds.tos[:, :, :]
```

In this case, you should know in advance how many dimensions there are and how long they are, which shouldn't be hard to determine since this information is already displayed when querying such variables.

== Complete Dataset

```@example read_netcdf
ds_loaded = readcubedata(ds)
ds_loaded["tos"] # Load the variable of interest; the loaded status is shown for each variable.
```

:::

Note how the loading status changes from `loaded lazily` to `loaded in memory`.
Loading