Skip to content

Repository files navigation

toy-ensemble-correlations

A toy ensemble of Gaussian-correlated 2-D fields, with scripts to plot fields and to visualize sample correlations at a chosen base point.

The empirical sample correlation function c(r) in sample_corr.py is not implemented. Once implemented, it is automatically overlaid on the analytic curve by plot_corr_map.py.

Setup

Dependencies: numpy, netCDF4, pyyaml, matplotlib, cartopy, shapely.

Generate an ensemble

Cartesian:

python cartesian/generate_ensemble.py --config config_gen_cartesian.yaml

Lat-lon sphere (uses a diffusion operator, the same family used in SOCA/SABER for correlation models):

python sphere/generate_ensemble.py --config config_gen_sphere.yaml

Output goes to output_cartesian/ or output_sphere/ (one netCDF per member, plus a few quick-look PNGs of the first members).

Plot a single field

Cartesian:

python cartesian/plot_field.py output_cartesian/mem_0000.nc --var temperature

Sphere:

python sphere/plot_field.py output_sphere/mem_0000.nc --var temperature

SOCA grid (uses the gridspec file for lat/lon and mask). Two mutually-exclusive forms:

yaml form:

python soca/plot_field_soca.py --config config_plot_soca.yaml

flag form:

python soca/plot_field_soca.py \
    --data     <path to ocean or ice SOCA file> \
    --gridspec <path to soca_gridspec.nc>c \
    --var aice_h \
    --out aice.png

For 3-D variables (e.g. ocean Temp, Salt) pass --level N (or set level: in the yaml) to pick a vertical layer. --level 0 is the surface; the default is 0. --projection accepts platecarree (default), north, south, robinson — the polar ones are useful for sea ice.

Plot a correlation map at a base point

After generating an ensemble:

python cartesian/plot_corr_map.py --config config_corr_cartesian.yaml
python sphere/plot_corr_map.py    --config config_corr_sphere.yaml

One figure per base point listed under base_points in the corr-map config. Each figure has:

  • Left: 2-D map of sample correlation corr(x_base, x) computed from the ensemble.
  • Right: the analytic correlation function for the field being generated. A single curve C(r) in the isotropic case; two curves (zonal + meridional) when is_anisotropic is set in the file's attributes.

Base points are listed in the config:

  • Cartesian: [x, y]
  • Sphere: [lat, lon]

If mask is set, and a base point falls on land, it is skipped with a note.

About

A toy ensemble of Gaussian-correlated 2D fields, with scripts to plot fields and to visualize sample correlations at a chosen base point.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages