From 6f9a43d5ea88ddd03f5ce9c1cccd671d640968c2 Mon Sep 17 00:00:00 2001 From: Antonio <43267076+aasdelat@users.noreply.github.com> Date: Thu, 11 Jul 2024 16:59:43 +0100 Subject: [PATCH 01/10] Update faq.md Remake of the "How do I subset a Cube? " section in order to incorporate information of various ways of selection, including selecting a variable based on the values of another variable with which it shares a dimension. --- docs/src/UserGuide/faq.md | 206 +++++++++++++++++++++++++++++++++++--- 1 file changed, 192 insertions(+), 14 deletions(-) diff --git a/docs/src/UserGuide/faq.md b/docs/src/UserGuide/faq.md index b292ca31..e177347e 100644 --- a/docs/src/UserGuide/faq.md +++ b/docs/src/UserGuide/faq.md @@ -77,46 +77,224 @@ Now we can concatenate `ds1` and `ds2`: dsfinal = concatenatecubes([ds1, ds2], Dim{:Variables}(["var1", "var2"])) ```` -## How do I subset a Cube? +## How do I subset a YAXArray, Cube or Dataset? -Let's start by creating a dummy cube. Define the time span of the cube +These are the three main datatypes provided by the YAXArrays libray. You can find a description of them [here](https://juliadatacubes.github.io/YAXArrays.jl/dev/UserGuide/types). + +### Subsetting a YAXArray + +Let's start by creating a dummy YAXArray. + +Firstly, load the required libraries +````@example howdoi +using YAXArrays +usinng Dates # To generate the dates of the time axis +using DimensionalData # To use the "Between" option for selecting data +```` + +Define the time span of the YAXArray ````@example howdoi -using Dates t = Date("2020-01-01"):Month(1):Date("2022-12-31") ```` -create cube axes +create YAXArray axes ````@example howdoi axes = (Dim{:Lon}(1:10), Dim{:Lat}(1:10), Dim{:Time}(t)) ```` -assign values to a cube +create the YAXArray + +````@ansi howdoi +y = YAXArray(axes, reshape(1:3600, (10, 10, 36))) +```` +````@ansi howdoi +╭────────────────────────────╮ +│ 10×10×36 YAXArray{Int64,3} │ +├────────────────────────────┴──────────────────────────────────────────────────────────── dims ┐ + ↓ Lon Sampled{Int64} 1:10 ForwardOrdered Regular Points, + → Lat Sampled{Int64} 1:10 ForwardOrdered Regular Points, + ↗ Time Sampled{Date} Date("2020-01-01"):Month(1):Date("2022-12-01") ForwardOrdered Regular Points +├───────────────────────────────────────────────────────────────────────────────────── metadata ┤ + Dict{String, Any}() +├──────────────────────────────────────────────────────────────────────────────────── file size ┤ + file size: 28.12 KB +└───────────────────────────────────────────────────────────────────────────────────────────────┘ +```` + +Now we subset the YAXArray by any dimension. + +Subset YAXArray by years ````@ansi howdoi -c = YAXArray(axes, reshape(1:3600, (10, 10, 36))) +ytime = y[Time=Between(Date(2021,1,1), Date(2021,12,31))] +```` +````@ansi howdoi +╭────────────────────────────╮ +│ 10×10×12 YAXArray{Int64,3} │ +├────────────────────────────┴──────────────────────────────────────────────────────────── dims ┐ + ↓ Lon Sampled{Int64} 1:10 ForwardOrdered Regular Points, + → Lat Sampled{Int64} 1:10 ForwardOrdered Regular Points, + ↗ Time Sampled{Date} Date("2021-01-01"):Month(1):Date("2021-12-01") ForwardOrdered Regular Points +├───────────────────────────────────────────────────────────────────────────────────── metadata ┤ + Dict{String, Any}() +├──────────────────────────────────────────────────────────────────────────────────── file size ┤ + file size: 9.38 KB +└───────────────────────────────────────────────────────────────────────────────────────────────┘ ```` -Now we subset the cube by any dimension. +Subset YAXArray by a specific date + +````@ansi howdoi +ytime2 = y[Time=At(Date("2021-05-01"))] +```` +````@ansi howdoi +╭─────────────────────────╮ +│ 10×10 YAXArray{Int64,2} │ +├─────────────────────────┴────────────────────────── dims ┐ + ↓ Lon Sampled{Int64} 1:10 ForwardOrdered Regular Points, + → Lat Sampled{Int64} 1:10 ForwardOrdered Regular Points +├──────────────────────────────────────────────── metadata ┤ + Dict{String, Any}() +├─────────────────────────────────────────────── file size ┤ + file size: 800.0 bytes +└──────────────────────────────────────────────────────────┘ +```` +Subset YAXArray by a date range +````@ansi howdoi +ytime3 = y[Time=Date("2021-05-01") .. Date("2021-12-01")] +```` +````@ansi howdoi +╭───────────────────────────╮ +│ 10×10×8 YAXArray{Int64,3} │ +├───────────────────────────┴───────────────────────────────────────────────────────────── dims ┐ + ↓ Lon Sampled{Int64} 1:10 ForwardOrdered Regular Points, + → Lat Sampled{Int64} 1:10 ForwardOrdered Regular Points, + ↗ Time Sampled{Date} Date("2021-05-01"):Month(1):Date("2021-12-01") ForwardOrdered Regular Points +├───────────────────────────────────────────────────────────────────────────────────── metadata ┤ + Dict{String, Any}() +├──────────────────────────────────────────────────────────────────────────────────── file size ┤ + file size: 6.25 KB +└───────────────────────────────────────────────────────────────────────────────────────────────┘ +```` -Subset cube by years +Subset YAXArray by longitude and latitude ````@ansi howdoi -ctime = c[Time=Between(Date(2021,1,1), Date(2021,12,31))] +ylonlat = y[Lon=1 .. 5, Lat=5 .. 10] # check even numbers range, it is ommiting them ```` +````@ansi howdoi +╭──────────────────────────╮ +│ 5×6×36 YAXArray{Int64,3} │ +├──────────────────────────┴────────────────────────────────────────────────────────────── dims ┐ + ↓ Lon Sampled{Int64} 1:5 ForwardOrdered Regular Points, + → Lat Sampled{Int64} 5:10 ForwardOrdered Regular Points, + ↗ Time Sampled{Date} Date("2020-01-01"):Month(1):Date("2022-12-01") ForwardOrdered Regular Points +├───────────────────────────────────────────────────────────────────────────────────── metadata ┤ + Dict{String, Any}() +├──────────────────────────────────────────────────────────────────────────────────── file size ┤ + file size: 8.44 KB +└───────────────────────────────────────────────────────────────────────────────────────────────┘ +```` + +### Subsetting a Cube -Subset cube by a specific date and date range +A cube can be subsetted just in the same manner as a YAXArray. +### Subsetting a Dataset + +In a dataset, we can have several variables (YAXArrays) that share some or all of their dimensions. + +#### Subsetting a Dataset whose variables share all their dimensions + +This works the same as for YAXArrays and Cubes. Let's make an example. + +````@ansi howdoi +using YAXArrays +using Dates # To generate the dates of the time axis +using DimensionalData # To use the "Between" option for selecting data + +t = Date("2020-01-01"):Month(1):Date("2022-12-31") +axes = (Dim{:Lon}(1:10), Dim{:Lat}(1:10), Dim{:Time}(t)) + +var1 = YAXArray(axes, reshape(1:3600, (10, 10, 36))) +var2 = YAXArray(axes, reshape((1:3600)*5, (10, 10, 36))) + +ds = Dataset(; var1=var1, var2=var2) +```` +````@ansi howdoi +YAXArray Dataset +Shared Axes: +↓ Lon Sampled{Int64} 1:10 ForwardOrdered Regular Points, +→ Lat Sampled{Int64} 1:10 ForwardOrdered Regular Points, +↗ Time Sampled{Date} Date("2020-01-01"):Month(1):Date("2022-12-01") ForwardOrdered Regular Points +Variables: +var1, var2, +```` ````@ansi howdoi -ctime2 = c[Time=At(Date("2021-05-01"))] -ctime3 = c[Time=Date("2021-05-01") .. Date("2021-12-01")] +ds_lonlat = ds[Lon=1 .. 5, Lat=5 .. 10] ```` +````@ansi howdoi +YAXArray Dataset +Shared Axes: +↓ Lon Sampled{Int64} 1:5 ForwardOrdered Regular Points, +→ Lat Sampled{Int64} 5:10 ForwardOrdered Regular Points, +↗ Time Sampled{Date} Date("2020-01-01"):Month(1):Date("2022-12-01") ForwardOrdered Regular Points +Variables: +var1, var2, +```` + +#### Subsetting a Dataset whose variables share some but not all of their dimensions + +In this case, if we subset by the common dimension/s, this works the same as for YAXArrays, Cubes, and datasets that share all their dimensions. + +But we can also subset a variable by the values os another variable with wich it shares some dimensions. Let's make an example. +````@ansi howdoi +using YAXArrays +using Dates # To generate the dates of the time axis +using DimensionalData # To use the "Between" option for selecting data -Subset cube by longitude and latitude +t = Date("2020-01-01"):Month(1):Date("2022-12-31") +common_axis = Dim{:points}(1:100) +time_axis = Dim{:Time}(t) + +# Note that longitudes and latitudes are not dimensions, but YAXArrays +longitudes = YAXArray((common_axis,), rand(1:369, 100)) # 100 random values taken from 1 to 359 +latitudes = YAXArray((common_axis,), rand(0:90, 100)) # 100 random values taken from 0 to 90 +temperature = YAXArray((common_axis, time_axis), rand(-40:40, (100, 36))) +ds = Dataset(; longitudes=longitudes, latitudes=latitudes, temperature=temperature) +```` +````@ansi howdoi +YAXArray Dataset +Shared Axes: +↓ points Sampled{Int64} 1:100 ForwardOrdered Regular Points +Variables: +longitudes, latitudes, +temperature + ↓ Time Sampled{Date} Date("2020-01-01"):Month(1):Date("2022-12-01") ForwardOrdered Regular Points +```` +Select all points above between 20ºN to 85ºN, and 0ºE to 180ºE +````@ansi howdoi +ds_subset = ds[points = Where(p-> ds["latitudes"][p] >= 20 && ds["latitudes"][p] <= 80 && + ds["longitudes"][p] >= 0 && ds["longitudes"][p] <= 180 + ) + ] +```` ````@ansi howdoi -clonlat = c[Lon=1 .. 5, Lat=5 .. 10] # check even numbers range, it is ommiting them +YAXArray Dataset +Shared Axes: +() +Variables: + +longitudes + ↓ points Sampled{Int64} [1, 3, …, 95, 98] ForwardOrdered Irregular Points +latitudes + ↓ points Sampled{Int64} [1, 3, …, 95, 98] ForwardOrdered Irregular Points +temperature + ↓ points Sampled{Int64} [1, 3, …, 95, 98] ForwardOrdered Irregular Points, + → Time Sampled{Date} Date("2020-01-01"):Month(1):Date("2022-12-01") ForwardOrdered Regular Points ```` ## How do I apply map algebra? From 65050d39a532757ea148db3d74e5561301f899b7 Mon Sep 17 00:00:00 2001 From: Antonio <43267076+aasdelat@users.noreply.github.com> Date: Tue, 23 Jul 2024 13:06:38 +0100 Subject: [PATCH 02/10] Update faq.md Eliminated explicit output blocks. Added information about subsetting when the data is not loaded into memory. --- docs/src/UserGuide/faq.md | 178 +++++++++----------------------------- 1 file changed, 40 insertions(+), 138 deletions(-) diff --git a/docs/src/UserGuide/faq.md b/docs/src/UserGuide/faq.md index e177347e..fcc9818e 100644 --- a/docs/src/UserGuide/faq.md +++ b/docs/src/UserGuide/faq.md @@ -86,117 +86,50 @@ These are the three main datatypes provided by the YAXArrays libray. You can fin Let's start by creating a dummy YAXArray. Firstly, load the required libraries -````@example howdoi +```@example howdoi using YAXArrays -usinng Dates # To generate the dates of the time axis +using Dates # To generate the dates of the time axis using DimensionalData # To use the "Between" option for selecting data -```` +``` Define the time span of the YAXArray -````@example howdoi +```@example howdoi t = Date("2020-01-01"):Month(1):Date("2022-12-31") -```` +``` create YAXArray axes -````@example howdoi +```@example howdoi axes = (Dim{:Lon}(1:10), Dim{:Lat}(1:10), Dim{:Time}(t)) -```` +``` create the YAXArray - -````@ansi howdoi +```@example howdoi y = YAXArray(axes, reshape(1:3600, (10, 10, 36))) -```` -````@ansi howdoi -╭────────────────────────────╮ -│ 10×10×36 YAXArray{Int64,3} │ -├────────────────────────────┴──────────────────────────────────────────────────────────── dims ┐ - ↓ Lon Sampled{Int64} 1:10 ForwardOrdered Regular Points, - → Lat Sampled{Int64} 1:10 ForwardOrdered Regular Points, - ↗ Time Sampled{Date} Date("2020-01-01"):Month(1):Date("2022-12-01") ForwardOrdered Regular Points -├───────────────────────────────────────────────────────────────────────────────────── metadata ┤ - Dict{String, Any}() -├──────────────────────────────────────────────────────────────────────────────────── file size ┤ - file size: 28.12 KB -└───────────────────────────────────────────────────────────────────────────────────────────────┘ -```` - +``` Now we subset the YAXArray by any dimension. Subset YAXArray by years -````@ansi howdoi +```@example howdoi ytime = y[Time=Between(Date(2021,1,1), Date(2021,12,31))] -```` -````@ansi howdoi -╭────────────────────────────╮ -│ 10×10×12 YAXArray{Int64,3} │ -├────────────────────────────┴──────────────────────────────────────────────────────────── dims ┐ - ↓ Lon Sampled{Int64} 1:10 ForwardOrdered Regular Points, - → Lat Sampled{Int64} 1:10 ForwardOrdered Regular Points, - ↗ Time Sampled{Date} Date("2021-01-01"):Month(1):Date("2021-12-01") ForwardOrdered Regular Points -├───────────────────────────────────────────────────────────────────────────────────── metadata ┤ - Dict{String, Any}() -├──────────────────────────────────────────────────────────────────────────────────── file size ┤ - file size: 9.38 KB -└───────────────────────────────────────────────────────────────────────────────────────────────┘ -```` +``` Subset YAXArray by a specific date - -````@ansi howdoi +```@example howdoi ytime2 = y[Time=At(Date("2021-05-01"))] -```` -````@ansi howdoi -╭─────────────────────────╮ -│ 10×10 YAXArray{Int64,2} │ -├─────────────────────────┴────────────────────────── dims ┐ - ↓ Lon Sampled{Int64} 1:10 ForwardOrdered Regular Points, - → Lat Sampled{Int64} 1:10 ForwardOrdered Regular Points -├──────────────────────────────────────────────── metadata ┤ - Dict{String, Any}() -├─────────────────────────────────────────────── file size ┤ - file size: 800.0 bytes -└──────────────────────────────────────────────────────────┘ -```` +``` Subset YAXArray by a date range -````@ansi howdoi +```@example howdoi ytime3 = y[Time=Date("2021-05-01") .. Date("2021-12-01")] -```` -````@ansi howdoi -╭───────────────────────────╮ -│ 10×10×8 YAXArray{Int64,3} │ -├───────────────────────────┴───────────────────────────────────────────────────────────── dims ┐ - ↓ Lon Sampled{Int64} 1:10 ForwardOrdered Regular Points, - → Lat Sampled{Int64} 1:10 ForwardOrdered Regular Points, - ↗ Time Sampled{Date} Date("2021-05-01"):Month(1):Date("2021-12-01") ForwardOrdered Regular Points -├───────────────────────────────────────────────────────────────────────────────────── metadata ┤ - Dict{String, Any}() -├──────────────────────────────────────────────────────────────────────────────────── file size ┤ - file size: 6.25 KB -└───────────────────────────────────────────────────────────────────────────────────────────────┘ -```` +``` Subset YAXArray by longitude and latitude -````@ansi howdoi +```@example howdoi ylonlat = y[Lon=1 .. 5, Lat=5 .. 10] # check even numbers range, it is ommiting them -```` -````@ansi howdoi -╭──────────────────────────╮ -│ 5×6×36 YAXArray{Int64,3} │ -├──────────────────────────┴────────────────────────────────────────────────────────────── dims ┐ - ↓ Lon Sampled{Int64} 1:5 ForwardOrdered Regular Points, - → Lat Sampled{Int64} 5:10 ForwardOrdered Regular Points, - ↗ Time Sampled{Date} Date("2020-01-01"):Month(1):Date("2022-12-01") ForwardOrdered Regular Points -├───────────────────────────────────────────────────────────────────────────────────── metadata ┤ - Dict{String, Any}() -├──────────────────────────────────────────────────────────────────────────────────── file size ┤ - file size: 8.44 KB -└───────────────────────────────────────────────────────────────────────────────────────────────┘ -```` +``` ### Subsetting a Cube @@ -210,7 +143,7 @@ In a dataset, we can have several variables (YAXArrays) that share some or all o This works the same as for YAXArrays and Cubes. Let's make an example. -````@ansi howdoi +```@example howdoi using YAXArrays using Dates # To generate the dates of the time axis using DimensionalData # To use the "Between" option for selecting data @@ -222,38 +155,21 @@ var1 = YAXArray(axes, reshape(1:3600, (10, 10, 36))) var2 = YAXArray(axes, reshape((1:3600)*5, (10, 10, 36))) ds = Dataset(; var1=var1, var2=var2) -```` -````@ansi howdoi -YAXArray Dataset -Shared Axes: -↓ Lon Sampled{Int64} 1:10 ForwardOrdered Regular Points, -→ Lat Sampled{Int64} 1:10 ForwardOrdered Regular Points, -↗ Time Sampled{Date} Date("2020-01-01"):Month(1):Date("2022-12-01") ForwardOrdered Regular Points -Variables: -var1, var2, -```` -````@ansi howdoi +``` +```@example howdoi ds_lonlat = ds[Lon=1 .. 5, Lat=5 .. 10] -```` -````@ansi howdoi -YAXArray Dataset -Shared Axes: -↓ Lon Sampled{Int64} 1:5 ForwardOrdered Regular Points, -→ Lat Sampled{Int64} 5:10 ForwardOrdered Regular Points, -↗ Time Sampled{Date} Date("2020-01-01"):Month(1):Date("2022-12-01") ForwardOrdered Regular Points -Variables: -var1, var2, -```` - +``` #### Subsetting a Dataset whose variables share some but not all of their dimensions In this case, if we subset by the common dimension/s, this works the same as for YAXArrays, Cubes, and datasets that share all their dimensions. -But we can also subset a variable by the values os another variable with wich it shares some dimensions. Let's make an example. -````@ansi howdoi +But we can also subset a variable by the values of another variable with wich it shares some dimensions. +**Important:** If your data is not loaded into memory, the selection will be too slow. So, you have load into memory, at least, the variable with which you make the selection. +Let's make an example. +```@example howdoi using YAXArrays using Dates # To generate the dates of the time axis -using DimensionalData # To use the "Between" option for selecting data +using DimensionalData # To use the "Between" selector for selecting data t = Date("2020-01-01"):Month(1):Date("2022-12-31") common_axis = Dim{:points}(1:100) @@ -265,37 +181,23 @@ latitudes = YAXArray((common_axis,), rand(0:90, 100)) # 100 random values take temperature = YAXArray((common_axis, time_axis), rand(-40:40, (100, 36))) ds = Dataset(; longitudes=longitudes, latitudes=latitudes, temperature=temperature) -```` -````@ansi howdoi -YAXArray Dataset -Shared Axes: -↓ points Sampled{Int64} 1:100 ForwardOrdered Regular Points -Variables: -longitudes, latitudes, -temperature - ↓ Time Sampled{Date} Date("2020-01-01"):Month(1):Date("2022-12-01") ForwardOrdered Regular Points -```` +``` Select all points above between 20ºN to 85ºN, and 0ºE to 180ºE -````@ansi howdoi +```@example howdoi ds_subset = ds[points = Where(p-> ds["latitudes"][p] >= 20 && ds["latitudes"][p] <= 80 && ds["longitudes"][p] >= 0 && ds["longitudes"][p] <= 180 - ) - ] -```` -````@ansi howdoi -YAXArray Dataset -Shared Axes: -() -Variables: - -longitudes - ↓ points Sampled{Int64} [1, 3, …, 95, 98] ForwardOrdered Irregular Points -latitudes - ↓ points Sampled{Int64} [1, 3, …, 95, 98] ForwardOrdered Irregular Points -temperature - ↓ points Sampled{Int64} [1, 3, …, 95, 98] ForwardOrdered Irregular Points, - → Time Sampled{Date} Date("2020-01-01"):Month(1):Date("2022-12-01") ForwardOrdered Regular Points -```` + ) # Where + ] # ds +``` +If your dataset has been read from a file with `Cube` it is not loaded into memory, and you have to load the `latitudes` and `longitudes` YAXArrays into memory: +```@example howdoi +latitudes_yasxa = readcubedata(ds["latitudes"]) +longitudes_yasxa = readcubedata(ds["longitudes"]) +ds_subset = ds[points = Where(p-> latitudes_yasxa[p] >= 20 && latitudes_yasxa[p] <= 80 && + longitudes_yasxa[p] >= 0 && longitudes_yasxa[p] <= 180 + ) # Where + ] # ds +``` ## How do I apply map algebra? From 039728ba5c3c9773f632a067852252985f9d5f25 Mon Sep 17 00:00:00 2001 From: Antonio <43267076+aasdelat@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:23:44 +0100 Subject: [PATCH 03/10] Update docs/src/UserGuide/faq.md Co-authored-by: Lazaro Alonso --- docs/src/UserGuide/faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/UserGuide/faq.md b/docs/src/UserGuide/faq.md index fcc9818e..a8a53078 100644 --- a/docs/src/UserGuide/faq.md +++ b/docs/src/UserGuide/faq.md @@ -77,7 +77,7 @@ Now we can concatenate `ds1` and `ds2`: dsfinal = concatenatecubes([ds1, ds2], Dim{:Variables}(["var1", "var2"])) ```` -## How do I subset a YAXArray, Cube or Dataset? +## How do I subset a YAXArray ( Cube ) or Dataset? These are the three main datatypes provided by the YAXArrays libray. You can find a description of them [here](https://juliadatacubes.github.io/YAXArrays.jl/dev/UserGuide/types). From 5a54f71e15eea9d210f952a19d9adf6e7ba30af1 Mon Sep 17 00:00:00 2001 From: Antonio <43267076+aasdelat@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:24:56 +0100 Subject: [PATCH 04/10] Update docs/src/UserGuide/faq.md Co-authored-by: Lazaro Alonso --- docs/src/UserGuide/faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/UserGuide/faq.md b/docs/src/UserGuide/faq.md index a8a53078..dea8c873 100644 --- a/docs/src/UserGuide/faq.md +++ b/docs/src/UserGuide/faq.md @@ -89,7 +89,7 @@ Firstly, load the required libraries ```@example howdoi using YAXArrays using Dates # To generate the dates of the time axis -using DimensionalData # To use the "Between" option for selecting data +using DimensionalData # To use the "Between" option for selecting data, however the intervals notation should be used instead, i.e. `a .. b`. ``` Define the time span of the YAXArray From 4c54d912c063c245a8cd4532fb104b5d64a36a30 Mon Sep 17 00:00:00 2001 From: Antonio <43267076+aasdelat@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:25:18 +0100 Subject: [PATCH 05/10] Update docs/src/UserGuide/faq.md Co-authored-by: Lazaro Alonso --- docs/src/UserGuide/faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/UserGuide/faq.md b/docs/src/UserGuide/faq.md index dea8c873..10270e51 100644 --- a/docs/src/UserGuide/faq.md +++ b/docs/src/UserGuide/faq.md @@ -141,7 +141,7 @@ In a dataset, we can have several variables (YAXArrays) that share some or all o #### Subsetting a Dataset whose variables share all their dimensions -This works the same as for YAXArrays and Cubes. Let's make an example. +This works for YAXArrays. Let's make an example. ```@example howdoi using YAXArrays From 2386acd0075513d59ea196176e39a07261f8ef24 Mon Sep 17 00:00:00 2001 From: Antonio <43267076+aasdelat@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:25:39 +0100 Subject: [PATCH 06/10] Update docs/src/UserGuide/faq.md Co-authored-by: Lazaro Alonso --- docs/src/UserGuide/faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/UserGuide/faq.md b/docs/src/UserGuide/faq.md index 10270e51..82853fb5 100644 --- a/docs/src/UserGuide/faq.md +++ b/docs/src/UserGuide/faq.md @@ -163,7 +163,7 @@ ds_lonlat = ds[Lon=1 .. 5, Lat=5 .. 10] In this case, if we subset by the common dimension/s, this works the same as for YAXArrays, Cubes, and datasets that share all their dimensions. -But we can also subset a variable by the values of another variable with wich it shares some dimensions. +But we can also subset a variable by the values of another variable with which it shares some dimensions. **Important:** If your data is not loaded into memory, the selection will be too slow. So, you have load into memory, at least, the variable with which you make the selection. Let's make an example. ```@example howdoi From 0bbc5e0a5e98685d3a2ff800f02fa8dfc7cb4b58 Mon Sep 17 00:00:00 2001 From: Antonio <43267076+aasdelat@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:25:57 +0100 Subject: [PATCH 07/10] Update docs/src/UserGuide/faq.md Co-authored-by: Lazaro Alonso --- docs/src/UserGuide/faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/UserGuide/faq.md b/docs/src/UserGuide/faq.md index 82853fb5..87155494 100644 --- a/docs/src/UserGuide/faq.md +++ b/docs/src/UserGuide/faq.md @@ -182,7 +182,7 @@ temperature = YAXArray((common_axis, time_axis), rand(-40:40, (100, 36))) ds = Dataset(; longitudes=longitudes, latitudes=latitudes, temperature=temperature) ``` -Select all points above between 20ºN to 85ºN, and 0ºE to 180ºE +Select all points between 20ºN and 85ºN, and 0ºE to 180ºE ```@example howdoi ds_subset = ds[points = Where(p-> ds["latitudes"][p] >= 20 && ds["latitudes"][p] <= 80 && ds["longitudes"][p] >= 0 && ds["longitudes"][p] <= 180 From 98690da43cb5342534cb1fab97f8fa73614825a1 Mon Sep 17 00:00:00 2001 From: Antonio <43267076+aasdelat@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:31:44 +0100 Subject: [PATCH 08/10] Update faq.md Take into account that a Cube is no more than a YAXArray. So, the explicit section about Cubes has been deleted. --- docs/src/UserGuide/faq.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docs/src/UserGuide/faq.md b/docs/src/UserGuide/faq.md index 87155494..66b663a5 100644 --- a/docs/src/UserGuide/faq.md +++ b/docs/src/UserGuide/faq.md @@ -79,7 +79,7 @@ dsfinal = concatenatecubes([ds1, ds2], Dim{:Variables}(["var1", "var2"])) ## How do I subset a YAXArray ( Cube ) or Dataset? -These are the three main datatypes provided by the YAXArrays libray. You can find a description of them [here](https://juliadatacubes.github.io/YAXArrays.jl/dev/UserGuide/types). +These are the three main datatypes provided by the YAXArrays libray. You can find a description of them [here](https://juliadatacubes.github.io/YAXArrays.jl/dev/UserGuide/types). A Cube is no more than a YAXArray, so, we will not explicitly tell about a Cube. ### Subsetting a YAXArray @@ -131,10 +131,6 @@ Subset YAXArray by longitude and latitude ylonlat = y[Lon=1 .. 5, Lat=5 .. 10] # check even numbers range, it is ommiting them ``` -### Subsetting a Cube - -A cube can be subsetted just in the same manner as a YAXArray. - ### Subsetting a Dataset In a dataset, we can have several variables (YAXArrays) that share some or all of their dimensions. From c9a4eb9a42ec03fc7ea8e0187e2e90ecb432045e Mon Sep 17 00:00:00 2001 From: Antonio <43267076+aasdelat@users.noreply.github.com> Date: Wed, 24 Jul 2024 09:35:30 +0100 Subject: [PATCH 09/10] Update faq.md I have deleted a comment in the code exaple because I do not understand it. --- docs/src/UserGuide/faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/UserGuide/faq.md b/docs/src/UserGuide/faq.md index 66b663a5..99dc0a52 100644 --- a/docs/src/UserGuide/faq.md +++ b/docs/src/UserGuide/faq.md @@ -128,7 +128,7 @@ ytime3 = y[Time=Date("2021-05-01") .. Date("2021-12-01")] Subset YAXArray by longitude and latitude ```@example howdoi -ylonlat = y[Lon=1 .. 5, Lat=5 .. 10] # check even numbers range, it is ommiting them +ylonlat = y[Lon=1 .. 5, Lat=5 .. 10] ``` ### Subsetting a Dataset From 59d23fc73328e8a6ebe0c7db6acc5de3ff7b2f76 Mon Sep 17 00:00:00 2001 From: Lazaro Alonso Date: Thu, 25 Jul 2024 15:09:58 +0200 Subject: [PATCH 10/10] Update docs/src/UserGuide/faq.md --- docs/src/UserGuide/faq.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/src/UserGuide/faq.md b/docs/src/UserGuide/faq.md index 99dc0a52..d5ad6cdd 100644 --- a/docs/src/UserGuide/faq.md +++ b/docs/src/UserGuide/faq.md @@ -160,7 +160,9 @@ ds_lonlat = ds[Lon=1 .. 5, Lat=5 .. 10] In this case, if we subset by the common dimension/s, this works the same as for YAXArrays, Cubes, and datasets that share all their dimensions. But we can also subset a variable by the values of another variable with which it shares some dimensions. -**Important:** If your data is not loaded into memory, the selection will be too slow. So, you have load into memory, at least, the variable with which you make the selection. +!!! warning + If your data is not loaded into memory, the selection will be too slow. So, you have load into memory, at least, the variable with which you make the selection. + Let's make an example. ```@example howdoi using YAXArrays