Regridding Data#
cd ..
from omegaconf import OmegaConf
import hydra
import xarray as xr
import oceanbench._src.geoprocessing.validation as geoval
import importlib
importlib.reload(geoval)
raw_natl = xr.open_dataset('../sla-data-registry/NATL60/NATL/ref_new/NATL60-CJM165_NATL_ssh_y2013.1y.nc')
raw_natl
Preprocessing steps#
set time units “seconds since 2012-10-01”
decode times to datetime
add longitude and latitude units
add sea surface height unit
select domain
Decode time
print('Before: ', raw_natl.time)
print()
natl = geoval.decode_cf_time(raw_natl, units="seconds since 2012-10-01")
print('After: ', natl.time)
Validate lat lon coordinates
print('Before: ', natl.lon.attrs, natl.lat.attrs)
print()
natl = geoval.validate_latlon(natl)
print('After: ', natl.lon.attrs, natl.lat.attrs)
Validate ssh variable
print('Before: ', natl.ssh.attrs)
print()
natl = geoval.validate_ssh(natl)
print('After: ', natl.ssh.attrs)
print('Before: ', natl.dims)
print()
final_natl = natl.sel(lat=slice(32, 44), lon=slice(-66, -54), time=slice('2013-01-10', '2013-03-10'))
print('After: ', final_natl.dims)
final_natl
Using configuration for processing#
import yaml
from IPython.display import Markdown, display
def disp_config(cfg):
display(Markdown("""```yaml\n""" +yaml.dump(OmegaConf.to_container(cfg), default_flow_style=None, indent=2)+"""\n```"""))
data_cfg = OmegaConf.load('config/data/gridded.yaml')
data = hydra.utils.call(data_cfg)
disp_config(data_cfg)
key = 'natl'
OmegaConf.resolve(data_cfg[key])
disp_config(data_cfg[key])
data[key]()
key = 'oi'
OmegaConf.resolve(data_cfg[key])
disp_config(data_cfg[key])
data[key]()
key = 'obs'
OmegaConf.resolve(data_cfg[key])
disp_config(data_cfg[key])
data[key]()
hydra.utils.call(data).natl
hydra.utils.call(data_cfg).oi()