Information content example: compute required bits#

[1]:
%load_ext autoreload
%autoreload
import fcpy
[2]:
ds = fcpy.open_dataset("../data/cams_q_20191201_v3.nc")

ds = ds[["q"]].isel(lev=range(0, 10))
ds
[2]:
<xarray.Dataset>
Dimensions:  (time: 1, lev: 10, lat: 451, lon: 900)
Coordinates:
  * time     (time) datetime64[ns] 2019-12-01T12:00:00
  * lon      (lon) float64 0.0 0.4 0.8 1.2 1.6 ... 358.0 358.4 358.8 359.2 359.6
  * lat      (lat) float64 -90.0 -89.6 -89.2 -88.8 -88.4 ... 88.8 89.2 89.6 90.0
  * lev      (lev) float64 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0
Data variables:
    q        (time, lev, lat, lon) float32 dask.array<chunksize=(1, 10, 451, 900), meta=np.ndarray>
Attributes:
    CDI:          Climate Data Interface version 1.9.8 (https://mpimet.mpg.de...
    Conventions:  CF-1.6
    history:      Mon Feb 15 18:37:28 2021: cdo -f nc4 copy tmp.grib data/mil...
    institution:  European Centre for Medium-Range Weather Forecasts
    CDO:          Climate Data Operators version 1.9.8 (https://mpimet.mpg.de...
[3]:
data = fcpy.sigmas_iterate_ds(
    ds, compressors=[fcpy.Round(), fcpy.LinQuantization()]
)
q
Compressor: Round
  0%|          | 0/29 [00:00<?, ?it/s]  Activating project at `~/work/field-compression/field-compression`
WARNING: method definition for == at /usr/share/miniconda/envs/fcpy/share/julia/packages/ChainRulesCore/ctmSK/src/tangent_types/tangent.jl:68 declares type variable T but does not use it.
WARNING: method definition for getindex at /usr/share/miniconda/envs/fcpy/share/julia/packages/ChainRulesCore/ctmSK/src/tangent_types/tangent.jl:120 declares type variable T but does not use it.
WARNING: method definition for getindex at /usr/share/miniconda/envs/fcpy/share/julia/packages/ChainRulesCore/ctmSK/src/tangent_types/tangent.jl:120 declares type variable P but does not use it.
WARNING: method definition for canonicalize at /usr/share/miniconda/envs/fcpy/share/julia/packages/ChainRulesCore/ctmSK/src/tangent_types/tangent.jl:240 declares type variable L but does not use it.
WARNING: method definition for canonicalize at /usr/share/miniconda/envs/fcpy/share/julia/packages/ChainRulesCore/ctmSK/src/tangent_types/tangent.jl:241 declares type variable L but does not use it.
 76%|███████▌  | 22/29 [01:02<00:03,  2.04it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 79%|███████▉  | 23/29 [01:02<00:02,  2.05it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 83%|████████▎ | 24/29 [01:03<00:02,  2.06it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 86%|████████▌ | 25/29 [01:03<00:01,  2.08it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 90%|████████▉ | 26/29 [01:04<00:01,  2.09it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 93%|█████████▎| 27/29 [01:04<00:00,  2.11it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 97%|█████████▋| 28/29 [01:05<00:00,  2.11it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
100%|██████████| 29/29 [01:05<00:00,  2.26s/it]
Compressor: LinQuantization
100%|██████████| 29/29 [00:11<00:00,  2.52it/s]
Compressor: Round
 76%|███████▌  | 22/29 [00:10<00:03,  2.10it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 79%|███████▉  | 23/29 [00:11<00:02,  2.12it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 83%|████████▎ | 24/29 [00:11<00:02,  2.09it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 86%|████████▌ | 25/29 [00:12<00:01,  2.10it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 90%|████████▉ | 26/29 [00:12<00:01,  2.08it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 93%|█████████▎| 27/29 [00:13<00:00,  2.08it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 97%|█████████▋| 28/29 [00:13<00:00,  2.07it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
100%|██████████| 29/29 [00:14<00:00,  2.07it/s]
Compressor: LinQuantization
100%|██████████| 29/29 [00:11<00:00,  2.52it/s]
Compressor: Round
 76%|███████▌  | 22/29 [00:10<00:03,  2.08it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 79%|███████▉  | 23/29 [00:10<00:02,  2.03it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 83%|████████▎ | 24/29 [00:11<00:02,  2.02it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 86%|████████▌ | 25/29 [00:11<00:01,  2.04it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 90%|████████▉ | 26/29 [00:12<00:01,  2.05it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 93%|█████████▎| 27/29 [00:12<00:00,  2.05it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 97%|█████████▋| 28/29 [00:13<00:00,  2.09it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
100%|██████████| 29/29 [00:13<00:00,  2.10it/s]
Compressor: LinQuantization
100%|██████████| 29/29 [00:11<00:00,  2.57it/s]
Compressor: Round
 76%|███████▌  | 22/29 [00:10<00:03,  2.06it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 79%|███████▉  | 23/29 [00:11<00:02,  2.08it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 83%|████████▎ | 24/29 [00:11<00:02,  2.04it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 86%|████████▌ | 25/29 [00:12<00:01,  2.04it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 90%|████████▉ | 26/29 [00:12<00:01,  2.04it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 93%|█████████▎| 27/29 [00:13<00:00,  2.05it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 97%|█████████▋| 28/29 [00:13<00:00,  2.04it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
100%|██████████| 29/29 [00:14<00:00,  2.07it/s]
Compressor: LinQuantization
100%|██████████| 29/29 [00:11<00:00,  2.53it/s]
Compressor: Round
 76%|███████▌  | 22/29 [00:10<00:03,  2.10it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 79%|███████▉  | 23/29 [00:11<00:02,  2.10it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 83%|████████▎ | 24/29 [00:11<00:02,  2.13it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 86%|████████▌ | 25/29 [00:11<00:01,  2.13it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 90%|████████▉ | 26/29 [00:12<00:01,  2.12it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 93%|█████████▎| 27/29 [00:12<00:00,  2.12it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 97%|█████████▋| 28/29 [00:13<00:00,  2.11it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
100%|██████████| 29/29 [00:13<00:00,  2.09it/s]
Compressor: LinQuantization
100%|██████████| 29/29 [00:11<00:00,  2.51it/s]
Compressor: Round
 76%|███████▌  | 22/29 [00:10<00:03,  2.04it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 79%|███████▉  | 23/29 [00:11<00:02,  2.02it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 83%|████████▎ | 24/29 [00:11<00:02,  2.05it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 86%|████████▌ | 25/29 [00:12<00:01,  2.07it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 90%|████████▉ | 26/29 [00:12<00:01,  2.08it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 93%|█████████▎| 27/29 [00:12<00:00,  2.08it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 97%|█████████▋| 28/29 [00:13<00:00,  2.07it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
100%|██████████| 29/29 [00:13<00:00,  2.08it/s]
Compressor: LinQuantization
100%|██████████| 29/29 [00:11<00:00,  2.52it/s]
Compressor: Round
 76%|███████▌  | 22/29 [00:10<00:03,  2.02it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 79%|███████▉  | 23/29 [00:11<00:02,  2.03it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 83%|████████▎ | 24/29 [00:11<00:02,  2.05it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 86%|████████▌ | 25/29 [00:12<00:01,  2.06it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 90%|████████▉ | 26/29 [00:12<00:01,  2.06it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 93%|█████████▎| 27/29 [00:13<00:00,  2.08it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 97%|█████████▋| 28/29 [00:13<00:00,  2.08it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
100%|██████████| 29/29 [00:14<00:00,  2.05it/s]
Compressor: LinQuantization
100%|██████████| 29/29 [00:11<00:00,  2.51it/s]
Compressor: Round
 76%|███████▌  | 22/29 [00:10<00:03,  2.11it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 79%|███████▉  | 23/29 [00:11<00:02,  2.11it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 83%|████████▎ | 24/29 [00:11<00:02,  2.10it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 86%|████████▌ | 25/29 [00:12<00:01,  2.09it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 90%|████████▉ | 26/29 [00:12<00:01,  2.10it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 93%|█████████▎| 27/29 [00:12<00:00,  2.10it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 97%|█████████▋| 28/29 [00:13<00:00,  2.09it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
100%|██████████| 29/29 [00:13<00:00,  2.08it/s]
Compressor: LinQuantization
100%|██████████| 29/29 [00:11<00:00,  2.51it/s]
Compressor: Round
 76%|███████▌  | 22/29 [00:10<00:03,  2.01it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 79%|███████▉  | 23/29 [00:11<00:02,  2.03it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 83%|████████▎ | 24/29 [00:11<00:02,  2.03it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 86%|████████▌ | 25/29 [00:12<00:01,  2.05it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 90%|████████▉ | 26/29 [00:12<00:01,  2.04it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 93%|█████████▎| 27/29 [00:13<00:00,  2.05it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 97%|█████████▋| 28/29 [00:13<00:00,  2.05it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
100%|██████████| 29/29 [00:14<00:00,  2.06it/s]
Compressor: LinQuantization
100%|██████████| 29/29 [00:11<00:00,  2.56it/s]
Compressor: Round
 71%|███████   | 22/31 [00:10<00:04,  1.98it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 74%|███████▍  | 23/31 [00:11<00:04,  2.00it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 77%|███████▋  | 24/31 [00:11<00:03,  2.03it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 81%|████████  | 25/31 [00:12<00:02,  2.05it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 84%|████████▍ | 26/31 [00:12<00:02,  2.08it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 87%|████████▋ | 27/31 [00:13<00:01,  2.10it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 90%|█████████ | 28/31 [00:13<00:01,  2.11it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 94%|█████████▎| 29/31 [00:13<00:00,  2.11it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
 97%|█████████▋| 30/31 [00:14<00:00,  2.11it/s]/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/dask/core.py:119: RuntimeWarning: invalid value encountered in divide
  return func(*(_execute_task(a, cache) for a in args))
100%|██████████| 31/31 [00:14<00:00,  2.08it/s]
Compressor: LinQuantization
100%|██████████| 31/31 [00:11<00:00,  2.62it/s]
[4]:
def plot_vertical_bits(ds, y, metric):
    import matplotlib.pyplot as plt
    from cycler import cycler
    import seaborn as sns
    from matplotlib.ticker import MaxNLocator

    _, ax = plt.subplots()
    colors = sns.color_palette("colorblind", 2)
    custom_cycler = cycler(color=colors)
    ax.set_prop_cycle(custom_cycler)
    ds[metric].squeeze().plot.line(
        ax=ax, y=y, hue="compressor", marker="o", linestyle="--"
    )
    ax.xaxis.set_major_locator(MaxNLocator(integer=True))
    ax.yaxis.set_major_locator(MaxNLocator(integer=True))
    ax.set_title(f'{ds.attrs["long_name"]} in {ds.attrs["units"]}\n{metric}')
    ax.set_xlabel(metric)
    ax.set_ylabel("Model level")
[5]:
for data_ in data.values():
    plot_vertical_bits(data_, y="lev", metric="bits")
../_images/_notebooks_examples-information-content_5_0.png
[6]:
for data_ in data.values():
    plot_vertical_bits(data_, y="lev", metric="sigmas")
../_images/_notebooks_examples-information-content_6_0.png
[7]:
for data_ in data.values():
    plot_vertical_bits(data_, y="lev", metric="bitinf")
../_images/_notebooks_examples-information-content_7_0.png
[8]:
# Here we compare the spatial change of specific humidity
# by rounding values to 8 bits
fcpy.spatialplot(
    ds=ds,
    baseline=fcpy.Float(bits=32),
    var_name="q",
    compressor=fcpy.Round(bits=6),
    metric=fcpy.Difference,
    latitude=0,
    longitude=0,
    lev=1,
    third_dim="lev",
)
/usr/share/miniconda/envs/fcpy/lib/python3.10/site-packages/cartopy/io/__init__.py:241: DownloadWarning: Downloading: https://naturalearth.s3.amazonaws.com/110m_physical/ne_110m_coastline.zip
  warnings.warn(f'Downloading: {url}', DownloadWarning)
../_images/_notebooks_examples-information-content_8_1.png
../_images/_notebooks_examples-information-content_8_2.png
../_images/_notebooks_examples-information-content_8_3.png
../_images/_notebooks_examples-information-content_8_4.png
[ ]: