<jupyter_start><jupyter_text>Along Track Altimetry Analysis<jupyter_code>import fsspec
import xarray as xr
import numpy as np
import hvplot
import hvplot.dask
import hvplot.pandas
import hvplot.xarray<jupyter_output><empty_output><jupyter_text>Load DataThe analysis ready along-track altimetry data were prepared by CNES. They are catalogged in the Pangeo Cloud Data Catalog here: https://catalog.pangeo.io/browse/master/ocean/altimetry/We work with Jason 3.<jupyter_code>from intake import open_catalog
cat = open_catalog("https://raw.githubusercontent.com/pangeo-data/pangeo-datastore/master/intake-catalogs/ocean/altimetry.yaml")
print(list(cat))
ds = cat['j3'].to_dask()
ds<jupyter_output><empty_output><jupyter_text>Load somed data into memory:<jupyter_code>ds_ll = ds[['latitude', 'longitude', 'sla_filtered']].reset_coords().astype('f4').load()
ds_ll<jupyter_output><empty_output><jupyter_text>Convert to pandas dataframe:<jupyter_code>df = ds_ll.to_dataframe()
df<jupyter_output><empty_output><jupyter_text>Visualize with hvplot<jupyter_code>df.hvplot.scatter(x='longitude', y='latitude', datashade=True, )<jupyter_output><empty_output><jupyter_text>Bin using xhistogramhttps://xhistogram.readthedocs.io/<jupyter_code>from xhistogram.xarray import histogram

lon_bins = np.arange(0, 361, 2)
lat_bins = np.arange(-70, 71, 2)

# helps with memory management
ds_ll_chunked = ds_ll.chunk({'time': '5MB'})

sla_variance = histogram(ds_ll_chunked.longitude, ds_ll_chunked.latitude,
                         bins=[lon_bins, lat_bins],
                         weights=ds_ll_chunked.sla_filtered.fillna(0.)**2)

norm = histogram(ds_ll_chunked.longitude, ds_ll_chunked.latitude,
                         bins=[lon_bins, lat_bins])


# let's get at least 200 points in a box for it to be unmasked
thresh = 200
sla_variance = sla_variance / norm.where(norm > thresh)
sla_variance
sla_variance.load()
sla_variance.plot(x='longitude_bin', figsize=(12, 6), vmax=0.2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11658291457286432, 'fraction_numerical': 0.013567839195979899, 'mean_word_length': 6.01056338028169, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 26, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '603777', 'license': 'MIT', 'n_tokens_mistral': 780, 'n_tokens_neox': 729, 'n_words': 130, 'path': '02_along_track.ipynb', 'repo_name': 'jbusecke/physical-oceanography', 'size': '1990'}