@@ -147,6 +147,30 @@ note that the following can be extended to arbitrary `YAXArrays` with additional
147147
148148Let's generate a new ` cube ` using ` mapCube ` and saving the output directly into disk.
149149
150+ ::: tabs
151+
152+ == xmap (DAE)
153+
154+ ```` @ansi mapCube
155+ r = f.(lon_yax, lat_yax, time_yax)
156+ ````
157+
158+ or as
159+
160+ ```` @ansi mapCube
161+ r = xmap(f, lon_yax, lat_yax, time_yax, output=XOutput(outtype=Float32), inplace=false)
162+ ````
163+
164+ and triggering the computation and saving to ` zarr ` is done with ` compute_to_zarr ` :
165+
166+ ```` @ansi mapCube
167+ gen_cube = compute_to_zarr(Dataset(layer=r), "my_gen_cube.zarr", overwrite=true, max_cache=1e9)
168+ ````
169+
170+ note that it takes as input a ` Dataset ` .
171+
172+ == mapCube
173+
150174```` @ansi mapCube
151175gen_cube = mapCube(g, (lon_yax, lat_yax, time_yax);
152176 indims = (InDims(), InDims(), InDims("time")),
@@ -163,6 +187,7 @@ Note that currently the `time` axis in the output cube goes first.
163187:::
164188
165189
190+
166191Check that it is working
167192
168193```` @ansi mapCube
@@ -233,26 +258,49 @@ end
233258f1(xin) = xin + 1
234259f2(xin) = xin + 2
235260````
261+
262+ ```` @example outdims
263+ properties_one = Dict{String, Any}("name" => "plus_one")
264+ properties_two = Dict{String, Any}("name" => "plus_two");
265+ nothing # hide
266+ ````
267+
268+ ::: tabs
269+
270+ == xmap (DAE)
271+
272+ ```` @example outdims
273+ output_one = XOutput(yax_test.time; properties=properties_one)
274+ output_two = XOutput(yax_test.time; properties=properties_two)
275+ output_flat = XOutput(;)
276+
277+ ds = xmap(one_to_many, yax_test⊘:time,
278+ output=(output_one, output_two, output_flat)
279+ );
280+ nothing # hide
281+ ````
282+
283+ == mapCube
284+
236285now, we define ` InDims ` and ` OutDims ` :
237286
238287```` @example outdims
239288indims_one = InDims("Time")
240289# outputs dimension
241- properties_one = Dict{String, Any}("name" => "plus_one")
242- properties_two = Dict{String, Any}("name" => "plus_two")
243-
244290outdims_one = OutDims("Time"; properties=properties_one)
245291outdims_two = OutDims("Time"; properties=properties_two)
246292outdims_flat = OutDims(;) # it will get the default `layer` name if open as dataset
293+ nothing # hide
247294````
248-
249295```` @example outdims
250296ds = mapCube(one_to_many, yax_test,
251297 indims = indims_one,
252298 outdims = (outdims_one, outdims_two, outdims_flat));
253299nothing # hide
254300````
255301
302+ :::
303+
256304let's see the second output
257305
258306```` @example outdims
@@ -278,17 +326,36 @@ function many_to_many(xout_one, xout_two, xout_flat, xin_one, xin_two, xin_drei)
278326 return nothing
279327end
280328f2mix(xin_xyt, xin_xy) = xin_xyt - xin_xy
329+ nothing # hide
281330````
282331
332+ ::: tabs
333+
334+ == xmap (DAE)
335+
336+ ```` @example outdims
337+ output_time = XOutput(yax_test.time)
338+ output_flat = XOutput()
339+
340+ r1, r2, r3 = xmap(many_to_many, yax_test⊘:time, yax_2d, yax_test⊘"time",
341+ output =(output_time, output_time, output_flat), inplace=true);
342+ dsout = Dataset(many_to_many_two=r2)
343+
344+ compute_to_zarr(dsout, "test_mm.zarr", overwrite=true)
345+ ````
346+
347+ == mapCube
348+
283349#### Specify path in OutDims
284350
285351```` @example outdims
286352indims_one = InDims("Time")
287353indims_2d = InDims() # ? it matches only to the other 2 dimensions and uses the same values for each time step
288354properties = Dict{String, Any}("name"=> "many_to_many_two")
289355outdims_one = OutDims("Time")
290- outdims_two = OutDims("Time"; path = "test_mm.zarr", properties)
291- outdims_flat = OutDims()
356+ outdims_two = OutDims("Time"; path = "test_mm.zarr", properties, overwrite=true)
357+ outdims_flat = OutDims();
358+ nothing # hide
292359````
293360
294361```` @example outdims
@@ -304,6 +371,9 @@ And we can open the one that was saved directly to disk.
304371ds_mm = open_dataset("test_mm.zarr")
305372````
306373
374+ :::
375+
376+
307377### Different InDims names
308378
309379Here, the goal is to operate at the pixel level (longitude, latitude), and then apply the corresponding function to the extracted values. Consider the following toy cubes:
322392Random.seed!(123)
323393data = rand(3.0:5.0, 5, 4, 3)
324394
325- axlist = (YAX.time(Date("2022-01-01"):Day(1):Date("2022-01-05")),
326- lon(1:4), lat(1:3),)
395+ axlist = (
396+ YAX.time(Date("2022-01-01"):Day(1):Date("2022-01-05")),
397+ lon(1:4),
398+ lat(1:3),
399+ )
327400
328401properties = Dict("description" => "multi dimensional test cube")
329402yax_test = YAXArray(axlist, data, properties)
@@ -345,12 +418,26 @@ end
345418
346419with the final mapCube operation as follows
347420
421+ ::: tabs
422+
423+ == xmap (DAE)
424+
425+ ```` @example outdims
426+ ds = xmap(mix_time_depth, yax_test ⊘ :time, yax_2d ⊘ :depth,
427+ output = XOutput(yax_test.time), inplace=false)
428+ ````
429+
430+ == mapCube
431+
348432```` @example outdims
349433ds = mapCube(time_depth, (yax_test, yax_2d),
350434 indims = (InDims("Time"), InDims("depth")), # ? anchor dimensions and then map over the others.
351435 outdims = OutDims("Time"))
352436````
353437
438+ :::
439+
440+
354441- TODO:
355442 - Example passing additional arguments to function.
356443 - MovingWindow
463550 output[:] .= mean (pixel)
464551end
465552
553+ ````
554+
555+ ::: tabs
556+
557+ == xmap (DAE)
558+
559+ ```` julia
560+ meantime = xmap (mymean, a⊘ :time )
561+ # and save!
562+ compute_to_zarr (Dataset (time_mean= meantime), tempname ())
563+ ````
564+
565+ == mapCube
566+
567+ ```` julia
466568mapCube (mymean, a, indims= InDims (" time" ), outdims= OutDims ())
467569````
468570
571+ :::
572+
573+
469574In the last example, ` mapCube ` was used to map the ` mymean ` function. ` mapslices ` is a convenient function that can replace ` mapCube ` , where you can omit defining an extra function with the output argument as an input (e.g. ` mymean ` ). It is possible to simply use ` mapslice `
470575
471576```` julia
0 commit comments